$_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 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"); } } } } ?>