Passed
Push — v6 ( 9d6bdb...3d5ed9 )
by 光春
03:06
created
src/service/taobao/TbkService.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -563,9 +563,9 @@  discard block
 block discarded – undo
563 563
                 $this->output = json_encode($this->output, JSON_UNESCAPED_UNICODE);
564 564
             }
565 565
             return json_decode($this->output, true);
566
-        } else {
566
+        }else {
567 567
             // 正常
568
-            $response = substr(Strings::replace('.', '_', $this->method), 7) . "_response";
568
+            $response = substr(Strings::replace('.', '_', $this->method), 7)."_response";
569 569
             if (is_array($this->output)) {
570 570
                 if (isset($this->output["$response"])) {
571 571
                     return $this->output["$response"];
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
             $this->output = json_decode($this->output, true);
579 579
             if (isset($this->output["$response"])) {
580 580
                 return $this->output["$response"];
581
-            } else {
581
+            }else {
582 582
                 return $this->output;
583 583
             }
584 584
         }
@@ -610,12 +610,12 @@  discard block
 block discarded – undo
610 610
         $sign = $this->createSign();
611 611
         //组织参数
612 612
         $strParam = $this->createStrParam();
613
-        $strParam .= 'sign=' . $sign;
613
+        $strParam .= 'sign='.$sign;
614 614
         //访问服务
615 615
         if (empty($this->sandbox)) {
616
-            $url = 'http://gw.api.taobao.com/router/rest?' . $strParam;
617
-        } else {
618
-            $url = 'http://gw.api.tbsandbox.com/router/rest?' . $strParam;
616
+            $url = 'http://gw.api.taobao.com/router/rest?'.$strParam;
617
+        }else {
618
+            $url = 'http://gw.api.tbsandbox.com/router/rest?'.$strParam;
619 619
         }
620 620
         $result = file_get_contents($url);
621 621
         $result = json_decode($result, true);
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
         ksort($this->param);
640 640
         foreach ($this->param as $key => $val) {
641 641
             if ($key != '' && $val != '') {
642
-                $sign .= $key . $val;
642
+                $sign .= $key.$val;
643 643
             }
644 644
         }
645 645
         $sign .= $this->app_secret;
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
         $strParam = '';
657 657
         foreach ($this->param as $key => $val) {
658 658
             if ($key != '' && $val != '') {
659
-                $strParam .= $key . '=' . urlencode($val) . '&';
659
+                $strParam .= $key.'='.urlencode($val).'&';
660 660
             }
661 661
         }
662 662
         return $strParam;
Please login to merge, or discard this patch.
src/service/SystemService.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
         if (empty($suffix) && !empty($fillSuffix)) {
53 53
             if (empty($url_common_param)) {
54 54
                 $location = $this->app->route->buildUrl($url, $vars)->suffix($suffix)->domain($domain)->build();
55
-            } else {
55
+            }else {
56 56
                 $location = $this->app->route->buildUrl($url, [])->suffix($suffix)->domain($domain)->build();
57 57
             }
58 58
             if (empty($vars)) {
59
-                $location = substr($location . "{$pathinfo_depr}" . $this->arr_to_str($vars, $pathinfo_depr), 0, -1) . ".{$url_html_suffix}";
60
-            } else {
61
-                $location = $location . "{$pathinfo_depr}" . $this->arr_to_str($vars, $pathinfo_depr) . ".{$url_html_suffix}";
59
+                $location = substr($location."{$pathinfo_depr}".$this->arr_to_str($vars, $pathinfo_depr), 0, -1).".{$url_html_suffix}";
60
+            }else {
61
+                $location = $location."{$pathinfo_depr}".$this->arr_to_str($vars, $pathinfo_depr).".{$url_html_suffix}";
62 62
             }
63
-        } else {
63
+        }else {
64 64
             $location = $this->app->route->buildUrl($url, $vars)->suffix($suffix)->domain($domain)->build();
65 65
         }
66 66
         return $location;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $t = '';
78 78
         foreach ($arr as $k => $v) {
79
-            $t .= $k . $glue . $v . $glue;
79
+            $t .= $k.$glue.$v.$glue;
80 80
         }
81 81
         $t = substr($t, 0, -1); // 利用字符串截取函数消除最后一个
82 82
         return $t;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
         }
113 113
         $tem = array();
114 114
         foreach ($this->result as $val) {
115
-            if (preg_match("/[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f]/i", $val, $tem)) {
116
-                $this->macAddr = $tem[0];//多个网卡时,会返回第一个网卡的mac地址,一般够用。
115
+            if (preg_match("/[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f]/i", $val, $tem)) {
116
+                $this->macAddr = $tem[0]; //多个网卡时,会返回第一个网卡的mac地址,一般够用。
117 117
                 break;
118 118
                 //$this->macAddrs[] = $temp_array[0];//返回所有的mac地址
119 119
             }
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
         @exec("ipconfig /all", $this->result);
142 142
         if ($this->result) {
143 143
             return $this->result;
144
-        } else {
145
-            $ipconfig = $_SERVER["WINDIR"] . "\system32\ipconfig.exe";
144
+        }else {
145
+            $ipconfig = $_SERVER["WINDIR"]."\system32\ipconfig.exe";
146 146
             if (is_file($ipconfig)) {
147
-                @exec($ipconfig . " /all", $this->result);
147
+                @exec($ipconfig." /all", $this->result);
148 148
                 return $this->result;
149
-            } else {
150
-                @exec($_SERVER["WINDIR"] . "\system\ipconfig.exe /all", $this->result);
149
+            }else {
150
+                @exec($_SERVER["WINDIR"]."\system\ipconfig.exe /all", $this->result);
151 151
                 return $this->result;
152 152
             }
153 153
         }
Please login to merge, or discard this patch.
src/service/aliyun/OssService.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
         try {
85 85
             $ossClient = new OssClient($this->accessKeyId, $this->accessKeySecret, $this->endpoint);
86 86
             $ossClient->uploadFile($this->bucket, $object, $filePath);
87
-            return config('dtapp.aliyun.oss.url', '') . $object;
87
+            return config('dtapp.aliyun.oss.url', '').$object;
88 88
         } catch (OssException $e) {
89 89
             return $e->getMessage();
90 90
         }
Please login to merge, or discard this patch.
src/service/ksyun/bin/exceptions/Exceptions.php 3 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -3,32 +3,32 @@
 block discarded – undo
3 3
 	
4 4
 }
5 5
 class Ks3ServiceException extends Ks3ClientException{
6
-	private $requestId;
7
-	private $errorCode;
8
-	private $errorMessage;
9
-	private $resource;
10
-	private $statusCode;
11
-	public function __set($property_name, $value){
12
-		$this->$property_name=$value;
13
-	}
14
-	public function __get($property_name){
15
-		if(isset($this->$property_name))
16
-		{
17
-			return($this->$property_name);
18
-		}else
19
-		{
20
-			return(NULL);
21
-		}
22
-	}
23
-	public function __toString()
24
-  	{
25
-      		$message = get_class($this) . ': '
26
-      			."(errorCode:".$this->errorCode.";"
27
-      			."errorMessage:".$this->errorMessage.";"
28
-      			."resource:".$this->resource.";"
29
-      			."requestId:".$this->requestId.";"
30
-      			."statusCode:".$this->statusCode.")";
31
-		return $message;
32
-      	}
6
+    private $requestId;
7
+    private $errorCode;
8
+    private $errorMessage;
9
+    private $resource;
10
+    private $statusCode;
11
+    public function __set($property_name, $value){
12
+        $this->$property_name=$value;
13
+    }
14
+    public function __get($property_name){
15
+        if(isset($this->$property_name))
16
+        {
17
+            return($this->$property_name);
18
+        }else
19
+        {
20
+            return(NULL);
21
+        }
22
+    }
23
+    public function __toString()
24
+        {
25
+                $message = get_class($this) . ': '
26
+                    ."(errorCode:".$this->errorCode.";"
27
+                    ."errorMessage:".$this->errorMessage.";"
28
+                    ."resource:".$this->resource.";"
29
+                    ."requestId:".$this->requestId.";"
30
+                    ."statusCode:".$this->statusCode.")";
31
+        return $message;
32
+            }
33 33
 }
34 34
 ?>
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class Ks3ClientException extends RuntimeException{
2
+class Ks3ClientException extends RuntimeException {
3 3
 	
4 4
 }
5
-class Ks3ServiceException extends Ks3ClientException{
5
+class Ks3ServiceException extends Ks3ClientException {
6 6
 	private $requestId;
7 7
 	private $errorCode;
8 8
 	private $errorMessage;
9 9
 	private $resource;
10 10
 	private $statusCode;
11
-	public function __set($property_name, $value){
12
-		$this->$property_name=$value;
11
+	public function __set($property_name, $value) {
12
+		$this->$property_name = $value;
13 13
 	}
14
-	public function __get($property_name){
15
-		if(isset($this->$property_name))
14
+	public function __get($property_name) {
15
+		if (isset($this->$property_name))
16 16
 		{
17 17
 			return($this->$property_name);
18 18
 		}else
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	}
23 23
 	public function __toString()
24 24
   	{
25
-      		$message = get_class($this) . ': '
25
+      		$message = get_class($this).': '
26 26
       			."(errorCode:".$this->errorCode.";"
27 27
       			."errorMessage:".$this->errorMessage.";"
28 28
       			."resource:".$this->resource.";"
Please login to merge, or discard this 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/Headers.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,29 +1,29 @@
 block discarded – undo
1 1
 <?php
2 2
 class Headers{
3
-	static $Date = "Date";
4
-	static $Authorization = "Authorization";
5
-	static $ContentMd5 = "Content-MD5";
6
-	static $ContentType = "Content-Type";
7
-	static $ContentLength="Content-Length";
8
-	static $Acl = "x-kss-acl";
9
-	static $CopySource = "x-kss-copy-source";
10
-	static $ETag = "ETag";
11
-	static $TaskID = "TaskID";
12
-	static $Range = "Range";
13
-	static $AsynchronousProcessingList = "kss-async-process";
14
-	static $NotifyURL = "kss-notifyurl";
15
-	static $XKssCallbackUrl = "x-kss-callbackurl";
16
-	static $XKssCallbackBody = "x-kss-callbackbody";
17
-	static $UserAgent = "User-Agent";
18
-	static $SSEAlgm = "x-kss-server-side-encryption";
19
-	static $SSEKMSId = "x-kss-server-side-encryption-kss-kms-key-id";
20
-	static $SSECAlgm = "x-kss-server-side-encryption-customer-algorithm";
21
-	static $SSECKey = "x-kss-server-side-encryption-customer-key";
22
-	static $SSECMD5 = "x-kss-server-side-encryption-customer-key-MD5";
3
+    static $Date = "Date";
4
+    static $Authorization = "Authorization";
5
+    static $ContentMd5 = "Content-MD5";
6
+    static $ContentType = "Content-Type";
7
+    static $ContentLength="Content-Length";
8
+    static $Acl = "x-kss-acl";
9
+    static $CopySource = "x-kss-copy-source";
10
+    static $ETag = "ETag";
11
+    static $TaskID = "TaskID";
12
+    static $Range = "Range";
13
+    static $AsynchronousProcessingList = "kss-async-process";
14
+    static $NotifyURL = "kss-notifyurl";
15
+    static $XKssCallbackUrl = "x-kss-callbackurl";
16
+    static $XKssCallbackBody = "x-kss-callbackbody";
17
+    static $UserAgent = "User-Agent";
18
+    static $SSEAlgm = "x-kss-server-side-encryption";
19
+    static $SSEKMSId = "x-kss-server-side-encryption-kss-kms-key-id";
20
+    static $SSECAlgm = "x-kss-server-side-encryption-customer-algorithm";
21
+    static $SSECKey = "x-kss-server-side-encryption-customer-key";
22
+    static $SSECMD5 = "x-kss-server-side-encryption-customer-key-MD5";
23 23
 
24
-	static $SSECSourceAlgm = "x-kss-copy-source-server-side-encryption-customer-algorithm";
25
-	static $SSECSourceKey = "x-kss-copy-source-server-side-encryption-customer-key";
26
-	static $SSECSourceMD5 = "x-kss-copy-source-server-side-encryption-customer-key-MD5";
24
+    static $SSECSourceAlgm = "x-kss-copy-source-server-side-encryption-customer-algorithm";
25
+    static $SSECSourceKey = "x-kss-copy-source-server-side-encryption-customer-key";
26
+    static $SSECSourceMD5 = "x-kss-copy-source-server-side-encryption-customer-key-MD5";
27 27
 
28 28
 }
29 29
 ?>
30 30
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2
-class Headers{
2
+class Headers {
3 3
 	static $Date = "Date";
4 4
 	static $Authorization = "Authorization";
5 5
 	static $ContentMd5 = "Content-MD5";
6 6
 	static $ContentType = "Content-Type";
7
-	static $ContentLength="Content-Length";
7
+	static $ContentLength = "Content-Length";
8 8
 	static $Acl = "x-kss-acl";
9 9
 	static $CopySource = "x-kss-copy-source";
10 10
 	static $ETag = "ETag";
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Logger.php 3 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,46 +1,46 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."exceptions".DIRECTORY_SEPARATOR."Exceptions.php";
3 3
 class Logger{
4
-	function info($msg){
5
-		$this->log("INFO",$msg);
6
-	}
7
-	function error($msg){
8
-		$this->log("ERROR",$msg);
9
-	}
10
-	function warn($msg){
11
-		$this->log("WARN",$msg);
12
-	}
13
-	function debug($msg){
14
-		$this->log("DEBUG",$msg);
15
-	}
16
-	private function log($level,$msg){
17
-		$date = gmdate('D, d M Y H:i:s \G\M\T');
18
-		$log = $date." ".$level."\r\n".$msg."\r\n";
19
-		if(defined('KS3_API_LOG_PATH') ){
20
-			$log_path = KS3_API_LOG_PATH;
21
-			if(empty($log_path)){
22
-				$log_path = KS3_API_PATH.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR;
23
-			}
24
-		}else{
25
-			$log_path = KS3_API_PATH.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR;
26
-		}
4
+    function info($msg){
5
+        $this->log("INFO",$msg);
6
+    }
7
+    function error($msg){
8
+        $this->log("ERROR",$msg);
9
+    }
10
+    function warn($msg){
11
+        $this->log("WARN",$msg);
12
+    }
13
+    function debug($msg){
14
+        $this->log("DEBUG",$msg);
15
+    }
16
+    private function log($level,$msg){
17
+        $date = gmdate('D, d M Y H:i:s \G\M\T');
18
+        $log = $date." ".$level."\r\n".$msg."\r\n";
19
+        if(defined('KS3_API_LOG_PATH') ){
20
+            $log_path = KS3_API_LOG_PATH;
21
+            if(empty($log_path)){
22
+                $log_path = KS3_API_PATH.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR;
23
+            }
24
+        }else{
25
+            $log_path = KS3_API_PATH.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR;
26
+        }
27 27
 		
28
-		//检测日志目录是否存在
29
-		if(!file_exists($log_path)){
30
-			mkdir($log_path);
31
-		}
28
+        //检测日志目录是否存在
29
+        if(!file_exists($log_path)){
30
+            mkdir($log_path);
31
+        }
32 32
 
33
-		$log_name = $log_path.'ks3_php_sdk_'.date('Y-m-d').'.log';
33
+        $log_name = $log_path.'ks3_php_sdk_'.date('Y-m-d').'.log';
34 34
 
35
-		if(KS3_API_DISPLAY_LOG){
36
-			echo $log;
37
-		}
35
+        if(KS3_API_DISPLAY_LOG){
36
+            echo $log;
37
+        }
38 38
 		
39
-		if(KS3_API_LOG){
40
-			if(!error_log($log,3,$log_name)){
41
-				throw new Ks3ClientException("write to log file error");
42
-			}
43
-		}
44
-	}
39
+        if(KS3_API_LOG){
40
+            if(!error_log($log,3,$log_name)){
41
+                throw new Ks3ClientException("write to log file error");
42
+            }
43
+        }
44
+    }
45 45
 }
46 46
 ?>
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,43 +1,43 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."exceptions".DIRECTORY_SEPARATOR."Exceptions.php";
3
-class Logger{
4
-	function info($msg){
5
-		$this->log("INFO",$msg);
3
+class Logger {
4
+	function info($msg) {
5
+		$this->log("INFO", $msg);
6 6
 	}
7
-	function error($msg){
8
-		$this->log("ERROR",$msg);
7
+	function error($msg) {
8
+		$this->log("ERROR", $msg);
9 9
 	}
10
-	function warn($msg){
11
-		$this->log("WARN",$msg);
10
+	function warn($msg) {
11
+		$this->log("WARN", $msg);
12 12
 	}
13
-	function debug($msg){
14
-		$this->log("DEBUG",$msg);
13
+	function debug($msg) {
14
+		$this->log("DEBUG", $msg);
15 15
 	}
16
-	private function log($level,$msg){
16
+	private function log($level, $msg) {
17 17
 		$date = gmdate('D, d M Y H:i:s \G\M\T');
18 18
 		$log = $date." ".$level."\r\n".$msg."\r\n";
19
-		if(defined('KS3_API_LOG_PATH') ){
19
+		if (defined('KS3_API_LOG_PATH')) {
20 20
 			$log_path = KS3_API_LOG_PATH;
21
-			if(empty($log_path)){
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
 		
28 28
 		//检测日志目录是否存在
29
-		if(!file_exists($log_path)){
29
+		if (!file_exists($log_path)) {
30 30
 			mkdir($log_path);
31 31
 		}
32 32
 
33 33
 		$log_name = $log_path.'ks3_php_sdk_'.date('Y-m-d').'.log';
34 34
 
35
-		if(KS3_API_DISPLAY_LOG){
35
+		if (KS3_API_DISPLAY_LOG) {
36 36
 			echo $log;
37 37
 		}
38 38
 		
39
-		if(KS3_API_LOG){
40
-			if(!error_log($log,3,$log_name)){
39
+		if (KS3_API_LOG) {
40
+			if (!error_log($log, 3, $log_name)) {
41 41
 				throw new Ks3ClientException("write to log file error");
42 42
 			}
43 43
 		}
Please login to merge, or discard this 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 3 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -3,100 +3,100 @@
 block discarded – undo
3 3
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."config".DIRECTORY_SEPARATOR."Consts.php";
4 4
 
5 5
 class LocationBuilder{
6
-	function build($args){
7
-		if(isset($args["Location"])){
8
-			$location = $args["Location"];
9
-			$xml = new SimpleXmlElement('<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></CreateBucketConfiguration>');
10
-			$xml->addChild("LocationConstraint",$args["Location"]);
11
-			return $xml->asXml();
12
-		}
13
-	}
6
+    function build($args){
7
+        if(isset($args["Location"])){
8
+            $location = $args["Location"];
9
+            $xml = new SimpleXmlElement('<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></CreateBucketConfiguration>');
10
+            $xml->addChild("LocationConstraint",$args["Location"]);
11
+            return $xml->asXml();
12
+        }
13
+    }
14 14
 }
15 15
 class CORSBuilder{
16
-	function build($args){
17
-		if(isset($args["CORS"])){
18
-			$cors = $args["CORS"];
19
-			$xml = new SimpleXmlElement('<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></CORSConfiguration>');
20
-			if(is_array($cors)){
21
-				foreach ($cors as $key => $rule) {
22
-					$ruleXml = $xml->addChild("CORSRule");
23
-					if(is_array($rule)){
24
-						foreach ($rule as $key => $value) {
25
-							if(in_array($key,Consts::$CORSElements)){
26
-								if(is_array($value)){
27
-									foreach ($value as  $ele) {
28
-										$ruleXml->addChild($key,$ele);
29
-									}
30
-								}else{
31
-									$ruleXml->addChild($key,$value);
32
-								}
16
+    function build($args){
17
+        if(isset($args["CORS"])){
18
+            $cors = $args["CORS"];
19
+            $xml = new SimpleXmlElement('<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></CORSConfiguration>');
20
+            if(is_array($cors)){
21
+                foreach ($cors as $key => $rule) {
22
+                    $ruleXml = $xml->addChild("CORSRule");
23
+                    if(is_array($rule)){
24
+                        foreach ($rule as $key => $value) {
25
+                            if(in_array($key,Consts::$CORSElements)){
26
+                                if(is_array($value)){
27
+                                    foreach ($value as  $ele) {
28
+                                        $ruleXml->addChild($key,$ele);
29
+                                    }
30
+                                }else{
31
+                                    $ruleXml->addChild($key,$value);
32
+                                }
33 33
 								
34
-							}
35
-						}
36
-					}
37
-				}
38
-			}
39
-			return $xml->asXml();
40
-		}
41
-	}
34
+                            }
35
+                        }
36
+                    }
37
+                }
38
+            }
39
+            return $xml->asXml();
40
+        }
41
+    }
42 42
 }
43 43
 class BucketLoggingBuilder{
44
-	function build($args){
45
-		if(isset($args["BucketLogging"])){
46
-			$logging = $args["BucketLogging"];
47
-			$xml = new SimpleXmlElement('<BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/" />');
48
-			if(is_array($logging)){
44
+    function build($args){
45
+        if(isset($args["BucketLogging"])){
46
+            $logging = $args["BucketLogging"];
47
+            $xml = new SimpleXmlElement('<BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/" />');
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
-				if($logging["Enable"]){
54
-					if(!isset($logging["TargetBucket"]))
55
-						throw new Ks3ClientException("bucket logging must provide TargetBucket argument");
56
-					$loggingConfig = $xml->addChild("LoggingEnabled");
57
-					foreach ($logging as $key => $value) {
58
-						if(in_array($key,Consts::$BucketLoggingElements)){
59
-							$loggingConfig->addChild($key,$value);
60
-						}
61
-					}
62
-				}
63
-			}
64
-			return $xml->asXml();
65
-		}
66
-	}
53
+                if($logging["Enable"]){
54
+                    if(!isset($logging["TargetBucket"]))
55
+                        throw new Ks3ClientException("bucket logging must provide TargetBucket argument");
56
+                    $loggingConfig = $xml->addChild("LoggingEnabled");
57
+                    foreach ($logging as $key => $value) {
58
+                        if(in_array($key,Consts::$BucketLoggingElements)){
59
+                            $loggingConfig->addChild($key,$value);
60
+                        }
61
+                    }
62
+                }
63
+            }
64
+            return $xml->asXml();
65
+        }
66
+    }
67 67
 }
68 68
 class DeleteObjectsBuilder{
69
-	function build($args){
70
-		if(isset($args["DeleteKeys"])){
71
-			$keys = $args["DeleteKeys"];
72
-			$xml = new SimpleXmlElement('<Delete></Delete>');
73
-			if(is_array($keys)){
74
-				foreach ($keys as $key => $value) {
75
-					$object = $xml->addChild("Object");
76
-					$object->addChild("Key",$value);
77
-				}
78
-			}
79
-			return $xml->asXml();
80
-		}
81
-	}
69
+    function build($args){
70
+        if(isset($args["DeleteKeys"])){
71
+            $keys = $args["DeleteKeys"];
72
+            $xml = new SimpleXmlElement('<Delete></Delete>');
73
+            if(is_array($keys)){
74
+                foreach ($keys as $key => $value) {
75
+                    $object = $xml->addChild("Object");
76
+                    $object->addChild("Key",$value);
77
+                }
78
+            }
79
+            return $xml->asXml();
80
+        }
81
+    }
82 82
 }
83 83
 class CompleteMultipartUploadBuilder{
84
-	function build($args){
85
-		if(isset($args["Parts"])){
86
-			$parts = $args["Parts"];
87
-			$xml = new SimpleXmlElement('<CompleteMultipartUpload></CompleteMultipartUpload>');
88
-			if(is_array($parts)){
89
-				foreach ($parts as $part) {
90
-					$partXml = $xml->addChild("Part");
91
-					foreach ($part as $key => $value) {
92
-						if(in_array($key,Consts::$PartsElement)){
93
-							$partXml->addChild($key,$value);
94
-						}
95
-					}
96
-				}
97
-			}
98
-			return $xml->asXml();
99
-		}
100
-	}
84
+    function build($args){
85
+        if(isset($args["Parts"])){
86
+            $parts = $args["Parts"];
87
+            $xml = new SimpleXmlElement('<CompleteMultipartUpload></CompleteMultipartUpload>');
88
+            if(is_array($parts)){
89
+                foreach ($parts as $part) {
90
+                    $partXml = $xml->addChild("Part");
91
+                    foreach ($part as $key => $value) {
92
+                        if(in_array($key,Consts::$PartsElement)){
93
+                            $partXml->addChild($key,$value);
94
+                        }
95
+                    }
96
+                }
97
+            }
98
+            return $xml->asXml();
99
+        }
100
+    }
101 101
 }
102 102
 ?>
103 103
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -2,33 +2,33 @@  discard block
 block discarded – undo
2 2
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."exceptions".DIRECTORY_SEPARATOR."Exceptions.php";
3 3
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."config".DIRECTORY_SEPARATOR."Consts.php";
4 4
 
5
-class LocationBuilder{
6
-	function build($args){
7
-		if(isset($args["Location"])){
5
+class LocationBuilder {
6
+	function build($args) {
7
+		if (isset($args["Location"])) {
8 8
 			$location = $args["Location"];
9 9
 			$xml = new SimpleXmlElement('<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></CreateBucketConfiguration>');
10
-			$xml->addChild("LocationConstraint",$args["Location"]);
10
+			$xml->addChild("LocationConstraint", $args["Location"]);
11 11
 			return $xml->asXml();
12 12
 		}
13 13
 	}
14 14
 }
15
-class CORSBuilder{
16
-	function build($args){
17
-		if(isset($args["CORS"])){
15
+class CORSBuilder {
16
+	function build($args) {
17
+		if (isset($args["CORS"])) {
18 18
 			$cors = $args["CORS"];
19 19
 			$xml = new SimpleXmlElement('<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></CORSConfiguration>');
20
-			if(is_array($cors)){
20
+			if (is_array($cors)) {
21 21
 				foreach ($cors as $key => $rule) {
22 22
 					$ruleXml = $xml->addChild("CORSRule");
23
-					if(is_array($rule)){
23
+					if (is_array($rule)) {
24 24
 						foreach ($rule as $key => $value) {
25
-							if(in_array($key,Consts::$CORSElements)){
26
-								if(is_array($value)){
25
+							if (in_array($key, Consts::$CORSElements)) {
26
+								if (is_array($value)) {
27 27
 									foreach ($value as  $ele) {
28
-										$ruleXml->addChild($key,$ele);
28
+										$ruleXml->addChild($key, $ele);
29 29
 									}
30
-								}else{
31
-									$ruleXml->addChild($key,$value);
30
+								}else {
31
+									$ruleXml->addChild($key, $value);
32 32
 								}
33 33
 								
34 34
 							}
@@ -40,23 +40,23 @@  discard block
 block discarded – undo
40 40
 		}
41 41
 	}
42 42
 }
43
-class BucketLoggingBuilder{
44
-	function build($args){
45
-		if(isset($args["BucketLogging"])){
43
+class BucketLoggingBuilder {
44
+	function build($args) {
45
+		if (isset($args["BucketLogging"])) {
46 46
 			$logging = $args["BucketLogging"];
47 47
 			$xml = new SimpleXmlElement('<BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/" />');
48
-			if(is_array($logging)){
48
+			if (is_array($logging)) {
49 49
 
50
-				if(!isset($logging["Enable"]))
50
+				if (!isset($logging["Enable"]))
51 51
 					throw new Ks3ClientException("bucket logging must provide Enable argument");
52 52
 				
53
-				if($logging["Enable"]){
54
-					if(!isset($logging["TargetBucket"]))
53
+				if ($logging["Enable"]) {
54
+					if (!isset($logging["TargetBucket"]))
55 55
 						throw new Ks3ClientException("bucket logging must provide TargetBucket argument");
56 56
 					$loggingConfig = $xml->addChild("LoggingEnabled");
57 57
 					foreach ($logging as $key => $value) {
58
-						if(in_array($key,Consts::$BucketLoggingElements)){
59
-							$loggingConfig->addChild($key,$value);
58
+						if (in_array($key, Consts::$BucketLoggingElements)) {
59
+							$loggingConfig->addChild($key, $value);
60 60
 						}
61 61
 					}
62 62
 				}
@@ -65,32 +65,32 @@  discard block
 block discarded – undo
65 65
 		}
66 66
 	}
67 67
 }
68
-class DeleteObjectsBuilder{
69
-	function build($args){
70
-		if(isset($args["DeleteKeys"])){
68
+class DeleteObjectsBuilder {
69
+	function build($args) {
70
+		if (isset($args["DeleteKeys"])) {
71 71
 			$keys = $args["DeleteKeys"];
72 72
 			$xml = new SimpleXmlElement('<Delete></Delete>');
73
-			if(is_array($keys)){
73
+			if (is_array($keys)) {
74 74
 				foreach ($keys as $key => $value) {
75 75
 					$object = $xml->addChild("Object");
76
-					$object->addChild("Key",$value);
76
+					$object->addChild("Key", $value);
77 77
 				}
78 78
 			}
79 79
 			return $xml->asXml();
80 80
 		}
81 81
 	}
82 82
 }
83
-class CompleteMultipartUploadBuilder{
84
-	function build($args){
85
-		if(isset($args["Parts"])){
83
+class CompleteMultipartUploadBuilder {
84
+	function build($args) {
85
+		if (isset($args["Parts"])) {
86 86
 			$parts = $args["Parts"];
87 87
 			$xml = new SimpleXmlElement('<CompleteMultipartUpload></CompleteMultipartUpload>');
88
-			if(is_array($parts)){
88
+			if (is_array($parts)) {
89 89
 				foreach ($parts as $part) {
90 90
 					$partXml = $xml->addChild("Part");
91 91
 					foreach ($part as $key => $value) {
92
-						if(in_array($key,Consts::$PartsElement)){
93
-							$partXml->addChild($key,$value);
92
+						if (in_array($key, Consts::$PartsElement)) {
93
+							$partXml->addChild($key, $value);
94 94
 						}
95 95
 					}
96 96
 				}
Please login to merge, or discard this 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 3 patches
Indentation   +473 added lines, -473 removed lines patch added patch discarded remove patch
@@ -6,536 +6,536 @@
 block discarded – undo
6 6
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."exceptions".DIRECTORY_SEPARATOR."Exceptions.php";
7 7
 
8 8
 interface Signer{
9
-	public function sign( Ks3Request $request,$args=array());
9
+    public function sign( Ks3Request $request,$args=array());
10 10
 }
11 11
 class DefaultUserAgentSigner implements Signer{
12
-	public function sign(Ks3Request $request,$args=array()){
13
-		$request->addHeader(Headers::$UserAgent,Consts::$UserAgent);
14
-	}
12
+    public function sign(Ks3Request $request,$args=array()){
13
+        $request->addHeader(Headers::$UserAgent,Consts::$UserAgent);
14
+    }
15 15
 }
16 16
 class DefaultContentTypeSigner implements Signer{
17
-	public function sign(Ks3Request $request,$args=array()){
18
-		$contentType = $request->getHeader(Headers::$ContentType);
19
-		if(empty($contentType)){
20
-			$request->addHeader(Headers::$ContentType,"application/xml");
21
-		}
22
-	}
17
+    public function sign(Ks3Request $request,$args=array()){
18
+        $contentType = $request->getHeader(Headers::$ContentType);
19
+        if(empty($contentType)){
20
+            $request->addHeader(Headers::$ContentType,"application/xml");
21
+        }
22
+    }
23 23
 }
24 24
 class StreamContentTypeSigner implements Signer{
25
-	public function sign(Ks3Request $request,$args=array()){
26
-		$contentType = $request->getHeader(Headers::$ContentType);
27
-		if(empty($contentType)){
28
-			$request->addHeader(Headers::$ContentType,"application/ocet-stream");
29
-		}
30
-	}
25
+    public function sign(Ks3Request $request,$args=array()){
26
+        $contentType = $request->getHeader(Headers::$ContentType);
27
+        if(empty($contentType)){
28
+            $request->addHeader(Headers::$ContentType,"application/ocet-stream");
29
+        }
30
+    }
31 31
 }
32 32
 class SuffixContentTypeSigner implements Signer{
33
-	public function sign(Ks3Request $request,$args=array()){
34
-		$key = $request->key;
35
-		$objArr = explode('/', $key);
36
-		$basename = array_pop($objArr);
37
-		$extension = explode ( '.', $basename );
38
-		$extension = array_pop ( $extension );
39
-		$content_type = Utils::get_mimetype(strtolower($extension));
40
-		$request->addHeader(Headers::$ContentType,$content_type);
41
-	}
33
+    public function sign(Ks3Request $request,$args=array()){
34
+        $key = $request->key;
35
+        $objArr = explode('/', $key);
36
+        $basename = array_pop($objArr);
37
+        $extension = explode ( '.', $basename );
38
+        $extension = array_pop ( $extension );
39
+        $content_type = Utils::get_mimetype(strtolower($extension));
40
+        $request->addHeader(Headers::$ContentType,$content_type);
41
+    }
42 42
 }
43 43
 class HeaderAuthSigner implements Signer{
44
-	public function sign(Ks3Request $request,$args=array()){
45
-		$log = "stringToSing->\r\n";
46
-		$date = gmdate('D, d M Y H:i:s \G\M\T');
47
-		$request->addHeader(Headers::$Date, $date);
44
+    public function sign(Ks3Request $request,$args=array()){
45
+        $log = "stringToSing->\r\n";
46
+        $date = gmdate('D, d M Y H:i:s \G\M\T');
47
+        $request->addHeader(Headers::$Date, $date);
48 48
 
49
-		$ak = $args["accessKey"];
50
-		$sk = $args["secretKey"];
51
-		if(empty($ak)){
52
-			throw new Ks3ClientException("you should provide accessKey");
53
-		}
54
-		if(empty($sk)){
55
-			throw new Ks3ClientException("you should provide secretKey");
56
-		}
57
-		$authration = "KSS ";
58
-		$signList = array(
59
-			$request->method,
60
-			$request->getHeader(Headers::$ContentMd5),
61
-			$request->getHeader(Headers::$ContentType),
62
-			$date
63
-			);
64
-		$headers = AuthUtils::canonicalizedKssHeaders($request);
65
-		$resource = AuthUtils::canonicalizedResource($request);
66
-		if(!empty($headers)){
67
-			array_push($signList,$headers);
68
-		}
69
-		array_push($signList,$resource);
70
-		$stringToSign = join("\n",$signList);
71
-		$log.= $stringToSign;
72
-		$signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));
49
+        $ak = $args["accessKey"];
50
+        $sk = $args["secretKey"];
51
+        if(empty($ak)){
52
+            throw new Ks3ClientException("you should provide accessKey");
53
+        }
54
+        if(empty($sk)){
55
+            throw new Ks3ClientException("you should provide secretKey");
56
+        }
57
+        $authration = "KSS ";
58
+        $signList = array(
59
+            $request->method,
60
+            $request->getHeader(Headers::$ContentMd5),
61
+            $request->getHeader(Headers::$ContentType),
62
+            $date
63
+            );
64
+        $headers = AuthUtils::canonicalizedKssHeaders($request);
65
+        $resource = AuthUtils::canonicalizedResource($request);
66
+        if(!empty($headers)){
67
+            array_push($signList,$headers);
68
+        }
69
+        array_push($signList,$resource);
70
+        $stringToSign = join("\n",$signList);
71
+        $log.= $stringToSign;
72
+        $signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));
73 73
 
74
-		$authration.=$ak.":".$signature;
75
-		$request->addHeader(Headers::$Authorization, $authration);
76
-		return $log;
77
-	}
74
+        $authration.=$ak.":".$signature;
75
+        $request->addHeader(Headers::$Authorization, $authration);
76
+        return $log;
77
+    }
78 78
 }
79 79
 class QueryAuthSigner implements Signer{
80
-	public function sign(Ks3Request $request,$args=array()){
81
-		$log = "stringToSing->\r\n";
82
-		$ak = $args["accessKey"];
83
-		$sk = $args["secretKey"];
84
-		$expires = $args["args"]["Options"]["Expires"];
85
-		$expiresSencond = time()+$expires;
80
+    public function sign(Ks3Request $request,$args=array()){
81
+        $log = "stringToSing->\r\n";
82
+        $ak = $args["accessKey"];
83
+        $sk = $args["secretKey"];
84
+        $expires = $args["args"]["Options"]["Expires"];
85
+        $expiresSencond = time()+$expires;
86 86
 
87
-		$resource = AuthUtils::canonicalizedResource($request);
88
-		$signList = array(
89
-			$request->method,
90
-			$request->getHeader(Headers::$ContentMd5),
91
-			$request->getHeader(Headers::$ContentType),
92
-			$expiresSencond
93
-			);
94
-		$headers = AuthUtils::canonicalizedKssHeaders($request);
95
-		$resource = AuthUtils::canonicalizedResource($request);
96
-		if(!empty($headers)){
97
-			array_push($signList,$headers);
98
-		}
99
-		array_push($signList,$resource);
87
+        $resource = AuthUtils::canonicalizedResource($request);
88
+        $signList = array(
89
+            $request->method,
90
+            $request->getHeader(Headers::$ContentMd5),
91
+            $request->getHeader(Headers::$ContentType),
92
+            $expiresSencond
93
+            );
94
+        $headers = AuthUtils::canonicalizedKssHeaders($request);
95
+        $resource = AuthUtils::canonicalizedResource($request);
96
+        if(!empty($headers)){
97
+            array_push($signList,$headers);
98
+        }
99
+        array_push($signList,$resource);
100 100
 
101
-		$stringToSign = join("\n",$signList);
102
-		$log.= $stringToSign;
103
-		$signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));
104
-		$request->addQueryParams("KSSAccessKeyId",$ak);
105
-		$request->addQueryParams("Signature",$signature);
106
-		$request->addQueryParams("Expires",$expiresSencond);
107
-		return $log;
108
-	}
101
+        $stringToSign = join("\n",$signList);
102
+        $log.= $stringToSign;
103
+        $signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));
104
+        $request->addQueryParams("KSSAccessKeyId",$ak);
105
+        $request->addQueryParams("Signature",$signature);
106
+        $request->addQueryParams("Expires",$expiresSencond);
107
+        return $log;
108
+    }
109 109
 }
110 110
 class ACLSigner implements Signer{
111
-	public function sign(Ks3Request $request,$args=array()){
112
-		$args = $args["args"];
113
-		if(isset($args["ACL"])){
114
-			$acl = $args["ACL"];
115
-			if(!in_array($acl, Consts::$Acl)){
116
-				throw new Ks3ClientException("unsupport acl :".$acl);
117
-			}else{
118
-				$request->addHeader(Headers::$Acl,$acl);
119
-			}
120
-		}
121
-		if(isset($args["ACP"])){
111
+    public function sign(Ks3Request $request,$args=array()){
112
+        $args = $args["args"];
113
+        if(isset($args["ACL"])){
114
+            $acl = $args["ACL"];
115
+            if(!in_array($acl, Consts::$Acl)){
116
+                throw new Ks3ClientException("unsupport acl :".$acl);
117
+            }else{
118
+                $request->addHeader(Headers::$Acl,$acl);
119
+            }
120
+        }
121
+        if(isset($args["ACP"])){
122 122
 
123
-		}
124
-	}
123
+        }
124
+    }
125 125
 }
126 126
 class ContentMD5Signer implements Signer{
127
-	public function sign(Ks3Request $request,$args=array()){
128
-		$args = $args["args"];
129
-		$contentmd5 = "";
130
-		if(isset($args["ObjectMeta"][Headers::$ContentMd5])){
131
-			$contentmd5 = $args["ObjectMeta"][Headers::$ContentMd5];
132
-		}
133
-		if(empty($contentmd5)){
134
-			$body = $request->body;
135
-			if(!empty($body)){
136
-				$length = $request->getHeader(Headers::$ContentLength);
137
-				if(empty($length)){
138
-					if(isset($args["ObjectMeta"][Headers::$ContentLength]))
139
-						$length = $args["ObjectMeta"][Headers::$ContentLength];
140
-				}
141
-				if(!empty($length)){
142
-					$body = substr($body,0,$length);
143
-				}
144
-				$contentmd5 = Utils::hex_to_base64(md5($body));
145
-			}
146
-		}
147
-		if(!empty($contentmd5))
148
-			$request->addHeader(Headers::$ContentMd5,$contentmd5);
149
-	}
127
+    public function sign(Ks3Request $request,$args=array()){
128
+        $args = $args["args"];
129
+        $contentmd5 = "";
130
+        if(isset($args["ObjectMeta"][Headers::$ContentMd5])){
131
+            $contentmd5 = $args["ObjectMeta"][Headers::$ContentMd5];
132
+        }
133
+        if(empty($contentmd5)){
134
+            $body = $request->body;
135
+            if(!empty($body)){
136
+                $length = $request->getHeader(Headers::$ContentLength);
137
+                if(empty($length)){
138
+                    if(isset($args["ObjectMeta"][Headers::$ContentLength]))
139
+                        $length = $args["ObjectMeta"][Headers::$ContentLength];
140
+                }
141
+                if(!empty($length)){
142
+                    $body = substr($body,0,$length);
143
+                }
144
+                $contentmd5 = Utils::hex_to_base64(md5($body));
145
+            }
146
+        }
147
+        if(!empty($contentmd5))
148
+            $request->addHeader(Headers::$ContentMd5,$contentmd5);
149
+    }
150 150
 }
151 151
 class ContentLengthSigner implements Signer{
152
-	public function sign(Ks3Request $request,$args=array()){
153
-		$args = $args["args"];
154
-		$contentlength = "";
155
-		if(isset($args["ObjectMeta"][Headers::$ContentLength])){
156
-			$contentlength = $args["ObjectMeta"][Headers::$ContentLength];
157
-		}
158
-		if(empty($contentlength)){
159
-			$body = $request->body;
160
-			if(!empty($body)){
161
-				$contentlength = strlen($body);
162
-			}
163
-		}
164
-		if(!empty($contentlength))
165
-			$request->addHeader(Headers::$ContentLength,$contentlength);
166
-	}
152
+    public function sign(Ks3Request $request,$args=array()){
153
+        $args = $args["args"];
154
+        $contentlength = "";
155
+        if(isset($args["ObjectMeta"][Headers::$ContentLength])){
156
+            $contentlength = $args["ObjectMeta"][Headers::$ContentLength];
157
+        }
158
+        if(empty($contentlength)){
159
+            $body = $request->body;
160
+            if(!empty($body)){
161
+                $contentlength = strlen($body);
162
+            }
163
+        }
164
+        if(!empty($contentlength))
165
+            $request->addHeader(Headers::$ContentLength,$contentlength);
166
+    }
167 167
 }
168 168
 class ObjectMetaSigner implements Signer{
169
-	public function sign(Ks3Request $request,$args=array()){
170
-		$args = $args["args"];
171
-		if(isset($args["ObjectMeta"])){
172
-			$ObjectMeta = $args["ObjectMeta"];
173
-			if(is_array($ObjectMeta)){
174
-				foreach ($ObjectMeta as $key => $value) {
175
-					if(in_array($key,Consts::$ObjectMeta)&&!empty($value)){
176
-						$request->addHeader($key,$value);
177
-					}
178
-				}
179
-			}
180
-		}
181
-	}
169
+    public function sign(Ks3Request $request,$args=array()){
170
+        $args = $args["args"];
171
+        if(isset($args["ObjectMeta"])){
172
+            $ObjectMeta = $args["ObjectMeta"];
173
+            if(is_array($ObjectMeta)){
174
+                foreach ($ObjectMeta as $key => $value) {
175
+                    if(in_array($key,Consts::$ObjectMeta)&&!empty($value)){
176
+                        $request->addHeader($key,$value);
177
+                    }
178
+                }
179
+            }
180
+        }
181
+    }
182 182
 }
183 183
 class MultipartObjectMetaSigner implements Signer{
184
-	public function sign(Ks3Request $request,$args=array()){
185
-		$args = $args["args"];
186
-		if(isset($args["ObjectMeta"])){
187
-			$ObjectMeta = $args["ObjectMeta"];
188
-			if(is_array($ObjectMeta)){
189
-				foreach ($ObjectMeta as $key => $value) {
190
-					if(in_array($key,Consts::$MultipartObjectMeta)&&!empty($value)){
191
-						$request->addHeader($key,$value);
192
-					}
193
-				}
194
-			}
195
-		}
196
-	}
184
+    public function sign(Ks3Request $request,$args=array()){
185
+        $args = $args["args"];
186
+        if(isset($args["ObjectMeta"])){
187
+            $ObjectMeta = $args["ObjectMeta"];
188
+            if(is_array($ObjectMeta)){
189
+                foreach ($ObjectMeta as $key => $value) {
190
+                    if(in_array($key,Consts::$MultipartObjectMeta)&&!empty($value)){
191
+                        $request->addHeader($key,$value);
192
+                    }
193
+                }
194
+            }
195
+        }
196
+    }
197 197
 }
198 198
 class UserMetaSigner implements Signer{
199
-	public function sign(Ks3Request $request,$args=array()){
200
-		$args = $args["args"];
201
-		if(isset($args["UserMeta"])){
202
-			$UserMeta = $args["UserMeta"];
203
-			if(is_array($UserMeta)){
204
-				foreach ($UserMeta as $key => $value) {
205
-					if (substr(strtolower($key), 0, 10) === Consts::$UserMetaPrefix){
206
-						$request->addHeader($key,$value);
207
-					}
208
-				}
209
-			}
210
-		}
211
-	}
199
+    public function sign(Ks3Request $request,$args=array()){
200
+        $args = $args["args"];
201
+        if(isset($args["UserMeta"])){
202
+            $UserMeta = $args["UserMeta"];
203
+            if(is_array($UserMeta)){
204
+                foreach ($UserMeta as $key => $value) {
205
+                    if (substr(strtolower($key), 0, 10) === Consts::$UserMetaPrefix){
206
+                        $request->addHeader($key,$value);
207
+                    }
208
+                }
209
+            }
210
+        }
211
+    }
212 212
 }
213 213
 class CopySourceSigner implements Signer{
214
-	public function sign(Ks3Request $request,$args=array()){
215
-		$args = $args["args"];
216
-		if(isset($args["CopySource"])){
217
-			$CopySource = $args["CopySource"];
218
-			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");
223
-				$bucket = $CopySource["Bucket"];
224
-				$key = Utils::encodeUrl($CopySource["Key"]);
225
-				$request->addHeader(Headers::$CopySource,"/".$bucket."/".$key);
226
-			}
227
-		}
228
-	}
214
+    public function sign(Ks3Request $request,$args=array()){
215
+        $args = $args["args"];
216
+        if(isset($args["CopySource"])){
217
+            $CopySource = $args["CopySource"];
218
+            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");
223
+                $bucket = $CopySource["Bucket"];
224
+                $key = Utils::encodeUrl($CopySource["Key"]);
225
+                $request->addHeader(Headers::$CopySource,"/".$bucket."/".$key);
226
+            }
227
+        }
228
+    }
229 229
 }
230 230
 class StreamUploadSigner implements Signer{
231
-	public function sign(Ks3Request $request,$args=array()){
232
-		$args = $args["args"];
233
-		if(isset($args["Content"])&&is_array($args["Content"])&&isset($args["Content"]["content"])){
234
-			$content = $args["Content"]["content"];
235
-			$seek_position = 0;
236
-			$resourceLength = 0;
237
-			$length = -1;
238
-			$isFile = FALSE;
231
+    public function sign(Ks3Request $request,$args=array()){
232
+        $args = $args["args"];
233
+        if(isset($args["Content"])&&is_array($args["Content"])&&isset($args["Content"]["content"])){
234
+            $content = $args["Content"]["content"];
235
+            $seek_position = 0;
236
+            $resourceLength = 0;
237
+            $length = -1;
238
+            $isFile = FALSE;
239 239
 
240
-			if (!is_resource($content)){
241
-				$isFile = TRUE;
242
-				//如果之前用户已经转化为GBK则不转换
243
-				if(Utils::chk_chinese($content)&&!Utils::check_char($content)){
244
-					$content = iconv('utf-8','gbk',$content);
245
-				}
246
-				if(!file_exists($content))
247
-					throw new Ks3ClientException("the specified file does not exist ");
248
-				$length = Utils::getFileSize($content);
249
-				$content = fopen($content,"r");
250
-			}else{
251
-				$stats = fstat($content);
252
-				if ($stats && $stats["size"] >= 0){
253
-					$length = $stats["size"];	
254
-				}
255
-			}
256
-			//之所以取resourceLength是为了防止Content-Length大于实际数据的大小,导致一直等待。
257
-			$resourceLength = $length;
258
-			//优先取用户设置seek_position,没有的话取ftell
259
-			if(isset($args["Content"]["seek_position"])&&$args["Content"]["seek_position"]>0){
260
-				$seek_position = $args["Content"]["seek_position"];
261
-			}else if(!$isFile){
262
-				$seek_position = ftell($content);
263
-				if($seek_position<0)
264
-					$seek_position = 0;
265
-				fseek($content,0);
266
-			}
240
+            if (!is_resource($content)){
241
+                $isFile = TRUE;
242
+                //如果之前用户已经转化为GBK则不转换
243
+                if(Utils::chk_chinese($content)&&!Utils::check_char($content)){
244
+                    $content = iconv('utf-8','gbk',$content);
245
+                }
246
+                if(!file_exists($content))
247
+                    throw new Ks3ClientException("the specified file does not exist ");
248
+                $length = Utils::getFileSize($content);
249
+                $content = fopen($content,"r");
250
+            }else{
251
+                $stats = fstat($content);
252
+                if ($stats && $stats["size"] >= 0){
253
+                    $length = $stats["size"];	
254
+                }
255
+            }
256
+            //之所以取resourceLength是为了防止Content-Length大于实际数据的大小,导致一直等待。
257
+            $resourceLength = $length;
258
+            //优先取用户设置seek_position,没有的话取ftell
259
+            if(isset($args["Content"]["seek_position"])&&$args["Content"]["seek_position"]>0){
260
+                $seek_position = $args["Content"]["seek_position"];
261
+            }else if(!$isFile){
262
+                $seek_position = ftell($content);
263
+                if($seek_position<0)
264
+                    $seek_position = 0;
265
+                fseek($content,0);
266
+            }
267 267
 
268
-			$lengthInMeta = -1;
269
-			if(isset($args["ObjectMeta"]["Content-Length"])){
270
-				$lengthInMeta = $args["ObjectMeta"]["Content-Length"];
271
-			}
272
-			if($lengthInMeta > 0){
273
-				$length = $lengthInMeta;
274
-			}else if($resourceLength > 0){
275
-				//根据seek_position计算实际长度
276
-				$length = $resourceLength - $seek_position;
277
-			}
278
-			if($length <= 0)
279
-				throw new Ks3ClientException("calculate content length failed,unexpected contetn length ".$length);
280
-			$request->read_stream = $content;
281
-			$request->addHeader(Headers::$ContentLength,$length);
282
-			$request->seek_position = $seek_position;
283
-		}else{
284
-			throw new Ks3ClientException("please specifie upload content in args");
285
-		}
286
-	}
268
+            $lengthInMeta = -1;
269
+            if(isset($args["ObjectMeta"]["Content-Length"])){
270
+                $lengthInMeta = $args["ObjectMeta"]["Content-Length"];
271
+            }
272
+            if($lengthInMeta > 0){
273
+                $length = $lengthInMeta;
274
+            }else if($resourceLength > 0){
275
+                //根据seek_position计算实际长度
276
+                $length = $resourceLength - $seek_position;
277
+            }
278
+            if($length <= 0)
279
+                throw new Ks3ClientException("calculate content length failed,unexpected contetn length ".$length);
280
+            $request->read_stream = $content;
281
+            $request->addHeader(Headers::$ContentLength,$length);
282
+            $request->seek_position = $seek_position;
283
+        }else{
284
+            throw new Ks3ClientException("please specifie upload content in args");
285
+        }
286
+    }
287 287
 }
288 288
 class RangeSigner{
289
-	public function sign(Ks3Request $request,$args=array()){
290
-		$args = $args["args"];
291
-		if(isset($args["Range"])){
292
-			$Range = $args["Range"];
293
-			if(is_array($Range)){
294
-				$start = $Range["start"];
295
-				$end = $Range["end"];
296
-				$range = "bytes=".$start."-".$end;
297
-				$request->addHeader(Headers::$Range,$range);
298
-			}else
299
-				$request->addHeader(Headers::$Range,$Range);
300
-		}
301
-	}
289
+    public function sign(Ks3Request $request,$args=array()){
290
+        $args = $args["args"];
291
+        if(isset($args["Range"])){
292
+            $Range = $args["Range"];
293
+            if(is_array($Range)){
294
+                $start = $Range["start"];
295
+                $end = $Range["end"];
296
+                $range = "bytes=".$start."-".$end;
297
+                $request->addHeader(Headers::$Range,$range);
298
+            }else
299
+                $request->addHeader(Headers::$Range,$Range);
300
+        }
301
+    }
302 302
 }
303 303
 class GetObjectSigner{
304
-	public function sign(Ks3Request $request,$args=array()){
305
-		$args = $args["args"];
306
-		if(isset($args["WriteTo"])){
307
-			$WriteTo = $args["WriteTo"];
308
-			if(is_resource($WriteTo)){
309
-				$request->write_stream = $WriteTo;
310
-			}else{
311
-				//如果之前用户已经转化为GBK则不转换
312
-				if(Utils::chk_chinese($WriteTo)&&!Utils::check_char($WriteTo)){
313
-					$WriteTo = iconv('utf-8','gbk',$WriteTo);
314
-				}
315
-				$request->write_stream = fopen($WriteTo,"w");
316
-			}
317
-		}
318
-	}
304
+    public function sign(Ks3Request $request,$args=array()){
305
+        $args = $args["args"];
306
+        if(isset($args["WriteTo"])){
307
+            $WriteTo = $args["WriteTo"];
308
+            if(is_resource($WriteTo)){
309
+                $request->write_stream = $WriteTo;
310
+            }else{
311
+                //如果之前用户已经转化为GBK则不转换
312
+                if(Utils::chk_chinese($WriteTo)&&!Utils::check_char($WriteTo)){
313
+                    $WriteTo = iconv('utf-8','gbk',$WriteTo);
314
+                }
315
+                $request->write_stream = fopen($WriteTo,"w");
316
+            }
317
+        }
318
+    }
319 319
 }
320 320
 class AdpSigner{
321
-	public function sign(Ks3Request $request,$args=array()){
322
-		$args = $args["args"];
323
-		if(isset($args["Adp"])){
324
-			$AdpConf = $args["Adp"];
325
-			if(is_array($AdpConf)){
326
-				if(isset($AdpConf["NotifyURL"])){
327
-					$NotifyURL = $AdpConf["NotifyURL"];
328
-				}else{
329
-					throw new Ks3ClientException("adp should provide NotifyURL");
330
-				}
331
-				if(isset($AdpConf["Adps"])){
332
-					$Adps = $AdpConf["Adps"];
333
-				}else{
334
-					throw new Ks3ClientException("adp should provide Adps");
335
-				}
336
-				$AdpString = "";
337
-				foreach ($Adps as $Adp) {
338
-					if(is_array($Adp)){
339
-						if(!isset($Adp["Command"])){
340
-							throw new Ks3ClientException("command is needed in adp");
341
-						}
342
-						$command = $Adp["Command"];
343
-						$bucket = NULL;
344
-						$key = NULL;
345
-						if(isset($Adp["Bucket"])){
346
-							$bucket = $Adp["Bucket"];
347
-						}
348
-						if(isset($Adp["Key"])){
349
-							$key = $Adp["Key"];
350
-						}
351
-						$AdpString.=$command;
352
-						if(!(empty($bucket)&&empty($key))){
353
-							if(empty($bucket)){
354
-								$AdpString.="|tag=saveas&object=".base64_encode($key);
355
-							}elseif (empty($key)) {
356
-								$AdpString.="|tag=saveas&bucket=".$bucket;
357
-							}else{
358
-								$AdpString.="|tag=saveas&bucket=".$bucket."&"."object=".base64_encode($key);
359
-							}
360
-						}
361
-						$AdpString.=";";
362
-					}
363
-				}
364
-				if(!empty($AdpString)&&!empty($NotifyURL)){
365
-					$request->addHeader(Headers::$AsynchronousProcessingList,$AdpString);
366
-					$request->addHeader(Headers::$NotifyURL,$NotifyURL);
367
-				}
368
-			}
369
-		}
370
-	}
321
+    public function sign(Ks3Request $request,$args=array()){
322
+        $args = $args["args"];
323
+        if(isset($args["Adp"])){
324
+            $AdpConf = $args["Adp"];
325
+            if(is_array($AdpConf)){
326
+                if(isset($AdpConf["NotifyURL"])){
327
+                    $NotifyURL = $AdpConf["NotifyURL"];
328
+                }else{
329
+                    throw new Ks3ClientException("adp should provide NotifyURL");
330
+                }
331
+                if(isset($AdpConf["Adps"])){
332
+                    $Adps = $AdpConf["Adps"];
333
+                }else{
334
+                    throw new Ks3ClientException("adp should provide Adps");
335
+                }
336
+                $AdpString = "";
337
+                foreach ($Adps as $Adp) {
338
+                    if(is_array($Adp)){
339
+                        if(!isset($Adp["Command"])){
340
+                            throw new Ks3ClientException("command is needed in adp");
341
+                        }
342
+                        $command = $Adp["Command"];
343
+                        $bucket = NULL;
344
+                        $key = NULL;
345
+                        if(isset($Adp["Bucket"])){
346
+                            $bucket = $Adp["Bucket"];
347
+                        }
348
+                        if(isset($Adp["Key"])){
349
+                            $key = $Adp["Key"];
350
+                        }
351
+                        $AdpString.=$command;
352
+                        if(!(empty($bucket)&&empty($key))){
353
+                            if(empty($bucket)){
354
+                                $AdpString.="|tag=saveas&object=".base64_encode($key);
355
+                            }elseif (empty($key)) {
356
+                                $AdpString.="|tag=saveas&bucket=".$bucket;
357
+                            }else{
358
+                                $AdpString.="|tag=saveas&bucket=".$bucket."&"."object=".base64_encode($key);
359
+                            }
360
+                        }
361
+                        $AdpString.=";";
362
+                    }
363
+                }
364
+                if(!empty($AdpString)&&!empty($NotifyURL)){
365
+                    $request->addHeader(Headers::$AsynchronousProcessingList,$AdpString);
366
+                    $request->addHeader(Headers::$NotifyURL,$NotifyURL);
367
+                }
368
+            }
369
+        }
370
+    }
371 371
 }
372 372
 class CallBackSigner{
373
-	public function sign(Ks3Request $request,$args=array()){
374
-		$args = $args["args"];
375
-		if(isset($args["CallBack"])&&is_array($args["CallBack"])){
376
-			$CallBackConf = $args["CallBack"];
377
-			$url = NULL;
378
-			$body = NULL;
379
-			if(isset($CallBackConf["Url"])){
380
-				$url = $CallBackConf["Url"];
381
-			}
382
-			if(empty($url))
383
-				throw new Ks3ClientException("Url is needed in CallBack");
384
-			if(isset($CallBackConf["BodyMagicVariables"])){
385
-				if(is_array($CallBackConf["BodyMagicVariables"])){
386
-					$magics = $CallBackConf["BodyMagicVariables"];
387
-					foreach ($magics as $key => $value) {
388
-						if(in_array($value,Consts::$CallBackMagics))
389
-							$body.=$key."=\${".$value."}&";
390
-					}
391
-				}
392
-			}
393
-			if(isset($CallBackConf["BodyVariables"])){
394
-				if(is_array($CallBackConf["BodyVariables"])){
395
-					$variables = $CallBackConf["BodyVariables"];
396
-					foreach ($variables as $key => $value) {
397
-						$body.=$key."=\${kss-".$key."}&";
398
-						$request->addHeader("kss-".$key,$value);
399
-					}
400
-				}
401
-			}
402
-			if(!empty($body)){
403
-				$body=substr($body,0,strlen($body)-1);
404
-				$request->addHeader(Headers::$XKssCallbackBody,$body);
405
-			}
406
-			$request->addHeader(Headers::$XKssCallbackUrl,$url);
407
-		}
408
-	}
373
+    public function sign(Ks3Request $request,$args=array()){
374
+        $args = $args["args"];
375
+        if(isset($args["CallBack"])&&is_array($args["CallBack"])){
376
+            $CallBackConf = $args["CallBack"];
377
+            $url = NULL;
378
+            $body = NULL;
379
+            if(isset($CallBackConf["Url"])){
380
+                $url = $CallBackConf["Url"];
381
+            }
382
+            if(empty($url))
383
+                throw new Ks3ClientException("Url is needed in CallBack");
384
+            if(isset($CallBackConf["BodyMagicVariables"])){
385
+                if(is_array($CallBackConf["BodyMagicVariables"])){
386
+                    $magics = $CallBackConf["BodyMagicVariables"];
387
+                    foreach ($magics as $key => $value) {
388
+                        if(in_array($value,Consts::$CallBackMagics))
389
+                            $body.=$key."=\${".$value."}&";
390
+                    }
391
+                }
392
+            }
393
+            if(isset($CallBackConf["BodyVariables"])){
394
+                if(is_array($CallBackConf["BodyVariables"])){
395
+                    $variables = $CallBackConf["BodyVariables"];
396
+                    foreach ($variables as $key => $value) {
397
+                        $body.=$key."=\${kss-".$key."}&";
398
+                        $request->addHeader("kss-".$key,$value);
399
+                    }
400
+                }
401
+            }
402
+            if(!empty($body)){
403
+                $body=substr($body,0,strlen($body)-1);
404
+                $request->addHeader(Headers::$XKssCallbackBody,$body);
405
+            }
406
+            $request->addHeader(Headers::$XKssCallbackUrl,$url);
407
+        }
408
+    }
409 409
 }
410 410
 class SSESigner{
411
-	public function sign(Ks3Request $request,$args=array()){
412
-		$args = $args["args"];
413
-		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"];
418
-			if(!empty($algm)){		
419
-				$request->addHeader(Headers::$SSEAlgm,$algm);
420
-				if(!empty($id))
421
-					$request->addHeader(Headers::$SSEKMSId,$id);
422
-			}
423
-		}
424
-	}
411
+    public function sign(Ks3Request $request,$args=array()){
412
+        $args = $args["args"];
413
+        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"];
418
+            if(!empty($algm)){		
419
+                $request->addHeader(Headers::$SSEAlgm,$algm);
420
+                if(!empty($id))
421
+                    $request->addHeader(Headers::$SSEKMSId,$id);
422
+            }
423
+        }
424
+    }
425 425
 }
426 426
 class SSECSigner{
427
-	public function sign(Ks3Request $request,$args=array()){
428
-		$args = $args["args"];
429
-		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"];
438
-			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));
427
+    public function sign(Ks3Request $request,$args=array()){
428
+        $args = $args["args"];
429
+        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"];
438
+            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));
445 445
 
446
-				$request->addHeader(Headers::$SSECAlgm,$algm);
447
-				$request->addHeader(Headers::$SSECKey,base64_encode($key));
448
-				$request->addHeader(Headers::$SSECMD5,$md5);
449
-			}
450
-		}
451
-	}	
446
+                $request->addHeader(Headers::$SSECAlgm,$algm);
447
+                $request->addHeader(Headers::$SSECKey,base64_encode($key));
448
+                $request->addHeader(Headers::$SSECMD5,$md5);
449
+            }
450
+        }
451
+    }	
452 452
 }
453 453
 class SSECSourceSigner{
454
-	public function sign(Ks3Request $request,$args=array()){
455
-		$args = $args["args"];
456
-		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"];
465
-			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));
454
+    public function sign(Ks3Request $request,$args=array()){
455
+        $args = $args["args"];
456
+        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"];
465
+            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));
472 472
 
473
-				$request->addHeader(Headers::$SSECSourceAlgm,$algm);
474
-				$request->addHeader(Headers::$SSECSourceKey,base64_encode($key));
475
-				$request->addHeader(Headers::$SSECSourceMD5,$md5);
476
-			}
477
-		}
478
-	}
473
+                $request->addHeader(Headers::$SSECSourceAlgm,$algm);
474
+                $request->addHeader(Headers::$SSECSourceKey,base64_encode($key));
475
+                $request->addHeader(Headers::$SSECSourceMD5,$md5);
476
+            }
477
+        }
478
+    }
479 479
 }
480 480
 class AllHeaderSigner{
481
-	public function sign(Ks3Request $request,$args=array()){
482
-		$args = $args["args"];
483
-		$headers = isset($args["Headers"])?$args["Headers"]:"";
484
-		if(!empty($headers)&&is_array($headers)){
485
-			foreach ($headers as $key => $value) {
486
-				$request->addHeader($key,$value);
487
-			}
488
-		}
489
-	}
481
+    public function sign(Ks3Request $request,$args=array()){
482
+        $args = $args["args"];
483
+        $headers = isset($args["Headers"])?$args["Headers"]:"";
484
+        if(!empty($headers)&&is_array($headers)){
485
+            foreach ($headers as $key => $value) {
486
+                $request->addHeader($key,$value);
487
+            }
488
+        }
489
+    }
490 490
 }
491 491
 class AuthUtils{
492
-	public static function canonicalizedKssHeaders(Ks3Request $request){
493
-		$header = "";
494
-		$headers = $request->headers;
495
-		ksort($headers,SORT_STRING);
496
-		foreach ( $headers as $header_key => $header_value ) {
497
-			if (substr(strtolower($header_key), 0, 6) === Consts::$KS3HeaderPrefix){
498
-				$header .= "\n".strtolower($header_key) . ':' .$header_value;
499
-			}			
500
-		}
501
-		$header = substr($header, 1);
502
-		return $header;
503
-	}
504
-	public static function canonicalizedResource(Ks3Request $request){
505
-		$resource = "/";
506
-		$bucket = $request->bucket;
507
-		$key = $request->key;
508
-		$subResource = $request->subResource;
509
-		if(!empty($bucket)){
510
-			$resource.=$request->bucket."/";
511
-		}
512
-		if(!empty($key)){
513
-			$resource.=Utils::encodeUrl($request->key);
514
-		}
492
+    public static function canonicalizedKssHeaders(Ks3Request $request){
493
+        $header = "";
494
+        $headers = $request->headers;
495
+        ksort($headers,SORT_STRING);
496
+        foreach ( $headers as $header_key => $header_value ) {
497
+            if (substr(strtolower($header_key), 0, 6) === Consts::$KS3HeaderPrefix){
498
+                $header .= "\n".strtolower($header_key) . ':' .$header_value;
499
+            }			
500
+        }
501
+        $header = substr($header, 1);
502
+        return $header;
503
+    }
504
+    public static function canonicalizedResource(Ks3Request $request){
505
+        $resource = "/";
506
+        $bucket = $request->bucket;
507
+        $key = $request->key;
508
+        $subResource = $request->subResource;
509
+        if(!empty($bucket)){
510
+            $resource.=$request->bucket."/";
511
+        }
512
+        if(!empty($key)){
513
+            $resource.=Utils::encodeUrl($request->key);
514
+        }
515 515
 
516
-		$encodeParams = "";
517
-		$querys = $request->queryParams;
518
-		if(!empty($subResource)){
519
-			$querys[$subResource] = NULL;
520
-		}
521
-		ksort($querys,SORT_STRING);
522
-		foreach ($querys as $key => $value) {
523
-			if(in_array($key,Consts::$SubResource)||in_array($key,Consts::$QueryParam)){
524
-				if(empty($value)){
525
-					$encodeParams.="&".$key;
526
-				}else{
527
-					$encodeParams.="&".$key."=".$value;
528
-				}
529
-			}
530
-		}
531
-		$encodeParams = substr($encodeParams,1);
516
+        $encodeParams = "";
517
+        $querys = $request->queryParams;
518
+        if(!empty($subResource)){
519
+            $querys[$subResource] = NULL;
520
+        }
521
+        ksort($querys,SORT_STRING);
522
+        foreach ($querys as $key => $value) {
523
+            if(in_array($key,Consts::$SubResource)||in_array($key,Consts::$QueryParam)){
524
+                if(empty($value)){
525
+                    $encodeParams.="&".$key;
526
+                }else{
527
+                    $encodeParams.="&".$key."=".$value;
528
+                }
529
+            }
530
+        }
531
+        $encodeParams = substr($encodeParams,1);
532 532
 
533
-		$resource = str_replace("//","/%2F", $resource);
533
+        $resource = str_replace("//","/%2F", $resource);
534 534
 
535
-		if(!empty($encodeParams)){
536
-			$resource.="?".$encodeParams;
537
-		}
538
-		return $resource;
539
-	}
535
+        if(!empty($encodeParams)){
536
+            $resource.="?".$encodeParams;
537
+        }
538
+        return $resource;
539
+    }
540 540
 }
541 541
 ?>
542 542
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -5,53 +5,53 @@  discard block
 block discarded – undo
5 5
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."config".DIRECTORY_SEPARATOR."Consts.php";
6 6
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."exceptions".DIRECTORY_SEPARATOR."Exceptions.php";
7 7
 
8
-interface Signer{
9
-	public function sign( Ks3Request $request,$args=array());
8
+interface Signer {
9
+	public function sign(Ks3Request $request, $args = array());
10 10
 }
11
-class DefaultUserAgentSigner implements Signer{
12
-	public function sign(Ks3Request $request,$args=array()){
13
-		$request->addHeader(Headers::$UserAgent,Consts::$UserAgent);
11
+class DefaultUserAgentSigner implements Signer {
12
+	public function sign(Ks3Request $request, $args = array()) {
13
+		$request->addHeader(Headers::$UserAgent, Consts::$UserAgent);
14 14
 	}
15 15
 }
16
-class DefaultContentTypeSigner implements Signer{
17
-	public function sign(Ks3Request $request,$args=array()){
16
+class DefaultContentTypeSigner implements Signer {
17
+	public function sign(Ks3Request $request, $args = array()) {
18 18
 		$contentType = $request->getHeader(Headers::$ContentType);
19
-		if(empty($contentType)){
20
-			$request->addHeader(Headers::$ContentType,"application/xml");
19
+		if (empty($contentType)) {
20
+			$request->addHeader(Headers::$ContentType, "application/xml");
21 21
 		}
22 22
 	}
23 23
 }
24
-class StreamContentTypeSigner implements Signer{
25
-	public function sign(Ks3Request $request,$args=array()){
24
+class StreamContentTypeSigner implements Signer {
25
+	public function sign(Ks3Request $request, $args = array()) {
26 26
 		$contentType = $request->getHeader(Headers::$ContentType);
27
-		if(empty($contentType)){
28
-			$request->addHeader(Headers::$ContentType,"application/ocet-stream");
27
+		if (empty($contentType)) {
28
+			$request->addHeader(Headers::$ContentType, "application/ocet-stream");
29 29
 		}
30 30
 	}
31 31
 }
32
-class SuffixContentTypeSigner implements Signer{
33
-	public function sign(Ks3Request $request,$args=array()){
32
+class SuffixContentTypeSigner implements Signer {
33
+	public function sign(Ks3Request $request, $args = array()) {
34 34
 		$key = $request->key;
35 35
 		$objArr = explode('/', $key);
36 36
 		$basename = array_pop($objArr);
37
-		$extension = explode ( '.', $basename );
38
-		$extension = array_pop ( $extension );
37
+		$extension = explode('.', $basename);
38
+		$extension = array_pop($extension);
39 39
 		$content_type = Utils::get_mimetype(strtolower($extension));
40
-		$request->addHeader(Headers::$ContentType,$content_type);
40
+		$request->addHeader(Headers::$ContentType, $content_type);
41 41
 	}
42 42
 }
43
-class HeaderAuthSigner implements Signer{
44
-	public function sign(Ks3Request $request,$args=array()){
43
+class HeaderAuthSigner implements Signer {
44
+	public function sign(Ks3Request $request, $args = array()) {
45 45
 		$log = "stringToSing->\r\n";
46 46
 		$date = gmdate('D, d M Y H:i:s \G\M\T');
47 47
 		$request->addHeader(Headers::$Date, $date);
48 48
 
49 49
 		$ak = $args["accessKey"];
50 50
 		$sk = $args["secretKey"];
51
-		if(empty($ak)){
51
+		if (empty($ak)) {
52 52
 			throw new Ks3ClientException("you should provide accessKey");
53 53
 		}
54
-		if(empty($sk)){
54
+		if (empty($sk)) {
55 55
 			throw new Ks3ClientException("you should provide secretKey");
56 56
 		}
57 57
 		$authration = "KSS ";
@@ -63,21 +63,21 @@  discard block
 block discarded – undo
63 63
 			);
64 64
 		$headers = AuthUtils::canonicalizedKssHeaders($request);
65 65
 		$resource = AuthUtils::canonicalizedResource($request);
66
-		if(!empty($headers)){
67
-			array_push($signList,$headers);
66
+		if (!empty($headers)) {
67
+			array_push($signList, $headers);
68 68
 		}
69
-		array_push($signList,$resource);
70
-		$stringToSign = join("\n",$signList);
71
-		$log.= $stringToSign;
69
+		array_push($signList, $resource);
70
+		$stringToSign = join("\n", $signList);
71
+		$log .= $stringToSign;
72 72
 		$signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));
73 73
 
74
-		$authration.=$ak.":".$signature;
74
+		$authration .= $ak.":".$signature;
75 75
 		$request->addHeader(Headers::$Authorization, $authration);
76 76
 		return $log;
77 77
 	}
78 78
 }
79
-class QueryAuthSigner implements Signer{
80
-	public function sign(Ks3Request $request,$args=array()){
79
+class QueryAuthSigner implements Signer {
80
+	public function sign(Ks3Request $request, $args = array()) {
81 81
 		$log = "stringToSing->\r\n";
82 82
 		$ak = $args["accessKey"];
83 83
 		$sk = $args["secretKey"];
@@ -93,447 +93,447 @@  discard block
 block discarded – undo
93 93
 			);
94 94
 		$headers = AuthUtils::canonicalizedKssHeaders($request);
95 95
 		$resource = AuthUtils::canonicalizedResource($request);
96
-		if(!empty($headers)){
97
-			array_push($signList,$headers);
96
+		if (!empty($headers)) {
97
+			array_push($signList, $headers);
98 98
 		}
99
-		array_push($signList,$resource);
99
+		array_push($signList, $resource);
100 100
 
101
-		$stringToSign = join("\n",$signList);
102
-		$log.= $stringToSign;
101
+		$stringToSign = join("\n", $signList);
102
+		$log .= $stringToSign;
103 103
 		$signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));
104
-		$request->addQueryParams("KSSAccessKeyId",$ak);
105
-		$request->addQueryParams("Signature",$signature);
106
-		$request->addQueryParams("Expires",$expiresSencond);
104
+		$request->addQueryParams("KSSAccessKeyId", $ak);
105
+		$request->addQueryParams("Signature", $signature);
106
+		$request->addQueryParams("Expires", $expiresSencond);
107 107
 		return $log;
108 108
 	}
109 109
 }
110
-class ACLSigner implements Signer{
111
-	public function sign(Ks3Request $request,$args=array()){
110
+class ACLSigner implements Signer {
111
+	public function sign(Ks3Request $request, $args = array()) {
112 112
 		$args = $args["args"];
113
-		if(isset($args["ACL"])){
113
+		if (isset($args["ACL"])) {
114 114
 			$acl = $args["ACL"];
115
-			if(!in_array($acl, Consts::$Acl)){
115
+			if (!in_array($acl, Consts::$Acl)) {
116 116
 				throw new Ks3ClientException("unsupport acl :".$acl);
117
-			}else{
118
-				$request->addHeader(Headers::$Acl,$acl);
117
+			}else {
118
+				$request->addHeader(Headers::$Acl, $acl);
119 119
 			}
120 120
 		}
121
-		if(isset($args["ACP"])){
121
+		if (isset($args["ACP"])) {
122 122
 
123 123
 		}
124 124
 	}
125 125
 }
126
-class ContentMD5Signer implements Signer{
127
-	public function sign(Ks3Request $request,$args=array()){
126
+class ContentMD5Signer implements Signer {
127
+	public function sign(Ks3Request $request, $args = array()) {
128 128
 		$args = $args["args"];
129 129
 		$contentmd5 = "";
130
-		if(isset($args["ObjectMeta"][Headers::$ContentMd5])){
130
+		if (isset($args["ObjectMeta"][Headers::$ContentMd5])) {
131 131
 			$contentmd5 = $args["ObjectMeta"][Headers::$ContentMd5];
132 132
 		}
133
-		if(empty($contentmd5)){
133
+		if (empty($contentmd5)) {
134 134
 			$body = $request->body;
135
-			if(!empty($body)){
135
+			if (!empty($body)) {
136 136
 				$length = $request->getHeader(Headers::$ContentLength);
137
-				if(empty($length)){
138
-					if(isset($args["ObjectMeta"][Headers::$ContentLength]))
137
+				if (empty($length)) {
138
+					if (isset($args["ObjectMeta"][Headers::$ContentLength]))
139 139
 						$length = $args["ObjectMeta"][Headers::$ContentLength];
140 140
 				}
141
-				if(!empty($length)){
142
-					$body = substr($body,0,$length);
141
+				if (!empty($length)) {
142
+					$body = substr($body, 0, $length);
143 143
 				}
144 144
 				$contentmd5 = Utils::hex_to_base64(md5($body));
145 145
 			}
146 146
 		}
147
-		if(!empty($contentmd5))
148
-			$request->addHeader(Headers::$ContentMd5,$contentmd5);
147
+		if (!empty($contentmd5))
148
+			$request->addHeader(Headers::$ContentMd5, $contentmd5);
149 149
 	}
150 150
 }
151
-class ContentLengthSigner implements Signer{
152
-	public function sign(Ks3Request $request,$args=array()){
151
+class ContentLengthSigner implements Signer {
152
+	public function sign(Ks3Request $request, $args = array()) {
153 153
 		$args = $args["args"];
154 154
 		$contentlength = "";
155
-		if(isset($args["ObjectMeta"][Headers::$ContentLength])){
155
+		if (isset($args["ObjectMeta"][Headers::$ContentLength])) {
156 156
 			$contentlength = $args["ObjectMeta"][Headers::$ContentLength];
157 157
 		}
158
-		if(empty($contentlength)){
158
+		if (empty($contentlength)) {
159 159
 			$body = $request->body;
160
-			if(!empty($body)){
160
+			if (!empty($body)) {
161 161
 				$contentlength = strlen($body);
162 162
 			}
163 163
 		}
164
-		if(!empty($contentlength))
165
-			$request->addHeader(Headers::$ContentLength,$contentlength);
164
+		if (!empty($contentlength))
165
+			$request->addHeader(Headers::$ContentLength, $contentlength);
166 166
 	}
167 167
 }
168
-class ObjectMetaSigner implements Signer{
169
-	public function sign(Ks3Request $request,$args=array()){
168
+class ObjectMetaSigner implements Signer {
169
+	public function sign(Ks3Request $request, $args = array()) {
170 170
 		$args = $args["args"];
171
-		if(isset($args["ObjectMeta"])){
171
+		if (isset($args["ObjectMeta"])) {
172 172
 			$ObjectMeta = $args["ObjectMeta"];
173
-			if(is_array($ObjectMeta)){
173
+			if (is_array($ObjectMeta)) {
174 174
 				foreach ($ObjectMeta as $key => $value) {
175
-					if(in_array($key,Consts::$ObjectMeta)&&!empty($value)){
176
-						$request->addHeader($key,$value);
175
+					if (in_array($key, Consts::$ObjectMeta) && !empty($value)) {
176
+						$request->addHeader($key, $value);
177 177
 					}
178 178
 				}
179 179
 			}
180 180
 		}
181 181
 	}
182 182
 }
183
-class MultipartObjectMetaSigner implements Signer{
184
-	public function sign(Ks3Request $request,$args=array()){
183
+class MultipartObjectMetaSigner implements Signer {
184
+	public function sign(Ks3Request $request, $args = array()) {
185 185
 		$args = $args["args"];
186
-		if(isset($args["ObjectMeta"])){
186
+		if (isset($args["ObjectMeta"])) {
187 187
 			$ObjectMeta = $args["ObjectMeta"];
188
-			if(is_array($ObjectMeta)){
188
+			if (is_array($ObjectMeta)) {
189 189
 				foreach ($ObjectMeta as $key => $value) {
190
-					if(in_array($key,Consts::$MultipartObjectMeta)&&!empty($value)){
191
-						$request->addHeader($key,$value);
190
+					if (in_array($key, Consts::$MultipartObjectMeta) && !empty($value)) {
191
+						$request->addHeader($key, $value);
192 192
 					}
193 193
 				}
194 194
 			}
195 195
 		}
196 196
 	}
197 197
 }
198
-class UserMetaSigner implements Signer{
199
-	public function sign(Ks3Request $request,$args=array()){
198
+class UserMetaSigner implements Signer {
199
+	public function sign(Ks3Request $request, $args = array()) {
200 200
 		$args = $args["args"];
201
-		if(isset($args["UserMeta"])){
201
+		if (isset($args["UserMeta"])) {
202 202
 			$UserMeta = $args["UserMeta"];
203
-			if(is_array($UserMeta)){
203
+			if (is_array($UserMeta)) {
204 204
 				foreach ($UserMeta as $key => $value) {
205
-					if (substr(strtolower($key), 0, 10) === Consts::$UserMetaPrefix){
206
-						$request->addHeader($key,$value);
205
+					if (substr(strtolower($key), 0, 10) === Consts::$UserMetaPrefix) {
206
+						$request->addHeader($key, $value);
207 207
 					}
208 208
 				}
209 209
 			}
210 210
 		}
211 211
 	}
212 212
 }
213
-class CopySourceSigner implements Signer{
214
-	public function sign(Ks3Request $request,$args=array()){
213
+class CopySourceSigner implements Signer {
214
+	public function sign(Ks3Request $request, $args = array()) {
215 215
 		$args = $args["args"];
216
-		if(isset($args["CopySource"])){
216
+		if (isset($args["CopySource"])) {
217 217
 			$CopySource = $args["CopySource"];
218
-			if(is_array($CopySource)){
219
-				if(!isset($CopySource["Bucket"]))
218
+			if (is_array($CopySource)) {
219
+				if (!isset($CopySource["Bucket"]))
220 220
 					throw new Ks3ClientException("you should provide copy source bucket");
221
-				if(!isset($CopySource["Key"]))
221
+				if (!isset($CopySource["Key"]))
222 222
 					throw new Ks3ClientException("you should provide copy source key");
223 223
 				$bucket = $CopySource["Bucket"];
224 224
 				$key = Utils::encodeUrl($CopySource["Key"]);
225
-				$request->addHeader(Headers::$CopySource,"/".$bucket."/".$key);
225
+				$request->addHeader(Headers::$CopySource, "/".$bucket."/".$key);
226 226
 			}
227 227
 		}
228 228
 	}
229 229
 }
230
-class StreamUploadSigner implements Signer{
231
-	public function sign(Ks3Request $request,$args=array()){
230
+class StreamUploadSigner implements Signer {
231
+	public function sign(Ks3Request $request, $args = array()) {
232 232
 		$args = $args["args"];
233
-		if(isset($args["Content"])&&is_array($args["Content"])&&isset($args["Content"]["content"])){
233
+		if (isset($args["Content"]) && is_array($args["Content"]) && isset($args["Content"]["content"])) {
234 234
 			$content = $args["Content"]["content"];
235 235
 			$seek_position = 0;
236 236
 			$resourceLength = 0;
237 237
 			$length = -1;
238 238
 			$isFile = FALSE;
239 239
 
240
-			if (!is_resource($content)){
240
+			if (!is_resource($content)) {
241 241
 				$isFile = TRUE;
242 242
 				//如果之前用户已经转化为GBK则不转换
243
-				if(Utils::chk_chinese($content)&&!Utils::check_char($content)){
244
-					$content = iconv('utf-8','gbk',$content);
243
+				if (Utils::chk_chinese($content) && !Utils::check_char($content)) {
244
+					$content = iconv('utf-8', 'gbk', $content);
245 245
 				}
246
-				if(!file_exists($content))
246
+				if (!file_exists($content))
247 247
 					throw new Ks3ClientException("the specified file does not exist ");
248 248
 				$length = Utils::getFileSize($content);
249
-				$content = fopen($content,"r");
250
-			}else{
249
+				$content = fopen($content, "r");
250
+			}else {
251 251
 				$stats = fstat($content);
252
-				if ($stats && $stats["size"] >= 0){
252
+				if ($stats && $stats["size"] >= 0) {
253 253
 					$length = $stats["size"];	
254 254
 				}
255 255
 			}
256 256
 			//之所以取resourceLength是为了防止Content-Length大于实际数据的大小,导致一直等待。
257 257
 			$resourceLength = $length;
258 258
 			//优先取用户设置seek_position,没有的话取ftell
259
-			if(isset($args["Content"]["seek_position"])&&$args["Content"]["seek_position"]>0){
259
+			if (isset($args["Content"]["seek_position"]) && $args["Content"]["seek_position"] > 0) {
260 260
 				$seek_position = $args["Content"]["seek_position"];
261
-			}else if(!$isFile){
261
+			}else if (!$isFile) {
262 262
 				$seek_position = ftell($content);
263
-				if($seek_position<0)
263
+				if ($seek_position < 0)
264 264
 					$seek_position = 0;
265
-				fseek($content,0);
265
+				fseek($content, 0);
266 266
 			}
267 267
 
268 268
 			$lengthInMeta = -1;
269
-			if(isset($args["ObjectMeta"]["Content-Length"])){
269
+			if (isset($args["ObjectMeta"]["Content-Length"])) {
270 270
 				$lengthInMeta = $args["ObjectMeta"]["Content-Length"];
271 271
 			}
272
-			if($lengthInMeta > 0){
272
+			if ($lengthInMeta > 0) {
273 273
 				$length = $lengthInMeta;
274
-			}else if($resourceLength > 0){
274
+			}else if ($resourceLength > 0) {
275 275
 				//根据seek_position计算实际长度
276
-				$length = $resourceLength - $seek_position;
276
+				$length = $resourceLength-$seek_position;
277 277
 			}
278
-			if($length <= 0)
278
+			if ($length <= 0)
279 279
 				throw new Ks3ClientException("calculate content length failed,unexpected contetn length ".$length);
280 280
 			$request->read_stream = $content;
281
-			$request->addHeader(Headers::$ContentLength,$length);
281
+			$request->addHeader(Headers::$ContentLength, $length);
282 282
 			$request->seek_position = $seek_position;
283
-		}else{
283
+		}else {
284 284
 			throw new Ks3ClientException("please specifie upload content in args");
285 285
 		}
286 286
 	}
287 287
 }
288
-class RangeSigner{
289
-	public function sign(Ks3Request $request,$args=array()){
288
+class RangeSigner {
289
+	public function sign(Ks3Request $request, $args = array()) {
290 290
 		$args = $args["args"];
291
-		if(isset($args["Range"])){
291
+		if (isset($args["Range"])) {
292 292
 			$Range = $args["Range"];
293
-			if(is_array($Range)){
293
+			if (is_array($Range)) {
294 294
 				$start = $Range["start"];
295 295
 				$end = $Range["end"];
296 296
 				$range = "bytes=".$start."-".$end;
297
-				$request->addHeader(Headers::$Range,$range);
297
+				$request->addHeader(Headers::$Range, $range);
298 298
 			}else
299
-				$request->addHeader(Headers::$Range,$Range);
299
+				$request->addHeader(Headers::$Range, $Range);
300 300
 		}
301 301
 	}
302 302
 }
303
-class GetObjectSigner{
304
-	public function sign(Ks3Request $request,$args=array()){
303
+class GetObjectSigner {
304
+	public function sign(Ks3Request $request, $args = array()) {
305 305
 		$args = $args["args"];
306
-		if(isset($args["WriteTo"])){
306
+		if (isset($args["WriteTo"])) {
307 307
 			$WriteTo = $args["WriteTo"];
308
-			if(is_resource($WriteTo)){
308
+			if (is_resource($WriteTo)) {
309 309
 				$request->write_stream = $WriteTo;
310
-			}else{
310
+			}else {
311 311
 				//如果之前用户已经转化为GBK则不转换
312
-				if(Utils::chk_chinese($WriteTo)&&!Utils::check_char($WriteTo)){
313
-					$WriteTo = iconv('utf-8','gbk',$WriteTo);
312
+				if (Utils::chk_chinese($WriteTo) && !Utils::check_char($WriteTo)) {
313
+					$WriteTo = iconv('utf-8', 'gbk', $WriteTo);
314 314
 				}
315
-				$request->write_stream = fopen($WriteTo,"w");
315
+				$request->write_stream = fopen($WriteTo, "w");
316 316
 			}
317 317
 		}
318 318
 	}
319 319
 }
320
-class AdpSigner{
321
-	public function sign(Ks3Request $request,$args=array()){
320
+class AdpSigner {
321
+	public function sign(Ks3Request $request, $args = array()) {
322 322
 		$args = $args["args"];
323
-		if(isset($args["Adp"])){
323
+		if (isset($args["Adp"])) {
324 324
 			$AdpConf = $args["Adp"];
325
-			if(is_array($AdpConf)){
326
-				if(isset($AdpConf["NotifyURL"])){
325
+			if (is_array($AdpConf)) {
326
+				if (isset($AdpConf["NotifyURL"])) {
327 327
 					$NotifyURL = $AdpConf["NotifyURL"];
328
-				}else{
328
+				}else {
329 329
 					throw new Ks3ClientException("adp should provide NotifyURL");
330 330
 				}
331
-				if(isset($AdpConf["Adps"])){
331
+				if (isset($AdpConf["Adps"])) {
332 332
 					$Adps = $AdpConf["Adps"];
333
-				}else{
333
+				}else {
334 334
 					throw new Ks3ClientException("adp should provide Adps");
335 335
 				}
336 336
 				$AdpString = "";
337 337
 				foreach ($Adps as $Adp) {
338
-					if(is_array($Adp)){
339
-						if(!isset($Adp["Command"])){
338
+					if (is_array($Adp)) {
339
+						if (!isset($Adp["Command"])) {
340 340
 							throw new Ks3ClientException("command is needed in adp");
341 341
 						}
342 342
 						$command = $Adp["Command"];
343 343
 						$bucket = NULL;
344 344
 						$key = NULL;
345
-						if(isset($Adp["Bucket"])){
345
+						if (isset($Adp["Bucket"])) {
346 346
 							$bucket = $Adp["Bucket"];
347 347
 						}
348
-						if(isset($Adp["Key"])){
348
+						if (isset($Adp["Key"])) {
349 349
 							$key = $Adp["Key"];
350 350
 						}
351
-						$AdpString.=$command;
352
-						if(!(empty($bucket)&&empty($key))){
353
-							if(empty($bucket)){
354
-								$AdpString.="|tag=saveas&object=".base64_encode($key);
351
+						$AdpString .= $command;
352
+						if (!(empty($bucket) && empty($key))) {
353
+							if (empty($bucket)) {
354
+								$AdpString .= "|tag=saveas&object=".base64_encode($key);
355 355
 							}elseif (empty($key)) {
356
-								$AdpString.="|tag=saveas&bucket=".$bucket;
357
-							}else{
358
-								$AdpString.="|tag=saveas&bucket=".$bucket."&"."object=".base64_encode($key);
356
+								$AdpString .= "|tag=saveas&bucket=".$bucket;
357
+							}else {
358
+								$AdpString .= "|tag=saveas&bucket=".$bucket."&"."object=".base64_encode($key);
359 359
 							}
360 360
 						}
361
-						$AdpString.=";";
361
+						$AdpString .= ";";
362 362
 					}
363 363
 				}
364
-				if(!empty($AdpString)&&!empty($NotifyURL)){
365
-					$request->addHeader(Headers::$AsynchronousProcessingList,$AdpString);
366
-					$request->addHeader(Headers::$NotifyURL,$NotifyURL);
364
+				if (!empty($AdpString) && !empty($NotifyURL)) {
365
+					$request->addHeader(Headers::$AsynchronousProcessingList, $AdpString);
366
+					$request->addHeader(Headers::$NotifyURL, $NotifyURL);
367 367
 				}
368 368
 			}
369 369
 		}
370 370
 	}
371 371
 }
372
-class CallBackSigner{
373
-	public function sign(Ks3Request $request,$args=array()){
372
+class CallBackSigner {
373
+	public function sign(Ks3Request $request, $args = array()) {
374 374
 		$args = $args["args"];
375
-		if(isset($args["CallBack"])&&is_array($args["CallBack"])){
375
+		if (isset($args["CallBack"]) && is_array($args["CallBack"])) {
376 376
 			$CallBackConf = $args["CallBack"];
377 377
 			$url = NULL;
378 378
 			$body = NULL;
379
-			if(isset($CallBackConf["Url"])){
379
+			if (isset($CallBackConf["Url"])) {
380 380
 				$url = $CallBackConf["Url"];
381 381
 			}
382
-			if(empty($url))
382
+			if (empty($url))
383 383
 				throw new Ks3ClientException("Url is needed in CallBack");
384
-			if(isset($CallBackConf["BodyMagicVariables"])){
385
-				if(is_array($CallBackConf["BodyMagicVariables"])){
384
+			if (isset($CallBackConf["BodyMagicVariables"])) {
385
+				if (is_array($CallBackConf["BodyMagicVariables"])) {
386 386
 					$magics = $CallBackConf["BodyMagicVariables"];
387 387
 					foreach ($magics as $key => $value) {
388
-						if(in_array($value,Consts::$CallBackMagics))
389
-							$body.=$key."=\${".$value."}&";
388
+						if (in_array($value, Consts::$CallBackMagics))
389
+							$body .= $key."=\${".$value."}&";
390 390
 					}
391 391
 				}
392 392
 			}
393
-			if(isset($CallBackConf["BodyVariables"])){
394
-				if(is_array($CallBackConf["BodyVariables"])){
393
+			if (isset($CallBackConf["BodyVariables"])) {
394
+				if (is_array($CallBackConf["BodyVariables"])) {
395 395
 					$variables = $CallBackConf["BodyVariables"];
396 396
 					foreach ($variables as $key => $value) {
397
-						$body.=$key."=\${kss-".$key."}&";
398
-						$request->addHeader("kss-".$key,$value);
397
+						$body .= $key."=\${kss-".$key."}&";
398
+						$request->addHeader("kss-".$key, $value);
399 399
 					}
400 400
 				}
401 401
 			}
402
-			if(!empty($body)){
403
-				$body=substr($body,0,strlen($body)-1);
404
-				$request->addHeader(Headers::$XKssCallbackBody,$body);
402
+			if (!empty($body)) {
403
+				$body = substr($body, 0, strlen($body)-1);
404
+				$request->addHeader(Headers::$XKssCallbackBody, $body);
405 405
 			}
406
-			$request->addHeader(Headers::$XKssCallbackUrl,$url);
406
+			$request->addHeader(Headers::$XKssCallbackUrl, $url);
407 407
 		}
408 408
 	}
409 409
 }
410
-class SSESigner{
411
-	public function sign(Ks3Request $request,$args=array()){
410
+class SSESigner {
411
+	public function sign(Ks3Request $request, $args = array()) {
412 412
 		$args = $args["args"];
413
-		if(isset($args["SSE"])){
414
-			if(isset($args["SSE"]["Algm"]))
413
+		if (isset($args["SSE"])) {
414
+			if (isset($args["SSE"]["Algm"]))
415 415
 				$algm = $args["SSE"]["Algm"];
416
-			if(isset($args["SSE"]["KMSId"]))
416
+			if (isset($args["SSE"]["KMSId"]))
417 417
 				$id = $args["SSE"]["KMSId"];
418
-			if(!empty($algm)){		
419
-				$request->addHeader(Headers::$SSEAlgm,$algm);
420
-				if(!empty($id))
421
-					$request->addHeader(Headers::$SSEKMSId,$id);
418
+			if (!empty($algm)) {		
419
+				$request->addHeader(Headers::$SSEAlgm, $algm);
420
+				if (!empty($id))
421
+					$request->addHeader(Headers::$SSEKMSId, $id);
422 422
 			}
423 423
 		}
424 424
 	}
425 425
 }
426
-class SSECSigner{
427
-	public function sign(Ks3Request $request,$args=array()){
426
+class SSECSigner {
427
+	public function sign(Ks3Request $request, $args = array()) {
428 428
 		$args = $args["args"];
429
-		if(isset($args["SSEC"])){
430
-			if(isset($args["SSEC"]["Algm"]))
429
+		if (isset($args["SSEC"])) {
430
+			if (isset($args["SSEC"]["Algm"]))
431 431
 				$algm = $args["SSEC"]["Algm"];
432
-			if(isset($args["SSEC"]["Key"]))
432
+			if (isset($args["SSEC"]["Key"]))
433 433
 				$key = $args["SSEC"]["Key"];
434
-			if(isset($args["SSEC"]["KeyBase64"]))
434
+			if (isset($args["SSEC"]["KeyBase64"]))
435 435
 				$keybase64 = $args["SSEC"]["KeyBase64"];
436
-			if(isset($args["SSEC"]["KeyMD5"]))
436
+			if (isset($args["SSEC"]["KeyMD5"]))
437 437
 				$md5 = $args["SSEC"]["KeyMD5"];
438
-			if(!empty($key)||!empty($keybase64)){
439
-				if(empty($key))
438
+			if (!empty($key) || !empty($keybase64)) {
439
+				if (empty($key))
440 440
 					$key = base64_decode($keybase64);
441
-				if(empty($algm))
441
+				if (empty($algm))
442 442
 					$algm = Consts::$SSEDefaultAlgm;
443
-				if(empty($md5))
443
+				if (empty($md5))
444 444
 					$md5 = Utils::hex_to_base64(md5($key));
445 445
 
446
-				$request->addHeader(Headers::$SSECAlgm,$algm);
447
-				$request->addHeader(Headers::$SSECKey,base64_encode($key));
448
-				$request->addHeader(Headers::$SSECMD5,$md5);
446
+				$request->addHeader(Headers::$SSECAlgm, $algm);
447
+				$request->addHeader(Headers::$SSECKey, base64_encode($key));
448
+				$request->addHeader(Headers::$SSECMD5, $md5);
449 449
 			}
450 450
 		}
451 451
 	}	
452 452
 }
453
-class SSECSourceSigner{
454
-	public function sign(Ks3Request $request,$args=array()){
453
+class SSECSourceSigner {
454
+	public function sign(Ks3Request $request, $args = array()) {
455 455
 		$args = $args["args"];
456
-		if(isset($args["SSECSource"])){
457
-			if(isset($args["SSECSource"]["Algm"]))
456
+		if (isset($args["SSECSource"])) {
457
+			if (isset($args["SSECSource"]["Algm"]))
458 458
 				$algm = $args["SSECSource"]["Algm"];
459
-			if(isset($args["SSECSource"]["Key"]))
459
+			if (isset($args["SSECSource"]["Key"]))
460 460
 				$key = $args["SSECSource"]["Key"];
461
-			if(isset($args["SSECSource"]["KeyBase64"]))
461
+			if (isset($args["SSECSource"]["KeyBase64"]))
462 462
 				$keybase64 = $args["SSECSource"]["KeyBase64"];
463
-			if(isset($args["SSECSource"]["KeyMD5"]))
463
+			if (isset($args["SSECSource"]["KeyMD5"]))
464 464
 				$md5 = $args["SSECSource"]["KeyMD5"];
465
-			if(!empty($key)||!empty($keybase64)){
466
-				if(empty($key))
465
+			if (!empty($key) || !empty($keybase64)) {
466
+				if (empty($key))
467 467
 					$key = base64_decode($keybase64);
468
-				if(empty($algm))
468
+				if (empty($algm))
469 469
 					$algm = Consts::$SSEDefaultAlgm;
470
-				if(empty($md5))
470
+				if (empty($md5))
471 471
 					$md5 = Utils::hex_to_base64(md5($key));
472 472
 
473
-				$request->addHeader(Headers::$SSECSourceAlgm,$algm);
474
-				$request->addHeader(Headers::$SSECSourceKey,base64_encode($key));
475
-				$request->addHeader(Headers::$SSECSourceMD5,$md5);
473
+				$request->addHeader(Headers::$SSECSourceAlgm, $algm);
474
+				$request->addHeader(Headers::$SSECSourceKey, base64_encode($key));
475
+				$request->addHeader(Headers::$SSECSourceMD5, $md5);
476 476
 			}
477 477
 		}
478 478
 	}
479 479
 }
480
-class AllHeaderSigner{
481
-	public function sign(Ks3Request $request,$args=array()){
480
+class AllHeaderSigner {
481
+	public function sign(Ks3Request $request, $args = array()) {
482 482
 		$args = $args["args"];
483
-		$headers = isset($args["Headers"])?$args["Headers"]:"";
484
-		if(!empty($headers)&&is_array($headers)){
483
+		$headers = isset($args["Headers"]) ? $args["Headers"] : "";
484
+		if (!empty($headers) && is_array($headers)) {
485 485
 			foreach ($headers as $key => $value) {
486
-				$request->addHeader($key,$value);
486
+				$request->addHeader($key, $value);
487 487
 			}
488 488
 		}
489 489
 	}
490 490
 }
491
-class AuthUtils{
492
-	public static function canonicalizedKssHeaders(Ks3Request $request){
491
+class AuthUtils {
492
+	public static function canonicalizedKssHeaders(Ks3Request $request) {
493 493
 		$header = "";
494 494
 		$headers = $request->headers;
495
-		ksort($headers,SORT_STRING);
496
-		foreach ( $headers as $header_key => $header_value ) {
497
-			if (substr(strtolower($header_key), 0, 6) === Consts::$KS3HeaderPrefix){
498
-				$header .= "\n".strtolower($header_key) . ':' .$header_value;
495
+		ksort($headers, SORT_STRING);
496
+		foreach ($headers as $header_key => $header_value) {
497
+			if (substr(strtolower($header_key), 0, 6) === Consts::$KS3HeaderPrefix) {
498
+				$header .= "\n".strtolower($header_key).':'.$header_value;
499 499
 			}			
500 500
 		}
501 501
 		$header = substr($header, 1);
502 502
 		return $header;
503 503
 	}
504
-	public static function canonicalizedResource(Ks3Request $request){
504
+	public static function canonicalizedResource(Ks3Request $request) {
505 505
 		$resource = "/";
506 506
 		$bucket = $request->bucket;
507 507
 		$key = $request->key;
508 508
 		$subResource = $request->subResource;
509
-		if(!empty($bucket)){
510
-			$resource.=$request->bucket."/";
509
+		if (!empty($bucket)) {
510
+			$resource .= $request->bucket."/";
511 511
 		}
512
-		if(!empty($key)){
513
-			$resource.=Utils::encodeUrl($request->key);
512
+		if (!empty($key)) {
513
+			$resource .= Utils::encodeUrl($request->key);
514 514
 		}
515 515
 
516 516
 		$encodeParams = "";
517 517
 		$querys = $request->queryParams;
518
-		if(!empty($subResource)){
518
+		if (!empty($subResource)) {
519 519
 			$querys[$subResource] = NULL;
520 520
 		}
521
-		ksort($querys,SORT_STRING);
521
+		ksort($querys, SORT_STRING);
522 522
 		foreach ($querys as $key => $value) {
523
-			if(in_array($key,Consts::$SubResource)||in_array($key,Consts::$QueryParam)){
524
-				if(empty($value)){
525
-					$encodeParams.="&".$key;
526
-				}else{
527
-					$encodeParams.="&".$key."=".$value;
523
+			if (in_array($key, Consts::$SubResource) || in_array($key, Consts::$QueryParam)) {
524
+				if (empty($value)) {
525
+					$encodeParams .= "&".$key;
526
+				}else {
527
+					$encodeParams .= "&".$key."=".$value;
528 528
 				}
529 529
 			}
530 530
 		}
531
-		$encodeParams = substr($encodeParams,1);
531
+		$encodeParams = substr($encodeParams, 1);
532 532
 
533
-		$resource = str_replace("//","/%2F", $resource);
533
+		$resource = str_replace("//", "/%2F", $resource);
534 534
 
535
-		if(!empty($encodeParams)){
536
-			$resource.="?".$encodeParams;
535
+		if (!empty($encodeParams)) {
536
+			$resource .= "?".$encodeParams;
537 537
 		}
538 538
 		return $resource;
539 539
 	}
Please login to merge, or discard this 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/MessageHolder.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 class MessageHolder{
3
-	public $msg;
3
+    public $msg;
4 4
 }
5 5
 ?>
6 6
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-class MessageHolder{
2
+class MessageHolder {
3 3
 	public $msg;
4 4
 }
5 5
 ?>
6 6
\ No newline at end of file
Please login to merge, or discard this patch.