當前位置: 首頁>>代碼示例>>PHP>>正文


PHP router::remove_url方法代碼示例

本文整理匯總了PHP中router::remove_url方法的典型用法代碼示例。如果您正苦於以下問題:PHP router::remove_url方法的具體用法?PHP router::remove_url怎麽用?PHP router::remove_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在router的用法示例。


在下文中一共展示了router::remove_url方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 public function __construct($_clean_url = null)
 {
     self::$repository = repository;
     $path = preg_replace("/^\\.\\//", "/", '/');
     $clean_url = $_clean_url !== null ? $_clean_url : $_SERVER['REQUEST_URI'];
     if (preg_match("#0x#", $clean_url)) {
         // error
     }
     $clean_url = preg_replace("#0x#Ui", "", $clean_url);
     $clean_url = preg_replace("#^https?://{$_SERVER['HTTP_HOST']}\\/#", '', $clean_url);
     $clean_url = preg_replace("#^{$path}#", '', $clean_url);
     $clean_url = urldecode($clean_url);
     preg_match("/^([^?]*)(\\?.*)?\$/", $clean_url, $url);
     self::$real_url_string = self::$url_string = $url[1];
     self::$real_url_array = self::$url_array = preg_split("[\\/]", preg_replace("/^\\/|\\/\$/", '', $url[1]), -1, PREG_SPLIT_NO_EMPTY);
     // HTTP_HOST is not secure and attacker can change it
     $domain = $_SERVER['HTTP_HOST'];
     self::$domain = preg_split("[\\.]", $domain);
     self::$sub_domain = self::$domain;
     array_pop(self::$sub_domain);
     array_pop(self::$sub_domain);
     if (isset(self::$real_url_array[0]) && self::$real_url_array[0] == 'home' || isset(self::$real_url_array[1]) && self::$real_url_array[1] == 'home') {
         \lib\error::page("home");
     }
     /**
      * user want control panel or CMS
      */
     if (defined('CMS') && constant('CMS')) {
         $myCP = constant('CMS') === true ? 'cp' : constant('CMS');
         router::set_storage('CMS', $myCP);
     } else {
         router::set_storage('CMS', 'cp');
     }
     /**
      * before router
      */
     if (self::$auto_repository) {
         // first get subdomain and if not exist get first url part as mysub
         $mysub = router::get_sub_domain();
         if (!$mysub) {
             $mysub = router::get_url(0);
             router::$sub_is_fake = true;
             // router::$sub_is_fake = $mysub? true: false;
             // router::set_storage('language', router::get_storage('defaultLanguage') );
         }
         if ($mysub) {
             // automatically set repository if folder of it exist
             $myaddons = array();
             $mysub_real = $mysub;
             $myloc = null;
             $mysub_valid = null;
             // check for account with specefic name
             if (\lib\router::get_storage('CMS')) {
                 $myaddons[\lib\router::get_storage('CMS')] = 'cp';
                 $myaddons['account'] = 'account';
             }
             // check this sub is exist in our data or not
             if (array_key_exists($mysub, $myaddons)) {
                 $mysub = $myaddons[$mysub];
                 $mysub_valid = true;
             }
             // set repository name
             $myrep = 'content_' . $mysub;
             // check content_aaa folder is exist in project or saloos addons folder
             if (is_dir(root . $myrep)) {
                 $myloc = false;
             } elseif ($mysub_valid && is_dir(addons . $myrep)) {
                 $myloc = addons;
             }
             // if folder exist
             if (!is_null($myloc)) {
                 // if url is fake, show it like subdomain and remove from url
                 if (router::$sub_is_fake) {
                     router::remove_url($mysub_real);
                     router::set_sub_domain($mysub_real);
                 }
                 // set repository to this folder
                 $myparam = array($myrep);
                 if ($myloc) {
                     array_push($myparam, $myloc);
                 }
                 // call function and pass param value to it
                 router::set_repository(...$myparam);
             }
         }
     }
     if (self::$auto_api) {
         // automatically allow api, if you wan't to desable it, only set a value
         $route = new router\route("/^api([^\\/]*)/", function ($reg) {
             router::remove_url($reg->url);
             router::set_storage('api', true);
         });
     }
     if (class_exists('\\cls\\route')) {
         $router = new \cls\route();
         $router->main = $this;
         if (method_exists($router, "_before")) {
             $router->_before();
         }
     }
//.........這裏部分代碼省略.........
開發者ID:Ermile,項目名稱:Saloos,代碼行數:101,代碼來源:router.php


注:本文中的router::remove_url方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。