UCenter 批量添加用户的php代码
2015-01-24信息快讯网
有时候我们需要批量添加用户,只要把该php放进UCenter目录下,执行就可以了。
<?
//作者:www.tongqiong.com
//header("content-type:text/html; charset=utf-8");
//include_once("include/config.php");
//include_once("include/db_mysql.inc.php");
////include_once("include/n_public_function.php");
//$db = new DB_MYSQL("localhost","dbh218710","root","123");
include_once('./common.php');
include_once(S_ROOT.'./data/data_magic.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<?
global $_SGLOBAL;//定义全局变量
//注册的用户名
$rando_first_name = array(
'哪里购物',
'同穷论坛',
'台州妈妈',
'7788黑客'
);
//注册的密码
$rando_first_password = array(
'15032x',
'103716',
'114517',
'1ggg17'
);
/*为了确保用户名和密码能对上号,输出个字的数组长度进行比较
echo count($rando_first_name);
echo "______";
echo count($rando_first_password);
exit;
*/
for($i=0;$i<count($rando_first_name);$i++){
$username = $rando_first_name[$i];
$pwd1 = $rando_first_password[$i];
$salt = substr(uniqid(rand()), -6);
$pwd = md5(md5($pwd1).$salt);
//查询是否已存在此用户名
$sql_username = "select username from uc_members where username='".$username."'";
$s_name = $_SGLOBAL['db']->fetch_array($_SGLOBAL['db']->query($sql_username));
//如果不存在重名的用户
if($username != $s_name['username']){//如果不存在
$_SGLOBAL['db']->query("INSERT INTO uc_members (username, password,regdate,salt)
VALUES ('$username', '$pwd','".mktime()."','$salt')");
$sql = "select uid from uc_members where username='".$username."'";
$_SGLOBAL['db']->query($sql);
$uuu = $_SGLOBAL['db']->fetch_array($_SGLOBAL['db']->query($sql));
echo $uuu['uid'];
$_SGLOBAL['db']->query("INSERT INTO uc_memberfields (uid)
VALUES ('".$uuu['uid']."')");
echo $username."success<br/>";
}else{
echo "您要添加的用户已添加!";
}
}
//作者:www.tongqiong.com
?>
</body>
</html>
PHP中mb_convert_encoding与iconv函数的深入解析
解析php中var_dump,var_export,print_r三个函数的区别
解析PHP中intval()等int转换时的意外异常情况
探讨GDFONTPATH能否被winxp下的php支持
解析php中array_merge与array+array的区别
php输出echo、print、print_r、printf、sprintf、var_dump的区别比较
Function eregi is deprecated (解决方法)
php连接Access数据库错误及解决方法
PHP连接Access数据库的方法小结
解析smarty 截取字符串函数 truncate的用法介绍
完美解决令人抓狂的zend studio 7代码提示(content Assist)速度慢的问题
慎用preg_replace危险的/e修饰符(一句话后门常用)
解析CodeIgniter自定义配置文件
php class中public,private,protected的区别以及实例分析
解析mysql left( right ) join使用on与where筛选的差异
解析htaccess伪静态的规则
CentOS 6.2使用yum安装LAMP以及phpMyadmin详解
php日期转时间戳,指定日期转换成时间戳
一个简单的网页密码登陆php代码
PHP imagecreatefrombmp 从BMP文件或URL新建一图像
PHP连接SQLServer2005的实现方法(附ntwdblib.dll下载)
apache+codeigniter 通过.htcaccess做动态二级域名解析
PHP sprintf() 函数的应用(定义和用法)
PHP连接SQLSERVER 注意事项(附dll文件下载)
深入了解 register_globals (附register_globals=off 网站打不开的解决方法)
php中jQuery插件autocomplate的简单使用笔记
深入理解PHP之数组(遍历顺序) Laruence原创
header中Content-Disposition的作用与使用方法
PHP的异常处理类Exception的使用及说明
PHP Parse Error: syntax error, unexpected $end 错误的解决办法
php提示Call-time pass-by-reference has been deprecated in的解决方法[已测]
PHP中return 和 exit 、break和contiue 区别与用法
Notice: Trying to get property of non-object problem(PHP)解决办法