Exemplo n.º 1
0
 public function execute()
 {
     $this->test = $this->hasOption('test');
     $this->verbose = $this->hasOption('verbose');
     $action = $this->getOption('action');
     $key = $this->getOption('key');
     $class = $this->hasOption("class");
     $servers = $this->hasOption("servers");
     if ($class) {
         global $gMemCachedClass;
         echo get_class(F::app()->wg->Memc->getClient()) . "\n";
     }
     if ($servers) {
         //print_r( F::app()->wg->Memc->getClient() );
         //echo "\n\n";
         foreach (F::app()->wg->Memc->getClient()->_servers as $stuff) {
             print_r($stuff);
             echo "\n";
         }
     }
     $memc = F::app()->wg->Memc;
     if ($action == 'get') {
         print_r($memc->get($key));
     }
     if ($action == 'delete') {
         print_r($memc->delete($key));
     }
 }
 public function execute($subpage)
 {
     global $wgOut, $wgUser, $wgExtensionsPath, $wgResourceBasePath;
     // Boilerplate special page permissions
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     if (wfReadOnly() && !wfAutomaticReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if (!$wgUser->isAllowed('createpage') || !$wgUser->isAllowed('edit')) {
         $this->displayRestrictionError();
         return;
     }
     $wgOut->addModules("wikia.jquery.ui");
     $wgOut->addScript('<script src="' . $wgExtensionsPath . '/wikia/WikiaPoll/js/CreateWikiaPoll.js"></script>');
     $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('/extensions/wikia/WikiaPoll/css/CreateWikiaPoll.scss'));
     if ($subpage != '') {
         // We came here from the edit link, go into edit mode
         $wgOut->addHtml(F::app()->renderView('WikiaPoll', 'SpecialPageEdit', array('title' => $subpage)));
     } else {
         $wgOut->addHtml(F::app()->renderView('WikiaPoll', 'SpecialPage'));
     }
 }
Exemplo n.º 3
0
/**
 * Make sure the keys are defined.
 *
 * @throws Exception
 */
function efReCaptcha()
{
    $wg = F::app()->wg;
    if ($wg->ReCaptchaPublicKey == '' || $wg->ReCaptchaPrivateKey == '') {
        throw new Exception(wfMessage('recaptcha-misconfigured')->escaped());
    }
}
 private function buildMimeTypesBlacklist()
 {
     if (self::$mimeTypesBlacklist === null) {
         wfProfileIn(__METHOD__);
         $app = F::app();
         // blacklist types that thumbnailer cannot generate thumbs for (BAC-770)
         $mimeTypesBlacklist = ['svg+xml', 'svg'];
         if ($app->wg->UseMimeMagicLite) {
             // MimeMagicLite defines all the mMediaTypes in PHP that MimeMagic
             // defines in text files
             $mimeTypes = new MimeMagicLite();
         } else {
             $mimeTypes = new MimeMagic();
         }
         foreach (['AUDIO', 'VIDEO'] as $type) {
             foreach ($mimeTypes->mMediaTypes[$type] as $mime) {
                 // parse mime type - "image/svg" -> "svg"
                 list(, $mimeMinor) = explode('/', $mime);
                 $mimeTypesBlacklist[] = $mimeMinor;
             }
         }
         self::$mimeTypesBlacklist = array_unique($mimeTypesBlacklist);
         wfDebug(sprintf("%s: minor MIME types blacklist - %s\n", __CLASS__, join(', ', self::$mimeTypesBlacklist)));
         wfProfileOut(__METHOD__);
     }
 }
 public function execute($subpage)
 {
     global $wgOut, $wgUser, $wgExtensionsPath, $wgResourceBasePath;
     // Boilerplate special page permissions
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     if (!$wgUser->isAllowed('wikiaquiz')) {
         $this->displayRestrictionError();
         return;
     }
     if (wfReadOnly() && !wfAutomaticReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     $wgOut->addScript('<script src="' . $wgResourceBasePath . '/resources/wikia/libraries/jquery-ui/jquery-ui-1.8.14.custom.js"></script>');
     $wgOut->addScript('<script src="' . $wgExtensionsPath . '/wikia/WikiaQuiz/js/CreateWikiaQuizArticle.js"></script>');
     $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('/extensions/wikia/WikiaQuiz/css/WikiaQuizBuilder.scss'));
     if ($subpage != '') {
         // We came here from the edit link, go into edit mode
         $wgOut->addHtml(F::app()->renderView('WikiaQuiz', 'EditQuizArticle', array('title' => $subpage)));
     } else {
         $wgOut->addHtml(F::app()->renderView('WikiaQuiz', 'CreateQuizArticle'));
     }
 }
 /**
  * set appropriate status code for deleted pages
  *
  * @author ADi
  * @param Title $title
  * @param Article $article
  * @return bool
  */
 public function onArticleFromTitle(&$title, &$article)
 {
     if (!$title->exists() && $title->isDeleted()) {
         F::app()->wg->Out->setStatusCode(SEOTweaksHooksHelper::DELETED_PAGES_STATUS_CODE);
     }
     return true;
 }
 public function index()
 {
     $this->wg->Out->setPageTitle(wfMsg('wikifeatures-title'));
     if (!$this->wg->User->isAllowed('wikifeaturesview')) {
         // show this feature to logged in users only regardless of their rights
         $this->displayRestrictionError();
         return false;
         // skip rendering
     }
     $this->isOasis = F::app()->checkSkin('oasis');
     if (!$this->isOasis) {
         $this->forward('WikiFeaturesSpecial', 'notOasis');
         return;
     }
     $this->response->addAsset('extensions/wikia/WikiFeatures/css/WikiFeatures.scss');
     $this->response->addAsset('extensions/wikia/WikiFeatures/js/modernizr.transform.js');
     $this->response->addAsset('extensions/wikia/WikiFeatures/js/WikiFeatures.js');
     if ($this->getVal('simulateNewLabs', false)) {
         // debug code
         WikiFeaturesHelper::$release_date = array('wgEnableChat' => '2032-09-01');
     }
     $this->features = WikiFeaturesHelper::getInstance()->getFeatureNormal();
     $this->labsFeatures = WikiFeaturesHelper::getInstance()->getFeatureLabs();
     $this->editable = $this->wg->User->isAllowed('wikifeatures') ? true : false;
     // only those with rights can make edits
     if ($this->getVal('simulateEmptyLabs', false)) {
         // debug code
         $this->labsFeatures = array();
     }
 }
Exemplo n.º 8
0
 /**
  * @group UsingDB
  */
 public function testCache()
 {
     $user = $this->getTestUser();
     //create object here, so we use the same one all the time, that way we can test local cache
     $object = new UserService();
     $cachedLocalUser = $this->invokePrivateMethod('UserService', 'getUserFromLocalCacheById', $user->getId(), $object);
     $cachedLocalUserByName = $this->invokePrivateMethod('UserService', 'getUserFromLocalCacheByName', $user->getName(), $object);
     //values are not cached localy yet
     $this->assertEquals(false, $cachedLocalUser);
     $this->assertEquals(false, $cachedLocalUserByName);
     //cache user, both locally and mem cached
     $this->invokePrivateMethod('UserService', 'cacheUser', $user, $object);
     //do the assertion again, local cache should have hit one
     $cachedLocalUser = $this->invokePrivateMethod('UserService', 'getUserFromLocalCacheById', $user->getId(), $object);
     $cachedLocalUserByName = $this->invokePrivateMethod('UserService', 'getUserFromLocalCacheByName', $user->getName(), $object);
     $this->assertEquals($user, $cachedLocalUser);
     $this->assertEquals($user, $cachedLocalUserByName);
     //check if user was cached in memcache, use new object for that
     $cachedMemCacheById = $this->invokePrivateMethod('UserService', 'getUserFromMemCacheById', $user->getId());
     $cachedMemCacheByName = $this->invokePrivateMethod('UserService', 'getUserFromMemCacheByName', $user->getName());
     $this->assertEquals($user, $cachedMemCacheById);
     $this->assertEquals($user, $cachedMemCacheByName);
     //need for deleting form cache test values
     $sharedIdKey = wfSharedMemcKey("UserCache:" . $user->getId());
     $sharedNameKey = wfSharedMemcKey("UserCache:" . $user->getName());
     //remove user from memcache
     F::app()->wg->memc->delete($sharedIdKey);
     F::app()->wg->memc->delete($sharedNameKey);
     //do assert against memcache again
     $cachedMemCacheById = $this->invokePrivateMethod('UserService', 'getUserFromMemCacheById', $user->getId());
     $cachedMemCacheByName = $this->invokePrivateMethod('UserService', 'getUserFromMemCacheByName', $user->getName());
     $this->assertEquals(false, $cachedMemCacheById);
     $this->assertEquals(false, $cachedMemCacheByName);
 }
 public static function onOverwriteTOC(&$title, &$toc)
 {
     if (F::app()->checkSkin('venus')) {
         $toc = '';
     }
     return true;
 }
Exemplo n.º 10
0
 /**
  * Blocks view source page & make it so that users cannot create/edit
  * pages that are on the takedown list.
  *
  * @param EditPage $editPage edit page instance
  * @return bool show edit page form?
  */
 public static function onAlternateEdit(EditPage $editPage)
 {
     $wg = F::app()->wg;
     $wf = F::app()->wf;
     $title = $editPage->getTitle();
     // Block view-source on the certain pages.
     if ($title->exists()) {
         // Look at the page-props to see if this page is blocked.
         if (!$wg->user->isAllowed('editlyricfind')) {
             // some users (staff/admin) will be allowed to edit these to prevent vandalism/spam issues.
             $removedProp = $wf->GetWikiaPageProp(WPP_LYRICFIND_MARKED_FOR_REMOVAL, $title->getArticleID());
             if (!empty($removedProp)) {
                 $wg->Out->addHTML(Wikia::errorbox(wfMessage('lyricfind-editpage-blocked')));
                 $blockEdit = true;
             }
         }
     } else {
         // Page is being created. Prevent this if page is prohibited by LyricFind.
         $blockEdit = LyricFindTrackingService::isPageBlockedViaApi($amgId = "", $gracenoteId = "", $title->getText());
         if ($blockEdit) {
             $wg->Out->addHTML(Wikia::errorbox(wfMessage('lyricfind-creation-blocked')));
         }
     }
     return !$blockEdit;
 }
Exemplo n.º 11
0
 public function __construct()
 {
     $this->allowedRequests['store'] = array('json');
     $this->allowedRequests['index'] = array('json');
     $this->app = F::app();
     $this->UAD = new UAD();
 }
    public function getEmbed($width, array $options = [])
    {
        $autoplay = !empty($options['autoplay']);
        $height = $this->getHeight($width);
        $autoplayParam = self::$autoplayParam;
        $autoplayValue = $autoplay ? self::$autoplayValue : 'false';
        $url = $this->getEmbedUrl();
        $sizeString = $this->getSizeString($width, $height);
        if (F::app()->checkSkin('wikiamobile')) {
            $style = '';
        } else {
            $style = "style='background: #000000; display:block; overflow: hidden;'";
        }
        $html = <<<EOT
<object {$sizeString} type="application/x-shockwave-flash" data="{$url}/" {$style}>
\t<param name="movie" value="{$url}" />
\t<param name="allowfullscreen" value="true" />
\t<param name="bgcolor" value="#000000" />
\t<param name="wmode" value="transparent" />
\t<param name="allowscriptaccess" value="always" />
\t<param name="FlashVars" value="{$autoplayParam}={$autoplayValue}" />
\t<embed src="{$url}" type="application/x-shockwave-flash" allowfullscreen="true" movie="{$url}" wmode="transparent" allowscriptaccess="always" ></embed>
</object>
EOT;
        return array('html' => $html, 'width' => $width, 'height' => $height);
    }
Exemplo n.º 13
0
 /**
  * See functions below for expected URL params
  */
 public function execute()
 {
     $app = F::app();
     wfProfileIn(__METHOD__);
     $format = 'html';
     extract($this->extractRequestParams());
     if (!empty($controller)) {
         if (empty($method)) {
             $method = 'index';
         }
         if (!empty($parameters)) {
             $par = array();
             $params = explode('|', $parameters);
             foreach ($params as $param) {
                 $p = explode(':', $param);
                 $par[$p[0]] = $p[1];
             }
         } else {
             $params = null;
         }
         $resp = $app->sendRequest($controller, $method, $params);
         if ($format == 'html' || $format == 'json') {
             $resp = $resp->toString();
         }
         $this->getResult()->addValue($this->getModuleName(), $controller, $resp);
     } else {
         $this->getResult()->addValue($this->getModuleName(), 'Error', 'No Controller Specified');
     }
     wfProfileOut(__METHOD__);
 }
 public function setupSource($startDate, $endDate)
 {
     $this->serieName = wfMessage('special-pageviews-report-series')->escaped();
     $this->setDatabase(wfGetDB(DB_SLAVE, array(), F::app()->wg->DWStatsDB));
     $this->setStartDate($startDate->format('Y-m-d'));
     $this->setEndDate($endDate->format('Y-m-d'));
 }
Exemplo n.º 15
0
 public static function onGetRecentChangeQuery(&$conds, &$tables, &$join_conds, $opts)
 {
     $app = F::app();
     if ($app->wg->User->isAnon()) {
         return true;
     }
     if ($app->wg->Title->isSpecial('RecentChanges')) {
         return true;
     }
     if ($opts['invert'] !== false) {
         return true;
     }
     if (!isset($opts['namespace']) || empty($opts['namespace'])) {
         $rcfs = new RecentChangesFiltersStorage($app->wg->User);
         $selected = $rcfs->get();
         if (empty($selected)) {
             return true;
         }
         $db = wfGetDB(DB_SLAVE);
         $cond = 'rc_namespace IN (' . $db->makeList($selected) . ')';
         $flag = true;
         foreach ($conds as $key => &$value) {
             if (strpos($value, 'rc_namespace') !== false) {
                 $value = $cond;
                 $flag = false;
                 break;
             }
         }
         if ($flag) {
             $conds[] = $cond;
         }
     }
     return true;
 }
	/**
	 * Render blog listing
	 *
	 * Output HTML just for Oasis which will be hidden by default
	 */
	static function renderBlogListing(&$html, $posts, $aOptions, $sPager = null) {
		wfProfileIn(__METHOD__);

		// macbre: prevent PHP warnings and try to find the reason of them
		if (!is_array($posts)) {
			$url = wfGetCurrentUrl();
			Wikia::log(__METHOD__, false, "\$posts is not an array - {$url['url']}", true);

			wfProfileOut(__METHOD__);
			return true;
		}

		$additionalClass = '';
		if (!empty($aOptions['class'])) {
			$additionalClass = ' '.$aOptions['class'];
		}

		$seeMoreUrl = (isset($aOptions['seemore']) ? $aOptions['seemore'] : "");
		if ($aOptions['type'] == 'box') {
			$html .= F::app()->getView( 'BlogListing', 'Index', array('posts' => $posts, 'blogListingClass' => "WikiaBlogListingBox module $additionalClass", 'title' => $aOptions['title'], 'seeMoreUrl' => $seeMoreUrl))->render();
		} else {
			$html .= F::app()->getView( 'BlogListing', 'Index', array('posts' => $posts, 'blogListingClass' => "WikiaBlogListing$additionalClass", 'title' => $aOptions['title'], 'pager' => $sPager, 'seeMoreUrl' => $seeMoreUrl))->render();
		}

		wfProfileOut(__METHOD__);
		return true;
	}
Exemplo n.º 17
0
 public function __construct(WikiaApp $app = null)
 {
     if (is_null($app)) {
         $app = F::app();
     }
     $this->app = $app;
 }
Exemplo n.º 18
0
/**
 * Given a username, returns one of several codes to indicate whether it is valid to be a NEW username or not.
 *
 * Codes:
 * - OK: A user with this username may be created.
 * - INVALID: This is not a valid username.  This may mean that it is too long or has characters that aren't permitted, etc.
 * - EXISTS: A user with this name, so you cannot create one with this name.
 *
 * TODO: Is this a duplicate of user::isCreatableName()? It is important to note that wgWikiaMaxNameChars may be less than wgMaxNameChars which
 * is intentional because there are some long usernames that were created when only wgMaxNameChars limited to 255 characters and we still want
 * those usernames to be valid (so that they can still login), but we just don't want NEW accounts to be created above the length of wgWikiaMaxNameChars.
 *
 * @param string $uName The user name to check
 *
 * @return bool|string Return errors as an i18n key or true if the name is valid
 */
function wfValidateUserName($uName)
{
    if (!User::isNotMaxNameChars($uName)) {
        return 'userlogin-bad-username-length';
    }
    $userTitle = Title::newFromText($uName);
    if (is_null($userTitle)) {
        return 'userlogin-bad-username-character';
    }
    $uName = $userTitle->getText();
    if (!User::isCreatableName($uName)) {
        return 'userlogin-bad-username-character';
    }
    $dbr = wfGetDB(DB_SLAVE);
    $uName = $dbr->strencode($uName);
    if ($uName == '') {
        return 'userlogin-bad-username-character';
    }
    if (class_exists('SpoofUser')) {
        $spoof = new SpoofUser($uName);
        if ($spoof->isLegal()) {
            $conflicts = $spoof->getConflicts();
            if (!empty($conflicts)) {
                return 'userlogin-bad-username-taken';
            }
        }
    }
    if (in_array($uName, F::app()->wg->ReservedUsernames)) {
        // if we returned 'invalid', that would be confusing once a user
        // checked and found that the name already met the naming requirements.
        return 'userlogin-bad-username-taken';
    }
    // This username is valid
    return true;
}
Exemplo n.º 19
0
 public function addNewAccountMailPassword()
 {
     $u = $this->addNewAccountInternal();
     if ($u == null) {
         return false;
     }
     // reset password
     $tempUser = TempUser::getTempUserFromName($this->mUsername);
     $tempUser->setPassword('');
     $tempUser->updateData();
     $u = $tempUser->mapTempUserToUser(false, $u);
     // add log
     $userLoginHelper = F::build('UserLoginHelper');
     $userLoginHelper->addNewUserLogEntry($u, true);
     // mail temporary password
     $emailTextTemplate = F::app()->renderView("UserLogin", "GeneralMail", array('language' => $u->getOption('language'), 'type' => 'account-creation-email'));
     $result = $this->mailPasswordInternal($u, false, 'usersignup-account-creation-email-subject', 'usersignup-account-creation-email-body', $emailTextTemplate);
     if (!$result->isGood()) {
         $this->mainLoginForm(wfMessage('userlogin-error-mail-error', $result->getMessage())->parse());
         return false;
     } else {
         $this->mainLoginForm(wfMsgExt('usersignup-account-creation-email-sent', array('parseinline'), $this->mEmail, $this->username), 'success');
         return $u;
     }
 }
Exemplo n.º 20
0
 function execute()
 {
     F::app()->setSkinTemplateObj($this);
     $response = $this->app->sendRequest('Venus', 'index');
     $response->sendHeaders();
     $response->render();
 }
Exemplo n.º 21
0
 function __construct()
 {
     $this->app = F::app();
     $this->magicWords = array_keys($this->app->wg->LandingPagesAsContentMagicWords);
     //singleton
     F::setInstance(__CLASS__, $this);
 }
Exemplo n.º 22
0
 private function getSource($startDate, $endDate, $param)
 {
     $aAllOptions = array_merge($this->aAvailableLanguages, $this->aAvailableOtherOptions);
     $param = in_array($param, $aAllOptions) ? $param : '';
     $oSource = F::build('SpecialNewWikisGraphSourceDatabase', array('wikicreations' . $param));
     $oSource->serieName = wfMsg('newwikisgraph-wikis-created');
     $oSource->setDatabase(wfGetDB(DB_SLAVE, array(), F::app()->wg->externalSharedDB));
     $sql = "SELECT count(city_id) as number, DATE( city_created ) as creation_date\n                FROM city_list\n                WHERE city_created >= '%s'\n                AND city_created <= '%s'";
     if (!in_array($param, $aAllOptions)) {
         $param = 'all';
     }
     switch ($param) {
         case 'other':
             $sql .= " AND city_lang NOT IN ('" . implode("', '", $this->aAvailableLanguages) . "')";
             break;
         case 'all':
             break;
         default:
             $sql .= " AND city_lang = '" . $param . "'";
             break;
     }
     $sql .= " GROUP BY creation_date ORDER BY city_created";
     $oSource->setQuery($sql);
     $oSource->setStartDate($startDate->format('Y-m-d'));
     $oSource->setEndDate($endDate->format('Y-m-d'));
     return $oSource;
 }
Exemplo n.º 23
0
 public static function onGalleryBeforeProduceHTML($data, &$out)
 {
     global $wgArticleAsJson;
     wfProfileIn(__METHOD__);
     if ($wgArticleAsJson) {
         $parser = ParserPool::get();
         $parserOptions = new ParserOptions();
         $title = F::app()->wg->Title;
         $media = [];
         foreach ($data['images'] as $image) {
             $details = WikiaFileHelper::getMediaDetail(Title::newFromText($image['name'], NS_FILE), self::$mediaDetailConfig);
             $details['context'] = self::MEDIA_CONTEXT_GALLERY_IMAGE;
             $caption = $image['caption'];
             if (!empty($caption)) {
                 $caption = $parser->parse($caption, $title, $parserOptions, false)->getText();
             }
             $linkHref = isset($image['linkhref']) ? $image['linkhref'] : null;
             $media[] = self::createMediaObject($details, $image['name'], $caption, $linkHref);
             self::addUserObj($details);
         }
         self::$media[] = $media;
         if (!empty($media)) {
             $out = self::createMarker($media[0]['width'], $media[0]['height'], true);
         } else {
             $out = '';
         }
         ParserPool::release($parser);
         wfProfileOut(__METHOD__);
         return false;
     }
     wfProfileOut(__METHOD__);
     return true;
 }
Exemplo n.º 24
0
 /**
  * Return PlaceStorage model for article with given ID
  *
  * @param int $pageId article ID
  * @return PlaceStorage model object
  */
 public static function newFromId($pageId)
 {
     $instance = F::build('PlaceStorage', array('app' => F::app(), 'pageId' => $pageId));
     // read data from database
     $instance->read();
     return $instance;
 }
Exemplo n.º 25
0
 protected function getInterfaceObjectFromType($type)
 {
     wfProfileIn(__METHOD__);
     $apiUrl = $this->getApiUrl();
     if (empty($this->videoId)) {
         throw new EmptyResponseException($apiUrl);
     }
     $memcKey = F::app()->wf->memcKey(static::$CACHE_KEY, $apiUrl, static::$CACHE_KEY_VERSION);
     $processedResponse = F::app()->wg->memc->get($memcKey);
     if (empty($processedResponse)) {
         $req = MWHttpRequest::factory($apiUrl);
         $req->setHeader('User-Agent', self::$REQUEST_USER_AGENT);
         $status = $req->execute();
         if ($status->isOK()) {
             $response = $req->getContent();
             $this->response = $response;
             // Only for migration purposes
             if (empty($response)) {
                 throw new EmptyResponseException($apiUrl);
             } else {
                 if ($req->getStatus() == 301) {
                     throw new VideoNotFoundException($req->getStatus(), $this->videoId . ' Moved Permanently.', $apiUrl);
                 }
             }
         } else {
             $this->checkForResponseErrors($req->status, $req->getContent(), $apiUrl);
         }
         $processedResponse = $this->processResponse($response, $type);
         F::app()->wg->memc->set($memcKey, $processedResponse, static::$CACHE_EXPIRY);
     }
     wfProfileOut(__METHOD__);
     return $processedResponse;
 }
 /**
  * Whether CategorySelect should be used for the current request.
  * @return Boolean
  */
 public static function isEnabled()
 {
     wfProfileIn(__METHOD__);
     if (!isset(self::$isEnabled)) {
         $app = F::app();
         $request = $app->wg->Request;
         $title = $app->wg->Title;
         $user = $app->wg->User;
         $action = $request->getVal('action', 'view');
         $undo = $request->getVal('undo');
         $undoafter = $request->getVal('undoafter');
         $viewModeActions = array('view', 'purge');
         $editModeActions = array('edit', 'submit');
         $supportedActions = array_merge($viewModeActions, $editModeActions);
         $supportedSkins = array('SkinAnswers', 'SkinOasis', 'SkinVenus');
         $isViewMode = in_array($action, $viewModeActions);
         $isEditMode = in_array($action, $editModeActions);
         $extraNamespacesOnView = array(NS_FILE, NS_CATEGORY);
         $extraNamespacesOnEdit = array(NS_FILE, NS_CATEGORY, NS_USER, NS_SPECIAL);
         $isEnabled = true;
         if ($request->getVal('usecatsel', '') == 'no' || $user->getGlobalPreference('disablecategoryselect') || !in_array(get_class(RequestContext::getMain()->getSkin()), $supportedSkins) || !in_array($action, $supportedActions) || $title->isCssJsSubpage() || $action == 'view' && !$title->exists() || $action == 'purge' && $user->isAnon() && !$request->wasPosted() || $undo > 0 && $undoafter > 0 || $title->mNamespace == NS_TEMPLATE || $isViewMode && !in_array($title->mNamespace, array_merge($app->wg->ContentNamespaces, $extraNamespacesOnView)) || $isEditMode && !in_array($title->mNamespace, array_merge($app->wg->ContentNamespaces, $extraNamespacesOnEdit))) {
             $isEnabled = false;
         }
         self::$isEnabled = $isEnabled;
     }
     wfProfileOut(__METHOD__);
     return self::$isEnabled;
 }
 public function delete($targetWikiId, $wikiList)
 {
     $app = \F::app();
     foreach ($wikiList as $sourceWikiId => $images) {
         $sourceWikiLang = \WikiFactory::getVarValueByName('wgLanguageCode', $sourceWikiId);
         if (!empty($images)) {
             $removedImages = array();
             foreach ($images as $imageName) {
                 if (\PromoImage::fromPathname($imageName)->isValid()) {
                     $result = $this->removeSingleImage($targetWikiId, $imageName);
                     if ($result['status'] === 0) {
                         $removedImages[] = $imageName;
                     }
                 }
             }
         }
         if (!empty($removedImages)) {
             $memcKey = $this->helper->getMemcKey($sourceWikiId, $sourceWikiLang);
             $updateData = $this->syncAdditionalImages($sourceWikiId, $sourceWikiLang, $removedImages);
             // update in db
             if (!empty($updateData)) {
                 // updating city_visualization table
                 $this->model->saveVisualizationData($sourceWikiId, $updateData, $sourceWikiLang);
                 // purging interstitial cache
                 $app->wg->Memc->set($memcKey, null);
             }
         }
     }
     // since an admin can't delete main image we don't purge visualization list cache
     // as it happens during uploads
     return true;
 }
Exemplo n.º 28
0
 protected function buildData()
 {
     $this->available = F::app()->wg->user->isAllowed('performancestats');
     $this->enabled = F::app()->wg->user->isAllowed('performancestats');
     $this->caption = wfMsg('oasis-toolbar-devinfo');
     $this->linkClass = 'tools-devinfo';
 }
Exemplo n.º 29
0
 /**
  * Check if:
  * controller - is first parameter
  * method - is second parameter
  * rest of parameters - are sorted
  *
  * @author Jakub Olek <*****@*****.**>
  *
  * @throws WikiaException
  */
 public final function init()
 {
     $webRequest = F::app()->wg->Request;
     $accessService = new ApiAccessService($this->getRequest());
     $controller = $webRequest->getVal('controller');
     $method = $webRequest->getVal('method');
     $accessService->checkUse($controller . 'Controller', $method);
     //this is used for monitoring purposes, do not change unless you know what you are doing
     //should set api/v1 as the transaction name
     if (!$this->request->isInternal()) {
         Transaction::setEntryPoint(Transaction::ENTRY_POINT_API_V1);
     }
     if (!$this->request->isInternal()) {
         if ($this->hideNonCommercialContent()) {
             $this->blockIfNonCommercialOnly();
         }
         $paramKeys = array_keys($webRequest->getQueryValues());
         $count = count($paramKeys);
         if ($count >= 2 && $paramKeys[0] === 'controller' && $paramKeys[1] === 'method') {
             if ($count > 2) {
                 $origParam = $paramKeys = array_flip(array_slice($paramKeys, 2));
                 ksort($paramKeys);
                 ksort($origParam);
                 if ($paramKeys !== $origParam) {
                     throw new BadRequestApiException('The parameters\' order is incorrect');
                 }
             }
         } else {
             throw new BadRequestApiException('Controller and/or method missing');
         }
     }
 }
Exemplo n.º 30
0
 public function __construct($name)
 {
     $this->sName = $name;
     $this->iNumberOfXGuideLines = 7;
     $this->App = F::app();
     $this->frequency = SponsorshipDashboardDateProvider::getProvider();
 }