manager_class.php
1.54 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
<?php
/**
* Tiny - A PHP Framework For Web Artisans
* @author Tiny <tinylofty@gmail.com>
* @copyright Copyright(c) 2010-2014 http://www.tinyrise.com All rights reserved
* @version 1.0
*/
/**
* 管理者类,封装到系统框架内
*
* @author Tiny
* @class Manager
*/
class Manager extends Object
{
private $status;
/**
* 构造函数
*
* @access public
* @param mixed $name
* @param mixed $password
* @return mixed
*/
public function __construct($name,$password)
{
$safebox = Safebox::getInstance();
$manager = $safebox->get('manager');
if(!isset($manager['id']) || $manager['id']=='' || $manager['name']!=$name)
{
$model = new Model('manager');
$name = Filter::sql($name);
$user = $model->where("name='".$name."'")->find();
if(!empty($user))
{
$key = md5($user['validcode']);
$password = substr($key,0,16).$password.substr($key,16,16);
if($user['password'] == md5($password))
{
$this->status='online';
$this->properties=$user;
$safebox->set('manager',$this->properties);
}
else
{
$this->status='offline';
$this->properties=null;
}
}
else
{
$this->status='offline';
$this->properties=null;
}
}
else
{
$this->status='online';
$this->properties=$safebox->get('manager');
}
}
/**
* 最得管理者的状态
*
* @access public
* @return mixed
*/
public function getStatus()
{
return $this->status;
}
}