1<?php /* BOTMON PLUGIN HEARTBEAT TICKER SCRIPT */ 2 3 // Note: this script is normally called in HEAD mode, therefore it can not return any payload. 4 5 // what is the session identifier? 6 $sessionId = preg_replace('/[\x00-\x1F{};\"\']/', "\u{FFFD}", $_GET['id']) /* clean json parameter */ 7 ?? session_id() 8 ?? $_SERVER['REMOTE_ADDR']; 9 10 11 // clean the page ID 12 $pageId = preg_replace('/[\x00-\x1F]/', "\u{FFFD}", $_GET['p'] ?? ''); 13 14 // clean the user agent string 15 $agent = preg_replace('/[\x00-\x1F]/', "\u{FFFD}", $_SERVER['HTTP_USER_AGENT'] ?? ''); 16 17 /* build the resulting log line */ 18 $logArr = Array( 19 $_SERVER['REMOTE_ADDR'] ?? '', /* Remote IP */ 20 $pageId, /* Page ID */ 21 $sessionId, /* Session ID */ 22 $agent /* User agent */ 23 ); 24 25 /* create the log line */ 26 $filename = 'logs/' . gmdate('Y-m-d') . '.tck.txt'; /* use GMT date for filename */ 27 $line = gmdate('Y-m-d H:i:s'); /* use GMT time for log entries */ 28 foreach ($logArr as $val) { 29 $line .= "\t" . $val; 30 }; 31 32 /* write the log line to the file */ 33 $tickfile = fopen($filename, 'a'); 34 if (!$tickfile) { 35 http_response_code(500); 36 die("Error: Unable to open log file. Please check file permissions."); 37 } 38 if (fwrite($tickfile, $line . "\n") === false) { 39 http_response_code(507); 40 fclose($tickfile); 41 die("Error: Could not write to log file."); 42 } 43 fclose($tickfile); 44 45 /* Send "Accepted" header */ 46 http_response_code(202); 47 echo "OK";