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" );
39 # Insert the account into the database
40 $user->addToDatabase();
41 $user->setPassword( $password );
42 $user->saveSettings();
45 $user->addGroup( 'sysop' );
46 if( isset( $option['bureaucrat'] ) )
47 $user->addGroup( 'bureaucrat' );
49 # Increment site_stats.ss_users
50 $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
57 Create a new user account with administrator rights
59 USAGE: php createAndPromote.php [--bureaucrat|--help] <username> <password>
62 Grant the account bureaucrat rights
64 Show this help information