public static function getMatchingEdits($username, $begin, $end, $count, $api = false) { global $dbr, $phptemp; $timeconds = array('rev_user_text' => $username); if ($begin) { $timeconds[] = 'UNIX_TIMESTAMP(rev_timestamp) > ' . $dbr->strencode(strtotime($begin)); } if ($end) { $timeconds[] = 'UNIX_TIMESTAMP(rev_timestamp) < ' . $dbr->strencode(strtotime($end)); } $contribs = $urls = array(); foreach (AutoEditsBase::$AEBTypes as $name => $check) { $conds = $timeconds; $conds[] = 'rev_comment ' . $check['type'] . ' \'' . $check['query'] . '\''; try { $res = $dbr->select(array('revision_userindex'), array('COUNT(*) AS count'), $conds); $contribs[$name] = $res[0]['count']; } catch (Exception $e) { if ($api) { return array('error' => 'dberror', 'info' => $e->getMessage()); } WebTool::toDieMsg('mysqlerror', $e->getMessage()); } $urls[$name] = $check['shortcut']; } $formattedpct = WebTool::number_format(($count ? array_sum($contribs) / $count : 0) * 100, 2); if ($api) { return array('counts' => $contribs, 'total' => array_sum($contribs), 'editcount' => $count, 'pct' => $formattedpct); } else { return array('counts' => $contribs, 'total' => WebTool::number_format(array_sum($contribs), 0), 'editcount' => WebTool::number_format($count, 0), 'pct' => $formattedpct, 'urls' => $urls); } }
if ($lang == "en" && $wiki == "wikipedia") { //WebTool::toDie( "In order to both discourage editcountitis and give the English Wikipedia editors a chance to realize what editing is all about and why I created this tool in the first place, I have disabled my edit counters (pcount, simplecount, autoedits) until August 17 2010. Please use this time to reflect on why I made this tool in the first place: To serve curiosity, not to create false judgement descisions about editors. -X! 13 August 2010" ); } $user = WebTool::prettyTitle($wgRequest->getSafeVal('user'), true); //Initialize Peachy try { $userClass = $site->initUser($user); } catch (Exception $e) { WebTool::toDie($e->getMessage()); } $phptemp->assign("page", $user); if (!$userClass->exists()) { WebTool::toDieMsg('nosuchuser', $user); } $useLabs = true; $count = $userClass->get_editcount(false, $dbr); //Here if ($count > 100000) { WebTool::toDieMsg('toomanyedits', 100000); } //Start doing the DB request $data = AutoEditsBase::getMatchingEdits($user, $wgRequest->getSafeVal('getBool', 'begin') ? $wgRequest->getSafeVal('begin') : false, $wgRequest->getSafeVal('getBool', 'end') ? $wgRequest->getSafeVal('end') : false, $count); $content->assign('showedits', true); $content->assign('data', $data['counts']); $content->assign('tools', AutoEditsBase::$AEBTypes); $content->assign('url', $url); $content->assign('totalauto', $data['total']); $content->assign('totalall', $data['editcount']); $content->assign('pct', $data['pct']); $content->assign('urls', $data['urls']); WebTool::finishScript();