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); } }