Tools.class.php
2.26 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
<?php
/**
* 用户信息
*/
class Controller_Tools extends Controller_Abstract
{
/**
* 首页
*/
public function init()
{
$valid_passwords = array ("yoho" => "yoho9646abcdef");
$valid_users = array_keys($valid_passwords);
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);
if (!$validated)
{
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
die ("Not authorized");
}
}
public function cleanUserCacheAction()
{
$uid = $this->_request->uid ;
if (!$uid)
{
exit('Missing Uid');
}
Facade_Userinfo::cleanUserCache($uid);
return 'success';
}
/**
* 用户信息操作 --- 通过手机号或邮箱获取用户信息
*/
public function userAction()
{
$auth_type = intval($this->_request->type);
$account = trim( $this->_request->account ) ;
$uid = 0 ;
if ($account && $auth_type > 0)
{
$row = Facade_Auth::getAuthByAccount($account,$auth_type);
$uid = isset($row['uid']) ?$row['uid'] : 0 ;
}
if ($auth_type == -1 || $auth_type == -2)
{
$uid = $account ;
}
$error = '' ;
if ($auth_type == -2 && $uid)
{
Facade_Userinfo::cleanUserCache($uid);
$error = '成功清除缓存';
}
$auth_list = $userinfo = array();
if ($uid)
{
$auth_list = Facade_Auth::getAllAuth($uid);
$userinfo = Facade_Userinfo::getUserinfoByUid($uid);
}
if ($this->_request->isPost() && !$userinfo)
{
$error .= '未查到该账号信息';
}
$this->_view['types'] = Facade_Auth::getAllowAuthType() + array('-1' => 'SSO_UID', '-2' => '根据用户ID清除用户缓存');
$this->_view['auth_list'] = $auth_list ;
$this->_view['userinfo'] = $userinfo ;
$this->_view['type'] = $auth_type ;
$this->_view['account'] = $account ;
$this->_view['error'] = $error ;
}
}