コード例 #1
0
set_include_path(get_include_path() . PATH_SEPARATOR . 'src/main/php/' . PATH_SEPARATOR . '/usr/share/php/' . PATH_SEPARATOR . 'vendor/jwread/lib-allure/src/main/php/');
date_default_timezone_set('Europe/London');
function __autoload($class)
{
    $class = DIRECTORY_SEPARATOR . $class . '.php';
    foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
        if (file_exists($path . $class)) {
            require_once $path . $class;
            return;
        }
    }
}
require_once 'includes/functions.php';
require_once 'libAllure/Exceptions.php';
require_once 'libAllure/ErrorHandler.php';
require_once 'libAllure/Database.php';
require_once 'libAllure/Form.php';
require_once 'libAllure/Logger.php';
require_once 'libAllure/User.php';
require_once 'libAllure/Inflector.php';
require_once 'libAllure/Session.php';
require_once 'libAllure/AuthBackend.php';
require_once 'libAllure/AuthBackendDatabase.php';
require_once 'libAllure/HtmlLinksCollection.php';
require_once 'config.php';
\libAllure\ErrorHandler::getInstance()->beGreedy();
$db = new \libAllure\Database(CFG_DB_DSN, CFG_DB_USER, CFG_DB_PASS);
\libAllure\DatabaseFactory::registerInstance($db);
\libAllure\AuthBackend::setBackend(new \libAllure\AuthBackendDatabase());
\libAllure\Session::checkCredentials('SYSTEM', '');
コード例 #2
0
function connectDatabase()
{
    try {
        $db = new \libAllure\Database(CFG_DB_DSN, CFG_DB_USER, CFG_DB_PASS);
        \libAllure\DatabaseFactory::registerInstance($db);
    } catch (Exception $e) {
        throw new Exception('Could not connect to database. Check the username, password, host, port and database name.<br />' . $e->getMessage(), null, $e);
    }
    try {
        $maint = getSiteSetting('maintenanceMode', 'NONE');
    } catch (Exception $e) {
        if ($e->getCode() == '42S02') {
            throw new Exception('Settings table not found. Did you import the table schema?', null, $e);
        } else {
            throw new Exception('Unhandled SQL error while getting settings table: ' . $e->getMessage(), null, $e);
        }
    }
    if ($maint === 'NONE') {
        throw new Exception('Essential setting "maintenanceMode" does not exist in the DB. Did you import the initial data?');
    }
    return $db;
}