$info = $_LANG['email_not_alive']; } show_message($info, $_LANG['back_home_lnk'], 'index.php'); } } elseif ($action == 'send_hash_mail') { include_once ROOT_PATH . 'includes/cls_json.php'; include_once ROOT_PATH . 'includes/lib_passport.php'; $json = new JSON(); $result = array('error' => 0, 'message' => '', 'content' => ''); if ($user_id == 0) { /* 用户没有登录 */ $result['error'] = 1; $result['message'] = $_LANG['login_please']; die($json->encode($result)); } if (send_regiter_hash($user_id)) { /* 用户没有登录 */ $result['message'] = $_LANG['validate_mail_ok']; die($json->encode($result)); } else { $result['error'] = 1; $result['message'] = $GLOBALS['err']->last_message(); } die($json->encode($result)); } else { if ($action == 'track_packages') { include_once ROOT_PATH . 'includes/lib_transaction.php'; include_once ROOT_PATH . 'includes/lib_order.php'; $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $orders = array(); $sql = "SELECT order_id,order_sn,invoice_no,shipping_id FROM " . $ecs->table('order_info') . " WHERE user_id = '{$user_id}' AND shipping_status = '" . SS_SHIPPED . "'";
function action_send_hash_mail() { $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $user_id = $_SESSION['user_id']; include_once ROOT_PATH . 'includes/cls_json.php'; include_once ROOT_PATH . 'includes/lib_passport.php'; $json = new JSON(); $result = array('error' => 0, 'message' => '', 'content' => ''); if ($user_id == 0) { /* 用户没有登录 */ $result['error'] = 1; $result['message'] = $_LANG['login_please']; die($json->encode($result)); } if (send_regiter_hash($user_id)) { $result['message'] = $_LANG['validate_mail_ok']; die($json->encode($result)); } else { $result['error'] = 1; $result['message'] = $GLOBALS['err']->last_message(); } die($json->encode($result)); }
/** * 注册会员的处理 */ function action_register() { // 获取全局变量 $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $err = $GLOBALS['err']; include_once 'includes/cls_json.php'; $json = new JSON(); $res = array('err_msg' => '', 'result' => ''); /* 增加是否关闭注册 */ if ($_CFG['shop_reg_closed']) { $smarty->assign('action', 'register'); $smarty->assign('shop_reg_closed', $_CFG['shop_reg_closed']); $smarty->display('user_passport.dwt'); } else { include_once ROOT_PATH . 'includes/lib_passport.php'; $username = isset($_POST['username']) ? trim($_POST['username']) : ''; $password = isset($_POST['password']) ? trim($_POST['password']) : ''; $email = isset($_POST['email']) ? trim($_POST['email']) : ''; $other['msn'] = isset($_POST['extend_field1']) ? $_POST['extend_field1'] : ''; $other['qq'] = isset($_POST['extend_field2']) ? $_POST['extend_field2'] : ''; $other['office_phone'] = isset($_POST['extend_field3']) ? $_POST['extend_field3'] : ''; $other['home_phone'] = isset($_POST['extend_field4']) ? $_POST['extend_field4'] : ''; $other['mobile_phone'] = isset($_POST['extend_field5']) ? $_POST['extend_field5'] : ''; $sel_question = empty($_POST['sel_question']) ? '' : compile_str($_POST['sel_question']); $passwd_answer = isset($_POST['passwd_answer']) ? compile_str(trim($_POST['passwd_answer'])) : ''; // 注册类型:email、mobile $register_type = isset($_POST['register_type']) ? trim($_POST['register_type']) : ''; $back_act = isset($_POST['back_act']) ? trim($_POST['back_act']) : ''; if (empty($_POST['agreement'])) { $res['err_msg'] = $_LANG['passport_js']['agreement']; $res['err_no'] = 1; die($json->encode($res)); } if (strlen($username) < 3) { $res['err_msg'] = $_LANG['passport_js']['username_shorter']; $res['err_no'] = 1; die($json->encode($res)); } if (strlen($password) < 6) { $res['err_msg'] = $_LANG['passport_js']['password_shorter']; $res['err_no'] = 1; die($json->encode($res)); } if (strpos($password, ' ') > 0) { $res['err_msg'] = $_LANG['passwd_balnk']; $res['err_no'] = 1; die($json->encode($res)); } /* 验证码检查 */ if (intval($_CFG['captcha']) & CAPTCHA_REGISTER && gd_version() > 0) { if (empty($_POST['captcha'])) { $res['err_msg'] = $_LANG['invalid_captcha']; $res['err_no'] = 1; die($json->encode($res)); } /* 检查验证码 */ include_once 'includes/cls_captcha.php'; $validator = new captcha(); if (!$validator->check_word($_POST['captcha'])) { $res['err_msg'] = $_LANG['invalid_captcha']; $res['err_no'] = 1; die($json->encode($res)); } } if (register($username, $password, $email, $other) !== false) { /*把新注册用户的扩展信息插入数据库*/ $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 = ''; //生成扩展字段的内容字符串 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 .= " ('" . $_SESSION['user_id'] . "', '" . $val['id'] . "', '" . compile_str($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); } /* 写入密码提示问题和答案 */ if (!empty($passwd_answer) && !empty($sel_question)) { $sql = 'UPDATE ' . $ecs->table('users') . " SET `passwd_question`='{$sel_question}', `passwd_answer`='{$passwd_answer}' WHERE `user_id`='" . $_SESSION['user_id'] . "'"; $db->query($sql); } /* 判断是否需要自动发送注册邮件 */ if ($GLOBALS['_CFG']['member_email_validate'] && $GLOBALS['_CFG']['send_verify_email']) { send_regiter_hash($_SESSION['user_id']); } $ucdata = empty($user->ucdata) ? "" : $user->ucdata; if (empty($back_act)) { $back_act = 'index.php'; } $res['err_no'] = 0; $res['back_act'] = $back_act; $res['err_msg'] = ''; die($json->encode($res)); } else { $message['content'] = ''; foreach ($err->_message as $msg) { $message['content'] .= '' . htmlspecialchars($msg) . "\n"; } $res['err_msg'] = $message['content']; $res['err_no'] = 1; die($json->encode($res)); } } }
/** * 注册会员的处理 */ function action_register() { // 获取全局变量 $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; /* 增加是否关闭注册 */ if ($_CFG['shop_reg_closed']) { $smarty->assign('action', 'register'); $smarty->assign('shop_reg_closed', $_CFG['shop_reg_closed']); $smarty->display('user_passport.dwt'); } else { include_once ROOT_PATH . 'includes/lib_passport.php'; $username = isset($_POST['username']) ? trim($_POST['username']) : ''; $password = isset($_POST['password']) ? trim($_POST['password']) : ''; $email = isset($_POST['email']) ? trim($_POST['email']) : ''; $other['msn'] = isset($_POST['extend_field1']) ? $_POST['extend_field1'] : ''; $other['qq'] = isset($_POST['extend_field2']) ? $_POST['extend_field2'] : ''; $other['office_phone'] = isset($_POST['extend_field3']) ? $_POST['extend_field3'] : ''; $other['home_phone'] = isset($_POST['extend_field4']) ? $_POST['extend_field4'] : ''; //$other['mobile_phone'] = isset($_POST['extend_field5']) ? $_POST['extend_field5'] : ''; $sel_question = empty($_POST['sel_question']) ? '' : compile_str($_POST['sel_question']); $passwd_answer = isset($_POST['passwd_answer']) ? compile_str(trim($_POST['passwd_answer'])) : ''; // 注册类型:email、mobile $register_type = isset($_POST['register_type']) ? trim($_POST['register_type']) : ''; $back_act = isset($_POST['back_act']) ? trim($_POST['back_act']) : ''; // if(empty($_POST['agreement'])) // { // show_message($_LANG['passport_js']['agreement']); // } // 注册类型不能为空 if (empty($register_type)) { show_message($_LANG['passport_js']['msg_register_type_blank']); } // 用户名将自动生成 if (strlen($username) < 3) { // show_message($_LANG['passport_js']['username_shorter']); } if (strlen($password) < 6) { show_message($_LANG['passport_js']['password_shorter']); } if (strpos($password, ' ') > 0) { show_message($_LANG['passwd_balnk']); } /* 验证码检查 */ if (intval($_CFG['captcha']) & CAPTCHA_REGISTER && gd_version() > 0) { if (empty($_POST['captcha'])) { show_message($_LANG['invalid_captcha'], $_LANG['sign_up'], 'register.php', 'error'); } /* 检查验证码 */ include_once 'includes/cls_captcha.php'; $captcha = new captcha(); if (!$captcha->check_word(trim($_POST['captcha']))) { show_message($_LANG['invalid_captcha'], $_LANG['sign_up'], 'register.php', 'error'); } } if ($register_type == "email") { /* 邮箱验证码检查 */ require_once ROOT_PATH . 'includes/lib_validate_record.php'; if (empty($email)) { show_message($_LANG['msg_email_blank'], $_LANG['sign_up'], 'register.php', 'error'); } $record = get_validate_record($email); $session_email = $_SESSION[VT_EMAIL_REGISTER]; $email_code = !empty($_POST['email_code']) ? trim($_POST['email_code']) : ''; if (empty($email_code)) { show_message($_LANG['msg_email_code_blank'], $_LANG['sign_up'], 'register.php', 'error'); } else { if ($session_email != $email) { show_message($_LANG['email_changed'], $_LANG['sign_up'], 'register.php', 'error'); } else { if ($email_code != $record['record_code']) { show_message($_LANG['invalid_email_code'], $_LANG['sign_up'], 'register.php', 'error'); } } } /* 邮箱注册时 */ $username = generate_username(); /* 邮箱注册 */ $result = register_by_email($username, $password, $email, $other); if ($result) { /* 删除注册的验证记录 */ remove_validate_record($email); } } else { if ($register_type == "mobile") { require_once ROOT_PATH . 'includes/lib_validate_record.php'; $mobile_phone = !empty($_POST['mobile_phone']) ? trim($_POST['mobile_phone']) : ''; $mobile_code = !empty($_POST['mobile_code']) ? trim($_POST['mobile_code']) : ''; $record = get_validate_record($mobile_phone); $session_mobile_phone = $_SESSION[VT_MOBILE_REGISTER]; /* 手机验证码检查 */ if (empty($mobile_code)) { show_message($_LANG['msg_mobile_phone_blank'], $_LANG['sign_up'], 'register.php', 'error'); } else { if ($session_mobile_phone != $mobile_phone) { show_message($_LANG['mobile_phone_changed'], $_LANG['sign_up'], 'register.php', 'error'); } else { if ($record['record_code'] != $mobile_code) { show_message($_LANG['invalid_mobile_phone_code'], $_LANG['sign_up'], 'register.php', 'error'); } else { if ($record['expired_time'] < time()) { show_message($_LANG['invalid_mobile_phone_code'], $_LANG['sign_up'], 'register.php', 'error'); } } } } /* 手机注册时,用户名默认为u+手机号 */ $username = generate_username_by_mobile($mobile_phone); /* 手机注册 */ $result = register_by_mobile($username, $password, $mobile_phone, $other); if ($result) { /* 删除注册的验证记录 */ remove_validate_record($mobile_phone); } } else { /* 无效的注册类型 */ show_message($_LANG['register_type_invalid'], $_LANG['sign_up'], 'register.php', 'error'); } } /* 随进生成用户名 */ // $username = generate_username(); if ($result) { /* 把新注册用户的扩展信息插入数据库 */ $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 = ''; // 生成扩展字段的内容字符串 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 .= " ('" . $_SESSION['user_id'] . "', '" . $val['id'] . "', '" . compile_str($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); } /* 代码增加2014-12-23 by www.68ecshop.com _star */ // if($_SESSION['tag'] > 0) // { // $sql = "update " . $GLOBALS['ecs']->table('users') . " set // is_validated = 1 where user_id = '" . $_SESSION['user_id'] . "'"; // $GLOBALS['db']->query($sql); // } // if($other['mobile_phone'] != '') // { // if($_CFG['sms_register'] == 1) // { // $sql = "update " . $GLOBALS['ecs']->table('users') . " set // validated = 1 where user_id = '" . $_SESSION['user_id'] . "'"; // $GLOBALS['db']->query($sql); // } // } /* 代码增加2014-12-23 by www.68ecshop.com _end */ /* * 代码增加_start By www.68ecshop.com * include_once(ROOT_PATH . '/includes/cls_image.php'); * $image = new cls_image($_CFG['bgcolor']); * $headimg_original = * $GLOBALS['image']->upload_image($_FILES['headimg'], 'headimg/'. * date('Ym')); * * $thumb_path=DATA_DIR. '/headimg/' . date('Ym').'/' ; * $headimg_thumb = $GLOBALS['image']->make_thumb($headimg_original, * '80', '50', $thumb_path); * $headimg_thumb = $headimg_thumb ? $headimg_thumb : * $headimg_original; * if ($headimg_thumb) * { * $sql = 'UPDATE ' . $ecs->table('users') . " SET * `headimg`='$headimg_thumb' WHERE `user_id`='" . * $_SESSION['user_id'] . "'"; * $db->query($sql); * } * 代码增加_end By www.68ecshop.com */ /* 写入密码提示问题和答案 */ if (!empty($passwd_answer) && !empty($sel_question)) { $sql = 'UPDATE ' . $ecs->table('users') . " SET `passwd_question`='{$sel_question}', `passwd_answer`='{$passwd_answer}' WHERE `user_id`='" . $_SESSION['user_id'] . "'"; $db->query($sql); } /* 代码增加_start By www.68ecshop.com */ $now = gmtime(); if ($_CFG['bonus_reg_rand']) { $sql_bonus_ext = " order by rand() limit 0,1"; } $sql_b = "SELECT type_id FROM " . $ecs->table("bonus_type") . " WHERE send_type='" . SEND_BY_REGISTER . "' AND send_start_date<=" . $now . " AND send_end_date>=" . $now . $sql_bonus_ext; $res_bonus = $db->query($sql_b); $kkk_bonus = 0; while ($row_bonus = $db->fetchRow($res_bonus)) { $sql = "INSERT INTO " . $ecs->table('user_bonus') . "(bonus_type_id, bonus_sn, user_id, used_time, order_id, emailed)" . " VALUES('" . $row_bonus['type_id'] . "', 0, '" . $_SESSION['user_id'] . "', 0, 0, 0)"; $db->query($sql); $kkk_bonus = $kkk_bonus + 1; } if ($kkk_bonus) { $_LANG['register_success'] = '用户名 %s 注册成功,并获得官方赠送的红包礼品'; } /* 代码增加_end By www.68ecshop.com */ /* 判断是否需要自动发送注册邮件 */ if ($GLOBALS['_CFG']['member_email_validate'] && $GLOBALS['_CFG']['send_verify_email']) { send_regiter_hash($_SESSION['user_id']); } $ucdata = empty($user->ucdata) ? "" : $user->ucdata; show_message(sprintf($_LANG['register_success'], $username . $ucdata), array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act, 'user.php'), 'info'); } else { $GLOBALS['err']->show($_LANG['sign_up'], 'register.php'); } } /* 代码增加2014-12-23 by www.68ecshop.com _star */ }
if ($user_id == 0) { /* 用户没有登录 */ $result['error'] = 1; $result['message'] = $_LANG['login_please']; die($json->encode($result)); } $validate = $_REQUEST['is_validate']; $type = "register"; if ($validate == 0) { $type = "disbind"; } else { if ($validate == 'emailUser_register_email') { $type = 'emailUser_register_email'; } } if (send_regiter_hash($user_id, $type)) { $result['message'] = $_LANG['validate_mail_ok']; die($json->encode($result)); } else { $result['error'] = 1; $result['message'] = $GLOBALS['err']->last_message(); } die($json->encode($result)); } else { if ($action == 'track_packages') { include_once ROOT_PATH . 'includes/lib_transaction.php'; include_once ROOT_PATH . 'includes/lib_order.php'; $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $orders = array(); $sql = "SELECT order_id,order_sn,invoice_no,shipping_id FROM " . $ecs->table('order_info') . " WHERE user_id = '{$user_id}' AND shipping_status = '" . SS_SHIPPED . "'"; $res = $db->query($sql);
/* 检查验证码 */ include_once 'includes/cls_captcha.php'; $validator = new captcha(); if (!$validator->check_word($_POST['captcha'])) { show_api_message($_LANG['invalid_captcha'], $_LANG['sign_up'], $api_url . '/intefrace.php?act=qq_bind_user', 'error'); } } if (register($username, $password, $email, array()) !== false) { $sql = 'UPDATE ' . $ecs->table('users') . " SET `qq_openid`='{$qq_user_info['qq_openid']}', `nick_name`='{$qq_user_info['nick_name']}', `sex`='{$qq_user_info['sex']}', user_rank='{$qq_user_info['user_rank']}' WHERE `user_id`='" . $_SESSION['user_id'] . "'"; /* 通过插件来删除用户 */ $users =& init_users(); $users->remove_user($qq_user_info['user_name']); //已经删除用户所有数据 /* 判断是否需要自动发送注册邮件 */ if ($GLOBALS['_CFG']['member_email_validate'] && $GLOBALS['_CFG']['send_verify_email']) { send_regiter_hash($_SESSION['user_id']); } $ucdata = empty($user->ucdata) ? "" : $user->ucdata; show_api_message(sprintf($_LANG['register_success'], $username . $ucdata), array('回到网站首页', $_LANG['profile_lnk']), array($site_url, $site_url . '/user.php'), 'info'); } else { show_api_message('注册失败', '重新注册绑定', $api_url . '/intefrace.php?act=qq_bind_user', 'error'); } } if (empty($qq_user_info) || empty($qq_user_info['qq_openid'])) { show_api_message('用户信息错误或非qq登录会员', '回到网站首页', $site_url, 'error'); } $smarty->assign('template_dir', $_CFG['template']); $smarty->assign('lang', $_LANG); die($smarty->fetch($api_tpl)); } else { if (empty($api_config['qq_appid']) || empty($api_config['qq_appkey'])) {