47 lines
1.2 KiB
PHP
47 lines
1.2 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="manual_pro.txt";
|
|
if (file_exists($filename)){
|
|
$delta_time=time()-filemtime($filename);
|
|
}
|
|
else{
|
|
$delta_time=1000;
|
|
}
|
|
|
|
if ($delta_time>3)
|
|
{
|
|
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 latitude,longitude,magnitude,code,ban,msg,address,date,TIMESTAMPDIFF(MINUTE,date, NOW()) AS difference FROM manual WHERE date > date_sub(now(), interval 10080 minute) and donotshow=0 ORDER BY date DESC LIMIT 150");
|
|
if (mysql_num_rows($sql)>0){
|
|
|
|
while($e=mysql_fetch_assoc($sql))
|
|
$output_file[]=$e;
|
|
$json_file = json_encode($output_file);
|
|
file_put_contents($filename,$json_file);
|
|
}
|
|
else{
|
|
//$fh = fopen($filename,'w');
|
|
//fclose($fh);
|
|
}
|
|
mysql_close();
|
|
}
|
|
|
|
$data = file_get_contents($filename);
|
|
print($data);
|
|
|
|
|
|
?>
|