/**
  * 生成会员数据
  * @param $user_data  提交[post或get]的会员数据
  * @param $mode  处理的方式,注册或保存
  * 返回:data中返回出错的字段信息,包括field_name, 可能存在的field_show_name 以及 error 错误常量
  * 不会更新保存的字段为:score,money,verify,pid
  */
 function add_user($user_data)
 {
     //$res = array('status'=>1,'id'=>0); //用于返回的数据
     //验证结束开始插入数据
     $user_id = 0;
     $user['user_name'] = $user_data['user_name'];
     $user['create_time'] = TIME_UTC;
     $user['update_time'] = TIME_UTC;
     $user['pid'] = (int) $user_data['pid'];
     $user['referer_memo'] = $user_data['referer_memo'];
     //获取默认会员组, 即升级积分最小的会员组
     $user['group_id'] = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user_group order by score asc limit 1");
     $user['is_effect'] = 1;
     $user['mobile'] = $user_data['mobile'];
     $user['mobilepassed'] = 1;
     //是否已经绑定手机;1:是;0:否; 手机注册的,直接就绑定手机了;
     $user['code'] = '';
     //默认不使用code, 该值用于其他系统导入时的初次认证
     $user['user_pwd'] = md5($user_data['user_pwd'] . $user['code']);
     /*
     //载入会员整合,手机端没填:email,暂时不做会员整合;
     $integrate_code = trim(app_conf("INTEGRATE_CODE"));
     if($integrate_code!='')
     {
     	$integrate_file = APP_ROOT_PATH."system/integrate/".$integrate_code."_integrate.php";
     	if(file_exists($integrate_file))
     	{
     		require_once $integrate_file;
     		$integrate_class = $integrate_code."_integrate";
     		$integrate_obj = new $integrate_class;
     	}
     }
     
     //同步整合
     if($integrate_obj)
     {
     	$res = $integrate_obj->add_user($user_data['user_name'],$user_data['user_pwd'],$user_data['email']);
     	$user['integrate_id'] = intval($res['data']);
     	
     	if(intval($res['status'])==0) //整合注册失败
     	{
     		return $res;
     	}
     }
     
      $s_api_user_info = es_session::get("api_user_info");
     $user[$s_api_user_info['field']] = $s_api_user_info['id'];
     es_session::delete("api_user_info");
     */
     if ($GLOBALS['db']->autoExecute(DB_PREFIX . "user", $user, 'INSERT')) {
         $user_id = $GLOBALS['db']->insert_id();
         if ((int) app_conf("OPEN_IPS") > 0) {
             $email = get_site_email($user_id);
             $GLOBALS['db']->query("UPDATE " . DB_PREFIX . "user SET email='{$email}' where id=" . $user_id);
         }
         $register_money = doubleval(app_conf("USER_REGISTER_MONEY"));
         $register_score = intval(app_conf("USER_REGISTER_SCORE"));
         $register_point = intval(app_conf("USER_REGISTER_POINT"));
         $register_lock_money = intval(app_conf("USER_LOCK_MONEY"));
         if ($register_money > 0 || $register_score > 0 || $register_point > 0 || $register_lock_money > 0) {
             $user_get['score'] = $register_score;
             $user_get['money'] = $register_money;
             $user_get['point'] = $register_point;
             $user_get['lock_money'] = $register_lock_money;
             modify_account($user_get, intval($user_id), "在" . to_date(TIME_UTC) . "注册成功", 18);
         }
     }
     return $user_id;
 }
Exemple #2
0
/**
 * 生成会员数据
 * @param $user_data  提交[post或get]的会员数据
 * @param $mode  处理的方式,注册或保存
 * 返回:data中返回出错的字段信息,包括field_name, 可能存在的field_show_name 以及 error 错误常量
 * 不会更新保存的字段为:score,money,verify,pid
 */
function save_user($user_data, $mode = 'INSERT')
{
    //开始数据验证
    $res = array('status' => 1, 'info' => '', 'data' => '');
    //用于返回的数据
    if ($mode == "INSERT" || isset($user_data['user_name'])) {
        if (trim($user_data['user_name']) == '') {
            $field_item['field_name'] = 'user_name';
            $field_item['error'] = EMPTY_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if (!preg_match("/^(?!_|\\s\\')[A-Za-z0-9_�-�\\']+\$/", $user_data['user_name']) || is_numeric($user_data['user_name'])) {
            $field_item['field_name'] = 'user_name';
            $field_item['error'] = FORMAT_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where user_name = '" . trim($user_data['user_name']) . "' and id <> " . intval($user_data['id'])) > 0) {
            $field_item['field_name'] = 'user_name';
            $field_item['error'] = EXIST_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
    }
    if ((intval($_REQUEST["REGISTER_TYPE"]) == 0 || intval($_REQUEST["REGISTER_TYPE"]) == 2) && intval($user_data["user_type"]) != 2 && intval($user_data["user_type"]) != 3 && ($mode == "INSERT" && (intval(app_conf('REGISTER_TYPE')) == 0 || intval(app_conf('REGISTER_TYPE')) == 2) || isset($user_data['email']))) {
        if (strim($user_data['email']) != "" && $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where email = '" . trim($user_data['email']) . "' and id <> " . intval($user_data['id'])) > 0) {
            $field_item['field_name'] = 'email';
            $field_item['error'] = EXIST_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if (trim($user_data['email']) == '') {
            $field_item['field_name'] = 'email';
            $field_item['error'] = EMPTY_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if (!check_email(trim($user_data['email']))) {
            $field_item['field_name'] = 'email';
            $field_item['error'] = FORMAT_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if (isset($user_data['emailpassed'])) {
            $user['emailpassed'] = intval($user_data['emailpassed']);
        }
    }
    if (intval($user_data["user_type"]) == 3 && $user_data["idno"] != "") {
        $user["idcardpassed"] = $user_data["idcardpassed"];
        $user["idcardpassed_time"] = $user_data["idcardpassed_time"];
    }
    if ((intval($_REQUEST["REGISTER_TYPE"]) == 0 || intval($_REQUEST["REGISTER_TYPE"]) == 1) && intval($user_data["user_type"]) != 2 && intval($user_data["user_type"]) != 3 && ($mode == "INSERT" && (intval(app_conf('REGISTER_TYPE')) == 0 || intval(app_conf('REGISTER_TYPE')) == 1) || isset($user_data['mobile']))) {
        if (trim($user_data['mobile']) == '') {
            $field_item['field_name'] = 'mobile';
            $field_item['error'] = EMPTY_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if (!check_mobile(trim($user_data['mobile']))) {
            $field_item['field_name'] = 'mobile';
            $field_item['error'] = FORMAT_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if ($user_data['mobile'] != '' && $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where mobile = '" . trim($user_data['mobile']) . "' and id <> " . intval($user_data['id'])) > 0) {
            $field_item['field_name'] = 'mobile';
            $field_item['error'] = EXIST_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if (isset($user_data['mobilepassed'])) {
            $user['mobilepassed'] = intval($user_data['mobilepassed']);
        }
    }
    if (isset($user_data['idno']) && strim($user_data['idno']) != "") {
        if (getIDCardInfo($user_data['idno']) == 0) {
            $field_item['field_name'] = 'idno';
            $field_item['error'] = FORMAT_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where idno = '" . trim($user_data['idno']) . "' and id <> " . intval($user_data['id'])) > 0) {
            $field_item['field_name'] = 'idno';
            $field_item['error'] = EXIST_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
    }
    //验证扩展字段
    if (isset($user_data['user_pwd'])) {
        $user_field = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user_field");
        foreach ($user_field as $field_item) {
            if ($field_item['is_must'] == 1 && trim($user_data[$field_item['field_name']]) == '') {
                $field_item['error'] = EMPTY_ERROR;
                $res['status'] = 0;
                $res['data'] = $field_item;
                return $res;
            }
        }
    }
    //验证结束开始插入数据
    if ($mode == "INSERT" || $user_data['user_name']) {
        $user['user_name'] = $user_data['user_name'];
    }
    $user['update_time'] = TIME_UTC;
    if (isset($user_data['pid'])) {
        $user['pid'] = $user_data['pid'];
    }
    if (isset($user_data['referral_rate'])) {
        $user['referral_rate'] = $user_data['referral_rate'];
    }
    if (isset($user_data['real_name'])) {
        $user['real_name'] = $user_data['real_name'];
    }
    if (isset($user_data['idno'])) {
        $user['idno'] = $user_data['idno'];
    }
    if (isset($user_data['graduation'])) {
        $user['graduation'] = $user_data['graduation'];
    }
    if (isset($user_data['graduatedyear'])) {
        $user['graduatedyear'] = intval($user_data['graduatedyear']);
    }
    if (isset($user_data['university'])) {
        $user['university'] = $user_data['university'];
    }
    if (isset($user_data['marriage'])) {
        $user['marriage'] = $user_data['marriage'];
    }
    if (isset($user_data['haschild'])) {
        $user['haschild'] = intval($user_data['haschild']);
    }
    if (isset($user_data['hashouse'])) {
        $user['hashouse'] = intval($user_data['hashouse']);
    }
    if (isset($user_data['houseloan'])) {
        $user['houseloan'] = intval($user_data['houseloan']);
    }
    if (isset($user_data['hascar'])) {
        $user['hascar'] = intval($user_data['hascar']);
    }
    if (isset($user_data['carloan'])) {
        $user['carloan'] = intval($user_data['carloan']);
    }
    if (isset($user_data['address'])) {
        $user['address'] = $user_data['address'];
    }
    if (isset($user_data['phone'])) {
        $user['phone'] = $user_data['phone'];
    }
    if (isset($user_data['n_province_id'])) {
        $user['n_province_id'] = intval($user_data['n_province_id']);
    }
    if (isset($user_data['n_city_id'])) {
        $user['n_city_id'] = intval($user_data['n_city_id']);
    }
    if (isset($user_data['province_id'])) {
        $user['province_id'] = intval($user_data['province_id']);
    }
    if (isset($user_data['city_id'])) {
        $user['city_id'] = intval($user_data['city_id']);
    }
    if (isset($user_data['sex'])) {
        $user['sex'] = intval($user_data['sex']);
    }
    if (isset($user_data['byear'])) {
        $user['byear'] = intval($user_data['byear']);
    }
    if (isset($user_data['bmonth'])) {
        $user['bmonth'] = intval($user_data['bmonth']);
    }
    if (isset($user_data['bday'])) {
        $user['bday'] = intval($user_data['bday']);
    }
    if (isset($user_data['referer_memo'])) {
        $user['referer_memo'] = $user_data['referer_memo'];
    }
    if (isset($user_data['admin_id'])) {
        $user['admin_id'] = $user_data['admin_id'];
    }
    /**担保机构字段**/
    if (isset($user_data['short_name'])) {
        $user['short_name'] = $user_data['short_name'];
    }
    if (isset($user_data['brief'])) {
        $user['brief'] = $user_data['brief'];
    }
    if (isset($user_data['header'])) {
        $user['header'] = $user_data['header'];
    }
    if (isset($user_data['company_brief'])) {
        $user['company_brief'] = $user_data['company_brief'];
    }
    if (isset($user_data['history'])) {
        $user['history'] = $user_data['history'];
    }
    if (isset($user_data['content'])) {
        $user['content'] = $user_data['content'];
    }
    if (isset($user_data['sort'])) {
        $user['sort'] = $user_data['sort'];
    }
    if (isset($user_data['ips_mer_code'])) {
        $user['ips_mer_code'] = $user_data['ips_mer_code'];
    }
    if (isset($user_data['ips_acct_no'])) {
        $user['ips_acct_no'] = $user_data['ips_acct_no'];
    }
    if (isset($user_data['acct_type'])) {
        $user['acct_type'] = intval($user_data['acct_type']);
    }
    if (isset($user_data['u_year'])) {
        $user['u_year'] = $user_data['u_year'];
    }
    if (isset($user_data['u_special'])) {
        $user['u_special'] = $user_data['u_special'];
    }
    if (isset($user_data['university'])) {
        $user['university'] = $user_data['university'];
    }
    if (isset($user_data['u_alipay'])) {
        $user['u_alipay'] = $user_data['u_alipay'];
    }
    //		//定义注册完成为普通VIP会员
    //		$vip_grade="普通VIP会员";
    //		$vip_grade_id=$GLOBALS['db']->getOne("select id from ".DB_PREFIX."vip_type where vip_grade = '".$vip_grade."' ");
    //		if($vip_grade_id){
    //			$user['vip_grade'] = $vip_grade_id;
    //		}else{
    //			$user['vip_grade'] = 1;
    //		}
    //		$user['vip_state'] = 1;
    //自动获取会员分组
    if (intval($user_data['group_id']) != 0) {
        $user['group_id'] = $user_data['group_id'];
    } else {
        if ($mode == 'INSERT') {
            //获取默认会员组, 即升级积分最小的会员组
            $user['group_id'] = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user_group order by score asc limit 1");
        }
    }
    //会员状态
    if (intval($user_data['is_effect']) != 0) {
        $user['is_effect'] = $user_data['is_effect'];
    } else {
        if ($mode == 'INSERT') {
            if (intval(app_conf("USER_VERIFY")) == 4) {
                $user['is_effect'] = 0;
            } elseif (app_conf("USER_VERIFY") == 3) {
                $user['is_effect'] = 1;
            }
        }
    }
    if ($mode == "INSERT" || isset($user_data['email'])) {
        $user['email'] = $user_data['email'];
    }
    if ($mode == "INSERT" || isset($user_data['mobile'])) {
        $user['mobile'] = $user_data['mobile'];
    }
    if ($mode == "INSERT" || isset($user_data['user_type'])) {
        $user['user_type'] = intval($user_data['user_type']);
    }
    if ($mode == 'INSERT') {
        $user['create_time'] = TIME_UTC;
        $user['create_date'] = to_date(TIME_UTC, "Y-m-d");
        $user['code'] = '';
        //默认不使用code, 该值用于其他系统导入时的初次认证
    } else {
        $user['code'] = $GLOBALS['db']->getOne("select code from " . DB_PREFIX . "user where id =" . $user_data['id']);
    }
    if (isset($user_data['user_pwd']) && $user_data['user_pwd'] != '') {
        $user['user_pwd'] = md5($user_data['user_pwd'] . $user['code']);
    }
    $user['old_user_name'] = $user_data['old_user_name'];
    $user['old_email'] = $user_data['old_email'];
    $user['old_password'] = $user_data['old_password'];
    $user['new_password'] = $user_data['user_pwd'];
    $date_time = to_date(TIME_UTC);
    //载入会员整合
    $integrate_code = trim(app_conf("INTEGRATE_CODE"));
    if ($integrate_code != '') {
        $integrate_file = APP_ROOT_PATH . "system/integrate/" . $integrate_code . "_integrate.php";
        if (file_exists($integrate_file)) {
            require_once $integrate_file;
            $integrate_class = $integrate_code . "_integrate";
            $integrate_obj = new $integrate_class();
        }
    }
    //同步整合
    if ($integrate_obj) {
        if (empty($user_data['email'])) {
            if (!empty($user_data['mobile'])) {
                //如果有手机号码则使用:  手机号@域名  格式组成邮箱
                $user_data['email'] = get_site_email($user_data['mobile']);
            } else {
                if (ctype_alnum($user_data['user_name'])) {
                    //昵称是字母跟数字的组合则:  昵称@域名  格式组成邮箱
                    $user_data['email'] = get_site_email($user_data['user_name']);
                } else {
                    //昵称是中文组合则:  base64(昵称)@域名  格式组成邮箱
                    $user_data['email'] = get_site_email(base64_encode($user_data['user_name']));
                }
            }
            $user['email'] = $user_data['email'];
        }
        if ($mode == 'INSERT') {
            $res = $integrate_obj->add_user($user_data['user_name'], $user_data['user_pwd'], $user_data['email']);
            $user['integrate_id'] = intval($res['data']);
        } else {
            $add_res = $integrate_obj->add_user($user_data['user_name'], $user_data['user_pwd'], $user_data['email']);
            if (intval($add_res['status']) && $integrate_code != "Cn273") {
                $GLOBALS['db']->query("update " . DB_PREFIX . "user set integrate_id = " . intval($add_res['data']) . " where id = " . intval($user_data['id']));
            } else {
                if (isset($user_data['user_pwd']) && $user_data['user_pwd'] != '') {
                    $status = $integrate_obj->edit_user($user, $user_data['user_pwd']);
                    if ($status <= 0) {
                        //修改密码失败
                        $res['status'] = 0;
                    }
                }
            }
        }
        if (intval($res['status']) == 0) {
            return $res;
        }
    }
    //引入时区配置及定义时间函数
    if (function_exists('date_default_timezone_set')) {
        date_default_timezone_set(app_conf('DEFAULT_TIMEZONE'));
    }
    if ($mode == 'INSERT') {
        $user['register_ip'] = CLIENT_IP;
        $s_api_user_info = es_session::get("api_user_info");
        $user[$s_api_user_info['field']] = $s_api_user_info['id'];
        es_session::delete("api_user_info");
        $where = '';
    } else {
        unset($user['pid']);
        $where = "id=" . intval($user_data['id']);
    }
    if ($GLOBALS['db']->autoExecute(DB_PREFIX . "user", $user, $mode, $where)) {
        if ($mode == 'INSERT' && ($user_data["user_type"] == 0 || $user_data["user_type"] == 1)) {
            $user_id = $GLOBALS['db']->insert_id();
            $register_money = doubleval(app_conf("USER_REGISTER_MONEY"));
            $register_score = intval(app_conf("USER_REGISTER_SCORE"));
            $register_point = intval(app_conf("USER_REGISTER_POINT"));
            $register_lock_money = intval(app_conf("USER_LOCK_MONEY"));
            if ($register_money > 0 || $register_score > 0 || $register_point > 0 || $register_lock_money > 0) {
                $user_get['score'] = $register_score;
                $user_get['money'] = $register_money;
                $user_get['point'] = $register_point;
                $user_get['lock_money'] = $register_lock_money;
                modify_account($user_get, intval($user_id), "在" . $date_time . "注册成功", 18);
            }
        } else {
            $user_id = $user_data['id'];
        }
    }
    $res['data'] = $user_id;
    //开始更新处理扩展字段
    if ($mode == 'INSERT') {
        foreach ($user_field as $field_item) {
            $extend = array();
            $extend['user_id'] = $user_id;
            $extend['field_id'] = $field_item['id'];
            $extend['value'] = $user_data[$field_item['field_name']];
            $GLOBALS['db']->autoExecute(DB_PREFIX . "user_extend", $extend, $mode);
        }
    } else {
        foreach ($user_field as $field_item) {
            $extend = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_extend where user_id=" . $user_id . " and field_id =" . $field_item['id']);
            if ($extend) {
                $extend['value'] = $user_data[$field_item['field_name']];
                $where = 'id=' . $extend['id'];
                $GLOBALS['db']->autoExecute(DB_PREFIX . "user_extend", $extend, $mode, $where);
            } else {
                $extend = array();
                $extend['user_id'] = $user_id;
                $extend['field_id'] = $field_item['id'];
                $extend['value'] = $user_data[$field_item['field_name']];
                $GLOBALS['db']->autoExecute(DB_PREFIX . "user_extend", $extend, "INSERT");
            }
        }
    }
    return $res;
}
Exemple #3
0
 public function do_re_name_id()
 {
     $id = $GLOBALS['user_info']['id'];
     $real_name = strim($_REQUEST['real_name']);
     $idno = strim($_REQUEST['idno']);
     $sex = strim($_REQUEST['sex']);
     $byear = strim($_REQUEST['byear']);
     $bmonth = strim($_REQUEST['bmonth']);
     $bday = strim($_REQUEST['bday']);
     $user_type = intval($GLOBALS['user_info']['user_type']);
     if ($user_type == 1) {
         $enterpriseName = strim($_REQUEST['enterpriseName']);
         $bankLicense = strim($_REQUEST['bankLicense']);
         $orgNo = strim($_REQUEST['orgNo']);
         $businessLicense = strim($_REQUEST['businessLicense']);
         $taxNo = strim($_REQUEST['taxNo']);
         if ($enterpriseName == "") {
             showErr("请输入企业名称");
         }
         if ($bankLicense == "") {
             showErr("请输入开户银行许可证");
         }
         if ($orgNo == "") {
             showErr("请输入组织机构代码");
         }
         if ($businessLicense == "") {
             showErr("请输入营业执照编号");
         }
         if ($taxNo == "") {
             showErr("请输入税务登记号");
         }
     }
     if (!$id) {
         showErr("该用户尚未登陆", url("index", "user#login"));
     }
     if (!$real_name) {
         showErr("请输入真实姓名");
         //姓名格式错误
     }
     if ($idno == "") {
         showErr("请输入身份证号");
     }
     if (getIDCardInfo($idno) == 0) {
         showErr("身份证号码错误!");
     }
     //判断该实名是否存在
     if ($GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "user where idno = '.{$idno}.' and id<> {$id} ") > 0) {
         showErr("该实名已被其他用户认证,非本人请联系客服");
     }
     if ($user = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id =" . $id)) {
         $user_info_re = array();
         $user_info_re['id'] = $id;
         $user_info_re['real_name'] = $real_name;
         $user_info_re['idno'] = $idno;
         $user_info_re['sex'] = $sex;
         $user_info_re['byear'] = $byear;
         $user_info_re['bmonth'] = $bmonth;
         $user_info_re['bday'] = $bday;
         if ($user_type == 1) {
             $user_info_re['enterpriseName'] = $enterpriseName;
             $user_info_re['bankLicense'] = $bankLicense;
             $user_info_re['orgNo'] = $orgNo;
             $user_info_re['businessLicense'] = $businessLicense;
             $user_info_re['taxNo'] = $taxNo;
         }
         if ($user['email'] == "" && (int) app_conf("OPEN_IPS") > 0) {
             $user_info_re['email'] = get_site_email($id);
         }
         $GLOBALS['db']->autoExecute(DB_PREFIX . "user", $user_info_re, "UPDATE", "id=" . $id);
         $data['user_id'] = $GLOBALS['user_info']['id'];
         $data['type'] = "credit_identificationscanning";
         $data['status'] = 0;
         $data['create_time'] = TIME_UTC;
         $data['passed'] = 0;
         $condition = "";
         if ($GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "user_credit_file WHERE user_id=" . $GLOBALS['user_info']['id'] . " AND type='credit_identificationscanning'") > 0) {
             $mode = "UPDATE";
             $condition = "user_id=" . $GLOBALS['user_info']['id'] . " AND type='credit_identificationscanning'";
         } else {
             $mode = "INSERT";
         }
         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_credit_file", $data, $mode, $condition);
         if ($user_type == 1) {
             $user_company = array();
             $user_company['company_name'] = $enterpriseName;
             $user_company['contact'] = $real_name;
             $user_company['bankLicense'] = $bankLicense;
             $user_company['orgNo'] = $orgNo;
             $user_company['businessLicense'] = $businessLicense;
             $user_company['taxNo'] = $taxNo;
             if ($GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "user_company WHERE user_id=" . intval($GLOBALS['user_info']['id'])) > 0) {
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "user_company", $user_company, "UPDATE", "user_id=" . $id);
             } else {
                 $user_company['user_id'] = $id;
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "user_company", $user_company, "INSERT");
             }
         }
         if (app_conf("OPEN_IPS") == 1) {
             showSuccess("验证成功", 0, APP_ROOT . "/index.php?ctl=collocation&act=CreateNewAcct&user_type=0&user_id=" . $id);
         } else {
             showSuccess("注册成功", 0, APP_ROOT . "/");
         }
     } else {
         showErr("该用户尚未注册");
         //尚未注册
     }
 }
 public function saveemail()
 {
     $oemail = strim($_REQUEST['oemail']);
     $email = strim($_REQUEST['email']);
     $code = $_REQUEST['code'];
     $remail = get_site_email($GLOBALS['user_info']['id']);
     if ($GLOBALS['user_info']['email'] != "" && $remail != $GLOBALS['user_info']['email']) {
         if ($oemail != $GLOBALS['user_info']['email']) {
             $result['info'] = "旧邮箱确认失败";
             ajax_return($result);
         }
     }
     if ($email != "" && !check_email($email)) {
         $result['info'] = "新邮箱格式错误";
         ajax_return($result);
     }
     if ($GLOBALS['user_info']['emailpassed'] == 1) {
         $result['info'] = "该账户已绑定认证过邮箱,无法进行此操作";
         ajax_return($result);
     }
     if ($code != $GLOBALS['user_info']['verify']) {
         $result['info'] = "验证码错误";
         ajax_return($result);
     }
     if ($email == "") {
         $email = $oemail;
     }
     $GLOBALS['db']->query("update " . DB_PREFIX . "user set email = '" . $email . "',verify = '',emailpassed = 1 where id = " . $GLOBALS['user_info']['id']);
     $result['status'] = 1;
     $result['info'] = "邮箱绑定成功";
     ajax_return($result);
 }
 public function do_re_name_id()
 {
     $id = $GLOBALS['user_info']['id'];
     $real_name = strim($_REQUEST['real_name']);
     $idno = strim($_REQUEST['idno']);
     $sex = strim($_REQUEST['sex']);
     $byear = strim($_REQUEST['byear']);
     $bmonth = strim($_REQUEST['bmonth']);
     $bday = strim($_REQUEST['bday']);
     if (!$id) {
         showErr("该用户尚未登陆", 0, url("index", "user#login"));
     }
     if (!$real_name) {
         showErr("请输入真实姓名");
         //姓名格式错误
     }
     if ($idno == "") {
         showErr("请输入身份证号");
     }
     if (getIDCardInfo($idno) == 0) {
         showErr("身份证号码错误!");
     }
     //判断该实名是否存在
     if ($GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "user where idno = '.{$idno}.' and id<> {$id} ") > 0) {
         showErr("该实名已被其他用户认证,非本人请联系客服");
     }
     if ($user = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id =" . $id)) {
         $user_info_re = array();
         $user_info_re['id'] = $id;
         $user_info_re['real_name'] = $real_name;
         $user_info_re['idno'] = $idno;
         $user_info_re['sex'] = $sex;
         $user_info_re['byear'] = $byear;
         $user_info_re['bmonth'] = $bmonth;
         $user_info_re['bday'] = $bday;
         if ($user['email'] == "" && (int) app_conf("OPEN_IPS") > 0) {
             $user_info_re['email'] = get_site_email($id);
         }
         $GLOBALS['db']->autoExecute(DB_PREFIX . "user", $user_info_re, "UPDATE", "id=" . $id);
         if (app_conf("OPEN_IPS") == 1) {
             showSuccess("验证成功", 0, APP_ROOT . "/index.php?ctl=collocation&act=CreateNewAcct&user_type=0&user_id=" . $id);
         } else {
             showSuccess("注册成功", 0, APP_ROOT . "/");
         }
     } else {
         showErr("该用户尚未注册");
         //尚未注册
     }
 }
 public function saveemail()
 {
     $GLOBALS['manageagency_info'] = $this->checkLogin();
     $oemail = strim($_REQUEST['oemail']);
     $email = strim($_REQUEST['email']);
     $code = $_REQUEST['code'];
     $GLOBALS['manageagency_info'] = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_agency where id = '" . intval($GLOBALS['manageagency_info']['id']) . "'");
     $remail = get_site_email($GLOBALS['manageagency_info']['id']);
     if ($GLOBALS['manageagency_info']['email'] != "" && $remail != $GLOBALS['manageagency_info']['email']) {
         if ($oemail != $GLOBALS['manageagency_info']['email']) {
             $data['status'] = 0;
             $data['info'] = "原邮箱不匹配";
             ajax_return($data);
         }
     }
     if ($email != "" && !check_email($email)) {
         $data['status'] = 0;
         $data['info'] = "新邮箱格式错误";
         ajax_return($data);
     }
     if ($GLOBALS['manageagency_info']['emailpassed'] == 1) {
         $data['status'] = 0;
         $data['info'] = "该账户已绑定认证过邮箱,无法进行此操作";
         ajax_return($data);
     }
     if ($code != $GLOBALS['manageagency_info']['verify']) {
         $data['status'] = 0;
         $data['info'] = "验证码错误";
         ajax_return($data);
     }
     if ($email == "") {
         $email = $oemail;
     }
     $GLOBALS['db']->query("update " . DB_PREFIX . "deal_agency set email = '" . $email . "',emailpassed = 1 where id = " . $GLOBALS['manageagency_info']['id']);
     $result['status'] = 1;
     $result['info'] = "邮箱绑定成功";
     ajax_return($result);
 }
<?php

include 'core/init.php';
protect_page();
admin_page();
include 'includes/overall/overall_header.php';
?>
<h1><a href="admin.php">Administration</a> - Site Settings</h1>
<?php 
$site_email = get_site_email();
if (!empty($_REQUEST)) {
    if (isset($_REQUEST['site-email']) && $site_email != $_REQUEST['site-email']) {
        $_SESSION['admin-save']['site-email'] = 0;
        if (set_site_setting('site_email', $_REQUEST['site-email'])) {
            $_SESSION['admin-save']['site-email'] = 1;
        }
    }
    if (isset($_REQUEST['site-status']) && SITE_STATUS != $_REQUEST['site-status']) {
        $_SESSION['admin-save']['site-status'] = 0;
        if (set_site_setting('site_status', $_REQUEST['site-status'])) {
            $_SESSION['admin-save']['site-status'] = 1;
        }
    }
    header('Location: admin_site_settings.php');
    exit;
}
if (isset($_SESSION['admin-save'])) {
    if (isset($_SESSION['admin-save']['site-email'])) {
        $message = '<h3 style="color: #ff0000;>There was a problem saving the site email!</h3>';
        if ($_SESSION['admin-save']['site-email']) {
            $message = '<h3>Site email saved successfully!</h3>';
 public function saveemail()
 {
     if (!check_hash_key()) {
         showErr("非法请求!", $ajax);
     }
     $authorized_info = es_session::get("authorized_info");
     $authorized_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id =" . $authorized_info["id"]);
     $oemail = strim($_REQUEST['oemail']);
     $email = strim($_REQUEST['email']);
     $code = $_REQUEST['code'];
     $remail = get_site_email($GLOBALS['authorized_info']['id']);
     if ($GLOBALS['authorized_info']['email'] != "" && $remail != $authorized_info['email']) {
         if ($oemail != $authorized_info['email']) {
             $result['info'] = "旧邮箱确认失败";
             ajax_return($result);
         }
     }
     if ($email != "" && !check_email($email)) {
         $result['info'] = "新邮箱格式错误";
         ajax_return($result);
     }
     if ($authorized_info['emailpassed'] == 1) {
         $result['info'] = "该账户已绑定认证过邮箱,无法进行此操作";
         ajax_return($result);
     }
     if ($code != $authorized_info['verify']) {
         $result['info'] = "验证码错误";
         ajax_return($result);
     }
     if ($email == "") {
         $email = $oemail;
     }
     $GLOBALS['db']->query("update " . DB_PREFIX . "user set email = '" . $email . "',verify = '',emailpassed = 1 where id = " . $GLOBALS['authorized_info']['id']);
     $result['status'] = 1;
     $result['info'] = "邮箱绑定成功";
     ajax_return($result);
 }