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


PHP Server::redirect方法代码示例

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


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

示例1: action

 /**
  * request to load controller
  */
 static function action()
 {
     // benchmark
     $benchmark = new Benchmark();
     $benchmark->start();
     $request = new Request();
     $request->setBaseUri(Application::getBaseUrl());
     // auth checkc
     if (self::$auth) {
         foreach (self::$auth as $auth) {
             $auth->check($request->getUri());
         }
     }
     $routing = new Routing();
     if (!($data = $routing::getRouleClass($request->getUri()))) {
         if ($data = $routing::getRouleClass($request->getUri() . '/')) {
             Server::redirect(Application::getBaseUrl() . $request->getUri() . '/');
         }
     }
     if (empty($data)) {
         $data = array('class' => 'core:default:error_404');
     } else {
         if ($data['class'] == '') {
             $data = array('class' => 'core:default:index');
         }
     }
     // pearse class method
     if (preg_match("/^([0-9a-zA-Z\\-_]+):([0-9a-zA-Z\\-_]+):?([0-9a-zA-Z\\-_]*)\$/", $data['class'], $matchs)) {
         $project = $matchs[1];
         $class = $matchs[2];
         $method = $matchs[3];
         $method = !empty($method) ? $method : "index";
     } else {
         throw new PMPException('Error Class Method or Class Name(`' . $data['class'] . '` is not routing find).');
     }
     $benchmark->setMark("routing");
     try {
         $path = self::$source_dir . '/' . $project;
         $filename = $path . '/conf';
         dir_include_all($filename);
         $filename = $path . '/class';
         dir_include_all($filename);
         $filename = $path . '/controller/' . $class . '.php';
         if (file_exists($filename)) {
             include_once $filename;
         } else {
             $path = dirname(__FILE__) . '/../../component';
             $filename = $path . '/controller/' . $class . '.php';
             if (file_exists($filename)) {
                 include_once $filename;
             }
         }
         $classname = $class . 'Controller';
         $controller = new $classname($path, $class, $method, $project);
         $controller->addDefaultTemplatefiles(dirname(__FILE__) . '/../../component/view/form.tpl');
         $benchmark->setMark('included');
         if (isset($data['param'])) {
             $reflection = new \ReflectionClass($controller);
             $reflection_method = $reflection->getMethod($method);
             $params = array();
             foreach ($reflection_method->getParameters() as $key => $p) {
                 if (array_key_exists($p->getName(), $data['param'])) {
                     $params[$key] = $data['param'][$p->getName()];
                 } else {
                     if ($p->isDefaultValueAvailable()) {
                         $params[$key] = $p->getDefaultValue();
                     } else {
                         throw new PMPException(sprintf('Not Found Controller Paramater %s In %s', get_class($controller) . ':' . $method, $p->getName()));
                     }
                 }
             }
             call_user_func_array(array($controller, $method), $params);
         } else {
             $controller->{$method}();
         }
         $benchmark->setMark("action");
         $benchmark->stop();
         //$benchmark->display(false);
     } catch (\Exception $e) {
         throw new PMPException($e);
     }
 }
开发者ID:ateliee,项目名称:pmp,代码行数:85,代码来源:application.php

示例2: failedAuth

 /**
  *
  */
 public function failedAuth()
 {
     if ($this->failed_url) {
         Server::redirect($this->failed_url);
     }
 }
开发者ID:ateliee,项目名称:pmp,代码行数:9,代码来源:authManager.php

示例3: showContent

 /**
  * Returns the content, or, if streaming, shows what content we have added
  * and saves the footer for later.
  * @return unknown_type
  */
 public function showContent()
 {
     if (isset($this->authRequired) && $this->authRequired == true) {
         if (AuthUser::hasAuth()) {
             echo $this->content;
         } else {
             Server::redirect('/Home/login?r=' . $_SERVER['REQUEST_URI']);
         }
     } else {
         echo $this->content;
     }
     if ($this->stream_depth > 0) {
         ob_flush();
         flush();
         // Record the footer
         ob_start();
     }
 }
开发者ID:MrYogi,项目名称:hasoffers-promotional-platform,代码行数:23,代码来源:Templator.php


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