protected final function start() { Assert::isFalse($this->isStarted, 'response already started'); if ($this->status) { $protocol = $this->request ? $this->request->getProtocol() : 'HTTP/1.0'; header($protocol . ' ' . $this->status->getValue() . ' ' . $this->status->getStatusMessage(), true); } foreach ($this->headers as $name => $value) { header($name . ': ' . $value, true); } foreach ($this->cookies as $cookie) { setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpire(), $cookie->getPath()); } $this->isStarted = true; }
function setStatus(HttpStatus $status) { $protocol = $this->request ? $this->request->getProtocol() : 'HTTP/1.0'; header($protocol . ' ' . $status->getValue() . ' ' . $status->getStatusMessage(), true); }
/** * @private */ function mainLoginForm($msg, $msgtype = 'error', $errorlist = array()) { global $wgEnableEmail, $wgEnableUserEmail; global $wgHiddenPrefs, $wgLoginLanguageSelector; global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration; global $wgSecureLogin, $wgPasswordResetRoutes; $titleObj = $this->getPageTitle(); $user = $this->getUser(); $out = $this->getOutput(); if ($this->mType == 'signup') { // Block signup here if in readonly. Keeps user from // going through the process (filling out data, etc) // and being informed later. $permErrors = $titleObj->getUserPermissionsErrors('createaccount', $user, true); if (count($permErrors)) { throw new PermissionsError('createaccount', $permErrors); } elseif ($user->isBlockedFromCreateAccount()) { $this->userBlockedMessage($user->isBlockedFromCreateAccount()); return; } elseif (wfReadOnly()) { throw new ReadOnlyError(); } } // Pre-fill username (if not creating an account, bug 44775). if ($this->mUsername == '' && $this->mType != 'signup') { if ($user->isLoggedIn()) { $this->mUsername = $user->getName(); } else { $this->mUsername = $this->getRequest()->getCookie('UserName'); } } // Generic styles and scripts for both login and signup form $out->addModuleStyles(array('mediawiki.ui', 'mediawiki.ui.button', 'mediawiki.special.userlogin.common.styles')); $out->addModules(array('mediawiki.special.userlogin.common.js')); if ($this->mType == 'signup') { // XXX hack pending RL or JS parse() support for complex content messages // https://bugzilla.wikimedia.org/show_bug.cgi?id=25349 $out->addJsConfigVars('wgCreateacctImgcaptchaHelp', $this->msg('createacct-imgcaptcha-help')->parse()); // Additional styles and scripts for signup form $out->addModules(array('mediawiki.special.userlogin.signup.js')); $out->addModuleStyles(array('mediawiki.special.userlogin.signup.styles')); //XXCHANGEDXX - new login template for 1.23 [sc] // $template = new UsercreateTemplate(); $template = new WikihowCreateTemplate(); // Must match number of benefits defined in messages $template->set('benefitCount', 3); $q = 'action=submitlogin&type=signup'; $linkq = 'type=login'; } else { // Additional styles for login form $out->addModuleStyles(array('mediawiki.special.userlogin.login.styles')); //XXCHANGEDXX - new login template for 1.23 [sc] // $template = new UserloginTemplate(); $template = new WikihowLoginTemplate(); $q = 'action=submitlogin&type=login'; $linkq = 'type=signup'; } if ($this->mReturnTo !== '') { $returnto = '&returnto=' . wfUrlencode($this->mReturnTo); if ($this->mReturnToQuery !== '') { $returnto .= '&returntoquery=' . wfUrlencode($this->mReturnToQuery); } $q .= $returnto; $linkq .= $returnto; } # Don't show a "create account" link if the user can't. if ($this->showCreateOrLoginLink($user)) { # Pass any language selection on to the mode switch link if ($wgLoginLanguageSelector && $this->mLanguage) { $linkq .= '&uselang=' . $this->mLanguage; } // Supply URL, login template creates the button. $template->set('createOrLoginHref', $titleObj->getLocalURL($linkq)); } else { $template->set('link', ''); } $resetLink = $this->mType == 'signup' ? null : is_array($wgPasswordResetRoutes) && in_array(true, array_values($wgPasswordResetRoutes)); $template->set('header', ''); $template->set('skin', $this->getSkin()); $template->set('name', $this->mUsername); $template->set('password', $this->mPassword); $template->set('retype', $this->mRetype); $template->set('createemailset', $this->mCreateaccountMail); $template->set('email', $this->mEmail); $template->set('realname', $this->mRealName); $template->set('domain', $this->mDomain); $template->set('reason', $this->mReason); $template->set('action', $titleObj->getLocalURL($q)); $template->set('message', $msg); $template->set('messagetype', $msgtype); // Added errorlist variable to list all errors. $template->set('errorlist', $errorlist); $template->set('createemail', $wgEnableEmail && $user->isLoggedIn()); $template->set('userealname', !in_array('createrealname', $wgHiddenPrefs)); $template->set('useemail', $wgEnableEmail); $template->set('emailrequired', $wgEmailConfirmToEdit); $template->set('emailothers', $wgEnableUserEmail); $template->set('canreset', $wgAuth->allowPasswordChange()); $template->set('resetlink', $resetLink); $template->set('canremember', $wgCookieExpiration > 0); $template->set('usereason', $user->isLoggedIn()); $template->set('remember', $user->getOption('rememberpassword') || $this->mRemember); $template->set('cansecurelogin', $wgSecureLogin === true); $template->set('stickhttps', (int) $this->mStickHTTPS); $template->set('loggedin', $user->isLoggedIn()); $template->set('loggedinuser', $user->getName()); if ($this->mType == 'signup') { if (!self::getCreateaccountToken()) { self::setCreateaccountToken(); } $template->set('token', self::getCreateaccountToken()); } else { if (!self::getLoginToken()) { self::setLoginToken(); } $template->set('token', self::getLoginToken()); } # Prepare language selection links as needed if ($wgLoginLanguageSelector) { $template->set('languages', $this->makeLanguageSelector()); if ($this->mLanguage) { $template->set('uselang', $this->mLanguage); } } $template->set('secureLoginUrl', $this->mSecureLoginUrl); // Use loginend-https for HTTPS requests if it's not blank, loginend otherwise // Ditto for signupend. New forms use neither. $usingHTTPS = $this->mRequest->getProtocol() == 'https'; $loginendHTTPS = $this->msg('loginend-https'); $signupendHTTPS = $this->msg('signupend-https'); if ($usingHTTPS && !$loginendHTTPS->isBlank()) { $template->set('loginend', $loginendHTTPS->parse()); } else { $template->set('loginend', $this->msg('loginend')->parse()); } if ($usingHTTPS && !$signupendHTTPS->isBlank()) { $template->set('signupend', $signupendHTTPS->parse()); } else { $template->set('signupend', $this->msg('signupend')->parse()); } // Give authentication and captcha plugins a chance to modify the form $wgAuth->modifyUITemplate($template, $this->mType); if ($this->mType == 'signup') { wfRunHooks('UserCreateForm', array(&$template)); } else { wfRunHooks('UserLoginForm', array(&$template)); } $out->disallowUserJs(); // just in case... $out->addTemplate($template); }