本文整理汇总了PHP中Utility::getReferer方法的典型用法代码示例。如果您正苦于以下问题:PHP Utility::getReferer方法的具体用法?PHP Utility::getReferer怎么用?PHP Utility::getReferer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utility
的用法示例。
在下文中一共展示了Utility::getReferer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetReferer
/**
* UtilityTest::testGetReferer()
*
* @covers Utility::getReferer
* @return void
*/
public function testGetReferer()
{
$res = Utility::getReferer();
$this->assertEquals(env('HTTP_REFERER'), $res);
$res = Utility::getReferer(true);
$this->assertEquals(env('HTTP_REFERER'), $res);
$_SERVER['HTTP_REFERER'] = '/foo/bar';
$res = Utility::getReferer(true);
$base = Configure::read('App.fullBaseUrl');
if (!$base) {
$base = 'http://localhost';
}
$this->assertEquals($base . env('HTTP_REFERER'), $res);
}
示例2: traceDetails
/**
* Append some more infos to better track down the error
*
* @return string
*/
public static function traceDetails()
{
if (empty($_SERVER['REQUEST_URI']) || strpos($_SERVER['REQUEST_URI'], '/test.php?') === 0) {
return null;
}
$currentUrl = Router::url();
//isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : 'n/a';
$refererUrl = Utility::getReferer();
//Router::getRequest()->url().'
$uid = !empty($_SESSION) && !empty($_SESSION['Auth']['User']['id']) ? $_SESSION['Auth']['User']['id'] : null;
$data = array(@CakeRequest::clientIp(), $currentUrl . (!empty($refererUrl) ? ' (' . $refererUrl . ')' : ''), $uid, env('HTTP_USER_AGENT'));
return implode(' - ', $data);
}
示例3: _logAttempt
/**
* Logs attempts
*
* @param bool ErrorsOnly (only if error occured, otherwise always)
* @returns null if not logged, true otherwise
*/
protected function _logAttempt($errorsOnly = true)
{
if ($errorsOnly === true && empty($this->error) && empty($this->internalError)) {
return null;
}
if (!$this->settings[$this->Model->alias]['log']) {
return null;
}
$msg = 'IP \'' . Utility::getClientIp() . '\', Agent \'' . env('HTTP_USER_AGENT') . '\', Referer \'' . env('HTTP_REFERER') . '\', Host-Referer \'' . Utility::getReferer() . '\'';
if (!empty($this->error)) {
$msg .= ', ' . $this->error;
}
if (!empty($this->internalError)) {
$msg .= ' (' . $this->internalError . ')';
}
$this->log($msg, 'captcha');
return true;
}
示例4: getReferer
/**
* get the current referer
* @param bool $full (defaults to false and leaves the url untouched)
* @return string $referer (local or foreign)
* 2011-11-02 ms
*/
public static function getReferer($full = false)
{
return Utility::getReferer($full);
}