Compare commits

..

3 Commits

3 changed files with 26 additions and 14 deletions

View File

@ -13,10 +13,9 @@ function connectDB($config, $database = '', $dbFile = '', $platformId = '') {
'type' => 'sqlite',
'dbFile' => $dbFile,
]);
return ['db' => $db, 'error' => null];
} catch (Exception $e) {
$error = getError('Error connecting to DB.', $e->getMessage());
include '../app/templates/block-message.php';
exit();
return ['db' => null, 'error' => getError('Error connecting to DB.', $e->getMessage())];
}
// connecting to a jilo-web database of the web app
@ -30,10 +29,9 @@ function connectDB($config, $database = '', $dbFile = '', $platformId = '') {
'dbFile' => $config['db']['sqlite_file'],
]);
$pdo = $db->getConnection();
return ['db' => $db, 'error' => null];
} catch (Exception $e) {
$error = getError('Error connecting to DB.', $e->getMessage());
include '../app/templates/block-message.php';
exit();
return ['db' => null, 'error' => getError('Error connecting to DB.', $e->getMessage())];
}
// mysql/mariadb database
} elseif ($config['db']['db_type'] === 'mysql' || $config['db']['db_type'] === 'mariadb') {
@ -47,10 +45,9 @@ function connectDB($config, $database = '', $dbFile = '', $platformId = '') {
'password' => $config['db']['sql_password'],
]);
$pdo = $db->getConnection();
return ['db' => $db, 'error' => null];
} catch (Exception $e) {
$error = getError('Error connecting to DB.', $e->getMessage());
include '../app/templates/block-message.php';
exit();
return ['db' => null, 'error' => getError('Error connecting to DB.', $e->getMessage())];
}
// unknown database
} else {
@ -61,6 +58,5 @@ function connectDB($config, $database = '', $dbFile = '', $platformId = '') {
}
return $db;
}
?>

View File

@ -4,8 +4,13 @@ require '../app/classes/conference.php';
require '../app/classes/participant.php';
// connect to database
$db = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $platform_id);
$response = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $platform_id);
if ($response['db'] === null) {
$error = $response['error'];
include '../app/templates/block-message.php';
} else {
$db = $response['db'];
}
//
// dashboard widget listings

View File

@ -1,13 +1,24 @@
<?php
// 'notice' for all non-critical messages
// 'error' for errors
if (isset($_SESSION['error'])) {
echo "\t\t" . '<div class="error">' . $_SESSION['error'] . '</div>';
}
// 'error' for errors
// 'notice' for all non-critical messages
if (isset($_SESSION['notice'])) {
echo "\t\t" . '<div class="notice">' . $_SESSION['notice'] . '</div>';
}
// 'error' for errors
if (isset($error)) {
echo "\t\t" . '<div class="error">' . $error . '</div>';
}
// 'notice' for all non-critical messages
if (isset($_SESSION['notice'])) {
echo "\t\t" . '<div class="notice">' . $_SESSION['notice'] . '</div>';
}
?>