Exemple #1
0
    error_reporting($error_reporting);
    ini_set('display_errors', $error_mode);
    ini_set('display_startup_errors', $error_mode);
    if ($_SERVER['REQUEST_METHOD'] == 'CLI') {
        ini_set('html_errors', 'Off');
    }
    if (true === \olifant\Settings::get('system.errlog', false)) {
        ini_set('log_errors', 'On');
        ini_set('error_log', \olifant\constants\STORAGE_PATH . '/log/error/' . date('Y-m') . '.error.log');
        ini_set('log_errors_max_len', 10 * 1024);
    }
});
call_user_func(function () {
    date_default_timezone_set('UTC');
    ini_set('memory_limit', \olifant\Settings::get('system.memory_limit', '128M'));
    set_time_limit(\olifant\Settings::get('system.time_limit', 30));
});
call_user_func(function () {
    $obd = array(\olifant\constants\BACKEND_PATH, \olifant\constants\FRONTEND_PATH, \olifant\constants\STORAGE_PATH);
    ini_set('open_basedir', implode(PATH_SEPARATOR, $obd));
});
call_user_func(function () {
    ini_set('session.name', 'UNIQSESSID');
    ini_set('session.cookie_lifetime', 30 * 3600);
    ini_set('session.cookie_httponly', 1);
    ini_set('session.gc_divisor', 100);
    ini_set('session.gc_maxlifetime', 40);
    ini_set('session.gc_probability', 100);
    //session_start();
    //new \core\utils\ModelSessionHandler();
});
Exemple #2
0
 public static function handleError($errno, $errstr, $errfile, $errline)
 {
     $errors = array(1 => 'E_ERROR', 2 => 'E_WARNING', 4 => 'E_PARSE', 8 => 'E_NOTICE', 16 => 'E_CORE_ERROR', 32 => 'E_CORE_WARNING', 64 => 'E_COMPILE_ERROR', 128 => 'E_COMPILE_WARNING', 256 => 'E_USER_ERROR', 512 => 'E_USER_WARNING', 1024 => 'E_USER_NOTICE', 2048 => 'E_STRICT', 4096 => 'E_RECOVERABLE_ERROR', 8192 => 'E_DEPRECATED', 16384 => 'E_USER_DEPRECATED', 30719 => 'E_ALL');
     if (true === \olifant\Settings::get('system.errlog', false)) {
         $msg = implode(' ', array('PHP', str_replace('_', ' ', ucfirst(strtolower(substr($errors[$errno], 2)))) . ':', $errstr, 'in', $errfile, 'on line', $errline));
         self::log($msg);
     }
     if (!(error_reporting() & $errno)) {
         return;
     }
     $echo = '<div class="olifant-error">' . '<div class="item">' . '<h1>' . $errors[$errno] . ': ' . $errstr . '</h1>' . '<div class="path">' . $errfile . '</div>' . self::getSource($errfile, $errline) . '</div>' . '<h1>Stack trace</h1>' . self::parseStack(debug_backtrace()) . '</div>';
     echo $echo;
     return true;
 }
Exemple #3
0
namespace olifant\constants {
    define(__NAMESPACE__ . '\\NAMESPACE_SEPARATOR', '\\');
    define(__NAMESPACE__ . '\\BACKEND_PATH', __DIR__);
    define(__NAMESPACE__ . '\\FRONTEND_PATH', __DIR__ . '/../frontend');
    define(__NAMESPACE__ . '\\APP_PATH', BACKEND_PATH . '/app');
    define(__NAMESPACE__ . '\\ROUTE_PATH', BACKEND_PATH . '/route');
    define(__NAMESPACE__ . '\\CONTROLLER_PATH', BACKEND_PATH . '/controller');
    define(__NAMESPACE__ . '\\MODEL_PATH', BACKEND_PATH . '/model');
    define(__NAMESPACE__ . '\\VIEW_PATH', BACKEND_PATH . '/view');
    define(__NAMESPACE__ . '\\SETUP_PATH', BACKEND_PATH . '/setup');
    define(__NAMESPACE__ . '\\STORAGE_PATH', __DIR__ . '/../storage');
}
namespace {
    require_once \olifant\constants\BACKEND_PATH . '/app/kernel/autoload.php';
    spl_autoload_register('\\olifant\\kernel\\Autoload::load');
    $configs = array('settings', 'enviroment', 'general', 'upgrade', 'olifant', 'middlewares');
    foreach ($configs as $conf) {
        require_once \olifant\constants\SETUP_PATH . DIRECTORY_SEPARATOR . $conf . '.php';
    }
    try {
        \olifant\kernel\Application::run();
    } catch (Exception $e) {
        if ('debug' == \olifant\Settings::get('system.devmode', 'debug')) {
            \olifant\kernel\ErrorHandler::handleException($e);
        }
        if (true === \olifant\Settings::get('system.errlog', false)) {
            \olifant\kernel\ErrorHandler::log('PHP Exception' . PHP_EOL . $e);
        }
    }
}