예제 #1
0
 */
// MediaWiki
ini_set("include_path", dirname(__FILE__) . "/../../../../../maintenance/");
require_once "commandLine.inc";
// Phalanx caches its blocks by the type and by the language. Let's
// get supported types and languages.
$aTypes = array_keys(PhalanxFallback::$typeNames);
$aLanguages = array_keys($wgPhalanxSupportedLanguages);
function getmicrotime()
{
    list($usec, $sec) = explode(" ", microtime());
    return (double) $usec + (double) $sec;
}
// Walk through all types...
foreach ($aTypes as $iType) {
    // ... and languages.
    foreach ($aLanguages as $sLanguage) {
        $time_start = getmicrotime();
        // Fill the cache with the current data from DB_MASTER.
        PhalanxFallback::getFromFilter($iType, $sLanguage, true, true);
        if ($iType == Phalanx::TYPE_USER) {
            PhalanxFallback::getFromFilterShort($iType, $sLanguage, true, true);
        }
        $time_end = getmicrotime();
        $time = $time_end - $time_start;
        echo "iType = " . PhalanxFallback::$typeNames[$iType] . " ( {$iType} ) , {$sLanguage}, " . sprintf("%0.2f", $time) . " sec \n";
    }
    // Touch.
    PhalanxFallback::setLastUpdate();
}
exit(0);
예제 #2
0
 /**
  * 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, &$block)
 {
     $text = $user->getName();
     $blocksData = PhalanxFallback::getFromFilterShort(self::TYPE);
     $state = self::blockCheckInternal($user, $blocksData, $text, $block, true);
     if (!$state) {
         $abortError = wfMsg('phalanx-user-block-new-account');
         return false;
     }
     // Check if email is blocked
     $emailBlocksData = PhalanxFallback::getFromFilter(PhalanxFallback::TYPE_EMAIL);
     $userEmail = $user->getEmail();
     if ($userEmail !== '') {
         $blockData = null;
         $result = PhalanxFallback::findBlocked($userEmail, $emailBlocksData, true, $blockData);
         if ($result['blocked']) {
             $block = (object) $blockData;
             $abortError = wfMsg('phalanx-user-block-new-account');
             return false;
         }
     }
     return true;
 }