Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Vistitors Online Script

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

tbl

Established Member
Impact
2
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
0
Close
Here's a PHP script that uses a text file to store data. Just create a blank online.txt file and CHMOD it 777
PHP:
<?php
$userip = $_SERVER['REMOTE_ADDR'];
$time = time();
$usersonline = 0;
$alreadyonline = 0;
$onlinetxt = fopen("./online.txt","r+");
flock($onlinetxt,2);
while (!feof($onlinetxt)) { 
$user[] = chop(fgets($onlinetxt,65536));
}
fseek($onlinetxt,0,SEEK_SET);
ftruncate($onlinetxt,0);
foreach ($user as $line) {
@list($savedip,$savedtime) = split("|",$line);
if ($savedip == $userip) {
  $savedtime = $time;
  $alreadyonline = 1;
}
if ($time < $savedtime + ($session_length)) {
  fputs($onlinetxt,"$savedip|$savedtime\n");
  $usersonline = $usersonline + 1;
}
}
if (!$alreadyonline) {
fputs($onlinetxt,"$userip|$time\n");
$usersonline = $usersonline + 1;
}
fclose ($onlinetxt);
if($usersonline==1){
echo "<center> 1 user online </center>";
} else {
echo "<center> "$usersonline." users online</center>";
}
?>
 
0
Close
Last edited:
0
Close
tbl said:
Jim I tried yours: http://tbldesign.net/online.php and I got Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in /home/tbltk/public_html/online.php on line 39

weblord I tried yours: http://tbldesign.net/onlinecount.cgi and I got a 500 error.
that's not my script i just saw it on google, make sure you chmod 755 onlinecount.cgi and it should work and it needs to be stored on your cgi-bin folder not just on the root.

as for the other error, there's no line 39? did you copy and paste the whole code and added nothing to it? it should work on any folder provided you have php enabled and it's named .php
 
0
Close
The cgi one works now thanx. Is there any way to get it on another page. I just pasted the php code in to a php page.
This is on line 31
PHP:
echo "<center> "$usersonline." users online</center>";
 
Last edited:
0
Close
yes, make sure it's .shtml or .shtm and place this code:
Code:
<!--#include virtual="/server_path_to/onlinecount.cgi" -->

HTH
 
0
Close
weblord said:
yes, make sure it's .shtml or .shtm and place this code:
Code:
<!--#include virtual="/server_path_to/onlinecount.cgi" -->

HTH
So not in a php page :(
 
0
Close
0
Close
no didnt work. nothing was there (except for the rest of the site). dont the <!--...--> tags hide whats in them?
 
0
Close
meaning it's an include..

:imho: just try Jim_
code and it will work just save on a separate file or try a remote who's online service like: livecounter.net works on any type of page.
 
0
Close
echo "<center> "$usersonline." users online</center>";

change that to

echo "<center> ".$usersonline." users online</center>";

>.<
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back