コード例 #1
0
ファイル: SpecialImport.php プロジェクト: GodelDesign/Godel
 /**
  * Execute
  */
 function execute($par)
 {
     global $wgRequest, $wgUser, $wgOut;
     $this->setHeaders();
     $this->outputHeader();
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if (!$wgUser->isAllowed('import') && !$wgUser->isAllowed('importupload')) {
         return $wgOut->permissionRequired('import');
     }
     # TODO: allow Title::getUserPermissionsErrors() to take an array
     # FIXME: Title::checkSpecialsAndNSPermissions() has a very wierd expectation of what
     # getUserPermissionsErrors() might actually be used for, hence the 'ns-specialprotected'
     $errors = wfMergeErrorArrays($this->getTitle()->getUserPermissionsErrors('import', $wgUser, true, array('ns-specialprotected', 'badaccess-group0', 'badaccess-groups')), $this->getTitle()->getUserPermissionsErrors('importupload', $wgUser, true, array('ns-specialprotected', 'badaccess-group0', 'badaccess-groups')));
     if ($errors) {
         $wgOut->showPermissionsErrorPage($errors);
         return;
     }
     if ($wgRequest->wasPosted() && $wgRequest->getVal('action') == 'submit') {
         $this->doImport();
     }
     $this->showForm();
 }
コード例 #2
0
 function execute($par)
 {
     global $wgOut, $wgUser, $wgRequest;
     $this->setHeaders();
     $this->outputHeader();
     $wgOut->disallowUserJs();
     # Prevent hijacked user scripts from sniffing passwords etc.
     if ($wgUser->isAnon()) {
         $wgOut->showErrorPage('prefsnologin', 'prefsnologintext', array($this->getTitle()->getPrefixedDBkey()));
         return;
     }
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if ($par == 'reset') {
         $this->showResetForm();
         return;
     }
     $wgOut->addModules('mediawiki.legacy.prefs');
     $wgOut->addModules('mediawiki.special.preferences');
     if ($wgRequest->getCheck('success')) {
         $wgOut->wrapWikiMsg("<div class=\"successbox\"><strong>\n\$1\n</strong></div><div id=\"mw-pref-clear\"></div>", 'savedprefs');
     }
     if ($wgRequest->getCheck('eauth')) {
         $wgOut->wrapWikiMsg("<div class='error' style='clear: both;'>\n\$1\n</div>", 'eauthentsent', $wgUser->getName());
     }
     $htmlForm = Preferences::getFormObject($wgUser);
     $htmlForm->setSubmitCallback(array('Preferences', 'tryUISubmit'));
     $htmlForm->show();
 }
コード例 #3
0
ファイル: ProtectionForm.php プロジェクト: k-hasan-19/wiki
 function ProtectionForm(&$article)
 {
     global $wgRequest, $wgUser;
     global $wgRestrictionTypes, $wgRestrictionLevels;
     $this->mArticle =& $article;
     $this->mTitle =& $article->mTitle;
     if ($this->mTitle) {
         foreach ($wgRestrictionTypes as $action) {
             // Fixme: this form currently requires individual selections,
             // but the db allows multiples separated by commas.
             $this->mRestrictions[$action] = implode('', $this->mTitle->getRestrictions($action));
         }
     }
     // The form will be available in read-only to show levels.
     $this->disabled = !$wgUser->isAllowed('protect') || wfReadOnly() || $wgUser->isBlocked();
     $this->disabledAttrib = $this->disabled ? array('disabled' => 'disabled') : array();
     if ($wgRequest->wasPosted()) {
         $this->mReason = $wgRequest->getText('mwProtect-reason');
         foreach ($wgRestrictionTypes as $action) {
             $val = $wgRequest->getVal("mwProtect-level-{$action}");
             if (isset($val) && in_array($val, $wgRestrictionLevels)) {
                 $this->mRestrictions[$action] = $val;
             }
         }
     }
 }
コード例 #4
0
ファイル: msupload_body.php プロジェクト: Ratin/WikiExtension
function wfMsUploadRender()
{
    #global $wgOut,$wgUser,$wgUserName,$wgScriptPath;
    global $output, $wgUser;
    global $wgMSU_ShowAutoKat, $wgMSU_AutoIndex, $wgMSU_CheckedAutoKat;
    if (!$wgUser->isAllowed('upload')) {
        if (!$wgUser->isLoggedIn()) {
            $output .= "<a id='ImageUploadLoginMsg'>einloggen</a>";
            return 0;
        } else {
            $output .= "keine Berechtigung";
            return 1;
        }
    } else {
        if (wfReadOnly()) {
            $output .= "Nur lesen";
            return 2;
        } else {
            $output .= "<form action='' method='post' id='upload-form'>";
            $output .= "<ul id='upload_list'></ul>";
            $output .= "<hr noshade>";
            $output .= "</form><a href='#' id='upload_all'></a>";
        }
    }
    #return $output."|".$wgUser->getName();
    return $output . "|" . $wgUser->getName() . "|" . $wgMSU_ShowAutoKat . "|" . $wgMSU_AutoIndex . "|" . $wgMSU_CheckedAutoKat;
}
コード例 #5
0
/**
 * Constructor
 */
function wfSpecialMovepage($par = null)
{
    global $wgUser, $wgOut, $wgRequest, $action;
    # Check rights
    if (!$wgUser->isAllowed('move')) {
        $wgOut->showPermissionsErrorPage(array($wgUser->isAnon() ? 'movenologintext' : 'movenotallowed'));
        return;
    }
    # Don't allow blocked users to move pages
    if ($wgUser->isBlocked()) {
        $wgOut->blockedPage();
        return;
    }
    # Check for database lock
    if (wfReadOnly()) {
        $wgOut->readOnlyPage();
        return;
    }
    $f = new MovePageForm($par);
    if ('success' == $action) {
        $f->showSuccess();
    } else {
        if ('submit' == $action && $wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
            $f->doSubmit();
        } else {
            $f->showForm('');
        }
    }
}
コード例 #6
0
	/**
	 * Show the special page
	 *
	 * @param $par Mixed: parameter passed to the page or null
	 */
	public function execute( $par ) {
		global $wgRequest, $wgOut, $wgUser;

		// If the user doesn't have the required 'awardsmanage' permission, display an error
		if ( !$wgUser->isAllowed( 'awardsmanage' ) ) {
			$wgOut->permissionRequired( 'awardsmanage' );
			return;
		}

		// Show a message if the database is in read-only mode
		if ( wfReadOnly() ) {
			$wgOut->readOnlyPage();
			return;
		}

		// If user is blocked, s/he doesn't need to access this page
		if ( $wgUser->isBlocked() ) {
			$wgOut->blockedPage();
			return;
		}

		$this->gift_id = $wgRequest->getInt( 'gift_id' );
		$this->initLogo( $wgRequest );
		$this->executeLogo();
	}
コード例 #7
0
 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'));
     }
 }
コード例 #8
0
 public function execute()
 {
     global $wgOut, $wgUser, $wgRequest, $wgTitle;
     wfRunHooks('beforeBlogListingForm', array(&$this, $wgRequest->getVal('article')));
     if (!$wgUser->isLoggedIn()) {
         $wgOut->showErrorPage('create-blog-no-login', 'create-blog-login-required', array(wfGetReturntoParam()));
         return;
     }
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     $this->mTitle = Title::makeTitle(NS_SPECIAL, 'CreateBlogListingPage');
     $wgOut->setPageTitle(wfMsg('create-blog-listing-title'));
     if ($wgRequest->wasPosted()) {
         $this->parseFormData();
         if (count($this->mFormErrors) > 0 || !empty($this->mRenderedPreview)) {
             $this->renderForm();
         } else {
             $this->save();
         }
     } else {
         if ($wgRequest->getVal('article') != null) {
             $this->parseTag(urldecode($wgRequest->getVal('article')));
         }
         $this->renderForm();
     }
 }
コード例 #9
0
ファイル: SpecialMovepage.php プロジェクト: rocLv/conference
/**
 * Constructor
 */
function wfSpecialMovepage($par = null)
{
    global $wgUser, $wgOut, $wgRequest, $action;
    # Check for database lock
    if (wfReadOnly()) {
        $wgOut->readOnlyPage();
        return;
    }
    $target = isset($par) ? $par : $wgRequest->getVal('target');
    // Yes, the use of getVal() and getText() is wanted, see bug 20365
    $oldTitleText = $wgRequest->getVal('wpOldTitle', $target);
    $newTitleText = $wgRequest->getText('wpNewTitle');
    $oldTitle = Title::newFromText($oldTitleText);
    $newTitle = Title::newFromText($newTitleText);
    if (is_null($oldTitle)) {
        $wgOut->showErrorPage('notargettitle', 'notargettext');
        return;
    }
    if (!$oldTitle->exists()) {
        $wgOut->showErrorPage('nopagetitle', 'nopagetext');
        return;
    }
    # Check rights
    $permErrors = $oldTitle->getUserPermissionsErrors('move', $wgUser);
    if (!empty($permErrors)) {
        $wgOut->showPermissionsErrorPage($permErrors);
        return;
    }
    $form = new MovePageForm($oldTitle, $newTitle);
    if ('submit' == $action && $wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
        $form->doSubmit();
    } else {
        $form->showForm('');
    }
}
コード例 #10
0
ファイル: SpecialBlockip.php プロジェクト: GodelDesign/Godel
 public function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest;
     # Can't block when the database is locked
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     # Permission check
     if (!$this->userCanExecute($wgUser)) {
         $wgOut->permissionRequired('block');
         return;
     }
     $this->setup($par);
     # bug 15810: blocked admins should have limited access here
     if ($wgUser->isBlocked()) {
         $status = IPBlockForm::checkUnblockSelf($this->BlockAddress);
         if ($status !== true) {
             throw new ErrorPageError('badaccess', $status);
         }
     }
     $action = $wgRequest->getVal('action');
     if ('success' == $action) {
         $this->showSuccess();
     } elseif ($wgRequest->wasPosted() && 'submit' == $action && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
         $this->doSubmit();
     } else {
         $this->showForm('');
     }
 }
コード例 #11
0
ファイル: AddToList.php プロジェクト: Tjorriemorrie/app
function efAddToListEdit($action, $article)
{
    global $wgOut, $wgRequest, $wgTitle;
    if ($action !== 'addtolist') {
        return true;
    }
    if ($article->mTitle->getText() != $wgTitle->getText()) {
        return true;
    }
    // @todo should return some error
    if (wfReadOnly()) {
        return true;
    }
    $content = $article->getContent();
    $item = trim($wgRequest->getText('item')) . $wgRequest->getText('postfix');
    if (empty($item)) {
        return true;
    }
    $parts = explode('* <addmore', $content);
    $first = array_shift($parts);
    array_unshift($parts, "* {$item}\n* <addmore");
    array_unshift($parts, $first);
    $newContent = implode('', $parts);
    $article->doEdit($newContent, 'added list item');
    $wgOut->redirect($article->mTitle->getFullUrl());
    return false;
}
コード例 #12
0
 /**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     $out = $this->getOutput();
     $request = $this->getRequest();
     $user = $this->getUser();
     // Set the robot policies, etc.
     $out->setArticleRelated(false);
     $out->setRobotPolicy('noindex,nofollow');
     // If the user doesn't have the required 'awardsmanage' permission, display an error
     if (!$user->isAllowed('awardsmanage')) {
         $out->permissionRequired('awardsmanage');
         return;
     }
     // Show a message if the database is in read-only mode
     if (wfReadOnly()) {
         $out->readOnlyPage();
         return;
     }
     // If user is blocked, s/he doesn't need to access this page
     if ($user->isBlocked()) {
         $out->blockedPage();
         return;
     }
     $this->gift_id = $this->getRequest()->getInt('gift_id');
     $this->initLogo();
     $this->executeLogo();
 }
コード例 #13
0
ファイル: FavoritesHooks.php プロジェクト: yusufchang/app
 public static function onUnknownAction($action, $article)
 {
     global $wgUser, $wgOut;
     if ($action !== 'unfavorite' && $action !== 'favorite') {
         return true;
     }
     if ($wgUser->isAnon()) {
         $wgOut->showErrorPage('favoritenologin', 'favoritenologintext');
         return;
     }
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     $wgOut->setRobotPolicy('noindex,nofollow');
     if ($action === 'favorite') {
         if (self::doFavorite($article)) {
             $wgOut->setPagetitle(wfMsg('addedfavorite'));
             $wgOut->addWikiMsg('addedfavoritetext', $article->getTitle()->getPrefixedText());
         }
     } else {
         if (self::doUnfavorite($article)) {
             $wgOut->setPagetitle(wfMsg('removedfavorite'));
             $wgOut->addWikiMsg('removedfavoritetext', $article->getTitle()->getPrefixedText());
         }
     }
     $wgOut->returnToMain(true, $article->getTitle()->getPrefixedText());
     return false;
 }
コード例 #14
0
 function execute()
 {
     wfProfileIn(__METHOD__);
     global $wgOut, $wgRequest;
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         wfProfileOut(__METHOD__);
         return;
     }
     $articleID = $wgRequest->getInt('articleid');
     $title = Title::newFromID($articleID);
     if (!is_null($title) && $title->exists()) {
         if (strpos($_SERVER['HTTP_USER_AGENT'], 'facebook') === false && strpos($_SERVER['HTTP_USER_AGENT'], 'bitlybot') === false) {
             $sharerID = $wgRequest->getInt('userid');
             $viewerIP = $wgRequest->getIP();
             $awardingService = new AchAwardingService();
             $awardingService->processSharing($articleID, $sharerID, $viewerIP);
         }
     } else {
         $title = Title::newMainPage();
     }
     // this works only for Wikia and only in current varnish configuration
     if (!headers_sent()) {
         header('X-Pass-Cache-Control: no-store, private, no-cache, must-revalidate');
     }
     $wgOut->redirect($title->getLocalURL());
     wfProfileOut(__METHOD__);
 }
コード例 #15
0
 function execute($subpage)
 {
     global $wgUser, $wgOut, $wgRequest;
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if (!$wgUser->isAllowed('makesysop')) {
         $this->displayRestrictionError();
         return;
     }
     $this->setHeaders();
     if ($wgUser->isAllowed('userrights')) {
         $f = new MakesysopStewardForm($wgRequest);
         $f->execute();
     } else {
         $f = new MakesysopForm($wgRequest);
         if ($f->mSubmit) {
             $f->doSubmit();
         } else {
             $f->showForm('');
         }
     }
 }
コード例 #16
0
/**
 * Send the message if the UserBoard class exists (duh!) and the welcome
 * message has some content.
 *
 * @param $user User: the new User object being created
 * @param $byEmail Boolean: true if the account was created by e-mail
 * @return Boolean: true
 */
function wfSendUserBoardMessageOnRegistration($user, $byEmail)
{
    if (class_exists('UserBoard') && $user instanceof User) {
        $message = trim(wfMsgForContent('user-board-welcome-message'));
        // If the welcome message is empty, short-circuit right away.
        if (wfEmptyMsg('user-board-welcome-message', $message)) {
            return true;
        }
        // Just quit if we're in read-only mode
        if (wfReadOnly()) {
            return true;
        }
        $dbr = wfGetDB(DB_SLAVE);
        // Get all users who are in the 'sysop' group and aren't blocked from
        // the database
        $res = $dbr->select(array('user_groups', 'ipblocks'), array('ug_group', 'ug_user'), array('ug_group' => 'sysop', 'ipb_user' => null), __METHOD__, array(), array('ipblocks' => array('LEFT JOIN', 'ipb_user = ug_user')));
        $adminUids = array();
        foreach ($res as $row) {
            $adminUids[] = $row->ug_user;
        }
        // Pick one UID from the array of admin user IDs
        $random = array_rand(array_flip($adminUids), 1);
        $sender = User::newFromId($random);
        $senderUid = $sender->getId();
        $senderName = $sender->getName();
        // Send the message
        $b = new UserBoard();
        $b->sendBoardMessage($senderUid, $senderName, $user->getId(), $user->getName(), wfMsgForContent('user-board-welcome-message', $senderName));
    }
    return true;
}
コード例 #17
0
 /**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgOut, $wgUser;
     $wgOut->setPageTitle('Update Edit Counts');
     // Check permissions -- we must be allowed to access this special page
     // before we can run any database queries
     if (!$wgUser->isAllowed('updatepoints')) {
         throw new ErrorPageError('error', 'badaccess');
     }
     // And obviously the database needs to be writable before we start
     // running INSERT/UPDATE queries against it...
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     $dbw = wfGetDB(DB_MASTER);
     $this->updateMainEditsCount();
     global $wgUserLevels;
     $wgUserLevels = '';
     $res = $dbw->select('user_stats', array('stats_user_id', 'stats_user_name', 'stats_total_points'), array(), __METHOD__, array('ORDER BY' => 'stats_user_name'));
     $out = '';
     $x = 0;
     foreach ($res as $row) {
         $x++;
         $stats = new UserStatsTrack($row->stats_user_id, $row->stats_user_name);
         $stats->updateTotalPoints();
     }
     $out = "Updated stats for <b>{$x}</b> users";
     $wgOut->addHTML($out);
 }
コード例 #18
0
ファイル: SpecialBlockip.php プロジェクト: ErdemA/wikihow
/**
 * Constructor
 */
function wfSpecialBlockip($par)
{
    global $wgUser, $wgOut, $wgRequest;
    # Can't block when the database is locked
    if (wfReadOnly()) {
        $wgOut->readOnlyPage();
        return;
    }
    # Permission check
    if (!$wgUser->isAllowed('block')) {
        $wgOut->permissionRequired('block');
        return;
    }
    $ipb = new IPBlockForm($par);
    $action = $wgRequest->getVal('action');
    if ('success' == $action) {
        $ipb->showSuccess();
    } else {
        if ($wgRequest->wasPosted() && 'submit' == $action && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
            $ipb->doSubmit();
        } else {
            $ipb->showForm('');
        }
    }
}
コード例 #19
0
 public function execute($subpage)
 {
     global $wgUser, $wgOut, $wgRequest;
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if (!$wgUser->isAllowed('tagsreport')) {
         $this->displayRestrictionError();
         return;
     }
     /**
      * initial output
      */
     $this->mTitle = Title::makeTitle(NS_SPECIAL, 'TagsReport');
     $wgOut->setPageTitle(wfMsg('tagsreporttitle'));
     $wgOut->setRobotpolicy('noindex,nofollow');
     $wgOut->setArticleRelated(false);
     $this->mTag = $wgRequest->getVal('target');
     /**
      * show form
      */
     $this->showForm();
     $this->showArticleList();
 }
コード例 #20
0
 /**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser;
     # If user is blocked, s/he doesn't need to access this page
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     # Show a message if the database is in read-only mode
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     # If the user doesn't have the required 'maintenance' permission, display an error
     if (!$wgUser->isAllowed('maintenance')) {
         $wgOut->permissionRequired('maintenance');
         return;
     }
     $this->type = $par ? $par : '';
     if ($this->type === '') {
         $this->makeInitialForm();
     } elseif ($this->type !== '' && !$wgRequest->wasPosted()) {
         $this->makeForm($this->type);
     } elseif ($this->type !== '' && $wgRequest->wasPosted()) {
         $this->executeScript($this->type);
     }
 }
コード例 #21
0
ファイル: importDump.php プロジェクト: xfstudio/mediawiki
 public function execute()
 {
     if (wfReadOnly()) {
         $this->error("Wiki is in read-only mode; you'll need to disable it for import to work.", true);
     }
     $this->reportingInterval = intval($this->getOption('report', 100));
     if (!$this->reportingInterval) {
         $this->reportingInterval = 100;
         // avoid division by zero
     }
     $this->dryRun = $this->hasOption('dry-run');
     $this->uploads = $this->hasOption('uploads');
     // experimental!
     if ($this->hasOption('image-base-path')) {
         $this->imageBasePath = $this->getOption('image-base-path');
     }
     if ($this->hasOption('namespaces')) {
         $this->setNsfilter(explode('|', $this->getOption('namespaces')));
     }
     if ($this->hasArg()) {
         $this->importFromFile($this->getArg());
     } else {
         $this->importFromStdin();
     }
     $this->output("Done!\n");
     $this->output("You might want to run rebuildrecentchanges.php to regenerate RecentChanges\n");
 }
コード例 #22
0
 /**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest;
     // Check permissions
     if (!Link::canAdmin()) {
         $this->displayRestrictionError();
         return;
     }
     // Is the database locked or not?
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return false;
     }
     // No access for blocked users
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage(false);
         return false;
     }
     // Add CSS & JS
     $wgOut->addModules('ext.linkFilter');
     if ($wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false) {
         $_SESSION['alreadysubmitted'] = true;
         // Update link
         $dbw = wfGetDB(DB_MASTER);
         $dbw->update('link', array('link_url' => $_POST['lf_URL'], 'link_description' => $_POST['lf_desc'], 'link_type' => intval($_POST['lf_type'])), array('link_page_id' => $wgRequest->getInt('id')), __METHOD__);
         $title = Title::newFromId($wgRequest->getInt('id'));
         $wgOut->redirect($title->getFullURL());
     } else {
         $wgOut->addHTML($this->displayEditForm());
     }
 }
コード例 #23
0
 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'));
     }
 }
コード例 #24
0
 function execute($par)
 {
     wfProfileIn(__METHOD__);
     global $wgOut, $wgExtensionsPath, $wgResourceBasePath, $wgJsMimeType, $wgUser;
     // set basic headers
     $this->setHeaders();
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         wfProfileOut(__METHOD__);
         return;
     }
     if (!$this->userCanExecute($wgUser)) {
         $this->displayRestrictionError();
         wfProfileOut(__METHOD__);
         return;
     }
     // include resources (css and js)
     $wgOut->addExtensionStyle("{$wgExtensionsPath}/wikia/AchievementsII/css/platinum.css\n");
     $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/AchievementsII/css/oasis.scss'));
     $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$wgExtensionsPath}/wikia/AchievementsII/js/platinum.js\"></script>\n");
     $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$wgResourceBasePath}/resources/wikia/libraries/aim/jquery.aim.js\"></script>\n");
     // call service to get needed data
     $badges = AchPlatinumService::getList();
     // pass data to template
     $template = new EasyTemplate(dirname(__FILE__) . '/templates');
     $template->set_vars(array('badges' => $badges));
     // render template
     $wgOut->addHTML($template->render('SpecialPlatinum'));
     wfProfileOut(__METHOD__);
 }
コード例 #25
0
 public function index()
 {
     if ($this->wg->user->isBlocked()) {
         $this->wg->out->blockedPage();
         return false;
         // skip rendering
     }
     if (!$this->wg->user->isAllowed('specialvideohandler')) {
         $this->displayRestrictionError();
         return false;
     }
     if (wfReadOnly() && !wfAutomaticReadOnly()) {
         $this->wg->out->readOnlyPage();
         return false;
     }
     $videoId = $this->getVal('videoid', null);
     $provider = strtolower($this->getVal('provider', null));
     $undercover = $this->getVal('undercover', false);
     $videoTitle = $this->getVal('videotitle', null);
     if ($videoId && $provider) {
         $overrideMetadata = array();
         if (!empty($videoTitle)) {
             $overrideMetadata['title'] = $videoTitle;
         }
         try {
             $result = VideoFileUploader::uploadVideo($provider, $videoId, $title, null, $undercover, $overrideMetadata);
         } catch (Exception $e) {
             $result = (object) array('ok' => null, 'value' => null);
         }
         $this->setVal('uploadStatus', $result->ok);
         $this->setVal('isNewFile', empty($result->value));
         $this->setVal('title', !empty($title) ? $title->getText() : '');
         $this->setVal('url', !empty($title) ? $title->getFullURL() : '');
     }
 }
コード例 #26
0
 public function execute($par)
 {
     global $wgUser, $wgCommandLineMode, $wgLang, $wgOut, $wrAdminUserName;
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if ($wgUser->isLoggedIn()) {
         if ($wgUser->getName() == $wrAdminUserName) {
             $user = User::newFromName($par);
         } else {
             $user = $wgUser;
         }
         $msg = '';
         if ($user->getID() > 0) {
             $user->setOption('enotifwatchlistpages', 0);
             $user->setOption('enotifusertalkpages', 0);
             $user->setOption('enotifminoredits', 0);
             $user->setOption('disablemail', 1);
             $user->saveSettings();
         } else {
             $msg = $user->getName() . ' not found';
         }
         $this->show($msg);
     } else {
         if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) {
             User::SetupSession();
         }
         $request = new FauxRequest(array('returnto' => $wgLang->specialPage('Unsubscribe')));
         require_once 'includes/SpecialUserlogin.php';
         $form = new LoginForm($request);
         $form->mainLoginForm("You need to log in to unsubscribe<br/><br/>", '');
     }
 }
コード例 #27
0
	/**
	 * Show the special page
	 *
	 * @param $gift_category Mixed: parameter passed to the page or null
	 */
	public function execute( $gift_category ) {
		global $wgUser, $wgOut, $wgUserLevels;

		// If the user doesn't have the required 'awardsmanage' permission, display an error
		if ( !$wgUser->isAllowed( 'awardsmanage' ) ) {
			$wgOut->permissionRequired( 'awardsmanage' );
			return;
		}

		// Show a message if the database is in read-only mode
		if ( wfReadOnly() ) {
			$wgOut->readOnlyPage();
			return;
		}

		// If user is blocked, s/he doesn't need to access this page
		if ( $wgUser->isBlocked() ) {
			$wgOut->blockedPage();
			return;
		}

		$wgUserLevels = '';

		$g = new SystemGifts();
		$g->update_system_gifts();
	}
コード例 #28
0
 /**
  * get task from queue and execute
  *
  * main entry point, task executor run this method
  *
  * @access public
  * @author eloy
  *
  * @return void
  */
 public function execute()
 {
     if (wfReadOnly()) {
         $this->log("Database is in read-only mode");
     } else {
         $this->log("Task Manager started");
         for ($taskNumber = 1; $taskNumber <= self::LIMIT; $taskNumber++) {
             $taskClass = $this->getTask();
             if ($taskClass instanceof BatchTask) {
                 /**
                  * lock task
                  */
                 $taskId = $this->mTaskData->task_id;
                 $this->lockTask($taskId);
                 $taskClass->setId($taskId);
                 /**
                  * execute task
                  */
                 $taskClass->addlog(sprintf("task started: %s", wfTimestamp(TS_DB, time())));
                 $status = $taskClass->execute($this->mTaskData);
                 $taskClass->addlog(sprintf("task finished: %s", wfTimestamp(TS_DB, time())));
                 /**
                  * unlock task
                  */
                 $this->unlockTask($taskId, $status);
                 $this->log(sprintf("batch(%d) finished task id=%d; type=%s", $taskNumber, $taskId, $taskClass->getType()));
             } else {
                 $this->log(sprintf("batch(%d) queue is empty", $taskNumber));
                 sleep(10);
             }
         }
         $this->log("Task Manager finished");
     }
 }
コード例 #29
0
ファイル: maintenance.php プロジェクト: schwarer2006/wikia
/**
 * remove user from user_temp table
 * @param integer $fromUserId
 * @param integer $toUserId
 * @param integer $range 
 * @param string $condition
 */
function removeOldTempUser($fromUserId, $toUserId, $range, $condition)
{
    wfProfileIn(__METHOD__);
    if (wfReadOnly()) {
        echo "Error: Read Only Mode.\n";
    } else {
        // get scope
        if (empty($fromUserId) || empty($toUserId)) {
            getScope($fromUserId, $toUserId, $condition);
        }
        // remove old temp user
        $cnt = 0;
        do {
            $to = $toUserId - $fromUserId > $range ? $fromUserId + $range : $toUserId;
            echo "Removing temp user (UserId {$fromUserId} to {$to})...\n";
            $users = getTempUsers($fromUserId, $to, $condition);
            $cnt = $cnt + count($users);
            foreach ($users as $username) {
                $tempUser = TempUser::getTempUserFromName($username);
                $id = $tempUser->getId();
                $tempUser->removeFromDatabase();
                // remove spoof normalization record from the database
                $spoof = new SpoofUser($username);
                $spoof->removeRecord();
                echo "Removed temp user (id={$id}) from database.\n";
            }
            $fromUserId = $to;
        } while ($fromUserId < $toUserId);
        echo "Total {$cnt} temp users removed from database.\n";
    }
    wfProfileOut(__METHOD__);
}
コード例 #30
0
ファイル: LogPage.php プロジェクト: puring0815/OpenKore
 function saveContent()
 {
     if (wfReadOnly()) {
         return false;
     }
     global $wgUser;
     $fname = 'LogPage::saveContent';
     $dbw =& wfGetDB(DB_MASTER);
     $uid = $wgUser->getID();
     $this->timestamp = $now = wfTimestampNow();
     $dbw->insert('logging', array('log_type' => $this->type, 'log_action' => $this->action, 'log_timestamp' => $dbw->timestamp($now), 'log_user' => $uid, 'log_namespace' => $this->target->getNamespace(), 'log_title' => $this->target->getDBkey(), 'log_comment' => $this->comment, 'log_params' => $this->params), $fname);
     # And update recentchanges
     if ($this->updateRecentChanges) {
         $titleObj = Title::makeTitle(NS_SPECIAL, 'Log/' . $this->type);
         $rcComment = $this->actionText;
         if ('' != $this->comment) {
             if ($rcComment == '') {
                 $rcComment = $this->comment;
             } else {
                 $rcComment .= ': ' . $this->comment;
             }
         }
         RecentChange::notifyLog($now, $titleObj, $wgUser, $rcComment, '', $this->type, $this->action, $this->target, $this->comment, $this->params);
     }
     return true;
 }