createandpromote.php

来自「php 开发的内容管理系统」· PHP 代码 · 共 48 行

PHP
48
字号
<?php/** * Maintenance script to create an account and grant it administrator rights * * @package MediaWiki * @subpackage Maintenance * @author Rob Church <robchur@gmail.com> */ 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" );?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?