public function do_api_register() { require_once APP_ROOT_PATH . "system/libs/user.php"; $api_info = es_session::get("api_user_info"); if (!$api_info) { app_redirect_preview(); } $user_name = strim($_REQUEST['user_name']); $email = strim($_REQUEST['email']); $user_pwd = strim($_REQUEST['user_pwd']); if (app_conf("USER_VERIFY") == 2) { $user_data['mobile'] = strim($_REQUEST['mobile']); $user_data['verify_coder'] = strim($_REQUEST['verify_coder']); } $user_data['user_name'] = $user_name; $user_data['email'] = $email; //$user_data['user_pwd'] = rand(100000,999999); $user_data['user_pwd'] = $user_pwd; $user_data['province'] = $api_info['province']; $user_data['city'] = $api_info['city']; $user_data['is_effect'] = 1; $user_data['sex'] = $api_info['sex']; if (intval($GLOBALS['ref_uid']) > 0) { $user_data['pid'] = intval($GLOBALS['ref_uid']); //推荐人id $user_data['is_send_referrals'] = 1; //未发放返利给推荐人 } else { $user_data['pid'] = 0; //没有推荐人 $user_data['is_send_referrals'] = 0; //不用发放返利 } $res = save_user($user_data); if ($res['status'] == 1) { if (!check_ipop_limit(get_client_ip(), "user_do_api_register", 5)) { showErr("提交太快", 1); } $user_id = intval($res['data']); $GLOBALS['db']->query("update " . DB_PREFIX . "user set " . $api_info['field'] . " = '" . $api_info['id'] . "'," . $api_info['token_field'] . " = '" . $api_info['token'] . "'," . $api_info['secret_field'] . " = '" . $api_info['secret'] . "'," . $api_info['url_field'] . " = '" . $api_info['url'] . "' where id = " . $user_id); $GLOBALS['db']->query("delete from " . DB_PREFIX . "user_weibo where user_id = " . $user_id . " and weibo_url = '" . $api_info['url'] . "'"); update_user_weibo($user_id, $api_info['url']); $user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $user_id); if ($user_info['is_effect'] == 1) { //发放返利给推荐人 if ($user_info['pid'] > 0) { send_referrals($user_info); } //在此自动登录 //send_register_success(0,$user_data); do_login_user($user_data['email'], $user_data['user_pwd']); ajax_return(array("status" => 1, "jump" => get_gopreview())); } else { ajax_return(array("status" => 0, "info" => "请等待管理员审核", "jump" => get_gopreview())); } } else { $error = $res['data']; if ($error['field_name'] == "user_name") { $data[] = array("type" => "form_success", "field" => "email", "info" => ""); $field_name = "会员帐号"; } if ($error['field_name'] == "email") { $data[] = array("type" => "form_success", "field" => "user_name", "info" => ""); $field_name = "电子邮箱"; } if ($error['field_name'] == "verify_coder") { $data[] = array("type" => "form_success", "field" => "verify_coder", "info" => ""); $field_name = "验证码"; } if ($error['field_name'] == "mobile") { $data[] = array("type" => "form_success", "field" => "mobile", "info" => ""); $field_name = "手机号"; } if ($error['error'] == EMPTY_ERROR) { $error_info = "不能为空"; $type = "form_tip"; } if ($error['error'] == FORMAT_ERROR) { $error_info = "格式有误"; $type = "form_error"; } if ($error['error'] == EXIST_ERROR) { $error_info = "已存在"; $type = "form_error"; } ajax_return(array("status" => 0, "info" => $field_name . $error_info, "field" => $error['field_name'], "jump" => get_gopreview())); } }
public function do_register() { $email = strim($_REQUEST['email']); require_once APP_ROOT_PATH . "system/libs/user.php"; $return = $this->register_check_all(); if ($return['status'] == 0) { ajax_return($return); } $user_data = $_POST; foreach ($_POST as $k => $v) { $user_data[$k] = strim($v); } //开启邮箱验证 if (app_conf("USER_VERIFY") == 0 || app_conf("USER_VERIFY") == 2 || app_conf("USER_VERIFY") == 1 || app_conf("USER_VERIFY") == 4) { $user_data['is_effect'] = 1; } else { $user_data['is_effect'] = 0; } if (intval($GLOBALS['ref_uid']) > 0) { $user_data['pid'] = intval($GLOBALS['ref_uid']); //推荐人id $user_data['is_send_referrals'] = 1; //未发放返利给推荐人 } else { $user_data['pid'] = 0; //没有推荐人 $user_data['is_send_referrals'] = 0; //不用发放返利 } $res = save_user($user_data); if ($res['status'] == 1) { if (!check_ipop_limit(get_client_ip(), "user_do_register", 5)) { showErr("提交太快", 1); } $user_id = intval($res['data']); $user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $user_id); if ($user_info['is_effect'] == 1) { //发放返利给推荐人 if ($user_info['pid'] > 0) { send_referrals($user_info); } //在此自动登录 //send_register_success(0,$user_data); $result = do_login_user($user_data['user_name'], $user_data['user_pwd']); // ajax_return(array("status"=>1,"jump"=>get_gopreview())); ajax_return(array("status" => 1, "data" => $result['msg'], "jump" => get_gopreview())); } else { if (app_conf("USER_VERIFY") == 1) { ajax_return(array("status" => 1, "jump" => url_wap("user#mail_check", array('uid' => $user_id)))); } else { if (app_conf("USER_VERIFY") == 3) { ajax_return(array("status" => 0, "info" => "请等待管理员审核")); } } } } else { $error = $res['data']; if ($error['field_name'] == "user_name") { $data[] = array("type" => "form_success", "field" => "email", "info" => ""); $field_name = "会员帐号"; } if ($error['field_name'] == "email") { $data[] = array("type" => "form_success", "field" => "user_name", "info" => ""); $field_name = "电子邮箱"; } if ($error['field_name'] == "mobile") { $data[] = array("type" => "form_success", "field" => "mobile", "info" => ""); $field_name = "手机号码"; } if ($error['field_name'] == "verify_code") { $data[] = array("type" => "form_success", "field" => "verify_code", "info" => ""); $field_name = "验证码"; } if ($error['error'] == EMPTY_ERROR) { $error_info = "不能为空"; $type = "form_tip"; } if ($error['error'] == FORMAT_ERROR) { $error_info = "错误"; $type = "form_error"; } if ($error['error'] == EXIST_ERROR) { $error_info = "已存在"; $type = "form_error"; } //$data[] = array("type"=>$type,"field"=>$error['field_name'],"info"=>$field_name.$error_info); ajax_return(array("status" => 0, "data" => $field_name . $error_info, "info" => "")); } }
public function set_effect() { $id = intval($_REQUEST['id']); $ajax = intval($_REQUEST['ajax']); $user_info = M(MODULE_NAME)->getById($id); $c_is_effect = M(MODULE_NAME)->where("id=" . $id)->getField("is_effect"); //当前状态 $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态 $result = M(MODULE_NAME)->where("id=" . $id)->setField("is_effect", $n_is_effect); if ($result && $c_is_effect == 0 && $user_info['is_send_referrals'] == 1 && $user_info['pid'] > 0) { send_referrals($user_info); //发入返利给推荐人 } save_log($user_info['user_name'] . l("SET_EFFECT_" . $n_is_effect), 1); $this->ajaxReturn($n_is_effect, l("SET_EFFECT_" . $n_is_effect), 1); }