This repository was archived by the owner on Apr 11, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-db-schema.php
More file actions
executable file
·74 lines (58 loc) · 1.84 KB
/
Copy pathcheck-db-schema.php
File metadata and controls
executable file
·74 lines (58 loc) · 1.84 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env php
<?php
function loadEnv($path) {
if (!file_exists($path)) {
return [];
}
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$env = [];
foreach ($lines as $line) {
if (strpos(trim($line), '#') === 0) {
continue;
}
list($name, $value) = explode('=', $line, 2);
$name = trim($name);
$value = trim($value);
$value = trim($value, '"\'');
$env[$name] = $value;
}
return $env;
}
$env = loadEnv(__DIR__ . '/.env.ci');
$dbHost = $env['DB_HOST'] ?? '127.0.0.1';
$dbPort = $env['DB_PORT'] ?? '3306';
$dbName = $env['DB_DATABASE'] ?? 'panel';
$dbUser = $env['DB_USERNAME'] ?? 'pterodactyl';
$dbPass = $env['DB_PASSWORD'] ?? '';
try {
$dsn = "mysql:host=$dbHost;port=$dbPort;dbname=$dbName;charset=utf8mb4";
$pdo = new PDO($dsn, $dbUser, $dbPass, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
echo "Structure de la table 'users':\n\n";
$stmt = $pdo->query("DESCRIBE users");
$columns = $stmt->fetchAll();
foreach ($columns as $col) {
printf("%-20s %-20s %-10s %-10s %-20s %s\n",
$col['Field'],
$col['Type'],
$col['Null'],
$col['Key'],
$col['Default'] ?? 'NULL',
$col['Extra']
);
}
echo "\n\nExemple d'un utilisateur existant:\n\n";
$stmt = $pdo->query("SELECT * FROM users LIMIT 1");
$user = $stmt->fetch();
if ($user) {
foreach ($user as $key => $value) {
printf("%-20s : %s\n", $key, $value ?? 'NULL');
}
} else {
echo "Aucun utilisateur dans la base.\n";
}
} catch (PDOException $e) {
die("Erreur: " . $e->getMessage() . "\n");
}