2015-04-06 17:46:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$text = isset($_POST['text']) ? $_POST['text'] : '';
|
2015-04-10 23:54:09 +02:00
|
|
|
$name = isset($_POST['name']) ? $_POST['name'] : '';
|
|
|
|
$room = isset($_POST['room']) ? $_POST['room'] : '';
|
2015-04-06 17:46:57 +02:00
|
|
|
|
2015-04-11 19:32:50 +02:00
|
|
|
if ($text === '' || $name === '' ) return;
|
2015-04-06 17:46:57 +02:00
|
|
|
|
|
|
|
$time = time();
|
|
|
|
$date = date('Y-m-d', $time);
|
|
|
|
|
|
|
|
$historyDir = './history/';
|
2015-04-10 23:54:09 +02:00
|
|
|
$historyFile = $historyDir.$room.$date;
|
2015-04-06 17:46:57 +02:00
|
|
|
|
|
|
|
$fh = @fopen($historyFile, 'a');
|
|
|
|
if ($fh === false) {
|
|
|
|
mkdir($historyDir);
|
|
|
|
$fh = @fopen($historyFile, 'a');
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start semafore */
|
|
|
|
flock($fh, LOCK_EX);
|
|
|
|
|
2015-04-11 19:32:50 +02:00
|
|
|
$data = array($time, $name, stripslashes(htmlspecialchars($text)));
|
2015-04-10 23:54:09 +02:00
|
|
|
fwrite($fh, implode('>', $data)."\n");
|
2015-04-06 17:46:57 +02:00
|
|
|
|
|
|
|
/* end semafore */
|
|
|
|
flock($fh, LOCK_UN);
|
|
|
|
fclose($fh);
|