36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
$ini = parse_ini_file("conf.ini", true);
|
|
mysql_connect($ini['db']['host'],$ini['db']['user'],$ini['db']['pass']);
|
|
mysql_select_db($ini['db']['db']);
|
|
|
|
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);
|
|
}
|
|
|
|
mysql_set_charset("utf8");
|
|
|
|
$idmin=$_REQUEST['idmin'];
|
|
$postfix=$_REQUEST['postfix'];
|
|
|
|
$table="chat".$postfix;
|
|
|
|
$q=mysql_query("SELECT $table.ID,$table.user_code as user_id,nick,message,moderator,TIMESTAMPDIFF(MINUTE,date, NOW()) AS difference FROM $table left join contest_nick on $table.user_code=contest_nick.user_code where $table.ID>$idmin and $table.date > date_sub(NOW(), interval 1440 minute) order by $table.ID asc");
|
|
|
|
if (mysql_num_rows($q))
|
|
{
|
|
while($e=mysql_fetch_assoc($q))
|
|
$output[]=$e;
|
|
print(json_encode($output));
|
|
}
|
|
else{
|
|
print("no_new");
|
|
}
|
|
|
|
|
|
mysql_close();
|
|
?>
|