<! DOCTYPE html> <!--[if Lt IE 7]>
<?php//Display all Errors error_reporting (-1);
Ini_set (' display_errors ', ' on ');
Disable caching of the current Document:header (' Cache-control:no-cache, No-store, max-age=0, Must-revalidate '); Header (' Expires:mon, June 1997 05:00:00 GMT ');
Date in the past header (' Pragma:no-cache '); $filename = DirName (__file__).
'/data.txt '; Store new message in the file $message = isset ($_post[' message '))?
$_post[' message ']: ';
if ($message!= ') {file_put_contents ($filename, $message);
Exit (); }//infinite loop until the data file is modified $LASTMODIF = isset ($_post[' timestamp '])?
$_post[' timestamp ': 0;
$currentmodif = Filemtime ($filename); while ($currentmodif <= $lastmodif) {//check if the data file has been modified Usleep (10000);//Sleep 10ms to UNL
Oad the CPU clearstatcache ();
$currentmodif = Filemtime ($filename);
//Return a JSON array $response = array ();
$response [' message '] = file_get_contents ($filename); $response [' timestamp '] = $currentmodIf
echo Json_encode ($response); Flush ();