@@ -8,8 +8,9 @@ discard block |
||
8 | 8 | |
9 | 9 | function __construct() |
10 | 10 | { |
11 | - if (!extension_loaded("yac")) |
|
12 | - $this->isEnable = false; |
|
11 | + if (!extension_loaded("yac")) { |
|
12 | + $this->isEnable = false; |
|
13 | + } |
|
13 | 14 | } |
14 | 15 | |
15 | 16 | public function getCache($key) |
@@ -18,7 +19,7 @@ discard block |
||
18 | 19 | if($this->isEnable){ |
19 | 20 | $yac = new Yac(); |
20 | 21 | return $yac->get($key); |
21 | - }else{ |
|
22 | + } else{ |
|
22 | 23 | echo "yac is not enable ,skip getCache"; |
23 | 24 | } |
24 | 25 | } |
@@ -29,7 +30,7 @@ discard block |
||
29 | 30 | if($this->isEnable){ |
30 | 31 | $yac = new Yac(); |
31 | 32 | $yac->set($key, $var); |
32 | - }else{ |
|
33 | + } else{ |
|
33 | 34 | echo "yac is not enable ,skip setCache"; |
34 | 35 | } |
35 | 36 | } |
@@ -69,8 +69,7 @@ discard block |
||
69 | 69 | if($str[$i] == $sep) |
70 | 70 | { |
71 | 71 | $start = $i + 1; |
72 | - } |
|
73 | - else |
|
72 | + } else |
|
74 | 73 | { |
75 | 74 | break; |
76 | 75 | } |
@@ -80,8 +79,7 @@ discard block |
||
80 | 79 | if($str[$i] == $sep) |
81 | 80 | { |
82 | 81 | $end = $i - 1; |
83 | - } |
|
84 | - else |
|
82 | + } else |
|
85 | 83 | { |
86 | 84 | break; |
87 | 85 | } |
@@ -93,7 +91,7 @@ discard block |
||
93 | 91 | { |
94 | 92 | if(count($dataArray) == 2){ |
95 | 93 | return $this->isBase64Str($dataArray[0]); |
96 | - }else{ |
|
94 | + } else{ |
|
97 | 95 | return $this->isBase64Str($dataArray[0]) && $this->isBase64Str($dataArray[1]); |
98 | 96 | } |
99 | 97 | } |
@@ -155,8 +153,7 @@ discard block |
||
155 | 153 | if($data[$strlen - 2] == $separator) |
156 | 154 | { |
157 | 155 | return $this->checkEncryptData($dataArray); |
158 | - } |
|
159 | - else |
|
156 | + } else |
|
160 | 157 | { |
161 | 158 | $version = $dataArray[$arrayLength -1]; |
162 | 159 | if(is_numeric($version)) |
@@ -165,16 +162,14 @@ discard block |
||
165 | 162 | return $this->isBase64Str($base64Val); |
166 | 163 | } |
167 | 164 | } |
168 | - }else{ |
|
165 | + } else{ |
|
169 | 166 | if($data[strlen($data) - 2] == $separator && $arrayLength == 3) |
170 | 167 | { |
171 | 168 | return $this->checkEncryptData($dataArray); |
172 | - } |
|
173 | - else if($arrayLength == 2) |
|
169 | + } else if($arrayLength == 2) |
|
174 | 170 | { |
175 | 171 | return $this->checkEncryptData($dataArray); |
176 | - } |
|
177 | - else |
|
172 | + } else |
|
178 | 173 | { |
179 | 174 | return false; |
180 | 175 | } |
@@ -222,7 +217,7 @@ discard block |
||
222 | 217 | $slideSize = $this->getArrayValue($secretContext->appConfig,'encrypt_slide_size',4); |
223 | 218 | return $this->encryptNormalIndex($data,$compressLen,$slideSize,$separator,$secretContext); |
224 | 219 | } |
225 | - }else{ |
|
220 | + } else{ |
|
226 | 221 | if('phone' == $type) { |
227 | 222 | return $this->encryptPhone($data,$separator,$secretContext); |
228 | 223 | } else { |
@@ -273,7 +268,7 @@ discard block |
||
273 | 268 | $secretData = null; |
274 | 269 | if($data[$dataLen - 2] == $separator){ |
275 | 270 | $secretData = $this->getIndexSecretData($data,$separator); |
276 | - }else{ |
|
271 | + } else{ |
|
277 | 272 | $secretData = $this->getSecretData($data,$separator); |
278 | 273 | } |
279 | 274 | |
@@ -312,7 +307,7 @@ discard block |
||
312 | 307 | |
313 | 308 | if($data[$dataLen - 2] == $separator){ |
314 | 309 | return $secretData = $this->getIndexSecretData($data,$separator); |
315 | - }else{ |
|
310 | + } else{ |
|
316 | 311 | return $secretData = $this->getSecretData($data,$separator); |
317 | 312 | } |
318 | 313 | } |
@@ -330,7 +325,7 @@ discard block |
||
330 | 325 | { |
331 | 326 | if($arrayLength != 3){ |
332 | 327 | return null; |
333 | - }else{ |
|
328 | + } else{ |
|
334 | 329 | $version = $dataArray[2]; |
335 | 330 | if(is_numeric($version)) |
336 | 331 | { |
@@ -339,12 +334,11 @@ discard block |
||
339 | 334 | $secretData->secretVersion = $version; |
340 | 335 | } |
341 | 336 | } |
342 | - } |
|
343 | - else |
|
337 | + } else |
|
344 | 338 | { |
345 | 339 | if($arrayLength != 2){ |
346 | 340 | return null; |
347 | - }else{ |
|
341 | + } else{ |
|
348 | 342 | $version = $dataArray[1]; |
349 | 343 | if(is_numeric($version)) |
350 | 344 | { |
@@ -364,7 +358,7 @@ discard block |
||
364 | 358 | if($separator == PHONE_SEPARATOR_CHAR) { |
365 | 359 | if ($arrayLength != 3) { |
366 | 360 | return null; |
367 | - }else{ |
|
361 | + } else{ |
|
368 | 362 | $version = $dataArray[2]; |
369 | 363 | if(is_numeric($version)) |
370 | 364 | { |
@@ -517,7 +511,7 @@ discard block |
||
517 | 511 | if($endIndex != 0){ |
518 | 512 | if($startsWithLetterOrDigit){ |
519 | 513 | $currentWindowSize -= 1; |
520 | - }else{ |
|
514 | + } else{ |
|
521 | 515 | $currentWindowSize -= 2; |
522 | 516 | } |
523 | 517 | $startIndex ++; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | if(empty($secretData)){ |
137 | 137 | $result[$value] = $value; |
138 | - }else{ |
|
138 | + } else{ |
|
139 | 139 | $result[$value] = $this->securityUtil->decrypt($value,$type,$secretContext); |
140 | 140 | $this->incrCounter(2,$type,$secretContext,true); |
141 | 141 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | default: |
392 | 392 | break; |
393 | 393 | } |
394 | - }else if($op == 2){ |
|
394 | + } else if($op == 2){ |
|
395 | 395 | switch ($type) { |
396 | 396 | case 'nick': |
397 | 397 | $secretContext->decryptNickNum ++ ; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | default: |
409 | 409 | break; |
410 | 410 | } |
411 | - }else{ |
|
411 | + } else{ |
|
412 | 412 | switch ($type) { |
413 | 413 | case 'nick': |
414 | 414 | $secretContext->searchNickNum ++ ; |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | |
479 | 479 | if(empty($secretContext->session)){ |
480 | 480 | $request->setType(APP_SECRET_TYPE); |
481 | - }else{ |
|
481 | + } else{ |
|
482 | 482 | $request->setType(APP_USER_SECRET_TYPE); |
483 | 483 | } |
484 | 484 | |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | |
535 | 535 | if(empty($session)){ |
536 | 536 | $secretContext->secretVersion = -1 * intval($response->secret_version); |
537 | - }else{ |
|
537 | + } else{ |
|
538 | 538 | $secretContext->secretVersion = intval($response->secret_version); |
539 | 539 | } |
540 | 540 | return $secretContext; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $originalValue = $client->decrypt($encty2,$type2,$session); |
51 | 51 | echo "解密后:".$originalValue.PHP_EOL; |
52 | 52 | echo "search明文:".$originalValue." -->".$client->search($originalValue,$type2,$session).PHP_EOL; |
53 | - }else{ |
|
53 | + } else{ |
|
54 | 54 | echo "不是加密数据".PHP_EOL; |
55 | 55 | } |
56 | 56 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 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 |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | |
49 | 49 | if($type == "nick"){ |
50 | 50 | $item->$decryptNickNum += $delt; |
51 | - }else if($type == "receiver_name"){ |
|
51 | + } else if($type == "receiver_name"){ |
|
52 | 52 | $item->$decryptReceiverNameNum += $delt ; |
53 | - }else if($type == "phone"){ |
|
53 | + } else if($type == "phone"){ |
|
54 | 54 | $item->$decryptPhoneNum += $delt ; |
55 | - }else if($type == "simple"){ |
|
55 | + } else if($type == "simple"){ |
|
56 | 56 | $item->$decryptSimpleNum += $delt ; |
57 | 57 | } |
58 | 58 | } |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | |
68 | 68 | if($type == "nick"){ |
69 | 69 | $item->$encryptNickNum += $delt ; |
70 | - }else if($type == "receiver_name"){ |
|
70 | + } else if($type == "receiver_name"){ |
|
71 | 71 | $item->$encryptReceiverNameNum += $delt ; |
72 | - }else if($type == "phone"){ |
|
72 | + } else if($type == "phone"){ |
|
73 | 73 | $item->$encryptPhoneNum += $delt ; |
74 | - }else if($type == "simple"){ |
|
74 | + } else if($type == "simple"){ |
|
75 | 75 | $item->$encryptSimpleNum += $delt ; |
76 | 76 | } |
77 | 77 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | { |
81 | 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 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | if($this->cacheClient == null){ |
91 | 91 | $counterMap[$session] = $item; |
92 | - }else{ |
|
92 | + } else{ |
|
93 | 93 | $this->cacheClient->setCache('s_'.$session,$item); |
94 | 94 | } |
95 | 95 | } |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | |
16 | 16 | public function setValue($var_name,$var_value) |
17 | 17 | { |
18 | - if (!is_string($var_name) || empty($var_name)) |
|
19 | - return false; |
|
18 | + if (!is_string($var_name) || empty($var_name)) { |
|
19 | + return false; |
|
20 | + } |
|
20 | 21 | |
21 | 22 | $this->application[$var_name] = $var_value; |
22 | 23 | } |
@@ -28,8 +29,9 @@ discard block |
||
28 | 29 | |
29 | 30 | public function getValue() |
30 | 31 | { |
31 | - if (!is_file($this->save_file)) |
|
32 | - $this->__writeToFile(); |
|
32 | + if (!is_file($this->save_file)) { |
|
33 | + $this->__writeToFile(); |
|
34 | + } |
|
33 | 35 | return @unserialize(@file_get_contents($this->save_file)); |
34 | 36 | } |
35 | 37 |
@@ -18,8 +18,9 @@ discard block |
||
18 | 18 | unset($tmpConfig); |
19 | 19 | |
20 | 20 | ClusterTopClient::$syncDate = $saveConfig['syncDate']; |
21 | - if(!ClusterTopClient::$syncDate) |
|
22 | - ClusterTopClient::$syncDate = 0; |
|
21 | + if(!ClusterTopClient::$syncDate) { |
|
22 | + ClusterTopClient::$syncDate = 0; |
|
23 | + } |
|
23 | 24 | } |
24 | 25 | } |
25 | 26 | |
@@ -70,24 +71,29 @@ discard block |
||
70 | 71 | } |
71 | 72 | $currentEnv = $this->getEnvByApiName($apiname,$session); |
72 | 73 | $vip = $this->getVipByEnv($url,$currentEnv); |
73 | - if($vip) |
|
74 | - return $vip; |
|
74 | + if($vip) { |
|
75 | + return $vip; |
|
76 | + } |
|
75 | 77 | return $url; |
76 | 78 | } |
77 | 79 | |
78 | 80 | private function getVipByEnv($comUrl,$currentEnv){ |
79 | 81 | $urlSchema = parse_url($comUrl); |
80 | - if(!$urlSchema) |
|
81 | - return null; |
|
82 | - if(!ClusterTopClient::$dnsconfig['env']) |
|
83 | - return null; |
|
82 | + if(!$urlSchema) { |
|
83 | + return null; |
|
84 | + } |
|
85 | + if(!ClusterTopClient::$dnsconfig['env']) { |
|
86 | + return null; |
|
87 | + } |
|
84 | 88 | |
85 | - if(!array_key_exists($currentEnv,ClusterTopClient::$dnsconfig['env'])) |
|
86 | - return null; |
|
89 | + if(!array_key_exists($currentEnv,ClusterTopClient::$dnsconfig['env'])) { |
|
90 | + return null; |
|
91 | + } |
|
87 | 92 | |
88 | 93 | $hostList = ClusterTopClient::$dnsconfig['env'][$currentEnv]; |
89 | - if(!$hostList) |
|
90 | - return null ; |
|
94 | + if(!$hostList) { |
|
95 | + return null ; |
|
96 | + } |
|
91 | 97 | |
92 | 98 | $vipList = null; |
93 | 99 | foreach ($hostList as $key => $value) { |
@@ -114,7 +120,7 @@ discard block |
||
114 | 120 | $flag = $this->getUserFlag($session); |
115 | 121 | if($userFlag && $flag ){ |
116 | 122 | return $this->getEnvBySessionFlag($userFlag,$flag); |
117 | - }else{ |
|
123 | + } else{ |
|
118 | 124 | return $this->getRandomWeightElement($apiCfg['rule']); |
119 | 125 | } |
120 | 126 | } |
@@ -127,7 +133,7 @@ discard block |
||
127 | 133 | if($session && strlen($session) > 5){ |
128 | 134 | if($session[0] == '6' || $session[0] == '7'){ |
129 | 135 | return $session[strlen($session) -1]; |
130 | - }else if($session[0] == '5' || $session[0] == '8'){ |
|
136 | + } else if($session[0] == '5' || $session[0] == '8'){ |
|
131 | 137 | return $session[5]; |
132 | 138 | } |
133 | 139 | } |
@@ -139,10 +145,11 @@ discard block |
||
139 | 145 | $userConf = ClusterTopClient::$dnsconfig['user']; |
140 | 146 | $cfgArry = $userConf[$targetConfig]; |
141 | 147 | foreach ($cfgArry as $key => $value) { |
142 | - if(in_array($flag,$value)) |
|
143 | - return $key; |
|
148 | + if(in_array($flag,$value)) { |
|
149 | + return $key; |
|
150 | + } |
|
144 | 151 | } |
145 | - }else{ |
|
152 | + } else{ |
|
146 | 153 | return null; |
147 | 154 | } |
148 | 155 | } |
@@ -64,15 +64,13 @@ discard block |
||
64 | 64 | try |
65 | 65 | { |
66 | 66 | $resp = $this->curl($requestUrl, null); |
67 | - } |
|
68 | - catch (Exception $e) |
|
67 | + } catch (Exception $e) |
|
69 | 68 | { |
70 | 69 | $this->logCommunicationError($apiParams["Action"],$requestUrl,"HTTP_ERROR_" . $e->getCode(),$e->getMessage()); |
71 | 70 | if ("json" == $this->format) |
72 | 71 | { |
73 | 72 | return json_decode($e->getMessage()); |
74 | - } |
|
75 | - else if("xml" == $this->format) |
|
73 | + } else if("xml" == $this->format) |
|
76 | 74 | { |
77 | 75 | return @simplexml_load_string($e->getMessage()); |
78 | 76 | } |
@@ -87,8 +85,7 @@ discard block |
||
87 | 85 | { |
88 | 86 | $respWellFormed = true; |
89 | 87 | } |
90 | - } |
|
91 | - else if("xml" == $this->format) |
|
88 | + } else if("xml" == $this->format) |
|
92 | 89 | { |
93 | 90 | $respObject = @simplexml_load_string($resp); |
94 | 91 | if (false !== $respObject) |
@@ -203,11 +200,12 @@ discard block |
||
203 | 200 | $postMultipart = false; |
204 | 201 | foreach ($postFields as $k => $v) |
205 | 202 | { |
206 | - if("@" != substr($v, 0, 1))//判断是不是文件上传 |
|
203 | + if("@" != substr($v, 0, 1)) { |
|
204 | + //判断是不是文件上传 |
|
207 | 205 | { |
208 | - $postBodyString .= "$k=" . urlencode($v) . "&"; |
|
206 | + $postBodyString .= "$k=" . urlencode($v) . "&"; |
|
209 | 207 | } |
210 | - else//文件上传用multipart/form-data,否则用www-form-urlencoded |
|
208 | + } else//文件上传用multipart/form-data,否则用www-form-urlencoded |
|
211 | 209 | { |
212 | 210 | $postMultipart = true; |
213 | 211 | } |
@@ -217,8 +215,7 @@ discard block |
||
217 | 215 | if ($postMultipart) |
218 | 216 | { |
219 | 217 | curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); |
220 | - } |
|
221 | - else |
|
218 | + } else |
|
222 | 219 | { |
223 | 220 | curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString,0,-1)); |
224 | 221 | } |
@@ -77,11 +77,12 @@ discard block |
||
77 | 77 | $postMultipart = false; |
78 | 78 | foreach ($postFields as $k => $v) |
79 | 79 | { |
80 | - if("@" != substr($v, 0, 1))//判断是不是文件上传 |
|
80 | + if("@" != substr($v, 0, 1)) { |
|
81 | + //判断是不是文件上传 |
|
81 | 82 | { |
82 | - $postBodyString .= "$k=" . urlencode($v) . "&"; |
|
83 | + $postBodyString .= "$k=" . urlencode($v) . "&"; |
|
83 | 84 | } |
84 | - else//文件上传用multipart/form-data,否则用www-form-urlencoded |
|
85 | + } else//文件上传用multipart/form-data,否则用www-form-urlencoded |
|
85 | 86 | { |
86 | 87 | $postMultipart = true; |
87 | 88 | if(class_exists('\CURLFile')){ |
@@ -101,8 +102,7 @@ discard block |
||
101 | 102 | } |
102 | 103 | } |
103 | 104 | curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); |
104 | - } |
|
105 | - else |
|
105 | + } else |
|
106 | 106 | { |
107 | 107 | $header = array("content-type: application/x-www-form-urlencoded; charset=UTF-8"); |
108 | 108 | curl_setopt($ch,CURLOPT_HTTPHEADER,$header); |
@@ -114,8 +114,7 @@ discard block |
||
114 | 114 | if (curl_errno($ch)) |
115 | 115 | { |
116 | 116 | throw new Exception(curl_error($ch),0); |
117 | - } |
|
118 | - else |
|
117 | + } else |
|
119 | 118 | { |
120 | 119 | $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
121 | 120 | if (200 !== $httpStatusCode) |
@@ -186,8 +185,7 @@ discard block |
||
186 | 185 | if (curl_errno($ch)) |
187 | 186 | { |
188 | 187 | throw new Exception(curl_error($ch),0); |
189 | - } |
|
190 | - else |
|
188 | + } else |
|
191 | 189 | { |
192 | 190 | $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
193 | 191 | if (200 !== $httpStatusCode) |
@@ -257,7 +255,7 @@ discard block |
||
257 | 255 | if($bestUrl){ |
258 | 256 | $requestUrl = $bestUrl."?"; |
259 | 257 | $sysParams["partner_id"] = $this->getClusterTag(); |
260 | - }else{ |
|
258 | + } else{ |
|
261 | 259 | $requestUrl = $this->gatewayUrl."?"; |
262 | 260 | $sysParams["partner_id"] = $this->sdkVersion; |
263 | 261 | } |
@@ -287,11 +285,10 @@ discard block |
||
287 | 285 | { |
288 | 286 | if(count($fileFields) > 0){ |
289 | 287 | $resp = $this->curl_with_memory_file($requestUrl, $apiParams, $fileFields); |
290 | - }else{ |
|
288 | + } else{ |
|
291 | 289 | $resp = $this->curl($requestUrl, $apiParams); |
292 | 290 | } |
293 | - } |
|
294 | - catch (Exception $e) |
|
291 | + } catch (Exception $e) |
|
295 | 292 | { |
296 | 293 | $this->logCommunicationError($sysParams["method"],$requestUrl,"HTTP_ERROR_" . $e->getCode(),$e->getMessage()); |
297 | 294 | $result->code = $e->getCode(); |
@@ -314,8 +311,7 @@ discard block |
||
314 | 311 | $respObject = $propValue; |
315 | 312 | } |
316 | 313 | } |
317 | - } |
|
318 | - else if("xml" == $this->format) |
|
314 | + } else if("xml" == $this->format) |
|
319 | 315 | { |
320 | 316 | $respObject = @simplexml_load_string($resp); |
321 | 317 | if (false !== $respObject) |