/**
  * Finds search suggestions phrases for chosen query
  *
  * @requestParam string $query search term for suggestions
  *
  * @responseParam array $items The list of phrases matching the query
  *
  * @example &query=los
  */
 public function getList()
 {
     wfProfileIn(__METHOD__);
     if (!empty($this->wg->EnableLinkSuggestExt)) {
         $query = trim($this->request->getVal(self::PARAMETER_QUERY, null));
         if (empty($query)) {
             throw new MissingParameterApiException(self::PARAMETER_QUERY);
         }
         $request = new WebRequest();
         $request->setVal('format', 'array');
         $linkSuggestions = LinkSuggest::getLinkSuggest($request);
         if (!empty($linkSuggestions)) {
             foreach ($linkSuggestions as $suggestion) {
                 $searchSuggestions[]['title'] = $suggestion;
             }
             $this->response->setVal('items', $searchSuggestions);
         } else {
             throw new NotFoundApiException();
         }
         $this->response->setCacheValidity(WikiaResponse::CACHE_STANDARD);
     } else {
         throw new NotFoundApiException('Link Suggest extension not available');
     }
     wfProfileOut(__METHOD__);
 }
Example #2
0
 public function parseCode($code)
 {
     global $parserMemc;
     static $parserCache;
     // Unserializing can be expensive as well
     wfProfileIn(__METHOD__);
     $code = trim($code);
     $memcKey = 'isparser:ast:' . md5($code);
     if (isset($parserCache[$memcKey])) {
         wfProfileOut(__METHOD__);
         return $parserCache[$memcKey];
     }
     $cached = $parserMemc->get($memcKey);
     if (@$cached instanceof ISParserOutput && !$cached->isOutOfDate()) {
         $cached->appendTokenCount($this);
         $parserCache[$memcKey] = $cached->getParserTree();
         wfProfileOut(__METHOD__);
         return $cached->getParserTree();
     }
     $scanner = new ISScanner($code);
     $out = $this->mCodeParser->parse($scanner, $this->getMaxTokensLeft());
     $out->appendTokenCount($this);
     $parserMemc->set($memcKey, $out);
     $parserCache[$memcKey] = $out->getParserTree();
     wfProfileOut(__METHOD__);
     return $out->getParserTree();
 }
Example #3
0
 /**
  * Get list of Title objects representing existing boards
  *
  * @author Władysław Bodzek <*****@*****.**>
  *
  * @return array List of board IDs
  */
 public function getListTitles($db = DB_SLAVE, $namespace = NS_USER_WALL)
 {
     wfProfileIn(__METHOD__);
     $titles = TitleBatch::newFromConds('page_wikia_props', array('page.page_namespace' => $namespace, 'page_wikia_props.page_id = page.page_id'), __METHOD__, array('ORDER BY' => 'page_title'), $db);
     wfProfileOut(__METHOD__);
     return $titles;
 }
 /**
  * Adds users to watchlist if:
  * - User is watching parent page
  * - User has 'watchlistsubpages' turned on
  *
  * @param $watchers array of user ID
  * @param $title Title object
  * @param $editor User object
  * @param $notificationTimeoutSql string timeout to the watchlist
  *
  * @author Jakub Kurcek <*****@*****.**>
  */
 public static function NotifyOnSubPageChange($watchers, $title, $editor, $notificationTimeoutSql)
 {
     wfProfileIn(__METHOD__);
     // Gets parent data
     $arrTitle = explode('/', $title->getDBkey());
     if (empty($arrTitle)) {
         wfProfileOut(__METHOD__);
         return true;
     }
     // make Title
     $t = reset($arrTitle);
     $newTitle = Title::newFromDBkey($t);
     if (!$newTitle instanceof Title) {
         return true;
     }
     $dbw = wfGetDB(DB_MASTER);
     /** @var $dbw Database */
     $res = $dbw->select(array('watchlist'), array('wl_user'), array('wl_title' => $newTitle->getDBkey(), 'wl_namespace' => $newTitle->getNamespace(), 'wl_user != ' . intval($editor->getID()), $notificationTimeoutSql), __METHOD__);
     // Gets user settings
     $parentpageWatchers = array();
     while ($row = $dbw->fetchObject($res)) {
         $userId = intval($row->wl_user);
         $tmpUser = User::newFromId($userId);
         if ($tmpUser->getBoolOption(self::PREFERENCES_ENTRY)) {
             $parentpageWatchers[] = $userId;
         }
         unset($tmpUser);
     }
     // Updates parent watchlist timestamp for $parentOnlyWatchers.
     $parentOnlyWatchers = array_diff($parentpageWatchers, $watchers);
     $wl = WatchedItem::fromUserTitle($editor, $newTitle);
     $wl->updateWatch($parentOnlyWatchers);
     wfProfileOut(__METHOD__);
     return true;
 }
 protected function filterImages($imagesList = array())
 {
     wfProfileIn(__METHOD__);
     # get image names from imagelinks table
     $imagesName = array_keys($imagesList);
     if (!empty($imagesName)) {
         foreach ($imagesName as $img_name) {
             $result = $this->db->select(array('imagelinks'), array('il_from'), array('il_to' => $img_name), __METHOD__, array('LIMIT' => $this->maxCount + 1));
             #something goes wrong
             if (empty($result)) {
                 continue;
             }
             # skip images which are too popular
             if ($result->numRows() > $this->maxCount) {
                 continue;
             }
             # check image table
             $oRowImg = $this->db->selectRow(array('image'), array('img_name', 'img_height', 'img_width', 'img_minor_mime'), array('img_name' => $img_name), __METHOD__);
             if (empty($oRowImg)) {
                 continue;
             }
             if ($oRowImg->img_height > $this->minSize && $oRowImg->img_width > $this->minSize) {
                 if (!in_array($oRowImg->img_minor_mime, array("svg+xml", "svg"))) {
                     $this->addToFiltredList($oRowImg->img_name, $result->numRows(), $oRowImg->img_width, $oRowImg->img_height, $oRowImg->img_minor_mime);
                 }
             }
         }
     }
     wfProfileOut(__METHOD__);
 }
 /**
  * Render Quiz namespace page
  */
 public function view()
 {
     global $wgOut, $wgUser, $wgTitle, $wgRequest;
     wfProfileIn(__METHOD__);
     // let MW handle basic stuff
     parent::view();
     // don't override history pages
     $action = $wgRequest->getVal('action');
     if (in_array($action, array('history', 'historysubmit'))) {
         wfProfileOut(__METHOD__);
         return;
     }
     // quiz doesn't exist
     if (!$wgTitle->exists() || empty($this->mQuiz)) {
         wfProfileOut(__METHOD__);
         return;
     }
     // set page title
     $title = $this->mQuiz->getTitle();
     $wgOut->setPageTitle($title);
     // add CSS/JS
     $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/WikiaQuiz/css/WikiaQuizBuilder.scss'));
     // render quiz page
     $wgOut->clearHTML();
     $wgOut->addHTML($this->mQuiz->render());
     wfProfileOut(__METHOD__);
 }
 /**
  * Records a hit and enforces rate limits unless that is explicitly disabled in the call (see 'enforceRateLimits' param).
  *
  * @param apiKey - string - the API key of the app that made the request we are now logging
  * @param method - string - the method-name that was called in this request (should include class-name if appropriate - eg: 'MyClass::myMethod').
  * @param timestamp - int - number of seconds since the unix epoch at the time that this hit was made.
  * @param params - array - array of key-value pairs of the parameters that were passed into the method
  * @param enforceRateLimits - boolean - optional (default:true) - if true, then this function will check rate-limits after logging, and ban the apiKey if
  *                                      it has surpassed any of its rate-limits.
  */
 public function processHit($apiKey, $method, $timestamp, $params, $enforceRateLimits = true)
 {
     wfProfileIn(__METHOD__);
     // TODO: IMPLEMENT
     // TODO: IMPLEMENT
     wfProfileOut(__METHOD__);
 }
 public static function getBadge($badgeTypeId)
 {
     wfProfileIn(__METHOD__);
     global $wgExternalSharedDB;
     global $wgEnableAchievementsStoreLocalData;
     $badges = array();
     if (empty($wgEnableAchievementsStoreLocalData)) {
         $dbr = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB);
     } else {
         $dbr = wfGetDB(DB_SLAVE);
     }
     $res = $dbr->select('ach_custom_badges', array('id', 'enabled', 'sponsored', 'badge_tracking_url', 'hover_tracking_url', 'click_tracking_url'), array('id' => $badgeTypeId), __METHOD__);
     if ($row = $dbr->fetchObject($res)) {
         $badge = array();
         $image = wfFindFile(AchConfig::getInstance()->getBadgePictureName($row->id));
         if ($image) {
             $hoverImage = wfFindFile(AchConfig::getInstance()->getHoverPictureName($row->id));
             $badge['type_id'] = $row->id;
             $badge['enabled'] = $row->enabled;
             $badge['thumb_url'] = $image->createThumb(90);
             $badge['awarded_users'] = AchPlatinumService::getAwardedUserNames($row->id);
             $badge['is_sponsored'] = $row->sponsored;
             $badge['badge_tracking_url'] = $row->badge_tracking_url;
             $badge['hover_tracking_url'] = $row->hover_tracking_url;
             $badge['click_tracking_url'] = $row->click_tracking_url;
             $badge['hover_content_url'] = is_object($hoverImage) ? wfReplaceImageServer($hoverImage->getFullUrl()) : null;
             wfProfileOut(__METHOD__);
             return $badge;
         }
     }
     wfProfileOut(__METHOD__);
     return false;
 }
 public static function onArticleSaveComplete($article, $user, $revision, $status)
 {
     wfProfileIn(__METHOD__);
     $insertedImages = Wikia::getVar('imageInserts');
     $imageDeletes = Wikia::getVar('imageDeletes');
     $changedImages = $imageDeletes;
     foreach ($insertedImages as $img) {
         $changedImages[$img['il_to']] = true;
     }
     $sendTrackEvent = false;
     foreach ($changedImages as $imageDBName => $dummy) {
         $title = Title::newFromDBkey($imageDBName);
         if (!empty($title)) {
             $mq = new self($title);
             $mq->unsetCache();
             $sendTrackEvent = true;
         }
     }
     // send track event if embed change
     if ($sendTrackEvent) {
         Track::event('embed_change');
     }
     wfProfileOut(__METHOD__);
     return true;
 }
Example #10
0
function ActivityFeedTag_render($content, $attributes, $parser, $frame)
{
    global $wgExtensionsPath, $wgEnableAchievementsInActivityFeed, $wgEnableAchievementsExt;
    if (!class_exists('ActivityFeedHelper')) {
        return '';
    }
    wfProfileIn(__METHOD__);
    $parameters = ActivityFeedHelper::parseParameters($attributes);
    $tagid = str_replace('.', '_', uniqid('activitytag_', true));
    //jQuery might have a problem with . in ID
    $jsParams = "size={$parameters['maxElements']}";
    if (!empty($parameters['includeNamespaces'])) {
        $jsParams .= "&ns={$parameters['includeNamespaces']}";
    }
    if (!empty($parameters['flags'])) {
        $jsParams .= '&flags=' . implode('|', $parameters['flags']);
    }
    $parameters['tagid'] = $tagid;
    $feedHTML = ActivityFeedHelper::getList($parameters);
    $style = empty($parameters['style']) ? '' : ' style="' . $parameters['style'] . '"';
    $timestamp = wfTimestampNow();
    $snippetsDependencies = array('/extensions/wikia/MyHome/ActivityFeedTag.js', '/extensions/wikia/MyHome/ActivityFeedTag.css');
    if (!empty($wgEnableAchievementsInActivityFeed) && !empty($wgEnableAchievementsExt)) {
        array_push($snippetsDependencies, '/extensions/wikia/AchievementsII/css/achievements_sidebar.css');
    }
    $snippets = F::build('JSSnippets')->addToStack($snippetsDependencies, null, 'ActivityFeedTag.initActivityTag', array('tagid' => $tagid, 'jsParams' => $jsParams, 'timestamp' => $timestamp));
    wfProfileOut(__METHOD__);
    return "<div{$style}>{$feedHTML}</div>{$snippets}";
}
 /**
  * Load JS needed to display the VideosModule at the bottom of the article content
  * @param OutputPage $out
  * @param string $text
  * @return bool
  */
 public static function onOutputPageBeforeHTML(OutputPage $out, &$text)
 {
     wfProfileIn(__METHOD__);
     // Check if we're on a page where we want to show the Videos Module.
     // If we're not, stop right here.
     if (!self::canShowVideosModule()) {
         wfProfileOut(__METHOD__);
         return true;
     }
     // On file pages, this hook can be called multiple times, so we're going to check if the
     // assets are loaded already before we load them again.
     $app = F::app();
     // Don't do anything if we've already loaded the assets
     if ($app->wg->VideosModuleAssetsLoaded) {
         wfProfileOut(__METHOD__);
         return true;
     }
     // Don't do anything if this is the main page of a site with the VPT enabled
     if ($app->wg->Title->isMainPage() && $app->wg->EnableVideoPageToolExt) {
         wfProfileOut(__METHOD__);
         return true;
     }
     JSMessages::enqueuePackage('VideosModule', JSMessages::EXTERNAL);
     if ($app->checkSkin('venus')) {
         Wikia::addAssetsToOutput('videos_module_venus_js');
         Wikia::addAssetsToOutput('videos_module_venus_scss');
     } else {
         Wikia::addAssetsToOutput('videos_module_js');
     }
     $app->wg->VideosModuleAssetsLoaded = true;
     wfProfileOut(__METHOD__);
     return true;
 }
Example #12
0
 /**
  * @see Content::replaceSection()
  */
 public function replaceSection($section, Content $with, $sectionTitle = '')
 {
     wfProfileIn(__METHOD__);
     $myModelId = $this->getModel();
     $sectionModelId = $with->getModel();
     if ($sectionModelId != $myModelId) {
         wfProfileOut(__METHOD__);
         throw new MWException("Incompatible content model for section: " . "document uses {$myModelId} but " . "section uses {$sectionModelId}.");
     }
     $oldtext = $this->getNativeData();
     $text = $with->getNativeData();
     if ($section === '') {
         wfProfileOut(__METHOD__);
         return $with;
         # XXX: copy first?
     }
     if ($section == 'new') {
         # Inserting a new section
         $subject = $sectionTitle ? wfMessage('newsectionheaderdefaultlevel')->rawParams($sectionTitle)->inContentLanguage()->text() . "\n\n" : '';
         if (wfRunHooks('PlaceNewSection', array($this, $oldtext, $subject, &$text))) {
             $text = strlen(trim($oldtext)) > 0 ? "{$oldtext}\n\n{$subject}{$text}" : "{$subject}{$text}";
         }
     } else {
         # Replacing an existing section; roll out the big guns
         global $wgParser;
         $text = $wgParser->replaceSection($oldtext, $section, $text);
     }
     $newContent = new WikitextContent($text);
     wfProfileOut(__METHOD__);
     return $newContent;
 }
 /**
  * Execute function for generating view of Button template
  * Sets params' values of template
  * @param $params array of params described below
  * @param $params['link_url'] string Full link to some destination (mandatory)
  * @param $params['link_text'] string Description showed on a button
  */
 public function executeButton($params)
 {
     wfProfileIn(__METHOD__);
     $this->link_url = $params['link_url'];
     $this->link_text = array_key_exists('link_text', $params) ? $params['link_text'] : $this->link_url;
     wfProfileOut(__METHOD__);
 }
 public function index()
 {
     wfProfileIn(__METHOD__);
     $socialSharingService = SocialSharingService::getInstance();
     $this->setVal('networks', $socialSharingService->getNetworks(array('facebook', 'twitter', 'plusone', 'email')));
     wfProfileOut(__METHOD__);
 }
 protected function collect()
 {
     global $wgHitcounterUpdateFreq;
     $dbw = wfGetDB(DB_MASTER);
     $rown = $dbw->selectField('hitcounter', 'COUNT(*)', array(), __METHOD__);
     if ($rown < $wgHitcounterUpdateFreq) {
         return;
     }
     wfProfileIn(__METHOD__ . '-collect');
     $old_user_abort = ignore_user_abort(true);
     $dbw->lockTables(array(), array('hitcounter'), __METHOD__, false);
     $dbType = $dbw->getType();
     $tabletype = $dbType == 'mysql' ? "ENGINE=HEAP " : '';
     $hitcounterTable = $dbw->tableName('hitcounter');
     $acchitsTable = $dbw->tableName('acchits');
     $pageTable = $dbw->tableName('page');
     $dbw->query("CREATE TEMPORARY TABLE {$acchitsTable} {$tabletype} AS " . "SELECT hc_id,COUNT(*) AS hc_n FROM {$hitcounterTable} " . 'GROUP BY hc_id', __METHOD__);
     $dbw->delete('hitcounter', '*', __METHOD__);
     $dbw->unlockTables(__METHOD__);
     if ($dbType == 'mysql') {
         $dbw->query("UPDATE {$pageTable},{$acchitsTable} SET page_counter=page_counter + hc_n " . 'WHERE page_id = hc_id', __METHOD__);
     } else {
         $dbw->query("UPDATE {$pageTable} SET page_counter=page_counter + hc_n " . "FROM {$acchitsTable} WHERE page_id = hc_id", __METHOD__);
     }
     $dbw->query("DROP TABLE {$acchitsTable}", __METHOD__);
     ignore_user_abort($old_user_abort);
     wfProfileOut(__METHOD__ . '-collect');
 }
Example #16
0
 function performAction()
 {
     global $wgAjaxExportList, $wgOut;
     if (empty($this->mode)) {
         return;
     }
     wfProfileIn('AjaxDispatcher::performAction');
     if (!in_array($this->func_name, $wgAjaxExportList)) {
         header('Status: 400 Bad Request', true, 400);
         print "unknown function " . htmlspecialchars((string) $this->func_name);
     } else {
         try {
             $result = call_user_func_array($this->func_name, $this->args);
             if ($result === false || $result === NULL) {
                 header('Status: 500 Internal Error', true, 500);
                 echo "{$this->func_name} returned no data";
             } else {
                 if (is_string($result)) {
                     $result = new AjaxResponse($result);
                 }
                 $result->sendHeaders();
                 $result->printText();
             }
         } catch (Exception $e) {
             if (!headers_sent()) {
                 header('Status: 500 Internal Error', true, 500);
                 print $e->getMessage();
             } else {
                 print $e->getMessage();
             }
         }
     }
     wfProfileOut('AjaxDispatcher::performAction');
     $wgOut = null;
 }
Example #17
0
 /**
  * Returns the HTML which is added to $wgOut after the article text.
  *
  * @return string
  */
 protected function getHtml()
 {
     wfProfileIn(__METHOD__ . ' (SMW)');
     if ($this->limit > 0) {
         // limit==0: configuration setting to disable this completely
         $store = smwfGetStore();
         $description = new SMWConceptDescription($this->getDataItem());
         $query = SMWPageLister::getQuery($description, $this->limit, $this->from, $this->until);
         $queryResult = $store->getQueryResult($query);
         $diWikiPages = $queryResult->getResults();
         if ($this->until !== '') {
             $diWikiPages = array_reverse($diWikiPages);
         }
         $errors = $queryResult->getErrors();
     } else {
         $diWikiPages = array();
         $errors = array();
     }
     $pageLister = new SMWPageLister($diWikiPages, null, $this->limit, $this->from, $this->until);
     $this->mTitle->setFragment('#SMWResults');
     // Make navigation point to the result list.
     $navigation = $pageLister->getNavigationLinks($this->mTitle);
     $titleText = htmlspecialchars($this->mTitle->getText());
     $resultNumber = min($this->limit, count($diWikiPages));
     $result = "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMsg('smw_concept_header', $titleText) . "</h2>\n" . wfMsgExt('smw_conceptarticlecount', array('parsemag'), $resultNumber) . smwfEncodeMessages($errors) . "\n" . $navigation . $pageLister->formatList() . $navigation . "</div>\n";
     wfProfileOut(__METHOD__ . ' (SMW)');
     return $result;
 }
 public function getExhibitionItems(Title $title)
 {
     wfProfileIn(__METHOD__);
     if (class_exists('CategoryDataService')) {
         $cacheKey = $this->getExhibitionItemsCacheKey($title->getText());
         $items = $this->wg->memc->get($cacheKey);
         if (!is_array($items)) {
             $exh = CategoryDataService::getMostVisited($title->getDBkey(), null, self::EXHIBITION_ITEMS_LIMIT);
             $ids = array_keys($exh);
             $length = count($ids);
             $items = array();
             for ($i = 0; $i < $length; $i++) {
                 $pageId = $ids[$i];
                 $imgRespnse = $this->app->sendRequest('ImageServing', 'index', array('ids' => array($pageId), 'height' => 150, 'width' => 150, 'count' => 1));
                 $img = $imgRespnse->getVal('result');
                 if (!empty($img[$pageId])) {
                     $img = $img[$pageId][0]['url'];
                 } else {
                     $img = false;
                 }
                 $oTitle = Title::newFromID($pageId);
                 $items[] = ['img' => $img, 'title' => $oTitle->getText(), 'url' => $oTitle->getFullURL()];
             }
             $this->wg->memc->set($cacheKey, $items, self::CACHE_TTL_EXHIBITION);
         }
         wfProfileOut(__METHOD__);
         return $items;
     }
     wfProfileOut(__METHOD__);
     return false;
 }
Example #19
0
 /**
  * Format the category data list.
  *
  * @return string HTML output
  */
 public function getHTML()
 {
     global $wgCategoryMagicGallery;
     wfProfileIn(__METHOD__);
     $this->showGallery = $wgCategoryMagicGallery && !$this->getOutput()->mNoGallery;
     $this->clearCategoryState();
     $this->doCategoryQuery();
     $this->finaliseCategoryState();
     $r = $this->getSubcategorySection() . $this->getPagesSection() . $this->getImageSection();
     if ($r == '') {
         // If there is no category content to display, only
         // show the top part of the navigation links.
         // @todo FIXME: Cannot be completely suppressed because it
         //        is unknown if 'until' or 'from' makes this
         //        give 0 results.
         $r = $r . $this->getCategoryTop();
     } else {
         $r = $this->getCategoryTop() . $r . $this->getCategoryBottom();
     }
     // Give a proper message if category is empty
     if ($r == '') {
         $r = wfMsgExt('category-empty', array('parse'));
     }
     $lang = $this->getLanguage();
     $langAttribs = array('lang' => $lang->getCode(), 'dir' => $lang->getDir());
     # put a div around the headings which are in the user language
     $r = Html::openElement('div', $langAttribs) . $r . '</div>';
     wfProfileOut(__METHOD__);
     return $r;
 }
Example #20
0
 /** Open an MSSQL database and return a resource handle to it
  *  NOTE: only $dbName is used, the other parameters are irrelevant for MSSQL databases
  */
 function open($server, $user, $password, $dbName)
 {
     wfProfileIn(__METHOD__);
     # Test for missing mysql.so
     # First try to load it
     if (!@extension_loaded('mssql')) {
         @dl('mssql.so');
     }
     # Fail now
     # Otherwise we get a suppressed fatal error, which is very hard to track down
     if (!function_exists('mssql_connect')) {
         throw new DBConnectionError($this, "MSSQL functions missing, have you compiled PHP with the --with-mssql option?\n");
     }
     $this->close();
     $this->mServer = $server;
     $this->mUser = $user;
     $this->mPassword = $password;
     $this->mDBname = $dbName;
     wfProfileIn("dbconnect-{$server}");
     # Try to connect up to three times
     # The kernel's default SYN retransmission period is far too slow for us,
     # so we use a short timeout plus a manual retry.
     $this->mConn = false;
     $max = 3;
     for ($i = 0; $i < $max && !$this->mConn; $i++) {
         if ($i > 1) {
             usleep(1000);
         }
         if ($this->mFlags & DBO_PERSISTENT) {
             @($this->mConn = mssql_pconnect($server, $user, $password));
         } else {
             # Create a new connection...
             @($this->mConn = mssql_connect($server, $user, $password, true));
         }
     }
     wfProfileOut("dbconnect-{$server}");
     if ($dbName != '') {
         if ($this->mConn !== false) {
             $success = @mssql_select_db($dbName, $this->mConn);
             if (!$success) {
                 $error = "Error selecting database {$dbName} on server {$this->mServer} " . "from client host " . wfHostname() . "\n";
                 wfLogDBError(" Error selecting database {$dbName} on server {$this->mServer} \n");
                 wfDebug($error);
             }
         } else {
             wfDebug("DB connection error\n");
             wfDebug("Server: {$server}, User: {$user}, Password: "******"...\n");
             $success = false;
         }
     } else {
         # Delay USE query
         $success = (bool) $this->mConn;
     }
     if (!$success) {
         $this->reportConnectionError();
     }
     $this->mOpened = $success;
     wfProfileOut(__METHOD__);
     return $success;
 }
Example #21
0
 /**
  * Stream a file to the browser, adding all the headings and fun stuff.
  * Headers sent include: Content-type, Content-Length, Last-Modified,
  * and Content-Disposition.
  *
  * @param string $fname Full name and path of the file to stream
  * @param array $headers Any additional headers to send
  * @param bool $sendErrors Send error messages if errors occur (like 404)
  * @throws MWException
  * @return bool Success
  */
 public static function stream($fname, $headers = array(), $sendErrors = true)
 {
     wfProfileIn(__METHOD__);
     if (FileBackend::isStoragePath($fname)) {
         // sanity
         wfProfileOut(__METHOD__);
         throw new MWException(__FUNCTION__ . " given storage path '{$fname}'.");
     }
     wfSuppressWarnings();
     $stat = stat($fname);
     wfRestoreWarnings();
     $res = self::prepareForStream($fname, $stat, $headers, $sendErrors);
     if ($res == self::NOT_MODIFIED) {
         $ok = true;
         // use client cache
     } elseif ($res == self::READY_STREAM) {
         wfProfileIn(__METHOD__ . '-send');
         $ok = readfile($fname);
         wfProfileOut(__METHOD__ . '-send');
     } else {
         $ok = false;
         // failed
     }
     wfProfileOut(__METHOD__);
     return $ok;
 }
function __autoload($className)
{
    global $wgAutoloadClasses;
    # Locations of core classes
    # Extension classes are specified with $wgAutoloadClasses
    static $localClasses = array('AjaxDispatcher' => 'includes/AjaxDispatcher.php', 'AjaxCachePolicy' => 'includes/AjaxFunctions.php', 'AjaxResponse' => 'includes/AjaxResponse.php', 'AlphabeticPager' => 'includes/Pager.php', 'Article' => 'includes/Article.php', 'AuthPlugin' => 'includes/AuthPlugin.php', 'Autopromote' => 'includes/Autopromote.php', 'BagOStuff' => 'includes/BagOStuff.php', 'HashBagOStuff' => 'includes/BagOStuff.php', 'SqlBagOStuff' => 'includes/BagOStuff.php', 'MediaWikiBagOStuff' => 'includes/BagOStuff.php', 'TurckBagOStuff' => 'includes/BagOStuff.php', 'APCBagOStuff' => 'includes/BagOStuff.php', 'eAccelBagOStuff' => 'includes/BagOStuff.php', 'XCacheBagOStuff' => 'includes/BagOStuff.php', 'DBABagOStuff' => 'includes/BagOStuff.php', 'Block' => 'includes/Block.php', 'HTMLFileCache' => 'includes/HTMLFileCache.php', 'DependencyWrapper' => 'includes/CacheDependency.php', 'FileDependency' => 'includes/CacheDependency.php', 'TitleDependency' => 'includes/CacheDependency.php', 'TitleListDependency' => 'includes/CacheDependency.php', 'CategoryPage' => 'includes/CategoryPage.php', 'CategoryViewer' => 'includes/CategoryPage.php', 'Categoryfinder' => 'includes/Categoryfinder.php', 'RCCacheEntry' => 'includes/ChangesList.php', 'ChangesList' => 'includes/ChangesList.php', 'OldChangesList' => 'includes/ChangesList.php', 'EnhancedChangesList' => 'includes/ChangesList.php', 'CoreParserFunctions' => 'includes/CoreParserFunctions.php', 'DBObject' => 'includes/Database.php', 'Database' => 'includes/Database.php', 'DatabaseMysql' => 'includes/Database.php', 'ResultWrapper' => 'includes/Database.php', 'DatabasePostgres' => 'includes/DatabasePostgres.php', 'DatabaseOracle' => 'includes/DatabaseOracle.php', 'DateFormatter' => 'includes/DateFormatter.php', 'DifferenceEngine' => 'includes/DifferenceEngine.php', '_DiffOp' => 'includes/DifferenceEngine.php', '_DiffOp_Copy' => 'includes/DifferenceEngine.php', '_DiffOp_Delete' => 'includes/DifferenceEngine.php', '_DiffOp_Add' => 'includes/DifferenceEngine.php', '_DiffOp_Change' => 'includes/DifferenceEngine.php', '_DiffEngine' => 'includes/DifferenceEngine.php', 'Diff' => 'includes/DifferenceEngine.php', 'MappedDiff' => 'includes/DifferenceEngine.php', 'DiffFormatter' => 'includes/DifferenceEngine.php', 'UnifiedDiffFormatter' => 'includes/DifferenceEngine.php', 'ArrayDiffFormatter' => 'includes/DifferenceEngine.php', 'DjVuImage' => 'includes/DjVuImage.php', '_HWLDF_WordAccumulator' => 'includes/DifferenceEngine.php', 'WordLevelDiff' => 'includes/DifferenceEngine.php', 'TableDiffFormatter' => 'includes/DifferenceEngine.php', 'EditPage' => 'includes/EditPage.php', 'MWException' => 'includes/Exception.php', 'Exif' => 'includes/Exif.php', 'FormatExif' => 'includes/Exif.php', 'WikiExporter' => 'includes/Export.php', 'XmlDumpWriter' => 'includes/Export.php', 'DumpOutput' => 'includes/Export.php', 'DumpFileOutput' => 'includes/Export.php', 'DumpPipeOutput' => 'includes/Export.php', 'DumpGZipOutput' => 'includes/Export.php', 'DumpBZip2Output' => 'includes/Export.php', 'Dump7ZipOutput' => 'includes/Export.php', 'DumpFilter' => 'includes/Export.php', 'DumpNotalkFilter' => 'includes/Export.php', 'DumpNamespaceFilter' => 'includes/Export.php', 'DumpLatestFilter' => 'includes/Export.php', 'DumpMultiWriter' => 'includes/Export.php', 'ExternalEdit' => 'includes/ExternalEdit.php', 'ExternalStore' => 'includes/ExternalStore.php', 'ExternalStoreDB' => 'includes/ExternalStoreDB.php', 'ExternalStoreHttp' => 'includes/ExternalStoreHttp.php', 'FakeTitle' => 'includes/FakeTitle.php', 'FeedItem' => 'includes/Feed.php', 'ChannelFeed' => 'includes/Feed.php', 'RSSFeed' => 'includes/Feed.php', 'AtomFeed' => 'includes/Feed.php', 'FileStore' => 'includes/FileStore.php', 'FSException' => 'includes/FileStore.php', 'FSTransaction' => 'includes/FileStore.php', 'HistoryBlob' => 'includes/HistoryBlob.php', 'ConcatenatedGzipHistoryBlob' => 'includes/HistoryBlob.php', 'HistoryBlobStub' => 'includes/HistoryBlob.php', 'HistoryBlobCurStub' => 'includes/HistoryBlob.php', 'HTMLCacheUpdate' => 'includes/HTMLCacheUpdate.php', 'Http' => 'includes/HttpFunctions.php', 'IP' => 'includes/IP.php', 'ImageGallery' => 'includes/ImageGallery.php', 'ImagePage' => 'includes/ImagePage.php', 'ImageHistoryList' => 'includes/ImagePage.php', 'FileDeleteForm' => 'includes/FileDeleteForm.php', 'FileRevertForm' => 'includes/FileRevertForm.php', 'Job' => 'includes/JobQueue.php', 'EmaillingJob' => 'includes/EmaillingJob.php', 'EnotifNotifyJob' => 'includes/EnotifNotifyJob.php', 'HTMLCacheUpdateJob' => 'includes/HTMLCacheUpdate.php', 'RefreshLinksJob' => 'includes/RefreshLinksJob.php', 'Licenses' => 'includes/Licenses.php', 'License' => 'includes/Licenses.php', 'LinkBatch' => 'includes/LinkBatch.php', 'LinkCache' => 'includes/LinkCache.php', 'LinkFilter' => 'includes/LinkFilter.php', 'Linker' => 'includes/Linker.php', 'LinksUpdate' => 'includes/LinksUpdate.php', 'LoadBalancer' => 'includes/LoadBalancer.php', 'LogPage' => 'includes/LogPage.php', 'MacBinary' => 'includes/MacBinary.php', 'MagicWord' => 'includes/MagicWord.php', 'MagicWordArray' => 'includes/MagicWord.php', 'MathRenderer' => 'includes/Math.php', 'MediaTransformOutput' => 'includes/MediaTransformOutput.php', 'ThumbnailImage' => 'includes/MediaTransformOutput.php', 'MediaTransformError' => 'includes/MediaTransformOutput.php', 'TransformParameterError' => 'includes/MediaTransformOutput.php', 'MessageCache' => 'includes/MessageCache.php', 'MimeMagic' => 'includes/MimeMagic.php', 'Namespace' => 'includes/Namespace.php', 'FakeMemCachedClient' => 'includes/ObjectCache.php', 'OutputPage' => 'includes/OutputPage.php', 'PageHistory' => 'includes/PageHistory.php', 'IndexPager' => 'includes/Pager.php', 'ReverseChronologicalPager' => 'includes/Pager.php', 'TablePager' => 'includes/Pager.php', 'Parser' => 'includes/Parser.php', 'Parser_OldPP' => 'includes/Parser_OldPP.php', 'Parser_DiffTest' => 'includes/Parser_DiffTest.php', 'ParserCache' => 'includes/ParserCache.php', 'ParserOutput' => 'includes/ParserOutput.php', 'ParserOptions' => 'includes/ParserOptions.php', 'PatrolLog' => 'includes/PatrolLog.php', 'Preprocessor' => 'includes/Preprocessor.php', 'PrefixSearch' => 'includes/PrefixSearch.php', 'PPFrame' => 'includes/Preprocessor.php', 'PPNode' => 'includes/Preprocessor.php', 'Preprocessor_DOM' => 'includes/Preprocessor_DOM.php', 'PPFrame_DOM' => 'includes/Preprocessor_DOM.php', 'PPTemplateFrame_DOM' => 'includes/Preprocessor_DOM.php', 'PPDStack' => 'includes/Preprocessor_DOM.php', 'PPDStackElement' => 'includes/Preprocessor_DOM.php', 'PPNode_DOM' => 'includes/Preprocessor_DOM.php', 'Preprocessor_Hash' => 'includes/Preprocessor_Hash.php', 'ProfilerSimple' => 'includes/ProfilerSimple.php', 'ProfilerSimpleUDP' => 'includes/ProfilerSimpleUDP.php', 'Profiler' => 'includes/Profiler.php', 'ProxyTools' => 'includes/ProxyTools.php', 'ProtectionForm' => 'includes/ProtectionForm.php', 'QueryPage' => 'includes/QueryPage.php', 'PageQueryPage' => 'includes/PageQueryPage.php', 'ImageQueryPage' => 'includes/ImageQueryPage.php', 'RawPage' => 'includes/RawPage.php', 'RecentChange' => 'includes/RecentChange.php', 'Revision' => 'includes/Revision.php', 'Sanitizer' => 'includes/Sanitizer.php', 'SearchEngine' => 'includes/SearchEngine.php', 'SearchResultSet' => 'includes/SearchEngine.php', 'SearchResult' => 'includes/SearchEngine.php', 'SearchEngineDummy' => 'includes/SearchEngine.php', 'SearchMySQL' => 'includes/SearchMySQL.php', 'MySQLSearchResultSet' => 'includes/SearchMySQL.php', 'SearchMySQL4' => 'includes/SearchMySQL4.php', 'SearchPostgres' => 'includes/SearchPostgres.php', 'SearchUpdate' => 'includes/SearchUpdate.php', 'SearchUpdateMyISAM' => 'includes/SearchUpdate.php', 'SearchOracle' => 'includes/SearchOracle.php', 'SiteConfiguration' => 'includes/SiteConfiguration.php', 'SiteStats' => 'includes/SiteStats.php', 'SiteStatsUpdate' => 'includes/SiteStats.php', 'Skin' => 'includes/Skin.php', 'MediaWiki_I18N' => 'includes/SkinTemplate.php', 'SkinTemplate' => 'includes/SkinTemplate.php', 'QuickTemplate' => 'includes/SkinTemplate.php', 'SpecialAllpages' => 'includes/SpecialAllpages.php', 'AncientPagesPage' => 'includes/SpecialAncientpages.php', 'IPBlockForm' => 'includes/SpecialBlockip.php', 'SpecialBookSources' => 'includes/SpecialBooksources.php', 'BrokenRedirectsPage' => 'includes/SpecialBrokenRedirects.php', 'EmailConfirmation' => 'includes/SpecialConfirmemail.php', 'ContributionsPage' => 'includes/SpecialContributions.php', 'DeadendPagesPage' => 'includes/SpecialDeadendpages.php', 'DisambiguationsPage' => 'includes/SpecialDisambiguations.php', 'DoubleRedirectsPage' => 'includes/SpecialDoubleRedirects.php', 'EmailUserForm' => 'includes/SpecialEmailuser.php', 'WikiRevision' => 'includes/SpecialImport.php', 'WikiImporter' => 'includes/SpecialImport.php', 'ImportStringSource' => 'includes/SpecialImport.php', 'ImportStreamSource' => 'includes/SpecialImport.php', 'IPUnblockForm' => 'includes/SpecialIpblocklist.php', 'ListredirectsPage' => 'includes/SpecialListredirects.php', 'DBLockForm' => 'includes/SpecialLockdb.php', 'LogReader' => 'includes/SpecialLog.php', 'LogViewer' => 'includes/SpecialLog.php', 'LonelyPagesPage' => 'includes/SpecialLonelypages.php', 'LongPagesPage' => 'includes/SpecialLongpages.php', 'MIMEsearchPage' => 'includes/SpecialMIMEsearch.php', 'MostcategoriesPage' => 'includes/SpecialMostcategories.php', 'MostimagesPage' => 'includes/SpecialMostimages.php', 'MostlinkedPage' => 'includes/SpecialMostlinked.php', 'MostlinkedCategoriesPage' => 'includes/SpecialMostlinkedcategories.php', 'SpecialMostlinkedtemplates' => 'includes/SpecialMostlinkedtemplates.php', 'MostrevisionsPage' => 'includes/SpecialMostrevisions.php', 'FewestrevisionsPage' => 'includes/SpecialFewestrevisions.php', 'MovePageForm' => 'includes/SpecialMovepage.php', 'NewbieContributionsPage' => 'includes/SpecialNewbieContributions.php', 'NewPagesPage' => 'includes/SpecialNewpages.php', 'SpecialPage' => 'includes/SpecialPage.php', 'UnlistedSpecialPage' => 'includes/SpecialPage.php', 'IncludableSpecialPage' => 'includes/SpecialPage.php', 'PopularPagesPage' => 'includes/SpecialPopularpages.php', 'PreferencesForm' => 'includes/SpecialPreferences.php', 'SpecialPrefixindex' => 'includes/SpecialPrefixindex.php', 'RandomPage' => 'includes/SpecialRandompage.php', 'SpecialRandomredirect' => 'includes/SpecialRandomredirect.php', 'PasswordResetForm' => 'includes/SpecialResetpass.php', 'RevisionDeleteForm' => 'includes/SpecialRevisiondelete.php', 'RevisionDeleter' => 'includes/SpecialRevisiondelete.php', 'SpecialSearch' => 'includes/SpecialSearch.php', 'ShortPagesPage' => 'includes/SpecialShortpages.php', 'UncategorizedCategoriesPage' => 'includes/SpecialUncategorizedcategories.php', 'UncategorizedPagesPage' => 'includes/SpecialUncategorizedpages.php', 'UncategorizedTemplatesPage' => 'includes/SpecialUncategorizedtemplates.php', 'PageArchive' => 'includes/SpecialUndelete.php', 'UndeleteForm' => 'includes/SpecialUndelete.php', 'DBUnlockForm' => 'includes/SpecialUnlockdb.php', 'UnusedCategoriesPage' => 'includes/SpecialUnusedcategories.php', 'UnusedimagesPage' => 'includes/SpecialUnusedimages.php', 'UnusedtemplatesPage' => 'includes/SpecialUnusedtemplates.php', 'UnwatchedpagesPage' => 'includes/SpecialUnwatchedpages.php', 'UploadForm' => 'includes/SpecialUpload.php', 'UploadFormMogile' => 'includes/SpecialUploadMogile.php', 'LoginForm' => 'includes/SpecialUserlogin.php', 'UserrightsPage' => 'includes/SpecialUserrights.php', 'SpecialVersion' => 'includes/SpecialVersion.php', 'WantedCategoriesPage' => 'includes/SpecialWantedcategories.php', 'WantedPagesPage' => 'includes/SpecialWantedpages.php', 'WhatLinksHerePage' => 'includes/SpecialWhatlinkshere.php', 'WithoutInterwikiPage' => 'includes/SpecialWithoutinterwiki.php', 'SquidUpdate' => 'includes/SquidUpdate.php', 'ReplacementArray' => 'includes/StringUtils.php', 'Replacer' => 'includes/StringUtils.php', 'RegexlikeReplacer' => 'includes/StringUtils.php', 'DoubleReplacer' => 'includes/StringUtils.php', 'HashtableReplacer' => 'includes/StringUtils.php', 'StringUtils' => 'includes/StringUtils.php', 'Title' => 'includes/Title.php', 'User' => 'includes/User.php', 'UserRightsProxy' => 'includes/UserRightsProxy.php', 'MailAddress' => 'includes/UserMailer.php', 'EmailNotification' => 'includes/UserMailer.php', 'UserMailer' => 'includes/UserMailer.php', 'WatchedItem' => 'includes/WatchedItem.php', 'WebRequest' => 'includes/WebRequest.php', 'WebResponse' => 'includes/WebResponse.php', 'FauxRequest' => 'includes/WebRequest.php', 'MediaWiki' => 'includes/Wiki.php', 'WikiError' => 'includes/WikiError.php', 'WikiErrorMsg' => 'includes/WikiError.php', 'WikiXmlError' => 'includes/WikiError.php', 'Xml' => 'includes/Xml.php', 'XmlTypeCheck' => 'includes/XmlTypeCheck.php', 'ZhClient' => 'includes/ZhClient.php', 'memcached' => 'includes/memcached-client.php', 'EmaillingJob' => 'includes/JobQueue.php', 'WatchlistEditor' => 'includes/WatchlistEditor.php', 'ArchivedFile' => 'includes/filerepo/ArchivedFile.php', 'File' => 'includes/filerepo/File.php', 'FileRepo' => 'includes/filerepo/FileRepo.php', 'FileRepoStatus' => 'includes/filerepo/FileRepoStatus.php', 'ForeignDBFile' => 'includes/filerepo/ForeignDBFile.php', 'ForeignDBRepo' => 'includes/filerepo/ForeignDBRepo.php', 'FSRepo' => 'includes/filerepo/FSRepo.php', 'Image' => 'includes/filerepo/LocalFile.php', 'LocalFile' => 'includes/filerepo/LocalFile.php', 'LocalFileDeleteBatch' => 'includes/filerepo/LocalFile.php', 'LocalFileRestoreBatch' => 'includes/filerepo/LocalFile.php', 'LocalRepo' => 'includes/filerepo/LocalRepo.php', 'OldLocalFile' => 'includes/filerepo/OldLocalFile.php', 'RepoGroup' => 'includes/filerepo/RepoGroup.php', 'UnregisteredLocalFile' => 'includes/filerepo/UnregisteredLocalFile.php', 'BitmapHandler' => 'includes/media/Bitmap.php', 'BmpHandler' => 'includes/media/BMP.php', 'DjVuHandler' => 'includes/media/DjVu.php', 'MediaHandler' => 'includes/media/Generic.php', 'ImageHandler' => 'includes/media/Generic.php', 'SvgHandler' => 'includes/media/SVG.php', 'UtfNormal' => 'includes/normal/UtfNormal.php', 'UsercreateTemplate' => 'includes/templates/Userlogin.php', 'UserloginTemplate' => 'includes/templates/Userlogin.php', 'Language' => 'languages/Language.php', 'ApiBase' => 'includes/api/ApiBase.php', 'ApiExpandTemplates' => 'includes/api/ApiExpandTemplates.php', 'ApiFormatFeedWrapper' => 'includes/api/ApiFormatBase.php', 'ApiFeedWatchlist' => 'includes/api/ApiFeedWatchlist.php', 'ApiFormatBase' => 'includes/api/ApiFormatBase.php', 'Services_JSON' => 'includes/api/ApiFormatJson_json.php', 'ApiFormatJson' => 'includes/api/ApiFormatJson.php', 'ApiFormatPhp' => 'includes/api/ApiFormatPhp.php', 'ApiFormatWddx' => 'includes/api/ApiFormatWddx.php', 'ApiFormatXml' => 'includes/api/ApiFormatXml.php', 'ApiFormatTxt' => 'includes/api/ApiFormatTxt.php', 'ApiFormatDbg' => 'includes/api/ApiFormatDbg.php', 'Spyc' => 'includes/api/ApiFormatYaml_spyc.php', 'ApiFormatYaml' => 'includes/api/ApiFormatYaml.php', 'ApiHelp' => 'includes/api/ApiHelp.php', 'ApiLogin' => 'includes/api/ApiLogin.php', 'ApiLogout' => 'includes/api/ApiLogout.php', 'ApiMain' => 'includes/api/ApiMain.php', 'ApiOpenSearch' => 'includes/api/ApiOpenSearch.php', 'ApiPageSet' => 'includes/api/ApiPageSet.php', 'ApiParamInfo' => 'includes/api/ApiParamInfo.php', 'ApiParse' => 'includes/api/ApiParse.php', 'ApiQuery' => 'includes/api/ApiQuery.php', 'ApiQueryAllpages' => 'includes/api/ApiQueryAllpages.php', 'ApiQueryAllLinks' => 'includes/api/ApiQueryAllLinks.php', 'ApiQueryAllCategories' => 'includes/api/ApiQueryAllCategories.php', 'ApiQueryAllUsers' => 'includes/api/ApiQueryAllUsers.php', 'ApiQueryBase' => 'includes/api/ApiQueryBase.php', 'ApiQueryGeneratorBase' => 'includes/api/ApiQueryBase.php', 'ApiQueryBacklinks' => 'includes/api/ApiQueryBacklinks.php', 'ApiQueryCategories' => 'includes/api/ApiQueryCategories.php', 'ApiQueryCategoryMembers' => 'includes/api/ApiQueryCategoryMembers.php', 'ApiQueryContributions' => 'includes/api/ApiQueryUserContributions.php', 'ApiQueryExternalLinks' => 'includes/api/ApiQueryExternalLinks.php', 'ApiQueryExtLinksUsage' => 'includes/api/ApiQueryExtLinksUsage.php', 'ApiQueryImages' => 'includes/api/ApiQueryImages.php', 'ApiQueryImageInfo' => 'includes/api/ApiQueryImageInfo.php', 'ApiQueryInfo' => 'includes/api/ApiQueryInfo.php', 'ApiQueryLangLinks' => 'includes/api/ApiQueryLangLinks.php', 'ApiQueryLinks' => 'includes/api/ApiQueryLinks.php', 'ApiQueryLogEvents' => 'includes/api/ApiQueryLogEvents.php', 'ApiQueryRandom' => 'includes/api/ApiQueryRandom.php', 'ApiQueryRecentChanges' => 'includes/api/ApiQueryRecentChanges.php', 'ApiQueryRevisions' => 'includes/api/ApiQueryRevisions.php', 'ApiQuerySearch' => 'includes/api/ApiQuerySearch.php', 'ApiQueryAllmessages' => 'includes/api/ApiQueryAllmessages.php', 'ApiQuerySiteinfo' => 'includes/api/ApiQuerySiteinfo.php', 'ApiQueryUsers' => 'includes/api/ApiQueryUsers.php', 'ApiQueryUserInfo' => 'includes/api/ApiQueryUserInfo.php', 'ApiQueryWatchlist' => 'includes/api/ApiQueryWatchlist.php', 'ApiResult' => 'includes/api/ApiResult.php', 'ApiBlock' => 'includes/api/ApiBlock.php', 'ApiDelete' => 'includes/api/ApiDelete.php', 'ApiMove' => 'includes/api/ApiMove.php', 'ApiProtect' => 'includes/api/ApiProtect.php', 'ApiQueryBlocks' => 'includes/api/ApiQueryBlocks.php', 'ApiQueryDeletedrevs' => 'includes/api/ApiQueryDeletedrevs.php', 'ApiRollback' => 'includes/api/ApiRollback.php', 'ApiUnblock' => 'includes/api/ApiUnblock.php', 'ApiUndelete' => 'includes/api/ApiUndelete.php');
    wfProfileIn(__METHOD__);
    if (isset($localClasses[$className])) {
        $filename = $localClasses[$className];
    } elseif (isset($wgAutoloadClasses[$className])) {
        $filename = $wgAutoloadClasses[$className];
    } else {
        # Try a different capitalisation
        # The case can sometimes be wrong when unserializing PHP 4 objects
        $filename = false;
        $lowerClass = strtolower($className);
        foreach ($localClasses as $class2 => $file2) {
            if (strtolower($class2) == $lowerClass) {
                $filename = $file2;
            }
        }
        if (!$filename) {
            # Give up
            wfProfileOut(__METHOD__);
            return;
        }
    }
    # Make an absolute path, this improves performance by avoiding some stat calls
    if (substr($filename, 0, 1) != '/' && substr($filename, 1, 1) != ':') {
        global $IP;
        $filename = "{$IP}/{$filename}";
    }
    require $filename;
    wfProfileOut(__METHOD__);
}
 public function executeWordmark()
 {
     $themeSettings = new ThemeSettings();
     $settings = $themeSettings->getSettings();
     $this->wordmarkText = $settings['wordmark-text'];
     $this->wordmarkType = $settings['wordmark-type'];
     $this->wordmarkSize = $settings['wordmark-font-size'];
     $this->wordmarkFont = $settings['wordmark-font'];
     $this->wordmarkFontClass = !empty($settings["wordmark-font"]) ? "font-{$settings['wordmark-font']}" : '';
     $this->wordmarkUrl = '';
     if ($this->wordmarkType == "graphic") {
         wfProfileIn(__METHOD__ . 'graphicWordmark');
         $this->wordmarkUrl = $themeSettings->getWordmarkUrl();
         $imageTitle = Title::newFromText($themeSettings::WordmarkImageName, NS_IMAGE);
         if ($imageTitle instanceof Title) {
             $attributes = array();
             $file = wfFindFile($imageTitle);
             if ($file instanceof File) {
                 $attributes[] = 'width="' . $file->width . '"';
                 $attributes[] = 'height="' . $file->height . '"';
                 if (!empty($attributes)) {
                     $this->wordmarkStyle = ' ' . implode(' ', $attributes) . ' ';
                 }
             }
         }
         wfProfileOut(__METHOD__ . 'graphicWordmark');
     }
     $this->mainPageURL = Title::newMainPage()->getLocalURL();
 }
 public function Wordmark()
 {
     $themeSettings = new ThemeSettings();
     $settings = $themeSettings->getSettings();
     $wordmarkURL = '';
     if ($settings['wordmark-type'] == 'graphic') {
         wfProfileIn(__METHOD__ . 'graphicWordmark');
         $imageTitle = Title::newFromText($themeSettings::WordmarkImageName, NS_IMAGE);
         $file = wfFindFile($imageTitle);
         $attributes = [];
         $wordmarkStyle = '';
         if ($file instanceof File) {
             $wordmarkURL = $file->getUrl();
             $attributes[] = 'width="' . $file->width . '"';
             $attributes[] = 'height="' . $file->height . '"';
             if (!empty($attributes)) {
                 $this->wordmarkStyle = ' ' . implode(' ', $attributes) . ' ';
             }
         }
         wfProfileOut(__METHOD__ . 'graphicWordmark');
     }
     $mainPageURL = Title::newMainPage()->getLocalURL();
     $this->setVal('mainPageURL', $mainPageURL);
     $this->setVal('wordmarkText', $settings['wordmark-text']);
     $this->setVal('wordmarkFontSize', $settings['wordmark-font-size']);
     $this->setVal('wordmarkUrl', $wordmarkURL);
     $this->setVal('wordmarkStyle', $wordmarkStyle);
 }
Example #25
0
 public function execute()
 {
     global $wgRevisionCacheExpiry, $wgMemc;
     wfProfileIn(__METHOD__);
     $cluster = $blobid = null;
     extract($this->extractRequestParams());
     if (empty($blobid)) {
         $this->dieUsage('Invalid blobid', 1, 404);
     }
     if (empty($cluster)) {
         $this->dieUsage('Invalid cluster', 2, 404);
     }
     $url = sprintf("DB://%s/%d", $cluster, $blobid);
     $text = ExternalStore::fetchFromURL($url);
     if ($text === false) {
         $this->dieUsage('Text not found', 3, 404);
     }
     $result = $this->getResult();
     $result->setRawMode();
     $result->disableSizeCheck();
     $result->reset();
     $result->addValue(null, 'text', $text);
     $result->addValue(null, 'mime', 'text/plain');
     $result->enableSizeCheck();
     wfProfileOut(__METHOD__);
 }
Example #26
0
 protected static function fetchRegexData($mode)
 {
     global $wgMemc;
     wfProfileIn(__METHOD__);
     $phrases = array();
     /* first, check if regex string is already stored in memcache */
     $key_clause = $mode == SPAMREGEX_SUMMARY ? 'Summary' : 'Textbox';
     $key = wfSpamRegexCacheKey('spamRegexCore', 'spamRegex', $key_clause);
     $cached = $wgMemc->get($key);
     if (!$cached) {
         /* fetch data from db, concatenate into one string, then fill cache */
         $field = $mode == SPAMREGEX_SUMMARY ? 'spam_summary' : 'spam_textbox';
         $dbr = wfGetDB(DB_SLAVE);
         $res = $dbr->select('spam_regex', 'spam_text', array($field => 1), __METHOD__);
         while ($row = $res->fetchObject()) {
             $concat = $row->spam_text;
             $phrases[] = "/" . $concat . "/i";
         }
         $wgMemc->set($key, $phrases, 0);
         $res->free();
     } else {
         /* take from cache */
         $phrases = $cached;
     }
     wfProfileOut(__METHOD__);
     return $phrases;
 }
 /**
  * Get users with avatar who sign up on the wiki (include founder)
  *
  * @param integer $wikiId
  * @param integer $limit (number of users)
  * @return array $wikiUsers
  */
 protected function getWikiUsers($wikiId = null, $limit = 30)
 {
     global $wgSpecialsDB;
     wfProfileIn(__METHOD__);
     $wikiId = empty($wikiId) ? $this->wg->CityId : $wikiId;
     $memKey = wfSharedMemcKey('userlogin', 'users_with_avatar', $wikiId);
     $wikiUsers = $this->wg->Memc->get($memKey);
     if (!is_array($wikiUsers)) {
         $wikiUsers = array();
         $db = wfGetDB(DB_SLAVE, array(), $wgSpecialsDB);
         $result = $db->select(array('user_login_history'), array('distinct user_id'), array('city_id' => $wikiId), __METHOD__, array('LIMIT' => $limit));
         while ($row = $db->fetchObject($result)) {
             $this->addUserToUserList($row->user_id, $wikiUsers);
         }
         $db->freeResult($result);
         // add founder if not exist
         $founder = WikiFactory::getWikiById($wikiId)->city_founding_user;
         if (!array_key_exists($founder, $wikiUsers)) {
             $this->addUserToUserList($founder, $wikiUsers);
         }
         $this->wg->Memc->set($memKey, $wikiUsers, WikiaResponse::CACHE_STANDARD);
     }
     wfProfileOut(__METHOD__);
     return $wikiUsers;
 }
 /**
  * @param $langCode string
  * @return array
  * @throws MWException
  */
 private static function getFeedsInternal($langCode)
 {
     global $wgFeaturedFeeds, $wgFeaturedFeedsDefaults, $wgContLang;
     wfProfileIn(__METHOD__);
     $feedDefs = $wgFeaturedFeeds;
     wfRunHooks('FeaturedFeeds::getFeeds', array(&$feedDefs));
     // fill defaults
     foreach ($feedDefs as $name => $opts) {
         foreach ($wgFeaturedFeedsDefaults as $setting => $value) {
             if (!isset($opts[$setting])) {
                 $feedDefs[$name][$setting] = $value;
             }
         }
     }
     $feeds = array();
     $requestedLang = Language::factory($langCode);
     $parser = new Parser();
     foreach ($feedDefs as $name => $opts) {
         $feed = new FeaturedFeedChannel($name, $opts, $requestedLang);
         if (!$feed->isOK()) {
             continue;
         }
         $feed->getFeedItems();
         $feeds[$name] = $feed;
     }
     wfProfileOut(__METHOD__);
     return $feeds;
 }
Example #29
0
 public function getHTML()
 {
     wfProfileIn(__METHOD__);
     $this->report->loadSources();
     $aData = array();
     $aLabel = array();
     if (count($this->report->reportSources) == 0) {
         return '';
     }
     foreach ($this->report->reportSources as $reportSource) {
         $reportSource->getData();
         $this->actualDate = $reportSource->actualDate;
         if (!empty($reportSource->dataAll) && !empty($reportSource->dataTitles)) {
             if (is_array($reportSource->dataAll)) {
                 foreach ($reportSource->dataAll as $key => $val) {
                     if (isset($aData[$key])) {
                         $aData[$key] = array_merge($aData[$key], $val);
                     } else {
                         $aData[$key] = $val;
                     }
                 }
             }
             $aLabel += $reportSource->dataTitles;
         }
     }
     sort($aData);
     $this->sourceData = array_reverse($aData);
     $this->sourceLabels = array_reverse($aLabel);
     $oTmpl = F::build('EasyTemplate', array(dirname(__FILE__) . "/templates/"));
     /** @var $oTmpl EasyTemplate */
     $oTmpl->set_vars(array('data' => $this->sourceData, 'labels' => $this->sourceLabels));
     wfProfileOut(__METHOD__);
     $this->beforePrint();
     return $oTmpl->render('../../templates/output/' . self::TEMPLATE_MAIN);
 }
	/**
	 * Run a pageSchemasCreatePage job
	 * @return boolean success
	 */
	function run() {
		wfProfileIn( __METHOD__ );

		if ( is_null( $this->title ) ) {
			$this->error = "pageSchemasCreatePage: Invalid title";
			wfProfileOut( __METHOD__ );
			return false;
		}
		$article = new Article( $this->title );
		if ( !$article ) {
			$this->error = 'pageSchemasCreatePage: Article not found "' . $this->title->getPrefixedDBkey() . '"';
			wfProfileOut( __METHOD__ );
			return false;
		}

		$page_text = $this->params['page_text'];
		// change global $wgUser variable to the one
		// specified by the job only for the extent of this
		// replacement
		global $wgUser;
		$actual_user = $wgUser;
		$wgUser = User::newFromId( $this->params['user_id'] );
		$edit_summary = wfMsgForContent( 'ps-generatepages-editsummary' );
		$article->doEdit( $page_text, $edit_summary );
		$wgUser = $actual_user;
		wfProfileOut( __METHOD__ );
		return true;
	}