Пример #1
0
 function execute($par)
 {
     global $wgOut, $wgUser, $wgRequest, $wgServer, $wgCookiePrefix;
     wfProfileIn(__METHOD__);
     $wgOut->disable(true);
     header("Content-type: text/plain");
     // users may have skipped a bunch of edits, don't include them here
     $skip = array();
     foreach ($_COOKIE as $key => $value) {
         if (strpos($key, $wgCookiePrefix . "WsSkip_") === 0) {
             $skip[] = $value;
         }
     }
     $delay = $wgRequest->getInt('delay');
     $count = $this->getFeaturedUnpatrolCount($delay, $skip);
     $results = array('unpatrolled_fa' => $count);
     $results = self::getPageWideStats($results);
     if ($wgUser->getNewtalk()) {
         $results['new_talk'] = 1;
     } else {
         $results['new_talk'] = 0;
     }
     $window = Patrolcount::getPatrolcountWindow();
     $dbr = wfGetDB(DB_SLAVE);
     $count = $dbr->selectField('logging', array('count(*)'), array("log_user" => $wgUser->getId(), "log_type" => 'patrol', "log_timestamp > " . $dbr->addQuotes($window[0]), "log_timestamp < " . $dbr->addQuotes($window[1])), __METHOD__);
     $results['patrolledtoday'] = $count;
     foreach ($results as $k => $v) {
         echo "{$k}={$v}\n";
     }
     wfProfileOut(__METHOD__);
     return;
 }
Пример #2
0
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgLang;
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     $sk = $wgUser->getSkin();
     $dbr =& wfGetDB(DB_SLAVE);
     $wgOut->setHTMLTitle('Edits Patrol Count - wikiHow');
     $wgOut->addHTML('  <style type="text/css" media="all">/*<![CDATA[*/ @import "/extensions/wikihow/Patrolcount.css"; /*]]>*/</style>');
     $me = Title::makeTitle(NS_SPECIAL, "Patrolcount");
     // allow the user to grab the local patrol count relative to their own timezone
     if ($wgRequest->getVal('patrolcountview', null)) {
         $wgUser->setOption('patrolcountlocal', $wgRequest->getVal('patrolcountview'));
         $wgUser->saveSettings();
     }
     if ($wgUser->getOption('patrolcountlocal', "GMT") != "GMT") {
         $links = "[" . $sk->makeLinkObj($me, wfMsg('patrolcount_viewGMT'), "patrolcountview=GMT") . "] [" . wfMsg('patrolcount_viewlocal') . "]";
         $result = Patrolcount::getPatrolcountWindow();
         $date1 = $result[0];
         $date2 = $result[1];
         //echo "$date1 , $date2";
     } else {
         $links = "[" . wfMsg('patrolcount_viewGMT') . "] [" . $sk->makeLinkObj($me, wfMsg('patrolcount_viewlocal'), "patrolcountview=local") . "]";
         $now = wfTimestamp(TS_UNIX);
         $date1 = substr(wfTimestamp(TS_MW), 0, 8) . "000000";
         $date2 = substr(wfTimestamp(TS_MW, $now + 24 * 3600), 0, 8) . "000000";
     }
     //echo "<h3>date1 $date1 to $date2</h3>";
     //grab the total
     $total = $dbr->selectField('logging', 'count(*)', array('log_type' => 'patrol', "log_timestamp>'{$date1}'", "log_timestamp<'{$date2}'"));
     $wgOut->addHTML("<div id='Patrolcount'>");
     $wgOut->addHTML(wfMsg('patrolcount_summary') . "<br/><br/>" . wfMsg('patrolcount_total', number_format($total, 0, '', ',')) . "<br/><br/><center>");
     $wgOut->addHTML($links);
     $wgOut->addHTML("<br/><br/><table width='500px' align='center' class='status'>");
     $sql = "SELECT log_user, count(*) as C FROM logging FORCE INDEX (times) WHERE log_type='patrol' AND log_timestamp > '{$date1}' AND log_timestamp < '{$date2}' GROUP BY log_user ORDER BY C DESC LIMIT 20";
     $res = $dbr->query($sql, __METHOD__);
     $index = 1;
     $wgOut->addHTML("<tr>\n\t                       <td></td>\n\t                        <td>User</td>\n\t                        <td  align='right'>" . wfMsg('patrolcount_numberofeditspatrolled') . "</td>\n\t                        <td align='right'>" . wfMsg('patrolcount_percentangeheader') . "</td>\n\t                        </tr>\n\t        ");
     while (($row = $dbr->fetchObject($res)) != null) {
         $u = User::newFromID($row->log_user);
         //skip auto-patrolled patrols
         if (in_array('bot', $u->getGroups()) || $u->getOption('autopatrol')) {
             continue;
         }
         $percent = $total == 0 ? "0" : number_format($row->C / $total * 100, 2);
         $count = number_format($row->C, 0, "", ',');
         $class = "";
         if ($index % 2 == 1) {
             $class = 'class="odd"';
         }
         $log = $sk->makeLinkObj(Title::makeTitle(NS_SPECIAL, 'Log'), $count, 'type=patrol&user='******'right'>{$log}</td>\n\t\t\t\t<td align='right'> {$percent} % </td>\n\t\t\t\t</tr>\n\t\t\t");
         $index++;
     }
     $wgOut->addHTML("</table></center>");
     if ($wgUser->getOption('patrolcountlocal', "GMT") != "GMT") {
         $wgOut->addHTML("<br/><br/><i><font size='-2'>" . wfMsgWikiHtml('patrolcount_viewlocal_info') . "</font></i>");
     }
     $wgOut->addHTML("</div>");
 }