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

Recent

Welcome to TinyPortal. Please login or sign up.

May 15, 2024, 05:06:43 AM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,188
  • Total Topics: 21,220
  • Online today: 149
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 122
  • Total: 122

# People Visited This Page..

Started by Bounda, July 20, 2006, 05:42:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bounda

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.

Bounda


akulion

Added to Block code Index under "P" as "People visited this Page Block"

rebelrose

That is a nice little script, thanks for posting it.

Crip

What Type of Block? -- phpbox -- doesn't work?
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



rebelrose

#5
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.

Crip

doesn't work at all for me, not-in-any-type-of-block /
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



Bounda

its for each member that views a page with the bar its on enabled, i think.

Assistance


hanzboer

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.

Vinspire

is there a screenie for this block ? thank you :)

kjb0007

#11
Just tried this in a php box and it works great! You just have to adjust the date/time to your current date/time.

kjb0007

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:



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



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

IchBin

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?

kjb0007

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.