diff options
author | Andrey Andreev <narf@devilix.net> | 2013-07-20 21:09:50 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2013-07-20 21:09:50 +0200 |
commit | 2aa622c37e4e67dd28cbafdc9da14134293479ad (patch) | |
tree | 08fd91d54eb7269c4669132ad3004a0771e884d4 /system/libraries | |
parent | 3d3e250e40e2f844424a7984488f6dd89495fa5f (diff) | |
parent | c05ab73237a536802e224b6e8d3a90157eb1b51a (diff) |
Merge pull request #2543 from vlakoff/develop-3
User_agent library: robuster detection in is_referral()
Diffstat (limited to 'system/libraries')
-rw-r--r-- | system/libraries/User_agent.php | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 2f6f81909..50ac9be98 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -471,13 +471,24 @@ class CI_User_agent { */ public function is_referral() { - if (empty($_SERVER['HTTP_REFERER'])) + static $result; + + if ( ! isset($result)) { - return FALSE; + if (empty($_SERVER['HTTP_REFERER'])) + { + $result = FALSE; + } + else + { + $referer_host = @parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST); + $own_host = parse_url(config_item('base_url'), PHP_URL_HOST); + + $result = ($referer_host && $referer_host !== $own_host); + } } - $referer = parse_url($_SERVER['HTTP_REFERER']); - return ! (empty($referer['host']) && strpos(config_item('base_url'), $referer['host']) !== FALSE); + return $result; } // -------------------------------------------------------------------- |