function wfSpecialMakesysop()
{
- global $wgUser, $wgOut, $action, $target;
+ global $wgUser, $wgOut, $wgRequest;
if ( 0 == $wgUser->getID() or $wgUser->isBlocked() ) {
$wgOut->errorpage( "movenologin", "movenologintext" );
$wgOut->errorpage( "bureaucrattitle", "bureaucrattext" );
return;
}
-
+
if ( wfReadOnly() ) {
$wgOut->readOnlyPage();
return;
}
- $f = new MakesysopForm();
+ $f = new MakesysopForm( $wgRequest );
- if ( $_POST['wpMakesysopSubmit'] ) {
+ if ( $f->mSubmit ) {
$f->doSubmit();
} else {
$f->showForm( "" );
}
}
-class MakesysopForm {
+class MakesysopForm {
+ var $mTarget, $mAction, $mRights, $mUser, $mSubmit;
+
+ function MakesysopForm( &$request )
+ {
+ $this->mAction = $request->getText( 'action' );
+ $this->mRights = $request->getVal( 'wpRights' );
+ $this->mUser = $request->getText( 'wpMakesysopUser' );
+ $this->mSubmit = $request->getBool( 'wpMakesysopSubmit' ) && $request->wasPosted();
+ $this->mBuro = $request->getBool( 'wpSetBureaucrat' );
+ }
+
function showForm( $err = "")
{
global $wgOut, $wgUser, $wgLang;
- global $wpNewTitle, $wpOldTitle, $wpMovetalk, $target, $wpRights, $wpMakesysopUser;
if ( $wgUser->isDeveloper() ) {
$wgOut->setPageTitle( wfMsg( "set_user_rights" ) );
$wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
}
$namedesc = wfMsg( "makesysopname" );
- if ( isset( $wpMakesysopUser ) ) {
- $encUser = htmlspecialchars( $wpMakesysopUser );
+ if ( !is_null( $this->mUser ) ) {
+ $encUser = htmlspecialchars( $this->mUser );
} else {
$encUser = "";
}
if ( $wgUser->isDeveloper() ) {
$rights = wfMsg( "rights" );
- if ( isset( $wpRights ) ) {
- $encRights = htmlspecialchars( $wpRights );
+ if ( !is_null( $this->mRights ) ) {
+ $encRights = htmlspecialchars( $this->mRights );
} else {
$encRights = "sysop";
}
function doSubmit()
{
+ global $wgOut, $wgUser, $wgLang;
+ global $wgDBname, $wgMemc, $wgLocalDatabases;
- global $wgOut, $wgUser, $wgLang, $wpMakesysopUser, $wpSetBureaucrat;
- global $wgDBname, $wgMemc, $wpRights, $wgLocalDatabases;
-
- $parts = explode( "@", $wpMakesysopUser );
+ $parts = explode( "@", $this->mUser );
if( count( $parts ) == 2 && $wgUser->isDeveloper() ){
- $username = $parts[0];
+ $username = wfStrencode( $parts[0] );
if ( array_key_exists( $parts[1], $wgLocalDatabases ) ) {
$dbName = $wgLocalDatabases[$parts[1]];
$usertable = $dbName . ".user";
return;
}
} else {
- $username = $wpMakesysopUser;
+ $username = wfStrencode( $this->mUser );
$usertable = "user";
$dbName = $wgDBname;
}
$sql = "SELECT user_id,user_rights FROM $usertable WHERE user_id=$id";
} else {
$encName = wfStrencode( $username );
- $sql = "SELECT user_id, user_rights FROM $usertable WHERE user_name = '{$encName}'";
- }
-
- $prev = wfIgnoreSQLErrors( TRUE );
- $res = wfQuery( $sql, DB_WRITE);
- wfIgnoreSQLErrors( $prev );
-
- global $wgOut, $wgUser, $wgLang, $wpMakesysopUser, $wpSetBureaucrat;
- global $wgDBname, $wgMemc, $wpRights, $wgLocalDatabases;
-
- $parts = explode( "@", $wpMakesysopUser );
- if( count( $parts ) == 2 && $wgUser->isDeveloper() ){
- $username = wfStrencode( $parts[0] );
- if ( array_key_exists( $parts[1], $wgLocalDatabases ) ) {
- $dbName = $wgLocalDatabases[$parts[1]];
- $usertable = $dbName . ".user";
- } else {
- $this->showFail();
- return;
- }
- } else {
- $username = wfStrencode( $wpMakesysopUser );
- $usertable = "user";
- $dbName = $wgDBname;
+ $sql = "SELECT user_id, user_rights FROM $usertable WHERE user_name = '{$username}'";
}
- if ( $username{0} == "#" ) {
- $id = intval( substr( $username, 1 ) );
- $sql = "SELECT user_id,user_rights FROM $usertable WHERE user_id=$id";
- } else {
- $encName = wfStrencode( $username );
- $sql = "SELECT user_id, user_rights FROM $usertable WHERE user_name = '{$username}'";
- }
-
$prev = wfIgnoreSQLErrors( TRUE );
$res = wfQuery("SELECT user_id, user_rights FROM $usertable WHERE user_name = '{$username}'", DB_WRITE);
$rightsNotation = array();
if ( $wgUser->isDeveloper() ) {
- $newrights = (string)$wpRights;
- $rightsNotation[] = "=$wpRights";
+ $newrights = (string)$this->mRights;
+ $rightsNotation[] = "=$this->mRights";
} else {
if( $row->user_rights ){
$rights = explode(",", $row->user_rights );
$rights[] = "sysop";
$rightsNotation[] = "+sysop ";
}
- if ( $wpSetBureaucrat && !in_array( "bureaucrat", $rights ) ) {
+ if ( $this->mBuro && !in_array( "bureaucrat", $rights ) ) {
$rights[] = "bureaucrat";
$rightsNotation[] = "+bureaucrat ";
}
} else {
$newrights = "sysop";
$rightsNotation[] = "+sysop";
- if ( $wpSetBureaucrat ) {
+ if ( $this->mBuro ) {
$rightsNotation[] = "+bureaucrat";
$newrights .= ",bureaucrat";
}
$wgMemc->delete( "$dbName:user:id:$id" );
$bureaucratLog = wfMsg( "bureaucratlog" );
- $action = wfMsg( "bureaucratlogentry", $wpMakesysopUser, implode( " ", $rightsNotation ) );
+ $action = wfMsg( "bureaucratlogentry", $this->mUser, implode( " ", $rightsNotation ) );
$log = new LogPage( $bureaucratLog );
$log->addEntry( $action, "" );
function showSuccess()
{
- global $wgOut, $wpMakesysopUser, $wgUser;
+ global $wgOut, $wgUser;
$wgOut->setPagetitle( wfMsg( "makesysoptitle" ) );
if ( $wgUser->isDeveloper() ) {
- $text = wfMsg( "user_rights_set", $wpMakesysopUser );
+ $text = wfMsg( "user_rights_set", $this->mUser );
} else {
- $text = wfMsg( "makesysopok", $wpMakesysopUser );
+ $text = wfMsg( "makesysopok", $this->mUser );
}
$text .= "\n\n";
$wgOut->addWikiText( $text );
function showFail()
{
- global $wgOut, $wpMakesysopUser, $wgUser;
+ global $wgOut, $wgUser;
$wgOut->setPagetitle( wfMsg( "makesysoptitle" ) );
if ( $wgUser->isDeveloper() ) {
- $this->showForm( wfMsg( "set_rights_fail", $wpMakesysopUser ) );
+ $this->showForm( wfMsg( "set_rights_fail", $this->mUser ) );
} else {
- $this->showForm( wfMsg( "makesysopfail", $wpMakesysopUser ) );
+ $this->showForm( wfMsg( "makesysopfail", $this->mUser ) );
}
}
}
function wfSpecialPreferences()
{
- global $wgUser, $wgOut, $wgUseDynamicDates, $action;
- global $wpSaveprefs, $wpReset, $wgRequest;
-
- # EWWWWWW temp hack
- global $wpOldpass, $wpNewpass, $wpRetypePass, $wpNick, $wpUserEmail;
- $wpOldpass = $wgRequest->getText( 'wpOldpass' );
- $wpNewpass = $wgRequest->getText( 'wpNewpass' );
- $wpRetypePass = $wgRequest->getText( 'wpRetypePass' );
- $wpNick = $wgRequest->getText( 'wpNick' );
- $wpUserEmail = $wgRequest->getVal( 'wpUserEmail' );
-
- if ( 0 == $wgUser->getID() ) {
- $wgOut->errorpage( "prefsnologin", "prefsnologintext" );
- return;
- }
- if ( wfReadOnly() ) {
- $wgOut->readOnlyPage();
- return;
- }
- if ( isset( $wpReset ) ) {
- resetPrefs();
- mainPrefsForm( WfMsg( "prefsreset" ) );
- } else if ( isset( $_POST['wpSaveprefs'] ) ) {
- savePreferences();
- } else {
- resetPrefs();
- mainPrefsForm( "" );
- }
-}
+ global $wgRequest;
-/* private */ function validateInt( &$val, $min=0, $max=0x7fffffff ) {
- $val = intval($val);
- $val = min($val, $max);
- $val = max($val, $min);
- return $val;
+ $form = new PreferencesForm( $wgRequest );
+ $form->execute();
}
-/* private */ function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
- $val = trim($val);
- if($val === "") {
- return $val;
- } else {
- return validateInt( $val, $min, $max );
+class PreferencesForm {
+ var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
+ var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
+ var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
+ var $mReset, $mPosted, $mToggles, $mSearchNs;
+
+ function PreferencesForm( &$request ) {
+ global $wgLang;
+
+ $this->mQuickbar = $request->getVal( 'wpQuickbar' );
+ $this->mOldpass = $request->getVal( 'wpOldpass' );
+ $this->mNewpass = $request->getVal( 'wpNewpass' );
+ $this->mRetypePass =$request->getVal( 'wpRetypePass' );
+ $this->mStubs = $request->getVal( 'wpStubs' );
+ $this->mRows = $request->getVal( 'wpRows' );
+ $this->mCols = $request->getVal( 'wpCols' );
+ $this->mSkin = $request->getVal( 'wpSkin' );
+ $this->mMath = $request->getVal( 'wpMath' );
+ $this->mDate = $request->getVal( 'wpDate' );
+ $this->mUserEmail = $request->getVal( 'wpUserEmail' );
+ $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0;
+ $this->mNick = $request->getVal( 'wpNick' );
+ $this->mSearch = $request->getVal( 'wpSearch' );
+ $this->mRecent = $request->getVal( 'wpRecent' );
+ $this->mHourDiff = $request->getVal( 'wpHourDiff' );
+ $this->mSearchLines = $request->getVal( 'wpSearchLines' );
+ $this->mSearchChars = $request->getVal( 'wpSearchChars' );
+ $this->mAction = $request->getVal( 'action' );
+ $this->mReset = $request->getCheck( 'wpReset' );
+ $this->mPosted = $request->wasPosted();
+ $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) && $this->mPosted;
+
+ # User toggles (the big ugly unsorted list of checkboxes)
+ $this->mToggles = array();
+ if ( $this->mPosted ) {
+ $togs = $wgLang->getUserToggles();
+ foreach ( $togs as $tname => $ttext ) {
+ $this->mToggles[$tname] = $request->getCheck( "wpOp$tname" ) ? 1 : 0;
+ }
+ }
+
+ # Search namespace options
+ # Note: namespaces don't necessarily have consecutive keys
+ $this->mSearchNs = array();
+ if ( $this->mPosted ) {
+ $namespaces = $wgLang->getNamespaces();
+ foreach ( $namespaces as $i => $namespace ) {
+ if ( $i >= 0 ) {
+ $this->mSearchNs[$i] = $request->getCheck( "wpNs$i" ) ? 1 : 0;
+ }
+ }
+ }
}
-}
-
-/* private */ function validateCheckbox( $cb )
-{
- if ( $cb )
- {
- return 1;
+ function execute() {
+ global $wgUser, $wgOut, $wgUseDynamicDates;
+
+ if ( 0 == $wgUser->getID() ) {
+ $wgOut->errorpage( "prefsnologin", "prefsnologintext" );
+ return;
+ }
+ if ( wfReadOnly() ) {
+ $wgOut->readOnlyPage();
+ return;
+ }
+ if ( $this->mReset ) {
+ $this->resetPrefs();
+ $this->mainPrefsForm( wfMsg( "prefsreset" ) );
+ } else if ( $this->mSaveprefs ) {
+ $this->savePreferences();
+ } else {
+ $this->resetPrefs();
+ $this->mainPrefsForm( "" );
+ }
}
- else
- {
- return 0;
+
+ /* private */ function validateInt( &$val, $min=0, $max=0x7fffffff ) {
+ $val = intval($val);
+ $val = min($val, $max);
+ $val = max($val, $min);
+ return $val;
}
-}
-/* private */ function validateTimeZone( $s )
-{
-
- if ( $s !== "" ) {
- if ( strpos( $s, ":" ) ) {
- # HH:MM
- $array = explode( ":" , $s );
- $hour = intval( $array[0] );
- $minute = intval( $array[1] );
+ /* private */ function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
+ $val = trim($val);
+ if($val === "") {
+ return $val;
} else {
- $minute = intval( $s * 60 );
- $hour = intval( $minute / 60 );
- $minute = abs( $minute ) % 60;
+ return $this->validateInt( $val, $min, $max );
}
- $hour = min( $hour, 15 );
- $hour = max( $hour, -15 );
- $minute = min( $minute, 59 );
- $minute = max( $minute, 0 );
- $s = sprintf( "%02d:%02d", $hour, $minute );
}
- return $s;
-}
-/* private */ function savePreferences()
-{
- global $wgUser, $wgLang, $wgDeferredUpdateList;
- global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetypePass;
- global $wpSkin, $wpMath, $wpDate, $wpUserEmail, $wpEmailFlag, $wpNick, $wpSearch, $wpRecent;
- global $wpSearchLines, $wpSearchChars, $wpStubs;
- global $wpRows, $wpCols, $wpHourDiff;
-
- if ( "" != $wpNewpass ) {
- if ( $wpNewpass != $wpRetypePass ) {
- mainPrefsForm( wfMsg( "badretype" ) );
- return;
+ /* private */ function validateTimeZone( $s )
+ {
+
+ if ( $s !== "" ) {
+ if ( strpos( $s, ":" ) ) {
+ # HH:MM
+ $array = explode( ":" , $s );
+ $hour = intval( $array[0] );
+ $minute = intval( $array[1] );
+ } else {
+ $minute = intval( $s * 60 );
+ $hour = intval( $minute / 60 );
+ $minute = abs( $minute ) % 60;
+ }
+ $hour = min( $hour, 15 );
+ $hour = max( $hour, -15 );
+ $minute = min( $minute, 59 );
+ $minute = max( $minute, 0 );
+ $s = sprintf( "%02d:%02d", $hour, $minute );
}
- $ep = $wgUser->encryptPassword( $wpOldpass );
- if ( $ep != $wgUser->getPassword() ) {
- if ( $ep != $wgUser->getNewpassword() ) {
- mainPrefsForm( wfMsg( "wrongpassword" ) );
+ return $s;
+ }
+
+ /* private */ function savePreferences()
+ {
+ global $wgUser, $wgLang, $wgDeferredUpdateList;
+
+ if ( "" != $this->mNewpass ) {
+ if ( $this->mNewpass != $this->mRetypePass ) {
+ $this->mainPrefsForm( wfMsg( "badretype" ) );
return;
}
+ $ep = $wgUser->encryptPassword( $this->mOldpass );
+ if ( $ep != $wgUser->getPassword() ) {
+ if ( $ep != $wgUser->getNewpassword() ) {
+ $this->mainPrefsForm( wfMsg( "wrongpassword" ) );
+ return;
+ }
+ }
+ $wgUser->setPassword( $this->mNewpass );
}
- $wgUser->setPassword( $wpNewpass );
- }
- $wgUser->setEmail( $wpUserEmail );
- $wgUser->setOption( "nickname", $wpNick );
- $wgUser->setOption( "quickbar", $wpQuickbar );
- $wgUser->setOption( "skin", $wpSkin );
- $wgUser->setOption( "math", $wpMath );
- $wgUser->setOption( "date", $wpDate );
- $wgUser->setOption( "searchlimit", validateIntOrNull( $wpSearch ) );
- $wgUser->setOption( "contextlines", validateIntOrNull( $wpSearchLines ) );
- $wgUser->setOption( "contextchars", validateIntOrNull( $wpSearchChars ) );
- $wgUser->setOption( "rclimit", validateIntOrNull( $wpRecent ) );
- $wgUser->setOption( "rows", validateInt( $wpRows, 4, 1000 ) );
- $wgUser->setOption( "cols", validateInt( $wpCols, 4, 1000 ) );
- $wgUser->setOption( "stubthreshold", validateIntOrNull( $wpStubs ) );
- $wgUser->setOption( "timecorrection", validateTimeZone( $wpHourDiff, -12, 14 ) );
-
- $namespaces = $wgLang->getNamespaces();
- # Set search namespace options
- # Note: namespaces don't necessarily have consecutive keys
- foreach ( $namespaces as $i => $namespaces ) {
- if ( $i >= 0 ) {
- $nsvar = "wpNs$i";
- global $$nsvar;
- $wgUser->setOption( "searchNs{$i}", validateCheckbox( $$nsvar ) );
+ $wgUser->setEmail( $this->mUserEmail );
+ $wgUser->setOption( "nickname", $this->mNick );
+ $wgUser->setOption( "quickbar", $this->mQuickbar );
+ $wgUser->setOption( "skin", $this->mSkin );
+ $wgUser->setOption( "math", $this->mMath );
+ $wgUser->setOption( "date", $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( "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 ) );
+
+ # Set search namespace options
+ foreach( $this->mSearchNs as $i => $value ) {
+ $wgUser->setOption( "searchNs{$i}", $value );
}
- }
-
- $wgUser->setOption( "disablemail", validateCheckbox( $wpEmailFlag ) );
+
+ $wgUser->setOption( "disablemail", $this->mEmailFlag );
- $togs = $wgLang->getUserToggles();
- foreach ( $togs as $tname => $ttext ) {
- if ( array_key_exists( "wpOp$tname", $_POST ) ) {
- $wgUser->setOption( $tname, 1 );
- } else {
- $wgUser->setOption( $tname, 0 );
+ # Set user toggles
+ foreach ( $this->mToggles as $tname => $tvalue ) {
+ $wgUser->setOption( $tname, $tvalue );
}
+ $wgUser->setCookies();
+ $up = new UserUpdate();
+ array_push( $wgDeferredUpdateList, $up );
+ $this->mainPrefsForm( wfMsg( "savedprefs" ) );
}
- $wgUser->setCookies();
- $up = new UserUpdate();
- array_push( $wgDeferredUpdateList, $up );
- mainPrefsForm( wfMsg( "savedprefs" ) );
-}
-/* private */ function resetPrefs()
-{
- global $wgUser, $wgLang;
- global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetypePass, $wpStubs;
- global $wpRows, $wpCols, $wpSkin, $wpMath, $wpDate, $wpUserEmail, $wpEmailFlag, $wpNick;
- global $wpSearch, $wpRecent;
- global $wpHourDiff, $wpSearchLines, $wpSearchChars;
-
- $wpOldpass = $wpNewpass = $wpRetypePass = "";
- $wpUserEmail = $wgUser->getEmail();
- if ( 1 == $wgUser->getOption( "disablemail" ) ) { $wpEmailFlag = 1; }
- else { $wpEmailFlag = 0; }
- $wpNick = $wgUser->getOption( "nickname" );
-
- $wpQuickbar = $wgUser->getOption( "quickbar" );
- $wpSkin = $wgUser->getOption( "skin" );
- $wpMath = $wgUser->getOption( "math" );
- $wpDate = $wgUser->getOption( "date" );
- $wpRows = $wgUser->getOption( "rows" );
- $wpCols = $wgUser->getOption( "cols" );
- $wpStubs = $wgUser->getOption( "stubthreshold" );
- $wpHourDiff = $wgUser->getOption( "timecorrection" );
- $wpSearch = $wgUser->getOption( "searchlimit" );
- $wpSearchLines = $wgUser->getOption( "contextlines" );
- $wpSearchChars = $wgUser->getOption( "contextchars" );
- $wpRecent = $wgUser->getOption( "rclimit" );
-
- $togs = $wgLang->getUserToggles();
- foreach ( $togs as $tname => $ttext ) {
- $_POST["wpOp$tname"] = $wgUser->getOption( $tname );
- }
-}
+ /* private */ function resetPrefs()
+ {
+ global $wgUser, $wgLang;
+
+ $this->mOldpass = $this->mNewpass = $this->mRetypePass = "";
+ $this->mUserEmail = $wgUser->getEmail();
+ if ( 1 == $wgUser->getOption( "disablemail" ) ) { $this->mEmailFlag = 1; }
+ else { $this->mEmailFlag = 0; }
+ $this->mNick = $wgUser->getOption( "nickname" );
+
+ $this->mQuickbar = $wgUser->getOption( "quickbar" );
+ $this->mSkin = $wgUser->getOption( "skin" );
+ $this->mMath = $wgUser->getOption( "math" );
+ $this->mDate = $wgUser->getOption( "date" );
+ $this->mRows = $wgUser->getOption( "rows" );
+ $this->mCols = $wgUser->getOption( "cols" );
+ $this->mStubs = $wgUser->getOption( "stubthreshold" );
+ $this->mHourDiff = $wgUser->getOption( "timecorrection" );
+ $this->mSearch = $wgUser->getOption( "searchlimit" );
+ $this->mSearchLines = $wgUser->getOption( "contextlines" );
+ $this->mSearchChars = $wgUser->getOption( "contextchars" );
+ $this->mRecent = $wgUser->getOption( "rclimit" );
+
+ $togs = $wgLang->getUserToggles();
+ foreach ( $togs as $tname => $ttext ) {
+ $this->mToggles[$tname] = $wgUser->getOption( $tname );
+ }
-/* private */ function namespacesCheckboxes()
-{
- global $wgLang, $wgUser;
-
- # Determine namespace checkboxes
- $namespaces = $wgLang->getNamespaces();
- $r1 = "";
-
- foreach ( $namespaces as $i => $name ) {
- # Skip special or anything similar
- if ( $i >= 0 ) {
- $checked = "";
- if ( $wgUser->getOption( "searchNs$i" ) ) {
- $checked = " checked";
- }
- $name = str_replace( "_", " ", $namespaces[$i] );
- if ( "" == $name ) {
- $name = wfMsg( "blanknamespace" );
+ $namespaces = $wgLang->getNamespaces();
+ foreach ( $namespaces as $i => $namespace ) {
+ if ( $i >= 0 ) {
+ $this->mSearchNs[$i] = $wgUser->getOption( "searchNs$i" );
}
+ }
+ }
- if ( 0 != $i ) {
- $r1 .= " ";
+ /* private */ function namespacesCheckboxes()
+ {
+ global $wgLang, $wgUser;
+
+ # Determine namespace checkboxes
+ $namespaces = $wgLang->getNamespaces();
+ $r1 = "";
+
+ foreach ( $namespaces as $i => $name ) {
+ # Skip special or anything similar
+ if ( $i >= 0 ) {
+ $checked = "";
+ if ( $this->mSearchNs[$i] ) {
+ $checked = " checked";
+ }
+ $name = str_replace( "_", " ", $namespaces[$i] );
+ if ( "" == $name ) {
+ $name = wfMsg( "blanknamespace" );
+ }
+
+ if ( 0 != $i ) {
+ $r1 .= " ";
+ }
+ $r1 .= "<label><input type=checkbox value=\"1\" name=\"" .
+ "wpNs$i\"{$checked}>{$name}</label>\n";
}
- $r1 .= "<label><input type=checkbox value=\"1\" name=\"" .
- "wpNs$i\"{$checked}>{$name}</label>\n";
}
+
+ return $r1;
}
-
- return $r1;
-}
-/* private */ function mainPrefsForm( $err )
-{
- global $wgUser, $wgOut, $wgLang, $wgUseDynamicDates;
- global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetypePass;
- global $wpSkin, $wpMath, $wpDate, $wpUserEmail, $wpEmailFlag, $wpNick, $wpSearch, $wpRecent;
- global $wpRows, $wpCols, $wpSaveprefs, $wpReset, $wpHourDiff;
- global $wpSearchLines, $wpSearchChars, $wpStubs, $wgValidSkinNames;
-
- $wgOut->setPageTitle( wfMsg( "preferences" ) );
- $wgOut->setArticleRelated( false );
- $wgOut->setRobotpolicy( "noindex,nofollow" );
-
- if ( "" != $err ) {
- $wgOut->addHTML( "<font size='+1' color='red'>$err</font>\n<p>" );
- }
- $uname = $wgUser->getName();
- $uid = $wgUser->getID();
-
- $wgOut->addWikiText( wfMsg( "prefslogintext", $uname, $uid ) );
-
- $qbs = $wgLang->getQuickbarSettings();
- $skinNames = $wgLang->getSkinNames();
- $mathopts = $wgLang->getMathNames();
- $dateopts = $wgLang->getDateFormats();
- $togs = $wgLang->getUserToggles();
-
- $titleObj = Title::makeTitle( NS_SPECIAL, "Preferences" );
- $action = $titleObj->escapeLocalURL();
-
- $qb = wfMsg( "qbsettings" );
- $cp = wfMsg( "changepassword" );
- $sk = wfMsg( "skin" );
- $math = wfMsg( "math" );
- $dateFormat = wfMsg("dateformat");
- $opw = wfMsg( "oldpassword" );
- $npw = wfMsg( "newpassword" );
- $rpw = wfMsg( "retypenew" );
- $svp = wfMsg( "saveprefs" );
- $rsp = wfMsg( "resetprefs" );
- $tbs = wfMsg( "textboxsize" );
- $tbr = wfMsg( "rows" );
- $tbc = wfMsg( "columns" );
- $ltz = wfMsg( "localtime" );
- $tzt = wfMsg( "timezonetext" );
- $tzo = wfMsg( "timezoneoffset" );
- $tzGuess = wfMsg( "guesstimezone" );
- $tzServerTime = wfMsg( "servertime" );
- $yem = wfMsg( "youremail" );
- $emf = wfMsg( "emailflag" );
- $ynn = wfMsg( "yournick" );
- $stt = wfMsg ( "stubthreshold" ) ;
- $srh = wfMsg( "searchresultshead" );
- $rpp = wfMsg( "resultsperpage" );
- $scl = wfMsg( "contextlines" );
- $scc = wfMsg( "contextchars" );
- $rcc = wfMsg( "recentchangescount" );
- $dsn = wfMsg( "defaultns" );
-
- $wgOut->addHTML( "<form id=\"preferences\" name=\"preferences\" action=\"$action\"
-method=\"post\"><table border=\"1\"><tr><td valign=top nowrap><b>$qb:</b><br>\n" );
-
- # Quickbar setting
- #
- for ( $i = 0; $i < count( $qbs ); ++$i ) {
- if ( $i == $wpQuickbar ) { $checked = " checked"; }
- else { $checked = ""; }
- $wgOut->addHTML( "<label><input type=radio name=\"wpQuickbar\"
-value=\"$i\"$checked> {$qbs[$i]}</label><br>\n" );
- }
+ /* private */ function mainPrefsForm( $err )
+ {
+ global $wgUser, $wgOut, $wgLang, $wgUseDynamicDates, $wgValidSkinNames;
+
+ $wgOut->setPageTitle( wfMsg( "preferences" ) );
+ $wgOut->setArticleRelated( false );
+ $wgOut->setRobotpolicy( "noindex,nofollow" );
- # Fields for changing password
- #
- $wpOldpass = wfEscapeHTML( $wpOldpass );
- $wpNewpass = wfEscapeHTML( $wpNewpass );
- $wpRetypePass = wfEscapeHTML( $wpRetypePass );
-
- $wgOut->addHTML( "</td><td vaign=top nowrap><b>$cp:</b><br>
-<label>$opw: <input type=password name=\"wpOldpass\" value=\"$wpOldpass\" size=20></label><br>
-<label>$npw: <input type=password name=\"wpNewpass\" value=\"$wpNewpass\" size=20></label><br>
-<label>$rpw: <input type=password name=\"wpRetypePass\" value=\"$wpRetypePass\" size=20></label><br>
-</td></tr>\n" );
-
- # Skin setting
- #
- $wgOut->addHTML( "<tr><td valign=top nowrap><b>$sk:</b><br>\n" );
- # Only show members of $wgValidSkinNames rather than
- # $skinNames (skins is all skin names from Language.php)
- foreach ($wgValidSkinNames as $skinkey => $skinname ) {
- if ( $skinkey == $wpSkin ) {
- $checked = ' checked';
- } else {
- $checked = "";
+ if ( "" != $err ) {
+ $wgOut->addHTML( "<font size='+1' color='red'>$err</font>\n<p>" );
+ }
+ $uname = $wgUser->getName();
+ $uid = $wgUser->getID();
+
+ $wgOut->addWikiText( wfMsg( "prefslogintext", $uname, $uid ) );
+
+ $qbs = $wgLang->getQuickbarSettings();
+ $skinNames = $wgLang->getSkinNames();
+ $mathopts = $wgLang->getMathNames();
+ $dateopts = $wgLang->getDateFormats();
+ $togs = $wgLang->getUserToggles();
+
+ $titleObj = Title::makeTitle( NS_SPECIAL, "Preferences" );
+ $action = $titleObj->escapeLocalURL();
+
+ $qb = wfMsg( "qbsettings" );
+ $cp = wfMsg( "changepassword" );
+ $sk = wfMsg( "skin" );
+ $math = wfMsg( "math" );
+ $dateFormat = wfMsg("dateformat");
+ $opw = wfMsg( "oldpassword" );
+ $npw = wfMsg( "newpassword" );
+ $rpw = wfMsg( "retypenew" );
+ $svp = wfMsg( "saveprefs" );
+ $rsp = wfMsg( "resetprefs" );
+ $tbs = wfMsg( "textboxsize" );
+ $tbr = wfMsg( "rows" );
+ $tbc = wfMsg( "columns" );
+ $ltz = wfMsg( "localtime" );
+ $tzt = wfMsg( "timezonetext" );
+ $tzo = wfMsg( "timezoneoffset" );
+ $tzGuess = wfMsg( "guesstimezone" );
+ $tzServerTime = wfMsg( "servertime" );
+ $yem = wfMsg( "youremail" );
+ $emf = wfMsg( "emailflag" );
+ $ynn = wfMsg( "yournick" );
+ $stt = wfMsg ( "stubthreshold" ) ;
+ $srh = wfMsg( "searchresultshead" );
+ $rpp = wfMsg( "resultsperpage" );
+ $scl = wfMsg( "contextlines" );
+ $scc = wfMsg( "contextchars" );
+ $rcc = wfMsg( "recentchangescount" );
+ $dsn = wfMsg( "defaultns" );
+
+ $wgOut->addHTML( "<form id=\"preferences\" name=\"preferences\" action=\"$action\"
+ method=\"post\"><table border=\"1\"><tr><td valign=top nowrap><b>$qb:</b><br>\n" );
+
+ # Quickbar setting
+ #
+ for ( $i = 0; $i < count( $qbs ); ++$i ) {
+ if ( $i == $this->mQuickbar ) { $checked = " checked"; }
+ else { $checked = ""; }
+ $wgOut->addHTML( "<label><input type=radio name=\"wpQuickbar\"
+ value=\"$i\"$checked> {$qbs[$i]}</label><br>\n" );
}
- $wgOut->addHTML( "<label><input type=radio name=\"wpSkin\"
-value=\"$skinkey\"$checked> {$skinNames[$skinkey]}</label><br>\n" );
- }
- # Various checkbox options
- #
- if ( $wgUseDynamicDates ) {
- $wgOut->addHTML( "</td><td rowspan=3 valign=top nowrap>\n" );
- } else {
- $wgOut->addHTML( "</td><td rowspan=2 valign=top nowrap>\n" );
- }
- $wgOut->addHTML("<table border=0>");
- foreach ( $togs as $tname => $ttext ) {
- if ( 1 == $wgUser->getOption( $tname ) ) {
- $checked = " checked";
+ # Fields for changing password
+ #
+ $this->mOldpass = wfEscapeHTML( $this->mOldpass );
+ $this->mNewpass = wfEscapeHTML( $this->mNewpass );
+ $this->mRetypePass = wfEscapeHTML( $this->mRetypePass );
+
+ $wgOut->addHTML( "</td><td vaign=top nowrap><b>$cp:</b><br>
+ <label>$opw: <input type=password name=\"wpOldpass\" value=\"{$this->mOldpass}\" size=20></label><br>
+ <label>$npw: <input type=password name=\"wpNewpass\" value=\"{$this->mNewpass}\" size=20></label><br>
+ <label>$rpw: <input type=password name=\"wpRetypePass\" value=\"{$this->mRetypePass}\" size=20></label><br>
+ </td></tr>\n" );
+
+ # Skin setting
+ #
+ $wgOut->addHTML( "<tr><td valign=top nowrap><b>$sk:</b><br>\n" );
+ # Only show members of $wgValidSkinNames rather than
+ # $skinNames (skins is all skin names from Language.php)
+ foreach ($wgValidSkinNames as $skinkey => $skinname ) {
+ if ( $skinkey == $this->mSkin ) {
+ $checked = ' checked';
+ } else {
+ $checked = "";
+ }
+ $wgOut->addHTML( "<label><input type=radio name=\"wpSkin\"
+ value=\"$skinkey\"$checked> {$skinNames[$skinkey]}</label><br>\n" );
+ }
+
+ # Various checkbox options
+ #
+ if ( $wgUseDynamicDates ) {
+ $wgOut->addHTML( "</td><td rowspan=3 valign=top nowrap>\n" );
} else {
- $checked = "";
- }
- $wgOut->addHTML( "<tr valign=\"top\"><td><input type=checkbox value=\"1\" "
- . "id=\"$tname\" name=\"wpOp$tname\"$checked></td><td><label for=\"$tname\">$ttext</label></td></tr>\n" );
- }
- $wgOut->addHTML( "</table></td>" );
-
- # Math setting
- #
- $wgOut->addHTML( "<tr><td valign=top nowrap><b>$math:</b><br>\n" );
- for ( $i = 0; $i < count( $mathopts ); ++$i ) {
- if ( $i == $wpMath ) { $checked = " checked"; }
- else { $checked = ""; }
- $wgOut->addHTML( "<label><input type=radio name=\"wpMath\"
-value=\"$i\"$checked> {$mathopts[$i]}</label><br>\n" );
- }
- $wgOut->addHTML( "</td></tr>" );
-
- # Date format
- #
- if ( $wgUseDynamicDates ) {
- $wgOut->addHTML( "<tr><td valign=top nowrap><b>$dateFormat:</b><br>" );
- for ( $i = 0; $i < count( $dateopts ); ++$i) {
- if ( $i == $wpDate ) {
+ $wgOut->addHTML( "</td><td rowspan=2 valign=top nowrap>\n" );
+ }
+ $wgOut->addHTML("<table border=0>");
+ foreach ( $togs as $tname => $ttext ) {
+ if ( 1 == $wgUser->getOption( $tname ) ) {
$checked = " checked";
} else {
$checked = "";
+ }
+ $wgOut->addHTML( "<tr valign=\"top\"><td><input type=checkbox value=\"1\" "
+ . "id=\"$tname\" name=\"wpOp$tname\"$checked></td><td><label for=\"$tname\">$ttext</label></td></tr>\n" );
+ }
+ $wgOut->addHTML( "</table></td>" );
+
+ # Math setting
+ #
+ $wgOut->addHTML( "<tr><td valign=top nowrap><b>$math:</b><br>\n" );
+ for ( $i = 0; $i < count( $mathopts ); ++$i ) {
+ if ( $i == $this->mMath ) { $checked = " checked"; }
+ else { $checked = ""; }
+ $wgOut->addHTML( "<label><input type=radio name=\"wpMath\"
+ value=\"$i\"$checked> {$mathopts[$i]}</label><br>\n" );
+ }
+ $wgOut->addHTML( "</td></tr>" );
+
+ # Date format
+ #
+ if ( $wgUseDynamicDates ) {
+ $wgOut->addHTML( "<tr><td valign=top nowrap><b>$dateFormat:</b><br>" );
+ for ( $i = 0; $i < count( $dateopts ); ++$i) {
+ if ( $i == $this->mDate ) {
+ $checked = " checked";
+ } else {
+ $checked = "";
+ }
+ $wgOut->addHTML( "<label><input type=radio name=\"wpDate\" ".
+ "value=\"$i\"$checked> {$dateopts[$i]}</label><br>\n" );
}
- $wgOut->addHTML( "<label><input type=radio name=\"wpDate\" ".
- "value=\"$i\"$checked> {$dateopts[$i]}</label><br>\n" );
+ $wgOut->addHTML( "</td></tr>");
}
- $wgOut->addHTML( "</td></tr>");
+ # Textbox rows, cols
+ #
+ $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
+ $nowserver = $wgLang->time( $now, false );
+ $wgOut->addHTML( "<td valign=top nowrap><b>$tbs:</b><br>
+ <label>$tbr: <input type=text name=\"wpRows\" value=\"{$this->mRows}\" size=6></label><br>
+ <label>$tbc: <input type=text name=\"wpCols\" value=\"{$this->mCols}\" size=6></label><br><br>
+ <b>$tzServerTime:</b> $nowserver<br />
+ <b>$ltz:</b> $nowlocal<br />
+ <label>$tzo*: <input type=text name=\"wpHourDiff\" value=\"{$this->mHourDiff}\" size=6></label><br />
+ <input type=\"button\" value=\"$tzGuess\" onClick=\"javascript:guessTimezone()\" />
+ </td>" );
+
+ # Email, etc.
+ #
+ $this->mUserEmail = wfEscapeHTML( $this->mUserEmail );
+ $this->mNick = wfEscapeHTML( $this->mNick );
+ if ( $this->mEmailFlag ) { $emfc = "checked"; }
+ else { $emfc = ""; }
+
+ $ps = $this->namespacesCheckboxes();
+
+ $wgOut->addHTML( "<td valign=top nowrap>
+ <label>$yem: <input type=text name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size=20></label><br>
+ <label><input type=checkbox $emfc value=\"1\" name=\"wpEmailFlag\"> $emf</label><br>
+ <label>$ynn: <input type=text name=\"wpNick\" value=\"{$this->mNick}\" size=12></label><br>
+ <label>$rcc: <input type=text name=\"wpRecent\" value=\"$this->mRecent\" size=6></label><br>
+ <label>$stt: <input type=text name=\"wpStubs\" value=\"$this->mStubs\" size=6></label><br>
+ <strong>{$srh}:</strong><br>
+ <label>$rpp: <input type=text name=\"wpSearch\" value=\"$this->mSearch\" size=6></label><br>
+ <label>$scl: <input type=text name=\"wpSearchLines\" value=\"$this->mSearchLines\" size=6></label><br>
+ <label>$scc: <input type=text name=\"wpSearchChars\" value=\"$this->mSearchChars\" size=6></label></td>
+ </tr><tr>
+ <td colspan=2>
+ <b>$dsn</b><br>
+ $ps
+ </td>
+ </tr><tr>
+ <td align=center><input type=submit name=\"wpSaveprefs\" value=\"$svp\"></td>
+ <td align=center><input type=submit name=\"wpReset\" value=\"$rsp\"></td>
+ </tr></table>* {$tzt} </form>\n" );
}
- # Textbox rows, cols
- #
- $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
- $nowserver = $wgLang->time( $now, false );
- $wgOut->addHTML( "<td valign=top nowrap><b>$tbs:</b><br>
-<label>$tbr: <input type=text name=\"wpRows\" value=\"{$wpRows}\" size=6></label><br>
-<label>$tbc: <input type=text name=\"wpCols\" value=\"{$wpCols}\" size=6></label><br><br>
-<b>$tzServerTime:</b> $nowserver<br />
-<b>$ltz:</b> $nowlocal<br />
-<label>$tzo*: <input type=text name=\"wpHourDiff\" value=\"{$wpHourDiff}\" size=6></label><br />
-<input type=\"button\" value=\"$tzGuess\" onClick=\"javascript:guessTimezone()\" />
-</td>" );
-
- # Email, etc.
- #
- $wpUserEmail = wfEscapeHTML( $wpUserEmail );
- $wpNick = wfEscapeHTML( $wpNick );
- if ( $wpEmailFlag ) { $emfc = "checked"; }
- else { $emfc = ""; }
-
- $ps = namespacesCheckboxes();
-
- $wgOut->addHTML( "<td valign=top nowrap>
-<label>$yem: <input type=text name=\"wpUserEmail\" value=\"{$wpUserEmail}\" size=20></label><br>
-<label><input type=checkbox $emfc value=\"1\" name=\"wpEmailFlag\"> $emf</label><br>
-<label>$ynn: <input type=text name=\"wpNick\" value=\"{$wpNick}\" size=12></label><br>
-<label>$rcc: <input type=text name=\"wpRecent\" value=\"$wpRecent\" size=6></label><br>
-<label>$stt: <input type=text name=\"wpStubs\" value=\"$wpStubs\" size=6></label><br>
-<strong>{$srh}:</strong><br>
-<label>$rpp: <input type=text name=\"wpSearch\" value=\"$wpSearch\" size=6></label><br>
-<label>$scl: <input type=text name=\"wpSearchLines\" value=\"$wpSearchLines\" size=6></label><br>
-<label>$scc: <input type=text name=\"wpSearchChars\" value=\"$wpSearchChars\" size=6></label></td>
-</tr><tr>
-<td colspan=2>
-<b>$dsn</b><br>
-$ps
-</td>
-</tr><tr>
-<td align=center><input type=submit name=\"wpSaveprefs\" value=\"$svp\"></td>
-<td align=center><input type=submit name=\"wpReset\" value=\"$rsp\"></td>
-</tr></table>* {$tzt} </form>\n" );
}
-
?>
{
global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgDBname;
global $wgRequest, $wgSitename, $wgLanguageCode;
- global $days, $hideminor, $from, $hidebots, $hideliu; # From query string
$fname = "wfSpecialRecentchanges";
+ # Get query parameters
$feedFormat = $wgRequest->getVal( "feed" );
$feeding = ( $feedFormat == "rss" );
+
+ $defaultDays = $wgUser->getOption( 'rcdays' );
+ if ( !$defaultDays ) {
+ $defaultDays = 3;
+ }
+
+ $days = $wgRequest->getInt( 'days', $defaultDays );
+ $hideminor = $wgRequest->getBool( 'hideminor', $wgUser->getOption( 'hideminor' ) ) ? 1 : 0;
+ $from = $wgRequest->getText( 'from' );
+ $hidebots = $wgRequest->getBool( 'hidebots', true ) ? 1 : 0;
+ $hideliu = $wgRequest->getBool( 'hideliu', false ) ? 1 : 0;
+ # Get query parameters from path
if( $par ) {
$bits = preg_split( '/\s*,\s*/', trim( $par ) );
if( in_array( "hidebots", $bits ) ) $hidebots = 1;
}
$wgOut->addWikiText( $rctext );
-
- if ( ! $days ) {
- $days = $wgUser->getOption( "rcdays" );
- if ( ! $days ) { $days = 3; }
- }
- $days = (int)$days;
+
list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
$now = wfTimestampNow();
$cutoff_unixtime = time() - ( $days * 86400 );
$sk = $wgUser->getSkin();
$showhide = array( wfMsg( "show" ), wfMsg( "hide" ));
- if ( ! isset( $hideminor ) ) {
- $hideminor = $wgUser->getOption( "hideminor" );
- }
- $hideminor = ($hideminor ? 1 : 0);
if ( $hideminor ) {
$hidem = "AND rc_minor=0";
} else {
$hidem = "";
}
- if ( !isset( $hidebots ) ) {
- $hidebots = 1;
- }
if( $hidebots ) {
$hidem .= " AND rc_bot=0";
}
- $hidebots = ($hidebots ? 1 : 0);
- if ( !isset( $hideliu ) ) {
- $hideliu = 0;
- }
if ( $hideliu ) {
$hidem .= " AND rc_user=0";
}
function wfSpecialUndelete( $par )
{
- global $wgLang, $wgUser, $wgOut, $action, $target, $timestamp, $restore;
-
- if( $par != "" ) $target = $par;
- if( isset($target ) ) {
- $t = Title::newFromURL( $target );
- $title = $t->mDbkeyform;
- $namespace = $t->mNamespace;
- if( isset( $timestamp ) ) {
- return doUndeleteShowRevision( $namespace, $title, $timestamp );
- }
- if( isset( $action ) and isset( $restore) and $action == "submit" ) {
- return doUndeleteArticle( $namespace, $title );
- }
- return doUndeleteShowHistory( $namespace, $title );
- }
-
- # List undeletable articles
- $sql = "SELECT ar_namespace,ar_title, COUNT(*) AS count FROM archive GROUP BY ar_namespace,ar_title ORDER BY ar_namespace,ar_title";
- $res = wfQuery( $sql, DB_READ );
-
- $wgOut->setPagetitle( wfMsg( "undeletepage" ) );
- $wgOut->addWikiText( wfMsg( "undeletepagetext" ) );
-
- $special = $wgLang->getNsText( Namespace::getSpecial() );
- $sk = $wgUser->getSkin();
- $wgOut->addHTML( "<ul>\n" );
- while ($row = wfFetchObject( $res )) {
- $n = ($row->ar_namespace ?
- ($wgLang->getNsText( $row->ar_namespace ) . ":") : "").
- $row->ar_title;
-
- $wgOut->addHTML( "<li>" .
- $sk->makeKnownLink( $wgLang->specialPage( "Undelete" ),
- $n, "target=" . urlencode($n) ) . " " .
- wfMsg( "undeleterevisions", $row->count ) );
- }
- $wgOut->addHTML( "</ul>\n" );
-
- return $ret;
-}
+ global $wgRequest;
-/* private */ function doUndeleteShowRevision( $namespace, $title, $timestamp ) {
- global $wgLang, $wgUser, $wgOut, $action, $target, $timestamp, $restore;
-
- if(!preg_match("/[0-9]{14}/",$timestamp)) return 0;
-
- $sql = "SELECT ar_text,ar_flags FROM archive WHERE ar_namespace={$namespace} AND ar_title=\"{$title}\" AND ar_timestamp={$timestamp}";
- $ret = wfQuery( $sql, DB_READ );
- $row = wfFetchObject( $ret );
-
- $wgOut->setPagetitle( wfMsg( "undeletepage" ) );
- $wgOut->addWikiText( "(" . wfMsg( "undeleterevision", $wgLang->date($timestamp, true) )
- . ")\n<hr>\n" . Article::getRevisionText( $row, "ar_" ) );
-
- return 0;
+ $form = new UndeleteForm( $wgRequest, $par );
+ $form->execute();
}
-/* private */ function doUndeleteShowHistory( $namespace, $title ) {
- global $wgLang, $wgUser, $wgOut, $action, $target, $timestamp, $restore;
-
- $sk = $wgUser->getSkin();
- $wgOut->setPagetitle( wfMsg( "undeletepage" ) );
+class UndeleteForm {
+ var $mAction, $mTarget, $mTimestamp, $mRestore, $mTargetObj;
+
+ function UndeleteForm( &$request, $par = "" ) {
+ $this->mAction = $request->getText( 'action' );
+ $this->mTarget = $request->getText( 'target' );
+ $this->mTimestamp = $request->getText( 'timestamp' );
+ $this->mRestore = $request->getCheck( 'restore' );
+ if( $par != "" ) {
+ $this->mTarget = $par;
+ }
+ if ( $this->mTarget !== "" ) {
+ $this->mTargetObj = Title::newFromURL( $this->mTarget );
+ } else {
+ $this->mTargetObj = NULL;
+ }
+ }
+
+ function execute() {
+ if( !is_null( $this->mTargetObj ) ) {
+ $title = $this->mTargetObj->mDbkeyform;
+ $namespace = $this->mTargetObj->mNamespace;
+ if( $this->mTimestamp !== "" ) {
+ return $this->showRevision( $namespace, $title, $this->mTimestamp );
+ }
+ if( $this->mRestore and $this->mAction == "submit" ) {
+ return $this->undelete( $namespace, $title );
+ }
+ return $this->showHistory( $namespace, $title );
+ } else {
+ return $this->showList();
+ }
+ }
+
+ /* private */ function showList() {
+ global $wgLang, $wgUser, $wgOut;
+ $fname = "UndeleteForm::showList";
+
+ # List undeletable articles
+ $sql = "SELECT ar_namespace,ar_title, COUNT(*) AS count FROM archive " .
+ "GROUP BY ar_namespace,ar_title ORDER BY ar_namespace,ar_title";
+ $res = wfQuery( $sql, DB_READ, $fname );
+
+ $wgOut->setPagetitle( wfMsg( "undeletepage" ) );
+ $wgOut->addWikiText( wfMsg( "undeletepagetext" ) );
+
+ $special = $wgLang->getNsText( Namespace::getSpecial() );
+ $sk = $wgUser->getSkin();
+ $wgOut->addHTML( "<ul>\n" );
+ while ($row = wfFetchObject( $res )) {
+ $n = ($row->ar_namespace ?
+ ($wgLang->getNsText( $row->ar_namespace ) . ":") : "").
+ $row->ar_title;
+
+ $wgOut->addHTML( "<li>" .
+ $sk->makeKnownLink( $wgLang->specialPage( "Undelete" ),
+ $n, "target=" . urlencode($n) ) . " " .
+ wfMsg( "undeleterevisions", $row->count ) );
+ }
+ $wgOut->addHTML( "</ul>\n" );
+
+ return 0;
+ }
- # Get text of first revision
- $sql = "SELECT ar_text FROM archive WHERE ar_namespace={$namespace} AND ar_title=\"{$title}\"
- ORDER BY ar_timestamp DESC LIMIT 1";
- $ret = wfQuery( $sql, DB_READ );
+ /* private */ function showRevision( $namespace, $title, $timestamp ) {
+ global $wgLang, $wgUser, $wgOut;
+ $fname = "UndeleteForm::showRevision";
+
+ if(!preg_match("/[0-9]{14}/",$timestamp)) return 0;
+
+ $sql = "SELECT ar_text,ar_flags FROM archive ".
+ "WHERE ar_namespace={$namespace} AND ar_title=\"{$title}\" AND ar_timestamp={$timestamp}";
+ $ret = wfQuery( $sql, DB_READ, $fname );
+ $row = wfFetchObject( $ret );
+
+ $wgOut->setPagetitle( wfMsg( "undeletepage" ) );
+ $wgOut->addWikiText( "(" . wfMsg( "undeleterevision", $wgLang->date($timestamp, true) )
+ . ")\n<hr>\n" . Article::getRevisionText( $row, "ar_" ) );
- if( wfNumRows( $ret ) == 0 ) {
- $wgOut->addWikiText( wfMsg( "nohistory" ) );
return 0;
}
- $row = wfFetchObject( $ret );
- $wgOut->addWikiText( wfMsg( "undeletehistory" ) . "\n<hr>\n" . $row->ar_text );
-
- # Get remaining revisions
- $sql = "SELECT ar_minor_edit,ar_timestamp,ar_user,ar_user_text,ar_comment
- FROM archive WHERE ar_namespace={$namespace} AND ar_title=\"{$title}\"
- ORDER BY ar_timestamp DESC";
- $ret = wfQuery( $sql, DB_READ );
- # Ditch first row
- $row = wfFetchObject( $ret );
-
- $titleObj = Title::makeTitle( NS_SPECIAL, "Undelete" );
- $action = $titleObj->escapeLocalURL( "action=submit" );
- $wgOut->addHTML("<p>
-<form id=\"undelete\" method=\"post\" action=\"{$action}\">
-<input type=hidden name=\"target\" value=\"{$target}\">
-<input type=submit name=\"restore\" value=\"".wfMsg("undeletebtn")."\">
-</form>");
-
- $log = wfGetSQL("cur", "cur_text", "cur_namespace=4 AND cur_title=\"".wfMsg("dellogpage")."\"" );
- if(preg_match("/^(.*".
- preg_quote( ($namespace ? ($wgLang->getNsText($namespace) . ":") : "")
- . str_replace("_", " ", $title), "/" ).".*)$/m", $log, $m)) {
- $wgOut->addWikiText( $m[1] );
- }
-
- $special = $wgLang->getNsText( Namespace::getSpecial() );
- $wgOut->addHTML("<ul>");
- while( $row = wfFetchObject( $ret ) ) {
- $wgOut->addHTML( "<li>" .
- $sk->makeKnownLink( $wgLang->specialPage( "Undelete" ),
- $wgLang->timeanddate( $row->ar_timestamp, true ),
- "target=" . urlencode($target) . "×tamp={$row->ar_timestamp}" ) . " " .
- ". . {$row->ar_user_text}" .
- " <i>(" . htmlspecialchars($row->ar_comment) . "</i>)\n");
-
- }
- $wgOut->addHTML("</ul>");
-
- return 0;
-}
-
-/* private */ function doUndeleteArticle( $namespace, $title )
+
+ /* private */ function showHistory( $namespace, $title ) {
+ global $wgLang, $wgUser, $wgOut;
+
+ $sk = $wgUser->getSkin();
+ $wgOut->setPagetitle( wfMsg( "undeletepage" ) );
+
+ # Get text of first revision
+ $sql = "SELECT ar_text FROM archive WHERE ar_namespace={$namespace} AND ar_title=\"{$title}\"
+ ORDER BY ar_timestamp DESC LIMIT 1";
+ $ret = wfQuery( $sql, DB_READ );
+
+ if( wfNumRows( $ret ) == 0 ) {
+ $wgOut->addWikiText( wfMsg( "nohistory" ) );
+ return 0;
+ }
+ $row = wfFetchObject( $ret );
+ $wgOut->addWikiText( wfMsg( "undeletehistory" ) . "\n<hr>\n" . $row->ar_text );
+
+ # Get remaining revisions
+ $sql = "SELECT ar_minor_edit,ar_timestamp,ar_user,ar_user_text,ar_comment
+ FROM archive WHERE ar_namespace={$namespace} AND ar_title=\"{$title}\"
+ ORDER BY ar_timestamp DESC";
+ $ret = wfQuery( $sql, DB_READ );
+ # Ditch first row
+ $row = wfFetchObject( $ret );
+
+ $titleObj = Title::makeTitle( NS_SPECIAL, "Undelete" );
+ $action = $titleObj->escapeLocalURL( "action=submit" );
+ $encTarget = htmlspecialchars( $this->mTarget );
+
+ $wgOut->addHTML("<p>
+ <form id=\"undelete\" method=\"post\" action=\"{$action}\">
+ <input type=hidden name=\"target\" value=\"{$encTarget}\">
+ <input type=submit name=\"restore\" value=\"".wfMsg("undeletebtn")."\">
+ </form>");
+
+ $log = wfGetSQL("cur", "cur_text", "cur_namespace=4 AND cur_title=\"".wfMsg("dellogpage")."\"" );
+ if(preg_match("/^(.*".
+ preg_quote( ($namespace ? ($wgLang->getNsText($namespace) . ":") : "")
+ . str_replace("_", " ", $title), "/" ).".*)$/m", $log, $m)) {
+ $wgOut->addWikiText( $m[1] );
+ }
+
+ $special = $wgLang->getNsText( Namespace::getSpecial() );
+ $wgOut->addHTML("<ul>");
+ while( $row = wfFetchObject( $ret ) ) {
+ $wgOut->addHTML( "<li>" .
+ $sk->makeKnownLink( $wgLang->specialPage( "Undelete" ),
+ $wgLang->timeanddate( $row->ar_timestamp, true ),
+ "target=" . urlencode($this->mTarget) . "×tamp={$row->ar_timestamp}" ) . " " .
+ ". . {$row->ar_user_text}" .
+ " <i>(" . htmlspecialchars($row->ar_comment) . "</i>)\n");
+
+ }
+ $wgOut->addHTML("</ul>");
+
+ return 0;
+ }
+
+ /* private */ function undelete( $namespace, $title )
{
- global $wgUser, $wgOut, $wgLang, $target, $wgDeferredUpdateList;
+ global $wgUser, $wgOut, $wgLang, $wgDeferredUpdateList;
global $wgUseSquid, $wgInternalServer;
$fname = "doUndeleteArticle";
"ar_user,ar_user_text,ar_timestamp,99999999999999-ar_timestamp,ar_minor_edit,{$redir},RAND(),'{$now}' FROM archive " .
"WHERE ar_namespace={$namespace} AND ar_title='{$t}' AND ar_timestamp={$max}";
wfQuery( $sql, DB_WRITE, $fname );
- $newid = wfInsertId();
+ $newid = wfInsertId();
$oldones = "AND ar_timestamp<{$max}";
} else {
# If already exists, put history entirely into old table
"FROM archive WHERE ar_namespace={$namespace} AND ar_title='{$t}' {$oldones}";
wfQuery( $sql, DB_WRITE, $fname );
- # Finally, clean up the link tables
+ # Finally, clean up the link tables
if( $newid ) {
# Create a dummy OutputPage to update the outgoing links
# This works at the moment due to good luck. It may stop working in the
# future. Damn globals.
$dummyOut = new OutputPage();
- $to = Title::newFromDBKey( $target );
$res = wfQuery( "SELECT cur_text FROM cur WHERE cur_id={$newid} " .
"AND cur_namespace={$namespace}", DB_READ, $fname );
$row = wfFetchObject( $res );
$dummyOut->addWikiText( $text );
wfFreeResult( $res );
- $u = new LinksUpdate( $newid, $to->getPrefixedDBkey() );
+ $u = new LinksUpdate( $newid, $this->mTargetObj->getPrefixedDBkey() );
array_push( $wgDeferredUpdateList, $u );
- Article::onArticleCreate( $to );
+ Article::onArticleCreate( $this->mTargetObj );
#TODO: SearchUpdate, etc.
}
# Touch the log?
$log = new LogPage( wfMsg( "dellogpage" ), wfMsg( "dellogpagetext" ) );
- $log->addEntry( wfMsg( "undeletedarticle", $target ), "" );
+ $log->addEntry( wfMsg( "undeletedarticle", $this->mTarget ), "" );
- $wgOut->addWikiText( wfMsg( "undeletedtext", $target ) );
+ $wgOut->addWikiText( wfMsg( "undeletedtext", $this->mTarget ) );
return 0;
}
+}
?>
User::SetupSession();
}
- $fields = array( "wpName", "wpPassword", "wpName",
- "wpPassword", "wpRetype" );
- # FIXME: UGLY HACK
- foreach( $fields as $x ) {
- $_REQUEST[$x] = $wgRequest->getText( $x );
- }
+ $form = new LoginForm( $wgRequest );
+ $form->execute();
+}
- # When switching accounts, it sucks to get automatically logged out
- global $wgLang;
- if( $wgRequest->getVal( 'returnto' ) == $wgLang->specialPage( "Userlogout" ) ) {
- $_REQUEST['returnto'] = "";
- }
+class LoginForm {
+ var $mName, $mPassword, $mRetype, $mReturnto, $mCookieCheck, $mPosted;
+ var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
+ var $mLoginattempt, $mRemember, $mEmail;
- $wpCookieCheck = $wgRequest->getVal( "wpCookieCheck" );
-
- if ( isset( $wpCookieCheck ) ) {
- onCookieRedirectCheck( $wpCookieCheck );
- } else if( $wgRequest->wasPosted() ) {
- if( $wgRequest->getCheck( 'wpCreateaccount' ) ) {
- return addNewAccount();
- } else if ( $wgRequest->getCheck( 'wpCreateaccountMail' ) ) {
- return addNewAccountMailPassword();
- } else if ( $wgRequest->getCheck( 'wpMailmypassword' ) ) {
- return mailPassword();
- } else if ( "submit" == $wgRequest->getVal( 'action' ) || $wgRequest->getCheck( 'wpLoginattempt' ) ) {
- return processLogin();
+ function LoginForm( &$request ) {
+ global $wgLang;
+
+ $this->mName = $request->getText( 'wpName' );
+ $this->mPassword = $request->getText( 'wpPassword' );
+ $this->mRetype = $request->getText( 'wpRetype' );
+ $this->mReturnto = $request->getText( 'returnto' );
+ $this->mCookieCheck = $request->getVal( "wpCookieCheck" );
+ $this->mPosted = $request->wasPosted();
+ $this->mCreateaccount = $request->getCheck( 'wpCreateaccount' );
+ $this->mCreateaccountMail = $request->getCheck( 'wpCreateaccountMail' );
+ $this->mMailmypassword = $request->getCheck( 'wpMailmypassword' );
+ $this->mLoginattempt = $request->getCheck( 'wpLoginattempt' );
+ $this->mAction = $request->getVal( 'action' );
+ $this->mRemember = $request->getCheck( 'wpRemember' );
+ $this->mEmail = $request->getText( 'wpEmail' );
+
+ # When switching accounts, it sucks to get automatically logged out
+ if( $this->mReturnto == $wgLang->specialPage( "Userlogout" ) ) {
+ $this->mReturnto = "";
}
}
- mainLoginForm( "" );
-}
-
-/* private */ function addNewAccountMailPassword()
-{
- global $wgOut;
-
- if ("" == $_REQUEST['wpEmail']) {
- mainLoginForm( wfMsg( "noemail", $_REQUEST['wpName'] ) );
- return;
+ function execute() {
+ if ( !is_null( $this->mCookieCheck ) ) {
+ $this->onCookieRedirectCheck( $this->mCookieCheck );
+ } else if( $this->mPosted ) {
+ if( $this->mCreateaccount ) {
+ return $this->addNewAccount();
+ } else if ( $this->mCreateaccountMail ) {
+ return $this->addNewAccountMailPassword();
+ } else if ( $this->mMailmypassword ) {
+ return $this->mailPassword();
+ } else if ( ( "submit" == $this->mAction ) || $this->mLoginattempt ) {
+ return $this->processLogin();
+ }
+ }
+ $this->mainLoginForm( "" );
}
- $u = addNewaccountInternal();
+ /* private */ function addNewAccountMailPassword()
+ {
+ global $wgOut;
+
+ if ("" == $this->mEmail) {
+ $this->mainLoginForm( wfMsg( "noemail", $this->mName ) );
+ return;
+ }
- if ($u == NULL) {
- return;
- }
+ $u = $this->addNewaccountInternal();
- $u->saveSettings();
- if (mailPasswordInternal($u) == NULL) {
- return;
- }
+ if ($u == NULL) {
+ return;
+ }
- $wgOut->setPageTitle( wfMsg( "accmailtitle" ) );
- $wgOut->setRobotpolicy( "noindex,nofollow" );
- $wgOut->setArticleRelated( false );
+ $u->saveSettings();
+ $error = $this->mailPasswordInternal($u);
- $wgOut->addWikiText( wfMsg( "accmailtext", $u->getName(), $u->getEmail() ) );
- $wgOut->returnToMain( false );
+ $wgOut->setPageTitle( wfMsg( "accmailtitle" ) );
+ $wgOut->setRobotpolicy( "noindex,nofollow" );
+ $wgOut->setArticleRelated( false );
+
+ if ( $error === "" ) {
+ $wgOut->addWikiText( wfMsg( "accmailtext", $u->getName(), $u->getEmail() ) );
+ $wgOut->returnToMain( false );
+ } else {
+ $this->mainLoginForm( wfMsg( "mailerror", $error ) );
+ }
- $u = 0;
-}
+ $u = 0;
+ }
-/* private */ function addNewAccount()
-{
- global $wgUser, $wgOut;
- global $wgDeferredUpdateList;
+ /* private */ function addNewAccount()
+ {
+ global $wgUser, $wgOut;
+ global $wgDeferredUpdateList;
- $u = addNewAccountInternal();
+ $u = $this->addNewAccountInternal();
- if ($u == NULL) {
- return;
- }
+ if ($u == NULL) {
+ return;
+ }
- $wgUser = $u;
- $wgUser->setCookies();
+ $wgUser = $u;
+ $wgUser->setCookies();
- $up = new UserUpdate();
- array_push( $wgDeferredUpdateList, $up );
+ $up = new UserUpdate();
+ array_push( $wgDeferredUpdateList, $up );
- if( hasSessionCookie() ) {
- return successfulLogin( wfMsg( "welcomecreation", $wgUser->getName() ) );
- } else {
- return cookieRedirectCheck( "new" );
+ if( $this->hasSessionCookie() ) {
+ return $this->successfulLogin( wfMsg( "welcomecreation", $wgUser->getName() ) );
+ } else {
+ return $this->cookieRedirectCheck( "new" );
+ }
}
-}
-/* private */ function addNewAccountInternal()
-{
- global $wgUser, $wgOut;
- global $wgMaxNameChars;
- global $wgRequest;
+ /* private */ function addNewAccountInternal()
+ {
+ global $wgUser, $wgOut;
+ global $wgMaxNameChars;
- if (!$wgUser->isAllowedToCreateAccount()) {
- userNotPrivilegedMessage();
- return;
- }
+ if (!$wgUser->isAllowedToCreateAccount()) {
+ $this->userNotPrivilegedMessage();
+ return;
+ }
- if ( 0 != strcmp( $_REQUEST['wpPassword'], $_REQUEST['wpRetype'] ) ) {
- mainLoginForm( wfMsg( "badretype" ) );
- return;
- }
-
- $name = trim( $_REQUEST['wpName'] );
- if ( ( "" == $name ) ||
- preg_match( "/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/", $name ) ||
- (strpos( $name, "/" ) !== false) ||
- (strlen( $name ) > $wgMaxNameChars) )
- {
- mainLoginForm( wfMsg( "noname" ) );
- return;
- }
- if ( wfReadOnly() ) {
- $wgOut->readOnlyPage();
- return;
- }
- $u = User::newFromName( $name );
-
- if ( 0 != $u->idForName() ) {
- mainLoginForm( wfMsg( "userexists" ) );
- return;
+ if ( 0 != strcmp( $this->mPassword, $this->mRetype ) ) {
+ $this->mainLoginForm( wfMsg( "badretype" ) );
+ return;
+ }
+
+ $name = trim( $this->mName );
+ if ( ( "" == $name ) ||
+ preg_match( "/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/", $name ) ||
+ (strpos( $name, "/" ) !== false) ||
+ (strlen( $name ) > $wgMaxNameChars) )
+ {
+ $this->mainLoginForm( wfMsg( "noname" ) );
+ return;
+ }
+ if ( wfReadOnly() ) {
+ $wgOut->readOnlyPage();
+ return;
+ }
+ $u = User::newFromName( $name );
+
+ if ( 0 != $u->idForName() ) {
+ $this->mainLoginForm( wfMsg( "userexists" ) );
+ return;
+ }
+ $u->addToDatabase();
+ $u->setPassword( $this->mPassword );
+ $u->setEmail( $this->mEmail );
+ if ( $this->mRemember ) { $r = 1; }
+ else { $r = 0; }
+ $u->setOption( "rememberpassword", $r );
+
+ return $u;
}
- $u->addToDatabase();
- $u->setPassword( $_REQUEST['wpPassword'] );
- $u->setEmail( $_REQUEST['wpEmail'] );
- if ( $wgRequest->getCheck( 'wpRemember' ) ) { $r = 1; }
- else { $r = 0; }
- $u->setOption( "rememberpassword", $r );
-
- return $u;
-}
+ /* private */ function processLogin()
+ {
+ global $wgUser;
+ global $wgDeferredUpdateList;
-/* private */ function processLogin()
-{
- global $wgUser;
- global $wgDeferredUpdateList;
- global $wgRequest;
-
- if ( "" == $_REQUEST['wpName'] ) {
- mainLoginForm( wfMsg( "noname" ) );
- return;
- }
- $u = User::newFromName( $_REQUEST['wpName'] );
- $id = $u->idForName();
- if ( 0 == $id ) {
- mainLoginForm( wfMsg( "nosuchuser", $u->getName() ) );
- return;
- }
- $u->setId( $id );
- $u->loadFromDatabase();
- $ep = $u->encryptPassword( $_REQUEST['wpPassword'] );
- if ( 0 != strcmp( $ep, $u->getPassword() ) ) {
- if ( 0 != strcmp( $ep, $u->getNewpassword() ) ) {
- mainLoginForm( wfMsg( "wrongpassword" ) );
+ if ( "" == $this->mName ) {
+ $this->mainLoginForm( wfMsg( "noname" ) );
return;
}
- }
+ $u = User::newFromName( $this->mName );
+ $id = $u->idForName();
+ if ( 0 == $id ) {
+ $this->mainLoginForm( wfMsg( "nosuchuser", $u->getName() ) );
+ return;
+ }
+ $u->setId( $id );
+ $u->loadFromDatabase();
+ $ep = $u->encryptPassword( $this->mPassword );
+ if ( 0 != strcmp( $ep, $u->getPassword() ) ) {
+ if ( 0 != strcmp( $ep, $u->getNewpassword() ) ) {
+ $this->mainLoginForm( wfMsg( "wrongpassword" ) );
+ return;
+ }
+ }
- # We've verified now, update the real record
- #
- if ( $wgRequest->getCheck( 'wpRemember' ) ) {
- $r = 1;
- $u->setCookiePassword( $wgRequest->getText( 'wpPassword' ) );
- } else {
- $r = 0;
- }
- $u->setOption( "rememberpassword", $r );
+ # We've verified now, update the real record
+ #
+ if ( $this->mRemember ) {
+ $r = 1;
+ $u->setCookiePassword( $this->mPassword );
+ } else {
+ $r = 0;
+ }
+ $u->setOption( "rememberpassword", $r );
- $wgUser = $u;
- $wgUser->setCookies();
+ $wgUser = $u;
+ $wgUser->setCookies();
- $up = new UserUpdate();
- array_push( $wgDeferredUpdateList, $up );
+ $up = new UserUpdate();
+ array_push( $wgDeferredUpdateList, $up );
- if( hasSessionCookie() ) {
- return successfulLogin( wfMsg( "loginsuccess", $wgUser->getName() ) );
- } else {
- return cookieRedirectCheck( "login" );
+ if( $this->hasSessionCookie() ) {
+ return $this->successfulLogin( wfMsg( "loginsuccess", $wgUser->getName() ) );
+ } else {
+ return $this->cookieRedirectCheck( "login" );
+ }
}
-}
-/* private */ function mailPassword()
-{
- global $wgUser, $wgDeferredUpdateList, $wgOutputEncoding;
- global $wgCookiePath, $wgCookieDomain, $wgDBname;
+ /* private */ function mailPassword()
+ {
+ global $wgUser, $wgDeferredUpdateList, $wgOutputEncoding;
+ global $wgCookiePath, $wgCookieDomain, $wgDBname;
- if ( "" == $_REQUEST['wpName'] ) {
- mainLoginForm( wfMsg( "noname" ) );
- return;
- }
- $u = User::newFromName( $_REQUEST['wpName'] );
- $id = $u->idForName();
- if ( 0 == $id ) {
- mainLoginForm( wfMsg( "nosuchuser", $u->getName() ) );
- return;
- }
- $u->setId( $id );
- $u->loadFromDatabase();
+ if ( "" == $this->mName ) {
+ $this->mainLoginForm( wfMsg( "noname" ) );
+ return;
+ }
+ $u = User::newFromName( $this->mName );
+ $id = $u->idForName();
+ if ( 0 == $id ) {
+ $this->mainLoginForm( wfMsg( "nosuchuser", $u->getName() ) );
+ return;
+ }
+ $u->setId( $id );
+ $u->loadFromDatabase();
+
+ $error = $this->mailPasswordInternal( $u );
+ if ($error === "") {
+ $this->mainLoginForm( wfMsg( "passwordsent", $u->getName() ) );
+ } else {
+ $this->mainLoginForm( wfMsg( "mailerror", $error ) );
+ }
- if (mailPasswordInternal($u) == NULL) {
- return;
}
- mainLoginForm( wfMsg( "passwordsent", $u->getName() ) );
-}
+ /* private */ function mailPasswordInternal( $u )
+ {
+ global $wgDeferredUpdateList, $wgOutputEncoding;
+ global $wgPasswordSender, $wgDBname, $wgIP;
+ global $wgCookiePath, $wgCookieDomain;
-/* private */ function mailPasswordInternal( $u )
-{
- global $wgDeferredUpdateList, $wgOutputEncoding;
- global $wgPasswordSender, $wgDBname, $wgIP;
+ if ( "" == $u->getEmail() ) {
+ $this->mainLoginForm( wfMsg( "noemail", $u->getName() ) );
+ return;
+ }
+ $np = User::randomPassword();
+ $u->setNewpassword( $np );
- if ( "" == $u->getEmail() ) {
- mainLoginForm( wfMsg( "noemail", $u->getName() ) );
- return;
- }
- $np = User::randomPassword();
- $u->setNewpassword( $np );
+ setcookie( "{$wgDBname}Password", "", time() - 3600, $wgCookiePath, $wgCookieDomain );
+ $u->saveSettings();
- setcookie( "{$wgDBname}Password", "", time() - 3600, $wgCookiePath, $wgCookieDomain );
- $u->saveSettings();
+ $ip = $wgIP;
+ if ( "" == $ip ) { $ip = "(Unknown)"; }
- $ip = $wgIP;
- if ( "" == $ip ) { $ip = "(Unknown)"; }
+ $m = wfMsg( "passwordremindertext", $ip, $u->getName(), $np );
- $m = wfMsg( "passwordremindertext", $ip, $u->getName(), $np );
+ $error = userMailer( $u->getEmail(), $wgPasswordSender, wfMsg( "passwordremindertitle" ), $m );
+
+ return $error;
+ }
- userMailer( $u->getEmail(), $wgPasswordSender, wfMsg( "passwordremindertitle" ), $m );
-
- return $u;
-}
+ /* private */ function successfulLogin( $msg )
+ {
+ global $wgUser;
+ global $wgDeferredUpdateList;
+ global $wgOut;
+
+ $wgOut->setPageTitle( wfMsg( "loginsuccesstitle" ) );
+ $wgOut->setRobotpolicy( "noindex,nofollow" );
+ $wgOut->setArticleRelated( false );
+ $wgOut->addHTML( $msg . "\n<p>" );
+ $wgOut->returnToMain();
+ }
-/* private */ function successfulLogin( $msg )
-{
- global $wgUser;
- global $wgDeferredUpdateList;
- global $wgOut;
-
- $wgOut->setPageTitle( wfMsg( "loginsuccesstitle" ) );
- $wgOut->setRobotpolicy( "noindex,nofollow" );
- $wgOut->setArticleRelated( false );
- $wgOut->addHTML( $msg . "\n<p>" );
- $wgOut->returnToMain();
-}
+ function userNotPrivilegedMessage()
+ {
+ global $wgOut, $wgUser, $wgLang;
+
+ $wgOut->setPageTitle( wfMsg( "whitelistacctitle" ) );
+ $wgOut->setRobotpolicy( "noindex,nofollow" );
+ $wgOut->setArticleRelated( false );
+
+ $wgOut->addWikiText( wfMsg( "whitelistacctext" ) );
+
+ $wgOut->returnToMain( false );
+ }
-function userNotPrivilegedMessage()
-{
- global $wgOut, $wgUser, $wgLang;
-
- $wgOut->setPageTitle( wfMsg( "whitelistacctitle" ) );
- $wgOut->setRobotpolicy( "noindex,nofollow" );
- $wgOut->setArticleRelated( false );
+ /* private */ function mainLoginForm( $err )
+ {
+ global $wgUser, $wgOut, $wgLang;
+ global $wgDBname;
+
+ $le = wfMsg( "loginerror" );
+ $yn = wfMsg( "yourname" );
+ $yp = wfMsg( "yourpassword" );
+ $ypa = wfMsg( "yourpasswordagain" );
+ $rmp = wfMsg( "remembermypassword" );
+ $nuo = wfMsg( "newusersonly" );
+ $li = wfMsg( "login" );
+ $ca = wfMsg( "createaccount" );
+ $cam = wfMsg( "createaccountmail" );
+ $ye = wfMsg( "youremail" );
+ $efl = wfMsg( "emailforlost" );
+ $mmp = wfMsg( "mailmypassword" );
+ $endText = wfMsg( "loginend" );
+
+ if ( $endText = "<loginend>" ) {
+ $endText = "";
+ }
- $wgOut->addWikiText( wfMsg( "whitelistacctext" ) );
-
- $wgOut->returnToMain( false );
-}
+ if ( "" == $this->mName ) {
+ if ( 0 != $wgUser->getID() ) {
+ $this->mName = $wgUser->getName();
+ } else {
+ $this->mName = @$_COOKIE["{$wgDBname}UserName"];
+ }
+ }
-/* private */ function mainLoginForm( $err )
-{
- global $wgUser, $wgOut, $wgLang;
- global $wgRequest, $wgDBname;
-
- $le = wfMsg( "loginerror" );
- $yn = wfMsg( "yourname" );
- $yp = wfMsg( "yourpassword" );
- $ypa = wfMsg( "yourpasswordagain" );
- $rmp = wfMsg( "remembermypassword" );
- $nuo = wfMsg( "newusersonly" );
- $li = wfMsg( "login" );
- $ca = wfMsg( "createaccount" );
- $cam = wfMsg( "createaccountmail" );
- $ye = wfMsg( "youremail" );
- $efl = wfMsg( "emailforlost" );
- $mmp = wfMsg( "mailmypassword" );
- $endText = wfMsg( "loginend" );
-
- if ( $endText = "<loginend>" ) {
- $endText = "";
- }
+ $wgOut->setPageTitle( wfMsg( "userlogin" ) );
+ $wgOut->setRobotpolicy( "noindex,nofollow" );
+ $wgOut->setArticleRelated( false );
- $name = $wgRequest->getText( 'wpName' );
- if ( "" == $name ) {
- if ( 0 != $wgUser->getID() ) {
- $name = $wgUser->getName();
+ if ( "" == $err ) {
+ $lp = wfMsg( "loginprompt" );
+ $wgOut->addHTML( "<h2>$li:</h2>\n<p>$lp</p>" );
} else {
- $name = @$_COOKIE["{$wgDBname}UserName"];
+ $wgOut->addHTML( "<h2>$le:</h2>\n<font size='+1'
+ color='red'>$err</font>\n" );
}
- }
- $pwd = $wgRequest->getText( 'wpPassword' );
-
- $wgOut->setPageTitle( wfMsg( "userlogin" ) );
- $wgOut->setRobotpolicy( "noindex,nofollow" );
- $wgOut->setArticleRelated( false );
-
- if ( "" == $err ) {
- $lp = wfMsg( "loginprompt" );
- $wgOut->addHTML( "<h2>$li:</h2>\n<p>$lp</p>" );
- } else {
- $wgOut->addHTML( "<h2>$le:</h2>\n<font size='+1'
-color='red'>$err</font>\n" );
- }
- if ( 1 == $wgUser->getOption( "rememberpassword" ) ) {
- $checked = " checked";
- } else {
- $checked = "";
- }
-
- $q = "action=submit";
- $returnto = $wgRequest->getVal( "returnto" );
- if ( !empty( $returnto ) ) {
- $q .= "&returnto=" . wfUrlencode( $returnto );
- }
-
- $titleObj = Title::makeTitle( NS_SPECIAL, "Userlogin" );
- $action = $titleObj->escapeLocalUrl( $q );
-
- $encName = wfEscapeHTML( $name );
- $encPassword = wfEscapeHTML( $pwd );
- $encRetype = wfEscapeHTML( $wgRequest->getText( 'wpRetype' ) );
- $encEmail = wfEscapeHTML( $wgRequest->getVal( 'wpEmail' ) );
-
- if ($wgUser->getID() != 0) {
- $cambutton = "<input tabindex=6 type=submit name=\"wpCreateaccountMail\" value=\"{$cam}\">";
- } else {
- $cambutton = "";
- }
+ if ( 1 == $wgUser->getOption( "rememberpassword" ) ) {
+ $checked = " checked";
+ } else {
+ $checked = "";
+ }
+
+ $q = "action=submit";
+ if ( !empty( $this->mReturnto ) ) {
+ $q .= "&returnto=" . wfUrlencode( $this->mReturnto );
+ }
+
+ $titleObj = Title::makeTitle( NS_SPECIAL, "Userlogin" );
+ $action = $titleObj->escapeLocalUrl( $q );
- $wgOut->addHTML( "
-<form name=\"userlogin\" id=\"userlogin\" method=\"post\" action=\"{$action}\">
-<table border=0><tr>
-<td align=right>$yn:</td>
-<td align=left>
-<input tabindex=1 type=text name=\"wpName\" value=\"{$encName}\" size=20>
-</td>
-<td align=left>
-<input tabindex=3 type=submit name=\"wpLoginattempt\" value=\"{$li}\">
-</td>
-</tr>
-<tr>
-<td align=right>$yp:</td>
-<td align=left>
-<input tabindex=2 type=password name=\"wpPassword\" value=\"{$encPassword}\" size=20>
-</td>
-<td align=left>
-<input tabindex=7 type=checkbox name=\"wpRemember\" value=\"1\" id=\"wpRemember\"$checked><label for=\"wpRemember\">$rmp</label>
-</td>
-</tr>");
-
- if ($wgUser->isAllowedToCreateAccount()) {
- $encRetype = htmlspecialchars( $wgRequest->getText( 'wpRetype' ) );
- $encEmail = htmlspecialchars( $wgRequest->getText( 'wpEmail' ) );
-$wgOut->addHTML("<tr><td colspan=3> </td></tr><tr>
-<td align=right>$ypa:</td>
-<td align=left>
-<input tabindex=4 type=password name=\"wpRetype\" value=\"{$encRetype}\"
-size=20>
-</td><td>$nuo</td></tr>
-<tr>
-<td align=right>$ye:</td>
-<td align=left>
-<input tabindex=5 type=text name=\"wpEmail\" value=\"{$encEmail}\" size=20>
-</td><td align=left>
-<input tabindex=6 type=submit name=\"wpCreateaccount\" value=\"{$ca}\">
-$cambutton
-</td></tr>");
- }
+ $encName = wfEscapeHTML( $this->mName );
+ $encPassword = wfEscapeHTML( $this->mPassword );
+ $encRetype = wfEscapeHTML( $this->mRetype );
+ $encEmail = wfEscapeHTML( $this->mEmail );
- $wgOut->addHTML("
-<tr><td colspan=3> </td></tr><tr>
-<td colspan=3 align=left>
-<p>$efl<br>
-<input tabindex=8 type=submit name=\"wpMailmypassword\" value=\"{$mmp}\">
-</td></tr></table>
-</form>\n" );
- $wgOut->addHTML( $endText );
-}
+ if ($wgUser->getID() != 0) {
+ $cambutton = "<input tabindex=6 type=submit name=\"wpCreateaccountMail\" value=\"{$cam}\">";
+ } else {
+ $cambutton = "";
+ }
-/* private */ function hasSessionCookie()
-{
- global $wgDisableCookieCheck;
- return ( $wgDisableCookieCheck ) ? true : ( "" != $_COOKIE[session_name()] );
-}
-
-/* private */ function cookieRedirectCheck( $type )
-{
- global $wgOut, $wgLang;
+ $wgOut->addHTML( "
+ <form name=\"userlogin\" id=\"userlogin\" method=\"post\" action=\"{$action}\">
+ <table border=0><tr>
+ <td align=right>$yn:</td>
+ <td align=left>
+ <input tabindex=1 type=text name=\"wpName\" value=\"{$encName}\" size=20>
+ </td>
+ <td align=left>
+ <input tabindex=3 type=submit name=\"wpLoginattempt\" value=\"{$li}\">
+ </td>
+ </tr>
+ <tr>
+ <td align=right>$yp:</td>
+ <td align=left>
+ <input tabindex=2 type=password name=\"wpPassword\" value=\"{$encPassword}\" size=20>
+ </td>
+ <td align=left>
+ <input tabindex=7 type=checkbox name=\"wpRemember\" value=\"1\" id=\"wpRemember\"$checked><label for=\"wpRemember\">$rmp</label>
+ </td>
+ </tr>");
+
+ if ($wgUser->isAllowedToCreateAccount()) {
+ $encRetype = htmlspecialchars( $this->mRetype );
+ $encEmail = htmlspecialchars( $this->mEmail );
+ $wgOut->addHTML("<tr><td colspan=3> </td></tr><tr>
+ <td align=right>$ypa:</td>
+ <td align=left>
+ <input tabindex=4 type=password name=\"wpRetype\" value=\"{$encRetype}\"
+ size=20>
+ </td><td>$nuo</td></tr>
+ <tr>
+ <td align=right>$ye:</td>
+ <td align=left>
+ <input tabindex=5 type=text name=\"wpEmail\" value=\"{$encEmail}\" size=20>
+ </td><td align=left>
+ <input tabindex=6 type=submit name=\"wpCreateaccount\" value=\"{$ca}\">
+ $cambutton
+ </td></tr>");
+ }
+
+ $wgOut->addHTML("
+ <tr><td colspan=3> </td></tr><tr>
+ <td colspan=3 align=left>
+ <p>$efl<br>
+ <input tabindex=8 type=submit name=\"wpMailmypassword\" value=\"{$mmp}\">
+ </td></tr></table>
+ </form>\n" );
+ $wgOut->addHTML( $endText );
+ }
- $titleObj = Title::makeTitle( NS_SPECIAL, "Userlogin" );
- $check = $titleObj->getFullURL( "wpCookieCheck=$type" );
+ /* private */ function hasSessionCookie()
+ {
+ global $wgDisableCookieCheck;
+ return ( $wgDisableCookieCheck ) ? true : ( "" != $_COOKIE[session_name()] );
+ }
+
+ /* private */ function cookieRedirectCheck( $type )
+ {
+ global $wgOut, $wgLang;
- return $wgOut->redirect( $check );
-}
+ $titleObj = Title::makeTitle( NS_SPECIAL, "Userlogin" );
+ $check = $titleObj->getFullURL( "wpCookieCheck=$type" );
-/* private */ function onCookieRedirectCheck( $type ) {
- global $wgUser;
+ return $wgOut->redirect( $check );
+ }
- if ( !hasSessionCookie() ) {
- if ( $type == "new" ) {
- return mainLoginForm( wfMsg( "nocookiesnew" ) );
- } else if ( $type == "login" ) {
- return mainLoginForm( wfMsg( "nocookieslogin" ) );
+ /* private */ function onCookieRedirectCheck( $type ) {
+ global $wgUser;
+
+ if ( !$this->hasSessionCookie() ) {
+ if ( $type == "new" ) {
+ return $this->mainLoginForm( wfMsg( "nocookiesnew" ) );
+ } else if ( $type == "login" ) {
+ return $this->mainLoginForm( wfMsg( "nocookieslogin" ) );
+ } else {
+ # shouldn't happen
+ return $this->mainLoginForm( wfMsg( "error" ) );
+ }
} else {
- # shouldn't happen
- return mainLoginForm( wfMsg( "error" ) );
+ return $this->successfulLogin( wfMsg( "loginsuccess", $wgUser->getName() ) );
}
- } else {
- return successfulLogin( wfMsg( "loginsuccess", $wgUser->getName() ) );
}
}
-
?>