52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
import re
|
|
|
|
with open('includes/app.php', 'r') as f:
|
|
content = f.read()
|
|
|
|
# Add ensure_app_settings_schema call
|
|
content = content.replace(
|
|
'ensure_center_application_schema($pdo);',
|
|
'ensure_app_settings_schema($pdo);
|
|
ensure_center_application_schema($pdo);'
|
|
)
|
|
|
|
# Add function definitions before ensure_center_application_schema definition
|
|
new_funcs = """function ensure_app_settings_schema(PDO $pdo): void
|
|
{
|
|
$pdo->exec("
|
|
CREATE TABLE IF NOT EXISTS app_settings (
|
|
id INT PRIMARY KEY DEFAULT 1,
|
|
app_name VARCHAR(190) NOT NULL DEFAULT 'Central Admin',
|
|
app_email VARCHAR(190) DEFAULT NULL,
|
|
app_telephone VARCHAR(60) DEFAULT NULL,
|
|
app_logo VARCHAR(255) DEFAULT NULL,
|
|
app_favicon VARCHAR(255) DEFAULT NULL,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
");
|
|
$pdo->exec("INSERT IGNORE INTO app_settings (id, app_name) VALUES (1, 'Central Admin')");
|
|
}
|
|
|
|
function get_app_settings(): array
|
|
{
|
|
$pdo = db_connection();
|
|
$stmt = $pdo->query('SELECT * FROM app_settings WHERE id = 1');
|
|
$res = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
if (!$res) {
|
|
return [
|
|
'app_name' => 'Central Admin',
|
|
'app_email' => '',
|
|
'app_telephone' => '',
|
|
'app_logo' => '',
|
|
'app_favicon' => ''
|
|
];
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
function ensure_center_application_schema(PDO $pdo): void"""
|
|
|
|
content = content.replace('function ensure_center_application_schema(PDO $pdo): void', new_funcs)
|
|
|
|
with open('includes/app.php', 'w') as f:
|
|
f.write(content) |