Пример #1
0
 public static function processEditThread($change)
 {
     $change['edit_status'] = 'not_reverted';
     if (!isset($s)) {
         $change['edit_score'] = 'N/A';
         $s = null;
     } else {
         $change['edit_score'] = $s;
     }
     if (!in_array('all', $change) || !isVandalism($change['all'], $s)) {
         Feed::bail($change, 'Below threshold', $s);
         return;
     }
     echo 'Is ' . $change['user'] . ' whitelisted ?' . "\n";
     if (Action::isWhitelisted($change['user'])) {
         Feed::bail($change, 'Whitelisted', $s);
         return;
     }
     echo 'No.' . "\n";
     $reason = 'ANN scored at ' . $s;
     $heuristic = '';
     $log = null;
     $diff = 'https://en.wikipedia.org/w/index.php' . '?title=' . urlencode($change['title']) . '&diff=' . urlencode($change['revid']) . '&oldid=' . urlencode($change['old_revid']);
     $report = '[[' . str_replace('File:', ':File:', $change['title']) . ']] was ' . '[' . $diff . ' changed] by ' . '[[Special:Contributions/' . $change['user'] . '|' . $change['user'] . ']] ' . '[[User:'******'user'] . '|(u)]] ' . '[[User talk:' . $change['user'] . '|(t)]] ' . $reason . ' on ' . gmdate('c');
     $oftVand = unserialize(file_get_contents('oftenvandalized.txt'));
     if (rand(1, 50) == 2) {
         foreach ($oftVand as $art => $artVands) {
             foreach ($artVands as $key => $time) {
                 if (time() - $time > 2 * 24 * 60 * 60) {
                     unset($oftVand[$art][$key]);
                 }
             }
         }
     }
     $oftVand[$change['title']][] = time();
     if (count($oftVand[$change['title']]) >= 30) {
         IRC::say('reportchannel', '!admin [[' . $change['title'] . ']] has been vandalized ' . count($oftVand[$change['title']]) . ' times in the last 2 days.');
     }
     file_put_contents('oftenvandalized.txt', serialize($oftVand));
     $ircreport = "15[[07" . $change['title'] . "15]] by \"03" . $change['user'] . "15\" (12 " . $change['url'] . " 15) 06" . $s . "15 (";
     $change['mysqlid'] = Db::detectedVandalism($change['user'], $change['title'], $heuristic, $reason, $change['url'], $change['old_revid'], $change['revid']);
     echo 'Should revert?' . "\n";
     list($shouldRevert, $revertReason) = Action::shouldRevert($change);
     $change['revert_reason'] = $revertReason;
     if ($shouldRevert) {
         echo 'Yes.' . "\n";
         $rbret = Action::doRevert($change);
         if ($rbret !== false) {
             $change['edit_status'] = 'reverted';
             RedisProxy::send($change);
             IRC::say('debugchannel', $ircreport . "04Reverted15) (13" . $revertReason . "15) (02" . (microtime(true) - $change['startTime']) . " 15s)");
             Action::doWarn($change, $report);
             Db::vandalismReverted($change['mysqlid']);
             Feed::bail($change, $revertReason, $s, true);
         } else {
             $change['edit_status'] = 'beaten';
             $rv2 = Api::$a->revisions($change['title'], 1);
             if ($change['user'] != $rv2[0]['user']) {
                 RedisProxy::send($change);
                 IRC::say('debugchannel', $ircreport . "03Not Reverted15) (13Beaten by " . $rv2[0]['user'] . "15) (02" . (microtime(true) - $change['startTime']) . " 15s)");
                 Db::vandalismRevertBeaten($change['mysqlid'], $change['title'], $rv2[0]['user'], $change['url']);
                 Feed::bail($change, 'Beaten by ' . $rv2[0]['user'], $s);
             }
         }
     } else {
         RedisProxy::send($change);
         IRC::say('debugchannel', $ircreport . "03Not Reverted15) (13" . $revertReason . "15) (02" . (microtime(true) - $change['startTime']) . " 15s)");
         Feed::bail($change, $revertReason, $s);
     }
 }
Пример #2
0
 public static function processEditThread($change)
 {
     $change['edit_status'] = 'not_reverted';
     if (!isset($s)) {
         $change['edit_score'] = 'N/A';
     } else {
         $change['edit_score'] = $s;
     }
     if (!isVandalism($change['all'], $s)) {
         Feed::bail($change, 'Below threshold', $s);
         return;
     }
     echo 'Is ' . $change['user'] . ' whitelisted ?' . "\n";
     if (Action::isWhitelisted($change['user'])) {
         Feed::bail($change, 'Whitelisted', $s);
         return;
     }
     echo 'No.' . "\n";
     $reason = 'ANN scored at ' . $s;
     $heuristic = '';
     $log = null;
     $diff = 'https://en.wikipedia.org/w/index.php' . '?title=' . urlencode($change['title']) . '&diff=' . urlencode($change['revid']) . '&oldid=' . urlencode($change['old_revid']);
     $report = '[[' . str_replace('File:', ':File:', $change['title']) . ']] was ' . '[' . $diff . ' changed] by ' . '[[Special:Contributions/' . $change['user'] . '|' . $change['user'] . ']] ' . '[[User:'******'user'] . '|(u)]] ' . '[[User talk:' . $change['user'] . '|(t)]] ' . $reason . ' on ' . gmdate('c');
     $oftVand = unserialize(file_get_contents('oftenvandalized.txt'));
     if (rand(1, 50) == 2) {
         foreach ($oftVand as $art => $artVands) {
             foreach ($artVands as $key => $time) {
                 if (time() - $time > 2 * 24 * 60 * 60) {
                     unset($oftVand[$art][$key]);
                 }
             }
         }
     }
     $oftVand[$change['title']][] = time();
     if (count($oftVand[$change['title']]) >= 30) {
         IRC::say('reportchannel', '!admin [[' . $change['title'] . ']] has been vandalized ' . count($oftVand[$change['title']]) . ' times in the last 2 days.');
     }
     file_put_contents('oftenvandalized.txt', serialize($oftVand));
     //IRC::say( 'debugchannel', 'Possible vandalism: ' . $change[ 'title' ] . ' changed by ' . $change[ 'user' ] . ' ' . $reason . '(' . $s . ')' );
     //IRC::say( 'debugchannel', '( https://en.wikipedia.org/w/index.php?title=' . urlencode( $change[ 'title' ] ) . '&action=history | ' . $change[ 'url' ] . ' )' );
     $ircreport = "15[[07" . $change['title'] . "15]] by \"03" . $change['user'] . "15\" (12 " . $change['url'] . " 15) 06" . $s . "15 (";
     checkMySQL();
     $query = 'INSERT INTO `vandalism` ' . '(`id`,`user`,`article`,`heuristic`' . (is_array($log) ? ',`regex`' : '') . ',`reason`,`diff`,`old_id`,`new_id`,`reverted`) ' . 'VALUES ' . '(NULL,\'' . mysql_real_escape_string($change['user']) . '\',' . '\'' . mysql_real_escape_string($change['title']) . '\',' . '\'' . mysql_real_escape_string($heuristic) . '\',' . (is_array($log) ? '\'' . mysql_real_escape_string($logt) . '\',' : '') . '\'' . mysql_real_escape_string($reason) . '\',' . '\'' . mysql_real_escape_string($change['url']) . '\',' . '\'' . mysql_real_escape_string($change['old_revid']) . '\',' . '\'' . mysql_real_escape_string($change['revid']) . '\',0)';
     mysql_query($query, Globals::$mysql);
     $change['mysqlid'] = mysql_insert_id();
     echo 'Should revert?' . "\n";
     list($shouldRevert, $revertReason) = Action::shouldRevert($change);
     $change['revert_reason'] = $revertReason;
     if ($shouldRevert) {
         echo 'Yes.' . "\n";
         $rbret = Action::doRevert($change);
         if ($rbret !== false) {
             $change['edit_status'] = 'reverted';
             RedisProxy::send($change);
             //IRC::say( 'debugchannel', 'Reverted. (' . ( microtime( true ) - $change[ 'startTime' ] ) . ' s)' );
             IRC::say('debugchannel', $ircreport . "04Reverted15) (13" . $revertReason . "15) (02" . (microtime(true) - $change['startTime']) . " 15s)");
             Action::doWarn($change, $report);
             checkMySQL();
             mysql_query('UPDATE `vandalism` SET `reverted` = 1 WHERE `id` = \'' . mysql_real_escape_string($change['mysqlid']) . '\'', Globals::$mysql);
             Feed::bail($change, $revertReason, $s, true);
         } else {
             $change['edit_status'] = 'beaten';
             $rv2 = API::$a->revisions($change['title'], 1);
             if ($change['user'] != $rv2[0]['user']) {
                 //IRC::say( 'debugchannel', 'Grr! Beaten by ' . $rv2[ 0 ][ 'user' ] );
                 RedisProxy::send($change);
                 IRC::say('debugchannel', $ircreport . "03Not Reverted15) (13Beaten by " . $rv2[0]['user'] . "15) (02" . (microtime(true) - $change['startTime']) . " 15s)");
                 checkMySQL();
                 mysql_query('INSERT INTO `beaten` (`id`,`article`,`diff`,`user`) VALUES (NULL,\'' . mysql_real_escape_string($change['title']) . '\',\'' . mysql_real_escape_string($change['url']) . '\',\'' . mysql_real_escape_string($rv2[0]['user']) . '\')', Globals::$mysql);
                 Feed::bail($change, 'Beaten by ' . $rv2[0]['user'], $s);
             }
         }
     } else {
         RedisProxy::send($change);
         IRC::say('debugchannel', $ircreport . "03Not Reverted15) (13" . $revertReason . "15) (02" . (microtime(true) - $change['startTime']) . " 15s)");
         Feed::bail($change, $revertReason, $s);
     }
 }