Compare commits
No commits in common. "13f2ca4fe48fb181ff02e6053de6fab7a4af3e9c" and "c2f0fe6793effbdb5c4cec104aaaab02c69ea0c9" have entirely different histories.
13f2ca4fe4
...
c2f0fe6793
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Core;
|
||||
|
||||
use Exception;
|
||||
use Feedback;
|
||||
|
||||
class DatabaseConnector
|
||||
{
|
||||
/**
|
||||
* Connect to the database using given configuration and handle errors.
|
||||
*
|
||||
* @param array $config
|
||||
* @return mixed Database connection
|
||||
*/
|
||||
public static function connect(array $config)
|
||||
{
|
||||
// Load DB classes
|
||||
require_once __DIR__ . '/../classes/database.php';
|
||||
require_once __DIR__ . '/../includes/database.php';
|
||||
|
||||
try {
|
||||
$db = connectDB($config);
|
||||
if (!$db['db']) {
|
||||
throw new Exception('Could not connect to database');
|
||||
}
|
||||
return $db['db'];
|
||||
} catch (Exception $e) {
|
||||
// Show error and exit
|
||||
Feedback::flash('ERROR', 'DEFAULT', getError('Error connecting to the database.', $e->getMessage()));
|
||||
include __DIR__ . '/../templates/page-header.php';
|
||||
include __DIR__ . '/../helpers/feedback.php';
|
||||
include __DIR__ . '/../templates/page-footer.php';
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -134,10 +134,22 @@ $public_pages = filter_public_pages($public_pages);
|
|||
require_once __DIR__ . '/../app/core/Router.php';
|
||||
$currentUser = \App\Core\Router::checkAuth($config, $app_root, $public_pages, $page);
|
||||
|
||||
// connect to DB via DatabaseConnector
|
||||
require_once __DIR__ . '/../app/core/DatabaseConnector.php';
|
||||
use App\Core\DatabaseConnector;
|
||||
$dbWeb = DatabaseConnector::connect($config);
|
||||
// connect to db of Jilo Web
|
||||
require '../app/classes/database.php';
|
||||
require '../app/includes/database.php';
|
||||
try {
|
||||
$response = connectDB($config);
|
||||
if (!$response['db']) {
|
||||
throw new Exception('Could not connect to database: ' . $response['error']);
|
||||
}
|
||||
$dbWeb = $response['db'];
|
||||
} catch (Exception $e) {
|
||||
Feedback::flash('ERROR', 'DEFAULT', getError('Error connecting to the database.', $e->getMessage()));
|
||||
include '../app/templates/page-header.php';
|
||||
include '../app/helpers/feedback.php';
|
||||
include '../app/templates/page-footer.php';
|
||||
exit();
|
||||
}
|
||||
|
||||
// start logging
|
||||
require '../app/classes/log.php';
|
||||
|
|
Loading…
Reference in New Issue