Exemple #1
0
 /**
  * 会员添加操作
  *
  * @param
  * @return
  */
 public function usersaveOp()
 {
     //重复注册验证
     if (check_repeat('reg', 40)) {
         showDialog(Language::get('nc_common_op_repeat'), 'index.php');
     }
     /**
      * 读取语言包
      */
     Language::read("home_login_register");
     $lang = Language::getLangContent();
     /**
      * 实例化模型
      */
     $model_member = Model('member');
     /**
      * 检查登录状态
      */
     $model_member->checkloginMember();
     /**
      * 注册验证
      */
     $obj_validate = new Validate();
     $obj_validate->validateparam = array(array("input" => $_POST["user_name"], "require" => "true", "message" => $lang['login_usersave_username_isnull']), array("input" => $_POST["password"], "require" => "true", "message" => $lang['login_usersave_password_isnull']), array("input" => $_POST["password_confirm"], "require" => "true", "validator" => "Compare", "operator" => "==", "to" => $_POST["password"], "message" => $lang['login_usersave_password_not_the_same']), array("input" => $_POST["email"], "require" => "true", "validator" => "email", "message" => $lang['login_usersave_wrong_format_email']), array("input" => strtoupper($_POST["captcha"]), "require" => C('captcha_status_register') == '1' ? "true" : "false", "message" => $lang['login_usersave_code_isnull']), array("input" => $_POST["agree"], "require" => "true", "message" => $lang['login_usersave_you_must_agree']));
     $error = $obj_validate->validate();
     if ($error != '') {
         showValidateError($error);
     }
     if (C('captcha_status_login')) {
         if (!checkSeccode($_POST['nchash'], $_POST['captcha'])) {
             showDialog($lang['login_usersave_wrong_code']);
         }
     }
     $check_member_name = $model_member->infoMember(array('member_name' => trim($_POST['user_name'])));
     if (is_array($check_member_name) and count($check_member_name) > 0) {
         showDialog($lang['login_usersave_your_username_exists']);
     }
     $check_member_email = $model_member->infoMember(array('member_email' => trim($_POST['email'])));
     if (is_array($check_member_email) and count($check_member_email) > 0) {
         showDialog($lang['login_usersave_your_email_exists']);
     }
     $user_array = array();
     if (C('ucenter_status')) {
         /**
          * Ucenter处理
          */
         $model_ucenter = Model('ucenter');
         $uid = $model_ucenter->addUser(trim($_POST['user_name']), trim($_POST['password']), trim($_POST['email']));
         if ($uid < 1) {
             showMessage($lang['login_usersave_regist_fail'], '', 'html', 'error');
         }
         $user_array['member_id'] = $uid;
     }
     /**
     * 注册会员发送短信<?php echo $_POST["name"]; ?>----------------------------------------------------------------------------
     */
     $phone_zc = $_POST['mobile'];
     //注册填写的手机号
     $user = $GLOBALS['setting_config']['dxuser'];
     //短信接口账号
     $passwd = $GLOBALS['setting_config']['dxmima'];
     //短信接口密码
     $message_mj = $GLOBALS['setting_config']['hyzctz'];
     //会员注册时的短信内容
     $gateway_1 = $GLOBALS['setting_config']['hyzctzjk'];
     //HTTP_POST接口代码
     $gateway_1 = iconv("UTF-8", "GB2312//IGNORE", $gateway_1);
     $rccc_1 = @file_get_contents($gateway_1);
     //短信发送结束------------------------------------------------------------------------------------------------------------
     /**
      * 会员添加<?php echo $_POST["name"]; ?>
      */
     $user_array['member_name'] = $_POST['user_name'];
     $user_array['member_passwd'] = $_POST['password'];
     $user_array['member_email'] = $_POST['email'];
     $user_array['member_mobile'] = $_POST['mobile'];
     $result = $model_member->addMember($user_array);
     if ($result) {
         //注册时间标记,访问灌入垃圾用户
         setNcCookie('rp_reg', time());
         $_SESSION['is_login'] = '******';
         $_SESSION['member_id'] = $result;
         $_SESSION['member_name'] = trim($user_array['member_name']);
         $_SESSION['member_email'] = trim($user_array['member_email']);
         $_SESSION['member_mobile'] = trim($user_array['member_mobile']);
         $this->mergecart();
         // cookie中的cart存入数据库
         //添加会员积分
         if ($GLOBALS['setting_config']['points_isuse'] == 1) {
             $points_model = Model('points');
             $points_model->savePointsLog('regist', array('pl_memberid' => $_SESSION['member_id'], 'pl_membername' => $_SESSION['member_name']), false);
         }
         $_POST['ref_url'] = strstr($_POST['ref_url'], 'logout') === false && !empty($_POST['ref_url']) ? $_POST['ref_url'] : 'index.php?act=home&op=member';
         showDialog(str_replace('site_name', C('site_name'), $lang['login_usersave_regist_success_ajax']), $_POST['ref_url'], 'succ', '', 3);
     } else {
         showDialog(Language::get('login_usersave_regist_fail'));
     }
 }
Exemple #2
0
 /**
  * 商品咨询添加
  */
 public function save_consultajaxOp()
 {
     //检查是否可以评论
     if (!C('guest_comment') && !$_SESSION['member_id']) {
         echo json_encode(array('done' => 'false', 'msg' => Language::get('goods_index_goods_noallow')));
         die;
     }
     $goods_id = intval($_GET['goods_id']);
     if ($goods_id <= 0) {
         echo json_encode(array('done' => 'false', 'msg' => Language::get('wrong_argument')));
         die;
     }
     //咨询内容的非空验证
     if (trim($_GET['goods_content']) == "") {
         echo json_encode(array('done' => 'false', 'msg' => Language::get('goods_index_input_consult')));
         die;
     }
     //验证码验证
     if (C('captcha_status_goodsqa') == '1' && !checkSeccode($_GET['nchash'], $_GET['captcha'])) {
         echo json_encode(array('done' => 'false', 'msg' => Language::get('wrong_checkcode')));
         die;
     }
     if (check_repeat('comment')) {
         echo json_encode(array('done' => 'false', 'msg' => Language::get('nc_common_op_repeat')));
         die;
     }
     if ($_SESSION['member_id']) {
         //查询会员信息
         $member_model = Model('member');
         $member_info = $member_model->infoMember(array('member_id' => "{$_SESSION['member_id']}"));
         if (empty($member_info) || $member_info['is_allowtalk'] == 0) {
             echo json_encode(array('done' => 'false', 'msg' => Language::get('goods_index_goods_noallow')));
             die;
         }
     }
     //判断商品编号的存在性和合法性
     $goods = Model('goods');
     $goods_info = array();
     $goods_info = $goods->checkGoods(array('goods_id' => "{$goods_id}"));
     if (empty($goods_info)) {
         echo json_encode(array('done' => 'false', 'msg' => Language::get('goods_index_goods_not_exists')));
         die;
     }
     //判断是否是店主本人
     if ($_SESSION['store_id'] && $goods_info['store_id'] == $_SESSION['store_id']) {
         echo json_encode(array('done' => 'false', 'msg' => Language::get('goods_index_consult_store_error')));
         die;
     }
     //检查店铺状态
     $store_model = Model('store');
     $store_info = $store_model->shopStore(array('store_id' => "{$goods_info['store_id']}"));
     if ($store_info['store_state'] == '0' || intval($store_info['store_state']) == '2' || intval($store_info['store_end_time']) != 0 && $store_info['store_end_time'] <= time()) {
         echo json_encode(array('done' => 'false', 'msg' => Language::get('goods_index_goods_store_closed')));
         die;
     }
     //接收数据并保存
     $input = array();
     $input['goods_id'] = $goods_id;
     $input['cgoods_name'] = $goods_info['goods_name'];
     $input['member_id'] = intval($_SESSION['member_id']) > 0 ? $_SESSION['member_id'] : 0;
     $input['cmember_name'] = $_SESSION['member_name'] ? $_SESSION['member_name'] : '';
     $input['seller_id'] = $store_info['member_id'];
     $input['email'] = $_GET['email'];
     if (strtoupper(CHARSET) == 'GBK') {
         $input['consult_content'] = Language::getGBK($_GET['goods_content']);
     } else {
         $input['consult_content'] = $_GET['goods_content'];
     }
     $input['isanonymous'] = $_GET['hide_name'] == 'hide' ? 1 : 0;
     $consult_model = Model('consult');
     if ($consult_model->addConsult($input)) {
         echo json_encode(array('done' => 'true'));
         die;
     } else {
         echo json_encode(array('done' => 'false', 'msg' => Language::get('goods_index_consult_fail')));
         die;
     }
 }