/* Error reporting ------------------------------------------------------------------------ */ ini_set('error_reporting', 'true'); error_reporting(E_ALL | E_STRICT); /* class Cfg is mandatory for futher work ------------------------------------------------------------------------ */ if (!class_exists('CfgData')) { die('CfgData not found. Have you done install steps?'); } /* Session ------------------------------------------------------------------------ */ session_start(); /* Functions ------------------------------------------------------------------------ */ // this function below will handle all arising exception set_exception_handler(function ($exception) { // inside here we must declare vital classes separately $loc = new Locator(); $log = new Logger($loc->path('log')); $log->log($exception, LOG_ERR); // emergency mailer is defined separately $mail = MailerFactory::createMailerProvider('PHP'); // notify by email only once per exception $lockfile = $loc->path('secure') . '/lock.err_' . md5($exception); if (!file_exists($lockfile)) { touch($lockfile); $mail->sendEmail('root', gethostname(), 'Site Reporter', 'Problem occured', $exception); } include_once $loc->path('pages/error.php'); exit; });
defined('INSIDE') or exit('Direct access is not permitted'); /** * Init script for all used classes. * This version of the script is intended for online shop. * * @author efoft */ /* Locator ------------------------------------------------------------------------ */ $loc = new Locator(); /* Config ------------------------------------------------------------------------ */ $cfg = new Cfg(); if ($cfg->val('SECFILE')) { if (!file_exists($loc->path($cfg->val('SECFILE')))) { throw new Exception('SECFILE defined but the file not found'); } $cfg->loadSecrets($loc->path($cfg->val('SECFILE'))); } /* Logging ------------------------------------------------------------------------ */ $log = new Logger($loc->path('log'), $cfg->val('DEBUG')); /* Database ------------------------------------------------------------------------ */ if ($cfg->val('DBdriver')) { $dbdrv = $cfg->val('DBdriver'); switch ($dbdrv) { case 'mysql': $dbhost = $cfg->val('DBhost', true); $dbname = $cfg->val('DBname', true);