General project setup

This commit is contained in:
Sascha Leib
2025-08-20 22:58:42 +03:00
parent 6980370b98
commit cf9f7fe823
8 changed files with 188 additions and 29 deletions

34
tick.php Normal file
View File

@@ -0,0 +1,34 @@
<?php /* MONITOR PLUGIN HEARTBEAT TICKER SCRIPT */
/* build the resulting log line (ensure fixed column positions!) */
$logArr = Array(
intval($_GET['t']), /* timestamp */
$_GET['p'] ?? null, /* page ID */
$_SERVER['REMOTE_ADDR'] ?? 'null', /* remote IP */
$_COOKIE['DokuWiki'] ?? 'null', /* DokuWiki session ID */
$_GET['t'] ?? null /* client time */
);
/* create the log line */
$filename = 'logs/' . gmdate('Y-m-d') . ".tck"; /* use GMT date for filename */
$line = gmdate('Y-m-d H:i:s'); /* use GMT time for log entries */
foreach ($logArr as $val) {
$line .= "\t" . $val;
};
/* write the log line to the file */
$tickfile = fopen($filename, "a");
if (!$tickfile) {
http_response_code(500);
die("Error: Unable to open log file. Please check file permissions.");
}
if (fwrite($tickfile, $line . "\n") === false) {
http_response_code(500);
fclose($tickfile);
die("Error: Could not write to log file.");
}
fclose($tickfile);
/* Send "Accepted" header */
http_response_code(202);
echo "OK";