YULUserOptFormatter.class.php
2.71 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
require_once 'YULMessageFormatter.class.php';
/**
* 用户操作格式器. 用来格式化产生插入日志数据库中的用户操作消息.消息格式如下
*
* 用户ID|模块|操作代码|ip地址|是否成功|错误代码|加密码
*
* @author dan
*
*/
class YULUserOptFormatter extends YULMessageFormatter {
private $formatter = array(
// 消息类型
'type'=>self::USER_OPT_TYPE,
//用户ID
'userID'=>0,
//模块
'module'=>null,
//操作代码
'operation'=>null,
//ip地址
'ip'=>null,
//是否成功
'isSuccess'=>0,
//错误代码
'errorCode'=>0,
//加密码
'skey'=>null,
);
public function __construct($userID=NULL, $module=NULL, $operation=NULL,
$ip=NULL, $isSuccess=0, $errorCode=0, $skey=NULL)
{
$this->formatter['userID'] = $userID;
$this->formatter['module'] = $module;
$this->formatter['operation'] = $operation;
$this->formatter['ip'] = $ip;
$this->formatter['isSuccess'] = $isSuccess;
$this->formatter['errorCode'] = $errorCode;
$this->formatter['skey'] = $skey;
}
public function setUserID($userID)
{
if (isset($userID))
{
$this->formatter['userID'] = $userID;
}
}
public function setModule($module)
{
if (isset($module))
{
$this->formatter['module'] = $module;
}
}
public function setOperation($operation)
{
if (isset($operation))
{
$this->formatter['operation'] = $operation;
}
}
public function setIp($ip)
{
if (isset($ip))
{
$this->formatter['ip'] = $ip;
}
}
public function setIsSuccess($isSuccess)
{
if (isset($isSuccess))
{
$this->formatter['isSuccess'] = $isSuccess;
}
}
public function setErrorCode($errorCode)
{
if (isset($errorCode))
{
$this->formatter['errorCode'] = $errorCode;
}
}
public function setSkey($skey)
{
if (isset($skey))
{
$this->formatter['skey'] = $skey;
}
}
/*
* 返回最终的格式化数据
*/
public function toString() {
$result = '';
$separator = $this->getSeparator();
foreach ($this->formatter as $format)
{
$result .= $format;
$result .= $separator;
}
return trim($result, $separator);
}
}
?>