pisethnam / phpmobilizer

Automatically exported from code.google.com/p/phpmobilizer
0 stars 0 forks source link

Very large error log each time mobile site is accessed #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the product are you using? On what operating system?
Latest version as of: 8th Sept 2010 on hostgator shared linux server using 
Apache 2.2.16 PHP version: 5.2.14

Additional information below.
Each time the mobile site is accessed is was getting error_log files as large 
as 300mb (which linux system wouldn't let me access to read them)
After adding this...

AddHandler custom-php .php .pcgi .phtml .inc .phtml~ .php~ .inc~ .html~
Action custom-php /cgi-sys/php5

To the .htaccess file

The error_log on each access to the site has been reduced to around 300kb but 
this is 300kb each time the mobile site is accessed.

The error log output is as follows:
[08-Sep-2010 11:00:23] PHP Warning:  
fopen(http://mysite.com/apicture.gif?url=apicture.gif) [<a 
href='function.fopen'>function.fopen</a>]: failed to open stream: Connection 
timed out in /home/myserver/public_html/m/phpmobilizer.class.php on line 35
[08-Sep-2010 11:00:23] PHP Warning:  feof(): supplied argument is not a valid 
stream resource in /home/myserver/public_html/m/phpmobilizer.class.php on line 
36
[08-Sep-2010 11:00:23] PHP Warning:  fgets(): supplied argument is not a valid 
stream resource in /home/myserver/public_html/m/phpmobilizer.class.php on line 
37

The latter two errors on lines 36 and 37 are repeated hundreds of times down 
the error log page.

Have checked php.ini file to make sure fopen setting are correct, php.ini file 
shows:
allow_url_fopen = On
allow_url_include = On

Original issue reported on code.google.com by terryhan...@yahoo.co.uk on 8 Sep 2010 at 4:14

GoogleCodeExporter commented 9 years ago
Same exact issue here, it happened so much and so fast that before I noticed it 
I was banned from the whole server while doing testing...

The main site in this case is a WordPress site with its standard SEO htaccess 
settings of:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Any help is greatly appreciated.

Original comment by IMakeTy...@gmail.com on 29 Jun 2011 at 11:49

GoogleCodeExporter commented 9 years ago
I have had the same problem with a huge error_log file being generated by the 
line-36-line-37 loop. In my particular case, the error seemed to be caused by 
users attempting to view forum postings which had been deleted. The point, 
though, was that "fopen" was returning "false" rather than the intended URL 
(or, rather, the text of the page at the intended URL).

I "fixed" the looping problem by inserting lines into the function in 
phpmobilizer.class.php which contained "line 35". The following starts at "line 
34":

 function loadData(){
    $fp=fopen($this->_url(), "r");

   // insert the following 'if' loop
   // to correct errors when the
   // target URL doesn't actually exist

     // if fopen has returned 'false'

     if (!$fp) {

       // then replace the 'false'
       // with your 404_error page
       // (replace examplified URL
       // with your page's URL)

         $fp=fopen("http://m.my_domain.com/404_error.htm", "r");

           // begin the regular "while" loop
           // to read in the 404_error page

             while(!feof($fp)){
             $this->html .= fgets($fp);
             }
             fclose($fp);
     }

     // else, if fopen has returned
     // valid webpage text...

     else {

       // ...do the regular thing:

             while(!feof($fp)){
             $this->html .= fgets($fp);
             }
             fclose($fp);
     }

     // following end-curly-brace
     // reflects edits; remove if
     // deleting if-else coding

   }

 }

I hope this can help others.

Original comment by stapel.p...@gmail.com on 29 Apr 2015 at 1:25