/
index.php
executable file
·41 lines (36 loc) · 1019 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
session_start();
date_default_timezone_set("UTC");
$path='../tmp/';//sesion files folder
$file_name='sess_'.$_COOKIE['PHPSESSID'];
$file=$path.$file_name;
$atime=300;//5 min
function inc_count($path,$file,$atime)
{
!is_dir($path)?mkdir($path,0755,true):false;
!file_exists($file)?fopen($file, "w"):false;
$time=file_get_contents($file);
empty($time)?file_put_contents($file, (time()+$atime)):false;
if($time<=time())
{
file_put_contents($file, time()+$atime);
}
if ($handle = opendir($path))
{
while (false !== ($entry = readdir($handle)))
{
if ($entry != "." && $entry != "..")
{
$time=file_get_contents($path.$entry);
if($time<=time())
{
unlink($path.$entry);
}
}
}
closedir($handle);
$prefix = ((count(scandir($path))-2) == 1) ? '' : '\'s';
return 'There is<b> '.(count(scandir($path))-2).' </b>online user' . $prefix . '. (based on users active over the past '.($atime / 60).' minutes)';
}
}
echo inc_count($path,$file,$atime);