$oldtime = filemtime("./counter.txt"); $newtime = time(); if ($newtime>$oldtime+30) { //actualizamos cada 30 segundos $directory="./iplog/tmp/"; $directory_handle = opendir($directory); $count = 0; while ( false !== ( $file = readdir( $directory_handle ) ) ) { if(time() - fileatime($directory . $file) < 900) $count++; // 10minutos } closedir($directory_handle); $myFile = "counter.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $count); fclose($fh); } $myFile = "counter.txt"; $fh = fopen($myFile, 'r'); $counter = fgets($fh); fclose($fh); ob_start ("ob_gzhandler"); header("Content-type: text/html"); ?>
| echo $counter; ?> |