From 5b886f9ae101069e63781978fea36fbd2c0a863a Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 16 Sep 2007 15:40:27 +0000 Subject: [PATCH] mlanthaler: Bugfix: Fixed "FATAL ERROR: get_browser() [function.get-browser]: browscap ini directive not set" and some E_NOTICE errors. @Quin: Maybe you should implement some fail-back function for get_browser that evaluates the HTTP user agent header (browscap.ini is often not available!). a (merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@42099 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/PageView.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/model/PageView.php b/core/model/PageView.php index 11f0d6830..07fee72d2 100644 --- a/core/model/PageView.php +++ b/core/model/PageView.php @@ -33,10 +33,11 @@ class PageView extends DataObject { static $defaults = array(); - protected $hitdata; + protected $hitdata = null; function init() { - $this->hitdata = get_browser(null, true); + if($hitdata = @get_browser(null, true)) + $this->hitdata = get_browser(null, true); } function record() { @@ -55,12 +56,16 @@ class PageView extends DataObject { } function setBrowser() { - $this->setField('Browser', $this->hitdata['browser']); - $this->setField('BrowserVersion', $this->hitdata['version']); + if(isset($this->hitdata['browser'])) + $this->setField('Browser', $this->hitdata['browser']); + + if(isset($this->hitdata['version'])) + $this->setField('BrowserVersion', $this->hitdata['version']); } function setOS() { - $this->setField('OS', $this->hitdata['platform']); + if(isset($this->hitdata['platform'])) + $this->setField('OS', $this->hitdata['platform']); } function setUserID() { @@ -79,7 +84,7 @@ class PageView extends DataObject { } function setIP() { - if ($_SERVER['HTTP_X_FORWARDED_FOR']){ + if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; @@ -90,4 +95,4 @@ class PageView extends DataObject { } -?> +?> \ No newline at end of file