/**
  * Initialize instance variables from request and create an Upload handler
  *
  * What was changed here: $this->mIgnoreWarning is now unconditionally true
  * and we use our own handler for $this->mUpload instead of UploadBase
  *
  * @param WebRequest $request The request to extract variables from
  */
 protected function loadRequest($request)
 {
     global $wgUser;
     $this->mRequest = $request;
     $this->mSourceType = $request->getVal('wpSourceType', 'file');
     $this->mUpload = FanBoxUpload::createFromRequest($request);
     $this->mUploadClicked = $request->wasPosted() && ($request->getCheck('wpUpload') || $request->getCheck('wpUploadIgnoreWarning'));
     // Guess the desired name from the filename if not provided
     $this->mDesiredDestName = $request->getText('wpDestFile');
     if (!$this->mDesiredDestName && $request->getFileName('wpUploadFile') !== null) {
         $this->mDesiredDestName = $request->getFileName('wpUploadFile');
     }
     $this->mComment = $request->getText('wpUploadDescription');
     $this->mLicense = $request->getText('wpLicense');
     $this->mDestWarningAck = $request->getText('wpDestFileWarningAck');
     $this->mIgnoreWarning = true;
     //$request->getCheck( 'wpIgnoreWarning' ) || $request->getCheck( 'wpUploadIgnoreWarning' );
     $this->mWatchthis = $request->getBool('wpWatchthis') && $wgUser->isLoggedIn();
     $this->mCopyrightStatus = $request->getText('wpUploadCopyStatus');
     $this->mCopyrightSource = $request->getText('wpUploadSource');
     $this->mForReUpload = $request->getBool('wpForReUpload');
     // updating a file
     $this->mCancelUpload = $request->getCheck('wpCancelUpload') || $request->getCheck('wpReUpload');
     // b/w compat
     // If it was posted check for the token (no remote POST'ing with user credentials)
     $token = $request->getVal('wpEditToken');
     if ($this->mSourceType == 'file' && $token == null) {
         // Skip token check for file uploads as that can't be faked via JS...
         // Some client-side tools don't expect to need to send wpEditToken
         // with their submissions, as that's new in 1.16.
         $this->mTokenOk = true;
     } else {
         $this->mTokenOk = $wgUser->matchEditToken($token);
     }
 }
 /**
  * @param $resourceLoader ResourceLoader
  * @param $request WebRequest
  */
 public function __construct($resourceLoader, WebRequest $request)
 {
     global $wgDefaultSkin, $wgResourceLoaderDebug;
     $this->resourceLoader = $resourceLoader;
     $this->request = $request;
     // Interpret request
     // List of modules
     $modules = $request->getVal('modules');
     $this->modules = $modules ? self::expandModuleNames($modules) : array();
     // Various parameters
     $this->skin = $request->getVal('skin');
     $this->user = $request->getVal('user');
     $this->debug = $request->getFuzzyBool('debug', $wgResourceLoaderDebug);
     $this->only = $request->getVal('only');
     $this->version = $request->getVal('version');
     // Wikia - change begin - @author: wladek
     $this->sassParams = array();
     foreach ($request->getValues() as $key => $value) {
         if (startsWith($key, 'sass_')) {
             $this->sassParams[substr($key, strlen('sass_'))] = $value;
         }
     }
     ksort($this->sassParams);
     // Wikia - change end
     $skinnames = Skin::getSkinNames();
     // If no skin is specified, or we don't recognize the skin, use the default skin
     if (!$this->skin || !isset($skinnames[$this->skin])) {
         $this->skin = $wgDefaultSkin;
     }
 }
 /**
  * Basic setup and applies the limiting factors from the WebRequest object.
  * @param WebRequest $request
  * @private
  */
 function setupQuery($request)
 {
     $page = $this->db->tableName('page');
     $user = $this->db->tableName('user');
     $this->joinClauses = array("LEFT OUTER JOIN {$page} ON log_namespace=page_namespace AND log_title=page_title");
     $this->whereClauses = array('user_id=log_user');
     $this->limitType($request->getVal('type'));
     $this->limitUser($request->getText('user'));
     $this->limitTitle($request->getText('page'));
     $this->limitTime($request->getVal('from'), '>=');
     $this->limitTime($request->getVal('until'), '<=');
     list($this->limit, $this->offset) = $request->getLimitOffset();
 }
 function __construct(WebRequest $request)
 {
     $this->fbUserId = $request->getVal('fbuserid');
     $this->fbFeedOptions = explode(',', $request->getVal('fbfeedoptions', ''));
     // get an email from Facebook API
     $resp = F::app()->sendRequest('FacebookSignup', 'getFacebookData', array('fbUserId' => $this->fbUserId));
     // add an email to the request and pass it to the underlying class
     $request->setVal('email', $resp->getVal('email', false));
     if ($request->getVal('type', '') == '') {
         $request->setVal('type', 'signup');
     }
     parent::__construct($request);
 }
 /**
  * @param ResourceLoader $resourceLoader
  * @param WebRequest $request
  */
 public function __construct(ResourceLoader $resourceLoader, WebRequest $request)
 {
     $this->resourceLoader = $resourceLoader;
     $this->request = $request;
     // Interpret request
     // List of modules
     $modules = $request->getVal('modules');
     $this->modules = $modules ? self::expandModuleNames($modules) : array();
     // Various parameters
     $this->skin = $request->getVal('skin');
     $this->user = $request->getVal('user');
     $this->debug = $request->getFuzzyBool('debug', $resourceLoader->getConfig()->get('ResourceLoaderDebug'));
     $this->only = $request->getVal('only');
     $this->version = $request->getVal('version');
     $this->raw = $request->getFuzzyBool('raw');
     // Image requests
     $this->image = $request->getVal('image');
     $this->variant = $request->getVal('variant');
     $this->format = $request->getVal('format');
     $skinnames = Skin::getSkinNames();
     // If no skin is specified, or we don't recognize the skin, use the default skin
     if (!$this->skin || !isset($skinnames[$this->skin])) {
         $this->skin = $resourceLoader->getConfig()->get('DefaultSkin');
     }
 }
Exemple #6
0
 function getMustShowThreads($threads = array())
 {
     if ($this->request->getCheck('lqt_operand')) {
         $operands = explode(',', $this->request->getVal('lqt_operand'));
         $threads = array_merge($threads, $operands);
     }
     if ($this->request->getCheck('lqt_mustshow')) {
         // Check for must-show in the request
         $specifiedMustShow = $this->request->getVal('lqt_mustshow');
         $specifiedMustShow = explode(',', $specifiedMustShow);
         $threads = array_merge($threads, $specifiedMustShow);
     }
     foreach ($threads as $walk_thread) {
         do {
             if (!is_object($walk_thread)) {
                 $walk_thread = Threads::withId($walk_thread);
             }
             if (!is_object($walk_thread)) {
                 continue;
             }
             $threads[$walk_thread->id()] = $walk_thread;
             $walk_thread = $walk_thread->superthread();
         } while ($walk_thread);
     }
     return $threads;
 }
Exemple #7
0
 /**
  * Constructor
  * @param WebRequest $request A WebRequest object passed by reference
  */
 function LoginForm(&$request, $par = '')
 {
     global $wgLang, $wgAllowRealName, $wgEnableEmail;
     global $wgAuth;
     $this->mType = $par == 'signup' ? $par : $request->getText('type');
     # Check for [[Special:Userlogin/signup]]
     $this->mName = $request->getText('wpName');
     $this->mPassword = $request->getText('wpPassword');
     $this->mRetype = $request->getText('wpRetype');
     $this->mRetypeEmail = $request->getText('wpRetypeEmail');
     $this->mDomain = $request->getText('wpDomain');
     $this->mReturnTo = $request->getVal('returnto');
     $this->mAutoRedirect = $request->getVal('autoredirect');
     $this->mFromSite = $request->getVal('sitelogin');
     $this->mCookieCheck = $request->getVal('wpCookieCheck');
     $this->mPosted = $request->wasPosted();
     $this->mCreateaccount = $request->getCheck('wpCreateaccount');
     $this->mCreateaccountMail = $request->getCheck('wpCreateaccountMail') && $wgEnableEmail;
     $this->mMailmypassword = $request->getCheck('wpMailmypassword') && $wgEnableEmail;
     $this->mLoginattempt = $request->getCheck('wpLoginattempt');
     $this->mAction = $request->getVal('action');
     $this->mRemember = $request->getCheck('wpRemember');
     $this->mLanguage = $request->getText('uselang');
     if ($wgEnableEmail) {
         $this->mEmail = $request->getText('wpEmail');
     } else {
         $this->mEmail = '';
     }
     if ($wgAllowRealName && $request->getText('wpUseRealNameAsDisplay') == "on") {
         $this->mRealName = @strip_tags($request->getText('wpRealName'));
     } else {
         $this->mRealName = '';
     }
     if (!$wgAuth->validDomain($this->mDomain)) {
         $this->mDomain = 'invaliddomain';
     }
     $wgAuth->setDomain($this->mDomain);
     # When switching accounts, it sucks to get automatically logged out
     if ($this->mReturnTo == $wgLang->specialPage('Userlogout')) {
         $this->mReturnTo = '';
     }
     if ($this->mAutoRedirect == $wgLang->specialPage('Userlogout')) {
         $this->mAutoRedirect = '';
     }
 }
 /**
  * Basic setup and applies the limiting factors from the WebRequest object.
  * @param WebRequest $request
  * @private
  */
 function setupQuery($request)
 {
     $page = $this->db->tableName('page');
     $user = $this->db->tableName('user');
     $this->joinClauses = array("LEFT OUTER JOIN {$page} ON log_namespace=page_namespace AND log_title=page_title", "INNER JOIN {$user} ON user_id=log_user");
     $this->whereClauses = array();
     $this->limitType($request->getVal('type'));
     $this->limitUser($request->getText('user'));
     $this->limitTitle($request->getText('page'), $request->getBool('pattern'));
     $this->limitTime($request->getVal('from'), '>=');
     $this->limitTime($request->getVal('until'), '<=');
     list($this->limit, $this->offset) = $request->getLimitOffset();
     // XXX This all needs to use Pager, ugly hack for now.
     global $wgMiserMode;
     if ($wgMiserMode) {
         $this->offset = min($this->offset, 10000);
     }
 }
 public function __construct(ResourceLoader $resourceLoader, WebRequest $request)
 {
     global $wgDefaultSkin, $wgResourceLoaderDebug;
     $this->resourceLoader = $resourceLoader;
     $this->request = $request;
     // Interpret request
     // List of modules
     $modules = $request->getVal('modules');
     $this->modules = $modules ? self::expandModuleNames($modules) : array();
     // Various parameters
     $this->skin = $request->getVal('skin');
     $this->user = $request->getVal('user');
     $this->debug = $request->getFuzzyBool('debug', $wgResourceLoaderDebug);
     $this->only = $request->getVal('only');
     $this->version = $request->getVal('version');
     if (!$this->skin) {
         $this->skin = $wgDefaultSkin;
     }
 }
 /**
  * Try and get an email for the user from Facebook. If Facebook has an email for the user
  * we don't have to confirm it, Facebook has done that for us. If Facebook doesn't have one,
  * try and pull one from the form and make note that we'll have to confirm the user.
  * @param WebRequest $request
  * @return String
  */
 private function getUserEmail(WebRequest $request)
 {
     $userInfo = FacebookClient::getInstance()->getUserInfo();
     $userEmail = $userInfo->getProperty('email');
     if (empty($userEmail)) {
         // Email didn't come from facebook, we have to confirm it ourselves
         $this->hasConfirmedEmail = false;
         $userEmail = $request->getVal('email', '');
     }
     return $userEmail;
 }
 /**
  * @param $resourceLoader ResourceLoader
  * @param $request WebRequest
  */
 public function __construct($resourceLoader, WebRequest $request)
 {
     global $wgDefaultSkin, $wgResourceLoaderDebug;
     $this->resourceLoader = $resourceLoader;
     $this->request = $request;
     // Interpret request
     // List of modules
     $modules = $request->getVal('modules');
     $this->modules = $modules ? self::expandModuleNames($modules) : array();
     // Various parameters
     $this->skin = $request->getVal('skin');
     $this->user = $request->getVal('user');
     $this->debug = $request->getFuzzyBool('debug', $wgResourceLoaderDebug);
     $this->only = $request->getVal('only');
     $this->version = $request->getVal('version');
     $skinnames = Skin::getSkinNames();
     // If no skin is specified, or we don't recognize the skin, use the default skin
     if (!$this->skin || !isset($skinnames[$this->skin])) {
         $this->skin = $wgDefaultSkin;
     }
 }
 /**
  * @param WebRequest $request
  *
  * @return string
  */
 function loadDataFromRequest($request)
 {
     $invert = isset($this->mParams['invert']) && $this->mParams['invert'];
     // GetCheck won't work like we want for checks.
     // Fetch the value in either one of the two following case:
     // - we have a valid token (form got posted or GET forged by the user)
     // - checkbox name has a value (false or true), ie is not null
     if ($request->getCheck('wpEditToken') || $request->getVal($this->mName) !== null) {
         return $invert ? !$request->getBool($this->mName) : $request->getBool($this->mName);
     } else {
         return $this->getDefault();
     }
 }
 /**
  * Constructor
  * @param WebRequest $request A WebRequest object passed by reference
  */
 function LoginForm(&$request)
 {
     global $wgLang, $wgAllowRealName, $wgEnableEmail;
     global $wgAuth;
     $this->mType = $request->getText('type');
     $this->mName = $request->getText('wpName');
     $this->mPassword = $request->getText('wpPassword');
     $this->mRetype = $request->getText('wpRetype');
     $this->mDomain = $request->getText('wpDomain');
     $this->mReturnTo = $request->getVal('returnto');
     $this->mCookieCheck = $request->getVal('wpCookieCheck');
     $this->mPosted = $request->wasPosted();
     $this->mCreateaccount = $request->getCheck('wpCreateaccount');
     $this->mCreateaccountMail = $request->getCheck('wpCreateaccountMail') && $wgEnableEmail;
     $this->mMailmypassword = $request->getCheck('wpMailmypassword') && $wgEnableEmail;
     $this->mLoginattempt = $request->getCheck('wpLoginattempt');
     $this->mAction = $request->getVal('action');
     $this->mRemember = $request->getCheck('wpRemember');
     $this->mLanguage = $request->getText('uselang');
     if ($wgEnableEmail) {
         $this->mEmail = $request->getText('wpEmail');
     } else {
         $this->mEmail = '';
     }
     if ($wgAllowRealName) {
         $this->mRealName = $request->getText('wpRealName');
     } else {
         $this->mRealName = '';
     }
     if (!$wgAuth->validDomain($this->mDomain)) {
         $this->mDomain = 'invaliddomain';
     }
     $wgAuth->setDomain($this->mDomain);
     # When switching accounts, it sucks to get automatically logged out
     if ($this->mReturnTo == $wgLang->specialPage('Userlogout')) {
         $this->mReturnTo = '';
     }
 }
 /**
  * @param WebRequest $request
  *
  * @return string
  */
 function loadDataFromRequest($request)
 {
     $size = $request->getInt($this->mName);
     if (!$size) {
         return $this->getDefault();
     }
     $size = abs($size);
     // negative numbers represent "max", positive numbers represent "min"
     if ($request->getVal($this->mName . '-mode') === 'max') {
         return -$size;
     } else {
         return $size;
     }
 }
 /**
  * Initialize instance variables from request and create an Upload handler
  *
  * @param WebRequest $request The request to extract variables from
  */
 protected function loadRequest($request)
 {
     global $wgUser, $wgMaxUploadFiles;
     // let's make the parent happy
     wfSuppressWarnings();
     $_FILES['wpUploadFile'] = $_FILES['wpUploadFile0'];
     wfRestoreWarnings();
     // Guess the desired name from the filename if not provided
     $this->mDesiredDestNames = array();
     $this->mUploads = array();
     // deal with session keys, if we have some pick the first one, for now
     $vals = $request->getValues();
     $fromsession = false;
     foreach ($vals as $k => $v) {
         if (preg_match("@^wpSessionKey@", $k)) {
             $request->setVal('wpSessionKey', $v);
             $fromsession = true;
             $filenum = preg_replace("@wpSessionKey@", '', $k);
             $request->setVal('wpDestFile', $request->getVal('wpDestFile' . $filenum));
             $up = UploadBase::createFromRequest($request);
             $this->mUploads[] = $up;
             $this->mDesiredDestNames[] = $request->getVal('wpDestFile' . $filenum);
         }
     }
     parent::loadRequest($request);
     $this->mUploadClicked = $request->wasPosted() && ($request->getCheck('wpUpload') || $request->getCheck('wpUploadIgnoreWarning'));
     if (!$fromsession) {
         for ($i = 0; $i < $wgMaxUploadFiles; $i++) {
             $this->mDesiredDestNames[$i] = $request->getText('wpDestFile' . $i);
             if (!$this->mDesiredDestNames[$i] && $request->getFileName('wpUploadFile' . $i) !== null) {
                 $this->mDesiredDestNames[$i] = $request->getFileName('wpUploadFile' . $i);
             }
             wfSuppressWarnings();
             $request->setVal('wpUploadFile', $_FILES['wpUploadFile' . $i]);
             wfRestoreWarnings();
             $request->setVal('wpDestFile', $request->getVal('wpDestFile' . $i));
             move_uploaded_file('wpUploadFile' . $i, 'wpUploadFile');
             wfSuppressWarnings();
             $_FILES['wpUploadFile'] = $_FILES['wpUploadFile' . $i];
             wfRestoreWarnings();
             $up = UploadBase::createFromRequest($request);
             if ($up) {
                 $this->mUploads[] = $up;
             }
         }
     }
     $this->mDesiredDestName = $this->mDesiredDestNames[0];
     $this->mUpload = $this->mUploads[0];
 }
 /**
  * Set up basic search parameters from the request and user settings.
  * Typically you'll pass $wgRequest and $wgUser.
  *
  * @param WebRequest $request
  * @param User $user
  * @public
  */
 function __construct(&$request, &$user)
 {
     list($this->limit, $this->offset) = $request->getLimitOffset(20, 'searchlimit');
     $this->mPrefix = $request->getVal('prefix', '');
     # Extract requested namespaces
     $this->namespaces = $this->powerSearch($request);
     if (empty($this->namespaces)) {
         $this->namespaces = SearchEngine::userNamespaces($user);
     }
     $this->searchRedirects = $request->getcheck('redirs') ? true : false;
     $this->searchAdvanced = $request->getVal('advanced');
     $this->active = 'advanced';
     $this->sk = $user->getSkin();
     $this->didYouMeanHtml = '';
     # html of did you mean... link
     $this->fulltext = $request->getVal('fulltext');
 }
 /**
  * Convenience function to set variables based on form data.
  * Assumes that variables containing "password" in the name are (potentially
  * fake) passwords.
  *
  * @param $varNames Array
  * @param string $prefix the prefix added to variables to obtain form names
  *
  * @return array
  */
 public function setVarsFromRequest($varNames, $prefix = 'config_')
 {
     $newValues = array();
     foreach ($varNames as $name) {
         $value = trim($this->request->getVal($prefix . $name));
         $newValues[$name] = $value;
         if ($value === null) {
             // Checkbox?
             $this->setVar($name, false);
         } else {
             if (stripos($name, 'password') !== false) {
                 $this->setPassword($name, $value);
             } else {
                 $this->setVar($name, $value);
             }
         }
     }
     return $newValues;
 }
 /**
  * What we should do if the permission action is clicked.
  * @param OutputPage $output
  * @param Article $article
  * @param Title $title
  * @param User $user
  * @param WebRequest $request
  * @Param MediaWiki $wiki
  */
 static function displayACLForm($output, $article, $title, $user, $request, $wiki)
 {
     global $wgParser;
     if ($request->getVal('action') != self::$ACTION) {
         return true;
     }
     $text = "";
     $owner = MWUtil::pageOwner($title, true);
     $text .= "Page owner is '''" . $owner->getName() . "'''.";
     ACL::loadUserGroups();
     $ownergroups = ACL::getUserGroups($owner);
     $ogroups = " Owner belongs to these user groups:";
     if ($ownergroups) {
         foreach ($ownergroups as $g) {
             $ogroups .= $g['name'] . ",";
         }
     } else {
         $ogroups = " Owner does not belong to any user group";
     }
     $text .= $ogroups . "\n\n";
     $permissionpage = ACL_ACL . ":" . $article->getID();
     $permissiontitle = Title::newFromText($permissionpage);
     $ns = $title->getNSText();
     if (!$ns) {
         $ns = "Main";
     }
     $sp = SpecialPage::getPage("FormEdit");
     $sp_url = $sp->getTitle()->getLocalURL();
     $sp_url .= "?form=" . self::$FORM . "&target={$permissionpage}&ACL Page Permission[PageId]={$article->getID()}&ACL Page Permission[PageName]={$title->getDBkey()}&ACL Page Permission[Namespace]={$ns}";
     if ($permissiontitle->exists()) {
         $text .= "[[{$permissionpage}|View Page Permission]]\n\n----\n";
         $output->addWikiText($text);
         $output->addHTML("<a href='{$sp_url}'>Edit permission for this page</a>");
     } else {
         $text .= "No page specific Permission is set.";
         $output->addWikiText($text);
         $output->addHTML("<a href='{$sp_url}'>Set permission for this page</a>");
     }
     return false;
 }
Exemple #19
0
 /**
  * @param WebRequest $request
  *
  * @return string
  */
 function loadDataFromRequest($request)
 {
     $invert = false;
     if (isset($this->mParams['invert']) && $this->mParams['invert']) {
         $invert = true;
     }
     // GetCheck won't work like we want for checks.
     // Fetch the value in either one of the two following case:
     // - we have a valid token (form got posted or GET forged by the user)
     // - checkbox name has a value (false or true), ie is not null
     if ($request->getCheck('wpEditToken') || $request->getVal($this->mName) !== null) {
         // XOR has the following truth table, which is what we want
         // INVERT VALUE | OUTPUT
         // true   true  | false
         // false  true  | true
         // false  false | false
         // true   false | true
         return $request->getBool($this->mName) xor $invert;
     } else {
         return $this->getDefault();
     }
 }
Exemple #20
0
<?php

define('MW_NO_SETUP', 1);
require_once './includes/WebStart.php';
global $wgArticlePath;
require_once 'includes/WebRequest.php';
$wgRequest = new WebRequest();
$page = $wgRequest->getVal('wpDropdown');
$url = str_replace("\$1", urlencode($page), $wgArticlePath);
header("Location: {$url}");
 /**
  * Determine whether we are editing the watchlist, and if so, what
  * kind of editing operation
  *
  * @param WebRequest $request
  * @param string $par
  * @return int
  */
 public static function getMode($request, $par)
 {
     $mode = strtolower($request->getVal('action', $par));
     switch ($mode) {
         case 'clear':
         case self::EDIT_CLEAR:
             return self::EDIT_CLEAR;
         case 'raw':
         case self::EDIT_RAW:
             return self::EDIT_RAW;
         case 'edit':
         case self::EDIT_NORMAL:
             return self::EDIT_NORMAL;
         default:
             return false;
     }
 }
 /**
  * Make sure the form isn't faking a user's credentials.
  *
  * @param WebRequest $request
  * @return bool
  * @access private
  */
 function tokenOk(&$request)
 {
     global $wgUser;
     if ($wgUser->isAnon()) {
         # Anonymous users may not have a session
         # open. Don't tokenize.
         return true;
     } else {
         return $wgUser->matchEditToken($request->getVal('wpEditToken'));
     }
 }
 /**
  * @param WebRequest $request
  */
 private function submit($request)
 {
     global $wgUser, $wgOut;
     # Check edit token on submission
     if ($this->wasPosted && !$wgUser->matchEditToken($request->getVal('wpEditToken'))) {
         $wgOut->addWikiMsg('sessionfailure');
         return false;
     }
     $bitfield = $this->extractBitfield($request);
     $comment = $request->getText('wpReason');
     # Can the user set this field?
     if ($bitfield & Revision::DELETED_RESTRICTED && !$wgUser->isAllowed('suppressrevision')) {
         $wgOut->permissionRequired('suppressrevision');
         return false;
     }
     # If the save went through, go to success message. Otherwise
     # bounce back to form...
     if ($this->save($bitfield, $comment, $this->page)) {
         $this->success();
     } else {
         if ($request->getCheck('oldid') || $request->getCheck('artimestamp')) {
             return $this->showRevs();
         } else {
             if ($request->getCheck('logid')) {
                 return $this->showLogs();
             } else {
                 if ($request->getCheck('oldimage') || $request->getCheck('fileid')) {
                     return $this->showImages();
                 }
             }
         }
     }
 }
 /**
  * Builds a JSON blob of the data required to use the iterator.
  * @param WebRequest $request
  * @return type 
  */
 private function buildIteratorParameters(WebRequest &$request)
 {
     global $spsgIterators;
     // iteratorName
     $iteratorName = $request->getVal('iterator');
     if (is_null($iteratorName)) {
         throw new SPSException(SPSUtils::buildMessage('spserror-noiteratorname'));
     }
     if (!array_key_exists($iteratorName, $spsgIterators)) {
         throw new SPSException(SPSUtils::buildMessage('spserror-iteratorunknown', $iteratorName));
     }
     // iterator
     $iterator = new $spsgIterators[$iteratorName]();
     // targetFormName
     $targetFormName = $request->getVal('target_form');
     if (is_null($targetFormName)) {
         throw new SPSException(SPSUtils::buildMessage('spserror-notargetformname'));
     }
     // targetFormTitle is not really needed at this stage,
     // but we throw an error early if it does not exist
     $targetFormTitle = Title::makeTitleSafe(SF_NS_FORM, $targetFormName);
     if (!$targetFormTitle->exists()) {
         throw new SPSException(SPSUtils::buildMessage('spserror-formunknown', $targetFormName));
     }
     // targetFieldName
     $targetFieldName = $request->getVal('target_field');
     if (is_null($targetFieldName)) {
         throw new SPSException(SPSUtils::buildMessage('spserror-notargetfieldname'));
     }
     $params = array('iterator' => $iteratorName, 'target_form' => $targetFormName, 'target_field' => $targetFieldName, 'origin' => $request->getVal('origin'));
     // add the iterator-specific values
     $paramNames = $iterator->getParameterNames();
     $errors = '';
     foreach ($paramNames as $paramName => $paramOptional) {
         $param = $request->getVal($paramName);
         if (is_null($param)) {
             if ($paramOptional === SPS_MANDATORY) {
                 // mandatory parameter missing
                 $errors .= "* {$paramName}\n";
             }
         } else {
             $params[$paramName] = $param;
         }
     }
     if ($errors !== '') {
         throw new SPSException(SPSUtils::buildMessage('spserror-iteratorparammissing', $errors));
     }
     return FormatJson::encode($params);
 }
 /**
  * Check if the submitted form matches the captcha session data provided
  * by the plugin when the form was generated.
  *
  * Override this!
  *
  * @param WebRequest $request
  * @param array $info
  * @return bool
  */
 function keyMatch($request, $info)
 {
     return $request->getVal('wpCaptchaWord') == $info['answer'];
 }
Exemple #26
0
 /**
  * Tries to create an existing title object for current request. Used for setting the title
  * global during ajax requests. It uses title URL param to keep backward compatibility.
  *
  * @static
  * @param WebRequest $request
  * @return Title
  */
 public static function createTitleFromRequest($request)
 {
     if ($request->getVal('title', '') === '') {
         $title = Title::newMainPage();
     } else {
         $title = Title::newFromText($request->getVal('title', 'AJAX'), $request->getInt('namespace', NS_MAIN));
         if (!$title instanceof Title) {
             $title = Title::makeTitle(NS_MAIN, 'AJAX');
         }
     }
     return $title;
 }
 /**
  * @param WebRequest $request
  * @return bool
  */
 public static function isValidRequest($request)
 {
     global $wgUser;
     $url = $request->getVal('wpUploadFileURL');
     return !empty($url) && $wgUser->isAllowed('upload_by_url');
 }
Exemple #28
0
 /**
  * Make sure the form isn't faking a user's credentials.
  *
  * @param WebRequest $request
  * @return bool
  * @private
  */
 function tokenOk(&$request)
 {
     global $wgUser;
     $token = $request->getVal('wpEditToken');
     $this->mTokenOk = $wgUser->matchEditToken($token);
     $this->mTokenOkExceptSuffix = $wgUser->matchEditTokenNoSuffix($token);
     return $this->mTokenOk;
 }
 public static function isBeta(WebRequest $request)
 {
     $tux = $request->getVal('tux', null);
     if ($tux === null) {
         $tux = $request->getCookie('tux', null, true);
     } elseif ($tux) {
         $request->response()->setCookie('tux', 1);
     } else {
         $request->response()->setCookie('tux', 0);
     }
     return $tux;
 }
Exemple #30
0
 /**
  * Create a form of UploadBase depending on wpSourceType and initializes it
  *
  * @param WebRequest $request
  * @param string|null $type
  * @return null|UploadBase
  */
 public static function createFromRequest(&$request, $type = null)
 {
     $type = $type ? $type : $request->getVal('wpSourceType', 'File');
     if (!$type) {
         return null;
     }
     // Get the upload class
     $type = ucfirst($type);
     // Give hooks the chance to handle this request
     $className = null;
     Hooks::run('UploadCreateFromRequest', [$type, &$className]);
     if (is_null($className)) {
         $className = 'UploadFrom' . $type;
         wfDebug(__METHOD__ . ": class name: {$className}\n");
         if (!in_array($type, self::$uploadHandlers)) {
             return null;
         }
     }
     // Check whether this upload class is enabled
     if (!call_user_func([$className, 'isEnabled'])) {
         return null;
     }
     // Check whether the request is valid
     if (!call_user_func([$className, 'isValidRequest'], $request)) {
         return null;
     }
     /** @var UploadBase $handler */
     $handler = new $className();
     $handler->initializeFromRequest($request);
     return $handler;
 }