2021-08-08 17:23:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$path = __DIR__ . '/../../tmp/quicknotes';
|
|
|
|
|
|
|
|
if (!file_exists($path)) {
|
|
|
|
mkdir($path);
|
|
|
|
}
|
2021-08-08 18:54:01 +00:00
|
|
|
if (!file_exists($path . '/logs.txt')) {
|
|
|
|
file_put_contents($path . '/logs.txt', '');
|
|
|
|
}
|
2021-08-08 17:23:49 +00:00
|
|
|
|
|
|
|
$path = realpath($path);
|
|
|
|
|
2021-08-08 18:54:01 +00:00
|
|
|
if ($_SERVER['REQUEST_URI'] === '/list') {
|
|
|
|
$msgs = explode("\n", file_get_contents($path . '/logs.txt'));
|
|
|
|
array_pop($msgs);
|
|
|
|
?>
|
|
|
|
<h3>List of messages</h3>
|
|
|
|
<ul>
|
|
|
|
<?php
|
|
|
|
foreach ($msgs as $msg) {
|
|
|
|
?>
|
|
|
|
<li><?= $msg ?></li>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</ul>
|
|
|
|
<?php
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2021-08-08 17:23:49 +00:00
|
|
|
$message = '';
|
|
|
|
|
|
|
|
if (isset($_GET['m'])) {
|
|
|
|
$message = $_GET['m'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_GET['message'])) {
|
|
|
|
$message = $_GET['message'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen($message) === 0) {
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
$data = '[' . date('Y-m-d H:i:s') . ']';
|
|
|
|
$data .= ' - ' . $message;
|
|
|
|
$data .= "\n";
|
|
|
|
|
|
|
|
file_put_contents($path . '/logs.txt', $data, FILE_APPEND);
|
|
|
|
|
|
|
|
echo 'OK';
|