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


PHP Request::referer方法代码示例

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


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

示例1: filterMustBeCleared

 protected function filterMustBeCleared($options)
 {
     $current_path = $this->getComparisonPath($this->request->params);
     $referer_path = $this->getComparisonPath(Router::parse($this->request->referer(true)));
     if ($current_path == $referer_path) {
         return false;
     } else {
         $plugin = isset($this->request->params['plugin']) ? $this->request->params['plugin'] : null;
         $prefix = isset($this->request->params['prefix']) ? $this->request->params['prefix'] : null;
         $controller = $this->request->params['controller'];
         $action = $this->request->params['action'];
         $pass = isset($this->request->params['pass']) ? $this->request->params['pass'] : [];
         $query = isset($this->request->params['?']) ? $this->request->params['?'] : [];
         $referer = Router::parse($this->request->referer(true));
         $referer_plugin = isset($referer['plugin']) ? $referer['plugin'] : null;
         $referer_prefix = isset($referer['prefix']) ? $referer['prefix'] : null;
         $referer_controller = $referer['controller'];
         $referer_action = $referer['action'];
         $referer_pass = isset($referer['pass']) ? $referer['pass'] : [];
         $referer_query = isset($referer['?']) ? $referer['?'] : [];
         if ($plugin == $referer_plugin && $prefix == $referer_prefix && $controller == $referer_controller) {
             if (isset($options['keep_filter_actions']) && is_array($options['keep_filter_actions'])) {
                 if (in_array($referer_action, $options['keep_filter_actions'])) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:alaxos,项目名称:cakephp3-libs,代码行数:30,代码来源:FilterComponent.php

示例2: testRefererBasePath

 /**
  * Test referer() with a base path that duplicates the
  * first segment.
  *
  * @return void
  */
 public function testRefererBasePath()
 {
     $request = new Request('some/path');
     $request->url = 'users/login';
     $request->webroot = '/waves/';
     $request->base = '/waves';
     $request->here = '/waves/users/login';
     $request->env('HTTP_REFERER', Configure::read('App.fullBaseUrl') . '/waves/waves/add');
     $result = $request->referer(true);
     $this->assertSame('/waves/add', $result);
 }
开发者ID:alexunique0519,项目名称:Blog_Cakephp_association,代码行数:17,代码来源:RequestTest.php

示例3: referer

 /**
  * Returns the referring URL for this request.
  *
  * @param string|null $default Default URL to use if HTTP_REFERER cannot be read from headers
  * @param bool $local If true, restrict referring URLs to local server
  * @return string Referring URL
  */
 public function referer($default = null, $local = false)
 {
     if (!$this->request) {
         return Router::url($default, !$local);
     }
     $referer = $this->request->referer($local);
     if ($referer === '/' && $default && $default !== $referer) {
         return Router::url($default, !$local);
     }
     return $referer;
 }
开发者ID:Vibeosys,项目名称:RorderWeb,代码行数:18,代码来源:Controller.php

示例4: referer

 /**
  * Returns the referring URL for this request.
  *
  * @param string|array|null $default Default URL to use if HTTP_REFERER cannot be read from headers
  * @param bool $local If true, restrict referring URLs to local server
  * @return string Referring URL
  */
 public function referer($default = null, $local = false)
 {
     if (!$this->request) {
         return Router::url($default, !$local);
     }
     $referer = $this->request->referer($local);
     if ($referer === '/' && $default && $default !== $referer) {
         $url = Router::url($default, !$local);
         if ($local && $this->request->base && strpos($url, $this->request->base) === 0) {
             $url = substr($url, strlen($this->request->base));
             if ($url[0] !== '/') {
                 $url = '/' . $url;
             }
             return $url;
         }
         return $url;
     }
     return $referer;
 }
开发者ID:cakephp,项目名称:cakephp,代码行数:26,代码来源:Controller.php


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