private function run()
 {
     global $wgRequest;
     wfProfileIn(__METHOD__);
     if (preg_match('/^[a-zA-Z]+$/', $this->mAction)) {
         $func = "__" . $this->mAction;
         if (method_exists($this, $func)) {
             $this->mStats = WikiStats::newFromId($this->mCityId);
             $this->mResult = $this->{$func}();
         }
     }
     wfProfileOut(__METHOD__);
 }
 public function execute($subpage)
 {
     global $wgUser, $wgOut, $wgRequest, $wgCityId, $wgDBname, $wgLang;
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     // Set the current wiki ID, DB name and user from globals
     $this->mCityId = $wgCityId;
     $this->mCityDBName = $wgDBname;
     $this->mUser = $wgUser;
     // Check the current $wgUser against the set of groups WikiStats recognizes
     $this->userIsSpecial = WikiStats::isAllowed();
     $this->mFromDate = $wgRequest->getVal("wsfrom", WIKISTATS_MIN_STATS_YEAR . WIKISTATS_MIN_STATS_MONTH);
     $this->mToDate = $wgRequest->getVal("wsto", date("Ym"));
     $this->mTitle = Title::makeTitle(NS_SPECIAL, "WikiStats");
     $this->mAction = $wgRequest->getVal("action", "");
     $this->mXLS = $wgRequest->getVal("wsxls", false);
     $this->mMonth = $wgRequest->getVal("wsmonth", 0);
     $this->mLimit = $wgRequest->getVal("wslimit", WIKISTATS_WIKIANS_RANK_NBR);
     $this->mAllWikis = 0;
     // Use the first part of the subpage as the action
     if ($subpage) {
         $path = explode("/", $subpage);
         $this->mAction = $path[0];
     }
     // Redirect to the default action if one hasn't been set
     if (empty($this->mAction)) {
         $wgOut->redirect($this->mTitle->getFullURL("action={$this->defaultAction}"));
     }
     // Split out the the from and to month and year for convenience
     if (preg_match("/^([0-9]{4})([0-9]{1,2})/", $this->mFromDate, $m)) {
         list(, $this->fromYear, $this->fromMonth) = $m;
     } else {
         $wgOut->showErrorPage("Bad parameters", "wikistats_error_malformed_date");
         return;
     }
     if (preg_match("/^([0-9]{4})([0-9]{1,2})/", $this->mToDate, $m)) {
         list(, $this->toYear, $this->toMonth) = $m;
     } else {
         $wgOut->showErrorPage("Bad parameters", "wikistats_error_malformed_date");
         return;
     }
     $domain = $all = "";
     if ($this->userIsSpecial) {
         $this->mLang = $wgRequest->getVal("wslang", "");
         $this->mHub = $wgRequest->getVal("wscat", "");
         $this->mNS = $wgRequest->getIntArray("wsns", "");
         $domain = $wgRequest->getVal("wswiki", "");
         $all = $wgRequest->getVal("wsall", 0);
         $this->mNamespaces = $wgLang->getNamespaces();
     }
     // Override some values if we're special and got a domain (or 'all')
     if ($domain == 'all' || $all == 1) {
         $this->mCityId = 0;
         $this->mCityDBName = WIKISTATS_CENTRAL_ID;
         $this->mCityDomain = 'all';
         $this->mAllWikis = 1;
     } elseif (!empty($domain) && $this->userIsSpecial == 1) {
         $this->mCityId = WikiFactory::DomainToId($domain);
         $this->mCityDBName = WikiFactory::IDToDB($this->mCityId);
         $this->mCityDomain = $domain;
     } else {
         $this->mCityDomain = WikiFactory::DBToDomain($this->mCityDBName);
     }
     $this->mStats = WikiStats::newFromId($this->mCityId);
     $this->mPredefinedNamespaces = $this->mStats->getPageNSList();
     $this->mStats->setStatsDate(array('fromMonth' => $this->fromMonth, 'fromYear' => $this->fromYear, 'toMonth' => $this->toMonth, 'toYear' => $this->toYear));
     $this->mStats->setHub($this->mHub);
     $this->mStats->setLang($this->mLang);
     #---
     $this->mSkin = RequestContext::getMain()->getSkin();
     if (is_object($this->mSkin)) {
         $skinname = get_class($this->mSkin);
         $skinname = strtolower(str_replace("Skin", "", $skinname));
         $this->mSkinName = $skinname;
     }
     $this->showForm();
     if ($this->mAction) {
         $func = 'show' . ucfirst(strtolower($this->mAction));
         if (method_exists($this, $func)) {
             $this->{$func}($subpage);
         }
     }
 }