Site Problems -URGENT

User avatar
Duncan
Posts: 405
Joined: Sun Apr 10, 2005 7:22 pm

Site Problems -URGENT

Postby Duncan » Tue Dec 09, 2008 6:48 pm

From our host,

You have a PHP file template that is programmed incorrectly and is
causing very high server load issues. Please have your webmaster fix
this ASAP, the two repeating errors are below. The errors happen every
second over and over. Please fix this ASAP as I was forced to
suspend your site as this error will use up server resources and
possibly crash the server. Please confirm once this has been fixed.

[Tue Dec 9 10:10:22 2008] [error] PHP Warning: feof(): supplied
argument is not a valid stream resource in
/home/forest/public_html/templates/forestsite/index.php on line 75
[Tue Dec 9 10:10:22 2008] [error] PHP Warning: fgets(): supplied
argument is not a valid stream resource in
/home/forest/public_html/templates/forestsite/index.php on line 76


I've had a quick look myself and can't see the problem, but I have no experience of PHP.
0 x
I love the bomb.

User avatar
milk
Posts: 1798
Joined: Wed Apr 18, 2007 12:02 pm
Location: Edinburgh, UK
Contact:

Re: Site Problems -URGENT

Postby milk » Tue Dec 09, 2008 6:59 pm

weird. this related to the banner script that selects a random <img src=..etc...> from http://www.theforest.org.uk/images/stor ... random.txt.

the code is thus;

Code: Select all

<?php
// load the file that contains the images
$adfile = "http://www.theforest.org.uk/images/stories/site_images/headers/top_random.txt";
$ads = array();
// one line per image
$fh = fopen($adfile, "r");
while(!feof($fh)) {
  $line = fgets($fh, 10240);
  $line = trim($line);
  if($line != "") {
    $ads[] = $line;
  }
}
// randomly pick an image
$num = count($ads);
$idx = rand(0, $num-1);
echo $ads[$idx];
?>


it hasn't been touched recently, not have top_random.txt or the images themselves (their perms are 644). my php skills are basic - can someone tell if the code is correct? php is still at 4.4.7. duncan has asked and we're waiting to hear when the problem started. i've commented it out for now leaving a banner sized gap on every forest site page.
0 x
hey, if you don't like it, post on the BB (so you can ask about participating for better) | MilkMiruku

User avatar
ChaoticReality
Posts: 1111
Joined: Sun Nov 23, 2008 10:16 am
Location: Edinburgh!
Contact:

Re: Site Problems -URGENT

Postby ChaoticReality » Wed Dec 10, 2008 1:07 am

Argh, the non-relative links, they hurt my eyes!

Seriously, though, it looks like PHP, for whatever reason, is unable to read the top_random file anymore. It may be that its HTTP transport has been turned off for whatever reason, or that an apache or php config file has changed (nothing to do with us).

The solution should be to change this line:
$adfile = "http://www.theforest.org.uk/images/stories/site_images/headers/top_random.txt";

To one with a relative link (I guess this will be right, pathwise):
$adfile = "images/stories/site_images/headers/top_random.txt";



If the forest site is database driven, which I assume it must be, due to the use of Drupal, it would be nice if we could move this to a database instead and then we can use SQL to select a random record/banner.
0 x
Mike

Dawnsio 'mlaen i'r gwres prynhawn a rwy'n addo erbyn yfori byddai wedi mynd, hwyl fawr i pawb, hwyl fawr i pawb...

User avatar
milk
Posts: 1798
Joined: Wed Apr 18, 2007 12:02 pm
Location: Edinburgh, UK
Contact:

Re: Site Problems -URGENT

Postby milk » Wed Dec 10, 2008 2:01 am

the current site uses joomla (*spit*), but there are db driven rotating banner modules available for drupal.
0 x
hey, if you don't like it, post on the BB (so you can ask about participating for better) | MilkMiruku

User avatar
ChaoticReality
Posts: 1111
Joined: Sun Nov 23, 2008 10:16 am
Location: Edinburgh!
Contact:

Re: Site Problems -URGENT

Postby ChaoticReality » Wed Dec 10, 2008 2:06 am

Awesome.

Until then, should we try the fix I posted above?
0 x
Mike

Dawnsio 'mlaen i'r gwres prynhawn a rwy'n addo erbyn yfori byddai wedi mynd, hwyl fawr i pawb, hwyl fawr i pawb...

User avatar
milk
Posts: 1798
Joined: Wed Apr 18, 2007 12:02 pm
Location: Edinburgh, UK
Contact:

Re: Site Problems -URGENT

Postby milk » Wed Dec 10, 2008 5:26 am

i'll give it a go and ask the admin to uncomment the section at his leasure so he can check the log files in case the problem remains.

ChaoticReality wrote:The solution should be to change this line:
$adfile = "http://www.theforest.org.uk/images/stories/site_images/headers/top_random.txt";

To one with a relative link (I guess this will be right, pathwise):
$adfile = "images/stories/site_images/headers/top_random.txt";


$adfile = "images/stories/site_images/headers/top_random.txt";

as the problem php file is at /home/forest/public_html/templates/forestsite/index.php, would it not instead be "$adfile = "../../images/stories/site_images/headers/top_random.txt";"? i'm drunk, rather tired and can't entirly remember how php treats relative paths from included files so thought i'd check ;)
0 x
hey, if you don't like it, post on the BB (so you can ask about participating for better) | MilkMiruku

User avatar
ChaoticReality
Posts: 1111
Joined: Sun Nov 23, 2008 10:16 am
Location: Edinburgh!
Contact:

Re: Site Problems -URGENT

Postby ChaoticReality » Wed Dec 10, 2008 5:54 am

Yup, it would be. Silly me for not looking at the path of the file causing the error.
0 x
Mike

Dawnsio 'mlaen i'r gwres prynhawn a rwy'n addo erbyn yfori byddai wedi mynd, hwyl fawr i pawb, hwyl fawr i pawb...

User avatar
Duncan
Posts: 405
Joined: Sun Apr 10, 2005 7:22 pm

Re: Site Problems -URGENT

Postby Duncan » Wed Dec 10, 2008 11:45 am

Sounds good. I got as far as figuring that line, and the random file seems intact, so no more idea. Must be some other config thing like Chaotic suggests.

Milk, not sure if you've been in touch with the admin already so I'll leave it to you to make the change and let him know.

Nice.
0 x
I love the bomb.

User avatar
milk
Posts: 1798
Joined: Wed Apr 18, 2007 12:02 pm
Location: Edinburgh, UK
Contact:

Re: Site Problems -URGENT

Postby milk » Wed Dec 10, 2008 4:46 pm

my e-mail;

Hello Barnabas,

I commented out the offending code yesterday and double checked with some folks via out forum. The only thing noted was the use of an absolute rather than relitive path to point to the banner rotation img src txt file which has now been changed. I've left the whole banner section (starting around line 70 in /public_html/templates/forestsite/index.php) commented out - if you could uncomment and hit the page to see if any error is logged at your leasure.

Nothing has been added to the site recently so we're not expecting any above average traffic coming in. Do the logs show it as having been an issue priot to yesterday? Has there been any change to the server in the last three or four days that might have had an unepected knock on effect? Another strange factor is that the banner rotation appeard to be working when I checked the site just before the commenting out so the script wasn't dying everytime, just on certain occasions. Did the error register with hits to any specific page, or from any certain IP range? Maybe a search engine bot somehow got the direct url of the banner include file and was triggering it while spidering? If this could be the case, I could make a change to robots.txt.

Thanks for your help,
milky.x
0 x
hey, if you don't like it, post on the BB (so you can ask about participating for better) | MilkMiruku

User avatar
ChaoticReality
Posts: 1111
Joined: Sun Nov 23, 2008 10:16 am
Location: Edinburgh!
Contact:

Re: Site Problems -URGENT

Postby ChaoticReality » Tue Dec 16, 2008 6:42 am

Did we get a reply as to whether the fix worked?
0 x
Mike

Dawnsio 'mlaen i'r gwres prynhawn a rwy'n addo erbyn yfori byddai wedi mynd, hwyl fawr i pawb, hwyl fawr i pawb...

User avatar
Duncan
Posts: 405
Joined: Sun Apr 10, 2005 7:22 pm

Re: Site Problems -URGENT

Postby Duncan » Tue Dec 16, 2008 1:45 pm

Milk mailed Barnabas the admin but I think he's still left it commented out for now. To be honest I'd be tempted to do the same in his position. I think I'll progress things by asking about a shift to PHP 5.
0 x
I love the bomb.

User avatar
milk
Posts: 1798
Joined: Wed Apr 18, 2007 12:02 pm
Location: Edinburgh, UK
Contact:

Re: Site Problems -URGENT

Postby milk » Tue Dec 16, 2008 9:12 pm

a msg from Barnabas, sent this afternoon;

"I looked into this once I received your message but I noticed nothing out of the ordinary. The one thing I did notice and block via the firewall was an IP from the UK that was requesting the same set of pages on your site every second over and over."

i've replied with "A-ha, very strange.. Could I ask what the offending IP was, and was there a user agent string along with it in the logs? Thanks very much again for your help."
0 x
hey, if you don't like it, post on the BB (so you can ask about participating for better) | MilkMiruku

User avatar
milk
Posts: 1798
Joined: Wed Apr 18, 2007 12:02 pm
Location: Edinburgh, UK
Contact:

Re: Site Problems -URGENT

Postby milk » Tue Dec 16, 2008 10:24 pm

"My servers blacklist and un-list hundreds of IPs daily so I do not keep a log. I do know that the IP resolved to a .uk address."

ah well.
0 x
hey, if you don't like it, post on the BB (so you can ask about participating for better) | MilkMiruku

User avatar
Duncan
Posts: 405
Joined: Sun Apr 10, 2005 7:22 pm

Re: Site Problems -URGENT

Postby Duncan » Fri Dec 19, 2008 4:57 pm

In response to PHP5 query, Barnabas asks, will we be needing MySQL 5 as well ?
0 x
I love the bomb.

User avatar
milk
Posts: 1798
Joined: Wed Apr 18, 2007 12:02 pm
Location: Edinburgh, UK
Contact:

Re: Site Problems -URGENT

Postby milk » Sat Dec 20, 2008 4:30 pm

i think it would be worth it. more and more systems will start requiring mysql 5 in the next year or so (i.e., as drupal 7). thoughts anyone else?
0 x
hey, if you don't like it, post on the BB (so you can ask about participating for better) | MilkMiruku

User avatar
ChaoticReality
Posts: 1111
Joined: Sun Nov 23, 2008 10:16 am
Location: Edinburgh!
Contact:

Re: Site Problems -URGENT

Postby ChaoticReality » Sat Dec 20, 2008 5:08 pm

Yes. Up to date stuff is good. Old stuff is bad, has security holes and doesn't get patched.
0 x
Mike

Dawnsio 'mlaen i'r gwres prynhawn a rwy'n addo erbyn yfori byddai wedi mynd, hwyl fawr i pawb, hwyl fawr i pawb...


Return to “Website/Online”

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron