function insertEdit($id, $isVand, $isActive, $reviewers, $reviewers_agreeing, $source, $data = null) { $mysql = getMasterMySQL(); if ($data === null) { $data = oldData($id); } if ($data === false) { echo 'Bad revid. Not inserted.'; return false; } $query = 'REPLACE INTO `editset` ( `edittype`, `editid`, `comment`, `user`, `user_edit_count`, `user_distinct_pages`, `user_warns`, `prev_user`, `user_reg_time`, `common_page_made_time`, `common_title`, `common_namespace`, `common_creator`, `common_num_recent_edits`, `common_num_recent_reversions`, `current_minor`, `current_timestamp`, `current_text`, `previous_timestamp`, `previous_text`, `isvandalism`, `isactive`, `source`, `reviewers`, `reviewers_agreeing` ) VALUES ('; $escaped = array($data['EditType'], $data['EditID'], $data['comment'], $data['user'], $data['user_edit_count'], $data['user_distinct_pages'], $data['user_warns'], $data['prev_user'], $data['user_reg_time'], $data['common']['page_made_time'], $data['common']['title'], $data['common']['namespace'], $data['common']['creator'], $data['common']['num_recent_edits'], $data['common']['num_recent_reversions'], $data['current']['minor'] == 'true' ? 1 : 0, $data['current']['timestamp'], $data['current']['text'], $data['previous']['timestamp'], $data['previous']['text'], $isVand ? 1 : 0, $isActive ? 1 : 0, $source, $reviewers, $reviewers_agreeing); foreach ($escaped as $key => &$value) { if ($key == 8 or $key == 9 or $key == 16 or $key == 18) { $value = 'FROM_UNIXTIME( \'' . mysql_real_escape_string($value) . '\' )'; } else { $value = '\'' . mysql_real_escape_string($value) . '\''; } } $query .= implode(',', $escaped); $query .= ' )'; $ret = mysql_query($query); if (!$ret) { echo 'Error inserting ' . $id . ': ' . mysql_error(); return false; } return true; }
function processEdit(&$stack, &$frame) { $id = $frame['ID']; $isVand = $frame['RealClassification'] == 'V' ? 1 : 0; if ($isVand or $frame['RealClassification'] == 'C') { $isActive = 1; } else { $isActive = 0; } $reviewers = $frame['Vandalism'] + $frame['Constructive'] + $frame['Skipped']; $reviewers_agreeing = max($frame['Vandalism'], $frame['Constructive'], $frame['Skipped']); $source = 'Review Interface'; foreach ($stack as &$stackFrame) { if (isset($stackFrame['Name'])) { $source = $stackFrame['Name']; } } $mysql = getMasterMySQL(); $row = mysql_fetch_assoc(mysql_query('SELECT `isvandalism`, `isactive`, `reviewers`, `reviewers_agreeing` FROM `editset` WHERE `editid` = \'' . mysql_real_escape_string($id) . '\'')); if (!$row) { echo 'Inserting ' . $id . ' ...'; $ret = insertEdit($id, $isVand, $isActive, $reviewers, $reviewers_agreeing, $source); if ($ret) { echo ' Done.' . "\n"; } else { echo ' Failed.' . "\n"; } } else { $updates = array(); if ($row['isvandalism'] != $isVand) { $updates[] = '`isvandalism` = \'' . mysql_real_escape_string($isVand) . '\''; } if ($row['isactive'] != $isActive) { $updates[] = '`isactive` = \'' . mysql_real_escape_string($isActive) . '\''; } if ($row['reviewers'] != $reviewers) { $updates[] = '`reviewers` = \'' . mysql_real_escape_string($reviewers) . '\''; } if ($row['reviewers_agreeing'] != $reviewers_agreeing) { $updates[] = '`reviewers_agreeing` = \'' . mysql_real_escape_string($reviewers_agreeing) . '\''; } if (count($updates) > 0) { echo 'Updating ' . $id . ' ...'; $ret = mysql_query('UPDATE `editset` SET ' . implode(', ', $updates) . ' WHERE `editid` = \'' . mysql_real_escape_string($id) . '\''); if ($ret) { echo ' Done.' . "\n"; } else { echo ' Failed.' . "\n"; } } } }
sleep(1); echo "[1;31m>>>[1;32m 8 [1;31m<<<[0m\n"; sleep(1); echo "[1;31m>>>[1;32m 7 [1;31m<<<[0m\n"; sleep(1); echo "[1;31m>>>[1;32m 6 [1;31m<<<[0m\n"; sleep(1); echo "[1;31m>>>[1;32m 5 [1;31m<<<[0m\n"; sleep(1); echo "[1;31m>>>[1;32m 4 [1;31m<<<[0m\n"; sleep(1); echo "[1;31m>>>[1;32m 3 [1;31m<<<[0m\n"; sleep(1); echo "[1;31m>>>[1;32m 2 [1;31m<<<[0m\n"; sleep(1); echo "[1;31m>>>[1;32m 1 [1;31m<<<[0m\n"; sleep(1); echo "[1;31m>>>[1;32m 0 [1;31m<<<[0m\n"; sleep(2); echo 'Please wait while the master database is refreshed.' . "\n"; $mysql = getMasterMySQL(); $total = mysql_fetch_assoc(mysql_query('SELECT COUNT(*) AS `count` FROM `editset`')); $total = $total['count']; $count = 0; $results = mysql_query('SELECT `editid`, `isvandalism`, `isactive`, `reviewers`, `reviewers_agreeing`, `source` FROM `editset`'); while ($row = mysql_fetch_assoc($results)) { $count++; echo "[1;32m" . round($count * 100 / $total) . "[1;31m% ([1;32m" . $count . "[1;31m/[1;32m" . $total . "[1;31m)[1;36m: [1;32m" . $row['editid'] . "[1;33m ... [1;32m"; processRow($row['editid'], $row['isvandalism'], $row['isactive'], $row['reviewers'], $row['reviewers_agreeing'], $row['source']); echo "[1;32m Done![0m\n"; }