Claudia Posted April 19, 2023 Share Posted April 19, 2023 I keep getting these 2 PHP Warnings in my error log. Just today (19th) over 200 of them [19-Apr-2023 08:58:18 America/Louisville] PHP Warning: Undefined array key "HTTP_USER_AGENT" in /home/xxxxxx/public_html/classes/session.class.php on line 676 [19-Apr-2023 08:58:18 America/Louisville] PHP Warning: Undefined array key "_g" in /home/xxxxxx/public_html/classes/ssl.class.php on line 39 Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 19, 2023 Share Posted April 19, 2023 You have a busy site! The first is because CubeCart assumes everything that makes a call to your site will announce what it is - a header called the User-Agent-String. But this bit of info is not always present. Basically, these are two cases of many where PHP 8+ now makes Warning complaints where they were Notices before. Until the next version of CubeCart comes out, these edits will silence PHP complaining about these particular statements: /classes/ssl.class.php, line 39, from: if ($GLOBALS['config']->get('config', 'ssl') && !ADMIN_CP && !CC_SSL && !in_array($_GET['_g'], $this->_ignored_pages)) { To: if (isset($_GET['_g']) && $GLOBALS['config']->get('config', 'ssl') && !ADMIN_CP && !CC_SSL && !in_array($_GET['_g'], $this->_ignored_pages)) { /classes/session.class.php, line 676, from: return strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') ? 'IEX' : htmlspecialchars($_SERVER['HTTP_USER_AGENT']); To: return strpos(($_SERVER['HTTP_USER_AGENT'] ?? "Not Available"), 'Trident') ? 'IEX' : htmlspecialchars($_SERVER['HTTP_USER_AGENT'] ?? "Not Available"); Quote Link to comment Share on other sites More sharing options...
Claudia Posted April 19, 2023 Author Share Posted April 19, 2023 Thanks Brian! "You have a busy site" Most of it is probably me adding new products. LOL Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 19, 2023 Share Posted April 19, 2023 But, the browser you are using probably does send a User-Agent-String. As well as all your valid visitors. So, that means there are automated scanners hitting your site that does not send this header. Mostly unknown search engines? Quote Link to comment Share on other sites More sharing options...
Claudia Posted April 21, 2023 Author Share Posted April 21, 2023 Made changes now I get this [21-Apr-2023 10:06:46 America/Louisville] PHP Warning: Undefined array key "HTTP_USER_AGENT" in /home/xxxxxx/public_html/classes/user.class.php on line 719 Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 21, 2023 Share Posted April 21, 2023 in /classes/user.class.php: Near lines 719-721, from: $agent = strtolower($_SERVER['HTTP_USER_AGENT']); foreach ($this->_bot_sigs as $signature) { if (strpos($agent, $signature) !== false) { To: $agent = strtolower($_SERVER['HTTP_USER_AGENT'] ?? ""); foreach ($this->_bot_sigs as $signature) { if (empty($agent) || (strpos($agent, $signature) !== false)) { This change will use an empty string if a User-Agent-String was not provided. Then, not having provided a User-Agent-String, it will be assumed that this is not a real customer. Quote Link to comment Share on other sites More sharing options...
Claudia Posted April 21, 2023 Author Share Posted April 21, 2023 Thanks Brian! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.