$wgMathDirectory = "{$wgUploadDirectory}/math";
$wgTmpDirectory = "{$wgUploadDirectory}/tmp";
$wgEmergencyContact = "wikiadmin@" . getenv( "SERVER_NAME" );
+#$wgPasswordSender = "Wikipedia Mail <apache@www.wikipedia.org>";
+$wgPasswordSender = "Wikipedia Mail <apache@www.wikipedia.org>\r\nReply-To: webmaster@www.wikipedia.org";
+
# MySQL settings
#
$wgLogQueries = false;
$wgUseBetterLinksUpdate = true;
+
+# The following three config variables are used to define
+# the rights of users in your system.
+#
# If wgWhitelistEdit is set to true, only logged in users
# are allowed to edit articles.
-# $wgWhitelistEdit = true;
+# If wgWhitelistRead is set to true, only logged in users
+# are allowed to read articles.
+#
+# wgWhitelistAccount lists user types that can add user accounts:
+# "key" => 1 defines permission if user has right "key".
+#
+# Typical setups are:
+#
+# Everything goes (this is the default behaviour):
+# $wgWhitelistEdit = false;
+# $wgWhitelistRead = false;
+# $wgWhitelistAccount = array ( "user" => 1, "sysop" => 1, "developer" => 1 );
+#
+# Invitation-only closed shop type of system
+# $wgWhitelistEdit = true;
+# $wgWhitelistRead = true;
+# $wgWhitelistAccount = array ( "user" => 0, "sysop" => 1, "developer" => 1 );
+#
+# Public website, closed editorial team
+# $wgWhitelistEdit = true;
+# $wgWhitelistRead = false;
+# $wgWhitelistAccount = array ( "user" => 0, "sysop" => 1, "developer" => 1 );
+
# Client-side caching:
$wgCachePages = true; # Allow client-side caching of pages
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();
+ mailPasswordInternal($u);
+
+ $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 (!userAllowedToCreateAccount()) {
+ userNotPrivilegedMessage();
+ return;
+ }
+
if ( 0 != strcmp( $wpPassword, $wpRetype ) ) {
mainLoginForm( wfMsg( "badretype" ) );
return;
if ( ( "" == $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 $wgUser, $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();
}
+
+
+/* private */ function userAllowedToCreateAccount()
+{
+ global $wgUser, $wgWhitelistAccount;
+ $allowed = false;
+
+ if (!$wgWhitelistAccount) { return 1; }; // default behaviour
+ foreach ($wgWhitelistAccount as $right => $ok) {
+ $userHasRight = (!strcmp($right, "user") || in_array($right, $wgUser->getRights()));
+ $allowed |= ($ok && $userHasRight);
+ }
+ return $allowed;
+}
+
+
+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 id=\"userlogin\" method=\"post\" action=\"{$action}\">
<table border=0><tr>
</td>
<td align=left>
<input tabindex=3 type=submit name=\"wpLoginattempt\" value=\"{$li}\">
-</td></tr>
-<tr><td colspan=3> </td></tr><tr>
+</td></tr>");
+
+ if (userAllowedToCreateAccount($wgUser)) {
+
+$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=5 type=text name=\"wpEmail\" value=\"{$wpEmail}\" size=20>
</td><td align=left>
<input tabindex=6 type=submit name=\"wpCreateaccount\" value=\"{$ca}\">
-</td></tr>
+$cambutton
+</td></tr>");
+ }
+
+ $wgOut->addHTML("
<tr>
<td colspan=3 align=left>
<input tabindex=7 type=checkbox name=\"wpRemember\" value=\"1\"$checked>$rmp
<input tabindex=8 type=submit name=\"wpMailmypassword\" value=\"{$mmp}\">
</td></tr></table>
</form>\n" );
+
+
+
}
?>
"userlogout" => "Log out",
"notloggedin" => "Not logged in",
"createaccount" => "Create new account",
+"createaccountmail" => "by eMail",
"badretype" => "The passwords you entered do not match.",
"userexists" => "The user name you entered is already in use. Please choose a different name.",
"youremail" => "Your e-mail*",
"blockedtext" => "Your user name or IP address has been blocked by $1.
The reason given is this:<br>''$2''<p>You may contact $1 or one of the other
[[Wikipedia:administrators|administrators]] to discuss the block.",
-"whitelistedittitle" => "User not logged in",
-"whitelistedittext" => "You have to [[Spezial:Userlogin|login]] to edit articles.",
+"whitelistedittitle" => "Login required to edit",
+"whitelistedittext" => "You have to [[Special:Userlogin|login]] to edit articles.",
+"whitelistreadtitle" => "Login required to read",
+"whitelistreadtext" => "You have to [[Special:Userlogin|login]] to read articles.",
+"whitelistacctitle" => "You are not allowed to create an account",
+"whitelistacctext" => "To be allowed to create accounts in this Wiki you have to [[Special:Userlogin|log]] in and have the appropriate permissions.",
+"accmailtitle" => "Password sent.",
+"accmailtext" => "The Password for '$1' has been sent to $2.",
"newarticle" => "(New)",
"newarticletext" =>
"You've followed a link to a page that doesn't exist yet.