function wfSpecialUserlogin()
{
- global $wpCreateaccount, $wpLoginattempt, $wpMailmypassword;
+ global $wpCreateaccount, $wpCreateaccountMail;
+ global $wpLoginattempt, $wpMailmypassword;
global $action;
$fields = array( "wpName", "wpPassword", "wpName",
if ( isset( $wpCreateaccount ) ) {
addNewAccount();
+ } else if ( isset( $wpCreateaccountMail ) ) {
+ addNewAccountMailPassword();
} else if ( isset( $wpMailmypassword ) ) {
mailPassword();
} else if ( "submit" == $action || isset( $wpLoginattempt ) ) {
}
}
+
+/* private */ function addNewAccountMailPassword()
+{
+ global $wgOut, $wpEmail, $wpName;
+
+ if ("" == $wpEmail) {
+ $m = str_replace( "$1", $wpName, wfMsg( "noemail" ) );
+ mainLoginForm( $m );
+ return;
+ }
+
+ $u = addNewaccountInternal();
+
+ if ($u == NULL) {
+ return;
+ }
+
+ $u->saveSettings();
+ if (mailPasswordInternal($u) == NULL)
+ {
+ return;
+ }
+
+ $wgOut->setPageTitle( wfMsg( "accmailtitle" ) );
+ $wgOut->setRobotpolicy( "noindex,nofollow" );
+ $wgOut->setArticleFlag( false );
+
+ $m = str_replace( "$1", $u->getName(), wfMsg( "accmailtext" ) );
+ $m = str_replace( "$2", $u->getEmail(), $m );
+ $wgOut->addWikiText( $m );
+ $wgOut->returnToMain( false );
+
+ $u = 0;
+}
+
+
/* private */ function addNewAccount()
{
global $wgUser, $wgOut, $wpPassword, $wpRetype, $wpName, $wpRemember;
global $wpEmail, $wgDeferredUpdateList;
+ $u = addNewAccountInternal();
+
+ if ($u == NULL) {
+ return;
+ }
+
+ $wgUser = $u;
+ $m = str_replace( "$1", $wgUser->getName(), wfMsg( "welcomecreation" ) );
+ successfulLogin( $m );
+}
+
+
+/* private */ function addNewAccountInternal()
+{
+ global $wgUser, $wgOut, $wpPassword, $wpRetype, $wpName, $wpRemember;
+ global $wpEmail, $wgDeferredUpdateList;
+
+ if (!$wgUser->isAllowedToCreateAccount()) {
+ userNotPrivilegedMessage();
+ return;
+ }
+
if ( 0 != strcmp( $wpPassword, $wpRetype ) ) {
mainLoginForm( wfMsg( "badretype" ) );
return;
}
$wpName = trim( $wpName );
if ( ( "" == $wpName ) ||
- preg_match( "/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/", $wpName ) )
-{
+ preg_match( "/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/", $wpName ) ||
+ (strpos( $wpName, "/" ) !== false) )
+ {
mainLoginForm( wfMsg( "noname" ) );
return;
}
if ( 1 == $wpRemember ) { $r = 1; }
else { $r = 0; }
$u->setOption( "rememberpassword", $r );
-
- $wgUser = $u;
- $m = str_replace( "$1", $wgUser->getName(), wfMsg( "welcomecreation" ) );
- successfulLogin( $m );
+
+ return $u;
}
+
+
+
/* private */ function processLogin()
{
global $wgUser, $wpName, $wpPassword, $wpRemember;
$u->setId( $id );
$u->loadFromDatabase();
+ if (mailPasswordInternal($u) == NULL) {
+ return;
+ }
+
+ $m = str_replace( "$1", $u->getName(), wfMsg( "passwordsent" ) );
+ mainLoginForm( $m );
+}
+
+
+/* private */ function mailPasswordInternal( $u )
+{
+ global $wpName, $wgDeferredUpdateList, $wgOutputEncoding;
+ global $wgPasswordSender;
+
if ( "" == $u->getEmail() ) {
$m = str_replace( "$1", $u->getName(), wfMsg( "noemail" ) );
mainLoginForm( $m );
$m = str_replace( "$2", $u->getName(), $m );
$m = str_replace( "$3", $np, $m );
- #FIXME: Generilize the email addresses for 3rd party sites...
mail( $u->getEmail(), wfMsg( "passwordremindertitle" ), $m,
"MIME-Version: 1.0\r\n" .
"Content-type: text/plain; charset={$wgOutputEncoding}\r\n" .
"Content-transfer-encoding: 8bit\r\n" .
- "From: Wikipedia Mail <apache@www.wikipedia.org>\r\n" .
- "Reply-To: webmaster@www.wikipedia.org" );
- $m = str_replace( "$1", $u->getName(), wfMsg( "passwordsent" ) );
- mainLoginForm( $m );
+ "From: $wgPasswordSender" );
+
+ return $u;
}
+
+
+
+
/* private */ function successfulLogin( $msg )
{
global $wgUser, $wgOut, $returnto;
$wgOut->returnToMain();
}
+
+
+
+
+function userNotPrivilegedMessage()
+{
+ global $wgOut, $wgUser, $wgLang;
+
+ $wgOut->setPageTitle( wfMsg( "whitelistacctitle" ) );
+ $wgOut->setRobotpolicy( "noindex,nofollow" );
+ $wgOut->setArticleFlag( false );
+
+ $wgOut->addWikiText( wfMsg( "whitelistacctext" ) );
+ $wgOut->returnToMain( false );
+}
+
+
+
+
/* private */ function mainLoginForm( $err )
{
global $wgUser, $wgOut, $wgLang, $returnto;
$nuo = wfMsg( "newusersonly" );
$li = wfMsg( "login" );
$ca = wfMsg( "createaccount" );
+ $cam = wfMsg( "createaccountmail" );
$ye = wfMsg( "youremail" );
$efl = wfMsg( "emailforlost" );
$mmp = wfMsg( "mailmypassword" );
$wpRetype = wfEscapeHTML( $wpRetype );
$wpEmail = wfEscapeHTML( $wpEmail );
+ if ($wgUser->getID() != 0) {
+ $cambutton = "<input tabindex=6 type=submit name=\"wpCreateaccountMail\" value=\"{$cam}\">";
+ }
+
$wgOut->addHTML( "
-<form name='userlogin' method=post action=\"{$action}\">
+<form id=\"userlogin\" method=\"post\" action=\"{$action}\">
<table border=0><tr>
<td align=right>$yn:</td>
<td colspan=2 align=left>
-<input tabindex=1 type=text name='wpName' value=\"{$name}\" size=20>
+<input tabindex=1 type=text name=\"wpName\" value=\"{$name}\" size=20>
</td></tr><tr>
<td align=right>$yp:</td>
<td align=left>
-<input tabindex=2 type=password name='wpPassword' value=\"{$pwd}\" size=20>
+<input tabindex=2 type=password name=\"wpPassword\" value=\"{$pwd}\" size=20>
</td>
<td align=left>
-<input tabindex=3 type=submit name='wpLoginattempt' value=\"{$li}\">
-</td></tr>
-<tr><td colspan=3> </td></tr><tr>
+<input tabindex=3 type=submit name=\"wpLoginattempt\" value=\"{$li}\">
+</td></tr>");
+
+ if ($wgUser->isAllowedToCreateAccount()) {
+
+$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=\"{$wpRetype}\"
+<input tabindex=4 type=password name=\"wpRetype\" value=\"{$wpRetype}\"
size=20>
</td><td>$nuo</td></tr>
<tr>
<td align=right>$ye:</td>
<td align=left>
-<input tabindex=5 type=text name='wpEmail' value=\"{$wpEmail}\" size=20>
+<input tabindex=5 type=text name=\"wpEmail\" value=\"{$wpEmail}\" size=20>
</td><td align=left>
-<input tabindex=6 type=submit name='wpCreateaccount' value=\"{$ca}\">
-</td></tr>
+<input tabindex=6 type=submit name=\"wpCreateaccount\" value=\"{$ca}\">
+$cambutton
+</td></tr>");
+ }
+
+ $wgOut->addHTML("
<tr>
<td colspan=3 align=left>
-<input tabindex=7 type=checkbox name='wpRemember' value='1'$checked>$rmp
+<input tabindex=7 type=checkbox name=\"wpRemember\" value=\"1\" id=\"wpRemember\"$checked><label for=\"wpRemember\">$rmp</label>
</td></tr>
<tr><td colspan=3> </td></tr><tr>
<td colspan=3 align=left>
<p>$efl<br>
-<input tabindex=8 type=submit name='wpMailmypassword' value=\"{$mmp}\">
+<input tabindex=8 type=submit name=\"wpMailmypassword\" value=\"{$mmp}\">
</td></tr></table>
</form>\n" );
+
+
+
}
?>