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


PHP CakeRequest::referer方法代码示例

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


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

示例1: beforeSave

 /**
  * beforeSave is called before a model is saved. Returning false from a beforeSave callback
  * will abort the save operation.
  *
  * @param Model $model Model using this behavior
  * @param array $options Options passed from Model::save().
  *
  * @return mixed|void
  */
 public function beforeSave(\Model $model, $options = array())
 {
     parent::beforeSave($model);
     $request = new CakeRequest();
     $data = ['blog' => urlencode(Configure::read('General.site_url')), 'user_ip' => urlencode($model->data[$model->alias]['author_ip']), 'user_agent' => urlencode($model->data[$model->alias]['agent']), 'referrer' => urlencode($request->referer()), 'permalink' => urlencode($request->referer()), 'comment_type' => urlencode('comment'), 'comment_author' => urlencode($model->data[$model->alias]['author']), 'comment_author_email' => urlencode($model->data[$model->alias]['author_email']), 'comment_author_url' => urlencode($model->data[$model->alias]['author_url']), 'comment_content' => urlencode($model->data[$model->alias]['content'])];
     if (Akismet::isSpam($data, Configure::read('Akismet.api_key'))) {
         $model->data[$model->alias]['status'] = 'spam';
     }
 }
开发者ID:atkrad,项目名称:akismet,代码行数:18,代码来源:AkismetBehavior.php

示例2: referer

 /**
  * Returns the referring URL for this request.
  *
  * @param string $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
  * @link http://book.cakephp.org/2.0/en/controllers.html#Controller::referer
  */
 public function referer($default = null, $local = false)
 {
     if (!$this->request) {
         return '/';
     }
     $referer = $this->request->referer($local);
     if ($referer === '/' && $default && $default !== $referer) {
         return Router::url($default, !$local);
     }
     return $referer;
 }
开发者ID:amysupeta,项目名称:Exame1,代码行数:19,代码来源:Controller.php

示例3: testRefererBasePath

 /**
  * Test referer() with a base path that duplicates the
  * first segment.
  *
  * @return void
  */
 public function testRefererBasePath()
 {
     $request = new CakeRequest('some/path');
     $request->url = 'users/login';
     $request->webroot = '/waves/';
     $request->base = '/waves';
     $request->here = '/waves/users/login';
     $_SERVER['HTTP_REFERER'] = FULL_BASE_URL . '/waves/waves/add';
     $result = $request->referer(true);
     $this->assertSame($result, '/waves/add');
 }
开发者ID:xMyThoLoGyx,项目名称:centremedicaletp3,代码行数:17,代码来源:CakeRequestTest.php

示例4: testReferer

 /**
  * test the referer function.
  *
  * @return void
  */
 public function testReferer()
 {
     $request = new CakeRequest('some/path');
     $request->webroot = '/';
     $_SERVER['HTTP_REFERER'] = 'http://cakephp.org';
     $result = $request->referer();
     $this->assertSame($result, 'http://cakephp.org');
     $_SERVER['HTTP_REFERER'] = '';
     $result = $request->referer();
     $this->assertSame($result, '/');
     $_SERVER['HTTP_REFERER'] = FULL_BASE_URL . '/some/path';
     $result = $request->referer(true);
     $this->assertSame($result, '/some/path');
     $_SERVER['HTTP_REFERER'] = FULL_BASE_URL . '/some/path';
     $result = $request->referer(false);
     $this->assertSame($result, FULL_BASE_URL . '/some/path');
     $_SERVER['HTTP_REFERER'] = FULL_BASE_URL . '/some/path';
     $result = $request->referer(true);
     $this->assertSame($result, '/some/path');
     $_SERVER['HTTP_REFERER'] = FULL_BASE_URL . '/recipes/add';
     $result = $request->referer(true);
     $this->assertSame($result, '/recipes/add');
     $_SERVER['HTTP_X_FORWARDED_HOST'] = 'cakephp.org';
     $result = $request->referer();
     $this->assertSame($result, 'cakephp.org');
 }
开发者ID:nabeelio,项目名称:CakePHP-Base,代码行数:31,代码来源:CakeRequestTest.php

示例5: getReferer

 /**
  * Gets the server name from which this request was referred
  *
  * @return string Server address
  * @deprecated use $this->request->referer() from your controller instead
  */
 public function getReferer()
 {
     return $this->request->referer(false);
 }
开发者ID:rednazj,项目名称:Inventory,代码行数:10,代码来源:RequestHandlerComponent.php

示例6: _get_request

 /**
  * @param $data
  *
  * @return mixed
  */
 protected function _get_request($data)
 {
     $request = new CakeRequest();
     $data['request_user_agent'] = $request::header('User-Agent');
     $data['request_client_ip'] = $request->clientIp();
     $data['request_method'] = $request->method();
     $data['request_referer'] = $request->referer();
     $data['request_url'] = Router::url(null, true);
     return $data;
 }
开发者ID:andtxr,项目名称:cakephp-log,代码行数:15,代码来源:LogBehavior.php

示例7: getReferer

 /**
  * Gets the server name from which this request was referred
  *
  * @return string Server address
  * @deprecated 3.0.0 Use $this->request->referer() from your controller instead
  */
 public function getReferer()
 {
     return $this->request->referer(FALSE);
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:10,代码来源:RequestHandlerComponent.php


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