Example #1
0
 public static function end()
 {
     if (self::$is_start) {
         if (function_exists('xhprof_disable')) {
             $xhprof_data = xhprof_disable();
             include SYSPATH . 'librarys/xhprof/xhprof_lib/utils/xhprof_lib.php';
             include SYSPATH . 'librarys/xhprof/xhprof_lib/utils/xhprof_runs.php';
             $save_path = Config::get('xhprof.save_path') ?: '';
             $xhprof_runs = new XHProfRuns_Default($save_path);
             $type = str_replace('/', '.', Router::getUri()) ?: 'index';
             $run_id = $xhprof_runs->save_run($xhprof_data, $type, Date('YmdHis'));
             $url = "http://www.xhprof.me/xhprof_html/index.php?run={$run_id}&source={$type}&path=" . urlencode(base64_encode($save_path));
             echo '<div><a target="_blank"  href="' . $url . '">xhprof性能分析</a>';
         }
     }
 }
 public function searchAction()
 {
     $page_data = $this->index('basic_page');
     $request = new Request();
     if ($request->isPost()) {
         $search = new SearchModel($request);
         if (!$search->isSmall()) {
             if (!$search->isLarge()) {
                 $search_data = $search->search();
             } else {
                 Session::setFlash(__t('long_inquiry'));
             }
         } else {
             Session::setFlash(__t('short_inquiry'));
         }
     }
     $search_array = array();
     if (isset($search_data)) {
         foreach ($search_data as $material_type) {
             foreach ($material_type as $val) {
                 $search_array[] = $val;
             }
         }
     }
     $items_count = count($search_array);
     $items_per_page = Config::get('search_per_page');
     $request = new Request();
     $currentPage = $request->get('page') ? (int) $request->get('page') : 1;
     $data_pagination = self::getPagination($items_count, $items_per_page, $currentPage);
     if ($items_count) {
         $data_search_page = array_chunk($search_array, $items_per_page, true);
         if (isset($data_search_page[$currentPage - 1])) {
             $data_search_page = $data_search_page[$currentPage - 1];
         } else {
             throw new Exception('Page (' . Router::getUri() . ') not found', 404);
         }
     } else {
         $data_search_page = null;
     }
     $data_url = explode('?', Router::getUri());
     $lang = Router::getLanguage() == Config::get('default_language') ? '' : Router::getLanguage() . '/';
     //    $search_request = $search->getSearchRequest();
     $args = array('page_data' => $page_data, 'data_search' => $data_search_page, 'data_pagination' => $data_pagination, 'data_url' => $data_url[0], 'lang' => $lang, 'items_count' => $items_count, 'img' => $page_data['img']);
     return $this->render($args);
 }
 public function messagesListAction()
 {
     if (Session::hasUser('admin')) {
         $adminModel = new AdminModel();
         $data_admin = $adminModel->getAdminPage(Router::getId());
         $request = new Request();
         $contactModel = new ContactModel($request);
         $data_message = $contactModel->getMessagesList();
         $items_count = count($data_message);
         $items_per_page = Config::get('message_per_page');
         $currentPage = $request->get('page') ? (int) $request->get('page') : 1;
         $data_pagination = self::getPagination($items_count, $items_per_page, $currentPage);
         if ($items_count) {
             $data_message_page = array_chunk($data_message, $items_per_page, true);
             if (isset($data_message_page[$currentPage - 1])) {
                 $data_message_page = $data_message_page[$currentPage - 1];
             } else {
                 throw new Exception('Page (' . Router::getUri() . ') not found', 404);
             }
         } else {
             $data_message_page = null;
         }
         $data_url = explode('?', Router::getUri());
         $args = array('data_admin' => $data_admin[0], 'data_message' => $data_message, 'data_materials' => $data_message_page, 'data_pagination' => $data_pagination, 'data_url' => $data_url[0], 'items_per_page' => $items_per_page);
         return $this->render_admin($args);
     } else {
         throw new Exception('Access is forbidden', 403);
     }
 }
Example #4
0
 protected function execute($cmd = '', $blockRedundancy = true)
 {
     if (empty($cmd)) {
         $cmd = $this->cmdFile;
     }
     if ($this->isCli() == true) {
         if ($this->isRunning() && $blockRedundancy) {
             throw new Exception("이미 실행중인 커맨드 입니다.");
         }
         $this->makePidFile();
         Router::callClassByUri(Router::getUri($cmd));
     } else {
         throw new Exception("커맨드 실행만 가능합니다.");
     }
 }
Example #5
0
 public function getRules()
 {
     $params = Config::get(Router::getUri(), 'params');
     if ($params) {
         return $params['rule'];
     }
     return false;
 }