Showing
4 changed files
with
120 additions
and
1 deletions
@@ -12,6 +12,8 @@ | @@ -12,6 +12,8 @@ | ||
12 | namespace Api; | 12 | namespace Api; |
13 | 13 | ||
14 | use Plugin\Cache; | 14 | use Plugin\Cache; |
15 | +use Plugin\UdpLog; | ||
16 | + | ||
15 | class Yohobuy | 17 | class Yohobuy |
16 | { | 18 | { |
17 | /* 正式环境 */ | 19 | /* 正式环境 */ |
@@ -186,6 +188,8 @@ class Yohobuy | @@ -186,6 +188,8 @@ class Yohobuy | ||
186 | curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); | 188 | curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); |
187 | } | 189 | } |
188 | $result = curl_exec($ch); | 190 | $result = curl_exec($ch); |
191 | + //log打印 | ||
192 | + UdpLog::info('get调用接口入参url/出参:', 'in:'.$url.' out:'.$result); | ||
189 | if (!$returnJson && !empty($result)) { | 193 | if (!$returnJson && !empty($result)) { |
190 | $result = json_decode($result, true); | 194 | $result = json_decode($result, true); |
191 | } | 195 | } |
@@ -249,6 +253,8 @@ class Yohobuy | @@ -249,6 +253,8 @@ class Yohobuy | ||
249 | curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | 253 | curl_setopt($ch, CURLOPT_POSTFIELDS, $str); |
250 | } | 254 | } |
251 | $result = curl_exec($ch); | 255 | $result = curl_exec($ch); |
256 | + //log打印 | ||
257 | + UdpLog::info('get调用接口入参url/出参:', 'in:'.$url.'?'.$str.' out:'.$result); | ||
252 | if (!$returnJson && !empty($result)) { | 258 | if (!$returnJson && !empty($result)) { |
253 | $result = json_decode($result, true); | 259 | $result = json_decode($result, true); |
254 | } | 260 | } |
library/Plugin/UdpLog.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by IntelliJ IDEA. | ||
4 | + * User: hbomb_000 | ||
5 | + * Date: 2016/5/5 | ||
6 | + * Time: 18:17 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace Plugin; | ||
10 | + | ||
11 | + | ||
12 | +/** | ||
13 | + * Class UdpLog | ||
14 | + * @useage: | ||
15 | + * UdpLog::info('get payment list begin',array('order_code'=>123231)); | ||
16 | + * @package WebPlugin | ||
17 | + */ | ||
18 | +class UdpLog | ||
19 | +{ | ||
20 | + //influxdb url | ||
21 | + public static $url = 'influxdb.yohobuy.com'; | ||
22 | + //influxdb port | ||
23 | + public static $port = '4444'; | ||
24 | + //influxdb measurement | ||
25 | + public static $measurement = 'php_log'; | ||
26 | + | ||
27 | + /** | ||
28 | + * proc line and send log to influxdb | ||
29 | + * @param $level | ||
30 | + * @param $message | ||
31 | + * @param $meta | ||
32 | + */ | ||
33 | + private static function procLog($level,$message,$debugInfo,$meta='') { | ||
34 | + $level = str_replace(__CLASS__.'::','',$level); | ||
35 | + $file = $debugInfo[0]["file"]; | ||
36 | + $line = $debugInfo[0]["line"]; | ||
37 | + | ||
38 | + //make tags | ||
39 | + $tags = array( | ||
40 | + 'host='.gethostname(), | ||
41 | + 'level='.$level, | ||
42 | + 'file='.$file, | ||
43 | + 'line='.$line | ||
44 | + ); | ||
45 | + | ||
46 | + //make a line | ||
47 | + $tags = implode(',',$tags); | ||
48 | + | ||
49 | + $string = self::$measurement .','.$tags.' message="'.$message.'",meta="'.var_export($meta,true).'"'; | ||
50 | + self::send($string); | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * send by udp | ||
55 | + * @param $string | ||
56 | + */ | ||
57 | + private static function send($string) { | ||
58 | + $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); | ||
59 | + $len = strlen($string); | ||
60 | + socket_sendto($sock, $string, $len, 0, self::$url, self::$port); | ||
61 | + socket_close($sock); | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * info log | ||
66 | + * @param $message | ||
67 | + * @param $meta | ||
68 | + */ | ||
69 | + public static function info($message,$meta='') { | ||
70 | + self::procLog(__METHOD__,$message,debug_backtrace(),$meta); | ||
71 | + } | ||
72 | + | ||
73 | + /** | ||
74 | + * warn log | ||
75 | + * @param $message | ||
76 | + * @param $meta | ||
77 | + */ | ||
78 | + public static function warn($message,$meta='') { | ||
79 | + self::procLog(__METHOD__,$message,debug_backtrace(),$meta); | ||
80 | + } | ||
81 | + | ||
82 | + /** | ||
83 | + * error log | ||
84 | + * @param $message | ||
85 | + * @param $meta | ||
86 | + */ | ||
87 | + public static function error($message,$meta='') { | ||
88 | + self::procLog(__METHOD__,$message,debug_backtrace(),$meta); | ||
89 | + } | ||
90 | + | ||
91 | + /** | ||
92 | + * debug log | ||
93 | + * @param $message | ||
94 | + * @param $meta | ||
95 | + */ | ||
96 | + public static function debug($message,$meta='') { | ||
97 | + self::procLog(__METHOD__,$message,debug_backtrace(),$meta); | ||
98 | + } | ||
99 | +} | ||
100 | + |
@@ -5,6 +5,7 @@ use LibModels\Wap\Passport\LoginData; | @@ -5,6 +5,7 @@ use LibModels\Wap\Passport\LoginData; | ||
5 | use LibModels\Wap\Passport\RegData; | 5 | use LibModels\Wap\Passport\RegData; |
6 | use Plugin\Helpers; | 6 | use Plugin\Helpers; |
7 | use Plugin\Partner\Factory; | 7 | use Plugin\Partner\Factory; |
8 | +use Plugin\UdpLog; | ||
8 | 9 | ||
9 | /** | 10 | /** |
10 | * 登录的控制器 | 11 | * 登录的控制器 |
@@ -117,6 +118,7 @@ class LoginController extends AbstractAction | @@ -117,6 +118,7 @@ class LoginController extends AbstractAction | ||
117 | $profile = $this->post('account'); | 118 | $profile = $this->post('account'); |
118 | $password = $this->post('password'); | 119 | $password = $this->post('password'); |
119 | if (!is_numeric($area) || empty($profile) || empty($password)) { | 120 | if (!is_numeric($area) || empty($profile) || empty($password)) { |
121 | + UdpLog::info('【登录】校验参数传递auth','area:'.$area.'profile:'.$profile.'password:'.$password); | ||
120 | break; | 122 | break; |
121 | } | 123 | } |
122 | 124 | ||
@@ -124,6 +126,7 @@ class LoginController extends AbstractAction | @@ -124,6 +126,7 @@ class LoginController extends AbstractAction | ||
124 | $verifyEmail = Helpers::verifyEmail($profile); | 126 | $verifyEmail = Helpers::verifyEmail($profile); |
125 | $verifyMobile = ($area === '86') ? Helpers::verifyMobile($profile) : Helpers::verifyAreaMobile($profile, $area); | 127 | $verifyMobile = ($area === '86') ? Helpers::verifyMobile($profile) : Helpers::verifyAreaMobile($profile, $area); |
126 | if (!$verifyEmail && !$verifyMobile) { | 128 | if (!$verifyEmail && !$verifyMobile) { |
129 | + UdpLog::info('【登录】校验账号是否有效auth','email:'.$verifyEmail.'mobile:'.$verifyMobile); | ||
127 | break; | 130 | break; |
128 | } | 131 | } |
129 | 132 |
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | use LibModels\Wap\Passport\RegData; | 4 | use LibModels\Wap\Passport\RegData; |
5 | use Plugin\Helpers; | 5 | use Plugin\Helpers; |
6 | +use Plugin\UdpLog; | ||
6 | 7 | ||
7 | /** | 8 | /** |
8 | * 注册的控制器 | 9 | * 注册的控制器 |
@@ -64,7 +65,7 @@ class RegController extends AbstractAction | @@ -64,7 +65,7 @@ class RegController extends AbstractAction | ||
64 | 'backUrl' => SITE_MAIN . '/?go=1', // 返回的URL链接 | 65 | 'backUrl' => SITE_MAIN . '/?go=1', // 返回的URL链接 |
65 | 'headerText' => '注册', // 头部信息 | 66 | 'headerText' => '注册', // 头部信息 |
66 | 'isPassportPage' => true, // 模板中模块标识 | 67 | 'isPassportPage' => true, // 模板中模块标识 |
67 | - 'areaCode' => $area, // 地区编号 | 68 | + 'areaCode' => '+' . $area, // 地区编号 |
68 | 'phoneNum' => $mobile, // 手机号 | 69 | 'phoneNum' => $mobile, // 手机号 |
69 | 'token' => $token, // 访问令牌 | 70 | 'token' => $token, // 访问令牌 |
70 | 'serviceUrl'=>'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info='//在线客服 | 71 | 'serviceUrl'=>'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info='//在线客服 |
@@ -127,12 +128,14 @@ class RegController extends AbstractAction | @@ -127,12 +128,14 @@ class RegController extends AbstractAction | ||
127 | $area = $this->post('areaCode', '86'); | 128 | $area = $this->post('areaCode', '86'); |
128 | /* 判断参数是否合法 */ | 129 | /* 判断参数是否合法 */ |
129 | if (!is_numeric($mobile) || !is_numeric($area)) { | 130 | if (!is_numeric($mobile) || !is_numeric($area)) { |
131 | + UdpLog::info('【注册】校验参数传递verfymobile','area:'.$area.'profile:'.$mobile); | ||
130 | break; | 132 | break; |
131 | } | 133 | } |
132 | 134 | ||
133 | /* 设置注册有效时间30分钟, 防机器刷 */ | 135 | /* 设置注册有效时间30分钟, 防机器刷 */ |
134 | $expire = $this->getSession('_REG_EXPIRE'); | 136 | $expire = $this->getSession('_REG_EXPIRE'); |
135 | if (empty($expire) || $expire < time()) { | 137 | if (empty($expire) || $expire < time()) { |
138 | + UdpLog::info('【注册】校验session页面停留时间verfymobile','注册有效时间失效(30min)'); | ||
136 | break; | 139 | break; |
137 | } | 140 | } |
138 | 141 | ||
@@ -176,12 +179,14 @@ class RegController extends AbstractAction | @@ -176,12 +179,14 @@ class RegController extends AbstractAction | ||
176 | $code = $this->post('code'); | 179 | $code = $this->post('code'); |
177 | /* 判断参数是否合法 */ | 180 | /* 判断参数是否合法 */ |
178 | if (!is_numeric($mobile) || !is_numeric($area) || !isset($code)) { | 181 | if (!is_numeric($mobile) || !is_numeric($area) || !isset($code)) { |
182 | + UdpLog::info('【注册】校验参数传递verifycode','area:'.$area.'mobile:'.$mobile.'code:'.$code); | ||
179 | break; | 183 | break; |
180 | } | 184 | } |
181 | 185 | ||
182 | /* 设置注册有效时间30分钟, 防机器刷 */ | 186 | /* 设置注册有效时间30分钟, 防机器刷 */ |
183 | $expire = $this->getSession('_REG_EXPIRE'); | 187 | $expire = $this->getSession('_REG_EXPIRE'); |
184 | if (empty($expire) || $expire < time()) { | 188 | if (empty($expire) || $expire < time()) { |
189 | + UdpLog::info('【注册】校验session页面停留时间verifycode','注册有效时间失效(30min)'); | ||
185 | break; | 190 | break; |
186 | } | 191 | } |
187 | 192 | ||
@@ -224,12 +229,14 @@ class RegController extends AbstractAction | @@ -224,12 +229,14 @@ class RegController extends AbstractAction | ||
224 | $area = $this->post('areaCode', '86'); | 229 | $area = $this->post('areaCode', '86'); |
225 | /* 判断参数是否合法 */ | 230 | /* 判断参数是否合法 */ |
226 | if (!is_numeric($mobile) || !is_numeric($area)) { | 231 | if (!is_numeric($mobile) || !is_numeric($area)) { |
232 | + UdpLog::info('【注册】发送验证码sendcode','mobile:'.$mobile.'area:'.$area); | ||
227 | break; | 233 | break; |
228 | } | 234 | } |
229 | 235 | ||
230 | /* 设置注册有效时间30分钟, 防机器刷 */ | 236 | /* 设置注册有效时间30分钟, 防机器刷 */ |
231 | $expire = $this->getSession('_REG_EXPIRE'); | 237 | $expire = $this->getSession('_REG_EXPIRE'); |
232 | if (empty($expire) || $expire < time()) { | 238 | if (empty($expire) || $expire < time()) { |
239 | + UdpLog::info('【注册】发送验证码sendcode','注册有效时间失效(30min)'); | ||
233 | break; | 240 | break; |
234 | } | 241 | } |
235 | 242 | ||
@@ -268,16 +275,19 @@ class RegController extends AbstractAction | @@ -268,16 +275,19 @@ class RegController extends AbstractAction | ||
268 | $password = $this->post('password'); | 275 | $password = $this->post('password'); |
269 | /* 判断参数是否合法 */ | 276 | /* 判断参数是否合法 */ |
270 | if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area) || !isset($password)) { | 277 | if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area) || !isset($password)) { |
278 | + UdpLog::info('【注册】判断参数是否合法setpassword','token:'.$token.'mobile:'.$mobile.'area:'.$area.'passsport:'.$password); | ||
271 | break; | 279 | break; |
272 | } | 280 | } |
273 | 281 | ||
274 | /* 判断是否允许访问 */ | 282 | /* 判断是否允许访问 */ |
275 | if (!Helpers::verifyToken($mobile, $token)) { | 283 | if (!Helpers::verifyToken($mobile, $token)) { |
284 | + UdpLog::info('【注册】判断参数是否可访问setpassword','token:'.$token.'mobile:'.$mobile); | ||
276 | break; | 285 | break; |
277 | } | 286 | } |
278 | 287 | ||
279 | /* 判断密码是否符合规则 */ | 288 | /* 判断密码是否符合规则 */ |
280 | if (!Helpers::verifyPassword($password)) { | 289 | if (!Helpers::verifyPassword($password)) { |
290 | + UdpLog::info('【注册】密码不符合规范setpassword','password:'.$password); | ||
281 | break; | 291 | break; |
282 | } | 292 | } |
283 | 293 |
-
Please register or login to post a comment