Minor fixes
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
# DokuWiki Monitoring Plugin
|
||||
Plugin for live-monitoring your DokuWiki instance
|
||||
|
||||
#TODO: Work in progress
|
||||
#TODO: Work in progress
|
||||
|
||||
IMPORTANT: This is an experimental plugin to investigate bot traffic. This is not a "install and forget" software, but rather requires that you actively look at and manage the log files.
|
||||
|
||||
This plugin creates various log files in its own "logs" directory. These files can get quite large, and you should check them actively.
|
||||
|
||||
Also, these files can get quite large and fill up your server. Make sure to manually delete older files from time to time!
|
||||
|
||||
21
action.php
21
action.php
@@ -55,10 +55,25 @@ class action_plugin_monitor extends DokuWiki_Action_Plugin {
|
||||
|
||||
/* Write out client info to a server log: */
|
||||
|
||||
// what is the session identifier?
|
||||
$sessionId = $_COOKIE['DokuWiki'] ?? null;
|
||||
if (!$sessionId) {
|
||||
if (session_id()) {
|
||||
// if a session ID is set, use it
|
||||
$sessionId = 'P:' . session_id();
|
||||
} else {
|
||||
// if no session ID is set, use an empty string
|
||||
$sessionId = '';
|
||||
}
|
||||
} else {
|
||||
// if no cookie is set, use the session ID
|
||||
$sessionId = 'D:' . $sessionId;
|
||||
}
|
||||
|
||||
$logArr = Array(
|
||||
$_SERVER['REMOTE_ADDR'] ?? '–', /* remote IP */
|
||||
$INFO['id'] ?? '–', /* user agent */
|
||||
$_COOKIE['DokuWiki'] ?? '–', /* DokuWiki session ID */
|
||||
$_SERVER['REMOTE_ADDR'] ?? '', /* remote IP */
|
||||
$INFO['id'] ?? '', /* page ID */
|
||||
$sessionId, /* Session ID */
|
||||
$username,
|
||||
$_SERVER['HTTP_USER_AGENT'] ?? '' /* User agent */
|
||||
);
|
||||
|
||||
24
pview.php
24
pview.php
@@ -9,18 +9,18 @@ if (!$json) {
|
||||
|
||||
/* build the resulting log line (ensure fixed column positions!) */
|
||||
$logArr = Array(
|
||||
$_SERVER['REMOTE_ADDR'] ?? 'null', /* remote IP */
|
||||
$json['pg'] ?? 'null', /* DW page ID */
|
||||
$_COOKIE['DokuWiki'] ?? 'null', /* DokuWiki session ID */
|
||||
$json['u'] ?? 'null' /* DW User id (if logged in) */
|
||||
// $json['tz'] ?? 'null', /* timzone offset */
|
||||
// $json['lg'] ?? 'null', /* browser language */
|
||||
// $json['td'] ?? 'null', /* load time */
|
||||
// $json['scr'] ?? 'null', /* Screen dimensions */
|
||||
// $json['l'] ?? 'null', /* Accepted languages list */
|
||||
// $json['url'] ?? 'null', /* Full request URL */
|
||||
// $json['r'] ?? 'null', /* Referrer URL */
|
||||
// $_SERVER['HTTP_USER_AGENT'] ?? 'null', /* User agent */
|
||||
$_SERVER['REMOTE_ADDR'] ?? '', /* remote IP */
|
||||
$json['pg'] ?? '', /* DW page ID */
|
||||
$_COOKIE['DokuWiki'] ?? session_id() ?? '', /* DokuWiki session ID */
|
||||
$json['u'] ?? '' /* DW User id (if logged in) */
|
||||
// $json['tz'] ?? '', /* timzone offset */
|
||||
// $json['lg'] ?? '', /* browser language */
|
||||
// $json['td'] ?? '', /* load time */
|
||||
// $json['scr'] ?? '', /* Screen dimensions */
|
||||
// $json['l'] ?? '', /* Accepted languages list */
|
||||
// $json['url'] ?? '', /* Full request URL */
|
||||
// $json['r'] ?? '', /* Referrer URL */
|
||||
// $_SERVER['HTTP_USER_AGENT'] ?? '', /* User agent */
|
||||
// $json['t'] ?? '' /* Page title */
|
||||
);
|
||||
|
||||
|
||||
10
tick.php
10
tick.php
@@ -2,20 +2,20 @@
|
||||
|
||||
/* build the resulting log line (ensure fixed column positions!) */
|
||||
$logArr = Array(
|
||||
$_SERVER['REMOTE_ADDR'] ?? 'null', /* remote IP */
|
||||
$_GET['p'] ?? null, /* page ID */
|
||||
$_COOKIE['DokuWiki'] ?? 'null' /* DokuWiki session ID */
|
||||
$_SERVER['REMOTE_ADDR'] ?? '', /* remote IP */
|
||||
$_GET['p'] ?? '', /* page ID */
|
||||
$_COOKIE['DokuWiki'] ?? session_id() ?? '' /* DokuWiki session ID */
|
||||
);
|
||||
|
||||
/* create the log line */
|
||||
$filename = 'logs/' . gmdate('Y-m-d') . ".tck"; /* use GMT date for filename */
|
||||
$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");
|
||||
$tickfile = fopen($filename, 'a');
|
||||
if (!$tickfile) {
|
||||
http_response_code(500);
|
||||
die("Error: Unable to open log file. Please check file permissions.");
|
||||
|
||||
Reference in New Issue
Block a user