|
|
@ -106,7 +106,10 @@ try {
|
|
|
|
'server' => $SETTINGS['database']['server'],
|
|
|
|
'server' => $SETTINGS['database']['server'],
|
|
|
|
'username' => $SETTINGS['database']['user'],
|
|
|
|
'username' => $SETTINGS['database']['user'],
|
|
|
|
'password' => $SETTINGS['database']['password'],
|
|
|
|
'password' => $SETTINGS['database']['password'],
|
|
|
|
'charset' => $SETTINGS['database']['charset']
|
|
|
|
'charset' => $SETTINGS['database']['charset'],
|
|
|
|
|
|
|
|
'option' => [
|
|
|
|
|
|
|
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
|
|
|
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
//header('HTTP/1.1 500 Internal Server Error');
|
|
|
|
//header('HTTP/1.1 500 Internal Server Error');
|
|
|
@ -145,23 +148,6 @@ function dieifnotloggedin() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check if the previous database action had a problem.
|
|
|
|
|
|
|
|
* @param array $specials int=>string array with special response messages for SQL errors
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function checkDBError($specials = []) {
|
|
|
|
|
|
|
|
global $database;
|
|
|
|
|
|
|
|
$errors = $database->error();
|
|
|
|
|
|
|
|
if (!is_null($errors[1])) {
|
|
|
|
|
|
|
|
foreach ($specials as $code => $text) {
|
|
|
|
|
|
|
|
if ($errors[1] == $code) {
|
|
|
|
|
|
|
|
sendError($text);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sendError("A database error occurred:<br /><code>" . $errors[2] . "</code>");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function redirectIfNotLoggedIn() {
|
|
|
|
function redirectIfNotLoggedIn() {
|
|
|
|
global $SETTINGS;
|
|
|
|
global $SETTINGS;
|
|
|
|
if ($_SESSION['loggedin'] !== TRUE) {
|
|
|
|
if ($_SESSION['loggedin'] !== TRUE) {
|
|
|
|