From: Tim Starling Date: Fri, 12 Mar 2004 05:56:25 +0000 (+0000) Subject: Allowing user ids to be specified e.g. "#1234@en", to work around any encoding problems X-Git-Tag: 1.3.0beta1~817 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%22%20.%20generer_url_entite%28%24id_rubrique%2C?a=commitdiff_plain;h=60a3cfe1c71d356d75fcdd5074683175993d889d;p=lhc%2Fweb%2Fwiklou.git Allowing user ids to be specified e.g. "#1234@en", to work around any encoding problems --- diff --git a/includes/SpecialMakesysop.php b/includes/SpecialMakesysop.php index f062ec2691..f1346e086f 100644 --- a/includes/SpecialMakesysop.php +++ b/includes/SpecialMakesysop.php @@ -111,9 +111,40 @@ class MakesysopForm { function doSubmit() { + global $wgOut, $wgUser, $wgLang, $wpMakesysopUser, $wpSetBureaucrat; global $wgDBname, $wgMemc, $wpRights, $wgLocalDatabases; - + + $parts = explode( "@", $wpMakesysopUser ); + if( count( $parts ) == 2 && $wgUser->isDeveloper() ){ + $username = $parts[0]; + if ( array_key_exists( $parts[1], $wgLocalDatabases ) ) { + $dbName = $wgLocalDatabases[$parts[1]]; + $usertable = $dbName . ".user"; + } else { + $this->showFail(); + return; + } + } else { + $username = $wpMakesysopUser; + $usertable = "user"; + $dbName = $wgDBname; + } + 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 = '{$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] ); @@ -129,6 +160,15 @@ class MakesysopForm { $usertable = "user"; $dbName = $wgDBname; } + 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); wfIgnoreSQLErrors( $prev );