@@ -37,7 +37,7 @@ |
||
37 | 37 | .$this->decryptPhoneNum.','.$this->decryptNickNum.','.$this->decryptReceiverNameNum.',' |
38 | 38 | .$this->decryptSimpleNum.','.$this->decryptSearchNum.','.$this->searchPhoneNum.',' |
39 | 39 | .$this->searchNickNum.','.$this->searchReceiverNameNum.','.$this->searchSimpleNum.',' |
40 | - .$this->searchSearchNum ; |
|
40 | + .$this->searchSearchNum; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | function __construct() |
@@ -14,19 +14,19 @@ |
||
14 | 14 | return $this->apiParas; |
15 | 15 | } |
16 | 16 | |
17 | - public function setRandomNum($random){ |
|
17 | + public function setRandomNum($random) { |
|
18 | 18 | $this->apiParas['random_num'] = $random; |
19 | 19 | } |
20 | 20 | |
21 | - public function setCustomerUserId($customId){ |
|
21 | + public function setCustomerUserId($customId) { |
|
22 | 22 | $this->apiParas['customer_user_id'] = $customId; |
23 | 23 | } |
24 | 24 | |
25 | - public function setSecretVersion($version){ |
|
25 | + public function setSecretVersion($version) { |
|
26 | 26 | $this->apiParas['secret_version'] = $version; |
27 | 27 | } |
28 | 28 | |
29 | - public function check(){} |
|
29 | + public function check() {} |
|
30 | 30 | |
31 | 31 | public function putOtherTextParam($key, $value) { |
32 | 32 | $this->apiParas[$key] = $value; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | $session = '6101701a21788e0e44743d5f1032ccd5276f00ea6a2d9092050695162'; |
13 | 13 | |
14 | - $client = new SecurityClient($c,'S7/xdg4AD7WooWY7+g11qoBpaVsEkonULDJPEiMcXPE='); |
|
14 | + $client = new SecurityClient($c, 'S7/xdg4AD7WooWY7+g11qoBpaVsEkonULDJPEiMcXPE='); |
|
15 | 15 | $yac = new YacCache; |
16 | 16 | $client->setCacheClient($yac); |
17 | 17 | |
@@ -19,50 +19,50 @@ discard block |
||
19 | 19 | $val = '13834566786'; |
20 | 20 | |
21 | 21 | echo "原文:13834566786".PHP_EOL; |
22 | - $encryptValue = $client->encrypt($val,$type,$session); |
|
22 | + $encryptValue = $client->encrypt($val, $type, $session); |
|
23 | 23 | echo "加密后:".$encryptValue.PHP_EOL; |
24 | - echo "search明文:".$val." -->".$client->search("6786",$type,$session).PHP_EOL; |
|
24 | + echo "search明文:".$val." -->".$client->search("6786", $type, $session).PHP_EOL; |
|
25 | 25 | |
26 | - if($client->isEncryptData($encryptValue,$type)) |
|
26 | + if ($client->isEncryptData($encryptValue, $type)) |
|
27 | 27 | { |
28 | - $originalValue = $client->decrypt($encryptValue,$type,$session); |
|
28 | + $originalValue = $client->decrypt($encryptValue, $type, $session); |
|
29 | 29 | echo "解密后:".$originalValue.PHP_EOL; |
30 | 30 | } |
31 | 31 | |
32 | - $originalValue = $client->decrypt('~YjW+T6rCmKcc0tGqzWIDaQ==~-113~','nick',$session); |
|
32 | + $originalValue = $client->decrypt('~YjW+T6rCmKcc0tGqzWIDaQ==~-113~', 'nick', $session); |
|
33 | 33 | echo "公钥解密后:".$originalValue.PHP_EOL; |
34 | 34 | |
35 | 35 | |
36 | 36 | $secArray = array('~YjW+T6rCmKcc0tGqzWIDaQ==~-113~'); |
37 | - $client->decryptBatch($secArray,'nick',$session); |
|
37 | + $client->decryptBatch($secArray, 'nick', $session); |
|
38 | 38 | |
39 | 39 | |
40 | - $typeArray = array('normal','nick','receiver_name'); |
|
40 | + $typeArray = array('normal', 'nick', 'receiver_name'); |
|
41 | 41 | |
42 | 42 | $val2 = '啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊看哦【啊啊啊的'; |
43 | 43 | |
44 | 44 | foreach ($typeArray as $type2) { |
45 | 45 | echo "==============================TOP================================".PHP_EOL; |
46 | - $encty2 = $client->encrypt($val2,$type2,$session); |
|
46 | + $encty2 = $client->encrypt($val2, $type2, $session); |
|
47 | 47 | echo $type2."|明文:".$val2." ---->密文:".$encty2.PHP_EOL; |
48 | - if($client->isEncryptData($encty2,$type2)) |
|
48 | + if ($client->isEncryptData($encty2, $type2)) |
|
49 | 49 | { |
50 | - $originalValue = $client->decrypt($encty2,$type2,$session); |
|
50 | + $originalValue = $client->decrypt($encty2, $type2, $session); |
|
51 | 51 | echo "解密后:".$originalValue.PHP_EOL; |
52 | - echo "search明文:".$originalValue." -->".$client->search($originalValue,$type2,$session).PHP_EOL; |
|
53 | - }else{ |
|
52 | + echo "search明文:".$originalValue." -->".$client->search($originalValue, $type2, $session).PHP_EOL; |
|
53 | + }else { |
|
54 | 54 | echo "不是加密数据".PHP_EOL; |
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | - $encryptNick = $client->encrypt("xxxuxxxuxxxu","nick"); |
|
58 | + $encryptNick = $client->encrypt("xxxuxxxuxxxu", "nick"); |
|
59 | 59 | echo "加密后:".$encryptNick.PHP_EOL; |
60 | - echo "search明文:xxxuxxxuxxxu -->".$client->search("xxxu","nick").PHP_EOL; |
|
61 | - if($client->isEncryptData($encryptNick,"nick")) |
|
60 | + echo "search明文:xxxuxxxuxxxu -->".$client->search("xxxu", "nick").PHP_EOL; |
|
61 | + if ($client->isEncryptData($encryptNick, "nick")) |
|
62 | 62 | { |
63 | - $originalNick = $client->decryptPublic($encryptNick,"nick"); |
|
63 | + $originalNick = $client->decryptPublic($encryptNick, "nick"); |
|
64 | 64 | echo "解密后:".$originalNick.PHP_EOL; |
65 | - }else{ |
|
65 | + }else { |
|
66 | 66 | echo "不是加密数据 ".$encryptNick.PHP_EOL; |
67 | 67 | } |
68 | 68 | ?> |
69 | 69 | \ No newline at end of file |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | |
7 | 7 | class SecretCounterUtil |
8 | 8 | { |
9 | - private $topClient ; |
|
9 | + private $topClient; |
|
10 | 10 | private $cacheClient = null; |
11 | 11 | |
12 | 12 | private $counterMap; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function __destruct() |
25 | 25 | { |
26 | - if($this->cacheClient == null){ |
|
26 | + if ($this->cacheClient == null) { |
|
27 | 27 | |
28 | 28 | } |
29 | 29 | } |
@@ -38,59 +38,59 @@ discard block |
||
38 | 38 | $this->cacheClient = $cache; |
39 | 39 | } |
40 | 40 | |
41 | - function incrDecrypt($delt,$session,$type) |
|
41 | + function incrDecrypt($delt, $session, $type) |
|
42 | 42 | { |
43 | 43 | $item = getItem($session); |
44 | - if($item == null){ |
|
44 | + if ($item == null) { |
|
45 | 45 | $item = new SecretCounter(); |
46 | - putItem($session,$item); |
|
46 | + putItem($session, $item); |
|
47 | 47 | } |
48 | 48 | |
49 | - if($type == "nick"){ |
|
49 | + if ($type == "nick") { |
|
50 | 50 | $item->$decryptNickNum += $delt; |
51 | - }else if($type == "receiver_name"){ |
|
52 | - $item->$decryptReceiverNameNum += $delt ; |
|
53 | - }else if($type == "phone"){ |
|
54 | - $item->$decryptPhoneNum += $delt ; |
|
55 | - }else if($type == "simple"){ |
|
56 | - $item->$decryptSimpleNum += $delt ; |
|
51 | + }else if ($type == "receiver_name") { |
|
52 | + $item->$decryptReceiverNameNum += $delt; |
|
53 | + }else if ($type == "phone") { |
|
54 | + $item->$decryptPhoneNum += $delt; |
|
55 | + }else if ($type == "simple") { |
|
56 | + $item->$decryptSimpleNum += $delt; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | - function incrEncrypt($delt,$session,$type) |
|
60 | + function incrEncrypt($delt, $session, $type) |
|
61 | 61 | { |
62 | 62 | $item = getItem($session); |
63 | - if($item == null){ |
|
63 | + if ($item == null) { |
|
64 | 64 | $item = new SecretCounter(); |
65 | - putItem($session,$item); |
|
65 | + putItem($session, $item); |
|
66 | 66 | } |
67 | 67 | |
68 | - if($type == "nick"){ |
|
69 | - $item->$encryptNickNum += $delt ; |
|
70 | - }else if($type == "receiver_name"){ |
|
71 | - $item->$encryptReceiverNameNum += $delt ; |
|
72 | - }else if($type == "phone"){ |
|
73 | - $item->$encryptPhoneNum += $delt ; |
|
74 | - }else if($type == "simple"){ |
|
75 | - $item->$encryptSimpleNum += $delt ; |
|
68 | + if ($type == "nick") { |
|
69 | + $item->$encryptNickNum += $delt; |
|
70 | + }else if ($type == "receiver_name") { |
|
71 | + $item->$encryptReceiverNameNum += $delt; |
|
72 | + }else if ($type == "phone") { |
|
73 | + $item->$encryptPhoneNum += $delt; |
|
74 | + }else if ($type == "simple") { |
|
75 | + $item->$encryptSimpleNum += $delt; |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | 79 | function getItem($session) |
80 | 80 | { |
81 | - if($this->cacheClient == null){ |
|
81 | + if ($this->cacheClient == null) { |
|
82 | 82 | return $counterMap[$session]; |
83 | - }else{ |
|
83 | + }else { |
|
84 | 84 | return $this->cacheClient->getCache('s_'.$session); |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - function putItem($session,$item) |
|
88 | + function putItem($session, $item) |
|
89 | 89 | { |
90 | - if($this->cacheClient == null){ |
|
90 | + if ($this->cacheClient == null) { |
|
91 | 91 | $counterMap[$session] = $item; |
92 | - }else{ |
|
93 | - $this->cacheClient->setCache('s_'.$session,$item); |
|
92 | + }else { |
|
93 | + $this->cacheClient->setCache('s_'.$session, $item); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | |
10 | 10 | function __construct() |
11 | 11 | { |
12 | - $this->save_file = __DIR__.'/httpdns.conf' ; |
|
12 | + $this->save_file = __DIR__.'/httpdns.conf'; |
|
13 | 13 | $this->application = array(); |
14 | 14 | } |
15 | 15 | |
16 | - public function setValue($var_name,$var_value) |
|
16 | + public function setValue($var_name, $var_value) |
|
17 | 17 | { |
18 | 18 | if (!is_string($var_name) || empty($var_name)) |
19 | 19 | return false; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $this->application[$var_name] = $var_value; |
22 | 22 | } |
23 | 23 | |
24 | - public function write(){ |
|
24 | + public function write() { |
|
25 | 25 | $this->app_data = @serialize($this->application); |
26 | 26 | $this->__writeToFile(); |
27 | 27 | } |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | |
36 | 36 | function __writeToFile() |
37 | 37 | { |
38 | - $fp = @fopen($this->save_file,"w"); |
|
39 | - if(flock($fp , LOCK_EX | LOCK_NB)){ |
|
40 | - @fwrite($fp,$this->app_data); |
|
41 | - flock($fp , LOCK_UN); |
|
38 | + $fp = @fopen($this->save_file, "w"); |
|
39 | + if (flock($fp, LOCK_EX | LOCK_NB)) { |
|
40 | + @fwrite($fp, $this->app_data); |
|
41 | + flock($fp, LOCK_UN); |
|
42 | 42 | } |
43 | 43 | @fclose($fp); |
44 | 44 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | { |
37 | 37 | $logData = implode($this->conf["separator"], $logData); |
38 | 38 | } |
39 | - $logData = $logData. "\n"; |
|
39 | + $logData = $logData."\n"; |
|
40 | 40 | fwrite($this->getFileHandle(), $logData); |
41 | 41 | } |
42 | 42 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | public function check() |
55 | 55 | { |
56 | 56 | |
57 | - RequestCheckUtil::checkNotNull($this->type,"type"); |
|
57 | + RequestCheckUtil::checkNotNull($this->type, "type"); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public function putOtherTextParam($key, $value) { |
@@ -118,9 +118,9 @@ |
||
118 | 118 | public function check() |
119 | 119 | { |
120 | 120 | |
121 | - RequestCheckUtil::checkNotNull($this->activityId,"activityId"); |
|
122 | - RequestCheckUtil::checkMaxValue($this->pageSize,100,"pageSize"); |
|
123 | - RequestCheckUtil::checkMinValue($this->pageSize,1,"pageSize"); |
|
121 | + RequestCheckUtil::checkNotNull($this->activityId, "activityId"); |
|
122 | + RequestCheckUtil::checkMaxValue($this->pageSize, 100, "pageSize"); |
|
123 | + RequestCheckUtil::checkMinValue($this->pageSize, 1, "pageSize"); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | public function putOtherTextParam($key, $value) { |
@@ -182,8 +182,8 @@ |
||
182 | 182 | public function check() |
183 | 183 | { |
184 | 184 | |
185 | - RequestCheckUtil::checkNotNull($this->endTime,"endTime"); |
|
186 | - RequestCheckUtil::checkNotNull($this->startTime,"startTime"); |
|
185 | + RequestCheckUtil::checkNotNull($this->endTime, "endTime"); |
|
186 | + RequestCheckUtil::checkNotNull($this->startTime, "startTime"); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | public function putOtherTextParam($key, $value) { |