From: Rob Church Date: Sat, 17 Jun 2006 23:07:16 +0000 (+0000) Subject: Maintenance script to create an account and promote it to administrator X-Git-Tag: 1.31.0-rc.0~56750 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=f261dbceeb1b13bb9d4d36491794079d185515ad;p=lhc%2Fweb%2Fwiklou.git Maintenance script to create an account and promote it to administrator --- diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php new file mode 100644 index 0000000000..df29c114fb --- /dev/null +++ b/maintenance/createAndPromote.php @@ -0,0 +1,48 @@ + + */ + +require_once( 'commandLine.inc' ); + +if( !count( $args ) == 2 ) { + echo( "Please provide a username and password for the new account.\n" ); + die( 1 ); +} + +$username = $args[0]; +$password = $args[1]; + +global $wgDBname; +echo( "{$wgDBname}: Creating and promoting User:{$username}..." ); + +# Validate username and check it doesn't exist +$user = User::newFromName( $username ); +if( !is_object( $user ) ) { + echo( "invalid username.\n" ); + die( 1 ); +} elseif( 0 != $user->idForName() ) { + echo( "account exists.\n" ); + die( 1 ); +} + +# Insert the account into the database +$user->addToDatabase(); +$user->setPassword( $password ); +$user->setToken(); + +# Promote user +$user->addGroup( 'sysop' ); + +# Increment site_stats.ss_users +$ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); +$ssu->doUpdate(); + +echo( "done.\n" ); + +?> \ No newline at end of file