[Return]

Report a post

Preview
oh i didn't notice it was in utilities. that place just seemed like some sort of extra that was not used in main script.

now i am thinking it is hidden to just collect the ip and log it for 24 hours

<?php
/*
Online counter for kokonotsuba
from http://php.loglog.jp/
*/
define(USR_LST, "../dat/users.dat");
define(TIMEOUT, 300); // Update every 5 minutes

$usr_arr = file(USR_LST);
touch(USR_LST);

$fp = fopen(USR_LST, "w");
$now = time();
$addr = $_SERVER['REMOTE_ADDR'];

for ($i = 0; $i < sizeof($usr_arr); $i++) {
list($ip_addr,$stamp) = explode("|", $usr_arr[$i]);
if (($now - $stamp) < TIMEOUT && $ip_addr != $addr) {
fputs($fp, $ip_addr.'|'.$stamp);
}
}
fputs($fp, $addr.'|'.$now."\n");
fclose($fp);

$count = count($usr_arr);
$data = '<div style="background-color: #000000; color: #00FF00;">Currently <b>'.$count.'</b> unique user'.($count > 1 ? 's' : '').' online</div>';
echo $data;
?>
Post number No.66462
Board Site Discussion@Heyuri
Optional. Describe what's wrong with it.