function action_do_register($captcha, $mobile, $redirect, $password) { PtApp::session_start(); $reg_captcha = empty($_SESSION['reg_captcha_' . $mobile]) ? "" : $_SESSION['reg_captcha_' . $mobile]; if (!$reg_captcha) { throw new Exception("验证码不能为空", 8001); } $is_register = self::_db()->select_row('select id from et_user where mobile = ? ', $mobile); //var_dump($mobile);exit; if ($is_register) { throw new Exception("当前号码已经注册过"); } $password = md5($password); if ($captcha != "0000" && $captcha != $reg_captcha) { throw new Exception("验证码不正确"); } $uid = self::_db()->insert("et_user", array('nick_name' => $mobile, 'mobile' => $mobile, 'password' => $password, 'add_time' => date_time_now())); self::_db()->insert("et_user_finance", array('uid' => $uid)); $user_info = array("uid" => $uid, "nick_name" => $mobile); Model_User_Auth::set_login($user_info); unset($_SESSION['reg_captcha_' . $mobile]); setcookie("invite_id_cookie", "", time() - 3600, "/"); $res = array("message" => "注册成功"); if ($redirect) { $res['redirect'] = $redirect; } return $res; }
function action_login_as() { $request = \PtLib\http_request("uid"); $uid = $request['uid']; $user = \PtLib\db_select_row("select n.* from users as u left join new_users as n on n.id = u.app_uid where n.id = ?", $uid); $user_info = array("nick_name" => $user['nickname'] ? $user['nickname'] : ($user['mobile'] ? $user['mobile'] : $user['email']), "mobile" => $user['mobile'], "email" => $user['email'], "uid" => $user['id']); Model_User_Auth::set_login($user_info); \PtLib\location("/user/index"); }