13 lines
974 B
PHP
13 lines
974 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
try {
|
|
$ini = parse_ini_file(dirname(__DIR__, 2) . '/server/.env', true, INI_SCANNER_RAW);
|
|
$config = array_change_key_case($ini['database'], CASE_LOWER);
|
|
if (!preg_match('/^[A-Za-z0-9_]+$/D', $config['prefix'])) { exit(1); }
|
|
$db = new PDO('mysql:host=' . $config['hostname'] . ';port=' . ($config['hostport'] ?? 3306) . ';dbname=' . $config['database'] . ';charset=utf8mb4', $config['username'], $config['password'], [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
|
|
$db->exec('START TRANSACTION READ ONLY');
|
|
$rows = $db->query('SHOW COLUMNS FROM `' . $config['prefix'] . 'admin_session`')->fetchAll(PDO::FETCH_ASSOC);
|
|
$db->rollBack();
|
|
foreach ($rows as $row) { if (in_array($row['Field'], ['token', 'terminal'], true)) { echo json_encode(['field' => $row['Field'], 'type' => $row['Type']]) . PHP_EOL; } }
|
|
} catch (Throwable $error) { echo 'Session schema check failed without printing configuration.'; exit(1); }
|