function processFeatured() { global $wgServer, $wgFeedClasses; echo "Processing Featured Articles Notification\n"; $days = 1; date_default_timezone_set("UTC"); $feeds = FeaturedArticles::getFeaturedArticles($days); $now = time(); $tomorrow = strtotime('tomorrow'); $today = strtotime('today'); echo "Tomorrow: " . date('m/d/Y H:i:s', $tomorrow) . "[{$tomorrow}] Today: " . date('m/d/Y H:i:s', $today) . "[{$today}] NOW: " . date('m/d/Y H:i:s', $now) . " \n"; foreach ($feeds as $f) { $url = $f[0]; $d = $f[1]; echo "Processing url: {$url} with epoch " . date('m/d/Y H:i:s', $d) . "[{$d}]\n"; if ($d > $tomorrow || $d < $today) { continue; } $url = str_replace("http://www.wikihow.com/", "", $url); $url = str_replace($wgServer . "/", "", $url); $title = Title::newFromURL(urldecode($url)); $title_text = $title->getText(); if (isset($f[2]) && $f[2] != null && trim($f[2]) != '') { $title_text = $f[2]; } else { $title_text = wfMsg('howto', $title_text); } if (isset($title)) { echo "Featured: {$title_text} [AID] " . $title->getArticleID() . " [URL] {$url}\n"; AuthorEmailNotification::notifyFeatured($title); } else { echo "Warning Featured: could not retrieve article id for {$url}\n"; } } }
require_once 'commandLine.inc'; $dbr = wfGetDB(DB_SLAVE); $dbw = wfGetDB(DB_MASTER); // PROCESS FA articles $fas = FeaturedArticles::getFeaturedArticles(1); foreach ($fas as $fa) { $url = urldecode(preg_replace("@http://www.wikihow.com/@", "", $fa[0])); $t = Title::newFromURL($url); if (!$t) { echo "Can't make title"; print_r($fa); continue; } echo "sending notification for FA for {$t->getFullText()}\n"; AuthorEmailNotification::notifyFeatured($t); } // PROCESS VIEWERSHIP EMAILS $ts = wfTimestamp(TS_MW, time() - 86400); $sql = "SELECT page_namespace, page_title, page_counter, en_viewership, en_user\n\t\tFROM email_notifications \n\t\tLEFT JOIN page ON en_page=page_id\n\t\tWHERE en_viewership_email IS NULL\n\t\t\tOR en_viewership_email < '{$ts}'"; $res = $dbr->query($sql, __FILE__); $milestones = array(10000, 5000, 1000, 500, 100); while ($row = $dbr->fetchObject($res)) { $send = false; if (!$row->page_title) { continue; } if ($row->page_counter >= 10000 && $row->page_counter - $row->en_viewership >= 10000) { $milestone = floor($row->page_counter / 10000) * 10000; $send = true; } else {