/usr/share/mediawiki-extensions/openid/SpecialOpenIDConvert.body.php is in mediawiki-extensions-openid 3.6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | <?php
/**
* SpecialOpenIDConvert.body.php -- Convert existing account to OpenID account
* Copyright 2006,2007 Internet Brands (http://www.internetbrands.com/)
* Copyright 2007,2008 Evan Prodromou <evan@prodromou.name>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @file
* @author Evan Prodromou <evan@prodromou.name>
* @ingroup Extensions
*/
if ( !defined( 'MEDIAWIKI' ) ) {
exit( 1 );
}
class SpecialOpenIDConvert extends SpecialOpenID {
function __construct() {
parent::__construct( 'OpenIDConvert', 'openid-converter-access' );
}
function execute( $par ) {
global $wgRequest, $wgUser, $wgOut;
if ( !$this->userCanExecute( $wgUser ) ) {
$this->displayRestrictionError();
return;
}
$this->setHeaders();
$this->outputHeader();
switch ( $par ) {
case 'Finish':
$this->finish();
break;
case 'Delete':
$this->delete();
break;
default:
$openid_url = $wgRequest->getText( 'openid_url' );
if ( isset( $openid_url ) && strlen( $openid_url ) > 0 ) {
$this->convert( $openid_url );
} else {
$this->form();
}
}
}
function convert( $openid_url ) {
global $wgUser, $wgOut;
# Expand Interwiki
$openid_url = $this->interwikiExpand( $openid_url );
# Is this ID allowed to log in?
if ( !$this->canLogin( $openid_url ) ) {
$wgOut->showErrorPage( 'openidpermission', 'openidpermissiontext' );
return;
}
# Is this ID already taken?
$other = self::getUserFromUrl( $openid_url );
if ( isset( $other ) ) {
if ( $other->getId() == $wgUser->getID() ) {
$wgOut->showErrorPage( 'openiderror', 'openidconvertyourstext' );
} else {
$wgOut->showErrorPage( 'openiderror', 'openidconvertothertext' );
}
return;
}
# If we're OK to here, let the user go log in
$this->login( $openid_url, SpecialPage::getTitleFor( 'OpenIDConvert', 'Finish' ) );
}
function form() {
global $wgOut, $wgUser, $wgOpenIDShowProviderIcons;
$wgOut->addModules( $wgOpenIDShowProviderIcons ? 'ext.openid.icons' : 'ext.openid.plain' );
$formsHTML = '';
$largeButtonsHTML = '<div id="openid_large_providers">';
foreach ( OpenIDProvider::getLargeProviders() as $provider ) {
$largeButtonsHTML .= $provider->getLargeButtonHTML();
$formsHTML .= $provider->getLoginFormHTML();
}
$largeButtonsHTML .= '</div>';
$smallButtonsHTML = '';
if ( $wgOpenIDShowProviderIcons ) {
$smallButtonsHTML .= '<div id="openid_small_providers_icons">';
foreach ( OpenIDProvider::getSmallProviders() as $provider ) {
$smallButtonsHTML .= $provider->getSmallButtonHTML();
$formsHTML .= $provider->getLoginFormHTML();
}
$smallButtonsHTML .= '</div>';
} else {
$smallButtonsHTML .= '<div id="openid_small_providers_links">';
$smallButtonsHTML .= '<ul class="openid_small_providers_block">';
$small = OpenIDProvider::getSmallProviders();
$i = 0;
$break = true;
foreach ( $small as $provider ) {
if ( $break && $i > count( $small ) / 2 ) {
$smallButtonsHTML .= '</ul><ul class="openid_small_providers_block">';
$break = false;
}
$smallButtonsHTML .= '<li>' . $provider->getSmallButtonHTML() . '</li>';
$formsHTML .= $provider->getLoginFormHTML();
$i++;
}
$smallButtonsHTML .= '</ul>';
$smallButtonsHTML .= '</div>';
}
$wgOut->addHTML(
Xml::openElement( 'form', array( 'id' => 'openid_form', 'action' => $this->getTitle()->getLocalUrl(), 'method' => 'post', 'onsubmit' => 'openid.update()' ) ) .
Xml::fieldset( wfMsg( 'openidconvertoraddmoreids' ) ) .
Xml::openElement( 'p' ) . wfMsg( 'openidconvertinstructions' ) . Xml::closeElement( 'p' ) .
$largeButtonsHTML .
'<div id="openid_input_area">' .
$formsHTML .
'</div>' .
$smallButtonsHTML .
Xml::closeElement( 'fieldset' ) . Xml::closeElement( 'form' )
);
}
function delete() {
global $wgUser, $wgOut, $wgRequest, $wgOpenIDOnly;
$openid = $wgRequest->getVal( 'url' );
$user = self::getUserFromUrl( $openid );
if ( $user->getId() == 0 || $user->getId() != $wgUser->getId() ) {
$wgOut->showErrorPage( 'openiderror', 'openidconvertothertext' );
return;
}
$wgOut->setPageTitle( wfMsg( 'openiddelete' ) );
# Check if the user is removing it's last OpenID url
$urls = self::getUserOpenIDInformation( $wgUser );
if ( count( $urls ) == 1 ) {
if ( $wgUser->mPassword == '' ) {
$wgOut->showErrorPage( 'openiderror', 'openiddeleteerrornopassword' );
return;
} elseif ( $wgOpenIDOnly ) {
$wgOut->showErrorPage( 'openiderror', 'openiddeleteerroropenidonly' );
return;
}
}
if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $openid ) ) {
$ret = self::removeUserUrl( $wgUser, $openid );
$wgOut->addWikiMsg( $ret ? 'openiddelete-sucess' : 'openiddelete-error' );
return;
}
$wgOut->addWikiMsg( 'openiddelete-text', $openid );
$wgOut->addHtml(
Xml::openElement( 'form', array( 'action' => $this->getTitle( 'Delete' )->getLocalUrl(), 'method' => 'post' ) ) .
Xml::submitButton( wfMsg( 'openiddelete-button' ) ) . "\n" .
Html::Hidden( 'url', $openid ) . "\n" .
Html::Hidden( 'wpEditToken', $wgUser->editToken( $openid ) ) . "\n" .
Xml::closeElement( 'form' )
);
}
function finish() {
global $wgUser, $wgOut;
wfSuppressWarnings();
$consumer = $this->getConsumer();
$response = $consumer->complete( $this->scriptUrl( 'Finish' ) );
wfRestoreWarnings();
if ( is_null( $response ) ) {
wfDebug( "OpenID: aborting in openid converter because the response was missing\n" );
$wgOut->showErrorPage( 'openiderror', 'openiderrortext' );
return;
}
switch ( $response->status ) {
case Auth_OpenID_CANCEL:
// This means the authentication was cancelled.
$wgOut->showErrorPage( 'openidcancel', 'openidcanceltext' );
break;
case Auth_OpenID_FAILURE:
wfDebug( "OpenID: error in convert: '" . $response->message . "'\n" );
$wgOut->showErrorPage( 'openidfailure', 'openidfailuretext', array( $response->message ) );
break;
case Auth_OpenID_SUCCESS:
// This means the authentication succeeded.
$openid_url = $response->identity_url;
if ( !$this->canLogin( $openid_url ) ) {
$wgOut->showErrorPage( 'openidpermission', 'openidpermissiontext' );
return;
}
if ( !isset( $openid_url ) ) {
wfDebug( "OpenID: aborting in openid converter because the openid_url was missing\n" );
$wgOut->showErrorPage( 'openiderror', 'openiderrortext' );
return;
}
# We check again for dupes; this may be normalized or
# reformatted by the server.
$other = self::getUserFromUrl( $openid_url );
if ( isset( $other ) ) {
if ( $other->getId() == $wgUser->getID() ) {
$wgOut->showErrorPage( 'openiderror', 'openidconvertyourstext' );
} else {
$wgOut->showErrorPage( 'openiderror', 'openidconvertothertext' );
}
return;
}
self::addUserUrl( $wgUser, $openid_url );
$this->loginSetCookie( $openid_url );
$wgOut->setPageTitle( wfMsg( 'openidconvertsuccess' ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->addWikiMsg( 'openidconvertsuccesstext', $openid_url );
$wgOut->returnToMain();
}
}
}
|