4 * Maintenance script to create an account and grant it administrator rights
8 * @author Rob Church <robchur@gmail.com>
11 $options = array( 'help', 'bureaucrat' );
12 require_once( 'commandLine.inc' );
14 if( isset( $options['help'] ) ) {
19 if( count( $args ) < 2 ) {
20 echo( "Please provide a username and password for the new account.\n" );
27 echo( wfWikiID() . ": Creating and promoting User:{$username}..." );
29 # Validate username and check it doesn't exist
30 $user = User
::newFromName( $username );
31 if( !is_object( $user ) ) {
32 echo( "invalid username.\n" );
34 } elseif( 0 != $user->idForName() ) {
35 echo( "account exists.\n" );
40 $user->setPassword( $password );
41 } catch( PasswordError
$pwe ) {
42 $this->error( $pwe->getText(), true );
45 # Insert the account into the database
46 $user->addToDatabase();
47 $user->saveSettings();
50 $user->addGroup( 'sysop' );
51 if( isset( $option['bureaucrat'] ) )
52 $user->addGroup( 'bureaucrat' );
54 # Increment site_stats.ss_users
55 $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
62 Create a new user account with administrator rights
64 USAGE: php createAndPromote.php [--bureaucrat|--help] <username> <password>
67 Grant the account bureaucrat rights
69 Show this help information