You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.5 KiB
104 lines
2.5 KiB
<?php
|
|
|
|
|
|
define('IN_ECS', true);
|
|
|
|
require(dirname(__FILE__) . '/includes/init.php');
|
|
require('mc_function.php');
|
|
|
|
/* 检查权限 */
|
|
admin_priv('users_manage');
|
|
|
|
/* act操作项的初始化 */
|
|
if (empty($_REQUEST['act']))
|
|
{
|
|
$_REQUEST['act'] = 'list';
|
|
}
|
|
else
|
|
{
|
|
$_REQUEST['act'] = trim($_REQUEST['act']);
|
|
}
|
|
|
|
|
|
/*------------------------------------------------------ */
|
|
//-- 批量写入
|
|
/*------------------------------------------------------ */
|
|
if ($_REQUEST['act'] == 'mc_add')
|
|
{
|
|
$link[] = array('text' => $_LANG['go_back'], 'href' => 'mc_user.php');
|
|
//$upfile_flash
|
|
$password = $_REQUEST['password'];
|
|
$confirm_password = $_REQUEST['confirm_password'];
|
|
|
|
if(!$password || $password!=$confirm_password){
|
|
sys_msg('两次密码输入不一致,请检查;', 0, $link);
|
|
}
|
|
|
|
if(!$_FILES['upfile']){
|
|
sys_msg('没有上传文件;', 0, $link);
|
|
}
|
|
|
|
//文件上传
|
|
$path = "../mc_upfile/".date("Ym")."/";
|
|
//上传,备份;
|
|
$file_chk=uploadfile("upfile",$path,'mc_user.php',1024000,'txt');
|
|
if($file_chk){
|
|
$filename = $path.$file_chk[0];
|
|
//读取内容;
|
|
$str = mc_read_txt($filename);
|
|
//注册用户
|
|
if($str){
|
|
mc_reg_user($str, $password);
|
|
}else{
|
|
sys_msg('读取文件出错;', 0, $link);
|
|
}
|
|
|
|
sys_msg('恭喜,批量注册用户成功!;', 0, $link);
|
|
}else{
|
|
sys_msg('文件未上传成功;', 0, $link);
|
|
}
|
|
}
|
|
|
|
/*------------------------------------------------------ */
|
|
//-- 操作界面
|
|
/*------------------------------------------------------ */
|
|
else
|
|
{
|
|
|
|
$smarty->display('mc_user.htm');
|
|
}
|
|
|
|
function mc_reg_user($str = '', $password = 'admin123'){
|
|
if(!$str) return false;
|
|
|
|
$str = get_preg_replace($str);
|
|
$str_arr = explode(',', $str);
|
|
|
|
//用户信息
|
|
$password = md5($password);
|
|
|
|
for($i=0; $i<count($str_arr); $i++){
|
|
if(!empty($str_arr[$i])){
|
|
$str_arr[$i] = explode("|", $str_arr[$i]);
|
|
$other = array(
|
|
'user_name' => str_iconv($str_arr[$i][0]),
|
|
'password' => $password,
|
|
'email' => $str_arr[$i][1],
|
|
'msn' => $str_arr[$i][2],
|
|
'qq' => $str_arr[$i][3],
|
|
'office_phone' => $str_arr[$i][4],
|
|
'home_phone' => $str_arr[$i][5],
|
|
'mobile_phone' => $str_arr[$i][6]
|
|
);
|
|
|
|
$sql = "select user_id from " .$GLOBALS['ecs']->table('users'). " where user_name = '" .$other['user_name']. "'";
|
|
$user_id = $GLOBALS['db']->getOne($sql);
|
|
|
|
if($user_id < 1){ //用户不存在时
|
|
$GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('users'), $other, "INSERT");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|