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


PHP URI::redirect方法代码示例

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


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

示例1: parse_uri

 /**
  *	\brief Lê a URLs (em modo re-write) e transforma em variáveis $_GET
  *
  *	\note Este método não retorna valor
  */
 public static function parse_uri($UriString = NULL)
 {
     // $_GET['_rw_'] é definida no .htaccess e contém a url em modo ReWrite
     if (NULL === $UriString) {
         $UriString = !empty($_GET['_rw_']) ? $_GET['_rw_'] : '';
         //unset($_GET['_rw_']);
     }
     // [pt-br] Processa a URI
     $Segments = array();
     self::$segments = array();
     //foreach(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $UriString)) as $val) {
     preg_match('/^([A-Za-z0-9_.\\-\\/]+)*[&]?/', $UriString, $UriString);
     if (isset($UriString[1])) {
         $UriString = $UriString[1];
         foreach (explode('/', $UriString) as $val) {
             $val = trim($val);
             if ($val != '') {
                 self::$segments[] = $val;
             }
         }
     }
     if (empty(self::$segments)) {
         self::$segments[] = 'index';
     }
     //Se suspeita de Big int > 8, Index
     foreach (self::$segments as $teste => $value) {
         if (is_numeric($value)) {
             $value = strlen($value);
             $valueLTRIM = strlen(ltrim($value, '0'));
             if ($value > 14 or $valueLTRIM > 16) {
                 Messages::getInstance()->error('URL inválida.');
                 URI::redirect(URI::build_url(array('.')));
             }
         }
     }
     // [pt-br] Guarda os parâmetros passados por GET na URL
     foreach ($_GET as $key => $value) {
         if ($key == '_rw_') {
             continue;
         }
         self::$get_params[$key] = $value;
         unset($_GET[$key]);
     }
     //Se suspeita de Big int > 8 , Index
     foreach (self::$get_params as $teste => $value) {
         if (is_numeric($value)) {
             $value = strlen($value);
             $valueLTRIM = strlen(ltrim($value, '0'));
             if ($value > 16 or $valueLTRIM > 16) {
                 Messages::getInstance()->error('Parâmetro inválido.');
                 URI::redirect(URI::build_url(array('.')));
             }
         }
     }
 }
开发者ID:sostenesgomes,项目名称:middleware-vtex,代码行数:60,代码来源:URI.php

示例2: default_dispatcher

 static function default_dispatcher()
 {
     if (Input::$AJAX && Input::$AJAX['widget']) {
         $widget = Widget::factory(Input::$AJAX['widget']);
         $method = 'on_' . (Input::$AJAX['object'] ?: 'unknown') . '_' . (Input::$AJAX['event'] ?: 'unknown');
         if (method_exists($widget, $method)) {
             Event::bind('system.output', 'Output::AJAX');
             $widget->{$method}();
         }
         return;
     }
     $args = Input::args();
     $default_page = Config::get('system.default_page');
     if (!$default_page) {
         $default_page = 'index';
     }
     //从末端开始尝试
     /*
     	home/page/edit.1
     	home/page/index.php Index_Controller::edit(1)
     	home/page/index.php Index_Controller::index('edit', 1)
     	home/page.php		Page_Controller::edit(1)
     	home/page.php		Page_Controller::index('edit', 1)
     */
     $file = end($args);
     if (!preg_match('/[^\\\\]\\./', $file)) {
         //有非法字符的只能是参数
         $path = implode('/', $args);
         // home/page/edit/index => index, NULL
         $candidates[($path ? $path . '/' : '') . $default_page] = array($default_page, NULL);
         $candidates[$path] = array($file, NULL);
         // home/page/edit => edit, NULL
     }
     if ($args) {
         $params = array_pop($args);
         $file = $args ? end($args) : $default_page;
         $path = $args ? implode('/', $args) : $default_page;
         $candidates[$path] = array($file, $params);
         // home/page.php => page, edit|1
     } else {
         $candidates[$default_page] = array($default_page, NULL);
     }
     $class = NULL;
     foreach ($candidates as $path => $candidate) {
         if (Core::load(CONTROLLER_BASE, $path)) {
             $class = str_replace('/', '_', $path);
             $params = array();
             if (preg_match_all('/(.*?[^\\\\])\\./', $candidate[1] . '.', $parts)) {
                 foreach ($parts[1] as $part) {
                     $params[] = strtr($part, array('\\.' => '.'));
                 }
             }
             Config::set('system.controller_path', $path);
             Config::set('system.controller_class', $class);
             break;
         }
     }
     if (!$class) {
         URI::redirect('error/404');
     }
     if (Input::$AJAX) {
         $class .= AJAX_SUFFIX;
         if (!class_exists($class, false)) {
             Core::load(CONTROLLER_BASE, 'ajax');
             $class = 'AJAX' . CONTROLLER_SUFFIX;
         }
         $controller = new $class();
         $object = Input::$AJAX['object'];
         $event = Input::$AJAX['event'];
         $method = $params[0];
         if (!$method || $method[0] == '_') {
             $method = 'index_';
         }
         $method .= '_' . ($object ? $object . '_' : '') . $event;
         if (method_exists($controller, $method)) {
             array_shift($params);
         } else {
             $method = 'index_' . ($object ? $object . '_' : '') . $event;
             if (!method_exists($controller, $method)) {
                 $method = NULL;
             }
         }
         if ($method) {
             Controller::$CURRENT = $controller;
             Config::set('system.controller_method', $method);
             Config::set('system.controller_params', $params);
             $controller->_before_call($method, $params);
             call_user_func_array(array($controller, $method), $params);
             $controller->_after_call($method, $params);
         }
     } else {
         $class .= CONTROLLER_SUFFIX;
         $controller = new $class();
         $method = $params[0];
         if ($method && $method[0] != '_' && method_exists($controller, $method)) {
             array_shift($params);
         } elseif ($method && $method[0] != '_' && method_exists($controller, 'do_' . $method)) {
             $method = 'do_' . $method;
             array_shift($params);
         } else {
//.........这里部分代码省略.........
开发者ID:pihizi,项目名称:qf,代码行数:101,代码来源:core.php


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