47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
// Parse with sections
|
|
$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="count_manual.txt";
|
|
if (file_exists($filename)){
|
|
$delta_time=time()-filemtime($filename);
|
|
}
|
|
else{
|
|
$delta_time=1000;
|
|
}
|
|
|
|
if ($delta_time>5)
|
|
{
|
|
mysql_connect($ini['db']['host'],$ini['db']['user'],$ini['db']['pass']);
|
|
mysql_select_db($ini['db']['db']);
|
|
|
|
$sql1=mysql_query("select count(*) as count_manual_green from manual where magnitude=1 and ban<3 and donotshow=0 and date > date_sub(now(), interval 1440 minute)");
|
|
$e=mysql_fetch_assoc($sql1);
|
|
$output[]=$e;
|
|
|
|
$sql1=mysql_query("select count(*) as count_manual_yellow from manual where magnitude=2 and ban<3 and donotshow=0 and date > date_sub(now(), interval 1440 minute)");
|
|
$e=mysql_fetch_assoc($sql1);
|
|
$output[]=$e;
|
|
|
|
$sql1=mysql_query("select count(*) as count_manual_red from manual where magnitude=3 and ban<3 and donotshow=0 and date > date_sub(now(), interval 1440 minute)");
|
|
$e=mysql_fetch_assoc($sql1);
|
|
$output[]=$e;
|
|
|
|
$json_file = json_encode($output);
|
|
file_put_contents($filename,$json_file);
|
|
|
|
mysql_close();
|
|
}
|
|
|
|
$data = file_get_contents($filename);
|
|
print($data);
|
|
?>
|