本文整理汇总了PHP中Action::isWhitelisted方法的典型用法代码示例。如果您正苦于以下问题:PHP Action::isWhitelisted方法的具体用法?PHP Action::isWhitelisted怎么用?PHP Action::isWhitelisted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Action
的用法示例。
在下文中一共展示了Action::isWhitelisted方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getAction
protected static function _getAction()
{
do {
$action = readline("action > ");
if ($action === false) {
break;
}
$action = trim($action);
if ($action === '') {
echo implode("\n", Action::$whitelist), "\n\n";
} else {
if (in_array($action, ['q', 'quit'])) {
return false;
} else {
if ($action) {
if (!Action::isWhitelisted($action)) {
echo "Action not found\n";
$action = '';
}
}
}
}
} while ($action === '');
return $action;
}
示例2: processEditThread
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:' . $change['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);
}
}
示例3: processEditThread
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:' . $change['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);
}
}