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"); }
function view_login() { if (Model_User_Auth::is_logined()) { $this->_location("/user/index"); } }
<span class="sr-only">切换导航</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand site-logo" href="/">易衫网</a> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li><a href="/design" class="design">开始设计</a></li> <!--<li><a href="/invite">邀请朋友</a></li>--> </ul> <?php if (Model_User_Auth::is_logined()) { $uid = Model_User_Abstract::get_uid(); $user = \PtLib\db_select_row("select * from users where id = ?", $uid); ?> <ul class="nav navbar-nav navbar-right"> <li><a href="/user/order/index">我的订单</a></li> <li><a href="/user/activity/index">我的活动</a></li> <li class="dropdown pull-right"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">你好,<?php echo $user['nick_name']; ?> <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <li><a href="/user/setting/profile">账户设置</a></li> <li class="divider"></li> <li><a href="/api?model=user/auth&action=logout">注销</a></li>
static function get_uid() { $uid = Model_User_Auth::get_uid(); return $uid; }