Cgi.class.php
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* 登录控制器
*/
class Controller_Cgi extends Controller_Abstract
{
private $_app_info = null ;
public function init()
{
$key = trim($this->_request->key);
if (!$key)
{
return "Missing Key" ;
}
$appInfo = Facade_Subscribe::get($key);
if(!$appInfo)
{
return "KEY Error" ;
}
$this->_appId = $appInfo['key'];
$this->_app_info = $appInfo ;
}
/**
* 登录
*/
public function loginAction()
{
$uid = Facade_Auth::getAuthedUid();
$callback = urldecode($this->_request->callback) ;
$refer = urldecode($this->_request->refer) ;
$findpwd = urldecode($this->_request->findpwd) ;
$reg = urldecode($this->_request->reg) ;
if (!$callback)
{
return "Missing Callback" ;
}
$headpic = '' ;
if ($uid)
{
//@TODO 获取用户头像
$headpic = '' ;
if(!$headpic)
{
//默认头像(必须有)
$headpic = 'http://passport.yoho.cn/img/ad.jpg' ;
}
}
$this->_view['headpic'] = $headpic ;
$this->_view['app_key'] = $this->_appId ;
$this->_view['callback'] = $callback;
$this->_view['refer'] = $refer ? $refer : $this->_request->referer();
$this->_view['reg'] = $reg;
$this->_view['findpwd'] = $findpwd;
}
public function dologinAction()
{
if ($this->_request->isPost() )
{
$account = trim($this->_request->post('account'));
$password = trim($this->_request->post('password'));
$check = Facade_Auth::checkLogin($account, $password);
if (isset($check['uid']) && $check['uid'])
{
$data = Api_Uuc::buildData(array('uid' => $check['uid']), $this->_app_info['key'], $this->_app_info['secret']);
return '1|'. http_build_query($data);
}
return '0|'.$check['message'];
}
}
/**
* 快捷登录
*/
public function autologinAction()
{
$uid = Facade_Auth::getAuthedUid() ;
if($uid)
{
$data = Api_Uuc::buildData(array('uid' => $uid), $this->_app_info['key'], $this->_app_info['secret']);
return '1|'. http_build_query($data);
}
return '0|该请求已过期,请尝试刷新页面!';
}
}