Translation preparation and some webgui code

This commit is contained in:
2025-05-15 09:14:14 +02:00
parent fb93c83388
commit 1f2af40943
7 changed files with 131 additions and 9 deletions
+28 -3
View File
@@ -1,7 +1,7 @@
<?php
/******************************************************************************
* YMS - Yacht Management Software
* Copyright (C) 2024 Thomas Hooge
* Copyright (C) 2024-2025 Thomas Hooge
*
* SPDX-License-Identifier: WTFPL
******************************************************************************
@@ -72,14 +72,39 @@ try {
$pdo = new PDO("mysql:host=$g_db_host;dbname=$g_db_schema;charset=utf8mb4", $g_db_username, $g_db_password);
} catch (PDOException $e) {
echo '<pre>';
print_r($e);
switch ($e->getCode()) {
case 2002:
echo "Unable to connect to database, perhaps host info is wrong.\n";
break;
case 1044:
case 1045:
// access denied to db or generic access denied
echo "Unable to connect to database, perhaps username or password is wrong.\n";
break;
case 1049:
echo "Unable to connect to database, perhaps database name is wrong.\n";
break;
default:
print_r($e);
}
echo '</pre>';
exit(1);
}
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
# $pdo->query("SET lc_time_names='de_DE'");
$sth = $pdo->query("SELECT valint FROM settings WHERE userid=0 AND sno=0");
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>';
exit(1)
}
}
$g_db_scheme_version = $sth->fetchColumn();
// TODO Check version
$user = User::GetInstance(); // There can be only one
if ($g_scriptname != 'login.php') {