コード例 #1
0
 /**
  * execute -- main entry point to api method
  *
  * use secret hash for checking if api is called by proper engine
  *
  * @access public
  *
  * @return api result
  */
 public function execute()
 {
     global $wgTheSchwartzSecretToken, $wgCityId, $wgServer, $wgExtensionMessagesFiles;
     $params = $this->extractRequestParams();
     $status = 0;
     if (isset($params["token"]) && $params["token"] === $wgTheSchwartzSecretToken) {
         /**
          * get creator from param
          */
         $founder = User::newFromId($params["user_id"]);
         $founder->load();
         /**
          * get city_founding_user from city_list
          */
         if (!$founder) {
             $wiki = WikiFactory::getWikiByID($wgCityId);
             $founder = User::newFromId($wiki->city_founding_user);
         }
         Wikia::log(__METHOD__, "user", $founder->getName());
         if ($founder && $founder->isEmailConfirmed()) {
             if ($founder->sendMail(wfMsg("autocreatewiki-reminder-subject"), wfMsg("autocreatewiki-reminder-body", array($founder->getName(), $wgServer)), null, null, "AutoCreateWikiReminder", wfMsg("autocreatewiki-reminder-body-HTML", array($founder->getName(), $wgServer)))) {
                 $status = 1;
             }
         }
     } else {
         $this->dieUsageMsg(array("sessionfailure"));
     }
     $result = array("status" => $status);
     $this->getResult()->setIndexedTagName($result, 'status');
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
コード例 #2
0
 public function __construct($cityId)
 {
     global $wgForeignFileRepos;
     parent::__construct();
     $this->cityId = $cityId;
     $this->skinName = RequestContext::getMain()->getSkin()->getSkinName();
     $hubWiki = WikiFactory::getWikiByID($cityId);
     $hubDbName = $hubWiki->city_dbname;
     $wgForeignFileRepos[] = ['class' => 'WikiaForeignDBViaLBRepo', 'name' => $hubDbName, 'transformVia404' => true, 'wiki' => $hubDbName, 'backend' => "wikia{$hubDbName}-backend"];
 }
コード例 #3
0
 function execute($params = null)
 {
     global $IP, $wgWikiaLocalSettingsPath;
     /*  go with each supplied wiki and delete the supplied article
     			load all configs for particular wikis before doing so
     			(from wikifactory, not by _obsolete_ maintenance scripts
     			and from LocalSettings as worked on fps)
     		 */
     $this->mTaskID = $params->task_id;
     $oUser = User::newFromId($params->task_user_id);
     if ($oUser instanceof User) {
         $oUser->load();
         $this->mUser = $oUser->getName();
     } else {
         $this->log("Invalid user - id: " . $params->task_user_id);
         return true;
     }
     $data = unserialize($params->task_arguments);
     foreach ($data['page_list'] as $imageData) {
         $retval = "";
         list($wikiId, $imageId) = $imageData;
         $dbname = WikiFactory::getWikiByID($wikiId);
         if (!$dbname) {
             continue;
         }
         $title = GlobalTitle::newFromId($imageId, $wikiId);
         if (!is_object($title)) {
             $this->log('Apparently the article does not exist anymore');
             continue;
         }
         $city_url = WikiFactory::getVarValueByName("wgServer", $wikiId);
         if (empty($city_url)) {
             continue;
         }
         $city_path = WikiFactory::getVarValueByName("wgScript", $wikiId);
         $city_lang = WikiFactory::getVarValueByName("wgLanguageCode", $wikiId);
         $reason = wfMsgExt('imagereview-reason', array('language' => $city_lang));
         $sCommand = "perl /usr/wikia/backend/bin/run_maintenance --id={$wikiId} --script=wikia/deleteOn.php ";
         $sCommand .= "-- ";
         $sCommand .= "-u " . escapeshellarg($this->mUser) . " ";
         $sCommand .= "-t " . escapeshellarg($title->getPrefixedText()) . " ";
         if ($reason) {
             $sCommand .= "-r " . escapeshellarg($reason) . " ";
         }
         $actual_title = wfShellExec($sCommand, $retval);
         if ($retval) {
             $this->addLog('Article deleting error! (' . $city_url . '). Error code returned: ' . $retval . ' Error was: ' . $actual_title);
         } else {
             $this->addLog('Removed: <a href="' . $city_url . $city_path . '?title=' . wfEscapeWikiText($actual_title) . '">' . $city_url . $city_path . '?title=' . $actual_title . '</a>');
         }
         $this->flagUser($imageId, $wikiId);
         $this->flagWiki($wikiId);
     }
     return true;
 }
コード例 #4
0
 protected function appendWikidesc($property)
 {
     global $wgLanguageCode, $wgDBcluster;
     $result = $this->getResult();
     $lang_id = WikiFactory::LangCodeToId($wgLanguageCode);
     $cats = WikiFactory::getCategory($this->cityId);
     $oWiki = WikiFactory::getWikiByID($this->cityId);
     $cat_id = !empty($cats) ? $cats->cat_id : 0;
     $data = array("langid" => $lang_id, "id" => $this->cityId, "catid" => $cat_id, "pagetitle" => wfMsg('pagetitle'), "flags" => $oWiki->city_flags, "db" => $oWiki->city_dbname, "position" => isset($wgDBcluster) ? $wgDBcluster : $oWiki->city_cluster);
     $result->setIndexedTagName($data, $property);
     $result->addValue('query', $property, $data);
 }
コード例 #5
0
 public function __construct($wikiId)
 {
     $dbName = false;
     if (!empty($wikiId)) {
         $wikiInfo = WikiFactory::getWikiByID($wikiId);
         $dbName = $wikiInfo->city_dbname;
     }
     $this->app = F::app();
     $this->db = wfGetDB(DB_SLAVE, array(), $dbName);
     $this->wikiId = $wikiId;
     $this->api = new EntityAPIClient();
     $this->api->setLogLevel(5);
 }
コード例 #6
0
 public function delete($pageList, $suppress = false)
 {
     global $IP;
     $user = \User::newFromId($this->createdBy);
     $userName = $user->getName();
     $articlesDeleted = 0;
     foreach ($pageList as $imageData) {
         list($wikiId, $imageId) = $imageData;
         if (!\WikiFactory::isPublic($wikiId)) {
             $this->notice('wiki has been disabled', ['wiki_id' => $wikiId]);
             continue;
         }
         $dbname = \WikiFactory::getWikiByID($wikiId);
         if (!$dbname) {
             $this->warning('did not find database', ['wiki_id' => $wikiId]);
             continue;
         }
         $cityUrl = \WikiFactory::getVarValueByName('wgServer', $wikiId);
         if (empty($cityUrl)) {
             $this->warning('could not determine city url', ['wiki_id' => $wikiId]);
             continue;
         }
         $cityLang = \WikiFactory::getVarValueByName('wgLanguageCode', $wikiId);
         $reason = wfMsgExt('imagereview-reason', ['language' => $cityLang]);
         $command = "SERVER_ID={$wikiId} php {$IP}/maintenance/wikia/deleteOn.php" . ' -u ' . escapeshellarg($userName) . ' --id ' . $imageId;
         if ($reason) {
             $command .= ' -r ' . escapeshellarg($reason);
         }
         if ($suppress) {
             $command .= ' -s';
         }
         $title = wfShellExec($command, $exitStatus);
         if ($exitStatus !== 0) {
             $this->error('article deletion error', ['city_url' => $cityUrl, 'exit_status' => $exitStatus, 'error' => $title]);
             continue;
         }
         $cityPath = \WikiFactory::getVarValueByName('wgScript', $wikiId);
         $escapedTitle = wfEscapeWikiText($title);
         $this->info('removed image', ['link' => "{$cityUrl}{$cityPath}?title={$escapedTitle}", 'title' => $escapedTitle]);
         ++$articlesDeleted;
     }
     $success = $articlesDeleted == count($pageList);
     if (!$success) {
         $this->sendNotification();
     }
     return $success;
 }
コード例 #7
0
ファイル: DumpsOnDemand.php プロジェクト: schwarer2006/wikia
 /**
  * @access public
  * @static
  */
 public static function customSpecialStatistics(&$specialpage, &$text)
 {
     global $wgOut, $wgDBname, $wgLang, $wgRequest, $wgTitle, $wgUser, $wgCityId, $wgHTTPProxy;
     /**
      * read json file with dumps information
      */
     $tmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
     $index = array();
     $proxy = array();
     if (isset($wgHTTPProxy) && $wgHTTPProxy) {
         $proxy["proxy"] = $wgHTTPProxy;
     } else {
         $proxy["noProxy"] = true;
     }
     $url = self::getUrl($wgDBname, "index.json");
     $json = Http::get($url, 5, $proxy);
     if ($json) {
         wfDebug(__METHOD__ . ": getting informations about last dump from {$url} succeded\n");
         $index = (array) json_decode($json);
     } else {
         wfDebug(__METHOD__ . ": getting informations about last dump from {$url} failed\n");
     }
     /**
      * get last dump request timestamp
      */
     $wiki = WikiFactory::getWikiByID($wgCityId);
     if (strtotime(wfTimestampNow()) - strtotime($wiki->city_lastdump_timestamp) > 7 * 24 * 60 * 60) {
         $tmpl->set("available", true);
     } else {
         $tmpl->set("available", false);
     }
     $tmpl->set("title", $wgTitle);
     $tmpl->set("isAnon", $wgUser->isAnon());
     $tmpl->set("curr", array("url" => self::getUrl($wgDBname, "pages_current.xml.gz"), "timestamp" => !empty($index["pages_current.xml.gz"]->mwtimestamp) ? $wgLang->timeanddate($index["pages_current.xml.gz"]->mwtimestamp) : "unknown"));
     $tmpl->set("full", array("url" => self::getUrl($wgDBname, "pages_full.xml.gz"), "timestamp" => !empty($index["pages_full.xml.gz"]->mwtimestamp) ? $wgLang->timeanddate($index["pages_full.xml.gz"]->mwtimestamp) : "unknown"));
     $tmpl->set("index", $index);
     $text .= $tmpl->render("dod");
     if ($wgRequest->wasPosted() && !$wgUser->isAnon()) {
         self::sendMail();
         wfDebug(__METHOD__, ": request for database dump was posted\n");
         $text = Wikia::successbox(wfMsg("dump-database-request-requested")) . $text;
     }
     return true;
 }
コード例 #8
0
ファイル: GWTClient.php プロジェクト: yusufchang/app
 /**
  * constructor
  * If email and password are empty, will use the default preferred account from '
  *
  * @access public
  */
 public function __construct($email, $pass, $wiki = null)
 {
     global $wgGoogleWebToolsAccts;
     // If email and password weren't specified, use the preferred account.
     if (empty($email) && empty($pass)) {
         if (is_array($wgGoogleWebToolsAccts)) {
             foreach ($wgGoogleWebToolsAccts as $acctEmail => $acctData) {
                 if (isset($acctData['preferred']) && $acctData['preferred'] == 1) {
                     $email = $acctEmail;
                     $pass = $acctData['pass'];
                     break;
                 }
             }
             // If no preferred email/pass was found, just grab the first one
             if (empty($email) && empty($pass) && count($wgGoogleWebToolsAccts) > 0) {
                 $keys = array_keys($wgGoogleWebToolsAccts);
                 $email = $keys[0];
                 $pass = isset($wgGoogleWebToolsAccts[$email]['pass']) ? $wgGoogleWebToolsAccts[$email]['pass'] : "";
             }
         }
     }
     $this->mEmail = $email;
     $this->mPass = $pass;
     $this->mType = 'GOOGLE';
     $this->mSource = 'WIKIA';
     $this->mService = 'sitemaps';
     if ($wiki != null) {
         if (!is_object($wiki)) {
             if (is_string($wiki)) {
                 $wiki = WikiFactory::DBtoID($wiki);
             }
             $wikiId = WikiFactory::getWikiByID($wiki);
             if (!$wikiId) {
                 throw new Exception("Could not find wiki by ID (id=" . $wiki . ").");
             }
             $wiki = $wikiId;
         }
         $this->mWiki = $wiki;
         $this->mSiteURI = $this->make_site_uri();
     }
     $this->mAuth = $this->getAuthToken();
 }
コード例 #9
0
 /**
  * Get image list
  *
  * @param  integer $userId ID of the user to get the list for
  * @param  string  $from   Timestamp to get images before
  * @return array           List of images
  */
 public function getImageList($userId, $from = null)
 {
     wfProfileIn(__METHOD__);
     $imageList = [];
     $db = $this->getDatawareDB(DB_MASTER);
     $where = ['user_id' => $userId, 'state != ' . ImageReviewStatuses::STATE_DELETED . ' AND state != ' . ImageReviewStatuses::STATE_WIKI_DISABLED];
     $from = wfTimestampOrNull(TS_DB, $from);
     if (!empty($from)) {
         $where[] = 'last_edited < ' . $db->addQuotes($from);
     }
     $result = $db->select(['image_review'], ['wiki_id, page_id, state, flags, priority, last_edited'], $where, __METHOD__, ['ORDER BY' => 'last_edited desc', 'LIMIT' => self::LIMIT_IMAGES]);
     foreach ($result as $row) {
         $img = ImagesService::getImageSrc($row->wiki_id, $row->page_id);
         $wikiRow = WikiFactory::getWikiByID($row->wiki_id);
         $extension = pathinfo(strtolower($img['page']), PATHINFO_EXTENSION);
         $isThumb = true;
         if (empty($img['src'])) {
             // If we don't have a thumb by this point, we still need to display something, fall back to placeholder
             $globalTitle = GlobalTitle::newFromId($row->page_id, $row->wiki_id);
             if (is_object($globalTitle)) {
                 $img['page'] = $globalTitle->getFullUrl();
                 // @TODO this should be taken from the code instead of being hardcoded
                 $img['src'] = '//images.wikia.com/central/images/8/8c/Wikia_image_placeholder.png';
             } else {
                 // This should never happen
                 continue;
             }
         }
         if (in_array($extension, ['gif', 'svg'])) {
             $img = ImagesService::getImageOriginalUrl($row->wiki_id, $row->page_id);
             $isThumb = false;
         }
         $imageList[] = ['wikiId' => $row->wiki_id, 'pageId' => $row->page_id, 'state' => $row->state, 'src' => $img['src'], 'priority' => $row->priority, 'url' => $img['page'], 'isthumb' => $isThumb, 'flags' => $row->flags, 'wiki_url' => isset($wikiRow->city_url) ? $wikiRow->city_url : '', 'user_page' => '', 'last_edited' => $row->last_edited];
     }
     $db->freeResult($result);
     wfProfileOut(__METHOD__);
     return $imageList;
 }
コード例 #10
0
 public function pageList($wikiId)
 {
     /* TEST */
     $important = new ImportantArticles($wikiId);
     $wikiTopics = $important->getWikiTopics();
     $importantByRedirects = $important->getImportantPhrasesByRedirects();
     $importantByTopPages = $important->getImportantPhrasesByTopPages();
     $importantByLinks = $important->getImportantPhrasesByInterlinks();
     $commonPrefix = $important->getCommonPrefix();
     $importantByDomainNames = $important->getImportantPhrasesByDomainNames();
     $merged = $important->getMostImportantTopics();
     $this->setVal('wikiTopics', $wikiTopics);
     $this->setVal('importantByTopPages', $importantByTopPages);
     $this->setVal('importantByLinks', $importantByLinks);
     $this->setVal('commonPrefix', $commonPrefix);
     $this->setVal('phrases', $important->getImportantPhrasesAsList());
     $this->setVal('importantByDomainNames', $importantByDomainNames);
     $this->setVal('importantByRedirects', $importantByRedirects);
     $this->setVal('merged', $merged);
     $wiki = WikiFactory::getWikiByID($wikiId);
     $this->setVal('domain_name', $wiki->city_url);
     $this->overrideTemplate('pageList');
 }
コード例 #11
0
 private function getWikiData($city_id)
 {
     $res = array();
     $oRow = WikiFactory::getWikiByID($city_id);
     if (is_object($oRow)) {
         $res = array("id" => $oRow->city_id, "url" => $oRow->city_url, "dbname" => $oRow->city_dbname, "title" => $oRow->city_title, "active" => $oRow->city_public);
     }
     return $res;
 }
コード例 #12
0
 function sendMail($commandLineOptions, $jobOptions, $wikiId, $wikiData)
 {
     global $wgSitename;
     $wiki = WikiFactory::getWikiByID($wikiId);
     $magicwords = array('#WIKINAME' => $wiki->city_title);
     $flags = WikiFactory::getFlags($wikiId);
     $flag = $jobOptions['mailType'] == 'first' ? WikiFactory::FLAG_ADOPT_MAIL_FIRST : WikiFactory::FLAG_ADOPT_MAIL_SECOND;
     //this kind of e-mail already sent for this wiki
     if ($flags & $flag) {
         return;
     }
     $globalTitleUserRights = GlobalTitle::newFromText('UserRights', -1, $wikiId);
     $specialUserRightsUrl = $globalTitleUserRights->getFullURL();
     $globalTitlePreferences = GlobalTitle::newFromText('Preferences', -1, $wikiId);
     $specialPreferencesUrl = $globalTitlePreferences->getFullURL();
     //at least one admin has not edited during xx days
     foreach ($wikiData['admins'] as $adminId) {
         //print info
         if (!isset($commandLineOptions['quiet'])) {
             echo "Trying to send the e-mail to the user (id:{$adminId}) on wiki (id:{$wikiId}).\n";
         }
         $adminUser = User::newFromId($adminId);
         $defaultOption = null;
         if ($wikiId > 194785) {
             $defaultOption = 1;
         }
         $acceptMails = $adminUser->getOption("adoptionmails-{$wikiId}", $defaultOption);
         if ($acceptMails && $adminUser->isEmailConfirmed()) {
             $adminName = $adminUser->getName();
             if (!isset($commandLineOptions['quiet'])) {
                 echo "Sending the e-mail to the user (id:{$adminId}, name:{$adminName}) on wiki (id:{$wikiId}).\n";
             }
             if (!isset($commandLineOptions['dryrun'])) {
                 echo "Really Sending the e-mail to the user (id:{$adminId}, name:{$adminName}) on wiki (id:{$wikiId}).\n";
                 $adminUser->sendMail(strtr(wfMsgForContent("wikiadoption-mail-{$jobOptions['mailType']}-subject"), $magicwords), strtr(wfMsgForContent("wikiadoption-mail-{$jobOptions['mailType']}-content", $adminName, $specialUserRightsUrl, $specialPreferencesUrl), $magicwords), null, null, 'AutomaticWikiAdoption', strtr(wfMsgForContent("wikiadoption-mail-{$jobOptions['mailType']}-content-HTML", $adminName, $specialUserRightsUrl, $specialPreferencesUrl), $magicwords));
             }
         }
     }
     if (!isset($commandLineOptions['dryrun'])) {
         WikiFactory::setFlags($wikiId, $flag);
     }
 }
コード例 #13
0
ファイル: TvRssModel.class.php プロジェクト: yusufchang/app
 protected function formatTitle($item)
 {
     switch ($item['source']) {
         case self::SOURCE_TVRAGE:
             $item['title'] = sprintf('%s, the new episode from %s', $item['episode_name'], $item['series_name']);
             break;
         case self::SOURCE_HUB:
             break;
         case self::SOURCE_GENERATOR:
             $titles = ['Read more about %s from %s', 'More info about %s from %s', 'Recommended page: %s from %s'];
             $titleNum = rand(0, count($titles) - 1);
             if (!array_key_exists('wikititle', $item) || !$item['wikititle']) {
                 $info = WikiFactory::getWikiByID($item['wikia_id']);
                 $item['wikititle'] = $info->city_title;
             }
             $item['title'] = sprintf($titles[$titleNum], $item['title'], $item['wikititle']);
             break;
     }
     return $item;
 }
コード例 #14
0
 public function execute($wikiID)
 {
     global $wgOut, $wgRequest, $wgCityId, $wgUser;
     wfProfileIn(__METHOD__);
     $this->setHeaders();
     $firstVisit = true;
     $wikiID = !empty($wikiID) ? (int) $wikiID : $wgCityId;
     if (isset($_COOKIE[$this->mCookieName])) {
         $this->mCookie = json_decode($_COOKIE[$this->mCookieName]);
         $firstVisit = false;
     } else {
         $this->mCookie = new stdClass();
         $this->mCookie->origHub = null;
         $this->mCookie->langCode = null;
         $this->mCookie->history = array();
         if (!empty($wikiID)) {
             $hub = WikiFactory::getCategory($wikiID);
             if (is_object($hub)) {
                 $this->mCookie->origHub = $hub->cat_id;
                 $this->mCookie->langCode = WikiFactory::getWikiByID($wikiID)->city_lang;
                 $this->mCookie->history[] = $wikiID;
             }
         }
     }
     $this->loadData();
     $historyCount = count($this->mCookie->history);
     // reset the history if the user visited all the possible targets
     if ($historyCount >= $this->mData['total']) {
         $this->mCookie->history = array($wikiID);
     }
     // if language other than English and list of targets exhausted fall back to english
     if (($historyCount >= $this->mData['total'] || $this->mData['total'] == 0 && (count($this->mData['recommended']) == 0 || !$firstVisit)) && $this->mCookie->langCode != 'en') {
         $this->mCookie->langCode = 'en';
         $this->loadData();
     }
     $destinationID = null;
     $from = null;
     srand(time());
     // pick a recommended wiki the first time
     if ($firstVisit && !empty($this->mData['recommended'])) {
         $destinationID = $this->mData['recommended'][array_rand($this->mData['recommended'])];
         $from = 'recommended';
     } elseif (!empty($this->mCookie->origHub) && !empty($this->mData['hubs'][$this->mCookie->origHub])) {
         $currentHub = array_diff($this->mData['hubs'][$this->mCookie->origHub], $this->mCookie->history);
         if (count($currentHub) && count($this->mCookie->history) < RandomWikiHelper::TRACK_LIMIT) {
             $destinationID = $currentHub[array_rand($currentHub)];
             $from = 'origHub';
         }
     }
     // in case no wiki has been selected in the previous block pick a wiki from a random hub
     if (empty($destinationID)) {
         $hubsCount = count($this->mData['hubs']);
         $hub = array_rand($this->mData['hubs'], $hubsCount);
         if (!is_array($hub)) {
             $hub = array($hub);
         }
         foreach ($hub as $key) {
             $tmpHub = array_diff($this->mData['hubs'][$key], $this->mCookie->history);
             if (!count($tmpHub)) {
                 continue;
             }
             $itemKey = array_rand($tmpHub);
             $destinationID = $tmpHub[$itemKey];
             $from = "hub {$itemKey}";
         }
     }
     $this->mCookie->history[] = $destinationID;
     $cookieValue = json_encode($this->mCookie);
     $wgRequest->response()->setcookie(self::COOKIE_NAME_TOKEN, $cookieValue, time() + 3600 * self::COOKIE_EXPIRY);
     $url = WikiFactory::getVarValueByName('wgServer', $destinationID);
     //FB#1033: avoid being sent to Special:WikiActivity when logged-in, see MyHomw::getInitialMainPage
     if ($wgUser->isLoggedIn()) {
         $url .= '?redirect=no';
     }
     // Redirect the user to a randomly-chosen wiki (or not if profiling requested)
     $profiling = $wgRequest->getInt('forceprofile', 0);
     if ($profiling !== 1) {
         $wgOut->redirect($url);
     }
     wfProfileOut(__METHOD__);
 }
コード例 #15
0
ファイル: WikiFactory.php プロジェクト: Tjorriemorrie/app
 /**
  * copyToArchive
  *
  * copy data from WikiFactory database to Archive database
  *
  * @author Krzysztof Krzyżaniak (eloy) <*****@*****.**>
  * @access public
  * @static
  *
  * @param integer	$city_id	source Wiki ID
  * @return bool
  */
 public static function copyToArchive($city_id)
 {
     global $wgExternalArchiveDB, $wgWikicitiesReadOnly;
     if ($wgWikicitiesReadOnly) {
         Wikia::log(__METHOD__, "", "wgWikicitiesReadOnly mode. Skipping update.");
         return false;
     }
     wfProfileIn(__METHOD__);
     /**
      * do only on inactive wikis
      */
     $wiki = WikiFactory::getWikiByID($city_id);
     if (isset($wiki->city_id)) {
         $timestamp = wfTimestampNow();
         $dbw = self::db(DB_MASTER);
         $dba = wfGetDB(DB_MASTER, [], $wgExternalArchiveDB);
         $dba->begin();
         /**
          * copy city_list to archive
          */
         $dba->insert("city_list", ["city_id" => $wiki->city_id, "city_path" => $wiki->city_path, "city_dbname" => $wiki->city_dbname, "city_sitename" => $wiki->city_sitename, "city_url" => $wiki->city_url, "city_created" => $wiki->city_created, "city_founding_user" => $wiki->city_founding_user, "city_adult" => $wiki->city_adult, "city_public" => $wiki->city_public, "city_additional" => $wiki->city_additional, "city_description" => $wiki->city_description, "city_title" => $wiki->city_title, "city_founding_email" => $wiki->city_founding_email, "city_founding_ip" => $wiki->city_founding_ip, "city_lang" => $wiki->city_lang, "city_special_config" => $wiki->city_special_config, "city_umbrella" => $wiki->city_umbrella, "city_ip" => $wiki->city_ip, "city_google_analytics" => $wiki->city_google_analytics, "city_google_search" => $wiki->city_google_search, "city_google_maps" => $wiki->city_google_maps, "city_indexed_rev" => $wiki->city_indexed_rev, "city_lastdump_timestamp" => $timestamp, "city_factory_timestamp" => $timestamp, "city_useshared" => $wiki->city_useshared, "city_flags" => $wiki->city_flags, "city_cluster" => $wiki->city_cluster], __METHOD__);
         /**
          * copy city_variables to archive
          */
         $sth = $dbw->select(["city_variables"], ["cv_city_id", "cv_variable_id", "cv_value"], ["cv_city_id" => $city_id], __METHOD__);
         while ($row = $dbw->fetchObject($sth)) {
             $dba->insert("city_variables", ["cv_city_id" => $row->cv_city_id, "cv_variable_id" => $row->cv_variable_id, "cv_value" => $row->cv_value, "cv_timestamp" => $timestamp], __METHOD__);
         }
         $dbw->freeResult($sth);
         /**
          * copy domains to archive
          */
         $sth = $dbw->select(['city_domains'], ['*'], ['city_id' => $city_id], __METHOD__);
         while ($row = $dbw->fetchObject($sth)) {
             $dba->insert("city_domains", ["city_id" => $row->city_id, "city_domain" => $row->city_domain, "city_new_id" => $row->city_id, "city_timestamp" => $timestamp], __METHOD__);
             self::clearDomainCache($row->city_id);
         }
         $dbw->freeResult($sth);
         $dba->commit();
     }
     wfProfileOut(__METHOD__);
 }
コード例 #16
0
 /**
  * Helper method which sends request to maps service to create a map from existing tiles' set
  * and processes the response providing results array
  *
  * @return Array
  */
 private function createMapFromTilesetId()
 {
     $cityId = $this->getData('cityId');
     $wiki = WikiFactory::getWikiByID($cityId);
     $response = $this->mapsModel->saveMap(['title' => $this->getData('title'), 'tile_set_id' => $this->getData('tileSetId'), 'city_id' => $cityId, 'city_title' => $wiki->city_title, 'city_url' => $wiki->city_url, 'created_by' => $this->getData('creatorName')]);
     if (true === $response['success']) {
         $mapId = $response['content']->id;
         $response['content']->mapUrl = Title::newFromText(WikiaMapsSpecialController::PAGE_NAME . '/' . $mapId, NS_SPECIAL)->getFullUrl();
         // Log new map created
         WikiaMapsLogger::addLogEntry(WikiaMapsLogger::ACTION_CREATE_MAP, $this->wg->User, $mapId, $this->getData('title'));
     }
     return $response;
 }
コード例 #17
0
 private static function allowResultsForEditedArticles($row, $from_db = false)
 {
     global $wgTTCache;
     wfProfileIn(__METHOD__);
     $result = array();
     $memkey = wfMemcKey(__METHOD__, 'oWikia', intval($row['wikia']));
     $oWikia = $wgTTCache->get($memkey);
     if (!isset($oWikia)) {
         $allowed = true;
         /*
          * check city list
          */
         $oWikia = WikiFactory::getWikiByID($row['wikia']);
         if (!$oWikia) {
             $allowed = false;
         }
         /*
          * check city lang
          */
         if ($allowed && !in_array($oWikia->city_lang, self::$allowedLanguages)) {
             $allowed = false;
         }
         /*
          * check sitename
          */
         if ($allowed) {
             $siteName = WikiFactory::getVarByName('wgSitename', $row['wikia']);
             if (!$siteName) {
                 $allowed = false;
             }
         }
         /*
          * check wikiname
          */
         $oWikia->city_sitename = "";
         if ($allowed) {
             $oWikia->city_sitename = unserialize($siteName->cv_value);
             if (!$oWikia->city_sitename) {
                 $allowed = false;
             } else {
                 foreach (self::$excludeNames as $search) {
                     $pos = stripos($oWikia->city_sitename, $search);
                     if ($pos !== false) {
                         $allowed = false;
                     }
                 }
             }
         }
         if (!$allowed) {
             $oWikia = 'ERROR';
         }
         # set in memc
         if ($oWikia != 'ERROR') {
             $wgTTCache->set($memkey, $oWikia, 60 * 60);
         }
     }
     if ($oWikia == 'ERROR') {
         wfProfileOut(__METHOD__);
         return false;
     }
     /* check article */
     $memkey = wfMemcKey(__METHOD__, 'article', intval($row['wikia']), intval($row['page']), $oWikia->city_dbname);
     $result = $from_db === true ? null : $wgTTCache->get($memkey);
     if (!isset($result)) {
         $allowedPage = true;
         /*
          * check Title && Wiki domain
          */
         $oGTitle = GlobalTitle::newFromId($row['page'], $row['wikia'], $oWikia->city_dbname);
         if (!is_object($oGTitle)) {
             $allowedPage = false;
         }
         if ($allowedPage) {
             $wikiaUrl = $oGTitle->getServer();
             $pageUrl = $oGTitle->getFullURL();
             $articleName = $oGTitle->getArticleName();
             $oRegexCore = new TextRegexCore(self::$excludeWikiDomainsKey, 0);
             if (is_object($oRegexCore)) {
                 $allowed = $oRegexCore->isAllowedText($wikiaUrl, "", false);
                 if (!$allowed) {
                     $allowedPage = false;
                 }
             }
         }
         /*
          * check hub name
          */
         if ($allowedPage) {
             $hubName = WikiFactoryHub::getInstance()->getCategoryName($row['wikia']);
             if (in_array($hubName, self::$excludeWikiHubs)) {
                 $allowedPage = false;
             }
         }
         /*
          * check article name
          */
         if ($allowedPage) {
             $oRegexArticles = new TextRegexCore(self::$excludeWikiArticles, 0);
             if (is_object($oRegexArticles)) {
                 $filterText = sprintf("%s:%s", $oWikia->city_dbname, $articleName);
                 $allowed = $oRegexArticles->isAllowedText($filterText, "", false);
                 if (!$allowed) {
                     $allowedPage = false;
                 }
             }
         }
         if (!$allowedPage) {
             $result = 'ERROR';
         } else {
             /*
              * ok
              */
             $result = array('wikia' => $oWikia->city_sitename, 'db' => $oWikia->city_dbname, 'hub' => $hubName, 'page_name' => $articleName, 'wikia_url' => $wikiaUrl, 'page_url' => $pageUrl, 'count' => $row['count']);
             # set in memc
             $wgTTCache->set($memkey, $result, 60 * 30);
         }
     }
     if ($result == 'ERROR') {
         $result = false;
     }
     wfProfileOut(__METHOD__);
     return $result;
 }
コード例 #18
0
 /**
  * send email to user
  */
 private function sendDigestsToUser($iUserId)
 {
     global $wgExternalDatawareDB, $wgGlobalWatchlistMaxDigestedArticlesPerWiki;
     $dbr = wfGetDB(DB_SLAVE, array(), $wgExternalDatawareDB);
     $oResource = $dbr->select(array("global_watchlist"), array("gwa_id", "gwa_user_id", "gwa_city_id", "gwa_namespace", "gwa_title", "gwa_rev_id", "gwa_timestamp"), array("gwa_user_id" => intval($iUserId), "gwa_timestamp <= gwa_rev_timestamp", "gwa_timestamp is not null"), __METHOD__, array("ORDER BY" => "gwa_timestamp, gwa_city_id"));
     $records = $dbr->numRows($oResource);
     $bTooManyPages = $records > $wgGlobalWatchlistMaxDigestedArticlesPerWiki ? true : false;
     $this->printDebug("Found {$records} records - limit {$wgGlobalWatchlistMaxDigestedArticlesPerWiki}");
     $iWikiId = $loop = 0;
     $aDigestData = array();
     $aWikiDigest = array('pages' => array());
     $aRemove = array();
     while ($oResultRow = $dbr->fetchObject($oResource)) {
         # ---
         if ($loop >= $wgGlobalWatchlistMaxDigestedArticlesPerWiki) {
             break;
         }
         $oWikia = WikiFactory::getWikiByID($oResultRow->gwa_city_id);
         if (empty($oWikia) || empty($oWikia->city_public)) {
             $this->printDebug("Unknown Wikia: " . $oResultRow->gwa_city_id);
             continue;
         }
         if ($iWikiId != $oResultRow->gwa_city_id) {
             $this->printDebug("Prepare email for Wiki: " . $oResultRow->gwa_city_id);
             if (count($aWikiDigest['pages'])) {
                 $aDigestData[$iWikiId] = $aWikiDigest;
             }
             $iWikiId = $oResultRow->gwa_city_id;
             if (isset($aDigestData[$iWikiId])) {
                 $aWikiDigest = $aDigestData[$iWikiId];
             } else {
                 $aWikiDigest = array('wikiName' => $oWikia->city_title, 'wikiLangCode' => $oWikia->city_lang, 'pages' => array());
             }
         }
         // if
         if (in_array($oResultRow->gwa_namespace, array(NS_BLOG_ARTICLE_TALK, NS_BLOG_ARTICLE))) {
             # blogs
             $aWikiBlogs[$iWikiId][] = $oResultRow;
             $this->makeBlogsList($aWikiDigest, $iWikiId, $oResultRow);
         } else {
             $oGlobalTitle = GlobalTitle::newFromText($oResultRow->gwa_title, $oResultRow->gwa_namespace, $iWikiId);
             if ($oGlobalTitle->exists()) {
                 $aWikiDigest['pages'][] = array('title' => GlobalTitle::newFromText($oResultRow->gwa_title, $oResultRow->gwa_namespace, $iWikiId), 'revisionId' => $oResultRow->gwa_rev_id);
             } else {
                 $aRemove[] = $oResultRow->gwa_id;
             }
         }
         $loop++;
     }
     // while
     $dbr->freeResult($oResource);
     $cnt = count($aWikiDigest['pages']);
     if (isset($aWikiDigest['blogs'])) {
         $cnt += count($aWikiDigest['blogs']);
     }
     if (!empty($cnt)) {
         $aDigestData[$iWikiId] = $aWikiDigest;
     }
     $iEmailsSent = 0;
     if (count($aDigestData)) {
         $iEmailsSent++;
         $this->printDebug("Sending email with " . count($aDigestData) . " records ");
         $this->sendMail($iUserId, $aDigestData, $bTooManyPages);
     } else {
         $this->printDebug("No records to send ");
     }
     if (count($aRemove)) {
         $dbs = wfGetDB(DB_MASTER, array(), $wgExternalDatawareDB);
         foreach ($aRemove as $gwa_id) {
             $dbs->delete('global_watchlist', array('gwa_user_id' => $iUserId, 'gwa_id' => $gwa_id), __METHOD__);
         }
         $dbs->commit();
     }
     return $iEmailsSent;
 }
コード例 #19
0
 private function getEventsInfo()
 {
     wfProfileIn(__METHOD__);
     $where = array();
     $where['wiki_id'] = intval($this->mCityId);
     # bot
     if (empty($this->params['bot'])) {
         $where['user_is_bot'] = 'N';
     }
     # content
     if ($this->params['content'] == 1) {
         $where['is_content'] = 'Y';
     }
     # anons
     if (empty($this->params['anons'])) {
         $where[] = 'user_id > 0';
     }
     $db = $this->getDB();
     if (is_null($db)) {
         return false;
     }
     $this->profileDBIn();
     $oRes = $db->select('events', array('wiki_id', 'page_id', 'rev_id', 'log_id', 'user_id', 'user_is_bot', 'page_ns', 'is_content', 'is_redirect', 'ip', 'rev_timestamp', 'image_links', 'video_links', 'total_words', 'rev_size', 'wiki_lang_id', 'wiki_cat_id', 'event_type', 'event_date', 'media_type'), $where, __METHOD__, array('ORDER BY' => 'rev_timestamp DESC', 'LIMIT' => $this->params['limit'], 'OFFSET' => $this->params['offset']));
     $i = 0;
     $data = array();
     while ($row = $db->fetchObject($oRes)) {
         # wiki
         $oWiki = WikiFactory::getWikiByID($row->wiki_id);
         if (empty($oWiki)) {
             continue;
         }
         # server name
         $server = WikiFactory::getVarValueByName("wgServer", $row->wiki_id);
         # user
         $oUser = null;
         $username = long2ip($row->ip);
         if ($row->user_id > 0) {
             $oUser = User::newFromId($row->user_id);
             $username = $oUser->getName();
         }
         # page
         $url = "";
         if ($row->event_type == 1 || $row->event_type == 2) {
             // edit or create
             $oGTitle = GlobalTitle::newFromId($row->page_id, $row->wiki_id);
             if (is_object($oGTitle)) {
                 $url = $oGTitle->getFullURL();
             }
         }
         if (empty($url)) {
             if (is_object($oUser)) {
                 $url = $oUser->getUserPage()->getFullURL();
             } else {
                 $url = $server;
             }
         }
         # avatar
         $avatar = AvatarService::getAvatarUrl($username, 75);
         $data[$i] = array('wiki_id' => $row->wiki_id, 'wiki_url' => $server, 'page_id' => $row->page_id, 'page_url' => $url, 'namespace' => $row->page_ns, 'action' => $row->log_id > 0 ? 'remove' : 'edit', 'user_id' => $row->user_id, 'user_name' => $username, 'user_avatar' => $avatar, 'bot' => $row->user_is_bot, 'content' => $row->is_content, 'redirect' => $row->is_redirect, 'edited' => $row->rev_timestamp);
         $i++;
     }
     $db->freeResult($oRes);
     $this->profileDBOut();
     wfProfileOut(__METHOD__);
     return $data;
 }
コード例 #20
0
ファイル: DumpsOnDemand.php プロジェクト: Tjorriemorrie/app
 /**
  * @static
  * @access public
  */
 public static function queueDump($iCityId = null, $bHidden = false, $bClose = false)
 {
     if (is_null($iCityId)) {
         global $wgCityId;
         $iCityId = $wgCityId;
     }
     $oWiki = WikiFactory::getWikiByID($iCityId);
     if (!is_object($oWiki)) {
         trigger_error(sprintf('%s terminated. No such wiki (city_id: %d.', __METHOD__, $iCityId), E_USER_WARNING);
         return null;
     }
     global $wgUser;
     $aData = array('dump_wiki_id' => $iCityId, 'dump_wiki_dbname' => $oWiki->city_dbname, 'dump_wiki_url' => $oWiki->city_url, 'dump_user_name' => $wgUser->getName(), 'dump_requested' => wfTimestampNow());
     if ($bHidden) {
         $aData['dump_hidden'] = 'Y';
     }
     if ($bClose) {
         $aData['dump_closed'] = 'Y';
     }
     $oDB = wfGetDB(DB_MASTER, array(), 'wikicities');
     $oDB->insert('dumps', $aData, __METHOD__);
     $oDB->update('city_list', array('city_lastdump_timestamp' => wfTimestampNow()), array('city_id' => $iCityId), __METHOD__);
 }
コード例 #21
0
 function checkUserActivity($order = null)
 {
     global $wgMemc, $wgStatsDB, $wgStatsDBEnabled, $wgLang;
     $userActivity = array();
     $ip = ip2long($this->mUsername);
     $memkey = __METHOD__ . ":all:ip:" . $ip . ":limit:" . intval($this->mLimit) . ":offset:" . intval($this->mOffset) . ":order:" . $order;
     $cached = $wgMemc->get($memkey);
     if ((!is_array($cached) || MULTILOOKUP_NO_CACHE) && !empty($wgStatsDBEnabled)) {
         $dbs = wfGetDB(DB_SLAVE, array(), $wgStatsDB);
         $qOptions = array('ORDER BY' => 'ml_count DESC, ml_ts DESC', 'LIMIT' => $this->mLimit, 'OFFSET' => $this->mOffset);
         if (preg_match('/^lastedit:(asc|desc)$/', $order, $aMatches)) {
             if (isset($aMatches[1])) {
                 $qOptions['ORDER BY'] = $aMatches[1] == 'desc' ? 'ml_ts DESC' : 'ml_ts';
             }
         }
         $oRes = $dbs->select(array('`specials`.`multilookup`'), array('ml_city_id', 'ml_ts'), array('ml_ip' => $ip), __METHOD__, $qOptions);
         while ($oRow = $dbs->fetchObject($oRes)) {
             $oWikia = WikiFactory::getWikiByID($oRow->ml_city_id);
             if ($oWikia) {
                 $lastEditDate = $wgLang->timeanddate(wfTimestamp(TS_MW, $oRow->ml_ts));
                 $userActivity[] = array($oWikia->city_dbname, $oWikia->city_title, $oWikia->city_url, $lastEditDate);
             }
         }
         $dbs->freeResult($oRes);
         if (!MULTILOOKUP_NO_CACHE) {
             $wgMemc->set($memkey, $userActivity, 60 * 15);
         }
     } else {
         $userActivity = $cached;
     }
     return $userActivity;
 }
コード例 #22
0
 /**
  * Gets the information about wikis [DEPRECATED]
  *
  * @requestParam array $ids The list of wiki ids that will be fetched
  * @requestParam int $height [OPTIONAL] Thumbnail height in pixels
  * @requestParam int $width [OPTIONAL] Thumbnail width in pixels
  * @requestParam int $snippet [OPTIONAL] Maximum number of words returned in description
  *
  * @responseParam array $items The list of wikis, each containing: title, url, description, thumbnail, no. of articles, no. of photos, list of top contributors, no. of videos
  *
  * @example &ids=159,831,3125
  * @example &ids=159,831,3125&width=100
  * @example &ids=159,831,3125&height=100&width=100&snippet=25
  */
 public function getWikiData()
 {
     wfProfileIn(__METHOD__);
     $ids = $this->request->getArray('ids');
     $imageWidth = $this->request->getInt('width', static::DEFAULT_WIDTH);
     $imageHeight = $this->request->getInt('height', static::DEFAULT_HEIGHT);
     $length = $this->request->getVal('snippet', static::DEFAULT_SNIPPET_LENGTH);
     $items = array();
     $service = new WikiService();
     foreach ($ids as $wikiId) {
         if (($cached = $this->getFromCacheWiki($wikiId, __METHOD__)) !== false) {
             //get from cache
             $wikiInfo = $cached;
         } else {
             //get data providers
             $wikiObj = WikiFactory::getWikiByID($wikiId);
             $wikiStats = $service->getSiteStats($wikiId);
             $topUsers = $service->getTopEditors($wikiId, static::DEFAULT_TOP_EDITORS_NUMBER, true);
             $wikiInfo = array('id' => (int) $wikiId, 'articles' => (int) $wikiStats['articles'], 'images' => (int) $wikiStats['images'], 'videos' => (int) $service->getTotalVideos($wikiId), 'topUsers' => array_keys($topUsers), 'title' => $wikiObj->city_title, 'url' => $wikiObj->city_url);
             //cache data
             $this->cacheWikiData($wikiInfo, __METHOD__);
         }
         $wikiDesc = $service->getWikiDescription([$wikiId], $imageWidth, $imageHeight);
         //set snippet
         $wikiInfo['description'] = $this->getSnippet(isset($wikiDesc[$wikiId]) ? $wikiDesc[$wikiId]['desc'] : '', $length);
         //add image, its cached on different level
         $wikiInfo['thumbnail'] = isset($wikiDesc[$wikiId]) ? $wikiDesc[$wikiId]['image_url'] : '';
         //add to result
         $items[] = $wikiInfo;
     }
     $this->response->setVal('items', $items);
     wfProfileOut(__METHOD__);
 }
コード例 #23
0
 public function outputResults($skin, $data)
 {
     global $wgContLang, $wgLang, $wgOut;
     wfProfileIn(__METHOD__);
     $num = 0;
     $html = array();
     if ($this->mShow) {
         $wgOut->addHTML(XML::openElement('div', array('class' => 'mw-spcontent')));
     }
     if (isset($data) && $data['numrec'] > 0) {
         $num = $data['numrec'];
         if ($this->mShow) {
             $html[] = XML::openElement('ol', array('start' => $this->offset + 1, 'class' => 'special'));
         }
         if ($data['numrec'] <= self::ORDER_ROWS) {
             arsort($data['order']);
         }
         $loop = 0;
         $skip = 0;
         foreach ($data['order'] as $city_id => $ordered) {
             # check loop
             if ($loop >= $this->offset && $loop < $this->limit + $this->offset) {
                 list($page_id, $page_url, $page_server) = $data['rows'][$city_id];
                 # page url
                 if (empty($page_url) || empty($page_server)) {
                     $oGTitle = GlobalTitle::newFromText($this->mPageTitle, $this->mPageNS, $city_id);
                     if (is_object($oGTitle)) {
                         $page_url = $oGTitle->getFullURL();
                         $page_server = $oGTitle->getServer();
                     }
                     if (empty($page_url) || empty($page_server)) {
                         $skip++;
                         continue;
                     }
                 }
                 # check Wiki
                 if (!empty($city_id)) {
                     $oWikia = WikiFactory::getWikiByID($city_id);
                     if (empty($oWikia) || empty($oWikia->city_public)) {
                         continue;
                     }
                 }
                 if (empty($this->mShow)) {
                     $res = "";
                     $this->data[$city_id] = array('city_id' => $city_id, 'page_id' => $page_id, 'url' => $page_url);
                 } else {
                     $res = wfSpecialList(Xml::openElement('a', array('href' => $page_url)) . $page_url . Xml::closeElement('a'), "");
                 }
                 $html[] = $this->mShow ? Xml::openElement('li') . $res . Xml::closeElement('li') : "";
             }
             $loop++;
         }
         $num = $num - $skip;
         if ($this->mShow) {
             $html[] = XML::closeElement('ol');
         }
     }
     # Top header and navigation
     if ($this->mShow) {
         $wgOut->addHTML('<p>' . wfMsgExt('multiwikirecords', array(), $num) . '</p>');
         if ($num > 0) {
             $wgOut->addHTML('<p>' . wfShowingResults($this->offset, $num) . '</p>');
             # Disable the "next" link when we reach the end
             $paging = $wgLang->viewPrevNext(SpecialPage::getTitleFor($this->mName), $this->offset, $this->limit, $this->linkParameters(), $num < $this->limit);
             $wgOut->addHTML('<p>' . $paging . '</p>');
         } else {
             $wgOut->addHTML(XML::closeElement('div'));
             return;
         }
     }
     $html = $this->mShow ? implode('', $html) : $wgContLang->listToText($html);
     $wgOut->addHTML($html);
     # Repeat the paging links at the bottom
     if ($this->mShow) {
         $wgOut->addHTML('<p>' . $paging . '</p>');
     }
     $wgOut->addHTML(XML::closeElement('div'));
     wfProfileOut(__METHOD__);
     return $num;
 }
コード例 #24
0
 /**
  * @param int $id WikiId
  * @param boolean $exists States if Wikia with given id exists
  * @return array
  */
 protected function getFromWikiFactory($id, &$exists = null)
 {
     $exists = false;
     $wikiObj = WikiFactory::getWikiByID($id);
     if ($wikiObj) {
         $exists = true;
         return ['title' => $wikiObj->city_title, 'url' => $wikiObj->city_url];
     }
     return [];
 }
コード例 #25
0
 protected function getGAUrlFromCityId()
 {
     $url = WikiFactory::getWikiByID($this->getCityId())->city_url;
     $hostname = str_replace('http://', '', $url);
     $hostname = str_replace('/', '', $hostname);
     return $hostname;
 }
コード例 #26
0
 private function loadWikiListFromDB($userId)
 {
     $db = $this->getDB(false);
     $res = $db->select('wall_notification', array('distinct wiki_id'), array('user_id' => $userId), __METHOD__);
     $output = array();
     while ($row = $db->fetchRow($res)) {
         $output[$row['wiki_id']] = $sitename = WikiFactory::getWikiByID($row['wiki_id'])->city_title;
     }
     return $output;
 }
コード例 #27
0
ファイル: GlobalTitle.php プロジェクト: yusufchang/app
 /**
  * loadServer
  *
  * Determine wgServer value from WikiFactory variables
  *
  * @return string
  */
 private function loadServer()
 {
     /**
      * don't do this twice
      */
     if ($this->mServer) {
         return $this->mServer;
     }
     $server = WikiFactory::getVarValueByName("wgServer", $this->mCityId);
     /**
      * special handling for dev boxes
      *
      * @author macbre
      */
     global $wgDevelEnvironment;
     if (!empty($wgDevelEnvironment)) {
         $this->mServer = WikiFactory::getLocalEnvURL($server);
         return $this->mServer;
     }
     /**
      * get value from city_variables
      */
     if ($server) {
         $this->mServer = $server;
         return $server;
     }
     /**
      * get value from city_list.city_url
      */
     $city = WikiFactory::getWikiByID($this->mCityId);
     /**
      * if we got this far and not have a value, ask master
      */
     if (empty($city)) {
         $city = WikiFactory::getWikiByID($this->mCityId, true);
     }
     if ($city) {
         $server = rtrim($city->city_url, "/");
         $this->mServer = $server;
         return $server;
     }
     return false;
 }
コード例 #28
0
ファイル: fixNavMessages.php プロジェクト: Tjorriemorrie/app
 * fix Navigation Messages (bugid: 13714)
 *
 * This script runs through MediaWiki:Wiki-navigation messages on wikis
 * and replaces default message keys with their respective message
 * values
 *
 * Usage: SERVER_ID=80433 php fixNavMessages.php --conf=/usr/wikia/docroot/wiki.factory/LocalSettings.php
 *
 * @addto maintenance
 * @author Sebastian Marzjan <sebastianm at wikia-inc.com>
 * @see https://wikia.fogbugz.com/default.asp?13714
 */
ini_set("include_path", dirname(__FILE__) . "/..");
require_once 'commandLine.inc';
echo date("Y-m-d H:i:s");
echo " / Processing navigation message for " . WikiFactory::getWikiByID($wgCityId)->city_title . "...\n";
$handler = new NavMessageHandler();
$handler->fixNavMessage();
echo date("Y-m-d H:i:s");
echo " / Script finished running!\n";
class NavMessageHandler
{
    const DEFAULT_USER_NAME = 'Default';
    private $messagesToReplace = array('blogs-recent-url-text', 'blogs-recent-url', 'portal-url', 'forum-url');
    private $user = null;
    /**
     * Main function fixing message for current (SERVER_ID) wiki
     */
    public function fixNavMessage()
    {
        $title = Title::newFromText(NavigationModel::WIKI_LOCAL_MESSAGE, NS_MEDIAWIKI);
コード例 #29
0
 /**
  * @param $outputModel
  * @return mixed
  */
 protected function getImage($wikiId, $articleId)
 {
     $dbName = '';
     try {
         $row = \WikiFactory::getWikiByID($wikiId);
         if ($row) {
             $dbName = $row->city_dbname;
             if (!empty($dbName)) {
                 $db = wfGetDB(DB_SLAVE, [], $dbName);
                 // throws if database does not exits.
                 $imageServing = new \ImageServing([$articleId], self::IMAGE_SIZE, self::IMAGE_SIZE, $db);
                 $isResult = $imageServing->getImages(1);
                 $images = isset($isResult[$articleId]) ? $isResult[$articleId] : false;
                 if ($images && sizeof($images) > 0) {
                     $imageName = $images[0]['name'];
                     $file = \GlobalFile::newFromText($imageName, $wikiId);
                     if ($file->exists()) {
                         return $imageServing->getUrl($file, $file->getWidth(), $file->getHeight());
                     }
                 }
             }
         }
     } catch (\DBConnectionError $ex) {
         // Swallow this exception. there is no simple way of telling if database does not exist other than catching exception.
         // Or am I wrong ?
         \Wikia::log(__METHOD__, false, "Cannot get database connection to " . $dbName);
     }
     return null;
 }
コード例 #30
0
$rows = $dbr->select('image',
	array( 'img_name' ),
	array( "img_name LIKE ':%'" ),
	__METHOD__
);

$rowCount = $rows->numRows();

$dbr->freeResult($rows);

$v = WikiFactory::getVarByName('wgVideoHandlersVideosMigrated', $wgCityId);
$ve = $v->cv_value;
echo(": {$rowCount} old videos found ($ve)\n");

if($rowCount > 0 && $ve != True) {
//if(true) {
	$dbw_dataware->insert(
		'video_notmigrated2',
		array(
			'wiki_id' => $wgCityId,
			'wiki_name' => WikiFactory::getWikiByID($wgCityId)->city_url,
			'video_count' => $rowCount
		)
	);
	echo("$wgCityId has videos but was not migrated!\n");
}


?>