700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > php168批量添加会员 ecshop快速批量添加会员

php168批量添加会员 ecshop快速批量添加会员

时间:2020-03-26 11:08:48

相关推荐

php168批量添加会员 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.'@';

/*******************以上是主要内容 ********************/

$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

批量添加会员

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。