Jump to content

I keep getting these 2 Warnings in error log


Claudia

Recommended Posts

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

Link to comment
Share on other sites

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");

 

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...