Forest BB

The digital grapevine of The Forest.
It is currently Thu Apr 24, 2014 10:24 pm

All times are UTC




Post new topic Reply to topic  [ 16 posts ] 
Author Message
 Post subject: Site Problems -URGENT
PostPosted: Tue Dec 09, 2008 6:48 pm 
Offline
User avatar

Joined: Sun Apr 10, 2005 7:22 pm
Posts: 405
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.

_________________
I love the bomb.


Top
 Profile  
 
PostPosted: Tue Dec 09, 2008 6:59 pm 
Offline
User avatar

Joined: Wed Apr 18, 2007 12:02 pm
Posts: 1798
Location: Edinburgh, UK
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:
<?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.

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


Top
 Profile  
 
PostPosted: Wed Dec 10, 2008 1:07 am 
Offline
User avatar

Joined: Sun Nov 23, 2008 10:16 am
Posts: 1111
Location: Edinburgh!
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.

_________________
Mike

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


Top
 Profile  
 
PostPosted: Wed Dec 10, 2008 2:01 am 
Offline
User avatar

Joined: Wed Apr 18, 2007 12:02 pm
Posts: 1798
Location: Edinburgh, UK
the current site uses joomla (*spit*), but there are db driven rotating banner modules available for drupal.

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


Top
 Profile  
 
PostPosted: Wed Dec 10, 2008 2:06 am 
Offline
User avatar

Joined: Sun Nov 23, 2008 10:16 am
Posts: 1111
Location: Edinburgh!
Awesome.

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

_________________
Mike

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


Top
 Profile  
 
PostPosted: Wed Dec 10, 2008 5:26 am 
Offline
User avatar

Joined: Wed Apr 18, 2007 12:02 pm
Posts: 1798
Location: Edinburgh, UK
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 ;)

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


Top
 Profile  
 
PostPosted: Wed Dec 10, 2008 5:54 am 
Offline
User avatar

Joined: Sun Nov 23, 2008 10:16 am
Posts: 1111
Location: Edinburgh!
Yup, it would be. Silly me for not looking at the path of the file causing the error.

_________________
Mike

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


Top
 Profile  
 
PostPosted: Wed Dec 10, 2008 11:45 am 
Offline
User avatar

Joined: Sun Apr 10, 2005 7:22 pm
Posts: 405
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.

_________________
I love the bomb.


Top
 Profile  
 
PostPosted: Wed Dec 10, 2008 4:46 pm 
Offline
User avatar

Joined: Wed Apr 18, 2007 12:02 pm
Posts: 1798
Location: Edinburgh, UK
my e-mail;

Quote:
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

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


Top
 Profile  
 
PostPosted: Tue Dec 16, 2008 6:42 am 
Offline
User avatar

Joined: Sun Nov 23, 2008 10:16 am
Posts: 1111
Location: Edinburgh!
Did we get a reply as to whether the fix worked?

_________________
Mike

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


Top
 Profile  
 
PostPosted: Tue Dec 16, 2008 1:45 pm 
Offline
User avatar

Joined: Sun Apr 10, 2005 7:22 pm
Posts: 405
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.

_________________
I love the bomb.


Top
 Profile  
 
PostPosted: Tue Dec 16, 2008 9:12 pm 
Offline
User avatar

Joined: Wed Apr 18, 2007 12:02 pm
Posts: 1798
Location: Edinburgh, UK
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."

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


Top
 Profile  
 
PostPosted: Tue Dec 16, 2008 10:24 pm 
Offline
User avatar

Joined: Wed Apr 18, 2007 12:02 pm
Posts: 1798
Location: Edinburgh, UK
"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.

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


Top
 Profile  
 
PostPosted: Fri Dec 19, 2008 4:57 pm 
Offline
User avatar

Joined: Sun Apr 10, 2005 7:22 pm
Posts: 405
In response to PHP5 query, Barnabas asks, will we be needing MySQL 5 as well ?

_________________
I love the bomb.


Top
 Profile  
 
PostPosted: Sat Dec 20, 2008 4:30 pm 
Offline
User avatar

Joined: Wed Apr 18, 2007 12:02 pm
Posts: 1798
Location: Edinburgh, UK
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?

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


Top
 Profile  
 
PostPosted: Sat Dec 20, 2008 5:08 pm 
Offline
User avatar

Joined: Sun Nov 23, 2008 10:16 am
Posts: 1111
Location: Edinburgh!
Yes. Up to date stuff is good. Old stuff is bad, has security holes and doesn't get patched.

_________________
Mike

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group