<?php
error_reporting(E_ALL); //E_ALL

// 调试助手函数
function dlog($data, $label = 'DEBUG') {
    $log_file = '/tmp/php_debug.log';
    $message = sprintf(
        "[%s] %s (%s):\n%s\n\n",
        date('Y-m-d H:i:s'),
        $label,
        gettype($data),
        print_r($data, true)
    );
    file_put_contents($log_file, $message, FILE_APPEND);
}

function dclear() {
    file_put_contents('/tmp/php_debug.log', '');
}

function cache_shutdown_error() {

    $_error = error_get_last();

    if ($_error && in_array($_error['type'], array(1, 4, 16, 64, 256, 4096, E_ALL))) {

        echo '<font color=red>你的代码出错了：</font></br>';
        echo '致命错误:' . $_error['message'] . '</br>';
        echo '文件:' . $_error['file'] . '</br>';
        echo '在第' . $_error['line'] . '行</br>';
    }
}

register_shutdown_function("cache_shutdown_error");
// Version
define('VERSION', '3.0.2.0');

// Configuration
if (is_file('config.php')) {
	require_once('config.php');
}

// Install
if (!defined('DIR_APPLICATION')) {
	header('Location: install/index.php');
	exit;
}

// Startup
require_once(DIR_SYSTEM . 'startup.php');

start('catalog');