本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}