function wfGetRegexBlocked($blocker, $user, $user_ip) { global $wgContactLink; $names = wfGetRegexBlockedData($blocker, $user, REGEXBLOCK_MODE_NAMES); $ips = wfGetRegexBlockedData($blocker, $user, REGEXBLOCK_MODE_IPS); $username = $user->getName(); $matched_name = preg_match('/' . $names . '/i', $user->getName(), $matches); $matched_ip = preg_match('/' . $ips . '/i', $user_ip, $ip_matches); if ($matched_name && $names != "" || $matched_ip && $ips != "") { /* check if this block hasn't expired already */ if ($matched_ip && $ips != "") { $valid = wfRegexBlockExpireCheck($user, null, $ip_matches); } else { $valid = wfRegexBlockExpireCheck($user, $matches, null); } if (is_array($valid)) { $user->mBlockedby = $blocker; if ($valid['reason'] != "") { /* a reason was given, display it */ $user->mBlockreason = $valid['reason']; } else { /* display generic reasons */ if ($matched_ip && $ips != "") { /* we blocked by IP */ $user->mBlockreason = wfMsgHtml('regexblock-reason-ip', $wgContactLink); } else { if ($valid['exact'] == 1) { /* we blocked by username exact match */ $user->mBlockreason = wfMsgHtml('regexblock-reason-name', $wgContactLink); } else { /* we blocked by regex match */ $user->mBlockreason = wfMsgHtml('regexblock-reason-regex', $wgContactLink); } } } /* account creation check goes through the same hook... */ if ($valid['create'] == 1) { $user->mBlock->mCreateAccount = 1; } wfRegexBlockUpdateStats($username, $user_ip, $blocker); } } }
function wfRegexBlockSetUserData(&$user, $user_ip, $blocker, $valid) { global $wgContactLink, $wgRequest; wfProfileIn(__METHOD__); $result = false; if (!$user instanceof User) { wfProfileOut(__METHOD__); return $result; } if (empty($wgContactLink)) { $wgContactLink = '[[Special:Contact|contact Wikia]]'; } if (is_array($valid)) { $user->mBlockedby = User::idFromName($blocker); if ($valid['reason'] != "") { /* a reason was given, display it */ $user->mBlockreason = $valid['reason']; } else { /* display generic reasons */ /* default we blocked by regex match */ $user->mBlockreason = wfMsg('regexblock_reason_regex', array($wgContactLink)); if ($valid['ip'] == 1) { /* we blocked by IP */ $user->mBlockreason = wfMsg('regexblock_reason_ip', array($wgContactLink)); } else { if ($valid['exact'] == 1) { /* we blocked by username exact match */ $user->mBlockreason = wfMsg('regexblock_reason_name', array($wgContactLink)); } } } /* account creation check goes through the same hook... */ if ($valid['create'] == 1) { if ($user->mBlock) { $user->mBlock->setCreateAccount(1); } } /* set expiry information */ if ($user->mBlock) { $user->mBlock->setId($valid['blckid']); # correct inifinity keyword on the fly, see rt#25419 $user->mBlock->mExpiry = $valid['expire'] == 'infinite' ? 'infinity' : $valid['expire']; $user->mBlock->mTimestamp = $valid['timestamp']; $user->mBlock->setTarget($valid['ip'] == 1 ? $wgRequest->getIP() : $user->getName()); } if (wfReadOnly()) { $result = true; } else { $result = wfRegexBlockUpdateStats($user, $user_ip, $blocker, $valid['match'], $valid['blckid']); } } wfProfileOut(__METHOD__); return $result; }