Example #1
0
$ajax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower(trim($_SERVER['HTTP_X_REQUESTED_WITH'])) == 'xmlhttprequest';
$method = $_SERVER['REQUEST_METHOD'];
$errno = 0;
$errstr = '';
// error_handle
// register_shutdown_function('shutdown_handle');
set_error_handler('error_handle', -1);
date_default_timezone_set($conf['timezone']);
// 超级全局变量
$_GET += init_query_string();
$_REQUEST = array_merge($_COOKIE, $_POST, $_GET);
// 初始化 db cache,这里并没有连接,在获取数据的时候会自动连接。
include './xiunophp/db.class.php';
include './xiunophp/cache.class.php';
$db = db_new($conf['db']);
$cache = cache_new($conf['cache']);
$db->errno and message(-1, $db->errstr);
// 安装的时候检测过了,不必每次都检测。但是要考虑环境移植。
$cache and $cache->errno and message(-1, $cache->errstr);
// ----------------------------------------------------------> 全局变量申明结束
// ----------------------------------------------------------> 全局函数
// 此处不利于 HHVM,应该强制要求 APP 定义 message 函数,为了正确性,暂时如此。
if (!function_exists('message')) {
    function message($code, $message)
    {
        global $ajax;
        echo $ajax ? xn_json_encode(array('code' => $code, 'message' => $message)) : $message;
        exit;
    }
}
function log_post_data()
Example #2
0
$method = $_SERVER['REQUEST_METHOD'];
$errno = 0;
$errstr = '';
// error_handle
// register_shutdown_function('shutdown_handle');
set_error_handler('error_handle', -1);
empty($conf['timezone']) and $conf['timezone'] = 'Asia/Shanghai';
date_default_timezone_set($conf['timezone']);
// 超级全局变量
$_GET += init_query_string();
$_REQUEST = array_merge($_COOKIE, $_POST, $_GET);
// 初始化 db cache,这里并没有连接,在获取数据的时候会自动连接。
include './xiunophp/db.class.php';
include './xiunophp/cache.class.php';
$db = !empty($conf['db']) ? db_new($conf['db']) : NULL;
$cache = !empty($conf['cache']) ? cache_new($conf['cache']) : NULL;
$db and $db->errno and xn_message(-1, $db->errstr);
// 安装的时候检测过了,不必每次都检测。但是要考虑环境移植。
$cache and $cache->errno and xn_message(-1, $cache->errstr);
// ----------------------------------------------------------> 全局变量申明结束
// ----------------------------------------------------------> 全局函数
if (!function_exists('message')) {
    // 此处不利于 HHVM,应该强制要求 APP 定义 message 函数,为了正确性,暂时如此。
    function message($code, $message)
    {
        xn_message($code, $message);
    }
}
// 此处不利于 HHVM,应该强制要求 APP 定义 message 函数,为了正确性,暂时如此。
function xn_message($code, $message)
{