Some database improvements and associated changes in webgui

This commit is contained in:
2026-09-14 10:12:32 +02:00
parent 2250fb9743
commit 57c42d1398
23 changed files with 203 additions and 39 deletions
+29 -4
View File
@@ -114,14 +114,25 @@ try {
$sth = $pdo->query("SELECT valint FROM settings WHERE userid=0 AND sno=0");
} catch (PDOException $e) {
if ($e->getCode() == 1146) {
echo '<pre>';
echo 'Settings table not found! Perhaps database is not initialized';
echo '</pre>';
echo "<pre>\n";
echo "Settings table not found! Perhaps database is not initialized?\n";
echo "</pre>\n";
exit(1);
}
}
$g_db_scheme_version = $sth->fetchColumn();
// TODO Check version
$g_db_scheme_required = 1;
// Schema version check
if ($g_db_scheme_version !== $g_db_scheme_required) {
echo "<pre>\n";
echo "Database schema is wrong: detected version $g_db_scheme_version, but required version $g_db_scheme_required!\n";
echo "</pre>\n";
exit(1);
}
// currency symbol is global
$sth = $pdo->query("SELECT valint FROM settings WHERE userid=0 AND sno=4");
$g_currsym = $sth->fetchColumn();
$user = User::GetInstance(); // There can be only one
if ($g_scriptname != 'login.php') {
@@ -1269,6 +1280,20 @@ function format_date($date) {
return date($user->datefmt, $timestamp);
}
function format_datetime($datetime, $seconds=false) {
// datetime is string in ISO format
global $user;
if (empty($datetime)) {
return '';
}
$timestamp = strtotime($datetime);
if ($timestamp === false) {
return '';
}
$timefmt = $seconds ? 'H:i:s' : 'H:i';
return date($user->datefmt. ' ' . $timefmt, $timestamp);
}
function format_color($color) {
$colstr = '<span style="';
$style = "padding:2px 4px;border-radius:4px;background-color:#".$color;