bootstrap($app);(new Illuminate\Foundation\Bootstrap\LoadConfiguration)->bootstrap($app); $c=config('database.connections.'.config('database.default')); if($c['driver']!=='pgsql'||(int)$c['port']!==5432||$c['database']!=='investemoz'||!empty($c['url']))throw new RuntimeException('Target refused'); $db=new PDO('pgsql:host=127.0.0.1;port=5432;dbname=investemoz',$c['username'],$c['password'],[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]);$db->exec('BEGIN READ ONLY'); $flags=[];foreach(['profile_administration_enabled','profile_access_enabled','opportunity_dashboard_access_enabled','opportunity_specialized_drafts_enabled','opportunity_modular_profiles_qa_enabled','organization_country_enabled','notifications_enabled']as$f)$flags[$f]=(bool)config('portal.'.$f); $m=$db->query('SELECT migration FROM migrations ORDER BY migration')->fetchAll(PDO::FETCH_COLUMN);$installed=array_values(array_filter($m,fn($s)=>preg_match('/_(030000|040000|050000|190000)_/',$s))); $queue=$db->query('SELECT queue,count(*) AS count FROM jobs GROUP BY queue')->fetchAll(PDO::FETCH_ASSOC);$failed=(int)$db->query('SELECT count(*) FROM failed_jobs')->fetchColumn(); $referenceCounts=[];foreach(['sectors','economic_activities','geo_locations','contacts','investors']as$t)$referenceCounts[$t]=(int)$db->query('SELECT count(*) FROM '.$t)->fetchColumn(); $referenceCounts['published_economic_activities']=(int)$db->query("SELECT count(*) FROM economic_activities WHERE status='published'")->fetchColumn(); $referenceCounts['available_districts']=(int)$db->query("SELECT count(*) FROM geo_locations WHERE deleted_at IS NULL AND location_type='district' AND data_classification IN ('public','internal')")->fetchColumn(); $db->exec('ROLLBACK'); $health=(new App\Services\Malware\ClamDScanner)->health(); if(isset($health['signatures_at'])&&$health['signatures_at'] instanceof DateTimeInterface)$health['signatures_at']=$health['signatures_at']->format('c'); echo json_encode(['at'=>gmdate('c'),'read_only'=>true,'target'=>'investemoz:5432','installed'=>$installed,'flags'=>$flags,'scanner'=>$health,'queue'=>$queue,'failed_jobs'=>$failed,'queue_driver'=>config('queue.default'),'reference_counts'=>$referenceCounts],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR); }catch(Throwable $e){echo json_encode(['result'=>'stopped','type'=>$e::class,'line'=>$e->getLine()]);exit(1);}