Passed
Push — v6 ( acff9b...736453 )
by 光春
02:38
created
src/service/ksyun/bin/exceptions/Exceptions.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 		if(isset($this->$property_name))
16 16
 		{
17 17
 			return($this->$property_name);
18
-		}else
18
+		} else
19 19
 		{
20 20
 			return(NULL);
21 21
 		}
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Logger.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 			if(empty($log_path)){
22 22
 				$log_path = KS3_API_PATH.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR;
23 23
 			}
24
-		}else{
24
+		} else{
25 25
 			$log_path = KS3_API_PATH.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR;
26 26
 		}
27 27
 		
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Builders.php 1 patch
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 									foreach ($value as  $ele) {
28 28
 										$ruleXml->addChild($key,$ele);
29 29
 									}
30
-								}else{
30
+								} else{
31 31
 									$ruleXml->addChild($key,$value);
32 32
 								}
33 33
 								
@@ -47,12 +47,14 @@  discard block
 block discarded – undo
47 47
 			$xml = new SimpleXmlElement('<BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/" />');
48 48
 			if(is_array($logging)){
49 49
 
50
-				if(!isset($logging["Enable"]))
51
-					throw new Ks3ClientException("bucket logging must provide Enable argument");
50
+				if(!isset($logging["Enable"])) {
51
+									throw new Ks3ClientException("bucket logging must provide Enable argument");
52
+				}
52 53
 				
53 54
 				if($logging["Enable"]){
54
-					if(!isset($logging["TargetBucket"]))
55
-						throw new Ks3ClientException("bucket logging must provide TargetBucket argument");
55
+					if(!isset($logging["TargetBucket"])) {
56
+											throw new Ks3ClientException("bucket logging must provide TargetBucket argument");
57
+					}
56 58
 					$loggingConfig = $xml->addChild("LoggingEnabled");
57 59
 					foreach ($logging as $key => $value) {
58 60
 						if(in_array($key,Consts::$BucketLoggingElements)){
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Signers.php 1 patch
Braces   +95 added lines, -67 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 			$acl = $args["ACL"];
115 115
 			if(!in_array($acl, Consts::$Acl)){
116 116
 				throw new Ks3ClientException("unsupport acl :".$acl);
117
-			}else{
117
+			} else{
118 118
 				$request->addHeader(Headers::$Acl,$acl);
119 119
 			}
120 120
 		}
@@ -135,8 +135,9 @@  discard block
 block discarded – undo
135 135
 			if(!empty($body)){
136 136
 				$length = $request->getHeader(Headers::$ContentLength);
137 137
 				if(empty($length)){
138
-					if(isset($args["ObjectMeta"][Headers::$ContentLength]))
139
-						$length = $args["ObjectMeta"][Headers::$ContentLength];
138
+					if(isset($args["ObjectMeta"][Headers::$ContentLength])) {
139
+											$length = $args["ObjectMeta"][Headers::$ContentLength];
140
+					}
140 141
 				}
141 142
 				if(!empty($length)){
142 143
 					$body = substr($body,0,$length);
@@ -144,8 +145,9 @@  discard block
 block discarded – undo
144 145
 				$contentmd5 = Utils::hex_to_base64(md5($body));
145 146
 			}
146 147
 		}
147
-		if(!empty($contentmd5))
148
-			$request->addHeader(Headers::$ContentMd5,$contentmd5);
148
+		if(!empty($contentmd5)) {
149
+					$request->addHeader(Headers::$ContentMd5,$contentmd5);
150
+		}
149 151
 	}
150 152
 }
151 153
 class ContentLengthSigner implements Signer{
@@ -161,8 +163,9 @@  discard block
 block discarded – undo
161 163
 				$contentlength = strlen($body);
162 164
 			}
163 165
 		}
164
-		if(!empty($contentlength))
165
-			$request->addHeader(Headers::$ContentLength,$contentlength);
166
+		if(!empty($contentlength)) {
167
+					$request->addHeader(Headers::$ContentLength,$contentlength);
168
+		}
166 169
 	}
167 170
 }
168 171
 class ObjectMetaSigner implements Signer{
@@ -216,10 +219,12 @@  discard block
 block discarded – undo
216 219
 		if(isset($args["CopySource"])){
217 220
 			$CopySource = $args["CopySource"];
218 221
 			if(is_array($CopySource)){
219
-				if(!isset($CopySource["Bucket"]))
220
-					throw new Ks3ClientException("you should provide copy source bucket");
221
-				if(!isset($CopySource["Key"]))
222
-					throw new Ks3ClientException("you should provide copy source key");
222
+				if(!isset($CopySource["Bucket"])) {
223
+									throw new Ks3ClientException("you should provide copy source bucket");
224
+				}
225
+				if(!isset($CopySource["Key"])) {
226
+									throw new Ks3ClientException("you should provide copy source key");
227
+				}
223 228
 				$bucket = $CopySource["Bucket"];
224 229
 				$key = Utils::encodeUrl($CopySource["Key"]);
225 230
 				$request->addHeader(Headers::$CopySource,"/".$bucket."/".$key);
@@ -243,11 +248,12 @@  discard block
 block discarded – undo
243 248
 				if(Utils::chk_chinese($content)&&!Utils::check_char($content)){
244 249
 					$content = iconv('utf-8','gbk',$content);
245 250
 				}
246
-				if(!file_exists($content))
247
-					throw new Ks3ClientException("the specified file does not exist ");
251
+				if(!file_exists($content)) {
252
+									throw new Ks3ClientException("the specified file does not exist ");
253
+				}
248 254
 				$length = Utils::getFileSize($content);
249 255
 				$content = fopen($content,"r");
250
-			}else{
256
+			} else{
251 257
 				$stats = fstat($content);
252 258
 				if ($stats && $stats["size"] >= 0){
253 259
 					$length = $stats["size"];	
@@ -258,10 +264,11 @@  discard block
 block discarded – undo
258 264
 			//优先取用户设置seek_position,没有的话取ftell
259 265
 			if(isset($args["Content"]["seek_position"])&&$args["Content"]["seek_position"]>0){
260 266
 				$seek_position = $args["Content"]["seek_position"];
261
-			}else if(!$isFile){
267
+			} else if(!$isFile){
262 268
 				$seek_position = ftell($content);
263
-				if($seek_position<0)
264
-					$seek_position = 0;
269
+				if($seek_position<0) {
270
+									$seek_position = 0;
271
+				}
265 272
 				fseek($content,0);
266 273
 			}
267 274
 
@@ -271,16 +278,17 @@  discard block
 block discarded – undo
271 278
 			}
272 279
 			if($lengthInMeta > 0){
273 280
 				$length = $lengthInMeta;
274
-			}else if($resourceLength > 0){
281
+			} else if($resourceLength > 0){
275 282
 				//根据seek_position计算实际长度
276 283
 				$length = $resourceLength - $seek_position;
277 284
 			}
278
-			if($length <= 0)
279
-				throw new Ks3ClientException("calculate content length failed,unexpected contetn length ".$length);
285
+			if($length <= 0) {
286
+							throw new Ks3ClientException("calculate content length failed,unexpected contetn length ".$length);
287
+			}
280 288
 			$request->read_stream = $content;
281 289
 			$request->addHeader(Headers::$ContentLength,$length);
282 290
 			$request->seek_position = $seek_position;
283
-		}else{
291
+		} else{
284 292
 			throw new Ks3ClientException("please specifie upload content in args");
285 293
 		}
286 294
 	}
@@ -295,8 +303,9 @@  discard block
 block discarded – undo
295 303
 				$end = $Range["end"];
296 304
 				$range = "bytes=".$start."-".$end;
297 305
 				$request->addHeader(Headers::$Range,$range);
298
-			}else
299
-				$request->addHeader(Headers::$Range,$Range);
306
+			} else {
307
+							$request->addHeader(Headers::$Range,$Range);
308
+			}
300 309
 		}
301 310
 	}
302 311
 }
@@ -307,7 +316,7 @@  discard block
 block discarded – undo
307 316
 			$WriteTo = $args["WriteTo"];
308 317
 			if(is_resource($WriteTo)){
309 318
 				$request->write_stream = $WriteTo;
310
-			}else{
319
+			} else{
311 320
 				//如果之前用户已经转化为GBK则不转换
312 321
 				if(Utils::chk_chinese($WriteTo)&&!Utils::check_char($WriteTo)){
313 322
 					$WriteTo = iconv('utf-8','gbk',$WriteTo);
@@ -325,12 +334,12 @@  discard block
 block discarded – undo
325 334
 			if(is_array($AdpConf)){
326 335
 				if(isset($AdpConf["NotifyURL"])){
327 336
 					$NotifyURL = $AdpConf["NotifyURL"];
328
-				}else{
337
+				} else{
329 338
 					throw new Ks3ClientException("adp should provide NotifyURL");
330 339
 				}
331 340
 				if(isset($AdpConf["Adps"])){
332 341
 					$Adps = $AdpConf["Adps"];
333
-				}else{
342
+				} else{
334 343
 					throw new Ks3ClientException("adp should provide Adps");
335 344
 				}
336 345
 				$AdpString = "";
@@ -352,9 +361,9 @@  discard block
 block discarded – undo
352 361
 						if(!(empty($bucket)&&empty($key))){
353 362
 							if(empty($bucket)){
354 363
 								$AdpString.="|tag=saveas&object=".base64_encode($key);
355
-							}elseif (empty($key)) {
364
+							} elseif (empty($key)) {
356 365
 								$AdpString.="|tag=saveas&bucket=".$bucket;
357
-							}else{
366
+							} else{
358 367
 								$AdpString.="|tag=saveas&bucket=".$bucket."&"."object=".base64_encode($key);
359 368
 							}
360 369
 						}
@@ -379,14 +388,16 @@  discard block
 block discarded – undo
379 388
 			if(isset($CallBackConf["Url"])){
380 389
 				$url = $CallBackConf["Url"];
381 390
 			}
382
-			if(empty($url))
383
-				throw new Ks3ClientException("Url is needed in CallBack");
391
+			if(empty($url)) {
392
+							throw new Ks3ClientException("Url is needed in CallBack");
393
+			}
384 394
 			if(isset($CallBackConf["BodyMagicVariables"])){
385 395
 				if(is_array($CallBackConf["BodyMagicVariables"])){
386 396
 					$magics = $CallBackConf["BodyMagicVariables"];
387 397
 					foreach ($magics as $key => $value) {
388
-						if(in_array($value,Consts::$CallBackMagics))
389
-							$body.=$key."=\${".$value."}&";
398
+						if(in_array($value,Consts::$CallBackMagics)) {
399
+													$body.=$key."=\${".$value."}&";
400
+						}
390 401
 					}
391 402
 				}
392 403
 			}
@@ -411,14 +422,17 @@  discard block
 block discarded – undo
411 422
 	public function sign(Ks3Request $request,$args=array()){
412 423
 		$args = $args["args"];
413 424
 		if(isset($args["SSE"])){
414
-			if(isset($args["SSE"]["Algm"]))
415
-				$algm = $args["SSE"]["Algm"];
416
-			if(isset($args["SSE"]["KMSId"]))
417
-				$id = $args["SSE"]["KMSId"];
425
+			if(isset($args["SSE"]["Algm"])) {
426
+							$algm = $args["SSE"]["Algm"];
427
+			}
428
+			if(isset($args["SSE"]["KMSId"])) {
429
+							$id = $args["SSE"]["KMSId"];
430
+			}
418 431
 			if(!empty($algm)){		
419 432
 				$request->addHeader(Headers::$SSEAlgm,$algm);
420
-				if(!empty($id))
421
-					$request->addHeader(Headers::$SSEKMSId,$id);
433
+				if(!empty($id)) {
434
+									$request->addHeader(Headers::$SSEKMSId,$id);
435
+				}
422 436
 			}
423 437
 		}
424 438
 	}
@@ -427,21 +441,28 @@  discard block
 block discarded – undo
427 441
 	public function sign(Ks3Request $request,$args=array()){
428 442
 		$args = $args["args"];
429 443
 		if(isset($args["SSEC"])){
430
-			if(isset($args["SSEC"]["Algm"]))
431
-				$algm = $args["SSEC"]["Algm"];
432
-			if(isset($args["SSEC"]["Key"]))
433
-				$key = $args["SSEC"]["Key"];
434
-			if(isset($args["SSEC"]["KeyBase64"]))
435
-				$keybase64 = $args["SSEC"]["KeyBase64"];
436
-			if(isset($args["SSEC"]["KeyMD5"]))
437
-				$md5 = $args["SSEC"]["KeyMD5"];
444
+			if(isset($args["SSEC"]["Algm"])) {
445
+							$algm = $args["SSEC"]["Algm"];
446
+			}
447
+			if(isset($args["SSEC"]["Key"])) {
448
+							$key = $args["SSEC"]["Key"];
449
+			}
450
+			if(isset($args["SSEC"]["KeyBase64"])) {
451
+							$keybase64 = $args["SSEC"]["KeyBase64"];
452
+			}
453
+			if(isset($args["SSEC"]["KeyMD5"])) {
454
+							$md5 = $args["SSEC"]["KeyMD5"];
455
+			}
438 456
 			if(!empty($key)||!empty($keybase64)){
439
-				if(empty($key))
440
-					$key = base64_decode($keybase64);
441
-				if(empty($algm))
442
-					$algm = Consts::$SSEDefaultAlgm;
443
-				if(empty($md5))
444
-					$md5 = Utils::hex_to_base64(md5($key));
457
+				if(empty($key)) {
458
+									$key = base64_decode($keybase64);
459
+				}
460
+				if(empty($algm)) {
461
+									$algm = Consts::$SSEDefaultAlgm;
462
+				}
463
+				if(empty($md5)) {
464
+									$md5 = Utils::hex_to_base64(md5($key));
465
+				}
445 466
 
446 467
 				$request->addHeader(Headers::$SSECAlgm,$algm);
447 468
 				$request->addHeader(Headers::$SSECKey,base64_encode($key));
@@ -454,21 +475,28 @@  discard block
 block discarded – undo
454 475
 	public function sign(Ks3Request $request,$args=array()){
455 476
 		$args = $args["args"];
456 477
 		if(isset($args["SSECSource"])){
457
-			if(isset($args["SSECSource"]["Algm"]))
458
-				$algm = $args["SSECSource"]["Algm"];
459
-			if(isset($args["SSECSource"]["Key"]))
460
-				$key = $args["SSECSource"]["Key"];
461
-			if(isset($args["SSECSource"]["KeyBase64"]))
462
-				$keybase64 = $args["SSECSource"]["KeyBase64"];
463
-			if(isset($args["SSECSource"]["KeyMD5"]))
464
-				$md5 = $args["SSECSource"]["KeyMD5"];
478
+			if(isset($args["SSECSource"]["Algm"])) {
479
+							$algm = $args["SSECSource"]["Algm"];
480
+			}
481
+			if(isset($args["SSECSource"]["Key"])) {
482
+							$key = $args["SSECSource"]["Key"];
483
+			}
484
+			if(isset($args["SSECSource"]["KeyBase64"])) {
485
+							$keybase64 = $args["SSECSource"]["KeyBase64"];
486
+			}
487
+			if(isset($args["SSECSource"]["KeyMD5"])) {
488
+							$md5 = $args["SSECSource"]["KeyMD5"];
489
+			}
465 490
 			if(!empty($key)||!empty($keybase64)){
466
-				if(empty($key))
467
-					$key = base64_decode($keybase64);
468
-				if(empty($algm))
469
-					$algm = Consts::$SSEDefaultAlgm;
470
-				if(empty($md5))
471
-					$md5 = Utils::hex_to_base64(md5($key));
491
+				if(empty($key)) {
492
+									$key = base64_decode($keybase64);
493
+				}
494
+				if(empty($algm)) {
495
+									$algm = Consts::$SSEDefaultAlgm;
496
+				}
497
+				if(empty($md5)) {
498
+									$md5 = Utils::hex_to_base64(md5($key));
499
+				}
472 500
 
473 501
 				$request->addHeader(Headers::$SSECSourceAlgm,$algm);
474 502
 				$request->addHeader(Headers::$SSECSourceKey,base64_encode($key));
@@ -523,7 +551,7 @@  discard block
 block discarded – undo
523 551
 			if(in_array($key,Consts::$SubResource)||in_array($key,Consts::$QueryParam)){
524 552
 				if(empty($value)){
525 553
 					$encodeParams.="&".$key;
526
-				}else{
554
+				} else{
527 555
 					$encodeParams.="&".$key."=".$value;
528 556
 				}
529 557
 			}
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Ks3Request.class.php 1 patch
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 		if(isset($this->$property_name))
23 23
 		{
24 24
 			return($this->$property_name);
25
-		}else
25
+		} else
26 26
 		{
27 27
 			return(NULL);
28 28
 		}
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	public function getHeader($key){
31 31
 		if(isset($this->headers[$key])){
32 32
 			return  $this->headers[$key];
33
-		}else{
33
+		} else{
34 34
 			return(NULL);
35 35
 		}
36 36
 	}
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	public function getQueryParams($key){
42 42
 		if(isset($this->queryParams[$key])){
43 43
 			return  $this->queryParams[$key];
44
-		}else{
44
+		} else{
45 45
 			return(NULL);
46 46
 		}
47 47
 	}
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 		if(!empty($bucket)){
57 57
 			if(KS3_API_VHOST){
58 58
 				$url.=$bucket.".".$endpoint;
59
-			}else{
59
+			} else{
60 60
 				$url.=$endpoint."/".$bucket;
61 61
 			}
62
-		}else{
62
+		} else{
63 63
 			$url.=$endpoint;
64 64
 		}
65 65
 		if(!empty($key)){
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Utils.class.php 1 patch
Braces   +28 added lines, -15 removed lines patch added patch discarded remove patch
@@ -158,13 +158,20 @@  discard block
 block discarded – undo
158 158
 	        $v = ord( $str[$i] );  
159 159
 	        if( $v > 127) {  
160 160
 	            if( ($v >= 228) && ($v <= 233) ){  
161
-	                if( ($i+2) >= (strlen($str) - 1)) return true;  // not enough characters  
161
+	                if( ($i+2) >= (strlen($str) - 1)) {
162
+	                    return true;
163
+	                }
164
+	                // not enough characters  
162 165
 	                $v1 = ord( $str[$i+1] );  
163 166
 	                $v2 = ord( $str[$i+2] );  
164
-	                if( ($v1 >= 128) && ($v1 <=191) && ($v2 >=128) && ($v2 <= 191) )  
165
-	                    return false;   //UTF-8编码  
166
-	                else  
167
-	                    return true;    //GB编码  
167
+	                if( ($v1 >= 128) && ($v1 <=191) && ($v2 >=128) && ($v2 <= 191) ) {
168
+	                	                    return false;
169
+	                }
170
+	                //UTF-8编码  
171
+	                else {
172
+	                	                    return true;
173
+	                }
174
+	                //GB编码  
168 175
 	            }  
169 176
 	        }  
170 177
 	    }  
@@ -182,11 +189,14 @@  discard block
 block discarded – undo
182 189
 	        $v = ord( $str[$i] );
183 190
 	        if( $v > 127){
184 191
 	            if( ($v >= 228) && ($v <= 233) ){
185
-	                 if(($i+2)>= (strlen($str)-1)) return $gbk?true:FALSE;  // not enough characters
192
+	                 if(($i+2)>= (strlen($str)-1)) {
193
+	                     return $gbk?true:FALSE;
194
+	                 }
195
+	                 // not enough characters
186 196
 	                 $v1 = ord( $str[$i+1] ); $v2 = ord( $str[$i+2] );
187 197
 	                 if($gbk){
188 198
 	                      return (($v1 >= 128) && ($v1 <=191) && ($v2 >=128) && ($v2 <= 191))?FALSE:TRUE;//GBK
189
-	                 }else{
199
+	                 } else{
190 200
 	                      return (($v1 >= 128) && ($v1 <=191) && ($v2 >=128) && ($v2 <= 191))?TRUE:FALSE;
191 201
 	                 }
192 202
 	            }
@@ -195,7 +205,9 @@  discard block
 block discarded – undo
195 205
 	   return $gbk?TRUE:FALSE;
196 206
 	}
197 207
 	public static function iso8601($time=false) {
198
-    	if ($time === false) $time = time();
208
+    	if ($time === false) {
209
+    	    $time = time();
210
+    	}
199 211
    		$date = date('Y-m-d\TH:i:s\.Z', $time);
200 212
    		return (substr($date, 0, strlen($date)-2).'Z');
201 213
 	}
@@ -205,7 +217,7 @@  discard block
 block discarded – undo
205 217
 		if(!is_resource($path)){
206 218
 			$isresource = FALSE;
207 219
 			$resource = fopen($path,"r");
208
-		}else{
220
+		} else{
209 221
 			$isresource = TRUE;
210 222
 			$resource = $path;
211 223
 		}
@@ -213,16 +225,17 @@  discard block
 block discarded – undo
213 225
 		$size = $stat["size"];
214 226
 		if($size<0){
215 227
 			$success = FALSE;
216
-		}else{
228
+		} else{
217 229
 			$success = TRUE;
218 230
 		}
219
-		if($success)
220
-			return $size;
221
-		else if($isresource)
222
-			throw new Ks3ClientException("please use file path instead resource");
231
+		if($success) {
232
+					return $size;
233
+		} else if($isresource) {
234
+					throw new Ks3ClientException("please use file path instead resource");
235
+		}
223 236
 		if(!((strtoupper(substr(PHP_OS,0,3))=="WIN"))){//如果不是windows系统,尝试使用stat命令
224 237
 			$size=trim(`stat -c%s $path`);
225
-		}else{//如果是windows系统,尝试cmd命令
238
+		} else{//如果是windows系统,尝试cmd命令
226 239
 			if(!class_exists("COM")){
227 240
 				throw new Ks3ClientException("please add 'extension=php_com_dotnet.dll' and set 'com.allow_dcom = true' in php.ini and restart");
228 241
 			}
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Handlers.php 1 patch
Braces   +17 added lines, -16 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 				$exception->resource=$xml->Resource->__toString();
19 19
 			}
20 20
 			throw $exception;
21
-		}else{
21
+		} else{
22 22
 			return $response;
23 23
 		}
24 24
 	}
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 						$owner[$ownerkey]=$ownervalue->__toString();
60 60
 					}
61 61
 					$content["Owner"] = $owner;
62
-				}else{
62
+				} else{
63 63
 					$content[$key]=$value->__toString();
64 64
 				}
65 65
 			}
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 				if($key === "MaxAgeSeconds")
88 88
 				{
89 89
 					$acors[$key] = $value->__toString();
90
-				}else{
90
+				} else{
91 91
 					if(!isset($acors[$key])){
92 92
 						$acors[$key] = array();
93 93
 					}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 				$logging["Enable"] = TRUE;
119 119
 				$logging[$key] = $value->__toString();
120 120
 			}
121
-		}else{
121
+		} else{
122 122
 			$logging["Enable"] = FALSE;
123 123
 		}
124 124
 		return $logging;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		foreach ($response->header as $key => $value) {
132 132
 			if (substr(strtolower($key), 0, 10) === Consts::$UserMetaPrefix){
133 133
 				$UserMeta[$key]=$value;
134
-			}else if(isset(Consts::$ResponseObjectMeta[strtolower($key)])){
134
+			} else if(isset(Consts::$ResponseObjectMeta[strtolower($key)])){
135 135
 				$ObjectMeta[Consts::$ResponseObjectMeta[strtolower($key)]]=$value;
136 136
 			}
137 137
 		}
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		foreach ($response->header as $key => $value) {
150 150
 			if (substr(strtolower($key), 0, 10) === Consts::$UserMetaPrefix){
151 151
 				$UserMeta[$key]=$value;
152
-			}else if(isset(Consts::$ResponseObjectMeta[strtolower($key)])){
152
+			} else if(isset(Consts::$ResponseObjectMeta[strtolower($key)])){
153 153
 				$ObjectMeta[Consts::$ResponseObjectMeta[strtolower($key)]]=$value;
154 154
 			}
155 155
 		}
@@ -261,18 +261,19 @@  discard block
 block discarded – undo
261 261
 			if($hasURI){
262 262
 				if($permission===Consts::$Permission_Read){
263 263
 					$hasread = TRUE;
264
-				}elseif($permission===Consts::$Permission_Write){
264
+				} elseif($permission===Consts::$Permission_Write){
265 265
 					$haswrite = TRUE;
266 266
 				}
267 267
 			}
268 268
 		}
269 269
 		if($hasread&&$haswrite){
270 270
 			return "public-read-write";
271
-		}else{
272
-			if($hasread)
273
-				return "public-read";
274
-			else
275
-				return "private";
271
+		} else{
272
+			if($hasread) {
273
+							return "public-read";
274
+			} else {
275
+							return "private";
276
+			}
276 277
 		}
277 278
 	}
278 279
 }
@@ -300,13 +301,13 @@  discard block
 block discarded – undo
300 301
 						$initer[$key1] = $value1->__toString();
301 302
 					}
302 303
 					$upload["Initiator"] = $initer;
303
-				}elseif($key === "Owner"){
304
+				} elseif($key === "Owner"){
304 305
 					$owner = array();
305 306
 					foreach ($value->children() as $key1 => $value1) {
306 307
 						$owner[$key1] = $value1->__toString();
307 308
 					}
308 309
 					$upload["Owner"] = $owner;
309
-				}else{
310
+				} else{
310 311
 					$upload[$key] = $value->__toString();
311 312
 				}
312 313
 			}
@@ -325,7 +326,7 @@  discard block
 block discarded – undo
325 326
 	public function handle(ResponseCore $response){
326 327
 		if($response->isOk()){
327 328
 			return TRUE;
328
-		}else{
329
+		} else{
329 330
 			return FALSE;
330 331
 		}
331 332
 	}
@@ -335,7 +336,7 @@  discard block
 block discarded – undo
335 336
 		$status = $response->status;
336 337
 		if($status === 404){
337 338
 			return FALSE;
338
-		}else{
339
+		} else{
339 340
 			return TRUE;
340 341
 		}
341 342
 	}
Please login to merge, or discard this patch.
src/service/ksyun/bin/lib/RequestCore.class.php 1 patch
Braces   +16 added lines, -12 removed lines patch added patch discarded remove patch
@@ -621,8 +621,7 @@  discard block
 block discarded – undo
621 621
 		{
622 622
 			curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, true);
623 623
 			curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, 2);
624
-		}
625
-		else
624
+		} else
626 625
 		{
627 626
 			curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
628 627
 			curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, false);
@@ -632,8 +631,7 @@  discard block
 block discarded – undo
632 631
 		if ($this->cacert_location === true)
633 632
 		{
634 633
 			curl_setopt($curl_handle, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
635
-		}
636
-		elseif (is_string($this->cacert_location))
634
+		} elseif (is_string($this->cacert_location))
637 635
 		{
638 636
 			curl_setopt($curl_handle, CURLOPT_CAINFO, $this->cacert_location);
639 637
 		}
@@ -705,8 +703,7 @@  discard block
 block discarded – undo
705 703
 
706 704
 					curl_setopt($curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size);
707 705
 					curl_setopt($curl_handle, CURLOPT_UPLOAD, true);
708
-				}
709
-				else
706
+				} else
710 707
 				{
711 708
 					curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body);
712 709
 				}
@@ -728,8 +725,7 @@  discard block
 block discarded – undo
728 725
 				{
729 726
 					curl_setopt($curl_handle, CURLOPT_WRITEFUNCTION, array($this, 'streaming_write_callback'));
730 727
 					curl_setopt($curl_handle, CURLOPT_HEADER, false);
731
-				}
732
-				else
728
+				} else
733 729
 				{
734 730
 					curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body);
735 731
 				}
@@ -849,9 +845,13 @@  discard block
 block discarded – undo
849 845
 		set_time_limit(0);
850 846
 
851 847
 		// Skip everything if there are no handles to process.
852
-		if (count($handles) === 0) return array();
848
+		if (count($handles) === 0) {
849
+		    return array();
850
+		}
853 851
 
854
-		if (!$opt) $opt = array();
852
+		if (!$opt) {
853
+		    $opt = array();
854
+		}
855 855
 
856 856
 		// Initialize any missing options
857 857
 		$limit = isset($opt['limit']) ? $opt['limit'] : -1;
@@ -869,7 +869,9 @@  discard block
 block discarded – undo
869 869
 		// Loop through the cURL handles and add as many as it set by the limit parameter.
870 870
 		while ($i < $added)
871 871
 		{
872
-			if ($limit > 0 && $i >= $limit) break;
872
+			if ($limit > 0 && $i >= $limit) {
873
+			    break;
874
+			}
873 875
 			curl_multi_add_handle($multi_handle, array_shift($handles));
874 876
 			$i++;
875 877
 		}
@@ -882,7 +884,9 @@  discard block
 block discarded – undo
882 884
 			while (($status = curl_multi_exec($multi_handle, $active)) === CURLM_CALL_MULTI_PERFORM)
883 885
 			{
884 886
 				// Start looking for possible responses immediately when we have to add more handles
885
-				if (count($handles) > 0) break;
887
+				if (count($handles) > 0) {
888
+				    break;
889
+				}
886 890
 			}
887 891
 
888 892
 			// Figure out which requests finished.
Please login to merge, or discard this patch.
src/service/ksyun/bin/Ks3EncryptionClient.class.php 1 patch
Braces   +20 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,21 +1,24 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 //使用客户端加密的方式上传下载文件
3 3
 //检测API路径
4
-if(!defined('KS3_API_PATH'))
5
-define('KS3_API_PATH', dirname(__FILE__));
4
+if(!defined('KS3_API_PATH')) {
5
+    define('KS3_API_PATH', dirname(__FILE__));
6
+}
6 7
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."Ks3Client.class.php";
7 8
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."encryption".DIRECTORY_SEPARATOR."EncryptionUtil.php";
8 9
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."encryption".DIRECTORY_SEPARATOR."EncryptionHandlers.php";
9 10
 
10 11
 //加密模式
11 12
 //暂时仅支持EO,使用AES/CBC/PKCS5Padding算法对数据进行加密
12
-if(!defined("ENCRYPTPTION_MODE"))
13
-define("ENCRYPTPTION_MODE","EO");
13
+if(!defined("ENCRYPTPTION_MODE")) {
14
+    define("ENCRYPTPTION_MODE","EO");
15
+}
14 16
 //加密信息存储模式,暂时支持 ObjectMetadata和InstructionFile
15 17
 //ObjectMetadata:存在用户元数据中
16 18
 //InstructionFile:存在一个.instruction文件中
17
-if(!defined("ENCRYPTPTION_STORAGE_MODE"))
18
-define("ENCRYPTPTION_STORAGE_MODE","ObjectMetadata");
19
+if(!defined("ENCRYPTPTION_STORAGE_MODE")) {
20
+    define("ENCRYPTPTION_STORAGE_MODE","ObjectMetadata");
21
+}
19 22
 
20 23
 
21 24
 if(function_exists('get_loaded_extensions')){
@@ -28,10 +31,10 @@  discard block
 block discarded – undo
28 31
 		if(!in_array('openssl', $extensions)){
29 32
 			throw new Ks3ClientException("please install openssl extension");
30 33
 		}
31
-	}else{
34
+	} else{
32 35
 		throw new Ks3ClientException("please install extensions");
33 36
 	}
34
-}else{
37
+} else{
35 38
 	throw new Ks3ClientException();
36 39
 } 
37 40
 class Ks3EncryptionClient extends Ks3Client{
@@ -45,12 +48,14 @@  discard block
 block discarded – undo
45 48
 			if(count($encryptionMaterials)==2){
46 49
 				$pk = openssl_pkey_get_public($encryptionMaterials[0]);
47 50
 				$sk = openssl_pkey_get_private($encryptionMaterials[1]);
48
-				if(!$pk)
49
-					throw new Ks3ClientException("invalid RSA public key,you can generate key use openssl");
50
-				if(!$sk)
51
-					throw new Ks3ClientException("invalid RSA private key,you can generate key use openssl");
51
+				if(!$pk) {
52
+									throw new Ks3ClientException("invalid RSA public key,you can generate key use openssl");
53
+				}
54
+				if(!$sk) {
55
+									throw new Ks3ClientException("invalid RSA private key,you can generate key use openssl");
56
+				}
52 57
 				$encryptionMaterials = array($pk,$sk);
53
-			}else{
58
+			} else{
54 59
 				throw new Ks3ClientException("encryptionMaterials should be string or an array of size 2");
55 60
 			}
56 61
 		}
@@ -58,10 +63,9 @@  discard block
 block discarded – undo
58 63
 		$this->encryptionMaterials = $encryptionMaterials;
59 64
 		if(ENCRYPTPTION_MODE == "EO"){
60 65
 			$this->encryptionHandler = new EncryptionEO($ks3client,$encryptionMaterials);
61
-		}elseif (ENCRYPTPTION_MODE == "AE") {
66
+		} elseif (ENCRYPTPTION_MODE == "AE") {
62 67
 			throw new Ks3ClientException("Authenticated encryption will be supported in the futher");
63
-		}
64
-		else{
68
+		} else{
65 69
 			throw new Ks3ClientException("unsupported encryption mode :".ENCRYPTPTION_MODE);
66 70
 		}
67 71
 		if(ENCRYPTPTION_STORAGE_MODE != "ObjectMetadata"&&ENCRYPTPTION_STORAGE_MODE!="InstructionFile"){
Please login to merge, or discard this patch.