Difference between revisions of "MonitorUserLogin.php"

From Organic Design wiki
m
({{legacy}}, Category:MediaWiki)
Line 1: Line 1:
<?
+
{{legacy}}
 +
<php><?
 
# Log user login activity
 
# Log user login activity
 
function monitorUserLogin(&$text) {
 
function monitorUserLogin(&$text) {
Line 18: Line 19:
 
}
 
}
 
}
 
}
?>
+
?></php>
 +
[[Category:MediaWiki]]

Revision as of 11:52, 18 July 2007

Legacy.svg Legacy: This article describes a concept that has been superseded in the course of ongoing development on the Organic Design wiki. Please do not develop this any further or base work on this concept, now this page is for historic record only.

<php><?

  1. Log user login activity

function monitorUserLogin(&$text) { $entry = ;

if (preg_match('/

Login error:<\\/h2>\\s*(.+?)\\s*<\\/div>/',$text,$error)) $entry = "Login Error: $error[1]"; else if (preg_match('/You are now logged in to .+? as "(.+?)".<\\/b>/',$text,$user)) $entry = "User Login: [[User:$user[1]]] has logged in sucecssfuly"; if ($entry) { $ts = $GLOBALS['wgLang']->timeanddate(wfTimestampNow(),true); $la = new Article(Title::newFromText('Event log')); $log = $la->fetchContent(0,false,false); $log .= "\n*$ts: $entry"; $log .= "\n:IP Address: ".$_SERVER['REMOTE_ADDR']; $log .= "\n:User Agent: ".$_SERVER['HTTP_USER_AGENT']; $log .= "\n:Cookie: ".$_SERVER['HTTP_COOKIE']; $log .= "\n:Query-string: ".$_SERVER['QUERY_STRING']; $la->quickEdit($log); } } ?></php>