<?php
// Version
define('VERSION', '3.0.3.2');

// Configuration
if (is_file('config.php')) {
	require_once('config.php');
}

// Install
if (!defined('DIR_APPLICATION')) {
	header('Location: install/index.php');
	exit;
}

error_reporting(E_ALL); //E_ALL
function cache_shutdown_error() {
    $_error = error_get_last();

    if ($_error && in_array($_error['type'], array(1, 4, 16, 64, 256, 4096, E_ALL))) {
        $error = [
            'message'   => $_error['message'],
            'where'     => $_error['file'] . ' Line: ' . $_error['line']
        ];

        $error['md5'] = md5(json_encode($error));

        $handle = @fopen(DIR_LOGS . '500error.log', 'a');

        @flock($handle, LOCK_EX);

        @fwrite($handle, date('Y-m-d G:i:s') . ' - ' . print_r($error, true) . "\n");

        @fflush($handle);

        @flock($handle, LOCK_UN);

        @fclose($handle);
    }
}

register_shutdown_function("cache_shutdown_error");

// Startup
require_once(DIR_SYSTEM . 'startup.php');

start('catalog');