2025-08-20 22:58:42 +03:00
|
|
|
<?php /* MONITOR PLUGIN HEARTBEAT TICKER SCRIPT */
|
|
|
|
|
|
|
|
|
|
/* build the resulting log line (ensure fixed column positions!) */
|
|
|
|
|
$logArr = Array(
|
2025-08-26 21:37:19 +03:00
|
|
|
$_SERVER['REMOTE_ADDR'] ?? '', /* remote IP */
|
|
|
|
|
$_GET['p'] ?? '', /* page ID */
|
2025-08-30 18:40:16 +03:00
|
|
|
$_COOKIE['DokuWiki'] ?? session_id() ?? '', /* DokuWiki session ID */
|
|
|
|
|
$_SERVER['HTTP_USER_AGENT'] ?? '' /* User agent */
|
2025-08-20 22:58:42 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* create the log line */
|
2025-09-01 10:15:36 +02:00
|
|
|
$filename = 'logs/' . gmdate('Y-m-d') . '.tck.txt'; /* use GMT date for filename */
|
2025-08-20 22:58:42 +03:00
|
|
|
$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 */
|
2025-08-26 21:37:19 +03:00
|
|
|
$tickfile = fopen($filename, 'a');
|
2025-08-20 22:58:42 +03:00
|
|
|
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";
|