当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::set404方法代码示例

本文整理汇总了PHP中Router::set404方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::set404方法的具体用法?PHP Router::set404怎么用?PHP Router::set404使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Router的用法示例。


在下文中一共展示了Router::set404方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _run_

 public function _run_($param = null)
 {
     if (is_null($param)) {
         if (method_exists($this, '_absent_')) {
             $this->_absent_();
         } else {
             Router::set404();
         }
         return;
     }
     if (method_exists($this, '_always_')) {
         if ($this->_always_() === false) {
             return;
         }
     }
     if ($param === '') {
         if (method_exists($this, '_empty_')) {
             $this->_empty_();
         } else {
             Router::set404();
         }
     } elseif (mb_substr($param, 0, 1) !== '_' && method_exists($this, $param)) {
         $rm = new ReflectionMethod($this, $param);
         if ($rm->isPublic()) {
             $this->{$param}();
         } else {
             Router::set404();
         }
     } else {
         Router::set404();
     }
 }
开发者ID:pavel78779,项目名称:my_cms,代码行数:32,代码来源:Controller.php

示例2: getUrlSegment

 public static function getUrlSegment($part, $required = true, $pattern = '/^[-a-z0-9_]+$/i')
 {
     try {
         return self::getFromArr(self::$url_segments, $part, $required, $pattern, '');
     } catch (ValidatorException $e) {
         Router::set404();
     }
 }
开发者ID:pavel78779,项目名称:my_cms,代码行数:8,代码来源:Request.php

示例3: file

 public static function file($path, $data = null)
 {
     try {
         FileSys::includeFile($path, $data);
     } catch (SystemException $e) {
         Router::set404();
     }
 }
开发者ID:pavel78779,项目名称:my_cms,代码行数:8,代码来源:Load.php

示例4: start

 public static function start()
 {
     //если сайт отключен
     if (SConfig::SITE_DISABLED) {
         FileSys::includeFile(SITE_ROOT . '/client/pages/site_disabled.php');
         exit;
     }
     //в переменную $request_url заносим url без GET-параметров
     $request_url = explode('?', $_SERVER['REQUEST_URI'])[0];
     //проверяем url
     if (!preg_match('/^\\/(([-a-z0-9_]+\\/)*[-a-z0-9_]+\\.html)?(\\?.*)?$/', $request_url)) {
         Router::set404();
     }
     Request::setOriginalUrl($request_url);
     $db = (new Db())->setTable('url_redirects');
     //если у страницы есть новый адрес - перенаправляем, чтобы избежать дублей страниц
     if ($ou = $db->getOne('SELECT `old_url` FROM # WHERE new_url=?s AND type="I"', $request_url)) {
         Router::redirect($ou);
     }
     //проверяем, есть ли редиректы
     $r = $db->getRow('SELECT `new_url`,`type`,`comment` FROM # WHERE old_url=?s', $request_url);
     if ($r) {
         //если редирект внутренний
         if ($r[1] === 'I') {
             $request_url = $r[0];
         } elseif ($r[1] === 'E') {
             Router::redirect($r[0]);
         }
     }
     //получаем параметры пункта меню (если есть)
     $item = $db->getRow('SELECT * FROM ##menu_items WHERE `item_url`=?s', [Request::getOriginalUrl()], MYSQLI_ASSOC);
     if ($item) {
         if ($item['params']) {
             $item['params'] = Json::decode($item['params']);
         }
         Request::setItemParams($item);
     }
     Request::setRealUrl($request_url);
     Request::setUrlSegments(explode('/', substr($request_url, 1, -5)));
     //запускаем вывод страницы
     Document::generate();
 }
开发者ID:pavel78779,项目名称:my_cms,代码行数:42,代码来源:Router.php

示例5: generateComponent

 public static function generateComponent()
 {
     $com_name = Request::getUrlSegment(0);
     //проверяем наличие такого компонента
     if (!is_dir(SITE_ROOT . '/components/' . $com_name)) {
         Router::set404();
     }
     ob_start();
     //запускаем работу компонента
     if (is_file(SITE_ROOT . '/components/' . $com_name . '/index.php')) {
         Load::file(SITE_ROOT . '/components/' . $com_name . '/index.php');
     } else {
         $section = Request::getUrlSegment(1);
         if (is_file(SITE_ROOT . '/components/' . $com_name . '/' . $section . '/' . $section . '.php')) {
             Load::file(SITE_ROOT . '/components/' . $com_name . '/' . $section . '/' . $section . '.php');
         } else {
             Router::set404();
         }
     }
     return ob_get_clean();
 }
开发者ID:pavel78779,项目名称:my_cms,代码行数:21,代码来源:Document.php

示例6: _absent_

 public function _absent_()
 {
     switch (Request::get('action')) {
         case 'login':
             $username = Request::post('username', true, Validator::STRICT_STRING);
             $password = Request::post('password');
             $user = (new Db())->getRow('SELECT * FROM ##users WHERE `username`=?s LIMIT 1', $username, MYSQLI_ASSOC);
             if (!$user || crypt($password, $user['password']) !== $user['password'] || $user['username'] !== $username) {
                 throw new ValidatorException('Неверное имя пользователя или пароль');
             }
             session_regenerate_id(true);
             $_SESSION['user'] = $user;
             break;
         case 'logout':
             $_SESSION = [];
             session_destroy();
             setcookie('PHPSESSID', '', time() - 3600);
             break;
         default:
             Router::set404();
     }
 }
开发者ID:pavel78779,项目名称:my_cms,代码行数:22,代码来源:SectionController.php

示例7: _changeOrdering

 protected function _changeOrdering($id, $new_order)
 {
     Router::set404();
 }
开发者ID:pavel78779,项目名称:my_cms,代码行数:4,代码来源:ConfigFileManager.php

示例8: toCamelCase

    } else {
        $com = Request::get('com');
        if (!is_dir(ADMIN_ROOT . '/components/' . $com)) {
            Router::set404();
        }
        if (is_file(ADMIN_ROOT . '/components/' . $com . '/config.php')) {
            require_once ADMIN_ROOT . '/components/' . $com . '/config.php';
        }
        if (is_file(ADMIN_ROOT . '/components/' . $com . '/SectionController.php')) {
            Load::controller(ADMIN_ROOT . '/components/' . $com . '/SectionController.php', Request::get('section', false));
        } else {
            $com_dirs = FileSys::getDirs(ADMIN_ROOT . '/components/' . $com);
            $forbidden_dir = ['client'];
            $section = Request::get('section');
            if (in_array($section, $com_dirs) && !in_array($section, $forbidden_dir)) {
                Load::manager(ADMIN_ROOT . '/components/' . $com . '/' . $section . '/' . toCamelCase($section) . 'Manager.php');
            } else {
                Router::set404();
            }
        }
    }
} catch (SystemException $e) {
    header('HTTP/1.0 500 Internal Server Error');
    echo $e->getError();
} catch (ValidatorException $e) {
    header('HTTP/1.0 400 Bad Request');
    echo $e->getError();
} catch (AccessException $e) {
    header('HTTP/1.0 403 Forbidden');
    echo $e->getError();
}
开发者ID:pavel78779,项目名称:my_cms,代码行数:31,代码来源:index.php


注:本文中的Router::set404方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。