Пример #1
0
 /**
  * Generate debug html file from collected data
  */
 public static function generate()
 {
     if (!DRAGON_DEBUG) {
         return;
     }
     $path = BASE_PATH . DS . 'tmp' . DS . 'debug' . DS;
     if (!file_exists($path)) {
         mkdir($path, 0777, true);
     }
     //clear old files
     if (file_exists($path . 'last.html')) {
         unlink($path . 'last.html');
     }
     $files = glob($path . '*.html');
     if (count($files) >= 10) {
         rsort($files);
         for ($i = count($files) - 1; $i >= 10; $i--) {
             unlink($files[$i]);
             unset($files[$i]);
         }
     }
     self::history($files);
     $time = microtime(true);
     ob_start();
     self::echoHtml('<!DOCTYPE html>', '<html>', '<head>');
     self::htmlStyles();
     self::htmlScripts();
     self::echoHtml('</head>', '<body>');
     if (!empty($_SERVER['REQUEST_URI'])) {
         self::echoHtml('URI: <b>' . $_SERVER['REQUEST_URI'] . '</b><br>');
     }
     self::echoHtml('CM: <b>' . Dragon::$controller . '::' . Dragon::$method . '</b><br>');
     self::echoHtml('Time: <b>' . date('Y-m-d H:i:s', $time) . substr($time, strpos($time, '.')) . '</b><br>');
     //tabs switches
     $tabs = [];
     $class = 'active';
     foreach (array_keys(Debug::$tables) as $key) {
         $tabs[] = '<li class="' . $class . '" data-tab="' . $key . '">' . $key . ' (' . count(Debug::$tables[$key]) . ')</li>';
         $class = '';
     }
     self::echoHtml('<br><ul>' . implode('', $tabs) . '</ul>');
     self::htmlTables();
     self::echoHtml('</body>', '</html>');
     $html = ob_get_clean();
     $filename = $time . '.html';
     file_put_contents($path . $filename, $html);
     file_put_contents($path . 'last.html', $html);
     Debug::$tables = [];
 }
Пример #2
0
 /**
  * Homepage -- default method
  */
 public function index()
 {
     Debug::timer('test');
     Assets::add('main', Assets::TYPE_CSS);
     Assets::add('default', Assets::TYPE_JS);
     /*
      * Sample information about access to database data
      * Default read:
      */
     //        $modelSample = new mSample();
     //        $rows = $modelSample->get();
     //        Debug::var_dump($rows);
     //        $modelSample->get(2);
     /*
      * Sample get instance of component
      */
     $componentEmail = new cEmail($this->config, $this->router);
     Debug::var_dump('test');
     Debug::var_dump([432, 654]);
     Debug::timer('test');
     $this->set('variable', 'how to set variable to view');
     $this->set('links', array('produkt' => $this->router->getUrl('products', 'detail', 123, array('list' => 5))));
 }
Пример #3
0
 function liste($keyconnexion = null, $cid = null, $hashtorrentselectionne = "")
 {
     \model\simple\Utilisateur::authentificationPourRtorrent($keyconnexion);
     $tor = null;
     if (!\config\Conf::$user["user"]) {
         throw new \Exception("Non User");
     }
     $cmds = array("d.hash=", "d.is_open=", "d.is_hash_checking=", "d.is_hash_checked=", "d.state=", "d.name=", "d.size_bytes=", "d.completed_chunks=", "d.size_chunks=", "d.bytes_done=", "d.up.total=", "d.ratio=", "d.up.rate=", "d.down.rate=", "d.chunk_size=", "d.custom1=", "d.peers_accounted=", "d.peers_not_connected=", "d.peers_connected=", "d.peers_complete=", "d.left_bytes=", "d.priority=", "d.state_changed=", "d.skip.total=", "d.hashing=", "d.chunks_hashed=", "d.base_path=", "d.creation_date=", "d.tracker_focus=", "d.is_active=", "d.message=", "d.custom2=", "d.free_diskspace=", "d.is_private=", "d.is_multi_file=", "d.throttle_name=", "d.custom=chk-state", "d.custom=chk-time", "d.custom=sch_ignore", 'cat="$t.multicall=d.hash=,t.scrape_complete=,cat={#}"', 'cat="$t.multicall=d.hash=,t.scrape_incomplete=,cat={#}"', 'cat=$d.views=', "d.timestamp.finished=", "d.timestamp.started=", "d.custom=clefunique", "d.custom=typemedias");
     $cmd = new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "d.multicall2", array("", "main"));
     $res = array();
     foreach ($cmds as $v) {
         $res[] = \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, $v);
     }
     $cmd->addParameters($res);
     $cnt = count($cmd->params) - 1;
     $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi, $cmd);
     $t = null;
     Debug::startTimer("rtorrent");
     /*$req->success();
       Debug::endTimer("rtorrent");
       $this->set(array(
           //"torrent"=>$req->val,
           "tt"=> $req->vals
       ));
       return true;//*/
     if ($req->success(false)) {
         Debug::endTimer("rtorrent");
         $i = 0;
         $tmp = array();
         $status = array('started' => 1, 'paused' => 2, 'checking' => 4, 'hashing' => 8, 'error' => 16);
         $i = preg_match_all("/<array><data>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<value>(<string>|<i.>)(.*)((\n)?<\\/string>|<\\/i.>)<\\/value>.*<\\/data><\\/array>/Us", $req->val, $tmp1);
         for ($ii = 0; $ii < $i; $ii++) {
             $torrent = null;
             $state = 0;
             $is_open = $tmp1[2 + 4 * 1][$ii];
             $is_hash_checking = $tmp1[2 + 4 * 2][$ii];
             $is_hash_checked = $tmp1[2 + 4 * 3][$ii];
             $get_state = $tmp1[2 + 4 * 4][$ii];
             $get_hashing = $tmp1[2 + 4 * 24][$ii];
             $is_active = $tmp1[2 + 4 * 29][$ii];
             $msg = $tmp1[2 + 4 * 30][$ii];
             if ($is_open != 0) {
                 $state |= $status["started"];
                 if ($get_state == 0 || $is_active == 0) {
                     $state |= $status["paused"];
                 }
             }
             if ($get_hashing != 0) {
                 $state |= $status["hashing"];
             }
             if ($is_hash_checking != 0) {
                 $state |= $status["checking"];
             }
             if ($msg != "" && $msg != "Tracker: [Tried all trackers.]") {
                 $state |= $status["error"];
             }
             $torrent[] = $state;
             //state 0
             $torrent[] = $tmp1[2 + 4 * 5][$ii];
             //nom 1
             $torrent[] = intval($tmp1[2 + 4 * 6][$ii]);
             //taille 2
             $get_completed_chunks = $tmp1[2 + 4 * 7][$ii];
             $get_hashed_chunks = $tmp1[2 + 4 * 25][$ii];
             $get_size_chunks = $tmp1[2 + 4 * 8][$ii];
             $chunks_processing = $is_hash_checking == 0 ? $get_completed_chunks : $get_hashed_chunks;
             $done = floor($chunks_processing / $get_size_chunks * 1000);
             $torrent[] = $done;
             // 3
             $torrent[] = intval($tmp1[2 + 4 * 9][$ii]);
             //downloaded 4
             $torrent[] = intval($tmp1[2 + 4 * 10][$ii]);
             //Uploaded 5
             $torrent[] = intval($tmp1[2 + 4 * 11][$ii]);
             //ratio 6
             $torrent[] = intval($tmp1[2 + 4 * 12][$ii]);
             //UL 7
             $torrent[] = intval($tmp1[2 + 4 * 13][$ii]);
             //DL 8
             $get_chunk_size = $tmp1[2 + 4 * 14][$ii];
             $torrent[] = $tmp1[2 + 4 * 13][$ii] > 0 ? floor(($get_size_chunks - $get_completed_chunks) * $get_chunk_size / $tmp1[2 + 4 * 13][$ii]) : -1;
             //Eta 9 (Temps restant en seconde)
             /*$get_peers_not_connected = $tmp1[2+4*17][$ii];
               $get_peers_connected = $tmp1[2+4*18][$ii];
               $get_peers_all = $get_peers_not_connected+$get_peers_connected;*/
             $torrent[] = intval($tmp1[2 + 4 * 16][$ii]);
             //Peer Actual 10
             $torrent[] = intval($tmp1[2 + 4 * 19][$ii]);
             //Seed Actual 11
             $seeds = 0;
             foreach (explode("#", $tmp1[2 + 4 * 39][$ii]) as $k => $v) {
                 $seeds += $v;
             }
             $peers = 0;
             foreach (explode("#", $tmp1[2 + 4 * 40][$ii]) as $k => $v) {
                 $peers += $v;
             }
             $torrent[] = $peers;
             //Peer total 12
             $torrent[] = $seeds;
             //Seed tota 13
             $torrent[] = intval($tmp1[2 + 4 * 20][$ii]);
             //Taille restant 14
             $torrent[] = intval($tmp1[2 + 4 * 21][$ii]);
             //Priority 15 (0 ne pas télécharger, 1 basse, 2 moyenne, 3 haute)
             $torrent[] = intval($tmp1[2 + 4 * 22][$ii]);
             //State change 16 (dernière date de change d'état)
             $torrent[] = intval($tmp1[2 + 4 * 23][$ii]);
             //Skip total Contiens les rejets en mo 17
             $torrent[] = $tmp1[2 + 4 * 26][$ii];
             //Base Path 18
             $torrent[] = intval($tmp1[2 + 4 * 27][$ii]);
             //Date create 19
             $torrent[] = intval($tmp1[2 + 4 * 28][$ii]);
             //Focus tracker 20
             /*try {
                   torrent.comment = this.getValue(values,31);
                   if(torrent.comment.search("VRS24mrker")==0)
                       torrent.comment = decodeURIComponent(torrent.comment.substr(10));
               } catch(e) { torrent.comment = ''; }*/
             $torrent[] = intval($tmp1[2 + 4 * 32][$ii]);
             //Torrent free diskspace 21
             $torrent[] = intval($tmp1[2 + 4 * 33][$ii]);
             //Torrent is private 22
             $torrent[] = intval($tmp1[2 + 4 * 34][$ii]);
             //Torrent is multifile 23
             $torrent[] = intval($tmp1[2 + 4 * 42][$ii]);
             //Torrent seed time 24
             $torrent[] = intval($tmp1[2 + 4 * 43][$ii]);
             //Torrent add time 25
             $torrent[] = $msg;
             //Message tracker 26
             $torrent[] = $tmp1[2 + 4 * 0][$ii];
             //Hash 27
             $torrent[] = $tmp1[2 + 4 * 44][$ii];
             //Clefunique
             $torrent[] = $tmp1[2 + 4 * 45][$ii];
             //Type medias
             if ($hashtorrentselectionne == $tmp1[2 + 4 * 0][$ii]) {
                 $tor = $torrent;
             }
             $tmp[$tmp1[2 + 4 * 0][$ii]] = $torrent;
         }
         $data = $tmp;
         if (!is_null($cid)) {
             if ($anc = \core\Memcached::value("torrentlist" . \config\Conf::$userscgi, $cid)) {
                 foreach ($anc as $k => $v) {
                     if (!isset($tmp[$k])) {
                         $tmp[$k] = false;
                     }
                     foreach ($v as $kk => $vv) {
                         if (isset($tmp[$k][$kk]) && $tmp[$k][$kk] == $vv) {
                             unset($tmp[$k][$kk]);
                         }
                     }
                     if (count($tmp[$k]) == 0) {
                         unset($tmp[$k]);
                     }
                 }
             }
         }
         $ncid = \model\simple\String::random(5);
         \core\Memcached::del("torrentlist" . \config\Conf::$userscgi, $cid);
         if (!\core\Memcached::value("torrentlist" . \config\Conf::$userscgi, $ncid, $data, 60 * 5)) {
             trigger_error("Impossible de mettre des données dans le cache");
         }
         $t[] = $tmp;
         $t[] = $ncid;
         $path = DS . "home" . DS . \config\Conf::$user["user"]->login . DS . "rtorrent" . DS . "data";
         $t[] = disk_total_space($path) - disk_free_space($path);
         $t[] = disk_total_space($path);
         $cmds = array("throttle.global_up.rate", "throttle.global_up.max_rate", "throttle.global_up.total", "throttle.global_down.rate", "throttle.global_down.max_rate", "throttle.global_down.total");
         $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi);
         foreach ($cmds as $cmd) {
             $req->addCommand(new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, $cmd));
         }
         if ($req->success()) {
             $t[] = $req->val;
         }
     }
     if (is_null($t)) {
         trigger_error("Impossible de se connecter à rtorrent :(");
     }
     $torrent = null;
     if ($hashtorrentselectionne !== "") {
         /*
          * =================================================
          * Détails du torrent hashtorrent
          * =================================================
          */
         $tmp = $tor;
         $data = $tmp;
         if (!is_null($cid)) {
             if ($anc = \core\Memcached::value("detaillist" . \config\Conf::$userscgi, sha1($cid . $hashtorrentselectionne))) {
                 foreach ($anc as $k => $v) {
                     if (isset($tmp[$k]) && $tmp[$k] == $v) {
                         unset($tmp[$k]);
                     }
                 }
             }
         }
         \core\Memcached::del("detaillist" . \config\Conf::$userscgi, sha1($cid . $hashtorrentselectionne));
         if (!\core\Memcached::value("detaillist" . \config\Conf::$userscgi, sha1($ncid . $hashtorrentselectionne), $data, 60 * 5)) {
             trigger_error("Impossible de mettre des données dans le cache");
         }
         $torrent["detail"] = $tmp;
         /*
          * =================================================
          * Détails du torrent hashtorrent (file liste)
          * =================================================
          */
         $cmds = array("f.path=", "f.completed_chunks=", "f.size_chunks=", "f.size_bytes=", "f.priority=", "f.prioritize_first=", "f.prioritize_last=");
         $cmd = new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "f.multicall", array($hashtorrentselectionne, ""));
         foreach ($cmds as $prm) {
             $cmd->addParameter(\model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, $prm));
         }
         $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi, $cmd);
         $files = null;
         $to = null;
         if (!$req->success()) {
             trigger_error("Impossible de récupéré la liste des fichiers de " . $hashtorrentselectionne);
             $files = $req->val;
         } else {
             $taille = count($req->val);
             $j = 0;
             for ($i = 0; $i < $taille; $i += 7) {
                 $files[] = array($j, $req->val[$i], $req->val[$i + 1], $req->val[$i + 2], $req->val[$i + 3], $req->val[$i + 4], $req->val[$i + 5], $req->val[$i + 6]);
                 $j++;
             }
             $tmp = $files;
             $data = $tmp;
             if (!is_null($cid)) {
                 if ($anc = \core\Memcached::value("fileslist" . \config\Conf::$userscgi, sha1($cid . $hashtorrentselectionne))) {
                     foreach ($anc as $k => $v) {
                         if (!isset($tmp[$k])) {
                             $tmp[$k] = false;
                         }
                         foreach ($v as $kk => $vv) {
                             if (isset($tmp[$k][$kk]) && $tmp[$k][$kk] == $vv) {
                                 unset($tmp[$k][$kk]);
                             }
                         }
                         if (count($tmp[$k]) == 0) {
                             unset($tmp[$k]);
                         }
                     }
                 }
             }
             \core\Memcached::del("fileslist" . \config\Conf::$userscgi, sha1($cid . $hashtorrentselectionne));
             if (!\core\Memcached::value("fileslist" . \config\Conf::$userscgi, sha1($ncid . $hashtorrentselectionne), $data, 60 * 5)) {
                 trigger_error("Impossible de mettre des données dans le cache");
             }
             $torrent["files"] = $tmp;
         }
         /*
          * =================================================
          * Détails du torrent hashtorrent (traker liste)
          * =================================================
          */
         $cmds = array("t.url=", "t.type=", "t.is_enabled=", "t.group=", "t.scrape_complete=", "t.scrape_incomplete=", "t.scrape_downloaded=", "t.normal_interval=", "t.scrape_time_last=");
         $cmd = new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "t.multicall", array($hashtorrentselectionne, ""));
         foreach ($cmds as $prm) {
             $cmd->addParameter(\model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, $prm));
         }
         $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi, $cmd);
         $trackers = null;
         if (!$req->success()) {
             trigger_error("Impossible de récupéré la liste des trakers de " . $hashtorrentselectionne);
             $traker = $req->val;
         } else {
             $taille = count($req->val);
             $j = 0;
             for ($i = 0; $i < $taille; $i += 9) {
                 $trackers[] = array($j, $req->val[$i], $req->val[$i + 1], $req->val[$i + 2], $req->val[$i + 3], $req->val[$i + 4], $req->val[$i + 5], $req->val[$i + 6], $req->val[$i + 7], $req->val[$i + 8]);
                 $j++;
             }
             /*for ($i = 0; $i < 30; $i++)
                                 $trackers[] = $trackers[0];
                                 /*$tmp = $files;
                                 $data = $tmp;
                                 if (!is_null($cid)) {
                                     if ($anc = \core\Memcached::value("fileslist" . \config\Conf::$userscgi, sha1($cid . $hashtorrentselectionne))) {
                                         foreach ($anc as $k => $v) {
                                             if (!isset($tmp[$k]))
                                                 $tmp[$k] = false;
                                             foreach ($v as $kk => $vv) {
                                                 if (isset($tmp[$k][$kk]) && $tmp[$k][$kk] == $vv) {
                                                     unset($tmp[$k][$kk]);
                                                 }
                                             }
                                             if (count($tmp[$k]) == 0)
                                                 unset($tmp[$k]);
                                         }
                                     }
                                 }
             
                                 if (!(\core\Memcached::value("fileslist" . \config\Conf::$userscgi, sha1($ncid . $hashtorrentselectionne), $data, 60 * 5)))
                                     trigger_error("Impossible de mettre des données dans le cache");
                                 */
             $torrent["trackers"] = $trackers;
         }
     }
     $this->set(array("torrent" => $t, "torrentselectionnee" => $torrent, "hashtorrent" => $hashtorrentselectionne, "host" => HOST));
 }
Пример #4
0
    }
    //v priecinku vendor mame cudzie riesenia
    if ($tryVendor) {
        $path = BASE_PATH . DS . 'vendor';
        foreach ($parts as $i => $part) {
            $path .= DS . $part;
            if ($i == $cnt) {
                $path .= '.php';
            }
        }
        if (file_exists($path)) {
            include_once $path;
        }
    }
    if (class_exists("\\core\\Debug")) {
        \core\Debug::files($path);
    }
});
$workspace = false;
if (IS_CLI) {
    //console
    if (empty($argv[1]) || !in_array($argv[1], array('production', 'development'))) {
        exit('Wrong environment definition, check shell variable "env"');
    }
    $workspace = $argv[1] == 'development';
    //    $_SERVER['SERVER_PORT'] = 80;
    //    $_SERVER['HTTP_HOST'] = $workspace ? '' : '';
    set_time_limit(0);
} else {
    //website
    if (isset($_SERVER['HTTP_HOST'])) {
Пример #5
0
 public function success($factory = true)
 {
     Debug::startTimer("sucess");
     $res = $this->run($factory) && !$this->fault;
     Debug::endTimer("sucess");
     return $res;
 }
Пример #6
0
 /**
  * Load controller
  * 
  * @param array $cmv array('controller' => '', 'method' => '', 'vars' => array())
  */
 private function loadController($cmv)
 {
     //if we have nothing to do, then quit
     if (empty($cmv) or empty($cmv['controller']) or empty($cmv['method'])) {
         trigger_error('Not call controller->method', E_USER_ERROR);
         exit;
     }
     if (!is_array($cmv['controller'])) {
         $cmv['controller'] = array($cmv['controller']);
     }
     self::$controller = implode("\\", $cmv['controller']);
     self::$method = $cmv['method'];
     $this->view->setView(self::$controller . DS . self::$method);
     //add controllers folder to begin and uppercase first letter class name
     array_unshift($cmv['controller'], 'controllers');
     end($cmv['controller']);
     $cmv['controller'][key($cmv['controller'])] = ucfirst($cmv['controller'][key($cmv['controller'])]);
     $cmv['controller'] = "\\" . implode("\\", $cmv['controller']);
     $controller = new $cmv['controller']($this->config, $this->router, $this->view);
     if (method_exists($controller, 'beforeMethod')) {
         Debug::timer('beforeMethod');
         $controller->beforeMethod();
         Debug::timer('beforeMethod');
     }
     if (is_callable(array($controller, $cmv['method']), true)) {
         Debug::timer('Controller logic');
         call_user_func_array(array($controller, $cmv['method']), $cmv['vars']);
         Debug::timer('Controller logic');
     }
     if (method_exists($controller, 'afterMethod')) {
         Debug::timer('afterMethod');
         $controller->afterMethod();
         Debug::timer('afterMethod');
     }
 }