TinyPortal

Development => Block Codes => Topic started by: Bounda on July 20, 2006, 05:42:20 AM

Title: # People Visited This Page..
Post by: Bounda on July 20, 2006, 05:42:20 AM
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 11:34 PM Central Time on July 19th.");
$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);
}


Saw it at some php scripting site, thought it would be cool. Use it in a block, but change "people have visited this page, starting at 11:34 PM Central Time on July 19th." To whatever fits you.
Title: Re: # People Visited This Page..
Post by: Bounda on July 23, 2006, 07:12:13 PM
30 views no replys makes me sad :'(
Title: Re: # People Visited This Page..
Post by: akulion on July 26, 2006, 10:38:27 AM
Added to Block code Index under "P" as "People visited this Page Block"
Title: Re: # People Visited This Page..
Post by: rebelrose on August 06, 2006, 12:22:11 AM
That is a nice little script, thanks for posting it.
Title: Re: # People Visited This Page..
Post by: Crip on August 06, 2006, 01:03:22 AM
What Type of Block? -- phpbox -- doesn't work?
Title: Re: # People Visited This Page..
Post by: rebelrose on August 06, 2006, 01:05:24 AM
Quote from: crip on August 06, 2006, 01:03:22 AM
What Type of Block? -- phpbox -- doesn't work?

I just put it in a php block and it works except if you have the front page turned on it counts that as well as when you go into the forum, not sure if it counts when you view a post I didn't check that yet.

So I turned it off, because it is not giving a true count, unless someone knows how to fix that.
Title: Re: # People Visited This Page..
Post by: Crip on August 06, 2006, 11:36:50 AM
doesn't work at all for me, not-in-any-type-of-block /
Title: Re: # People Visited This Page..
Post by: Bounda on August 07, 2006, 06:06:29 AM
its for each member that views a page with the bar its on enabled, i think.
Title: Re: # People Visited This Page..
Post by: Assistance on August 07, 2006, 06:07:52 AM
 create a hits.txt file ?
Title: Re: # People Visited This Page..
Post by: hanzboer on October 17, 2006, 10:07:56 AM
For the same purpose, I used the one in this thread:
http://www.tinyportal.net/smf/index.php?topic=3125.0
it works quite well.
Title: Re: # People Visited This Page..
Post by: Vinspire on October 17, 2006, 12:25:51 PM
is there a screenie for this block ? thank you :)
Title: Re: # People Visited This Page..
Post by: kjb0007 on March 24, 2008, 12:02:05 AM
Just tried this in a php box and it works great! You just have to adjust the date/time to your current date/time.
Title: Re: # People Visited This Page..
Post by: kjb0007 on October 13, 2008, 10:40:04 PM
I have had this installed since March 2008 and it all of as sudden just stopped working and I get errors every time there is a visit to the portal page:

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


As you can see, it is having trouble pulling the number now:

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi34.tinypic.com%2F15jyxh.gif&hash=a06a9b857bf2fd2b0b1b2763907b32a6a08ee121)

When I edit the hits.txt file this is all that is in it:

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi37.tinypic.com%2F2r3wcxj.gif&hash=ff094bc829ef71320052b8beea28952abf8b747c)

Not sure what was supposed to be in it originally as I have never edited this file before. Any ideas? I already tried chmodding the file to 777 and that didnt seem to work - it was orig set to 644
Title: Re: # People Visited This Page..
Post by: IchBin on October 13, 2008, 10:55:41 PM
Where do you have the hits.txt file located? If you add a number to the file does it read it? Does the file get erased if you add something to it?
Title: Re: # People Visited This Page..
Post by: kjb0007 on October 14, 2008, 06:50:15 AM
Quote from: IchBinâ,,¢ on October 13, 2008, 10:55:41 PM
Where do you have the hits.txt file located? If you add a number to the file does it read it? Does the file get erased if you add something to it?

The file is right inside the public_html folder on the server. Through trial and error and with the help of Ianedres we were able to kind of get it sorted out. We still dont know what actually caused it to happen, but somehow the number that was in that file that gets incrimented by one on each visit just dissappeared. Ianedres recommended i try adding an actual value to that file and then putting that one on the server - and I just tried that and the block seems to be working again like its supposed to with no errors (so far). I hate when weird things like this happen because we will probably never know what happened to cause it.   :o 8). Thanks for the response tho.