exec('BEGIN;'); $db->exec(file_get_contents(__DIR__ . '/../schema.sql')); if (!LDAP::enabled()) { @session_start(); $users = new Users; $p = 'karadavdemo'; $users->create('demo', $p, 10, true); $_SESSION['install_password'] = $p; $users->login('demo', $p); } $db->exec('END;'); } if (isset($_COOKIE[session_name()]) && !isset($_SESSION)) { @session_start(); } function html_head(string $title): void { $title = htmlspecialchars($title); echo << {$title}

{$title}

EOF; if (isset($_SESSION['install_password'])) { printf('

Your server has been installed with a user named demo and the password %s, please change it.

This message will disappear when you log out.

', htmlspecialchars($_SESSION['install_password'])); } } function html_foot(): void { echo '
'; } function format_bytes(int $bytes, string $unit = 'B'): string { if ($bytes >= 1024*1024*1024) { return round($bytes / (1024*1024*1024), 1) . ' G' . $unit; } elseif ($bytes >= 1024*1024) { return round($bytes / (1024*1024), 1) . ' M' . $unit; } elseif ($bytes >= 1024) { return round($bytes / 1024, 1) . ' K' . $unit; } else { return $bytes . ' ' . $unit; } } function http_log(string $message, ...$params): void { if (!LOG_FILE) { return; } $msg = vsprintf($message, $params) . "\n\n"; if (LOG_FILE) { file_put_contents(LOG_FILE, $msg, FILE_APPEND); } }