更新
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
$envPath = __DIR__ . DIRECTORY_SEPARATOR . '.env';
|
||||
$lines = @file($envPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
if (!$lines) {
|
||||
echo "failed to read env: {$envPath}\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$map = [];
|
||||
foreach ($lines as $line) {
|
||||
$line = trim((string)$line);
|
||||
if ($line === '' || strpos($line, '=') === false) {
|
||||
continue;
|
||||
}
|
||||
$parts = explode('=', $line, 2);
|
||||
$map[trim((string)$parts[0])] = trim((string)$parts[1]);
|
||||
}
|
||||
|
||||
$dsn = 'mysql:host=' . $map['DB_HOST'] . ';port=' . $map['DB_PORT'] . ';dbname=' . $map['DB_NAME'] . ';charset=' . $map['DB_CHARSET'];
|
||||
$pdo = new PDO($dsn, $map['DB_USER'], $map['DB_PASS'], [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
]);
|
||||
|
||||
$stmt = $pdo->prepare('SELECT label,value FROM ' . $map['DB_PREFIX'] . 'system_site_settings WHERE label IN (?, ?) ORDER BY id ASC');
|
||||
$stmt->execute(['backendUrl', 'apiKey']);
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($rows as $r) {
|
||||
$label = (string)$r['label'];
|
||||
$value = (string)$r['value'];
|
||||
if ($label === 'apiKey') {
|
||||
$mask = substr($value, 0, 3) . '***' . substr($value, -3);
|
||||
echo $label . '=' . $mask . PHP_EOL;
|
||||
} else {
|
||||
echo $label . '=' . $value . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user