public function index() { //require_once APP_ROOT_PATH."system/libs/user.php"; $root = array(); $root['status'] = 0; $email = strim($GLOBALS['request']['email']); //用户名或邮箱 $pwd = strim($GLOBALS['request']['pwd']); //密码 //检查用户,用户密码 $user = user_check($email, $pwd); $user_id = intval($user['id']); if ($user_id > 0) { $root['user_login_status'] = 1; $real_name = strim($GLOBALS['request']['real_name']); $idno = strim($GLOBALS['request']['idno']); if (!$real_name) { $root['response_code'] = 0; $root['show_err'] = "请输入真实姓名"; output($root); } if ($idno == "") { $root['response_code'] = 0; $root['show_err'] = "请输入身份证号"; output($root); } if (getIDCardInfo($idno) == 0) { $root['response_code'] = 0; $root['show_err'] = "身份证号码错误!"; output($root); } //$root['show_err'] = $idno;output($root); //判断该实名是否存在 if ($GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "user where idno = '.{$idno}.' and id<> {$user_id}") > 0) { $root['response_code'] = 0; $root['show_err'] = "该实名已被其他用户认证,非本人请联系客服"; output($root); } $user_info_re = array(); $user_info_re['real_name'] = $real_name; $user_info_re['idno'] = $idno; $GLOBALS['db']->autoExecute(DB_PREFIX . "user", $user_info_re, "UPDATE", "id=" . $user_id); if (intval(app_conf("OPEN_IPS")) > 0) { $app_url = APP_ROOT . "/index.php?ctl=collocation&act=CreateNewAcct&user_type=0&user_id=" . $user_id . "&from=" . $GLOBALS['request']['from']; $root['app_url'] = str_replace("/mapi", "", SITE_DOMAIN . $app_url); $root['acct_url'] = $root['app_url']; } $root['open_ips'] = intval(app_conf("OPEN_IPS")); $root['response_code'] = 1; $root['show_err'] = "验证成功"; $root['status'] = 1; } else { $root['response_code'] = 0; $root['show_err'] = "未登录"; $root['user_login_status'] = 0; } $root['program_title'] = "身份证验证"; output($root); }
/** * 生成会员数据 * @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("/^[\\x{4e00}-\\x{9fa5}_\\-]*[0-9a-zA-Z_\\-]*[\\x{201c}\\x{201d}\\x{3001}\\x{uff1a}\\x{300a}\\x{300b\\x{ff0c}\\x{ff1b}\\x{3002}_\\-]*\$/u", $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 ($mode == "INSERT" && (intval(app_conf('REGISTER_TYPE')) == 0 || intval(app_conf('REGISTER_TYPE')) == 2) || isset($user_data['email'])) { if ($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; } $user['emailpassed'] = intval($user_data['emailpassed']); } if ($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; } $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 (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['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 ($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 ($mode == 'INSERT') { $user['register_ip'] = get_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_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; }
function dobidstepone() { if (!$GLOBALS['user_info']) { showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], 1); } if (strim($_REQUEST['name']) == "") { showErr($GLOBALS['lang']['PLEASE_INPUT'] . $GLOBALS['lang']['URGENTCONTACT'], 1); } $data['real_name'] = strim($_REQUEST['name']); if ($GLOBALS['user_info']['idcardpassed'] == 0) { if (strim($_REQUEST['idno']) == "") { showErr($GLOBALS['lang']['PLEASE_INPUT'] . $GLOBALS['lang']['IDNO'], 1); } if (getIDCardInfo(strim($_REQUEST['idno'])) == 0) { //身份证正则表达式 showErr($GLOBALS['lang']['FILL_CORRECT_IDNO'], 1); } if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where idno = '" . strim($_REQUEST['idno']) . "' and id <> " . intval($GLOBALS['user_info']['id'])) > 0) { showErr(sprintf($GLOBALS['lang']['EXIST_ERROR_TIP'], $GLOBALS['lang']['IDNO']), 1); } if (strim($_REQUEST['idno']) != strim($_REQUEST['idno_re'])) { showErr($GLOBALS['lang']['TWO_ENTER_IDNO_ERROR'], 1); } $data['idno'] = strim($_REQUEST['idno']); $data['idcardpassed'] = 0; } /*手机*/ if ($GLOBALS['user_info']['mobilepassed'] == 0) { if (strim($_REQUEST['phone']) == "") { showErr($GLOBALS['lang']['MOBILE_EMPTY_TIP'], 1); } if (!check_mobile(strim($_REQUEST['phone']))) { showErr($GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'], 1); } if (strim($_REQUEST['validateCode']) == "") { showErr($GLOBALS['lang']['PLEASE_INPUT'] . $GLOBALS['lang']['VERIFY_CODE'], 1); } if (strim($_REQUEST['validateCode']) != $GLOBALS['user_info']['bind_verify']) { showErr($GLOBALS['lang']['BIND_MOBILE_VERIFY_ERROR'], 1); } $data['mobile'] = strim($_REQUEST['phone']); $data['mobilepassed'] = 1; } $GLOBALS['db']->autoExecute(DB_PREFIX . "user", $data, "UPDATE", "id=" . $GLOBALS['user_info']['id']); showSuccess($GLOBALS['lang']['SUCCESS_TITLE'], 1); }
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("该用户尚未注册"); //尚未注册 } }
function credit_save() { $authorized_info = es_session::get("authorized_info"); $type = strim($_REQUEST['type']); $credit_type = load_auto_cache("credit_type"); if (!isset($credit_type['list'][$type])) { showErr('认证类型不存在', $this->is_ajax); } $field_array = array("credit_identificationscanning" => "idcardpassed", "credit_contact" => "workpassed", "credit_credit" => "creditpassed", "credit_incomeduty" => "incomepassed", "credit_house" => "housepassed", "credit_car" => "carpassed", "credit_marriage" => "marrypassed", "credit_titles" => "skillpassed", "credit_videoauth" => "videopassed", "credit_mobilereceipt" => "mobiletruepassed", "credit_residence" => "residencepassed", "credit_seal" => "sealpassed"); $u_c_data[$field_array[$type]] = 0; //身份认证 if ($type == "credit_identificationscanning") { $u_c_data['real_name'] = strim($_REQUEST['real_name']); $u_c_data['idno'] = strim($_REQUEST['idno']); if (getIDCardInfo($u_c_data['idno']) == 0) { showErr("提交失败,身份证号码错误!", $this->is_ajax); } if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where idno = '" . $u_c_data['idno'] . "' and id <> " . intval($authorized_info['id'])) > 0) { showErr("提交失败,身份证号码已使用!", $this->is_ajax); } $u_c_data['sex'] = intval($_REQUEST['sex']); $u_c_data['byear'] = intval($_REQUEST['byear']); $u_c_data['bmonth'] = intval($_REQUEST['bmonth']); $u_c_data['bday'] = intval($_REQUEST['bday']); $u_c_data['bday'] = intval($_REQUEST['bday']); } //汽车认证 if ($type == "credit_car") { $u_c_data['car_brand'] = strim($_REQUEST['carbrand']); $u_c_data['car_year'] = intval($_REQUEST['caryear']); $u_c_data['car_number'] = strim($_REQUEST['carnumber']); $u_c_data['carloan'] = intval($_REQUEST['carloan']); } //房产认证 if ($type == "credit_house") { $u_c_data['houseloan'] = intval($_REQUEST['houseloan']); } //结婚认证 if ($type == "credit_marriage") { $u_c_data['haschild'] = intval($_REQUEST['haschild']); } //学历认证 if ($type == "credit_graducation") { $u_c_data['edu_validcode'] = strim($_REQUEST['validcode']); $u_c_data['graduation'] = strim($_REQUEST['graduation']); $u_c_data['university'] = strim($_REQUEST['university']); $u_c_data['graduatedyear'] = intval($_REQUEST['graduatedyear']); } //视频认证 if ($type == "credit_videoauth") { $u_c_data['has_send_video'] = intval($_REQUEST['usemail']); } //居住地证明 if ($type == "credit_residence") { $u_w_data['province_id'] = intval($_REQUEST['province_id']); $u_w_data['city_id'] = intval($_REQUEST['city_id']); if ($GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "user_work where user_id=" . $authorized_info['id']) > 0) { $u_w_data['user_id'] = $authorized_info['id']; $GLOBALS['db']->autoExecute(DB_PREFIX . "user_work", $u_w_data, "INSERT"); } else { $GLOBALS['db']->autoExecute(DB_PREFIX . "user_work", $u_w_data, "UPDATE", "user_id=" . $authorized_info['id']); } $u_c_data['address'] = htmlspecialchars($_REQUEST['address']); $u_c_data['phone'] = htmlspecialchars($_REQUEST['phone']); $u_c_data['postcode'] = htmlspecialchars($_REQUEST['postcode']); } $GLOBALS['db']->autoExecute(DB_PREFIX . "user", $u_c_data, "UPDATE", "id=" . $authorized_info['id']); $file = array(); if ($credit_type['list'][$type]['file_count'] > 0) { for ($i = 1; $i <= $credit_type['list'][$type]['file_count']; $i++) { if (trim($_REQUEST['file' . $i]) != "") { $file[] = replace_public(strim($_REQUEST['file' . $i])); } } if (count($file) == 0) { exit; } } $mode = "INSERT"; $condition = ""; $temp_info = $GLOBALS['db']->getRow("SELECT user_id,`type`,`file` FROM " . DB_PREFIX . "user_credit_file WHERE user_id=" . $authorized_info['id'] . " AND type='" . $type . "'"); if ($temp_info) { $file_list = unserialize($temp_info['file']); //认证是否过期 $time = TIME_UTC; $expire_time = $credit_type['list'][$type]['expire'] * 30 * 24 * 3600; switch ($type) { case "credit_contact": if ($authorized_info['workpassed'] == 1) { if ($time - $authorized_info['workpassed_time'] > $expire_time) { $authorized_info['workpassed'] = 0; $GLOBALS['db']->query("update " . DB_PREFIX . "user set workpassed=0 WHERE id=" . $authorized_info['id']); es_session::set('user_info', $authorized_info); } } break; case "credit_credit": if ($authorized_info['creditpassed'] == 1) { if ($time - $authorized_info['creditpassed_time'] > $expire_time) { $authorized_info['creditpassed'] = 0; $GLOBALS['db']->query("update " . DB_PREFIX . "user set creditpassed=0 WHERE id=" . $authorized_info['id']); es_session::set('user_info', $authorized_info); } } break; case "credit_incomeduty": if ($authorized_info['incomepassed'] == 1) { if ($time - $authorized_info['incomepassed_time'] > $expire_time) { $authorized_info['incomepassed'] = 0; $GLOBALS['db']->query("update " . DB_PREFIX . "user set incomepassed=0 WHERE id=" . $authorized_info['id']); es_session::set('user_info', $authorized_info); } } break; case "credit_residence": if ($authorized_info['residencepassed'] == 1) { if ($time - $authorized_info['residencepassed_time'] > $expire_time) { $authorized_info['residencepassed'] = 0; $GLOBALS['db']->query("update " . DB_PREFIX . "user set residencepassed=0 WHERE id=" . $authorized_info['id']); es_session::set('user_info', $authorized_info); } } break; case "credit_seal": foreach ($file_list as $k => $v) { @unlink(APP_ROOT_PATH . $v); } $file_list = array(); $authorized_info['sealpassed'] = 0; $GLOBALS['db']->query("update " . DB_PREFIX . "user set sealpassed=0 WHERE id=" . $authorized_info['id']); es_session::set('user_info', $authorized_info); break; } $mode = "UPDATE"; $condition = "user_id=" . $authorized_info['id'] . " AND type='" . $type . "'"; } if ($file) { foreach ($file as $v) { $file_list[] = $v; } } $data['user_id'] = $authorized_info['id']; $data['type'] = $type; $data['status'] = 0; $data['file'] = serialize($file); $data['create_time'] = TIME_UTC; $data['passed'] = 0; $GLOBALS['db']->autoExecute(DB_PREFIX . "user_credit_file", $data, $mode, $condition); if ($this->is_ajax == 1) { showSuccess("提交成功,请等待管理员审核!", $this->is_ajax); } else { $GLOBALS['tmpl']->display("inc/credit/upload_result_tip.html"); } }
/** * 生成会员数据 * @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; }
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("该用户尚未注册"); //尚未注册 } }