forked from MrZer0x0/trueCORD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_test.php
More file actions
26 lines (21 loc) · 924 Bytes
/
Copy pathapi_test.php
File metadata and controls
26 lines (21 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
header('Content-Type: application/json; charset=UTF-8');
$out = [];
try {
$out['step'] = 'before_config';
require_once __DIR__ . '/config.php';
$out['config_loaded'] = true;
$out['DB_PATH'] = defined('DB_PATH') ? DB_PATH : 'NOT_DEFINED';
$out['db_file_exists'] = is_file($out['DB_PATH']);
$out['db_file_readable'] = is_readable($out['DB_PATH']);
$out['dir_writable'] = is_writable(__DIR__);
$out['step'] = 'pdo_connect';
$db = new PDO('sqlite:' . $out['DB_PATH']);
$out['pdo_ok'] = true;
$out['step'] = 'schema_check';
$tables = $db->query("SELECT name FROM sqlite_master WHERE type='table'")->fetchAll(PDO::FETCH_COLUMN);
$out['tables'] = $tables;
} catch (Throwable $e) {
$out['error'] = get_class($e) . ': ' . $e->getMessage() . ' @ ' . basename($e->getFile()) . ':' . $e->getLine();
}
echo json_encode($out, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);