notice: Undefined index: HTTP_USER_AGENT

Support help forum dedicated to free and commerical templates for Joomla 3 and 2.5 version.
GK User
Sun Dec 02, 2012 1:57 pm
I have gk_sporter template and since i moved to a new host who have error reporting on i see sometimes these messages. I googled these and i found out that when some users or bots dont send correct "signals" to site or something the website doesnt know what version of browser to use and shows these messages. Unfortunately i cant find a solution... Any help out there?

Notice: Undefined index: HTTP_USER_AGENT in /var/www/clients/client1/web1/web/templates/gk_sporter/libs/gk.template.helper.php on line 363

Notice: Undefined index: HTTP_USER_AGENT in /var/www/clients/client1/web1/web/templates/gk_sporter/libs/mobile_device_detect.php on line 4

Notice: Undefined index: HTTP_USER_AGENT in /var/www/clients/client1/web1/web/templates/gk_sporter/libs/gk.template.helper.php on line 363

Notice: Undefined index: HTTP_USER_AGENT in /var/www/clients/client1/web1/web/templates/gk_sporter/libs/mobile_device_detect.php on line 4
User avatar
Fresh Boarder

GK User
Sun Dec 02, 2012 7:22 pm
Hi,

The fastest solution is disable notices in the php.ini file. We will add additional check for the HTTP_USER_AGENT variable in the next update.
User avatar
Administrator

GK User
Mon Dec 03, 2012 9:13 pm
dziudek wrote:Hi,

The fastest solution is disable notices in the php.ini file. We will add additional check for the HTTP_USER_AGENT variable in the next update.


Thanks for the quick reply but my web host insist that these errors cause high server load peaks and asks me to fix them. Any advice on this?

Thanks
User avatar
Fresh Boarder

GK User
Tue Dec 04, 2012 10:58 am
Please open file /templates/gk_sporter/libs/gk.template.helper.php and line 363 replace :

Code: Select all
function mobile_device_detect () {
      require_once ('mobile_device_detect.php');
      //bypass special browser:
      $special = array('jigs', 'w3c ', 'w3c-', 'w3c_');      
      if (in_array(strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4)), $special)) return false;
      return mobile_device_detect('iphone','android','opera','blackberry','palm','windows');
   }


with :

Code: Select all
function mobile_device_detect () {
      require_once ('mobile_device_detect.php');
      //bypass special browser:
      $special = array('jigs', 'w3c ', 'w3c-', 'w3c_');   
      if(isset($_SERVER['HTTP_USER_AGENT'])) {
         if (in_array(strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4)), $special)) return false;
      }
      return mobile_device_detect('iphone','android','opera','blackberry','palm','windows');
   }


then open the second file (templates/gk_sporter/libs/mobile_device_detect.php) and in line 4 replace :

Code: Select all
$useragent=$_SERVER['HTTP_USER_AGENT'];


with :

Code: Select all
if(isset($_SERVER['HTTP_USER_AGENT'])) {
      $useragent=$_SERVER['HTTP_USER_AGENT'];
   } else {
      $useragent='chrome';
   }
User avatar
Platinum Boarder

GK User
Tue Dec 04, 2012 12:28 pm
It seems the problem solved after following your instructions.

Thank you very much!
User avatar
Fresh Boarder


cron