summaryrefslogtreecommitdiffstats
path: root/system/libraries/User_agent.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2013-07-20 21:09:50 +0200
committerAndrey Andreev <narf@devilix.net>2013-07-20 21:09:50 +0200
commit2aa622c37e4e67dd28cbafdc9da14134293479ad (patch)
tree08fd91d54eb7269c4669132ad3004a0771e884d4 /system/libraries/User_agent.php
parent3d3e250e40e2f844424a7984488f6dd89495fa5f (diff)
parentc05ab73237a536802e224b6e8d3a90157eb1b51a (diff)
Merge pull request #2543 from vlakoff/develop-3
User_agent library: robuster detection in is_referral()
Diffstat (limited to 'system/libraries/User_agent.php')
-rw-r--r--system/libraries/User_agent.php19
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;
}
// --------------------------------------------------------------------