1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/minchat_ynh.git synced 2024-09-03 19:36:29 +02:00
minchat_ynh/sources/server.php
2015-04-11 19:32:50 +02:00

26 lines
No EOL
633 B
PHP

<?php
$pos = isset($_REQUEST['pos']) ? $_REQUEST['pos'] : '';
$lastdate = isset($_REQUEST['lastdate']) ? $_REQUEST['lastdate'] : '';
$room = isset($_REQUEST['room']) ? $_REQUEST['room'] : '';
$date = date('Y-m-d');
$file = './history/'.$room.$date;
if (!ctype_digit($pos) || !file_exists($file)) return;
settype($pos, "integer");
settype($lastdate, "integer");
if ($date!=date('Y-m-d',$lastdate)) $pos=0;
$data = array();
$fh =fopen($file, "r");
if (fseek($fh, $pos)==0) {
$i=0;
while($lig=fgets($fh)){ $data[$i++] = explode('>', $lig); }
$pos =ftell($fh);
echo json_encode(array('pos' => $pos, 'data' => $data));
}
?>