Ejemplo n.º 1
0
 /** This method is the main controller */
 public static function serveWeb()
 {
     if (Config::get('PROFILING_ENABLED')) {
         Profiling::start('index');
     }
     $url = $_SERVER['REQUEST_URI'];
     $hash = md5($url);
     if (!@(include 'cache/' . $hash)) {
         Router::setUrl($url);
         switch (Router::$node->getProperty('type')) {
             case 'page':
             case 'root':
                 ControllerPage::compile();
                 break;
             case 'php':
                 ControllerPhp::compile();
                 break;
         }
     }
     if (Config::get('PROFILING_ENABLED')) {
         Profiling::end();
     }
 }
Ejemplo n.º 2
0
 public static function callStack()
 {
     $GC = CARRY('get_class');
     $callstack = Tree::getActiveCallstack();
     $count = count($callstack);
     Tree::$currentIndex = count(Tree::getActiveNodes()) - 1;
     if (!$count) {
         return false;
     }
     for ($i = 0; $i < $count; $i++) {
         foreach (array_keys($callstack[$i]) as $key) {
             if (strpos($key, '_') === 0) {
                 $callstack[$i][substr($key, 1)] = $callstack[$i][$key];
                 unset($callstack[$i][$key]);
             } elseif ($i < $count - 1) {
                 unset($callstack[$i][$key]);
             }
         }
     }
     $final = array();
     for ($i = $count - 1; $i >= 0; $i--) {
         $final += $callstack[$i];
     }
     ksort($final);
     foreach ($final as $key => $value) {
         if (is_string($value)) {
             $name = "{$value}";
         } elseif (is_array($value) and is_string($value[0])) {
             $name = "{$value[0]}";
         } elseif (is_array($value) and is_array($value[0]) and is_string($value[0][0])) {
             $name = "{$value[0][0]}, {$value[0][1]}";
         } elseif (is_array($value) and is_array($value[0]) and is_object($value[0][0])) {
             $name = "{$GC($value[0][0])}, {$value[0][1]}";
         } elseif (is_closure($value)) {
             $name = "CLOSURE ({$key})";
         } else {
             continue;
         }
         Profiling::start($name);
         if (is_closure($value)) {
             $value();
         } else {
             if (is_string($value)) {
                 $value = array($value);
             }
             $function = array_shift($value);
             call_user_func_array($function, $value);
         }
         Profiling::stop();
     }
     return true;
 }