TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 629
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 469
  • Total: 469

Strange error I have never seen before

Started by kjb0007, October 13, 2008, 06:32:33 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kjb0007

Quote2: fread() [<a href='function.fread'>function.fread</a>]: Length parameter must be greater than 0
File: /home//public_html/Themes/default/TPortal.template.php (main_above sub template - eval?)
Line: 4

I am running on SMF 1.1.5, using TP v0.9.8. I have several mods installed, but I have only added one recently and that was the New Style Message Icon mod.

This is the first time I have ever seen this error. This error happens when someone views the TP page (even guests)

patriotgames2.info

G6Cad

what have you done when this error started to show ?

Ianedres

Looks to be attempting to read a file; several possibilities there, first of which could be that the file is no longer available or otherwise not accessible. Your host could have disabled reading remote (http) files through the php process...

Does the error cease if you remove the mod? What block is running the code?


kjb0007

#3
Quote from: G6 on October 13, 2008, 06:42:17 AM
what have you done when this error started to show ?

Nothing other than the normal stuff I do periodically on that page - such as change the text in an article once a week. One of my staff changes the text once a day in a block its merely text - for the jokes of the day block.

Quote from: Ianedres on October 13, 2008, 06:49:39 AM
Looks to be attempting to read a file; several possibilities there, first of which could be that the file is no longer available or otherwise not accessible. Your host could have disabled reading remote (http) files through the php process...

Does the error cease if you remove the mod? What block is running the code?



The first error didnt occur untul "Yesterday at 01:58:34 AM" which would have been early sunday morning. I added the mod 3 days prior to that on Thursday. I tried uninstalling the mod and the error still happens. That mod doesnt affect the TP page so I dont think its the mod causing it. Its a mod that changes the layout of the message icons for posts. Not sure which block you are asking about or which code. I have several blocks on that page all of which have been on there for several months. The only change I have made to the TP was on Saturday, I updated the movie of the week block which contains the embed code from MegaVideo which I have been using the codes from there for several months as well. This is a change I make every saturday.

I looked in the TPortal.template.php file and there is nothing on line 4 and there is no code that pertains to anything ragarding "fread". I can attach it here if that will help. 

Edit: The only file that that mod even changes is the Post.template.php

Ianedres

Do you have a valid RSS feed at this time? The fread statement is used to parse RSS in TPortal.php, and I would have to guess that a newsfeed is down or otherwise not available at this time...

kjb0007

#5
Quote from: Ianedres on October 13, 2008, 07:47:03 AM
Do you have a valid RSS feed at this time? The fread statement is used to parse RSS in TPortal.php, and I would have to guess that a newsfeed is down or otherwise not available at this time...

I have had the RSS Feed mod from SMF installed on my forum for probably about 2 months now. (http://custom.simplemachines.org/mods/index.php?mod=376), but I dont have any type of rss feed on the portal. Would that mod affect the portal page, and even cause the error when guests view the page? How can I tell if one of those category feeds is down?

I just saw that there is a block that is not working correctly. I cant remember the exact name of the snippet cuz its been on there for so long, but its the one that shows how many people have visited since a particular date. It seems to be having an issue pulling the number. It has that "fread" in the code. This block is both available to guests and to members which would explain why its happening on guests as well. Could this be the culprit? The last time I looked at that number - which was probably fri or sat, it was around 60,000.

~~edit~~: I turned that block off and I dont get that error in my log anymore. Any ideas on what the issue is with it and how I can fix it?



The code for that snipet is:

if(file_exists("hits.txt"))
{
$exist_file = fopen("hits.txt", "r+");
$new_count = fread($exist_file, filesize("hits.txt"));
$new_count++;
fclose($exist_file);
print("$new_count people have visited this page, starting at 7:00 PM Central Time on March 23rd, 2008.");
$exist_count = fopen("hits.txt", "w");
fputs($exist_count, $new_count);
fclose($exist_count);
}
else
{
$new_file = fopen("hits.txt", "w");
fputs($new_file, "1");
fclose($new_file);
}



Ianedres

The server is not able to access the file and php is producing the error in the log as such. This could be a variety of issues, all external of TinyPortal.

Most likely, either the file 'hits.txt' does not exist or the directory the file is in may have changed the permissions for reading and/or writing.

You should verify that the file exists in what would have to be your forum directory, since there is no relative path statement before the filename. Should be able to access it through your browser as www.yourdomain.com/hits.txt and see a) if the file is there and b) a numeric value is there on the first line.

You could investigate other counters that use SQL instead of a local file if you continue to have problems with it.

Good luck.

kjb0007

#7
ok I tried getting to the file via my browser using patriotgames2.info/hits.txt and all I got was a blank white page. So I FTP'd in to see if the file was there and it is but its showing 0 bytes. When I edit the file this is all that is in it (not sure what was actually in it before as I have never edited that file):



Its really weird that all of a sudden it just stopped working. I should probably go and find the thread where I got the code snippet from and ask this, but do you have any idea as to what would cause this to happen? I have done nothing to that block since I installed it back in March. Posting the code here for it is actually the first time I have even edited that block since march.

Edit: I have posted a help request in the actual thread the code snippet is in to see if anyone there knows why this happened and if there is a way to fix it without losing the actual data it once had.

Thanks for all your help. :)

Ianedres

The file is simply a numerical value on the first line; the script reads the value, increments it by one, and saves the new value by rewriting the file. You can make it any value you want with an editor and save the file to your server.

Most likely, a permission change either on the file, the directory the file is in, or through the server's php configuration file if they made security changes.

kjb0007

Quote from: Ianedres on October 14, 2008, 01:08:31 AM
The file is simply a numerical value on the first line; the script reads the value, increments it by one, and saves the new value by rewriting the file. You can make it any value you want with an editor and save the file to your server.

Most likely, a permission change either on the file, the directory the file is in, or through the server's php configuration file if they made security changes.

Well, I am not sure "why" it happened, however, doing what you mentioned in terms of making that value any number and then saving it to the server worked. Its incrementing by 1 like its supposed to and no errors  Thanks  8).

This website is proudly hosted on Crocweb Cloud Website Hosting.