[Pmwiki-users] Re: Insert PHP Code into pmwiki
Albi Rebmann
albi
Tue Jun 1 12:44:52 CDT 2004
Steven Leite schrieb:
> If you want to get fancy and do some functions, then let me know and I
> can send you some more complex examples.
Thanks again, here would be some script which shows how much users are
online. How could I insert it into pmwiki?
ALBI...
Script - user_online_file.php
<?php
/**********************************
* by Michael M?ller ***************
* Dieser Hinweis darf nicht *******
* entfernt werden *****************
**********************************/
$datei = "useronline.dat";
$min = 5;
$time = time() - $min*60;
$current_ip = $_SERVER['REMOTE_ADDR'];
// alte Beitr?ge l?schen
if(file_exists($datei)) {
$lines = file($datei);
foreach($lines as $key=>$data) {
list($ip, $timest) = explode("?", $data);
if(trim($timest) < $time
|| trim($ip) == $current_ip) {
unset($lines[$key]);
}
}
}
$lines[] = $current_ip."?".time()."\n";
$save = implode("", $lines);
$handle = fopen($datei, "w");
fputs($handle, $save);
fclose($handle);
$user = count($lines);
if($user == 1) {
echo "Es ist 1 User online";
} else {
echo "Es sind ".$user." User online";
}
?>
More information about the pmwiki-users
mailing list