From: Tim Starling Date: Mon, 1 Mar 2004 00:31:08 +0000 (+0000) Subject: Limited developer version of Special:Makesysop to a given list of databases X-Git-Tag: 1.3.0beta1~895 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=2c34ad2fc070a019d29a75ed78ea8fd9b9b34f05;p=lhc%2Fweb%2Fwiklou.git Limited developer version of Special:Makesysop to a given list of databases --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 6084e0672a..331d668c61 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -49,6 +49,10 @@ $wgDBtransactions = false; # Set to true if using InnoDB tables $wgDBmysql4 = false; # Set to true to use enhanced fulltext search $wgSqlTimeout = 30; +# Other wikis on this site, can be administered from a single developer account +# Array, interwiki prefix => database name +$wgLocalDatabases = array(); + # Database load balancer $wgDBservers = false; # e.g. array("larousse", "pliny") $wgDBloads = false; # e.g. array(0.6, 0.4); diff --git a/includes/SpecialMakesysop.php b/includes/SpecialMakesysop.php index b9dd2a63b8..7ab506f0be 100644 --- a/includes/SpecialMakesysop.php +++ b/includes/SpecialMakesysop.php @@ -112,20 +112,25 @@ class MakesysopForm { function doSubmit() { global $wgOut, $wgUser, $wgLang, $wpMakesysopUser, $wpSetBureaucrat; - global $wgDBname, $wgMemc, $wpRights; + global $wgDBname, $wgMemc, $wpRights, $wgLocalDatabases; $parts = explode( "@", $wpMakesysopUser ); if( count( $parts ) == 2 && $wgUser->isDeveloper() ){ - $username = addslashes( $parts[0] ); - $usertable = $parts[1] . "wiki.user"; - $dbName = $parts[1] . "wiki"; + $username = wfStrencode( $parts[0] ); + if ( array_key_exists( $parts[1], $wgLocalDatabases ) ) { + $dbName = $wgLocalDatabases[$parts[1]]; + $usertable = $dbName . ".user"; + } else { + $this->showFail(); + return; + } } else { - $username = addslashes( $wpMakesysopUser ); + $username = wfStrencode( $wpMakesysopUser ); $usertable = "user"; $dbName = $wgDBname; } $prev = wfIgnoreSQLErrors( TRUE ); - $res = wfQuery("SELECT user_id, user_rights FROM user WHERE user_name = '{$username}'", DB_WRITE); + $res = wfQuery("SELECT user_id, user_rights FROM $usertable WHERE user_name = '{$username}'", DB_WRITE); wfIgnoreSQLErrors( $prev ); if( wfLastErrno() || ! $username || wfNumRows( $res ) == 0 ){ @@ -165,9 +170,9 @@ class MakesysopForm { if ( count( $rightsNotation ) == 0 ) { $this->showFail(); } else { - $sql = "UPDATE user SET user_rights = '{$newrights}' WHERE user_id = $id LIMIT 1"; + $sql = "UPDATE $usertable SET user_rights = '{$newrights}' WHERE user_id = $id LIMIT 1"; wfQuery($sql, DB_WRITE); - $wgMemc->delete( "$wgDBname:user:id:$id" ); + $wgMemc->delete( "$dbName:user:id:$id" ); $bureaucratLog = wfMsg( "bureaucratlog" ); $action = wfMsg( "bureaucratlogentry", $wpMakesysopUser, implode( " ", $rightsNotation ) );