minimad Posted January 26, 2010 Share Posted January 26, 2010 Hi, I have found a log on script (just php) for my website which works well. The script generates a message to a user who should browse to the secure page without logging in, although this appears before it which is not required: Warning: fread() [function.fread]: Length parameter must be greater than 0. in /home/account/public_html/website/secure.php on line 7 I guess this is generated by the server and not the script itself. Is there any way I can disable this? Thanks for looking. Quote Link to comment https://forums.phpfreaks.com/topic/189871-disable-error-possible/ Share on other sites More sharing options...
akitchin Posted January 26, 2010 Share Posted January 26, 2010 we'll need to see the call to fread (note: i've linked to the function so you can see its documentation and try to spot the error yourself). presumably fread() is being used for some reason related to the script, and therefore it would be better to diagnose why the error is being caused, rather than simply suppressing it and potentially breaking the script. Quote Link to comment https://forums.phpfreaks.com/topic/189871-disable-error-possible/#findComment-1001915 Share on other sites More sharing options...
minimad Posted January 26, 2010 Author Share Posted January 26, 2010 hi, thanks for the prompt reply. Line 7 on secure.php: $contents = fread($log, filesize($filename)); The script I am using is from tropical solutions: http://scripts.tropicalpcsolutions.com/html/php-script/secure-login-php-script.html Thanks for the link - just trying to get my head around it now. Quote Link to comment https://forums.phpfreaks.com/topic/189871-disable-error-possible/#findComment-1001917 Share on other sites More sharing options...
akitchin Posted January 26, 2010 Share Posted January 26, 2010 well, it's telling you it can't have a 0 length. that means that filsize($filename) is returning 0, which most likely means that the file is not found. where is $filename coming from? if it will only exist when the user logs on, you should move the check on whether the user is logged in to above the fread() call. Quote Link to comment https://forums.phpfreaks.com/topic/189871-disable-error-possible/#findComment-1001922 Share on other sites More sharing options...
minimad Posted January 26, 2010 Author Share Posted January 26, 2010 hi, the log on process compiles of 3 files: dataprocess.php, secure.php, user.log - the form integrated in with index.php when secure.php loads it opens the log file to see if a valid user name is found. it also erases the log and display the content. The reason the code wipes the log clear is so no one (including the original visitor) can access the page again without re-logging on. If someones goes directly to secure.php without signing in the code will read an empty log and display an error to the visitor. It is not this error in the script I am trying to get rid off, but the one above it (shown in attachment) Thanks for looking! [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/189871-disable-error-possible/#findComment-1001946 Share on other sites More sharing options...
akitchin Posted January 26, 2010 Share Posted January 26, 2010 if it's erasing the log every time the file is accessed, you'll want to add an if() statement to check if the file is empty before running fread(): if (filesize($filename) == 0) { exit('Viewing this page requires logging in.'); } else { // run the fread() stuff to check if there's anything in there } Quote Link to comment https://forums.phpfreaks.com/topic/189871-disable-error-possible/#findComment-1002019 Share on other sites More sharing options...
minimad Posted January 27, 2010 Author Share Posted January 27, 2010 Sorry for the late reply. Placed your code before the fread line and it's worked. Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/189871-disable-error-possible/#findComment-1002341 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.