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 ISOLATION LEVEL REPEATABLE READ READ ONLY'); $digest = function (string $table) use ($db): array { $rows = $db->query('SELECT * FROM '.$table)->fetchAll(PDO::FETCH_ASSOC); $rows = array_map(fn ($row) => json_encode($row, JSON_THROW_ON_ERROR), $rows); sort($rows, SORT_STRING); return ['rows'=>count($rows), 'sha256'=>hash('sha256', json_encode($rows, JSON_THROW_ON_ERROR))]; }; $protected = []; foreach (['users','organizations','memberships','portal_role_assignments','portal_superuser_pair','portal_security_approvals','opportunities','contacts','investors','investor_contacts','documents','migrations','audit_events'] as $t) $protected[$t] = $digest($t); $queue = $db->query("SELECT queue,payload::jsonb->>'displayName' AS job_class,count(*) AS count FROM jobs GROUP BY queue,payload::jsonb->>'displayName'")->fetchAll(PDO::FETCH_ASSOC); $failed = (int) $db->query('SELECT count(*) FROM failed_jobs')->fetchColumn(); $staff = $db->query('SELECT id,name,email,(email_verified_at IS NOT NULL) AS email_verified,(two_factor_secret IS NOT NULL AND two_factor_confirmed_at IS NOT NULL) AS mfa_confirmed FROM users WHERE id IN (14,15,16) ORDER BY id')->fetchAll(PDO::FETCH_ASSOC); $grants = $db->query('SELECT user_id,role,organization_id,opportunity_types,source FROM portal_role_assignments WHERE user_id IN (14,15,16) AND revoked_at IS NULL AND starts_at<=now() AND (expires_at IS NULL OR expires_at>now()) ORDER BY id')->fetchAll(PDO::FETCH_ASSOC); $db->exec('ROLLBACK'); $flags = []; foreach (config('portal') as $k=>$v) if (str_ends_with($k, '_enabled')) $flags[$k]=(bool)$v; $flags['investor_path_enabled']=(bool)config('investor-path.enabled'); $scanner=(new App\Services\Malware\ClamDScanner)->health(); if (($scanner['signatures_at']??null) instanceof DateTimeInterface) $scanner['signatures_at']=$scanner['signatures_at']->format('c'); echo json_encode(['at'=>gmdate('c'),'read_only'=>true,'target'=>'investemoz:5432','app_url'=>config('app.url'),'flags'=>$flags,'protected_tables'=>$protected,'staff'=>$staff,'grants'=>$grants,'queue'=>$queue,'failed_jobs'=>$failed,'scanner'=>$scanner,'session'=>['driver'=>config('session.driver'),'cookie'=>config('session.cookie'),'secure'=>config('session.secure'),'same_site'=>config('session.same_site'),'path'=>config('session.path'),'domain'=>config('session.domain')],'config_cached'=>$app->configurationIsCached()], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR); } catch(Throwable $e) { echo json_encode(['result'=>'stopped','type'=>$e::class,'line'=>$e->getLine()]); exit(1); }