Example #1
0
 function __construct($location = NULL, $message = NULL, $data = NULL)
 {
     $time = mgGetMicrotime();
     //初始化解析时间
     parent::__construct($location);
     $this->stack = array();
     $this->stack['action'] = $this->runModule();
     $this->stack['action']['prase_time'] = $time;
     //初始化解析时间
     $this->stack['action']['data'] = $data;
     $this->stack['action']['message'] = $message;
     $this->runKernelModule();
     $this->runAction();
 }
Example #2
0
 public function runAction()
 {
     $module = array();
     //初始化module数组
     $args = array();
     //初始化args数组
     $hasRun = array();
     //已经运行的模块
     $waitting = array();
     //正在等待的模块
     $this->stack['action']['application_cache_path'] = __RUNTIME__ . '/template/' . mgPathToFileName($this->compileFile) . '.mod.php';
     $this->stack['action']['application_config_path'] = __RUNTIME__ . '/template/' . mgPathToFileName($this->compileFile) . '.cnf.php';
     require $this->stack['action']['application_cache_path'];
     foreach ($module as $nameSpace => $object) {
         //创建module
         mgTrace();
         $tmp = new $object();
         mgTrace(false);
         mgDebug('Create Module', $tmp);
         if ($tmp->waittingFor && isset($module[$tmp->waittingFor]) && !isset($hasRun[$tmp->waittingFor])) {
             $waitting[$nameSpace] = $tmp;
             continue;
         }
         //运行模块入口函数runModule并将运行结果保存到临时堆栈中
         mgTrace();
         $stack = $tmp->runModule(isset($args[$nameSpace]) ? $args[$nameSpace] : array());
         mgTrace(false);
         mgDebug('Run Module', $tmp);
         //将临时堆栈中的数据转移到全局堆栈中
         $this->stack = $this->pushData(explode('.', $nameSpace), $stack, $this->stack);
         $hasRun[$nameSpace] = $object;
     }
     foreach ($waitting as $key => $object) {
         //运行模块入口函数runModule并将运行结果保存到临时堆栈中
         mgTrace();
         $stack = $object->runModule(isset($args[$key]) ? $args[$key] : array());
         mgTrace(false);
         mgDebug('Run Module', $tmp);
         //将临时堆栈中的数据转移到全局堆栈中
         $this->stack = $this->pushData(explode('.', $key), $stack, $this->stack);
     }
     $this->stack['action']['prase_time'] = substr(mgGetMicrotime() - $this->stack['action']['prase_time'], 0, 6);
     $this->stack['action']['content_type'] = "content-Type: {$this->stack['static_var']['content_type']}; charset={$this->stack['static_var']['charset']}";
     //定义头文件
     header($this->stack['action']['content_type']);
     $data = $this->stack;
     require __COMPILE__ . '/' . mgPathToFileName($this->compileFile) . '.php';
 }
Example #3
0
            mgExportArrayToFile($stack['action']['application_config_path'], $files, 'files');
        }
    }
}
//打开系统缓存
if (__GZIP__ && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && ereg('gzip', $_SERVER['HTTP_ACCEPT_ENCODING'])) {
    ob_start("ob_gzhandler");
} else {
    ob_start();
}
//载入debug支持
if (__DEBUG__) {
    global $debugData, $debugTime;
    $debugData = array();
    $debugTime = array();
    $debugTime['now'] = array();
    $debugTime['start'] = mgGetMicrotime();
    $debugTime['now'][] = $debugTime['start'];
}
//关闭魔术变量功能
if (get_magic_quotes_gpc()) {
    $_GET = mgStripslashesDeep($_GET);
    $_POST = mgStripslashesDeep($_POST);
    $_COOKIE = mgStripslashesDeep($_COOKIE);
    reset($_GET);
    reset($_POST);
    reset($_COOKIE);
}
if (!ini_get("date.timezone") && function_exists("date_default_timezone_set")) {
    date_default_timezone_set(date_default_timezone_get());
}