ecshop 快速添加会员

/*------------------------------------------------------ */
//-- 快速添加会员
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'quick_insert')
{
    /* 检查权限 */
    admin_priv('users_manage');
    $str1_arr = array('0','1','2','3','4','5','6','7','8','9');
    $str2_arr = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
    $str3_arr = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
    
    $arr = array_merge($str1_arr,$str2_arr,$str3_arr);
    $rand = array_rand($arr,9);
    
    foreach($rand as $k=>$v){
        $New_arr[$k] = $arr[$v];    
    }
    
    $username = implode('',$New_arr);   //  用户名
    
    $mobile1 = array_rand($str1_arr,7);  //手机号
    $mobile2 = array_rand($str1_arr,4);
    $mobile_phone = implode('',array_merge($mobile1,$mobile2));
    
    $password = strtolower($username);    // 密码  大写字母转小写
    $user_money = '10000';
    

    $email =$username.'@qq.com';
/*******************以上是主要内容 ********************/ $sex
= empty($_POST['sex']) ? 0 : intval($_POST['sex']); $sex = in_array($sex, array(0, 1, 2)) ? $sex : 0; $birthday = $_POST['birthdayYear'] . '-' . $_POST['birthdayMonth'] . '-' . $_POST['birthdayDay']; $rank = empty($_POST['user_rank']) ? 0 : intval($_POST['user_rank']); $credit_line = empty($_POST['credit_line']) ? 0 : floatval($_POST['credit_line']); $users =& init_users(); if (!$users->add_user($username, $password, $email)) { /* 插入会员数据失败 */ if ($users->error == ERR_INVALID_USERNAME) { $msg = $_LANG['username_invalid']; } elseif ($users->error == ERR_USERNAME_NOT_ALLOW) { $msg = $_LANG['username_not_allow']; } elseif ($users->error == ERR_USERNAME_EXISTS) { $msg = $_LANG['username_exists']; } elseif ($users->error == ERR_INVALID_EMAIL) { $msg = $_LANG['email_invalid']; } elseif ($users->error == ERR_EMAIL_NOT_ALLOW) { $msg = $_LANG['email_not_allow']; } elseif ($users->error == ERR_EMAIL_EXISTS) { $msg = $_LANG['email_exists']; } else { //die('Error:'.$users->error_msg()); } sys_msg($msg, 1); } /* 注册送积分 */ if (!empty($GLOBALS['_CFG']['register_points'])) { log_account_change($_SESSION['user_id'], 0, 0, $GLOBALS['_CFG']['register_points'], $GLOBALS['_CFG']['register_points'], $_LANG['register_points']); } /*把新注册用户的扩展信息插入数据库*/ $sql = 'SELECT id FROM ' . $ecs->table('reg_fields') . ' WHERE type = 0 AND display = 1 ORDER BY dis_order, id'; //读出所有扩展字段的id $fields_arr = $db->getAll($sql); $extend_field_str = ''; //生成扩展字段的内容字符串 $user_id_arr = $users->get_profile_by_name($username); foreach ($fields_arr AS $val) { $extend_field_index = 'extend_field' . $val['id']; if(!empty($_POST[$extend_field_index])) { $temp_field_content = strlen($_POST[$extend_field_index]) > 100 ? mb_substr($_POST[$extend_field_index], 0, 99) : $_POST[$extend_field_index]; $extend_field_str .= " ('" . $user_id_arr['user_id'] . "', '" . $val['id'] . "', '" . $temp_field_content . "'),"; } } $extend_field_str = substr($extend_field_str, 0, -1); if ($extend_field_str) //插入注册扩展数据 { $sql = 'INSERT INTO '. $ecs->table('reg_extend_info') . ' (`user_id`, `reg_field_id`, `content`) VALUES' . $extend_field_str; $db->query($sql); } /* 更新会员的其它信息 */ $other = array(); $other['credit_line'] = $credit_line; $other['user_rank'] = $rank; $other['sex'] = $sex; $other['birthday'] = $birthday; $other['reg_time'] = local_strtotime(local_date('Y-m-d H:i:s')); $other['msn'] = isset($_POST['extend_field1']) ? htmlspecialchars(trim($_POST['extend_field1'])) : ''; $other['qq'] = isset($_POST['extend_field2']) ? htmlspecialchars(trim($_POST['extend_field2'])) : ''; $other['office_phone'] = isset($_POST['extend_field3']) ? htmlspecialchars(trim($_POST['extend_field3'])) : ''; $other['home_phone'] = isset($_POST['extend_field4']) ? htmlspecialchars(trim($_POST['extend_field4'])) : ''; //$other['mobile_phone'] = isset($_POST['extend_field5']) ? htmlspecialchars(trim($_POST['extend_field5'])) : ''; $other['mobile_phone'] = $mobile_phone; $other['user_money'] = $user_money; $db->autoExecute($ecs->table('users'), $other, 'UPDATE', "user_name = '$username'"); /* 记录管理员操作 */ admin_log($_POST['username'], 'add', 'users'); /* 提示信息 */ $link[] = array('text' => $_LANG['go_back'], 'href'=>'users.php?act=list'); sys_msg(sprintf($_LANG['add_success'], htmlspecialchars(stripslashes($_POST['username']))), 0, $link); }

admin/order_list.htm

<a href="users.php?act=quick_insert" style="padding-left: 20px;">批量添加会员</a>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值