/** * 注销 * @method logout * @return 重定向或者json字符 */ public function logoutAction() { Input::I('url', $url, FILTER_VALIDATE_URL, '/'); Cookie::flush(); Session::flush(); $this->success('注销成功', $url); }
/** * 获取真实姓名 * @method getName * @param [type] $number [description] * @param [type] $pwd [description] * @param [type] $code [description] * @return [type] [description] */ public static function getName($number, $pwd, $code = null) { if (!$code) { return 0; } $data['zjh'] = $number; $data['mm'] = $pwd; $data['v_yzm'] = $code; if ($cookie = Cookie::get('verify_cookie')) { Cookie::del('verify_cookie', null, $_SERVER['HTTP_HOST']); } else { if (\Input::I('verify_cookie', $cookie, 'trim')) { $cookie = @base64_decode($cookie); } } parent::$_cookie = $cookie; $result = parent::getHtml(self::LOGIN_URL, $data, 'gb2312'); if (strpos($result, self::SUCCESS_MSG) > 0) { $result = parent::getHtml(self::INFO_URL, null, 'GBK'); if ($result) { $name = parent::parseName($result, "当前用户:{$number}(", ')'); return trim($name); } } return false; }
/** * @method index * @param string $value [description] * @return [type] [description] * @author NewFuture */ public function indexAction() { Input::I('SERVER.HTTP_TOKEN', $token); Input::I('SERVER.HTTP_USER_AGENT', $agent); $method = $_SERVER['REQUEST_METHOD']; $reponse = ['method' => $method, 'agent' => $agent, 'token' => $token, 'data' => $_REQUEST, 'param' => $GLOBALS['_' . $method]]; $this->response = $reponse; }
/** * @method start * @return string [session id] * @author NewFuture */ public static function start($id = null) { if (!($sid = self::$_id)) { if (($sid = $id) || Input::I('SERVER.HTTP_SESSION_ID', $sid, 'ctype_alnum')) { session_id($sid); session_start(); } else { session_start(); $sid = session_id(); } self::$_id = $sid; } return $sid; }
/** * 获取当前用户 * @method getUser * @return [type] [description] * @author NewFuture */ public static function getUser() { if ($user = Session::get('user')) { /*session中的信息*/ return $user; } elseif (($token = Cookie::get('token')) || Input::I('SERVER.HTTP_TOKEN', $token)) { /*解析cookie*/ if ($token = Encrypt::aesDecode($token, Cookie::key(), true)) { list($uid, $token, $time) = explode(':', $token); if ($time + Config::get('cookie.expire') > $_SERVER['REQUEST_TIME'] && ($user = self::checkToken($uid, $token))) { /*token有效*/ Session::set('user', $user); return $user; } } } }
/** * 创建task数组 * @method create * @param string $method [POST或者PUT] * @return [array] [description] * @author NewFuture */ public static function create($method = '') { $method = $method ? $method . '.' : 'post.'; $task = array(); if (Input::I($method . 'copies', $copies, 'int')) { $task['copies'] = $copies; } if (Input::I($method . 'color', $color)) { $task['color'] = $color ? 1 : 0; } if (Input::I($method . 'isdouble', $is_double)) { $task['double'] = $is_double ? 1 : 0; } if (Input::I($method . 'format', $ppt, 'int')) { $task['format'] = $ppt; } if (Input::I($method . 'requirements', $requirements, 'text')) { $task['requirements'] = $requirements; } return $task; }
/** * 获取真实姓名 * @method getName * @param [type] $number [description] * @param [type] $pwd [description] * @param [type] $code [description] * @return [type] [description] */ public static function getName($number, $pwd, $code = null) { if (!$code) { return 0; } $data['uid'] = $number; $data['password'] = $pwd; $data['captchas'] = $code; if ($cookie = Cookie::get('verify_cookie')) { Cookie::del('verify_cookie', null, $_SERVER['HTTP_HOST']); } else { if (\Input::I('verify_cookie', $cookie, 'trim')) { $cookie = @base64_decode($cookie); } } parent::$_cookie = $cookie; $result = parent::getHtml(self::LOGIN_URL, $data, 'GBK'); if ($result) { $name = parent::parseName($result, "当前用户:{$number}(", ')'); return trim($name); } return false; }