Home World Forum
Stars! AutoHost web forums

Jump to Stars! AutoHost


 
 
Home » Stars! 2.6/7 » Questions about Stars! AutoHost » Editing an empty post (split off)
Re: Mid-game gateable missle defence reserve Mon, 07 August 2006 01:43 Go to previous messageGo to previous message
multilis is currently offline multilis

 
Lt. Commander

Messages: 789
Registered: October 2003
Location: Edmonton, Canada
Likely moderator will split this topic off, thanks in advance. Smile

Ron wrote on Sat, 05 August 2006 20:30

m.a@stars wrote on Sat, 29 July 2006 04:53

Hey, I got this while editing an empty post:

Warning: fread(): Length parameter must be greater than 0. in /var/www/autohost.cathey.us/htdocs/sahforum/theme/Stars/post .php on line 42

Warning: Cannot modify header information - headers already sent by (output started at /var/www/autohost.cathey.us/htdocs/sahforum/theme/Stars/post .php:42) in /var/www/autohost.cathey.us/htdocs/sahforum/theme/Stars/post .php on line 3631

Yes, I know... don't know what causes it.


A post with no content, only a subject and maybe a poll gets this error if you try to edit it. Line 42 of post.php likely needs a small change by adding an "if size>0" type statement. My php is rusty, but from my php help file:

Quote:

fread() reads up to length bytes from the file pointer referenced by handle. Reading stops when length bytes have been read, EOF (end of file) is reached, or (for network streams) when a packet becomes available, whichever comes first.

<?php
// get contents of a file into a string
$filename = "/usr/local/something.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
?>


The above sample to avoid similar problem might be changed to:
Quote:


<?php
// get contents of a file into a string
$filename = "/usr/local/something.txt";
$handle = fopen($filename, "r");
$readsize = filesize($filename);

if ($readsize>0)
{
$contents = fread($handle, filesize($filename));
}
else
{
$contents = "";
}
fclose($handle);
?>



A change similar in style to this to line 42 of post.php may get rid of first warning.

Some other minor tweak to line 42 may get rid of second warning, hard to say exactly without seeing source code, but one option is to fake having something if nothing, eg
Quote:

else { contents="X"; }
rather than
Quote:

else { contents=""; }


{Mod edit: fixed quote}


[Updated on: Mon, 07 August 2006 02:48] by Moderator


Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Game pages on hold
Next Topic: Long Posts
Goto Forum:
  


Current Time: Wed May 15 08:44:32 EDT 2024