/**
  * Show a nice form for the user to request a confirmation mail
  */
 function showRequestForm()
 {
     global $wgOut, $wgUser, $wgLang, $wgRequest;
     if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getText('token'))) {
         $ok = $wgUser->sendConfirmationMail();
         if (WikiError::isError($ok)) {
             $wgOut->addWikiMsg('confirmemail_sendfailed', $ok->toString());
         } else {
             $wgOut->addWikiMsg('confirmemail_sent');
         }
     } else {
         if ($wgUser->isEmailConfirmed()) {
             // date and time are separate parameters to facilitate localisation.
             // $time is kept for backward compat reasons.
             // 'emailauthenticated' is also used in SpecialPreferences.php
             $time = $wgLang->timeAndDate($wgUser->mEmailAuthenticated, true);
             $d = $wgLang->date($wgUser->mEmailAuthenticated, true);
             $t = $wgLang->time($wgUser->mEmailAuthenticated, true);
             $wgOut->addWikiMsg('emailauthenticated', $time, $d, $t);
         }
         if ($wgUser->isEmailConfirmationPending()) {
             $wgOut->wrapWikiMsg("<div class=\"error mw-confirmemail-pending\">\n\$1</div>", 'confirmemail_pending');
         }
         $wgOut->addWikiMsg('confirmemail_text');
         $form = Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl()));
         $form .= Xml::hidden('token', $wgUser->editToken());
         $form .= Xml::submitButton(wfMsg('confirmemail_send'));
         $form .= Xml::closeElement('form');
         $wgOut->addHTML($form);
     }
 }
 /**
  * Show a nice form for the user to request a confirmation mail
  */
 function showRequestForm()
 {
     global $wgOut, $wgUser, $wgLang, $wgRequest;
     if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getText('token'))) {
         $ok = $wgUser->sendConfirmationMail();
         if (WikiError::isError($ok)) {
             $wgOut->addWikiMsg('confirmemail_sendfailed', $ok->toString());
         } else {
             $wgOut->addWikiMsg('confirmemail_sent');
         }
     } else {
         if ($wgUser->isEmailConfirmed()) {
             $time = $wgLang->timeAndDate($wgUser->mEmailAuthenticated, true);
             $wgOut->addWikiMsg('emailauthenticated', $time);
         }
         if ($wgUser->isEmailConfirmationPending()) {
             $wgOut->addWikiMsg('confirmemail_pending');
         }
         $wgOut->addWikiMsg('confirmemail_text');
         $self = SpecialPage::getTitleFor('Confirmemail');
         $form = wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalUrl()));
         $form .= wfHidden('token', $wgUser->editToken());
         $form .= wfSubmitButton(wfMsgHtml('confirmemail_send'));
         $form .= wfCloseElement('form');
         $wgOut->addHtml($form);
     }
 }
 function processUpload()
 {
     global $wgUser, $wgOut, $wgFileExtensions;
     $details = null;
     $value = null;
     $value = $this->internalProcessUpload($details);
     switch ($value) {
         case self::SUCCESS:
             // don't... do... REDIRECT
             return;
         case self::BEFORE_PROCESSING:
             return false;
         case self::LARGE_FILE_SERVER:
             return wfMsg('largefileserver');
         case self::EMPTY_FILE:
             return wfMsg('emptyfile');
         case self::MIN_LENGTH_PARTNAME:
             return wfMsg('minlength1');
             return;
         case self::ILLEGAL_FILENAME:
             $filtered = $details['filtered'];
             return wfMsg('illegalfilename', $filtered);
         case self::PROTECTED_PAGE:
             return wfMsg('protectedpage');
         case self::OVERWRITE_EXISTING_FILE:
             $errorText = $details['overwrite'];
             $overwrite = new WikiError($wgOut->parse($errorText));
             return $overwrite->toString();
         case self::FILETYPE_MISSING:
             return wfMsg('filetype-missing');
         case self::FILETYPE_BADTYPE:
             $finalExt = $details['finalExt'];
             return wfMsg('filetype-badtype');
         case self::VERIFICATION_ERROR:
             $veri = $details['veri'];
             return $veri->toString();
         case self::UPLOAD_VERIFICATION_ERROR:
             $error = $details['error'];
             return $error;
         case self::UPLOAD_WARNING:
             $warning = $details['warning'];
             return $warning;
     }
     throw new MWException(__METHOD__ . ": Unknown value `{$value}`");
 }
/**
 * Constructor
 */
function wfSpecialImport($page = '')
{
    global $wgUser, $wgOut, $wgLang, $wgRequest, $wgTitle;
    global $wgImportSources;
    ###
    #	$wgOut->addWikiText( "Special:Import is not ready for this beta release, sorry." );
    #	return;
    ###
    if ($wgRequest->wasPosted() && $wgRequest->getVal('action') == 'submit') {
        switch ($wgRequest->getVal("source")) {
            case "upload":
                if ($wgUser->isAllowed('importupload')) {
                    $source = ImportStreamSource::newFromUpload("xmlimport");
                } else {
                    return $wgOut->permissionRequired('importupload');
                }
                break;
            case "interwiki":
                $source = ImportStreamSource::newFromInterwiki($wgRequest->getVal("interwiki"), $wgRequest->getText("frompage"));
                break;
            default:
                $source = new WikiError("Unknown import source type");
        }
        if (WikiError::isError($source)) {
            $wgOut->addWikiText(wfEscapeWikiText($source->getMessage()));
        } else {
            $importer = new WikiImporter($source);
            $result = $importer->doImport();
            if (WikiError::isError($result)) {
                $wgOut->addWikiText(wfMsg("importfailed", wfEscapeWikiText($result->getMessage())));
            } else {
                # Success!
                $wgOut->addWikiText(wfMsg("importsuccess"));
            }
        }
    }
    $action = $wgTitle->escapeLocalUrl('action=submit');
    if ($wgUser->isAllowed('importupload')) {
        $wgOut->addWikiText(wfMsg("importtext"));
        $wgOut->addHTML("\n<fieldset>\n\t<legend>" . wfMsgHtml('upload') . "</legend>\n\t<form enctype='multipart/form-data' method='post' action=\"{$action}\">\n\t\t<input type='hidden' name='action' value='submit' />\n\t\t<input type='hidden' name='source' value='upload' />\n\t\t<input type='hidden' name='MAX_FILE_SIZE' value='2000000' />\n\t\t<input type='file' name='xmlimport' value='' size='30' />\n\t\t<input type='submit' value='" . wfMsgHtml("uploadbtn") . "'/>\n\t</form>\n</fieldset>\n");
    } else {
        if (empty($wgImportSources)) {
            $wgOut->addWikiText(wfMsg('importnosources'));
        }
    }
    if (!empty($wgImportSources)) {
        $wgOut->addHTML("\n<fieldset>\n\t<legend>" . wfMsgHtml('importinterwiki') . "</legend>\n\t<form method='post' action=\"{$action}\">\n\t\t<input type='hidden' name='action' value='submit' />\n\t\t<input type='hidden' name='source' value='interwiki' />\n\t\t<select name='interwiki'>\n");
        foreach ($wgImportSources as $interwiki) {
            $iw = htmlspecialchars($interwiki);
            $wgOut->addHTML("<option value=\"{$iw}\">{$iw}</option>\n");
        }
        $wgOut->addHTML("\n\t\t</select>\n\t\t<input name='frompage' />\n\t\t<input type='submit' />\n\t</form>\n</fieldset>\n");
    }
}
Exemple #5
0
 public function execute()
 {
     global $wgUser;
     if (!$wgUser->isAllowed('import')) {
         $this->dieUsageMsg(array('cantimport'));
     }
     $params = $this->extractRequestParams();
     if (!isset($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     if (!$wgUser->matchEditToken($params['token'])) {
         $this->dieUsageMsg(array('sessionfailure'));
     }
     $source = null;
     $isUpload = false;
     if (isset($params['interwikisource'])) {
         if (!isset($params['interwikipage'])) {
             $this->dieUsageMsg(array('missingparam', 'interwikipage'));
         }
         $source = ImportStreamSource::newFromInterwiki($params['interwikisource'], $params['interwikipage'], $params['fullhistory'], $params['templates']);
     } else {
         $isUpload = true;
         if (!$wgUser->isAllowed('importupload')) {
             $this->dieUsageMsg(array('cantimport-upload'));
         }
         $source = ImportStreamSource::newFromUpload('xml');
     }
     if ($source instanceof WikiErrorMsg) {
         $this->dieUsageMsg(array_merge(array($source->getMessageKey()), $source->getMessageArgs()));
     } else {
         if (WikiError::isError($source)) {
             // This shouldn't happen
             $this->dieUsageMsg(array('import-unknownerror', $source->getMessage()));
         }
     }
     $importer = new WikiImporter($source);
     if (isset($params['namespace'])) {
         $importer->setTargetNamespace($params['namespace']);
     }
     $reporter = new ApiImportReporter($importer, $isUpload, $params['interwikisource'], $params['summary']);
     $result = $importer->doImport();
     if ($result instanceof WikiXmlError) {
         $this->dieUsageMsg(array('import-xml-error', $result->mLine, $result->mColumn, $result->mByte . $result->mContext, xml_error_string($result->mXmlError)));
     } else {
         if (WikiError::isError($result)) {
             // This shouldn't happen
             $this->dieUsageMsg(array('import-unknownerror', $result->getMessage()));
         }
     }
     $resultData = $reporter->getData();
     $this->getResult()->setIndexedTagName($resultData, 'page');
     $this->getResult()->addValue(null, $this->getModuleName(), $resultData);
 }
 /** */
 function checkAndSend()
 {
     global $wgUser, $wgRequest;
     if ($wgRequest->wasPosted() && $wgUser->isLoggedIn() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
         $result = $wgUser->sendConfirmationMail();
         if (WikiError::isError($result)) {
             return 'confirmemail_sendfailed';
         } else {
             return 'confirmemail_sent';
         }
     } else {
         # boo
         return '';
     }
 }
 function dump()
 {
     # This shouldn't happen if on console... ;)
     header('Content-type: text/html; charset=UTF-8');
     # Notice messages will foul up your XML output even if they're
     # relatively harmless.
     //		ini_set( 'display_errors', false );
     $this->initProgress($this->history);
     $this->db =& $this->backupDb();
     $this->egress = new ExportProgressFilter($this->sink, $this);
     $input = fopen($this->input, "rt");
     $result = $this->readDump($input);
     if (WikiError::isError($result)) {
         wfDie($result->getMessage());
     }
     $this->report(true);
 }
function UW_GenericEditPage_emailSuggestion ( $category ) {
	global $wgSuggestCategoryRecipient, $wgEmergencyContact, $wgSitename, $wgUser;

	

	$from = new MailAddress ( $wgEmergencyContact );
	$to   = new MailAddress ( $wgSuggestCategoryRecipient );
	$subj = wfMsg ( "gep-emailsubject", $wgSitename, $category );
	$body = wfMsg ( "gep-emailbody", $wgUser->getName(), $category, $wgSitename );

	// attempt to send the notification
	$result = UserMailer::send( $to, $from, $subj, $body );

	/* send a message back to the client, to let them
	 * know if the suggestion was successfully sent (or not) */
	return WikiError::isError ( $result )
	     ? wfMsg ( 'gep-emailfailure' )
	     : wfMsg ( 'gep-emailsuccess', $category );
}
 /**
  * Show a nice form for the user to request a confirmation mail
  */
 function showRequestForm()
 {
     global $wgOut, $wgUser, $wgLang, $wgRequest;
     if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getText('token'))) {
         $ok = $wgUser->sendConfirmationMail();
         $message = WikiError::isError($ok) ? 'confirmemail_sendfailed' : 'confirmemail_sent';
         $wgOut->addWikiText(wfMsg($message));
     } else {
         if ($wgUser->isEmailConfirmed()) {
             $time = $wgLang->timeAndDate($wgUser->mEmailAuthenticated, true);
             $wgOut->addWikiText(wfMsg('emailauthenticated', $time));
         }
         $wgOut->addWikiText(wfMsg('confirmemail_text'));
         $self = Title::makeTitle(NS_SPECIAL, 'Confirmemail');
         $form = wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalUrl()));
         $form .= wfHidden('token', $wgUser->editToken());
         $form .= wfSubmitButton(wfMsgHtml('confirmemail_send'));
         $form .= wfCloseElement('form');
         $wgOut->addHtml($form);
     }
 }
Exemple #10
0
 function run($par)
 {
     global $wgRequest, $wgEmailMeAddress, $wgOut;
     if ($wgRequest->wasPosted()) {
         $from = $wgRequest->getText('from');
         $subject = $wgRequest->getText('subject');
         $message = $wgRequest->getText('message');
         if (!($from && $subject && $message)) {
             return $this->print_form($this->getTitle(), $subject, $from, $message, wfMsg('emailme-incomplete'));
         }
         if (!User::isValidEmailAddr($from)) {
             return $this->print_form($this->getTitle(), $subject, $from, $message, wfMsg('emailme-invalid-email'));
         }
         $mailResult = UserMailer::send(new MailAddress($wgEmailMeAddress), new MailAddress($from), $subject, $message);
         if (WikiError::isError($mailResult)) {
             return $this->print_form($this->getTitle(), $subject, $from, $message, 'Sorry: ' . $mailResult->toString());
             dvLog("ERROR: EmailMe::run(" . $mailResult->toString() . ") {$from}|{$subject}");
         } else {
             dvLog("EMAIL: {$from} -> {$wgEmailMeAddress} ( {$subject} ) ");
             return $this->print_success();
         }
     }
     return $this->print_form($this->getTitle(), str_replace('_', ' ', $par));
 }
Exemple #11
0
 function doSubmit()
 {
     global $wgOut, $wgUser;
     $to = new MailAddress($this->target);
     $from = new MailAddress($wgUser);
     $subject = $this->subject;
     if (wfRunHooks('EmailUser', array(&$to, &$from, &$subject, &$this->text))) {
         $mailResult = userMailer($to, $from, $subject, $this->text);
         if (WikiError::isError($mailResult)) {
             $wgOut->addHTML(wfMsg("usermailererror") . $mailResult);
         } else {
             $titleObj = Title::makeTitle(NS_SPECIAL, "Emailuser");
             $encTarget = wfUrlencode($this->target->getName());
             $wgOut->redirect($titleObj->getFullURL("target={$encTarget}&action=success"));
             wfRunHooks('EmailUserComplete', array($to, $from, $subject, $this->text));
         }
     }
 }
 function saveSettings_basic()
 {
     global $wgUser, $wgRequest, $wgEmailAuthentication;
     $wgUser->setRealName($wgRequest->getVal('real_name'));
     $wgUser->setEmail($wgRequest->getVal('email'));
     if ($wgUser->getEmail() != $wgRequest->getVal('email')) {
         $wgUser->mEmailAuthenticated = null;
         # but flag as "dirty" = unauthenticated
     }
     if ($wgEmailAuthentication && !$wgUser->isEmailConfirmed()) {
         # Mail a temporary password to the dirty address.
         # User can come back through the confirmation URL to re-enable email.
         $result = $wgUser->sendConfirmationMail();
         if (WikiError::isError($result)) {
             $error = wfMsg('mailerror', htmlspecialchars($result->getMessage()));
         } else {
             $error = wfMsg('eauthentsent', $wgUser->getName());
         }
     }
     $wgUser->saveSettings();
 }
 /**
  * @access private
  */
 function savePreferences()
 {
     global $wgUser, $wgOut, $wgParser;
     global $wgEnableUserEmail, $wgEnableEmail;
     global $wgEmailAuthentication, $wgRCMaxAge;
     global $wgAuth, $wgEmailConfirmToEdit;
     $wgUser->setRealName($this->mRealName);
     $oldOptions = $wgUser->mOptions;
     if ($wgUser->getOption('language') !== $this->mUserLanguage) {
         $needRedirect = true;
     } else {
         $needRedirect = false;
     }
     # Validate the signature and clean it up as needed
     global $wgMaxSigChars;
     if (mb_strlen($this->mNick) > $wgMaxSigChars) {
         global $wgLang;
         $this->mainPrefsForm('error', wfMsgExt('badsiglength', 'parsemag', $wgLang->formatNum($wgMaxSigChars)));
         return;
     } elseif ($this->mToggles['fancysig']) {
         if ($wgParser->validateSig($this->mNick) !== false) {
             $this->mNick = $wgParser->cleanSig($this->mNick);
         } else {
             $this->mainPrefsForm('error', wfMsg('badsig'));
             return;
         }
     } else {
         // When no fancy sig used, make sure ~{3,5} get removed.
         $this->mNick = $wgParser->cleanSigInSig($this->mNick);
     }
     $wgUser->setOption('language', $this->mUserLanguage);
     $wgUser->setOption('variant', $this->mUserVariant);
     $wgUser->setOption('nickname', $this->mNick);
     $wgUser->setOption('quickbar', $this->mQuickbar);
     global $wgAllowUserSkin;
     if ($wgAllowUserSkin) {
         $wgUser->setOption('skin', $this->mSkin);
     }
     global $wgUseTeX;
     if ($wgUseTeX) {
         $wgUser->setOption('math', $this->mMath);
     }
     $wgUser->setOption('date', $this->validateDate($this->mDate));
     $wgUser->setOption('searchlimit', $this->validateIntOrNull($this->mSearch));
     $wgUser->setOption('contextlines', $this->validateIntOrNull($this->mSearchLines));
     $wgUser->setOption('contextchars', $this->validateIntOrNull($this->mSearchChars));
     $wgUser->setOption('rclimit', $this->validateIntOrNull($this->mRecent));
     $wgUser->setOption('rcdays', $this->validateInt($this->mRecentDays, 1, ceil($wgRCMaxAge / (3600 * 24))));
     $wgUser->setOption('wllimit', $this->validateIntOrNull($this->mWatchlistEdits, 0, 1000));
     $wgUser->setOption('rows', $this->validateInt($this->mRows, 4, 1000));
     $wgUser->setOption('cols', $this->validateInt($this->mCols, 4, 1000));
     $wgUser->setOption('stubthreshold', $this->validateIntOrNull($this->mStubs));
     $wgUser->setOption('timecorrection', $this->validateTimeZone($this->mTimeZone, $this->mHourDiff));
     $wgUser->setOption('imagesize', $this->mImageSize);
     $wgUser->setOption('thumbsize', $this->mThumbSize);
     $wgUser->setOption('underline', $this->validateInt($this->mUnderline, 0, 2));
     $wgUser->setOption('watchlistdays', $this->validateFloat($this->mWatchlistDays, 0, 7));
     $wgUser->setOption('disablesuggest', $this->mDisableMWSuggest);
     # Set search namespace options
     foreach ($this->mSearchNs as $i => $value) {
         $wgUser->setOption("searchNs{$i}", $value);
     }
     if ($wgEnableEmail && $wgEnableUserEmail) {
         $wgUser->setOption('disablemail', $this->mEmailFlag);
     }
     # Set user toggles
     foreach ($this->mToggles as $tname => $tvalue) {
         $wgUser->setOption($tname, $tvalue);
     }
     $error = false;
     if ($wgEnableEmail) {
         $newadr = $this->mUserEmail;
         $oldadr = $wgUser->getEmail();
         if ($newadr != '' && $newadr != $oldadr) {
             # the user has supplied a new email address on the login page
             if ($wgUser->isValidEmailAddr($newadr)) {
                 # new behaviour: set this new emailaddr from login-page into user database record
                 $wgUser->setEmail($newadr);
                 # but flag as "dirty" = unauthenticated
                 $wgUser->invalidateEmail();
                 if ($wgEmailAuthentication) {
                     # Mail a temporary password to the dirty address.
                     # User can come back through the confirmation URL to re-enable email.
                     $result = $wgUser->sendConfirmationMail();
                     if (WikiError::isError($result)) {
                         $error = wfMsg('mailerror', htmlspecialchars($result->getMessage()));
                     } else {
                         $error = wfMsg('eauthentsent', $wgUser->getName());
                     }
                 }
             } else {
                 $error = wfMsg('invalidemailaddress');
             }
         } else {
             if ($wgEmailConfirmToEdit && empty($newadr)) {
                 $this->mainPrefsForm('error', wfMsg('noemailtitle'));
                 return;
             }
             $wgUser->setEmail($this->mUserEmail);
         }
         if ($oldadr != $newadr) {
             wfRunHooks('PrefsEmailAudit', array($wgUser, $oldadr, $newadr));
         }
     }
     if (!$wgAuth->updateExternalDB($wgUser)) {
         $this->mainPrefsForm('error', wfMsg('externaldberror'));
         return;
     }
     $msg = '';
     if (!wfRunHooks('SavePreferences', array($this, $wgUser, &$msg, $oldOptions))) {
         $this->mainPrefsForm('error', $msg);
         return;
     }
     $wgUser->setCookies();
     $wgUser->saveSettings();
     if ($needRedirect && $error === false) {
         $title = SpecialPage::getTitleFor('Preferences');
         $wgOut->redirect($title->getFullURL('success'));
         return;
     }
     $wgOut->parserOptions(ParserOptions::newFromUser($wgUser));
     $this->mainPrefsForm($error === false ? 'success' : 'error', $error);
 }
Exemple #14
0
 /**
  * @private
  */
 function mailPassword()
 {
     global $wgUser, $wgOut, $wgAuth;
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return false;
     }
     if (!$wgAuth->allowPasswordChange()) {
         $this->mainLoginForm(wfMsg('resetpass_forbidden'));
         return;
     }
     # Check against blocked IPs so blocked users can't flood admins
     # with password resets
     if ($wgUser->isBlocked()) {
         $this->mainLoginForm(wfMsg('blocked-mailpassword'));
         return;
     }
     # Check for hooks
     $error = null;
     if (!wfRunHooks('UserLoginMailPassword', array($this->mName, &$error))) {
         $this->mainLoginForm($error);
         return;
     }
     # If the user doesn't have a login token yet, set one.
     if (!self::getLoginToken()) {
         self::setLoginToken();
         $this->mainLoginForm(wfMsg('sessionfailure'));
         return;
     }
     # If the user didn't pass a login token, tell them we need one
     if (!$this->mToken) {
         $this->mainLoginForm(wfMsg('sessionfailure'));
         return;
     }
     # Check against the rate limiter
     if ($wgUser->pingLimiter('mailpassword')) {
         $wgOut->rateLimited();
         return;
     }
     if ($this->mName == '') {
         $this->mainLoginForm(wfMsg('noname'));
         return;
     }
     $u = User::newFromName($this->mName);
     if (!$u instanceof User) {
         $this->mainLoginForm(wfMsg('noname'));
         return;
     }
     if (0 == $u->getID()) {
         $this->mainLoginForm(wfMsgWikiHtml('nosuchuser', htmlspecialchars($u->getName())));
         return;
     }
     # Validate the login token
     if ($this->mToken !== self::getLoginToken()) {
         $this->mainLoginForm(wfMsg('sessionfailure'));
         return;
     }
     # Check against password throttle
     if ($u->isPasswordReminderThrottled()) {
         global $wgPasswordReminderResendTime;
         # Round the time in hours to 3 d.p., in case someone is specifying
         # minutes or seconds.
         $this->mainLoginForm(wfMsgExt('throttled-mailpassword', array('parsemag'), round($wgPasswordReminderResendTime, 3)));
         return;
     }
     $result = $this->mailPasswordInternal($u, true, 'passwordremindertitle', 'passwordremindertext');
     if (WikiError::isError($result)) {
         $this->mainLoginForm(wfMsg('mailerror', $result->getMessage()));
     } else {
         $this->mainLoginForm(wfMsg('passwordsent', $u->getName()), 'success');
         self::clearLoginToken();
     }
 }
Exemple #15
0
 /**
  * @private
  */
 function mailPassword()
 {
     global $wgUser, $wgOut;
     # Check against the rate limiter
     if ($wgUser->pingLimiter('mailpassword')) {
         $wgOut->rateLimited();
         return;
     }
     if ('' == $this->mName) {
         $this->mainLoginForm(wfMsg('noname'));
         return;
     }
     $u = User::newFromName($this->mName);
     if (is_null($u)) {
         $this->mainLoginForm(wfMsg('noname'));
         return;
     }
     if (0 == $u->getID()) {
         $this->mainLoginForm(wfMsg('nosuchuser', $u->getName()));
         return;
     }
     $u->loadFromDatabase();
     $result = $this->mailPasswordInternal($u);
     if (WikiError::isError($result)) {
         $this->mainLoginForm(wfMsg('mailerror', $result->getMessage()));
     } else {
         $this->mainLoginForm(wfMsg('passwordsent', $u->getName()), 'success');
     }
 }
	/**
	 * Update some user's settings with value get from OpenID
	 *
	 * @param $user User object
	 * @param $sreg Array of options get from OpenID
	 * @param $force forces update regardless of user preferences
	 */
	function updateUser( $user, $sreg, $ax, $force = false ) {
		global $wgAllowRealName, $wgEmailAuthentication, $wgOpenIDTrustEmailAddress;

		// Nick name
		if ( $this->updateOption( 'nickname', $user, $force ) ) {
			if ( array_key_exists( 'nickname', $sreg ) && $sreg['nickname'] != $user->getOption( 'nickname' ) ) {
				$user->setOption( 'nickname', $sreg['nickname'] );
			}
		}

		// E-mail
		if ( $this->updateOption( 'email', $user, $force ) ) {
			// first check SREG, then AX; if both, AX takes higher priority
			if ( array_key_exists( 'email', $sreg ) ) {
				$email = $sreg['email'];
			}
			if ( array_key_exists ( 'http://axschema.org/contact/email', $ax ) ) {
				$email = $ax['http://axschema.org/contact/email'][0];
			}
			if ( $email ) {
				// If email changed, then email a confirmation mail
				if ( $email != $user->getEmail() ) {
					$user->setEmail( $email );
					if ( $wgOpenIDTrustEmailAddress ) {
						$user->confirmEmail();
					} else {
						$user->invalidateEmail();
						if ( $wgEmailAuthentication && $email != '' ) {
							$result = $user->sendConfirmationMail();
							if ( WikiError::isError( $result ) ) {
								$wgOut->addWikiMsg( 'mailerror', $result->getMessage() );
							}
						}
					}
				}
			}
		}

		// Full name
		if ( $wgAllowRealName && ( $this->updateOption( 'fullname', $user, $force ) ) ) {
			if ( array_key_exists( 'fullname', $sreg ) ) {
				$user->setRealName( $sreg['fullname'] );
			}

			if ( array_key_exists( 'http://axschema.org/namePerson/first', $ax ) || array_key_exists( 'http://axschema.org/namePerson/last', $ax ) ) {
				$user->setRealName( $ax['http://axschema.org/namePerson/first'][0] . " " . $ax['http://axschema.org/namePerson/last'][0] );
			}
		}

		// Language
		if ( $this->updateOption( 'language', $user, $force ) ) {
			if ( array_key_exists( 'language', $sreg ) ) {
				# FIXME: check and make sure the language exists
				$user->setOption( 'language', $sreg['language'] );
			}
		}

		if ( $this->updateOption( 'timezone', $user, $force ) ) {
			if ( array_key_exists( 'timezone', $sreg ) ) {
				# FIXME: do something with it.
				# $offset = OpenIDTimezoneToTzoffset($sreg['timezone']);
				# $user->setOption('timecorrection', $offset);
			}
		}

		$user->saveSettings();
	}
 /**
  * Edit user groups membership
  * @param string $username Name of the user.
  */
 function editUserGroupsForm($username)
 {
     global $wgOut, $wgUser;
     $split = $this->splitUsername($username);
     if (WikiError::isError($split)) {
         $wgOut->addWikiText(wfMsg('makesysop-nodatabase', $split->getMessage()));
         return;
     }
     list($database, $name) = $split;
     $this->db =& $this->getDB($database);
     $userid = $this->getUserId($database, $name);
     if ($userid == 0) {
         $wgOut->addWikiText(wfMsg('nosuchusershort', wfEscapeWikiText($username)));
         return;
     }
     $groups = $this->getUserGroups($database, $userid);
     $this->showEditUserGroupsForm($username, $groups);
 }
Exemple #18
0
/**
 * Constructor
 */
function wfSpecialImport($page = '')
{
    global $wgUser, $wgOut, $wgRequest, $wgTitle, $wgImportSources;
    global $wgImportTargetNamespace;
    $interwiki = false;
    $namespace = $wgImportTargetNamespace;
    $frompage = '';
    $history = true;
    if ($wgRequest->wasPosted() && $wgRequest->getVal('action') == 'submit') {
        $isUpload = false;
        $namespace = $wgRequest->getIntOrNull('namespace');
        switch ($wgRequest->getVal("source")) {
            case "upload":
                $isUpload = true;
                if ($wgUser->isAllowed('importupload')) {
                    $source = ImportStreamSource::newFromUpload("xmlimport");
                } else {
                    return $wgOut->permissionRequired('importupload');
                }
                break;
            case "interwiki":
                $interwiki = $wgRequest->getVal('interwiki');
                $history = $wgRequest->getCheck('interwikiHistory');
                $frompage = $wgRequest->getText("frompage");
                $source = ImportStreamSource::newFromInterwiki($interwiki, $frompage, $history);
                break;
            default:
                $source = new WikiErrorMsg("importunknownsource");
        }
        if (WikiError::isError($source)) {
            $wgOut->addWikiText(wfEscapeWikiText($source->getMessage()));
        } else {
            $wgOut->addWikiText(wfMsg("importstart"));
            $importer = new WikiImporter($source);
            if (!is_null($namespace)) {
                $importer->setTargetNamespace($namespace);
            }
            $reporter = new ImportReporter($importer, $isUpload, $interwiki);
            $reporter->open();
            $result = $importer->doImport();
            $reporter->close();
            if (WikiError::isError($result)) {
                $wgOut->addWikiText(wfMsg("importfailed", wfEscapeWikiText($result->getMessage())));
            } else {
                # Success!
                $wgOut->addWikiText(wfMsg("importsuccess"));
            }
        }
    }
    $action = $wgTitle->escapeLocalUrl('action=submit');
    if ($wgUser->isAllowed('importupload')) {
        $wgOut->addWikiText(wfMsg("importtext"));
        $wgOut->addHTML("\n<fieldset>\n\t<legend>" . wfMsgHtml('upload') . "</legend>\n\t<form enctype='multipart/form-data' method='post' action=\"{$action}\">\n\t\t<input type='hidden' name='action' value='submit' />\n\t\t<input type='hidden' name='source' value='upload' />\n\t\t<input type='hidden' name='MAX_FILE_SIZE' value='2000000' />\n\t\t<input type='file' name='xmlimport' value='' size='30' />\n\t\t<input type='submit' value=\"" . wfMsgHtml("uploadbtn") . "\" />\n\t</form>\n</fieldset>\n");
    } else {
        if (empty($wgImportSources)) {
            $wgOut->addWikiText(wfMsg('importnosources'));
        }
    }
    if (!empty($wgImportSources)) {
        $wgOut->addHTML("\n<fieldset>\n\t<legend>" . wfMsgHtml('importinterwiki') . "</legend>\n\t<form method='post' action=\"{$action}\">" . $wgOut->parse(wfMsg('import-interwiki-text')) . "\n\t\t<input type='hidden' name='action' value='submit' />\n\t\t<input type='hidden' name='source' value='interwiki' />\n\t\t<table>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<select name='interwiki'>");
        foreach ($wgImportSources as $prefix) {
            $iw = htmlspecialchars($prefix);
            $selected = $interwiki === $prefix ? ' selected="selected"' : '';
            $wgOut->addHTML("<option value=\"{$iw}\"{$selected}>{$iw}</option>\n");
        }
        $wgOut->addHTML("\n\t\t\t\t\t</select>\n\t\t\t\t</td>\n\t\t\t\t<td>" . wfInput('frompage', 50, $frompage) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td>" . wfCheckLabel(wfMsg('import-interwiki-history'), 'interwikiHistory', 'interwikiHistory', $history) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td>\n\t\t\t\t\t" . wfMsgHtml('import-interwiki-namespace') . " " . HTMLnamespaceselector($namespace, '') . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td>" . wfSubmitButton(wfMsg('import-interwiki-submit')) . "</td>\n\t\t\t</tr>\n\t\t</table>\n\t</form>\n</fieldset>\n");
    }
}
Exemple #19
0
 static function tryFormSubmit($formData, $entryPoint = 'internal')
 {
     global $wgUser, $wgEmailAuthentication, $wgEnableEmail;
     $result = true;
     // Filter input
     foreach (array_keys($formData) as $name) {
         if (isset(self::$saveFilters[$name])) {
             $formData[$name] = call_user_func(self::$saveFilters[$name], $formData[$name], $formData);
         }
     }
     // Stuff that shouldn't be saved as a preference.
     $saveBlacklist = array('realname', 'emailaddress');
     if ($wgEnableEmail) {
         $newadr = $formData['emailaddress'];
         $oldadr = $wgUser->getEmail();
         if ($newadr != '' && $newadr != $oldadr) {
             # the user has supplied a new email address on the login page
             # new behaviour: set this new emailaddr from login-page into user database record
             $wgUser->setEmail($newadr);
             # but flag as "dirty" = unauthenticated
             $wgUser->invalidateEmail();
             if ($wgEmailAuthentication) {
                 # Mail a temporary password to the dirty address.
                 # User can come back through the confirmation URL to re-enable email.
                 $result = $wgUser->sendConfirmationMail();
                 if (WikiError::isError($result)) {
                     return wfMsg('mailerror', htmlspecialchars($result->getMessage()));
                 } elseif ($entryPoint == 'ui') {
                     $result = 'eauth';
                 }
             }
         } else {
             $wgUser->setEmail($newadr);
         }
         if ($oldadr != $newadr) {
             wfRunHooks('PrefsEmailAudit', array($wgUser, $oldadr, $newadr));
         }
     }
     // Fortunately, the realname field is MUCH simpler
     global $wgHiddenPrefs;
     if (!in_array('realname', $wgHiddenPrefs)) {
         $realName = $formData['realname'];
         $wgUser->setRealName($realName);
     }
     foreach ($saveBlacklist as $b) {
         unset($formData[$b]);
     }
     //  Keeps old preferences from interfering due to back-compat
     //  code, etc.
     $wgUser->resetOptions();
     foreach ($formData as $key => $value) {
         $wgUser->setOption($key, $value);
     }
     $wgUser->saveSettings();
     return $result;
 }
 function processUpload()
 {
     global $wgUser, $wgOut, $wgFileExtensions, $wgScriptPath;
     $details = null;
     $value = null;
     global $mvMediaFilesTable, $mvStreamFilesTable, $wgRequest;
     $stream_id = $wgRequest->getVal('stream_id');
     $file_desc_msg = $wgRequest->getVal('file_desc_msg');
     $newStream = MV_Stream::newStreamByID($stream_id);
     $files = $newStream->getFileList();
     $doAdd = true;
     foreach ($files as $sf) {
         if ($sf->file_desc_msg == $file_desc_msg) {
             $doAdd = false;
         }
     }
     if (!$doAdd) {
         $value = 99;
     } else {
         $value = $this->internalProcessUpload($details);
     }
     switch ($value) {
         case self::SUCCESS:
             $html = 'File has been uploaded successfully<br/>';
             $file = '' . $this->mLocalFile->getPath();
             if (file_exists($file)) {
                 $f = fopen($file, "rb");
                 $header = fread($f, 512);
                 $page['serial'] = substr($header, 14, 4);
                 $page['segments'] = ord($header[26]);
                 $page['rate'] = ord($header[27 + $page['segments'] + 15]);
                 $page['rate'] = $page['rate'] << 8 | ord($header[27 + $page['segments'] + 14]);
                 $page['rate'] = $page['rate'] << 8 | ord($header[27 + $page['segments'] + 13]);
                 $page['rate'] = $page['rate'] << 8 | ord($header[27 + $page['segments'] + 12]);
                 fseek($f, -6000, SEEK_END);
                 $end = fread($f, 6000);
                 $tail = strstr($end, "OggS");
                 if ($tail) {
                     $serial = substr($tail, 14, 4);
                     if ($serial == $page['serial']) {
                         $duration = 103;
                         $granulepos = ord($tail[6]);
                         $granulepos = $granulepos | ord($tail[7]) << 8;
                         $granulepos = $granulepos | ord($tail[8]) << 16;
                         $granulepos = $granulepos | ord($tail[9]) << 24;
                         $granulepos = $granulepos | ord($tail[10]) << 32;
                         $granulepos = $granulepos | ord($tail[11]) << 40;
                         $granulepos = $granulepos | ord($tail[12]) << 48;
                         $granulepos = $granulepos | ord($tail[13]) << 56;
                         $duration = $granulepos / $page['rate'];
                     }
                 }
                 fclose($f);
             }
             $dbr =& wfGetDB(DB_WRITE);
             $text = '' . $wgScriptPath . '/images/' . $this->mLocalFile->getUrlRel();
             if ($duration === null) {
                 $duration = 0;
             }
             if ($dbr->insert($mvMediaFilesTable, array('path' => $text, 'duration' => $duration, 'file_desc_msg' => $file_desc_msg), __METHOD__)) {
                 $result = $dbr->query("SELECT LAST_INSERT_ID() AS id");
                 $row = $dbr->fetchObject($result);
                 $id = $row->id;
                 if ($dbr->insert($mvStreamFilesTable, array('file_id' => $id, 'stream_id' => $stream_id), __METHOD__)) {
                     $stream_name = MV_Stream::getStreamNameFromId($stream_id);
                     $title = Title::newFromText($stream_name, MV_NS_STREAM);
                     $wgOut->redirect($title->getLocalURL("action=edit"));
                 } else {
                     $html .= 'Inserting file path into DB failed, Please notify the Administrator immediately';
                 }
             } else {
                 $html .= 'Inserting file path into DB failed, Please notify the Administrator immediately';
             }
             /*
             				
             				if ($dbr->insert($mvStreamFilesTable, array('stream_id'=>$stream_id))) {
             					$result = $dbr->query("SELECT LAST_INSERT_ID()");
             					$row = $dbr->fetchObject($result);
             					if ($duration===null)$duration=0;
             					if ($dbr->insert($mvMediaFilesTable, array('id'=>$row->id,'path'=>$text,'duration'=>$duration))) {
             					
             						//$html .='<input type="button" name="Close" value="Close" Onclick="window.opener.document.getElementById(\'path\').value=\''.$wgScriptPath.'/images/'.$this->mLocalFile->getUrlRel().'\'; window.opener.document.getElementById(\'duration\').value='.floor($duration).'; window.close()"></input>' ;
             						$stream_name = MV_Stream::getStreamNameFromId($stream_id);
             						$title = Title::newFromText( $stream_name, MV_NS_STREAM  );
             						$wgOut->redirect($title->getLocalURL("action=edit"));	
             						
             					}
             					else {
             						$html .= 'Inserting file path into DB failed, Please notify the Administrator immediately';
             					}
             				} else {
             				$html .= 'Inserting file path into DB failed, Please notify the Administrator immediately';
             				}
             */
             $wgOut->addHTML($html);
             break;
         case self::BEFORE_PROCESSING:
             break;
         case self::LARGE_FILE_SERVER:
             $this->mainUploadForm(wfMsgHtml('largefileserver'));
             break;
         case self::EMPTY_FILE:
             $this->mainUploadForm(wfMsgHtml('emptyfile'));
             break;
         case self::MIN_LENGHT_PARTNAME:
             $this->mainUploadForm(wfMsgHtml('minlength1'));
             break;
         case self::ILLEGAL_FILENAME:
             $filtered = $details['filtered'];
             $this->uploadError(wfMsgWikiHtml('illegalfilename', htmlspecialchars($filtered)));
             break;
         case self::PROTECTED_PAGE:
             $this->uploadError(wfMsgWikiHtml('protectedpage'));
             break;
         case self::OVERWRITE_EXISTING_FILE:
             $errorText = $details['overwrite'];
             $overwrite = new WikiError($wgOut->parse($errorText));
             $this->uploadError($overwrite->toString());
             break;
         case self::FILETYPE_MISSING:
             $this->uploadError(wfMsgExt('filetype-missing', array('parseinline')));
             break;
         case self::FILETYPE_BADTYPE:
             $finalExt = $details['finalExt'];
             $this->uploadError(wfMsgExt('filetype-banned-type', array('parseinline'), htmlspecialchars($finalExt), implode(wfMsgExt('comma-separator', array('escapenoentities')), $wgFileExtensions)));
             break;
         case self::VERIFICATION_ERROR:
             $veri = $details['veri'];
             $this->uploadError($veri->toString());
             break;
         case self::UPLOAD_VERIFICATION_ERROR:
             $error = $details['error'];
             $this->uploadError($error);
             break;
         case self::UPLOAD_WARNING:
             $warning = $details['warning'];
             $this->uploadWarning($warning);
             break;
         case self::INTERNAL_ERROR:
             $internal = $details['internal'];
             $this->showError($internal);
             break;
         case 99:
             $this->mainUploadForm('Type ' . $file_desc_msg . ' already exists');
             break;
         default:
             throw new MWException(__METHOD__ . ": Unknown value `{$value}`");
     }
 }
     if ($image->exists()) {
         if (isset($options['overwrite'])) {
             echo "{$base} exists, overwriting...";
             $svar = 'overwritten';
         } else {
             echo "{$base} exists, skipping\n";
             $skipped++;
             continue;
         }
     } else {
         echo "Importing {$base}...";
         $svar = 'added';
     }
     # Import the file
     $archive = $image->publish($file);
     if (WikiError::isError($archive) || !$archive->isGood()) {
         echo "failed.\n";
         continue;
     }
     ${$svar}++;
     if ($image->recordUpload($archive->value, $comment, $license)) {
         # We're done!
         echo "done.\n";
     } else {
         echo "failed.\n";
     }
 }
 # Print out some statistics
 echo "\n";
 foreach (array('count' => 'Found', 'added' => 'Added', 'skipped' => 'Skipped', 'overwritten' => 'Overwritten') as $var => $desc) {
     if (${$var} > 0) {
	/**
	 * import xml data either into local or remote wiki, depending on self::$directionToLocal value
	 */
	static function importXML( $dstImportToken, $xmldata ) {
		global $wgUser, $wgTmpDirectory;
		// {{{ bugfixes
		global $wgSMTP;
//		global $wgMaxArticleSize, $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth;
		global $wgEnableEmail, $wgEnableUserEmail;
		// }}}
		list( $fname, $fp ) = self::tempnam_sfx( $wgTmpDirectory . '/', '.xml' );
		$flen = strlen( $xmldata );
		if ( @fwrite( $fp, $xmldata, $flen ) !== $flen ) {
			throw new MWException( 'Cannot write xmldata to file ' . $fname . ' in ' . __METHOD__ . ' disk full?' );
		}
		fclose( $fp );
		if ( self::$directionToLocal ) {
			# suppress "pear mail" possible smtp fatal errors
			# in EmailNotification::actuallyNotifyOnPageChange()
			$wgSMTP = false;
			$wgEnableEmail = false;
			$wgEnableUserEmail = false;
			/*
			if ( $wgMaxArticleSize < 8192 ) {
				$wgMaxArticleSize = 8192;
			}
			*/
			$json_result = new WikiSyncJSONresult( false );
			$json_result->setCode( 'import' );
			if( !$wgUser->isAllowed( 'importupload' ) ) {
				@unlink( $fname );
				return $json_result->getResult( 'no_import_rights' );
			}
			$source = ImportStreamSource::newFromFile( $fname );
			$err_msg = null;
			if ( $source instanceof Status ) {
				if ( $source->isOK() ) {
					$source = $source->value;
				} else {
					$err_msg = $source->getWikiText();
				}
			} elseif ( $source instanceof WikiErrorMsg || WikiError::isError( $source ) ) {
				$err_msg = $source->getMessage();
			}
			if ( $err_msg !== null ) {
				@unlink( $fname );
				return $json_result->getResult( 'import',  $err_msg );
			}
			$importer = new WikiImporter( $source );
			$reporter = new WikiSyncImportReporter( $importer, false, '', wfMsg( 'wikisync_log_imported_by' ) );
			$result = $importer->doImport();
			@fclose( $source->mHandle );
			if ( !WikiSyncSetup::$debug_mode ) {
				@unlink( $fname );
			}
			if ( $result instanceof WikiXmlError ) {
				$r =
					array(
						'line' => $result->mLine,
						'column' => $result->mColumn,
						'context' => $result->mByte . $result->mContext,
						'xmlerror' => xml_error_string( $result->mXmlError )
					);
				$json_result->append( $r );
				return $json_result->getResult( 'import', $result->getMessage() );
			} elseif ( WikiError::isError( $result ) ) {
				return $json_result->getResult( 'import', $source->getMessage() );
			}
			$resultData = $reporter->getData();
			$json_result->setStatus( '1' ); // API success
			return $json_result->getResult();
		} else {
			$APIparams = array(
				'action' => 'syncimport',
				'format' => 'json',
				'token' => $dstImportToken,
			);
			$APIfiles = array(
				'xml'=>$fname
			);
			// will POST 'multipart/form-data', because $APIfiles are defined
			$jr = self::remoteAPIget( self::$remoteContextJSON, $APIparams, $APIfiles, self::RESULT_JSON_ARRAY );
			@unlink( $fname );
			return $jr;
		}
	}
Exemple #23
0
 /**
  * Do the actual import
  */
 private function doImport()
 {
     global $wgOut, $wgRequest, $wgUser, $wgImportSources, $wgExportMaxLinkDepth;
     $isUpload = false;
     $this->namespace = $wgRequest->getIntOrNull('namespace');
     $sourceName = $wgRequest->getVal("source");
     $this->logcomment = $wgRequest->getText('log-comment');
     $this->pageLinkDepth = $wgExportMaxLinkDepth == 0 ? 0 : $wgRequest->getIntOrNull('pagelink-depth');
     if (!$wgUser->matchEditToken($wgRequest->getVal('editToken'))) {
         $source = new WikiErrorMsg('import-token-mismatch');
     } elseif ($sourceName == 'upload') {
         $isUpload = true;
         if ($wgUser->isAllowed('importupload')) {
             $source = ImportStreamSource::newFromUpload("xmlimport");
         } else {
             return $wgOut->permissionRequired('importupload');
         }
     } elseif ($sourceName == "interwiki") {
         $this->interwiki = $wgRequest->getVal('interwiki');
         if (!in_array($this->interwiki, $wgImportSources)) {
             $source = new WikiErrorMsg("import-invalid-interwiki");
         } else {
             $this->history = $wgRequest->getCheck('interwikiHistory');
             $this->frompage = $wgRequest->getText("frompage");
             $this->includeTemplates = $wgRequest->getCheck('interwikiTemplates');
             $source = ImportStreamSource::newFromInterwiki($this->interwiki, $this->frompage, $this->history, $this->includeTemplates, $this->pageLinkDepth);
         }
     } else {
         $source = new WikiErrorMsg("importunknownsource");
     }
     if (WikiError::isError($source)) {
         $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $source->getMessage()));
     } else {
         $wgOut->addWikiMsg("importstart");
         $importer = new WikiImporter($source);
         if (!is_null($this->namespace)) {
             $importer->setTargetNamespace($this->namespace);
         }
         $reporter = new ImportReporter($importer, $isUpload, $this->interwiki, $this->logcomment);
         $reporter->open();
         $result = $importer->doImport();
         $resultCount = $reporter->close();
         if (WikiError::isError($result)) {
             # No source or XML parse error
             $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $result->getMessage()));
         } elseif (WikiError::isError($resultCount)) {
             # Zero revisions
             $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $resultCount->getMessage()));
         } else {
             # Success!
             $wgOut->addWikiMsg('importsuccess');
         }
         $wgOut->addWikiText('<hr />');
     }
 }
/**
 * Constructor
 */
function wfSpecialImport($page = '')
{
    global $wgUser, $wgOut, $wgRequest, $wgTitle, $wgImportSources;
    global $wgImportTargetNamespace;
    $interwiki = false;
    $namespace = $wgImportTargetNamespace;
    $frompage = '';
    $history = true;
    if (wfReadOnly()) {
        $wgOut->readOnlyPage();
        return;
    }
    if ($wgRequest->wasPosted() && $wgRequest->getVal('action') == 'submit') {
        $isUpload = false;
        $namespace = $wgRequest->getIntOrNull('namespace');
        switch ($wgRequest->getVal("source")) {
            case "upload":
                $isUpload = true;
                if ($wgUser->isAllowed('importupload')) {
                    $source = ImportStreamSource::newFromUpload("xmlimport");
                } else {
                    return $wgOut->permissionRequired('importupload');
                }
                break;
            case "interwiki":
                $interwiki = $wgRequest->getVal('interwiki');
                $history = $wgRequest->getCheck('interwikiHistory');
                $frompage = $wgRequest->getText("frompage");
                $source = ImportStreamSource::newFromInterwiki($interwiki, $frompage, $history);
                break;
            default:
                $source = new WikiErrorMsg("importunknownsource");
        }
        if (WikiError::isError($source)) {
            $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $source->getMessage()));
        } else {
            $wgOut->addWikiMsg("importstart");
            $importer = new WikiImporter($source);
            if (!is_null($namespace)) {
                $importer->setTargetNamespace($namespace);
            }
            $reporter = new ImportReporter($importer, $isUpload, $interwiki);
            $reporter->open();
            $result = $importer->doImport();
            $resultCount = $reporter->close();
            if (WikiError::isError($result)) {
                # No source or XML parse error
                $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $result->getMessage()));
            } elseif (WikiError::isError($resultCount)) {
                # Zero revisions
                $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $resultCount->getMessage()));
            } else {
                # Success!
                $wgOut->addWikiMsg('importsuccess');
            }
            $wgOut->addWikiText('<hr />');
        }
    }
    $action = $wgTitle->getLocalUrl('action=submit');
    if ($wgUser->isAllowed('importupload')) {
        $wgOut->addWikiMsg("importtext");
        $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('upload')) . Xml::openElement('form', array('enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action)) . Xml::hidden('action', 'submit') . Xml::hidden('source', 'upload') . "<input type='file' name='xmlimport' value='' size='30' />" . Xml::submitButton(wfMsg('uploadbtn')) . Xml::closeElement('form') . Xml::closeElement('fieldset'));
    } else {
        if (empty($wgImportSources)) {
            $wgOut->addWikiMsg('importnosources');
        }
    }
    if (!empty($wgImportSources)) {
        $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('importinterwiki')) . Xml::openElement('form', array('method' => 'post', 'action' => $action)) . wfMsgExt('import-interwiki-text', array('parse')) . Xml::hidden('action', 'submit') . Xml::hidden('source', 'interwiki') . Xml::openElement('table') . "<tr>\n\t\t\t\t<td>" . Xml::openElement('select', array('name' => 'interwiki')));
        foreach ($wgImportSources as $prefix) {
            $selected = $interwiki === $prefix ? ' selected="selected"' : '';
            $wgOut->addHTML(Xml::option($prefix, $prefix, $selected));
        }
        $wgOut->addHTML(Xml::closeElement('select') . "</td>\n\t\t\t\t<td>" . Xml::input('frompage', 50, $frompage) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t</td>\n\t\t\t\t<td>" . Xml::checkLabel(wfMsg('import-interwiki-history'), 'interwikiHistory', 'interwikiHistory', $history) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t</td>\n\t\t\t\t<td>" . Xml::label(wfMsg('import-interwiki-namespace'), 'namespace') . Xml::namespaceSelector($namespace, '') . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t</td>\n\t\t\t\t<td>" . Xml::submitButton(wfMsg('import-interwiki-submit')) . "</td>\n\t\t\t</tr>" . Xml::closeElement('table') . Xml::closeElement('form') . Xml::closeElement('fieldset'));
    }
}
 /**
  * @private
  */
 function mailPassword()
 {
     global $wgUser, $wgOut, $wgAuth;
     if (!$wgAuth->allowPasswordChange()) {
         $this->mainLoginForm(wfMsg('resetpass_forbidden'));
         return;
     }
     # Check against blocked IPs
     # fixme -- should we not?
     if ($wgUser->isBlocked()) {
         $this->mainLoginForm(wfMsg('blocked-mailpassword'));
         return;
     }
     # Check against the rate limiter
     if ($wgUser->pingLimiter('mailpassword')) {
         $wgOut->rateLimited();
         return;
     }
     if ('' == $this->mName) {
         $this->mainLoginForm(wfMsg('noname'));
         return;
     }
     $u = User::newFromName($this->mName);
     if (is_null($u)) {
         $this->mainLoginForm(wfMsg('noname'));
         return;
     }
     if (0 == $u->getID()) {
         $this->mainLoginForm(wfMsg('nosuchuser', $u->getName()));
         return;
     }
     # Check against password throttle
     if ($u->isPasswordReminderThrottled()) {
         global $wgPasswordReminderResendTime;
         # Round the time in hours to 3 d.p., in case someone is specifying minutes or seconds.
         $this->mainLoginForm(wfMsg('throttled-mailpassword', round($wgPasswordReminderResendTime, 3)));
         return;
     }
     $result = $this->mailPasswordInternal($u, true);
     if (WikiError::isError($result)) {
         $this->mainLoginForm(wfMsg('mailerror', $result->getMessage()));
     } else {
         $this->mainLoginForm(wfMsg('passwordsent', $u->getName()), 'success');
     }
 }
Exemple #26
0
 function doSubmit()
 {
     global $wgOut, $wgUser, $wgUserEmailUseReplyTo;
     $to = new MailAddress($this->target);
     $from = new MailAddress($wgUser);
     $subject = $this->subject;
     if (wfRunHooks('EmailUser', array(&$to, &$from, &$subject, &$this->text))) {
         if ($wgUserEmailUseReplyTo) {
             // Put the generic wiki autogenerated address in the From:
             // header and reserve the user for Reply-To.
             //
             // This is a bit ugly, but will serve to differentiate
             // wiki-borne mails from direct mails and protects against
             // SPF and bounce problems with some mailers (see below).
             global $wgPasswordSender;
             $mailFrom = new MailAddress($wgPasswordSender);
             $replyTo = $from;
         } else {
             // Put the sending user's e-mail address in the From: header.
             //
             // This is clean-looking and convenient, but has issues.
             // One is that it doesn't as clearly differentiate the wiki mail
             // from "directly" sent mails.
             //
             // Another is that some mailers (like sSMTP) will use the From
             // address as the envelope sender as well. For open sites this
             // can cause mails to be flunked for SPF violations (since the
             // wiki server isn't an authorized sender for various users'
             // domains) as well as creating a privacy issue as bounces
             // containing the recipient's e-mail address may get sent to
             // the sending user.
             $mailFrom = $from;
             $replyTo = null;
         }
         $mailResult = UserMailer::send($to, $mailFrom, $subject, $this->text, $replyTo);
         if (WikiError::isError($mailResult)) {
             $wgOut->addHTML(wfMsg("usermailererror") . ' ' . htmlspecialchars($mailResult->getMessage()));
         } else {
             // if the user requested a copy of this mail, do this now,
             // unless they are emailing themselves, in which case one copy of the message is sufficient.
             if ($this->cc_me && $to != $from) {
                 $cc_subject = wfMsg('emailccsubject', $this->target->getName(), $subject);
                 if (wfRunHooks('EmailUser', array(&$from, &$from, &$cc_subject, &$this->text))) {
                     $ccResult = UserMailer::send($from, $from, $cc_subject, $this->text);
                     if (WikiError::isError($ccResult)) {
                         // At this stage, the user's CC mail has failed, but their
                         // original mail has succeeded. It's unlikely, but still, what to do?
                         // We can either show them an error, or we can say everything was fine,
                         // or we can say we sort of failed AND sort of succeeded. Of these options,
                         // simply saying there was an error is probably best.
                         $wgOut->addHTML(wfMsg("usermailererror") . ' ' . htmlspecialchars($ccResult->getMessage()));
                         return;
                     }
                 }
             }
             $titleObj = SpecialPage::getTitleFor("Emailuser");
             $encTarget = wfUrlencode($this->target->getName());
             $wgOut->redirect($titleObj->getFullURL("target={$encTarget}&action=success"));
             wfRunHooks('EmailUserComplete', array($to, $from, $subject, $this->text));
         }
     }
 }
 /**
  * @access private
  */
 function savePreferences()
 {
     global $wgUser, $wgOut, $wgParser;
     global $wgEnableUserEmail, $wgEnableEmail;
     global $wgEmailAuthentication, $wgMinimalPasswordLength;
     global $wgAuth;
     if ('' != $this->mNewpass && $wgAuth->allowPasswordChange()) {
         if ($this->mNewpass != $this->mRetypePass) {
             $this->mainPrefsForm('error', wfMsg('badretype'));
             return;
         }
         if (strlen($this->mNewpass) < $wgMinimalPasswordLength) {
             $this->mainPrefsForm('error', wfMsg('passwordtooshort', $wgMinimalPasswordLength));
             return;
         }
         if (!$wgUser->checkPassword($this->mOldpass)) {
             $this->mainPrefsForm('error', wfMsg('wrongpassword'));
             return;
         }
         if (!$wgAuth->setPassword($wgUser, $this->mNewpass)) {
             $this->mainPrefsForm('error', wfMsg('externaldberror'));
             return;
         }
         $wgUser->setPassword($this->mNewpass);
         $this->mNewpass = $this->mOldpass = $this->mRetypePass = '';
     }
     $wgUser->setRealName($this->mRealName);
     if ($wgUser->getOption('language') !== $this->mUserLanguage) {
         $needRedirect = true;
     } else {
         $needRedirect = false;
     }
     # Validate the signature and clean it up as needed
     if ($this->mToggles['fancysig']) {
         if (Parser::validateSig($this->mNick) !== false) {
             $this->mNick = $wgParser->cleanSig($this->mNick);
         } else {
             $this->mainPrefsForm('error', wfMsg('badsig'));
         }
     } else {
         // When no fancy sig used, make sure ~{3,5} get removed.
         $this->mNick = $wgParser->cleanSigInSig($this->mNick);
     }
     $wgUser->setOption('language', $this->mUserLanguage);
     $wgUser->setOption('variant', $this->mUserVariant);
     $wgUser->setOption('nickname', $this->mNick);
     $wgUser->setOption('quickbar', $this->mQuickbar);
     $wgUser->setOption('skin', $this->mSkin);
     global $wgUseTeX;
     if ($wgUseTeX) {
         $wgUser->setOption('math', $this->mMath);
     }
     $wgUser->setOption('date', $this->validateDate($this->mDate, 0, 20));
     // WERELATE removed
     //		$wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) );
     //		$wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) );
     //		$wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) );
     $wgUser->setOption('rclimit', $this->validateIntOrNull($this->mRecent));
     $wgUser->setOption('wllimit', $this->validateIntOrNull($this->mWatchlistEdits, 0, 1000));
     $wgUser->setOption('rows', $this->validateInt($this->mRows, 4, 1000));
     $wgUser->setOption('cols', $this->validateInt($this->mCols, 4, 1000));
     $wgUser->setOption('stubthreshold', $this->validateIntOrNull($this->mStubs));
     $wgUser->setOption('timecorrection', $this->validateTimeZone($this->mHourDiff, -12, 14));
     $wgUser->setOption('imagesize', $this->mImageSize);
     $wgUser->setOption('thumbsize', $this->mThumbSize);
     $wgUser->setOption('underline', $this->validateInt($this->mUnderline, 0, 2));
     $wgUser->setOption('watchlistdays', $this->validateFloat($this->mWatchlistDays, 0, 7));
     # Set search namespace options
     // WERELATE removed
     //		foreach( $this->mSearchNs as $i => $value ) {
     //			$wgUser->setOption( "searchNs{$i}", $value );
     //		}
     if ($wgEnableEmail && $wgEnableUserEmail) {
         $wgUser->setOption('disablemail', $this->mEmailFlag);
     }
     # Set user toggles
     foreach ($this->mToggles as $tname => $tvalue) {
         $wgUser->setOption($tname, $tvalue);
     }
     if (!$wgAuth->updateExternalDB($wgUser)) {
         $this->mainPrefsForm(wfMsg('externaldberror'));
         return;
     }
     $wgUser->setCookies();
     $wgUser->saveSettings();
     $error = false;
     if ($wgEnableEmail) {
         $newadr = $this->mUserEmail;
         $oldadr = $wgUser->getEmail();
         if ($newadr != '' && $newadr != $oldadr) {
             # the user has supplied a new email address on the login page
             if ($wgUser->isValidEmailAddr($newadr)) {
                 $wgUser->mEmail = $newadr;
                 # new behaviour: set this new emailaddr from login-page into user database record
                 $wgUser->mEmailAuthenticated = null;
                 # but flag as "dirty" = unauthenticated
                 $wgUser->saveSettings();
                 if ($wgEmailAuthentication) {
                     # Mail a temporary password to the dirty address.
                     # User can come back through the confirmation URL to re-enable email.
                     $result = $wgUser->sendConfirmationMail();
                     if (WikiError::isError($result)) {
                         $error = wfMsg('mailerror', htmlspecialchars($result->getMessage()));
                     } else {
                         $error = wfMsg('eauthentsent', $wgUser->getName());
                     }
                 }
             } else {
                 $error = wfMsg('invalidemailaddress');
             }
         } else {
             $wgUser->setEmail($this->mUserEmail);
             $wgUser->setCookies();
             $wgUser->saveSettings();
         }
     }
     if ($needRedirect && $error === false) {
         $title =& Title::makeTitle(NS_SPECIAL, "Preferences");
         $wgOut->redirect($title->getFullURL('success'));
         return;
     }
     $wgOut->setParserOptions(ParserOptions::newFromUser($wgUser));
     $po = ParserOptions::newFromUser($wgUser);
     $this->mainPrefsForm($error === false ? 'success' : 'error', $error);
 }
 function doSubmit()
 {
     global $wgOut, $wgUser;
     $to = new MailAddress($this->target);
     $from = new MailAddress($wgUser);
     $subject = $this->subject;
     if (wfRunHooks('EmailUser', array(&$to, &$from, &$subject, &$this->text))) {
         $mailResult = userMailer($to, $from, $subject, $this->text);
         if (WikiError::isError($mailResult)) {
             $wgOut->addHTML(wfMsg("usermailererror") . $mailResult);
         } else {
             // if the user requested a copy of this mail, do this now,
             // unless they are emailing themselves, in which case one copy of the message is sufficient.
             if ($this->cc_me && $to != $from) {
                 $cc_subject = wfMsg('emailccsubject', $this->target->getName(), $subject);
                 if (wfRunHooks('EmailUser', array(&$from, &$from, &$cc_subject, &$this->text))) {
                     $ccResult = userMailer($from, $from, $cc_subject, $this->text);
                     if (WikiError::isError($ccResult)) {
                         // At this stage, the user's CC mail has failed, but their
                         // original mail has succeeded. It's unlikely, but still, what to do?
                         // We can either show them an error, or we can say everything was fine,
                         // or we can say we sort of failed AND sort of succeeded. Of these options,
                         // simply saying there was an error is probably best.
                         $wgOut->addHTML(wfMsg("usermailererror") . $ccResult);
                         return;
                     }
                 }
             }
             $titleObj = SpecialPage::getTitleFor("Emailuser");
             $encTarget = wfUrlencode($this->target->getName());
             $wgOut->redirect($titleObj->getFullURL("target={$encTarget}&action=success"));
             wfRunHooks('EmailUserComplete', array($to, $from, $subject, $this->text));
         }
     }
 }
Exemple #29
0
 /**
  * Really do the upload
  * Checks are made in SpecialUpload::execute()
  * @access private
  */
 function processUpload()
 {
     global $wgUser, $wgOut;
     /* Check for PHP error if any, requires php 4.2 or newer */
     if ($this->mUploadError == 1) {
         $this->mainUploadForm(wfMsgHtml('largefileserver'));
         return;
     }
     /**
      * If there was no filename or a zero size given, give up quick.
      */
     if (trim($this->mOname) == '' || empty($this->mUploadSize)) {
         $this->mainUploadForm(wfMsgHtml('emptyfile'));
         return;
     }
     # Chop off any directories in the given filename
     if ($this->mDestFile) {
         $basename = wfBaseName($this->mDestFile);
     } else {
         $basename = wfBaseName($this->mOname);
     }
     /**
      * We'll want to blacklist against *any* 'extension', and use
      * only the final one for the whitelist.
      */
     list($partname, $ext) = $this->splitExtensions($basename);
     if (count($ext)) {
         $finalExt = $ext[count($ext) - 1];
     } else {
         $finalExt = '';
     }
     $fullExt = implode('.', $ext);
     # If there was more than one "extension", reassemble the base
     # filename to prevent bogus complaints about length
     if (count($ext) > 1) {
         for ($i = 0; $i < count($ext) - 1; $i++) {
             $partname .= '.' . $ext[$i];
         }
     }
     if (strlen($partname) < 3) {
         $this->mainUploadForm(wfMsgHtml('minlength'));
         return;
     }
     // WERELATE - added validation tests
     if (!$this->mLicense && !$this->mReUploading) {
         $this->uploadError("You must select a license (press the \"back button\" on your browser to correct this)");
         return;
     }
     /**
      * Filter out illegal characters, and try to make a legible name
      * out of it. We'll strip some silently that Title would die on.
      */
     $filtered = preg_replace("/[^" . Title::legalChars() . "]|:/", '-', $basename);
     $nt = Title::newFromText($filtered);
     if (is_null($nt)) {
         $this->uploadError(wfMsgWikiHtml('illegalfilename', htmlspecialchars($filtered)));
         return;
     }
     $nt =& Title::makeTitle(NS_IMAGE, $nt->getDBkey());
     $this->mUploadSaveName = $nt->getDBkey();
     /**
      * If the image is protected, non-sysop users won't be able
      * to modify it by uploading a new revision.
      */
     if (!$nt->userCanEdit()) {
         return $this->uploadError(wfMsgWikiHtml('protectedpage'));
     }
     /**
      * In some cases we may forbid overwriting of existing files.
      */
     $overwrite = $this->checkOverwrite($this->mUploadSaveName);
     if (WikiError::isError($overwrite)) {
         return $this->uploadError($overwrite->toString());
     }
     /* Don't allow users to override the blacklist (check file extension) */
     global $wgStrictFileExtensions;
     global $wgFileExtensions, $wgFileBlacklist;
     if ($this->checkFileExtensionList($ext, $wgFileBlacklist) || $wgStrictFileExtensions && !$this->checkFileExtension($finalExt, $wgFileExtensions)) {
         return $this->uploadError(wfMsgHtml('badfiletype', htmlspecialchars($fullExt)));
     }
     /**
      * Look at the contents of the file; if we can recognize the
      * type but it's corrupt or data of the wrong type, we should
      * probably not accept it.
      */
     if (!$this->mStashed) {
         $this->checkMacBinary();
         $veri = $this->verify($this->mUploadTempName, $finalExt);
         if ($veri !== true) {
             //it's a wiki error...
             return $this->uploadError($veri->toString());
         }
     }
     /**
      * Provide an opportunity for extensions to add futher checks
      */
     $error = '';
     if (!wfRunHooks('UploadVerification', array($this->mUploadSaveName, $this->mUploadTempName, &$error))) {
         return $this->uploadError($error);
     }
     /**
      * Check for non-fatal conditions
      */
     if (!$this->mIgnoreWarning) {
         $warning = '';
         global $wgCapitalLinks;
         if ($wgCapitalLinks) {
             $filtered = ucfirst($filtered);
         }
         if ($this->mUploadSaveName != $filtered) {
             $warning .= '<li>' . wfMsgHtml('badfilename', htmlspecialchars($this->mUploadSaveName)) . '</li>';
         }
         global $wgCheckFileExtensions;
         if ($wgCheckFileExtensions) {
             if (!$this->checkFileExtension($finalExt, $wgFileExtensions)) {
                 $warning .= '<li>' . wfMsgHtml('badfiletype', htmlspecialchars($fullExt)) . '</li>';
             }
         }
         global $wgUploadSizeWarning;
         if ($wgUploadSizeWarning && $this->mUploadSize > $wgUploadSizeWarning) {
             # TODO: Format $wgUploadSizeWarning to something that looks better than the raw byte
             # value, perhaps add GB,MB and KB suffixes?
             $warning .= '<li>' . wfMsgHtml('largefile', $wgUploadSizeWarning, $this->mUploadSize) . '</li>';
         }
         if ($this->mUploadSize == 0) {
             $warning .= '<li>' . wfMsgHtml('emptyfile') . '</li>';
         }
         if ($nt->getArticleID()) {
             global $wgUser;
             $sk = $wgUser->getSkin();
             $dlink = $sk->makeKnownLinkObj($nt);
             $warning .= '<li>' . wfMsgHtml('fileexists', $dlink) . '</li>';
             // WERELATE: added fileexistsnoreupload warning; assume that if user entered license, then this isn't a case of purposeful re-uploading
             if ($this->mLicense) {
                 $warning .= '<li>' . wfMsgHtml('fileexistsnoreupload') . '</li>';
             }
         } else {
             # If the file existed before and was deleted, warn the user of this
             # Don't bother doing so if the image exists now, however
             // WERELATE: remove
             //				$image = new Image( $nt );
             //				if( $image->wasDeleted() ) {
             //					$skin = $wgUser->getSkin();
             //					$ltitle = Title::makeTitle( NS_SPECIAL, 'Log' );
             //					$llink = $skin->makeKnownLinkObj( $ltitle, wfMsgHtml( 'deletionlog' ), 'type=delete&page=' . $nt->getPrefixedUrl() );
             //					$warning .= wfOpenElement( 'li' ) . wfMsgWikiHtml( 'filewasdeleted', $llink ) . wfCloseElement( 'li' );
             //				}
         }
         if ($warning != '') {
             /**
              * Stash the file in a temporary location; the user can choose
              * to let it through and we'll complete the upload then.
              */
             return $this->uploadWarning($warning);
         }
     }
     /**
      * Try actually saving the thing...
      * It will show an error form on failure.
      */
     $hasBeenMunged = !empty($this->mSessionKey) || $this->mRemoveTempFile;
     if ($this->saveUploadedFile($this->mUploadSaveName, $this->mUploadTempName, $hasBeenMunged)) {
         /**
          * Update the upload log and create the description page
          * if it's a new file.
          */
         $img = Image::newFromName($this->mUploadSaveName);
         // WERELATE - changed - added getMetadata, null out license (because we capture it in metadata), redirect only if target is empty
         $success = $img->recordUpload($this->mUploadOldVersion, $this->mUploadDescription, '', $this->mUploadCopyStatus, $this->mUploadSource, $this->mWatchthis, $this->getMetadata(), !$this->mTarget);
         if ($success) {
             // WERELATE - if we're uploading for a P/F target, showSuccess, else just redirect
             if ($this->mTarget) {
                 $this->showSuccess();
             } else {
                 $article = new Article($img->getTitle());
                 $article->doRedirect();
             }
             wfRunHooks('UploadComplete', array(&$img));
         } else {
             // Image::recordUpload() fails if the image went missing, which is
             // unlikely, hence the lack of a specialised message
             $wgOut->showFileNotFoundError($this->mUploadSaveName);
         }
     }
 }
Exemple #30
0
    wfDie("Wiki is in read-only mode; you'll need to disable it for import to work.\n");
}
$reader = new BackupReader();
if (isset($options['quiet'])) {
    $reader->reporting = false;
}
if (isset($options['report'])) {
    $reader->reportingInterval = intval($options['report']);
}
if (isset($options['dry-run'])) {
    $reader->dryRun = true;
}
if (isset($options['debug'])) {
    $reader->debug = true;
}
if (isset($options['uploads'])) {
    $reader->uploads = true;
    // experimental!
}
if (isset($args[0])) {
    $result = $reader->importFromFile($args[0]);
} else {
    $result = $reader->importFromStdin();
}
if (WikiError::isError($result)) {
    echo $result->getMessage() . "\n";
} else {
    echo "Done!\n";
    echo "You might want to run rebuildrecentchanges.php to regenerate\n";
    echo "the recentchanges page.\n";
}