jockeя
07-11-2007, 11:49 PM
index.php veya her hangi bir php ye eklediginiz bu kodun oldugu klasore bir tane log.txt dosya oluşturup izinlerini 777 yapmalısınız.
----------------------------------------
<?php
session_start();
$timer = 1;
$filename = "$DOCUMENT_ROOT/log.txt";
if (!$datei) $datei = dirname(__FILE__)."/$filename";
$time = @time();
$ip = session_id();
$string = "$ip|$time
";
$a = fopen("$filename", "a+");
fputs($a, $string);
fclose($a);
$timeout = time()-(60*$timer);
$all = "";
$i = 0;
$datei = file($filename);
for ($num = 0; $num < count($datei); $num++) {
$pieces = explode("|",$datei[$num]);
if ($pieces[1] > $timeout) {
$all .= $pieces[0];
$all .= ",";
}
$i++;
}
$all = substr($all,0,strlen($all)-1);
$arraypieces = explode(",",$all);
$useronline = count(array_flip(array_flip($arraypieces)));
echo $useronline;
$dell = "";
for ($numm = 0; $numm < count($datei); $numm++) {
$tiles = explode("|",$datei[$numm]);
if ($tiles[1] > $timeout) {
$dell .= "$tiles[0]|$tiles[1]";
}
}
if (!$datei) $datei = dirname(__FILE__)."/$filename";
$time = @time();
$ip = session_id();
$string = "$dell";
$a = fopen("$filename", "w+");
fputs($a, $string);
fclose($a);
?>
----------------------------------------
<?php
session_start();
$timer = 1;
$filename = "$DOCUMENT_ROOT/log.txt";
if (!$datei) $datei = dirname(__FILE__)."/$filename";
$time = @time();
$ip = session_id();
$string = "$ip|$time
";
$a = fopen("$filename", "a+");
fputs($a, $string);
fclose($a);
$timeout = time()-(60*$timer);
$all = "";
$i = 0;
$datei = file($filename);
for ($num = 0; $num < count($datei); $num++) {
$pieces = explode("|",$datei[$num]);
if ($pieces[1] > $timeout) {
$all .= $pieces[0];
$all .= ",";
}
$i++;
}
$all = substr($all,0,strlen($all)-1);
$arraypieces = explode(",",$all);
$useronline = count(array_flip(array_flip($arraypieces)));
echo $useronline;
$dell = "";
for ($numm = 0; $numm < count($datei); $numm++) {
$tiles = explode("|",$datei[$numm]);
if ($tiles[1] > $timeout) {
$dell .= "$tiles[0]|$tiles[1]";
}
}
if (!$datei) $datei = dirname(__FILE__)."/$filename";
$time = @time();
$ip = session_id();
$string = "$dell";
$a = fopen("$filename", "w+");
fputs($a, $string);
fclose($a);
?>