Reply New Topic
2008/12/27 13:26:56
#1
Offline
Just popping in

anyone know a simple code to show when a user is online?

i've been trying to do this for a few hours now. so far, i've found the php code in misc.php to show when the user is online, but i'm looking for a code i can put into the yogurt_index.html template. something like:

<{if isOnline==1}>Offline<{else}>Online<{/if}>

i know that's not right and it doesn't work, but it's the best sortuv example i could think of...
any help would be greatly appreciated.
thanks

_________________
and my time is a piece of wax, fallen on the termite that's chokin' on the splinters

2008/12/27 13:51:47
#2
Offline
Home away from home

Re: anyone know a simple code to show when a user is online?


_________________
VIL3/trabisdementia

2008/12/27 21:35:29
#3
Offline
Just popping in

Re: anyone know a simple code to show when a user is online?

great! hey, thanks dude. it works perfect.

_________________
and my time is a piece of wax, fallen on the termite that's chokin' on the splinters

2009/3/17 2:16:58
#4
Offline
Just popping in

Re: anyone know a simple code to show when a user is online?

You can try this one:


<?php

$file_name = "whois_online.dat.php";
$c_time = time();
$timeout = 300;
$time = $c_time - $timeout;
$ip = getenv("REMOTE_ADDR");

if(!file_exists($file_name)){
$fp = fopen($file_name, "w");
fwrite($fp, "<?php die('Restricted File');?> \n");
fclose($fp);
}


$fp = fopen($file_name, "a");
$write = $ip."||".$c_time."\n";
fwrite($fp, $write);
fclose($fp);


$file_array = file($file_name);
$online_array = array();
for($x = 1; $x < count($file_array); $x++){
list($ip, $ip_time) = explode("||", $file_array[$x]);
if($ip_time >= $time){
array_push($online_array, $ip);
}
}

$online = array_unique($online_array);
$online = count($online);
if($online == "1"){
print "User online: $online"."<br>";
}else{
print "Users online: $online"."<br>";
}
?>


Reply New Topic extras
 Previous Topic   Next Topic
You can view topic.
You can start a new topic.
You can reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You can post without approval.