diff options
author | vlakoff <vlakoff@gmail.com> | 2013-07-20 20:27:57 +0200 |
---|---|---|
committer | vlakoff <vlakoff@gmail.com> | 2013-07-20 20:27:57 +0200 |
commit | c05ab73237a536802e224b6e8d3a90157eb1b51a (patch) | |
tree | 08fd91d54eb7269c4669132ad3004a0771e884d4 /system/libraries | |
parent | 161f1935d72dadb12da1a314a91f5da75826b391 (diff) |
Cache result of is_referral()
Diffstat (limited to 'system/libraries')
-rw-r--r-- | system/libraries/User_agent.php | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index e27004e9e..50ac9be98 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -471,15 +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); - $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); + } + } - return ($referer_host && $referer_host !== $own_host); + return $result; } // -------------------------------------------------------------------- |