|
|
(3 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | <? | + | {{legacy}} |
| + | {{info|Logging of user logins, logouts and login errors is now handled by the [[MW:Extension:UserLoginLog|UserLoginLog extension]]. The code for UserLoginLog is [[Extension:UserLoginLog.php]].}} |
| + | <php><? |
| # Log user login activity | | # Log user login activity |
| function monitorUserLogin(&$text) { | | function monitorUserLogin(&$text) { |
Line 18: |
Line 20: |
| } | | } |
| } | | } |
− | ?> | + | ?></php> |
Latest revision as of 05:17, 23 July 2011
|
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><?
- 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>