miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
The Other miniBB Support Forums / The Other /  
 

PHP Warning - Length parameter must be greater than 0

 
Author harootun
Partaker
#1 | Posted: 6 Feb 2011 22:45 
I've checked my PHP log, and I see the following warning repeated:

PHP Warning: fread() [<a href='function.fread'>function.fread</a>]: Length parameter must be greater than 0 in /Users/JoeBlow/website/minibb/bb_functions.php on line 22

line 22 of bb_functions.php is: $tpl=fread($fd, filesize($fload));

Is this anything to be worried about? Anything I can make go away?

Sorry for my ignorance!

Author tom322
Active Member
#2 | Posted: 6 Feb 2011 23:37 
Maybe you removed/don't use one of the default templates that givese the warning. I would try to enter a space in this template and save it again.

Author Paul
Lead Developer 
#3 | Posted: 7 Feb 2011 04:34 
Yes, it means you have modified some template and completely deleted its content. Such error may appear when fread() function of PHP tries to read an empty file. Put a space or newline in this file.

How to determine the name of the template - in bb_functions.php, right after the function's statement put the following:

function makeUp($name,$addDir='') {
echo $name;
....
then run the script and watch the error report - PHP will drop the notice right after the template's name.

Author harootun
Partaker
#4 | Posted: 7 Feb 2011 13:01 
Yes, that was it! Found the problem template and put a space in there! Thanks so much!

Author Ricardo
Partaker
#5 | Posted: 23 Feb 2011 09:13 
Thanks too! I had the same error and now its fixed.

But i think i found a error in the forum search. First time i searched for fread(); and instead of the result page i get the following error:

Forbidden

You don't have permission to access /forums/index.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at ... Port 80

Author Paul
Lead Developer 
#6 | Posted: 23 Feb 2011 09:52 
Ricardo
If you are about Search on our forums - yes, it will give that error if the search phrase contains parentheses. For some reason parentheses are perceived by the server where we host miniBB like they would a filename or something. We just don't know why it happens currently. I think investigating it on the hoster's side would take years :) Anyway I'll try to know these guys about that, thanks.

So by now if something like this happens, try to improve your search, search for simply 'fread' for example.

It's only related to our server, it works by default on all proper configurations.

P.S. Hmm no I was wrong, it only happens if you type fread() / fwrite()! No other combination with parentheses. Strange! I'll disturb the hoster right now :)

Author Ricardo
Partaker
#7 | Posted: 23 Feb 2011 09:53 
Ok, good to know. Thanks for that information!

Author tom322
Active Member
#8 | Posted: 23 Feb 2011 15:05 
Paul:
I'll disturb the hoster right now :)
I also think it's hoster's custom security settings; from what I tested it works on some hosts correctly while on another not. I tend to think not to disturb hosters too much as there may be a risk they screw something even more ; ).

Author Paul
Lead Developer 
#9 | Posted: 24 Feb 2011 03:43 
It is hoster's job, to solve such errors. So it's always nice to disturb them, because the money is paid for that.

This is what they replied:

The forbidden message you are seeing is due to the search script that is being used hitting our Mod Security rule set. The mod security rule is in place to protect against common PHP injection attacks. In some cases it returns false positives due to the manner in which the script operates. Unfortunately, we can disclose the exact rule for security reasons.
They also suggested to whitelist our domain for this rule so that when searching for those variables, it will be allowed through the rule set.

I disagreed with that. There is nothing critical comes regarding this point comparing to security.

So like I replied above, do not use major PHP functions in search. Skipping parentheses and other system symbols, leaving the phrase characters clean, will help.

Author ramya
Guest
#10 | Posted: 4 Jun 2012 07:49 
try adding at symbol before fread

Author Paul
Lead Developer 
#11 | Posted: 4 Jun 2012 17:56 
ramya:
try adding at symbol before fread
This will eliminate the appearing of the problem, but not the problem itself.
Obviously, most often this error comes up because of some empty template or file.

Author lily3kms
Partaker
#12 | Posted: 29 Jul 2013 01:43 
can someone help me.. i have this problem

Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home1/laile/public_html/bbs/lib.php on line 1010

how to solve it??

please...

Author Paul
Lead Developer 
#13 | Posted: 29 Jul 2013 13:02 
Go to the line 1010 of lib.php, this script tries to fread some file, which obviously has 0 bytes in length.
How to fix it? Not sure. This script is not related to miniBB.

The Other miniBB Support Forums / The Other /
 PHP Warning - Length parameter must be greater than 0
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Check out the File and Picture Attachments add-on: extend your miniBB-forums, attaching images and files.


  ⇑