Parses URIs and determines routing
Автор: EllisLab Dev Team
Пример #1
0
 function _fetch_uri_string()
 {
     if (strtoupper($this->config->item('uri_protocol')) == 'AUTO') {
         // Let's try ORIG_PATH_INFO! This is an edge case, and in most cases won't be necessary,
         // but we need to try it first, because on servers where REQUEST_URI does not work,
         // CI still thinks it worked, and doesn't check the alternatives.
         $path = isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : @getenv('ORIG_PATH_INFO');
         $path = substr($path, 0, 10) == '/index.php' ? substr($path, 10) : $path;
         $path = substr($path, 0, 1) == '/' ? substr($path, 1) : $path;
         # To fix another bug, we have to remove index.php from the thing completely. First, let's add a slash to the end if it needs one.
         $path = substr($path, -1) == '/' ? $path : $path . '/';
         $path = str_ireplace('/index.php/', '/', $path);
         # Now, let's see if the start of $path is in the end of $url.
         $strlen = strlen($path);
         while ($strlen > 0) {
             if (substr(BASE_URL, -$strlen) == substr($path, 0, $strlen)) {
                 $path = str_ireplace(substr($path, 0, $strlen), '', substr($path, 0, $strlen));
                 break;
             }
             $strlen--;
         }
         if (trim($path, '/') != '') {
             $this->uri_string = $path;
             return;
         }
     }
     parent::_fetch_uri_string();
     if (substr($this->uri_string, 0, 10) == 'index.php/') {
         $this->uri_string = substr($this->uri_string, 10);
     }
 }
Пример #2
0
 function _fetch_uri_string()
 {
     $base_url = $this->protocol() . '://';
     $base_url .= $this->host();
     $base_url .= parse_url($this->config->item('base_url'), PHP_URL_PATH);
     $this->config->set_item('base_url', $base_url);
     parent::_fetch_uri_string();
 }
Пример #3
0
 function uri_string()
 {
     $uri = parent::uri_string();
     $ci =& get_instance();
     if ($ci->tenant && $ci->tenant->id > 1) {
         $uri = preg_replace('/^\\/' . $ci->tenant->url_prefix . '/', '', $uri);
     }
     return $uri;
 }
Пример #4
0
 /**
  * Get the URI String
  *
  * @access	private
  * @return	string
  */
 function _fetch_uri_string()
 {
     log_message('debug', "MY URI - Hack for PHPUnit to run");
     if (ENVIRONMENT == 'testing') {
         $this->uri_string = '';
         return;
     }
     parent::_fetch_uri_string();
 }
Пример #5
0
 /**
  * Constructor
  *
  * gets proper linkage to URI items for 1.6.x
  *
  * @access	public
  */
 function MY_URI()
 {
     parent::CI_URI();
     log_message('debug', "URI Class Initialized");
     //query_string isn't in CI_URI
     if (isset($GLOBALS['IN'])) {
         $this->query_string =& $GLOBALS['IN']->QSTR;
         $this->page_query_string =& $GLOBALS['IN']->PAGE_QSTR;
     }
 }
Пример #6
0
 function _set_uri_string($str)
 {
     $this->original_uri = $str;
     $pos = strrpos($str, '.');
     $this->extension = pathinfo($str, PATHINFO_EXTENSION);
     $rpos = strrpos($str, '.');
     if ($rpos !== FALSE) {
         $str = substr($str, 0, $rpos);
     }
     parent::_set_uri_string($str);
 }
Пример #7
0
 public function rsegment($n, $no_result = NULL)
 {
     if (!is_numeric($n)) {
         if (array_key_exists($n, $this->uri_parameters)) {
             $n = $this->uri_parameters[$n];
         } else {
             return $no_result;
         }
     }
     return parent::rsegment($n, $no_result);
 }
Пример #8
0
 /**
  * Fetch uri string extension
  *
  * We hook into fetch_uri_string to look for a session id in the $_GET
  * array, before passing it on to CI to figure out a url. Doing it after
  * CI did not work with query strings and auto since key($_GET) comes out
  * as /S, which is not a good path
  *
  * @access	private
  * @return	void
  */
 function _fetch_uri_string()
 {
     $key = FALSE;
     if (is_array($_GET)) {
         if (isset($_GET['S'])) {
             $key = 'S';
         } elseif (trim(key($_GET), '/') == 'S') {
             $key = key($_GET);
         }
     }
     if ($key) {
         $val = $_GET[$key];
         unset($_GET[$key]);
         $x = explode('/', $val);
         // Set the session ID
         $this->session_id = array_shift($x);
         $leftovers = implode('/', $x);
         if ($leftovers) {
             $_GET = array($leftovers => '1') + $_GET;
         }
     }
     return parent::_fetch_uri_string();
 }
Пример #9
0
 /**
  * Constructor
  *
  * Rebuild the $_GET array.
  *
  */
 function MY_URI()
 {
     // Call the parent constructor
     parent::CI_URI();
     // On some server setups (including fosspass.org's own lighttpd 1.4 +
     // FastCGI), $_GET variables are a pain to get at. If $_GET isn't set,
     // try to rebuild it. This seems to happen especially when using
     // REQUEST_URI for URL routing
     if (!$_GET) {
         if (isset($_SERVER['QUERY_STRING']) and $_SERVER['QUERY_STRING'] != '') {
             // Get the query string from the $_SERVER array; simple enough
             $query_string = $_SERVER['QUERY_STRING'];
         } elseif (strpos($_SERVER['REQUEST_URI'], '?') !== false) {
             // Filter out what should be the query string from the full REQUEST_URI
             $query_string = substr(strstr($_SERVER['REQUEST_URI'], '?'), 1);
         } else {
             $query_string = null;
         }
         // There's probably no GET data to begin with...
         // Rebuild the $_GET array
         parse_str($query_string, $_GET);
     }
 }
Пример #10
0
 function MY_URI()
 {
     parent::CI_URI();
 }
Пример #11
0
 public function assoc_to_uri($data)
 {
     return '/' . parent::assoc_to_uri($data);
 }
Пример #12
0
 public function __construct()
 {
     parent::__construct();
     parse_str($_SERVER['QUERY_STRING'], $this->GET_params_arr);
 }
Пример #13
0
 public function __construct()
 {
     parent::__construct();
 }
Пример #14
0
 function MY_URI()
 {
     parent::__construct();
 }
Пример #15
0
 /**
  * Stores $_GET variables as $params, then wipes $_GET variables and calls parent constructor
  */
 public function __construct()
 {
     $this->params = $_GET;
     $_GET = null;
     parent::CI_URI();
 }
Пример #16
0
 function __construct()
 {
     parent::__construct();
     $this->languages = $this->config->item('i18n');
     $this->special = $this->config->item('special_url');
 }