public static function badWordsTest($title) { global $wgLanguageCode; wfProfileIn(__METHOD__); $text = preg_replace('/[^\\PP]+/', '', $title->getText()); $text = preg_replace('/\\s+/', ' ', $text); $blocksData = Phalanx::getFromFilter(Phalanx::TYPE_ANSWERS_QUESTION_TITLE, $wgLanguageCode); $blockData = null; $result = Phalanx::findBlocked($text, $blocksData, true, $blockData); if ($result['blocked']) { Wikia::log(__METHOD__, __LINE__, "Block '{$result['msg']}' blocked '{$text}'."); wfProfileOut(__METHOD__); return false; } wfProfileOut(__METHOD__); return true; }
public static function isAllowedText($text, $where, $split) { wfProfileIn(__METHOD__); $text = trim($text); $blocksData = Phalanx::getFromFilter(Phalanx::TYPE_WIKI_CREATION); if (!empty($blocksData) && !empty($text)) { $blockData = null; $result = Phalanx::findBlocked($text, $blocksData, true, $blockData); if ($result['blocked']) { wfProfileOut(__METHOD__); Wikia::log(__METHOD__, __LINE__, "Block '{$result['msg']}' blocked '{$text}'."); return false; } } wfProfileOut(__METHOD__); return true; }
public static function filterWordsTest($question) { wfProfileIn(__METHOD__); $text = preg_replace('/\\pP+/', '', $question); $text = preg_replace('/\\s+/', ' ', $text); $blocksData = Phalanx::getFromFilter(Phalanx::TYPE_ANSWERS_RECENT_QUESTIONS); if (!empty($blocksData) && !empty($text)) { $blockData = null; $result = Phalanx::findBlocked($text, $blocksData, true, $blockData); if ($result['blocked']) { Wikia::log(__METHOD__, __LINE__, "Block '{$result['msg']}' blocked '{$text}'."); wfProfileOut(__METHOD__); return false; } } wfProfileOut(__METHOD__); return true; }
public static function checkTitle($title) { wfProfileIn(__METHOD__); if (is_null(self::$blocksData)) { self::$blocksData = Phalanx::getFromFilter(Phalanx::TYPE_TITLE); } $fullText = $title->getFullText(); $result = array('blocked' => false); if (!empty(self::$blocksData)) { $blockData = null; $result = Phalanx::findBlocked($fullText, self::$blocksData, true, $blockData); if ($result['blocked']) { self::spamPage($result['msg'], $title); Wikia::log(__METHOD__, __LINE__, "Block '{$result['msg']}' blocked '{$fullText}'."); } } wfProfileOut(__METHOD__); return !$result['blocked']; }
/** * Hook handler * Checks if user just being created is not blocked * * @author wladek * @param $user User * @param $name string * @param $validate string */ public static function onAbortNewAccount($user, &$abortError) { $text = $user->getName(); $blocksData = Phalanx::getFromFilterShort(self::TYPE); $state = self::blockCheckInternal($user, $blocksData, $text, true); if (!$state) { $abortError = wfMsg('phalanx-user-block-new-account'); return false; } // Check if email is blocked $emailBlocksData = Phalanx::getFromFilter(Phalanx::TYPE_EMAIL); $userEmail = $user->getEmail(); if ($userEmail !== '') { $result = Phalanx::findBlocked($userEmail, $emailBlocksData, true); if ($result['blocked']) { $abortError = wfMsg('phalanx-user-block-new-account'); return false; } } return true; }
public static function genericContentCheck($content) { wfProfileIn(__METHOD__); $blocksData = Phalanx::getFromFilter(Phalanx::TYPE_CONTENT); if (!empty($blocksData) && $content != '') { $content = self::applyWhitelist($content); $blockData = null; $result = Phalanx::findBlocked($content, $blocksData, true, $blockData); if ($result['blocked']) { Wikia::log(__METHOD__, __LINE__, "Block '{$result['msg']}' blocked '{$content}'."); wfProfileOut(__METHOD__); return false; } } wfProfileOut(__METHOD__); return true; }
/** * testBlock * * performs a test of all available filters and returns matching filters * * @param $text String to match * @return String with HTML to display via AJAX * * @author tor <*****@*****.**> */ public static function testBlock($text) { $data = array(); $output = ''; $aModules = Phalanx::$typeNames; $link_unblock = wfMsg('phalanx-link-unblock'); $link_modify = wfMsg('phalanx-link-modify'); $link_stats = wfMsg('phalanx-link-stats'); foreach ($aModules as $module => $name) { $filters = Phalanx::getFromFilter($module); $data[$module] = array(); if (empty($filters)) { continue; } $filter = null; $result = Phalanx::findBlocked($text, $filters, true, $filter); if ($result['blocked'] == true) { $data[$module][] = $filter; } if (!empty($data[$module])) { $output .= Xml::element('h2', null, $name); $output .= Xml::openElement('ul'); foreach ($data[$module] as $match) { $phalanxUrl = Title::newFromText('Phalanx', NS_SPECIAL)->getFullUrl(array('id' => $match['id'])); $statsUrl = Title::newFromText('PhalanxStats', NS_SPECIAL)->getFullUrl() . '/' . $match['id']; $line = htmlspecialchars($match['text']) . ' • ' . Xml::element('a', array('href' => $phalanxUrl, 'class' => 'unblock'), $link_unblock) . ' • ' . Xml::element('a', array('href' => $phalanxUrl, 'class' => 'modify'), $link_modify) . ' • ' . Xml::element('a', array('href' => $statsUrl, 'class' => 'stats'), $link_stats) . ' • ' . '#' . $match['id']; $output .= Xml::tags('li', null, $line); } $output .= Xml::closeElement('ul'); } } if (empty($output)) { $output = 'No matches found.'; } return $output; }