static function getAuthors($articleID) { global $wgMemc; $cachekey = self::getLoadAuthorsCachekey($articleID); $authors = $wgMemc->get($cachekey); if (is_array($authors)) { return $authors; } $authors = array(); $dbr = wfGetDB(DB_SLAVE); // filter out bots $bad = WikihowUser::getBotIDs(); $bad[] = 0; // filter out anons too, as per Jack $opts = array('rev_page' => $articleID); if (sizeof($bad) > 0) { $opts[] = 'rev_user NOT IN (' . $dbr->makeList($bad) . ')'; } $res = $dbr->select('revision', array('rev_user', 'rev_user_text'), $opts, __METHOD__, array('ORDER BY' => 'rev_timestamp')); foreach ($res as $row) { if ($row->rev_user == 0) { $authors['anonymous'] = 1; } elseif (!isset($authors[$row->user_text])) { $authors[$row->rev_user_text] = 1; } } if ($authors) { $wgMemc->set($cachekey, $authors); } return $authors; }
private static function getBotIDs() { if (!is_array(self::$mBots)) { self::$mBots = WikihowUser::getBotIDs(); } return self::$mBots; }
function wfCheckQC(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision) { global $wgChangedTemplatesToQC; // if an article becomes a redirect, vanquish all previous qc entries if (preg_match("@^#REDIRECT@", $text)) { QCRule::markAllAsPatrolled($article->getTitle()); return true; } // check for bots $bots = WikihowUser::getBotIDs(); if (in_array($user->getID(), $bots)) { return true; } // ignore reverted edits if (preg_match("@Reverted edits by@", $summary)) { return true; } // check for intro image change, reverts are ok for this one // $l = new QCRuleIntroImage($revision, $article); // $l->process(); // do the templates foreach ($wgChangedTemplatesToQC as $t) { wfDebug("QC: About to process template change {$t}\n"); $l = new QCRuleTemplateChange($t, $revision, $article); $l->process(); } // check for video changes $l = new QCRuleVideoChange($revision, $article); $l->process(); return true; }
/** * * Provides the content in the footer of the widget * for the top contributor to this widget */ public function getTopContributor(&$dbr) { $startdate = strtotime('7 days ago'); $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000'; $bots = WikihowUser::getBotIDs(); $bot = ""; if (sizeof($bots) > 0) { $bot = " AND fe_user NOT IN (" . $dbr->makeList($bots) . ", '0') "; } $sql = "SELECT fe_user_text, fe_user, count(fe_user) as fe_count, MAX(fe_timestamp) as fe_timestamp " . "FROM firstedit left join page on fe_page = page_id left join suggested_titles on page_title= st_title " . "WHERE fe_timestamp >= '{$starttimestamp}' AND st_isrequest IS NOT NULL" . $bot . " GROUP BY fe_user ORDER BY fe_count DESC"; $res = $dbr->query($sql); $row = $dbr->fetchObject($res); $res->free(); return $this->populateUserObject($row->fe_user, $row->fe_timestamp); }
function getLastEditedInfo() { global $wgTitle; if (self::$mLastEditedInfo) { return self::$mLastEditedInfo; } $dbr = wfGetDB(DB_SLAVE); $bad = WikihowUser::getBotIDs(); $bad[] = 0; // filter out anons too, as per Jack $row = $dbr->selectRow('revision', array('rev_user', 'rev_user_text', 'rev_timestamp'), array('rev_user NOT IN (' . $dbr->makeList($bad) . ")", "rev_page" => $wgTitle->getArticleID()), __METHOD__, array("ORDER BY" => "rev_id DESC", "LIMIT" => 1)); $info->rev_user_text = $row->rev_user_text; $info->rev_user = $row->rev_user; $info->rev_timestamp = $row->rev_timestamp; self::$mLastEditedInfo = $info; return $info; }
/** * * Provides the content in the footer of the widget * for the top contributor to this widget */ public function getTopContributor(&$dbr) { $sql = ""; $bots = WikihowUser::getBotIDs(); if (sizeof($bots) > 0) { $sql = "log_user NOT IN (" . $dbr->makeList($bots) . ")"; } $startdate = strtotime("7 days ago"); $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000'; if ($sql != "") { $res = $dbr->select('logging', array('*', 'count(*) as C', 'MAX(log_timestamp) as log_recent'), array('log_type' => 'EF_topic', 'log_timestamp > "' . $starttimestamp . '"', $sql), 'StubAppWidget::getTopContributor', array("GROUP BY" => 'log_user', "ORDER BY" => "C DESC", "LIMIT" => 1)); } else { $res = $dbr->select('logging', array('*', 'count(*) as C', 'MAX(log_timestamp) as log_recent'), array('log_type' => 'EF_topic', 'log_timestamp > "' . $starttimestamp . '"'), 'StubAppWidget::getTopContributor', array("GROUP BY" => 'log_user', "ORDER BY" => "C DESC", "LIMIT" => 1)); } $row = $dbr->fetchObject($res); $res->free(); return $this->populateUserObject($row->log_user, $row->log_recent); }
/** * * Provides the content in the footer of the widget * for the top contributor to this widget */ public function getTopContributor(&$dbr) { $startdate = strtotime("7 days ago"); $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000'; $sql = ""; $bots = WikihowUser::getBotIDs(); if (sizeof($bots) > 0) { $sql = "img_user NOT IN (" . $dbr->makeList($bots) . ")"; } if ($sql != "") { $res = $dbr->select('image', array('*', 'count(img_user) as img_count', 'MAX(img_timestamp) as recent_timestamp'), array("img_user_text != 'WRM'", 'img_timestamp > "' . $starttimestamp . '"', $sql), 'AddImagesAppWidget::getTopContributor', array("GROUP BY" => 'img_user', "ORDER BY" => "img_count DESC", "LIMIT" => 1)); } else { $res = $dbr->select('image', array('*', 'count(img_user) as img_count', 'MAX(img_timestamp) as recent_timestamp'), array("img_user_text != 'WRM'", 'img_timestamp > "' . $starttimestamp . '"'), 'AddImagesAppWidget::getTopContributor', array("GROUP BY" => 'img_user', "ORDER BY" => "img_count DESC", "LIMIT" => 1)); } $row = $dbr->fetchObject($res); $res->free(); return $this->populateUserObject($row->img_user, $row->recent_timestamp); }
function wfCheckNFD(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision) { //we only do NFD Guardian for articles if ($article->getTitle()->getNamespace() != NS_MAIN) { return true; } // if an article becomes a redirect, vanquish all previous nfd entries if (preg_match("@^#REDIRECT@", $text)) { NFDProcessor::markPreviousAsInactive($article->getID()); return true; } // check for bots $bots = WikihowUser::getBotIDs(); if (in_array($user->getID(), $bots)) { return true; } if ($revision && $article) { // do the templates wfDebug("NFD: Looking for NFD templates\n"); $l = new NFDProcessor($revision, $article); $l->process(); } return true; }
<?php require_once 'commandLine.inc'; $ignore_cats = array("Featured Articles", "Merge", "Cleanup", "Stub"); $pages = array(); $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select(array('firstedit', 'page'), array('fe_user', 'fe_user_text', 'fe_page'), array('fe_page=page_id', 'page_namespace' => NS_MAIN, 'fe_user > 0'), "init_followcats", array("LIMIT" => 30000)); echo $dbr->lastQuery() . "\n"; while ($row = $dbr->fetchObject($res)) { $pages[$row->fe_page] = $row; } $bots = WikihowUser::getBotIDs(); echo "Got " . sizeof($pages) . " articles\n"; foreach ($pages as $p) { $res = $dbr->select('categorylinks', array('cl_to'), array('cl_from' => $p->fe_page)); while ($row = $dbr->fetchObject($res)) { if (in_array($p->fe_user, $bots)) { continue; } $cat = Title::makeTitle(NS_CATEGORY, $row->cl_to); $u = User::newFromName($p->fe_user_text); $t = Title::newFromID($p->fe_page); if (!$t || !$cat || !$u) { continue; } if (!in_array($cat->getText(), $ignore_cats) && !preg_match("@NFD@", $cat->getText())) { Follow::followCat($t, $cat->getText(), $u); echo "{$u->getName()} is following {$cat->getText()} because of {$t->getFullText()}\n"; } } }
/** * Query for Videos Reviewed **/ function getVideosReviewed($starttimestamp, $lb_user = '', $getArticles = false) { global $wgMemc; if ($getArticles) { $key = "leaderboard:videos_reviewed:{$starttimestamp}:{$lb_user}"; } else { $key = "leaderboard:videos_reviewed:{$starttimestamp}"; } $cachekey = wfMemcKey($key); $val = $wgMemc->get($cachekey); if (is_array($val)) { return $val; } $dbr = wfGetDB(DB_SLAVE); $data = array(); $bot = ""; $bots = WikihowUser::getBotIDs(); if (sizeof($bots) > 0) { $bot = " AND va_user NOT IN (" . $dbr->makeList($bots) . ") "; } $sql = "SELECT va_user, va_user_text, count(*) as C " . "FROM videoadder " . "WHERE va_timestamp >= '{$starttimestamp}' " . $bot . "AND va_skipped_accepted IN ('0','1') " . "GROUP BY va_user ORDER BY C desc "; if ($getArticles) { $u = User::newFromName($lb_user); $u->load(); $id = $u->getID(); $sql = "SELECT va_user, page_title, page_namespace " . "FROM videoadder left join page on page_id=va_page " . "WHERE va_timestamp >= '{$starttimestamp}' and va_user={$id}"; } $res = $dbr->query($sql, __METHOD__); foreach ($res as $row) { if ($getArticles) { $t = Title::makeTitle($row->page_namespace, $row->page_title); if ($t) { $data[$t->getPartialURL()] = $t->getPrefixedText(); } } else { //$data[$row->va_user_text]++; $data[$row->va_user_text] = number_format($row->C, 0, "", ','); } } $wgMemc->set($cachekey, $data, 3600); return $data; }
/** * * Returns the id/date of the highest VAdder */ function getHighestVA(&$dbr, $period = '7 days ago') { $startdate = strtotime($period); $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000'; $sql = ""; $bots = WikihowUser::getBotIDs(); if (sizeof($bots) > 0) { $sql = " AND va_user NOT IN (" . $dbr->makeList($bots) . ") "; } $sql = "SELECT *, count(va_user) as va_count, MAX(va_timestamp) as va_recent FROM `videoadder` WHERE va_timestamp >= '" . $starttimestamp . "'" . $sql . " AND va_skipped_accepted IN ('0','1') GROUP BY va_user ORDER BY va_count DESC"; $res = $dbr->query($sql); $row = $dbr->fetchObject($res); $vauser = array(); $vauser['id'] = $row->va_user; $vauser['date'] = wfTimeAgo($row->va_recent); return $vauser; }
function getSQL($ts) { $bots = WikihowUser::getBotIDs(); $bot = ""; if (sizeof($bots) > 0) { $dbr = wfGetDB(DB_SLAVE); $bot = " AND fe_user NOT IN (" . $dbr->makeList($bots) . ", '0') "; } $sql = "SELECT page_title,\n\t\t\t\tfe_user_text as user_text,\n\t\t\t\tcount(*) as C\n \t\t\t\tFROM firstedit left join page on fe_page = page_id left join suggested_titles on page_title= st_title\n \t\t\t\tWHERE fe_timestamp >= '{$ts}' AND st_isrequest IS NOT NULL" . $bot . " group by user_text order by C limit 25"; return $sql; }