39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
$ini = parse_ini_file("conf.ini", true);
|
|
|
|
if ($ini['db']['log']=="1"){
|
|
$arrival_time=microtime(true);
|
|
$filename=basename(__FILE__);
|
|
$filename="log_".$filename.".txt";
|
|
$chunck=strval($arrival_time)." ".$_SERVER['REQUEST_URI']."\r\n";
|
|
file_put_contents($filename,$chunck,FILE_APPEND);
|
|
}
|
|
|
|
$filename="users_graph.txt";
|
|
if (file_exists($filename)){
|
|
$delta_time=time()-filemtime($filename);
|
|
}
|
|
else{
|
|
$delta_time=1000;
|
|
}
|
|
|
|
if ($delta_time>120)
|
|
{
|
|
mysql_connect($ini['db']['host'],$ini['db']['user'],$ini['db']['pass']);
|
|
mysql_select_db($ini['db']['db']);
|
|
|
|
$sql=mysql_query('SET CHARACTER SET utf8');
|
|
$sql=mysql_query("SELECT enabled as en,geolocated as geo,total as tot,DATE_FORMAT(date,'%e-%b') as dat FROM status order by date DESC limit 240");
|
|
if (mysql_num_rows($sql)){
|
|
while($e=mysql_fetch_assoc($sql))
|
|
$output_file[]=$e;
|
|
$json_file = json_encode($output_file);
|
|
file_put_contents($filename,$json_file);
|
|
}
|
|
mysql_close();
|
|
}
|
|
|
|
$data = file_get_contents($filename);
|
|
print($data);
|
|
?>
|