2008/12/27 13:26:56
|
---|
![]() |
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
|
---|
![]() |
Re: anyone know a simple code to show when a user is online?Here are some tips:
http://www.xoops.org/modules/newbb/viewtopic.php?viewmode=flat&type=&topic_id=67108&forum=27 |
_________________
VIL3/trabisdementia |
2008/12/27 21:35:29
|
---|
![]() |
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
|
---|
|
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>"; } ?> |