Completed
Push — master ( d99bf9...491baf )
by Stephen
13:47
created
src/wp-admin/includes/class-ftp-pure.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -83,6 +83,9 @@
 block discarded – undo
83 83
 		return $result;
84 84
 	}
85 85
 
86
+	/**
87
+	 * @param string $cmd
88
+	 */
86 89
 	function _exec($cmd, $fnction="_exec") {
87 90
 		if(!$this->_ready) {
88 91
 			$this->PushError($fnction,'Connect first');
Please login to merge, or discard this patch.
Braces   +44 added lines, -16 removed lines patch added patch discarded remove patch
@@ -75,10 +75,14 @@  discard block
 block discarded – undo
75 75
 				$this->PushError($fnction,'Read failed');
76 76
 			} else {
77 77
 				$this->_message.=$tmp;
78
-				if(preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) $go=false;
78
+				if(preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) {
79
+					$go=false;
80
+				}
79 81
 			}
80 82
 		} while($go);
81
-		if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
83
+		if($this->LocalEcho) {
84
+			echo "GET < ".rtrim($this->_message, CRLF).CRLF;
85
+		}
82 86
 		$this->_code=(int)$regs[1];
83 87
 		return $result;
84 88
 	}
@@ -88,19 +92,25 @@  discard block
 block discarded – undo
88 92
 			$this->PushError($fnction,'Connect first');
89 93
 			return FALSE;
90 94
 		}
91
-		if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
95
+		if($this->LocalEcho) {
96
+			echo "PUT > ",$cmd,CRLF;
97
+		}
92 98
 		$status=@fputs($this->_ftp_control_sock, $cmd.CRLF);
93 99
 		if($status===false) {
94 100
 			$this->PushError($fnction,'socket write failed');
95 101
 			return FALSE;
96 102
 		}
97 103
 		$this->_lastaction=time();
98
-		if(!$this->_readmsg($fnction)) return FALSE;
104
+		if(!$this->_readmsg($fnction)) {
105
+			return FALSE;
106
+		}
99 107
 		return TRUE;
100 108
 	}
101 109
 
102 110
 	function _data_prepare($mode=FTP_ASCII) {
103
-		if(!$this->_settype($mode)) return FALSE;
111
+		if(!$this->_settype($mode)) {
112
+			return FALSE;
113
+		}
104 114
 		if($this->_passive) {
105 115
 			if(!$this->_exec("PASV", "pasv")) {
106 116
 				$this->_data_close();
@@ -119,8 +129,9 @@  discard block
 block discarded – undo
119 129
 				$this->PushError("_data_prepare","fsockopen fails", $errstr." (".$errno.")");
120 130
 				$this->_data_close();
121 131
 				return FALSE;
132
+			} else {
133
+				$this->_ftp_data_sock;
122 134
 			}
123
-			else $this->_ftp_data_sock;
124 135
 		} else {
125 136
 			$this->SendMSG("Only passive connections available!");
126 137
 			return FALSE;
@@ -129,24 +140,35 @@  discard block
 block discarded – undo
129 140
 	}
130 141
 
131 142
 	function _data_read($mode=FTP_ASCII, $fp=NULL) {
132
-		if(is_resource($fp)) $out=0;
133
-		else $out="";
143
+		if(is_resource($fp)) {
144
+			$out=0;
145
+		} else {
146
+			$out="";
147
+		}
134 148
 		if(!$this->_passive) {
135 149
 			$this->SendMSG("Only passive connections available!");
136 150
 			return FALSE;
137 151
 		}
138 152
 		while (!feof($this->_ftp_data_sock)) {
139 153
 			$block=fread($this->_ftp_data_sock, $this->_ftp_buff_size);
140
-			if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
141
-			if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block));
142
-			else $out.=$block;
154
+			if($mode!=FTP_BINARY) {
155
+				$block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
156
+			}
157
+			if(is_resource($fp)) {
158
+				$out+=fwrite($fp, $block, strlen($block));
159
+			} else {
160
+				$out.=$block;
161
+			}
143 162
 		}
144 163
 		return $out;
145 164
 	}
146 165
 
147 166
 	function _data_write($mode=FTP_ASCII, $fp=NULL) {
148
-		if(is_resource($fp)) $out=0;
149
-		else $out="";
167
+		if(is_resource($fp)) {
168
+			$out=0;
169
+		} else {
170
+			$out="";
171
+		}
150 172
 		if(!$this->_passive) {
151 173
 			$this->SendMSG("Only passive connections available!");
152 174
 			return FALSE;
@@ -154,14 +176,20 @@  discard block
 block discarded – undo
154 176
 		if(is_resource($fp)) {
155 177
 			while(!feof($fp)) {
156 178
 				$block=fread($fp, $this->_ftp_buff_size);
157
-				if(!$this->_data_write_block($mode, $block)) return false;
179
+				if(!$this->_data_write_block($mode, $block)) {
180
+					return false;
181
+				}
158 182
 			}
159
-		} elseif(!$this->_data_write_block($mode, $fp)) return false;
183
+		} elseif(!$this->_data_write_block($mode, $fp)) {
184
+			return false;
185
+		}
160 186
 		return TRUE;
161 187
 	}
162 188
 
163 189
 	function _data_write_block($mode, $block) {
164
-		if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
190
+		if($mode!=FTP_BINARY) {
191
+			$block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
192
+		}
165 193
 		do {
166 194
 			if(($t=@fwrite($this->_ftp_data_sock, $block))===FALSE) {
167 195
 				$this->PushError("_data_write","Can't write to socket");
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@
 block discarded – undo
112 112
 			}
113 113
 			$ip_port = explode(",", preg_replace("/^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*$/s", "\\1", $this->_message));
114 114
 			$this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3];
115
-            $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]);
115
+			$this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]);
116 116
 			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
117 117
 			$this->_ftp_data_sock=@fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout);
118 118
 			if(!$this->_ftp_data_sock) {
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  */
28 28
 class ftp_pure extends ftp_base {
29 29
 
30
-	function __construct($verb=FALSE, $le=FALSE) {
30
+	function __construct($verb = FALSE, $le = FALSE) {
31 31
 		parent::__construct(false, $verb, $le);
32 32
 	}
33 33
 
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 // <!-- --------------------------------------------------------------------------------------- -->
37 37
 
38 38
 	function _settimeout($sock) {
39
-		if(!@stream_set_timeout($sock, $this->_timeout)) {
40
-			$this->PushError('_settimeout','socket set send timeout');
39
+		if ( ! @stream_set_timeout($sock, $this->_timeout)) {
40
+			$this->PushError('_settimeout', 'socket set send timeout');
41 41
 			$this->_quit();
42 42
 			return FALSE;
43 43
 		}
@@ -47,72 +47,72 @@  discard block
 block discarded – undo
47 47
 	function _connect($host, $port) {
48 48
 		$this->SendMSG("Creating socket");
49 49
 		$sock = @fsockopen($host, $port, $errno, $errstr, $this->_timeout);
50
-		if (!$sock) {
51
-			$this->PushError('_connect','socket connect failed', $errstr." (".$errno.")");
50
+		if ( ! $sock) {
51
+			$this->PushError('_connect', 'socket connect failed', $errstr." (".$errno.")");
52 52
 			return FALSE;
53 53
 		}
54
-		$this->_connected=true;
54
+		$this->_connected = true;
55 55
 		return $sock;
56 56
 	}
57 57
 
58
-	function _readmsg($fnction="_readmsg"){
59
-		if(!$this->_connected) {
58
+	function _readmsg($fnction = "_readmsg") {
59
+		if ( ! $this->_connected) {
60 60
 			$this->PushError($fnction, 'Connect first');
61 61
 			return FALSE;
62 62
 		}
63
-		$result=true;
64
-		$this->_message="";
65
-		$this->_code=0;
66
-		$go=true;
63
+		$result = true;
64
+		$this->_message = "";
65
+		$this->_code = 0;
66
+		$go = true;
67 67
 		do {
68
-			$tmp=@fgets($this->_ftp_control_sock, 512);
69
-			if($tmp===false) {
70
-				$go=$result=false;
71
-				$this->PushError($fnction,'Read failed');
68
+			$tmp = @fgets($this->_ftp_control_sock, 512);
69
+			if ($tmp === false) {
70
+				$go = $result = false;
71
+				$this->PushError($fnction, 'Read failed');
72 72
 			} else {
73
-				$this->_message.=$tmp;
74
-				if(preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) $go=false;
73
+				$this->_message .= $tmp;
74
+				if (preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) $go = false;
75 75
 			}
76
-		} while($go);
77
-		if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
78
-		$this->_code=(int)$regs[1];
76
+		} while ($go);
77
+		if ($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
78
+		$this->_code = (int) $regs[1];
79 79
 		return $result;
80 80
 	}
81 81
 
82
-	function _exec($cmd, $fnction="_exec") {
83
-		if(!$this->_ready) {
84
-			$this->PushError($fnction,'Connect first');
82
+	function _exec($cmd, $fnction = "_exec") {
83
+		if ( ! $this->_ready) {
84
+			$this->PushError($fnction, 'Connect first');
85 85
 			return FALSE;
86 86
 		}
87
-		if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
88
-		$status=@fputs($this->_ftp_control_sock, $cmd.CRLF);
89
-		if($status===false) {
90
-			$this->PushError($fnction,'socket write failed');
87
+		if ($this->LocalEcho) echo "PUT > ", $cmd, CRLF;
88
+		$status = @fputs($this->_ftp_control_sock, $cmd.CRLF);
89
+		if ($status === false) {
90
+			$this->PushError($fnction, 'socket write failed');
91 91
 			return FALSE;
92 92
 		}
93
-		$this->_lastaction=time();
94
-		if(!$this->_readmsg($fnction)) return FALSE;
93
+		$this->_lastaction = time();
94
+		if ( ! $this->_readmsg($fnction)) return FALSE;
95 95
 		return TRUE;
96 96
 	}
97 97
 
98
-	function _data_prepare($mode=FTP_ASCII) {
99
-		if(!$this->_settype($mode)) return FALSE;
100
-		if($this->_passive) {
101
-			if(!$this->_exec("PASV", "pasv")) {
98
+	function _data_prepare($mode = FTP_ASCII) {
99
+		if ( ! $this->_settype($mode)) return FALSE;
100
+		if ($this->_passive) {
101
+			if ( ! $this->_exec("PASV", "pasv")) {
102 102
 				$this->_data_close();
103 103
 				return FALSE;
104 104
 			}
105
-			if(!$this->_checkCode()) {
105
+			if ( ! $this->_checkCode()) {
106 106
 				$this->_data_close();
107 107
 				return FALSE;
108 108
 			}
109 109
 			$ip_port = explode(",", preg_replace("/^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*$/s", "\\1", $this->_message));
110
-			$this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3];
111
-            $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]);
110
+			$this->_datahost = $ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3];
111
+            $this->_dataport = (((int) $ip_port[4]) << 8) + ((int) $ip_port[5]);
112 112
 			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
113
-			$this->_ftp_data_sock=@fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout);
114
-			if(!$this->_ftp_data_sock) {
115
-				$this->PushError("_data_prepare","fsockopen fails", $errstr." (".$errno.")");
113
+			$this->_ftp_data_sock = @fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout);
114
+			if ( ! $this->_ftp_data_sock) {
115
+				$this->PushError("_data_prepare", "fsockopen fails", $errstr." (".$errno.")");
116 116
 				$this->_data_close();
117 117
 				return FALSE;
118 118
 			}
@@ -124,47 +124,47 @@  discard block
 block discarded – undo
124 124
 		return TRUE;
125 125
 	}
126 126
 
127
-	function _data_read($mode=FTP_ASCII, $fp=NULL) {
128
-		if(is_resource($fp)) $out=0;
129
-		else $out="";
130
-		if(!$this->_passive) {
127
+	function _data_read($mode = FTP_ASCII, $fp = NULL) {
128
+		if (is_resource($fp)) $out = 0;
129
+		else $out = "";
130
+		if ( ! $this->_passive) {
131 131
 			$this->SendMSG("Only passive connections available!");
132 132
 			return FALSE;
133 133
 		}
134
-		while (!feof($this->_ftp_data_sock)) {
135
-			$block=fread($this->_ftp_data_sock, $this->_ftp_buff_size);
136
-			if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
137
-			if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block));
138
-			else $out.=$block;
134
+		while ( ! feof($this->_ftp_data_sock)) {
135
+			$block = fread($this->_ftp_data_sock, $this->_ftp_buff_size);
136
+			if ($mode != FTP_BINARY) $block = preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
137
+			if (is_resource($fp)) $out += fwrite($fp, $block, strlen($block));
138
+			else $out .= $block;
139 139
 		}
140 140
 		return $out;
141 141
 	}
142 142
 
143
-	function _data_write($mode=FTP_ASCII, $fp=NULL) {
144
-		if(is_resource($fp)) $out=0;
145
-		else $out="";
146
-		if(!$this->_passive) {
143
+	function _data_write($mode = FTP_ASCII, $fp = NULL) {
144
+		if (is_resource($fp)) $out = 0;
145
+		else $out = "";
146
+		if ( ! $this->_passive) {
147 147
 			$this->SendMSG("Only passive connections available!");
148 148
 			return FALSE;
149 149
 		}
150
-		if(is_resource($fp)) {
151
-			while(!feof($fp)) {
152
-				$block=fread($fp, $this->_ftp_buff_size);
153
-				if(!$this->_data_write_block($mode, $block)) return false;
150
+		if (is_resource($fp)) {
151
+			while ( ! feof($fp)) {
152
+				$block = fread($fp, $this->_ftp_buff_size);
153
+				if ( ! $this->_data_write_block($mode, $block)) return false;
154 154
 			}
155
-		} elseif(!$this->_data_write_block($mode, $fp)) return false;
155
+		} elseif ( ! $this->_data_write_block($mode, $fp)) return false;
156 156
 		return TRUE;
157 157
 	}
158 158
 
159 159
 	function _data_write_block($mode, $block) {
160
-		if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
160
+		if ($mode != FTP_BINARY) $block = preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
161 161
 		do {
162
-			if(($t=@fwrite($this->_ftp_data_sock, $block))===FALSE) {
163
-				$this->PushError("_data_write","Can't write to socket");
162
+			if (($t = @fwrite($this->_ftp_data_sock, $block)) === FALSE) {
163
+				$this->PushError("_data_write", "Can't write to socket");
164 164
 				return FALSE;
165 165
 			}
166
-			$block=substr($block, $t);
167
-		} while(!empty($block));
166
+			$block = substr($block, $t);
167
+		} while ( ! empty($block));
168 168
 		return true;
169 169
 	}
170 170
 
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 		return TRUE;
175 175
 	}
176 176
 
177
-	function _quit($force=FALSE) {
178
-		if($this->_connected or $force) {
177
+	function _quit($force = FALSE) {
178
+		if ($this->_connected or $force) {
179 179
 			@fclose($this->_ftp_control_sock);
180
-			$this->_connected=false;
180
+			$this->_connected = false;
181 181
 			$this->SendMSG("Socket closed");
182 182
 		}
183 183
 	}
Please login to merge, or discard this patch.
src/wp-admin/includes/class-ftp.php 4 patches
Doc Comments   +48 added lines patch added patch discarded remove patch
@@ -231,6 +231,9 @@  discard block
 block discarded – undo
231 231
 		return TRUE;
232 232
 	}
233 233
 
234
+	/**
235
+	 * @param integer $mode
236
+	 */
234 237
 	function SetType($mode=FTP_AUTOASCII) {
235 238
 		if(!in_array($mode, $this->AuthorizedTransferMode)) {
236 239
 			$this->SendMSG("Wrong type");
@@ -256,6 +259,9 @@  discard block
 block discarded – undo
256 259
 		return TRUE;
257 260
 	}
258 261
 
262
+	/**
263
+	 * @param boolean $pasv
264
+	 */
259 265
 	function Passive($pasv=NULL) {
260 266
 		if(is_null($pasv)) $this->_passive=!$this->_passive;
261 267
 		else $this->_passive=$pasv;
@@ -389,6 +395,9 @@  discard block
 block discarded – undo
389 395
 		return true;
390 396
 	}
391 397
 
398
+	/**
399
+	 * @param string $pathname
400
+	 */
392 401
 	function chdir($pathname) {
393 402
 		if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE;
394 403
 		if(!$this->_checkCode()) return FALSE;
@@ -407,6 +416,10 @@  discard block
 block discarded – undo
407 416
 		return TRUE;
408 417
 	}
409 418
 
419
+	/**
420
+	 * @param string $from
421
+	 * @param string $to
422
+	 */
410 423
 	function rename($from, $to) {
411 424
 		if(!$this->_exec("RNFR ".$from, "rename")) return FALSE;
412 425
 		if(!$this->_checkCode()) return FALSE;
@@ -417,6 +430,9 @@  discard block
 block discarded – undo
417 430
 		return TRUE;
418 431
 	}
419 432
 
433
+	/**
434
+	 * @param string $pathname
435
+	 */
420 436
 	function filesize($pathname) {
421 437
 		if(!isset($this->_features["SIZE"])) {
422 438
 			$this->PushError("filesize", "not supported by server");
@@ -437,6 +453,9 @@  discard block
 block discarded – undo
437 453
 		return true;
438 454
 	}
439 455
 
456
+	/**
457
+	 * @param string $pathname
458
+	 */
440 459
 	function mdtm($pathname) {
441 460
 		if(!isset($this->_features["MDTM"])) {
442 461
 			$this->PushError("mdtm", "not supported by server");
@@ -457,12 +476,18 @@  discard block
 block discarded – undo
457 476
 		return array($DATA[1], $DATA[3]);
458 477
 	}
459 478
 
479
+	/**
480
+	 * @param string $pathname
481
+	 */
460 482
 	function delete($pathname) {
461 483
 		if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE;
462 484
 		if(!$this->_checkCode()) return FALSE;
463 485
 		return TRUE;
464 486
 	}
465 487
 
488
+	/**
489
+	 * @param string $command
490
+	 */
466 491
 	function site($command, $fnction="site") {
467 492
 		if(!$this->_exec("SITE ".$command, $fnction)) return FALSE;
468 493
 		if(!$this->_checkCode()) return FALSE;
@@ -524,6 +549,9 @@  discard block
 block discarded – undo
524 549
 		return $exists;
525 550
 	}
526 551
 
552
+	/**
553
+	 * @param string $remotefile
554
+	 */
527 555
 	function fget($fp, $remotefile,$rest=0) {
528 556
 		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
529 557
 		$pi=pathinfo($remotefile);
@@ -548,6 +576,10 @@  discard block
 block discarded – undo
548 576
 		return $out;
549 577
 	}
550 578
 
579
+	/**
580
+	 * @param string $remotefile
581
+	 * @param string $localfile
582
+	 */
551 583
 	function get($remotefile, $localfile=NULL, $rest=0) {
552 584
 		if(is_null($localfile)) $localfile=$remotefile;
553 585
 		if (@file_exists($localfile)) $this->SendMSG("Warning : local file will be overwritten");
@@ -583,6 +615,9 @@  discard block
 block discarded – undo
583 615
 		return $out;
584 616
 	}
585 617
 
618
+	/**
619
+	 * @param string $remotefile
620
+	 */
586 621
 	function fput($remotefile, $fp) {
587 622
 		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
588 623
 		$pi=pathinfo($remotefile);
@@ -607,6 +642,9 @@  discard block
 block discarded – undo
607 642
 		return $ret;
608 643
 	}
609 644
 
645
+	/**
646
+	 * @param string $localfile
647
+	 */
610 648
 	function put($localfile, $remotefile=NULL, $rest=0) {
611 649
 		if(is_null($remotefile)) $remotefile=$localfile;
612 650
 		if (!file_exists($localfile)) {
@@ -718,6 +756,9 @@  discard block
 block discarded – undo
718 756
 		return $ret;
719 757
 	}
720 758
 
759
+	/**
760
+	 * @param string $remote
761
+	 */
721 762
 	function mdel($remote, $continious=false) {
722 763
 		$list=$this->rawlist($remote, "-la");
723 764
 		if($list===false) {
@@ -823,6 +864,9 @@  discard block
 block discarded – undo
823 864
 		);
824 865
 	}
825 866
 
867
+	/**
868
+	 * @param string $remote
869
+	 */
826 870
 	function dirlist($remote) {
827 871
 		$list=$this->rawlist($remote, "-la");
828 872
 		if($list===false) {
@@ -878,6 +922,10 @@  discard block
 block discarded – undo
878 922
 // <!-- Partie : gestion des erreurs                                                            -->
879 923
 // <!-- --------------------------------------------------------------------------------------- -->
880 924
 // Gnre une erreur pour traitement externe  la classe
925
+	/**
926
+	 * @param string $fctname
927
+	 * @param string $msg
928
+	 */
881 929
 	function PushError($fctname,$msg,$desc=false){
882 930
 		$error=array();
883 931
 		$error['time']=time();
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 		$this->_login="anonymous";
147 147
 		$this->_password="[email protected]";
148 148
 		$this->_features=array();
149
-	    $this->OS_local=FTP_OS_Unix;
149
+		$this->OS_local=FTP_OS_Unix;
150 150
 		$this->OS_remote=FTP_OS_Unix;
151 151
 		$this->features=array();
152 152
 		if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows;
@@ -270,25 +270,25 @@  discard block
 block discarded – undo
270 270
 
271 271
 	function SetServer($host, $port=21, $reconnect=true) {
272 272
 		if(!is_long($port)) {
273
-	        $this->verbose=true;
274
-    	    $this->SendMSG("Incorrect port syntax");
273
+			$this->verbose=true;
274
+			$this->SendMSG("Incorrect port syntax");
275 275
 			return FALSE;
276 276
 		} else {
277 277
 			$ip=@gethostbyname($host);
278
-	        $dns=@gethostbyaddr($host);
279
-	        if(!$ip) $ip=$host;
280
-	        if(!$dns) $dns=$host;
281
-	        // Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false
282
-	        // -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid
283
-	        $ipaslong = ip2long($ip);
278
+			$dns=@gethostbyaddr($host);
279
+			if(!$ip) $ip=$host;
280
+			if(!$dns) $dns=$host;
281
+			// Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false
282
+			// -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid
283
+			$ipaslong = ip2long($ip);
284 284
 			if ( ($ipaslong == false) || ($ipaslong === -1) ) {
285 285
 				$this->SendMSG("Wrong host name/address \"".$host."\"");
286 286
 				return FALSE;
287 287
 			}
288
-	        $this->_host=$ip;
289
-	        $this->_fullhost=$dns;
290
-	        $this->_port=$port;
291
-	        $this->_dataport=$port-1;
288
+			$this->_host=$ip;
289
+			$this->_fullhost=$dns;
290
+			$this->_port=$port;
291
+			$this->_dataport=$port-1;
292 292
 		}
293 293
 		$this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\"");
294 294
 		if($reconnect){
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			if(!$this->SetServer($server)) return false;
322 322
 		}
323 323
 		if($this->_ready) return true;
324
-	    $this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]);
324
+		$this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]);
325 325
 		if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) {
326 326
 			$this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\"");
327 327
 			return FALSE;
Please login to merge, or discard this patch.
Braces   +434 added lines, -168 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
  * @since 2.5
21 21
  * @var string
22 22
  */
23
-if(!defined('CRLF')) define('CRLF',"\r\n");
23
+if(!defined('CRLF')) {
24
+	define('CRLF',"\r\n");
25
+}
24 26
 
25 27
 /**
26 28
  * Sets whatever to autodetect ASCII mode.
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
  * @since 2.5
31 33
  * @var int
32 34
  */
33
-if(!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1);
35
+if(!defined("FTP_AUTOASCII")) {
36
+	define("FTP_AUTOASCII", -1);
37
+}
34 38
 
35 39
 /**
36 40
  *
@@ -38,7 +42,9 @@  discard block
 block discarded – undo
38 42
  * @since 2.5
39 43
  * @var int
40 44
  */
41
-if(!defined("FTP_BINARY")) define("FTP_BINARY", 1);
45
+if(!defined("FTP_BINARY")) {
46
+	define("FTP_BINARY", 1);
47
+}
42 48
 
43 49
 /**
44 50
  *
@@ -46,7 +52,9 @@  discard block
 block discarded – undo
46 52
  * @since 2.5
47 53
  * @var int
48 54
  */
49
-if(!defined("FTP_ASCII")) define("FTP_ASCII", 0);
55
+if(!defined("FTP_ASCII")) {
56
+	define("FTP_ASCII", 0);
57
+}
50 58
 
51 59
 /**
52 60
  * Whether to force FTP.
@@ -56,7 +64,9 @@  discard block
 block discarded – undo
56 64
  * @since 2.5
57 65
  * @var bool
58 66
  */
59
-if(!defined('FTP_FORCE')) define('FTP_FORCE', true);
67
+if(!defined('FTP_FORCE')) {
68
+	define('FTP_FORCE', true);
69
+}
60 70
 
61 71
 /**
62 72
  * @since 2.5
@@ -149,8 +159,11 @@  discard block
 block discarded – undo
149 159
 	    $this->OS_local=FTP_OS_Unix;
150 160
 		$this->OS_remote=FTP_OS_Unix;
151 161
 		$this->features=array();
152
-		if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows;
153
-		elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac;
162
+		if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
163
+			$this->OS_local=FTP_OS_Windows;
164
+		} elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') {
165
+			$this->OS_local=FTP_OS_Mac;
166
+		}
154 167
 	}
155 168
 
156 169
 	function ftp_base($port_mode=FALSE) {
@@ -167,10 +180,11 @@  discard block
 block discarded – undo
167 180
 			$b = array();
168 181
 			if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix
169 182
 			$b['isdir'] = ($lucifer[7]=="<DIR>");
170
-			if ( $b['isdir'] )
171
-				$b['type'] = 'd';
172
-			else
173
-				$b['type'] = 'f';
183
+			if ( $b['isdir'] ) {
184
+							$b['type'] = 'd';
185
+			} else {
186
+							$b['type'] = 'f';
187
+			}
174 188
 			$b['size'] = $lucifer[7];
175 189
 			$b['month'] = $lucifer[1];
176 190
 			$b['day'] = $lucifer[2];
@@ -183,16 +197,19 @@  discard block
 block discarded – undo
183 197
 		} else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) {
184 198
 			//echo $line."\n";
185 199
 			$lcount=count($lucifer);
186
-			if ($lcount<8) return '';
200
+			if ($lcount<8) {
201
+				return '';
202
+			}
187 203
 			$b = array();
188 204
 			$b['isdir'] = $lucifer[0]{0} === "d";
189 205
 			$b['islink'] = $lucifer[0]{0} === "l";
190
-			if ( $b['isdir'] )
191
-				$b['type'] = 'd';
192
-			elseif ( $b['islink'] )
193
-				$b['type'] = 'l';
194
-			else
195
-				$b['type'] = 'f';
206
+			if ( $b['isdir'] ) {
207
+							$b['type'] = 'd';
208
+			} elseif ( $b['islink'] ) {
209
+							$b['type'] = 'l';
210
+			} else {
211
+							$b['type'] = 'f';
212
+			}
196 213
 			$b['perms'] = $lucifer[0];
197 214
 			$b['number'] = $lucifer[1];
198 215
 			$b['owner'] = $lucifer[2];
@@ -245,20 +262,29 @@  discard block
 block discarded – undo
245 262
 		if($this->_ready) {
246 263
 			if($mode==FTP_BINARY) {
247 264
 				if($this->_curtype!=FTP_BINARY) {
248
-					if(!$this->_exec("TYPE I", "SetType")) return FALSE;
265
+					if(!$this->_exec("TYPE I", "SetType")) {
266
+						return FALSE;
267
+					}
249 268
 					$this->_curtype=FTP_BINARY;
250 269
 				}
251 270
 			} elseif($this->_curtype!=FTP_ASCII) {
252
-				if(!$this->_exec("TYPE A", "SetType")) return FALSE;
271
+				if(!$this->_exec("TYPE A", "SetType")) {
272
+					return FALSE;
273
+				}
253 274
 				$this->_curtype=FTP_ASCII;
254 275
 			}
255
-		} else return FALSE;
276
+		} else {
277
+			return FALSE;
278
+		}
256 279
 		return TRUE;
257 280
 	}
258 281
 
259 282
 	function Passive($pasv=NULL) {
260
-		if(is_null($pasv)) $this->_passive=!$this->_passive;
261
-		else $this->_passive=$pasv;
283
+		if(is_null($pasv)) {
284
+			$this->_passive=!$this->_passive;
285
+		} else {
286
+			$this->_passive=$pasv;
287
+		}
262 288
 		if(!$this->_port_available and !$this->_passive) {
263 289
 			$this->SendMSG("Only passive connections available!");
264 290
 			$this->_passive=TRUE;
@@ -276,8 +302,12 @@  discard block
 block discarded – undo
276 302
 		} else {
277 303
 			$ip=@gethostbyname($host);
278 304
 	        $dns=@gethostbyaddr($host);
279
-	        if(!$ip) $ip=$host;
280
-	        if(!$dns) $dns=$host;
305
+	        if(!$ip) {
306
+	        	$ip=$host;
307
+	        }
308
+	        if(!$dns) {
309
+	        	$dns=$host;
310
+	        }
281 311
 	        // Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false
282 312
 	        // -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid
283 313
 	        $ipaslong = ip2long($ip);
@@ -294,8 +324,12 @@  discard block
 block discarded – undo
294 324
 		if($reconnect){
295 325
 			if($this->_connected) {
296 326
 				$this->SendMSG("Reconnecting");
297
-				if(!$this->quit(FTP_FORCE)) return FALSE;
298
-				if(!$this->connect()) return FALSE;
327
+				if(!$this->quit(FTP_FORCE)) {
328
+					return FALSE;
329
+				}
330
+				if(!$this->connect()) {
331
+					return FALSE;
332
+				}
299 333
 			}
300 334
 		}
301 335
 		return TRUE;
@@ -311,16 +345,21 @@  discard block
 block discarded – undo
311 345
 	function SetTimeout($timeout=30) {
312 346
 		$this->_timeout=$timeout;
313 347
 		$this->SendMSG("Timeout ".$this->_timeout);
314
-		if($this->_connected)
315
-			if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE;
348
+		if($this->_connected) {
349
+					if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE;
350
+		}
316 351
 		return TRUE;
317 352
 	}
318 353
 
319 354
 	function connect($server=NULL) {
320 355
 		if(!empty($server)) {
321
-			if(!$this->SetServer($server)) return false;
356
+			if(!$this->SetServer($server)) {
357
+				return false;
358
+			}
359
+		}
360
+		if($this->_ready) {
361
+			return true;
322 362
 		}
323
-		if($this->_ready) return true;
324 363
 	    $this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]);
325 364
 		if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) {
326 365
 			$this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\"");
@@ -328,29 +367,46 @@  discard block
 block discarded – undo
328 367
 		}
329 368
 		$this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting.");
330 369
 		do {
331
-			if(!$this->_readmsg()) return FALSE;
332
-			if(!$this->_checkCode()) return FALSE;
370
+			if(!$this->_readmsg()) {
371
+				return FALSE;
372
+			}
373
+			if(!$this->_checkCode()) {
374
+				return FALSE;
375
+			}
333 376
 			$this->_lastaction=time();
334 377
 		} while($this->_code<200);
335 378
 		$this->_ready=true;
336 379
 		$syst=$this->systype();
337
-		if(!$syst) $this->SendMSG("Can't detect remote OS");
338
-		else {
339
-			if(preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote=FTP_OS_Windows;
340
-			elseif(preg_match("/os/i", $syst[0])) $this->OS_remote=FTP_OS_Mac;
341
-			elseif(preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote=FTP_OS_Unix;
342
-			else $this->OS_remote=FTP_OS_Mac;
380
+		if(!$syst) {
381
+			$this->SendMSG("Can't detect remote OS");
382
+		} else {
383
+			if(preg_match("/win|dos|novell/i", $syst[0])) {
384
+				$this->OS_remote=FTP_OS_Windows;
385
+			} elseif(preg_match("/os/i", $syst[0])) {
386
+				$this->OS_remote=FTP_OS_Mac;
387
+			} elseif(preg_match("/(li|u)nix/i", $syst[0])) {
388
+				$this->OS_remote=FTP_OS_Unix;
389
+			} else {
390
+				$this->OS_remote=FTP_OS_Mac;
391
+			}
343 392
 			$this->SendMSG("Remote OS: ".$this->OS_FullName[$this->OS_remote]);
344 393
 		}
345
-		if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled");
346
-		else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features)));
394
+		if(!$this->features()) {
395
+			$this->SendMSG("Can't get features list. All supported - disabled");
396
+		} else {
397
+			$this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features)));
398
+		}
347 399
 		return TRUE;
348 400
 	}
349 401
 
350 402
 	function quit($force=false) {
351 403
 		if($this->_ready) {
352
-			if(!$this->_exec("QUIT") and !$force) return FALSE;
353
-			if(!$this->_checkCode() and !$force) return FALSE;
404
+			if(!$this->_exec("QUIT") and !$force) {
405
+				return FALSE;
406
+			}
407
+			if(!$this->_checkCode() and !$force) {
408
+				return FALSE;
409
+			}
354 410
 			$this->_ready=false;
355 411
 			$this->SendMSG("Session finished");
356 412
 		}
@@ -359,61 +415,108 @@  discard block
 block discarded – undo
359 415
 	}
360 416
 
361 417
 	function login($user=NULL, $pass=NULL) {
362
-		if(!is_null($user)) $this->_login=$user;
363
-		else $this->_login="anonymous";
364
-		if(!is_null($pass)) $this->_password=$pass;
365
-		else $this->_password="[email protected]";
366
-		if(!$this->_exec("USER ".$this->_login, "login")) return FALSE;
367
-		if(!$this->_checkCode()) return FALSE;
418
+		if(!is_null($user)) {
419
+			$this->_login=$user;
420
+		} else {
421
+			$this->_login="anonymous";
422
+		}
423
+		if(!is_null($pass)) {
424
+			$this->_password=$pass;
425
+		} else {
426
+			$this->_password="[email protected]";
427
+		}
428
+		if(!$this->_exec("USER ".$this->_login, "login")) {
429
+			return FALSE;
430
+		}
431
+		if(!$this->_checkCode()) {
432
+			return FALSE;
433
+		}
368 434
 		if($this->_code!=230) {
369
-			if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) return FALSE;
370
-			if(!$this->_checkCode()) return FALSE;
435
+			if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) {
436
+				return FALSE;
437
+			}
438
+			if(!$this->_checkCode()) {
439
+				return FALSE;
440
+			}
371 441
 		}
372 442
 		$this->SendMSG("Authentication succeeded");
373 443
 		if(empty($this->_features)) {
374
-			if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled");
375
-			else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features)));
444
+			if(!$this->features()) {
445
+				$this->SendMSG("Can't get features list. All supported - disabled");
446
+			} else {
447
+				$this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features)));
448
+			}
376 449
 		}
377 450
 		return TRUE;
378 451
 	}
379 452
 
380 453
 	function pwd() {
381
-		if(!$this->_exec("PWD", "pwd")) return FALSE;
382
-		if(!$this->_checkCode()) return FALSE;
454
+		if(!$this->_exec("PWD", "pwd")) {
455
+			return FALSE;
456
+		}
457
+		if(!$this->_checkCode()) {
458
+			return FALSE;
459
+		}
383 460
 		return preg_replace("/^[0-9]{3} \"(.+)\".*$/s", "\\1", $this->_message);
384 461
 	}
385 462
 
386 463
 	function cdup() {
387
-		if(!$this->_exec("CDUP", "cdup")) return FALSE;
388
-		if(!$this->_checkCode()) return FALSE;
464
+		if(!$this->_exec("CDUP", "cdup")) {
465
+			return FALSE;
466
+		}
467
+		if(!$this->_checkCode()) {
468
+			return FALSE;
469
+		}
389 470
 		return true;
390 471
 	}
391 472
 
392 473
 	function chdir($pathname) {
393
-		if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE;
394
-		if(!$this->_checkCode()) return FALSE;
474
+		if(!$this->_exec("CWD ".$pathname, "chdir")) {
475
+			return FALSE;
476
+		}
477
+		if(!$this->_checkCode()) {
478
+			return FALSE;
479
+		}
395 480
 		return TRUE;
396 481
 	}
397 482
 
398 483
 	function rmdir($pathname) {
399
-		if(!$this->_exec("RMD ".$pathname, "rmdir")) return FALSE;
400
-		if(!$this->_checkCode()) return FALSE;
484
+		if(!$this->_exec("RMD ".$pathname, "rmdir")) {
485
+			return FALSE;
486
+		}
487
+		if(!$this->_checkCode()) {
488
+			return FALSE;
489
+		}
401 490
 		return TRUE;
402 491
 	}
403 492
 
404 493
 	function mkdir($pathname) {
405
-		if(!$this->_exec("MKD ".$pathname, "mkdir")) return FALSE;
406
-		if(!$this->_checkCode()) return FALSE;
494
+		if(!$this->_exec("MKD ".$pathname, "mkdir")) {
495
+			return FALSE;
496
+		}
497
+		if(!$this->_checkCode()) {
498
+			return FALSE;
499
+		}
407 500
 		return TRUE;
408 501
 	}
409 502
 
410 503
 	function rename($from, $to) {
411
-		if(!$this->_exec("RNFR ".$from, "rename")) return FALSE;
412
-		if(!$this->_checkCode()) return FALSE;
504
+		if(!$this->_exec("RNFR ".$from, "rename")) {
505
+			return FALSE;
506
+		}
507
+		if(!$this->_checkCode()) {
508
+			return FALSE;
509
+		}
413 510
 		if($this->_code==350) {
414
-			if(!$this->_exec("RNTO ".$to, "rename")) return FALSE;
415
-			if(!$this->_checkCode()) return FALSE;
416
-		} else return FALSE;
511
+			if(!$this->_exec("RNTO ".$to, "rename")) {
512
+				return FALSE;
513
+			}
514
+			if(!$this->_checkCode()) {
515
+				return FALSE;
516
+			}
517
+		} else {
518
+			return FALSE;
519
+		}
417 520
 		return TRUE;
418 521
 	}
419 522
 
@@ -422,17 +525,29 @@  discard block
 block discarded – undo
422 525
 			$this->PushError("filesize", "not supported by server");
423 526
 			return FALSE;
424 527
 		}
425
-		if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE;
426
-		if(!$this->_checkCode()) return FALSE;
528
+		if(!$this->_exec("SIZE ".$pathname, "filesize")) {
529
+			return FALSE;
530
+		}
531
+		if(!$this->_checkCode()) {
532
+			return FALSE;
533
+		}
427 534
 		return preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message);
428 535
 	}
429 536
 
430 537
 	function abort() {
431
-		if(!$this->_exec("ABOR", "abort")) return FALSE;
538
+		if(!$this->_exec("ABOR", "abort")) {
539
+			return FALSE;
540
+		}
432 541
 		if(!$this->_checkCode()) {
433
-			if($this->_code!=426) return FALSE;
434
-			if(!$this->_readmsg("abort")) return FALSE;
435
-			if(!$this->_checkCode()) return FALSE;
542
+			if($this->_code!=426) {
543
+				return FALSE;
544
+			}
545
+			if(!$this->_readmsg("abort")) {
546
+				return FALSE;
547
+			}
548
+			if(!$this->_checkCode()) {
549
+				return FALSE;
550
+			}
436 551
 		}
437 552
 		return true;
438 553
 	}
@@ -442,8 +557,12 @@  discard block
 block discarded – undo
442 557
 			$this->PushError("mdtm", "not supported by server");
443 558
 			return FALSE;
444 559
 		}
445
-		if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE;
446
-		if(!$this->_checkCode()) return FALSE;
560
+		if(!$this->_exec("MDTM ".$pathname, "mdtm")) {
561
+			return FALSE;
562
+		}
563
+		if(!$this->_checkCode()) {
564
+			return FALSE;
565
+		}
447 566
 		$mdtm = preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message);
448 567
 		$date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d");
449 568
 		$timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]);
@@ -451,26 +570,40 @@  discard block
 block discarded – undo
451 570
 	}
452 571
 
453 572
 	function systype() {
454
-		if(!$this->_exec("SYST", "systype")) return FALSE;
455
-		if(!$this->_checkCode()) return FALSE;
573
+		if(!$this->_exec("SYST", "systype")) {
574
+			return FALSE;
575
+		}
576
+		if(!$this->_checkCode()) {
577
+			return FALSE;
578
+		}
456 579
 		$DATA = explode(" ", $this->_message);
457 580
 		return array($DATA[1], $DATA[3]);
458 581
 	}
459 582
 
460 583
 	function delete($pathname) {
461
-		if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE;
462
-		if(!$this->_checkCode()) return FALSE;
584
+		if(!$this->_exec("DELE ".$pathname, "delete")) {
585
+			return FALSE;
586
+		}
587
+		if(!$this->_checkCode()) {
588
+			return FALSE;
589
+		}
463 590
 		return TRUE;
464 591
 	}
465 592
 
466 593
 	function site($command, $fnction="site") {
467
-		if(!$this->_exec("SITE ".$command, $fnction)) return FALSE;
468
-		if(!$this->_checkCode()) return FALSE;
594
+		if(!$this->_exec("SITE ".$command, $fnction)) {
595
+			return FALSE;
596
+		}
597
+		if(!$this->_checkCode()) {
598
+			return FALSE;
599
+		}
469 600
 		return TRUE;
470 601
 	}
471 602
 
472 603
 	function chmod($pathname, $mode) {
473
-		if(!$this->site( sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) return FALSE;
604
+		if(!$this->site( sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) {
605
+			return FALSE;
606
+		}
474 607
 		return TRUE;
475 608
 	}
476 609
 
@@ -483,14 +616,22 @@  discard block
 block discarded – undo
483 616
 			$this->PushError("restore", "can't restore in ASCII mode");
484 617
 			return FALSE;
485 618
 		}
486
-		if(!$this->_exec("REST ".$from, "resore")) return FALSE;
487
-		if(!$this->_checkCode()) return FALSE;
619
+		if(!$this->_exec("REST ".$from, "resore")) {
620
+			return FALSE;
621
+		}
622
+		if(!$this->_checkCode()) {
623
+			return FALSE;
624
+		}
488 625
 		return TRUE;
489 626
 	}
490 627
 
491 628
 	function features() {
492
-		if(!$this->_exec("FEAT", "features")) return FALSE;
493
-		if(!$this->_checkCode()) return FALSE;
629
+		if(!$this->_exec("FEAT", "features")) {
630
+			return FALSE;
631
+		}
632
+		if(!$this->_checkCode()) {
633
+			return FALSE;
634
+		}
494 635
 		$f=preg_split("/[".CRLF."]+/", preg_replace("/[0-9]{3}[ -].*[".CRLF."]+/", "", $this->_message), -1, PREG_SPLIT_NO_EMPTY);
495 636
 		$this->_features=array();
496 637
 		foreach($f as $k=>$v) {
@@ -514,25 +655,38 @@  discard block
 block discarded – undo
514 655
 
515 656
 	function file_exists($pathname) {
516 657
 		$exists=true;
517
-		if(!$this->_exec("RNFR ".$pathname, "rename")) $exists=FALSE;
518
-		else {
519
-			if(!$this->_checkCode()) $exists=FALSE;
658
+		if(!$this->_exec("RNFR ".$pathname, "rename")) {
659
+			$exists=FALSE;
660
+		} else {
661
+			if(!$this->_checkCode()) {
662
+				$exists=FALSE;
663
+			}
520 664
 			$this->abort();
521 665
 		}
522
-		if($exists) $this->SendMSG("Remote file ".$pathname." exists");
523
-		else $this->SendMSG("Remote file ".$pathname." does not exist");
666
+		if($exists) {
667
+			$this->SendMSG("Remote file ".$pathname." exists");
668
+		} else {
669
+			$this->SendMSG("Remote file ".$pathname." does not exist");
670
+		}
524 671
 		return $exists;
525 672
 	}
526 673
 
527 674
 	function fget($fp, $remotefile,$rest=0) {
528
-		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
675
+		if($this->_can_restore and $rest!=0) {
676
+			fseek($fp, $rest);
677
+		}
529 678
 		$pi=pathinfo($remotefile);
530
-		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
531
-		else $mode=FTP_BINARY;
679
+		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) {
680
+			$mode=FTP_ASCII;
681
+		} else {
682
+			$mode=FTP_BINARY;
683
+		}
532 684
 		if(!$this->_data_prepare($mode)) {
533 685
 			return FALSE;
534 686
 		}
535
-		if($this->_can_restore and $rest!=0) $this->restore($rest);
687
+		if($this->_can_restore and $rest!=0) {
688
+			$this->restore($rest);
689
+		}
536 690
 		if(!$this->_exec("RETR ".$remotefile, "get")) {
537 691
 			$this->_data_close();
538 692
 			return FALSE;
@@ -543,28 +697,43 @@  discard block
 block discarded – undo
543 697
 		}
544 698
 		$out=$this->_data_read($mode, $fp);
545 699
 		$this->_data_close();
546
-		if(!$this->_readmsg()) return FALSE;
547
-		if(!$this->_checkCode()) return FALSE;
700
+		if(!$this->_readmsg()) {
701
+			return FALSE;
702
+		}
703
+		if(!$this->_checkCode()) {
704
+			return FALSE;
705
+		}
548 706
 		return $out;
549 707
 	}
550 708
 
551 709
 	function get($remotefile, $localfile=NULL, $rest=0) {
552
-		if(is_null($localfile)) $localfile=$remotefile;
553
-		if (@file_exists($localfile)) $this->SendMSG("Warning : local file will be overwritten");
710
+		if(is_null($localfile)) {
711
+			$localfile=$remotefile;
712
+		}
713
+		if (@file_exists($localfile)) {
714
+			$this->SendMSG("Warning : local file will be overwritten");
715
+		}
554 716
 		$fp = @fopen($localfile, "w");
555 717
 		if (!$fp) {
556 718
 			$this->PushError("get","can't open local file", "Cannot create \"".$localfile."\"");
557 719
 			return FALSE;
558 720
 		}
559
-		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
721
+		if($this->_can_restore and $rest!=0) {
722
+			fseek($fp, $rest);
723
+		}
560 724
 		$pi=pathinfo($remotefile);
561
-		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
562
-		else $mode=FTP_BINARY;
725
+		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) {
726
+			$mode=FTP_ASCII;
727
+		} else {
728
+			$mode=FTP_BINARY;
729
+		}
563 730
 		if(!$this->_data_prepare($mode)) {
564 731
 			fclose($fp);
565 732
 			return FALSE;
566 733
 		}
567
-		if($this->_can_restore and $rest!=0) $this->restore($rest);
734
+		if($this->_can_restore and $rest!=0) {
735
+			$this->restore($rest);
736
+		}
568 737
 		if(!$this->_exec("RETR ".$remotefile, "get")) {
569 738
 			$this->_data_close();
570 739
 			fclose($fp);
@@ -578,20 +747,31 @@  discard block
 block discarded – undo
578 747
 		$out=$this->_data_read($mode, $fp);
579 748
 		fclose($fp);
580 749
 		$this->_data_close();
581
-		if(!$this->_readmsg()) return FALSE;
582
-		if(!$this->_checkCode()) return FALSE;
750
+		if(!$this->_readmsg()) {
751
+			return FALSE;
752
+		}
753
+		if(!$this->_checkCode()) {
754
+			return FALSE;
755
+		}
583 756
 		return $out;
584 757
 	}
585 758
 
586 759
 	function fput($remotefile, $fp) {
587
-		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
760
+		if($this->_can_restore and $rest!=0) {
761
+			fseek($fp, $rest);
762
+		}
588 763
 		$pi=pathinfo($remotefile);
589
-		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
590
-		else $mode=FTP_BINARY;
764
+		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) {
765
+			$mode=FTP_ASCII;
766
+		} else {
767
+			$mode=FTP_BINARY;
768
+		}
591 769
 		if(!$this->_data_prepare($mode)) {
592 770
 			return FALSE;
593 771
 		}
594
-		if($this->_can_restore and $rest!=0) $this->restore($rest);
772
+		if($this->_can_restore and $rest!=0) {
773
+			$this->restore($rest);
774
+		}
595 775
 		if(!$this->_exec("STOR ".$remotefile, "put")) {
596 776
 			$this->_data_close();
597 777
 			return FALSE;
@@ -602,13 +782,19 @@  discard block
 block discarded – undo
602 782
 		}
603 783
 		$ret=$this->_data_write($mode, $fp);
604 784
 		$this->_data_close();
605
-		if(!$this->_readmsg()) return FALSE;
606
-		if(!$this->_checkCode()) return FALSE;
785
+		if(!$this->_readmsg()) {
786
+			return FALSE;
787
+		}
788
+		if(!$this->_checkCode()) {
789
+			return FALSE;
790
+		}
607 791
 		return $ret;
608 792
 	}
609 793
 
610 794
 	function put($localfile, $remotefile=NULL, $rest=0) {
611
-		if(is_null($remotefile)) $remotefile=$localfile;
795
+		if(is_null($remotefile)) {
796
+			$remotefile=$localfile;
797
+		}
612 798
 		if (!file_exists($localfile)) {
613 799
 			$this->PushError("put","can't open local file", "No such file or directory \"".$localfile."\"");
614 800
 			return FALSE;
@@ -619,15 +805,22 @@  discard block
 block discarded – undo
619 805
 			$this->PushError("put","can't open local file", "Cannot read file \"".$localfile."\"");
620 806
 			return FALSE;
621 807
 		}
622
-		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
808
+		if($this->_can_restore and $rest!=0) {
809
+			fseek($fp, $rest);
810
+		}
623 811
 		$pi=pathinfo($localfile);
624
-		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
625
-		else $mode=FTP_BINARY;
812
+		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) {
813
+			$mode=FTP_ASCII;
814
+		} else {
815
+			$mode=FTP_BINARY;
816
+		}
626 817
 		if(!$this->_data_prepare($mode)) {
627 818
 			fclose($fp);
628 819
 			return FALSE;
629 820
 		}
630
-		if($this->_can_restore and $rest!=0) $this->restore($rest);
821
+		if($this->_can_restore and $rest!=0) {
822
+			$this->restore($rest);
823
+		}
631 824
 		if(!$this->_exec("STOR ".$remotefile, "put")) {
632 825
 			$this->_data_close();
633 826
 			fclose($fp);
@@ -641,8 +834,12 @@  discard block
 block discarded – undo
641 834
 		$ret=$this->_data_write($mode, $fp);
642 835
 		fclose($fp);
643 836
 		$this->_data_close();
644
-		if(!$this->_readmsg()) return FALSE;
645
-		if(!$this->_checkCode()) return FALSE;
837
+		if(!$this->_readmsg()) {
838
+			return FALSE;
839
+		}
840
+		if(!$this->_checkCode()) {
841
+			return FALSE;
842
+		}
646 843
 		return $ret;
647 844
 	}
648 845
 
@@ -652,27 +849,41 @@  discard block
 block discarded – undo
652 849
 			$this->PushError("mput","can't open local folder", "Cannot stat folder \"".$local."\"");
653 850
 			return FALSE;
654 851
 		}
655
-		if(!is_dir($local)) return $this->put($local, $remote);
656
-		if(empty($remote)) $remote=".";
657
-		elseif(!$this->file_exists($remote) and !$this->mkdir($remote)) return FALSE;
852
+		if(!is_dir($local)) {
853
+			return $this->put($local, $remote);
854
+		}
855
+		if(empty($remote)) {
856
+			$remote=".";
857
+		} elseif(!$this->file_exists($remote) and !$this->mkdir($remote)) {
858
+			return FALSE;
859
+		}
658 860
 		if($handle = opendir($local)) {
659 861
 			$list=array();
660 862
 			while (false !== ($file = readdir($handle))) {
661
-				if ($file != "." && $file != "..") $list[]=$file;
863
+				if ($file != "." && $file != "..") {
864
+					$list[]=$file;
865
+				}
662 866
 			}
663 867
 			closedir($handle);
664 868
 		} else {
665 869
 			$this->PushError("mput","can't open local folder", "Cannot read folder \"".$local."\"");
666 870
 			return FALSE;
667 871
 		}
668
-		if(empty($list)) return TRUE;
872
+		if(empty($list)) {
873
+			return TRUE;
874
+		}
669 875
 		$ret=true;
670 876
 		foreach($list as $el) {
671
-			if(is_dir($local."/".$el)) $t=$this->mput($local."/".$el, $remote."/".$el);
672
-			else $t=$this->put($local."/".$el, $remote."/".$el);
877
+			if(is_dir($local."/".$el)) {
878
+				$t=$this->mput($local."/".$el, $remote."/".$el);
879
+			} else {
880
+				$t=$this->put($local."/".$el, $remote."/".$el);
881
+			}
673 882
 			if(!$t) {
674 883
 				$ret=FALSE;
675
-				if(!$continious) break;
884
+				if(!$continious) {
885
+					break;
886
+				}
676 887
 			}
677 888
 		}
678 889
 		return $ret;
@@ -685,7 +896,9 @@  discard block
 block discarded – undo
685 896
 			$this->PushError("mget","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
686 897
 			return FALSE;
687 898
 		}
688
-		if(empty($list)) return true;
899
+		if(empty($list)) {
900
+			return true;
901
+		}
689 902
 		if(!@file_exists($local)) {
690 903
 			if(!@mkdir($local)) {
691 904
 				$this->PushError("mget","can't create local folder", "Cannot create folder \"".$local."\"");
@@ -694,7 +907,9 @@  discard block
 block discarded – undo
694 907
 		}
695 908
 		foreach($list as $k=>$v) {
696 909
 			$list[$k]=$this->parselisting($v);
697
-			if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]);
910
+			if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") {
911
+				unset($list[$k]);
912
+			}
698 913
 		}
699 914
 		$ret=true;
700 915
 		foreach($list as $el) {
@@ -702,18 +917,24 @@  discard block
 block discarded – undo
702 917
 				if(!$this->mget($remote."/".$el["name"], $local."/".$el["name"], $continious)) {
703 918
 					$this->PushError("mget", "can't copy folder", "Can't copy remote folder \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\"");
704 919
 					$ret=false;
705
-					if(!$continious) break;
920
+					if(!$continious) {
921
+						break;
922
+					}
706 923
 				}
707 924
 			} else {
708 925
 				if(!$this->get($remote."/".$el["name"], $local."/".$el["name"])) {
709 926
 					$this->PushError("mget", "can't copy file", "Can't copy remote file \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\"");
710 927
 					$ret=false;
711
-					if(!$continious) break;
928
+					if(!$continious) {
929
+						break;
930
+					}
712 931
 				}
713 932
 			}
714 933
 			@chmod($local."/".$el["name"], $el["perms"]);
715 934
 			$t=strtotime($el["date"]);
716
-			if($t!==-1 and $t!==false) @touch($local."/".$el["name"], $t);
935
+			if($t!==-1 and $t!==false) {
936
+				@touch($local."/".$el["name"], $t);
937
+			}
717 938
 		}
718 939
 		return $ret;
719 940
 	}
@@ -727,24 +948,31 @@  discard block
 block discarded – undo
727 948
 
728 949
 		foreach($list as $k=>$v) {
729 950
 			$list[$k]=$this->parselisting($v);
730
-			if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]);
951
+			if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") {
952
+				unset($list[$k]);
953
+			}
731 954
 		}
732 955
 		$ret=true;
733 956
 
734 957
 		foreach($list as $el) {
735
-			if ( empty($el) )
736
-				continue;
958
+			if ( empty($el) ) {
959
+							continue;
960
+			}
737 961
 
738 962
 			if($el["type"]=="d") {
739 963
 				if(!$this->mdel($remote."/".$el["name"], $continious)) {
740 964
 					$ret=false;
741
-					if(!$continious) break;
965
+					if(!$continious) {
966
+						break;
967
+					}
742 968
 				}
743 969
 			} else {
744 970
 				if (!$this->delete($remote."/".$el["name"])) {
745 971
 					$this->PushError("mdel", "can't delete file", "Can't delete remote file \"".$remote."/".$el["name"]."\"");
746 972
 					$ret=false;
747
-					if(!$continious) break;
973
+					if(!$continious) {
974
+						break;
975
+					}
748 976
 				}
749 977
 			}
750 978
 		}
@@ -757,9 +985,15 @@  discard block
 block discarded – undo
757 985
 	}
758 986
 
759 987
 	function mmkdir($dir, $mode = 0777) {
760
-		if(empty($dir)) return FALSE;
761
-		if($this->is_exists($dir) or $dir == "/" ) return TRUE;
762
-		if(!$this->mmkdir(dirname($dir), $mode)) return false;
988
+		if(empty($dir)) {
989
+			return FALSE;
990
+		}
991
+		if($this->is_exists($dir) or $dir == "/" ) {
992
+			return TRUE;
993
+		}
994
+		if(!$this->mmkdir(dirname($dir), $mode)) {
995
+			return false;
996
+		}
763 997
 		$r=$this->mkdir($dir, $mode);
764 998
 		$this->chmod($dir,$mode);
765 999
 		return $r;
@@ -767,28 +1001,39 @@  discard block
 block discarded – undo
767 1001
 
768 1002
 	function glob($pattern, $handle=NULL) {
769 1003
 		$path=$output=null;
770
-		if(PHP_OS=='WIN32') $slash='\\';
771
-		else $slash='/';
1004
+		if(PHP_OS=='WIN32') {
1005
+			$slash='\\';
1006
+		} else {
1007
+			$slash='/';
1008
+		}
772 1009
 		$lastpos=strrpos($pattern,$slash);
773 1010
 		if(!($lastpos===false)) {
774 1011
 			$path=substr($pattern,0,-$lastpos-1);
775 1012
 			$pattern=substr($pattern,$lastpos);
776
-		} else $path=getcwd();
1013
+		} else {
1014
+			$path=getcwd();
1015
+		}
777 1016
 		if(is_array($handle) and !empty($handle)) {
778 1017
 			while($dir=each($handle)) {
779
-				if($this->glob_pattern_match($pattern,$dir))
780
-				$output[]=$dir;
1018
+				if($this->glob_pattern_match($pattern,$dir)) {
1019
+								$output[]=$dir;
1020
+				}
781 1021
 			}
782 1022
 		} else {
783 1023
 			$handle=@opendir($path);
784
-			if($handle===false) return false;
1024
+			if($handle===false) {
1025
+				return false;
1026
+			}
785 1027
 			while($dir=readdir($handle)) {
786
-				if($this->glob_pattern_match($pattern,$dir))
787
-				$output[]=$dir;
1028
+				if($this->glob_pattern_match($pattern,$dir)) {
1029
+								$output[]=$dir;
1030
+				}
788 1031
 			}
789 1032
 			closedir($handle);
790 1033
 		}
791
-		if(is_array($output)) return $output;
1034
+		if(is_array($output)) {
1035
+			return $output;
1036
+		}
792 1037
 		return false;
793 1038
 	}
794 1039
 
@@ -797,20 +1042,24 @@  discard block
 block discarded – undo
797 1042
 		$chunks=explode(';',$pattern);
798 1043
 		foreach($chunks as $pattern) {
799 1044
 			$escape=array('$','^','.','{','}','(',')','[',']','|');
800
-			while(strpos($pattern,'**')!==false)
801
-				$pattern=str_replace('**','*',$pattern);
802
-			foreach($escape as $probe)
803
-				$pattern=str_replace($probe,"\\$probe",$pattern);
1045
+			while(strpos($pattern,'**')!==false) {
1046
+							$pattern=str_replace('**','*',$pattern);
1047
+			}
1048
+			foreach($escape as $probe) {
1049
+							$pattern=str_replace($probe,"\\$probe",$pattern);
1050
+			}
804 1051
 			$pattern=str_replace('?*','*',
805 1052
 				str_replace('*?','*',
806 1053
 					str_replace('*',".*",
807 1054
 						str_replace('?','.{1,1}',$pattern))));
808 1055
 			$out[]=$pattern;
809 1056
 		}
810
-		if(count($out)==1) return($this->glob_regexp("^$out[0]$",$string));
811
-		else {
812
-			foreach($out as $tester)
813
-				if($this->my_regexp("^$tester$",$string)) return true;
1057
+		if(count($out)==1) {
1058
+			return($this->glob_regexp("^$out[0]$",$string));
1059
+		} else {
1060
+			foreach($out as $tester) {
1061
+							if($this->my_regexp("^$tester$",$string)) return true;
1062
+			}
814 1063
 		}
815 1064
 		return false;
816 1065
 	}
@@ -833,11 +1082,13 @@  discard block
 block discarded – undo
833 1082
 		$dirlist = array();
834 1083
 		foreach($list as $k=>$v) {
835 1084
 			$entry=$this->parselisting($v);
836
-			if ( empty($entry) )
837
-				continue;
1085
+			if ( empty($entry) ) {
1086
+							continue;
1087
+			}
838 1088
 
839
-			if($entry["name"]=="." or $entry["name"]=="..")
840
-				continue;
1089
+			if($entry["name"]=="." or $entry["name"]=="..") {
1090
+							continue;
1091
+			}
841 1092
 
842 1093
 			$dirlist[$entry['name']] = $entry;
843 1094
 		}
@@ -852,7 +1103,9 @@  discard block
 block discarded – undo
852 1103
 	}
853 1104
 
854 1105
 	function _list($arg="", $cmd="LIST", $fnction="_list") {
855
-		if(!$this->_data_prepare()) return false;
1106
+		if(!$this->_data_prepare()) {
1107
+			return false;
1108
+		}
856 1109
 		if(!$this->_exec($cmd.$arg, $fnction)) {
857 1110
 			$this->_data_close();
858 1111
 			return FALSE;
@@ -865,9 +1118,15 @@  discard block
 block discarded – undo
865 1118
 		if($this->_code<200) {
866 1119
 			$out=$this->_data_read();
867 1120
 			$this->_data_close();
868
-			if(!$this->_readmsg()) return FALSE;
869
-			if(!$this->_checkCode()) return FALSE;
870
-			if($out === FALSE ) return FALSE;
1121
+			if(!$this->_readmsg()) {
1122
+				return FALSE;
1123
+			}
1124
+			if(!$this->_checkCode()) {
1125
+				return FALSE;
1126
+			}
1127
+			if($out === FALSE ) {
1128
+				return FALSE;
1129
+			}
871 1130
 			$out=preg_split("/[".CRLF."]+/", $out, -1, PREG_SPLIT_NO_EMPTY);
872 1131
 //			$this->SendMSG(implode($this->_eol_code[$this->OS_local], $out));
873 1132
 		}
@@ -884,15 +1143,22 @@  discard block
 block discarded – undo
884 1143
 		$error['fctname']=$fctname;
885 1144
 		$error['msg']=$msg;
886 1145
 		$error['desc']=$desc;
887
-		if($desc) $tmp=' ('.$desc.')'; else $tmp='';
1146
+		if($desc) {
1147
+			$tmp=' ('.$desc.')';
1148
+		} else {
1149
+			$tmp='';
1150
+		}
888 1151
 		$this->SendMSG($fctname.': '.$msg.$tmp);
889 1152
 		return(array_push($this->_error_array,$error));
890 1153
 	}
891 1154
 
892 1155
 // Rcupre une erreur externe
893 1156
 	function PopError(){
894
-		if(count($this->_error_array)) return(array_pop($this->_error_array));
895
-			else return(false);
1157
+		if(count($this->_error_array)) {
1158
+			return(array_pop($this->_error_array));
1159
+		} else {
1160
+				return(false);
1161
+			}
896 1162
 	}
897 1163
 }
898 1164
 
Please login to merge, or discard this patch.
Spacing   +381 added lines, -382 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @since 2.5
21 21
  * @var string
22 22
  */
23
-if(!defined('CRLF')) define('CRLF',"\r\n");
23
+if ( ! defined('CRLF')) define('CRLF', "\r\n");
24 24
 
25 25
 /**
26 26
  * Sets whatever to autodetect ASCII mode.
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  * @since 2.5
31 31
  * @var int
32 32
  */
33
-if(!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1);
33
+if ( ! defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1);
34 34
 
35 35
 /**
36 36
  *
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @since 2.5
39 39
  * @var int
40 40
  */
41
-if(!defined("FTP_BINARY")) define("FTP_BINARY", 1);
41
+if ( ! defined("FTP_BINARY")) define("FTP_BINARY", 1);
42 42
 
43 43
 /**
44 44
  *
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
  * @since 2.5
47 47
  * @var int
48 48
  */
49
-if(!defined("FTP_ASCII")) define("FTP_ASCII", 0);
49
+if ( ! defined("FTP_ASCII")) define("FTP_ASCII", 0);
50 50
 
51 51
 /**
52 52
  * Whether to force FTP.
@@ -56,25 +56,25 @@  discard block
 block discarded – undo
56 56
  * @since 2.5
57 57
  * @var bool
58 58
  */
59
-if(!defined('FTP_FORCE')) define('FTP_FORCE', true);
59
+if ( ! defined('FTP_FORCE')) define('FTP_FORCE', true);
60 60
 
61 61
 /**
62 62
  * @since 2.5
63 63
  * @var string
64 64
  */
65
-define('FTP_OS_Unix','u');
65
+define('FTP_OS_Unix', 'u');
66 66
 
67 67
 /**
68 68
  * @since 2.5
69 69
  * @var string
70 70
  */
71
-define('FTP_OS_Windows','w');
71
+define('FTP_OS_Windows', 'w');
72 72
 
73 73
 /**
74 74
  * @since 2.5
75 75
  * @var string
76 76
  */
77
-define('FTP_OS_Mac','m');
77
+define('FTP_OS_Mac', 'm');
78 78
 
79 79
 /**
80 80
  * PemFTP base class
@@ -121,39 +121,39 @@  discard block
 block discarded – undo
121 121
 	var $AutoAsciiExt;
122 122
 
123 123
 	/* Constructor */
124
-	function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) {
125
-		$this->LocalEcho=$le;
126
-		$this->Verbose=$verb;
127
-		$this->_lastaction=NULL;
128
-		$this->_error_array=array();
129
-		$this->_eol_code=array(FTP_OS_Unix=>"\n", FTP_OS_Mac=>"\r", FTP_OS_Windows=>"\r\n");
130
-		$this->AuthorizedTransferMode=array(FTP_AUTOASCII, FTP_ASCII, FTP_BINARY);
131
-		$this->OS_FullName=array(FTP_OS_Unix => 'UNIX', FTP_OS_Windows => 'WINDOWS', FTP_OS_Mac => 'MACOS');
132
-		$this->AutoAsciiExt=array("ASP","BAT","C","CPP","CSS","CSV","JS","H","HTM","HTML","SHTML","INI","LOG","PHP3","PHTML","PL","PERL","SH","SQL","TXT");
133
-		$this->_port_available=($port_mode==TRUE);
134
-		$this->SendMSG("Staring FTP client class".($this->_port_available?"":" without PORT mode support"));
135
-		$this->_connected=FALSE;
136
-		$this->_ready=FALSE;
137
-		$this->_can_restore=FALSE;
138
-		$this->_code=0;
139
-		$this->_message="";
140
-		$this->_ftp_buff_size=4096;
141
-		$this->_curtype=NULL;
124
+	function __construct($port_mode = FALSE, $verb = FALSE, $le = FALSE) {
125
+		$this->LocalEcho = $le;
126
+		$this->Verbose = $verb;
127
+		$this->_lastaction = NULL;
128
+		$this->_error_array = array();
129
+		$this->_eol_code = array(FTP_OS_Unix=>"\n", FTP_OS_Mac=>"\r", FTP_OS_Windows=>"\r\n");
130
+		$this->AuthorizedTransferMode = array(FTP_AUTOASCII, FTP_ASCII, FTP_BINARY);
131
+		$this->OS_FullName = array(FTP_OS_Unix => 'UNIX', FTP_OS_Windows => 'WINDOWS', FTP_OS_Mac => 'MACOS');
132
+		$this->AutoAsciiExt = array("ASP", "BAT", "C", "CPP", "CSS", "CSV", "JS", "H", "HTM", "HTML", "SHTML", "INI", "LOG", "PHP3", "PHTML", "PL", "PERL", "SH", "SQL", "TXT");
133
+		$this->_port_available = ($port_mode == TRUE);
134
+		$this->SendMSG("Staring FTP client class".($this->_port_available ? "" : " without PORT mode support"));
135
+		$this->_connected = FALSE;
136
+		$this->_ready = FALSE;
137
+		$this->_can_restore = FALSE;
138
+		$this->_code = 0;
139
+		$this->_message = "";
140
+		$this->_ftp_buff_size = 4096;
141
+		$this->_curtype = NULL;
142 142
 		$this->SetUmask(0022);
143 143
 		$this->SetType(FTP_AUTOASCII);
144 144
 		$this->SetTimeout(30);
145
-		$this->Passive(!$this->_port_available);
146
-		$this->_login="anonymous";
147
-		$this->_password="[email protected]";
148
-		$this->_features=array();
149
-	    $this->OS_local=FTP_OS_Unix;
150
-		$this->OS_remote=FTP_OS_Unix;
151
-		$this->features=array();
152
-		if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows;
153
-		elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac;
154
-	}
155
-
156
-	function ftp_base($port_mode=FALSE) {
145
+		$this->Passive( ! $this->_port_available);
146
+		$this->_login = "anonymous";
147
+		$this->_password = "[email protected]";
148
+		$this->_features = array();
149
+	    $this->OS_local = FTP_OS_Unix;
150
+		$this->OS_remote = FTP_OS_Unix;
151
+		$this->features = array();
152
+		if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local = FTP_OS_Windows;
153
+		elseif (strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local = FTP_OS_Mac;
154
+	}
155
+
156
+	function ftp_base($port_mode = FALSE) {
157 157
 		$this->__construct($port_mode);
158 158
 	}
159 159
 
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
 
164 164
 	function parselisting($line) {
165 165
 		$is_windows = ($this->OS_remote == FTP_OS_Windows);
166
-		if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/",$line,$lucifer)) {
166
+		if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/", $line, $lucifer)) {
167 167
 			$b = array();
168
-			if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix
169
-			$b['isdir'] = ($lucifer[7]=="<DIR>");
170
-			if ( $b['isdir'] )
168
+			if ($lucifer[3] < 70) { $lucifer[3] += 2000; } else { $lucifer[3] += 1900; } // 4digit year fix
169
+			$b['isdir'] = ($lucifer[7] == "<DIR>");
170
+			if ($b['isdir'])
171 171
 				$b['type'] = 'd';
172 172
 			else
173 173
 				$b['type'] = 'f';
@@ -177,19 +177,19 @@  discard block
 block discarded – undo
177 177
 			$b['year'] = $lucifer[3];
178 178
 			$b['hour'] = $lucifer[4];
179 179
 			$b['minute'] = $lucifer[5];
180
-			$b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]);
180
+			$b['time'] = @mktime($lucifer[4] + (strcasecmp($lucifer[6], "PM") == 0 ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]);
181 181
 			$b['am/pm'] = $lucifer[6];
182 182
 			$b['name'] = $lucifer[8];
183
-		} else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) {
183
+		} else if ( ! $is_windows && $lucifer = preg_split("/[ ]/", $line, 9, PREG_SPLIT_NO_EMPTY)) {
184 184
 			//echo $line."\n";
185
-			$lcount=count($lucifer);
186
-			if ($lcount<8) return '';
185
+			$lcount = count($lucifer);
186
+			if ($lcount < 8) return '';
187 187
 			$b = array();
188 188
 			$b['isdir'] = $lucifer[0]{0} === "d";
189 189
 			$b['islink'] = $lucifer[0]{0} === "l";
190
-			if ( $b['isdir'] )
190
+			if ($b['isdir'])
191 191
 				$b['type'] = 'd';
192
-			elseif ( $b['islink'] )
192
+			elseif ($b['islink'])
193 193
 				$b['type'] = 'l';
194 194
 			else
195 195
 				$b['type'] = 'f';
@@ -198,15 +198,15 @@  discard block
 block discarded – undo
198 198
 			$b['owner'] = $lucifer[2];
199 199
 			$b['group'] = $lucifer[3];
200 200
 			$b['size'] = $lucifer[4];
201
-			if ($lcount==8) {
202
-				sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']);
203
-				sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']);
204
-				$b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']);
201
+			if ($lcount == 8) {
202
+				sscanf($lucifer[5], "%d-%d-%d", $b['year'], $b['month'], $b['day']);
203
+				sscanf($lucifer[6], "%d:%d", $b['hour'], $b['minute']);
204
+				$b['time'] = @mktime($b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year']);
205 205
 				$b['name'] = $lucifer[7];
206 206
 			} else {
207 207
 				$b['month'] = $lucifer[5];
208 208
 				$b['day'] = $lucifer[6];
209
-				if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) {
209
+				if (preg_match("/([0-9]{2}):([0-9]{2})/", $lucifer[7], $l2)) {
210 210
 					$b['year'] = date("Y");
211 211
 					$b['hour'] = $l2[1];
212 212
 					$b['minute'] = $l2[2];
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 					$b['hour'] = 0;
216 216
 					$b['minute'] = 0;
217 217
 				}
218
-				$b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute']));
218
+				$b['time'] = strtotime(sprintf("%d %s %d %02d:%02d", $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute']));
219 219
 				$b['name'] = $lucifer[8];
220 220
 			}
221 221
 		}
@@ -223,227 +223,227 @@  discard block
 block discarded – undo
223 223
 		return $b;
224 224
 	}
225 225
 
226
-	function SendMSG($message = "", $crlf=true) {
226
+	function SendMSG($message = "", $crlf = true) {
227 227
 		if ($this->Verbose) {
228
-			echo $message.($crlf?CRLF:"");
228
+			echo $message.($crlf ? CRLF : "");
229 229
 			flush();
230 230
 		}
231 231
 		return TRUE;
232 232
 	}
233 233
 
234
-	function SetType($mode=FTP_AUTOASCII) {
235
-		if(!in_array($mode, $this->AuthorizedTransferMode)) {
234
+	function SetType($mode = FTP_AUTOASCII) {
235
+		if ( ! in_array($mode, $this->AuthorizedTransferMode)) {
236 236
 			$this->SendMSG("Wrong type");
237 237
 			return FALSE;
238 238
 		}
239
-		$this->_type=$mode;
240
-		$this->SendMSG("Transfer type: ".($this->_type==FTP_BINARY?"binary":($this->_type==FTP_ASCII?"ASCII":"auto ASCII") ) );
239
+		$this->_type = $mode;
240
+		$this->SendMSG("Transfer type: ".($this->_type == FTP_BINARY ? "binary" : ($this->_type == FTP_ASCII ? "ASCII" : "auto ASCII")));
241 241
 		return TRUE;
242 242
 	}
243 243
 
244
-	function _settype($mode=FTP_ASCII) {
245
-		if($this->_ready) {
246
-			if($mode==FTP_BINARY) {
247
-				if($this->_curtype!=FTP_BINARY) {
248
-					if(!$this->_exec("TYPE I", "SetType")) return FALSE;
249
-					$this->_curtype=FTP_BINARY;
244
+	function _settype($mode = FTP_ASCII) {
245
+		if ($this->_ready) {
246
+			if ($mode == FTP_BINARY) {
247
+				if ($this->_curtype != FTP_BINARY) {
248
+					if ( ! $this->_exec("TYPE I", "SetType")) return FALSE;
249
+					$this->_curtype = FTP_BINARY;
250 250
 				}
251
-			} elseif($this->_curtype!=FTP_ASCII) {
252
-				if(!$this->_exec("TYPE A", "SetType")) return FALSE;
253
-				$this->_curtype=FTP_ASCII;
251
+			} elseif ($this->_curtype != FTP_ASCII) {
252
+				if ( ! $this->_exec("TYPE A", "SetType")) return FALSE;
253
+				$this->_curtype = FTP_ASCII;
254 254
 			}
255 255
 		} else return FALSE;
256 256
 		return TRUE;
257 257
 	}
258 258
 
259
-	function Passive($pasv=NULL) {
260
-		if(is_null($pasv)) $this->_passive=!$this->_passive;
261
-		else $this->_passive=$pasv;
262
-		if(!$this->_port_available and !$this->_passive) {
259
+	function Passive($pasv = NULL) {
260
+		if (is_null($pasv)) $this->_passive = ! $this->_passive;
261
+		else $this->_passive = $pasv;
262
+		if ( ! $this->_port_available and ! $this->_passive) {
263 263
 			$this->SendMSG("Only passive connections available!");
264
-			$this->_passive=TRUE;
264
+			$this->_passive = TRUE;
265 265
 			return FALSE;
266 266
 		}
267
-		$this->SendMSG("Passive mode ".($this->_passive?"on":"off"));
267
+		$this->SendMSG("Passive mode ".($this->_passive ? "on" : "off"));
268 268
 		return TRUE;
269 269
 	}
270 270
 
271
-	function SetServer($host, $port=21, $reconnect=true) {
272
-		if(!is_long($port)) {
273
-	        $this->verbose=true;
271
+	function SetServer($host, $port = 21, $reconnect = true) {
272
+		if ( ! is_long($port)) {
273
+	        $this->verbose = true;
274 274
     	    $this->SendMSG("Incorrect port syntax");
275 275
 			return FALSE;
276 276
 		} else {
277
-			$ip=@gethostbyname($host);
278
-	        $dns=@gethostbyaddr($host);
279
-	        if(!$ip) $ip=$host;
280
-	        if(!$dns) $dns=$host;
277
+			$ip = @gethostbyname($host);
278
+	        $dns = @gethostbyaddr($host);
279
+	        if ( ! $ip) $ip = $host;
280
+	        if ( ! $dns) $dns = $host;
281 281
 	        // Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false
282 282
 	        // -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid
283 283
 	        $ipaslong = ip2long($ip);
284
-			if ( ($ipaslong == false) || ($ipaslong === -1) ) {
284
+			if (($ipaslong == false) || ($ipaslong === -1)) {
285 285
 				$this->SendMSG("Wrong host name/address \"".$host."\"");
286 286
 				return FALSE;
287 287
 			}
288
-	        $this->_host=$ip;
289
-	        $this->_fullhost=$dns;
290
-	        $this->_port=$port;
291
-	        $this->_dataport=$port-1;
288
+	        $this->_host = $ip;
289
+	        $this->_fullhost = $dns;
290
+	        $this->_port = $port;
291
+	        $this->_dataport = $port - 1;
292 292
 		}
293 293
 		$this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\"");
294
-		if($reconnect){
295
-			if($this->_connected) {
294
+		if ($reconnect) {
295
+			if ($this->_connected) {
296 296
 				$this->SendMSG("Reconnecting");
297
-				if(!$this->quit(FTP_FORCE)) return FALSE;
298
-				if(!$this->connect()) return FALSE;
297
+				if ( ! $this->quit(FTP_FORCE)) return FALSE;
298
+				if ( ! $this->connect()) return FALSE;
299 299
 			}
300 300
 		}
301 301
 		return TRUE;
302 302
 	}
303 303
 
304
-	function SetUmask($umask=0022) {
305
-		$this->_umask=$umask;
304
+	function SetUmask($umask = 0022) {
305
+		$this->_umask = $umask;
306 306
 		umask($this->_umask);
307 307
 		$this->SendMSG("UMASK 0".decoct($this->_umask));
308 308
 		return TRUE;
309 309
 	}
310 310
 
311
-	function SetTimeout($timeout=30) {
312
-		$this->_timeout=$timeout;
311
+	function SetTimeout($timeout = 30) {
312
+		$this->_timeout = $timeout;
313 313
 		$this->SendMSG("Timeout ".$this->_timeout);
314
-		if($this->_connected)
315
-			if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE;
314
+		if ($this->_connected)
315
+			if ( ! $this->_settimeout($this->_ftp_control_sock)) return FALSE;
316 316
 		return TRUE;
317 317
 	}
318 318
 
319
-	function connect($server=NULL) {
320
-		if(!empty($server)) {
321
-			if(!$this->SetServer($server)) return false;
319
+	function connect($server = NULL) {
320
+		if ( ! empty($server)) {
321
+			if ( ! $this->SetServer($server)) return false;
322 322
 		}
323
-		if($this->_ready) return true;
323
+		if ($this->_ready) return true;
324 324
 	    $this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]);
325
-		if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) {
325
+		if ( ! ($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) {
326 326
 			$this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\"");
327 327
 			return FALSE;
328 328
 		}
329 329
 		$this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting.");
330 330
 		do {
331
-			if(!$this->_readmsg()) return FALSE;
332
-			if(!$this->_checkCode()) return FALSE;
333
-			$this->_lastaction=time();
334
-		} while($this->_code<200);
335
-		$this->_ready=true;
336
-		$syst=$this->systype();
337
-		if(!$syst) $this->SendMSG("Can't detect remote OS");
331
+			if ( ! $this->_readmsg()) return FALSE;
332
+			if ( ! $this->_checkCode()) return FALSE;
333
+			$this->_lastaction = time();
334
+		} while ($this->_code < 200);
335
+		$this->_ready = true;
336
+		$syst = $this->systype();
337
+		if ( ! $syst) $this->SendMSG("Can't detect remote OS");
338 338
 		else {
339
-			if(preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote=FTP_OS_Windows;
340
-			elseif(preg_match("/os/i", $syst[0])) $this->OS_remote=FTP_OS_Mac;
341
-			elseif(preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote=FTP_OS_Unix;
342
-			else $this->OS_remote=FTP_OS_Mac;
339
+			if (preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote = FTP_OS_Windows;
340
+			elseif (preg_match("/os/i", $syst[0])) $this->OS_remote = FTP_OS_Mac;
341
+			elseif (preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote = FTP_OS_Unix;
342
+			else $this->OS_remote = FTP_OS_Mac;
343 343
 			$this->SendMSG("Remote OS: ".$this->OS_FullName[$this->OS_remote]);
344 344
 		}
345
-		if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled");
345
+		if ( ! $this->features()) $this->SendMSG("Can't get features list. All supported - disabled");
346 346
 		else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features)));
347 347
 		return TRUE;
348 348
 	}
349 349
 
350
-	function quit($force=false) {
351
-		if($this->_ready) {
352
-			if(!$this->_exec("QUIT") and !$force) return FALSE;
353
-			if(!$this->_checkCode() and !$force) return FALSE;
354
-			$this->_ready=false;
350
+	function quit($force = false) {
351
+		if ($this->_ready) {
352
+			if ( ! $this->_exec("QUIT") and ! $force) return FALSE;
353
+			if ( ! $this->_checkCode() and ! $force) return FALSE;
354
+			$this->_ready = false;
355 355
 			$this->SendMSG("Session finished");
356 356
 		}
357 357
 		$this->_quit();
358 358
 		return TRUE;
359 359
 	}
360 360
 
361
-	function login($user=NULL, $pass=NULL) {
362
-		if(!is_null($user)) $this->_login=$user;
363
-		else $this->_login="anonymous";
364
-		if(!is_null($pass)) $this->_password=$pass;
365
-		else $this->_password="[email protected]";
366
-		if(!$this->_exec("USER ".$this->_login, "login")) return FALSE;
367
-		if(!$this->_checkCode()) return FALSE;
368
-		if($this->_code!=230) {
369
-			if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) return FALSE;
370
-			if(!$this->_checkCode()) return FALSE;
361
+	function login($user = NULL, $pass = NULL) {
362
+		if ( ! is_null($user)) $this->_login = $user;
363
+		else $this->_login = "anonymous";
364
+		if ( ! is_null($pass)) $this->_password = $pass;
365
+		else $this->_password = "[email protected]";
366
+		if ( ! $this->_exec("USER ".$this->_login, "login")) return FALSE;
367
+		if ( ! $this->_checkCode()) return FALSE;
368
+		if ($this->_code != 230) {
369
+			if ( ! $this->_exec((($this->_code == 331) ? "PASS " : "ACCT ").$this->_password, "login")) return FALSE;
370
+			if ( ! $this->_checkCode()) return FALSE;
371 371
 		}
372 372
 		$this->SendMSG("Authentication succeeded");
373
-		if(empty($this->_features)) {
374
-			if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled");
373
+		if (empty($this->_features)) {
374
+			if ( ! $this->features()) $this->SendMSG("Can't get features list. All supported - disabled");
375 375
 			else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features)));
376 376
 		}
377 377
 		return TRUE;
378 378
 	}
379 379
 
380 380
 	function pwd() {
381
-		if(!$this->_exec("PWD", "pwd")) return FALSE;
382
-		if(!$this->_checkCode()) return FALSE;
381
+		if ( ! $this->_exec("PWD", "pwd")) return FALSE;
382
+		if ( ! $this->_checkCode()) return FALSE;
383 383
 		return preg_replace("/^[0-9]{3} \"(.+)\".*$/s", "\\1", $this->_message);
384 384
 	}
385 385
 
386 386
 	function cdup() {
387
-		if(!$this->_exec("CDUP", "cdup")) return FALSE;
388
-		if(!$this->_checkCode()) return FALSE;
387
+		if ( ! $this->_exec("CDUP", "cdup")) return FALSE;
388
+		if ( ! $this->_checkCode()) return FALSE;
389 389
 		return true;
390 390
 	}
391 391
 
392 392
 	function chdir($pathname) {
393
-		if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE;
394
-		if(!$this->_checkCode()) return FALSE;
393
+		if ( ! $this->_exec("CWD ".$pathname, "chdir")) return FALSE;
394
+		if ( ! $this->_checkCode()) return FALSE;
395 395
 		return TRUE;
396 396
 	}
397 397
 
398 398
 	function rmdir($pathname) {
399
-		if(!$this->_exec("RMD ".$pathname, "rmdir")) return FALSE;
400
-		if(!$this->_checkCode()) return FALSE;
399
+		if ( ! $this->_exec("RMD ".$pathname, "rmdir")) return FALSE;
400
+		if ( ! $this->_checkCode()) return FALSE;
401 401
 		return TRUE;
402 402
 	}
403 403
 
404 404
 	function mkdir($pathname) {
405
-		if(!$this->_exec("MKD ".$pathname, "mkdir")) return FALSE;
406
-		if(!$this->_checkCode()) return FALSE;
405
+		if ( ! $this->_exec("MKD ".$pathname, "mkdir")) return FALSE;
406
+		if ( ! $this->_checkCode()) return FALSE;
407 407
 		return TRUE;
408 408
 	}
409 409
 
410 410
 	function rename($from, $to) {
411
-		if(!$this->_exec("RNFR ".$from, "rename")) return FALSE;
412
-		if(!$this->_checkCode()) return FALSE;
413
-		if($this->_code==350) {
414
-			if(!$this->_exec("RNTO ".$to, "rename")) return FALSE;
415
-			if(!$this->_checkCode()) return FALSE;
411
+		if ( ! $this->_exec("RNFR ".$from, "rename")) return FALSE;
412
+		if ( ! $this->_checkCode()) return FALSE;
413
+		if ($this->_code == 350) {
414
+			if ( ! $this->_exec("RNTO ".$to, "rename")) return FALSE;
415
+			if ( ! $this->_checkCode()) return FALSE;
416 416
 		} else return FALSE;
417 417
 		return TRUE;
418 418
 	}
419 419
 
420 420
 	function filesize($pathname) {
421
-		if(!isset($this->_features["SIZE"])) {
421
+		if ( ! isset($this->_features["SIZE"])) {
422 422
 			$this->PushError("filesize", "not supported by server");
423 423
 			return FALSE;
424 424
 		}
425
-		if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE;
426
-		if(!$this->_checkCode()) return FALSE;
425
+		if ( ! $this->_exec("SIZE ".$pathname, "filesize")) return FALSE;
426
+		if ( ! $this->_checkCode()) return FALSE;
427 427
 		return preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message);
428 428
 	}
429 429
 
430 430
 	function abort() {
431
-		if(!$this->_exec("ABOR", "abort")) return FALSE;
432
-		if(!$this->_checkCode()) {
433
-			if($this->_code!=426) return FALSE;
434
-			if(!$this->_readmsg("abort")) return FALSE;
435
-			if(!$this->_checkCode()) return FALSE;
431
+		if ( ! $this->_exec("ABOR", "abort")) return FALSE;
432
+		if ( ! $this->_checkCode()) {
433
+			if ($this->_code != 426) return FALSE;
434
+			if ( ! $this->_readmsg("abort")) return FALSE;
435
+			if ( ! $this->_checkCode()) return FALSE;
436 436
 		}
437 437
 		return true;
438 438
 	}
439 439
 
440 440
 	function mdtm($pathname) {
441
-		if(!isset($this->_features["MDTM"])) {
441
+		if ( ! isset($this->_features["MDTM"])) {
442 442
 			$this->PushError("mdtm", "not supported by server");
443 443
 			return FALSE;
444 444
 		}
445
-		if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE;
446
-		if(!$this->_checkCode()) return FALSE;
445
+		if ( ! $this->_exec("MDTM ".$pathname, "mdtm")) return FALSE;
446
+		if ( ! $this->_checkCode()) return FALSE;
447 447
 		$mdtm = preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message);
448 448
 		$date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d");
449 449
 		$timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]);
@@ -451,61 +451,61 @@  discard block
 block discarded – undo
451 451
 	}
452 452
 
453 453
 	function systype() {
454
-		if(!$this->_exec("SYST", "systype")) return FALSE;
455
-		if(!$this->_checkCode()) return FALSE;
454
+		if ( ! $this->_exec("SYST", "systype")) return FALSE;
455
+		if ( ! $this->_checkCode()) return FALSE;
456 456
 		$DATA = explode(" ", $this->_message);
457 457
 		return array($DATA[1], $DATA[3]);
458 458
 	}
459 459
 
460 460
 	function delete($pathname) {
461
-		if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE;
462
-		if(!$this->_checkCode()) return FALSE;
461
+		if ( ! $this->_exec("DELE ".$pathname, "delete")) return FALSE;
462
+		if ( ! $this->_checkCode()) return FALSE;
463 463
 		return TRUE;
464 464
 	}
465 465
 
466
-	function site($command, $fnction="site") {
467
-		if(!$this->_exec("SITE ".$command, $fnction)) return FALSE;
468
-		if(!$this->_checkCode()) return FALSE;
466
+	function site($command, $fnction = "site") {
467
+		if ( ! $this->_exec("SITE ".$command, $fnction)) return FALSE;
468
+		if ( ! $this->_checkCode()) return FALSE;
469 469
 		return TRUE;
470 470
 	}
471 471
 
472 472
 	function chmod($pathname, $mode) {
473
-		if(!$this->site( sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) return FALSE;
473
+		if ( ! $this->site(sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) return FALSE;
474 474
 		return TRUE;
475 475
 	}
476 476
 
477 477
 	function restore($from) {
478
-		if(!isset($this->_features["REST"])) {
478
+		if ( ! isset($this->_features["REST"])) {
479 479
 			$this->PushError("restore", "not supported by server");
480 480
 			return FALSE;
481 481
 		}
482
-		if($this->_curtype!=FTP_BINARY) {
482
+		if ($this->_curtype != FTP_BINARY) {
483 483
 			$this->PushError("restore", "can't restore in ASCII mode");
484 484
 			return FALSE;
485 485
 		}
486
-		if(!$this->_exec("REST ".$from, "resore")) return FALSE;
487
-		if(!$this->_checkCode()) return FALSE;
486
+		if ( ! $this->_exec("REST ".$from, "resore")) return FALSE;
487
+		if ( ! $this->_checkCode()) return FALSE;
488 488
 		return TRUE;
489 489
 	}
490 490
 
491 491
 	function features() {
492
-		if(!$this->_exec("FEAT", "features")) return FALSE;
493
-		if(!$this->_checkCode()) return FALSE;
494
-		$f=preg_split("/[".CRLF."]+/", preg_replace("/[0-9]{3}[ -].*[".CRLF."]+/", "", $this->_message), -1, PREG_SPLIT_NO_EMPTY);
495
-		$this->_features=array();
496
-		foreach($f as $k=>$v) {
497
-			$v=explode(" ", trim($v));
498
-			$this->_features[array_shift($v)]=$v;
492
+		if ( ! $this->_exec("FEAT", "features")) return FALSE;
493
+		if ( ! $this->_checkCode()) return FALSE;
494
+		$f = preg_split("/[".CRLF."]+/", preg_replace("/[0-9]{3}[ -].*[".CRLF."]+/", "", $this->_message), -1, PREG_SPLIT_NO_EMPTY);
495
+		$this->_features = array();
496
+		foreach ($f as $k=>$v) {
497
+			$v = explode(" ", trim($v));
498
+			$this->_features[array_shift($v)] = $v;
499 499
 		}
500 500
 		return true;
501 501
 	}
502 502
 
503
-	function rawlist($pathname="", $arg="") {
504
-		return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist");
503
+	function rawlist($pathname = "", $arg = "") {
504
+		return $this->_list(($arg ? " ".$arg : "").($pathname ? " ".$pathname : ""), "LIST", "rawlist");
505 505
 	}
506 506
 
507
-	function nlist($pathname="", $arg="") {
508
-		return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist");
507
+	function nlist($pathname = "", $arg = "") {
508
+		return $this->_list(($arg ? " ".$arg : "").($pathname ? " ".$pathname : ""), "NLST", "nlist");
509 509
 	}
510 510
 
511 511
 	function is_exists($pathname) {
@@ -513,330 +513,329 @@  discard block
 block discarded – undo
513 513
 	}
514 514
 
515 515
 	function file_exists($pathname) {
516
-		$exists=true;
517
-		if(!$this->_exec("RNFR ".$pathname, "rename")) $exists=FALSE;
516
+		$exists = true;
517
+		if ( ! $this->_exec("RNFR ".$pathname, "rename")) $exists = FALSE;
518 518
 		else {
519
-			if(!$this->_checkCode()) $exists=FALSE;
519
+			if ( ! $this->_checkCode()) $exists = FALSE;
520 520
 			$this->abort();
521 521
 		}
522
-		if($exists) $this->SendMSG("Remote file ".$pathname." exists");
522
+		if ($exists) $this->SendMSG("Remote file ".$pathname." exists");
523 523
 		else $this->SendMSG("Remote file ".$pathname." does not exist");
524 524
 		return $exists;
525 525
 	}
526 526
 
527
-	function fget($fp, $remotefile,$rest=0) {
528
-		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
529
-		$pi=pathinfo($remotefile);
530
-		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
531
-		else $mode=FTP_BINARY;
532
-		if(!$this->_data_prepare($mode)) {
527
+	function fget($fp, $remotefile, $rest = 0) {
528
+		if ($this->_can_restore and $rest != 0) fseek($fp, $rest);
529
+		$pi = pathinfo($remotefile);
530
+		if ($this->_type == FTP_ASCII or ($this->_type == FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode = FTP_ASCII;
531
+		else $mode = FTP_BINARY;
532
+		if ( ! $this->_data_prepare($mode)) {
533 533
 			return FALSE;
534 534
 		}
535
-		if($this->_can_restore and $rest!=0) $this->restore($rest);
536
-		if(!$this->_exec("RETR ".$remotefile, "get")) {
535
+		if ($this->_can_restore and $rest != 0) $this->restore($rest);
536
+		if ( ! $this->_exec("RETR ".$remotefile, "get")) {
537 537
 			$this->_data_close();
538 538
 			return FALSE;
539 539
 		}
540
-		if(!$this->_checkCode()) {
540
+		if ( ! $this->_checkCode()) {
541 541
 			$this->_data_close();
542 542
 			return FALSE;
543 543
 		}
544
-		$out=$this->_data_read($mode, $fp);
544
+		$out = $this->_data_read($mode, $fp);
545 545
 		$this->_data_close();
546
-		if(!$this->_readmsg()) return FALSE;
547
-		if(!$this->_checkCode()) return FALSE;
546
+		if ( ! $this->_readmsg()) return FALSE;
547
+		if ( ! $this->_checkCode()) return FALSE;
548 548
 		return $out;
549 549
 	}
550 550
 
551
-	function get($remotefile, $localfile=NULL, $rest=0) {
552
-		if(is_null($localfile)) $localfile=$remotefile;
551
+	function get($remotefile, $localfile = NULL, $rest = 0) {
552
+		if (is_null($localfile)) $localfile = $remotefile;
553 553
 		if (@file_exists($localfile)) $this->SendMSG("Warning : local file will be overwritten");
554 554
 		$fp = @fopen($localfile, "w");
555
-		if (!$fp) {
556
-			$this->PushError("get","can't open local file", "Cannot create \"".$localfile."\"");
555
+		if ( ! $fp) {
556
+			$this->PushError("get", "can't open local file", "Cannot create \"".$localfile."\"");
557 557
 			return FALSE;
558 558
 		}
559
-		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
560
-		$pi=pathinfo($remotefile);
561
-		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
562
-		else $mode=FTP_BINARY;
563
-		if(!$this->_data_prepare($mode)) {
559
+		if ($this->_can_restore and $rest != 0) fseek($fp, $rest);
560
+		$pi = pathinfo($remotefile);
561
+		if ($this->_type == FTP_ASCII or ($this->_type == FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode = FTP_ASCII;
562
+		else $mode = FTP_BINARY;
563
+		if ( ! $this->_data_prepare($mode)) {
564 564
 			fclose($fp);
565 565
 			return FALSE;
566 566
 		}
567
-		if($this->_can_restore and $rest!=0) $this->restore($rest);
568
-		if(!$this->_exec("RETR ".$remotefile, "get")) {
567
+		if ($this->_can_restore and $rest != 0) $this->restore($rest);
568
+		if ( ! $this->_exec("RETR ".$remotefile, "get")) {
569 569
 			$this->_data_close();
570 570
 			fclose($fp);
571 571
 			return FALSE;
572 572
 		}
573
-		if(!$this->_checkCode()) {
573
+		if ( ! $this->_checkCode()) {
574 574
 			$this->_data_close();
575 575
 			fclose($fp);
576 576
 			return FALSE;
577 577
 		}
578
-		$out=$this->_data_read($mode, $fp);
578
+		$out = $this->_data_read($mode, $fp);
579 579
 		fclose($fp);
580 580
 		$this->_data_close();
581
-		if(!$this->_readmsg()) return FALSE;
582
-		if(!$this->_checkCode()) return FALSE;
581
+		if ( ! $this->_readmsg()) return FALSE;
582
+		if ( ! $this->_checkCode()) return FALSE;
583 583
 		return $out;
584 584
 	}
585 585
 
586 586
 	function fput($remotefile, $fp) {
587
-		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
588
-		$pi=pathinfo($remotefile);
589
-		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
590
-		else $mode=FTP_BINARY;
591
-		if(!$this->_data_prepare($mode)) {
587
+		if ($this->_can_restore and $rest != 0) fseek($fp, $rest);
588
+		$pi = pathinfo($remotefile);
589
+		if ($this->_type == FTP_ASCII or ($this->_type == FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode = FTP_ASCII;
590
+		else $mode = FTP_BINARY;
591
+		if ( ! $this->_data_prepare($mode)) {
592 592
 			return FALSE;
593 593
 		}
594
-		if($this->_can_restore and $rest!=0) $this->restore($rest);
595
-		if(!$this->_exec("STOR ".$remotefile, "put")) {
594
+		if ($this->_can_restore and $rest != 0) $this->restore($rest);
595
+		if ( ! $this->_exec("STOR ".$remotefile, "put")) {
596 596
 			$this->_data_close();
597 597
 			return FALSE;
598 598
 		}
599
-		if(!$this->_checkCode()) {
599
+		if ( ! $this->_checkCode()) {
600 600
 			$this->_data_close();
601 601
 			return FALSE;
602 602
 		}
603
-		$ret=$this->_data_write($mode, $fp);
603
+		$ret = $this->_data_write($mode, $fp);
604 604
 		$this->_data_close();
605
-		if(!$this->_readmsg()) return FALSE;
606
-		if(!$this->_checkCode()) return FALSE;
605
+		if ( ! $this->_readmsg()) return FALSE;
606
+		if ( ! $this->_checkCode()) return FALSE;
607 607
 		return $ret;
608 608
 	}
609 609
 
610
-	function put($localfile, $remotefile=NULL, $rest=0) {
611
-		if(is_null($remotefile)) $remotefile=$localfile;
612
-		if (!file_exists($localfile)) {
613
-			$this->PushError("put","can't open local file", "No such file or directory \"".$localfile."\"");
610
+	function put($localfile, $remotefile = NULL, $rest = 0) {
611
+		if (is_null($remotefile)) $remotefile = $localfile;
612
+		if ( ! file_exists($localfile)) {
613
+			$this->PushError("put", "can't open local file", "No such file or directory \"".$localfile."\"");
614 614
 			return FALSE;
615 615
 		}
616 616
 		$fp = @fopen($localfile, "r");
617 617
 
618
-		if (!$fp) {
619
-			$this->PushError("put","can't open local file", "Cannot read file \"".$localfile."\"");
618
+		if ( ! $fp) {
619
+			$this->PushError("put", "can't open local file", "Cannot read file \"".$localfile."\"");
620 620
 			return FALSE;
621 621
 		}
622
-		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
623
-		$pi=pathinfo($localfile);
624
-		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
625
-		else $mode=FTP_BINARY;
626
-		if(!$this->_data_prepare($mode)) {
622
+		if ($this->_can_restore and $rest != 0) fseek($fp, $rest);
623
+		$pi = pathinfo($localfile);
624
+		if ($this->_type == FTP_ASCII or ($this->_type == FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode = FTP_ASCII;
625
+		else $mode = FTP_BINARY;
626
+		if ( ! $this->_data_prepare($mode)) {
627 627
 			fclose($fp);
628 628
 			return FALSE;
629 629
 		}
630
-		if($this->_can_restore and $rest!=0) $this->restore($rest);
631
-		if(!$this->_exec("STOR ".$remotefile, "put")) {
630
+		if ($this->_can_restore and $rest != 0) $this->restore($rest);
631
+		if ( ! $this->_exec("STOR ".$remotefile, "put")) {
632 632
 			$this->_data_close();
633 633
 			fclose($fp);
634 634
 			return FALSE;
635 635
 		}
636
-		if(!$this->_checkCode()) {
636
+		if ( ! $this->_checkCode()) {
637 637
 			$this->_data_close();
638 638
 			fclose($fp);
639 639
 			return FALSE;
640 640
 		}
641
-		$ret=$this->_data_write($mode, $fp);
641
+		$ret = $this->_data_write($mode, $fp);
642 642
 		fclose($fp);
643 643
 		$this->_data_close();
644
-		if(!$this->_readmsg()) return FALSE;
645
-		if(!$this->_checkCode()) return FALSE;
644
+		if ( ! $this->_readmsg()) return FALSE;
645
+		if ( ! $this->_checkCode()) return FALSE;
646 646
 		return $ret;
647 647
 	}
648 648
 
649
-	function mput($local=".", $remote=NULL, $continious=false) {
650
-		$local=realpath($local);
651
-		if(!@file_exists($local)) {
652
-			$this->PushError("mput","can't open local folder", "Cannot stat folder \"".$local."\"");
649
+	function mput($local = ".", $remote = NULL, $continious = false) {
650
+		$local = realpath($local);
651
+		if ( ! @file_exists($local)) {
652
+			$this->PushError("mput", "can't open local folder", "Cannot stat folder \"".$local."\"");
653 653
 			return FALSE;
654 654
 		}
655
-		if(!is_dir($local)) return $this->put($local, $remote);
656
-		if(empty($remote)) $remote=".";
657
-		elseif(!$this->file_exists($remote) and !$this->mkdir($remote)) return FALSE;
658
-		if($handle = opendir($local)) {
659
-			$list=array();
655
+		if ( ! is_dir($local)) return $this->put($local, $remote);
656
+		if (empty($remote)) $remote = ".";
657
+		elseif ( ! $this->file_exists($remote) and ! $this->mkdir($remote)) return FALSE;
658
+		if ($handle = opendir($local)) {
659
+			$list = array();
660 660
 			while (false !== ($file = readdir($handle))) {
661
-				if ($file != "." && $file != "..") $list[]=$file;
661
+				if ($file != "." && $file != "..") $list[] = $file;
662 662
 			}
663 663
 			closedir($handle);
664 664
 		} else {
665
-			$this->PushError("mput","can't open local folder", "Cannot read folder \"".$local."\"");
665
+			$this->PushError("mput", "can't open local folder", "Cannot read folder \"".$local."\"");
666 666
 			return FALSE;
667 667
 		}
668
-		if(empty($list)) return TRUE;
669
-		$ret=true;
670
-		foreach($list as $el) {
671
-			if(is_dir($local."/".$el)) $t=$this->mput($local."/".$el, $remote."/".$el);
672
-			else $t=$this->put($local."/".$el, $remote."/".$el);
673
-			if(!$t) {
674
-				$ret=FALSE;
675
-				if(!$continious) break;
668
+		if (empty($list)) return TRUE;
669
+		$ret = true;
670
+		foreach ($list as $el) {
671
+			if (is_dir($local."/".$el)) $t = $this->mput($local."/".$el, $remote."/".$el);
672
+			else $t = $this->put($local."/".$el, $remote."/".$el);
673
+			if ( ! $t) {
674
+				$ret = FALSE;
675
+				if ( ! $continious) break;
676 676
 			}
677 677
 		}
678 678
 		return $ret;
679 679
 
680 680
 	}
681 681
 
682
-	function mget($remote, $local=".", $continious=false) {
683
-		$list=$this->rawlist($remote, "-lA");
684
-		if($list===false) {
685
-			$this->PushError("mget","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
682
+	function mget($remote, $local = ".", $continious = false) {
683
+		$list = $this->rawlist($remote, "-lA");
684
+		if ($list === false) {
685
+			$this->PushError("mget", "can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
686 686
 			return FALSE;
687 687
 		}
688
-		if(empty($list)) return true;
689
-		if(!@file_exists($local)) {
690
-			if(!@mkdir($local)) {
691
-				$this->PushError("mget","can't create local folder", "Cannot create folder \"".$local."\"");
688
+		if (empty($list)) return true;
689
+		if ( ! @file_exists($local)) {
690
+			if ( ! @mkdir($local)) {
691
+				$this->PushError("mget", "can't create local folder", "Cannot create folder \"".$local."\"");
692 692
 				return FALSE;
693 693
 			}
694 694
 		}
695
-		foreach($list as $k=>$v) {
696
-			$list[$k]=$this->parselisting($v);
697
-			if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]);
695
+		foreach ($list as $k=>$v) {
696
+			$list[$k] = $this->parselisting($v);
697
+			if ( ! $list[$k] or $list[$k]["name"] == "." or $list[$k]["name"] == "..") unset($list[$k]);
698 698
 		}
699
-		$ret=true;
700
-		foreach($list as $el) {
701
-			if($el["type"]=="d") {
702
-				if(!$this->mget($remote."/".$el["name"], $local."/".$el["name"], $continious)) {
699
+		$ret = true;
700
+		foreach ($list as $el) {
701
+			if ($el["type"] == "d") {
702
+				if ( ! $this->mget($remote."/".$el["name"], $local."/".$el["name"], $continious)) {
703 703
 					$this->PushError("mget", "can't copy folder", "Can't copy remote folder \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\"");
704
-					$ret=false;
705
-					if(!$continious) break;
704
+					$ret = false;
705
+					if ( ! $continious) break;
706 706
 				}
707 707
 			} else {
708
-				if(!$this->get($remote."/".$el["name"], $local."/".$el["name"])) {
708
+				if ( ! $this->get($remote."/".$el["name"], $local."/".$el["name"])) {
709 709
 					$this->PushError("mget", "can't copy file", "Can't copy remote file \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\"");
710
-					$ret=false;
711
-					if(!$continious) break;
710
+					$ret = false;
711
+					if ( ! $continious) break;
712 712
 				}
713 713
 			}
714 714
 			@chmod($local."/".$el["name"], $el["perms"]);
715
-			$t=strtotime($el["date"]);
716
-			if($t!==-1 and $t!==false) @touch($local."/".$el["name"], $t);
715
+			$t = strtotime($el["date"]);
716
+			if ($t !== -1 and $t !== false) @touch($local."/".$el["name"], $t);
717 717
 		}
718 718
 		return $ret;
719 719
 	}
720 720
 
721
-	function mdel($remote, $continious=false) {
722
-		$list=$this->rawlist($remote, "-la");
723
-		if($list===false) {
724
-			$this->PushError("mdel","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
721
+	function mdel($remote, $continious = false) {
722
+		$list = $this->rawlist($remote, "-la");
723
+		if ($list === false) {
724
+			$this->PushError("mdel", "can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
725 725
 			return false;
726 726
 		}
727 727
 
728
-		foreach($list as $k=>$v) {
729
-			$list[$k]=$this->parselisting($v);
730
-			if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]);
728
+		foreach ($list as $k=>$v) {
729
+			$list[$k] = $this->parselisting($v);
730
+			if ( ! $list[$k] or $list[$k]["name"] == "." or $list[$k]["name"] == "..") unset($list[$k]);
731 731
 		}
732
-		$ret=true;
732
+		$ret = true;
733 733
 
734
-		foreach($list as $el) {
735
-			if ( empty($el) )
734
+		foreach ($list as $el) {
735
+			if (empty($el))
736 736
 				continue;
737 737
 
738
-			if($el["type"]=="d") {
739
-				if(!$this->mdel($remote."/".$el["name"], $continious)) {
740
-					$ret=false;
741
-					if(!$continious) break;
738
+			if ($el["type"] == "d") {
739
+				if ( ! $this->mdel($remote."/".$el["name"], $continious)) {
740
+					$ret = false;
741
+					if ( ! $continious) break;
742 742
 				}
743 743
 			} else {
744
-				if (!$this->delete($remote."/".$el["name"])) {
744
+				if ( ! $this->delete($remote."/".$el["name"])) {
745 745
 					$this->PushError("mdel", "can't delete file", "Can't delete remote file \"".$remote."/".$el["name"]."\"");
746
-					$ret=false;
747
-					if(!$continious) break;
746
+					$ret = false;
747
+					if ( ! $continious) break;
748 748
 				}
749 749
 			}
750 750
 		}
751 751
 
752
-		if(!$this->rmdir($remote)) {
752
+		if ( ! $this->rmdir($remote)) {
753 753
 			$this->PushError("mdel", "can't delete folder", "Can't delete remote folder \"".$remote."/".$el["name"]."\"");
754
-			$ret=false;
754
+			$ret = false;
755 755
 		}
756 756
 		return $ret;
757 757
 	}
758 758
 
759 759
 	function mmkdir($dir, $mode = 0777) {
760
-		if(empty($dir)) return FALSE;
761
-		if($this->is_exists($dir) or $dir == "/" ) return TRUE;
762
-		if(!$this->mmkdir(dirname($dir), $mode)) return false;
763
-		$r=$this->mkdir($dir, $mode);
764
-		$this->chmod($dir,$mode);
760
+		if (empty($dir)) return FALSE;
761
+		if ($this->is_exists($dir) or $dir == "/") return TRUE;
762
+		if ( ! $this->mmkdir(dirname($dir), $mode)) return false;
763
+		$r = $this->mkdir($dir, $mode);
764
+		$this->chmod($dir, $mode);
765 765
 		return $r;
766 766
 	}
767 767
 
768
-	function glob($pattern, $handle=NULL) {
769
-		$path=$output=null;
770
-		if(PHP_OS=='WIN32') $slash='\\';
771
-		else $slash='/';
772
-		$lastpos=strrpos($pattern,$slash);
773
-		if(!($lastpos===false)) {
774
-			$path=substr($pattern,0,-$lastpos-1);
775
-			$pattern=substr($pattern,$lastpos);
776
-		} else $path=getcwd();
777
-		if(is_array($handle) and !empty($handle)) {
778
-			while($dir=each($handle)) {
779
-				if($this->glob_pattern_match($pattern,$dir))
780
-				$output[]=$dir;
768
+	function glob($pattern, $handle = NULL) {
769
+		$path = $output = null;
770
+		if (PHP_OS == 'WIN32') $slash = '\\';
771
+		else $slash = '/';
772
+		$lastpos = strrpos($pattern, $slash);
773
+		if ( ! ($lastpos === false)) {
774
+			$path = substr($pattern, 0, -$lastpos - 1);
775
+			$pattern = substr($pattern, $lastpos);
776
+		} else $path = getcwd();
777
+		if (is_array($handle) and ! empty($handle)) {
778
+			while ($dir = each($handle)) {
779
+				if ($this->glob_pattern_match($pattern, $dir))
780
+				$output[] = $dir;
781 781
 			}
782 782
 		} else {
783
-			$handle=@opendir($path);
784
-			if($handle===false) return false;
785
-			while($dir=readdir($handle)) {
786
-				if($this->glob_pattern_match($pattern,$dir))
787
-				$output[]=$dir;
783
+			$handle = @opendir($path);
784
+			if ($handle === false) return false;
785
+			while ($dir = readdir($handle)) {
786
+				if ($this->glob_pattern_match($pattern, $dir))
787
+				$output[] = $dir;
788 788
 			}
789 789
 			closedir($handle);
790 790
 		}
791
-		if(is_array($output)) return $output;
791
+		if (is_array($output)) return $output;
792 792
 		return false;
793 793
 	}
794 794
 
795
-	function glob_pattern_match($pattern,$string) {
796
-		$out=null;
797
-		$chunks=explode(';',$pattern);
798
-		foreach($chunks as $pattern) {
799
-			$escape=array('$','^','.','{','}','(',')','[',']','|');
800
-			while(strpos($pattern,'**')!==false)
801
-				$pattern=str_replace('**','*',$pattern);
802
-			foreach($escape as $probe)
803
-				$pattern=str_replace($probe,"\\$probe",$pattern);
804
-			$pattern=str_replace('?*','*',
805
-				str_replace('*?','*',
806
-					str_replace('*',".*",
807
-						str_replace('?','.{1,1}',$pattern))));
808
-			$out[]=$pattern;
809
-		}
810
-		if(count($out)==1) return($this->glob_regexp("^$out[0]$",$string));
795
+	function glob_pattern_match($pattern, $string) {
796
+		$out = null;
797
+		$chunks = explode(';', $pattern);
798
+		foreach ($chunks as $pattern) {
799
+			$escape = array('$', '^', '.', '{', '}', '(', ')', '[', ']', '|');
800
+			while (strpos($pattern, '**') !== false)
801
+				$pattern = str_replace('**', '*', $pattern);
802
+			foreach ($escape as $probe)
803
+				$pattern = str_replace($probe, "\\$probe", $pattern);
804
+			$pattern = str_replace('?*', '*',
805
+				str_replace('*?', '*',
806
+					str_replace('*', ".*",
807
+						str_replace('?', '.{1,1}', $pattern))));
808
+			$out[] = $pattern;
809
+		}
810
+		if (count($out) == 1) return($this->glob_regexp("^$out[0]$", $string));
811 811
 		else {
812
-			foreach($out as $tester)
813
-				if($this->my_regexp("^$tester$",$string)) return true;
812
+			foreach ($out as $tester)
813
+				if ($this->my_regexp("^$tester$", $string)) return true;
814 814
 		}
815 815
 		return false;
816 816
 	}
817 817
 
818
-	function glob_regexp($pattern,$probe) {
819
-		$sensitive=(PHP_OS!='WIN32');
820
-		return ($sensitive?
821
-			preg_match( '/' . preg_quote( $pattern, '/' ) . '/', $probe ) :
822
-			preg_match( '/' . preg_quote( $pattern, '/' ) . '/i', $probe )
818
+	function glob_regexp($pattern, $probe) {
819
+		$sensitive = (PHP_OS != 'WIN32');
820
+		return ($sensitive ?
821
+			preg_match('/'.preg_quote($pattern, '/').'/', $probe) : preg_match('/'.preg_quote($pattern, '/').'/i', $probe)
823 822
 		);
824 823
 	}
825 824
 
826 825
 	function dirlist($remote) {
827
-		$list=$this->rawlist($remote, "-la");
828
-		if($list===false) {
829
-			$this->PushError("dirlist","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
826
+		$list = $this->rawlist($remote, "-la");
827
+		if ($list === false) {
828
+			$this->PushError("dirlist", "can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
830 829
 			return false;
831 830
 		}
832 831
 
833 832
 		$dirlist = array();
834
-		foreach($list as $k=>$v) {
835
-			$entry=$this->parselisting($v);
836
-			if ( empty($entry) )
833
+		foreach ($list as $k=>$v) {
834
+			$entry = $this->parselisting($v);
835
+			if (empty($entry))
837 836
 				continue;
838 837
 
839
-			if($entry["name"]=="." or $entry["name"]=="..")
838
+			if ($entry["name"] == "." or $entry["name"] == "..")
840 839
 				continue;
841 840
 
842 841
 			$dirlist[$entry['name']] = $entry;
@@ -848,27 +847,27 @@  discard block
 block discarded – undo
848 847
 // <!--       Private functions                                                                 -->
849 848
 // <!-- --------------------------------------------------------------------------------------- -->
850 849
 	function _checkCode() {
851
-		return ($this->_code<400 and $this->_code>0);
850
+		return ($this->_code < 400 and $this->_code > 0);
852 851
 	}
853 852
 
854
-	function _list($arg="", $cmd="LIST", $fnction="_list") {
855
-		if(!$this->_data_prepare()) return false;
856
-		if(!$this->_exec($cmd.$arg, $fnction)) {
853
+	function _list($arg = "", $cmd = "LIST", $fnction = "_list") {
854
+		if ( ! $this->_data_prepare()) return false;
855
+		if ( ! $this->_exec($cmd.$arg, $fnction)) {
857 856
 			$this->_data_close();
858 857
 			return FALSE;
859 858
 		}
860
-		if(!$this->_checkCode()) {
859
+		if ( ! $this->_checkCode()) {
861 860
 			$this->_data_close();
862 861
 			return FALSE;
863 862
 		}
864
-		$out="";
865
-		if($this->_code<200) {
866
-			$out=$this->_data_read();
863
+		$out = "";
864
+		if ($this->_code < 200) {
865
+			$out = $this->_data_read();
867 866
 			$this->_data_close();
868
-			if(!$this->_readmsg()) return FALSE;
869
-			if(!$this->_checkCode()) return FALSE;
870
-			if($out === FALSE ) return FALSE;
871
-			$out=preg_split("/[".CRLF."]+/", $out, -1, PREG_SPLIT_NO_EMPTY);
867
+			if ( ! $this->_readmsg()) return FALSE;
868
+			if ( ! $this->_checkCode()) return FALSE;
869
+			if ($out === FALSE) return FALSE;
870
+			$out = preg_split("/[".CRLF."]+/", $out, -1, PREG_SPLIT_NO_EMPTY);
872 871
 //			$this->SendMSG(implode($this->_eol_code[$this->OS_local], $out));
873 872
 		}
874 873
 		return $out;
@@ -878,34 +877,34 @@  discard block
 block discarded – undo
878 877
 // <!-- Partie : gestion des erreurs                                                            -->
879 878
 // <!-- --------------------------------------------------------------------------------------- -->
880 879
 // Gnre une erreur pour traitement externe  la classe
881
-	function PushError($fctname,$msg,$desc=false){
882
-		$error=array();
883
-		$error['time']=time();
884
-		$error['fctname']=$fctname;
885
-		$error['msg']=$msg;
886
-		$error['desc']=$desc;
887
-		if($desc) $tmp=' ('.$desc.')'; else $tmp='';
880
+	function PushError($fctname, $msg, $desc = false) {
881
+		$error = array();
882
+		$error['time'] = time();
883
+		$error['fctname'] = $fctname;
884
+		$error['msg'] = $msg;
885
+		$error['desc'] = $desc;
886
+		if ($desc) $tmp = ' ('.$desc.')'; else $tmp = '';
888 887
 		$this->SendMSG($fctname.': '.$msg.$tmp);
889
-		return(array_push($this->_error_array,$error));
888
+		return(array_push($this->_error_array, $error));
890 889
 	}
891 890
 
892 891
 // Rcupre une erreur externe
893
-	function PopError(){
894
-		if(count($this->_error_array)) return(array_pop($this->_error_array));
892
+	function PopError() {
893
+		if (count($this->_error_array)) return(array_pop($this->_error_array));
895 894
 			else return(false);
896 895
 	}
897 896
 }
898 897
 
899
-$mod_sockets = extension_loaded( 'sockets' );
900
-if ( ! $mod_sockets && function_exists( 'dl' ) && is_callable( 'dl' ) ) {
901
-	$prefix = ( PHP_SHLIB_SUFFIX == 'dll' ) ? 'php_' : '';
902
-	@dl( $prefix . 'sockets.' . PHP_SHLIB_SUFFIX );
903
-	$mod_sockets = extension_loaded( 'sockets' );
898
+$mod_sockets = extension_loaded('sockets');
899
+if ( ! $mod_sockets && function_exists('dl') && is_callable('dl')) {
900
+	$prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : '';
901
+	@dl($prefix.'sockets.'.PHP_SHLIB_SUFFIX);
902
+	$mod_sockets = extension_loaded('sockets');
904 903
 }
905 904
 
906
-require_once dirname( __FILE__ ) . "/class-ftp-" . ( $mod_sockets ? "sockets" : "pure" ) . ".php";
905
+require_once dirname(__FILE__)."/class-ftp-".($mod_sockets ? "sockets" : "pure").".php";
907 906
 
908
-if ( $mod_sockets ) {
907
+if ($mod_sockets) {
909 908
 	class ftp extends ftp_sockets {}
910 909
 } else {
911 910
 	class ftp extends ftp_pure {}
Please login to merge, or discard this patch.
src/wp-admin/includes/class-pclzip.php 4 patches
Doc Comments   +22 added lines patch added patch discarded remove patch
@@ -2339,6 +2339,10 @@  discard block
 block discarded – undo
2339 2339
   // Description :
2340 2340
   // Parameters :
2341 2341
   // --------------------------------------------------------------------------------
2342
+
2343
+  /**
2344
+   * @param string $p_mode
2345
+   */
2342 2346
   function privOpenFd($p_mode)
2343 2347
   {
2344 2348
     $v_result=1;
@@ -4150,6 +4154,10 @@  discard block
 block discarded – undo
4150 4154
   // Parameters :
4151 4155
   // Return Values :
4152 4156
   // --------------------------------------------------------------------------------
4157
+
4158
+  /**
4159
+   * @param string $p_string
4160
+   */
4153 4161
   function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4154 4162
   {
4155 4163
     $v_result=1;
@@ -5041,6 +5049,10 @@  discard block
 block discarded – undo
5041 5049
   // Parameters :
5042 5050
   // Return Values :
5043 5051
   // --------------------------------------------------------------------------------
5052
+
5053
+  /**
5054
+   * @param PclZip $p_archive_to_add
5055
+   */
5044 5056
   function privMerge(&$p_archive_to_add)
5045 5057
   {
5046 5058
     $v_result=1;
@@ -5548,6 +5560,11 @@  discard block
 block discarded – undo
5548 5560
   //             3 : src & dest gzip
5549 5561
   // Return Values :
5550 5562
   // --------------------------------------------------------------------------------
5563
+
5564
+  /**
5565
+   * @param integer $p_src
5566
+   * @param integer $p_dest
5567
+   */
5551 5568
   function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5552 5569
   {
5553 5570
     $v_result = 1;
@@ -5610,6 +5627,11 @@  discard block
 block discarded – undo
5610 5627
   // Return Values :
5611 5628
   //   1 on success, 0 on failure.
5612 5629
   // --------------------------------------------------------------------------------
5630
+
5631
+  /**
5632
+   * @param string $p_src
5633
+   * @param string $p_dest
5634
+   */
5613 5635
   function PclZipUtilRename($p_src, $p_dest)
5614 5636
   {
5615 5637
     $v_result = 1;
Please login to merge, or discard this patch.
Indentation   +3782 added lines, -3782 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
   // ----- Constants
29 29
   if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
30
-    define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
30
+	define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
31 31
   }
32 32
 
33 33
   // ----- File list separator
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
   //define( 'PCLZIP_SEPARATOR', ' ' );
42 42
   // Recommanded values for smart separation of filenames.
43 43
   if (!defined('PCLZIP_SEPARATOR')) {
44
-    define( 'PCLZIP_SEPARATOR', ',' );
44
+	define( 'PCLZIP_SEPARATOR', ',' );
45 45
   }
46 46
 
47 47
   // ----- Error configuration
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
   //     you must ensure that you have included PclError library.
51 51
   // [2,...] : reserved for futur use
52 52
   if (!defined('PCLZIP_ERROR_EXTERNAL')) {
53
-    define( 'PCLZIP_ERROR_EXTERNAL', 0 );
53
+	define( 'PCLZIP_ERROR_EXTERNAL', 0 );
54 54
   }
55 55
 
56 56
   // ----- Optional static temporary directory
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
   // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
64 64
   // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
65 65
   if (!defined('PCLZIP_TEMPORARY_DIR')) {
66
-    define( 'PCLZIP_TEMPORARY_DIR', '' );
66
+	define( 'PCLZIP_TEMPORARY_DIR', '' );
67 67
   }
68 68
 
69 69
   // ----- Optional threshold ratio for use of temporary files
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
   //       Samples :
76 76
   // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
77 77
   if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
78
-    define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
78
+	define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
79 79
   }
80 80
 
81 81
 // --------------------------------------------------------------------------------
@@ -189,20 +189,20 @@  discard block
 block discarded – undo
189 189
   // --------------------------------------------------------------------------------
190 190
   class PclZip
191 191
   {
192
-    // ----- Filename of the zip file
193
-    var $zipname = '';
192
+	// ----- Filename of the zip file
193
+	var $zipname = '';
194 194
 
195
-    // ----- File descriptor of the zip file
196
-    var $zip_fd = 0;
195
+	// ----- File descriptor of the zip file
196
+	var $zip_fd = 0;
197 197
 
198
-    // ----- Internal error handling
199
-    var $error_code = 1;
200
-    var $error_string = '';
198
+	// ----- Internal error handling
199
+	var $error_code = 1;
200
+	var $error_string = '';
201 201
 
202
-    // ----- Current status of the magic_quotes_runtime
203
-    // This value store the php configuration for magic_quotes
204
-    // The class can then disable the magic_quotes and reset it after
205
-    var $magic_quotes_status;
202
+	// ----- Current status of the magic_quotes_runtime
203
+	// This value store the php configuration for magic_quotes
204
+	// The class can then disable the magic_quotes and reset it after
205
+	var $magic_quotes_status;
206 206
 
207 207
   // --------------------------------------------------------------------------------
208 208
   // Function : PclZip()
@@ -215,23 +215,23 @@  discard block
 block discarded – undo
215 215
   function __construct($p_zipname)
216 216
   {
217 217
 
218
-    // ----- Tests the zlib
219
-    if (!function_exists('gzopen'))
220
-    {
221
-      die('Abort '.basename(__FILE__).' : Missing zlib extensions');
222
-    }
218
+	// ----- Tests the zlib
219
+	if (!function_exists('gzopen'))
220
+	{
221
+	  die('Abort '.basename(__FILE__).' : Missing zlib extensions');
222
+	}
223 223
 
224
-    // ----- Set the attributes
225
-    $this->zipname = $p_zipname;
226
-    $this->zip_fd = 0;
227
-    $this->magic_quotes_status = -1;
224
+	// ----- Set the attributes
225
+	$this->zipname = $p_zipname;
226
+	$this->zip_fd = 0;
227
+	$this->magic_quotes_status = -1;
228 228
 
229
-    // ----- Return
230
-    return;
229
+	// ----- Return
230
+	return;
231 231
   }
232 232
 
233 233
   public function PclZip($p_zipname) {
234
-    self::__construct($p_zipname);
234
+	self::__construct($p_zipname);
235 235
   }
236 236
   // --------------------------------------------------------------------------------
237 237
 
@@ -274,149 +274,149 @@  discard block
 block discarded – undo
274 274
   // --------------------------------------------------------------------------------
275 275
   function create($p_filelist)
276 276
   {
277
-    $v_result=1;
278
-
279
-    // ----- Reset the error handler
280
-    $this->privErrorReset();
281
-
282
-    // ----- Set default values
283
-    $v_options = array();
284
-    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
285
-
286
-    // ----- Look for variable options arguments
287
-    $v_size = func_num_args();
288
-
289
-    // ----- Look for arguments
290
-    if ($v_size > 1) {
291
-      // ----- Get the arguments
292
-      $v_arg_list = func_get_args();
293
-
294
-      // ----- Remove from the options list the first argument
295
-      array_shift($v_arg_list);
296
-      $v_size--;
297
-
298
-      // ----- Look for first arg
299
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
300
-
301
-        // ----- Parse the options
302
-        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
303
-                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
304
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
305
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',
306
-                                                   PCLZIP_CB_PRE_ADD => 'optional',
307
-                                                   PCLZIP_CB_POST_ADD => 'optional',
308
-                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',
309
-                                                   PCLZIP_OPT_COMMENT => 'optional',
310
-                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
311
-                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
312
-                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
313
-                                                   //, PCLZIP_OPT_CRYPT => 'optional'
314
-                                             ));
315
-        if ($v_result != 1) {
316
-          return 0;
317
-        }
318
-      }
277
+	$v_result=1;
278
+
279
+	// ----- Reset the error handler
280
+	$this->privErrorReset();
281
+
282
+	// ----- Set default values
283
+	$v_options = array();
284
+	$v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
285
+
286
+	// ----- Look for variable options arguments
287
+	$v_size = func_num_args();
288
+
289
+	// ----- Look for arguments
290
+	if ($v_size > 1) {
291
+	  // ----- Get the arguments
292
+	  $v_arg_list = func_get_args();
293
+
294
+	  // ----- Remove from the options list the first argument
295
+	  array_shift($v_arg_list);
296
+	  $v_size--;
297
+
298
+	  // ----- Look for first arg
299
+	  if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
300
+
301
+		// ----- Parse the options
302
+		$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
303
+											array (PCLZIP_OPT_REMOVE_PATH => 'optional',
304
+												   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
305
+												   PCLZIP_OPT_ADD_PATH => 'optional',
306
+												   PCLZIP_CB_PRE_ADD => 'optional',
307
+												   PCLZIP_CB_POST_ADD => 'optional',
308
+												   PCLZIP_OPT_NO_COMPRESSION => 'optional',
309
+												   PCLZIP_OPT_COMMENT => 'optional',
310
+												   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
311
+												   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
312
+												   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
313
+												   //, PCLZIP_OPT_CRYPT => 'optional'
314
+											 ));
315
+		if ($v_result != 1) {
316
+		  return 0;
317
+		}
318
+	  }
319 319
 
320
-      // ----- Look for 2 args
321
-      // Here we need to support the first historic synopsis of the
322
-      // method.
323
-      else {
324
-
325
-        // ----- Get the first argument
326
-        $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
327
-
328
-        // ----- Look for the optional second argument
329
-        if ($v_size == 2) {
330
-          $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
331
-        }
332
-        else if ($v_size > 2) {
333
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
334
-		                       "Invalid number / type of arguments");
335
-          return 0;
336
-        }
337
-      }
338
-    }
320
+	  // ----- Look for 2 args
321
+	  // Here we need to support the first historic synopsis of the
322
+	  // method.
323
+	  else {
324
+
325
+		// ----- Get the first argument
326
+		$v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
327
+
328
+		// ----- Look for the optional second argument
329
+		if ($v_size == 2) {
330
+		  $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
331
+		}
332
+		else if ($v_size > 2) {
333
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
334
+							   "Invalid number / type of arguments");
335
+		  return 0;
336
+		}
337
+	  }
338
+	}
339 339
 
340
-    // ----- Look for default option values
341
-    $this->privOptionDefaultThreshold($v_options);
340
+	// ----- Look for default option values
341
+	$this->privOptionDefaultThreshold($v_options);
342 342
 
343
-    // ----- Init
344
-    $v_string_list = array();
345
-    $v_att_list = array();
346
-    $v_filedescr_list = array();
347
-    $p_result_list = array();
343
+	// ----- Init
344
+	$v_string_list = array();
345
+	$v_att_list = array();
346
+	$v_filedescr_list = array();
347
+	$p_result_list = array();
348 348
 
349
-    // ----- Look if the $p_filelist is really an array
350
-    if (is_array($p_filelist)) {
349
+	// ----- Look if the $p_filelist is really an array
350
+	if (is_array($p_filelist)) {
351 351
 
352
-      // ----- Look if the first element is also an array
353
-      //       This will mean that this is a file description entry
354
-      if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
355
-        $v_att_list = $p_filelist;
356
-      }
352
+	  // ----- Look if the first element is also an array
353
+	  //       This will mean that this is a file description entry
354
+	  if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
355
+		$v_att_list = $p_filelist;
356
+	  }
357 357
 
358
-      // ----- The list is a list of string names
359
-      else {
360
-        $v_string_list = $p_filelist;
361
-      }
362
-    }
358
+	  // ----- The list is a list of string names
359
+	  else {
360
+		$v_string_list = $p_filelist;
361
+	  }
362
+	}
363 363
 
364
-    // ----- Look if the $p_filelist is a string
365
-    else if (is_string($p_filelist)) {
366
-      // ----- Create a list from the string
367
-      $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
368
-    }
364
+	// ----- Look if the $p_filelist is a string
365
+	else if (is_string($p_filelist)) {
366
+	  // ----- Create a list from the string
367
+	  $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
368
+	}
369 369
 
370
-    // ----- Invalid variable type for $p_filelist
371
-    else {
372
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
373
-      return 0;
374
-    }
370
+	// ----- Invalid variable type for $p_filelist
371
+	else {
372
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
373
+	  return 0;
374
+	}
375 375
 
376
-    // ----- Reformat the string list
377
-    if (sizeof($v_string_list) != 0) {
378
-      foreach ($v_string_list as $v_string) {
379
-        if ($v_string != '') {
380
-          $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
381
-        }
382
-        else {
383
-        }
384
-      }
385
-    }
376
+	// ----- Reformat the string list
377
+	if (sizeof($v_string_list) != 0) {
378
+	  foreach ($v_string_list as $v_string) {
379
+		if ($v_string != '') {
380
+		  $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
381
+		}
382
+		else {
383
+		}
384
+	  }
385
+	}
386 386
 
387
-    // ----- For each file in the list check the attributes
388
-    $v_supported_attributes
389
-    = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
390
-             ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
391
-             ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
392
-             ,PCLZIP_ATT_FILE_MTIME => 'optional'
393
-             ,PCLZIP_ATT_FILE_CONTENT => 'optional'
394
-             ,PCLZIP_ATT_FILE_COMMENT => 'optional'
387
+	// ----- For each file in the list check the attributes
388
+	$v_supported_attributes
389
+	= array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
390
+			 ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
391
+			 ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
392
+			 ,PCLZIP_ATT_FILE_MTIME => 'optional'
393
+			 ,PCLZIP_ATT_FILE_CONTENT => 'optional'
394
+			 ,PCLZIP_ATT_FILE_COMMENT => 'optional'
395 395
 						);
396
-    foreach ($v_att_list as $v_entry) {
397
-      $v_result = $this->privFileDescrParseAtt($v_entry,
398
-                                               $v_filedescr_list[],
399
-                                               $v_options,
400
-                                               $v_supported_attributes);
401
-      if ($v_result != 1) {
402
-        return 0;
403
-      }
404
-    }
396
+	foreach ($v_att_list as $v_entry) {
397
+	  $v_result = $this->privFileDescrParseAtt($v_entry,
398
+											   $v_filedescr_list[],
399
+											   $v_options,
400
+											   $v_supported_attributes);
401
+	  if ($v_result != 1) {
402
+		return 0;
403
+	  }
404
+	}
405 405
 
406
-    // ----- Expand the filelist (expand directories)
407
-    $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
408
-    if ($v_result != 1) {
409
-      return 0;
410
-    }
406
+	// ----- Expand the filelist (expand directories)
407
+	$v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
408
+	if ($v_result != 1) {
409
+	  return 0;
410
+	}
411 411
 
412
-    // ----- Call the create fct
413
-    $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
414
-    if ($v_result != 1) {
415
-      return 0;
416
-    }
412
+	// ----- Call the create fct
413
+	$v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
414
+	if ($v_result != 1) {
415
+	  return 0;
416
+	}
417 417
 
418
-    // ----- Return
419
-    return $p_result_list;
418
+	// ----- Return
419
+	return $p_result_list;
420 420
   }
421 421
   // --------------------------------------------------------------------------------
422 422
 
@@ -457,149 +457,149 @@  discard block
 block discarded – undo
457 457
   // --------------------------------------------------------------------------------
458 458
   function add($p_filelist)
459 459
   {
460
-    $v_result=1;
461
-
462
-    // ----- Reset the error handler
463
-    $this->privErrorReset();
464
-
465
-    // ----- Set default values
466
-    $v_options = array();
467
-    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
468
-
469
-    // ----- Look for variable options arguments
470
-    $v_size = func_num_args();
471
-
472
-    // ----- Look for arguments
473
-    if ($v_size > 1) {
474
-      // ----- Get the arguments
475
-      $v_arg_list = func_get_args();
476
-
477
-      // ----- Remove form the options list the first argument
478
-      array_shift($v_arg_list);
479
-      $v_size--;
480
-
481
-      // ----- Look for first arg
482
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
483
-
484
-        // ----- Parse the options
485
-        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
486
-                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
487
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
488
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',
489
-                                                   PCLZIP_CB_PRE_ADD => 'optional',
490
-                                                   PCLZIP_CB_POST_ADD => 'optional',
491
-                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',
492
-                                                   PCLZIP_OPT_COMMENT => 'optional',
493
-                                                   PCLZIP_OPT_ADD_COMMENT => 'optional',
494
-                                                   PCLZIP_OPT_PREPEND_COMMENT => 'optional',
495
-                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
496
-                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
497
-                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
498
-                                                   //, PCLZIP_OPT_CRYPT => 'optional'
460
+	$v_result=1;
461
+
462
+	// ----- Reset the error handler
463
+	$this->privErrorReset();
464
+
465
+	// ----- Set default values
466
+	$v_options = array();
467
+	$v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
468
+
469
+	// ----- Look for variable options arguments
470
+	$v_size = func_num_args();
471
+
472
+	// ----- Look for arguments
473
+	if ($v_size > 1) {
474
+	  // ----- Get the arguments
475
+	  $v_arg_list = func_get_args();
476
+
477
+	  // ----- Remove form the options list the first argument
478
+	  array_shift($v_arg_list);
479
+	  $v_size--;
480
+
481
+	  // ----- Look for first arg
482
+	  if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
483
+
484
+		// ----- Parse the options
485
+		$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
486
+											array (PCLZIP_OPT_REMOVE_PATH => 'optional',
487
+												   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
488
+												   PCLZIP_OPT_ADD_PATH => 'optional',
489
+												   PCLZIP_CB_PRE_ADD => 'optional',
490
+												   PCLZIP_CB_POST_ADD => 'optional',
491
+												   PCLZIP_OPT_NO_COMPRESSION => 'optional',
492
+												   PCLZIP_OPT_COMMENT => 'optional',
493
+												   PCLZIP_OPT_ADD_COMMENT => 'optional',
494
+												   PCLZIP_OPT_PREPEND_COMMENT => 'optional',
495
+												   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
496
+												   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
497
+												   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
498
+												   //, PCLZIP_OPT_CRYPT => 'optional'
499 499
 												   ));
500
-        if ($v_result != 1) {
501
-          return 0;
502
-        }
503
-      }
500
+		if ($v_result != 1) {
501
+		  return 0;
502
+		}
503
+	  }
504 504
 
505
-      // ----- Look for 2 args
506
-      // Here we need to support the first historic synopsis of the
507
-      // method.
508
-      else {
509
-
510
-        // ----- Get the first argument
511
-        $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
512
-
513
-        // ----- Look for the optional second argument
514
-        if ($v_size == 2) {
515
-          $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
516
-        }
517
-        else if ($v_size > 2) {
518
-          // ----- Error log
519
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
520
-
521
-          // ----- Return
522
-          return 0;
523
-        }
524
-      }
525
-    }
505
+	  // ----- Look for 2 args
506
+	  // Here we need to support the first historic synopsis of the
507
+	  // method.
508
+	  else {
509
+
510
+		// ----- Get the first argument
511
+		$v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
512
+
513
+		// ----- Look for the optional second argument
514
+		if ($v_size == 2) {
515
+		  $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
516
+		}
517
+		else if ($v_size > 2) {
518
+		  // ----- Error log
519
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
520
+
521
+		  // ----- Return
522
+		  return 0;
523
+		}
524
+	  }
525
+	}
526 526
 
527
-    // ----- Look for default option values
528
-    $this->privOptionDefaultThreshold($v_options);
527
+	// ----- Look for default option values
528
+	$this->privOptionDefaultThreshold($v_options);
529 529
 
530
-    // ----- Init
531
-    $v_string_list = array();
532
-    $v_att_list = array();
533
-    $v_filedescr_list = array();
534
-    $p_result_list = array();
530
+	// ----- Init
531
+	$v_string_list = array();
532
+	$v_att_list = array();
533
+	$v_filedescr_list = array();
534
+	$p_result_list = array();
535 535
 
536
-    // ----- Look if the $p_filelist is really an array
537
-    if (is_array($p_filelist)) {
536
+	// ----- Look if the $p_filelist is really an array
537
+	if (is_array($p_filelist)) {
538 538
 
539
-      // ----- Look if the first element is also an array
540
-      //       This will mean that this is a file description entry
541
-      if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
542
-        $v_att_list = $p_filelist;
543
-      }
539
+	  // ----- Look if the first element is also an array
540
+	  //       This will mean that this is a file description entry
541
+	  if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
542
+		$v_att_list = $p_filelist;
543
+	  }
544 544
 
545
-      // ----- The list is a list of string names
546
-      else {
547
-        $v_string_list = $p_filelist;
548
-      }
549
-    }
545
+	  // ----- The list is a list of string names
546
+	  else {
547
+		$v_string_list = $p_filelist;
548
+	  }
549
+	}
550 550
 
551
-    // ----- Look if the $p_filelist is a string
552
-    else if (is_string($p_filelist)) {
553
-      // ----- Create a list from the string
554
-      $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
555
-    }
551
+	// ----- Look if the $p_filelist is a string
552
+	else if (is_string($p_filelist)) {
553
+	  // ----- Create a list from the string
554
+	  $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
555
+	}
556 556
 
557
-    // ----- Invalid variable type for $p_filelist
558
-    else {
559
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
560
-      return 0;
561
-    }
557
+	// ----- Invalid variable type for $p_filelist
558
+	else {
559
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
560
+	  return 0;
561
+	}
562 562
 
563
-    // ----- Reformat the string list
564
-    if (sizeof($v_string_list) != 0) {
565
-      foreach ($v_string_list as $v_string) {
566
-        $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
567
-      }
568
-    }
563
+	// ----- Reformat the string list
564
+	if (sizeof($v_string_list) != 0) {
565
+	  foreach ($v_string_list as $v_string) {
566
+		$v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
567
+	  }
568
+	}
569 569
 
570
-    // ----- For each file in the list check the attributes
571
-    $v_supported_attributes
572
-    = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
573
-             ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
574
-             ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
575
-             ,PCLZIP_ATT_FILE_MTIME => 'optional'
576
-             ,PCLZIP_ATT_FILE_CONTENT => 'optional'
577
-             ,PCLZIP_ATT_FILE_COMMENT => 'optional'
570
+	// ----- For each file in the list check the attributes
571
+	$v_supported_attributes
572
+	= array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
573
+			 ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
574
+			 ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
575
+			 ,PCLZIP_ATT_FILE_MTIME => 'optional'
576
+			 ,PCLZIP_ATT_FILE_CONTENT => 'optional'
577
+			 ,PCLZIP_ATT_FILE_COMMENT => 'optional'
578 578
 						);
579
-    foreach ($v_att_list as $v_entry) {
580
-      $v_result = $this->privFileDescrParseAtt($v_entry,
581
-                                               $v_filedescr_list[],
582
-                                               $v_options,
583
-                                               $v_supported_attributes);
584
-      if ($v_result != 1) {
585
-        return 0;
586
-      }
587
-    }
579
+	foreach ($v_att_list as $v_entry) {
580
+	  $v_result = $this->privFileDescrParseAtt($v_entry,
581
+											   $v_filedescr_list[],
582
+											   $v_options,
583
+											   $v_supported_attributes);
584
+	  if ($v_result != 1) {
585
+		return 0;
586
+	  }
587
+	}
588 588
 
589
-    // ----- Expand the filelist (expand directories)
590
-    $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
591
-    if ($v_result != 1) {
592
-      return 0;
593
-    }
589
+	// ----- Expand the filelist (expand directories)
590
+	$v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
591
+	if ($v_result != 1) {
592
+	  return 0;
593
+	}
594 594
 
595
-    // ----- Call the create fct
596
-    $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
597
-    if ($v_result != 1) {
598
-      return 0;
599
-    }
595
+	// ----- Call the create fct
596
+	$v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
597
+	if ($v_result != 1) {
598
+	  return 0;
599
+	}
600 600
 
601
-    // ----- Return
602
-    return $p_result_list;
601
+	// ----- Return
602
+	return $p_result_list;
603 603
   }
604 604
   // --------------------------------------------------------------------------------
605 605
 
@@ -646,26 +646,26 @@  discard block
 block discarded – undo
646 646
   // --------------------------------------------------------------------------------
647 647
   function listContent()
648 648
   {
649
-    $v_result=1;
649
+	$v_result=1;
650 650
 
651
-    // ----- Reset the error handler
652
-    $this->privErrorReset();
651
+	// ----- Reset the error handler
652
+	$this->privErrorReset();
653 653
 
654
-    // ----- Check archive
655
-    if (!$this->privCheckFormat()) {
656
-      return(0);
657
-    }
654
+	// ----- Check archive
655
+	if (!$this->privCheckFormat()) {
656
+	  return(0);
657
+	}
658 658
 
659
-    // ----- Call the extracting fct
660
-    $p_list = array();
661
-    if (($v_result = $this->privList($p_list)) != 1)
662
-    {
663
-      unset($p_list);
664
-      return(0);
665
-    }
659
+	// ----- Call the extracting fct
660
+	$p_list = array();
661
+	if (($v_result = $this->privList($p_list)) != 1)
662
+	{
663
+	  unset($p_list);
664
+	  return(0);
665
+	}
666 666
 
667
-    // ----- Return
668
-    return $p_list;
667
+	// ----- Return
668
+	return $p_list;
669 669
   }
670 670
   // --------------------------------------------------------------------------------
671 671
 
@@ -703,120 +703,120 @@  discard block
 block discarded – undo
703 703
   // --------------------------------------------------------------------------------
704 704
   function extract()
705 705
   {
706
-    $v_result=1;
706
+	$v_result=1;
707 707
 
708
-    // ----- Reset the error handler
709
-    $this->privErrorReset();
708
+	// ----- Reset the error handler
709
+	$this->privErrorReset();
710 710
 
711
-    // ----- Check archive
712
-    if (!$this->privCheckFormat()) {
713
-      return(0);
714
-    }
711
+	// ----- Check archive
712
+	if (!$this->privCheckFormat()) {
713
+	  return(0);
714
+	}
715 715
 
716
-    // ----- Set default values
717
-    $v_options = array();
716
+	// ----- Set default values
717
+	$v_options = array();
718 718
 //    $v_path = "./";
719
-    $v_path = '';
720
-    $v_remove_path = "";
721
-    $v_remove_all_path = false;
722
-
723
-    // ----- Look for variable options arguments
724
-    $v_size = func_num_args();
725
-
726
-    // ----- Default values for option
727
-    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
728
-
729
-    // ----- Look for arguments
730
-    if ($v_size > 0) {
731
-      // ----- Get the arguments
732
-      $v_arg_list = func_get_args();
733
-
734
-      // ----- Look for first arg
735
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
736
-
737
-        // ----- Parse the options
738
-        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
739
-                                            array (PCLZIP_OPT_PATH => 'optional',
740
-                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
741
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
742
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',
743
-                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
744
-                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
745
-                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
746
-                                                   PCLZIP_OPT_BY_NAME => 'optional',
747
-                                                   PCLZIP_OPT_BY_EREG => 'optional',
748
-                                                   PCLZIP_OPT_BY_PREG => 'optional',
749
-                                                   PCLZIP_OPT_BY_INDEX => 'optional',
750
-                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
751
-                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
752
-                                                   PCLZIP_OPT_REPLACE_NEWER => 'optional'
753
-                                                   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
754
-                                                   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
755
-                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
756
-                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
757
-                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
758
-												    ));
759
-        if ($v_result != 1) {
760
-          return 0;
761
-        }
762
-
763
-        // ----- Set the arguments
764
-        if (isset($v_options[PCLZIP_OPT_PATH])) {
765
-          $v_path = $v_options[PCLZIP_OPT_PATH];
766
-        }
767
-        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
768
-          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
769
-        }
770
-        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
771
-          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
772
-        }
773
-        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
774
-          // ----- Check for '/' in last path char
775
-          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
776
-            $v_path .= '/';
777
-          }
778
-          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
779
-        }
780
-      }
719
+	$v_path = '';
720
+	$v_remove_path = "";
721
+	$v_remove_all_path = false;
722
+
723
+	// ----- Look for variable options arguments
724
+	$v_size = func_num_args();
725
+
726
+	// ----- Default values for option
727
+	$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
728
+
729
+	// ----- Look for arguments
730
+	if ($v_size > 0) {
731
+	  // ----- Get the arguments
732
+	  $v_arg_list = func_get_args();
733
+
734
+	  // ----- Look for first arg
735
+	  if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
736
+
737
+		// ----- Parse the options
738
+		$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
739
+											array (PCLZIP_OPT_PATH => 'optional',
740
+												   PCLZIP_OPT_REMOVE_PATH => 'optional',
741
+												   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
742
+												   PCLZIP_OPT_ADD_PATH => 'optional',
743
+												   PCLZIP_CB_PRE_EXTRACT => 'optional',
744
+												   PCLZIP_CB_POST_EXTRACT => 'optional',
745
+												   PCLZIP_OPT_SET_CHMOD => 'optional',
746
+												   PCLZIP_OPT_BY_NAME => 'optional',
747
+												   PCLZIP_OPT_BY_EREG => 'optional',
748
+												   PCLZIP_OPT_BY_PREG => 'optional',
749
+												   PCLZIP_OPT_BY_INDEX => 'optional',
750
+												   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
751
+												   PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
752
+												   PCLZIP_OPT_REPLACE_NEWER => 'optional'
753
+												   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
754
+												   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
755
+												   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
756
+												   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
757
+												   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
758
+													));
759
+		if ($v_result != 1) {
760
+		  return 0;
761
+		}
762
+
763
+		// ----- Set the arguments
764
+		if (isset($v_options[PCLZIP_OPT_PATH])) {
765
+		  $v_path = $v_options[PCLZIP_OPT_PATH];
766
+		}
767
+		if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
768
+		  $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
769
+		}
770
+		if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
771
+		  $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
772
+		}
773
+		if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
774
+		  // ----- Check for '/' in last path char
775
+		  if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
776
+			$v_path .= '/';
777
+		  }
778
+		  $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
779
+		}
780
+	  }
781 781
 
782
-      // ----- Look for 2 args
783
-      // Here we need to support the first historic synopsis of the
784
-      // method.
785
-      else {
786
-
787
-        // ----- Get the first argument
788
-        $v_path = $v_arg_list[0];
789
-
790
-        // ----- Look for the optional second argument
791
-        if ($v_size == 2) {
792
-          $v_remove_path = $v_arg_list[1];
793
-        }
794
-        else if ($v_size > 2) {
795
-          // ----- Error log
796
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
797
-
798
-          // ----- Return
799
-          return 0;
800
-        }
801
-      }
802
-    }
782
+	  // ----- Look for 2 args
783
+	  // Here we need to support the first historic synopsis of the
784
+	  // method.
785
+	  else {
786
+
787
+		// ----- Get the first argument
788
+		$v_path = $v_arg_list[0];
789
+
790
+		// ----- Look for the optional second argument
791
+		if ($v_size == 2) {
792
+		  $v_remove_path = $v_arg_list[1];
793
+		}
794
+		else if ($v_size > 2) {
795
+		  // ----- Error log
796
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
797
+
798
+		  // ----- Return
799
+		  return 0;
800
+		}
801
+	  }
802
+	}
803 803
 
804
-    // ----- Look for default option values
805
-    $this->privOptionDefaultThreshold($v_options);
804
+	// ----- Look for default option values
805
+	$this->privOptionDefaultThreshold($v_options);
806 806
 
807
-    // ----- Trace
807
+	// ----- Trace
808 808
 
809
-    // ----- Call the extracting fct
810
-    $p_list = array();
811
-    $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
812
-	                                     $v_remove_all_path, $v_options);
813
-    if ($v_result < 1) {
814
-      unset($p_list);
815
-      return(0);
816
-    }
809
+	// ----- Call the extracting fct
810
+	$p_list = array();
811
+	$v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
812
+										 $v_remove_all_path, $v_options);
813
+	if ($v_result < 1) {
814
+	  unset($p_list);
815
+	  return(0);
816
+	}
817 817
 
818
-    // ----- Return
819
-    return $p_list;
818
+	// ----- Return
819
+	return $p_list;
820 820
   }
821 821
   // --------------------------------------------------------------------------------
822 822
 
@@ -860,132 +860,132 @@  discard block
 block discarded – undo
860 860
   //function extractByIndex($p_index, options...)
861 861
   function extractByIndex($p_index)
862 862
   {
863
-    $v_result=1;
863
+	$v_result=1;
864 864
 
865
-    // ----- Reset the error handler
866
-    $this->privErrorReset();
865
+	// ----- Reset the error handler
866
+	$this->privErrorReset();
867 867
 
868
-    // ----- Check archive
869
-    if (!$this->privCheckFormat()) {
870
-      return(0);
871
-    }
868
+	// ----- Check archive
869
+	if (!$this->privCheckFormat()) {
870
+	  return(0);
871
+	}
872 872
 
873
-    // ----- Set default values
874
-    $v_options = array();
873
+	// ----- Set default values
874
+	$v_options = array();
875 875
 //    $v_path = "./";
876
-    $v_path = '';
877
-    $v_remove_path = "";
878
-    $v_remove_all_path = false;
879
-
880
-    // ----- Look for variable options arguments
881
-    $v_size = func_num_args();
882
-
883
-    // ----- Default values for option
884
-    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
885
-
886
-    // ----- Look for arguments
887
-    if ($v_size > 1) {
888
-      // ----- Get the arguments
889
-      $v_arg_list = func_get_args();
890
-
891
-      // ----- Remove form the options list the first argument
892
-      array_shift($v_arg_list);
893
-      $v_size--;
894
-
895
-      // ----- Look for first arg
896
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
897
-
898
-        // ----- Parse the options
899
-        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
900
-                                            array (PCLZIP_OPT_PATH => 'optional',
901
-                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
902
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
903
-                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
904
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',
905
-                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
906
-                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
907
-                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
908
-                                                   PCLZIP_OPT_REPLACE_NEWER => 'optional'
909
-                                                   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
910
-                                                   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
911
-                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
912
-                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
913
-                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
876
+	$v_path = '';
877
+	$v_remove_path = "";
878
+	$v_remove_all_path = false;
879
+
880
+	// ----- Look for variable options arguments
881
+	$v_size = func_num_args();
882
+
883
+	// ----- Default values for option
884
+	$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
885
+
886
+	// ----- Look for arguments
887
+	if ($v_size > 1) {
888
+	  // ----- Get the arguments
889
+	  $v_arg_list = func_get_args();
890
+
891
+	  // ----- Remove form the options list the first argument
892
+	  array_shift($v_arg_list);
893
+	  $v_size--;
894
+
895
+	  // ----- Look for first arg
896
+	  if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
897
+
898
+		// ----- Parse the options
899
+		$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
900
+											array (PCLZIP_OPT_PATH => 'optional',
901
+												   PCLZIP_OPT_REMOVE_PATH => 'optional',
902
+												   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
903
+												   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
904
+												   PCLZIP_OPT_ADD_PATH => 'optional',
905
+												   PCLZIP_CB_PRE_EXTRACT => 'optional',
906
+												   PCLZIP_CB_POST_EXTRACT => 'optional',
907
+												   PCLZIP_OPT_SET_CHMOD => 'optional',
908
+												   PCLZIP_OPT_REPLACE_NEWER => 'optional'
909
+												   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
910
+												   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
911
+												   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
912
+												   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
913
+												   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
914 914
 												   ));
915
-        if ($v_result != 1) {
916
-          return 0;
917
-        }
918
-
919
-        // ----- Set the arguments
920
-        if (isset($v_options[PCLZIP_OPT_PATH])) {
921
-          $v_path = $v_options[PCLZIP_OPT_PATH];
922
-        }
923
-        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
924
-          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
925
-        }
926
-        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
927
-          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
928
-        }
929
-        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
930
-          // ----- Check for '/' in last path char
931
-          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
932
-            $v_path .= '/';
933
-          }
934
-          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
935
-        }
936
-        if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
937
-          $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
938
-        }
939
-        else {
940
-        }
941
-      }
915
+		if ($v_result != 1) {
916
+		  return 0;
917
+		}
918
+
919
+		// ----- Set the arguments
920
+		if (isset($v_options[PCLZIP_OPT_PATH])) {
921
+		  $v_path = $v_options[PCLZIP_OPT_PATH];
922
+		}
923
+		if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
924
+		  $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
925
+		}
926
+		if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
927
+		  $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
928
+		}
929
+		if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
930
+		  // ----- Check for '/' in last path char
931
+		  if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
932
+			$v_path .= '/';
933
+		  }
934
+		  $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
935
+		}
936
+		if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
937
+		  $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
938
+		}
939
+		else {
940
+		}
941
+	  }
942 942
 
943
-      // ----- Look for 2 args
944
-      // Here we need to support the first historic synopsis of the
945
-      // method.
946
-      else {
947
-
948
-        // ----- Get the first argument
949
-        $v_path = $v_arg_list[0];
950
-
951
-        // ----- Look for the optional second argument
952
-        if ($v_size == 2) {
953
-          $v_remove_path = $v_arg_list[1];
954
-        }
955
-        else if ($v_size > 2) {
956
-          // ----- Error log
957
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
958
-
959
-          // ----- Return
960
-          return 0;
961
-        }
962
-      }
963
-    }
943
+	  // ----- Look for 2 args
944
+	  // Here we need to support the first historic synopsis of the
945
+	  // method.
946
+	  else {
947
+
948
+		// ----- Get the first argument
949
+		$v_path = $v_arg_list[0];
950
+
951
+		// ----- Look for the optional second argument
952
+		if ($v_size == 2) {
953
+		  $v_remove_path = $v_arg_list[1];
954
+		}
955
+		else if ($v_size > 2) {
956
+		  // ----- Error log
957
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
958
+
959
+		  // ----- Return
960
+		  return 0;
961
+		}
962
+	  }
963
+	}
964 964
 
965
-    // ----- Trace
966
-
967
-    // ----- Trick
968
-    // Here I want to reuse extractByRule(), so I need to parse the $p_index
969
-    // with privParseOptions()
970
-    $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
971
-    $v_options_trick = array();
972
-    $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
973
-                                        array (PCLZIP_OPT_BY_INDEX => 'optional' ));
974
-    if ($v_result != 1) {
975
-        return 0;
976
-    }
977
-    $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
965
+	// ----- Trace
966
+
967
+	// ----- Trick
968
+	// Here I want to reuse extractByRule(), so I need to parse the $p_index
969
+	// with privParseOptions()
970
+	$v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
971
+	$v_options_trick = array();
972
+	$v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
973
+										array (PCLZIP_OPT_BY_INDEX => 'optional' ));
974
+	if ($v_result != 1) {
975
+		return 0;
976
+	}
977
+	$v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
978 978
 
979
-    // ----- Look for default option values
980
-    $this->privOptionDefaultThreshold($v_options);
979
+	// ----- Look for default option values
980
+	$this->privOptionDefaultThreshold($v_options);
981 981
 
982
-    // ----- Call the extracting fct
983
-    if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
984
-        return(0);
985
-    }
982
+	// ----- Call the extracting fct
983
+	if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
984
+		return(0);
985
+	}
986 986
 
987
-    // ----- Return
988
-    return $p_list;
987
+	// ----- Return
988
+	return $p_list;
989 989
   }
990 990
   // --------------------------------------------------------------------------------
991 991
 
@@ -1009,54 +1009,54 @@  discard block
 block discarded – undo
1009 1009
   // --------------------------------------------------------------------------------
1010 1010
   function delete()
1011 1011
   {
1012
-    $v_result=1;
1012
+	$v_result=1;
1013 1013
 
1014
-    // ----- Reset the error handler
1015
-    $this->privErrorReset();
1014
+	// ----- Reset the error handler
1015
+	$this->privErrorReset();
1016 1016
 
1017
-    // ----- Check archive
1018
-    if (!$this->privCheckFormat()) {
1019
-      return(0);
1020
-    }
1017
+	// ----- Check archive
1018
+	if (!$this->privCheckFormat()) {
1019
+	  return(0);
1020
+	}
1021 1021
 
1022
-    // ----- Set default values
1023
-    $v_options = array();
1024
-
1025
-    // ----- Look for variable options arguments
1026
-    $v_size = func_num_args();
1027
-
1028
-    // ----- Look for arguments
1029
-    if ($v_size > 0) {
1030
-      // ----- Get the arguments
1031
-      $v_arg_list = func_get_args();
1032
-
1033
-      // ----- Parse the options
1034
-      $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1035
-                                        array (PCLZIP_OPT_BY_NAME => 'optional',
1036
-                                               PCLZIP_OPT_BY_EREG => 'optional',
1037
-                                               PCLZIP_OPT_BY_PREG => 'optional',
1038
-                                               PCLZIP_OPT_BY_INDEX => 'optional' ));
1039
-      if ($v_result != 1) {
1040
-          return 0;
1041
-      }
1042
-    }
1022
+	// ----- Set default values
1023
+	$v_options = array();
1024
+
1025
+	// ----- Look for variable options arguments
1026
+	$v_size = func_num_args();
1027
+
1028
+	// ----- Look for arguments
1029
+	if ($v_size > 0) {
1030
+	  // ----- Get the arguments
1031
+	  $v_arg_list = func_get_args();
1032
+
1033
+	  // ----- Parse the options
1034
+	  $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1035
+										array (PCLZIP_OPT_BY_NAME => 'optional',
1036
+											   PCLZIP_OPT_BY_EREG => 'optional',
1037
+											   PCLZIP_OPT_BY_PREG => 'optional',
1038
+											   PCLZIP_OPT_BY_INDEX => 'optional' ));
1039
+	  if ($v_result != 1) {
1040
+		  return 0;
1041
+	  }
1042
+	}
1043 1043
 
1044
-    // ----- Magic quotes trick
1045
-    $this->privDisableMagicQuotes();
1044
+	// ----- Magic quotes trick
1045
+	$this->privDisableMagicQuotes();
1046 1046
 
1047
-    // ----- Call the delete fct
1048
-    $v_list = array();
1049
-    if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
1050
-      $this->privSwapBackMagicQuotes();
1051
-      unset($v_list);
1052
-      return(0);
1053
-    }
1047
+	// ----- Call the delete fct
1048
+	$v_list = array();
1049
+	if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
1050
+	  $this->privSwapBackMagicQuotes();
1051
+	  unset($v_list);
1052
+	  return(0);
1053
+	}
1054 1054
 
1055
-    // ----- Magic quotes trick
1056
-    $this->privSwapBackMagicQuotes();
1055
+	// ----- Magic quotes trick
1056
+	$this->privSwapBackMagicQuotes();
1057 1057
 
1058
-    // ----- Return
1059
-    return $v_list;
1058
+	// ----- Return
1059
+	return $v_list;
1060 1060
   }
1061 1061
   // --------------------------------------------------------------------------------
1062 1062
 
@@ -1069,10 +1069,10 @@  discard block
 block discarded – undo
1069 1069
   function deleteByIndex($p_index)
1070 1070
   {
1071 1071
 
1072
-    $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
1072
+	$p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
1073 1073
 
1074
-    // ----- Return
1075
-    return $p_list;
1074
+	// ----- Return
1075
+	return $p_list;
1076 1076
   }
1077 1077
   // --------------------------------------------------------------------------------
1078 1078
 
@@ -1093,61 +1093,61 @@  discard block
 block discarded – undo
1093 1093
   function properties()
1094 1094
   {
1095 1095
 
1096
-    // ----- Reset the error handler
1097
-    $this->privErrorReset();
1096
+	// ----- Reset the error handler
1097
+	$this->privErrorReset();
1098 1098
 
1099
-    // ----- Magic quotes trick
1100
-    $this->privDisableMagicQuotes();
1099
+	// ----- Magic quotes trick
1100
+	$this->privDisableMagicQuotes();
1101 1101
 
1102
-    // ----- Check archive
1103
-    if (!$this->privCheckFormat()) {
1104
-      $this->privSwapBackMagicQuotes();
1105
-      return(0);
1106
-    }
1102
+	// ----- Check archive
1103
+	if (!$this->privCheckFormat()) {
1104
+	  $this->privSwapBackMagicQuotes();
1105
+	  return(0);
1106
+	}
1107 1107
 
1108
-    // ----- Default properties
1109
-    $v_prop = array();
1110
-    $v_prop['comment'] = '';
1111
-    $v_prop['nb'] = 0;
1112
-    $v_prop['status'] = 'not_exist';
1113
-
1114
-    // ----- Look if file exists
1115
-    if (@is_file($this->zipname))
1116
-    {
1117
-      // ----- Open the zip file
1118
-      if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
1119
-      {
1120
-        $this->privSwapBackMagicQuotes();
1121
-
1122
-        // ----- Error log
1123
-        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1124
-
1125
-        // ----- Return
1126
-        return 0;
1127
-      }
1108
+	// ----- Default properties
1109
+	$v_prop = array();
1110
+	$v_prop['comment'] = '';
1111
+	$v_prop['nb'] = 0;
1112
+	$v_prop['status'] = 'not_exist';
1113
+
1114
+	// ----- Look if file exists
1115
+	if (@is_file($this->zipname))
1116
+	{
1117
+	  // ----- Open the zip file
1118
+	  if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
1119
+	  {
1120
+		$this->privSwapBackMagicQuotes();
1121
+
1122
+		// ----- Error log
1123
+		PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1124
+
1125
+		// ----- Return
1126
+		return 0;
1127
+	  }
1128 1128
 
1129
-      // ----- Read the central directory informations
1130
-      $v_central_dir = array();
1131
-      if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1132
-      {
1133
-        $this->privSwapBackMagicQuotes();
1134
-        return 0;
1135
-      }
1129
+	  // ----- Read the central directory informations
1130
+	  $v_central_dir = array();
1131
+	  if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1132
+	  {
1133
+		$this->privSwapBackMagicQuotes();
1134
+		return 0;
1135
+	  }
1136 1136
 
1137
-      // ----- Close the zip file
1138
-      $this->privCloseFd();
1137
+	  // ----- Close the zip file
1138
+	  $this->privCloseFd();
1139 1139
 
1140
-      // ----- Set the user attributes
1141
-      $v_prop['comment'] = $v_central_dir['comment'];
1142
-      $v_prop['nb'] = $v_central_dir['entries'];
1143
-      $v_prop['status'] = 'ok';
1144
-    }
1140
+	  // ----- Set the user attributes
1141
+	  $v_prop['comment'] = $v_central_dir['comment'];
1142
+	  $v_prop['nb'] = $v_central_dir['entries'];
1143
+	  $v_prop['status'] = 'ok';
1144
+	}
1145 1145
 
1146
-    // ----- Magic quotes trick
1147
-    $this->privSwapBackMagicQuotes();
1146
+	// ----- Magic quotes trick
1147
+	$this->privSwapBackMagicQuotes();
1148 1148
 
1149
-    // ----- Return
1150
-    return $v_prop;
1149
+	// ----- Return
1150
+	return $v_prop;
1151 1151
   }
1152 1152
   // --------------------------------------------------------------------------------
1153 1153
 
@@ -1165,46 +1165,46 @@  discard block
 block discarded – undo
1165 1165
   // --------------------------------------------------------------------------------
1166 1166
   function duplicate($p_archive)
1167 1167
   {
1168
-    $v_result = 1;
1168
+	$v_result = 1;
1169 1169
 
1170
-    // ----- Reset the error handler
1171
-    $this->privErrorReset();
1170
+	// ----- Reset the error handler
1171
+	$this->privErrorReset();
1172 1172
 
1173
-    // ----- Look if the $p_archive is a PclZip object
1174
-    if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
1175
-    {
1173
+	// ----- Look if the $p_archive is a PclZip object
1174
+	if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
1175
+	{
1176 1176
 
1177
-      // ----- Duplicate the archive
1178
-      $v_result = $this->privDuplicate($p_archive->zipname);
1179
-    }
1177
+	  // ----- Duplicate the archive
1178
+	  $v_result = $this->privDuplicate($p_archive->zipname);
1179
+	}
1180 1180
 
1181
-    // ----- Look if the $p_archive is a string (so a filename)
1182
-    else if (is_string($p_archive))
1183
-    {
1181
+	// ----- Look if the $p_archive is a string (so a filename)
1182
+	else if (is_string($p_archive))
1183
+	{
1184 1184
 
1185
-      // ----- Check that $p_archive is a valid zip file
1186
-      // TBC : Should also check the archive format
1187
-      if (!is_file($p_archive)) {
1188
-        // ----- Error log
1189
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1190
-        $v_result = PCLZIP_ERR_MISSING_FILE;
1191
-      }
1192
-      else {
1193
-        // ----- Duplicate the archive
1194
-        $v_result = $this->privDuplicate($p_archive);
1195
-      }
1196
-    }
1185
+	  // ----- Check that $p_archive is a valid zip file
1186
+	  // TBC : Should also check the archive format
1187
+	  if (!is_file($p_archive)) {
1188
+		// ----- Error log
1189
+		PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1190
+		$v_result = PCLZIP_ERR_MISSING_FILE;
1191
+	  }
1192
+	  else {
1193
+		// ----- Duplicate the archive
1194
+		$v_result = $this->privDuplicate($p_archive);
1195
+	  }
1196
+	}
1197 1197
 
1198
-    // ----- Invalid variable
1199
-    else
1200
-    {
1201
-      // ----- Error log
1202
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1203
-      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1204
-    }
1198
+	// ----- Invalid variable
1199
+	else
1200
+	{
1201
+	  // ----- Error log
1202
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1203
+	  $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1204
+	}
1205 1205
 
1206
-    // ----- Return
1207
-    return $v_result;
1206
+	// ----- Return
1207
+	return $v_result;
1208 1208
   }
1209 1209
   // --------------------------------------------------------------------------------
1210 1210
 
@@ -1224,45 +1224,45 @@  discard block
 block discarded – undo
1224 1224
   // --------------------------------------------------------------------------------
1225 1225
   function merge($p_archive_to_add)
1226 1226
   {
1227
-    $v_result = 1;
1227
+	$v_result = 1;
1228 1228
 
1229
-    // ----- Reset the error handler
1230
-    $this->privErrorReset();
1229
+	// ----- Reset the error handler
1230
+	$this->privErrorReset();
1231 1231
 
1232
-    // ----- Check archive
1233
-    if (!$this->privCheckFormat()) {
1234
-      return(0);
1235
-    }
1232
+	// ----- Check archive
1233
+	if (!$this->privCheckFormat()) {
1234
+	  return(0);
1235
+	}
1236 1236
 
1237
-    // ----- Look if the $p_archive_to_add is a PclZip object
1238
-    if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
1239
-    {
1237
+	// ----- Look if the $p_archive_to_add is a PclZip object
1238
+	if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
1239
+	{
1240 1240
 
1241
-      // ----- Merge the archive
1242
-      $v_result = $this->privMerge($p_archive_to_add);
1243
-    }
1241
+	  // ----- Merge the archive
1242
+	  $v_result = $this->privMerge($p_archive_to_add);
1243
+	}
1244 1244
 
1245
-    // ----- Look if the $p_archive_to_add is a string (so a filename)
1246
-    else if (is_string($p_archive_to_add))
1247
-    {
1245
+	// ----- Look if the $p_archive_to_add is a string (so a filename)
1246
+	else if (is_string($p_archive_to_add))
1247
+	{
1248 1248
 
1249
-      // ----- Create a temporary archive
1250
-      $v_object_archive = new PclZip($p_archive_to_add);
1249
+	  // ----- Create a temporary archive
1250
+	  $v_object_archive = new PclZip($p_archive_to_add);
1251 1251
 
1252
-      // ----- Merge the archive
1253
-      $v_result = $this->privMerge($v_object_archive);
1254
-    }
1252
+	  // ----- Merge the archive
1253
+	  $v_result = $this->privMerge($v_object_archive);
1254
+	}
1255 1255
 
1256
-    // ----- Invalid variable
1257
-    else
1258
-    {
1259
-      // ----- Error log
1260
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1261
-      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1262
-    }
1256
+	// ----- Invalid variable
1257
+	else
1258
+	{
1259
+	  // ----- Error log
1260
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1261
+	  $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1262
+	}
1263 1263
 
1264
-    // ----- Return
1265
-    return $v_result;
1264
+	// ----- Return
1265
+	return $v_result;
1266 1266
   }
1267 1267
   // --------------------------------------------------------------------------------
1268 1268
 
@@ -1275,12 +1275,12 @@  discard block
 block discarded – undo
1275 1275
   // --------------------------------------------------------------------------------
1276 1276
   function errorCode()
1277 1277
   {
1278
-    if (PCLZIP_ERROR_EXTERNAL == 1) {
1279
-      return(PclErrorCode());
1280
-    }
1281
-    else {
1282
-      return($this->error_code);
1283
-    }
1278
+	if (PCLZIP_ERROR_EXTERNAL == 1) {
1279
+	  return(PclErrorCode());
1280
+	}
1281
+	else {
1282
+	  return($this->error_code);
1283
+	}
1284 1284
   }
1285 1285
   // --------------------------------------------------------------------------------
1286 1286
 
@@ -1291,42 +1291,42 @@  discard block
 block discarded – undo
1291 1291
   // --------------------------------------------------------------------------------
1292 1292
   function errorName($p_with_code=false)
1293 1293
   {
1294
-    $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
1295
-                      PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
1296
-                      PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
1297
-                      PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
1298
-                      PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
1299
-                      PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
1300
-                      PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
1301
-                      PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
1302
-                      PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
1303
-                      PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
1304
-                      PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
1305
-                      PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
1306
-                      PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
1307
-                      PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
1308
-                      PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
1309
-                      PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
1310
-                      PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
1311
-                      PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
1312
-                      PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
1313
-                      ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
1314
-                      ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
1315
-                    );
1316
-
1317
-    if (isset($v_name[$this->error_code])) {
1318
-      $v_value = $v_name[$this->error_code];
1319
-    }
1320
-    else {
1321
-      $v_value = 'NoName';
1322
-    }
1294
+	$v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
1295
+					  PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
1296
+					  PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
1297
+					  PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
1298
+					  PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
1299
+					  PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
1300
+					  PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
1301
+					  PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
1302
+					  PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
1303
+					  PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
1304
+					  PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
1305
+					  PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
1306
+					  PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
1307
+					  PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
1308
+					  PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
1309
+					  PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
1310
+					  PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
1311
+					  PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
1312
+					  PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
1313
+					  ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
1314
+					  ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
1315
+					);
1316
+
1317
+	if (isset($v_name[$this->error_code])) {
1318
+	  $v_value = $v_name[$this->error_code];
1319
+	}
1320
+	else {
1321
+	  $v_value = 'NoName';
1322
+	}
1323 1323
 
1324
-    if ($p_with_code) {
1325
-      return($v_value.' ('.$this->error_code.')');
1326
-    }
1327
-    else {
1328
-      return($v_value);
1329
-    }
1324
+	if ($p_with_code) {
1325
+	  return($v_value.' ('.$this->error_code.')');
1326
+	}
1327
+	else {
1328
+	  return($v_value);
1329
+	}
1330 1330
   }
1331 1331
   // --------------------------------------------------------------------------------
1332 1332
 
@@ -1337,17 +1337,17 @@  discard block
 block discarded – undo
1337 1337
   // --------------------------------------------------------------------------------
1338 1338
   function errorInfo($p_full=false)
1339 1339
   {
1340
-    if (PCLZIP_ERROR_EXTERNAL == 1) {
1341
-      return(PclErrorString());
1342
-    }
1343
-    else {
1344
-      if ($p_full) {
1345
-        return($this->errorName(true)." : ".$this->error_string);
1346
-      }
1347
-      else {
1348
-        return($this->error_string." [code ".$this->error_code."]");
1349
-      }
1350
-    }
1340
+	if (PCLZIP_ERROR_EXTERNAL == 1) {
1341
+	  return(PclErrorString());
1342
+	}
1343
+	else {
1344
+	  if ($p_full) {
1345
+		return($this->errorName(true)." : ".$this->error_string);
1346
+	  }
1347
+	  else {
1348
+		return($this->error_string." [code ".$this->error_code."]");
1349
+	  }
1350
+	}
1351 1351
   }
1352 1352
   // --------------------------------------------------------------------------------
1353 1353
 
@@ -1376,39 +1376,39 @@  discard block
 block discarded – undo
1376 1376
   // --------------------------------------------------------------------------------
1377 1377
   function privCheckFormat($p_level=0)
1378 1378
   {
1379
-    $v_result = true;
1379
+	$v_result = true;
1380 1380
 
1381 1381
 	// ----- Reset the file system cache
1382
-    clearstatcache();
1382
+	clearstatcache();
1383 1383
 
1384
-    // ----- Reset the error handler
1385
-    $this->privErrorReset();
1384
+	// ----- Reset the error handler
1385
+	$this->privErrorReset();
1386 1386
 
1387
-    // ----- Look if the file exits
1388
-    if (!is_file($this->zipname)) {
1389
-      // ----- Error log
1390
-      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1391
-      return(false);
1392
-    }
1387
+	// ----- Look if the file exits
1388
+	if (!is_file($this->zipname)) {
1389
+	  // ----- Error log
1390
+	  PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1391
+	  return(false);
1392
+	}
1393 1393
 
1394
-    // ----- Check that the file is readeable
1395
-    if (!is_readable($this->zipname)) {
1396
-      // ----- Error log
1397
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1398
-      return(false);
1399
-    }
1394
+	// ----- Check that the file is readeable
1395
+	if (!is_readable($this->zipname)) {
1396
+	  // ----- Error log
1397
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1398
+	  return(false);
1399
+	}
1400 1400
 
1401
-    // ----- Check the magic code
1402
-    // TBC
1401
+	// ----- Check the magic code
1402
+	// TBC
1403 1403
 
1404
-    // ----- Check the central header
1405
-    // TBC
1404
+	// ----- Check the central header
1405
+	// TBC
1406 1406
 
1407
-    // ----- Check each file header
1408
-    // TBC
1407
+	// ----- Check each file header
1408
+	// TBC
1409 1409
 
1410
-    // ----- Return
1411
-    return $v_result;
1410
+	// ----- Return
1411
+	return $v_result;
1412 1412
   }
1413 1413
   // --------------------------------------------------------------------------------
1414 1414
 
@@ -1429,395 +1429,395 @@  discard block
 block discarded – undo
1429 1429
   // --------------------------------------------------------------------------------
1430 1430
   function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
1431 1431
   {
1432
-    $v_result=1;
1432
+	$v_result=1;
1433 1433
 
1434
-    // ----- Read the options
1435
-    $i=0;
1436
-    while ($i<$p_size) {
1434
+	// ----- Read the options
1435
+	$i=0;
1436
+	while ($i<$p_size) {
1437 1437
 
1438
-      // ----- Check if the option is supported
1439
-      if (!isset($v_requested_options[$p_options_list[$i]])) {
1440
-        // ----- Error log
1441
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1438
+	  // ----- Check if the option is supported
1439
+	  if (!isset($v_requested_options[$p_options_list[$i]])) {
1440
+		// ----- Error log
1441
+		PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1442 1442
 
1443
-        // ----- Return
1444
-        return PclZip::errorCode();
1445
-      }
1443
+		// ----- Return
1444
+		return PclZip::errorCode();
1445
+	  }
1446 1446
 
1447
-      // ----- Look for next option
1448
-      switch ($p_options_list[$i]) {
1449
-        // ----- Look for options that request a path value
1450
-        case PCLZIP_OPT_PATH :
1451
-        case PCLZIP_OPT_REMOVE_PATH :
1452
-        case PCLZIP_OPT_ADD_PATH :
1453
-          // ----- Check the number of parameters
1454
-          if (($i+1) >= $p_size) {
1455
-            // ----- Error log
1456
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1457
-
1458
-            // ----- Return
1459
-            return PclZip::errorCode();
1460
-          }
1447
+	  // ----- Look for next option
1448
+	  switch ($p_options_list[$i]) {
1449
+		// ----- Look for options that request a path value
1450
+		case PCLZIP_OPT_PATH :
1451
+		case PCLZIP_OPT_REMOVE_PATH :
1452
+		case PCLZIP_OPT_ADD_PATH :
1453
+		  // ----- Check the number of parameters
1454
+		  if (($i+1) >= $p_size) {
1455
+			// ----- Error log
1456
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1457
+
1458
+			// ----- Return
1459
+			return PclZip::errorCode();
1460
+		  }
1461 1461
 
1462
-          // ----- Get the value
1463
-          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1464
-          $i++;
1465
-        break;
1462
+		  // ----- Get the value
1463
+		  $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1464
+		  $i++;
1465
+		break;
1466 1466
 
1467
-        case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
1468
-          // ----- Check the number of parameters
1469
-          if (($i+1) >= $p_size) {
1470
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1471
-            return PclZip::errorCode();
1472
-          }
1467
+		case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
1468
+		  // ----- Check the number of parameters
1469
+		  if (($i+1) >= $p_size) {
1470
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1471
+			return PclZip::errorCode();
1472
+		  }
1473 1473
 
1474
-          // ----- Check for incompatible options
1475
-          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1476
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1477
-            return PclZip::errorCode();
1478
-          }
1474
+		  // ----- Check for incompatible options
1475
+		  if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1476
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1477
+			return PclZip::errorCode();
1478
+		  }
1479 1479
 
1480
-          // ----- Check the value
1481
-          $v_value = $p_options_list[$i+1];
1482
-          if ((!is_integer($v_value)) || ($v_value<0)) {
1483
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1484
-            return PclZip::errorCode();
1485
-          }
1480
+		  // ----- Check the value
1481
+		  $v_value = $p_options_list[$i+1];
1482
+		  if ((!is_integer($v_value)) || ($v_value<0)) {
1483
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1484
+			return PclZip::errorCode();
1485
+		  }
1486 1486
 
1487
-          // ----- Get the value (and convert it in bytes)
1488
-          $v_result_list[$p_options_list[$i]] = $v_value*1048576;
1489
-          $i++;
1490
-        break;
1487
+		  // ----- Get the value (and convert it in bytes)
1488
+		  $v_result_list[$p_options_list[$i]] = $v_value*1048576;
1489
+		  $i++;
1490
+		break;
1491 1491
 
1492
-        case PCLZIP_OPT_TEMP_FILE_ON :
1493
-          // ----- Check for incompatible options
1494
-          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1495
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1496
-            return PclZip::errorCode();
1497
-          }
1492
+		case PCLZIP_OPT_TEMP_FILE_ON :
1493
+		  // ----- Check for incompatible options
1494
+		  if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1495
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1496
+			return PclZip::errorCode();
1497
+		  }
1498 1498
 
1499
-          $v_result_list[$p_options_list[$i]] = true;
1500
-        break;
1499
+		  $v_result_list[$p_options_list[$i]] = true;
1500
+		break;
1501 1501
 
1502
-        case PCLZIP_OPT_TEMP_FILE_OFF :
1503
-          // ----- Check for incompatible options
1504
-          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
1505
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
1506
-            return PclZip::errorCode();
1507
-          }
1508
-          // ----- Check for incompatible options
1509
-          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1510
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
1511
-            return PclZip::errorCode();
1512
-          }
1502
+		case PCLZIP_OPT_TEMP_FILE_OFF :
1503
+		  // ----- Check for incompatible options
1504
+		  if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
1505
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
1506
+			return PclZip::errorCode();
1507
+		  }
1508
+		  // ----- Check for incompatible options
1509
+		  if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1510
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
1511
+			return PclZip::errorCode();
1512
+		  }
1513 1513
 
1514
-          $v_result_list[$p_options_list[$i]] = true;
1515
-        break;
1514
+		  $v_result_list[$p_options_list[$i]] = true;
1515
+		break;
1516 1516
 
1517
-        case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
1518
-          // ----- Check the number of parameters
1519
-          if (($i+1) >= $p_size) {
1520
-            // ----- Error log
1521
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1517
+		case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
1518
+		  // ----- Check the number of parameters
1519
+		  if (($i+1) >= $p_size) {
1520
+			// ----- Error log
1521
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1522 1522
 
1523
-            // ----- Return
1524
-            return PclZip::errorCode();
1525
-          }
1523
+			// ----- Return
1524
+			return PclZip::errorCode();
1525
+		  }
1526 1526
 
1527
-          // ----- Get the value
1528
-          if (   is_string($p_options_list[$i+1])
1529
-              && ($p_options_list[$i+1] != '')) {
1530
-            $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1531
-            $i++;
1532
-          }
1533
-          else {
1534
-          }
1535
-        break;
1527
+		  // ----- Get the value
1528
+		  if (   is_string($p_options_list[$i+1])
1529
+			  && ($p_options_list[$i+1] != '')) {
1530
+			$v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1531
+			$i++;
1532
+		  }
1533
+		  else {
1534
+		  }
1535
+		break;
1536 1536
 
1537
-        // ----- Look for options that request an array of string for value
1538
-        case PCLZIP_OPT_BY_NAME :
1539
-          // ----- Check the number of parameters
1540
-          if (($i+1) >= $p_size) {
1541
-            // ----- Error log
1542
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1537
+		// ----- Look for options that request an array of string for value
1538
+		case PCLZIP_OPT_BY_NAME :
1539
+		  // ----- Check the number of parameters
1540
+		  if (($i+1) >= $p_size) {
1541
+			// ----- Error log
1542
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1543 1543
 
1544
-            // ----- Return
1545
-            return PclZip::errorCode();
1546
-          }
1544
+			// ----- Return
1545
+			return PclZip::errorCode();
1546
+		  }
1547 1547
 
1548
-          // ----- Get the value
1549
-          if (is_string($p_options_list[$i+1])) {
1550
-              $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1551
-          }
1552
-          else if (is_array($p_options_list[$i+1])) {
1553
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1554
-          }
1555
-          else {
1556
-            // ----- Error log
1557
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1548
+		  // ----- Get the value
1549
+		  if (is_string($p_options_list[$i+1])) {
1550
+			  $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1551
+		  }
1552
+		  else if (is_array($p_options_list[$i+1])) {
1553
+			  $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1554
+		  }
1555
+		  else {
1556
+			// ----- Error log
1557
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1558 1558
 
1559
-            // ----- Return
1560
-            return PclZip::errorCode();
1561
-          }
1562
-          $i++;
1563
-        break;
1564
-
1565
-        // ----- Look for options that request an EREG or PREG expression
1566
-        case PCLZIP_OPT_BY_EREG :
1567
-          // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
1568
-          // to PCLZIP_OPT_BY_PREG
1569
-          $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
1570
-        case PCLZIP_OPT_BY_PREG :
1571
-        //case PCLZIP_OPT_CRYPT :
1572
-          // ----- Check the number of parameters
1573
-          if (($i+1) >= $p_size) {
1574
-            // ----- Error log
1575
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1576
-
1577
-            // ----- Return
1578
-            return PclZip::errorCode();
1579
-          }
1559
+			// ----- Return
1560
+			return PclZip::errorCode();
1561
+		  }
1562
+		  $i++;
1563
+		break;
1564
+
1565
+		// ----- Look for options that request an EREG or PREG expression
1566
+		case PCLZIP_OPT_BY_EREG :
1567
+		  // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
1568
+		  // to PCLZIP_OPT_BY_PREG
1569
+		  $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
1570
+		case PCLZIP_OPT_BY_PREG :
1571
+		//case PCLZIP_OPT_CRYPT :
1572
+		  // ----- Check the number of parameters
1573
+		  if (($i+1) >= $p_size) {
1574
+			// ----- Error log
1575
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1576
+
1577
+			// ----- Return
1578
+			return PclZip::errorCode();
1579
+		  }
1580 1580
 
1581
-          // ----- Get the value
1582
-          if (is_string($p_options_list[$i+1])) {
1583
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1584
-          }
1585
-          else {
1586
-            // ----- Error log
1587
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1581
+		  // ----- Get the value
1582
+		  if (is_string($p_options_list[$i+1])) {
1583
+			  $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1584
+		  }
1585
+		  else {
1586
+			// ----- Error log
1587
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1588 1588
 
1589
-            // ----- Return
1590
-            return PclZip::errorCode();
1591
-          }
1592
-          $i++;
1593
-        break;
1594
-
1595
-        // ----- Look for options that takes a string
1596
-        case PCLZIP_OPT_COMMENT :
1597
-        case PCLZIP_OPT_ADD_COMMENT :
1598
-        case PCLZIP_OPT_PREPEND_COMMENT :
1599
-          // ----- Check the number of parameters
1600
-          if (($i+1) >= $p_size) {
1601
-            // ----- Error log
1602
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
1603
-			                     "Missing parameter value for option '"
1589
+			// ----- Return
1590
+			return PclZip::errorCode();
1591
+		  }
1592
+		  $i++;
1593
+		break;
1594
+
1595
+		// ----- Look for options that takes a string
1596
+		case PCLZIP_OPT_COMMENT :
1597
+		case PCLZIP_OPT_ADD_COMMENT :
1598
+		case PCLZIP_OPT_PREPEND_COMMENT :
1599
+		  // ----- Check the number of parameters
1600
+		  if (($i+1) >= $p_size) {
1601
+			// ----- Error log
1602
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
1603
+								 "Missing parameter value for option '"
1604 1604
 								 .PclZipUtilOptionText($p_options_list[$i])
1605 1605
 								 ."'");
1606 1606
 
1607
-            // ----- Return
1608
-            return PclZip::errorCode();
1609
-          }
1607
+			// ----- Return
1608
+			return PclZip::errorCode();
1609
+		  }
1610 1610
 
1611
-          // ----- Get the value
1612
-          if (is_string($p_options_list[$i+1])) {
1613
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1614
-          }
1615
-          else {
1616
-            // ----- Error log
1617
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
1618
-			                     "Wrong parameter value for option '"
1611
+		  // ----- Get the value
1612
+		  if (is_string($p_options_list[$i+1])) {
1613
+			  $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1614
+		  }
1615
+		  else {
1616
+			// ----- Error log
1617
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
1618
+								 "Wrong parameter value for option '"
1619 1619
 								 .PclZipUtilOptionText($p_options_list[$i])
1620 1620
 								 ."'");
1621 1621
 
1622
-            // ----- Return
1623
-            return PclZip::errorCode();
1624
-          }
1625
-          $i++;
1626
-        break;
1627
-
1628
-        // ----- Look for options that request an array of index
1629
-        case PCLZIP_OPT_BY_INDEX :
1630
-          // ----- Check the number of parameters
1631
-          if (($i+1) >= $p_size) {
1632
-            // ----- Error log
1633
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1634
-
1635
-            // ----- Return
1636
-            return PclZip::errorCode();
1637
-          }
1622
+			// ----- Return
1623
+			return PclZip::errorCode();
1624
+		  }
1625
+		  $i++;
1626
+		break;
1627
+
1628
+		// ----- Look for options that request an array of index
1629
+		case PCLZIP_OPT_BY_INDEX :
1630
+		  // ----- Check the number of parameters
1631
+		  if (($i+1) >= $p_size) {
1632
+			// ----- Error log
1633
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1634
+
1635
+			// ----- Return
1636
+			return PclZip::errorCode();
1637
+		  }
1638 1638
 
1639
-          // ----- Get the value
1640
-          $v_work_list = array();
1641
-          if (is_string($p_options_list[$i+1])) {
1639
+		  // ----- Get the value
1640
+		  $v_work_list = array();
1641
+		  if (is_string($p_options_list[$i+1])) {
1642 1642
 
1643
-              // ----- Remove spaces
1644
-              $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
1643
+			  // ----- Remove spaces
1644
+			  $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
1645 1645
 
1646
-              // ----- Parse items
1647
-              $v_work_list = explode(",", $p_options_list[$i+1]);
1648
-          }
1649
-          else if (is_integer($p_options_list[$i+1])) {
1650
-              $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1651
-          }
1652
-          else if (is_array($p_options_list[$i+1])) {
1653
-              $v_work_list = $p_options_list[$i+1];
1654
-          }
1655
-          else {
1656
-            // ----- Error log
1657
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1646
+			  // ----- Parse items
1647
+			  $v_work_list = explode(",", $p_options_list[$i+1]);
1648
+		  }
1649
+		  else if (is_integer($p_options_list[$i+1])) {
1650
+			  $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1651
+		  }
1652
+		  else if (is_array($p_options_list[$i+1])) {
1653
+			  $v_work_list = $p_options_list[$i+1];
1654
+		  }
1655
+		  else {
1656
+			// ----- Error log
1657
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1658 1658
 
1659
-            // ----- Return
1660
-            return PclZip::errorCode();
1661
-          }
1659
+			// ----- Return
1660
+			return PclZip::errorCode();
1661
+		  }
1662 1662
 
1663
-          // ----- Reduce the index list
1664
-          // each index item in the list must be a couple with a start and
1665
-          // an end value : [0,3], [5-5], [8-10], ...
1666
-          // ----- Check the format of each item
1667
-          $v_sort_flag=false;
1668
-          $v_sort_value=0;
1669
-          for ($j=0; $j<sizeof($v_work_list); $j++) {
1670
-              // ----- Explode the item
1671
-              $v_item_list = explode("-", $v_work_list[$j]);
1672
-              $v_size_item_list = sizeof($v_item_list);
1673
-
1674
-              // ----- TBC : Here we might check that each item is a
1675
-              // real integer ...
1676
-
1677
-              // ----- Look for single value
1678
-              if ($v_size_item_list == 1) {
1679
-                  // ----- Set the option value
1680
-                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1681
-                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
1682
-              }
1683
-              elseif ($v_size_item_list == 2) {
1684
-                  // ----- Set the option value
1685
-                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1686
-                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
1687
-              }
1688
-              else {
1689
-                  // ----- Error log
1690
-                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1691
-
1692
-                  // ----- Return
1693
-                  return PclZip::errorCode();
1694
-              }
1695
-
1696
-
1697
-              // ----- Look for list sort
1698
-              if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
1699
-                  $v_sort_flag=true;
1700
-
1701
-                  // ----- TBC : An automatic sort should be writen ...
1702
-                  // ----- Error log
1703
-                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1704
-
1705
-                  // ----- Return
1706
-                  return PclZip::errorCode();
1707
-              }
1708
-              $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
1709
-          }
1663
+		  // ----- Reduce the index list
1664
+		  // each index item in the list must be a couple with a start and
1665
+		  // an end value : [0,3], [5-5], [8-10], ...
1666
+		  // ----- Check the format of each item
1667
+		  $v_sort_flag=false;
1668
+		  $v_sort_value=0;
1669
+		  for ($j=0; $j<sizeof($v_work_list); $j++) {
1670
+			  // ----- Explode the item
1671
+			  $v_item_list = explode("-", $v_work_list[$j]);
1672
+			  $v_size_item_list = sizeof($v_item_list);
1673
+
1674
+			  // ----- TBC : Here we might check that each item is a
1675
+			  // real integer ...
1676
+
1677
+			  // ----- Look for single value
1678
+			  if ($v_size_item_list == 1) {
1679
+				  // ----- Set the option value
1680
+				  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1681
+				  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
1682
+			  }
1683
+			  elseif ($v_size_item_list == 2) {
1684
+				  // ----- Set the option value
1685
+				  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1686
+				  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
1687
+			  }
1688
+			  else {
1689
+				  // ----- Error log
1690
+				  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1691
+
1692
+				  // ----- Return
1693
+				  return PclZip::errorCode();
1694
+			  }
1695
+
1696
+
1697
+			  // ----- Look for list sort
1698
+			  if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
1699
+				  $v_sort_flag=true;
1700
+
1701
+				  // ----- TBC : An automatic sort should be writen ...
1702
+				  // ----- Error log
1703
+				  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1704
+
1705
+				  // ----- Return
1706
+				  return PclZip::errorCode();
1707
+			  }
1708
+			  $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
1709
+		  }
1710 1710
 
1711
-          // ----- Sort the items
1712
-          if ($v_sort_flag) {
1713
-              // TBC : To Be Completed
1714
-          }
1711
+		  // ----- Sort the items
1712
+		  if ($v_sort_flag) {
1713
+			  // TBC : To Be Completed
1714
+		  }
1715 1715
 
1716
-          // ----- Next option
1717
-          $i++;
1718
-        break;
1719
-
1720
-        // ----- Look for options that request no value
1721
-        case PCLZIP_OPT_REMOVE_ALL_PATH :
1722
-        case PCLZIP_OPT_EXTRACT_AS_STRING :
1723
-        case PCLZIP_OPT_NO_COMPRESSION :
1724
-        case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
1725
-        case PCLZIP_OPT_REPLACE_NEWER :
1726
-        case PCLZIP_OPT_STOP_ON_ERROR :
1727
-          $v_result_list[$p_options_list[$i]] = true;
1728
-        break;
1729
-
1730
-        // ----- Look for options that request an octal value
1731
-        case PCLZIP_OPT_SET_CHMOD :
1732
-          // ----- Check the number of parameters
1733
-          if (($i+1) >= $p_size) {
1734
-            // ----- Error log
1735
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1736
-
1737
-            // ----- Return
1738
-            return PclZip::errorCode();
1739
-          }
1716
+		  // ----- Next option
1717
+		  $i++;
1718
+		break;
1719
+
1720
+		// ----- Look for options that request no value
1721
+		case PCLZIP_OPT_REMOVE_ALL_PATH :
1722
+		case PCLZIP_OPT_EXTRACT_AS_STRING :
1723
+		case PCLZIP_OPT_NO_COMPRESSION :
1724
+		case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
1725
+		case PCLZIP_OPT_REPLACE_NEWER :
1726
+		case PCLZIP_OPT_STOP_ON_ERROR :
1727
+		  $v_result_list[$p_options_list[$i]] = true;
1728
+		break;
1729
+
1730
+		// ----- Look for options that request an octal value
1731
+		case PCLZIP_OPT_SET_CHMOD :
1732
+		  // ----- Check the number of parameters
1733
+		  if (($i+1) >= $p_size) {
1734
+			// ----- Error log
1735
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1736
+
1737
+			// ----- Return
1738
+			return PclZip::errorCode();
1739
+		  }
1740 1740
 
1741
-          // ----- Get the value
1742
-          $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1743
-          $i++;
1744
-        break;
1745
-
1746
-        // ----- Look for options that request a call-back
1747
-        case PCLZIP_CB_PRE_EXTRACT :
1748
-        case PCLZIP_CB_POST_EXTRACT :
1749
-        case PCLZIP_CB_PRE_ADD :
1750
-        case PCLZIP_CB_POST_ADD :
1751
-        /* for futur use
1741
+		  // ----- Get the value
1742
+		  $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1743
+		  $i++;
1744
+		break;
1745
+
1746
+		// ----- Look for options that request a call-back
1747
+		case PCLZIP_CB_PRE_EXTRACT :
1748
+		case PCLZIP_CB_POST_EXTRACT :
1749
+		case PCLZIP_CB_PRE_ADD :
1750
+		case PCLZIP_CB_POST_ADD :
1751
+		/* for futur use
1752 1752
         case PCLZIP_CB_PRE_DELETE :
1753 1753
         case PCLZIP_CB_POST_DELETE :
1754 1754
         case PCLZIP_CB_PRE_LIST :
1755 1755
         case PCLZIP_CB_POST_LIST :
1756 1756
         */
1757
-          // ----- Check the number of parameters
1758
-          if (($i+1) >= $p_size) {
1759
-            // ----- Error log
1760
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1757
+		  // ----- Check the number of parameters
1758
+		  if (($i+1) >= $p_size) {
1759
+			// ----- Error log
1760
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1761 1761
 
1762
-            // ----- Return
1763
-            return PclZip::errorCode();
1764
-          }
1762
+			// ----- Return
1763
+			return PclZip::errorCode();
1764
+		  }
1765 1765
 
1766
-          // ----- Get the value
1767
-          $v_function_name = $p_options_list[$i+1];
1766
+		  // ----- Get the value
1767
+		  $v_function_name = $p_options_list[$i+1];
1768 1768
 
1769
-          // ----- Check that the value is a valid existing function
1770
-          if (!function_exists($v_function_name)) {
1771
-            // ----- Error log
1772
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1769
+		  // ----- Check that the value is a valid existing function
1770
+		  if (!function_exists($v_function_name)) {
1771
+			// ----- Error log
1772
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1773 1773
 
1774
-            // ----- Return
1775
-            return PclZip::errorCode();
1776
-          }
1774
+			// ----- Return
1775
+			return PclZip::errorCode();
1776
+		  }
1777 1777
 
1778
-          // ----- Set the attribute
1779
-          $v_result_list[$p_options_list[$i]] = $v_function_name;
1780
-          $i++;
1781
-        break;
1778
+		  // ----- Set the attribute
1779
+		  $v_result_list[$p_options_list[$i]] = $v_function_name;
1780
+		  $i++;
1781
+		break;
1782 1782
 
1783
-        default :
1784
-          // ----- Error log
1785
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1786
-		                       "Unknown parameter '"
1783
+		default :
1784
+		  // ----- Error log
1785
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1786
+							   "Unknown parameter '"
1787 1787
 							   .$p_options_list[$i]."'");
1788 1788
 
1789
-          // ----- Return
1790
-          return PclZip::errorCode();
1791
-      }
1789
+		  // ----- Return
1790
+		  return PclZip::errorCode();
1791
+	  }
1792 1792
 
1793
-      // ----- Next options
1794
-      $i++;
1795
-    }
1793
+	  // ----- Next options
1794
+	  $i++;
1795
+	}
1796 1796
 
1797
-    // ----- Look for mandatory options
1798
-    if ($v_requested_options !== false) {
1799
-      for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1800
-        // ----- Look for mandatory option
1801
-        if ($v_requested_options[$key] == 'mandatory') {
1802
-          // ----- Look if present
1803
-          if (!isset($v_result_list[$key])) {
1804
-            // ----- Error log
1805
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1806
-
1807
-            // ----- Return
1808
-            return PclZip::errorCode();
1809
-          }
1810
-        }
1811
-      }
1812
-    }
1797
+	// ----- Look for mandatory options
1798
+	if ($v_requested_options !== false) {
1799
+	  for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1800
+		// ----- Look for mandatory option
1801
+		if ($v_requested_options[$key] == 'mandatory') {
1802
+		  // ----- Look if present
1803
+		  if (!isset($v_result_list[$key])) {
1804
+			// ----- Error log
1805
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1806
+
1807
+			// ----- Return
1808
+			return PclZip::errorCode();
1809
+		  }
1810
+		}
1811
+	  }
1812
+	}
1813 1813
 
1814
-    // ----- Look for default values
1815
-    if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1814
+	// ----- Look for default values
1815
+	if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1816 1816
 
1817
-    }
1817
+	}
1818 1818
 
1819
-    // ----- Return
1820
-    return $v_result;
1819
+	// ----- Return
1820
+	return $v_result;
1821 1821
   }
1822 1822
   // --------------------------------------------------------------------------------
1823 1823
 
@@ -1829,38 +1829,38 @@  discard block
 block discarded – undo
1829 1829
   // --------------------------------------------------------------------------------
1830 1830
   function privOptionDefaultThreshold(&$p_options)
1831 1831
   {
1832
-    $v_result=1;
1832
+	$v_result=1;
1833 1833
 
1834
-    if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
1835
-        || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
1836
-      return $v_result;
1837
-    }
1834
+	if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
1835
+		|| isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
1836
+	  return $v_result;
1837
+	}
1838 1838
 
1839
-    // ----- Get 'memory_limit' configuration value
1840
-    $v_memory_limit = ini_get('memory_limit');
1841
-    $v_memory_limit = trim($v_memory_limit);
1842
-    $v_memory_limit_int = (int) $v_memory_limit;
1843
-    $last = strtolower(substr($v_memory_limit, -1));
1839
+	// ----- Get 'memory_limit' configuration value
1840
+	$v_memory_limit = ini_get('memory_limit');
1841
+	$v_memory_limit = trim($v_memory_limit);
1842
+	$v_memory_limit_int = (int) $v_memory_limit;
1843
+	$last = strtolower(substr($v_memory_limit, -1));
1844 1844
 
1845
-    if($last == 'g')
1846
-        //$v_memory_limit_int = $v_memory_limit_int*1024*1024*1024;
1847
-        $v_memory_limit_int = $v_memory_limit_int*1073741824;
1848
-    if($last == 'm')
1849
-        //$v_memory_limit_int = $v_memory_limit_int*1024*1024;
1850
-        $v_memory_limit_int = $v_memory_limit_int*1048576;
1851
-    if($last == 'k')
1852
-        $v_memory_limit_int = $v_memory_limit_int*1024;
1845
+	if($last == 'g')
1846
+		//$v_memory_limit_int = $v_memory_limit_int*1024*1024*1024;
1847
+		$v_memory_limit_int = $v_memory_limit_int*1073741824;
1848
+	if($last == 'm')
1849
+		//$v_memory_limit_int = $v_memory_limit_int*1024*1024;
1850
+		$v_memory_limit_int = $v_memory_limit_int*1048576;
1851
+	if($last == 'k')
1852
+		$v_memory_limit_int = $v_memory_limit_int*1024;
1853 1853
 
1854
-    $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int*PCLZIP_TEMPORARY_FILE_RATIO);
1854
+	$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int*PCLZIP_TEMPORARY_FILE_RATIO);
1855 1855
 
1856 1856
 
1857
-    // ----- Sanity check : No threshold if value lower than 1M
1858
-    if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
1859
-      unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
1860
-    }
1857
+	// ----- Sanity check : No threshold if value lower than 1M
1858
+	if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
1859
+	  unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
1860
+	}
1861 1861
 
1862
-    // ----- Return
1863
-    return $v_result;
1862
+	// ----- Return
1863
+	return $v_result;
1864 1864
   }
1865 1865
   // --------------------------------------------------------------------------------
1866 1866
 
@@ -1874,116 +1874,116 @@  discard block
 block discarded – undo
1874 1874
   // --------------------------------------------------------------------------------
1875 1875
   function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
1876 1876
   {
1877
-    $v_result=1;
1877
+	$v_result=1;
1878 1878
 
1879
-    // ----- For each file in the list check the attributes
1880
-    foreach ($p_file_list as $v_key => $v_value) {
1879
+	// ----- For each file in the list check the attributes
1880
+	foreach ($p_file_list as $v_key => $v_value) {
1881 1881
 
1882
-      // ----- Check if the option is supported
1883
-      if (!isset($v_requested_options[$v_key])) {
1884
-        // ----- Error log
1885
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1882
+	  // ----- Check if the option is supported
1883
+	  if (!isset($v_requested_options[$v_key])) {
1884
+		// ----- Error log
1885
+		PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1886 1886
 
1887
-        // ----- Return
1888
-        return PclZip::errorCode();
1889
-      }
1887
+		// ----- Return
1888
+		return PclZip::errorCode();
1889
+	  }
1890 1890
 
1891
-      // ----- Look for attribute
1892
-      switch ($v_key) {
1893
-        case PCLZIP_ATT_FILE_NAME :
1894
-          if (!is_string($v_value)) {
1895
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1896
-            return PclZip::errorCode();
1897
-          }
1891
+	  // ----- Look for attribute
1892
+	  switch ($v_key) {
1893
+		case PCLZIP_ATT_FILE_NAME :
1894
+		  if (!is_string($v_value)) {
1895
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1896
+			return PclZip::errorCode();
1897
+		  }
1898 1898
 
1899
-          $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
1899
+		  $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
1900 1900
 
1901
-          if ($p_filedescr['filename'] == '') {
1902
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
1903
-            return PclZip::errorCode();
1904
-          }
1901
+		  if ($p_filedescr['filename'] == '') {
1902
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
1903
+			return PclZip::errorCode();
1904
+		  }
1905 1905
 
1906
-        break;
1906
+		break;
1907 1907
 
1908
-        case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1909
-          if (!is_string($v_value)) {
1910
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1911
-            return PclZip::errorCode();
1912
-          }
1908
+		case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1909
+		  if (!is_string($v_value)) {
1910
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1911
+			return PclZip::errorCode();
1912
+		  }
1913 1913
 
1914
-          $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
1914
+		  $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
1915 1915
 
1916
-          if ($p_filedescr['new_short_name'] == '') {
1917
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
1918
-            return PclZip::errorCode();
1919
-          }
1920
-        break;
1916
+		  if ($p_filedescr['new_short_name'] == '') {
1917
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
1918
+			return PclZip::errorCode();
1919
+		  }
1920
+		break;
1921 1921
 
1922
-        case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1923
-          if (!is_string($v_value)) {
1924
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1925
-            return PclZip::errorCode();
1926
-          }
1922
+		case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1923
+		  if (!is_string($v_value)) {
1924
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1925
+			return PclZip::errorCode();
1926
+		  }
1927 1927
 
1928
-          $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
1928
+		  $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
1929 1929
 
1930
-          if ($p_filedescr['new_full_name'] == '') {
1931
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
1932
-            return PclZip::errorCode();
1933
-          }
1934
-        break;
1930
+		  if ($p_filedescr['new_full_name'] == '') {
1931
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
1932
+			return PclZip::errorCode();
1933
+		  }
1934
+		break;
1935 1935
 
1936
-        // ----- Look for options that takes a string
1937
-        case PCLZIP_ATT_FILE_COMMENT :
1938
-          if (!is_string($v_value)) {
1939
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1940
-            return PclZip::errorCode();
1941
-          }
1936
+		// ----- Look for options that takes a string
1937
+		case PCLZIP_ATT_FILE_COMMENT :
1938
+		  if (!is_string($v_value)) {
1939
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1940
+			return PclZip::errorCode();
1941
+		  }
1942 1942
 
1943
-          $p_filedescr['comment'] = $v_value;
1944
-        break;
1943
+		  $p_filedescr['comment'] = $v_value;
1944
+		break;
1945 1945
 
1946
-        case PCLZIP_ATT_FILE_MTIME :
1947
-          if (!is_integer($v_value)) {
1948
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
1949
-            return PclZip::errorCode();
1950
-          }
1946
+		case PCLZIP_ATT_FILE_MTIME :
1947
+		  if (!is_integer($v_value)) {
1948
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
1949
+			return PclZip::errorCode();
1950
+		  }
1951 1951
 
1952
-          $p_filedescr['mtime'] = $v_value;
1953
-        break;
1952
+		  $p_filedescr['mtime'] = $v_value;
1953
+		break;
1954 1954
 
1955
-        case PCLZIP_ATT_FILE_CONTENT :
1956
-          $p_filedescr['content'] = $v_value;
1957
-        break;
1955
+		case PCLZIP_ATT_FILE_CONTENT :
1956
+		  $p_filedescr['content'] = $v_value;
1957
+		break;
1958 1958
 
1959
-        default :
1960
-          // ----- Error log
1961
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1962
-		                           "Unknown parameter '".$v_key."'");
1959
+		default :
1960
+		  // ----- Error log
1961
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1962
+								   "Unknown parameter '".$v_key."'");
1963 1963
 
1964
-          // ----- Return
1965
-          return PclZip::errorCode();
1966
-      }
1964
+		  // ----- Return
1965
+		  return PclZip::errorCode();
1966
+	  }
1967 1967
 
1968
-      // ----- Look for mandatory options
1969
-      if ($v_requested_options !== false) {
1970
-        for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1971
-          // ----- Look for mandatory option
1972
-          if ($v_requested_options[$key] == 'mandatory') {
1973
-            // ----- Look if present
1974
-            if (!isset($p_file_list[$key])) {
1975
-              PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1976
-              return PclZip::errorCode();
1977
-            }
1978
-          }
1979
-        }
1980
-      }
1968
+	  // ----- Look for mandatory options
1969
+	  if ($v_requested_options !== false) {
1970
+		for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1971
+		  // ----- Look for mandatory option
1972
+		  if ($v_requested_options[$key] == 'mandatory') {
1973
+			// ----- Look if present
1974
+			if (!isset($p_file_list[$key])) {
1975
+			  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1976
+			  return PclZip::errorCode();
1977
+			}
1978
+		  }
1979
+		}
1980
+	  }
1981 1981
 
1982
-    // end foreach
1983
-    }
1982
+	// end foreach
1983
+	}
1984 1984
 
1985
-    // ----- Return
1986
-    return $v_result;
1985
+	// ----- Return
1986
+	return $v_result;
1987 1987
   }
1988 1988
   // --------------------------------------------------------------------------------
1989 1989
 
@@ -2003,120 +2003,120 @@  discard block
 block discarded – undo
2003 2003
   // --------------------------------------------------------------------------------
2004 2004
   function privFileDescrExpand(&$p_filedescr_list, &$p_options)
2005 2005
   {
2006
-    $v_result=1;
2007
-
2008
-    // ----- Create a result list
2009
-    $v_result_list = array();
2010
-
2011
-    // ----- Look each entry
2012
-    for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
2013
-
2014
-      // ----- Get filedescr
2015
-      $v_descr = $p_filedescr_list[$i];
2016
-
2017
-      // ----- Reduce the filename
2018
-      $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
2019
-      $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
2020
-
2021
-      // ----- Look for real file or folder
2022
-      if (file_exists($v_descr['filename'])) {
2023
-        if (@is_file($v_descr['filename'])) {
2024
-          $v_descr['type'] = 'file';
2025
-        }
2026
-        else if (@is_dir($v_descr['filename'])) {
2027
-          $v_descr['type'] = 'folder';
2028
-        }
2029
-        else if (@is_link($v_descr['filename'])) {
2030
-          // skip
2031
-          continue;
2032
-        }
2033
-        else {
2034
-          // skip
2035
-          continue;
2036
-        }
2037
-      }
2006
+	$v_result=1;
2007
+
2008
+	// ----- Create a result list
2009
+	$v_result_list = array();
2010
+
2011
+	// ----- Look each entry
2012
+	for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
2013
+
2014
+	  // ----- Get filedescr
2015
+	  $v_descr = $p_filedescr_list[$i];
2016
+
2017
+	  // ----- Reduce the filename
2018
+	  $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
2019
+	  $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
2020
+
2021
+	  // ----- Look for real file or folder
2022
+	  if (file_exists($v_descr['filename'])) {
2023
+		if (@is_file($v_descr['filename'])) {
2024
+		  $v_descr['type'] = 'file';
2025
+		}
2026
+		else if (@is_dir($v_descr['filename'])) {
2027
+		  $v_descr['type'] = 'folder';
2028
+		}
2029
+		else if (@is_link($v_descr['filename'])) {
2030
+		  // skip
2031
+		  continue;
2032
+		}
2033
+		else {
2034
+		  // skip
2035
+		  continue;
2036
+		}
2037
+	  }
2038 2038
 
2039
-      // ----- Look for string added as file
2040
-      else if (isset($v_descr['content'])) {
2041
-        $v_descr['type'] = 'virtual_file';
2042
-      }
2039
+	  // ----- Look for string added as file
2040
+	  else if (isset($v_descr['content'])) {
2041
+		$v_descr['type'] = 'virtual_file';
2042
+	  }
2043 2043
 
2044
-      // ----- Missing file
2045
-      else {
2046
-        // ----- Error log
2047
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
2044
+	  // ----- Missing file
2045
+	  else {
2046
+		// ----- Error log
2047
+		PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
2048 2048
 
2049
-        // ----- Return
2050
-        return PclZip::errorCode();
2051
-      }
2049
+		// ----- Return
2050
+		return PclZip::errorCode();
2051
+	  }
2052 2052
 
2053
-      // ----- Calculate the stored filename
2054
-      $this->privCalculateStoredFilename($v_descr, $p_options);
2055
-
2056
-      // ----- Add the descriptor in result list
2057
-      $v_result_list[sizeof($v_result_list)] = $v_descr;
2058
-
2059
-      // ----- Look for folder
2060
-      if ($v_descr['type'] == 'folder') {
2061
-        // ----- List of items in folder
2062
-        $v_dirlist_descr = array();
2063
-        $v_dirlist_nb = 0;
2064
-        if ($v_folder_handler = @opendir($v_descr['filename'])) {
2065
-          while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
2066
-
2067
-            // ----- Skip '.' and '..'
2068
-            if (($v_item_handler == '.') || ($v_item_handler == '..')) {
2069
-                continue;
2070
-            }
2071
-
2072
-            // ----- Compose the full filename
2073
-            $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
2074
-
2075
-            // ----- Look for different stored filename
2076
-            // Because the name of the folder was changed, the name of the
2077
-            // files/sub-folders also change
2078
-            if (($v_descr['stored_filename'] != $v_descr['filename'])
2079
-                 && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2080
-              if ($v_descr['stored_filename'] != '') {
2081
-                $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2082
-              }
2083
-              else {
2084
-                $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
2085
-              }
2086
-            }
2087
-
2088
-            $v_dirlist_nb++;
2089
-          }
2053
+	  // ----- Calculate the stored filename
2054
+	  $this->privCalculateStoredFilename($v_descr, $p_options);
2055
+
2056
+	  // ----- Add the descriptor in result list
2057
+	  $v_result_list[sizeof($v_result_list)] = $v_descr;
2058
+
2059
+	  // ----- Look for folder
2060
+	  if ($v_descr['type'] == 'folder') {
2061
+		// ----- List of items in folder
2062
+		$v_dirlist_descr = array();
2063
+		$v_dirlist_nb = 0;
2064
+		if ($v_folder_handler = @opendir($v_descr['filename'])) {
2065
+		  while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
2066
+
2067
+			// ----- Skip '.' and '..'
2068
+			if (($v_item_handler == '.') || ($v_item_handler == '..')) {
2069
+				continue;
2070
+			}
2071
+
2072
+			// ----- Compose the full filename
2073
+			$v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
2074
+
2075
+			// ----- Look for different stored filename
2076
+			// Because the name of the folder was changed, the name of the
2077
+			// files/sub-folders also change
2078
+			if (($v_descr['stored_filename'] != $v_descr['filename'])
2079
+				 && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2080
+			  if ($v_descr['stored_filename'] != '') {
2081
+				$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2082
+			  }
2083
+			  else {
2084
+				$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
2085
+			  }
2086
+			}
2087
+
2088
+			$v_dirlist_nb++;
2089
+		  }
2090 2090
 
2091
-          @closedir($v_folder_handler);
2092
-        }
2093
-        else {
2094
-          // TBC : unable to open folder in read mode
2095
-        }
2096
-
2097
-        // ----- Expand each element of the list
2098
-        if ($v_dirlist_nb != 0) {
2099
-          // ----- Expand
2100
-          if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
2101
-            return $v_result;
2102
-          }
2091
+		  @closedir($v_folder_handler);
2092
+		}
2093
+		else {
2094
+		  // TBC : unable to open folder in read mode
2095
+		}
2096
+
2097
+		// ----- Expand each element of the list
2098
+		if ($v_dirlist_nb != 0) {
2099
+		  // ----- Expand
2100
+		  if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
2101
+			return $v_result;
2102
+		  }
2103 2103
 
2104
-          // ----- Concat the resulting list
2105
-          $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2106
-        }
2107
-        else {
2108
-        }
2104
+		  // ----- Concat the resulting list
2105
+		  $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2106
+		}
2107
+		else {
2108
+		}
2109 2109
 
2110
-        // ----- Free local array
2111
-        unset($v_dirlist_descr);
2112
-      }
2113
-    }
2110
+		// ----- Free local array
2111
+		unset($v_dirlist_descr);
2112
+	  }
2113
+	}
2114 2114
 
2115
-    // ----- Get the result list
2116
-    $p_filedescr_list = $v_result_list;
2115
+	// ----- Get the result list
2116
+	$p_filedescr_list = $v_result_list;
2117 2117
 
2118
-    // ----- Return
2119
-    return $v_result;
2118
+	// ----- Return
2119
+	return $v_result;
2120 2120
   }
2121 2121
   // --------------------------------------------------------------------------------
2122 2122
 
@@ -2128,30 +2128,30 @@  discard block
 block discarded – undo
2128 2128
   // --------------------------------------------------------------------------------
2129 2129
   function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
2130 2130
   {
2131
-    $v_result=1;
2132
-    $v_list_detail = array();
2131
+	$v_result=1;
2132
+	$v_list_detail = array();
2133 2133
 
2134
-    // ----- Magic quotes trick
2135
-    $this->privDisableMagicQuotes();
2134
+	// ----- Magic quotes trick
2135
+	$this->privDisableMagicQuotes();
2136 2136
 
2137
-    // ----- Open the file in write mode
2138
-    if (($v_result = $this->privOpenFd('wb')) != 1)
2139
-    {
2140
-      // ----- Return
2141
-      return $v_result;
2142
-    }
2137
+	// ----- Open the file in write mode
2138
+	if (($v_result = $this->privOpenFd('wb')) != 1)
2139
+	{
2140
+	  // ----- Return
2141
+	  return $v_result;
2142
+	}
2143 2143
 
2144
-    // ----- Add the list of files
2145
-    $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
2144
+	// ----- Add the list of files
2145
+	$v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
2146 2146
 
2147
-    // ----- Close
2148
-    $this->privCloseFd();
2147
+	// ----- Close
2148
+	$this->privCloseFd();
2149 2149
 
2150
-    // ----- Magic quotes trick
2151
-    $this->privSwapBackMagicQuotes();
2150
+	// ----- Magic quotes trick
2151
+	$this->privSwapBackMagicQuotes();
2152 2152
 
2153
-    // ----- Return
2154
-    return $v_result;
2153
+	// ----- Return
2154
+	return $v_result;
2155 2155
   }
2156 2156
   // --------------------------------------------------------------------------------
2157 2157
 
@@ -2163,175 +2163,175 @@  discard block
 block discarded – undo
2163 2163
   // --------------------------------------------------------------------------------
2164 2164
   function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
2165 2165
   {
2166
-    $v_result=1;
2167
-    $v_list_detail = array();
2166
+	$v_result=1;
2167
+	$v_list_detail = array();
2168 2168
 
2169
-    // ----- Look if the archive exists or is empty
2170
-    if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2171
-    {
2169
+	// ----- Look if the archive exists or is empty
2170
+	if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2171
+	{
2172 2172
 
2173
-      // ----- Do a create
2174
-      $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
2173
+	  // ----- Do a create
2174
+	  $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
2175 2175
 
2176
-      // ----- Return
2177
-      return $v_result;
2178
-    }
2179
-    // ----- Magic quotes trick
2180
-    $this->privDisableMagicQuotes();
2176
+	  // ----- Return
2177
+	  return $v_result;
2178
+	}
2179
+	// ----- Magic quotes trick
2180
+	$this->privDisableMagicQuotes();
2181 2181
 
2182
-    // ----- Open the zip file
2183
-    if (($v_result=$this->privOpenFd('rb')) != 1)
2184
-    {
2185
-      // ----- Magic quotes trick
2186
-      $this->privSwapBackMagicQuotes();
2182
+	// ----- Open the zip file
2183
+	if (($v_result=$this->privOpenFd('rb')) != 1)
2184
+	{
2185
+	  // ----- Magic quotes trick
2186
+	  $this->privSwapBackMagicQuotes();
2187 2187
 
2188
-      // ----- Return
2189
-      return $v_result;
2190
-    }
2188
+	  // ----- Return
2189
+	  return $v_result;
2190
+	}
2191 2191
 
2192
-    // ----- Read the central directory informations
2193
-    $v_central_dir = array();
2194
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2195
-    {
2196
-      $this->privCloseFd();
2197
-      $this->privSwapBackMagicQuotes();
2198
-      return $v_result;
2199
-    }
2192
+	// ----- Read the central directory informations
2193
+	$v_central_dir = array();
2194
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2195
+	{
2196
+	  $this->privCloseFd();
2197
+	  $this->privSwapBackMagicQuotes();
2198
+	  return $v_result;
2199
+	}
2200 2200
 
2201
-    // ----- Go to beginning of File
2202
-    @rewind($this->zip_fd);
2201
+	// ----- Go to beginning of File
2202
+	@rewind($this->zip_fd);
2203 2203
 
2204
-    // ----- Creates a temporay file
2205
-    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2204
+	// ----- Creates a temporay file
2205
+	$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2206 2206
 
2207
-    // ----- Open the temporary file in write mode
2208
-    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2209
-    {
2210
-      $this->privCloseFd();
2211
-      $this->privSwapBackMagicQuotes();
2207
+	// ----- Open the temporary file in write mode
2208
+	if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2209
+	{
2210
+	  $this->privCloseFd();
2211
+	  $this->privSwapBackMagicQuotes();
2212 2212
 
2213
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2213
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2214 2214
 
2215
-      // ----- Return
2216
-      return PclZip::errorCode();
2217
-    }
2215
+	  // ----- Return
2216
+	  return PclZip::errorCode();
2217
+	}
2218 2218
 
2219
-    // ----- Copy the files from the archive to the temporary file
2220
-    // TBC : Here I should better append the file and go back to erase the central dir
2221
-    $v_size = $v_central_dir['offset'];
2222
-    while ($v_size != 0)
2223
-    {
2224
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2225
-      $v_buffer = fread($this->zip_fd, $v_read_size);
2226
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2227
-      $v_size -= $v_read_size;
2228
-    }
2219
+	// ----- Copy the files from the archive to the temporary file
2220
+	// TBC : Here I should better append the file and go back to erase the central dir
2221
+	$v_size = $v_central_dir['offset'];
2222
+	while ($v_size != 0)
2223
+	{
2224
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2225
+	  $v_buffer = fread($this->zip_fd, $v_read_size);
2226
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2227
+	  $v_size -= $v_read_size;
2228
+	}
2229 2229
 
2230
-    // ----- Swap the file descriptor
2231
-    // Here is a trick : I swap the temporary fd with the zip fd, in order to use
2232
-    // the following methods on the temporary fil and not the real archive
2233
-    $v_swap = $this->zip_fd;
2234
-    $this->zip_fd = $v_zip_temp_fd;
2235
-    $v_zip_temp_fd = $v_swap;
2236
-
2237
-    // ----- Add the files
2238
-    $v_header_list = array();
2239
-    if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2240
-    {
2241
-      fclose($v_zip_temp_fd);
2242
-      $this->privCloseFd();
2243
-      @unlink($v_zip_temp_name);
2244
-      $this->privSwapBackMagicQuotes();
2245
-
2246
-      // ----- Return
2247
-      return $v_result;
2248
-    }
2230
+	// ----- Swap the file descriptor
2231
+	// Here is a trick : I swap the temporary fd with the zip fd, in order to use
2232
+	// the following methods on the temporary fil and not the real archive
2233
+	$v_swap = $this->zip_fd;
2234
+	$this->zip_fd = $v_zip_temp_fd;
2235
+	$v_zip_temp_fd = $v_swap;
2236
+
2237
+	// ----- Add the files
2238
+	$v_header_list = array();
2239
+	if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2240
+	{
2241
+	  fclose($v_zip_temp_fd);
2242
+	  $this->privCloseFd();
2243
+	  @unlink($v_zip_temp_name);
2244
+	  $this->privSwapBackMagicQuotes();
2245
+
2246
+	  // ----- Return
2247
+	  return $v_result;
2248
+	}
2249 2249
 
2250
-    // ----- Store the offset of the central dir
2251
-    $v_offset = @ftell($this->zip_fd);
2252
-
2253
-    // ----- Copy the block of file headers from the old archive
2254
-    $v_size = $v_central_dir['size'];
2255
-    while ($v_size != 0)
2256
-    {
2257
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2258
-      $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2259
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2260
-      $v_size -= $v_read_size;
2261
-    }
2250
+	// ----- Store the offset of the central dir
2251
+	$v_offset = @ftell($this->zip_fd);
2252
+
2253
+	// ----- Copy the block of file headers from the old archive
2254
+	$v_size = $v_central_dir['size'];
2255
+	while ($v_size != 0)
2256
+	{
2257
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2258
+	  $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2259
+	  @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2260
+	  $v_size -= $v_read_size;
2261
+	}
2262 2262
 
2263
-    // ----- Create the Central Dir files header
2264
-    for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2265
-    {
2266
-      // ----- Create the file header
2267
-      if ($v_header_list[$i]['status'] == 'ok') {
2268
-        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2269
-          fclose($v_zip_temp_fd);
2270
-          $this->privCloseFd();
2271
-          @unlink($v_zip_temp_name);
2272
-          $this->privSwapBackMagicQuotes();
2273
-
2274
-          // ----- Return
2275
-          return $v_result;
2276
-        }
2277
-        $v_count++;
2278
-      }
2263
+	// ----- Create the Central Dir files header
2264
+	for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2265
+	{
2266
+	  // ----- Create the file header
2267
+	  if ($v_header_list[$i]['status'] == 'ok') {
2268
+		if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2269
+		  fclose($v_zip_temp_fd);
2270
+		  $this->privCloseFd();
2271
+		  @unlink($v_zip_temp_name);
2272
+		  $this->privSwapBackMagicQuotes();
2273
+
2274
+		  // ----- Return
2275
+		  return $v_result;
2276
+		}
2277
+		$v_count++;
2278
+	  }
2279 2279
 
2280
-      // ----- Transform the header to a 'usable' info
2281
-      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2282
-    }
2280
+	  // ----- Transform the header to a 'usable' info
2281
+	  $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2282
+	}
2283 2283
 
2284
-    // ----- Zip file comment
2285
-    $v_comment = $v_central_dir['comment'];
2286
-    if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2287
-      $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2288
-    }
2289
-    if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
2290
-      $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
2291
-    }
2292
-    if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
2293
-      $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2294
-    }
2284
+	// ----- Zip file comment
2285
+	$v_comment = $v_central_dir['comment'];
2286
+	if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2287
+	  $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2288
+	}
2289
+	if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
2290
+	  $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
2291
+	}
2292
+	if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
2293
+	  $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2294
+	}
2295 2295
 
2296
-    // ----- Calculate the size of the central header
2297
-    $v_size = @ftell($this->zip_fd)-$v_offset;
2296
+	// ----- Calculate the size of the central header
2297
+	$v_size = @ftell($this->zip_fd)-$v_offset;
2298 2298
 
2299
-    // ----- Create the central dir footer
2300
-    if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2301
-    {
2302
-      // ----- Reset the file list
2303
-      unset($v_header_list);
2304
-      $this->privSwapBackMagicQuotes();
2299
+	// ----- Create the central dir footer
2300
+	if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2301
+	{
2302
+	  // ----- Reset the file list
2303
+	  unset($v_header_list);
2304
+	  $this->privSwapBackMagicQuotes();
2305 2305
 
2306
-      // ----- Return
2307
-      return $v_result;
2308
-    }
2306
+	  // ----- Return
2307
+	  return $v_result;
2308
+	}
2309 2309
 
2310
-    // ----- Swap back the file descriptor
2311
-    $v_swap = $this->zip_fd;
2312
-    $this->zip_fd = $v_zip_temp_fd;
2313
-    $v_zip_temp_fd = $v_swap;
2310
+	// ----- Swap back the file descriptor
2311
+	$v_swap = $this->zip_fd;
2312
+	$this->zip_fd = $v_zip_temp_fd;
2313
+	$v_zip_temp_fd = $v_swap;
2314 2314
 
2315
-    // ----- Close
2316
-    $this->privCloseFd();
2315
+	// ----- Close
2316
+	$this->privCloseFd();
2317 2317
 
2318
-    // ----- Close the temporary file
2319
-    @fclose($v_zip_temp_fd);
2318
+	// ----- Close the temporary file
2319
+	@fclose($v_zip_temp_fd);
2320 2320
 
2321
-    // ----- Magic quotes trick
2322
-    $this->privSwapBackMagicQuotes();
2321
+	// ----- Magic quotes trick
2322
+	$this->privSwapBackMagicQuotes();
2323 2323
 
2324
-    // ----- Delete the zip file
2325
-    // TBC : I should test the result ...
2326
-    @unlink($this->zipname);
2324
+	// ----- Delete the zip file
2325
+	// TBC : I should test the result ...
2326
+	@unlink($this->zipname);
2327 2327
 
2328
-    // ----- Rename the temporary file
2329
-    // TBC : I should test the result ...
2330
-    //@rename($v_zip_temp_name, $this->zipname);
2331
-    PclZipUtilRename($v_zip_temp_name, $this->zipname);
2328
+	// ----- Rename the temporary file
2329
+	// TBC : I should test the result ...
2330
+	//@rename($v_zip_temp_name, $this->zipname);
2331
+	PclZipUtilRename($v_zip_temp_name, $this->zipname);
2332 2332
 
2333
-    // ----- Return
2334
-    return $v_result;
2333
+	// ----- Return
2334
+	return $v_result;
2335 2335
   }
2336 2336
   // --------------------------------------------------------------------------------
2337 2337
 
@@ -2342,30 +2342,30 @@  discard block
 block discarded – undo
2342 2342
   // --------------------------------------------------------------------------------
2343 2343
   function privOpenFd($p_mode)
2344 2344
   {
2345
-    $v_result=1;
2345
+	$v_result=1;
2346 2346
 
2347
-    // ----- Look if already open
2348
-    if ($this->zip_fd != 0)
2349
-    {
2350
-      // ----- Error log
2351
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2347
+	// ----- Look if already open
2348
+	if ($this->zip_fd != 0)
2349
+	{
2350
+	  // ----- Error log
2351
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2352 2352
 
2353
-      // ----- Return
2354
-      return PclZip::errorCode();
2355
-    }
2353
+	  // ----- Return
2354
+	  return PclZip::errorCode();
2355
+	}
2356 2356
 
2357
-    // ----- Open the zip file
2358
-    if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2359
-    {
2360
-      // ----- Error log
2361
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2357
+	// ----- Open the zip file
2358
+	if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2359
+	{
2360
+	  // ----- Error log
2361
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2362 2362
 
2363
-      // ----- Return
2364
-      return PclZip::errorCode();
2365
-    }
2363
+	  // ----- Return
2364
+	  return PclZip::errorCode();
2365
+	}
2366 2366
 
2367
-    // ----- Return
2368
-    return $v_result;
2367
+	// ----- Return
2368
+	return $v_result;
2369 2369
   }
2370 2370
   // --------------------------------------------------------------------------------
2371 2371
 
@@ -2376,14 +2376,14 @@  discard block
 block discarded – undo
2376 2376
   // --------------------------------------------------------------------------------
2377 2377
   function privCloseFd()
2378 2378
   {
2379
-    $v_result=1;
2379
+	$v_result=1;
2380 2380
 
2381
-    if ($this->zip_fd != 0)
2382
-      @fclose($this->zip_fd);
2383
-    $this->zip_fd = 0;
2381
+	if ($this->zip_fd != 0)
2382
+	  @fclose($this->zip_fd);
2383
+	$this->zip_fd = 0;
2384 2384
 
2385
-    // ----- Return
2386
-    return $v_result;
2385
+	// ----- Return
2386
+	return $v_result;
2387 2387
   }
2388 2388
   // --------------------------------------------------------------------------------
2389 2389
 
@@ -2403,56 +2403,56 @@  discard block
 block discarded – undo
2403 2403
 //  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
2404 2404
   function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
2405 2405
   {
2406
-    $v_result=1;
2407
-
2408
-    // ----- Add the files
2409
-    $v_header_list = array();
2410
-    if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2411
-    {
2412
-      // ----- Return
2413
-      return $v_result;
2414
-    }
2406
+	$v_result=1;
2407
+
2408
+	// ----- Add the files
2409
+	$v_header_list = array();
2410
+	if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2411
+	{
2412
+	  // ----- Return
2413
+	  return $v_result;
2414
+	}
2415 2415
 
2416
-    // ----- Store the offset of the central dir
2417
-    $v_offset = @ftell($this->zip_fd);
2418
-
2419
-    // ----- Create the Central Dir files header
2420
-    for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2421
-    {
2422
-      // ----- Create the file header
2423
-      if ($v_header_list[$i]['status'] == 'ok') {
2424
-        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2425
-          // ----- Return
2426
-          return $v_result;
2427
-        }
2428
-        $v_count++;
2429
-      }
2416
+	// ----- Store the offset of the central dir
2417
+	$v_offset = @ftell($this->zip_fd);
2418
+
2419
+	// ----- Create the Central Dir files header
2420
+	for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2421
+	{
2422
+	  // ----- Create the file header
2423
+	  if ($v_header_list[$i]['status'] == 'ok') {
2424
+		if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2425
+		  // ----- Return
2426
+		  return $v_result;
2427
+		}
2428
+		$v_count++;
2429
+	  }
2430 2430
 
2431
-      // ----- Transform the header to a 'usable' info
2432
-      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2433
-    }
2431
+	  // ----- Transform the header to a 'usable' info
2432
+	  $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2433
+	}
2434 2434
 
2435
-    // ----- Zip file comment
2436
-    $v_comment = '';
2437
-    if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2438
-      $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2439
-    }
2435
+	// ----- Zip file comment
2436
+	$v_comment = '';
2437
+	if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2438
+	  $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2439
+	}
2440 2440
 
2441
-    // ----- Calculate the size of the central header
2442
-    $v_size = @ftell($this->zip_fd)-$v_offset;
2441
+	// ----- Calculate the size of the central header
2442
+	$v_size = @ftell($this->zip_fd)-$v_offset;
2443 2443
 
2444
-    // ----- Create the central dir footer
2445
-    if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
2446
-    {
2447
-      // ----- Reset the file list
2448
-      unset($v_header_list);
2444
+	// ----- Create the central dir footer
2445
+	if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
2446
+	{
2447
+	  // ----- Reset the file list
2448
+	  unset($v_header_list);
2449 2449
 
2450
-      // ----- Return
2451
-      return $v_result;
2452
-    }
2450
+	  // ----- Return
2451
+	  return $v_result;
2452
+	}
2453 2453
 
2454
-    // ----- Return
2455
-    return $v_result;
2454
+	// ----- Return
2455
+	return $v_result;
2456 2456
   }
2457 2457
   // --------------------------------------------------------------------------------
2458 2458
 
@@ -2467,57 +2467,57 @@  discard block
 block discarded – undo
2467 2467
   // --------------------------------------------------------------------------------
2468 2468
   function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
2469 2469
   {
2470
-    $v_result=1;
2471
-    $v_header = array();
2470
+	$v_result=1;
2471
+	$v_header = array();
2472 2472
 
2473
-    // ----- Recuperate the current number of elt in list
2474
-    $v_nb = sizeof($p_result_list);
2473
+	// ----- Recuperate the current number of elt in list
2474
+	$v_nb = sizeof($p_result_list);
2475 2475
 
2476
-    // ----- Loop on the files
2477
-    for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2478
-      // ----- Format the filename
2479
-      $p_filedescr_list[$j]['filename']
2480
-      = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
2476
+	// ----- Loop on the files
2477
+	for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2478
+	  // ----- Format the filename
2479
+	  $p_filedescr_list[$j]['filename']
2480
+	  = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
2481 2481
 
2482 2482
 
2483
-      // ----- Skip empty file names
2484
-      // TBC : Can this be possible ? not checked in DescrParseAtt ?
2485
-      if ($p_filedescr_list[$j]['filename'] == "") {
2486
-        continue;
2487
-      }
2483
+	  // ----- Skip empty file names
2484
+	  // TBC : Can this be possible ? not checked in DescrParseAtt ?
2485
+	  if ($p_filedescr_list[$j]['filename'] == "") {
2486
+		continue;
2487
+	  }
2488 2488
 
2489
-      // ----- Check the filename
2490
-      if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
2491
-          && (!file_exists($p_filedescr_list[$j]['filename']))) {
2492
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2493
-        return PclZip::errorCode();
2494
-      }
2489
+	  // ----- Check the filename
2490
+	  if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
2491
+		  && (!file_exists($p_filedescr_list[$j]['filename']))) {
2492
+		PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2493
+		return PclZip::errorCode();
2494
+	  }
2495 2495
 
2496
-      // ----- Look if it is a file or a dir with no all path remove option
2497
-      // or a dir with all its path removed
2496
+	  // ----- Look if it is a file or a dir with no all path remove option
2497
+	  // or a dir with all its path removed
2498 2498
 //      if (   (is_file($p_filedescr_list[$j]['filename']))
2499 2499
 //          || (   is_dir($p_filedescr_list[$j]['filename'])
2500
-      if (   ($p_filedescr_list[$j]['type'] == 'file')
2501
-          || ($p_filedescr_list[$j]['type'] == 'virtual_file')
2502
-          || (   ($p_filedescr_list[$j]['type'] == 'folder')
2503
-              && (   !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2504
-                  || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2505
-          ) {
2506
-
2507
-        // ----- Add the file
2508
-        $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
2509
-                                       $p_options);
2510
-        if ($v_result != 1) {
2511
-          return $v_result;
2512
-        }
2513
-
2514
-        // ----- Store the file infos
2515
-        $p_result_list[$v_nb++] = $v_header;
2516
-      }
2517
-    }
2500
+	  if (   ($p_filedescr_list[$j]['type'] == 'file')
2501
+		  || ($p_filedescr_list[$j]['type'] == 'virtual_file')
2502
+		  || (   ($p_filedescr_list[$j]['type'] == 'folder')
2503
+			  && (   !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2504
+				  || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2505
+		  ) {
2506
+
2507
+		// ----- Add the file
2508
+		$v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
2509
+									   $p_options);
2510
+		if ($v_result != 1) {
2511
+		  return $v_result;
2512
+		}
2513
+
2514
+		// ----- Store the file infos
2515
+		$p_result_list[$v_nb++] = $v_header;
2516
+	  }
2517
+	}
2518 2518
 
2519
-    // ----- Return
2520
-    return $v_result;
2519
+	// ----- Return
2520
+	return $v_result;
2521 2521
   }
2522 2522
   // --------------------------------------------------------------------------------
2523 2523
 
@@ -2529,22 +2529,22 @@  discard block
 block discarded – undo
2529 2529
   // --------------------------------------------------------------------------------
2530 2530
   function privAddFile($p_filedescr, &$p_header, &$p_options)
2531 2531
   {
2532
-    $v_result=1;
2532
+	$v_result=1;
2533 2533
 
2534
-    // ----- Working variable
2535
-    $p_filename = $p_filedescr['filename'];
2534
+	// ----- Working variable
2535
+	$p_filename = $p_filedescr['filename'];
2536 2536
 
2537
-    // TBC : Already done in the fileAtt check ... ?
2538
-    if ($p_filename == "") {
2539
-      // ----- Error log
2540
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2537
+	// TBC : Already done in the fileAtt check ... ?
2538
+	if ($p_filename == "") {
2539
+	  // ----- Error log
2540
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2541 2541
 
2542
-      // ----- Return
2543
-      return PclZip::errorCode();
2544
-    }
2542
+	  // ----- Return
2543
+	  return PclZip::errorCode();
2544
+	}
2545 2545
 
2546
-    // ----- Look for a stored different filename
2547
-    /* TBC : Removed
2546
+	// ----- Look for a stored different filename
2547
+	/* TBC : Removed
2548 2548
     if (isset($p_filedescr['stored_filename'])) {
2549 2549
       $v_stored_filename = $p_filedescr['stored_filename'];
2550 2550
     }
@@ -2553,242 +2553,242 @@  discard block
 block discarded – undo
2553 2553
     }
2554 2554
     */
2555 2555
 
2556
-    // ----- Set the file properties
2557
-    clearstatcache();
2558
-    $p_header['version'] = 20;
2559
-    $p_header['version_extracted'] = 10;
2560
-    $p_header['flag'] = 0;
2561
-    $p_header['compression'] = 0;
2562
-    $p_header['crc'] = 0;
2563
-    $p_header['compressed_size'] = 0;
2564
-    $p_header['filename_len'] = strlen($p_filename);
2565
-    $p_header['extra_len'] = 0;
2566
-    $p_header['disk'] = 0;
2567
-    $p_header['internal'] = 0;
2568
-    $p_header['offset'] = 0;
2569
-    $p_header['filename'] = $p_filename;
2556
+	// ----- Set the file properties
2557
+	clearstatcache();
2558
+	$p_header['version'] = 20;
2559
+	$p_header['version_extracted'] = 10;
2560
+	$p_header['flag'] = 0;
2561
+	$p_header['compression'] = 0;
2562
+	$p_header['crc'] = 0;
2563
+	$p_header['compressed_size'] = 0;
2564
+	$p_header['filename_len'] = strlen($p_filename);
2565
+	$p_header['extra_len'] = 0;
2566
+	$p_header['disk'] = 0;
2567
+	$p_header['internal'] = 0;
2568
+	$p_header['offset'] = 0;
2569
+	$p_header['filename'] = $p_filename;
2570 2570
 // TBC : Removed    $p_header['stored_filename'] = $v_stored_filename;
2571
-    $p_header['stored_filename'] = $p_filedescr['stored_filename'];
2572
-    $p_header['extra'] = '';
2573
-    $p_header['status'] = 'ok';
2574
-    $p_header['index'] = -1;
2575
-
2576
-    // ----- Look for regular file
2577
-    if ($p_filedescr['type']=='file') {
2578
-      $p_header['external'] = 0x00000000;
2579
-      $p_header['size'] = filesize($p_filename);
2580
-    }
2571
+	$p_header['stored_filename'] = $p_filedescr['stored_filename'];
2572
+	$p_header['extra'] = '';
2573
+	$p_header['status'] = 'ok';
2574
+	$p_header['index'] = -1;
2575
+
2576
+	// ----- Look for regular file
2577
+	if ($p_filedescr['type']=='file') {
2578
+	  $p_header['external'] = 0x00000000;
2579
+	  $p_header['size'] = filesize($p_filename);
2580
+	}
2581 2581
 
2582
-    // ----- Look for regular folder
2583
-    else if ($p_filedescr['type']=='folder') {
2584
-      $p_header['external'] = 0x00000010;
2585
-      $p_header['mtime'] = filemtime($p_filename);
2586
-      $p_header['size'] = filesize($p_filename);
2587
-    }
2582
+	// ----- Look for regular folder
2583
+	else if ($p_filedescr['type']=='folder') {
2584
+	  $p_header['external'] = 0x00000010;
2585
+	  $p_header['mtime'] = filemtime($p_filename);
2586
+	  $p_header['size'] = filesize($p_filename);
2587
+	}
2588 2588
 
2589
-    // ----- Look for virtual file
2590
-    else if ($p_filedescr['type'] == 'virtual_file') {
2591
-      $p_header['external'] = 0x00000000;
2592
-      $p_header['size'] = strlen($p_filedescr['content']);
2593
-    }
2589
+	// ----- Look for virtual file
2590
+	else if ($p_filedescr['type'] == 'virtual_file') {
2591
+	  $p_header['external'] = 0x00000000;
2592
+	  $p_header['size'] = strlen($p_filedescr['content']);
2593
+	}
2594 2594
 
2595 2595
 
2596
-    // ----- Look for filetime
2597
-    if (isset($p_filedescr['mtime'])) {
2598
-      $p_header['mtime'] = $p_filedescr['mtime'];
2599
-    }
2600
-    else if ($p_filedescr['type'] == 'virtual_file') {
2601
-      $p_header['mtime'] = time();
2602
-    }
2603
-    else {
2604
-      $p_header['mtime'] = filemtime($p_filename);
2605
-    }
2596
+	// ----- Look for filetime
2597
+	if (isset($p_filedescr['mtime'])) {
2598
+	  $p_header['mtime'] = $p_filedescr['mtime'];
2599
+	}
2600
+	else if ($p_filedescr['type'] == 'virtual_file') {
2601
+	  $p_header['mtime'] = time();
2602
+	}
2603
+	else {
2604
+	  $p_header['mtime'] = filemtime($p_filename);
2605
+	}
2606 2606
 
2607
-    // ------ Look for file comment
2608
-    if (isset($p_filedescr['comment'])) {
2609
-      $p_header['comment_len'] = strlen($p_filedescr['comment']);
2610
-      $p_header['comment'] = $p_filedescr['comment'];
2611
-    }
2612
-    else {
2613
-      $p_header['comment_len'] = 0;
2614
-      $p_header['comment'] = '';
2615
-    }
2607
+	// ------ Look for file comment
2608
+	if (isset($p_filedescr['comment'])) {
2609
+	  $p_header['comment_len'] = strlen($p_filedescr['comment']);
2610
+	  $p_header['comment'] = $p_filedescr['comment'];
2611
+	}
2612
+	else {
2613
+	  $p_header['comment_len'] = 0;
2614
+	  $p_header['comment'] = '';
2615
+	}
2616 2616
 
2617
-    // ----- Look for pre-add callback
2618
-    if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
2619
-
2620
-      // ----- Generate a local information
2621
-      $v_local_header = array();
2622
-      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2623
-
2624
-      // ----- Call the callback
2625
-      // Here I do not use call_user_func() because I need to send a reference to the
2626
-      // header.
2627
-      $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
2628
-      if ($v_result == 0) {
2629
-        // ----- Change the file status
2630
-        $p_header['status'] = "skipped";
2631
-        $v_result = 1;
2632
-      }
2617
+	// ----- Look for pre-add callback
2618
+	if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
2619
+
2620
+	  // ----- Generate a local information
2621
+	  $v_local_header = array();
2622
+	  $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2623
+
2624
+	  // ----- Call the callback
2625
+	  // Here I do not use call_user_func() because I need to send a reference to the
2626
+	  // header.
2627
+	  $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
2628
+	  if ($v_result == 0) {
2629
+		// ----- Change the file status
2630
+		$p_header['status'] = "skipped";
2631
+		$v_result = 1;
2632
+	  }
2633 2633
 
2634
-      // ----- Update the informations
2635
-      // Only some fields can be modified
2636
-      if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
2637
-        $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
2638
-      }
2639
-    }
2634
+	  // ----- Update the informations
2635
+	  // Only some fields can be modified
2636
+	  if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
2637
+		$p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
2638
+	  }
2639
+	}
2640 2640
 
2641
-    // ----- Look for empty stored filename
2642
-    if ($p_header['stored_filename'] == "") {
2643
-      $p_header['status'] = "filtered";
2644
-    }
2641
+	// ----- Look for empty stored filename
2642
+	if ($p_header['stored_filename'] == "") {
2643
+	  $p_header['status'] = "filtered";
2644
+	}
2645 2645
 
2646
-    // ----- Check the path length
2647
-    if (strlen($p_header['stored_filename']) > 0xFF) {
2648
-      $p_header['status'] = 'filename_too_long';
2649
-    }
2646
+	// ----- Check the path length
2647
+	if (strlen($p_header['stored_filename']) > 0xFF) {
2648
+	  $p_header['status'] = 'filename_too_long';
2649
+	}
2650 2650
 
2651
-    // ----- Look if no error, or file not skipped
2652
-    if ($p_header['status'] == 'ok') {
2653
-
2654
-      // ----- Look for a file
2655
-      if ($p_filedescr['type'] == 'file') {
2656
-        // ----- Look for using temporary file to zip
2657
-        if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
2658
-            && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2659
-                || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2660
-                    && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
2661
-          $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2662
-          if ($v_result < PCLZIP_ERR_NO_ERROR) {
2663
-            return $v_result;
2664
-          }
2665
-        }
2651
+	// ----- Look if no error, or file not skipped
2652
+	if ($p_header['status'] == 'ok') {
2653
+
2654
+	  // ----- Look for a file
2655
+	  if ($p_filedescr['type'] == 'file') {
2656
+		// ----- Look for using temporary file to zip
2657
+		if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
2658
+			&& (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2659
+				|| (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2660
+					&& ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
2661
+		  $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2662
+		  if ($v_result < PCLZIP_ERR_NO_ERROR) {
2663
+			return $v_result;
2664
+		  }
2665
+		}
2666 2666
 
2667
-        // ----- Use "in memory" zip algo
2668
-        else {
2667
+		// ----- Use "in memory" zip algo
2668
+		else {
2669 2669
 
2670
-        // ----- Open the source file
2671
-        if (($v_file = @fopen($p_filename, "rb")) == 0) {
2672
-          PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2673
-          return PclZip::errorCode();
2674
-        }
2670
+		// ----- Open the source file
2671
+		if (($v_file = @fopen($p_filename, "rb")) == 0) {
2672
+		  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2673
+		  return PclZip::errorCode();
2674
+		}
2675 2675
 
2676
-        // ----- Read the file content
2677
-        $v_content = @fread($v_file, $p_header['size']);
2676
+		// ----- Read the file content
2677
+		$v_content = @fread($v_file, $p_header['size']);
2678 2678
 
2679
-        // ----- Close the file
2680
-        @fclose($v_file);
2679
+		// ----- Close the file
2680
+		@fclose($v_file);
2681 2681
 
2682
-        // ----- Calculate the CRC
2683
-        $p_header['crc'] = @crc32($v_content);
2682
+		// ----- Calculate the CRC
2683
+		$p_header['crc'] = @crc32($v_content);
2684 2684
 
2685
-        // ----- Look for no compression
2686
-        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2687
-          // ----- Set header parameters
2688
-          $p_header['compressed_size'] = $p_header['size'];
2689
-          $p_header['compression'] = 0;
2690
-        }
2685
+		// ----- Look for no compression
2686
+		if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2687
+		  // ----- Set header parameters
2688
+		  $p_header['compressed_size'] = $p_header['size'];
2689
+		  $p_header['compression'] = 0;
2690
+		}
2691 2691
 
2692
-        // ----- Look for normal compression
2693
-        else {
2694
-          // ----- Compress the content
2695
-          $v_content = @gzdeflate($v_content);
2692
+		// ----- Look for normal compression
2693
+		else {
2694
+		  // ----- Compress the content
2695
+		  $v_content = @gzdeflate($v_content);
2696 2696
 
2697
-          // ----- Set header parameters
2698
-          $p_header['compressed_size'] = strlen($v_content);
2699
-          $p_header['compression'] = 8;
2700
-        }
2697
+		  // ----- Set header parameters
2698
+		  $p_header['compressed_size'] = strlen($v_content);
2699
+		  $p_header['compression'] = 8;
2700
+		}
2701 2701
 
2702
-        // ----- Call the header generation
2703
-        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2704
-          @fclose($v_file);
2705
-          return $v_result;
2706
-        }
2702
+		// ----- Call the header generation
2703
+		if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2704
+		  @fclose($v_file);
2705
+		  return $v_result;
2706
+		}
2707 2707
 
2708
-        // ----- Write the compressed (or not) content
2709
-        @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2708
+		// ----- Write the compressed (or not) content
2709
+		@fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2710 2710
 
2711
-        }
2711
+		}
2712 2712
 
2713
-      }
2713
+	  }
2714 2714
 
2715
-      // ----- Look for a virtual file (a file from string)
2716
-      else if ($p_filedescr['type'] == 'virtual_file') {
2715
+	  // ----- Look for a virtual file (a file from string)
2716
+	  else if ($p_filedescr['type'] == 'virtual_file') {
2717 2717
 
2718
-        $v_content = $p_filedescr['content'];
2718
+		$v_content = $p_filedescr['content'];
2719 2719
 
2720
-        // ----- Calculate the CRC
2721
-        $p_header['crc'] = @crc32($v_content);
2720
+		// ----- Calculate the CRC
2721
+		$p_header['crc'] = @crc32($v_content);
2722 2722
 
2723
-        // ----- Look for no compression
2724
-        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2725
-          // ----- Set header parameters
2726
-          $p_header['compressed_size'] = $p_header['size'];
2727
-          $p_header['compression'] = 0;
2728
-        }
2723
+		// ----- Look for no compression
2724
+		if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2725
+		  // ----- Set header parameters
2726
+		  $p_header['compressed_size'] = $p_header['size'];
2727
+		  $p_header['compression'] = 0;
2728
+		}
2729 2729
 
2730
-        // ----- Look for normal compression
2731
-        else {
2732
-          // ----- Compress the content
2733
-          $v_content = @gzdeflate($v_content);
2730
+		// ----- Look for normal compression
2731
+		else {
2732
+		  // ----- Compress the content
2733
+		  $v_content = @gzdeflate($v_content);
2734 2734
 
2735
-          // ----- Set header parameters
2736
-          $p_header['compressed_size'] = strlen($v_content);
2737
-          $p_header['compression'] = 8;
2738
-        }
2735
+		  // ----- Set header parameters
2736
+		  $p_header['compressed_size'] = strlen($v_content);
2737
+		  $p_header['compression'] = 8;
2738
+		}
2739 2739
 
2740
-        // ----- Call the header generation
2741
-        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2742
-          @fclose($v_file);
2743
-          return $v_result;
2744
-        }
2740
+		// ----- Call the header generation
2741
+		if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2742
+		  @fclose($v_file);
2743
+		  return $v_result;
2744
+		}
2745 2745
 
2746
-        // ----- Write the compressed (or not) content
2747
-        @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2748
-      }
2746
+		// ----- Write the compressed (or not) content
2747
+		@fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2748
+	  }
2749 2749
 
2750
-      // ----- Look for a directory
2751
-      else if ($p_filedescr['type'] == 'folder') {
2752
-        // ----- Look for directory last '/'
2753
-        if (@substr($p_header['stored_filename'], -1) != '/') {
2754
-          $p_header['stored_filename'] .= '/';
2755
-        }
2756
-
2757
-        // ----- Set the file properties
2758
-        $p_header['size'] = 0;
2759
-        //$p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
2760
-        $p_header['external'] = 0x00000010;   // Value for a folder : to be checked
2761
-
2762
-        // ----- Call the header generation
2763
-        if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
2764
-        {
2765
-          return $v_result;
2766
-        }
2767
-      }
2768
-    }
2750
+	  // ----- Look for a directory
2751
+	  else if ($p_filedescr['type'] == 'folder') {
2752
+		// ----- Look for directory last '/'
2753
+		if (@substr($p_header['stored_filename'], -1) != '/') {
2754
+		  $p_header['stored_filename'] .= '/';
2755
+		}
2756
+
2757
+		// ----- Set the file properties
2758
+		$p_header['size'] = 0;
2759
+		//$p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
2760
+		$p_header['external'] = 0x00000010;   // Value for a folder : to be checked
2761
+
2762
+		// ----- Call the header generation
2763
+		if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
2764
+		{
2765
+		  return $v_result;
2766
+		}
2767
+	  }
2768
+	}
2769 2769
 
2770
-    // ----- Look for post-add callback
2771
-    if (isset($p_options[PCLZIP_CB_POST_ADD])) {
2770
+	// ----- Look for post-add callback
2771
+	if (isset($p_options[PCLZIP_CB_POST_ADD])) {
2772 2772
 
2773
-      // ----- Generate a local information
2774
-      $v_local_header = array();
2775
-      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2773
+	  // ----- Generate a local information
2774
+	  $v_local_header = array();
2775
+	  $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2776 2776
 
2777
-      // ----- Call the callback
2778
-      // Here I do not use call_user_func() because I need to send a reference to the
2779
-      // header.
2780
-      $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
2781
-      if ($v_result == 0) {
2782
-        // ----- Ignored
2783
-        $v_result = 1;
2784
-      }
2777
+	  // ----- Call the callback
2778
+	  // Here I do not use call_user_func() because I need to send a reference to the
2779
+	  // header.
2780
+	  $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
2781
+	  if ($v_result == 0) {
2782
+		// ----- Ignored
2783
+		$v_result = 1;
2784
+	  }
2785 2785
 
2786
-      // ----- Update the informations
2787
-      // Nothing can be modified
2788
-    }
2786
+	  // ----- Update the informations
2787
+	  // Nothing can be modified
2788
+	}
2789 2789
 
2790
-    // ----- Return
2791
-    return $v_result;
2790
+	// ----- Return
2791
+	return $v_result;
2792 2792
   }
2793 2793
   // --------------------------------------------------------------------------------
2794 2794
 
@@ -2800,105 +2800,105 @@  discard block
 block discarded – undo
2800 2800
   // --------------------------------------------------------------------------------
2801 2801
   function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
2802 2802
   {
2803
-    $v_result=PCLZIP_ERR_NO_ERROR;
2803
+	$v_result=PCLZIP_ERR_NO_ERROR;
2804 2804
 
2805
-    // ----- Working variable
2806
-    $p_filename = $p_filedescr['filename'];
2805
+	// ----- Working variable
2806
+	$p_filename = $p_filedescr['filename'];
2807 2807
 
2808 2808
 
2809
-    // ----- Open the source file
2810
-    if (($v_file = @fopen($p_filename, "rb")) == 0) {
2811
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2812
-      return PclZip::errorCode();
2813
-    }
2809
+	// ----- Open the source file
2810
+	if (($v_file = @fopen($p_filename, "rb")) == 0) {
2811
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2812
+	  return PclZip::errorCode();
2813
+	}
2814 2814
 
2815
-    // ----- Creates a compressed temporary file
2816
-    $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2817
-    if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
2818
-      fclose($v_file);
2819
-      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2820
-      return PclZip::errorCode();
2821
-    }
2815
+	// ----- Creates a compressed temporary file
2816
+	$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2817
+	if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
2818
+	  fclose($v_file);
2819
+	  PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2820
+	  return PclZip::errorCode();
2821
+	}
2822 2822
 
2823
-    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2824
-    $v_size = filesize($p_filename);
2825
-    while ($v_size != 0) {
2826
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2827
-      $v_buffer = @fread($v_file, $v_read_size);
2828
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2829
-      @gzputs($v_file_compressed, $v_buffer, $v_read_size);
2830
-      $v_size -= $v_read_size;
2831
-    }
2823
+	// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2824
+	$v_size = filesize($p_filename);
2825
+	while ($v_size != 0) {
2826
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2827
+	  $v_buffer = @fread($v_file, $v_read_size);
2828
+	  //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2829
+	  @gzputs($v_file_compressed, $v_buffer, $v_read_size);
2830
+	  $v_size -= $v_read_size;
2831
+	}
2832 2832
 
2833
-    // ----- Close the file
2834
-    @fclose($v_file);
2835
-    @gzclose($v_file_compressed);
2833
+	// ----- Close the file
2834
+	@fclose($v_file);
2835
+	@gzclose($v_file_compressed);
2836 2836
 
2837
-    // ----- Check the minimum file size
2838
-    if (filesize($v_gzip_temp_name) < 18) {
2839
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
2840
-      return PclZip::errorCode();
2841
-    }
2837
+	// ----- Check the minimum file size
2838
+	if (filesize($v_gzip_temp_name) < 18) {
2839
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
2840
+	  return PclZip::errorCode();
2841
+	}
2842 2842
 
2843
-    // ----- Extract the compressed attributes
2844
-    if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
2845
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2846
-      return PclZip::errorCode();
2847
-    }
2843
+	// ----- Extract the compressed attributes
2844
+	if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
2845
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2846
+	  return PclZip::errorCode();
2847
+	}
2848 2848
 
2849
-    // ----- Read the gzip file header
2850
-    $v_binary_data = @fread($v_file_compressed, 10);
2851
-    $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
2849
+	// ----- Read the gzip file header
2850
+	$v_binary_data = @fread($v_file_compressed, 10);
2851
+	$v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
2852 2852
 
2853
-    // ----- Check some parameters
2854
-    $v_data_header['os'] = bin2hex($v_data_header['os']);
2853
+	// ----- Check some parameters
2854
+	$v_data_header['os'] = bin2hex($v_data_header['os']);
2855 2855
 
2856
-    // ----- Read the gzip file footer
2857
-    @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
2858
-    $v_binary_data = @fread($v_file_compressed, 8);
2859
-    $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
2856
+	// ----- Read the gzip file footer
2857
+	@fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
2858
+	$v_binary_data = @fread($v_file_compressed, 8);
2859
+	$v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
2860 2860
 
2861
-    // ----- Set the attributes
2862
-    $p_header['compression'] = ord($v_data_header['cm']);
2863
-    //$p_header['mtime'] = $v_data_header['mtime'];
2864
-    $p_header['crc'] = $v_data_footer['crc'];
2865
-    $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
2861
+	// ----- Set the attributes
2862
+	$p_header['compression'] = ord($v_data_header['cm']);
2863
+	//$p_header['mtime'] = $v_data_header['mtime'];
2864
+	$p_header['crc'] = $v_data_footer['crc'];
2865
+	$p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
2866 2866
 
2867
-    // ----- Close the file
2868
-    @fclose($v_file_compressed);
2867
+	// ----- Close the file
2868
+	@fclose($v_file_compressed);
2869 2869
 
2870
-    // ----- Call the header generation
2871
-    if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2872
-      return $v_result;
2873
-    }
2870
+	// ----- Call the header generation
2871
+	if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2872
+	  return $v_result;
2873
+	}
2874 2874
 
2875
-    // ----- Add the compressed data
2876
-    if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
2877
-    {
2878
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2879
-      return PclZip::errorCode();
2880
-    }
2875
+	// ----- Add the compressed data
2876
+	if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
2877
+	{
2878
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2879
+	  return PclZip::errorCode();
2880
+	}
2881 2881
 
2882
-    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2883
-    fseek($v_file_compressed, 10);
2884
-    $v_size = $p_header['compressed_size'];
2885
-    while ($v_size != 0)
2886
-    {
2887
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2888
-      $v_buffer = @fread($v_file_compressed, $v_read_size);
2889
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2890
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2891
-      $v_size -= $v_read_size;
2892
-    }
2882
+	// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2883
+	fseek($v_file_compressed, 10);
2884
+	$v_size = $p_header['compressed_size'];
2885
+	while ($v_size != 0)
2886
+	{
2887
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2888
+	  $v_buffer = @fread($v_file_compressed, $v_read_size);
2889
+	  //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2890
+	  @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2891
+	  $v_size -= $v_read_size;
2892
+	}
2893 2893
 
2894
-    // ----- Close the file
2895
-    @fclose($v_file_compressed);
2894
+	// ----- Close the file
2895
+	@fclose($v_file_compressed);
2896 2896
 
2897
-    // ----- Unlink the temporary file
2898
-    @unlink($v_gzip_temp_name);
2897
+	// ----- Unlink the temporary file
2898
+	@unlink($v_gzip_temp_name);
2899 2899
 
2900
-    // ----- Return
2901
-    return $v_result;
2900
+	// ----- Return
2901
+	return $v_result;
2902 2902
   }
2903 2903
   // --------------------------------------------------------------------------------
2904 2904
 
@@ -2912,107 +2912,107 @@  discard block
 block discarded – undo
2912 2912
   // --------------------------------------------------------------------------------
2913 2913
   function privCalculateStoredFilename(&$p_filedescr, &$p_options)
2914 2914
   {
2915
-    $v_result=1;
2916
-
2917
-    // ----- Working variables
2918
-    $p_filename = $p_filedescr['filename'];
2919
-    if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
2920
-      $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2921
-    }
2922
-    else {
2923
-      $p_add_dir = '';
2924
-    }
2925
-    if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
2926
-      $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2927
-    }
2928
-    else {
2929
-      $p_remove_dir = '';
2930
-    }
2931
-    if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
2932
-      $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2933
-    }
2934
-    else {
2935
-      $p_remove_all_dir = 0;
2936
-    }
2915
+	$v_result=1;
2937 2916
 
2917
+	// ----- Working variables
2918
+	$p_filename = $p_filedescr['filename'];
2919
+	if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
2920
+	  $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2921
+	}
2922
+	else {
2923
+	  $p_add_dir = '';
2924
+	}
2925
+	if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
2926
+	  $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2927
+	}
2928
+	else {
2929
+	  $p_remove_dir = '';
2930
+	}
2931
+	if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
2932
+	  $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2933
+	}
2934
+	else {
2935
+	  $p_remove_all_dir = 0;
2936
+	}
2938 2937
 
2939
-    // ----- Look for full name change
2940
-    if (isset($p_filedescr['new_full_name'])) {
2941
-      // ----- Remove drive letter if any
2942
-      $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
2943
-    }
2944 2938
 
2945
-    // ----- Look for path and/or short name change
2946
-    else {
2939
+	// ----- Look for full name change
2940
+	if (isset($p_filedescr['new_full_name'])) {
2941
+	  // ----- Remove drive letter if any
2942
+	  $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
2943
+	}
2947 2944
 
2948
-      // ----- Look for short name change
2949
-      // Its when we cahnge just the filename but not the path
2950
-      if (isset($p_filedescr['new_short_name'])) {
2951
-        $v_path_info = pathinfo($p_filename);
2952
-        $v_dir = '';
2953
-        if ($v_path_info['dirname'] != '') {
2954
-          $v_dir = $v_path_info['dirname'].'/';
2955
-        }
2956
-        $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2957
-      }
2958
-      else {
2959
-        // ----- Calculate the stored filename
2960
-        $v_stored_filename = $p_filename;
2961
-      }
2945
+	// ----- Look for path and/or short name change
2946
+	else {
2947
+
2948
+	  // ----- Look for short name change
2949
+	  // Its when we cahnge just the filename but not the path
2950
+	  if (isset($p_filedescr['new_short_name'])) {
2951
+		$v_path_info = pathinfo($p_filename);
2952
+		$v_dir = '';
2953
+		if ($v_path_info['dirname'] != '') {
2954
+		  $v_dir = $v_path_info['dirname'].'/';
2955
+		}
2956
+		$v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2957
+	  }
2958
+	  else {
2959
+		// ----- Calculate the stored filename
2960
+		$v_stored_filename = $p_filename;
2961
+	  }
2962 2962
 
2963
-      // ----- Look for all path to remove
2964
-      if ($p_remove_all_dir) {
2965
-        $v_stored_filename = basename($p_filename);
2966
-      }
2967
-      // ----- Look for partial path remove
2968
-      else if ($p_remove_dir != "") {
2969
-        if (substr($p_remove_dir, -1) != '/')
2970
-          $p_remove_dir .= "/";
2963
+	  // ----- Look for all path to remove
2964
+	  if ($p_remove_all_dir) {
2965
+		$v_stored_filename = basename($p_filename);
2966
+	  }
2967
+	  // ----- Look for partial path remove
2968
+	  else if ($p_remove_dir != "") {
2969
+		if (substr($p_remove_dir, -1) != '/')
2970
+		  $p_remove_dir .= "/";
2971 2971
 
2972
-        if (   (substr($p_filename, 0, 2) == "./")
2973
-            || (substr($p_remove_dir, 0, 2) == "./")) {
2972
+		if (   (substr($p_filename, 0, 2) == "./")
2973
+			|| (substr($p_remove_dir, 0, 2) == "./")) {
2974 2974
 
2975
-          if (   (substr($p_filename, 0, 2) == "./")
2976
-              && (substr($p_remove_dir, 0, 2) != "./")) {
2977
-            $p_remove_dir = "./".$p_remove_dir;
2978
-          }
2979
-          if (   (substr($p_filename, 0, 2) != "./")
2980
-              && (substr($p_remove_dir, 0, 2) == "./")) {
2981
-            $p_remove_dir = substr($p_remove_dir, 2);
2982
-          }
2983
-        }
2975
+		  if (   (substr($p_filename, 0, 2) == "./")
2976
+			  && (substr($p_remove_dir, 0, 2) != "./")) {
2977
+			$p_remove_dir = "./".$p_remove_dir;
2978
+		  }
2979
+		  if (   (substr($p_filename, 0, 2) != "./")
2980
+			  && (substr($p_remove_dir, 0, 2) == "./")) {
2981
+			$p_remove_dir = substr($p_remove_dir, 2);
2982
+		  }
2983
+		}
2984 2984
 
2985
-        $v_compare = PclZipUtilPathInclusion($p_remove_dir,
2986
-                                             $v_stored_filename);
2987
-        if ($v_compare > 0) {
2988
-          if ($v_compare == 2) {
2989
-            $v_stored_filename = "";
2990
-          }
2991
-          else {
2992
-            $v_stored_filename = substr($v_stored_filename,
2993
-                                        strlen($p_remove_dir));
2994
-          }
2995
-        }
2996
-      }
2985
+		$v_compare = PclZipUtilPathInclusion($p_remove_dir,
2986
+											 $v_stored_filename);
2987
+		if ($v_compare > 0) {
2988
+		  if ($v_compare == 2) {
2989
+			$v_stored_filename = "";
2990
+		  }
2991
+		  else {
2992
+			$v_stored_filename = substr($v_stored_filename,
2993
+										strlen($p_remove_dir));
2994
+		  }
2995
+		}
2996
+	  }
2997 2997
 
2998
-      // ----- Remove drive letter if any
2999
-      $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
2998
+	  // ----- Remove drive letter if any
2999
+	  $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
3000 3000
 
3001
-      // ----- Look for path to add
3002
-      if ($p_add_dir != "") {
3003
-        if (substr($p_add_dir, -1) == "/")
3004
-          $v_stored_filename = $p_add_dir.$v_stored_filename;
3005
-        else
3006
-          $v_stored_filename = $p_add_dir."/".$v_stored_filename;
3007
-      }
3008
-    }
3001
+	  // ----- Look for path to add
3002
+	  if ($p_add_dir != "") {
3003
+		if (substr($p_add_dir, -1) == "/")
3004
+		  $v_stored_filename = $p_add_dir.$v_stored_filename;
3005
+		else
3006
+		  $v_stored_filename = $p_add_dir."/".$v_stored_filename;
3007
+	  }
3008
+	}
3009 3009
 
3010
-    // ----- Filename (reduce the path of stored name)
3011
-    $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
3012
-    $p_filedescr['stored_filename'] = $v_stored_filename;
3010
+	// ----- Filename (reduce the path of stored name)
3011
+	$v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
3012
+	$p_filedescr['stored_filename'] = $v_stored_filename;
3013 3013
 
3014
-    // ----- Return
3015
-    return $v_result;
3014
+	// ----- Return
3015
+	return $v_result;
3016 3016
   }
3017 3017
   // --------------------------------------------------------------------------------
3018 3018
 
@@ -3024,40 +3024,40 @@  discard block
 block discarded – undo
3024 3024
   // --------------------------------------------------------------------------------
3025 3025
   function privWriteFileHeader(&$p_header)
3026 3026
   {
3027
-    $v_result=1;
3027
+	$v_result=1;
3028 3028
 
3029
-    // ----- Store the offset position of the file
3030
-    $p_header['offset'] = ftell($this->zip_fd);
3029
+	// ----- Store the offset position of the file
3030
+	$p_header['offset'] = ftell($this->zip_fd);
3031 3031
 
3032
-    // ----- Transform UNIX mtime to DOS format mdate/mtime
3033
-    $v_date = getdate($p_header['mtime']);
3034
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3035
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3032
+	// ----- Transform UNIX mtime to DOS format mdate/mtime
3033
+	$v_date = getdate($p_header['mtime']);
3034
+	$v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3035
+	$v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3036 3036
 
3037
-    // ----- Packed data
3038
-    $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
3039
-	                      $p_header['version_extracted'], $p_header['flag'],
3040
-                          $p_header['compression'], $v_mtime, $v_mdate,
3041
-                          $p_header['crc'], $p_header['compressed_size'],
3037
+	// ----- Packed data
3038
+	$v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
3039
+						  $p_header['version_extracted'], $p_header['flag'],
3040
+						  $p_header['compression'], $v_mtime, $v_mdate,
3041
+						  $p_header['crc'], $p_header['compressed_size'],
3042 3042
 						  $p_header['size'],
3043
-                          strlen($p_header['stored_filename']),
3043
+						  strlen($p_header['stored_filename']),
3044 3044
 						  $p_header['extra_len']);
3045 3045
 
3046
-    // ----- Write the first 148 bytes of the header in the archive
3047
-    fputs($this->zip_fd, $v_binary_data, 30);
3046
+	// ----- Write the first 148 bytes of the header in the archive
3047
+	fputs($this->zip_fd, $v_binary_data, 30);
3048 3048
 
3049
-    // ----- Write the variable fields
3050
-    if (strlen($p_header['stored_filename']) != 0)
3051
-    {
3052
-      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3053
-    }
3054
-    if ($p_header['extra_len'] != 0)
3055
-    {
3056
-      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3057
-    }
3049
+	// ----- Write the variable fields
3050
+	if (strlen($p_header['stored_filename']) != 0)
3051
+	{
3052
+	  fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3053
+	}
3054
+	if ($p_header['extra_len'] != 0)
3055
+	{
3056
+	  fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3057
+	}
3058 3058
 
3059
-    // ----- Return
3060
-    return $v_result;
3059
+	// ----- Return
3060
+	return $v_result;
3061 3061
   }
3062 3062
   // --------------------------------------------------------------------------------
3063 3063
 
@@ -3069,48 +3069,48 @@  discard block
 block discarded – undo
3069 3069
   // --------------------------------------------------------------------------------
3070 3070
   function privWriteCentralFileHeader(&$p_header)
3071 3071
   {
3072
-    $v_result=1;
3072
+	$v_result=1;
3073 3073
 
3074
-    // TBC
3075
-    //for(reset($p_header); $key = key($p_header); next($p_header)) {
3076
-    //}
3074
+	// TBC
3075
+	//for(reset($p_header); $key = key($p_header); next($p_header)) {
3076
+	//}
3077 3077
 
3078
-    // ----- Transform UNIX mtime to DOS format mdate/mtime
3079
-    $v_date = getdate($p_header['mtime']);
3080
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3081
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3078
+	// ----- Transform UNIX mtime to DOS format mdate/mtime
3079
+	$v_date = getdate($p_header['mtime']);
3080
+	$v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3081
+	$v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3082 3082
 
3083 3083
 
3084
-    // ----- Packed data
3085
-    $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
3086
-	                      $p_header['version'], $p_header['version_extracted'],
3087
-                          $p_header['flag'], $p_header['compression'],
3084
+	// ----- Packed data
3085
+	$v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
3086
+						  $p_header['version'], $p_header['version_extracted'],
3087
+						  $p_header['flag'], $p_header['compression'],
3088 3088
 						  $v_mtime, $v_mdate, $p_header['crc'],
3089
-                          $p_header['compressed_size'], $p_header['size'],
3090
-                          strlen($p_header['stored_filename']),
3089
+						  $p_header['compressed_size'], $p_header['size'],
3090
+						  strlen($p_header['stored_filename']),
3091 3091
 						  $p_header['extra_len'], $p_header['comment_len'],
3092
-                          $p_header['disk'], $p_header['internal'],
3092
+						  $p_header['disk'], $p_header['internal'],
3093 3093
 						  $p_header['external'], $p_header['offset']);
3094 3094
 
3095
-    // ----- Write the 42 bytes of the header in the zip file
3096
-    fputs($this->zip_fd, $v_binary_data, 46);
3095
+	// ----- Write the 42 bytes of the header in the zip file
3096
+	fputs($this->zip_fd, $v_binary_data, 46);
3097 3097
 
3098
-    // ----- Write the variable fields
3099
-    if (strlen($p_header['stored_filename']) != 0)
3100
-    {
3101
-      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3102
-    }
3103
-    if ($p_header['extra_len'] != 0)
3104
-    {
3105
-      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3106
-    }
3107
-    if ($p_header['comment_len'] != 0)
3108
-    {
3109
-      fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
3110
-    }
3098
+	// ----- Write the variable fields
3099
+	if (strlen($p_header['stored_filename']) != 0)
3100
+	{
3101
+	  fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3102
+	}
3103
+	if ($p_header['extra_len'] != 0)
3104
+	{
3105
+	  fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3106
+	}
3107
+	if ($p_header['comment_len'] != 0)
3108
+	{
3109
+	  fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
3110
+	}
3111 3111
 
3112
-    // ----- Return
3113
-    return $v_result;
3112
+	// ----- Return
3113
+	return $v_result;
3114 3114
   }
3115 3115
   // --------------------------------------------------------------------------------
3116 3116
 
@@ -3122,24 +3122,24 @@  discard block
 block discarded – undo
3122 3122
   // --------------------------------------------------------------------------------
3123 3123
   function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
3124 3124
   {
3125
-    $v_result=1;
3125
+	$v_result=1;
3126 3126
 
3127
-    // ----- Packed data
3128
-    $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
3129
-	                      $p_nb_entries, $p_size,
3127
+	// ----- Packed data
3128
+	$v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
3129
+						  $p_nb_entries, $p_size,
3130 3130
 						  $p_offset, strlen($p_comment));
3131 3131
 
3132
-    // ----- Write the 22 bytes of the header in the zip file
3133
-    fputs($this->zip_fd, $v_binary_data, 22);
3132
+	// ----- Write the 22 bytes of the header in the zip file
3133
+	fputs($this->zip_fd, $v_binary_data, 22);
3134 3134
 
3135
-    // ----- Write the variable fields
3136
-    if (strlen($p_comment) != 0)
3137
-    {
3138
-      fputs($this->zip_fd, $p_comment, strlen($p_comment));
3139
-    }
3135
+	// ----- Write the variable fields
3136
+	if (strlen($p_comment) != 0)
3137
+	{
3138
+	  fputs($this->zip_fd, $p_comment, strlen($p_comment));
3139
+	}
3140 3140
 
3141
-    // ----- Return
3142
-    return $v_result;
3141
+	// ----- Return
3142
+	return $v_result;
3143 3143
   }
3144 3144
   // --------------------------------------------------------------------------------
3145 3145
 
@@ -3151,69 +3151,69 @@  discard block
 block discarded – undo
3151 3151
   // --------------------------------------------------------------------------------
3152 3152
   function privList(&$p_list)
3153 3153
   {
3154
-    $v_result=1;
3154
+	$v_result=1;
3155 3155
 
3156
-    // ----- Magic quotes trick
3157
-    $this->privDisableMagicQuotes();
3156
+	// ----- Magic quotes trick
3157
+	$this->privDisableMagicQuotes();
3158 3158
 
3159
-    // ----- Open the zip file
3160
-    if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
3161
-    {
3162
-      // ----- Magic quotes trick
3163
-      $this->privSwapBackMagicQuotes();
3159
+	// ----- Open the zip file
3160
+	if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
3161
+	{
3162
+	  // ----- Magic quotes trick
3163
+	  $this->privSwapBackMagicQuotes();
3164 3164
 
3165
-      // ----- Error log
3166
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3165
+	  // ----- Error log
3166
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3167 3167
 
3168
-      // ----- Return
3169
-      return PclZip::errorCode();
3170
-    }
3168
+	  // ----- Return
3169
+	  return PclZip::errorCode();
3170
+	}
3171 3171
 
3172
-    // ----- Read the central directory informations
3173
-    $v_central_dir = array();
3174
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3175
-    {
3176
-      $this->privSwapBackMagicQuotes();
3177
-      return $v_result;
3178
-    }
3172
+	// ----- Read the central directory informations
3173
+	$v_central_dir = array();
3174
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3175
+	{
3176
+	  $this->privSwapBackMagicQuotes();
3177
+	  return $v_result;
3178
+	}
3179 3179
 
3180
-    // ----- Go to beginning of Central Dir
3181
-    @rewind($this->zip_fd);
3182
-    if (@fseek($this->zip_fd, $v_central_dir['offset']))
3183
-    {
3184
-      $this->privSwapBackMagicQuotes();
3180
+	// ----- Go to beginning of Central Dir
3181
+	@rewind($this->zip_fd);
3182
+	if (@fseek($this->zip_fd, $v_central_dir['offset']))
3183
+	{
3184
+	  $this->privSwapBackMagicQuotes();
3185 3185
 
3186
-      // ----- Error log
3187
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3186
+	  // ----- Error log
3187
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3188 3188
 
3189
-      // ----- Return
3190
-      return PclZip::errorCode();
3191
-    }
3189
+	  // ----- Return
3190
+	  return PclZip::errorCode();
3191
+	}
3192 3192
 
3193
-    // ----- Read each entry
3194
-    for ($i=0; $i<$v_central_dir['entries']; $i++)
3195
-    {
3196
-      // ----- Read the file header
3197
-      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3198
-      {
3199
-        $this->privSwapBackMagicQuotes();
3200
-        return $v_result;
3201
-      }
3202
-      $v_header['index'] = $i;
3193
+	// ----- Read each entry
3194
+	for ($i=0; $i<$v_central_dir['entries']; $i++)
3195
+	{
3196
+	  // ----- Read the file header
3197
+	  if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3198
+	  {
3199
+		$this->privSwapBackMagicQuotes();
3200
+		return $v_result;
3201
+	  }
3202
+	  $v_header['index'] = $i;
3203 3203
 
3204
-      // ----- Get the only interesting attributes
3205
-      $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
3206
-      unset($v_header);
3207
-    }
3204
+	  // ----- Get the only interesting attributes
3205
+	  $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
3206
+	  unset($v_header);
3207
+	}
3208 3208
 
3209
-    // ----- Close the zip file
3210
-    $this->privCloseFd();
3209
+	// ----- Close the zip file
3210
+	$this->privCloseFd();
3211 3211
 
3212
-    // ----- Magic quotes trick
3213
-    $this->privSwapBackMagicQuotes();
3212
+	// ----- Magic quotes trick
3213
+	$this->privSwapBackMagicQuotes();
3214 3214
 
3215
-    // ----- Return
3216
-    return $v_result;
3215
+	// ----- Return
3216
+	return $v_result;
3217 3217
   }
3218 3218
   // --------------------------------------------------------------------------------
3219 3219
 
@@ -3238,24 +3238,24 @@  discard block
 block discarded – undo
3238 3238
   // --------------------------------------------------------------------------------
3239 3239
   function privConvertHeader2FileInfo($p_header, &$p_info)
3240 3240
   {
3241
-    $v_result=1;
3242
-
3243
-    // ----- Get the interesting attributes
3244
-    $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
3245
-    $p_info['filename'] = $v_temp_path;
3246
-    $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
3247
-    $p_info['stored_filename'] = $v_temp_path;
3248
-    $p_info['size'] = $p_header['size'];
3249
-    $p_info['compressed_size'] = $p_header['compressed_size'];
3250
-    $p_info['mtime'] = $p_header['mtime'];
3251
-    $p_info['comment'] = $p_header['comment'];
3252
-    $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
3253
-    $p_info['index'] = $p_header['index'];
3254
-    $p_info['status'] = $p_header['status'];
3255
-    $p_info['crc'] = $p_header['crc'];
3256
-
3257
-    // ----- Return
3258
-    return $v_result;
3241
+	$v_result=1;
3242
+
3243
+	// ----- Get the interesting attributes
3244
+	$v_temp_path = PclZipUtilPathReduction($p_header['filename']);
3245
+	$p_info['filename'] = $v_temp_path;
3246
+	$v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
3247
+	$p_info['stored_filename'] = $v_temp_path;
3248
+	$p_info['size'] = $p_header['size'];
3249
+	$p_info['compressed_size'] = $p_header['compressed_size'];
3250
+	$p_info['mtime'] = $p_header['mtime'];
3251
+	$p_info['comment'] = $p_header['comment'];
3252
+	$p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
3253
+	$p_info['index'] = $p_header['index'];
3254
+	$p_info['status'] = $p_header['status'];
3255
+	$p_info['crc'] = $p_header['crc'];
3256
+
3257
+	// ----- Return
3258
+	return $v_result;
3259 3259
   }
3260 3260
   // --------------------------------------------------------------------------------
3261 3261
 
@@ -3277,122 +3277,122 @@  discard block
 block discarded – undo
3277 3277
   // --------------------------------------------------------------------------------
3278 3278
   function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3279 3279
   {
3280
-    $v_result=1;
3280
+	$v_result=1;
3281 3281
 
3282
-    // ----- Magic quotes trick
3283
-    $this->privDisableMagicQuotes();
3282
+	// ----- Magic quotes trick
3283
+	$this->privDisableMagicQuotes();
3284 3284
 
3285
-    // ----- Check the path
3286
-    if (   ($p_path == "")
3287
-	    || (   (substr($p_path, 0, 1) != "/")
3288
-		    && (substr($p_path, 0, 3) != "../")
3285
+	// ----- Check the path
3286
+	if (   ($p_path == "")
3287
+		|| (   (substr($p_path, 0, 1) != "/")
3288
+			&& (substr($p_path, 0, 3) != "../")
3289 3289
 			&& (substr($p_path,1,2)!=":/")))
3290
-      $p_path = "./".$p_path;
3291
-
3292
-    // ----- Reduce the path last (and duplicated) '/'
3293
-    if (($p_path != "./") && ($p_path != "/"))
3294
-    {
3295
-      // ----- Look for the path end '/'
3296
-      while (substr($p_path, -1) == "/")
3297
-      {
3298
-        $p_path = substr($p_path, 0, strlen($p_path)-1);
3299
-      }
3300
-    }
3290
+	  $p_path = "./".$p_path;
3291
+
3292
+	// ----- Reduce the path last (and duplicated) '/'
3293
+	if (($p_path != "./") && ($p_path != "/"))
3294
+	{
3295
+	  // ----- Look for the path end '/'
3296
+	  while (substr($p_path, -1) == "/")
3297
+	  {
3298
+		$p_path = substr($p_path, 0, strlen($p_path)-1);
3299
+	  }
3300
+	}
3301 3301
 
3302
-    // ----- Look for path to remove format (should end by /)
3303
-    if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
3304
-    {
3305
-      $p_remove_path .= '/';
3306
-    }
3307
-    $p_remove_path_size = strlen($p_remove_path);
3302
+	// ----- Look for path to remove format (should end by /)
3303
+	if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
3304
+	{
3305
+	  $p_remove_path .= '/';
3306
+	}
3307
+	$p_remove_path_size = strlen($p_remove_path);
3308 3308
 
3309
-    // ----- Open the zip file
3310
-    if (($v_result = $this->privOpenFd('rb')) != 1)
3311
-    {
3312
-      $this->privSwapBackMagicQuotes();
3313
-      return $v_result;
3314
-    }
3309
+	// ----- Open the zip file
3310
+	if (($v_result = $this->privOpenFd('rb')) != 1)
3311
+	{
3312
+	  $this->privSwapBackMagicQuotes();
3313
+	  return $v_result;
3314
+	}
3315 3315
 
3316
-    // ----- Read the central directory informations
3317
-    $v_central_dir = array();
3318
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3319
-    {
3320
-      // ----- Close the zip file
3321
-      $this->privCloseFd();
3322
-      $this->privSwapBackMagicQuotes();
3316
+	// ----- Read the central directory informations
3317
+	$v_central_dir = array();
3318
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3319
+	{
3320
+	  // ----- Close the zip file
3321
+	  $this->privCloseFd();
3322
+	  $this->privSwapBackMagicQuotes();
3323 3323
 
3324
-      return $v_result;
3325
-    }
3324
+	  return $v_result;
3325
+	}
3326 3326
 
3327
-    // ----- Start at beginning of Central Dir
3328
-    $v_pos_entry = $v_central_dir['offset'];
3327
+	// ----- Start at beginning of Central Dir
3328
+	$v_pos_entry = $v_central_dir['offset'];
3329 3329
 
3330
-    // ----- Read each entry
3331
-    $j_start = 0;
3332
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3333
-    {
3330
+	// ----- Read each entry
3331
+	$j_start = 0;
3332
+	for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3333
+	{
3334 3334
 
3335
-      // ----- Read next Central dir entry
3336
-      @rewind($this->zip_fd);
3337
-      if (@fseek($this->zip_fd, $v_pos_entry))
3338
-      {
3339
-        // ----- Close the zip file
3340
-        $this->privCloseFd();
3341
-        $this->privSwapBackMagicQuotes();
3335
+	  // ----- Read next Central dir entry
3336
+	  @rewind($this->zip_fd);
3337
+	  if (@fseek($this->zip_fd, $v_pos_entry))
3338
+	  {
3339
+		// ----- Close the zip file
3340
+		$this->privCloseFd();
3341
+		$this->privSwapBackMagicQuotes();
3342 3342
 
3343
-        // ----- Error log
3344
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3343
+		// ----- Error log
3344
+		PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3345 3345
 
3346
-        // ----- Return
3347
-        return PclZip::errorCode();
3348
-      }
3346
+		// ----- Return
3347
+		return PclZip::errorCode();
3348
+	  }
3349 3349
 
3350
-      // ----- Read the file header
3351
-      $v_header = array();
3352
-      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3353
-      {
3354
-        // ----- Close the zip file
3355
-        $this->privCloseFd();
3356
-        $this->privSwapBackMagicQuotes();
3350
+	  // ----- Read the file header
3351
+	  $v_header = array();
3352
+	  if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3353
+	  {
3354
+		// ----- Close the zip file
3355
+		$this->privCloseFd();
3356
+		$this->privSwapBackMagicQuotes();
3357 3357
 
3358
-        return $v_result;
3359
-      }
3358
+		return $v_result;
3359
+	  }
3360 3360
 
3361
-      // ----- Store the index
3362
-      $v_header['index'] = $i;
3361
+	  // ----- Store the index
3362
+	  $v_header['index'] = $i;
3363 3363
 
3364
-      // ----- Store the file position
3365
-      $v_pos_entry = ftell($this->zip_fd);
3364
+	  // ----- Store the file position
3365
+	  $v_pos_entry = ftell($this->zip_fd);
3366 3366
 
3367
-      // ----- Look for the specific extract rules
3368
-      $v_extract = false;
3367
+	  // ----- Look for the specific extract rules
3368
+	  $v_extract = false;
3369 3369
 
3370
-      // ----- Look for extract by name rule
3371
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
3372
-          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3370
+	  // ----- Look for extract by name rule
3371
+	  if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
3372
+		  && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3373 3373
 
3374
-          // ----- Look if the filename is in the list
3375
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3374
+		  // ----- Look if the filename is in the list
3375
+		  for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3376 3376
 
3377
-              // ----- Look for a directory
3378
-              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3377
+			  // ----- Look for a directory
3378
+			  if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3379 3379
 
3380
-                  // ----- Look if the directory is in the filename path
3381
-                  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3382
-                      && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3383
-                      $v_extract = true;
3384
-                  }
3385
-              }
3386
-              // ----- Look for a filename
3387
-              elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
3388
-                  $v_extract = true;
3389
-              }
3390
-          }
3391
-      }
3380
+				  // ----- Look if the directory is in the filename path
3381
+				  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3382
+					  && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3383
+					  $v_extract = true;
3384
+				  }
3385
+			  }
3386
+			  // ----- Look for a filename
3387
+			  elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
3388
+				  $v_extract = true;
3389
+			  }
3390
+		  }
3391
+	  }
3392 3392
 
3393
-      // ----- Look for extract by ereg rule
3394
-      // ereg() is deprecated with PHP 5.3
3395
-      /*
3393
+	  // ----- Look for extract by ereg rule
3394
+	  // ereg() is deprecated with PHP 5.3
3395
+	  /*
3396 3396
       else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
3397 3397
                && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
3398 3398
 
@@ -3402,207 +3402,207 @@  discard block
 block discarded – undo
3402 3402
       }
3403 3403
       */
3404 3404
 
3405
-      // ----- Look for extract by preg rule
3406
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
3407
-               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3405
+	  // ----- Look for extract by preg rule
3406
+	  else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
3407
+			   && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3408 3408
 
3409
-          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
3410
-              $v_extract = true;
3411
-          }
3412
-      }
3409
+		  if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
3410
+			  $v_extract = true;
3411
+		  }
3412
+	  }
3413 3413
 
3414
-      // ----- Look for extract by index rule
3415
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3416
-               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3414
+	  // ----- Look for extract by index rule
3415
+	  else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3416
+			   && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3417 3417
 
3418
-          // ----- Look if the index is in the list
3419
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3418
+		  // ----- Look if the index is in the list
3419
+		  for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3420 3420
 
3421
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3422
-                  $v_extract = true;
3423
-              }
3424
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3425
-                  $j_start = $j+1;
3426
-              }
3421
+			  if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3422
+				  $v_extract = true;
3423
+			  }
3424
+			  if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3425
+				  $j_start = $j+1;
3426
+			  }
3427 3427
 
3428
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3429
-                  break;
3430
-              }
3431
-          }
3432
-      }
3428
+			  if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3429
+				  break;
3430
+			  }
3431
+		  }
3432
+	  }
3433 3433
 
3434
-      // ----- Look for no rule, which means extract all the archive
3435
-      else {
3436
-          $v_extract = true;
3437
-      }
3434
+	  // ----- Look for no rule, which means extract all the archive
3435
+	  else {
3436
+		  $v_extract = true;
3437
+	  }
3438 3438
 
3439 3439
 	  // ----- Check compression method
3440 3440
 	  if (   ($v_extract)
3441
-	      && (   ($v_header['compression'] != 8)
3442
-		      && ($v_header['compression'] != 0))) {
3443
-          $v_header['status'] = 'unsupported_compression';
3441
+		  && (   ($v_header['compression'] != 8)
3442
+			  && ($v_header['compression'] != 0))) {
3443
+		  $v_header['status'] = 'unsupported_compression';
3444 3444
 
3445
-          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3446
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3447
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3445
+		  // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3446
+		  if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3447
+			  && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3448 3448
 
3449
-              $this->privSwapBackMagicQuotes();
3449
+			  $this->privSwapBackMagicQuotes();
3450 3450
 
3451
-              PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3452
-			                       "Filename '".$v_header['stored_filename']."' is "
3453
-				  	    	  	   ."compressed by an unsupported compression "
3454
-				  	    	  	   ."method (".$v_header['compression'].") ");
3451
+			  PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3452
+								   "Filename '".$v_header['stored_filename']."' is "
3453
+				  			  	   ."compressed by an unsupported compression "
3454
+				  			  	   ."method (".$v_header['compression'].") ");
3455 3455
 
3456
-              return PclZip::errorCode();
3456
+			  return PclZip::errorCode();
3457 3457
 		  }
3458 3458
 	  }
3459 3459
 
3460 3460
 	  // ----- Check encrypted files
3461 3461
 	  if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
3462
-          $v_header['status'] = 'unsupported_encryption';
3462
+		  $v_header['status'] = 'unsupported_encryption';
3463 3463
 
3464
-          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3465
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3466
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3464
+		  // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3465
+		  if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3466
+			  && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3467 3467
 
3468
-              $this->privSwapBackMagicQuotes();
3468
+			  $this->privSwapBackMagicQuotes();
3469 3469
 
3470
-              PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3471
-			                       "Unsupported encryption for "
3472
-				  	    	  	   ." filename '".$v_header['stored_filename']
3470
+			  PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3471
+								   "Unsupported encryption for "
3472
+				  			  	   ." filename '".$v_header['stored_filename']
3473 3473
 								   ."'");
3474 3474
 
3475
-              return PclZip::errorCode();
3475
+			  return PclZip::errorCode();
3476 3476
 		  }
3477
-    }
3477
+	}
3478 3478
 
3479
-      // ----- Look for real extraction
3480
-      if (($v_extract) && ($v_header['status'] != 'ok')) {
3481
-          $v_result = $this->privConvertHeader2FileInfo($v_header,
3482
-		                                        $p_file_list[$v_nb_extracted++]);
3483
-          if ($v_result != 1) {
3484
-              $this->privCloseFd();
3485
-              $this->privSwapBackMagicQuotes();
3486
-              return $v_result;
3487
-          }
3479
+	  // ----- Look for real extraction
3480
+	  if (($v_extract) && ($v_header['status'] != 'ok')) {
3481
+		  $v_result = $this->privConvertHeader2FileInfo($v_header,
3482
+												$p_file_list[$v_nb_extracted++]);
3483
+		  if ($v_result != 1) {
3484
+			  $this->privCloseFd();
3485
+			  $this->privSwapBackMagicQuotes();
3486
+			  return $v_result;
3487
+		  }
3488 3488
 
3489
-          $v_extract = false;
3490
-      }
3489
+		  $v_extract = false;
3490
+	  }
3491 3491
 
3492
-      // ----- Look for real extraction
3493
-      if ($v_extract)
3494
-      {
3492
+	  // ----- Look for real extraction
3493
+	  if ($v_extract)
3494
+	  {
3495 3495
 
3496
-        // ----- Go to the file position
3497
-        @rewind($this->zip_fd);
3498
-        if (@fseek($this->zip_fd, $v_header['offset']))
3499
-        {
3500
-          // ----- Close the zip file
3501
-          $this->privCloseFd();
3496
+		// ----- Go to the file position
3497
+		@rewind($this->zip_fd);
3498
+		if (@fseek($this->zip_fd, $v_header['offset']))
3499
+		{
3500
+		  // ----- Close the zip file
3501
+		  $this->privCloseFd();
3502 3502
 
3503
-          $this->privSwapBackMagicQuotes();
3503
+		  $this->privSwapBackMagicQuotes();
3504 3504
 
3505
-          // ----- Error log
3506
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3505
+		  // ----- Error log
3506
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3507 3507
 
3508
-          // ----- Return
3509
-          return PclZip::errorCode();
3510
-        }
3508
+		  // ----- Return
3509
+		  return PclZip::errorCode();
3510
+		}
3511 3511
 
3512
-        // ----- Look for extraction as string
3513
-        if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
3512
+		// ----- Look for extraction as string
3513
+		if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
3514 3514
 
3515
-          $v_string = '';
3515
+		  $v_string = '';
3516 3516
 
3517
-          // ----- Extracting the file
3518
-          $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
3519
-          if ($v_result1 < 1) {
3520
-            $this->privCloseFd();
3521
-            $this->privSwapBackMagicQuotes();
3522
-            return $v_result1;
3523
-          }
3517
+		  // ----- Extracting the file
3518
+		  $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
3519
+		  if ($v_result1 < 1) {
3520
+			$this->privCloseFd();
3521
+			$this->privSwapBackMagicQuotes();
3522
+			return $v_result1;
3523
+		  }
3524 3524
 
3525
-          // ----- Get the only interesting attributes
3526
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
3527
-          {
3528
-            // ----- Close the zip file
3529
-            $this->privCloseFd();
3530
-            $this->privSwapBackMagicQuotes();
3525
+		  // ----- Get the only interesting attributes
3526
+		  if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
3527
+		  {
3528
+			// ----- Close the zip file
3529
+			$this->privCloseFd();
3530
+			$this->privSwapBackMagicQuotes();
3531 3531
 
3532
-            return $v_result;
3533
-          }
3532
+			return $v_result;
3533
+		  }
3534 3534
 
3535
-          // ----- Set the file content
3536
-          $p_file_list[$v_nb_extracted]['content'] = $v_string;
3535
+		  // ----- Set the file content
3536
+		  $p_file_list[$v_nb_extracted]['content'] = $v_string;
3537 3537
 
3538
-          // ----- Next extracted file
3539
-          $v_nb_extracted++;
3538
+		  // ----- Next extracted file
3539
+		  $v_nb_extracted++;
3540 3540
 
3541
-          // ----- Look for user callback abort
3542
-          if ($v_result1 == 2) {
3543
-          	break;
3544
-          }
3545
-        }
3546
-        // ----- Look for extraction in standard output
3547
-        elseif (   (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3548
-		        && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3549
-          // ----- Extracting the file in standard output
3550
-          $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
3551
-          if ($v_result1 < 1) {
3552
-            $this->privCloseFd();
3553
-            $this->privSwapBackMagicQuotes();
3554
-            return $v_result1;
3555
-          }
3541
+		  // ----- Look for user callback abort
3542
+		  if ($v_result1 == 2) {
3543
+		  	break;
3544
+		  }
3545
+		}
3546
+		// ----- Look for extraction in standard output
3547
+		elseif (   (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3548
+				&& ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3549
+		  // ----- Extracting the file in standard output
3550
+		  $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
3551
+		  if ($v_result1 < 1) {
3552
+			$this->privCloseFd();
3553
+			$this->privSwapBackMagicQuotes();
3554
+			return $v_result1;
3555
+		  }
3556 3556
 
3557
-          // ----- Get the only interesting attributes
3558
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
3559
-            $this->privCloseFd();
3560
-            $this->privSwapBackMagicQuotes();
3561
-            return $v_result;
3562
-          }
3557
+		  // ----- Get the only interesting attributes
3558
+		  if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
3559
+			$this->privCloseFd();
3560
+			$this->privSwapBackMagicQuotes();
3561
+			return $v_result;
3562
+		  }
3563 3563
 
3564
-          // ----- Look for user callback abort
3565
-          if ($v_result1 == 2) {
3566
-          	break;
3567
-          }
3568
-        }
3569
-        // ----- Look for normal extraction
3570
-        else {
3571
-          // ----- Extracting the file
3572
-          $v_result1 = $this->privExtractFile($v_header,
3573
-		                                      $p_path, $p_remove_path,
3564
+		  // ----- Look for user callback abort
3565
+		  if ($v_result1 == 2) {
3566
+		  	break;
3567
+		  }
3568
+		}
3569
+		// ----- Look for normal extraction
3570
+		else {
3571
+		  // ----- Extracting the file
3572
+		  $v_result1 = $this->privExtractFile($v_header,
3573
+											  $p_path, $p_remove_path,
3574 3574
 											  $p_remove_all_path,
3575 3575
 											  $p_options);
3576
-          if ($v_result1 < 1) {
3577
-            $this->privCloseFd();
3578
-            $this->privSwapBackMagicQuotes();
3579
-            return $v_result1;
3580
-          }
3576
+		  if ($v_result1 < 1) {
3577
+			$this->privCloseFd();
3578
+			$this->privSwapBackMagicQuotes();
3579
+			return $v_result1;
3580
+		  }
3581 3581
 
3582
-          // ----- Get the only interesting attributes
3583
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
3584
-          {
3585
-            // ----- Close the zip file
3586
-            $this->privCloseFd();
3587
-            $this->privSwapBackMagicQuotes();
3582
+		  // ----- Get the only interesting attributes
3583
+		  if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
3584
+		  {
3585
+			// ----- Close the zip file
3586
+			$this->privCloseFd();
3587
+			$this->privSwapBackMagicQuotes();
3588 3588
 
3589
-            return $v_result;
3590
-          }
3589
+			return $v_result;
3590
+		  }
3591 3591
 
3592
-          // ----- Look for user callback abort
3593
-          if ($v_result1 == 2) {
3594
-          	break;
3595
-          }
3596
-        }
3597
-      }
3598
-    }
3592
+		  // ----- Look for user callback abort
3593
+		  if ($v_result1 == 2) {
3594
+		  	break;
3595
+		  }
3596
+		}
3597
+	  }
3598
+	}
3599 3599
 
3600
-    // ----- Close the zip file
3601
-    $this->privCloseFd();
3602
-    $this->privSwapBackMagicQuotes();
3600
+	// ----- Close the zip file
3601
+	$this->privCloseFd();
3602
+	$this->privSwapBackMagicQuotes();
3603 3603
 
3604
-    // ----- Return
3605
-    return $v_result;
3604
+	// ----- Return
3605
+	return $v_result;
3606 3606
   }
3607 3607
   // --------------------------------------------------------------------------------
3608 3608
 
@@ -3617,344 +3617,344 @@  discard block
 block discarded – undo
3617 3617
   // --------------------------------------------------------------------------------
3618 3618
   function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3619 3619
   {
3620
-    $v_result=1;
3620
+	$v_result=1;
3621 3621
 
3622
-    // ----- Read the file header
3623
-    if (($v_result = $this->privReadFileHeader($v_header)) != 1)
3624
-    {
3625
-      // ----- Return
3626
-      return $v_result;
3627
-    }
3622
+	// ----- Read the file header
3623
+	if (($v_result = $this->privReadFileHeader($v_header)) != 1)
3624
+	{
3625
+	  // ----- Return
3626
+	  return $v_result;
3627
+	}
3628 3628
 
3629 3629
 
3630
-    // ----- Check that the file header is coherent with $p_entry info
3631
-    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
3632
-        // TBC
3633
-    }
3630
+	// ----- Check that the file header is coherent with $p_entry info
3631
+	if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
3632
+		// TBC
3633
+	}
3634 3634
 
3635
-    // ----- Look for all path to remove
3636
-    if ($p_remove_all_path == true) {
3637
-        // ----- Look for folder entry that not need to be extracted
3638
-        if (($p_entry['external']&0x00000010)==0x00000010) {
3635
+	// ----- Look for all path to remove
3636
+	if ($p_remove_all_path == true) {
3637
+		// ----- Look for folder entry that not need to be extracted
3638
+		if (($p_entry['external']&0x00000010)==0x00000010) {
3639 3639
 
3640
-            $p_entry['status'] = "filtered";
3640
+			$p_entry['status'] = "filtered";
3641 3641
 
3642
-            return $v_result;
3643
-        }
3642
+			return $v_result;
3643
+		}
3644 3644
 
3645
-        // ----- Get the basename of the path
3646
-        $p_entry['filename'] = basename($p_entry['filename']);
3647
-    }
3645
+		// ----- Get the basename of the path
3646
+		$p_entry['filename'] = basename($p_entry['filename']);
3647
+	}
3648 3648
 
3649
-    // ----- Look for path to remove
3650
-    else if ($p_remove_path != "")
3651
-    {
3652
-      if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
3653
-      {
3649
+	// ----- Look for path to remove
3650
+	else if ($p_remove_path != "")
3651
+	{
3652
+	  if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
3653
+	  {
3654 3654
 
3655
-        // ----- Change the file status
3656
-        $p_entry['status'] = "filtered";
3655
+		// ----- Change the file status
3656
+		$p_entry['status'] = "filtered";
3657 3657
 
3658
-        // ----- Return
3659
-        return $v_result;
3660
-      }
3658
+		// ----- Return
3659
+		return $v_result;
3660
+	  }
3661 3661
 
3662
-      $p_remove_path_size = strlen($p_remove_path);
3663
-      if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
3664
-      {
3662
+	  $p_remove_path_size = strlen($p_remove_path);
3663
+	  if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
3664
+	  {
3665 3665
 
3666
-        // ----- Remove the path
3667
-        $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
3666
+		// ----- Remove the path
3667
+		$p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
3668 3668
 
3669
-      }
3670
-    }
3669
+	  }
3670
+	}
3671 3671
 
3672
-    // ----- Add the path
3673
-    if ($p_path != '') {
3674
-      $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3675
-    }
3672
+	// ----- Add the path
3673
+	if ($p_path != '') {
3674
+	  $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3675
+	}
3676 3676
 
3677
-    // ----- Check a base_dir_restriction
3678
-    if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
3679
-      $v_inclusion
3680
-      = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
3681
-                                $p_entry['filename']);
3682
-      if ($v_inclusion == 0) {
3677
+	// ----- Check a base_dir_restriction
3678
+	if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
3679
+	  $v_inclusion
3680
+	  = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
3681
+								$p_entry['filename']);
3682
+	  if ($v_inclusion == 0) {
3683 3683
 
3684
-        PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
3685
-			                     "Filename '".$p_entry['filename']."' is "
3684
+		PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
3685
+								 "Filename '".$p_entry['filename']."' is "
3686 3686
 								 ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
3687 3687
 
3688
-        return PclZip::errorCode();
3689
-      }
3690
-    }
3688
+		return PclZip::errorCode();
3689
+	  }
3690
+	}
3691 3691
 
3692
-    // ----- Look for pre-extract callback
3693
-    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3694
-
3695
-      // ----- Generate a local information
3696
-      $v_local_header = array();
3697
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3698
-
3699
-      // ----- Call the callback
3700
-      // Here I do not use call_user_func() because I need to send a reference to the
3701
-      // header.
3702
-      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3703
-      if ($v_result == 0) {
3704
-        // ----- Change the file status
3705
-        $p_entry['status'] = "skipped";
3706
-        $v_result = 1;
3707
-      }
3692
+	// ----- Look for pre-extract callback
3693
+	if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3694
+
3695
+	  // ----- Generate a local information
3696
+	  $v_local_header = array();
3697
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3698
+
3699
+	  // ----- Call the callback
3700
+	  // Here I do not use call_user_func() because I need to send a reference to the
3701
+	  // header.
3702
+	  $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3703
+	  if ($v_result == 0) {
3704
+		// ----- Change the file status
3705
+		$p_entry['status'] = "skipped";
3706
+		$v_result = 1;
3707
+	  }
3708 3708
 
3709
-      // ----- Look for abort result
3710
-      if ($v_result == 2) {
3711
-        // ----- This status is internal and will be changed in 'skipped'
3712
-        $p_entry['status'] = "aborted";
3713
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
3714
-      }
3709
+	  // ----- Look for abort result
3710
+	  if ($v_result == 2) {
3711
+		// ----- This status is internal and will be changed in 'skipped'
3712
+		$p_entry['status'] = "aborted";
3713
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
3714
+	  }
3715 3715
 
3716
-      // ----- Update the informations
3717
-      // Only some fields can be modified
3718
-      $p_entry['filename'] = $v_local_header['filename'];
3719
-    }
3716
+	  // ----- Update the informations
3717
+	  // Only some fields can be modified
3718
+	  $p_entry['filename'] = $v_local_header['filename'];
3719
+	}
3720 3720
 
3721 3721
 
3722
-    // ----- Look if extraction should be done
3723
-    if ($p_entry['status'] == 'ok') {
3722
+	// ----- Look if extraction should be done
3723
+	if ($p_entry['status'] == 'ok') {
3724 3724
 
3725
-    // ----- Look for specific actions while the file exist
3726
-    if (file_exists($p_entry['filename']))
3727
-    {
3725
+	// ----- Look for specific actions while the file exist
3726
+	if (file_exists($p_entry['filename']))
3727
+	{
3728 3728
 
3729
-      // ----- Look if file is a directory
3730
-      if (is_dir($p_entry['filename']))
3731
-      {
3729
+	  // ----- Look if file is a directory
3730
+	  if (is_dir($p_entry['filename']))
3731
+	  {
3732 3732
 
3733
-        // ----- Change the file status
3734
-        $p_entry['status'] = "already_a_directory";
3733
+		// ----- Change the file status
3734
+		$p_entry['status'] = "already_a_directory";
3735 3735
 
3736
-        // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3737
-        // For historical reason first PclZip implementation does not stop
3738
-        // when this kind of error occurs.
3739
-        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3740
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3736
+		// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3737
+		// For historical reason first PclZip implementation does not stop
3738
+		// when this kind of error occurs.
3739
+		if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3740
+			&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3741 3741
 
3742
-            PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3743
-			                     "Filename '".$p_entry['filename']."' is "
3742
+			PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3743
+								 "Filename '".$p_entry['filename']."' is "
3744 3744
 								 ."already used by an existing directory");
3745 3745
 
3746
-            return PclZip::errorCode();
3747
-		    }
3748
-      }
3749
-      // ----- Look if file is write protected
3750
-      else if (!is_writeable($p_entry['filename']))
3751
-      {
3746
+			return PclZip::errorCode();
3747
+			}
3748
+	  }
3749
+	  // ----- Look if file is write protected
3750
+	  else if (!is_writeable($p_entry['filename']))
3751
+	  {
3752 3752
 
3753
-        // ----- Change the file status
3754
-        $p_entry['status'] = "write_protected";
3753
+		// ----- Change the file status
3754
+		$p_entry['status'] = "write_protected";
3755 3755
 
3756
-        // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3757
-        // For historical reason first PclZip implementation does not stop
3758
-        // when this kind of error occurs.
3759
-        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3760
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3756
+		// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3757
+		// For historical reason first PclZip implementation does not stop
3758
+		// when this kind of error occurs.
3759
+		if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3760
+			&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3761 3761
 
3762
-            PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3763
-			                     "Filename '".$p_entry['filename']."' exists "
3762
+			PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3763
+								 "Filename '".$p_entry['filename']."' exists "
3764 3764
 								 ."and is write protected");
3765 3765
 
3766
-            return PclZip::errorCode();
3767
-		    }
3768
-      }
3766
+			return PclZip::errorCode();
3767
+			}
3768
+	  }
3769 3769
 
3770
-      // ----- Look if the extracted file is older
3771
-      else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3772
-      {
3773
-        // ----- Change the file status
3774
-        if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3775
-		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3770
+	  // ----- Look if the extracted file is older
3771
+	  else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3772
+	  {
3773
+		// ----- Change the file status
3774
+		if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3775
+			&& ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3776 3776
 	  	  }
3777
-		    else {
3778
-            $p_entry['status'] = "newer_exist";
3779
-
3780
-            // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3781
-            // For historical reason first PclZip implementation does not stop
3782
-            // when this kind of error occurs.
3783
-            if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3784
-		        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3785
-
3786
-                PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3787
-			             "Newer version of '".$p_entry['filename']."' exists "
3788
-					    ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
3789
-
3790
-                return PclZip::errorCode();
3791
-		      }
3792
-		    }
3793
-      }
3794
-      else {
3795
-      }
3796
-    }
3777
+			else {
3778
+			$p_entry['status'] = "newer_exist";
3779
+
3780
+			// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3781
+			// For historical reason first PclZip implementation does not stop
3782
+			// when this kind of error occurs.
3783
+			if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3784
+				&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3785
+
3786
+				PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3787
+						 "Newer version of '".$p_entry['filename']."' exists "
3788
+						."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
3789
+
3790
+				return PclZip::errorCode();
3791
+			  }
3792
+			}
3793
+	  }
3794
+	  else {
3795
+	  }
3796
+	}
3797 3797
 
3798
-    // ----- Check the directory availability and create it if necessary
3799
-    else {
3800
-      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3801
-        $v_dir_to_check = $p_entry['filename'];
3802
-      else if (!strstr($p_entry['filename'], "/"))
3803
-        $v_dir_to_check = "";
3804
-      else
3805
-        $v_dir_to_check = dirname($p_entry['filename']);
3806
-
3807
-        if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3808
-
3809
-          // ----- Change the file status
3810
-          $p_entry['status'] = "path_creation_fail";
3811
-
3812
-          // ----- Return
3813
-          //return $v_result;
3814
-          $v_result = 1;
3815
-        }
3816
-      }
3817
-    }
3798
+	// ----- Check the directory availability and create it if necessary
3799
+	else {
3800
+	  if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3801
+		$v_dir_to_check = $p_entry['filename'];
3802
+	  else if (!strstr($p_entry['filename'], "/"))
3803
+		$v_dir_to_check = "";
3804
+	  else
3805
+		$v_dir_to_check = dirname($p_entry['filename']);
3806
+
3807
+		if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3808
+
3809
+		  // ----- Change the file status
3810
+		  $p_entry['status'] = "path_creation_fail";
3818 3811
 
3819
-    // ----- Look if extraction should be done
3820
-    if ($p_entry['status'] == 'ok') {
3812
+		  // ----- Return
3813
+		  //return $v_result;
3814
+		  $v_result = 1;
3815
+		}
3816
+	  }
3817
+	}
3821 3818
 
3822
-      // ----- Do the extraction (if not a folder)
3823
-      if (!(($p_entry['external']&0x00000010)==0x00000010))
3824
-      {
3825
-        // ----- Look for not compressed file
3826
-        if ($p_entry['compression'] == 0) {
3819
+	// ----- Look if extraction should be done
3820
+	if ($p_entry['status'] == 'ok') {
3827 3821
 
3828
-    		  // ----- Opening destination file
3829
-          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
3830
-          {
3822
+	  // ----- Do the extraction (if not a folder)
3823
+	  if (!(($p_entry['external']&0x00000010)==0x00000010))
3824
+	  {
3825
+		// ----- Look for not compressed file
3826
+		if ($p_entry['compression'] == 0) {
3831 3827
 
3832
-            // ----- Change the file status
3833
-            $p_entry['status'] = "write_error";
3828
+			  // ----- Opening destination file
3829
+		  if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
3830
+		  {
3834 3831
 
3835
-            // ----- Return
3836
-            return $v_result;
3837
-          }
3832
+			// ----- Change the file status
3833
+			$p_entry['status'] = "write_error";
3834
+
3835
+			// ----- Return
3836
+			return $v_result;
3837
+		  }
3838 3838
 
3839 3839
 
3840
-          // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3841
-          $v_size = $p_entry['compressed_size'];
3842
-          while ($v_size != 0)
3843
-          {
3844
-            $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3845
-            $v_buffer = @fread($this->zip_fd, $v_read_size);
3846
-            /* Try to speed up the code
3840
+		  // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3841
+		  $v_size = $p_entry['compressed_size'];
3842
+		  while ($v_size != 0)
3843
+		  {
3844
+			$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3845
+			$v_buffer = @fread($this->zip_fd, $v_read_size);
3846
+			/* Try to speed up the code
3847 3847
             $v_binary_data = pack('a'.$v_read_size, $v_buffer);
3848 3848
             @fwrite($v_dest_file, $v_binary_data, $v_read_size);
3849 3849
             */
3850
-            @fwrite($v_dest_file, $v_buffer, $v_read_size);
3851
-            $v_size -= $v_read_size;
3852
-          }
3850
+			@fwrite($v_dest_file, $v_buffer, $v_read_size);
3851
+			$v_size -= $v_read_size;
3852
+		  }
3853 3853
 
3854
-          // ----- Closing the destination file
3855
-          fclose($v_dest_file);
3854
+		  // ----- Closing the destination file
3855
+		  fclose($v_dest_file);
3856 3856
 
3857
-          // ----- Change the file mtime
3858
-          touch($p_entry['filename'], $p_entry['mtime']);
3857
+		  // ----- Change the file mtime
3858
+		  touch($p_entry['filename'], $p_entry['mtime']);
3859 3859
 
3860 3860
 
3861
-        }
3862
-        else {
3863
-          // ----- TBC
3864
-          // Need to be finished
3865
-          if (($p_entry['flag'] & 1) == 1) {
3866
-            PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
3867
-            return PclZip::errorCode();
3868
-          }
3861
+		}
3862
+		else {
3863
+		  // ----- TBC
3864
+		  // Need to be finished
3865
+		  if (($p_entry['flag'] & 1) == 1) {
3866
+			PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
3867
+			return PclZip::errorCode();
3868
+		  }
3869 3869
 
3870 3870
 
3871
-          // ----- Look for using temporary file to unzip
3872
-          if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
3873
-              && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
3874
-                  || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3875
-                      && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
3876
-            $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
3877
-            if ($v_result < PCLZIP_ERR_NO_ERROR) {
3878
-              return $v_result;
3879
-            }
3880
-          }
3871
+		  // ----- Look for using temporary file to unzip
3872
+		  if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
3873
+			  && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
3874
+				  || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3875
+					  && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
3876
+			$v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
3877
+			if ($v_result < PCLZIP_ERR_NO_ERROR) {
3878
+			  return $v_result;
3879
+			}
3880
+		  }
3881 3881
 
3882
-          // ----- Look for extract in memory
3883
-          else {
3882
+		  // ----- Look for extract in memory
3883
+		  else {
3884 3884
 
3885 3885
 
3886
-            // ----- Read the compressed file in a buffer (one shot)
3887
-            $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
3886
+			// ----- Read the compressed file in a buffer (one shot)
3887
+			$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
3888 3888
 
3889
-            // ----- Decompress the file
3890
-            $v_file_content = @gzinflate($v_buffer);
3891
-            unset($v_buffer);
3892
-            if ($v_file_content === FALSE) {
3889
+			// ----- Decompress the file
3890
+			$v_file_content = @gzinflate($v_buffer);
3891
+			unset($v_buffer);
3892
+			if ($v_file_content === FALSE) {
3893 3893
 
3894
-              // ----- Change the file status
3895
-              // TBC
3896
-              $p_entry['status'] = "error";
3894
+			  // ----- Change the file status
3895
+			  // TBC
3896
+			  $p_entry['status'] = "error";
3897 3897
 
3898
-              return $v_result;
3899
-            }
3898
+			  return $v_result;
3899
+			}
3900 3900
 
3901
-            // ----- Opening destination file
3902
-            if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
3901
+			// ----- Opening destination file
3902
+			if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
3903 3903
 
3904
-              // ----- Change the file status
3905
-              $p_entry['status'] = "write_error";
3904
+			  // ----- Change the file status
3905
+			  $p_entry['status'] = "write_error";
3906 3906
 
3907
-              return $v_result;
3908
-            }
3907
+			  return $v_result;
3908
+			}
3909 3909
 
3910
-            // ----- Write the uncompressed data
3911
-            @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
3912
-            unset($v_file_content);
3910
+			// ----- Write the uncompressed data
3911
+			@fwrite($v_dest_file, $v_file_content, $p_entry['size']);
3912
+			unset($v_file_content);
3913 3913
 
3914
-            // ----- Closing the destination file
3915
-            @fclose($v_dest_file);
3914
+			// ----- Closing the destination file
3915
+			@fclose($v_dest_file);
3916 3916
 
3917
-          }
3917
+		  }
3918 3918
 
3919
-          // ----- Change the file mtime
3920
-          @touch($p_entry['filename'], $p_entry['mtime']);
3921
-        }
3919
+		  // ----- Change the file mtime
3920
+		  @touch($p_entry['filename'], $p_entry['mtime']);
3921
+		}
3922 3922
 
3923
-        // ----- Look for chmod option
3924
-        if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
3923
+		// ----- Look for chmod option
3924
+		if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
3925 3925
 
3926
-          // ----- Change the mode of the file
3927
-          @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
3928
-        }
3926
+		  // ----- Change the mode of the file
3927
+		  @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
3928
+		}
3929 3929
 
3930
-      }
3931
-    }
3930
+	  }
3931
+	}
3932 3932
 
3933 3933
   	// ----- Change abort status
3934 3934
   	if ($p_entry['status'] == "aborted") {
3935
-        $p_entry['status'] = "skipped";
3935
+		$p_entry['status'] = "skipped";
3936 3936
   	}
3937 3937
 
3938
-    // ----- Look for post-extract callback
3939
-    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3938
+	// ----- Look for post-extract callback
3939
+	elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3940 3940
 
3941
-      // ----- Generate a local information
3942
-      $v_local_header = array();
3943
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3941
+	  // ----- Generate a local information
3942
+	  $v_local_header = array();
3943
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3944 3944
 
3945
-      // ----- Call the callback
3946
-      // Here I do not use call_user_func() because I need to send a reference to the
3947
-      // header.
3948
-      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
3945
+	  // ----- Call the callback
3946
+	  // Here I do not use call_user_func() because I need to send a reference to the
3947
+	  // header.
3948
+	  $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
3949 3949
 
3950
-      // ----- Look for abort result
3951
-      if ($v_result == 2) {
3952
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
3953
-      }
3954
-    }
3950
+	  // ----- Look for abort result
3951
+	  if ($v_result == 2) {
3952
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
3953
+	  }
3954
+	}
3955 3955
 
3956
-    // ----- Return
3957
-    return $v_result;
3956
+	// ----- Return
3957
+	return $v_result;
3958 3958
   }
3959 3959
   // --------------------------------------------------------------------------------
3960 3960
 
@@ -3966,71 +3966,71 @@  discard block
 block discarded – undo
3966 3966
   // --------------------------------------------------------------------------------
3967 3967
   function privExtractFileUsingTempFile(&$p_entry, &$p_options)
3968 3968
   {
3969
-    $v_result=1;
3970
-
3971
-    // ----- Creates a temporary file
3972
-    $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
3973
-    if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
3974
-      fclose($v_file);
3975
-      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3976
-      return PclZip::errorCode();
3977
-    }
3969
+	$v_result=1;
3970
+
3971
+	// ----- Creates a temporary file
3972
+	$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
3973
+	if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
3974
+	  fclose($v_file);
3975
+	  PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3976
+	  return PclZip::errorCode();
3977
+	}
3978 3978
 
3979 3979
 
3980
-    // ----- Write gz file format header
3981
-    $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
3982
-    @fwrite($v_dest_file, $v_binary_data, 10);
3980
+	// ----- Write gz file format header
3981
+	$v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
3982
+	@fwrite($v_dest_file, $v_binary_data, 10);
3983 3983
 
3984
-    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3985
-    $v_size = $p_entry['compressed_size'];
3986
-    while ($v_size != 0)
3987
-    {
3988
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3989
-      $v_buffer = @fread($this->zip_fd, $v_read_size);
3990
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
3991
-      @fwrite($v_dest_file, $v_buffer, $v_read_size);
3992
-      $v_size -= $v_read_size;
3993
-    }
3984
+	// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3985
+	$v_size = $p_entry['compressed_size'];
3986
+	while ($v_size != 0)
3987
+	{
3988
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3989
+	  $v_buffer = @fread($this->zip_fd, $v_read_size);
3990
+	  //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
3991
+	  @fwrite($v_dest_file, $v_buffer, $v_read_size);
3992
+	  $v_size -= $v_read_size;
3993
+	}
3994 3994
 
3995
-    // ----- Write gz file format footer
3996
-    $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
3997
-    @fwrite($v_dest_file, $v_binary_data, 8);
3995
+	// ----- Write gz file format footer
3996
+	$v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
3997
+	@fwrite($v_dest_file, $v_binary_data, 8);
3998 3998
 
3999
-    // ----- Close the temporary file
4000
-    @fclose($v_dest_file);
3999
+	// ----- Close the temporary file
4000
+	@fclose($v_dest_file);
4001 4001
 
4002
-    // ----- Opening destination file
4003
-    if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
4004
-      $p_entry['status'] = "write_error";
4005
-      return $v_result;
4006
-    }
4002
+	// ----- Opening destination file
4003
+	if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
4004
+	  $p_entry['status'] = "write_error";
4005
+	  return $v_result;
4006
+	}
4007 4007
 
4008
-    // ----- Open the temporary gz file
4009
-    if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
4010
-      @fclose($v_dest_file);
4011
-      $p_entry['status'] = "read_error";
4012
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4013
-      return PclZip::errorCode();
4014
-    }
4008
+	// ----- Open the temporary gz file
4009
+	if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
4010
+	  @fclose($v_dest_file);
4011
+	  $p_entry['status'] = "read_error";
4012
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4013
+	  return PclZip::errorCode();
4014
+	}
4015 4015
 
4016 4016
 
4017
-    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
4018
-    $v_size = $p_entry['size'];
4019
-    while ($v_size != 0) {
4020
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4021
-      $v_buffer = @gzread($v_src_file, $v_read_size);
4022
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4023
-      @fwrite($v_dest_file, $v_buffer, $v_read_size);
4024
-      $v_size -= $v_read_size;
4025
-    }
4026
-    @fclose($v_dest_file);
4027
-    @gzclose($v_src_file);
4017
+	// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
4018
+	$v_size = $p_entry['size'];
4019
+	while ($v_size != 0) {
4020
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4021
+	  $v_buffer = @gzread($v_src_file, $v_read_size);
4022
+	  //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4023
+	  @fwrite($v_dest_file, $v_buffer, $v_read_size);
4024
+	  $v_size -= $v_read_size;
4025
+	}
4026
+	@fclose($v_dest_file);
4027
+	@gzclose($v_src_file);
4028 4028
 
4029
-    // ----- Delete the temporary file
4030
-    @unlink($v_gzip_temp_name);
4029
+	// ----- Delete the temporary file
4030
+	@unlink($v_gzip_temp_name);
4031 4031
 
4032
-    // ----- Return
4033
-    return $v_result;
4032
+	// ----- Return
4033
+	return $v_result;
4034 4034
   }
4035 4035
   // --------------------------------------------------------------------------------
4036 4036
 
@@ -4042,106 +4042,106 @@  discard block
 block discarded – undo
4042 4042
   // --------------------------------------------------------------------------------
4043 4043
   function privExtractFileInOutput(&$p_entry, &$p_options)
4044 4044
   {
4045
-    $v_result=1;
4045
+	$v_result=1;
4046 4046
 
4047
-    // ----- Read the file header
4048
-    if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
4049
-      return $v_result;
4050
-    }
4047
+	// ----- Read the file header
4048
+	if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
4049
+	  return $v_result;
4050
+	}
4051 4051
 
4052 4052
 
4053
-    // ----- Check that the file header is coherent with $p_entry info
4054
-    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4055
-        // TBC
4056
-    }
4053
+	// ----- Check that the file header is coherent with $p_entry info
4054
+	if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4055
+		// TBC
4056
+	}
4057 4057
 
4058
-    // ----- Look for pre-extract callback
4059
-    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4058
+	// ----- Look for pre-extract callback
4059
+	if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4060 4060
 
4061
-      // ----- Generate a local information
4062
-      $v_local_header = array();
4063
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4061
+	  // ----- Generate a local information
4062
+	  $v_local_header = array();
4063
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4064 4064
 
4065
-      // ----- Call the callback
4066
-      // Here I do not use call_user_func() because I need to send a reference to the
4067
-      // header.
4065
+	  // ----- Call the callback
4066
+	  // Here I do not use call_user_func() because I need to send a reference to the
4067
+	  // header.
4068 4068
 //      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4069
-      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4070
-      if ($v_result == 0) {
4071
-        // ----- Change the file status
4072
-        $p_entry['status'] = "skipped";
4073
-        $v_result = 1;
4074
-      }
4069
+	  $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4070
+	  if ($v_result == 0) {
4071
+		// ----- Change the file status
4072
+		$p_entry['status'] = "skipped";
4073
+		$v_result = 1;
4074
+	  }
4075 4075
 
4076
-      // ----- Look for abort result
4077
-      if ($v_result == 2) {
4078
-        // ----- This status is internal and will be changed in 'skipped'
4079
-        $p_entry['status'] = "aborted";
4080
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4081
-      }
4076
+	  // ----- Look for abort result
4077
+	  if ($v_result == 2) {
4078
+		// ----- This status is internal and will be changed in 'skipped'
4079
+		$p_entry['status'] = "aborted";
4080
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
4081
+	  }
4082 4082
 
4083
-      // ----- Update the informations
4084
-      // Only some fields can be modified
4085
-      $p_entry['filename'] = $v_local_header['filename'];
4086
-    }
4083
+	  // ----- Update the informations
4084
+	  // Only some fields can be modified
4085
+	  $p_entry['filename'] = $v_local_header['filename'];
4086
+	}
4087 4087
 
4088
-    // ----- Trace
4088
+	// ----- Trace
4089 4089
 
4090
-    // ----- Look if extraction should be done
4091
-    if ($p_entry['status'] == 'ok') {
4090
+	// ----- Look if extraction should be done
4091
+	if ($p_entry['status'] == 'ok') {
4092 4092
 
4093
-      // ----- Do the extraction (if not a folder)
4094
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4095
-        // ----- Look for not compressed file
4096
-        if ($p_entry['compressed_size'] == $p_entry['size']) {
4093
+	  // ----- Do the extraction (if not a folder)
4094
+	  if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4095
+		// ----- Look for not compressed file
4096
+		if ($p_entry['compressed_size'] == $p_entry['size']) {
4097 4097
 
4098
-          // ----- Read the file in a buffer (one shot)
4099
-          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4098
+		  // ----- Read the file in a buffer (one shot)
4099
+		  $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4100 4100
 
4101
-          // ----- Send the file to the output
4102
-          echo $v_buffer;
4103
-          unset($v_buffer);
4104
-        }
4105
-        else {
4101
+		  // ----- Send the file to the output
4102
+		  echo $v_buffer;
4103
+		  unset($v_buffer);
4104
+		}
4105
+		else {
4106 4106
 
4107
-          // ----- Read the compressed file in a buffer (one shot)
4108
-          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4107
+		  // ----- Read the compressed file in a buffer (one shot)
4108
+		  $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4109 4109
 
4110
-          // ----- Decompress the file
4111
-          $v_file_content = gzinflate($v_buffer);
4112
-          unset($v_buffer);
4110
+		  // ----- Decompress the file
4111
+		  $v_file_content = gzinflate($v_buffer);
4112
+		  unset($v_buffer);
4113 4113
 
4114
-          // ----- Send the file to the output
4115
-          echo $v_file_content;
4116
-          unset($v_file_content);
4117
-        }
4118
-      }
4119
-    }
4114
+		  // ----- Send the file to the output
4115
+		  echo $v_file_content;
4116
+		  unset($v_file_content);
4117
+		}
4118
+	  }
4119
+	}
4120 4120
 
4121 4121
 	// ----- Change abort status
4122 4122
 	if ($p_entry['status'] == "aborted") {
4123
-      $p_entry['status'] = "skipped";
4123
+	  $p_entry['status'] = "skipped";
4124 4124
 	}
4125 4125
 
4126
-    // ----- Look for post-extract callback
4127
-    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4126
+	// ----- Look for post-extract callback
4127
+	elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4128 4128
 
4129
-      // ----- Generate a local information
4130
-      $v_local_header = array();
4131
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4129
+	  // ----- Generate a local information
4130
+	  $v_local_header = array();
4131
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4132 4132
 
4133
-      // ----- Call the callback
4134
-      // Here I do not use call_user_func() because I need to send a reference to the
4135
-      // header.
4136
-      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4133
+	  // ----- Call the callback
4134
+	  // Here I do not use call_user_func() because I need to send a reference to the
4135
+	  // header.
4136
+	  $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4137 4137
 
4138
-      // ----- Look for abort result
4139
-      if ($v_result == 2) {
4140
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4141
-      }
4142
-    }
4138
+	  // ----- Look for abort result
4139
+	  if ($v_result == 2) {
4140
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
4141
+	  }
4142
+	}
4143 4143
 
4144
-    return $v_result;
4144
+	return $v_result;
4145 4145
   }
4146 4146
   // --------------------------------------------------------------------------------
4147 4147
 
@@ -4153,116 +4153,116 @@  discard block
 block discarded – undo
4153 4153
   // --------------------------------------------------------------------------------
4154 4154
   function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4155 4155
   {
4156
-    $v_result=1;
4157
-
4158
-    // ----- Read the file header
4159
-    $v_header = array();
4160
-    if (($v_result = $this->privReadFileHeader($v_header)) != 1)
4161
-    {
4162
-      // ----- Return
4163
-      return $v_result;
4164
-    }
4156
+	$v_result=1;
4157
+
4158
+	// ----- Read the file header
4159
+	$v_header = array();
4160
+	if (($v_result = $this->privReadFileHeader($v_header)) != 1)
4161
+	{
4162
+	  // ----- Return
4163
+	  return $v_result;
4164
+	}
4165 4165
 
4166 4166
 
4167
-    // ----- Check that the file header is coherent with $p_entry info
4168
-    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4169
-        // TBC
4170
-    }
4167
+	// ----- Check that the file header is coherent with $p_entry info
4168
+	if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4169
+		// TBC
4170
+	}
4171 4171
 
4172
-    // ----- Look for pre-extract callback
4173
-    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4174
-
4175
-      // ----- Generate a local information
4176
-      $v_local_header = array();
4177
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4178
-
4179
-      // ----- Call the callback
4180
-      // Here I do not use call_user_func() because I need to send a reference to the
4181
-      // header.
4182
-      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4183
-      if ($v_result == 0) {
4184
-        // ----- Change the file status
4185
-        $p_entry['status'] = "skipped";
4186
-        $v_result = 1;
4187
-      }
4172
+	// ----- Look for pre-extract callback
4173
+	if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4174
+
4175
+	  // ----- Generate a local information
4176
+	  $v_local_header = array();
4177
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4178
+
4179
+	  // ----- Call the callback
4180
+	  // Here I do not use call_user_func() because I need to send a reference to the
4181
+	  // header.
4182
+	  $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4183
+	  if ($v_result == 0) {
4184
+		// ----- Change the file status
4185
+		$p_entry['status'] = "skipped";
4186
+		$v_result = 1;
4187
+	  }
4188 4188
 
4189
-      // ----- Look for abort result
4190
-      if ($v_result == 2) {
4191
-        // ----- This status is internal and will be changed in 'skipped'
4192
-        $p_entry['status'] = "aborted";
4193
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4194
-      }
4189
+	  // ----- Look for abort result
4190
+	  if ($v_result == 2) {
4191
+		// ----- This status is internal and will be changed in 'skipped'
4192
+		$p_entry['status'] = "aborted";
4193
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
4194
+	  }
4195 4195
 
4196
-      // ----- Update the informations
4197
-      // Only some fields can be modified
4198
-      $p_entry['filename'] = $v_local_header['filename'];
4199
-    }
4196
+	  // ----- Update the informations
4197
+	  // Only some fields can be modified
4198
+	  $p_entry['filename'] = $v_local_header['filename'];
4199
+	}
4200 4200
 
4201 4201
 
4202
-    // ----- Look if extraction should be done
4203
-    if ($p_entry['status'] == 'ok') {
4202
+	// ----- Look if extraction should be done
4203
+	if ($p_entry['status'] == 'ok') {
4204 4204
 
4205
-      // ----- Do the extraction (if not a folder)
4206
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4207
-        // ----- Look for not compressed file
4205
+	  // ----- Do the extraction (if not a folder)
4206
+	  if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4207
+		// ----- Look for not compressed file
4208 4208
   //      if ($p_entry['compressed_size'] == $p_entry['size'])
4209
-        if ($p_entry['compression'] == 0) {
4209
+		if ($p_entry['compression'] == 0) {
4210 4210
 
4211
-          // ----- Reading the file
4212
-          $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4213
-        }
4214
-        else {
4211
+		  // ----- Reading the file
4212
+		  $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4213
+		}
4214
+		else {
4215 4215
 
4216
-          // ----- Reading the file
4217
-          $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
4216
+		  // ----- Reading the file
4217
+		  $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
4218 4218
 
4219
-          // ----- Decompress the file
4220
-          if (($p_string = @gzinflate($v_data)) === FALSE) {
4221
-              // TBC
4222
-          }
4223
-        }
4219
+		  // ----- Decompress the file
4220
+		  if (($p_string = @gzinflate($v_data)) === FALSE) {
4221
+			  // TBC
4222
+		  }
4223
+		}
4224 4224
 
4225
-        // ----- Trace
4226
-      }
4227
-      else {
4228
-          // TBC : error : can not extract a folder in a string
4229
-      }
4225
+		// ----- Trace
4226
+	  }
4227
+	  else {
4228
+		  // TBC : error : can not extract a folder in a string
4229
+	  }
4230 4230
 
4231
-    }
4231
+	}
4232 4232
 
4233 4233
   	// ----- Change abort status
4234 4234
   	if ($p_entry['status'] == "aborted") {
4235
-        $p_entry['status'] = "skipped";
4235
+		$p_entry['status'] = "skipped";
4236 4236
   	}
4237 4237
 
4238
-    // ----- Look for post-extract callback
4239
-    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4238
+	// ----- Look for post-extract callback
4239
+	elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4240 4240
 
4241
-      // ----- Generate a local information
4242
-      $v_local_header = array();
4243
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4241
+	  // ----- Generate a local information
4242
+	  $v_local_header = array();
4243
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4244 4244
 
4245
-      // ----- Swap the content to header
4246
-      $v_local_header['content'] = $p_string;
4247
-      $p_string = '';
4245
+	  // ----- Swap the content to header
4246
+	  $v_local_header['content'] = $p_string;
4247
+	  $p_string = '';
4248 4248
 
4249
-      // ----- Call the callback
4250
-      // Here I do not use call_user_func() because I need to send a reference to the
4251
-      // header.
4252
-      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4249
+	  // ----- Call the callback
4250
+	  // Here I do not use call_user_func() because I need to send a reference to the
4251
+	  // header.
4252
+	  $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4253 4253
 
4254
-      // ----- Swap back the content to header
4255
-      $p_string = $v_local_header['content'];
4256
-      unset($v_local_header['content']);
4254
+	  // ----- Swap back the content to header
4255
+	  $p_string = $v_local_header['content'];
4256
+	  unset($v_local_header['content']);
4257 4257
 
4258
-      // ----- Look for abort result
4259
-      if ($v_result == 2) {
4260
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4261
-      }
4262
-    }
4258
+	  // ----- Look for abort result
4259
+	  if ($v_result == 2) {
4260
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
4261
+	  }
4262
+	}
4263 4263
 
4264
-    // ----- Return
4265
-    return $v_result;
4264
+	// ----- Return
4265
+	return $v_result;
4266 4266
   }
4267 4267
   // --------------------------------------------------------------------------------
4268 4268
 
@@ -4274,98 +4274,98 @@  discard block
 block discarded – undo
4274 4274
   // --------------------------------------------------------------------------------
4275 4275
   function privReadFileHeader(&$p_header)
4276 4276
   {
4277
-    $v_result=1;
4277
+	$v_result=1;
4278 4278
 
4279
-    // ----- Read the 4 bytes signature
4280
-    $v_binary_data = @fread($this->zip_fd, 4);
4281
-    $v_data = unpack('Vid', $v_binary_data);
4279
+	// ----- Read the 4 bytes signature
4280
+	$v_binary_data = @fread($this->zip_fd, 4);
4281
+	$v_data = unpack('Vid', $v_binary_data);
4282 4282
 
4283
-    // ----- Check signature
4284
-    if ($v_data['id'] != 0x04034b50)
4285
-    {
4283
+	// ----- Check signature
4284
+	if ($v_data['id'] != 0x04034b50)
4285
+	{
4286 4286
 
4287
-      // ----- Error log
4288
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4287
+	  // ----- Error log
4288
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4289 4289
 
4290
-      // ----- Return
4291
-      return PclZip::errorCode();
4292
-    }
4290
+	  // ----- Return
4291
+	  return PclZip::errorCode();
4292
+	}
4293 4293
 
4294
-    // ----- Read the first 42 bytes of the header
4295
-    $v_binary_data = fread($this->zip_fd, 26);
4294
+	// ----- Read the first 42 bytes of the header
4295
+	$v_binary_data = fread($this->zip_fd, 26);
4296 4296
 
4297
-    // ----- Look for invalid block size
4298
-    if (strlen($v_binary_data) != 26)
4299
-    {
4300
-      $p_header['filename'] = "";
4301
-      $p_header['status'] = "invalid_header";
4297
+	// ----- Look for invalid block size
4298
+	if (strlen($v_binary_data) != 26)
4299
+	{
4300
+	  $p_header['filename'] = "";
4301
+	  $p_header['status'] = "invalid_header";
4302 4302
 
4303
-      // ----- Error log
4304
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4303
+	  // ----- Error log
4304
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4305 4305
 
4306
-      // ----- Return
4307
-      return PclZip::errorCode();
4308
-    }
4306
+	  // ----- Return
4307
+	  return PclZip::errorCode();
4308
+	}
4309 4309
 
4310
-    // ----- Extract the values
4311
-    $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
4310
+	// ----- Extract the values
4311
+	$v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
4312 4312
 
4313
-    // ----- Get filename
4314
-    $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
4313
+	// ----- Get filename
4314
+	$p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
4315 4315
 
4316
-    // ----- Get extra_fields
4317
-    if ($v_data['extra_len'] != 0) {
4318
-      $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4319
-    }
4320
-    else {
4321
-      $p_header['extra'] = '';
4322
-    }
4316
+	// ----- Get extra_fields
4317
+	if ($v_data['extra_len'] != 0) {
4318
+	  $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4319
+	}
4320
+	else {
4321
+	  $p_header['extra'] = '';
4322
+	}
4323 4323
 
4324
-    // ----- Extract properties
4325
-    $p_header['version_extracted'] = $v_data['version'];
4326
-    $p_header['compression'] = $v_data['compression'];
4327
-    $p_header['size'] = $v_data['size'];
4328
-    $p_header['compressed_size'] = $v_data['compressed_size'];
4329
-    $p_header['crc'] = $v_data['crc'];
4330
-    $p_header['flag'] = $v_data['flag'];
4331
-    $p_header['filename_len'] = $v_data['filename_len'];
4332
-
4333
-    // ----- Recuperate date in UNIX format
4334
-    $p_header['mdate'] = $v_data['mdate'];
4335
-    $p_header['mtime'] = $v_data['mtime'];
4336
-    if ($p_header['mdate'] && $p_header['mtime'])
4337
-    {
4338
-      // ----- Extract time
4339
-      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4340
-      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4341
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4342
-
4343
-      // ----- Extract date
4344
-      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4345
-      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4346
-      $v_day = $p_header['mdate'] & 0x001F;
4347
-
4348
-      // ----- Get UNIX date format
4349
-      $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4324
+	// ----- Extract properties
4325
+	$p_header['version_extracted'] = $v_data['version'];
4326
+	$p_header['compression'] = $v_data['compression'];
4327
+	$p_header['size'] = $v_data['size'];
4328
+	$p_header['compressed_size'] = $v_data['compressed_size'];
4329
+	$p_header['crc'] = $v_data['crc'];
4330
+	$p_header['flag'] = $v_data['flag'];
4331
+	$p_header['filename_len'] = $v_data['filename_len'];
4332
+
4333
+	// ----- Recuperate date in UNIX format
4334
+	$p_header['mdate'] = $v_data['mdate'];
4335
+	$p_header['mtime'] = $v_data['mtime'];
4336
+	if ($p_header['mdate'] && $p_header['mtime'])
4337
+	{
4338
+	  // ----- Extract time
4339
+	  $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4340
+	  $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4341
+	  $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4342
+
4343
+	  // ----- Extract date
4344
+	  $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4345
+	  $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4346
+	  $v_day = $p_header['mdate'] & 0x001F;
4347
+
4348
+	  // ----- Get UNIX date format
4349
+	  $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4350 4350
 
4351
-    }
4352
-    else
4353
-    {
4354
-      $p_header['mtime'] = time();
4355
-    }
4351
+	}
4352
+	else
4353
+	{
4354
+	  $p_header['mtime'] = time();
4355
+	}
4356 4356
 
4357
-    // TBC
4358
-    //for(reset($v_data); $key = key($v_data); next($v_data)) {
4359
-    //}
4357
+	// TBC
4358
+	//for(reset($v_data); $key = key($v_data); next($v_data)) {
4359
+	//}
4360 4360
 
4361
-    // ----- Set the stored filename
4362
-    $p_header['stored_filename'] = $p_header['filename'];
4361
+	// ----- Set the stored filename
4362
+	$p_header['stored_filename'] = $p_header['filename'];
4363 4363
 
4364
-    // ----- Set the status field
4365
-    $p_header['status'] = "ok";
4364
+	// ----- Set the status field
4365
+	$p_header['status'] = "ok";
4366 4366
 
4367
-    // ----- Return
4368
-    return $v_result;
4367
+	// ----- Return
4368
+	return $v_result;
4369 4369
   }
4370 4370
   // --------------------------------------------------------------------------------
4371 4371
 
@@ -4377,101 +4377,101 @@  discard block
 block discarded – undo
4377 4377
   // --------------------------------------------------------------------------------
4378 4378
   function privReadCentralFileHeader(&$p_header)
4379 4379
   {
4380
-    $v_result=1;
4380
+	$v_result=1;
4381 4381
 
4382
-    // ----- Read the 4 bytes signature
4383
-    $v_binary_data = @fread($this->zip_fd, 4);
4384
-    $v_data = unpack('Vid', $v_binary_data);
4382
+	// ----- Read the 4 bytes signature
4383
+	$v_binary_data = @fread($this->zip_fd, 4);
4384
+	$v_data = unpack('Vid', $v_binary_data);
4385 4385
 
4386
-    // ----- Check signature
4387
-    if ($v_data['id'] != 0x02014b50)
4388
-    {
4386
+	// ----- Check signature
4387
+	if ($v_data['id'] != 0x02014b50)
4388
+	{
4389 4389
 
4390
-      // ----- Error log
4391
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4390
+	  // ----- Error log
4391
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4392 4392
 
4393
-      // ----- Return
4394
-      return PclZip::errorCode();
4395
-    }
4393
+	  // ----- Return
4394
+	  return PclZip::errorCode();
4395
+	}
4396 4396
 
4397
-    // ----- Read the first 42 bytes of the header
4398
-    $v_binary_data = fread($this->zip_fd, 42);
4397
+	// ----- Read the first 42 bytes of the header
4398
+	$v_binary_data = fread($this->zip_fd, 42);
4399 4399
 
4400
-    // ----- Look for invalid block size
4401
-    if (strlen($v_binary_data) != 42)
4402
-    {
4403
-      $p_header['filename'] = "";
4404
-      $p_header['status'] = "invalid_header";
4400
+	// ----- Look for invalid block size
4401
+	if (strlen($v_binary_data) != 42)
4402
+	{
4403
+	  $p_header['filename'] = "";
4404
+	  $p_header['status'] = "invalid_header";
4405 4405
 
4406
-      // ----- Error log
4407
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4406
+	  // ----- Error log
4407
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4408 4408
 
4409
-      // ----- Return
4410
-      return PclZip::errorCode();
4411
-    }
4409
+	  // ----- Return
4410
+	  return PclZip::errorCode();
4411
+	}
4412 4412
 
4413
-    // ----- Extract the values
4414
-    $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
4415
-
4416
-    // ----- Get filename
4417
-    if ($p_header['filename_len'] != 0)
4418
-      $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4419
-    else
4420
-      $p_header['filename'] = '';
4421
-
4422
-    // ----- Get extra
4423
-    if ($p_header['extra_len'] != 0)
4424
-      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4425
-    else
4426
-      $p_header['extra'] = '';
4427
-
4428
-    // ----- Get comment
4429
-    if ($p_header['comment_len'] != 0)
4430
-      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4431
-    else
4432
-      $p_header['comment'] = '';
4433
-
4434
-    // ----- Extract properties
4435
-
4436
-    // ----- Recuperate date in UNIX format
4437
-    //if ($p_header['mdate'] && $p_header['mtime'])
4438
-    // TBC : bug : this was ignoring time with 0/0/0
4439
-    if (1)
4440
-    {
4441
-      // ----- Extract time
4442
-      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4443
-      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4444
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4445
-
4446
-      // ----- Extract date
4447
-      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4448
-      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4449
-      $v_day = $p_header['mdate'] & 0x001F;
4450
-
4451
-      // ----- Get UNIX date format
4452
-      $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4413
+	// ----- Extract the values
4414
+	$p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
4415
+
4416
+	// ----- Get filename
4417
+	if ($p_header['filename_len'] != 0)
4418
+	  $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4419
+	else
4420
+	  $p_header['filename'] = '';
4421
+
4422
+	// ----- Get extra
4423
+	if ($p_header['extra_len'] != 0)
4424
+	  $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4425
+	else
4426
+	  $p_header['extra'] = '';
4427
+
4428
+	// ----- Get comment
4429
+	if ($p_header['comment_len'] != 0)
4430
+	  $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4431
+	else
4432
+	  $p_header['comment'] = '';
4433
+
4434
+	// ----- Extract properties
4435
+
4436
+	// ----- Recuperate date in UNIX format
4437
+	//if ($p_header['mdate'] && $p_header['mtime'])
4438
+	// TBC : bug : this was ignoring time with 0/0/0
4439
+	if (1)
4440
+	{
4441
+	  // ----- Extract time
4442
+	  $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4443
+	  $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4444
+	  $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4445
+
4446
+	  // ----- Extract date
4447
+	  $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4448
+	  $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4449
+	  $v_day = $p_header['mdate'] & 0x001F;
4450
+
4451
+	  // ----- Get UNIX date format
4452
+	  $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4453 4453
 
4454
-    }
4455
-    else
4456
-    {
4457
-      $p_header['mtime'] = time();
4458
-    }
4454
+	}
4455
+	else
4456
+	{
4457
+	  $p_header['mtime'] = time();
4458
+	}
4459 4459
 
4460
-    // ----- Set the stored filename
4461
-    $p_header['stored_filename'] = $p_header['filename'];
4460
+	// ----- Set the stored filename
4461
+	$p_header['stored_filename'] = $p_header['filename'];
4462 4462
 
4463
-    // ----- Set default status to ok
4464
-    $p_header['status'] = 'ok';
4463
+	// ----- Set default status to ok
4464
+	$p_header['status'] = 'ok';
4465 4465
 
4466
-    // ----- Look if it is a directory
4467
-    if (substr($p_header['filename'], -1) == '/') {
4468
-      //$p_header['external'] = 0x41FF0010;
4469
-      $p_header['external'] = 0x00000010;
4470
-    }
4466
+	// ----- Look if it is a directory
4467
+	if (substr($p_header['filename'], -1) == '/') {
4468
+	  //$p_header['external'] = 0x41FF0010;
4469
+	  $p_header['external'] = 0x00000010;
4470
+	}
4471 4471
 
4472 4472
 
4473
-    // ----- Return
4474
-    return $v_result;
4473
+	// ----- Return
4474
+	return $v_result;
4475 4475
   }
4476 4476
   // --------------------------------------------------------------------------------
4477 4477
 
@@ -4485,7 +4485,7 @@  discard block
 block discarded – undo
4485 4485
   // --------------------------------------------------------------------------------
4486 4486
   function privCheckFileHeaders(&$p_local_header, &$p_central_header)
4487 4487
   {
4488
-    $v_result=1;
4488
+	$v_result=1;
4489 4489
 
4490 4490
   	// ----- Check the static values
4491 4491
   	// TBC
@@ -4504,13 +4504,13 @@  discard block
 block discarded – undo
4504 4504
 
4505 4505
   	// ----- Look for flag bit 3
4506 4506
   	if (($p_local_header['flag'] & 8) == 8) {
4507
-          $p_local_header['size'] = $p_central_header['size'];
4508
-          $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
4509
-          $p_local_header['crc'] = $p_central_header['crc'];
4507
+		  $p_local_header['size'] = $p_central_header['size'];
4508
+		  $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
4509
+		  $p_local_header['crc'] = $p_central_header['crc'];
4510 4510
   	}
4511 4511
 
4512
-    // ----- Return
4513
-    return $v_result;
4512
+	// ----- Return
4513
+	return $v_result;
4514 4514
   }
4515 4515
   // --------------------------------------------------------------------------------
4516 4516
 
@@ -4522,152 +4522,152 @@  discard block
 block discarded – undo
4522 4522
   // --------------------------------------------------------------------------------
4523 4523
   function privReadEndCentralDir(&$p_central_dir)
4524 4524
   {
4525
-    $v_result=1;
4526
-
4527
-    // ----- Go to the end of the zip file
4528
-    $v_size = filesize($this->zipname);
4529
-    @fseek($this->zip_fd, $v_size);
4530
-    if (@ftell($this->zip_fd) != $v_size)
4531
-    {
4532
-      // ----- Error log
4533
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4534
-
4535
-      // ----- Return
4536
-      return PclZip::errorCode();
4537
-    }
4525
+	$v_result=1;
4526
+
4527
+	// ----- Go to the end of the zip file
4528
+	$v_size = filesize($this->zipname);
4529
+	@fseek($this->zip_fd, $v_size);
4530
+	if (@ftell($this->zip_fd) != $v_size)
4531
+	{
4532
+	  // ----- Error log
4533
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4534
+
4535
+	  // ----- Return
4536
+	  return PclZip::errorCode();
4537
+	}
4538 4538
 
4539
-    // ----- First try : look if this is an archive with no commentaries (most of the time)
4540
-    // in this case the end of central dir is at 22 bytes of the file end
4541
-    $v_found = 0;
4542
-    if ($v_size > 26) {
4543
-      @fseek($this->zip_fd, $v_size-22);
4544
-      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4545
-      {
4546
-        // ----- Error log
4547
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4548
-
4549
-        // ----- Return
4550
-        return PclZip::errorCode();
4551
-      }
4539
+	// ----- First try : look if this is an archive with no commentaries (most of the time)
4540
+	// in this case the end of central dir is at 22 bytes of the file end
4541
+	$v_found = 0;
4542
+	if ($v_size > 26) {
4543
+	  @fseek($this->zip_fd, $v_size-22);
4544
+	  if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4545
+	  {
4546
+		// ----- Error log
4547
+		PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4548
+
4549
+		// ----- Return
4550
+		return PclZip::errorCode();
4551
+	  }
4552 4552
 
4553
-      // ----- Read for bytes
4554
-      $v_binary_data = @fread($this->zip_fd, 4);
4555
-      $v_data = @unpack('Vid', $v_binary_data);
4553
+	  // ----- Read for bytes
4554
+	  $v_binary_data = @fread($this->zip_fd, 4);
4555
+	  $v_data = @unpack('Vid', $v_binary_data);
4556 4556
 
4557
-      // ----- Check signature
4558
-      if ($v_data['id'] == 0x06054b50) {
4559
-        $v_found = 1;
4560
-      }
4557
+	  // ----- Check signature
4558
+	  if ($v_data['id'] == 0x06054b50) {
4559
+		$v_found = 1;
4560
+	  }
4561 4561
 
4562
-      $v_pos = ftell($this->zip_fd);
4563
-    }
4562
+	  $v_pos = ftell($this->zip_fd);
4563
+	}
4564 4564
 
4565
-    // ----- Go back to the maximum possible size of the Central Dir End Record
4566
-    if (!$v_found) {
4567
-      $v_maximum_size = 65557; // 0xFFFF + 22;
4568
-      if ($v_maximum_size > $v_size)
4569
-        $v_maximum_size = $v_size;
4570
-      @fseek($this->zip_fd, $v_size-$v_maximum_size);
4571
-      if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4572
-      {
4573
-        // ----- Error log
4574
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4575
-
4576
-        // ----- Return
4577
-        return PclZip::errorCode();
4578
-      }
4565
+	// ----- Go back to the maximum possible size of the Central Dir End Record
4566
+	if (!$v_found) {
4567
+	  $v_maximum_size = 65557; // 0xFFFF + 22;
4568
+	  if ($v_maximum_size > $v_size)
4569
+		$v_maximum_size = $v_size;
4570
+	  @fseek($this->zip_fd, $v_size-$v_maximum_size);
4571
+	  if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4572
+	  {
4573
+		// ----- Error log
4574
+		PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4575
+
4576
+		// ----- Return
4577
+		return PclZip::errorCode();
4578
+	  }
4579 4579
 
4580
-      // ----- Read byte per byte in order to find the signature
4581
-      $v_pos = ftell($this->zip_fd);
4582
-      $v_bytes = 0x00000000;
4583
-      while ($v_pos < $v_size)
4584
-      {
4585
-        // ----- Read a byte
4586
-        $v_byte = @fread($this->zip_fd, 1);
4587
-
4588
-        // -----  Add the byte
4589
-        //$v_bytes = ($v_bytes << 8) | Ord($v_byte);
4590
-        // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
4591
-        // Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
4592
-        $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
4593
-
4594
-        // ----- Compare the bytes
4595
-        if ($v_bytes == 0x504b0506)
4596
-        {
4597
-          $v_pos++;
4598
-          break;
4599
-        }
4600
-
4601
-        $v_pos++;
4602
-      }
4580
+	  // ----- Read byte per byte in order to find the signature
4581
+	  $v_pos = ftell($this->zip_fd);
4582
+	  $v_bytes = 0x00000000;
4583
+	  while ($v_pos < $v_size)
4584
+	  {
4585
+		// ----- Read a byte
4586
+		$v_byte = @fread($this->zip_fd, 1);
4587
+
4588
+		// -----  Add the byte
4589
+		//$v_bytes = ($v_bytes << 8) | Ord($v_byte);
4590
+		// Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
4591
+		// Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
4592
+		$v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
4593
+
4594
+		// ----- Compare the bytes
4595
+		if ($v_bytes == 0x504b0506)
4596
+		{
4597
+		  $v_pos++;
4598
+		  break;
4599
+		}
4600
+
4601
+		$v_pos++;
4602
+	  }
4603 4603
 
4604
-      // ----- Look if not found end of central dir
4605
-      if ($v_pos == $v_size)
4606
-      {
4604
+	  // ----- Look if not found end of central dir
4605
+	  if ($v_pos == $v_size)
4606
+	  {
4607 4607
 
4608
-        // ----- Error log
4609
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
4608
+		// ----- Error log
4609
+		PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
4610 4610
 
4611
-        // ----- Return
4612
-        return PclZip::errorCode();
4613
-      }
4614
-    }
4611
+		// ----- Return
4612
+		return PclZip::errorCode();
4613
+	  }
4614
+	}
4615 4615
 
4616
-    // ----- Read the first 18 bytes of the header
4617
-    $v_binary_data = fread($this->zip_fd, 18);
4616
+	// ----- Read the first 18 bytes of the header
4617
+	$v_binary_data = fread($this->zip_fd, 18);
4618 4618
 
4619
-    // ----- Look for invalid block size
4620
-    if (strlen($v_binary_data) != 18)
4621
-    {
4619
+	// ----- Look for invalid block size
4620
+	if (strlen($v_binary_data) != 18)
4621
+	{
4622 4622
 
4623
-      // ----- Error log
4624
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4623
+	  // ----- Error log
4624
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4625 4625
 
4626
-      // ----- Return
4627
-      return PclZip::errorCode();
4628
-    }
4626
+	  // ----- Return
4627
+	  return PclZip::errorCode();
4628
+	}
4629 4629
 
4630
-    // ----- Extract the values
4631
-    $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
4630
+	// ----- Extract the values
4631
+	$v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
4632 4632
 
4633
-    // ----- Check the global size
4634
-    if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
4633
+	// ----- Check the global size
4634
+	if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
4635 4635
 
4636 4636
 	  // ----- Removed in release 2.2 see readme file
4637 4637
 	  // The check of the file size is a little too strict.
4638 4638
 	  // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
4639 4639
 	  // While decrypted, zip has training 0 bytes
4640 4640
 	  if (0) {
4641
-      // ----- Error log
4642
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
4643
-	                       'The central dir is not at the end of the archive.'
4641
+	  // ----- Error log
4642
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
4643
+						   'The central dir is not at the end of the archive.'
4644 4644
 						   .' Some trailing bytes exists after the archive.');
4645 4645
 
4646
-      // ----- Return
4647
-      return PclZip::errorCode();
4646
+	  // ----- Return
4647
+	  return PclZip::errorCode();
4648 4648
 	  }
4649
-    }
4649
+	}
4650 4650
 
4651
-    // ----- Get comment
4652
-    if ($v_data['comment_size'] != 0) {
4653
-      $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4654
-    }
4655
-    else
4656
-      $p_central_dir['comment'] = '';
4657
-
4658
-    $p_central_dir['entries'] = $v_data['entries'];
4659
-    $p_central_dir['disk_entries'] = $v_data['disk_entries'];
4660
-    $p_central_dir['offset'] = $v_data['offset'];
4661
-    $p_central_dir['size'] = $v_data['size'];
4662
-    $p_central_dir['disk'] = $v_data['disk'];
4663
-    $p_central_dir['disk_start'] = $v_data['disk_start'];
4664
-
4665
-    // TBC
4666
-    //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
4667
-    //}
4668
-
4669
-    // ----- Return
4670
-    return $v_result;
4651
+	// ----- Get comment
4652
+	if ($v_data['comment_size'] != 0) {
4653
+	  $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4654
+	}
4655
+	else
4656
+	  $p_central_dir['comment'] = '';
4657
+
4658
+	$p_central_dir['entries'] = $v_data['entries'];
4659
+	$p_central_dir['disk_entries'] = $v_data['disk_entries'];
4660
+	$p_central_dir['offset'] = $v_data['offset'];
4661
+	$p_central_dir['size'] = $v_data['size'];
4662
+	$p_central_dir['disk'] = $v_data['disk'];
4663
+	$p_central_dir['disk_start'] = $v_data['disk_start'];
4664
+
4665
+	// TBC
4666
+	//for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
4667
+	//}
4668
+
4669
+	// ----- Return
4670
+	return $v_result;
4671 4671
   }
4672 4672
   // --------------------------------------------------------------------------------
4673 4673
 
@@ -4679,96 +4679,96 @@  discard block
 block discarded – undo
4679 4679
   // --------------------------------------------------------------------------------
4680 4680
   function privDeleteByRule(&$p_result_list, &$p_options)
4681 4681
   {
4682
-    $v_result=1;
4683
-    $v_list_detail = array();
4684
-
4685
-    // ----- Open the zip file
4686
-    if (($v_result=$this->privOpenFd('rb')) != 1)
4687
-    {
4688
-      // ----- Return
4689
-      return $v_result;
4690
-    }
4682
+	$v_result=1;
4683
+	$v_list_detail = array();
4684
+
4685
+	// ----- Open the zip file
4686
+	if (($v_result=$this->privOpenFd('rb')) != 1)
4687
+	{
4688
+	  // ----- Return
4689
+	  return $v_result;
4690
+	}
4691 4691
 
4692
-    // ----- Read the central directory informations
4693
-    $v_central_dir = array();
4694
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
4695
-    {
4696
-      $this->privCloseFd();
4697
-      return $v_result;
4698
-    }
4692
+	// ----- Read the central directory informations
4693
+	$v_central_dir = array();
4694
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
4695
+	{
4696
+	  $this->privCloseFd();
4697
+	  return $v_result;
4698
+	}
4699 4699
 
4700
-    // ----- Go to beginning of File
4701
-    @rewind($this->zip_fd);
4700
+	// ----- Go to beginning of File
4701
+	@rewind($this->zip_fd);
4702 4702
 
4703
-    // ----- Scan all the files
4704
-    // ----- Start at beginning of Central Dir
4705
-    $v_pos_entry = $v_central_dir['offset'];
4706
-    @rewind($this->zip_fd);
4707
-    if (@fseek($this->zip_fd, $v_pos_entry))
4708
-    {
4709
-      // ----- Close the zip file
4710
-      $this->privCloseFd();
4703
+	// ----- Scan all the files
4704
+	// ----- Start at beginning of Central Dir
4705
+	$v_pos_entry = $v_central_dir['offset'];
4706
+	@rewind($this->zip_fd);
4707
+	if (@fseek($this->zip_fd, $v_pos_entry))
4708
+	{
4709
+	  // ----- Close the zip file
4710
+	  $this->privCloseFd();
4711 4711
 
4712
-      // ----- Error log
4713
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4712
+	  // ----- Error log
4713
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4714 4714
 
4715
-      // ----- Return
4716
-      return PclZip::errorCode();
4717
-    }
4715
+	  // ----- Return
4716
+	  return PclZip::errorCode();
4717
+	}
4718 4718
 
4719
-    // ----- Read each entry
4720
-    $v_header_list = array();
4721
-    $j_start = 0;
4722
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4723
-    {
4719
+	// ----- Read each entry
4720
+	$v_header_list = array();
4721
+	$j_start = 0;
4722
+	for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4723
+	{
4724 4724
 
4725
-      // ----- Read the file header
4726
-      $v_header_list[$v_nb_extracted] = array();
4727
-      if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
4728
-      {
4729
-        // ----- Close the zip file
4730
-        $this->privCloseFd();
4725
+	  // ----- Read the file header
4726
+	  $v_header_list[$v_nb_extracted] = array();
4727
+	  if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
4728
+	  {
4729
+		// ----- Close the zip file
4730
+		$this->privCloseFd();
4731 4731
 
4732
-        return $v_result;
4733
-      }
4732
+		return $v_result;
4733
+	  }
4734 4734
 
4735 4735
 
4736
-      // ----- Store the index
4737
-      $v_header_list[$v_nb_extracted]['index'] = $i;
4738
-
4739
-      // ----- Look for the specific extract rules
4740
-      $v_found = false;
4741
-
4742
-      // ----- Look for extract by name rule
4743
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
4744
-          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4745
-
4746
-          // ----- Look if the filename is in the list
4747
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4748
-
4749
-              // ----- Look for a directory
4750
-              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4751
-
4752
-                  // ----- Look if the directory is in the filename path
4753
-                  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4754
-                      && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4755
-                      $v_found = true;
4756
-                  }
4757
-                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4758
-                          && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4759
-                      $v_found = true;
4760
-                  }
4761
-              }
4762
-              // ----- Look for a filename
4763
-              elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
4764
-                  $v_found = true;
4765
-              }
4766
-          }
4767
-      }
4736
+	  // ----- Store the index
4737
+	  $v_header_list[$v_nb_extracted]['index'] = $i;
4738
+
4739
+	  // ----- Look for the specific extract rules
4740
+	  $v_found = false;
4741
+
4742
+	  // ----- Look for extract by name rule
4743
+	  if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
4744
+		  && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4745
+
4746
+		  // ----- Look if the filename is in the list
4747
+		  for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4748
+
4749
+			  // ----- Look for a directory
4750
+			  if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4751
+
4752
+				  // ----- Look if the directory is in the filename path
4753
+				  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4754
+					  && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4755
+					  $v_found = true;
4756
+				  }
4757
+				  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4758
+						  && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4759
+					  $v_found = true;
4760
+				  }
4761
+			  }
4762
+			  // ----- Look for a filename
4763
+			  elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
4764
+				  $v_found = true;
4765
+			  }
4766
+		  }
4767
+	  }
4768 4768
 
4769
-      // ----- Look for extract by ereg rule
4770
-      // ereg() is deprecated with PHP 5.3
4771
-      /*
4769
+	  // ----- Look for extract by ereg rule
4770
+	  // ereg() is deprecated with PHP 5.3
4771
+	  /*
4772 4772
       else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
4773 4773
                && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
4774 4774
 
@@ -4778,201 +4778,201 @@  discard block
 block discarded – undo
4778 4778
       }
4779 4779
       */
4780 4780
 
4781
-      // ----- Look for extract by preg rule
4782
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
4783
-               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4781
+	  // ----- Look for extract by preg rule
4782
+	  else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
4783
+			   && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4784 4784
 
4785
-          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4786
-              $v_found = true;
4787
-          }
4788
-      }
4785
+		  if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4786
+			  $v_found = true;
4787
+		  }
4788
+	  }
4789 4789
 
4790
-      // ----- Look for extract by index rule
4791
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4792
-               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4790
+	  // ----- Look for extract by index rule
4791
+	  else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4792
+			   && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4793 4793
 
4794
-          // ----- Look if the index is in the list
4795
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4794
+		  // ----- Look if the index is in the list
4795
+		  for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4796 4796
 
4797
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4798
-                  $v_found = true;
4799
-              }
4800
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4801
-                  $j_start = $j+1;
4802
-              }
4797
+			  if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4798
+				  $v_found = true;
4799
+			  }
4800
+			  if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4801
+				  $j_start = $j+1;
4802
+			  }
4803 4803
 
4804
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4805
-                  break;
4806
-              }
4807
-          }
4808
-      }
4809
-      else {
4810
-      	$v_found = true;
4811
-      }
4804
+			  if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4805
+				  break;
4806
+			  }
4807
+		  }
4808
+	  }
4809
+	  else {
4810
+	  	$v_found = true;
4811
+	  }
4812 4812
 
4813
-      // ----- Look for deletion
4814
-      if ($v_found)
4815
-      {
4816
-        unset($v_header_list[$v_nb_extracted]);
4817
-      }
4818
-      else
4819
-      {
4820
-        $v_nb_extracted++;
4821
-      }
4822
-    }
4813
+	  // ----- Look for deletion
4814
+	  if ($v_found)
4815
+	  {
4816
+		unset($v_header_list[$v_nb_extracted]);
4817
+	  }
4818
+	  else
4819
+	  {
4820
+		$v_nb_extracted++;
4821
+	  }
4822
+	}
4823 4823
 
4824
-    // ----- Look if something need to be deleted
4825
-    if ($v_nb_extracted > 0) {
4826
-
4827
-        // ----- Creates a temporay file
4828
-        $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
4829
-
4830
-        // ----- Creates a temporary zip archive
4831
-        $v_temp_zip = new PclZip($v_zip_temp_name);
4832
-
4833
-        // ----- Open the temporary zip file in write mode
4834
-        if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
4835
-            $this->privCloseFd();
4836
-
4837
-            // ----- Return
4838
-            return $v_result;
4839
-        }
4840
-
4841
-        // ----- Look which file need to be kept
4842
-        for ($i=0; $i<sizeof($v_header_list); $i++) {
4843
-
4844
-            // ----- Calculate the position of the header
4845
-            @rewind($this->zip_fd);
4846
-            if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
4847
-                // ----- Close the zip file
4848
-                $this->privCloseFd();
4849
-                $v_temp_zip->privCloseFd();
4850
-                @unlink($v_zip_temp_name);
4851
-
4852
-                // ----- Error log
4853
-                PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4854
-
4855
-                // ----- Return
4856
-                return PclZip::errorCode();
4857
-            }
4858
-
4859
-            // ----- Read the file header
4860
-            $v_local_header = array();
4861
-            if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
4862
-                // ----- Close the zip file
4863
-                $this->privCloseFd();
4864
-                $v_temp_zip->privCloseFd();
4865
-                @unlink($v_zip_temp_name);
4866
-
4867
-                // ----- Return
4868
-                return $v_result;
4869
-            }
4870
-
4871
-            // ----- Check that local file header is same as central file header
4872
-            if ($this->privCheckFileHeaders($v_local_header,
4873
-			                                $v_header_list[$i]) != 1) {
4874
-                // TBC
4875
-            }
4876
-            unset($v_local_header);
4877
-
4878
-            // ----- Write the file header
4879
-            if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
4880
-                // ----- Close the zip file
4881
-                $this->privCloseFd();
4882
-                $v_temp_zip->privCloseFd();
4883
-                @unlink($v_zip_temp_name);
4884
-
4885
-                // ----- Return
4886
-                return $v_result;
4887
-            }
4888
-
4889
-            // ----- Read/write the data block
4890
-            if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
4891
-                // ----- Close the zip file
4892
-                $this->privCloseFd();
4893
-                $v_temp_zip->privCloseFd();
4894
-                @unlink($v_zip_temp_name);
4895
-
4896
-                // ----- Return
4897
-                return $v_result;
4898
-            }
4899
-        }
4900
-
4901
-        // ----- Store the offset of the central dir
4902
-        $v_offset = @ftell($v_temp_zip->zip_fd);
4903
-
4904
-        // ----- Re-Create the Central Dir files header
4905
-        for ($i=0; $i<sizeof($v_header_list); $i++) {
4906
-            // ----- Create the file header
4907
-            if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4908
-                $v_temp_zip->privCloseFd();
4909
-                $this->privCloseFd();
4910
-                @unlink($v_zip_temp_name);
4911
-
4912
-                // ----- Return
4913
-                return $v_result;
4914
-            }
4915
-
4916
-            // ----- Transform the header to a 'usable' info
4917
-            $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
4918
-        }
4919
-
4920
-
4921
-        // ----- Zip file comment
4922
-        $v_comment = '';
4923
-        if (isset($p_options[PCLZIP_OPT_COMMENT])) {
4924
-          $v_comment = $p_options[PCLZIP_OPT_COMMENT];
4925
-        }
4926
-
4927
-        // ----- Calculate the size of the central header
4928
-        $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
4929
-
4930
-        // ----- Create the central dir footer
4931
-        if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
4932
-            // ----- Reset the file list
4933
-            unset($v_header_list);
4934
-            $v_temp_zip->privCloseFd();
4935
-            $this->privCloseFd();
4936
-            @unlink($v_zip_temp_name);
4937
-
4938
-            // ----- Return
4939
-            return $v_result;
4940
-        }
4941
-
4942
-        // ----- Close
4943
-        $v_temp_zip->privCloseFd();
4944
-        $this->privCloseFd();
4945
-
4946
-        // ----- Delete the zip file
4947
-        // TBC : I should test the result ...
4948
-        @unlink($this->zipname);
4949
-
4950
-        // ----- Rename the temporary file
4951
-        // TBC : I should test the result ...
4952
-        //@rename($v_zip_temp_name, $this->zipname);
4953
-        PclZipUtilRename($v_zip_temp_name, $this->zipname);
4954
-
4955
-        // ----- Destroy the temporary archive
4956
-        unset($v_temp_zip);
4957
-    }
4824
+	// ----- Look if something need to be deleted
4825
+	if ($v_nb_extracted > 0) {
4826
+
4827
+		// ----- Creates a temporay file
4828
+		$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
4829
+
4830
+		// ----- Creates a temporary zip archive
4831
+		$v_temp_zip = new PclZip($v_zip_temp_name);
4832
+
4833
+		// ----- Open the temporary zip file in write mode
4834
+		if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
4835
+			$this->privCloseFd();
4836
+
4837
+			// ----- Return
4838
+			return $v_result;
4839
+		}
4840
+
4841
+		// ----- Look which file need to be kept
4842
+		for ($i=0; $i<sizeof($v_header_list); $i++) {
4843
+
4844
+			// ----- Calculate the position of the header
4845
+			@rewind($this->zip_fd);
4846
+			if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
4847
+				// ----- Close the zip file
4848
+				$this->privCloseFd();
4849
+				$v_temp_zip->privCloseFd();
4850
+				@unlink($v_zip_temp_name);
4851
+
4852
+				// ----- Error log
4853
+				PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4854
+
4855
+				// ----- Return
4856
+				return PclZip::errorCode();
4857
+			}
4858
+
4859
+			// ----- Read the file header
4860
+			$v_local_header = array();
4861
+			if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
4862
+				// ----- Close the zip file
4863
+				$this->privCloseFd();
4864
+				$v_temp_zip->privCloseFd();
4865
+				@unlink($v_zip_temp_name);
4866
+
4867
+				// ----- Return
4868
+				return $v_result;
4869
+			}
4870
+
4871
+			// ----- Check that local file header is same as central file header
4872
+			if ($this->privCheckFileHeaders($v_local_header,
4873
+											$v_header_list[$i]) != 1) {
4874
+				// TBC
4875
+			}
4876
+			unset($v_local_header);
4877
+
4878
+			// ----- Write the file header
4879
+			if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
4880
+				// ----- Close the zip file
4881
+				$this->privCloseFd();
4882
+				$v_temp_zip->privCloseFd();
4883
+				@unlink($v_zip_temp_name);
4884
+
4885
+				// ----- Return
4886
+				return $v_result;
4887
+			}
4888
+
4889
+			// ----- Read/write the data block
4890
+			if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
4891
+				// ----- Close the zip file
4892
+				$this->privCloseFd();
4893
+				$v_temp_zip->privCloseFd();
4894
+				@unlink($v_zip_temp_name);
4895
+
4896
+				// ----- Return
4897
+				return $v_result;
4898
+			}
4899
+		}
4900
+
4901
+		// ----- Store the offset of the central dir
4902
+		$v_offset = @ftell($v_temp_zip->zip_fd);
4903
+
4904
+		// ----- Re-Create the Central Dir files header
4905
+		for ($i=0; $i<sizeof($v_header_list); $i++) {
4906
+			// ----- Create the file header
4907
+			if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4908
+				$v_temp_zip->privCloseFd();
4909
+				$this->privCloseFd();
4910
+				@unlink($v_zip_temp_name);
4911
+
4912
+				// ----- Return
4913
+				return $v_result;
4914
+			}
4915
+
4916
+			// ----- Transform the header to a 'usable' info
4917
+			$v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
4918
+		}
4919
+
4920
+
4921
+		// ----- Zip file comment
4922
+		$v_comment = '';
4923
+		if (isset($p_options[PCLZIP_OPT_COMMENT])) {
4924
+		  $v_comment = $p_options[PCLZIP_OPT_COMMENT];
4925
+		}
4926
+
4927
+		// ----- Calculate the size of the central header
4928
+		$v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
4929
+
4930
+		// ----- Create the central dir footer
4931
+		if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
4932
+			// ----- Reset the file list
4933
+			unset($v_header_list);
4934
+			$v_temp_zip->privCloseFd();
4935
+			$this->privCloseFd();
4936
+			@unlink($v_zip_temp_name);
4937
+
4938
+			// ----- Return
4939
+			return $v_result;
4940
+		}
4941
+
4942
+		// ----- Close
4943
+		$v_temp_zip->privCloseFd();
4944
+		$this->privCloseFd();
4945
+
4946
+		// ----- Delete the zip file
4947
+		// TBC : I should test the result ...
4948
+		@unlink($this->zipname);
4949
+
4950
+		// ----- Rename the temporary file
4951
+		// TBC : I should test the result ...
4952
+		//@rename($v_zip_temp_name, $this->zipname);
4953
+		PclZipUtilRename($v_zip_temp_name, $this->zipname);
4954
+
4955
+		// ----- Destroy the temporary archive
4956
+		unset($v_temp_zip);
4957
+	}
4958 4958
 
4959
-    // ----- Remove every files : reset the file
4960
-    else if ($v_central_dir['entries'] != 0) {
4961
-        $this->privCloseFd();
4959
+	// ----- Remove every files : reset the file
4960
+	else if ($v_central_dir['entries'] != 0) {
4961
+		$this->privCloseFd();
4962 4962
 
4963
-        if (($v_result = $this->privOpenFd('wb')) != 1) {
4964
-          return $v_result;
4965
-        }
4963
+		if (($v_result = $this->privOpenFd('wb')) != 1) {
4964
+		  return $v_result;
4965
+		}
4966 4966
 
4967
-        if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
4968
-          return $v_result;
4969
-        }
4967
+		if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
4968
+		  return $v_result;
4969
+		}
4970 4970
 
4971
-        $this->privCloseFd();
4972
-    }
4971
+		$this->privCloseFd();
4972
+	}
4973 4973
 
4974
-    // ----- Return
4975
-    return $v_result;
4974
+	// ----- Return
4975
+	return $v_result;
4976 4976
   }
4977 4977
   // --------------------------------------------------------------------------------
4978 4978
 
@@ -4989,49 +4989,49 @@  discard block
 block discarded – undo
4989 4989
   // --------------------------------------------------------------------------------
4990 4990
   function privDirCheck($p_dir, $p_is_dir=false)
4991 4991
   {
4992
-    $v_result = 1;
4992
+	$v_result = 1;
4993 4993
 
4994 4994
 
4995
-    // ----- Remove the final '/'
4996
-    if (($p_is_dir) && (substr($p_dir, -1)=='/'))
4997
-    {
4998
-      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
4999
-    }
4995
+	// ----- Remove the final '/'
4996
+	if (($p_is_dir) && (substr($p_dir, -1)=='/'))
4997
+	{
4998
+	  $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
4999
+	}
5000 5000
 
5001
-    // ----- Check the directory availability
5002
-    if ((is_dir($p_dir)) || ($p_dir == ""))
5003
-    {
5004
-      return 1;
5005
-    }
5001
+	// ----- Check the directory availability
5002
+	if ((is_dir($p_dir)) || ($p_dir == ""))
5003
+	{
5004
+	  return 1;
5005
+	}
5006 5006
 
5007
-    // ----- Extract parent directory
5008
-    $p_parent_dir = dirname($p_dir);
5009
-
5010
-    // ----- Just a check
5011
-    if ($p_parent_dir != $p_dir)
5012
-    {
5013
-      // ----- Look for parent directory
5014
-      if ($p_parent_dir != "")
5015
-      {
5016
-        if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
5017
-        {
5018
-          return $v_result;
5019
-        }
5020
-      }
5021
-    }
5007
+	// ----- Extract parent directory
5008
+	$p_parent_dir = dirname($p_dir);
5009
+
5010
+	// ----- Just a check
5011
+	if ($p_parent_dir != $p_dir)
5012
+	{
5013
+	  // ----- Look for parent directory
5014
+	  if ($p_parent_dir != "")
5015
+	  {
5016
+		if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
5017
+		{
5018
+		  return $v_result;
5019
+		}
5020
+	  }
5021
+	}
5022 5022
 
5023
-    // ----- Create the directory
5024
-    if (!@mkdir($p_dir, 0777))
5025
-    {
5026
-      // ----- Error log
5027
-      PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
5023
+	// ----- Create the directory
5024
+	if (!@mkdir($p_dir, 0777))
5025
+	{
5026
+	  // ----- Error log
5027
+	  PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
5028 5028
 
5029
-      // ----- Return
5030
-      return PclZip::errorCode();
5031
-    }
5029
+	  // ----- Return
5030
+	  return PclZip::errorCode();
5031
+	}
5032 5032
 
5033
-    // ----- Return
5034
-    return $v_result;
5033
+	// ----- Return
5034
+	return $v_result;
5035 5035
   }
5036 5036
   // --------------------------------------------------------------------------------
5037 5037
 
@@ -5044,180 +5044,180 @@  discard block
 block discarded – undo
5044 5044
   // --------------------------------------------------------------------------------
5045 5045
   function privMerge(&$p_archive_to_add)
5046 5046
   {
5047
-    $v_result=1;
5047
+	$v_result=1;
5048 5048
 
5049
-    // ----- Look if the archive_to_add exists
5050
-    if (!is_file($p_archive_to_add->zipname))
5051
-    {
5049
+	// ----- Look if the archive_to_add exists
5050
+	if (!is_file($p_archive_to_add->zipname))
5051
+	{
5052 5052
 
5053
-      // ----- Nothing to merge, so merge is a success
5054
-      $v_result = 1;
5053
+	  // ----- Nothing to merge, so merge is a success
5054
+	  $v_result = 1;
5055 5055
 
5056
-      // ----- Return
5057
-      return $v_result;
5058
-    }
5056
+	  // ----- Return
5057
+	  return $v_result;
5058
+	}
5059 5059
 
5060
-    // ----- Look if the archive exists
5061
-    if (!is_file($this->zipname))
5062
-    {
5060
+	// ----- Look if the archive exists
5061
+	if (!is_file($this->zipname))
5062
+	{
5063 5063
 
5064
-      // ----- Do a duplicate
5065
-      $v_result = $this->privDuplicate($p_archive_to_add->zipname);
5064
+	  // ----- Do a duplicate
5065
+	  $v_result = $this->privDuplicate($p_archive_to_add->zipname);
5066 5066
 
5067
-      // ----- Return
5068
-      return $v_result;
5069
-    }
5067
+	  // ----- Return
5068
+	  return $v_result;
5069
+	}
5070 5070
 
5071
-    // ----- Open the zip file
5072
-    if (($v_result=$this->privOpenFd('rb')) != 1)
5073
-    {
5074
-      // ----- Return
5075
-      return $v_result;
5076
-    }
5071
+	// ----- Open the zip file
5072
+	if (($v_result=$this->privOpenFd('rb')) != 1)
5073
+	{
5074
+	  // ----- Return
5075
+	  return $v_result;
5076
+	}
5077 5077
 
5078
-    // ----- Read the central directory informations
5079
-    $v_central_dir = array();
5080
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
5081
-    {
5082
-      $this->privCloseFd();
5083
-      return $v_result;
5084
-    }
5078
+	// ----- Read the central directory informations
5079
+	$v_central_dir = array();
5080
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
5081
+	{
5082
+	  $this->privCloseFd();
5083
+	  return $v_result;
5084
+	}
5085 5085
 
5086
-    // ----- Go to beginning of File
5087
-    @rewind($this->zip_fd);
5086
+	// ----- Go to beginning of File
5087
+	@rewind($this->zip_fd);
5088 5088
 
5089
-    // ----- Open the archive_to_add file
5090
-    if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5091
-    {
5092
-      $this->privCloseFd();
5089
+	// ----- Open the archive_to_add file
5090
+	if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5091
+	{
5092
+	  $this->privCloseFd();
5093 5093
 
5094
-      // ----- Return
5095
-      return $v_result;
5096
-    }
5094
+	  // ----- Return
5095
+	  return $v_result;
5096
+	}
5097 5097
 
5098
-    // ----- Read the central directory informations
5099
-    $v_central_dir_to_add = array();
5100
-    if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
5101
-    {
5102
-      $this->privCloseFd();
5103
-      $p_archive_to_add->privCloseFd();
5098
+	// ----- Read the central directory informations
5099
+	$v_central_dir_to_add = array();
5100
+	if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
5101
+	{
5102
+	  $this->privCloseFd();
5103
+	  $p_archive_to_add->privCloseFd();
5104 5104
 
5105
-      return $v_result;
5106
-    }
5105
+	  return $v_result;
5106
+	}
5107 5107
 
5108
-    // ----- Go to beginning of File
5109
-    @rewind($p_archive_to_add->zip_fd);
5108
+	// ----- Go to beginning of File
5109
+	@rewind($p_archive_to_add->zip_fd);
5110 5110
 
5111
-    // ----- Creates a temporay file
5112
-    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
5111
+	// ----- Creates a temporay file
5112
+	$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
5113 5113
 
5114
-    // ----- Open the temporary file in write mode
5115
-    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
5116
-    {
5117
-      $this->privCloseFd();
5118
-      $p_archive_to_add->privCloseFd();
5114
+	// ----- Open the temporary file in write mode
5115
+	if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
5116
+	{
5117
+	  $this->privCloseFd();
5118
+	  $p_archive_to_add->privCloseFd();
5119 5119
 
5120
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5120
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5121 5121
 
5122
-      // ----- Return
5123
-      return PclZip::errorCode();
5124
-    }
5122
+	  // ----- Return
5123
+	  return PclZip::errorCode();
5124
+	}
5125 5125
 
5126
-    // ----- Copy the files from the archive to the temporary file
5127
-    // TBC : Here I should better append the file and go back to erase the central dir
5128
-    $v_size = $v_central_dir['offset'];
5129
-    while ($v_size != 0)
5130
-    {
5131
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5132
-      $v_buffer = fread($this->zip_fd, $v_read_size);
5133
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5134
-      $v_size -= $v_read_size;
5135
-    }
5126
+	// ----- Copy the files from the archive to the temporary file
5127
+	// TBC : Here I should better append the file and go back to erase the central dir
5128
+	$v_size = $v_central_dir['offset'];
5129
+	while ($v_size != 0)
5130
+	{
5131
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5132
+	  $v_buffer = fread($this->zip_fd, $v_read_size);
5133
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5134
+	  $v_size -= $v_read_size;
5135
+	}
5136 5136
 
5137
-    // ----- Copy the files from the archive_to_add into the temporary file
5138
-    $v_size = $v_central_dir_to_add['offset'];
5139
-    while ($v_size != 0)
5140
-    {
5141
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5142
-      $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5143
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5144
-      $v_size -= $v_read_size;
5145
-    }
5137
+	// ----- Copy the files from the archive_to_add into the temporary file
5138
+	$v_size = $v_central_dir_to_add['offset'];
5139
+	while ($v_size != 0)
5140
+	{
5141
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5142
+	  $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5143
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5144
+	  $v_size -= $v_read_size;
5145
+	}
5146 5146
 
5147
-    // ----- Store the offset of the central dir
5148
-    $v_offset = @ftell($v_zip_temp_fd);
5149
-
5150
-    // ----- Copy the block of file headers from the old archive
5151
-    $v_size = $v_central_dir['size'];
5152
-    while ($v_size != 0)
5153
-    {
5154
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5155
-      $v_buffer = @fread($this->zip_fd, $v_read_size);
5156
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5157
-      $v_size -= $v_read_size;
5158
-    }
5147
+	// ----- Store the offset of the central dir
5148
+	$v_offset = @ftell($v_zip_temp_fd);
5149
+
5150
+	// ----- Copy the block of file headers from the old archive
5151
+	$v_size = $v_central_dir['size'];
5152
+	while ($v_size != 0)
5153
+	{
5154
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5155
+	  $v_buffer = @fread($this->zip_fd, $v_read_size);
5156
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5157
+	  $v_size -= $v_read_size;
5158
+	}
5159 5159
 
5160
-    // ----- Copy the block of file headers from the archive_to_add
5161
-    $v_size = $v_central_dir_to_add['size'];
5162
-    while ($v_size != 0)
5163
-    {
5164
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5165
-      $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5166
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5167
-      $v_size -= $v_read_size;
5168
-    }
5160
+	// ----- Copy the block of file headers from the archive_to_add
5161
+	$v_size = $v_central_dir_to_add['size'];
5162
+	while ($v_size != 0)
5163
+	{
5164
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5165
+	  $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5166
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5167
+	  $v_size -= $v_read_size;
5168
+	}
5169 5169
 
5170
-    // ----- Merge the file comments
5171
-    $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
5170
+	// ----- Merge the file comments
5171
+	$v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
5172 5172
 
5173
-    // ----- Calculate the size of the (new) central header
5174
-    $v_size = @ftell($v_zip_temp_fd)-$v_offset;
5173
+	// ----- Calculate the size of the (new) central header
5174
+	$v_size = @ftell($v_zip_temp_fd)-$v_offset;
5175 5175
 
5176
-    // ----- Swap the file descriptor
5177
-    // Here is a trick : I swap the temporary fd with the zip fd, in order to use
5178
-    // the following methods on the temporary fil and not the real archive fd
5179
-    $v_swap = $this->zip_fd;
5180
-    $this->zip_fd = $v_zip_temp_fd;
5181
-    $v_zip_temp_fd = $v_swap;
5176
+	// ----- Swap the file descriptor
5177
+	// Here is a trick : I swap the temporary fd with the zip fd, in order to use
5178
+	// the following methods on the temporary fil and not the real archive fd
5179
+	$v_swap = $this->zip_fd;
5180
+	$this->zip_fd = $v_zip_temp_fd;
5181
+	$v_zip_temp_fd = $v_swap;
5182 5182
 
5183
-    // ----- Create the central dir footer
5184
-    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5185
-    {
5186
-      $this->privCloseFd();
5187
-      $p_archive_to_add->privCloseFd();
5188
-      @fclose($v_zip_temp_fd);
5189
-      $this->zip_fd = null;
5183
+	// ----- Create the central dir footer
5184
+	if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5185
+	{
5186
+	  $this->privCloseFd();
5187
+	  $p_archive_to_add->privCloseFd();
5188
+	  @fclose($v_zip_temp_fd);
5189
+	  $this->zip_fd = null;
5190 5190
 
5191
-      // ----- Reset the file list
5192
-      unset($v_header_list);
5191
+	  // ----- Reset the file list
5192
+	  unset($v_header_list);
5193 5193
 
5194
-      // ----- Return
5195
-      return $v_result;
5196
-    }
5194
+	  // ----- Return
5195
+	  return $v_result;
5196
+	}
5197 5197
 
5198
-    // ----- Swap back the file descriptor
5199
-    $v_swap = $this->zip_fd;
5200
-    $this->zip_fd = $v_zip_temp_fd;
5201
-    $v_zip_temp_fd = $v_swap;
5198
+	// ----- Swap back the file descriptor
5199
+	$v_swap = $this->zip_fd;
5200
+	$this->zip_fd = $v_zip_temp_fd;
5201
+	$v_zip_temp_fd = $v_swap;
5202 5202
 
5203
-    // ----- Close
5204
-    $this->privCloseFd();
5205
-    $p_archive_to_add->privCloseFd();
5203
+	// ----- Close
5204
+	$this->privCloseFd();
5205
+	$p_archive_to_add->privCloseFd();
5206 5206
 
5207
-    // ----- Close the temporary file
5208
-    @fclose($v_zip_temp_fd);
5207
+	// ----- Close the temporary file
5208
+	@fclose($v_zip_temp_fd);
5209 5209
 
5210
-    // ----- Delete the zip file
5211
-    // TBC : I should test the result ...
5212
-    @unlink($this->zipname);
5210
+	// ----- Delete the zip file
5211
+	// TBC : I should test the result ...
5212
+	@unlink($this->zipname);
5213 5213
 
5214
-    // ----- Rename the temporary file
5215
-    // TBC : I should test the result ...
5216
-    //@rename($v_zip_temp_name, $this->zipname);
5217
-    PclZipUtilRename($v_zip_temp_name, $this->zipname);
5214
+	// ----- Rename the temporary file
5215
+	// TBC : I should test the result ...
5216
+	//@rename($v_zip_temp_name, $this->zipname);
5217
+	PclZipUtilRename($v_zip_temp_name, $this->zipname);
5218 5218
 
5219
-    // ----- Return
5220
-    return $v_result;
5219
+	// ----- Return
5220
+	return $v_result;
5221 5221
   }
5222 5222
   // --------------------------------------------------------------------------------
5223 5223
 
@@ -5229,56 +5229,56 @@  discard block
 block discarded – undo
5229 5229
   // --------------------------------------------------------------------------------
5230 5230
   function privDuplicate($p_archive_filename)
5231 5231
   {
5232
-    $v_result=1;
5232
+	$v_result=1;
5233 5233
 
5234
-    // ----- Look if the $p_archive_filename exists
5235
-    if (!is_file($p_archive_filename))
5236
-    {
5234
+	// ----- Look if the $p_archive_filename exists
5235
+	if (!is_file($p_archive_filename))
5236
+	{
5237 5237
 
5238
-      // ----- Nothing to duplicate, so duplicate is a success.
5239
-      $v_result = 1;
5238
+	  // ----- Nothing to duplicate, so duplicate is a success.
5239
+	  $v_result = 1;
5240 5240
 
5241
-      // ----- Return
5242
-      return $v_result;
5243
-    }
5241
+	  // ----- Return
5242
+	  return $v_result;
5243
+	}
5244 5244
 
5245
-    // ----- Open the zip file
5246
-    if (($v_result=$this->privOpenFd('wb')) != 1)
5247
-    {
5248
-      // ----- Return
5249
-      return $v_result;
5250
-    }
5245
+	// ----- Open the zip file
5246
+	if (($v_result=$this->privOpenFd('wb')) != 1)
5247
+	{
5248
+	  // ----- Return
5249
+	  return $v_result;
5250
+	}
5251 5251
 
5252
-    // ----- Open the temporary file in write mode
5253
-    if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
5254
-    {
5255
-      $this->privCloseFd();
5252
+	// ----- Open the temporary file in write mode
5253
+	if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
5254
+	{
5255
+	  $this->privCloseFd();
5256 5256
 
5257
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5257
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5258 5258
 
5259
-      // ----- Return
5260
-      return PclZip::errorCode();
5261
-    }
5259
+	  // ----- Return
5260
+	  return PclZip::errorCode();
5261
+	}
5262 5262
 
5263
-    // ----- Copy the files from the archive to the temporary file
5264
-    // TBC : Here I should better append the file and go back to erase the central dir
5265
-    $v_size = filesize($p_archive_filename);
5266
-    while ($v_size != 0)
5267
-    {
5268
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5269
-      $v_buffer = fread($v_zip_temp_fd, $v_read_size);
5270
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
5271
-      $v_size -= $v_read_size;
5272
-    }
5263
+	// ----- Copy the files from the archive to the temporary file
5264
+	// TBC : Here I should better append the file and go back to erase the central dir
5265
+	$v_size = filesize($p_archive_filename);
5266
+	while ($v_size != 0)
5267
+	{
5268
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5269
+	  $v_buffer = fread($v_zip_temp_fd, $v_read_size);
5270
+	  @fwrite($this->zip_fd, $v_buffer, $v_read_size);
5271
+	  $v_size -= $v_read_size;
5272
+	}
5273 5273
 
5274
-    // ----- Close
5275
-    $this->privCloseFd();
5274
+	// ----- Close
5275
+	$this->privCloseFd();
5276 5276
 
5277
-    // ----- Close the temporary file
5278
-    @fclose($v_zip_temp_fd);
5277
+	// ----- Close the temporary file
5278
+	@fclose($v_zip_temp_fd);
5279 5279
 
5280
-    // ----- Return
5281
-    return $v_result;
5280
+	// ----- Return
5281
+	return $v_result;
5282 5282
   }
5283 5283
   // --------------------------------------------------------------------------------
5284 5284
 
@@ -5289,13 +5289,13 @@  discard block
 block discarded – undo
5289 5289
   // --------------------------------------------------------------------------------
5290 5290
   function privErrorLog($p_error_code=0, $p_error_string='')
5291 5291
   {
5292
-    if (PCLZIP_ERROR_EXTERNAL == 1) {
5293
-      PclError($p_error_code, $p_error_string);
5294
-    }
5295
-    else {
5296
-      $this->error_code = $p_error_code;
5297
-      $this->error_string = $p_error_string;
5298
-    }
5292
+	if (PCLZIP_ERROR_EXTERNAL == 1) {
5293
+	  PclError($p_error_code, $p_error_string);
5294
+	}
5295
+	else {
5296
+	  $this->error_code = $p_error_code;
5297
+	  $this->error_string = $p_error_string;
5298
+	}
5299 5299
   }
5300 5300
   // --------------------------------------------------------------------------------
5301 5301
 
@@ -5306,13 +5306,13 @@  discard block
 block discarded – undo
5306 5306
   // --------------------------------------------------------------------------------
5307 5307
   function privErrorReset()
5308 5308
   {
5309
-    if (PCLZIP_ERROR_EXTERNAL == 1) {
5310
-      PclErrorReset();
5311
-    }
5312
-    else {
5313
-      $this->error_code = 0;
5314
-      $this->error_string = '';
5315
-    }
5309
+	if (PCLZIP_ERROR_EXTERNAL == 1) {
5310
+	  PclErrorReset();
5311
+	}
5312
+	else {
5313
+	  $this->error_code = 0;
5314
+	  $this->error_string = '';
5315
+	}
5316 5316
   }
5317 5317
   // --------------------------------------------------------------------------------
5318 5318
 
@@ -5324,17 +5324,17 @@  discard block
 block discarded – undo
5324 5324
   // --------------------------------------------------------------------------------
5325 5325
   function privDisableMagicQuotes()
5326 5326
   {
5327
-    $v_result=1;
5327
+	$v_result=1;
5328 5328
 
5329
-    // ----- Look if function exists
5330
-    if (   (!function_exists("get_magic_quotes_runtime"))
5331
-	    || (!function_exists("set_magic_quotes_runtime"))) {
5332
-      return $v_result;
5329
+	// ----- Look if function exists
5330
+	if (   (!function_exists("get_magic_quotes_runtime"))
5331
+		|| (!function_exists("set_magic_quotes_runtime"))) {
5332
+	  return $v_result;
5333 5333
 	}
5334 5334
 
5335
-    // ----- Look if already done
5336
-    if ($this->magic_quotes_status != -1) {
5337
-      return $v_result;
5335
+	// ----- Look if already done
5336
+	if ($this->magic_quotes_status != -1) {
5337
+	  return $v_result;
5338 5338
 	}
5339 5339
 
5340 5340
 	// ----- Get and memorize the magic_quote value
@@ -5345,8 +5345,8 @@  discard block
 block discarded – undo
5345 5345
 	  @set_magic_quotes_runtime(0);
5346 5346
 	}
5347 5347
 
5348
-    // ----- Return
5349
-    return $v_result;
5348
+	// ----- Return
5349
+	return $v_result;
5350 5350
   }
5351 5351
   // --------------------------------------------------------------------------------
5352 5352
 
@@ -5358,17 +5358,17 @@  discard block
 block discarded – undo
5358 5358
   // --------------------------------------------------------------------------------
5359 5359
   function privSwapBackMagicQuotes()
5360 5360
   {
5361
-    $v_result=1;
5361
+	$v_result=1;
5362 5362
 
5363
-    // ----- Look if function exists
5364
-    if (   (!function_exists("get_magic_quotes_runtime"))
5365
-	    || (!function_exists("set_magic_quotes_runtime"))) {
5366
-      return $v_result;
5363
+	// ----- Look if function exists
5364
+	if (   (!function_exists("get_magic_quotes_runtime"))
5365
+		|| (!function_exists("set_magic_quotes_runtime"))) {
5366
+	  return $v_result;
5367 5367
 	}
5368 5368
 
5369
-    // ----- Look if something to do
5370
-    if ($this->magic_quotes_status != -1) {
5371
-      return $v_result;
5369
+	// ----- Look if something to do
5370
+	if ($this->magic_quotes_status != -1) {
5371
+	  return $v_result;
5372 5372
 	}
5373 5373
 
5374 5374
 	// ----- Swap back magic_quotes
@@ -5376,8 +5376,8 @@  discard block
 block discarded – undo
5376 5376
   	  @set_magic_quotes_runtime($this->magic_quotes_status);
5377 5377
 	}
5378 5378
 
5379
-    // ----- Return
5380
-    return $v_result;
5379
+	// ----- Return
5380
+	return $v_result;
5381 5381
   }
5382 5382
   // --------------------------------------------------------------------------------
5383 5383
 
@@ -5393,67 +5393,67 @@  discard block
 block discarded – undo
5393 5393
   // --------------------------------------------------------------------------------
5394 5394
   function PclZipUtilPathReduction($p_dir)
5395 5395
   {
5396
-    $v_result = "";
5397
-
5398
-    // ----- Look for not empty path
5399
-    if ($p_dir != "") {
5400
-      // ----- Explode path by directory names
5401
-      $v_list = explode("/", $p_dir);
5402
-
5403
-      // ----- Study directories from last to first
5404
-      $v_skip = 0;
5405
-      for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5406
-        // ----- Look for current path
5407
-        if ($v_list[$i] == ".") {
5408
-          // ----- Ignore this directory
5409
-          // Should be the first $i=0, but no check is done
5410
-        }
5411
-        else if ($v_list[$i] == "..") {
5396
+	$v_result = "";
5397
+
5398
+	// ----- Look for not empty path
5399
+	if ($p_dir != "") {
5400
+	  // ----- Explode path by directory names
5401
+	  $v_list = explode("/", $p_dir);
5402
+
5403
+	  // ----- Study directories from last to first
5404
+	  $v_skip = 0;
5405
+	  for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5406
+		// ----- Look for current path
5407
+		if ($v_list[$i] == ".") {
5408
+		  // ----- Ignore this directory
5409
+		  // Should be the first $i=0, but no check is done
5410
+		}
5411
+		else if ($v_list[$i] == "..") {
5412 5412
 		  $v_skip++;
5413
-        }
5414
-        else if ($v_list[$i] == "") {
5413
+		}
5414
+		else if ($v_list[$i] == "") {
5415 5415
 		  // ----- First '/' i.e. root slash
5416 5416
 		  if ($i == 0) {
5417
-            $v_result = "/".$v_result;
5418
-		    if ($v_skip > 0) {
5419
-		        // ----- It is an invalid path, so the path is not modified
5420
-		        // TBC
5421
-		        $v_result = $p_dir;
5422
-                $v_skip = 0;
5423
-		    }
5417
+			$v_result = "/".$v_result;
5418
+			if ($v_skip > 0) {
5419
+				// ----- It is an invalid path, so the path is not modified
5420
+				// TBC
5421
+				$v_result = $p_dir;
5422
+				$v_skip = 0;
5423
+			}
5424 5424
 		  }
5425 5425
 		  // ----- Last '/' i.e. indicates a directory
5426 5426
 		  else if ($i == (sizeof($v_list)-1)) {
5427
-            $v_result = $v_list[$i];
5427
+			$v_result = $v_list[$i];
5428 5428
 		  }
5429 5429
 		  // ----- Double '/' inside the path
5430 5430
 		  else {
5431
-            // ----- Ignore only the double '//' in path,
5432
-            // but not the first and last '/'
5431
+			// ----- Ignore only the double '//' in path,
5432
+			// but not the first and last '/'
5433 5433
 		  }
5434
-        }
5435
-        else {
5434
+		}
5435
+		else {
5436 5436
 		  // ----- Look for item to skip
5437 5437
 		  if ($v_skip > 0) {
5438
-		    $v_skip--;
5438
+			$v_skip--;
5439 5439
 		  }
5440 5440
 		  else {
5441
-            $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5441
+			$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5442 5442
 		  }
5443
-        }
5444
-      }
5443
+		}
5444
+	  }
5445 5445
 
5446
-      // ----- Look for skip
5447
-      if ($v_skip > 0) {
5448
-        while ($v_skip > 0) {
5449
-            $v_result = '../'.$v_result;
5450
-            $v_skip--;
5451
-        }
5452
-      }
5453
-    }
5446
+	  // ----- Look for skip
5447
+	  if ($v_skip > 0) {
5448
+		while ($v_skip > 0) {
5449
+			$v_result = '../'.$v_result;
5450
+			$v_skip--;
5451
+		}
5452
+	  }
5453
+	}
5454 5454
 
5455
-    // ----- Return
5456
-    return $v_result;
5455
+	// ----- Return
5456
+	return $v_result;
5457 5457
   }
5458 5458
   // --------------------------------------------------------------------------------
5459 5459
 
@@ -5474,67 +5474,67 @@  discard block
 block discarded – undo
5474 5474
   // --------------------------------------------------------------------------------
5475 5475
   function PclZipUtilPathInclusion($p_dir, $p_path)
5476 5476
   {
5477
-    $v_result = 1;
5477
+	$v_result = 1;
5478 5478
 
5479
-    // ----- Look for path beginning by ./
5480
-    if (   ($p_dir == '.')
5481
-        || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5482
-      $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5483
-    }
5484
-    if (   ($p_path == '.')
5485
-        || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5486
-      $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5487
-    }
5479
+	// ----- Look for path beginning by ./
5480
+	if (   ($p_dir == '.')
5481
+		|| ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5482
+	  $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5483
+	}
5484
+	if (   ($p_path == '.')
5485
+		|| ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5486
+	  $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5487
+	}
5488 5488
 
5489
-    // ----- Explode dir and path by directory separator
5490
-    $v_list_dir = explode("/", $p_dir);
5491
-    $v_list_dir_size = sizeof($v_list_dir);
5492
-    $v_list_path = explode("/", $p_path);
5493
-    $v_list_path_size = sizeof($v_list_path);
5494
-
5495
-    // ----- Study directories paths
5496
-    $i = 0;
5497
-    $j = 0;
5498
-    while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
5499
-
5500
-      // ----- Look for empty dir (path reduction)
5501
-      if ($v_list_dir[$i] == '') {
5502
-        $i++;
5503
-        continue;
5504
-      }
5505
-      if ($v_list_path[$j] == '') {
5506
-        $j++;
5507
-        continue;
5508
-      }
5489
+	// ----- Explode dir and path by directory separator
5490
+	$v_list_dir = explode("/", $p_dir);
5491
+	$v_list_dir_size = sizeof($v_list_dir);
5492
+	$v_list_path = explode("/", $p_path);
5493
+	$v_list_path_size = sizeof($v_list_path);
5494
+
5495
+	// ----- Study directories paths
5496
+	$i = 0;
5497
+	$j = 0;
5498
+	while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
5499
+
5500
+	  // ----- Look for empty dir (path reduction)
5501
+	  if ($v_list_dir[$i] == '') {
5502
+		$i++;
5503
+		continue;
5504
+	  }
5505
+	  if ($v_list_path[$j] == '') {
5506
+		$j++;
5507
+		continue;
5508
+	  }
5509 5509
 
5510
-      // ----- Compare the items
5511
-      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
5512
-        $v_result = 0;
5513
-      }
5510
+	  // ----- Compare the items
5511
+	  if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
5512
+		$v_result = 0;
5513
+	  }
5514 5514
 
5515
-      // ----- Next items
5516
-      $i++;
5517
-      $j++;
5518
-    }
5515
+	  // ----- Next items
5516
+	  $i++;
5517
+	  $j++;
5518
+	}
5519 5519
 
5520
-    // ----- Look if everything seems to be the same
5521
-    if ($v_result) {
5522
-      // ----- Skip all the empty items
5523
-      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5524
-      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5520
+	// ----- Look if everything seems to be the same
5521
+	if ($v_result) {
5522
+	  // ----- Skip all the empty items
5523
+	  while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5524
+	  while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5525 5525
 
5526
-      if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5527
-        // ----- There are exactly the same
5528
-        $v_result = 2;
5529
-      }
5530
-      else if ($i < $v_list_dir_size) {
5531
-        // ----- The path is shorter than the dir
5532
-        $v_result = 0;
5533
-      }
5534
-    }
5526
+	  if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5527
+		// ----- There are exactly the same
5528
+		$v_result = 2;
5529
+	  }
5530
+	  else if ($i < $v_list_dir_size) {
5531
+		// ----- The path is shorter than the dir
5532
+		$v_result = 0;
5533
+	  }
5534
+	}
5535 5535
 
5536
-    // ----- Return
5537
-    return $v_result;
5536
+	// ----- Return
5537
+	return $v_result;
5538 5538
   }
5539 5539
   // --------------------------------------------------------------------------------
5540 5540
 
@@ -5551,51 +5551,51 @@  discard block
 block discarded – undo
5551 5551
   // --------------------------------------------------------------------------------
5552 5552
   function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5553 5553
   {
5554
-    $v_result = 1;
5555
-
5556
-    if ($p_mode==0)
5557
-    {
5558
-      while ($p_size != 0)
5559
-      {
5560
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5561
-        $v_buffer = @fread($p_src, $v_read_size);
5562
-        @fwrite($p_dest, $v_buffer, $v_read_size);
5563
-        $p_size -= $v_read_size;
5564
-      }
5565
-    }
5566
-    else if ($p_mode==1)
5567
-    {
5568
-      while ($p_size != 0)
5569
-      {
5570
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5571
-        $v_buffer = @gzread($p_src, $v_read_size);
5572
-        @fwrite($p_dest, $v_buffer, $v_read_size);
5573
-        $p_size -= $v_read_size;
5574
-      }
5575
-    }
5576
-    else if ($p_mode==2)
5577
-    {
5578
-      while ($p_size != 0)
5579
-      {
5580
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5581
-        $v_buffer = @fread($p_src, $v_read_size);
5582
-        @gzwrite($p_dest, $v_buffer, $v_read_size);
5583
-        $p_size -= $v_read_size;
5584
-      }
5585
-    }
5586
-    else if ($p_mode==3)
5587
-    {
5588
-      while ($p_size != 0)
5589
-      {
5590
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5591
-        $v_buffer = @gzread($p_src, $v_read_size);
5592
-        @gzwrite($p_dest, $v_buffer, $v_read_size);
5593
-        $p_size -= $v_read_size;
5594
-      }
5595
-    }
5554
+	$v_result = 1;
5555
+
5556
+	if ($p_mode==0)
5557
+	{
5558
+	  while ($p_size != 0)
5559
+	  {
5560
+		$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5561
+		$v_buffer = @fread($p_src, $v_read_size);
5562
+		@fwrite($p_dest, $v_buffer, $v_read_size);
5563
+		$p_size -= $v_read_size;
5564
+	  }
5565
+	}
5566
+	else if ($p_mode==1)
5567
+	{
5568
+	  while ($p_size != 0)
5569
+	  {
5570
+		$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5571
+		$v_buffer = @gzread($p_src, $v_read_size);
5572
+		@fwrite($p_dest, $v_buffer, $v_read_size);
5573
+		$p_size -= $v_read_size;
5574
+	  }
5575
+	}
5576
+	else if ($p_mode==2)
5577
+	{
5578
+	  while ($p_size != 0)
5579
+	  {
5580
+		$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5581
+		$v_buffer = @fread($p_src, $v_read_size);
5582
+		@gzwrite($p_dest, $v_buffer, $v_read_size);
5583
+		$p_size -= $v_read_size;
5584
+	  }
5585
+	}
5586
+	else if ($p_mode==3)
5587
+	{
5588
+	  while ($p_size != 0)
5589
+	  {
5590
+		$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5591
+		$v_buffer = @gzread($p_src, $v_read_size);
5592
+		@gzwrite($p_dest, $v_buffer, $v_read_size);
5593
+		$p_size -= $v_read_size;
5594
+	  }
5595
+	}
5596 5596
 
5597
-    // ----- Return
5598
-    return $v_result;
5597
+	// ----- Return
5598
+	return $v_result;
5599 5599
   }
5600 5600
   // --------------------------------------------------------------------------------
5601 5601
 
@@ -5613,22 +5613,22 @@  discard block
 block discarded – undo
5613 5613
   // --------------------------------------------------------------------------------
5614 5614
   function PclZipUtilRename($p_src, $p_dest)
5615 5615
   {
5616
-    $v_result = 1;
5616
+	$v_result = 1;
5617 5617
 
5618
-    // ----- Try to rename the files
5619
-    if (!@rename($p_src, $p_dest)) {
5618
+	// ----- Try to rename the files
5619
+	if (!@rename($p_src, $p_dest)) {
5620 5620
 
5621
-      // ----- Try to copy & unlink the src
5622
-      if (!@copy($p_src, $p_dest)) {
5623
-        $v_result = 0;
5624
-      }
5625
-      else if (!@unlink($p_src)) {
5626
-        $v_result = 0;
5627
-      }
5628
-    }
5621
+	  // ----- Try to copy & unlink the src
5622
+	  if (!@copy($p_src, $p_dest)) {
5623
+		$v_result = 0;
5624
+	  }
5625
+	  else if (!@unlink($p_src)) {
5626
+		$v_result = 0;
5627
+	  }
5628
+	}
5629 5629
 
5630
-    // ----- Return
5631
-    return $v_result;
5630
+	// ----- Return
5631
+	return $v_result;
5632 5632
   }
5633 5633
   // --------------------------------------------------------------------------------
5634 5634
 
@@ -5644,20 +5644,20 @@  discard block
 block discarded – undo
5644 5644
   function PclZipUtilOptionText($p_option)
5645 5645
   {
5646 5646
 
5647
-    $v_list = get_defined_constants();
5648
-    for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5649
-	    $v_prefix = substr($v_key, 0, 10);
5650
-	    if ((   ($v_prefix == 'PCLZIP_OPT')
5651
-           || ($v_prefix == 'PCLZIP_CB_')
5652
-           || ($v_prefix == 'PCLZIP_ATT'))
5653
-	        && ($v_list[$v_key] == $p_option)) {
5654
-        return $v_key;
5655
-	    }
5656
-    }
5647
+	$v_list = get_defined_constants();
5648
+	for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5649
+		$v_prefix = substr($v_key, 0, 10);
5650
+		if ((   ($v_prefix == 'PCLZIP_OPT')
5651
+		   || ($v_prefix == 'PCLZIP_CB_')
5652
+		   || ($v_prefix == 'PCLZIP_ATT'))
5653
+			&& ($v_list[$v_key] == $p_option)) {
5654
+		return $v_key;
5655
+		}
5656
+	}
5657 5657
 
5658
-    $v_result = 'Unknown';
5658
+	$v_result = 'Unknown';
5659 5659
 
5660
-    return $v_result;
5660
+	return $v_result;
5661 5661
   }
5662 5662
   // --------------------------------------------------------------------------------
5663 5663
 
@@ -5674,17 +5674,17 @@  discard block
 block discarded – undo
5674 5674
   // --------------------------------------------------------------------------------
5675 5675
   function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
5676 5676
   {
5677
-    if (stristr(php_uname(), 'windows')) {
5678
-      // ----- Look for potential disk letter
5679
-      if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5680
-          $p_path = substr($p_path, $v_position+1);
5681
-      }
5682
-      // ----- Change potential windows directory separator
5683
-      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5684
-          $p_path = strtr($p_path, '\\', '/');
5685
-      }
5686
-    }
5687
-    return $p_path;
5677
+	if (stristr(php_uname(), 'windows')) {
5678
+	  // ----- Look for potential disk letter
5679
+	  if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5680
+		  $p_path = substr($p_path, $v_position+1);
5681
+	  }
5682
+	  // ----- Change potential windows directory separator
5683
+	  if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5684
+		  $p_path = strtr($p_path, '\\', '/');
5685
+	  }
5686
+	}
5687
+	return $p_path;
5688 5688
   }
5689 5689
   // --------------------------------------------------------------------------------
5690 5690
 
Please login to merge, or discard this patch.
Spacing   +325 added lines, -325 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 // --------------------------------------------------------------------------------
27 27
 
28 28
   // ----- Constants
29
-  if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
30
-    define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
29
+  if ( ! defined('PCLZIP_READ_BLOCK_SIZE')) {
30
+    define('PCLZIP_READ_BLOCK_SIZE', 2048);
31 31
   }
32 32
 
33 33
   // ----- File list separator
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
   // Recommanded values for compatibility with older versions :
41 41
   //define( 'PCLZIP_SEPARATOR', ' ' );
42 42
   // Recommanded values for smart separation of filenames.
43
-  if (!defined('PCLZIP_SEPARATOR')) {
44
-    define( 'PCLZIP_SEPARATOR', ',' );
43
+  if ( ! defined('PCLZIP_SEPARATOR')) {
44
+    define('PCLZIP_SEPARATOR', ',');
45 45
   }
46 46
 
47 47
   // ----- Error configuration
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
   // 1 : PclError external library error handling. By enabling this
50 50
   //     you must ensure that you have included PclError library.
51 51
   // [2,...] : reserved for futur use
52
-  if (!defined('PCLZIP_ERROR_EXTERNAL')) {
53
-    define( 'PCLZIP_ERROR_EXTERNAL', 0 );
52
+  if ( ! defined('PCLZIP_ERROR_EXTERNAL')) {
53
+    define('PCLZIP_ERROR_EXTERNAL', 0);
54 54
   }
55 55
 
56 56
   // ----- Optional static temporary directory
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
   //       Samples :
63 63
   // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
64 64
   // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
65
-  if (!defined('PCLZIP_TEMPORARY_DIR')) {
66
-    define( 'PCLZIP_TEMPORARY_DIR', '' );
65
+  if ( ! defined('PCLZIP_TEMPORARY_DIR')) {
66
+    define('PCLZIP_TEMPORARY_DIR', '');
67 67
   }
68 68
 
69 69
   // ----- Optional threshold ratio for use of temporary files
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
   //       Recommended values are under 0.5. Default 0.47.
75 75
   //       Samples :
76 76
   // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
77
-  if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
78
-    define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
77
+  if ( ! defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
78
+    define('PCLZIP_TEMPORARY_FILE_RATIO', 0.47);
79 79
   }
80 80
 
81 81
 // --------------------------------------------------------------------------------
@@ -100,72 +100,72 @@  discard block
 block discarded – undo
100 100
   //  -12 : Unable to rename file (rename)
101 101
   //  -13 : Invalid header checksum
102 102
   //  -14 : Invalid archive size
103
-  define( 'PCLZIP_ERR_USER_ABORTED', 2 );
104
-  define( 'PCLZIP_ERR_NO_ERROR', 0 );
105
-  define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
106
-  define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
107
-  define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
108
-  define( 'PCLZIP_ERR_MISSING_FILE', -4 );
109
-  define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
110
-  define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
111
-  define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
112
-  define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
113
-  define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
114
-  define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
115
-  define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
116
-  define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
117
-  define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
118
-  define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
119
-  define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
120
-  define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
121
-  define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
122
-  define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
123
-  define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
124
-  define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
125
-  define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
103
+  define('PCLZIP_ERR_USER_ABORTED', 2);
104
+  define('PCLZIP_ERR_NO_ERROR', 0);
105
+  define('PCLZIP_ERR_WRITE_OPEN_FAIL', -1);
106
+  define('PCLZIP_ERR_READ_OPEN_FAIL', -2);
107
+  define('PCLZIP_ERR_INVALID_PARAMETER', -3);
108
+  define('PCLZIP_ERR_MISSING_FILE', -4);
109
+  define('PCLZIP_ERR_FILENAME_TOO_LONG', -5);
110
+  define('PCLZIP_ERR_INVALID_ZIP', -6);
111
+  define('PCLZIP_ERR_BAD_EXTRACTED_FILE', -7);
112
+  define('PCLZIP_ERR_DIR_CREATE_FAIL', -8);
113
+  define('PCLZIP_ERR_BAD_EXTENSION', -9);
114
+  define('PCLZIP_ERR_BAD_FORMAT', -10);
115
+  define('PCLZIP_ERR_DELETE_FILE_FAIL', -11);
116
+  define('PCLZIP_ERR_RENAME_FILE_FAIL', -12);
117
+  define('PCLZIP_ERR_BAD_CHECKSUM', -13);
118
+  define('PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14);
119
+  define('PCLZIP_ERR_MISSING_OPTION_VALUE', -15);
120
+  define('PCLZIP_ERR_INVALID_OPTION_VALUE', -16);
121
+  define('PCLZIP_ERR_ALREADY_A_DIRECTORY', -17);
122
+  define('PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18);
123
+  define('PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19);
124
+  define('PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20);
125
+  define('PCLZIP_ERR_DIRECTORY_RESTRICTION', -21);
126 126
 
127 127
   // ----- Options values
128
-  define( 'PCLZIP_OPT_PATH', 77001 );
129
-  define( 'PCLZIP_OPT_ADD_PATH', 77002 );
130
-  define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
131
-  define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
132
-  define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
133
-  define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
134
-  define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
135
-  define( 'PCLZIP_OPT_BY_NAME', 77008 );
136
-  define( 'PCLZIP_OPT_BY_INDEX', 77009 );
137
-  define( 'PCLZIP_OPT_BY_EREG', 77010 );
138
-  define( 'PCLZIP_OPT_BY_PREG', 77011 );
139
-  define( 'PCLZIP_OPT_COMMENT', 77012 );
140
-  define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
141
-  define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
142
-  define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
143
-  define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
144
-  define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
128
+  define('PCLZIP_OPT_PATH', 77001);
129
+  define('PCLZIP_OPT_ADD_PATH', 77002);
130
+  define('PCLZIP_OPT_REMOVE_PATH', 77003);
131
+  define('PCLZIP_OPT_REMOVE_ALL_PATH', 77004);
132
+  define('PCLZIP_OPT_SET_CHMOD', 77005);
133
+  define('PCLZIP_OPT_EXTRACT_AS_STRING', 77006);
134
+  define('PCLZIP_OPT_NO_COMPRESSION', 77007);
135
+  define('PCLZIP_OPT_BY_NAME', 77008);
136
+  define('PCLZIP_OPT_BY_INDEX', 77009);
137
+  define('PCLZIP_OPT_BY_EREG', 77010);
138
+  define('PCLZIP_OPT_BY_PREG', 77011);
139
+  define('PCLZIP_OPT_COMMENT', 77012);
140
+  define('PCLZIP_OPT_ADD_COMMENT', 77013);
141
+  define('PCLZIP_OPT_PREPEND_COMMENT', 77014);
142
+  define('PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015);
143
+  define('PCLZIP_OPT_REPLACE_NEWER', 77016);
144
+  define('PCLZIP_OPT_STOP_ON_ERROR', 77017);
145 145
   // Having big trouble with crypt. Need to multiply 2 long int
146 146
   // which is not correctly supported by PHP ...
147 147
   //define( 'PCLZIP_OPT_CRYPT', 77018 );
148
-  define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
149
-  define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
150
-  define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
151
-  define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
152
-  define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
153
-  define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
154
-  define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
148
+  define('PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019);
149
+  define('PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020);
150
+  define('PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020); // alias
151
+  define('PCLZIP_OPT_TEMP_FILE_ON', 77021);
152
+  define('PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021); // alias
153
+  define('PCLZIP_OPT_TEMP_FILE_OFF', 77022);
154
+  define('PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022); // alias
155 155
 
156 156
   // ----- File description attributes
157
-  define( 'PCLZIP_ATT_FILE_NAME', 79001 );
158
-  define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
159
-  define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
160
-  define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
161
-  define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
162
-  define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
157
+  define('PCLZIP_ATT_FILE_NAME', 79001);
158
+  define('PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002);
159
+  define('PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003);
160
+  define('PCLZIP_ATT_FILE_MTIME', 79004);
161
+  define('PCLZIP_ATT_FILE_CONTENT', 79005);
162
+  define('PCLZIP_ATT_FILE_COMMENT', 79006);
163 163
 
164 164
   // ----- Call backs values
165
-  define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
166
-  define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
167
-  define( 'PCLZIP_CB_PRE_ADD', 78003 );
168
-  define( 'PCLZIP_CB_POST_ADD', 78004 );
165
+  define('PCLZIP_CB_PRE_EXTRACT', 78001);
166
+  define('PCLZIP_CB_POST_EXTRACT', 78002);
167
+  define('PCLZIP_CB_PRE_ADD', 78003);
168
+  define('PCLZIP_CB_POST_ADD', 78004);
169 169
   /* For futur use
170 170
   define( 'PCLZIP_CB_PRE_LIST', 78005 );
171 171
   define( 'PCLZIP_CB_POST_LIST', 78006 );
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
   {
217 217
 
218 218
     // ----- Tests the zlib
219
-    if (!function_exists('gzopen'))
219
+    if ( ! function_exists('gzopen'))
220 220
     {
221 221
       die('Abort '.basename(__FILE__).' : Missing zlib extensions');
222 222
     }
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
   // --------------------------------------------------------------------------------
275 275
   function create($p_filelist)
276 276
   {
277
-    $v_result=1;
277
+    $v_result = 1;
278 278
 
279 279
     // ----- Reset the error handler
280 280
     $this->privErrorReset();
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 
301 301
         // ----- Parse the options
302 302
         $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
303
-                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
303
+                                            array(PCLZIP_OPT_REMOVE_PATH => 'optional',
304 304
                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
305 305
                                                    PCLZIP_OPT_ADD_PATH => 'optional',
306 306
                                                    PCLZIP_CB_PRE_ADD => 'optional',
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 
387 387
     // ----- For each file in the list check the attributes
388 388
     $v_supported_attributes
389
-    = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
389
+    = array(PCLZIP_ATT_FILE_NAME => 'mandatory'
390 390
              ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
391 391
              ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
392 392
              ,PCLZIP_ATT_FILE_MTIME => 'optional'
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
   // --------------------------------------------------------------------------------
458 458
   function add($p_filelist)
459 459
   {
460
-    $v_result=1;
460
+    $v_result = 1;
461 461
 
462 462
     // ----- Reset the error handler
463 463
     $this->privErrorReset();
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 
484 484
         // ----- Parse the options
485 485
         $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
486
-                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
486
+                                            array(PCLZIP_OPT_REMOVE_PATH => 'optional',
487 487
                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
488 488
                                                    PCLZIP_OPT_ADD_PATH => 'optional',
489 489
                                                    PCLZIP_CB_PRE_ADD => 'optional',
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 
570 570
     // ----- For each file in the list check the attributes
571 571
     $v_supported_attributes
572
-    = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
572
+    = array(PCLZIP_ATT_FILE_NAME => 'mandatory'
573 573
              ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
574 574
              ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
575 575
              ,PCLZIP_ATT_FILE_MTIME => 'optional'
@@ -646,13 +646,13 @@  discard block
 block discarded – undo
646 646
   // --------------------------------------------------------------------------------
647 647
   function listContent()
648 648
   {
649
-    $v_result=1;
649
+    $v_result = 1;
650 650
 
651 651
     // ----- Reset the error handler
652 652
     $this->privErrorReset();
653 653
 
654 654
     // ----- Check archive
655
-    if (!$this->privCheckFormat()) {
655
+    if ( ! $this->privCheckFormat()) {
656 656
       return(0);
657 657
     }
658 658
 
@@ -703,13 +703,13 @@  discard block
 block discarded – undo
703 703
   // --------------------------------------------------------------------------------
704 704
   function extract()
705 705
   {
706
-    $v_result=1;
706
+    $v_result = 1;
707 707
 
708 708
     // ----- Reset the error handler
709 709
     $this->privErrorReset();
710 710
 
711 711
     // ----- Check archive
712
-    if (!$this->privCheckFormat()) {
712
+    if ( ! $this->privCheckFormat()) {
713 713
       return(0);
714 714
     }
715 715
 
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 
737 737
         // ----- Parse the options
738 738
         $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
739
-                                            array (PCLZIP_OPT_PATH => 'optional',
739
+                                            array(PCLZIP_OPT_PATH => 'optional',
740 740
                                                    PCLZIP_OPT_REMOVE_PATH => 'optional',
741 741
                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
742 742
                                                    PCLZIP_OPT_ADD_PATH => 'optional',
@@ -860,13 +860,13 @@  discard block
 block discarded – undo
860 860
   //function extractByIndex($p_index, options...)
861 861
   function extractByIndex($p_index)
862 862
   {
863
-    $v_result=1;
863
+    $v_result = 1;
864 864
 
865 865
     // ----- Reset the error handler
866 866
     $this->privErrorReset();
867 867
 
868 868
     // ----- Check archive
869
-    if (!$this->privCheckFormat()) {
869
+    if ( ! $this->privCheckFormat()) {
870 870
       return(0);
871 871
     }
872 872
 
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 
898 898
         // ----- Parse the options
899 899
         $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
900
-                                            array (PCLZIP_OPT_PATH => 'optional',
900
+                                            array(PCLZIP_OPT_PATH => 'optional',
901 901
                                                    PCLZIP_OPT_REMOVE_PATH => 'optional',
902 902
                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
903 903
                                                    PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
           }
934 934
           $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
935 935
         }
936
-        if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
936
+        if ( ! isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
937 937
           $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
938 938
         }
939 939
         else {
@@ -967,10 +967,10 @@  discard block
 block discarded – undo
967 967
     // ----- Trick
968 968
     // Here I want to reuse extractByRule(), so I need to parse the $p_index
969 969
     // with privParseOptions()
970
-    $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
970
+    $v_arg_trick = array(PCLZIP_OPT_BY_INDEX, $p_index);
971 971
     $v_options_trick = array();
972 972
     $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
973
-                                        array (PCLZIP_OPT_BY_INDEX => 'optional' ));
973
+                                        array(PCLZIP_OPT_BY_INDEX => 'optional'));
974 974
     if ($v_result != 1) {
975 975
         return 0;
976 976
     }
@@ -1009,13 +1009,13 @@  discard block
 block discarded – undo
1009 1009
   // --------------------------------------------------------------------------------
1010 1010
   function delete()
1011 1011
   {
1012
-    $v_result=1;
1012
+    $v_result = 1;
1013 1013
 
1014 1014
     // ----- Reset the error handler
1015 1015
     $this->privErrorReset();
1016 1016
 
1017 1017
     // ----- Check archive
1018
-    if (!$this->privCheckFormat()) {
1018
+    if ( ! $this->privCheckFormat()) {
1019 1019
       return(0);
1020 1020
     }
1021 1021
 
@@ -1032,10 +1032,10 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
       // ----- Parse the options
1034 1034
       $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1035
-                                        array (PCLZIP_OPT_BY_NAME => 'optional',
1035
+                                        array(PCLZIP_OPT_BY_NAME => 'optional',
1036 1036
                                                PCLZIP_OPT_BY_EREG => 'optional',
1037 1037
                                                PCLZIP_OPT_BY_PREG => 'optional',
1038
-                                               PCLZIP_OPT_BY_INDEX => 'optional' ));
1038
+                                               PCLZIP_OPT_BY_INDEX => 'optional'));
1039 1039
       if ($v_result != 1) {
1040 1040
           return 0;
1041 1041
       }
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
     $this->privDisableMagicQuotes();
1101 1101
 
1102 1102
     // ----- Check archive
1103
-    if (!$this->privCheckFormat()) {
1103
+    if ( ! $this->privCheckFormat()) {
1104 1104
       $this->privSwapBackMagicQuotes();
1105 1105
       return(0);
1106 1106
     }
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
 
1185 1185
       // ----- Check that $p_archive is a valid zip file
1186 1186
       // TBC : Should also check the archive format
1187
-      if (!is_file($p_archive)) {
1187
+      if ( ! is_file($p_archive)) {
1188 1188
         // ----- Error log
1189 1189
         PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1190 1190
         $v_result = PCLZIP_ERR_MISSING_FILE;
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
     $this->privErrorReset();
1231 1231
 
1232 1232
     // ----- Check archive
1233
-    if (!$this->privCheckFormat()) {
1233
+    if ( ! $this->privCheckFormat()) {
1234 1234
       return(0);
1235 1235
     }
1236 1236
 
@@ -1289,9 +1289,9 @@  discard block
 block discarded – undo
1289 1289
   // Description :
1290 1290
   // Parameters :
1291 1291
   // --------------------------------------------------------------------------------
1292
-  function errorName($p_with_code=false)
1292
+  function errorName($p_with_code = false)
1293 1293
   {
1294
-    $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
1294
+    $v_name = array(PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
1295 1295
                       PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
1296 1296
                       PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
1297 1297
                       PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
   // Description :
1336 1336
   // Parameters :
1337 1337
   // --------------------------------------------------------------------------------
1338
-  function errorInfo($p_full=false)
1338
+  function errorInfo($p_full = false)
1339 1339
   {
1340 1340
     if (PCLZIP_ERROR_EXTERNAL == 1) {
1341 1341
       return(PclErrorString());
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
   //   true on success,
1375 1375
   //   false on error, the error code is set.
1376 1376
   // --------------------------------------------------------------------------------
1377
-  function privCheckFormat($p_level=0)
1377
+  function privCheckFormat($p_level = 0)
1378 1378
   {
1379 1379
     $v_result = true;
1380 1380
 
@@ -1385,14 +1385,14 @@  discard block
 block discarded – undo
1385 1385
     $this->privErrorReset();
1386 1386
 
1387 1387
     // ----- Look if the file exits
1388
-    if (!is_file($this->zipname)) {
1388
+    if ( ! is_file($this->zipname)) {
1389 1389
       // ----- Error log
1390 1390
       PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1391 1391
       return(false);
1392 1392
     }
1393 1393
 
1394 1394
     // ----- Check that the file is readeable
1395
-    if (!is_readable($this->zipname)) {
1395
+    if ( ! is_readable($this->zipname)) {
1396 1396
       // ----- Error log
1397 1397
       PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1398 1398
       return(false);
@@ -1427,16 +1427,16 @@  discard block
 block discarded – undo
1427 1427
   //   1 on success.
1428 1428
   //   0 on failure.
1429 1429
   // --------------------------------------------------------------------------------
1430
-  function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
1430
+  function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options = false)
1431 1431
   {
1432
-    $v_result=1;
1432
+    $v_result = 1;
1433 1433
 
1434 1434
     // ----- Read the options
1435
-    $i=0;
1436
-    while ($i<$p_size) {
1435
+    $i = 0;
1436
+    while ($i < $p_size) {
1437 1437
 
1438 1438
       // ----- Check if the option is supported
1439
-      if (!isset($v_requested_options[$p_options_list[$i]])) {
1439
+      if ( ! isset($v_requested_options[$p_options_list[$i]])) {
1440 1440
         // ----- Error log
1441 1441
         PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1442 1442
 
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
         case PCLZIP_OPT_REMOVE_PATH :
1452 1452
         case PCLZIP_OPT_ADD_PATH :
1453 1453
           // ----- Check the number of parameters
1454
-          if (($i+1) >= $p_size) {
1454
+          if (($i + 1) >= $p_size) {
1455 1455
             // ----- Error log
1456 1456
             PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1457 1457
 
@@ -1460,13 +1460,13 @@  discard block
 block discarded – undo
1460 1460
           }
1461 1461
 
1462 1462
           // ----- Get the value
1463
-          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1463
+          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i + 1], FALSE);
1464 1464
           $i++;
1465 1465
         break;
1466 1466
 
1467 1467
         case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
1468 1468
           // ----- Check the number of parameters
1469
-          if (($i+1) >= $p_size) {
1469
+          if (($i + 1) >= $p_size) {
1470 1470
             PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1471 1471
             return PclZip::errorCode();
1472 1472
           }
@@ -1478,14 +1478,14 @@  discard block
 block discarded – undo
1478 1478
           }
1479 1479
 
1480 1480
           // ----- Check the value
1481
-          $v_value = $p_options_list[$i+1];
1482
-          if ((!is_integer($v_value)) || ($v_value<0)) {
1481
+          $v_value = $p_options_list[$i + 1];
1482
+          if (( ! is_integer($v_value)) || ($v_value < 0)) {
1483 1483
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1484 1484
             return PclZip::errorCode();
1485 1485
           }
1486 1486
 
1487 1487
           // ----- Get the value (and convert it in bytes)
1488
-          $v_result_list[$p_options_list[$i]] = $v_value*1048576;
1488
+          $v_result_list[$p_options_list[$i]] = $v_value * 1048576;
1489 1489
           $i++;
1490 1490
         break;
1491 1491
 
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
 
1517 1517
         case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
1518 1518
           // ----- Check the number of parameters
1519
-          if (($i+1) >= $p_size) {
1519
+          if (($i + 1) >= $p_size) {
1520 1520
             // ----- Error log
1521 1521
             PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1522 1522
 
@@ -1525,9 +1525,9 @@  discard block
 block discarded – undo
1525 1525
           }
1526 1526
 
1527 1527
           // ----- Get the value
1528
-          if (   is_string($p_options_list[$i+1])
1529
-              && ($p_options_list[$i+1] != '')) {
1530
-            $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1528
+          if (is_string($p_options_list[$i + 1])
1529
+              && ($p_options_list[$i + 1] != '')) {
1530
+            $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i + 1], FALSE);
1531 1531
             $i++;
1532 1532
           }
1533 1533
           else {
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
         // ----- Look for options that request an array of string for value
1538 1538
         case PCLZIP_OPT_BY_NAME :
1539 1539
           // ----- Check the number of parameters
1540
-          if (($i+1) >= $p_size) {
1540
+          if (($i + 1) >= $p_size) {
1541 1541
             // ----- Error log
1542 1542
             PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1543 1543
 
@@ -1546,11 +1546,11 @@  discard block
 block discarded – undo
1546 1546
           }
1547 1547
 
1548 1548
           // ----- Get the value
1549
-          if (is_string($p_options_list[$i+1])) {
1550
-              $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1549
+          if (is_string($p_options_list[$i + 1])) {
1550
+              $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i + 1];
1551 1551
           }
1552
-          else if (is_array($p_options_list[$i+1])) {
1553
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1552
+          else if (is_array($p_options_list[$i + 1])) {
1553
+              $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1];
1554 1554
           }
1555 1555
           else {
1556 1556
             // ----- Error log
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
         case PCLZIP_OPT_BY_PREG :
1571 1571
         //case PCLZIP_OPT_CRYPT :
1572 1572
           // ----- Check the number of parameters
1573
-          if (($i+1) >= $p_size) {
1573
+          if (($i + 1) >= $p_size) {
1574 1574
             // ----- Error log
1575 1575
             PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1576 1576
 
@@ -1579,8 +1579,8 @@  discard block
 block discarded – undo
1579 1579
           }
1580 1580
 
1581 1581
           // ----- Get the value
1582
-          if (is_string($p_options_list[$i+1])) {
1583
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1582
+          if (is_string($p_options_list[$i + 1])) {
1583
+              $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1];
1584 1584
           }
1585 1585
           else {
1586 1586
             // ----- Error log
@@ -1597,7 +1597,7 @@  discard block
 block discarded – undo
1597 1597
         case PCLZIP_OPT_ADD_COMMENT :
1598 1598
         case PCLZIP_OPT_PREPEND_COMMENT :
1599 1599
           // ----- Check the number of parameters
1600
-          if (($i+1) >= $p_size) {
1600
+          if (($i + 1) >= $p_size) {
1601 1601
             // ----- Error log
1602 1602
             PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
1603 1603
 			                     "Missing parameter value for option '"
@@ -1609,8 +1609,8 @@  discard block
 block discarded – undo
1609 1609
           }
1610 1610
 
1611 1611
           // ----- Get the value
1612
-          if (is_string($p_options_list[$i+1])) {
1613
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1612
+          if (is_string($p_options_list[$i + 1])) {
1613
+              $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1];
1614 1614
           }
1615 1615
           else {
1616 1616
             // ----- Error log
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
         // ----- Look for options that request an array of index
1629 1629
         case PCLZIP_OPT_BY_INDEX :
1630 1630
           // ----- Check the number of parameters
1631
-          if (($i+1) >= $p_size) {
1631
+          if (($i + 1) >= $p_size) {
1632 1632
             // ----- Error log
1633 1633
             PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1634 1634
 
@@ -1638,19 +1638,19 @@  discard block
 block discarded – undo
1638 1638
 
1639 1639
           // ----- Get the value
1640 1640
           $v_work_list = array();
1641
-          if (is_string($p_options_list[$i+1])) {
1641
+          if (is_string($p_options_list[$i + 1])) {
1642 1642
 
1643 1643
               // ----- Remove spaces
1644
-              $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
1644
+              $p_options_list[$i + 1] = strtr($p_options_list[$i + 1], ' ', '');
1645 1645
 
1646 1646
               // ----- Parse items
1647
-              $v_work_list = explode(",", $p_options_list[$i+1]);
1647
+              $v_work_list = explode(",", $p_options_list[$i + 1]);
1648 1648
           }
1649
-          else if (is_integer($p_options_list[$i+1])) {
1650
-              $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1649
+          else if (is_integer($p_options_list[$i + 1])) {
1650
+              $v_work_list[0] = $p_options_list[$i + 1].'-'.$p_options_list[$i + 1];
1651 1651
           }
1652
-          else if (is_array($p_options_list[$i+1])) {
1653
-              $v_work_list = $p_options_list[$i+1];
1652
+          else if (is_array($p_options_list[$i + 1])) {
1653
+              $v_work_list = $p_options_list[$i + 1];
1654 1654
           }
1655 1655
           else {
1656 1656
             // ----- Error log
@@ -1664,9 +1664,9 @@  discard block
 block discarded – undo
1664 1664
           // each index item in the list must be a couple with a start and
1665 1665
           // an end value : [0,3], [5-5], [8-10], ...
1666 1666
           // ----- Check the format of each item
1667
-          $v_sort_flag=false;
1668
-          $v_sort_value=0;
1669
-          for ($j=0; $j<sizeof($v_work_list); $j++) {
1667
+          $v_sort_flag = false;
1668
+          $v_sort_value = 0;
1669
+          for ($j = 0; $j < sizeof($v_work_list); $j++) {
1670 1670
               // ----- Explode the item
1671 1671
               $v_item_list = explode("-", $v_work_list[$j]);
1672 1672
               $v_size_item_list = sizeof($v_item_list);
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
 
1697 1697
               // ----- Look for list sort
1698 1698
               if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
1699
-                  $v_sort_flag=true;
1699
+                  $v_sort_flag = true;
1700 1700
 
1701 1701
                   // ----- TBC : An automatic sort should be writen ...
1702 1702
                   // ----- Error log
@@ -1730,7 +1730,7 @@  discard block
 block discarded – undo
1730 1730
         // ----- Look for options that request an octal value
1731 1731
         case PCLZIP_OPT_SET_CHMOD :
1732 1732
           // ----- Check the number of parameters
1733
-          if (($i+1) >= $p_size) {
1733
+          if (($i + 1) >= $p_size) {
1734 1734
             // ----- Error log
1735 1735
             PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1736 1736
 
@@ -1739,7 +1739,7 @@  discard block
 block discarded – undo
1739 1739
           }
1740 1740
 
1741 1741
           // ----- Get the value
1742
-          $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1742
+          $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1];
1743 1743
           $i++;
1744 1744
         break;
1745 1745
 
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
         case PCLZIP_CB_POST_LIST :
1756 1756
         */
1757 1757
           // ----- Check the number of parameters
1758
-          if (($i+1) >= $p_size) {
1758
+          if (($i + 1) >= $p_size) {
1759 1759
             // ----- Error log
1760 1760
             PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1761 1761
 
@@ -1764,10 +1764,10 @@  discard block
 block discarded – undo
1764 1764
           }
1765 1765
 
1766 1766
           // ----- Get the value
1767
-          $v_function_name = $p_options_list[$i+1];
1767
+          $v_function_name = $p_options_list[$i + 1];
1768 1768
 
1769 1769
           // ----- Check that the value is a valid existing function
1770
-          if (!function_exists($v_function_name)) {
1770
+          if ( ! function_exists($v_function_name)) {
1771 1771
             // ----- Error log
1772 1772
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1773 1773
 
@@ -1796,11 +1796,11 @@  discard block
 block discarded – undo
1796 1796
 
1797 1797
     // ----- Look for mandatory options
1798 1798
     if ($v_requested_options !== false) {
1799
-      for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1799
+      for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) {
1800 1800
         // ----- Look for mandatory option
1801 1801
         if ($v_requested_options[$key] == 'mandatory') {
1802 1802
           // ----- Look if present
1803
-          if (!isset($v_result_list[$key])) {
1803
+          if ( ! isset($v_result_list[$key])) {
1804 1804
             // ----- Error log
1805 1805
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1806 1806
 
@@ -1812,7 +1812,7 @@  discard block
 block discarded – undo
1812 1812
     }
1813 1813
 
1814 1814
     // ----- Look for default values
1815
-    if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1815
+    if ( ! isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1816 1816
 
1817 1817
     }
1818 1818
 
@@ -1829,7 +1829,7 @@  discard block
 block discarded – undo
1829 1829
   // --------------------------------------------------------------------------------
1830 1830
   function privOptionDefaultThreshold(&$p_options)
1831 1831
   {
1832
-    $v_result=1;
1832
+    $v_result = 1;
1833 1833
 
1834 1834
     if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
1835 1835
         || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
@@ -1842,16 +1842,16 @@  discard block
 block discarded – undo
1842 1842
     $v_memory_limit_int = (int) $v_memory_limit;
1843 1843
     $last = strtolower(substr($v_memory_limit, -1));
1844 1844
 
1845
-    if($last == 'g')
1845
+    if ($last == 'g')
1846 1846
         //$v_memory_limit_int = $v_memory_limit_int*1024*1024*1024;
1847
-        $v_memory_limit_int = $v_memory_limit_int*1073741824;
1848
-    if($last == 'm')
1847
+        $v_memory_limit_int = $v_memory_limit_int * 1073741824;
1848
+    if ($last == 'm')
1849 1849
         //$v_memory_limit_int = $v_memory_limit_int*1024*1024;
1850
-        $v_memory_limit_int = $v_memory_limit_int*1048576;
1851
-    if($last == 'k')
1852
-        $v_memory_limit_int = $v_memory_limit_int*1024;
1850
+        $v_memory_limit_int = $v_memory_limit_int * 1048576;
1851
+    if ($last == 'k')
1852
+        $v_memory_limit_int = $v_memory_limit_int * 1024;
1853 1853
 
1854
-    $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int*PCLZIP_TEMPORARY_FILE_RATIO);
1854
+    $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int * PCLZIP_TEMPORARY_FILE_RATIO);
1855 1855
 
1856 1856
 
1857 1857
     // ----- Sanity check : No threshold if value lower than 1M
@@ -1872,15 +1872,15 @@  discard block
 block discarded – undo
1872 1872
   //   1 on success.
1873 1873
   //   0 on failure.
1874 1874
   // --------------------------------------------------------------------------------
1875
-  function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
1875
+  function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options = false)
1876 1876
   {
1877
-    $v_result=1;
1877
+    $v_result = 1;
1878 1878
 
1879 1879
     // ----- For each file in the list check the attributes
1880 1880
     foreach ($p_file_list as $v_key => $v_value) {
1881 1881
 
1882 1882
       // ----- Check if the option is supported
1883
-      if (!isset($v_requested_options[$v_key])) {
1883
+      if ( ! isset($v_requested_options[$v_key])) {
1884 1884
         // ----- Error log
1885 1885
         PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1886 1886
 
@@ -1891,7 +1891,7 @@  discard block
 block discarded – undo
1891 1891
       // ----- Look for attribute
1892 1892
       switch ($v_key) {
1893 1893
         case PCLZIP_ATT_FILE_NAME :
1894
-          if (!is_string($v_value)) {
1894
+          if ( ! is_string($v_value)) {
1895 1895
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1896 1896
             return PclZip::errorCode();
1897 1897
           }
@@ -1906,7 +1906,7 @@  discard block
 block discarded – undo
1906 1906
         break;
1907 1907
 
1908 1908
         case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1909
-          if (!is_string($v_value)) {
1909
+          if ( ! is_string($v_value)) {
1910 1910
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1911 1911
             return PclZip::errorCode();
1912 1912
           }
@@ -1920,7 +1920,7 @@  discard block
 block discarded – undo
1920 1920
         break;
1921 1921
 
1922 1922
         case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1923
-          if (!is_string($v_value)) {
1923
+          if ( ! is_string($v_value)) {
1924 1924
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1925 1925
             return PclZip::errorCode();
1926 1926
           }
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
 
1936 1936
         // ----- Look for options that takes a string
1937 1937
         case PCLZIP_ATT_FILE_COMMENT :
1938
-          if (!is_string($v_value)) {
1938
+          if ( ! is_string($v_value)) {
1939 1939
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1940 1940
             return PclZip::errorCode();
1941 1941
           }
@@ -1944,7 +1944,7 @@  discard block
 block discarded – undo
1944 1944
         break;
1945 1945
 
1946 1946
         case PCLZIP_ATT_FILE_MTIME :
1947
-          if (!is_integer($v_value)) {
1947
+          if ( ! is_integer($v_value)) {
1948 1948
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
1949 1949
             return PclZip::errorCode();
1950 1950
           }
@@ -1967,11 +1967,11 @@  discard block
 block discarded – undo
1967 1967
 
1968 1968
       // ----- Look for mandatory options
1969 1969
       if ($v_requested_options !== false) {
1970
-        for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1970
+        for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) {
1971 1971
           // ----- Look for mandatory option
1972 1972
           if ($v_requested_options[$key] == 'mandatory') {
1973 1973
             // ----- Look if present
1974
-            if (!isset($p_file_list[$key])) {
1974
+            if ( ! isset($p_file_list[$key])) {
1975 1975
               PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1976 1976
               return PclZip::errorCode();
1977 1977
             }
@@ -2003,13 +2003,13 @@  discard block
 block discarded – undo
2003 2003
   // --------------------------------------------------------------------------------
2004 2004
   function privFileDescrExpand(&$p_filedescr_list, &$p_options)
2005 2005
   {
2006
-    $v_result=1;
2006
+    $v_result = 1;
2007 2007
 
2008 2008
     // ----- Create a result list
2009 2009
     $v_result_list = array();
2010 2010
 
2011 2011
     // ----- Look each entry
2012
-    for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
2012
+    for ($i = 0; $i < sizeof($p_filedescr_list); $i++) {
2013 2013
 
2014 2014
       // ----- Get filedescr
2015 2015
       $v_descr = $p_filedescr_list[$i];
@@ -2076,7 +2076,7 @@  discard block
 block discarded – undo
2076 2076
             // Because the name of the folder was changed, the name of the
2077 2077
             // files/sub-folders also change
2078 2078
             if (($v_descr['stored_filename'] != $v_descr['filename'])
2079
-                 && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2079
+                 && ( ! isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2080 2080
               if ($v_descr['stored_filename'] != '') {
2081 2081
                 $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2082 2082
               }
@@ -2128,7 +2128,7 @@  discard block
 block discarded – undo
2128 2128
   // --------------------------------------------------------------------------------
2129 2129
   function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
2130 2130
   {
2131
-    $v_result=1;
2131
+    $v_result = 1;
2132 2132
     $v_list_detail = array();
2133 2133
 
2134 2134
     // ----- Magic quotes trick
@@ -2163,11 +2163,11 @@  discard block
 block discarded – undo
2163 2163
   // --------------------------------------------------------------------------------
2164 2164
   function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
2165 2165
   {
2166
-    $v_result=1;
2166
+    $v_result = 1;
2167 2167
     $v_list_detail = array();
2168 2168
 
2169 2169
     // ----- Look if the archive exists or is empty
2170
-    if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2170
+    if (( ! is_file($this->zipname)) || (filesize($this->zipname) == 0))
2171 2171
     {
2172 2172
 
2173 2173
       // ----- Do a create
@@ -2180,7 +2180,7 @@  discard block
 block discarded – undo
2180 2180
     $this->privDisableMagicQuotes();
2181 2181
 
2182 2182
     // ----- Open the zip file
2183
-    if (($v_result=$this->privOpenFd('rb')) != 1)
2183
+    if (($v_result = $this->privOpenFd('rb')) != 1)
2184 2184
     {
2185 2185
       // ----- Magic quotes trick
2186 2186
       $this->privSwapBackMagicQuotes();
@@ -2261,7 +2261,7 @@  discard block
 block discarded – undo
2261 2261
     }
2262 2262
 
2263 2263
     // ----- Create the Central Dir files header
2264
-    for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2264
+    for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++)
2265 2265
     {
2266 2266
       // ----- Create the file header
2267 2267
       if ($v_header_list[$i]['status'] == 'ok') {
@@ -2294,10 +2294,10 @@  discard block
 block discarded – undo
2294 2294
     }
2295 2295
 
2296 2296
     // ----- Calculate the size of the central header
2297
-    $v_size = @ftell($this->zip_fd)-$v_offset;
2297
+    $v_size = @ftell($this->zip_fd) - $v_offset;
2298 2298
 
2299 2299
     // ----- Create the central dir footer
2300
-    if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2300
+    if (($v_result = $this->privWriteCentralHeader($v_count + $v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2301 2301
     {
2302 2302
       // ----- Reset the file list
2303 2303
       unset($v_header_list);
@@ -2342,7 +2342,7 @@  discard block
 block discarded – undo
2342 2342
   // --------------------------------------------------------------------------------
2343 2343
   function privOpenFd($p_mode)
2344 2344
   {
2345
-    $v_result=1;
2345
+    $v_result = 1;
2346 2346
 
2347 2347
     // ----- Look if already open
2348 2348
     if ($this->zip_fd != 0)
@@ -2376,7 +2376,7 @@  discard block
 block discarded – undo
2376 2376
   // --------------------------------------------------------------------------------
2377 2377
   function privCloseFd()
2378 2378
   {
2379
-    $v_result=1;
2379
+    $v_result = 1;
2380 2380
 
2381 2381
     if ($this->zip_fd != 0)
2382 2382
       @fclose($this->zip_fd);
@@ -2403,7 +2403,7 @@  discard block
 block discarded – undo
2403 2403
 //  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
2404 2404
   function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
2405 2405
   {
2406
-    $v_result=1;
2406
+    $v_result = 1;
2407 2407
 
2408 2408
     // ----- Add the files
2409 2409
     $v_header_list = array();
@@ -2417,7 +2417,7 @@  discard block
 block discarded – undo
2417 2417
     $v_offset = @ftell($this->zip_fd);
2418 2418
 
2419 2419
     // ----- Create the Central Dir files header
2420
-    for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2420
+    for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++)
2421 2421
     {
2422 2422
       // ----- Create the file header
2423 2423
       if ($v_header_list[$i]['status'] == 'ok') {
@@ -2439,7 +2439,7 @@  discard block
 block discarded – undo
2439 2439
     }
2440 2440
 
2441 2441
     // ----- Calculate the size of the central header
2442
-    $v_size = @ftell($this->zip_fd)-$v_offset;
2442
+    $v_size = @ftell($this->zip_fd) - $v_offset;
2443 2443
 
2444 2444
     // ----- Create the central dir footer
2445 2445
     if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
@@ -2467,14 +2467,14 @@  discard block
 block discarded – undo
2467 2467
   // --------------------------------------------------------------------------------
2468 2468
   function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
2469 2469
   {
2470
-    $v_result=1;
2470
+    $v_result = 1;
2471 2471
     $v_header = array();
2472 2472
 
2473 2473
     // ----- Recuperate the current number of elt in list
2474 2474
     $v_nb = sizeof($p_result_list);
2475 2475
 
2476 2476
     // ----- Loop on the files
2477
-    for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2477
+    for ($j = 0; ($j < sizeof($p_filedescr_list)) && ($v_result == 1); $j++) {
2478 2478
       // ----- Format the filename
2479 2479
       $p_filedescr_list[$j]['filename']
2480 2480
       = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
@@ -2487,8 +2487,8 @@  discard block
 block discarded – undo
2487 2487
       }
2488 2488
 
2489 2489
       // ----- Check the filename
2490
-      if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
2491
-          && (!file_exists($p_filedescr_list[$j]['filename']))) {
2490
+      if (($p_filedescr_list[$j]['type'] != 'virtual_file')
2491
+          && ( ! file_exists($p_filedescr_list[$j]['filename']))) {
2492 2492
         PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2493 2493
         return PclZip::errorCode();
2494 2494
       }
@@ -2497,11 +2497,11 @@  discard block
 block discarded – undo
2497 2497
       // or a dir with all its path removed
2498 2498
 //      if (   (is_file($p_filedescr_list[$j]['filename']))
2499 2499
 //          || (   is_dir($p_filedescr_list[$j]['filename'])
2500
-      if (   ($p_filedescr_list[$j]['type'] == 'file')
2500
+      if (($p_filedescr_list[$j]['type'] == 'file')
2501 2501
           || ($p_filedescr_list[$j]['type'] == 'virtual_file')
2502
-          || (   ($p_filedescr_list[$j]['type'] == 'folder')
2503
-              && (   !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2504
-                  || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2502
+          || (($p_filedescr_list[$j]['type'] == 'folder')
2503
+              && ( ! isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2504
+                  || ! $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2505 2505
           ) {
2506 2506
 
2507 2507
         // ----- Add the file
@@ -2529,7 +2529,7 @@  discard block
 block discarded – undo
2529 2529
   // --------------------------------------------------------------------------------
2530 2530
   function privAddFile($p_filedescr, &$p_header, &$p_options)
2531 2531
   {
2532
-    $v_result=1;
2532
+    $v_result = 1;
2533 2533
 
2534 2534
     // ----- Working variable
2535 2535
     $p_filename = $p_filedescr['filename'];
@@ -2574,13 +2574,13 @@  discard block
 block discarded – undo
2574 2574
     $p_header['index'] = -1;
2575 2575
 
2576 2576
     // ----- Look for regular file
2577
-    if ($p_filedescr['type']=='file') {
2577
+    if ($p_filedescr['type'] == 'file') {
2578 2578
       $p_header['external'] = 0x00000000;
2579 2579
       $p_header['size'] = filesize($p_filename);
2580 2580
     }
2581 2581
 
2582 2582
     // ----- Look for regular folder
2583
-    else if ($p_filedescr['type']=='folder') {
2583
+    else if ($p_filedescr['type'] == 'folder') {
2584 2584
       $p_header['external'] = 0x00000010;
2585 2585
       $p_header['mtime'] = filemtime($p_filename);
2586 2586
       $p_header['size'] = filesize($p_filename);
@@ -2654,10 +2654,10 @@  discard block
 block discarded – undo
2654 2654
       // ----- Look for a file
2655 2655
       if ($p_filedescr['type'] == 'file') {
2656 2656
         // ----- Look for using temporary file to zip
2657
-        if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
2657
+        if (( ! isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
2658 2658
             && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2659 2659
                 || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2660
-                    && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
2660
+                    && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])))) {
2661 2661
           $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2662 2662
           if ($v_result < PCLZIP_ERR_NO_ERROR) {
2663 2663
             return $v_result;
@@ -2757,7 +2757,7 @@  discard block
 block discarded – undo
2757 2757
         // ----- Set the file properties
2758 2758
         $p_header['size'] = 0;
2759 2759
         //$p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
2760
-        $p_header['external'] = 0x00000010;   // Value for a folder : to be checked
2760
+        $p_header['external'] = 0x00000010; // Value for a folder : to be checked
2761 2761
 
2762 2762
         // ----- Call the header generation
2763 2763
         if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
@@ -2800,7 +2800,7 @@  discard block
 block discarded – undo
2800 2800
   // --------------------------------------------------------------------------------
2801 2801
   function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
2802 2802
   {
2803
-    $v_result=PCLZIP_ERR_NO_ERROR;
2803
+    $v_result = PCLZIP_ERR_NO_ERROR;
2804 2804
 
2805 2805
     // ----- Working variable
2806 2806
     $p_filename = $p_filedescr['filename'];
@@ -2854,7 +2854,7 @@  discard block
 block discarded – undo
2854 2854
     $v_data_header['os'] = bin2hex($v_data_header['os']);
2855 2855
 
2856 2856
     // ----- Read the gzip file footer
2857
-    @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
2857
+    @fseek($v_file_compressed, filesize($v_gzip_temp_name) - 8);
2858 2858
     $v_binary_data = @fread($v_file_compressed, 8);
2859 2859
     $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
2860 2860
 
@@ -2862,7 +2862,7 @@  discard block
 block discarded – undo
2862 2862
     $p_header['compression'] = ord($v_data_header['cm']);
2863 2863
     //$p_header['mtime'] = $v_data_header['mtime'];
2864 2864
     $p_header['crc'] = $v_data_footer['crc'];
2865
-    $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
2865
+    $p_header['compressed_size'] = filesize($v_gzip_temp_name) - 18;
2866 2866
 
2867 2867
     // ----- Close the file
2868 2868
     @fclose($v_file_compressed);
@@ -2912,7 +2912,7 @@  discard block
 block discarded – undo
2912 2912
   // --------------------------------------------------------------------------------
2913 2913
   function privCalculateStoredFilename(&$p_filedescr, &$p_options)
2914 2914
   {
2915
-    $v_result=1;
2915
+    $v_result = 1;
2916 2916
 
2917 2917
     // ----- Working variables
2918 2918
     $p_filename = $p_filedescr['filename'];
@@ -2969,14 +2969,14 @@  discard block
 block discarded – undo
2969 2969
         if (substr($p_remove_dir, -1) != '/')
2970 2970
           $p_remove_dir .= "/";
2971 2971
 
2972
-        if (   (substr($p_filename, 0, 2) == "./")
2972
+        if ((substr($p_filename, 0, 2) == "./")
2973 2973
             || (substr($p_remove_dir, 0, 2) == "./")) {
2974 2974
 
2975
-          if (   (substr($p_filename, 0, 2) == "./")
2975
+          if ((substr($p_filename, 0, 2) == "./")
2976 2976
               && (substr($p_remove_dir, 0, 2) != "./")) {
2977 2977
             $p_remove_dir = "./".$p_remove_dir;
2978 2978
           }
2979
-          if (   (substr($p_filename, 0, 2) != "./")
2979
+          if ((substr($p_filename, 0, 2) != "./")
2980 2980
               && (substr($p_remove_dir, 0, 2) == "./")) {
2981 2981
             $p_remove_dir = substr($p_remove_dir, 2);
2982 2982
           }
@@ -3024,15 +3024,15 @@  discard block
 block discarded – undo
3024 3024
   // --------------------------------------------------------------------------------
3025 3025
   function privWriteFileHeader(&$p_header)
3026 3026
   {
3027
-    $v_result=1;
3027
+    $v_result = 1;
3028 3028
 
3029 3029
     // ----- Store the offset position of the file
3030 3030
     $p_header['offset'] = ftell($this->zip_fd);
3031 3031
 
3032 3032
     // ----- Transform UNIX mtime to DOS format mdate/mtime
3033 3033
     $v_date = getdate($p_header['mtime']);
3034
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3035
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3034
+    $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2;
3035
+    $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday'];
3036 3036
 
3037 3037
     // ----- Packed data
3038 3038
     $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
@@ -3069,7 +3069,7 @@  discard block
 block discarded – undo
3069 3069
   // --------------------------------------------------------------------------------
3070 3070
   function privWriteCentralFileHeader(&$p_header)
3071 3071
   {
3072
-    $v_result=1;
3072
+    $v_result = 1;
3073 3073
 
3074 3074
     // TBC
3075 3075
     //for(reset($p_header); $key = key($p_header); next($p_header)) {
@@ -3077,8 +3077,8 @@  discard block
 block discarded – undo
3077 3077
 
3078 3078
     // ----- Transform UNIX mtime to DOS format mdate/mtime
3079 3079
     $v_date = getdate($p_header['mtime']);
3080
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3081
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3080
+    $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2;
3081
+    $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday'];
3082 3082
 
3083 3083
 
3084 3084
     // ----- Packed data
@@ -3122,7 +3122,7 @@  discard block
 block discarded – undo
3122 3122
   // --------------------------------------------------------------------------------
3123 3123
   function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
3124 3124
   {
3125
-    $v_result=1;
3125
+    $v_result = 1;
3126 3126
 
3127 3127
     // ----- Packed data
3128 3128
     $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
@@ -3151,7 +3151,7 @@  discard block
 block discarded – undo
3151 3151
   // --------------------------------------------------------------------------------
3152 3152
   function privList(&$p_list)
3153 3153
   {
3154
-    $v_result=1;
3154
+    $v_result = 1;
3155 3155
 
3156 3156
     // ----- Magic quotes trick
3157 3157
     $this->privDisableMagicQuotes();
@@ -3191,7 +3191,7 @@  discard block
 block discarded – undo
3191 3191
     }
3192 3192
 
3193 3193
     // ----- Read each entry
3194
-    for ($i=0; $i<$v_central_dir['entries']; $i++)
3194
+    for ($i = 0; $i < $v_central_dir['entries']; $i++)
3195 3195
     {
3196 3196
       // ----- Read the file header
3197 3197
       if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
@@ -3238,7 +3238,7 @@  discard block
 block discarded – undo
3238 3238
   // --------------------------------------------------------------------------------
3239 3239
   function privConvertHeader2FileInfo($p_header, &$p_info)
3240 3240
   {
3241
-    $v_result=1;
3241
+    $v_result = 1;
3242 3242
 
3243 3243
     // ----- Get the interesting attributes
3244 3244
     $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
@@ -3249,7 +3249,7 @@  discard block
 block discarded – undo
3249 3249
     $p_info['compressed_size'] = $p_header['compressed_size'];
3250 3250
     $p_info['mtime'] = $p_header['mtime'];
3251 3251
     $p_info['comment'] = $p_header['comment'];
3252
-    $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
3252
+    $p_info['folder'] = (($p_header['external'] & 0x00000010) == 0x00000010);
3253 3253
     $p_info['index'] = $p_header['index'];
3254 3254
     $p_info['status'] = $p_header['status'];
3255 3255
     $p_info['crc'] = $p_header['crc'];
@@ -3277,16 +3277,16 @@  discard block
 block discarded – undo
3277 3277
   // --------------------------------------------------------------------------------
3278 3278
   function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3279 3279
   {
3280
-    $v_result=1;
3280
+    $v_result = 1;
3281 3281
 
3282 3282
     // ----- Magic quotes trick
3283 3283
     $this->privDisableMagicQuotes();
3284 3284
 
3285 3285
     // ----- Check the path
3286
-    if (   ($p_path == "")
3287
-	    || (   (substr($p_path, 0, 1) != "/")
3286
+    if (($p_path == "")
3287
+	    || ((substr($p_path, 0, 1) != "/")
3288 3288
 		    && (substr($p_path, 0, 3) != "../")
3289
-			&& (substr($p_path,1,2)!=":/")))
3289
+			&& (substr($p_path, 1, 2) != ":/")))
3290 3290
       $p_path = "./".$p_path;
3291 3291
 
3292 3292
     // ----- Reduce the path last (and duplicated) '/'
@@ -3295,7 +3295,7 @@  discard block
 block discarded – undo
3295 3295
       // ----- Look for the path end '/'
3296 3296
       while (substr($p_path, -1) == "/")
3297 3297
       {
3298
-        $p_path = substr($p_path, 0, strlen($p_path)-1);
3298
+        $p_path = substr($p_path, 0, strlen($p_path) - 1);
3299 3299
       }
3300 3300
     }
3301 3301
 
@@ -3329,7 +3329,7 @@  discard block
 block discarded – undo
3329 3329
 
3330 3330
     // ----- Read each entry
3331 3331
     $j_start = 0;
3332
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3332
+    for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++)
3333 3333
     {
3334 3334
 
3335 3335
       // ----- Read next Central dir entry
@@ -3368,17 +3368,17 @@  discard block
 block discarded – undo
3368 3368
       $v_extract = false;
3369 3369
 
3370 3370
       // ----- Look for extract by name rule
3371
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
3371
+      if ((isset($p_options[PCLZIP_OPT_BY_NAME]))
3372 3372
           && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3373 3373
 
3374 3374
           // ----- Look if the filename is in the list
3375
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3375
+          for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && ( ! $v_extract); $j++) {
3376 3376
 
3377 3377
               // ----- Look for a directory
3378 3378
               if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3379 3379
 
3380 3380
                   // ----- Look if the directory is in the filename path
3381
-                  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3381
+                  if ((strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3382 3382
                       && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3383 3383
                       $v_extract = true;
3384 3384
                   }
@@ -3403,7 +3403,7 @@  discard block
 block discarded – undo
3403 3403
       */
3404 3404
 
3405 3405
       // ----- Look for extract by preg rule
3406
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
3406
+      else if ((isset($p_options[PCLZIP_OPT_BY_PREG]))
3407 3407
                && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3408 3408
 
3409 3409
           if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
@@ -3412,20 +3412,20 @@  discard block
 block discarded – undo
3412 3412
       }
3413 3413
 
3414 3414
       // ----- Look for extract by index rule
3415
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3415
+      else if ((isset($p_options[PCLZIP_OPT_BY_INDEX]))
3416 3416
                && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3417 3417
 
3418 3418
           // ----- Look if the index is in the list
3419
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3419
+          for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && ( ! $v_extract); $j++) {
3420 3420
 
3421
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3421
+              if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3422 3422
                   $v_extract = true;
3423 3423
               }
3424
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3425
-                  $j_start = $j+1;
3424
+              if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3425
+                  $j_start = $j + 1;
3426 3426
               }
3427 3427
 
3428
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3428
+              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) {
3429 3429
                   break;
3430 3430
               }
3431 3431
           }
@@ -3437,14 +3437,14 @@  discard block
 block discarded – undo
3437 3437
       }
3438 3438
 
3439 3439
 	  // ----- Check compression method
3440
-	  if (   ($v_extract)
3441
-	      && (   ($v_header['compression'] != 8)
3440
+	  if (($v_extract)
3441
+	      && (($v_header['compression'] != 8)
3442 3442
 		      && ($v_header['compression'] != 0))) {
3443 3443
           $v_header['status'] = 'unsupported_compression';
3444 3444
 
3445 3445
           // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3446
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3447
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3446
+          if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3447
+		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3448 3448
 
3449 3449
               $this->privSwapBackMagicQuotes();
3450 3450
 
@@ -3462,8 +3462,8 @@  discard block
 block discarded – undo
3462 3462
           $v_header['status'] = 'unsupported_encryption';
3463 3463
 
3464 3464
           // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3465
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3466
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3465
+          if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3466
+		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3467 3467
 
3468 3468
               $this->privSwapBackMagicQuotes();
3469 3469
 
@@ -3544,7 +3544,7 @@  discard block
 block discarded – undo
3544 3544
           }
3545 3545
         }
3546 3546
         // ----- Look for extraction in standard output
3547
-        elseif (   (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3547
+        elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3548 3548
 		        && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3549 3549
           // ----- Extracting the file in standard output
3550 3550
           $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
@@ -3617,7 +3617,7 @@  discard block
 block discarded – undo
3617 3617
   // --------------------------------------------------------------------------------
3618 3618
   function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3619 3619
   {
3620
-    $v_result=1;
3620
+    $v_result = 1;
3621 3621
 
3622 3622
     // ----- Read the file header
3623 3623
     if (($v_result = $this->privReadFileHeader($v_header)) != 1)
@@ -3635,7 +3635,7 @@  discard block
 block discarded – undo
3635 3635
     // ----- Look for all path to remove
3636 3636
     if ($p_remove_all_path == true) {
3637 3637
         // ----- Look for folder entry that not need to be extracted
3638
-        if (($p_entry['external']&0x00000010)==0x00000010) {
3638
+        if (($p_entry['external'] & 0x00000010) == 0x00000010) {
3639 3639
 
3640 3640
             $p_entry['status'] = "filtered";
3641 3641
 
@@ -3736,8 +3736,8 @@  discard block
 block discarded – undo
3736 3736
         // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3737 3737
         // For historical reason first PclZip implementation does not stop
3738 3738
         // when this kind of error occurs.
3739
-        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3740
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3739
+        if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3740
+		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3741 3741
 
3742 3742
             PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3743 3743
 			                     "Filename '".$p_entry['filename']."' is "
@@ -3747,7 +3747,7 @@  discard block
 block discarded – undo
3747 3747
 		    }
3748 3748
       }
3749 3749
       // ----- Look if file is write protected
3750
-      else if (!is_writeable($p_entry['filename']))
3750
+      else if ( ! is_writeable($p_entry['filename']))
3751 3751
       {
3752 3752
 
3753 3753
         // ----- Change the file status
@@ -3756,8 +3756,8 @@  discard block
 block discarded – undo
3756 3756
         // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3757 3757
         // For historical reason first PclZip implementation does not stop
3758 3758
         // when this kind of error occurs.
3759
-        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3760
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3759
+        if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3760
+		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3761 3761
 
3762 3762
             PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3763 3763
 			                     "Filename '".$p_entry['filename']."' exists "
@@ -3771,8 +3771,8 @@  discard block
 block discarded – undo
3771 3771
       else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3772 3772
       {
3773 3773
         // ----- Change the file status
3774
-        if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3775
-		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3774
+        if ((isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3775
+		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER] === true)) {
3776 3776
 	  	  }
3777 3777
 		    else {
3778 3778
             $p_entry['status'] = "newer_exist";
@@ -3780,8 +3780,8 @@  discard block
 block discarded – undo
3780 3780
             // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3781 3781
             // For historical reason first PclZip implementation does not stop
3782 3782
             // when this kind of error occurs.
3783
-            if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3784
-		        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3783
+            if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3784
+		        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3785 3785
 
3786 3786
                 PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3787 3787
 			             "Newer version of '".$p_entry['filename']."' exists "
@@ -3797,14 +3797,14 @@  discard block
 block discarded – undo
3797 3797
 
3798 3798
     // ----- Check the directory availability and create it if necessary
3799 3799
     else {
3800
-      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3800
+      if ((($p_entry['external'] & 0x00000010) == 0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3801 3801
         $v_dir_to_check = $p_entry['filename'];
3802
-      else if (!strstr($p_entry['filename'], "/"))
3802
+      else if ( ! strstr($p_entry['filename'], "/"))
3803 3803
         $v_dir_to_check = "";
3804 3804
       else
3805 3805
         $v_dir_to_check = dirname($p_entry['filename']);
3806 3806
 
3807
-        if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3807
+        if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external'] & 0x00000010) == 0x00000010))) != 1) {
3808 3808
 
3809 3809
           // ----- Change the file status
3810 3810
           $p_entry['status'] = "path_creation_fail";
@@ -3820,7 +3820,7 @@  discard block
 block discarded – undo
3820 3820
     if ($p_entry['status'] == 'ok') {
3821 3821
 
3822 3822
       // ----- Do the extraction (if not a folder)
3823
-      if (!(($p_entry['external']&0x00000010)==0x00000010))
3823
+      if ( ! (($p_entry['external'] & 0x00000010) == 0x00000010))
3824 3824
       {
3825 3825
         // ----- Look for not compressed file
3826 3826
         if ($p_entry['compression'] == 0) {
@@ -3869,10 +3869,10 @@  discard block
 block discarded – undo
3869 3869
 
3870 3870
 
3871 3871
           // ----- Look for using temporary file to unzip
3872
-          if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
3872
+          if (( ! isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
3873 3873
               && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
3874 3874
                   || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3875
-                      && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
3875
+                      && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])))) {
3876 3876
             $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
3877 3877
             if ($v_result < PCLZIP_ERR_NO_ERROR) {
3878 3878
               return $v_result;
@@ -3966,7 +3966,7 @@  discard block
 block discarded – undo
3966 3966
   // --------------------------------------------------------------------------------
3967 3967
   function privExtractFileUsingTempFile(&$p_entry, &$p_options)
3968 3968
   {
3969
-    $v_result=1;
3969
+    $v_result = 1;
3970 3970
 
3971 3971
     // ----- Creates a temporary file
3972 3972
     $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
@@ -4042,7 +4042,7 @@  discard block
 block discarded – undo
4042 4042
   // --------------------------------------------------------------------------------
4043 4043
   function privExtractFileInOutput(&$p_entry, &$p_options)
4044 4044
   {
4045
-    $v_result=1;
4045
+    $v_result = 1;
4046 4046
 
4047 4047
     // ----- Read the file header
4048 4048
     if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
@@ -4091,7 +4091,7 @@  discard block
 block discarded – undo
4091 4091
     if ($p_entry['status'] == 'ok') {
4092 4092
 
4093 4093
       // ----- Do the extraction (if not a folder)
4094
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4094
+      if ( ! (($p_entry['external'] & 0x00000010) == 0x00000010)) {
4095 4095
         // ----- Look for not compressed file
4096 4096
         if ($p_entry['compressed_size'] == $p_entry['size']) {
4097 4097
 
@@ -4153,7 +4153,7 @@  discard block
 block discarded – undo
4153 4153
   // --------------------------------------------------------------------------------
4154 4154
   function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4155 4155
   {
4156
-    $v_result=1;
4156
+    $v_result = 1;
4157 4157
 
4158 4158
     // ----- Read the file header
4159 4159
     $v_header = array();
@@ -4203,7 +4203,7 @@  discard block
 block discarded – undo
4203 4203
     if ($p_entry['status'] == 'ok') {
4204 4204
 
4205 4205
       // ----- Do the extraction (if not a folder)
4206
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4206
+      if ( ! (($p_entry['external'] & 0x00000010) == 0x00000010)) {
4207 4207
         // ----- Look for not compressed file
4208 4208
   //      if ($p_entry['compressed_size'] == $p_entry['size'])
4209 4209
         if ($p_entry['compression'] == 0) {
@@ -4274,7 +4274,7 @@  discard block
 block discarded – undo
4274 4274
   // --------------------------------------------------------------------------------
4275 4275
   function privReadFileHeader(&$p_header)
4276 4276
   {
4277
-    $v_result=1;
4277
+    $v_result = 1;
4278 4278
 
4279 4279
     // ----- Read the 4 bytes signature
4280 4280
     $v_binary_data = @fread($this->zip_fd, 4);
@@ -4338,7 +4338,7 @@  discard block
 block discarded – undo
4338 4338
       // ----- Extract time
4339 4339
       $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4340 4340
       $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4341
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4341
+      $v_seconde = ($p_header['mtime'] & 0x001F) * 2;
4342 4342
 
4343 4343
       // ----- Extract date
4344 4344
       $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
@@ -4377,7 +4377,7 @@  discard block
 block discarded – undo
4377 4377
   // --------------------------------------------------------------------------------
4378 4378
   function privReadCentralFileHeader(&$p_header)
4379 4379
   {
4380
-    $v_result=1;
4380
+    $v_result = 1;
4381 4381
 
4382 4382
     // ----- Read the 4 bytes signature
4383 4383
     $v_binary_data = @fread($this->zip_fd, 4);
@@ -4441,7 +4441,7 @@  discard block
 block discarded – undo
4441 4441
       // ----- Extract time
4442 4442
       $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4443 4443
       $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4444
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4444
+      $v_seconde = ($p_header['mtime'] & 0x001F) * 2;
4445 4445
 
4446 4446
       // ----- Extract date
4447 4447
       $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
@@ -4485,7 +4485,7 @@  discard block
 block discarded – undo
4485 4485
   // --------------------------------------------------------------------------------
4486 4486
   function privCheckFileHeaders(&$p_local_header, &$p_central_header)
4487 4487
   {
4488
-    $v_result=1;
4488
+    $v_result = 1;
4489 4489
 
4490 4490
   	// ----- Check the static values
4491 4491
   	// TBC
@@ -4522,7 +4522,7 @@  discard block
 block discarded – undo
4522 4522
   // --------------------------------------------------------------------------------
4523 4523
   function privReadEndCentralDir(&$p_central_dir)
4524 4524
   {
4525
-    $v_result=1;
4525
+    $v_result = 1;
4526 4526
 
4527 4527
     // ----- Go to the end of the zip file
4528 4528
     $v_size = filesize($this->zipname);
@@ -4540,8 +4540,8 @@  discard block
 block discarded – undo
4540 4540
     // in this case the end of central dir is at 22 bytes of the file end
4541 4541
     $v_found = 0;
4542 4542
     if ($v_size > 26) {
4543
-      @fseek($this->zip_fd, $v_size-22);
4544
-      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4543
+      @fseek($this->zip_fd, $v_size - 22);
4544
+      if (($v_pos = @ftell($this->zip_fd)) != ($v_size - 22))
4545 4545
       {
4546 4546
         // ----- Error log
4547 4547
         PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
@@ -4563,12 +4563,12 @@  discard block
 block discarded – undo
4563 4563
     }
4564 4564
 
4565 4565
     // ----- Go back to the maximum possible size of the Central Dir End Record
4566
-    if (!$v_found) {
4566
+    if ( ! $v_found) {
4567 4567
       $v_maximum_size = 65557; // 0xFFFF + 22;
4568 4568
       if ($v_maximum_size > $v_size)
4569 4569
         $v_maximum_size = $v_size;
4570
-      @fseek($this->zip_fd, $v_size-$v_maximum_size);
4571
-      if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4570
+      @fseek($this->zip_fd, $v_size - $v_maximum_size);
4571
+      if (@ftell($this->zip_fd) != ($v_size - $v_maximum_size))
4572 4572
       {
4573 4573
         // ----- Error log
4574 4574
         PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
@@ -4589,7 +4589,7 @@  discard block
 block discarded – undo
4589 4589
         //$v_bytes = ($v_bytes << 8) | Ord($v_byte);
4590 4590
         // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
4591 4591
         // Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
4592
-        $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
4592
+        $v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
4593 4593
 
4594 4594
         // ----- Compare the bytes
4595 4595
         if ($v_bytes == 0x504b0506)
@@ -4679,11 +4679,11 @@  discard block
 block discarded – undo
4679 4679
   // --------------------------------------------------------------------------------
4680 4680
   function privDeleteByRule(&$p_result_list, &$p_options)
4681 4681
   {
4682
-    $v_result=1;
4682
+    $v_result = 1;
4683 4683
     $v_list_detail = array();
4684 4684
 
4685 4685
     // ----- Open the zip file
4686
-    if (($v_result=$this->privOpenFd('rb')) != 1)
4686
+    if (($v_result = $this->privOpenFd('rb')) != 1)
4687 4687
     {
4688 4688
       // ----- Return
4689 4689
       return $v_result;
@@ -4719,7 +4719,7 @@  discard block
 block discarded – undo
4719 4719
     // ----- Read each entry
4720 4720
     $v_header_list = array();
4721 4721
     $j_start = 0;
4722
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4722
+    for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++)
4723 4723
     {
4724 4724
 
4725 4725
       // ----- Read the file header
@@ -4740,21 +4740,21 @@  discard block
 block discarded – undo
4740 4740
       $v_found = false;
4741 4741
 
4742 4742
       // ----- Look for extract by name rule
4743
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
4743
+      if ((isset($p_options[PCLZIP_OPT_BY_NAME]))
4744 4744
           && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4745 4745
 
4746 4746
           // ----- Look if the filename is in the list
4747
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4747
+          for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && ( ! $v_found); $j++) {
4748 4748
 
4749 4749
               // ----- Look for a directory
4750 4750
               if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4751 4751
 
4752 4752
                   // ----- Look if the directory is in the filename path
4753
-                  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4753
+                  if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4754 4754
                       && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4755 4755
                       $v_found = true;
4756 4756
                   }
4757
-                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4757
+                  elseif ((($v_header_list[$v_nb_extracted]['external'] & 0x00000010) == 0x00000010) /* Indicates a folder */
4758 4758
                           && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4759 4759
                       $v_found = true;
4760 4760
                   }
@@ -4779,7 +4779,7 @@  discard block
 block discarded – undo
4779 4779
       */
4780 4780
 
4781 4781
       // ----- Look for extract by preg rule
4782
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
4782
+      else if ((isset($p_options[PCLZIP_OPT_BY_PREG]))
4783 4783
                && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4784 4784
 
4785 4785
           if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
@@ -4788,20 +4788,20 @@  discard block
 block discarded – undo
4788 4788
       }
4789 4789
 
4790 4790
       // ----- Look for extract by index rule
4791
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4791
+      else if ((isset($p_options[PCLZIP_OPT_BY_INDEX]))
4792 4792
                && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4793 4793
 
4794 4794
           // ----- Look if the index is in the list
4795
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4795
+          for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && ( ! $v_found); $j++) {
4796 4796
 
4797
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4797
+              if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4798 4798
                   $v_found = true;
4799 4799
               }
4800
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4801
-                  $j_start = $j+1;
4800
+              if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4801
+                  $j_start = $j + 1;
4802 4802
               }
4803 4803
 
4804
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4804
+              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) {
4805 4805
                   break;
4806 4806
               }
4807 4807
           }
@@ -4839,11 +4839,11 @@  discard block
 block discarded – undo
4839 4839
         }
4840 4840
 
4841 4841
         // ----- Look which file need to be kept
4842
-        for ($i=0; $i<sizeof($v_header_list); $i++) {
4842
+        for ($i = 0; $i < sizeof($v_header_list); $i++) {
4843 4843
 
4844 4844
             // ----- Calculate the position of the header
4845 4845
             @rewind($this->zip_fd);
4846
-            if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
4846
+            if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
4847 4847
                 // ----- Close the zip file
4848 4848
                 $this->privCloseFd();
4849 4849
                 $v_temp_zip->privCloseFd();
@@ -4902,7 +4902,7 @@  discard block
 block discarded – undo
4902 4902
         $v_offset = @ftell($v_temp_zip->zip_fd);
4903 4903
 
4904 4904
         // ----- Re-Create the Central Dir files header
4905
-        for ($i=0; $i<sizeof($v_header_list); $i++) {
4905
+        for ($i = 0; $i < sizeof($v_header_list); $i++) {
4906 4906
             // ----- Create the file header
4907 4907
             if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4908 4908
                 $v_temp_zip->privCloseFd();
@@ -4925,7 +4925,7 @@  discard block
 block discarded – undo
4925 4925
         }
4926 4926
 
4927 4927
         // ----- Calculate the size of the central header
4928
-        $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
4928
+        $v_size = @ftell($v_temp_zip->zip_fd) - $v_offset;
4929 4929
 
4930 4930
         // ----- Create the central dir footer
4931 4931
         if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
@@ -4987,15 +4987,15 @@  discard block
 block discarded – undo
4987 4987
   //    1 : OK
4988 4988
   //   -1 : Unable to create directory
4989 4989
   // --------------------------------------------------------------------------------
4990
-  function privDirCheck($p_dir, $p_is_dir=false)
4990
+  function privDirCheck($p_dir, $p_is_dir = false)
4991 4991
   {
4992 4992
     $v_result = 1;
4993 4993
 
4994 4994
 
4995 4995
     // ----- Remove the final '/'
4996
-    if (($p_is_dir) && (substr($p_dir, -1)=='/'))
4996
+    if (($p_is_dir) && (substr($p_dir, -1) == '/'))
4997 4997
     {
4998
-      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
4998
+      $p_dir = substr($p_dir, 0, strlen($p_dir) - 1);
4999 4999
     }
5000 5000
 
5001 5001
     // ----- Check the directory availability
@@ -5021,7 +5021,7 @@  discard block
 block discarded – undo
5021 5021
     }
5022 5022
 
5023 5023
     // ----- Create the directory
5024
-    if (!@mkdir($p_dir, 0777))
5024
+    if ( ! @mkdir($p_dir, 0777))
5025 5025
     {
5026 5026
       // ----- Error log
5027 5027
       PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
@@ -5044,10 +5044,10 @@  discard block
 block discarded – undo
5044 5044
   // --------------------------------------------------------------------------------
5045 5045
   function privMerge(&$p_archive_to_add)
5046 5046
   {
5047
-    $v_result=1;
5047
+    $v_result = 1;
5048 5048
 
5049 5049
     // ----- Look if the archive_to_add exists
5050
-    if (!is_file($p_archive_to_add->zipname))
5050
+    if ( ! is_file($p_archive_to_add->zipname))
5051 5051
     {
5052 5052
 
5053 5053
       // ----- Nothing to merge, so merge is a success
@@ -5058,7 +5058,7 @@  discard block
 block discarded – undo
5058 5058
     }
5059 5059
 
5060 5060
     // ----- Look if the archive exists
5061
-    if (!is_file($this->zipname))
5061
+    if ( ! is_file($this->zipname))
5062 5062
     {
5063 5063
 
5064 5064
       // ----- Do a duplicate
@@ -5069,7 +5069,7 @@  discard block
 block discarded – undo
5069 5069
     }
5070 5070
 
5071 5071
     // ----- Open the zip file
5072
-    if (($v_result=$this->privOpenFd('rb')) != 1)
5072
+    if (($v_result = $this->privOpenFd('rb')) != 1)
5073 5073
     {
5074 5074
       // ----- Return
5075 5075
       return $v_result;
@@ -5087,7 +5087,7 @@  discard block
 block discarded – undo
5087 5087
     @rewind($this->zip_fd);
5088 5088
 
5089 5089
     // ----- Open the archive_to_add file
5090
-    if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5090
+    if (($v_result = $p_archive_to_add->privOpenFd('rb')) != 1)
5091 5091
     {
5092 5092
       $this->privCloseFd();
5093 5093
 
@@ -5171,7 +5171,7 @@  discard block
 block discarded – undo
5171 5171
     $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
5172 5172
 
5173 5173
     // ----- Calculate the size of the (new) central header
5174
-    $v_size = @ftell($v_zip_temp_fd)-$v_offset;
5174
+    $v_size = @ftell($v_zip_temp_fd) - $v_offset;
5175 5175
 
5176 5176
     // ----- Swap the file descriptor
5177 5177
     // Here is a trick : I swap the temporary fd with the zip fd, in order to use
@@ -5181,7 +5181,7 @@  discard block
 block discarded – undo
5181 5181
     $v_zip_temp_fd = $v_swap;
5182 5182
 
5183 5183
     // ----- Create the central dir footer
5184
-    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5184
+    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries'] + $v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5185 5185
     {
5186 5186
       $this->privCloseFd();
5187 5187
       $p_archive_to_add->privCloseFd();
@@ -5229,10 +5229,10 @@  discard block
 block discarded – undo
5229 5229
   // --------------------------------------------------------------------------------
5230 5230
   function privDuplicate($p_archive_filename)
5231 5231
   {
5232
-    $v_result=1;
5232
+    $v_result = 1;
5233 5233
 
5234 5234
     // ----- Look if the $p_archive_filename exists
5235
-    if (!is_file($p_archive_filename))
5235
+    if ( ! is_file($p_archive_filename))
5236 5236
     {
5237 5237
 
5238 5238
       // ----- Nothing to duplicate, so duplicate is a success.
@@ -5243,7 +5243,7 @@  discard block
 block discarded – undo
5243 5243
     }
5244 5244
 
5245 5245
     // ----- Open the zip file
5246
-    if (($v_result=$this->privOpenFd('wb')) != 1)
5246
+    if (($v_result = $this->privOpenFd('wb')) != 1)
5247 5247
     {
5248 5248
       // ----- Return
5249 5249
       return $v_result;
@@ -5287,7 +5287,7 @@  discard block
 block discarded – undo
5287 5287
   // Description :
5288 5288
   // Parameters :
5289 5289
   // --------------------------------------------------------------------------------
5290
-  function privErrorLog($p_error_code=0, $p_error_string='')
5290
+  function privErrorLog($p_error_code = 0, $p_error_string = '')
5291 5291
   {
5292 5292
     if (PCLZIP_ERROR_EXTERNAL == 1) {
5293 5293
       PclError($p_error_code, $p_error_string);
@@ -5324,11 +5324,11 @@  discard block
 block discarded – undo
5324 5324
   // --------------------------------------------------------------------------------
5325 5325
   function privDisableMagicQuotes()
5326 5326
   {
5327
-    $v_result=1;
5327
+    $v_result = 1;
5328 5328
 
5329 5329
     // ----- Look if function exists
5330
-    if (   (!function_exists("get_magic_quotes_runtime"))
5331
-	    || (!function_exists("set_magic_quotes_runtime"))) {
5330
+    if (( ! function_exists("get_magic_quotes_runtime"))
5331
+	    || ( ! function_exists("set_magic_quotes_runtime"))) {
5332 5332
       return $v_result;
5333 5333
 	}
5334 5334
 
@@ -5358,11 +5358,11 @@  discard block
 block discarded – undo
5358 5358
   // --------------------------------------------------------------------------------
5359 5359
   function privSwapBackMagicQuotes()
5360 5360
   {
5361
-    $v_result=1;
5361
+    $v_result = 1;
5362 5362
 
5363 5363
     // ----- Look if function exists
5364
-    if (   (!function_exists("get_magic_quotes_runtime"))
5365
-	    || (!function_exists("set_magic_quotes_runtime"))) {
5364
+    if (( ! function_exists("get_magic_quotes_runtime"))
5365
+	    || ( ! function_exists("set_magic_quotes_runtime"))) {
5366 5366
       return $v_result;
5367 5367
 	}
5368 5368
 
@@ -5402,7 +5402,7 @@  discard block
 block discarded – undo
5402 5402
 
5403 5403
       // ----- Study directories from last to first
5404 5404
       $v_skip = 0;
5405
-      for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5405
+      for ($i = sizeof($v_list) - 1; $i >= 0; $i--) {
5406 5406
         // ----- Look for current path
5407 5407
         if ($v_list[$i] == ".") {
5408 5408
           // ----- Ignore this directory
@@ -5423,7 +5423,7 @@  discard block
 block discarded – undo
5423 5423
 		    }
5424 5424
 		  }
5425 5425
 		  // ----- Last '/' i.e. indicates a directory
5426
-		  else if ($i == (sizeof($v_list)-1)) {
5426
+		  else if ($i == (sizeof($v_list) - 1)) {
5427 5427
             $v_result = $v_list[$i];
5428 5428
 		  }
5429 5429
 		  // ----- Double '/' inside the path
@@ -5438,7 +5438,7 @@  discard block
 block discarded – undo
5438 5438
 		    $v_skip--;
5439 5439
 		  }
5440 5440
 		  else {
5441
-            $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5441
+            $v_result = $v_list[$i].($i != (sizeof($v_list) - 1) ? "/".$v_result : "");
5442 5442
 		  }
5443 5443
         }
5444 5444
       }
@@ -5477,12 +5477,12 @@  discard block
 block discarded – undo
5477 5477
     $v_result = 1;
5478 5478
 
5479 5479
     // ----- Look for path beginning by ./
5480
-    if (   ($p_dir == '.')
5481
-        || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5480
+    if (($p_dir == '.')
5481
+        || ((strlen($p_dir) >= 2) && (substr($p_dir, 0, 2) == './'))) {
5482 5482
       $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5483 5483
     }
5484
-    if (   ($p_path == '.')
5485
-        || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5484
+    if (($p_path == '.')
5485
+        || ((strlen($p_path) >= 2) && (substr($p_path, 0, 2) == './'))) {
5486 5486
       $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5487 5487
     }
5488 5488
 
@@ -5508,7 +5508,7 @@  discard block
 block discarded – undo
5508 5508
       }
5509 5509
 
5510 5510
       // ----- Compare the items
5511
-      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
5511
+      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ($v_list_path[$j] != '')) {
5512 5512
         $v_result = 0;
5513 5513
       }
5514 5514
 
@@ -5549,11 +5549,11 @@  discard block
 block discarded – undo
5549 5549
   //             3 : src & dest gzip
5550 5550
   // Return Values :
5551 5551
   // --------------------------------------------------------------------------------
5552
-  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5552
+  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode = 0)
5553 5553
   {
5554 5554
     $v_result = 1;
5555 5555
 
5556
-    if ($p_mode==0)
5556
+    if ($p_mode == 0)
5557 5557
     {
5558 5558
       while ($p_size != 0)
5559 5559
       {
@@ -5563,7 +5563,7 @@  discard block
 block discarded – undo
5563 5563
         $p_size -= $v_read_size;
5564 5564
       }
5565 5565
     }
5566
-    else if ($p_mode==1)
5566
+    else if ($p_mode == 1)
5567 5567
     {
5568 5568
       while ($p_size != 0)
5569 5569
       {
@@ -5573,7 +5573,7 @@  discard block
 block discarded – undo
5573 5573
         $p_size -= $v_read_size;
5574 5574
       }
5575 5575
     }
5576
-    else if ($p_mode==2)
5576
+    else if ($p_mode == 2)
5577 5577
     {
5578 5578
       while ($p_size != 0)
5579 5579
       {
@@ -5583,7 +5583,7 @@  discard block
 block discarded – undo
5583 5583
         $p_size -= $v_read_size;
5584 5584
       }
5585 5585
     }
5586
-    else if ($p_mode==3)
5586
+    else if ($p_mode == 3)
5587 5587
     {
5588 5588
       while ($p_size != 0)
5589 5589
       {
@@ -5616,13 +5616,13 @@  discard block
 block discarded – undo
5616 5616
     $v_result = 1;
5617 5617
 
5618 5618
     // ----- Try to rename the files
5619
-    if (!@rename($p_src, $p_dest)) {
5619
+    if ( ! @rename($p_src, $p_dest)) {
5620 5620
 
5621 5621
       // ----- Try to copy & unlink the src
5622
-      if (!@copy($p_src, $p_dest)) {
5622
+      if ( ! @copy($p_src, $p_dest)) {
5623 5623
         $v_result = 0;
5624 5624
       }
5625
-      else if (!@unlink($p_src)) {
5625
+      else if ( ! @unlink($p_src)) {
5626 5626
         $v_result = 0;
5627 5627
       }
5628 5628
     }
@@ -5647,7 +5647,7 @@  discard block
 block discarded – undo
5647 5647
     $v_list = get_defined_constants();
5648 5648
     for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5649 5649
 	    $v_prefix = substr($v_key, 0, 10);
5650
-	    if ((   ($v_prefix == 'PCLZIP_OPT')
5650
+	    if ((($v_prefix == 'PCLZIP_OPT')
5651 5651
            || ($v_prefix == 'PCLZIP_CB_')
5652 5652
            || ($v_prefix == 'PCLZIP_ATT'))
5653 5653
 	        && ($v_list[$v_key] == $p_option)) {
@@ -5672,15 +5672,15 @@  discard block
 block discarded – undo
5672 5672
   // Return Values :
5673 5673
   //   The path translated.
5674 5674
   // --------------------------------------------------------------------------------
5675
-  function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
5675
+  function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true)
5676 5676
   {
5677 5677
     if (stristr(php_uname(), 'windows')) {
5678 5678
       // ----- Look for potential disk letter
5679 5679
       if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5680
-          $p_path = substr($p_path, $v_position+1);
5680
+          $p_path = substr($p_path, $v_position + 1);
5681 5681
       }
5682 5682
       // ----- Change potential windows directory separator
5683
-      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5683
+      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) {
5684 5684
           $p_path = strtr($p_path, '\\', '/');
5685 5685
       }
5686 5686
     }
Please login to merge, or discard this patch.
Braces   +115 added lines, -158 removed lines patch added patch discarded remove patch
@@ -328,8 +328,7 @@  discard block
 block discarded – undo
328 328
         // ----- Look for the optional second argument
329 329
         if ($v_size == 2) {
330 330
           $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
331
-        }
332
-        else if ($v_size > 2) {
331
+        } else if ($v_size > 2) {
333 332
           PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
334 333
 		                       "Invalid number / type of arguments");
335 334
           return 0;
@@ -378,8 +377,7 @@  discard block
 block discarded – undo
378 377
       foreach ($v_string_list as $v_string) {
379 378
         if ($v_string != '') {
380 379
           $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
381
-        }
382
-        else {
380
+        } else {
383 381
         }
384 382
       }
385 383
     }
@@ -513,8 +511,7 @@  discard block
 block discarded – undo
513 511
         // ----- Look for the optional second argument
514 512
         if ($v_size == 2) {
515 513
           $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
516
-        }
517
-        else if ($v_size > 2) {
514
+        } else if ($v_size > 2) {
518 515
           // ----- Error log
519 516
           PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
520 517
 
@@ -790,8 +787,7 @@  discard block
 block discarded – undo
790 787
         // ----- Look for the optional second argument
791 788
         if ($v_size == 2) {
792 789
           $v_remove_path = $v_arg_list[1];
793
-        }
794
-        else if ($v_size > 2) {
790
+        } else if ($v_size > 2) {
795 791
           // ----- Error log
796 792
           PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
797 793
 
@@ -935,8 +931,7 @@  discard block
 block discarded – undo
935 931
         }
936 932
         if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
937 933
           $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
938
-        }
939
-        else {
934
+        } else {
940 935
         }
941 936
       }
942 937
 
@@ -951,8 +946,7 @@  discard block
 block discarded – undo
951 946
         // ----- Look for the optional second argument
952 947
         if ($v_size == 2) {
953 948
           $v_remove_path = $v_arg_list[1];
954
-        }
955
-        else if ($v_size > 2) {
949
+        } else if ($v_size > 2) {
956 950
           // ----- Error log
957 951
           PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
958 952
 
@@ -1188,8 +1182,7 @@  discard block
 block discarded – undo
1188 1182
         // ----- Error log
1189 1183
         PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1190 1184
         $v_result = PCLZIP_ERR_MISSING_FILE;
1191
-      }
1192
-      else {
1185
+      } else {
1193 1186
         // ----- Duplicate the archive
1194 1187
         $v_result = $this->privDuplicate($p_archive);
1195 1188
       }
@@ -1277,8 +1270,7 @@  discard block
 block discarded – undo
1277 1270
   {
1278 1271
     if (PCLZIP_ERROR_EXTERNAL == 1) {
1279 1272
       return(PclErrorCode());
1280
-    }
1281
-    else {
1273
+    } else {
1282 1274
       return($this->error_code);
1283 1275
     }
1284 1276
   }
@@ -1316,15 +1308,13 @@  discard block
 block discarded – undo
1316 1308
 
1317 1309
     if (isset($v_name[$this->error_code])) {
1318 1310
       $v_value = $v_name[$this->error_code];
1319
-    }
1320
-    else {
1311
+    } else {
1321 1312
       $v_value = 'NoName';
1322 1313
     }
1323 1314
 
1324 1315
     if ($p_with_code) {
1325 1316
       return($v_value.' ('.$this->error_code.')');
1326
-    }
1327
-    else {
1317
+    } else {
1328 1318
       return($v_value);
1329 1319
     }
1330 1320
   }
@@ -1339,12 +1329,10 @@  discard block
 block discarded – undo
1339 1329
   {
1340 1330
     if (PCLZIP_ERROR_EXTERNAL == 1) {
1341 1331
       return(PclErrorString());
1342
-    }
1343
-    else {
1332
+    } else {
1344 1333
       if ($p_full) {
1345 1334
         return($this->errorName(true)." : ".$this->error_string);
1346
-      }
1347
-      else {
1335
+      } else {
1348 1336
         return($this->error_string." [code ".$this->error_code."]");
1349 1337
       }
1350 1338
     }
@@ -1529,8 +1517,7 @@  discard block
 block discarded – undo
1529 1517
               && ($p_options_list[$i+1] != '')) {
1530 1518
             $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1531 1519
             $i++;
1532
-          }
1533
-          else {
1520
+          } else {
1534 1521
           }
1535 1522
         break;
1536 1523
 
@@ -1548,11 +1535,9 @@  discard block
 block discarded – undo
1548 1535
           // ----- Get the value
1549 1536
           if (is_string($p_options_list[$i+1])) {
1550 1537
               $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1551
-          }
1552
-          else if (is_array($p_options_list[$i+1])) {
1538
+          } else if (is_array($p_options_list[$i+1])) {
1553 1539
               $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1554
-          }
1555
-          else {
1540
+          } else {
1556 1541
             // ----- Error log
1557 1542
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1558 1543
 
@@ -1581,8 +1566,7 @@  discard block
 block discarded – undo
1581 1566
           // ----- Get the value
1582 1567
           if (is_string($p_options_list[$i+1])) {
1583 1568
               $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1584
-          }
1585
-          else {
1569
+          } else {
1586 1570
             // ----- Error log
1587 1571
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1588 1572
 
@@ -1611,8 +1595,7 @@  discard block
 block discarded – undo
1611 1595
           // ----- Get the value
1612 1596
           if (is_string($p_options_list[$i+1])) {
1613 1597
               $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1614
-          }
1615
-          else {
1598
+          } else {
1616 1599
             // ----- Error log
1617 1600
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
1618 1601
 			                     "Wrong parameter value for option '"
@@ -1645,14 +1628,11 @@  discard block
 block discarded – undo
1645 1628
 
1646 1629
               // ----- Parse items
1647 1630
               $v_work_list = explode(",", $p_options_list[$i+1]);
1648
-          }
1649
-          else if (is_integer($p_options_list[$i+1])) {
1631
+          } else if (is_integer($p_options_list[$i+1])) {
1650 1632
               $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1651
-          }
1652
-          else if (is_array($p_options_list[$i+1])) {
1633
+          } else if (is_array($p_options_list[$i+1])) {
1653 1634
               $v_work_list = $p_options_list[$i+1];
1654
-          }
1655
-          else {
1635
+          } else {
1656 1636
             // ----- Error log
1657 1637
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1658 1638
 
@@ -1679,13 +1659,11 @@  discard block
 block discarded – undo
1679 1659
                   // ----- Set the option value
1680 1660
                   $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1681 1661
                   $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
1682
-              }
1683
-              elseif ($v_size_item_list == 2) {
1662
+              } elseif ($v_size_item_list == 2) {
1684 1663
                   // ----- Set the option value
1685 1664
                   $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1686 1665
                   $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
1687
-              }
1688
-              else {
1666
+              } else {
1689 1667
                   // ----- Error log
1690 1668
                   PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1691 1669
 
@@ -1842,14 +1820,17 @@  discard block
 block discarded – undo
1842 1820
     $v_memory_limit_int = (int) $v_memory_limit;
1843 1821
     $last = strtolower(substr($v_memory_limit, -1));
1844 1822
 
1845
-    if($last == 'g')
1846
-        //$v_memory_limit_int = $v_memory_limit_int*1024*1024*1024;
1823
+    if($last == 'g') {
1824
+            //$v_memory_limit_int = $v_memory_limit_int*1024*1024*1024;
1847 1825
         $v_memory_limit_int = $v_memory_limit_int*1073741824;
1848
-    if($last == 'm')
1849
-        //$v_memory_limit_int = $v_memory_limit_int*1024*1024;
1826
+    }
1827
+    if($last == 'm') {
1828
+            //$v_memory_limit_int = $v_memory_limit_int*1024*1024;
1850 1829
         $v_memory_limit_int = $v_memory_limit_int*1048576;
1851
-    if($last == 'k')
1852
-        $v_memory_limit_int = $v_memory_limit_int*1024;
1830
+    }
1831
+    if($last == 'k') {
1832
+            $v_memory_limit_int = $v_memory_limit_int*1024;
1833
+    }
1853 1834
 
1854 1835
     $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int*PCLZIP_TEMPORARY_FILE_RATIO);
1855 1836
 
@@ -2022,15 +2003,12 @@  discard block
 block discarded – undo
2022 2003
       if (file_exists($v_descr['filename'])) {
2023 2004
         if (@is_file($v_descr['filename'])) {
2024 2005
           $v_descr['type'] = 'file';
2025
-        }
2026
-        else if (@is_dir($v_descr['filename'])) {
2006
+        } else if (@is_dir($v_descr['filename'])) {
2027 2007
           $v_descr['type'] = 'folder';
2028
-        }
2029
-        else if (@is_link($v_descr['filename'])) {
2008
+        } else if (@is_link($v_descr['filename'])) {
2030 2009
           // skip
2031 2010
           continue;
2032
-        }
2033
-        else {
2011
+        } else {
2034 2012
           // skip
2035 2013
           continue;
2036 2014
         }
@@ -2079,8 +2057,7 @@  discard block
 block discarded – undo
2079 2057
                  && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2080 2058
               if ($v_descr['stored_filename'] != '') {
2081 2059
                 $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2082
-              }
2083
-              else {
2060
+              } else {
2084 2061
                 $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
2085 2062
               }
2086 2063
             }
@@ -2089,8 +2066,7 @@  discard block
 block discarded – undo
2089 2066
           }
2090 2067
 
2091 2068
           @closedir($v_folder_handler);
2092
-        }
2093
-        else {
2069
+        } else {
2094 2070
           // TBC : unable to open folder in read mode
2095 2071
         }
2096 2072
 
@@ -2103,8 +2079,7 @@  discard block
 block discarded – undo
2103 2079
 
2104 2080
           // ----- Concat the resulting list
2105 2081
           $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2106
-        }
2107
-        else {
2082
+        } else {
2108 2083
         }
2109 2084
 
2110 2085
         // ----- Free local array
@@ -2378,8 +2353,9 @@  discard block
 block discarded – undo
2378 2353
   {
2379 2354
     $v_result=1;
2380 2355
 
2381
-    if ($this->zip_fd != 0)
2382
-      @fclose($this->zip_fd);
2356
+    if ($this->zip_fd != 0) {
2357
+          @fclose($this->zip_fd);
2358
+    }
2383 2359
     $this->zip_fd = 0;
2384 2360
 
2385 2361
     // ----- Return
@@ -2596,11 +2572,9 @@  discard block
 block discarded – undo
2596 2572
     // ----- Look for filetime
2597 2573
     if (isset($p_filedescr['mtime'])) {
2598 2574
       $p_header['mtime'] = $p_filedescr['mtime'];
2599
-    }
2600
-    else if ($p_filedescr['type'] == 'virtual_file') {
2575
+    } else if ($p_filedescr['type'] == 'virtual_file') {
2601 2576
       $p_header['mtime'] = time();
2602
-    }
2603
-    else {
2577
+    } else {
2604 2578
       $p_header['mtime'] = filemtime($p_filename);
2605 2579
     }
2606 2580
 
@@ -2608,8 +2582,7 @@  discard block
 block discarded – undo
2608 2582
     if (isset($p_filedescr['comment'])) {
2609 2583
       $p_header['comment_len'] = strlen($p_filedescr['comment']);
2610 2584
       $p_header['comment'] = $p_filedescr['comment'];
2611
-    }
2612
-    else {
2585
+    } else {
2613 2586
       $p_header['comment_len'] = 0;
2614 2587
       $p_header['comment'] = '';
2615 2588
     }
@@ -2918,20 +2891,17 @@  discard block
 block discarded – undo
2918 2891
     $p_filename = $p_filedescr['filename'];
2919 2892
     if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
2920 2893
       $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2921
-    }
2922
-    else {
2894
+    } else {
2923 2895
       $p_add_dir = '';
2924 2896
     }
2925 2897
     if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
2926 2898
       $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2927
-    }
2928
-    else {
2899
+    } else {
2929 2900
       $p_remove_dir = '';
2930 2901
     }
2931 2902
     if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
2932 2903
       $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2933
-    }
2934
-    else {
2904
+    } else {
2935 2905
       $p_remove_all_dir = 0;
2936 2906
     }
2937 2907
 
@@ -2954,8 +2924,7 @@  discard block
 block discarded – undo
2954 2924
           $v_dir = $v_path_info['dirname'].'/';
2955 2925
         }
2956 2926
         $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2957
-      }
2958
-      else {
2927
+      } else {
2959 2928
         // ----- Calculate the stored filename
2960 2929
         $v_stored_filename = $p_filename;
2961 2930
       }
@@ -2966,8 +2935,9 @@  discard block
 block discarded – undo
2966 2935
       }
2967 2936
       // ----- Look for partial path remove
2968 2937
       else if ($p_remove_dir != "") {
2969
-        if (substr($p_remove_dir, -1) != '/')
2970
-          $p_remove_dir .= "/";
2938
+        if (substr($p_remove_dir, -1) != '/') {
2939
+                  $p_remove_dir .= "/";
2940
+        }
2971 2941
 
2972 2942
         if (   (substr($p_filename, 0, 2) == "./")
2973 2943
             || (substr($p_remove_dir, 0, 2) == "./")) {
@@ -2987,8 +2957,7 @@  discard block
 block discarded – undo
2987 2957
         if ($v_compare > 0) {
2988 2958
           if ($v_compare == 2) {
2989 2959
             $v_stored_filename = "";
2990
-          }
2991
-          else {
2960
+          } else {
2992 2961
             $v_stored_filename = substr($v_stored_filename,
2993 2962
                                         strlen($p_remove_dir));
2994 2963
           }
@@ -3000,10 +2969,11 @@  discard block
 block discarded – undo
3000 2969
 
3001 2970
       // ----- Look for path to add
3002 2971
       if ($p_add_dir != "") {
3003
-        if (substr($p_add_dir, -1) == "/")
3004
-          $v_stored_filename = $p_add_dir.$v_stored_filename;
3005
-        else
3006
-          $v_stored_filename = $p_add_dir."/".$v_stored_filename;
2972
+        if (substr($p_add_dir, -1) == "/") {
2973
+                  $v_stored_filename = $p_add_dir.$v_stored_filename;
2974
+        } else {
2975
+                  $v_stored_filename = $p_add_dir."/".$v_stored_filename;
2976
+        }
3007 2977
       }
3008 2978
     }
3009 2979
 
@@ -3286,8 +3256,9 @@  discard block
 block discarded – undo
3286 3256
     if (   ($p_path == "")
3287 3257
 	    || (   (substr($p_path, 0, 1) != "/")
3288 3258
 		    && (substr($p_path, 0, 3) != "../")
3289
-			&& (substr($p_path,1,2)!=":/")))
3290
-      $p_path = "./".$p_path;
3259
+			&& (substr($p_path,1,2)!=":/"))) {
3260
+          $p_path = "./".$p_path;
3261
+    }
3291 3262
 
3292 3263
     // ----- Reduce the path last (and duplicated) '/'
3293 3264
     if (($p_path != "./") && ($p_path != "/"))
@@ -3773,8 +3744,7 @@  discard block
 block discarded – undo
3773 3744
         // ----- Change the file status
3774 3745
         if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3775 3746
 		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3776
-	  	  }
3777
-		    else {
3747
+	  	  } else {
3778 3748
             $p_entry['status'] = "newer_exist";
3779 3749
 
3780 3750
             // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
@@ -3790,19 +3760,19 @@  discard block
 block discarded – undo
3790 3760
                 return PclZip::errorCode();
3791 3761
 		      }
3792 3762
 		    }
3793
-      }
3794
-      else {
3763
+      } else {
3795 3764
       }
3796 3765
     }
3797 3766
 
3798 3767
     // ----- Check the directory availability and create it if necessary
3799 3768
     else {
3800
-      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3801
-        $v_dir_to_check = $p_entry['filename'];
3802
-      else if (!strstr($p_entry['filename'], "/"))
3803
-        $v_dir_to_check = "";
3804
-      else
3805
-        $v_dir_to_check = dirname($p_entry['filename']);
3769
+      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) {
3770
+              $v_dir_to_check = $p_entry['filename'];
3771
+      } else if (!strstr($p_entry['filename'], "/")) {
3772
+              $v_dir_to_check = "";
3773
+      } else {
3774
+              $v_dir_to_check = dirname($p_entry['filename']);
3775
+      }
3806 3776
 
3807 3777
         if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3808 3778
 
@@ -3858,8 +3828,7 @@  discard block
 block discarded – undo
3858 3828
           touch($p_entry['filename'], $p_entry['mtime']);
3859 3829
 
3860 3830
 
3861
-        }
3862
-        else {
3831
+        } else {
3863 3832
           // ----- TBC
3864 3833
           // Need to be finished
3865 3834
           if (($p_entry['flag'] & 1) == 1) {
@@ -4101,8 +4070,7 @@  discard block
 block discarded – undo
4101 4070
           // ----- Send the file to the output
4102 4071
           echo $v_buffer;
4103 4072
           unset($v_buffer);
4104
-        }
4105
-        else {
4073
+        } else {
4106 4074
 
4107 4075
           // ----- Read the compressed file in a buffer (one shot)
4108 4076
           $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
@@ -4210,8 +4178,7 @@  discard block
 block discarded – undo
4210 4178
 
4211 4179
           // ----- Reading the file
4212 4180
           $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4213
-        }
4214
-        else {
4181
+        } else {
4215 4182
 
4216 4183
           // ----- Reading the file
4217 4184
           $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
@@ -4223,8 +4190,7 @@  discard block
 block discarded – undo
4223 4190
         }
4224 4191
 
4225 4192
         // ----- Trace
4226
-      }
4227
-      else {
4193
+      } else {
4228 4194
           // TBC : error : can not extract a folder in a string
4229 4195
       }
4230 4196
 
@@ -4316,8 +4282,7 @@  discard block
 block discarded – undo
4316 4282
     // ----- Get extra_fields
4317 4283
     if ($v_data['extra_len'] != 0) {
4318 4284
       $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4319
-    }
4320
-    else {
4285
+    } else {
4321 4286
       $p_header['extra'] = '';
4322 4287
     }
4323 4288
 
@@ -4348,8 +4313,7 @@  discard block
 block discarded – undo
4348 4313
       // ----- Get UNIX date format
4349 4314
       $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4350 4315
 
4351
-    }
4352
-    else
4316
+    } else
4353 4317
     {
4354 4318
       $p_header['mtime'] = time();
4355 4319
     }
@@ -4414,22 +4378,25 @@  discard block
 block discarded – undo
4414 4378
     $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
4415 4379
 
4416 4380
     // ----- Get filename
4417
-    if ($p_header['filename_len'] != 0)
4418
-      $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4419
-    else
4420
-      $p_header['filename'] = '';
4381
+    if ($p_header['filename_len'] != 0) {
4382
+          $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4383
+    } else {
4384
+          $p_header['filename'] = '';
4385
+    }
4421 4386
 
4422 4387
     // ----- Get extra
4423
-    if ($p_header['extra_len'] != 0)
4424
-      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4425
-    else
4426
-      $p_header['extra'] = '';
4388
+    if ($p_header['extra_len'] != 0) {
4389
+          $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4390
+    } else {
4391
+          $p_header['extra'] = '';
4392
+    }
4427 4393
 
4428 4394
     // ----- Get comment
4429
-    if ($p_header['comment_len'] != 0)
4430
-      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4431
-    else
4432
-      $p_header['comment'] = '';
4395
+    if ($p_header['comment_len'] != 0) {
4396
+          $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4397
+    } else {
4398
+          $p_header['comment'] = '';
4399
+    }
4433 4400
 
4434 4401
     // ----- Extract properties
4435 4402
 
@@ -4451,8 +4418,7 @@  discard block
 block discarded – undo
4451 4418
       // ----- Get UNIX date format
4452 4419
       $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4453 4420
 
4454
-    }
4455
-    else
4421
+    } else
4456 4422
     {
4457 4423
       $p_header['mtime'] = time();
4458 4424
     }
@@ -4565,8 +4531,9 @@  discard block
 block discarded – undo
4565 4531
     // ----- Go back to the maximum possible size of the Central Dir End Record
4566 4532
     if (!$v_found) {
4567 4533
       $v_maximum_size = 65557; // 0xFFFF + 22;
4568
-      if ($v_maximum_size > $v_size)
4569
-        $v_maximum_size = $v_size;
4534
+      if ($v_maximum_size > $v_size) {
4535
+              $v_maximum_size = $v_size;
4536
+      }
4570 4537
       @fseek($this->zip_fd, $v_size-$v_maximum_size);
4571 4538
       if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4572 4539
       {
@@ -4651,9 +4618,9 @@  discard block
 block discarded – undo
4651 4618
     // ----- Get comment
4652 4619
     if ($v_data['comment_size'] != 0) {
4653 4620
       $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4621
+    } else {
4622
+          $p_central_dir['comment'] = '';
4654 4623
     }
4655
-    else
4656
-      $p_central_dir['comment'] = '';
4657 4624
 
4658 4625
     $p_central_dir['entries'] = $v_data['entries'];
4659 4626
     $p_central_dir['disk_entries'] = $v_data['disk_entries'];
@@ -4753,8 +4720,7 @@  discard block
 block discarded – undo
4753 4720
                   if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4754 4721
                       && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4755 4722
                       $v_found = true;
4756
-                  }
4757
-                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4723
+                  } elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4758 4724
                           && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4759 4725
                       $v_found = true;
4760 4726
                   }
@@ -4805,8 +4771,7 @@  discard block
 block discarded – undo
4805 4771
                   break;
4806 4772
               }
4807 4773
           }
4808
-      }
4809
-      else {
4774
+      } else {
4810 4775
       	$v_found = true;
4811 4776
       }
4812 4777
 
@@ -4814,8 +4779,7 @@  discard block
 block discarded – undo
4814 4779
       if ($v_found)
4815 4780
       {
4816 4781
         unset($v_header_list[$v_nb_extracted]);
4817
-      }
4818
-      else
4782
+      } else
4819 4783
       {
4820 4784
         $v_nb_extracted++;
4821 4785
       }
@@ -5291,8 +5255,7 @@  discard block
 block discarded – undo
5291 5255
   {
5292 5256
     if (PCLZIP_ERROR_EXTERNAL == 1) {
5293 5257
       PclError($p_error_code, $p_error_string);
5294
-    }
5295
-    else {
5258
+    } else {
5296 5259
       $this->error_code = $p_error_code;
5297 5260
       $this->error_string = $p_error_string;
5298 5261
     }
@@ -5308,8 +5271,7 @@  discard block
 block discarded – undo
5308 5271
   {
5309 5272
     if (PCLZIP_ERROR_EXTERNAL == 1) {
5310 5273
       PclErrorReset();
5311
-    }
5312
-    else {
5274
+    } else {
5313 5275
       $this->error_code = 0;
5314 5276
       $this->error_string = '';
5315 5277
     }
@@ -5407,11 +5369,9 @@  discard block
 block discarded – undo
5407 5369
         if ($v_list[$i] == ".") {
5408 5370
           // ----- Ignore this directory
5409 5371
           // Should be the first $i=0, but no check is done
5410
-        }
5411
-        else if ($v_list[$i] == "..") {
5372
+        } else if ($v_list[$i] == "..") {
5412 5373
 		  $v_skip++;
5413
-        }
5414
-        else if ($v_list[$i] == "") {
5374
+        } else if ($v_list[$i] == "") {
5415 5375
 		  // ----- First '/' i.e. root slash
5416 5376
 		  if ($i == 0) {
5417 5377
             $v_result = "/".$v_result;
@@ -5431,13 +5391,11 @@  discard block
 block discarded – undo
5431 5391
             // ----- Ignore only the double '//' in path,
5432 5392
             // but not the first and last '/'
5433 5393
 		  }
5434
-        }
5435
-        else {
5394
+        } else {
5436 5395
 		  // ----- Look for item to skip
5437 5396
 		  if ($v_skip > 0) {
5438 5397
 		    $v_skip--;
5439
-		  }
5440
-		  else {
5398
+		  } else {
5441 5399
             $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5442 5400
 		  }
5443 5401
         }
@@ -5520,14 +5478,17 @@  discard block
 block discarded – undo
5520 5478
     // ----- Look if everything seems to be the same
5521 5479
     if ($v_result) {
5522 5480
       // ----- Skip all the empty items
5523
-      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5524
-      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5481
+      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) {
5482
+      	$j++;
5483
+      }
5484
+      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) {
5485
+      	$i++;
5486
+      }
5525 5487
 
5526 5488
       if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5527 5489
         // ----- There are exactly the same
5528 5490
         $v_result = 2;
5529
-      }
5530
-      else if ($i < $v_list_dir_size) {
5491
+      } else if ($i < $v_list_dir_size) {
5531 5492
         // ----- The path is shorter than the dir
5532 5493
         $v_result = 0;
5533 5494
       }
@@ -5562,8 +5523,7 @@  discard block
 block discarded – undo
5562 5523
         @fwrite($p_dest, $v_buffer, $v_read_size);
5563 5524
         $p_size -= $v_read_size;
5564 5525
       }
5565
-    }
5566
-    else if ($p_mode==1)
5526
+    } else if ($p_mode==1)
5567 5527
     {
5568 5528
       while ($p_size != 0)
5569 5529
       {
@@ -5572,8 +5532,7 @@  discard block
 block discarded – undo
5572 5532
         @fwrite($p_dest, $v_buffer, $v_read_size);
5573 5533
         $p_size -= $v_read_size;
5574 5534
       }
5575
-    }
5576
-    else if ($p_mode==2)
5535
+    } else if ($p_mode==2)
5577 5536
     {
5578 5537
       while ($p_size != 0)
5579 5538
       {
@@ -5582,8 +5541,7 @@  discard block
 block discarded – undo
5582 5541
         @gzwrite($p_dest, $v_buffer, $v_read_size);
5583 5542
         $p_size -= $v_read_size;
5584 5543
       }
5585
-    }
5586
-    else if ($p_mode==3)
5544
+    } else if ($p_mode==3)
5587 5545
     {
5588 5546
       while ($p_size != 0)
5589 5547
       {
@@ -5621,8 +5579,7 @@  discard block
 block discarded – undo
5621 5579
       // ----- Try to copy & unlink the src
5622 5580
       if (!@copy($p_src, $p_dest)) {
5623 5581
         $v_result = 0;
5624
-      }
5625
-      else if (!@unlink($p_src)) {
5582
+      } else if (!@unlink($p_src)) {
5626 5583
         $v_result = 0;
5627 5584
       }
5628 5585
     }
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-filesystem-ftpsockets.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -359,7 +359,7 @@
 block discarded – undo
359 359
 
360 360
 	/**
361 361
 	 * @param string $file
362
-	 * @return int
362
+	 * @return false|string
363 363
 	 */
364 364
 	public function size($file) {
365 365
 		return $this->ftp->filesize($file);
Please login to merge, or discard this patch.
Braces   +90 added lines, -65 removed lines patch added patch discarded remove patch
@@ -36,26 +36,30 @@  discard block
 block discarded – undo
36 36
 		}
37 37
 		$this->ftp = new ftp();
38 38
 
39
-		if ( empty($opt['port']) )
40
-			$this->options['port'] = 21;
41
-		else
42
-			$this->options['port'] = (int) $opt['port'];
39
+		if ( empty($opt['port']) ) {
40
+					$this->options['port'] = 21;
41
+		} else {
42
+					$this->options['port'] = (int) $opt['port'];
43
+		}
43 44
 
44
-		if ( empty($opt['hostname']) )
45
-			$this->errors->add('empty_hostname', __('FTP hostname is required'));
46
-		else
47
-			$this->options['hostname'] = $opt['hostname'];
45
+		if ( empty($opt['hostname']) ) {
46
+					$this->errors->add('empty_hostname', __('FTP hostname is required'));
47
+		} else {
48
+					$this->options['hostname'] = $opt['hostname'];
49
+		}
48 50
 
49 51
 		// Check if the options provided are OK.
50
-		if ( empty ($opt['username']) )
51
-			$this->errors->add('empty_username', __('FTP username is required'));
52
-		else
53
-			$this->options['username'] = $opt['username'];
54
-
55
-		if ( empty ($opt['password']) )
56
-			$this->errors->add('empty_password', __('FTP password is required'));
57
-		else
58
-			$this->options['password'] = $opt['password'];
52
+		if ( empty ($opt['username']) ) {
53
+					$this->errors->add('empty_username', __('FTP username is required'));
54
+		} else {
55
+					$this->options['username'] = $opt['username'];
56
+		}
57
+
58
+		if ( empty ($opt['password']) ) {
59
+					$this->errors->add('empty_password', __('FTP password is required'));
60
+		} else {
61
+					$this->options['password'] = $opt['password'];
62
+		}
59 63
 	}
60 64
 
61 65
 	/**
@@ -64,8 +68,9 @@  discard block
 block discarded – undo
64 68
 	 * @return bool
65 69
 	 */
66 70
 	public function connect() {
67
-		if ( ! $this->ftp )
68
-			return false;
71
+		if ( ! $this->ftp ) {
72
+					return false;
73
+		}
69 74
 
70 75
 		$this->ftp->setTimeout(FS_CONNECT_TIMEOUT);
71 76
 
@@ -116,8 +121,9 @@  discard block
 block discarded – undo
116 121
 	 *                      or if the file doesn't exist.
117 122
 	 */
118 123
 	public function get_contents( $file ) {
119
-		if ( ! $this->exists($file) )
120
-			return false;
124
+		if ( ! $this->exists($file) ) {
125
+					return false;
126
+		}
121 127
 
122 128
 		$temp = wp_tempnam( $file );
123 129
 
@@ -142,8 +148,9 @@  discard block
 block discarded – undo
142 148
 		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
143 149
 		$contents = '';
144 150
 
145
-		while ( ! feof($temphandle) )
146
-			$contents .= fread($temphandle, 8192);
151
+		while ( ! feof($temphandle) ) {
152
+					$contents .= fread($temphandle, 8192);
153
+		}
147 154
 
148 155
 		fclose($temphandle);
149 156
 		unlink($temp);
@@ -209,8 +216,9 @@  discard block
 block discarded – undo
209 216
 	 */
210 217
 	public function cwd() {
211 218
 		$cwd = $this->ftp->pwd();
212
-		if ( $cwd )
213
-			$cwd = trailingslashit($cwd);
219
+		if ( $cwd ) {
220
+					$cwd = trailingslashit($cwd);
221
+		}
214 222
 		return $cwd;
215 223
 	}
216 224
 
@@ -234,19 +242,21 @@  discard block
 block discarded – undo
234 242
 	 */
235 243
 	public function chmod($file, $mode = false, $recursive = false ) {
236 244
 		if ( ! $mode ) {
237
-			if ( $this->is_file($file) )
238
-				$mode = FS_CHMOD_FILE;
239
-			elseif ( $this->is_dir($file) )
240
-				$mode = FS_CHMOD_DIR;
241
-			else
242
-				return false;
245
+			if ( $this->is_file($file) ) {
246
+							$mode = FS_CHMOD_FILE;
247
+			} elseif ( $this->is_dir($file) ) {
248
+							$mode = FS_CHMOD_DIR;
249
+			} else {
250
+							return false;
251
+			}
243 252
 		}
244 253
 
245 254
 		// chmod any sub-objects if recursive.
246 255
 		if ( $recursive && $this->is_dir($file) ) {
247 256
 			$filelist = $this->dirlist($file);
248
-			foreach ( (array)$filelist as $filename => $filemeta )
249
-				$this->chmod($file . '/' . $filename, $mode, $recursive);
257
+			foreach ( (array)$filelist as $filename => $filemeta ) {
258
+							$this->chmod($file . '/' . $filename, $mode, $recursive);
259
+			}
250 260
 		}
251 261
 
252 262
 		// chmod the file or directory
@@ -296,12 +306,14 @@  discard block
 block discarded – undo
296 306
 	 * @return bool
297 307
 	 */
298 308
 	public function copy($source, $destination, $overwrite = false, $mode = false) {
299
-		if ( ! $overwrite && $this->exists($destination) )
300
-			return false;
309
+		if ( ! $overwrite && $this->exists($destination) ) {
310
+					return false;
311
+		}
301 312
 
302 313
 		$content = $this->get_contents($source);
303
-		if ( false === $content )
304
-			return false;
314
+		if ( false === $content ) {
315
+					return false;
316
+		}
305 317
 
306 318
 		return $this->put_contents($destination, $content, $mode);
307 319
 	}
@@ -327,12 +339,15 @@  discard block
 block discarded – undo
327 339
 	 * @return bool
328 340
 	 */
329 341
 	public function delete($file, $recursive = false, $type = false) {
330
-		if ( empty($file) )
331
-			return false;
332
-		if ( 'f' == $type || $this->is_file($file) )
333
-			return $this->ftp->delete($file);
334
-		if ( !$recursive )
335
-			return $this->ftp->rmdir($file);
342
+		if ( empty($file) ) {
343
+					return false;
344
+		}
345
+		if ( 'f' == $type || $this->is_file($file) ) {
346
+					return $this->ftp->delete($file);
347
+		}
348
+		if ( !$recursive ) {
349
+					return $this->ftp->rmdir($file);
350
+		}
336 351
 
337 352
 		return $this->ftp->mdel($file);
338 353
 	}
@@ -361,10 +376,12 @@  discard block
 block discarded – undo
361 376
 	 * @return bool
362 377
 	 */
363 378
 	public function is_file($file) {
364
-		if ( $this->is_dir($file) )
365
-			return false;
366
-		if ( $this->exists($file) )
367
-			return true;
379
+		if ( $this->is_dir($file) ) {
380
+					return false;
381
+		}
382
+		if ( $this->exists($file) ) {
383
+					return true;
384
+		}
368 385
 		return false;
369 386
 	}
370 387
 
@@ -454,13 +471,16 @@  discard block
 block discarded – undo
454 471
 	 */
455 472
 	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false ) {
456 473
 		$path = untrailingslashit($path);
457
-		if ( empty($path) )
458
-			return false;
474
+		if ( empty($path) ) {
475
+					return false;
476
+		}
459 477
 
460
-		if ( ! $this->ftp->mkdir($path) )
461
-			return false;
462
-		if ( ! $chmod )
463
-			$chmod = FS_CHMOD_DIR;
478
+		if ( ! $this->ftp->mkdir($path) ) {
479
+					return false;
480
+		}
481
+		if ( ! $chmod ) {
482
+					$chmod = FS_CHMOD_DIR;
483
+		}
464 484
 		$this->chmod($path, $chmod);
465 485
 		return true;
466 486
 	}
@@ -504,25 +524,30 @@  discard block
 block discarded – undo
504 524
 		$ret = array();
505 525
 		foreach ( $list as $struc ) {
506 526
 
507
-			if ( '.' == $struc['name'] || '..' == $struc['name'] )
508
-				continue;
527
+			if ( '.' == $struc['name'] || '..' == $struc['name'] ) {
528
+							continue;
529
+			}
509 530
 
510
-			if ( ! $include_hidden && '.' == $struc['name'][0] )
511
-				continue;
531
+			if ( ! $include_hidden && '.' == $struc['name'][0] ) {
532
+							continue;
533
+			}
512 534
 
513
-			if ( $limit_file && $struc['name'] != $limit_file )
514
-				continue;
535
+			if ( $limit_file && $struc['name'] != $limit_file ) {
536
+							continue;
537
+			}
515 538
 
516 539
 			if ( 'd' == $struc['type'] ) {
517
-				if ( $recursive )
518
-					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
519
-				else
520
-					$struc['files'] = array();
540
+				if ( $recursive ) {
541
+									$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
542
+				} else {
543
+									$struc['files'] = array();
544
+				}
521 545
 			}
522 546
 
523 547
 			// Replace symlinks formatted as "source -> target" with just the source name
524
-			if ( $struc['islink'] )
525
-				$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
548
+			if ( $struc['islink'] ) {
549
+							$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
550
+			}
526 551
 
527 552
 			// Add the Octal representation of the file permissions
528 553
 			$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -26,33 +26,33 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param array $opt
28 28
 	 */
29
-	public function __construct( $opt  = '' ) {
29
+	public function __construct($opt = '') {
30 30
 		$this->method = 'ftpsockets';
31 31
 		$this->errors = new WP_Error();
32 32
 
33 33
 		// Check if possible to use ftp functions.
34
-		if ( ! @include_once( ABSPATH . 'wp-admin/includes/class-ftp.php' ) ) {
34
+		if ( ! @include_once(ABSPATH.'wp-admin/includes/class-ftp.php')) {
35 35
 			return;
36 36
 		}
37 37
 		$this->ftp = new ftp();
38 38
 
39
-		if ( empty($opt['port']) )
39
+		if (empty($opt['port']))
40 40
 			$this->options['port'] = 21;
41 41
 		else
42 42
 			$this->options['port'] = (int) $opt['port'];
43 43
 
44
-		if ( empty($opt['hostname']) )
44
+		if (empty($opt['hostname']))
45 45
 			$this->errors->add('empty_hostname', __('FTP hostname is required'));
46 46
 		else
47 47
 			$this->options['hostname'] = $opt['hostname'];
48 48
 
49 49
 		// Check if the options provided are OK.
50
-		if ( empty ($opt['username']) )
50
+		if (empty ($opt['username']))
51 51
 			$this->errors->add('empty_username', __('FTP username is required'));
52 52
 		else
53 53
 			$this->options['username'] = $opt['username'];
54 54
 
55
-		if ( empty ($opt['password']) )
55
+		if (empty ($opt['password']))
56 56
 			$this->errors->add('empty_password', __('FTP password is required'));
57 57
 		else
58 58
 			$this->options['password'] = $opt['password'];
@@ -64,44 +64,44 @@  discard block
 block discarded – undo
64 64
 	 * @return bool
65 65
 	 */
66 66
 	public function connect() {
67
-		if ( ! $this->ftp )
67
+		if ( ! $this->ftp)
68 68
 			return false;
69 69
 
70 70
 		$this->ftp->setTimeout(FS_CONNECT_TIMEOUT);
71 71
 
72
-		if ( ! $this->ftp->SetServer( $this->options['hostname'], $this->options['port'] ) ) {
73
-			$this->errors->add( 'connect',
72
+		if ( ! $this->ftp->SetServer($this->options['hostname'], $this->options['port'])) {
73
+			$this->errors->add('connect',
74 74
 				/* translators: %s: hostname:port */
75
-				sprintf( __( 'Failed to connect to FTP Server %s' ),
76
-					$this->options['hostname'] . ':' . $this->options['port']
75
+				sprintf(__('Failed to connect to FTP Server %s'),
76
+					$this->options['hostname'].':'.$this->options['port']
77 77
 				)
78 78
 			);
79 79
 			return false;
80 80
 		}
81 81
 
82
-		if ( ! $this->ftp->connect() ) {
83
-			$this->errors->add( 'connect',
82
+		if ( ! $this->ftp->connect()) {
83
+			$this->errors->add('connect',
84 84
 				/* translators: %s: hostname:port */
85
-				sprintf( __( 'Failed to connect to FTP Server %s' ),
86
-					$this->options['hostname'] . ':' . $this->options['port']
85
+				sprintf(__('Failed to connect to FTP Server %s'),
86
+					$this->options['hostname'].':'.$this->options['port']
87 87
 				)
88 88
 			);
89 89
 			return false;
90 90
 		}
91 91
 
92
-		if ( ! $this->ftp->login( $this->options['username'], $this->options['password'] ) ) {
93
-			$this->errors->add( 'auth',
92
+		if ( ! $this->ftp->login($this->options['username'], $this->options['password'])) {
93
+			$this->errors->add('auth',
94 94
 				/* translators: %s: username */
95
-				sprintf( __( 'Username/Password incorrect for %s' ),
95
+				sprintf(__('Username/Password incorrect for %s'),
96 96
 					$this->options['username']
97 97
 				)
98 98
 			);
99 99
 			return false;
100 100
 		}
101 101
 
102
-		$this->ftp->SetType( FTP_BINARY );
103
-		$this->ftp->Passive( true );
104
-		$this->ftp->setTimeout( FS_TIMEOUT );
102
+		$this->ftp->SetType(FTP_BINARY);
103
+		$this->ftp->Passive(true);
104
+		$this->ftp->setTimeout(FS_TIMEOUT);
105 105
 		return true;
106 106
 	}
107 107
 
@@ -115,20 +115,20 @@  discard block
 block discarded – undo
115 115
 	 * @return string|false File contents on success, false if no temp file could be opened,
116 116
 	 *                      or if the file doesn't exist.
117 117
 	 */
118
-	public function get_contents( $file ) {
119
-		if ( ! $this->exists($file) )
118
+	public function get_contents($file) {
119
+		if ( ! $this->exists($file))
120 120
 			return false;
121 121
 
122
-		$temp = wp_tempnam( $file );
122
+		$temp = wp_tempnam($file);
123 123
 
124
-		if ( ! $temphandle = fopen( $temp, 'w+' ) ) {
125
-			unlink( $temp );
124
+		if ( ! $temphandle = fopen($temp, 'w+')) {
125
+			unlink($temp);
126 126
 			return false;
127 127
 		}
128 128
 
129 129
 		mbstring_binary_safe_encoding();
130 130
 
131
-		if ( ! $this->ftp->fget($temphandle, $file) ) {
131
+		if ( ! $this->ftp->fget($temphandle, $file)) {
132 132
 			fclose($temphandle);
133 133
 			unlink($temp);
134 134
 
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 
140 140
 		reset_mbstring_encoding();
141 141
 
142
-		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
142
+		fseek($temphandle, 0); // Skip back to the start of the file being written to
143 143
 		$contents = '';
144 144
 
145
-		while ( ! feof($temphandle) )
145
+		while ( ! feof($temphandle))
146 146
 			$contents .= fread($temphandle, 8192);
147 147
 
148 148
 		fclose($temphandle);
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @return array
158 158
 	 */
159 159
 	public function get_contents_array($file) {
160
-		return explode("\n", $this->get_contents($file) );
160
+		return explode("\n", $this->get_contents($file));
161 161
 	}
162 162
 
163 163
 	/**
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 	 * @param int|bool $mode
169 169
 	 * @return bool
170 170
 	 */
171
-	public function put_contents($file, $contents, $mode = false ) {
172
-		$temp = wp_tempnam( $file );
173
-		if ( ! $temphandle = @fopen($temp, 'w+') ) {
171
+	public function put_contents($file, $contents, $mode = false) {
172
+		$temp = wp_tempnam($file);
173
+		if ( ! $temphandle = @fopen($temp, 'w+')) {
174 174
 			unlink($temp);
175 175
 			return false;
176 176
 		}
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
 		// The FTP class uses string functions internally during file download/upload
179 179
 		mbstring_binary_safe_encoding();
180 180
 
181
-		$bytes_written = fwrite( $temphandle, $contents );
182
-		if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) {
183
-			fclose( $temphandle );
184
-			unlink( $temp );
181
+		$bytes_written = fwrite($temphandle, $contents);
182
+		if (false === $bytes_written || $bytes_written != strlen($contents)) {
183
+			fclose($temphandle);
184
+			unlink($temp);
185 185
 
186 186
 			reset_mbstring_encoding();
187 187
 
188 188
 			return false;
189 189
 		}
190 190
 
191
-		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
191
+		fseek($temphandle, 0); // Skip back to the start of the file being written to
192 192
 
193 193
 		$ret = $this->ftp->fput($file, $temphandle);
194 194
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	public function cwd() {
211 211
 		$cwd = $this->ftp->pwd();
212
-		if ( $cwd )
212
+		if ($cwd)
213 213
 			$cwd = trailingslashit($cwd);
214 214
 		return $cwd;
215 215
 	}
@@ -232,21 +232,21 @@  discard block
 block discarded – undo
232 232
 	 * @param bool $recursive
233 233
 	 * @return bool
234 234
 	 */
235
-	public function chmod($file, $mode = false, $recursive = false ) {
236
-		if ( ! $mode ) {
237
-			if ( $this->is_file($file) )
235
+	public function chmod($file, $mode = false, $recursive = false) {
236
+		if ( ! $mode) {
237
+			if ($this->is_file($file))
238 238
 				$mode = FS_CHMOD_FILE;
239
-			elseif ( $this->is_dir($file) )
239
+			elseif ($this->is_dir($file))
240 240
 				$mode = FS_CHMOD_DIR;
241 241
 			else
242 242
 				return false;
243 243
 		}
244 244
 
245 245
 		// chmod any sub-objects if recursive.
246
-		if ( $recursive && $this->is_dir($file) ) {
246
+		if ($recursive && $this->is_dir($file)) {
247 247
 			$filelist = $this->dirlist($file);
248
-			foreach ( (array)$filelist as $filename => $filemeta )
249
-				$this->chmod($file . '/' . $filename, $mode, $recursive);
248
+			foreach ((array) $filelist as $filename => $filemeta)
249
+				$this->chmod($file.'/'.$filename, $mode, $recursive);
250 250
 		}
251 251
 
252 252
 		// chmod the file or directory
@@ -296,11 +296,11 @@  discard block
 block discarded – undo
296 296
 	 * @return bool
297 297
 	 */
298 298
 	public function copy($source, $destination, $overwrite = false, $mode = false) {
299
-		if ( ! $overwrite && $this->exists($destination) )
299
+		if ( ! $overwrite && $this->exists($destination))
300 300
 			return false;
301 301
 
302 302
 		$content = $this->get_contents($source);
303
-		if ( false === $content )
303
+		if (false === $content)
304 304
 			return false;
305 305
 
306 306
 		return $this->put_contents($destination, $content, $mode);
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 * @param bool   $overwrite
315 315
 	 * @return bool
316 316
 	 */
317
-	public function move($source, $destination, $overwrite = false ) {
317
+	public function move($source, $destination, $overwrite = false) {
318 318
 		return $this->ftp->rename($source, $destination);
319 319
 	}
320 320
 
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
 	 * @return bool
328 328
 	 */
329 329
 	public function delete($file, $recursive = false, $type = false) {
330
-		if ( empty($file) )
330
+		if (empty($file))
331 331
 			return false;
332
-		if ( 'f' == $type || $this->is_file($file) )
332
+		if ('f' == $type || $this->is_file($file))
333 333
 			return $this->ftp->delete($file);
334
-		if ( !$recursive )
334
+		if ( ! $recursive)
335 335
 			return $this->ftp->rmdir($file);
336 336
 
337 337
 		return $this->ftp->mdel($file);
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
 	 * @param string $file
344 344
 	 * @return bool
345 345
 	 */
346
-	public function exists( $file ) {
347
-		$list = $this->ftp->nlist( $file );
346
+	public function exists($file) {
347
+		$list = $this->ftp->nlist($file);
348 348
 
349
-		if ( empty( $list ) && $this->is_dir( $file ) ) {
349
+		if (empty($list) && $this->is_dir($file)) {
350 350
 			return true; // File is an empty directory.
351 351
 		}
352 352
 
353
-		return !empty( $list ); //empty list = no file, so invert.
353
+		return ! empty($list); //empty list = no file, so invert.
354 354
 		// Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
355 355
 	}
356 356
 
@@ -361,9 +361,9 @@  discard block
 block discarded – undo
361 361
 	 * @return bool
362 362
 	 */
363 363
 	public function is_file($file) {
364
-		if ( $this->is_dir($file) )
364
+		if ($this->is_dir($file))
365 365
 			return false;
366
-		if ( $this->exists($file) )
366
+		if ($this->exists($file))
367 367
 			return true;
368 368
 		return false;
369 369
 	}
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	 */
377 377
 	public function is_dir($path) {
378 378
 		$cwd = $this->cwd();
379
-		if ( $this->chdir($path) ) {
379
+		if ($this->chdir($path)) {
380 380
 			$this->chdir($cwd);
381 381
 			return true;
382 382
 		}
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	 * @param int $atime
440 440
 	 * @return bool
441 441
 	 */
442
-	public function touch($file, $time = 0, $atime = 0 ) {
442
+	public function touch($file, $time = 0, $atime = 0) {
443 443
 		return false;
444 444
 	}
445 445
 
@@ -452,14 +452,14 @@  discard block
 block discarded – undo
452 452
 	 * @param mixed  $chgrp
453 453
 	 * @return bool
454 454
 	 */
455
-	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false ) {
455
+	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
456 456
 		$path = untrailingslashit($path);
457
-		if ( empty($path) )
457
+		if (empty($path))
458 458
 			return false;
459 459
 
460
-		if ( ! $this->ftp->mkdir($path) )
460
+		if ( ! $this->ftp->mkdir($path))
461 461
 			return false;
462
-		if ( ! $chmod )
462
+		if ( ! $chmod)
463 463
 			$chmod = FS_CHMOD_DIR;
464 464
 		$this->chmod($path, $chmod);
465 465
 		return true;
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	 * @param bool $recursive
473 473
 	 * @return bool
474 474
 	 */
475
-	public function rmdir($path, $recursive = false ) {
475
+	public function rmdir($path, $recursive = false) {
476 476
 		return $this->delete($path, $recursive);
477 477
 	}
478 478
 
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
 	 * @param bool   $recursive
485 485
 	 * @return bool|array
486 486
 	 */
487
-	public function dirlist($path = '.', $include_hidden = true, $recursive = false ) {
488
-		if ( $this->is_file($path) ) {
487
+	public function dirlist($path = '.', $include_hidden = true, $recursive = false) {
488
+		if ($this->is_file($path)) {
489 489
 			$limit_file = basename($path);
490
-			$path = dirname($path) . '/';
490
+			$path = dirname($path).'/';
491 491
 		} else {
492 492
 			$limit_file = false;
493 493
 		}
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 		mbstring_binary_safe_encoding();
496 496
 
497 497
 		$list = $this->ftp->dirlist($path);
498
-		if ( empty( $list ) && ! $this->exists( $path ) ) {
498
+		if (empty($list) && ! $this->exists($path)) {
499 499
 
500 500
 			reset_mbstring_encoding();
501 501
 
@@ -503,32 +503,32 @@  discard block
 block discarded – undo
503 503
 		}
504 504
 
505 505
 		$ret = array();
506
-		foreach ( $list as $struc ) {
506
+		foreach ($list as $struc) {
507 507
 
508
-			if ( '.' == $struc['name'] || '..' == $struc['name'] )
508
+			if ('.' == $struc['name'] || '..' == $struc['name'])
509 509
 				continue;
510 510
 
511
-			if ( ! $include_hidden && '.' == $struc['name'][0] )
511
+			if ( ! $include_hidden && '.' == $struc['name'][0])
512 512
 				continue;
513 513
 
514
-			if ( $limit_file && $struc['name'] != $limit_file )
514
+			if ($limit_file && $struc['name'] != $limit_file)
515 515
 				continue;
516 516
 
517
-			if ( 'd' == $struc['type'] ) {
518
-				if ( $recursive )
519
-					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
517
+			if ('d' == $struc['type']) {
518
+				if ($recursive)
519
+					$struc['files'] = $this->dirlist($path.'/'.$struc['name'], $include_hidden, $recursive);
520 520
 				else
521 521
 					$struc['files'] = array();
522 522
 			}
523 523
 
524 524
 			// Replace symlinks formatted as "source -> target" with just the source name
525
-			if ( $struc['islink'] )
526
-				$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
525
+			if ($struc['islink'])
526
+				$struc['name'] = preg_replace('/(\s*->\s*.*)$/', '', $struc['name']);
527 527
 
528 528
 			// Add the Octal representation of the file permissions
529
-			$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
529
+			$struc['permsn'] = $this->getnumchmodfromh($struc['perms']);
530 530
 
531
-			$ret[ $struc['name'] ] = $struc;
531
+			$ret[$struc['name']] = $struc;
532 532
 		}
533 533
 
534 534
 		reset_mbstring_encoding();
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-list-table.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@
 block discarded – undo
183 183
 	 * @access public
184 184
 	 *
185 185
 	 * @param string $name Property to check if set.
186
-	 * @return bool Whether the property is set.
186
+	 * @return boolean|null Whether the property is set.
187 187
 	 */
188 188
 	public function __isset( $name ) {
189 189
 		if ( in_array( $name, $this->compat_fields ) ) {
Please login to merge, or discard this patch.
Spacing   +270 added lines, -270 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @access protected
94 94
 	 * @var array
95 95
 	 */
96
-	protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' );
96
+	protected $compat_fields = array('_args', '_pagination_args', 'screen', '_actions', '_pagination');
97 97
 
98 98
 	/**
99 99
 	 * {@internal Missing Summary}
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
 	 * @access protected
102 102
 	 * @var array
103 103
 	 */
104
-	protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions',
104
+	protected $compat_methods = array('set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions',
105 105
 		'row_actions', 'months_dropdown', 'view_switcher', 'comments_bubble', 'get_items_per_page', 'pagination',
106 106
 		'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav',
107
-		'single_row_columns' );
107
+		'single_row_columns');
108 108
 
109 109
 	/**
110 110
 	 * Constructor.
@@ -132,35 +132,35 @@  discard block
 block discarded – undo
132 132
 	 *                            Default null.
133 133
 	 * }
134 134
 	 */
135
-	public function __construct( $args = array() ) {
136
-		$args = wp_parse_args( $args, array(
135
+	public function __construct($args = array()) {
136
+		$args = wp_parse_args($args, array(
137 137
 			'plural' => '',
138 138
 			'singular' => '',
139 139
 			'ajax' => false,
140 140
 			'screen' => null,
141
-		) );
141
+		));
142 142
 
143
-		$this->screen = convert_to_screen( $args['screen'] );
143
+		$this->screen = convert_to_screen($args['screen']);
144 144
 
145
-		add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 );
145
+		add_filter("manage_{$this->screen->id}_columns", array($this, 'get_columns'), 0);
146 146
 
147
-		if ( !$args['plural'] )
147
+		if ( ! $args['plural'])
148 148
 			$args['plural'] = $this->screen->base;
149 149
 
150
-		$args['plural'] = sanitize_key( $args['plural'] );
151
-		$args['singular'] = sanitize_key( $args['singular'] );
150
+		$args['plural'] = sanitize_key($args['plural']);
151
+		$args['singular'] = sanitize_key($args['singular']);
152 152
 
153 153
 		$this->_args = $args;
154 154
 
155
-		if ( $args['ajax'] ) {
155
+		if ($args['ajax']) {
156 156
 			// wp_enqueue_script( 'list-table' );
157
-			add_action( 'admin_footer', array( $this, '_js_vars' ) );
157
+			add_action('admin_footer', array($this, '_js_vars'));
158 158
 		}
159 159
 
160
-		if ( empty( $this->modes ) ) {
160
+		if (empty($this->modes)) {
161 161
 			$this->modes = array(
162
-				'list'    => __( 'List View' ),
163
-				'excerpt' => __( 'Excerpt View' )
162
+				'list'    => __('List View'),
163
+				'excerpt' => __('Excerpt View')
164 164
 			);
165 165
 		}
166 166
 	}
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 * @param string $name Property to get.
175 175
 	 * @return mixed Property.
176 176
 	 */
177
-	public function __get( $name ) {
178
-		if ( in_array( $name, $this->compat_fields ) ) {
177
+	public function __get($name) {
178
+		if (in_array($name, $this->compat_fields)) {
179 179
 			return $this->$name;
180 180
 		}
181 181
 	}
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 	 * @param mixed  $value Property value.
191 191
 	 * @return mixed Newly-set property.
192 192
 	 */
193
-	public function __set( $name, $value ) {
194
-		if ( in_array( $name, $this->compat_fields ) ) {
193
+	public function __set($name, $value) {
194
+		if (in_array($name, $this->compat_fields)) {
195 195
 			return $this->$name = $value;
196 196
 		}
197 197
 	}
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
 	 * @param string $name Property to check if set.
206 206
 	 * @return bool Whether the property is set.
207 207
 	 */
208
-	public function __isset( $name ) {
209
-		if ( in_array( $name, $this->compat_fields ) ) {
210
-			return isset( $this->$name );
208
+	public function __isset($name) {
209
+		if (in_array($name, $this->compat_fields)) {
210
+			return isset($this->$name);
211 211
 		}
212 212
 	}
213 213
 
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
 	 *
220 220
 	 * @param string $name Property to unset.
221 221
 	 */
222
-	public function __unset( $name ) {
223
-		if ( in_array( $name, $this->compat_fields ) ) {
224
-			unset( $this->$name );
222
+	public function __unset($name) {
223
+		if (in_array($name, $this->compat_fields)) {
224
+			unset($this->$name);
225 225
 		}
226 226
 	}
227 227
 
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 	 * @param array    $arguments Arguments to pass when calling.
236 236
 	 * @return mixed|bool Return value of the callback, false otherwise.
237 237
 	 */
238
-	public function __call( $name, $arguments ) {
239
-		if ( in_array( $name, $this->compat_methods ) ) {
240
-			return call_user_func_array( array( $this, $name ), $arguments );
238
+	public function __call($name, $arguments) {
239
+		if (in_array($name, $this->compat_methods)) {
240
+			return call_user_func_array(array($this, $name), $arguments);
241 241
 		}
242 242
 		return false;
243 243
 	}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 * @abstract
251 251
 	 */
252 252
 	public function ajax_user_can() {
253
-		die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' );
253
+		die('function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.');
254 254
 	}
255 255
 
256 256
 	/**
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @abstract
263 263
 	 */
264 264
 	public function prepare_items() {
265
-		die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' );
265
+		die('function WP_List_Table::prepare_items() must be over-ridden in a sub-class.');
266 266
 	}
267 267
 
268 268
 	/**
@@ -273,19 +273,19 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @param array|string $args Array or string of arguments with information about the pagination.
275 275
 	 */
276
-	protected function set_pagination_args( $args ) {
277
-		$args = wp_parse_args( $args, array(
276
+	protected function set_pagination_args($args) {
277
+		$args = wp_parse_args($args, array(
278 278
 			'total_items' => 0,
279 279
 			'total_pages' => 0,
280 280
 			'per_page' => 0,
281
-		) );
281
+		));
282 282
 
283
-		if ( !$args['total_pages'] && $args['per_page'] > 0 )
284
-			$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
283
+		if ( ! $args['total_pages'] && $args['per_page'] > 0)
284
+			$args['total_pages'] = ceil($args['total_items'] / $args['per_page']);
285 285
 
286 286
 		// Redirect if page number is invalid and headers are not already sent.
287
-		if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
288
-			wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
287
+		if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages']) {
288
+			wp_redirect(add_query_arg('paged', $args['total_pages']));
289 289
 			exit;
290 290
 		}
291 291
 
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
 	 *                    'total_pages', 'per_page', or 'infinite_scroll'.
303 303
 	 * @return int Number of items that correspond to the given pagination argument.
304 304
 	 */
305
-	public function get_pagination_arg( $key ) {
306
-		if ( 'page' === $key ) {
305
+	public function get_pagination_arg($key) {
306
+		if ('page' === $key) {
307 307
 			return $this->get_pagenum();
308 308
 		}
309 309
 
310
-		if ( isset( $this->_pagination_args[$key] ) ) {
310
+		if (isset($this->_pagination_args[$key])) {
311 311
 			return $this->_pagination_args[$key];
312 312
 		}
313 313
 	}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	 * @return bool
322 322
 	 */
323 323
 	public function has_items() {
324
-		return !empty( $this->items );
324
+		return ! empty($this->items);
325 325
 	}
326 326
 
327 327
 	/**
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	 * @access public
332 332
 	 */
333 333
 	public function no_items() {
334
-		_e( 'No items found.' );
334
+		_e('No items found.');
335 335
 	}
336 336
 
337 337
 	/**
@@ -343,25 +343,25 @@  discard block
 block discarded – undo
343 343
 	 * @param string $text     The 'submit' button label.
344 344
 	 * @param string $input_id ID attribute value for the search input field.
345 345
 	 */
346
-	public function search_box( $text, $input_id ) {
347
-		if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
346
+	public function search_box($text, $input_id) {
347
+		if (empty($_REQUEST['s']) && ! $this->has_items())
348 348
 			return;
349 349
 
350
-		$input_id = $input_id . '-search-input';
350
+		$input_id = $input_id.'-search-input';
351 351
 
352
-		if ( ! empty( $_REQUEST['orderby'] ) )
353
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
354
-		if ( ! empty( $_REQUEST['order'] ) )
355
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
356
-		if ( ! empty( $_REQUEST['post_mime_type'] ) )
357
-			echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
358
-		if ( ! empty( $_REQUEST['detached'] ) )
359
-			echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
352
+		if ( ! empty($_REQUEST['orderby']))
353
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
354
+		if ( ! empty($_REQUEST['order']))
355
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
356
+		if ( ! empty($_REQUEST['post_mime_type']))
357
+			echo '<input type="hidden" name="post_mime_type" value="'.esc_attr($_REQUEST['post_mime_type']).'" />';
358
+		if ( ! empty($_REQUEST['detached']))
359
+			echo '<input type="hidden" name="detached" value="'.esc_attr($_REQUEST['detached']).'" />';
360 360
 ?>
361 361
 <p class="search-box">
362
-	<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label>
363
-	<input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" />
364
-	<?php submit_button( $text, '', '', false, array( 'id' => 'search-submit' ) ); ?>
362
+	<label class="screen-reader-text" for="<?php echo esc_attr($input_id); ?>"><?php echo $text; ?>:</label>
363
+	<input type="search" id="<?php echo esc_attr($input_id); ?>" name="s" value="<?php _admin_search_query(); ?>" />
364
+	<?php submit_button($text, '', '', false, array('id' => 'search-submit')); ?>
365 365
 </p>
366 366
 <?php
367 367
 	}
@@ -397,18 +397,18 @@  discard block
 block discarded – undo
397 397
 		 *
398 398
 		 * @param array $views An array of available list table views.
399 399
 		 */
400
-		$views = apply_filters( "views_{$this->screen->id}", $views );
400
+		$views = apply_filters("views_{$this->screen->id}", $views);
401 401
 
402
-		if ( empty( $views ) )
402
+		if (empty($views))
403 403
 			return;
404 404
 
405
-		$this->screen->render_screen_reader_content( 'heading_views' );
405
+		$this->screen->render_screen_reader_content('heading_views');
406 406
 
407 407
 		echo "<ul class='subsubsub'>\n";
408
-		foreach ( $views as $class => $view ) {
409
-			$views[ $class ] = "\t<li class='$class'>$view";
408
+		foreach ($views as $class => $view) {
409
+			$views[$class] = "\t<li class='$class'>$view";
410 410
 		}
411
-		echo implode( " |</li>\n", $views ) . "</li>\n";
411
+		echo implode(" |</li>\n", $views)."</li>\n";
412 412
 		echo "</ul>";
413 413
 	}
414 414
 
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
 	 * @param string $which The location of the bulk actions: 'top' or 'bottom'.
435 435
 	 *                      This is designated as optional for backward compatibility.
436 436
 	 */
437
-	protected function bulk_actions( $which = '' ) {
438
-		if ( is_null( $this->_actions ) ) {
437
+	protected function bulk_actions($which = '') {
438
+		if (is_null($this->_actions)) {
439 439
 			$this->_actions = $this->get_bulk_actions();
440 440
 			/**
441 441
 			 * Filters the list table Bulk Actions drop-down.
@@ -449,28 +449,28 @@  discard block
 block discarded – undo
449 449
 			 *
450 450
 			 * @param array $actions An array of the available bulk actions.
451 451
 			 */
452
-			$this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
452
+			$this->_actions = apply_filters("bulk_actions-{$this->screen->id}", $this->_actions);
453 453
 			$two = '';
454 454
 		} else {
455 455
 			$two = '2';
456 456
 		}
457 457
 
458
-		if ( empty( $this->_actions ) )
458
+		if (empty($this->_actions))
459 459
 			return;
460 460
 
461
-		echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
462
-		echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n";
463
-		echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>\n";
461
+		echo '<label for="bulk-action-selector-'.esc_attr($which).'" class="screen-reader-text">'.__('Select bulk action').'</label>';
462
+		echo '<select name="action'.$two.'" id="bulk-action-selector-'.esc_attr($which)."\">\n";
463
+		echo '<option value="-1">'.__('Bulk Actions')."</option>\n";
464 464
 
465
-		foreach ( $this->_actions as $name => $title ) {
465
+		foreach ($this->_actions as $name => $title) {
466 466
 			$class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
467 467
 
468
-			echo "\t" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>\n";
468
+			echo "\t".'<option value="'.$name.'"'.$class.'>'.$title."</option>\n";
469 469
 		}
470 470
 
471 471
 		echo "</select>\n";
472 472
 
473
-		submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
473
+		submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
474 474
 		echo "\n";
475 475
 	}
476 476
 
@@ -483,13 +483,13 @@  discard block
 block discarded – undo
483 483
 	 * @return string|false The action name or False if no action was selected
484 484
 	 */
485 485
 	public function current_action() {
486
-		if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) )
486
+		if (isset($_REQUEST['filter_action']) && ! empty($_REQUEST['filter_action']))
487 487
 			return false;
488 488
 
489
-		if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
489
+		if (isset($_REQUEST['action']) && -1 != $_REQUEST['action'])
490 490
 			return $_REQUEST['action'];
491 491
 
492
-		if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
492
+		if (isset($_REQUEST['action2']) && -1 != $_REQUEST['action2'])
493 493
 			return $_REQUEST['action2'];
494 494
 
495 495
 		return false;
@@ -505,22 +505,22 @@  discard block
 block discarded – undo
505 505
 	 * @param bool $always_visible Whether the actions should be always visible
506 506
 	 * @return string
507 507
 	 */
508
-	protected function row_actions( $actions, $always_visible = false ) {
509
-		$action_count = count( $actions );
508
+	protected function row_actions($actions, $always_visible = false) {
509
+		$action_count = count($actions);
510 510
 		$i = 0;
511 511
 
512
-		if ( !$action_count )
512
+		if ( ! $action_count)
513 513
 			return '';
514 514
 
515
-		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
516
-		foreach ( $actions as $action => $link ) {
515
+		$out = '<div class="'.($always_visible ? 'row-actions visible' : 'row-actions').'">';
516
+		foreach ($actions as $action => $link) {
517 517
 			++$i;
518
-			( $i == $action_count ) ? $sep = '' : $sep = ' | ';
518
+			($i == $action_count) ? $sep = '' : $sep = ' | ';
519 519
 			$out .= "<span class='$action'>$link$sep</span>";
520 520
 		}
521 521
 		$out .= '</div>';
522 522
 
523
-		$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>';
523
+		$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">'.__('Show more details').'</span></button>';
524 524
 
525 525
 		return $out;
526 526
 	}
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	 *
537 537
 	 * @param string $post_type
538 538
 	 */
539
-	protected function months_dropdown( $post_type ) {
539
+	protected function months_dropdown($post_type) {
540 540
 		global $wpdb, $wp_locale;
541 541
 
542 542
 		/**
@@ -547,24 +547,24 @@  discard block
 block discarded – undo
547 547
 		 * @param bool   $disable   Whether to disable the drop-down. Default false.
548 548
 		 * @param string $post_type The post type.
549 549
 		 */
550
-		if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) {
550
+		if (apply_filters('disable_months_dropdown', false, $post_type)) {
551 551
 			return;
552 552
 		}
553 553
 
554 554
 		$extra_checks = "AND post_status != 'auto-draft'";
555
-		if ( ! isset( $_GET['post_status'] ) || 'trash' !== $_GET['post_status'] ) {
555
+		if ( ! isset($_GET['post_status']) || 'trash' !== $_GET['post_status']) {
556 556
 			$extra_checks .= " AND post_status != 'trash'";
557
-		} elseif ( isset( $_GET['post_status'] ) ) {
558
-			$extra_checks = $wpdb->prepare( ' AND post_status = %s', $_GET['post_status'] );
557
+		} elseif (isset($_GET['post_status'])) {
558
+			$extra_checks = $wpdb->prepare(' AND post_status = %s', $_GET['post_status']);
559 559
 		}
560 560
 
561
-		$months = $wpdb->get_results( $wpdb->prepare( "
561
+		$months = $wpdb->get_results($wpdb->prepare("
562 562
 			SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
563 563
 			FROM $wpdb->posts
564 564
 			WHERE post_type = %s
565 565
 			$extra_checks
566 566
 			ORDER BY post_date DESC
567
-		", $post_type ) );
567
+		", $post_type));
568 568
 
569 569
 		/**
570 570
 		 * Filters the 'Months' drop-down results.
@@ -574,31 +574,31 @@  discard block
 block discarded – undo
574 574
 		 * @param object $months    The months drop-down query results.
575 575
 		 * @param string $post_type The post type.
576 576
 		 */
577
-		$months = apply_filters( 'months_dropdown_results', $months, $post_type );
577
+		$months = apply_filters('months_dropdown_results', $months, $post_type);
578 578
 
579
-		$month_count = count( $months );
579
+		$month_count = count($months);
580 580
 
581
-		if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
581
+		if ( ! $month_count || (1 == $month_count && 0 == $months[0]->month))
582 582
 			return;
583 583
 
584
-		$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
584
+		$m = isset($_GET['m']) ? (int) $_GET['m'] : 0;
585 585
 ?>
586
-		<label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date' ); ?></label>
586
+		<label for="filter-by-date" class="screen-reader-text"><?php _e('Filter by date'); ?></label>
587 587
 		<select name="m" id="filter-by-date">
588
-			<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
588
+			<option<?php selected($m, 0); ?> value="0"><?php _e('All dates'); ?></option>
589 589
 <?php
590
-		foreach ( $months as $arc_row ) {
591
-			if ( 0 == $arc_row->year )
590
+		foreach ($months as $arc_row) {
591
+			if (0 == $arc_row->year)
592 592
 				continue;
593 593
 
594
-			$month = zeroise( $arc_row->month, 2 );
594
+			$month = zeroise($arc_row->month, 2);
595 595
 			$year = $arc_row->year;
596 596
 
597
-			printf( "<option %s value='%s'>%s</option>\n",
598
-				selected( $m, $year . $month, false ),
599
-				esc_attr( $arc_row->year . $month ),
597
+			printf("<option %s value='%s'>%s</option>\n",
598
+				selected($m, $year.$month, false),
599
+				esc_attr($arc_row->year.$month),
600 600
 				/* translators: 1: month name, 2: 4-digit year */
601
-				sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
601
+				sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year)
602 602
 			);
603 603
 		}
604 604
 ?>
@@ -614,19 +614,19 @@  discard block
 block discarded – undo
614 614
 	 *
615 615
 	 * @param string $current_mode
616 616
 	 */
617
-	protected function view_switcher( $current_mode ) {
617
+	protected function view_switcher($current_mode) {
618 618
 ?>
619
-		<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
619
+		<input type="hidden" name="mode" value="<?php echo esc_attr($current_mode); ?>" />
620 620
 		<div class="view-switch">
621 621
 <?php
622
-			foreach ( $this->modes as $mode => $title ) {
623
-				$classes = array( 'view-' . $mode );
624
-				if ( $current_mode === $mode )
622
+			foreach ($this->modes as $mode => $title) {
623
+				$classes = array('view-'.$mode);
624
+				if ($current_mode === $mode)
625 625
 					$classes[] = 'current';
626 626
 				printf(
627 627
 					"<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
628
-					esc_url( add_query_arg( 'mode', $mode ) ),
629
-					implode( ' ', $classes ),
628
+					esc_url(add_query_arg('mode', $mode)),
629
+					implode(' ', $classes),
630 630
 					$title
631 631
 				);
632 632
 			}
@@ -644,45 +644,45 @@  discard block
 block discarded – undo
644 644
 	 * @param int $post_id          The post ID.
645 645
 	 * @param int $pending_comments Number of pending comments.
646 646
 	 */
647
-	protected function comments_bubble( $post_id, $pending_comments ) {
647
+	protected function comments_bubble($post_id, $pending_comments) {
648 648
 		$approved_comments = get_comments_number();
649 649
 
650
-		$approved_comments_number = number_format_i18n( $approved_comments );
651
-		$pending_comments_number = number_format_i18n( $pending_comments );
650
+		$approved_comments_number = number_format_i18n($approved_comments);
651
+		$pending_comments_number = number_format_i18n($pending_comments);
652 652
 
653
-		$approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number );
654
-		$approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number );
655
-		$pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number );
653
+		$approved_only_phrase = sprintf(_n('%s comment', '%s comments', $approved_comments), $approved_comments_number);
654
+		$approved_phrase = sprintf(_n('%s approved comment', '%s approved comments', $approved_comments), $approved_comments_number);
655
+		$pending_phrase = sprintf(_n('%s pending comment', '%s pending comments', $pending_comments), $pending_comments_number);
656 656
 
657 657
 		// No comments at all.
658
-		if ( ! $approved_comments && ! $pending_comments ) {
659
-			printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
660
-				__( 'No comments' )
658
+		if ( ! $approved_comments && ! $pending_comments) {
659
+			printf('<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
660
+				__('No comments')
661 661
 			);
662 662
 		// Approved comments have different display depending on some conditions.
663
-		} elseif ( $approved_comments ) {
664
-			printf( '<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
665
-				esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'approved' ), admin_url( 'edit-comments.php' ) ) ),
663
+		} elseif ($approved_comments) {
664
+			printf('<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
665
+				esc_url(add_query_arg(array('p' => $post_id, 'comment_status' => 'approved'), admin_url('edit-comments.php'))),
666 666
 				$approved_comments_number,
667 667
 				$pending_comments ? $approved_phrase : $approved_only_phrase
668 668
 			);
669 669
 		} else {
670
-			printf( '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
670
+			printf('<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
671 671
 				$approved_comments_number,
672
-				$pending_comments ? __( 'No approved comments' ) : __( 'No comments' )
672
+				$pending_comments ? __('No approved comments') : __('No comments')
673 673
 			);
674 674
 		}
675 675
 
676
-		if ( $pending_comments ) {
677
-			printf( '<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
678
-				esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'moderated' ), admin_url( 'edit-comments.php' ) ) ),
676
+		if ($pending_comments) {
677
+			printf('<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
678
+				esc_url(add_query_arg(array('p' => $post_id, 'comment_status' => 'moderated'), admin_url('edit-comments.php'))),
679 679
 				$pending_comments_number,
680 680
 				$pending_phrase
681 681
 			);
682 682
 		} else {
683
-			printf( '<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
683
+			printf('<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
684 684
 				$pending_comments_number,
685
-				$approved_comments ? __( 'No pending comments' ) : __( 'No comments' )
685
+				$approved_comments ? __('No pending comments') : __('No comments')
686 686
 			);
687 687
 		}
688 688
 	}
@@ -696,12 +696,12 @@  discard block
 block discarded – undo
696 696
 	 * @return int
697 697
 	 */
698 698
 	public function get_pagenum() {
699
-		$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
699
+		$pagenum = isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 0;
700 700
 
701
-		if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
701
+		if (isset($this->_pagination_args['total_pages']) && $pagenum > $this->_pagination_args['total_pages'])
702 702
 			$pagenum = $this->_pagination_args['total_pages'];
703 703
 
704
-		return max( 1, $pagenum );
704
+		return max(1, $pagenum);
705 705
 	}
706 706
 
707 707
 	/**
@@ -714,9 +714,9 @@  discard block
 block discarded – undo
714 714
 	 * @param int    $default
715 715
 	 * @return int
716 716
 	 */
717
-	protected function get_items_per_page( $option, $default = 20 ) {
718
-		$per_page = (int) get_user_option( $option );
719
-		if ( empty( $per_page ) || $per_page < 1 )
717
+	protected function get_items_per_page($option, $default = 20) {
718
+		$per_page = (int) get_user_option($option);
719
+		if (empty($per_page) || $per_page < 1)
720 720
 			$per_page = $default;
721 721
 
722 722
 		/**
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 		 *
733 733
 		 * @param int $per_page Number of items to be displayed. Default 20.
734 734
 		 */
735
-		return (int) apply_filters( "{$option}", $per_page );
735
+		return (int) apply_filters("{$option}", $per_page);
736 736
 	}
737 737
 
738 738
 	/**
@@ -743,30 +743,30 @@  discard block
 block discarded – undo
743 743
 	 *
744 744
 	 * @param string $which
745 745
 	 */
746
-	protected function pagination( $which ) {
747
-		if ( empty( $this->_pagination_args ) ) {
746
+	protected function pagination($which) {
747
+		if (empty($this->_pagination_args)) {
748 748
 			return;
749 749
 		}
750 750
 
751 751
 		$total_items = $this->_pagination_args['total_items'];
752 752
 		$total_pages = $this->_pagination_args['total_pages'];
753 753
 		$infinite_scroll = false;
754
-		if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
754
+		if (isset($this->_pagination_args['infinite_scroll'])) {
755 755
 			$infinite_scroll = $this->_pagination_args['infinite_scroll'];
756 756
 		}
757 757
 
758
-		if ( 'top' === $which && $total_pages > 1 ) {
759
-			$this->screen->render_screen_reader_content( 'heading_pagination' );
758
+		if ('top' === $which && $total_pages > 1) {
759
+			$this->screen->render_screen_reader_content('heading_pagination');
760 760
 		}
761 761
 
762
-		$output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
762
+		$output = '<span class="displaying-num">'.sprintf(_n('%s item', '%s items', $total_items), number_format_i18n($total_items)).'</span>';
763 763
 
764 764
 		$current = $this->get_pagenum();
765 765
 		$removable_query_args = wp_removable_query_args();
766 766
 
767
-		$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
767
+		$current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
768 768
 
769
-		$current_url = remove_query_arg( $removable_query_args, $current_url );
769
+		$current_url = remove_query_arg($removable_query_args, $current_url);
770 770
 
771 771
 		$page_links = array();
772 772
 
@@ -775,81 +775,81 @@  discard block
 block discarded – undo
775 775
 
776 776
 		$disable_first = $disable_last = $disable_prev = $disable_next = false;
777 777
 
778
- 		if ( $current == 1 ) {
778
+ 		if ($current == 1) {
779 779
 			$disable_first = true;
780 780
 			$disable_prev = true;
781 781
  		}
782
-		if ( $current == 2 ) {
782
+		if ($current == 2) {
783 783
 			$disable_first = true;
784 784
 		}
785
- 		if ( $current == $total_pages ) {
785
+ 		if ($current == $total_pages) {
786 786
 			$disable_last = true;
787 787
 			$disable_next = true;
788 788
  		}
789
-		if ( $current == $total_pages - 1 ) {
789
+		if ($current == $total_pages - 1) {
790 790
 			$disable_last = true;
791 791
 		}
792 792
 
793
-		if ( $disable_first ) {
793
+		if ($disable_first) {
794 794
 			$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&laquo;</span>';
795 795
 		} else {
796
-			$page_links[] = sprintf( "<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
797
-				esc_url( remove_query_arg( 'paged', $current_url ) ),
798
-				__( 'First page' ),
796
+			$page_links[] = sprintf("<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
797
+				esc_url(remove_query_arg('paged', $current_url)),
798
+				__('First page'),
799 799
 				'&laquo;'
800 800
 			);
801 801
 		}
802 802
 
803
-		if ( $disable_prev ) {
803
+		if ($disable_prev) {
804 804
 			$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&lsaquo;</span>';
805 805
 		} else {
806
-			$page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
807
-				esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
808
-				__( 'Previous page' ),
806
+			$page_links[] = sprintf("<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
807
+				esc_url(add_query_arg('paged', max(1, $current - 1), $current_url)),
808
+				__('Previous page'),
809 809
 				'&lsaquo;'
810 810
 			);
811 811
 		}
812 812
 
813
-		if ( 'bottom' === $which ) {
813
+		if ('bottom' === $which) {
814 814
 			$html_current_page  = $current;
815
-			$total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
815
+			$total_pages_before = '<span class="screen-reader-text">'.__('Current Page').'</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
816 816
 		} else {
817
-			$html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
818
-				'<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
817
+			$html_current_page = sprintf("%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
818
+				'<label for="current-page-selector" class="screen-reader-text">'.__('Current Page').'</label>',
819 819
 				$current,
820
-				strlen( $total_pages )
820
+				strlen($total_pages)
821 821
 			);
822 822
 		}
823
-		$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
824
-		$page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;
823
+		$html_total_pages = sprintf("<span class='total-pages'>%s</span>", number_format_i18n($total_pages));
824
+		$page_links[] = $total_pages_before.sprintf(_x('%1$s of %2$s', 'paging'), $html_current_page, $html_total_pages).$total_pages_after;
825 825
 
826
-		if ( $disable_next ) {
826
+		if ($disable_next) {
827 827
 			$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&rsaquo;</span>';
828 828
 		} else {
829
-			$page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
830
-				esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
831
-				__( 'Next page' ),
829
+			$page_links[] = sprintf("<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
830
+				esc_url(add_query_arg('paged', min($total_pages, $current + 1), $current_url)),
831
+				__('Next page'),
832 832
 				'&rsaquo;'
833 833
 			);
834 834
 		}
835 835
 
836
-		if ( $disable_last ) {
836
+		if ($disable_last) {
837 837
 			$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&raquo;</span>';
838 838
 		} else {
839
-			$page_links[] = sprintf( "<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
840
-				esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
841
-				__( 'Last page' ),
839
+			$page_links[] = sprintf("<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
840
+				esc_url(add_query_arg('paged', $total_pages, $current_url)),
841
+				__('Last page'),
842 842
 				'&raquo;'
843 843
 			);
844 844
 		}
845 845
 
846 846
 		$pagination_links_class = 'pagination-links';
847
-		if ( ! empty( $infinite_scroll ) ) {
847
+		if ( ! empty($infinite_scroll)) {
848 848
 			$pagination_links_class = ' hide-if-js';
849 849
 		}
850
-		$output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
850
+		$output .= "\n<span class='$pagination_links_class'>".join("\n", $page_links).'</span>';
851 851
 
852
-		if ( $total_pages ) {
852
+		if ($total_pages) {
853 853
 			$page_class = $total_pages < 2 ? ' one-page' : '';
854 854
 		} else {
855 855
 			$page_class = ' no-pages';
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 	 * @return array
871 871
 	 */
872 872
 	public function get_columns() {
873
-		die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' );
873
+		die('function WP_List_Table::get_columns() must be over-ridden in a sub-class.');
874 874
 	}
875 875
 
876 876
 	/**
@@ -902,14 +902,14 @@  discard block
 block discarded – undo
902 902
 		$columns = $this->get_columns();
903 903
 		$column = '';
904 904
 
905
-		if ( empty( $columns ) ) {
905
+		if (empty($columns)) {
906 906
 			return $column;
907 907
 		}
908 908
 
909 909
 		// We need a primary defined so responsive views show something,
910 910
 		// so let's fall back to the first non-checkbox column.
911
-		foreach ( $columns as $col => $column_name ) {
912
-			if ( 'cb' === $col ) {
911
+		foreach ($columns as $col => $column_name) {
912
+			if ('cb' === $col) {
913 913
 				continue;
914 914
 			}
915 915
 
@@ -941,12 +941,12 @@  discard block
 block discarded – undo
941 941
 	 * @return string The name of the primary column.
942 942
 	 */
943 943
 	protected function get_primary_column_name() {
944
-		$columns = get_column_headers( $this->screen );
944
+		$columns = get_column_headers($this->screen);
945 945
 		$default = $this->get_default_primary_column_name();
946 946
 
947 947
 		// If the primary column doesn't exist fall back to the
948 948
 		// first non-checkbox column.
949
-		if ( ! isset( $columns[ $default ] ) ) {
949
+		if ( ! isset($columns[$default])) {
950 950
 			$default = WP_List_Table::get_default_primary_column_name();
951 951
 		}
952 952
 
@@ -958,9 +958,9 @@  discard block
 block discarded – undo
958 958
 		 * @param string $default Column name default for the specific list table, e.g. 'name'.
959 959
 		 * @param string $context Screen ID for specific list table, e.g. 'plugins'.
960 960
 		 */
961
-		$column  = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
961
+		$column  = apply_filters('list_table_primary_column', $default, $this->screen->id);
962 962
 
963
-		if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
963
+		if (empty($column) || ! isset($columns[$column])) {
964 964
 			$column = $default;
965 965
 		}
966 966
 
@@ -977,19 +977,19 @@  discard block
 block discarded – undo
977 977
 	 */
978 978
 	protected function get_column_info() {
979 979
 		// $_column_headers is already set / cached
980
-		if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) {
980
+		if (isset($this->_column_headers) && is_array($this->_column_headers)) {
981 981
 			// Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
982 982
 			// In 4.3, we added a fourth argument for primary column.
983
-			$column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
984
-			foreach ( $this->_column_headers as $key => $value ) {
985
-				$column_headers[ $key ] = $value;
983
+			$column_headers = array(array(), array(), array(), $this->get_primary_column_name());
984
+			foreach ($this->_column_headers as $key => $value) {
985
+				$column_headers[$key] = $value;
986 986
 			}
987 987
 
988 988
 			return $column_headers;
989 989
 		}
990 990
 
991
-		$columns = get_column_headers( $this->screen );
992
-		$hidden = get_hidden_columns( $this->screen );
991
+		$columns = get_column_headers($this->screen);
992
+		$hidden = get_hidden_columns($this->screen);
993 993
 
994 994
 		$sortable_columns = $this->get_sortable_columns();
995 995
 		/**
@@ -1002,22 +1002,22 @@  discard block
 block discarded – undo
1002 1002
 		 *
1003 1003
 		 * @param array $sortable_columns An array of sortable columns.
1004 1004
 		 */
1005
-		$_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
1005
+		$_sortable = apply_filters("manage_{$this->screen->id}_sortable_columns", $sortable_columns);
1006 1006
 
1007 1007
 		$sortable = array();
1008
-		foreach ( $_sortable as $id => $data ) {
1009
-			if ( empty( $data ) )
1008
+		foreach ($_sortable as $id => $data) {
1009
+			if (empty($data))
1010 1010
 				continue;
1011 1011
 
1012 1012
 			$data = (array) $data;
1013
-			if ( !isset( $data[1] ) )
1013
+			if ( ! isset($data[1]))
1014 1014
 				$data[1] = false;
1015 1015
 
1016 1016
 			$sortable[$id] = $data;
1017 1017
 		}
1018 1018
 
1019 1019
 		$primary = $this->get_primary_column_name();
1020
-		$this->_column_headers = array( $columns, $hidden, $sortable, $primary );
1020
+		$this->_column_headers = array($columns, $hidden, $sortable, $primary);
1021 1021
 
1022 1022
 		return $this->_column_headers;
1023 1023
 	}
@@ -1031,9 +1031,9 @@  discard block
 block discarded – undo
1031 1031
 	 * @return int
1032 1032
 	 */
1033 1033
 	public function get_column_count() {
1034
-		list ( $columns, $hidden ) = $this->get_column_info();
1035
-		$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
1036
-		return count( $columns ) - count( $hidden );
1034
+		list ($columns, $hidden) = $this->get_column_info();
1035
+		$hidden = array_intersect(array_keys($columns), array_filter($hidden));
1036
+		return count($columns) - count($hidden);
1037 1037
 	}
1038 1038
 
1039 1039
 	/**
@@ -1046,51 +1046,51 @@  discard block
 block discarded – undo
1046 1046
 	 *
1047 1047
 	 * @param bool $with_id Whether to set the id attribute or not
1048 1048
 	 */
1049
-	public function print_column_headers( $with_id = true ) {
1050
-		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
1049
+	public function print_column_headers($with_id = true) {
1050
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
1051 1051
 
1052
-		$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
1053
-		$current_url = remove_query_arg( 'paged', $current_url );
1052
+		$current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
1053
+		$current_url = remove_query_arg('paged', $current_url);
1054 1054
 
1055
-		if ( isset( $_GET['orderby'] ) ) {
1055
+		if (isset($_GET['orderby'])) {
1056 1056
 			$current_orderby = $_GET['orderby'];
1057 1057
 		} else {
1058 1058
 			$current_orderby = '';
1059 1059
 		}
1060 1060
 
1061
-		if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) {
1061
+		if (isset($_GET['order']) && 'desc' === $_GET['order']) {
1062 1062
 			$current_order = 'desc';
1063 1063
 		} else {
1064 1064
 			$current_order = 'asc';
1065 1065
 		}
1066 1066
 
1067
-		if ( ! empty( $columns['cb'] ) ) {
1067
+		if ( ! empty($columns['cb'])) {
1068 1068
 			static $cb_counter = 1;
1069
-			$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
1070
-				. '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
1069
+			$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-'.$cb_counter.'">'.__('Select All').'</label>'
1070
+				. '<input id="cb-select-all-'.$cb_counter.'" type="checkbox" />';
1071 1071
 			$cb_counter++;
1072 1072
 		}
1073 1073
 
1074
-		foreach ( $columns as $column_key => $column_display_name ) {
1075
-			$class = array( 'manage-column', "column-$column_key" );
1074
+		foreach ($columns as $column_key => $column_display_name) {
1075
+			$class = array('manage-column', "column-$column_key");
1076 1076
 
1077
-			if ( in_array( $column_key, $hidden ) ) {
1077
+			if (in_array($column_key, $hidden)) {
1078 1078
 				$class[] = 'hidden';
1079 1079
 			}
1080 1080
 
1081
-			if ( 'cb' === $column_key )
1081
+			if ('cb' === $column_key)
1082 1082
 				$class[] = 'check-column';
1083
-			elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) )
1083
+			elseif (in_array($column_key, array('posts', 'comments', 'links')))
1084 1084
 				$class[] = 'num';
1085 1085
 
1086
-			if ( $column_key === $primary ) {
1086
+			if ($column_key === $primary) {
1087 1087
 				$class[] = 'column-primary';
1088 1088
 			}
1089 1089
 
1090
-			if ( isset( $sortable[$column_key] ) ) {
1091
-				list( $orderby, $desc_first ) = $sortable[$column_key];
1090
+			if (isset($sortable[$column_key])) {
1091
+				list($orderby, $desc_first) = $sortable[$column_key];
1092 1092
 
1093
-				if ( $current_orderby === $orderby ) {
1093
+				if ($current_orderby === $orderby) {
1094 1094
 					$order = 'asc' === $current_order ? 'desc' : 'asc';
1095 1095
 					$class[] = 'sorted';
1096 1096
 					$class[] = $current_order;
@@ -1100,15 +1100,15 @@  discard block
 block discarded – undo
1100 1100
 					$class[] = $desc_first ? 'asc' : 'desc';
1101 1101
 				}
1102 1102
 
1103
-				$column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
1103
+				$column_display_name = '<a href="'.esc_url(add_query_arg(compact('orderby', 'order'), $current_url)).'"><span>'.$column_display_name.'</span><span class="sorting-indicator"></span></a>';
1104 1104
 			}
1105 1105
 
1106
-			$tag = ( 'cb' === $column_key ) ? 'td' : 'th';
1107
-			$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
1106
+			$tag = ('cb' === $column_key) ? 'td' : 'th';
1107
+			$scope = ('th' === $tag) ? 'scope="col"' : '';
1108 1108
 			$id = $with_id ? "id='$column_key'" : '';
1109 1109
 
1110
-			if ( !empty( $class ) )
1111
-				$class = "class='" . join( ' ', $class ) . "'";
1110
+			if ( ! empty($class))
1111
+				$class = "class='".join(' ', $class)."'";
1112 1112
 
1113 1113
 			echo "<$tag $scope $id $class>$column_display_name</$tag>";
1114 1114
 		}
@@ -1123,11 +1123,11 @@  discard block
 block discarded – undo
1123 1123
 	public function display() {
1124 1124
 		$singular = $this->_args['singular'];
1125 1125
 
1126
-		$this->display_tablenav( 'top' );
1126
+		$this->display_tablenav('top');
1127 1127
 
1128
-		$this->screen->render_screen_reader_content( 'heading_list' );
1128
+		$this->screen->render_screen_reader_content('heading_list');
1129 1129
 ?>
1130
-<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
1130
+<table class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>">
1131 1131
 	<thead>
1132 1132
 	<tr>
1133 1133
 		<?php $this->print_column_headers(); ?>
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
 	</thead>
1136 1136
 
1137 1137
 	<tbody id="the-list"<?php
1138
-		if ( $singular ) {
1138
+		if ($singular) {
1139 1139
 			echo " data-wp-lists='list:$singular'";
1140 1140
 		} ?>>
1141 1141
 		<?php $this->display_rows_or_placeholder(); ?>
@@ -1143,13 +1143,13 @@  discard block
 block discarded – undo
1143 1143
 
1144 1144
 	<tfoot>
1145 1145
 	<tr>
1146
-		<?php $this->print_column_headers( false ); ?>
1146
+		<?php $this->print_column_headers(false); ?>
1147 1147
 	</tr>
1148 1148
 	</tfoot>
1149 1149
 
1150 1150
 </table>
1151 1151
 <?php
1152
-		$this->display_tablenav( 'bottom' );
1152
+		$this->display_tablenav('bottom');
1153 1153
 	}
1154 1154
 
1155 1155
 	/**
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
 	 * @return array List of CSS classes for the table tag.
1162 1162
 	 */
1163 1163
 	protected function get_table_classes() {
1164
-		return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] );
1164
+		return array('widefat', 'fixed', 'striped', $this->_args['plural']);
1165 1165
 	}
1166 1166
 
1167 1167
 	/**
@@ -1171,20 +1171,20 @@  discard block
 block discarded – undo
1171 1171
 	 * @access protected
1172 1172
 	 * @param string $which
1173 1173
 	 */
1174
-	protected function display_tablenav( $which ) {
1175
-		if ( 'top' === $which ) {
1176
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
1174
+	protected function display_tablenav($which) {
1175
+		if ('top' === $which) {
1176
+			wp_nonce_field('bulk-'.$this->_args['plural']);
1177 1177
 		}
1178 1178
 		?>
1179
-	<div class="tablenav <?php echo esc_attr( $which ); ?>">
1179
+	<div class="tablenav <?php echo esc_attr($which); ?>">
1180 1180
 
1181
-		<?php if ( $this->has_items() ): ?>
1181
+		<?php if ($this->has_items()): ?>
1182 1182
 		<div class="alignleft actions bulkactions">
1183
-			<?php $this->bulk_actions( $which ); ?>
1183
+			<?php $this->bulk_actions($which); ?>
1184 1184
 		</div>
1185 1185
 		<?php endif;
1186
-		$this->extra_tablenav( $which );
1187
-		$this->pagination( $which );
1186
+		$this->extra_tablenav($which);
1187
+		$this->pagination($which);
1188 1188
 ?>
1189 1189
 
1190 1190
 		<br class="clear" />
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
 	 *
1201 1201
 	 * @param string $which
1202 1202
 	 */
1203
-	protected function extra_tablenav( $which ) {}
1203
+	protected function extra_tablenav($which) {}
1204 1204
 
1205 1205
 	/**
1206 1206
 	 * Generate the tbody element for the list table.
@@ -1209,10 +1209,10 @@  discard block
 block discarded – undo
1209 1209
 	 * @access public
1210 1210
 	 */
1211 1211
 	public function display_rows_or_placeholder() {
1212
-		if ( $this->has_items() ) {
1212
+		if ($this->has_items()) {
1213 1213
 			$this->display_rows();
1214 1214
 		} else {
1215
-			echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
1215
+			echo '<tr class="no-items"><td class="colspanchange" colspan="'.$this->get_column_count().'">';
1216 1216
 			$this->no_items();
1217 1217
 			echo '</td></tr>';
1218 1218
 		}
@@ -1225,8 +1225,8 @@  discard block
 block discarded – undo
1225 1225
 	 * @access public
1226 1226
 	 */
1227 1227
 	public function display_rows() {
1228
-		foreach ( $this->items as $item )
1229
-			$this->single_row( $item );
1228
+		foreach ($this->items as $item)
1229
+			$this->single_row($item);
1230 1230
 	}
1231 1231
 
1232 1232
 	/**
@@ -1237,9 +1237,9 @@  discard block
 block discarded – undo
1237 1237
 	 *
1238 1238
 	 * @param object $item The current item
1239 1239
 	 */
1240
-	public function single_row( $item ) {
1240
+	public function single_row($item) {
1241 1241
 		echo '<tr>';
1242
-		$this->single_row_columns( $item );
1242
+		$this->single_row_columns($item);
1243 1243
 		echo '</tr>';
1244 1244
 	}
1245 1245
 
@@ -1248,13 +1248,13 @@  discard block
 block discarded – undo
1248 1248
 	 * @param object $item
1249 1249
 	 * @param string $column_name
1250 1250
 	 */
1251
-	protected function column_default( $item, $column_name ) {}
1251
+	protected function column_default($item, $column_name) {}
1252 1252
 
1253 1253
 	/**
1254 1254
 	 *
1255 1255
 	 * @param object $item
1256 1256
 	 */
1257
-	protected function column_cb( $item ) {}
1257
+	protected function column_cb($item) {}
1258 1258
 
1259 1259
 	/**
1260 1260
 	 * Generates the columns for a single row of the table
@@ -1264,46 +1264,46 @@  discard block
 block discarded – undo
1264 1264
 	 *
1265 1265
 	 * @param object $item The current item
1266 1266
 	 */
1267
-	protected function single_row_columns( $item ) {
1268
-		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
1267
+	protected function single_row_columns($item) {
1268
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
1269 1269
 
1270
-		foreach ( $columns as $column_name => $column_display_name ) {
1270
+		foreach ($columns as $column_name => $column_display_name) {
1271 1271
 			$classes = "$column_name column-$column_name";
1272
-			if ( $primary === $column_name ) {
1272
+			if ($primary === $column_name) {
1273 1273
 				$classes .= ' has-row-actions column-primary';
1274 1274
 			}
1275 1275
 
1276
-			if ( in_array( $column_name, $hidden ) ) {
1276
+			if (in_array($column_name, $hidden)) {
1277 1277
 				$classes .= ' hidden';
1278 1278
 			}
1279 1279
 
1280 1280
 			// Comments column uses HTML in the display name with screen reader text.
1281 1281
 			// Instead of using esc_attr(), we strip tags to get closer to a user-friendly string.
1282
-			$data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"';
1282
+			$data = 'data-colname="'.wp_strip_all_tags($column_display_name).'"';
1283 1283
 
1284 1284
 			$attributes = "class='$classes' $data";
1285 1285
 
1286
-			if ( 'cb' === $column_name ) {
1286
+			if ('cb' === $column_name) {
1287 1287
 				echo '<th scope="row" class="check-column">';
1288
-				echo $this->column_cb( $item );
1288
+				echo $this->column_cb($item);
1289 1289
 				echo '</th>';
1290
-			} elseif ( method_exists( $this, '_column_' . $column_name ) ) {
1290
+			} elseif (method_exists($this, '_column_'.$column_name)) {
1291 1291
 				echo call_user_func(
1292
-					array( $this, '_column_' . $column_name ),
1292
+					array($this, '_column_'.$column_name),
1293 1293
 					$item,
1294 1294
 					$classes,
1295 1295
 					$data,
1296 1296
 					$primary
1297 1297
 				);
1298
-			} elseif ( method_exists( $this, 'column_' . $column_name ) ) {
1298
+			} elseif (method_exists($this, 'column_'.$column_name)) {
1299 1299
 				echo "<td $attributes>";
1300
-				echo call_user_func( array( $this, 'column_' . $column_name ), $item );
1301
-				echo $this->handle_row_actions( $item, $column_name, $primary );
1300
+				echo call_user_func(array($this, 'column_'.$column_name), $item);
1301
+				echo $this->handle_row_actions($item, $column_name, $primary);
1302 1302
 				echo "</td>";
1303 1303
 			} else {
1304 1304
 				echo "<td $attributes>";
1305
-				echo $this->column_default( $item, $column_name );
1306
-				echo $this->handle_row_actions( $item, $column_name, $primary );
1305
+				echo $this->column_default($item, $column_name);
1306
+				echo $this->handle_row_actions($item, $column_name, $primary);
1307 1307
 				echo "</td>";
1308 1308
 			}
1309 1309
 		}
@@ -1320,8 +1320,8 @@  discard block
 block discarded – undo
1320 1320
 	 * @param string $primary     Primary column name.
1321 1321
 	 * @return string The row actions HTML, or an empty string if the current column is the primary column.
1322 1322
 	 */
1323
-	protected function handle_row_actions( $item, $column_name, $primary ) {
1324
-		return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>' : '';
1323
+	protected function handle_row_actions($item, $column_name, $primary) {
1324
+		return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">'.__('Show more details').'</span></button>' : '';
1325 1325
  	}
1326 1326
 
1327 1327
 	/**
@@ -1334,7 +1334,7 @@  discard block
 block discarded – undo
1334 1334
 		$this->prepare_items();
1335 1335
 
1336 1336
 		ob_start();
1337
-		if ( ! empty( $_REQUEST['no_placeholder'] ) ) {
1337
+		if ( ! empty($_REQUEST['no_placeholder'])) {
1338 1338
 			$this->display_rows();
1339 1339
 		} else {
1340 1340
 			$this->display_rows_or_placeholder();
@@ -1342,20 +1342,20 @@  discard block
 block discarded – undo
1342 1342
 
1343 1343
 		$rows = ob_get_clean();
1344 1344
 
1345
-		$response = array( 'rows' => $rows );
1345
+		$response = array('rows' => $rows);
1346 1346
 
1347
-		if ( isset( $this->_pagination_args['total_items'] ) ) {
1347
+		if (isset($this->_pagination_args['total_items'])) {
1348 1348
 			$response['total_items_i18n'] = sprintf(
1349
-				_n( '%s item', '%s items', $this->_pagination_args['total_items'] ),
1350
-				number_format_i18n( $this->_pagination_args['total_items'] )
1349
+				_n('%s item', '%s items', $this->_pagination_args['total_items']),
1350
+				number_format_i18n($this->_pagination_args['total_items'])
1351 1351
 			);
1352 1352
 		}
1353
-		if ( isset( $this->_pagination_args['total_pages'] ) ) {
1353
+		if (isset($this->_pagination_args['total_pages'])) {
1354 1354
 			$response['total_pages'] = $this->_pagination_args['total_pages'];
1355
-			$response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
1355
+			$response['total_pages_i18n'] = number_format_i18n($this->_pagination_args['total_pages']);
1356 1356
 		}
1357 1357
 
1358
-		die( wp_json_encode( $response ) );
1358
+		die(wp_json_encode($response));
1359 1359
 	}
1360 1360
 
1361 1361
 	/**
@@ -1365,13 +1365,13 @@  discard block
 block discarded – undo
1365 1365
 	 */
1366 1366
 	public function _js_vars() {
1367 1367
 		$args = array(
1368
-			'class'  => get_class( $this ),
1368
+			'class'  => get_class($this),
1369 1369
 			'screen' => array(
1370 1370
 				'id'   => $this->screen->id,
1371 1371
 				'base' => $this->screen->base,
1372 1372
 			)
1373 1373
 		);
1374 1374
 
1375
-		printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) );
1375
+		printf("<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode($args));
1376 1376
 	}
1377 1377
 }
Please login to merge, or discard this patch.
Braces   +72 added lines, -49 removed lines patch added patch discarded remove patch
@@ -144,8 +144,9 @@  discard block
 block discarded – undo
144 144
 
145 145
 		add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 );
146 146
 
147
-		if ( !$args['plural'] )
148
-			$args['plural'] = $this->screen->base;
147
+		if ( !$args['plural'] ) {
148
+					$args['plural'] = $this->screen->base;
149
+		}
149 150
 
150 151
 		$args['plural'] = sanitize_key( $args['plural'] );
151 152
 		$args['singular'] = sanitize_key( $args['singular'] );
@@ -280,8 +281,9 @@  discard block
 block discarded – undo
280 281
 			'per_page' => 0,
281 282
 		) );
282 283
 
283
-		if ( !$args['total_pages'] && $args['per_page'] > 0 )
284
-			$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
284
+		if ( !$args['total_pages'] && $args['per_page'] > 0 ) {
285
+					$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
286
+		}
285 287
 
286 288
 		// Redirect if page number is invalid and headers are not already sent.
287 289
 		if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
@@ -344,20 +346,25 @@  discard block
 block discarded – undo
344 346
 	 * @param string $input_id ID attribute value for the search input field.
345 347
 	 */
346 348
 	public function search_box( $text, $input_id ) {
347
-		if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
348
-			return;
349
+		if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) {
350
+					return;
351
+		}
349 352
 
350 353
 		$input_id = $input_id . '-search-input';
351 354
 
352
-		if ( ! empty( $_REQUEST['orderby'] ) )
353
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
354
-		if ( ! empty( $_REQUEST['order'] ) )
355
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
356
-		if ( ! empty( $_REQUEST['post_mime_type'] ) )
357
-			echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
358
-		if ( ! empty( $_REQUEST['detached'] ) )
359
-			echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
360
-?>
355
+		if ( ! empty( $_REQUEST['orderby'] ) ) {
356
+					echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
357
+		}
358
+		if ( ! empty( $_REQUEST['order'] ) ) {
359
+					echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
360
+		}
361
+		if ( ! empty( $_REQUEST['post_mime_type'] ) ) {
362
+					echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
363
+		}
364
+		if ( ! empty( $_REQUEST['detached'] ) ) {
365
+					echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
366
+		}
367
+		?>
361 368
 <p class="search-box">
362 369
 	<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label>
363 370
 	<input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" />
@@ -399,8 +406,9 @@  discard block
 block discarded – undo
399 406
 		 */
400 407
 		$views = apply_filters( "views_{$this->screen->id}", $views );
401 408
 
402
-		if ( empty( $views ) )
403
-			return;
409
+		if ( empty( $views ) ) {
410
+					return;
411
+		}
404 412
 
405 413
 		$this->screen->render_screen_reader_content( 'heading_views' );
406 414
 
@@ -455,8 +463,9 @@  discard block
 block discarded – undo
455 463
 			$two = '2';
456 464
 		}
457 465
 
458
-		if ( empty( $this->_actions ) )
459
-			return;
466
+		if ( empty( $this->_actions ) ) {
467
+					return;
468
+		}
460 469
 
461 470
 		echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
462 471
 		echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n";
@@ -483,14 +492,17 @@  discard block
 block discarded – undo
483 492
 	 * @return string|false The action name or False if no action was selected
484 493
 	 */
485 494
 	public function current_action() {
486
-		if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) )
487
-			return false;
495
+		if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) {
496
+					return false;
497
+		}
488 498
 
489
-		if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
490
-			return $_REQUEST['action'];
499
+		if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) {
500
+					return $_REQUEST['action'];
501
+		}
491 502
 
492
-		if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
493
-			return $_REQUEST['action2'];
503
+		if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) {
504
+					return $_REQUEST['action2'];
505
+		}
494 506
 
495 507
 		return false;
496 508
 	}
@@ -509,8 +521,9 @@  discard block
 block discarded – undo
509 521
 		$action_count = count( $actions );
510 522
 		$i = 0;
511 523
 
512
-		if ( !$action_count )
513
-			return '';
524
+		if ( !$action_count ) {
525
+					return '';
526
+		}
514 527
 
515 528
 		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
516 529
 		foreach ( $actions as $action => $link ) {
@@ -578,8 +591,9 @@  discard block
 block discarded – undo
578 591
 
579 592
 		$month_count = count( $months );
580 593
 
581
-		if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
582
-			return;
594
+		if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
595
+					return;
596
+		}
583 597
 
584 598
 		$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
585 599
 ?>
@@ -588,8 +602,9 @@  discard block
 block discarded – undo
588 602
 			<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
589 603
 <?php
590 604
 		foreach ( $months as $arc_row ) {
591
-			if ( 0 == $arc_row->year )
592
-				continue;
605
+			if ( 0 == $arc_row->year ) {
606
+							continue;
607
+			}
593 608
 
594 609
 			$month = zeroise( $arc_row->month, 2 );
595 610
 			$year = $arc_row->year;
@@ -621,8 +636,9 @@  discard block
 block discarded – undo
621 636
 <?php
622 637
 			foreach ( $this->modes as $mode => $title ) {
623 638
 				$classes = array( 'view-' . $mode );
624
-				if ( $current_mode === $mode )
625
-					$classes[] = 'current';
639
+				if ( $current_mode === $mode ) {
640
+									$classes[] = 'current';
641
+				}
626 642
 				printf(
627 643
 					"<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
628 644
 					esc_url( add_query_arg( 'mode', $mode ) ),
@@ -698,8 +714,9 @@  discard block
 block discarded – undo
698 714
 	public function get_pagenum() {
699 715
 		$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
700 716
 
701
-		if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
702
-			$pagenum = $this->_pagination_args['total_pages'];
717
+		if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) {
718
+					$pagenum = $this->_pagination_args['total_pages'];
719
+		}
703 720
 
704 721
 		return max( 1, $pagenum );
705 722
 	}
@@ -716,8 +733,9 @@  discard block
 block discarded – undo
716 733
 	 */
717 734
 	protected function get_items_per_page( $option, $default = 20 ) {
718 735
 		$per_page = (int) get_user_option( $option );
719
-		if ( empty( $per_page ) || $per_page < 1 )
720
-			$per_page = $default;
736
+		if ( empty( $per_page ) || $per_page < 1 ) {
737
+					$per_page = $default;
738
+		}
721 739
 
722 740
 		/**
723 741
 		 * Filters the number of items to be displayed on each page of the list table.
@@ -1006,12 +1024,14 @@  discard block
 block discarded – undo
1006 1024
 
1007 1025
 		$sortable = array();
1008 1026
 		foreach ( $_sortable as $id => $data ) {
1009
-			if ( empty( $data ) )
1010
-				continue;
1027
+			if ( empty( $data ) ) {
1028
+							continue;
1029
+			}
1011 1030
 
1012 1031
 			$data = (array) $data;
1013
-			if ( !isset( $data[1] ) )
1014
-				$data[1] = false;
1032
+			if ( !isset( $data[1] ) ) {
1033
+							$data[1] = false;
1034
+			}
1015 1035
 
1016 1036
 			$sortable[$id] = $data;
1017 1037
 		}
@@ -1078,10 +1098,11 @@  discard block
 block discarded – undo
1078 1098
 				$class[] = 'hidden';
1079 1099
 			}
1080 1100
 
1081
-			if ( 'cb' === $column_key )
1082
-				$class[] = 'check-column';
1083
-			elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) )
1084
-				$class[] = 'num';
1101
+			if ( 'cb' === $column_key ) {
1102
+							$class[] = 'check-column';
1103
+			} elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) {
1104
+							$class[] = 'num';
1105
+			}
1085 1106
 
1086 1107
 			if ( $column_key === $primary ) {
1087 1108
 				$class[] = 'column-primary';
@@ -1107,8 +1128,9 @@  discard block
 block discarded – undo
1107 1128
 			$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
1108 1129
 			$id = $with_id ? "id='$column_key'" : '';
1109 1130
 
1110
-			if ( !empty( $class ) )
1111
-				$class = "class='" . join( ' ', $class ) . "'";
1131
+			if ( !empty( $class ) ) {
1132
+							$class = "class='" . join( ' ', $class ) . "'";
1133
+			}
1112 1134
 
1113 1135
 			echo "<$tag $scope $id $class>$column_display_name</$tag>";
1114 1136
 		}
@@ -1225,8 +1247,9 @@  discard block
 block discarded – undo
1225 1247
 	 * @access public
1226 1248
 	 */
1227 1249
 	public function display_rows() {
1228
-		foreach ( $this->items as $item )
1229
-			$this->single_row( $item );
1250
+		foreach ( $this->items as $item ) {
1251
+					$this->single_row( $item );
1252
+		}
1230 1253
 	}
1231 1254
 
1232 1255
 	/**
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-ms-themes-list-table.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
 
50 50
 	/**
51 51
 	 *
52
-	 * @return array
52
+	 * @return string[]
53 53
 	 */
54 54
 	protected function get_table_classes() {
55 55
 		// todo: remove and add CSS for .themes
Please login to merge, or discard this patch.
Braces   +69 added lines, -48 removed lines patch added patch discarded remove patch
@@ -44,15 +44,17 @@  discard block
 block discarded – undo
44 44
 		) );
45 45
 
46 46
 		$status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all';
47
-		if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) )
48
-			$status = 'all';
47
+		if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) ) {
48
+					$status = 'all';
49
+		}
49 50
 
50 51
 		$page = $this->get_pagenum();
51 52
 
52 53
 		$this->is_site_themes = ( 'site-themes-network' === $this->screen->id ) ? true : false;
53 54
 
54
-		if ( $this->is_site_themes )
55
-			$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
55
+		if ( $this->is_site_themes ) {
56
+					$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
57
+		}
56 58
 	}
57 59
 
58 60
 	/**
@@ -69,10 +71,11 @@  discard block
 block discarded – undo
69 71
 	 * @return bool
70 72
 	 */
71 73
 	public function ajax_user_can() {
72
-		if ( $this->is_site_themes )
73
-			return current_user_can( 'manage_sites' );
74
-		else
75
-			return current_user_can( 'manage_network_themes' );
74
+		if ( $this->is_site_themes ) {
75
+					return current_user_can( 'manage_sites' );
76
+		} else {
77
+					return current_user_can( 'manage_network_themes' );
78
+		}
76 79
 	}
77 80
 
78 81
 	/**
@@ -137,11 +140,13 @@  discard block
 block discarded – undo
137 140
 		}
138 141
 
139 142
 		$totals = array();
140
-		foreach ( $themes as $type => $list )
141
-			$totals[ $type ] = count( $list );
143
+		foreach ( $themes as $type => $list ) {
144
+					$totals[ $type ] = count( $list );
145
+		}
142 146
 
143
-		if ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )
144
-			$status = 'all';
147
+		if ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) ) {
148
+					$status = 'all';
149
+		}
145 150
 
146 151
 		$this->items = $themes[ $status ];
147 152
 		WP_Theme::sort_by_name( $this->items );
@@ -164,8 +169,9 @@  discard block
 block discarded – undo
164 169
 
165 170
 		$start = ( $page - 1 ) * $themes_per_page;
166 171
 
167
-		if ( $total_this_page > $themes_per_page )
168
-			$this->items = array_slice( $this->items, $start, $themes_per_page, true );
172
+		if ( $total_this_page > $themes_per_page ) {
173
+					$this->items = array_slice( $this->items, $start, $themes_per_page, true );
174
+		}
169 175
 
170 176
 		$this->set_pagination_args( array(
171 177
 			'total_items' => $total_this_page,
@@ -180,20 +186,24 @@  discard block
 block discarded – undo
180 186
 	 */
181 187
 	public function _search_callback( $theme ) {
182 188
 		static $term = null;
183
-		if ( is_null( $term ) )
184
-			$term = wp_unslash( $_REQUEST['s'] );
189
+		if ( is_null( $term ) ) {
190
+					$term = wp_unslash( $_REQUEST['s'] );
191
+		}
185 192
 
186 193
 		foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) {
187 194
 			// Don't mark up; Do translate.
188
-			if ( false !== stripos( $theme->display( $field, false, true ), $term ) )
189
-				return true;
195
+			if ( false !== stripos( $theme->display( $field, false, true ), $term ) ) {
196
+							return true;
197
+			}
190 198
 		}
191 199
 
192
-		if ( false !== stripos( $theme->get_stylesheet(), $term ) )
193
-			return true;
200
+		if ( false !== stripos( $theme->get_stylesheet(), $term ) ) {
201
+					return true;
202
+		}
194 203
 
195
-		if ( false !== stripos( $theme->get_template(), $term ) )
196
-			return true;
204
+		if ( false !== stripos( $theme->get_template(), $term ) ) {
205
+					return true;
206
+		}
197 207
 
198 208
 		return false;
199 209
 	}
@@ -212,13 +222,15 @@  discard block
 block discarded – undo
212 222
 		$a = $theme_a[ $orderby ];
213 223
 		$b = $theme_b[ $orderby ];
214 224
 
215
-		if ( $a == $b )
216
-			return 0;
225
+		if ( $a == $b ) {
226
+					return 0;
227
+		}
217 228
 
218
-		if ( 'DESC' === $order )
219
-			return ( $a < $b ) ? 1 : -1;
220
-		else
221
-			return ( $a < $b ) ? -1 : 1;
229
+		if ( 'DESC' === $order ) {
230
+					return ( $a < $b ) ? 1 : -1;
231
+		} else {
232
+					return ( $a < $b ) ? -1 : 1;
233
+		}
222 234
 	}
223 235
 
224 236
 	/**
@@ -277,8 +289,9 @@  discard block
 block discarded – undo
277 289
 
278 290
 		$status_links = array();
279 291
 		foreach ( $totals as $type => $count ) {
280
-			if ( !$count )
281
-				continue;
292
+			if ( !$count ) {
293
+							continue;
294
+			}
282 295
 
283 296
 			switch ( $type ) {
284 297
 				case 'all':
@@ -298,10 +311,11 @@  discard block
 block discarded – undo
298 311
 					break;
299 312
 			}
300 313
 
301
-			if ( $this->is_site_themes )
302
-				$url = 'site-themes.php?id=' . $this->site_id;
303
-			else
304
-				$url = 'themes.php';
314
+			if ( $this->is_site_themes ) {
315
+							$url = 'site-themes.php?id=' . $this->site_id;
316
+			} else {
317
+							$url = 'themes.php';
318
+			}
305 319
 
306 320
 			if ( 'search' != $type ) {
307 321
 				$status_links[$type] = sprintf( "<a href='%s' %s>%s</a>",
@@ -324,15 +338,19 @@  discard block
 block discarded – undo
324 338
 		global $status;
325 339
 
326 340
 		$actions = array();
327
-		if ( 'enabled' != $status )
328
-			$actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' );
329
-		if ( 'disabled' != $status )
330
-			$actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' );
341
+		if ( 'enabled' != $status ) {
342
+					$actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' );
343
+		}
344
+		if ( 'disabled' != $status ) {
345
+					$actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' );
346
+		}
331 347
 		if ( ! $this->is_site_themes ) {
332
-			if ( current_user_can( 'update_themes' ) )
333
-				$actions['update-selected'] = __( 'Update' );
334
-			if ( current_user_can( 'delete_themes' ) )
335
-				$actions['delete-selected'] = __( 'Delete' );
348
+			if ( current_user_can( 'update_themes' ) ) {
349
+							$actions['update-selected'] = __( 'Update' );
350
+			}
351
+			if ( current_user_can( 'delete_themes' ) ) {
352
+							$actions['delete-selected'] = __( 'Delete' );
353
+			}
336 354
 		}
337 355
 		return $actions;
338 356
 	}
@@ -341,8 +359,9 @@  discard block
 block discarded – undo
341 359
 	 * @access public
342 360
 	 */
343 361
 	public function display_rows() {
344
-		foreach ( $this->items as $theme )
345
-			$this->single_row( $theme );
362
+		foreach ( $this->items as $theme ) {
363
+					$this->single_row( $theme );
364
+		}
346 365
 	}
347 366
 
348 367
 	/**
@@ -544,8 +563,9 @@  discard block
 block discarded – undo
544 563
 		}
545 564
 
546 565
 		$class = ! $allowed ? 'inactive' : 'active';
547
-		if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) )
548
-			$class .= ' update';
566
+		if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) {
567
+					$class .= ' update';
568
+		}
549 569
 
550 570
 		echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div>
551 571
 			<div class='$class second theme-version-author-uri'>";
@@ -695,8 +715,9 @@  discard block
 block discarded – undo
695 715
 
696 716
 		echo "</tr>";
697 717
 
698
-		if ( $this->is_site_themes )
699
-			remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' );
718
+		if ( $this->is_site_themes ) {
719
+					remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' );
720
+		}
700 721
 
701 722
 		/**
702 723
 		 * Fires after each row in the Multisite themes list table.
Please login to merge, or discard this patch.
Spacing   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -35,24 +35,24 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param array $args An associative array of arguments.
37 37
 	 */
38
-	public function __construct( $args = array() ) {
38
+	public function __construct($args = array()) {
39 39
 		global $status, $page;
40 40
 
41
-		parent::__construct( array(
41
+		parent::__construct(array(
42 42
 			'plural' => 'themes',
43
-			'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
44
-		) );
43
+			'screen' => isset($args['screen']) ? $args['screen'] : null,
44
+		));
45 45
 
46
-		$status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all';
47
-		if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) )
46
+		$status = isset($_REQUEST['theme_status']) ? $_REQUEST['theme_status'] : 'all';
47
+		if ( ! in_array($status, array('all', 'enabled', 'disabled', 'upgrade', 'search', 'broken')))
48 48
 			$status = 'all';
49 49
 
50 50
 		$page = $this->get_pagenum();
51 51
 
52
-		$this->is_site_themes = ( 'site-themes-network' === $this->screen->id ) ? true : false;
52
+		$this->is_site_themes = ('site-themes-network' === $this->screen->id) ? true : false;
53 53
 
54
-		if ( $this->is_site_themes )
55
-			$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
54
+		if ($this->is_site_themes)
55
+			$this->site_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
56 56
 	}
57 57
 
58 58
 	/**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	protected function get_table_classes() {
63 63
 		// todo: remove and add CSS for .themes
64
-		return array( 'widefat', 'plugins' );
64
+		return array('widefat', 'plugins');
65 65
 	}
66 66
 
67 67
 	/**
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 	 * @return bool
70 70
 	 */
71 71
 	public function ajax_user_can() {
72
-		if ( $this->is_site_themes )
73
-			return current_user_can( 'manage_sites' );
72
+		if ($this->is_site_themes)
73
+			return current_user_can('manage_sites');
74 74
 		else
75
-			return current_user_can( 'manage_network_themes' );
75
+			return current_user_can('manage_network_themes');
76 76
 	}
77 77
 
78 78
 	/**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	public function prepare_items() {
88 88
 		global $status, $totals, $page, $orderby, $order, $s;
89 89
 
90
-		wp_reset_vars( array( 'orderby', 'order', 's' ) );
90
+		wp_reset_vars(array('orderby', 'order', 's'));
91 91
 
92 92
 		$themes = array(
93 93
 			/**
@@ -98,84 +98,84 @@  discard block
 block discarded – undo
98 98
 			 *
99 99
 			 * @param array $all An array of WP_Theme objects to display in the list table.
100 100
 			 */
101
-			'all' => apply_filters( 'all_themes', wp_get_themes() ),
101
+			'all' => apply_filters('all_themes', wp_get_themes()),
102 102
 			'search' => array(),
103 103
 			'enabled' => array(),
104 104
 			'disabled' => array(),
105 105
 			'upgrade' => array(),
106
-			'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ),
106
+			'broken' => $this->is_site_themes ? array() : wp_get_themes(array('errors' => true)),
107 107
 		);
108 108
 
109
-		if ( $this->is_site_themes ) {
110
-			$themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' );
109
+		if ($this->is_site_themes) {
110
+			$themes_per_page = $this->get_items_per_page('site_themes_network_per_page');
111 111
 			$allowed_where = 'site';
112 112
 		} else {
113
-			$themes_per_page = $this->get_items_per_page( 'themes_network_per_page' );
113
+			$themes_per_page = $this->get_items_per_page('themes_network_per_page');
114 114
 			$allowed_where = 'network';
115 115
 		}
116 116
 
117
-		$maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current = get_site_transient( 'update_themes' );
117
+		$maybe_update = current_user_can('update_themes') && ! $this->is_site_themes && $current = get_site_transient('update_themes');
118 118
 
119
-		foreach ( (array) $themes['all'] as $key => $theme ) {
120
-			if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) {
121
-				unset( $themes['all'][ $key ] );
119
+		foreach ((array) $themes['all'] as $key => $theme) {
120
+			if ($this->is_site_themes && $theme->is_allowed('network')) {
121
+				unset($themes['all'][$key]);
122 122
 				continue;
123 123
 			}
124 124
 
125
-			if ( $maybe_update && isset( $current->response[ $key ] ) ) {
126
-				$themes['all'][ $key ]->update = true;
127
-				$themes['upgrade'][ $key ] = $themes['all'][ $key ];
125
+			if ($maybe_update && isset($current->response[$key])) {
126
+				$themes['all'][$key]->update = true;
127
+				$themes['upgrade'][$key] = $themes['all'][$key];
128 128
 			}
129 129
 
130
-			$filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled';
131
-			$themes[ $filter ][ $key ] = $themes['all'][ $key ];
130
+			$filter = $theme->is_allowed($allowed_where, $this->site_id) ? 'enabled' : 'disabled';
131
+			$themes[$filter][$key] = $themes['all'][$key];
132 132
 		}
133 133
 
134
-		if ( $s ) {
134
+		if ($s) {
135 135
 			$status = 'search';
136
-			$themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( $this, '_search_callback' ) );
136
+			$themes['search'] = array_filter(array_merge($themes['all'], $themes['broken']), array($this, '_search_callback'));
137 137
 		}
138 138
 
139 139
 		$totals = array();
140
-		foreach ( $themes as $type => $list )
141
-			$totals[ $type ] = count( $list );
140
+		foreach ($themes as $type => $list)
141
+			$totals[$type] = count($list);
142 142
 
143
-		if ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )
143
+		if (empty($themes[$status]) && ! in_array($status, array('all', 'search')))
144 144
 			$status = 'all';
145 145
 
146
-		$this->items = $themes[ $status ];
147
-		WP_Theme::sort_by_name( $this->items );
146
+		$this->items = $themes[$status];
147
+		WP_Theme::sort_by_name($this->items);
148 148
 
149
-		$this->has_items = ! empty( $themes['all'] );
150
-		$total_this_page = $totals[ $status ];
149
+		$this->has_items = ! empty($themes['all']);
150
+		$total_this_page = $totals[$status];
151 151
 
152
-		wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
152
+		wp_localize_script('updates', '_wpUpdatesItemCounts', array(
153 153
 			'themes' => $totals,
154 154
 			'totals' => wp_get_update_data(),
155
-		) );
155
+		));
156 156
 
157
-		if ( $orderby ) {
158
-			$orderby = ucfirst( $orderby );
159
-			$order = strtoupper( $order );
157
+		if ($orderby) {
158
+			$orderby = ucfirst($orderby);
159
+			$order = strtoupper($order);
160 160
 
161
-			if ( $orderby === 'Name' ) {
162
-				if ( 'ASC' === $order ) {
163
-					$this->items = array_reverse( $this->items );
161
+			if ($orderby === 'Name') {
162
+				if ('ASC' === $order) {
163
+					$this->items = array_reverse($this->items);
164 164
 				}
165 165
 			} else {
166
-				uasort( $this->items, array( $this, '_order_callback' ) );
166
+				uasort($this->items, array($this, '_order_callback'));
167 167
 			}
168 168
 		}
169 169
 
170
-		$start = ( $page - 1 ) * $themes_per_page;
170
+		$start = ($page - 1) * $themes_per_page;
171 171
 
172
-		if ( $total_this_page > $themes_per_page )
173
-			$this->items = array_slice( $this->items, $start, $themes_per_page, true );
172
+		if ($total_this_page > $themes_per_page)
173
+			$this->items = array_slice($this->items, $start, $themes_per_page, true);
174 174
 
175
-		$this->set_pagination_args( array(
175
+		$this->set_pagination_args(array(
176 176
 			'total_items' => $total_this_page,
177 177
 			'per_page' => $themes_per_page,
178
-		) );
178
+		));
179 179
 	}
180 180
 
181 181
 	/**
@@ -183,21 +183,21 @@  discard block
 block discarded – undo
183 183
 	 * @param WP_Theme $theme
184 184
 	 * @return bool
185 185
 	 */
186
-	public function _search_callback( $theme ) {
186
+	public function _search_callback($theme) {
187 187
 		static $term = null;
188
-		if ( is_null( $term ) )
189
-			$term = wp_unslash( $_REQUEST['s'] );
188
+		if (is_null($term))
189
+			$term = wp_unslash($_REQUEST['s']);
190 190
 
191
-		foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) {
191
+		foreach (array('Name', 'Description', 'Author', 'Author', 'AuthorURI') as $field) {
192 192
 			// Don't mark up; Do translate.
193
-			if ( false !== stripos( $theme->display( $field, false, true ), $term ) )
193
+			if (false !== stripos($theme->display($field, false, true), $term))
194 194
 				return true;
195 195
 		}
196 196
 
197
-		if ( false !== stripos( $theme->get_stylesheet(), $term ) )
197
+		if (false !== stripos($theme->get_stylesheet(), $term))
198 198
 			return true;
199 199
 
200
-		if ( false !== stripos( $theme->get_template(), $term ) )
200
+		if (false !== stripos($theme->get_template(), $term))
201 201
 			return true;
202 202
 
203 203
 		return false;
@@ -211,29 +211,29 @@  discard block
 block discarded – undo
211 211
 	 * @param array $theme_b
212 212
 	 * @return int
213 213
 	 */
214
-	public function _order_callback( $theme_a, $theme_b ) {
214
+	public function _order_callback($theme_a, $theme_b) {
215 215
 		global $orderby, $order;
216 216
 
217
-		$a = $theme_a[ $orderby ];
218
-		$b = $theme_b[ $orderby ];
217
+		$a = $theme_a[$orderby];
218
+		$b = $theme_b[$orderby];
219 219
 
220
-		if ( $a == $b )
220
+		if ($a == $b)
221 221
 			return 0;
222 222
 
223
-		if ( 'DESC' === $order )
224
-			return ( $a < $b ) ? 1 : -1;
223
+		if ('DESC' === $order)
224
+			return ($a < $b) ? 1 : -1;
225 225
 		else
226
-			return ( $a < $b ) ? -1 : 1;
226
+			return ($a < $b) ? -1 : 1;
227 227
 	}
228 228
 
229 229
 	/**
230 230
 	 * @access public
231 231
 	 */
232 232
 	public function no_items() {
233
-		if ( $this->has_items ) {
234
-			_e( 'No themes found.' );
233
+		if ($this->has_items) {
234
+			_e('No themes found.');
235 235
 		} else {
236
-			_e( 'You do not appear to have any themes available at this time.' );
236
+			_e('You do not appear to have any themes available at this time.');
237 237
 		}
238 238
 	}
239 239
 
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 	public function get_columns() {
245 245
 		return array(
246 246
 			'cb'          => '<input type="checkbox" />',
247
-			'name'        => __( 'Theme' ),
248
-			'description' => __( 'Description' ),
247
+			'name'        => __('Theme'),
248
+			'description' => __('Description'),
249 249
 		);
250 250
 	}
251 251
 
@@ -281,38 +281,38 @@  discard block
 block discarded – undo
281 281
 		global $totals, $status;
282 282
 
283 283
 		$status_links = array();
284
-		foreach ( $totals as $type => $count ) {
285
-			if ( !$count )
284
+		foreach ($totals as $type => $count) {
285
+			if ( ! $count)
286 286
 				continue;
287 287
 
288
-			switch ( $type ) {
288
+			switch ($type) {
289 289
 				case 'all':
290
-					$text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'themes' );
290
+					$text = _nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'themes');
291 291
 					break;
292 292
 				case 'enabled':
293
-					$text = _n( 'Enabled <span class="count">(%s)</span>', 'Enabled <span class="count">(%s)</span>', $count );
293
+					$text = _n('Enabled <span class="count">(%s)</span>', 'Enabled <span class="count">(%s)</span>', $count);
294 294
 					break;
295 295
 				case 'disabled':
296
-					$text = _n( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', $count );
296
+					$text = _n('Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', $count);
297 297
 					break;
298 298
 				case 'upgrade':
299
-					$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
299
+					$text = _n('Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count);
300 300
 					break;
301 301
 				case 'broken' :
302
-					$text = _n( 'Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count );
302
+					$text = _n('Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count);
303 303
 					break;
304 304
 			}
305 305
 
306
-			if ( $this->is_site_themes )
307
-				$url = 'site-themes.php?id=' . $this->site_id;
306
+			if ($this->is_site_themes)
307
+				$url = 'site-themes.php?id='.$this->site_id;
308 308
 			else
309 309
 				$url = 'themes.php';
310 310
 
311
-			if ( 'search' != $type ) {
312
-				$status_links[$type] = sprintf( "<a href='%s' %s>%s</a>",
313
-					esc_url( add_query_arg('theme_status', $type, $url) ),
314
-					( $type === $status ) ? ' class="current"' : '',
315
-					sprintf( $text, number_format_i18n( $count ) )
311
+			if ('search' != $type) {
312
+				$status_links[$type] = sprintf("<a href='%s' %s>%s</a>",
313
+					esc_url(add_query_arg('theme_status', $type, $url)),
314
+					($type === $status) ? ' class="current"' : '',
315
+					sprintf($text, number_format_i18n($count))
316 316
 				);
317 317
 			}
318 318
 		}
@@ -329,15 +329,15 @@  discard block
 block discarded – undo
329 329
 		global $status;
330 330
 
331 331
 		$actions = array();
332
-		if ( 'enabled' != $status )
333
-			$actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' );
334
-		if ( 'disabled' != $status )
335
-			$actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' );
336
-		if ( ! $this->is_site_themes ) {
337
-			if ( current_user_can( 'update_themes' ) )
338
-				$actions['update-selected'] = __( 'Update' );
339
-			if ( current_user_can( 'delete_themes' ) )
340
-				$actions['delete-selected'] = __( 'Delete' );
332
+		if ('enabled' != $status)
333
+			$actions['enable-selected'] = $this->is_site_themes ? __('Enable') : __('Network Enable');
334
+		if ('disabled' != $status)
335
+			$actions['disable-selected'] = $this->is_site_themes ? __('Disable') : __('Network Disable');
336
+		if ( ! $this->is_site_themes) {
337
+			if (current_user_can('update_themes'))
338
+				$actions['update-selected'] = __('Update');
339
+			if (current_user_can('delete_themes'))
340
+				$actions['delete-selected'] = __('Delete');
341 341
 		}
342 342
 		return $actions;
343 343
 	}
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
 	 * @access public
347 347
 	 */
348 348
 	public function display_rows() {
349
-		foreach ( $this->items as $theme )
350
-			$this->single_row( $theme );
349
+		foreach ($this->items as $theme)
350
+			$this->single_row($theme);
351 351
 	}
352 352
 
353 353
 	/**
@@ -358,11 +358,11 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
 	 * @param WP_Theme $theme The current WP_Theme object.
360 360
 	 */
361
-	public function column_cb( $theme ) {
362
-		$checkbox_id = 'checkbox_' . md5( $theme->get('Name') );
361
+	public function column_cb($theme) {
362
+		$checkbox_id = 'checkbox_'.md5($theme->get('Name'));
363 363
 		?>
364
-		<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ) ?>" id="<?php echo $checkbox_id ?>" />
365
-		<label class="screen-reader-text" for="<?php echo $checkbox_id ?>" ><?php _e( 'Select' ) ?>  <?php echo $theme->display( 'Name' ) ?></label>
364
+		<input type="checkbox" name="checked[]" value="<?php echo esc_attr($theme->get_stylesheet()) ?>" id="<?php echo $checkbox_id ?>" />
365
+		<label class="screen-reader-text" for="<?php echo $checkbox_id ?>" ><?php _e('Select') ?>  <?php echo $theme->display('Name') ?></label>
366 366
 		<?php
367 367
 	}
368 368
 
@@ -378,17 +378,17 @@  discard block
 block discarded – undo
378 378
 	 *
379 379
 	 * @param WP_Theme $theme The current WP_Theme object.
380 380
 	 */
381
-	public function column_name( $theme ) {
381
+	public function column_name($theme) {
382 382
 		global $status, $page, $s;
383 383
 
384 384
 		$context = $status;
385 385
 
386
-		if ( $this->is_site_themes ) {
386
+		if ($this->is_site_themes) {
387 387
 			$url = "site-themes.php?id={$this->site_id}&amp;";
388
-			$allowed = $theme->is_allowed( 'site', $this->site_id );
388
+			$allowed = $theme->is_allowed('site', $this->site_id);
389 389
 		} else {
390 390
 			$url = 'themes.php?';
391
-			$allowed = $theme->is_allowed( 'network' );
391
+			$allowed = $theme->is_allowed('network');
392 392
 		}
393 393
 
394 394
 		// Pre-order.
@@ -400,85 +400,85 @@  discard block
 block discarded – undo
400 400
 		);
401 401
 
402 402
 		$stylesheet = $theme->get_stylesheet();
403
-		$theme_key = urlencode( $stylesheet );
403
+		$theme_key = urlencode($stylesheet);
404 404
 
405
-		if ( ! $allowed ) {
406
-			if ( ! $theme->errors() ) {
407
-				$url = add_query_arg( array(
405
+		if ( ! $allowed) {
406
+			if ( ! $theme->errors()) {
407
+				$url = add_query_arg(array(
408 408
 					'action' => 'enable',
409 409
 					'theme'  => $theme_key,
410 410
 					'paged'  => $page,
411 411
 					's'      => $s,
412
-				), $url );
412
+				), $url);
413 413
 
414
-				if ( $this->is_site_themes ) {
414
+				if ($this->is_site_themes) {
415 415
 					/* translators: %s: theme name */
416
-					$aria_label = sprintf( __( 'Enable %s' ), $theme->display( 'Name' ) );
416
+					$aria_label = sprintf(__('Enable %s'), $theme->display('Name'));
417 417
 				} else {
418 418
 					/* translators: %s: theme name */
419
-					$aria_label = sprintf( __( 'Network Enable %s' ), $theme->display( 'Name' ) );
419
+					$aria_label = sprintf(__('Network Enable %s'), $theme->display('Name'));
420 420
 				}
421 421
 
422
-				$actions['enable'] = sprintf( '<a href="%s" class="edit" aria-label="%s">%s</a>',
423
-					esc_url( wp_nonce_url( $url, 'enable-theme_' . $stylesheet ) ),
424
-					esc_attr( $aria_label ),
425
-					( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) )
422
+				$actions['enable'] = sprintf('<a href="%s" class="edit" aria-label="%s">%s</a>',
423
+					esc_url(wp_nonce_url($url, 'enable-theme_'.$stylesheet)),
424
+					esc_attr($aria_label),
425
+					($this->is_site_themes ? __('Enable') : __('Network Enable'))
426 426
 				);
427 427
 			}
428 428
 		} else {
429
-			$url = add_query_arg( array(
429
+			$url = add_query_arg(array(
430 430
 				'action' => 'disable',
431 431
 				'theme'  => $theme_key,
432 432
 				'paged'  => $page,
433 433
 				's'      => $s,
434
-			), $url );
434
+			), $url);
435 435
 
436
-			if ( $this->is_site_themes ) {
436
+			if ($this->is_site_themes) {
437 437
 				/* translators: %s: theme name */
438
-				$aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) );
438
+				$aria_label = sprintf(__('Disable %s'), $theme->display('Name'));
439 439
 			} else {
440 440
 				/* translators: %s: theme name */
441
-				$aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) );
441
+				$aria_label = sprintf(__('Network Disable %s'), $theme->display('Name'));
442 442
 			}
443 443
 
444
-			$actions['disable'] = sprintf( '<a href="%s" aria-label="%s">%s</a>',
445
-				esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ),
446
-				esc_attr( $aria_label ),
447
-				( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) )
444
+			$actions['disable'] = sprintf('<a href="%s" aria-label="%s">%s</a>',
445
+				esc_url(wp_nonce_url($url, 'disable-theme_'.$stylesheet)),
446
+				esc_attr($aria_label),
447
+				($this->is_site_themes ? __('Disable') : __('Network Disable'))
448 448
 			);
449 449
 		}
450 450
 
451
-		if ( current_user_can('edit_themes') ) {
452
-			$url = add_query_arg( array(
451
+		if (current_user_can('edit_themes')) {
452
+			$url = add_query_arg(array(
453 453
 				'theme' => $theme_key,
454
-			), 'theme-editor.php' );
454
+			), 'theme-editor.php');
455 455
 
456 456
 			/* translators: %s: theme name */
457
-			$aria_label = sprintf( __( 'Open %s in the Theme Editor' ), $theme->display( 'Name' ) );
457
+			$aria_label = sprintf(__('Open %s in the Theme Editor'), $theme->display('Name'));
458 458
 
459
-			$actions['edit'] = sprintf( '<a href="%s" class="edit" aria-label="%s">%s</a>',
460
-				esc_url( $url ),
461
-				esc_attr( $aria_label ),
462
-				__( 'Edit' )
459
+			$actions['edit'] = sprintf('<a href="%s" class="edit" aria-label="%s">%s</a>',
460
+				esc_url($url),
461
+				esc_attr($aria_label),
462
+				__('Edit')
463 463
 			);
464 464
 		}
465 465
 
466
-		if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) {
467
-			$url = add_query_arg( array(
466
+		if ( ! $allowed && current_user_can('delete_themes') && ! $this->is_site_themes && $stylesheet != get_option('stylesheet') && $stylesheet != get_option('template')) {
467
+			$url = add_query_arg(array(
468 468
 				'action'       => 'delete-selected',
469 469
 				'checked[]'    => $theme_key,
470 470
 				'theme_status' => $context,
471 471
 				'paged'        => $page,
472 472
 				's'            => $s,
473
-			), 'themes.php' );
473
+			), 'themes.php');
474 474
 
475 475
 			/* translators: %s: theme name */
476
-			$aria_label = sprintf( _x( 'Delete %s', 'theme' ), $theme->display( 'Name' ) );
476
+			$aria_label = sprintf(_x('Delete %s', 'theme'), $theme->display('Name'));
477 477
 
478
-			$actions['delete'] = sprintf( '<a href="%s" class="delete" aria-label="%s">%s</a>',
479
-				esc_url( wp_nonce_url( $url, 'bulk-themes' ) ),
480
-				esc_attr( $aria_label ),
481
-				__( 'Delete' )
478
+			$actions['delete'] = sprintf('<a href="%s" class="delete" aria-label="%s">%s</a>',
479
+				esc_url(wp_nonce_url($url, 'bulk-themes')),
480
+				esc_attr($aria_label),
481
+				__('Delete')
482 482
 			);
483 483
 		}
484 484
 		/**
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 		 * @param WP_Theme $theme   The current WP_Theme object.
504 504
 		 * @param string   $context Status of the theme.
505 505
 		 */
506
-		$actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme, $context );
506
+		$actions = apply_filters('theme_action_links', array_filter($actions), $theme, $context);
507 507
 
508 508
 		/**
509 509
 		 * Filters the action links of a specific theme in the Multisite themes
@@ -519,9 +519,9 @@  discard block
 block discarded – undo
519 519
 		 * @param WP_Theme $theme   The current WP_Theme object.
520 520
 		 * @param string   $context Status of the theme.
521 521
 		 */
522
-		$actions = apply_filters( "theme_action_links_{$stylesheet}", $actions, $theme, $context );
522
+		$actions = apply_filters("theme_action_links_{$stylesheet}", $actions, $theme, $context);
523 523
 
524
-		echo $this->row_actions( $actions, true );
524
+		echo $this->row_actions($actions, true);
525 525
 	}
526 526
 
527 527
 	/**
@@ -535,42 +535,42 @@  discard block
 block discarded – undo
535 535
 	 *
536 536
 	 * @param WP_Theme $theme The current WP_Theme object.
537 537
 	 */
538
-	public function column_description( $theme ) {
538
+	public function column_description($theme) {
539 539
 		global $status, $totals;
540
-		if ( $theme->errors() ) {
541
-			$pre = $status === 'broken' ? __( 'Broken Theme:' ) . ' ' : '';
542
-			echo '<p><strong class="error-message">' . $pre . $theme->errors()->get_error_message() . '</strong></p>';
540
+		if ($theme->errors()) {
541
+			$pre = $status === 'broken' ? __('Broken Theme:').' ' : '';
542
+			echo '<p><strong class="error-message">'.$pre.$theme->errors()->get_error_message().'</strong></p>';
543 543
 		}
544 544
 
545
-		if ( $this->is_site_themes ) {
546
-			$allowed = $theme->is_allowed( 'site', $this->site_id );
545
+		if ($this->is_site_themes) {
546
+			$allowed = $theme->is_allowed('site', $this->site_id);
547 547
 		} else {
548
-			$allowed = $theme->is_allowed( 'network' );
548
+			$allowed = $theme->is_allowed('network');
549 549
 		}
550 550
 
551 551
 		$class = ! $allowed ? 'inactive' : 'active';
552
-		if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) )
552
+		if ( ! empty($totals['upgrade']) && ! empty($theme->update))
553 553
 			$class .= ' update';
554 554
 
555
-		echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div>
555
+		echo "<div class='theme-description'><p>".$theme->display('Description')."</p></div>
556 556
 			<div class='$class second theme-version-author-uri'>";
557 557
 
558 558
 		$stylesheet = $theme->get_stylesheet();
559 559
 		$theme_meta = array();
560 560
 
561
-		if ( $theme->get('Version') ) {
562
-			$theme_meta[] = sprintf( __( 'Version %s' ), $theme->display('Version') );
561
+		if ($theme->get('Version')) {
562
+			$theme_meta[] = sprintf(__('Version %s'), $theme->display('Version'));
563 563
 		}
564
-		$theme_meta[] = sprintf( __( 'By %s' ), $theme->display('Author') );
564
+		$theme_meta[] = sprintf(__('By %s'), $theme->display('Author'));
565 565
 
566
-		if ( $theme->get('ThemeURI') ) {
566
+		if ($theme->get('ThemeURI')) {
567 567
 			/* translators: %s: theme name */
568
-			$aria_label = sprintf( __( 'Visit %s homepage' ), $theme->display( 'Name' ) );
568
+			$aria_label = sprintf(__('Visit %s homepage'), $theme->display('Name'));
569 569
 
570
-			$theme_meta[] = sprintf( '<a href="%s" aria-label="%s">%s</a>',
571
-				$theme->display( 'ThemeURI' ),
572
-				esc_attr( $aria_label ),
573
-				__( 'Visit Theme Site' )
570
+			$theme_meta[] = sprintf('<a href="%s" aria-label="%s">%s</a>',
571
+				$theme->display('ThemeURI'),
572
+				esc_attr($aria_label),
573
+				__('Visit Theme Site')
574 574
 			);
575 575
 		}
576 576
 		/**
@@ -586,8 +586,8 @@  discard block
 block discarded – undo
586 586
 		 * @param WP_Theme $theme      WP_Theme object.
587 587
 		 * @param string   $status     Status of the theme.
588 588
 		 */
589
-		$theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status );
590
-		echo implode( ' | ', $theme_meta );
589
+		$theme_meta = apply_filters('theme_row_meta', $theme_meta, $stylesheet, $theme, $status);
590
+		echo implode(' | ', $theme_meta);
591 591
 
592 592
 		echo '</div>';
593 593
 	}
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	 * @param WP_Theme $theme       The current WP_Theme object.
602 602
 	 * @param string   $column_name The current column name.
603 603
 	 */
604
-	public function column_default( $theme, $column_name ) {
604
+	public function column_default($theme, $column_name) {
605 605
 		$stylesheet = $theme->get_stylesheet();
606 606
 
607 607
 		/**
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 		 * @param string   $stylesheet  Directory name of the theme.
614 614
 		 * @param WP_Theme $theme       Current WP_Theme object.
615 615
 		 */
616
-		do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
616
+		do_action('manage_themes_custom_column', $column_name, $stylesheet, $theme);
617 617
 	}
618 618
 
619 619
 	/**
@@ -624,28 +624,28 @@  discard block
 block discarded – undo
624 624
 	 *
625 625
 	 * @param WP_Theme $item The current WP_Theme object.
626 626
 	 */
627
-	public function single_row_columns( $item ) {
628
-		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
627
+	public function single_row_columns($item) {
628
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
629 629
 
630
-		foreach ( $columns as $column_name => $column_display_name ) {
630
+		foreach ($columns as $column_name => $column_display_name) {
631 631
 			$extra_classes = '';
632
-			if ( in_array( $column_name, $hidden ) ) {
632
+			if (in_array($column_name, $hidden)) {
633 633
 				$extra_classes .= ' hidden';
634 634
 			}
635 635
 
636
-			switch ( $column_name ) {
636
+			switch ($column_name) {
637 637
 				case 'cb':
638 638
 					echo '<th scope="row" class="check-column">';
639 639
 
640
-					$this->column_cb( $item );
640
+					$this->column_cb($item);
641 641
 
642 642
 					echo '</th>';
643 643
 					break;
644 644
 
645 645
 				case 'name':
646
-					echo "<td class='theme-title column-primary{$extra_classes}'><strong>" . $item->display('Name') . "</strong>";
646
+					echo "<td class='theme-title column-primary{$extra_classes}'><strong>".$item->display('Name')."</strong>";
647 647
 
648
-					$this->column_name( $item );
648
+					$this->column_name($item);
649 649
 
650 650
 					echo "</td>";
651 651
 					break;
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 				case 'description':
654 654
 					echo "<td class='column-description desc{$extra_classes}'>";
655 655
 
656
-					$this->column_description( $item );
656
+					$this->column_description($item);
657 657
 
658 658
 					echo '</td>';
659 659
 					break;
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 				default:
662 662
 					echo "<td class='$column_name column-$column_name{$extra_classes}'>";
663 663
 
664
-					$this->column_default( $item, $column_name );
664
+					$this->column_default($item, $column_name);
665 665
 
666 666
 					echo "</td>";
667 667
 					break;
@@ -675,33 +675,33 @@  discard block
 block discarded – undo
675 675
 	 *
676 676
 	 * @param WP_Theme $theme
677 677
 	 */
678
-	public function single_row( $theme ) {
678
+	public function single_row($theme) {
679 679
 		global $status, $totals;
680 680
 
681
-		if ( $this->is_site_themes ) {
682
-			$allowed = $theme->is_allowed( 'site', $this->site_id );
681
+		if ($this->is_site_themes) {
682
+			$allowed = $theme->is_allowed('site', $this->site_id);
683 683
 		} else {
684
-			$allowed = $theme->is_allowed( 'network' );
684
+			$allowed = $theme->is_allowed('network');
685 685
 		}
686 686
 
687 687
 		$stylesheet = $theme->get_stylesheet();
688 688
 
689 689
 		$class = ! $allowed ? 'inactive' : 'active';
690
-		if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) {
690
+		if ( ! empty($totals['upgrade']) && ! empty($theme->update)) {
691 691
 			$class .= ' update';
692 692
 		}
693 693
 
694
-		printf( '<tr class="%s" data-slug="%s">',
695
-			esc_attr( $class ),
696
-			esc_attr( $stylesheet )
694
+		printf('<tr class="%s" data-slug="%s">',
695
+			esc_attr($class),
696
+			esc_attr($stylesheet)
697 697
 		);
698 698
 
699
-		$this->single_row_columns( $theme );
699
+		$this->single_row_columns($theme);
700 700
 
701 701
 		echo "</tr>";
702 702
 
703
-		if ( $this->is_site_themes )
704
-			remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' );
703
+		if ($this->is_site_themes)
704
+			remove_action("after_theme_row_$stylesheet", 'wp_theme_update_row');
705 705
 
706 706
 		/**
707 707
 		 * Fires after each row in the Multisite themes list table.
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 		 * @param WP_Theme $theme      Current WP_Theme object.
713 713
 		 * @param string   $status     Status of the theme.
714 714
 		 */
715
-		do_action( 'after_theme_row', $stylesheet, $theme, $status );
715
+		do_action('after_theme_row', $stylesheet, $theme, $status);
716 716
 
717 717
 		/**
718 718
 		 * Fires after each specific row in the Multisite themes list table.
@@ -727,6 +727,6 @@  discard block
 block discarded – undo
727 727
 		 * @param WP_Theme $theme      Current WP_Theme object.
728 728
 		 * @param string   $status     Status of the theme.
729 729
 		 */
730
-		do_action( "after_theme_row_{$stylesheet}", $stylesheet, $theme, $status );
730
+		do_action("after_theme_row_{$stylesheet}", $stylesheet, $theme, $status);
731 731
 	}
732 732
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-ms-users-list-table.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -389,7 +389,7 @@
 block discarded – undo
389 389
 	 * @since 4.3.0
390 390
 	 * @access protected
391 391
 	 *
392
-	 * @param object $user        User being acted upon.
392
+	 * @param WP_User $user        User being acted upon.
393 393
 	 * @param string $column_name Current column name.
394 394
 	 * @param string $primary     Primary column name.
395 395
 	 * @return string Row actions output for users in Multisite.
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -68,18 +68,22 @@  discard block
 block discarded – undo
68 68
 		 * expensive count queries.
69 69
 		 */
70 70
 		if ( !$usersearch && wp_is_large_network( 'users' ) ) {
71
-			if ( !isset($_REQUEST['orderby']) )
72
-				$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
73
-			if ( !isset($_REQUEST['order']) )
74
-				$_GET['order'] = $_REQUEST['order'] = 'DESC';
71
+			if ( !isset($_REQUEST['orderby']) ) {
72
+							$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
73
+			}
74
+			if ( !isset($_REQUEST['order']) ) {
75
+							$_GET['order'] = $_REQUEST['order'] = 'DESC';
76
+			}
75 77
 			$args['count_total'] = false;
76 78
 		}
77 79
 
78
-		if ( isset( $_REQUEST['orderby'] ) )
79
-			$args['orderby'] = $_REQUEST['orderby'];
80
+		if ( isset( $_REQUEST['orderby'] ) ) {
81
+					$args['orderby'] = $_REQUEST['orderby'];
82
+		}
80 83
 
81
-		if ( isset( $_REQUEST['order'] ) )
82
-			$args['order'] = $_REQUEST['order'];
84
+		if ( isset( $_REQUEST['order'] ) ) {
85
+					$args['order'] = $_REQUEST['order'];
86
+		}
83 87
 
84 88
 		if ( ! empty( $_REQUEST['mode'] ) ) {
85 89
 			$mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list';
@@ -108,8 +112,9 @@  discard block
 block discarded – undo
108 112
 	 */
109 113
 	protected function get_bulk_actions() {
110 114
 		$actions = array();
111
-		if ( current_user_can( 'delete_users' ) )
112
-			$actions['delete'] = __( 'Delete' );
115
+		if ( current_user_can( 'delete_users' ) ) {
116
+					$actions['delete'] = __( 'Delete' );
117
+		}
113 118
 		$actions['spam'] = _x( 'Mark as Spam', 'user' );
114 119
 		$actions['notspam'] = _x( 'Not Spam', 'user' );
115 120
 
Please login to merge, or discard this patch.
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @return bool
22 22
 	 */
23 23
 	public function ajax_user_can() {
24
-		return current_user_can( 'manage_network_users' );
24
+		return current_user_can('manage_network_users');
25 25
 	}
26 26
 
27 27
 	/**
@@ -34,32 +34,32 @@  discard block
 block discarded – undo
34 34
 	public function prepare_items() {
35 35
 		global $usersearch, $role, $wpdb, $mode;
36 36
 
37
-		$usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
37
+		$usersearch = isset($_REQUEST['s']) ? wp_unslash(trim($_REQUEST['s'])) : '';
38 38
 
39
-		$users_per_page = $this->get_items_per_page( 'users_network_per_page' );
39
+		$users_per_page = $this->get_items_per_page('users_network_per_page');
40 40
 
41
-		$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
41
+		$role = isset($_REQUEST['role']) ? $_REQUEST['role'] : '';
42 42
 
43 43
 		$paged = $this->get_pagenum();
44 44
 
45 45
 		$args = array(
46 46
 			'number' => $users_per_page,
47
-			'offset' => ( $paged-1 ) * $users_per_page,
47
+			'offset' => ($paged - 1) * $users_per_page,
48 48
 			'search' => $usersearch,
49 49
 			'blog_id' => 0,
50 50
 			'fields' => 'all_with_meta'
51 51
 		);
52 52
 
53
-		if ( wp_is_large_network( 'users' ) ) {
54
-			$args['search'] = ltrim( $args['search'], '*' );
55
-		} else if ( '' !== $args['search'] ) {
56
-			$args['search'] = trim( $args['search'], '*' );
57
-			$args['search'] = '*' . $args['search'] . '*';
53
+		if (wp_is_large_network('users')) {
54
+			$args['search'] = ltrim($args['search'], '*');
55
+		} else if ('' !== $args['search']) {
56
+			$args['search'] = trim($args['search'], '*');
57
+			$args['search'] = '*'.$args['search'].'*';
58 58
 		}
59 59
 
60
-		if ( $role === 'super' ) {
61
-			$logins = implode( "', '", get_super_admins() );
62
-			$args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
60
+		if ($role === 'super') {
61
+			$logins = implode("', '", get_super_admins());
62
+			$args['include'] = $wpdb->get_col("SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')");
63 63
 		}
64 64
 
65 65
 		/*
@@ -67,39 +67,39 @@  discard block
 block discarded – undo
67 67
 		 * show only the latest users with no paging in order to avoid
68 68
 		 * expensive count queries.
69 69
 		 */
70
-		if ( !$usersearch && wp_is_large_network( 'users' ) ) {
71
-			if ( !isset($_REQUEST['orderby']) )
70
+		if ( ! $usersearch && wp_is_large_network('users')) {
71
+			if ( ! isset($_REQUEST['orderby']))
72 72
 				$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
73
-			if ( !isset($_REQUEST['order']) )
73
+			if ( ! isset($_REQUEST['order']))
74 74
 				$_GET['order'] = $_REQUEST['order'] = 'DESC';
75 75
 			$args['count_total'] = false;
76 76
 		}
77 77
 
78
-		if ( isset( $_REQUEST['orderby'] ) )
78
+		if (isset($_REQUEST['orderby']))
79 79
 			$args['orderby'] = $_REQUEST['orderby'];
80 80
 
81
-		if ( isset( $_REQUEST['order'] ) )
81
+		if (isset($_REQUEST['order']))
82 82
 			$args['order'] = $_REQUEST['order'];
83 83
 
84
-		if ( ! empty( $_REQUEST['mode'] ) ) {
84
+		if ( ! empty($_REQUEST['mode'])) {
85 85
 			$mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list';
86
-			set_user_setting( 'network_users_list_mode', $mode );
86
+			set_user_setting('network_users_list_mode', $mode);
87 87
 		} else {
88
-			$mode = get_user_setting( 'network_users_list_mode', 'list' );
88
+			$mode = get_user_setting('network_users_list_mode', 'list');
89 89
 		}
90 90
 
91 91
 		/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
92
-		$args = apply_filters( 'users_list_table_query_args', $args );
92
+		$args = apply_filters('users_list_table_query_args', $args);
93 93
 
94 94
 		// Query the user IDs for this page
95
-		$wp_user_search = new WP_User_Query( $args );
95
+		$wp_user_search = new WP_User_Query($args);
96 96
 
97 97
 		$this->items = $wp_user_search->get_results();
98 98
 
99
-		$this->set_pagination_args( array(
99
+		$this->set_pagination_args(array(
100 100
 			'total_items' => $wp_user_search->get_total(),
101 101
 			'per_page' => $users_per_page,
102
-		) );
102
+		));
103 103
 	}
104 104
 
105 105
 	/**
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	protected function get_bulk_actions() {
110 110
 		$actions = array();
111
-		if ( current_user_can( 'delete_users' ) )
112
-			$actions['delete'] = __( 'Delete' );
113
-		$actions['spam'] = _x( 'Mark as Spam', 'user' );
114
-		$actions['notspam'] = _x( 'Not Spam', 'user' );
111
+		if (current_user_can('delete_users'))
112
+			$actions['delete'] = __('Delete');
113
+		$actions['spam'] = _x('Mark as Spam', 'user');
114
+		$actions['notspam'] = _x('Not Spam', 'user');
115 115
 
116 116
 		return $actions;
117 117
 	}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * @access public
121 121
 	 */
122 122
 	public function no_items() {
123
-		_e( 'No users found.' );
123
+		_e('No users found.');
124 124
 	}
125 125
 
126 126
 	/**
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 
134 134
 		$total_users = get_user_count();
135 135
 		$super_admins = get_super_admins();
136
-		$total_admins = count( $super_admins );
136
+		$total_admins = count($super_admins);
137 137
 
138 138
 		$class = $role != 'super' ? ' class="current"' : '';
139 139
 		$role_links = array();
140
-		$role_links['all'] = "<a href='" . network_admin_url('users.php') . "'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
140
+		$role_links['all'] = "<a href='".network_admin_url('users.php')."'$class>".sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users'), number_format_i18n($total_users)).'</a>';
141 141
 		$class = $role === 'super' ? ' class="current"' : '';
142
-		$role_links['super'] = "<a href='" . network_admin_url('users.php?role=super') . "'$class>" . sprintf( _n( 'Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins ), number_format_i18n( $total_admins ) ) . '</a>';
142
+		$role_links['super'] = "<a href='".network_admin_url('users.php?role=super')."'$class>".sprintf(_n('Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins), number_format_i18n($total_admins)).'</a>';
143 143
 
144 144
 		return $role_links;
145 145
 	}
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param string $which
151 151
 	 */
152
-	protected function pagination( $which ) {
152
+	protected function pagination($which) {
153 153
 		global $mode;
154 154
 
155
-		parent::pagination ( $which );
155
+		parent::pagination($which);
156 156
 
157
-		if ( 'top' === $which ) {
158
-			$this->view_switcher( $mode );
157
+		if ('top' === $which) {
158
+			$this->view_switcher($mode);
159 159
 		}
160 160
 	}
161 161
 
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
 	public function get_columns() {
167 167
 		$users_columns = array(
168 168
 			'cb'         => '<input type="checkbox" />',
169
-			'username'   => __( 'Username' ),
170
-			'name'       => __( 'Name' ),
171
-			'email'      => __( 'Email' ),
172
-			'registered' => _x( 'Registered', 'user' ),
173
-			'blogs'      => __( 'Sites' )
169
+			'username'   => __('Username'),
170
+			'name'       => __('Name'),
171
+			'email'      => __('Email'),
172
+			'registered' => _x('Registered', 'user'),
173
+			'blogs'      => __('Sites')
174 174
 		);
175 175
 		/**
176 176
 		 * Filters the columns displayed in the Network Admin Users list table.
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		 * @param array $users_columns An array of user columns. Default 'cb', 'username',
181 181
 		 *                             'name', 'email', 'registered', 'blogs'.
182 182
 		 */
183
-		return apply_filters( 'wpmu_users_columns', $users_columns );
183
+		return apply_filters('wpmu_users_columns', $users_columns);
184 184
 	}
185 185
 
186 186
 	/**
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @param WP_User $user The current WP_User object.
206 206
 	 */
207
-	public function column_cb( $user ) {
208
-		if ( is_super_admin( $user->ID ) ) {
207
+	public function column_cb($user) {
208
+		if (is_super_admin($user->ID)) {
209 209
 			return;
210 210
 		}
211 211
 		?>
212
-		<label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label>
213
-		<input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" />
212
+		<label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf(__('Select %s'), $user->user_login); ?></label>
213
+		<input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr($user->ID) ?>" />
214 214
 		<?php
215 215
 	}
216 216
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @param WP_User $user The current WP_User object.
224 224
 	 */
225
-	public function column_id( $user ) {
225
+	public function column_id($user) {
226 226
 		echo $user->ID;
227 227
 	}
228 228
 
@@ -234,16 +234,16 @@  discard block
 block discarded – undo
234 234
 	 *
235 235
 	 * @param WP_User $user The current WP_User object.
236 236
 	 */
237
-	public function column_username( $user ) {
237
+	public function column_username($user) {
238 238
 		$super_admins = get_super_admins();
239
-		$avatar	= get_avatar( $user->user_email, 32 );
240
-		$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
239
+		$avatar = get_avatar($user->user_email, 32);
240
+		$edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user->ID)));
241 241
 
242 242
 		echo $avatar;
243 243
 
244 244
 		?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php
245
-		if ( in_array( $user->user_login, $super_admins ) ) {
246
-			echo ' - ' . __( 'Super Admin' );
245
+		if (in_array($user->user_login, $super_admins)) {
246
+			echo ' - '.__('Super Admin');
247 247
 		}
248 248
 		?></strong>
249 249
 	<?php
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 *
258 258
 	 * @param WP_User $user The current WP_User object.
259 259
 	 */
260
-	public function column_name( $user ) {
260
+	public function column_name($user) {
261 261
 		echo "$user->first_name $user->last_name";
262 262
 	}
263 263
 
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 * @param WP_User $user The current WP_User object.
271 271
 	 */
272
-	public function column_email( $user ) {
273
-		echo "<a href='" . esc_url( "mailto:$user->user_email" ) . "'>$user->user_email</a>";
272
+	public function column_email($user) {
273
+		echo "<a href='".esc_url("mailto:$user->user_email")."'>$user->user_email</a>";
274 274
 	}
275 275
 
276 276
 	/**
@@ -283,14 +283,14 @@  discard block
 block discarded – undo
283 283
 	 *
284 284
 	 * @param WP_User $user The current WP_User object.
285 285
 	 */
286
-	public function column_registered( $user ) {
286
+	public function column_registered($user) {
287 287
 		global $mode;
288
-		if ( 'list' === $mode ) {
289
-			$date = __( 'Y/m/d' );
288
+		if ('list' === $mode) {
289
+			$date = __('Y/m/d');
290 290
 		} else {
291
-			$date = __( 'Y/m/d g:i:s a' );
291
+			$date = __('Y/m/d g:i:s a');
292 292
 		}
293
-		echo mysql2date( $date, $user->user_registered );
293
+		echo mysql2date($date, $user->user_registered);
294 294
 	}
295 295
 
296 296
 	/**
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 	 * @param string  $data
303 303
 	 * @param string  $primary
304 304
 	 */
305
-	protected function _column_blogs( $user, $classes, $data, $primary ) {
305
+	protected function _column_blogs($user, $classes, $data, $primary) {
306 306
 		echo '<td class="', $classes, ' has-row-actions" ', $data, '>';
307
-		echo $this->column_blogs( $user );
308
-		echo $this->handle_row_actions( $user, 'blogs', $primary );
307
+		echo $this->column_blogs($user);
308
+		echo $this->handle_row_actions($user, 'blogs', $primary);
309 309
 		echo '</td>';
310 310
 	}
311 311
 
@@ -317,39 +317,39 @@  discard block
 block discarded – undo
317 317
 	 *
318 318
 	 * @param WP_User $user The current WP_User object.
319 319
 	 */
320
-	public function column_blogs( $user ) {
321
-		$blogs = get_blogs_of_user( $user->ID, true );
322
-		if ( ! is_array( $blogs ) ) {
320
+	public function column_blogs($user) {
321
+		$blogs = get_blogs_of_user($user->ID, true);
322
+		if ( ! is_array($blogs)) {
323 323
 			return;
324 324
 		}
325 325
 
326
-		foreach ( $blogs as $val ) {
327
-			if ( ! can_edit_network( $val->site_id ) ) {
326
+		foreach ($blogs as $val) {
327
+			if ( ! can_edit_network($val->site_id)) {
328 328
 				continue;
329 329
 			}
330 330
 
331
-			$path	= ( $val->path === '/' ) ? '' : $val->path;
332
-			echo '<span class="site-' . $val->site_id . '" >';
333
-			echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . get_network()->domain, '', $val->domain . $path ) . '</a>';
331
+			$path = ($val->path === '/') ? '' : $val->path;
332
+			echo '<span class="site-'.$val->site_id.'" >';
333
+			echo '<a href="'.esc_url(network_admin_url('site-info.php?id='.$val->userblog_id)).'">'.str_replace('.'.get_network()->domain, '', $val->domain.$path).'</a>';
334 334
 			echo ' <small class="row-actions">';
335 335
 			$actions = array();
336
-			$actions['edit'] = '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a>';
336
+			$actions['edit'] = '<a href="'.esc_url(network_admin_url('site-info.php?id='.$val->userblog_id)).'">'.__('Edit').'</a>';
337 337
 
338 338
 			$class = '';
339
-			if ( $val->spam == 1 ) {
339
+			if ($val->spam == 1) {
340 340
 				$class .= 'site-spammed ';
341 341
 			}
342
-			if ( $val->mature == 1 ) {
342
+			if ($val->mature == 1) {
343 343
 				$class .= 'site-mature ';
344 344
 			}
345
-			if ( $val->deleted == 1 ) {
345
+			if ($val->deleted == 1) {
346 346
 				$class .= 'site-deleted ';
347 347
 			}
348
-			if ( $val->archived == 1 ) {
348
+			if ($val->archived == 1) {
349 349
 				$class .= 'site-archived ';
350 350
 			}
351 351
 
352
-			$actions['view'] = '<a class="' . $class . '" href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'View' ) . '</a>';
352
+			$actions['view'] = '<a class="'.$class.'" href="'.esc_url(get_home_url($val->userblog_id)).'">'.__('View').'</a>';
353 353
 
354 354
 			/**
355 355
 			 * Filters the action links displayed next the sites a user belongs to
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
 			 *                           Default 'Edit', 'View'.
362 362
 			 * @param int   $userblog_id The site ID.
363 363
 			 */
364
-			$actions = apply_filters( 'ms_user_list_site_actions', $actions, $val->userblog_id );
364
+			$actions = apply_filters('ms_user_list_site_actions', $actions, $val->userblog_id);
365 365
 
366
-			$i=0;
367
-			$action_count = count( $actions );
368
-			foreach ( $actions as $action => $link ) {
366
+			$i = 0;
367
+			$action_count = count($actions);
368
+			foreach ($actions as $action => $link) {
369 369
 				++$i;
370
-				$sep = ( $i == $action_count ) ? '' : ' | ';
370
+				$sep = ($i == $action_count) ? '' : ' | ';
371 371
 				echo "<span class='$action'>$link$sep</span>";
372 372
 			}
373 373
 			echo '</small></span><br/>';
@@ -383,26 +383,26 @@  discard block
 block discarded – undo
383 383
 	 * @param WP_User $user       The current WP_User object.
384 384
 	 * @param string $column_name The current column name.
385 385
 	 */
386
-	public function column_default( $user, $column_name ) {
386
+	public function column_default($user, $column_name) {
387 387
 		/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
388
-		echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
388
+		echo apply_filters('manage_users_custom_column', '', $column_name, $user->ID);
389 389
 	}
390 390
 
391 391
 	public function display_rows() {
392
-		foreach ( $this->items as $user ) {
392
+		foreach ($this->items as $user) {
393 393
 			$class = '';
394 394
 
395
-			$status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
395
+			$status_list = array('spam' => 'site-spammed', 'deleted' => 'site-deleted');
396 396
 
397
-			foreach ( $status_list as $status => $col ) {
398
-				if ( $user->$status ) {
397
+			foreach ($status_list as $status => $col) {
398
+				if ($user->$status) {
399 399
 					$class .= " $col";
400 400
 				}
401 401
 			}
402 402
 
403 403
 			?>
404
-			<tr class="<?php echo trim( $class ); ?>">
405
-				<?php $this->single_row_columns( $user ); ?>
404
+			<tr class="<?php echo trim($class); ?>">
405
+				<?php $this->single_row_columns($user); ?>
406 406
 			</tr>
407 407
 			<?php
408 408
 		}
@@ -431,19 +431,19 @@  discard block
 block discarded – undo
431 431
 	 * @param string $primary     Primary column name.
432 432
 	 * @return string Row actions output for users in Multisite.
433 433
 	 */
434
-	protected function handle_row_actions( $user, $column_name, $primary ) {
435
-		if ( $primary !== $column_name ) {
434
+	protected function handle_row_actions($user, $column_name, $primary) {
435
+		if ($primary !== $column_name) {
436 436
 			return '';
437 437
 		}
438 438
 
439 439
 		$super_admins = get_super_admins();
440
-		$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
440
+		$edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user->ID)));
441 441
 
442 442
 		$actions = array();
443
-		$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
443
+		$actions['edit'] = '<a href="'.$edit_link.'">'.__('Edit').'</a>';
444 444
 
445
-		if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {
446
-			$actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
445
+		if (current_user_can('delete_user', $user->ID) && ! in_array($user->user_login, $super_admins)) {
446
+			$actions['delete'] = '<a href="'.$delete = esc_url(network_admin_url(add_query_arg('_wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), wp_nonce_url('users.php', 'deleteuser').'&amp;action=deleteuser&amp;id='.$user->ID))).'" class="delete">'.__('Delete').'</a>';
447 447
 		}
448 448
 
449 449
 		/**
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 		 *                         Default 'Edit', 'Delete'.
456 456
 		 * @param WP_User $user    WP_User object.
457 457
 		 */
458
-		$actions = apply_filters( 'ms_user_row_actions', $actions, $user );
459
-		return $this->row_actions( $actions );
458
+		$actions = apply_filters('ms_user_row_actions', $actions, $user);
459
+		return $this->row_actions($actions);
460 460
 	}
461 461
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/file.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -833,7 +833,7 @@
 block discarded – undo
833 833
  *
834 834
  * @global WP_Filesystem_Base $wp_filesystem Subclass
835 835
  *
836
- * @param array|false  $args                         Optional. Connection args, These are passed directly to
836
+ * @param boolean  $args                         Optional. Connection args, These are passed directly to
837 837
  *                                                   the `WP_Filesystem_*()` classes. Default false.
838 838
  * @param string|false $context                      Optional. Context for get_filesystem_method(). Default false.
839 839
  * @param bool         $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
Please login to merge, or discard this patch.
Spacing   +380 added lines, -380 removed lines patch added patch discarded remove patch
@@ -13,54 +13,54 @@  discard block
 block discarded – undo
13 13
 
14 14
 /** The descriptions for theme files. */
15 15
 $wp_file_descriptions = array(
16
-	'functions.php'         => __( 'Theme Functions' ),
17
-	'header.php'            => __( 'Theme Header' ),
18
-	'footer.php'            => __( 'Theme Footer' ),
19
-	'sidebar.php'           => __( 'Sidebar' ),
20
-	'comments.php'          => __( 'Comments' ),
21
-	'searchform.php'        => __( 'Search Form' ),
22
-	'404.php'               => __( '404 Template' ),
23
-	'link.php'              => __( 'Links Template' ),
16
+	'functions.php'         => __('Theme Functions'),
17
+	'header.php'            => __('Theme Header'),
18
+	'footer.php'            => __('Theme Footer'),
19
+	'sidebar.php'           => __('Sidebar'),
20
+	'comments.php'          => __('Comments'),
21
+	'searchform.php'        => __('Search Form'),
22
+	'404.php'               => __('404 Template'),
23
+	'link.php'              => __('Links Template'),
24 24
 	// Archives
25
-	'index.php'             => __( 'Main Index Template' ),
26
-	'archive.php'           => __( 'Archives' ),
27
-	'author.php'            => __( 'Author Template' ),
28
-	'taxonomy.php'          => __( 'Taxonomy Template' ),
29
-	'category.php'          => __( 'Category Template' ),
30
-	'tag.php'               => __( 'Tag Template' ),
31
-	'home.php'              => __( 'Posts Page' ),
32
-	'search.php'            => __( 'Search Results' ),
33
-	'date.php'              => __( 'Date Template' ),
25
+	'index.php'             => __('Main Index Template'),
26
+	'archive.php'           => __('Archives'),
27
+	'author.php'            => __('Author Template'),
28
+	'taxonomy.php'          => __('Taxonomy Template'),
29
+	'category.php'          => __('Category Template'),
30
+	'tag.php'               => __('Tag Template'),
31
+	'home.php'              => __('Posts Page'),
32
+	'search.php'            => __('Search Results'),
33
+	'date.php'              => __('Date Template'),
34 34
 	// Content
35
-	'singular.php'          => __( 'Singular Template' ),
36
-	'single.php'            => __( 'Single Post' ),
37
-	'page.php'              => __( 'Single Page' ),
38
-	'front-page.php'        => __( 'Static Front Page' ),
35
+	'singular.php'          => __('Singular Template'),
36
+	'single.php'            => __('Single Post'),
37
+	'page.php'              => __('Single Page'),
38
+	'front-page.php'        => __('Static Front Page'),
39 39
 	// Attachments
40
-	'attachment.php'        => __( 'Attachment Template' ),
41
-	'image.php'             => __( 'Image Attachment Template' ),
42
-	'video.php'             => __( 'Video Attachment Template' ),
43
-	'audio.php'             => __( 'Audio Attachment Template' ),
44
-	'application.php'       => __( 'Application Attachment Template' ),
40
+	'attachment.php'        => __('Attachment Template'),
41
+	'image.php'             => __('Image Attachment Template'),
42
+	'video.php'             => __('Video Attachment Template'),
43
+	'audio.php'             => __('Audio Attachment Template'),
44
+	'application.php'       => __('Application Attachment Template'),
45 45
 	// Embeds
46
-	'embed.php'             => __( 'Embed Template' ),
47
-	'embed-404.php'         => __( 'Embed 404 Template' ),
48
-	'embed-content.php'     => __( 'Embed Content Template' ),
49
-	'header-embed.php'      => __( 'Embed Header Template' ),
50
-	'footer-embed.php'      => __( 'Embed Footer Template' ),
46
+	'embed.php'             => __('Embed Template'),
47
+	'embed-404.php'         => __('Embed 404 Template'),
48
+	'embed-content.php'     => __('Embed Content Template'),
49
+	'header-embed.php'      => __('Embed Header Template'),
50
+	'footer-embed.php'      => __('Embed Footer Template'),
51 51
 	// Stylesheets
52
-	'style.css'             => __( 'Stylesheet' ),
53
-	'editor-style.css'      => __( 'Visual Editor Stylesheet' ),
54
-	'editor-style-rtl.css'  => __( 'Visual Editor RTL Stylesheet' ),
55
-	'rtl.css'               => __( 'RTL Stylesheet' ),
52
+	'style.css'             => __('Stylesheet'),
53
+	'editor-style.css'      => __('Visual Editor Stylesheet'),
54
+	'editor-style-rtl.css'  => __('Visual Editor RTL Stylesheet'),
55
+	'rtl.css'               => __('RTL Stylesheet'),
56 56
 	// Other
57
-	'my-hacks.php'          => __( 'my-hacks.php (legacy hacks support)' ),
58
-	'.htaccess'             => __( '.htaccess (for rewrite rules )' ),
57
+	'my-hacks.php'          => __('my-hacks.php (legacy hacks support)'),
58
+	'.htaccess'             => __('.htaccess (for rewrite rules )'),
59 59
 	// Deprecated files
60
-	'wp-layout.css'         => __( 'Stylesheet' ),
61
-	'wp-comments.php'       => __( 'Comments Template' ),
62
-	'wp-comments-popup.php' => __( 'Popup Comments Template' ),
63
-	'comments-popup.php'    => __( 'Popup Comments' ),
60
+	'wp-layout.css'         => __('Stylesheet'),
61
+	'wp-comments.php'       => __('Comments Template'),
62
+	'wp-comments-popup.php' => __('Popup Comments Template'),
63
+	'comments-popup.php'    => __('Popup Comments'),
64 64
 );
65 65
 
66 66
 /**
@@ -74,22 +74,22 @@  discard block
 block discarded – undo
74 74
  * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist.
75 75
  *                Appends 'Page Template' to basename of $file if the file is a page template
76 76
  */
77
-function get_file_description( $file ) {
77
+function get_file_description($file) {
78 78
 	global $wp_file_descriptions, $allowed_files;
79 79
 
80
-	$dirname = pathinfo( $file, PATHINFO_DIRNAME );
80
+	$dirname = pathinfo($file, PATHINFO_DIRNAME);
81 81
 
82
-	$file_path = $allowed_files[ $file ];
83
-	if ( isset( $wp_file_descriptions[ basename( $file ) ] ) && '.' === $dirname ) {
84
-		return $wp_file_descriptions[ basename( $file ) ];
85
-	} elseif ( file_exists( $file_path ) && is_file( $file_path ) ) {
86
-		$template_data = implode( '', file( $file_path ) );
87
-		if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) {
88
-			return sprintf( __( '%s Page Template' ), _cleanup_header_comment( $name[1] ) );
82
+	$file_path = $allowed_files[$file];
83
+	if (isset($wp_file_descriptions[basename($file)]) && '.' === $dirname) {
84
+		return $wp_file_descriptions[basename($file)];
85
+	} elseif (file_exists($file_path) && is_file($file_path)) {
86
+		$template_data = implode('', file($file_path));
87
+		if (preg_match('|Template Name:(.*)$|mi', $template_data, $name)) {
88
+			return sprintf(__('%s Page Template'), _cleanup_header_comment($name[1]));
89 89
 		}
90 90
 	}
91 91
 
92
-	return trim( basename( $file ) );
92
+	return trim(basename($file));
93 93
 }
94 94
 
95 95
 /**
@@ -100,18 +100,18 @@  discard block
 block discarded – undo
100 100
  * @return string Full filesystem path to the root of the WordPress installation
101 101
  */
102 102
 function get_home_path() {
103
-	$home    = set_url_scheme( get_option( 'home' ), 'http' );
104
-	$siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
105
-	if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
106
-		$wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
107
-		$pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) );
108
-		$home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos );
109
-		$home_path = trailingslashit( $home_path );
103
+	$home    = set_url_scheme(get_option('home'), 'http');
104
+	$siteurl = set_url_scheme(get_option('siteurl'), 'http');
105
+	if ( ! empty($home) && 0 !== strcasecmp($home, $siteurl)) {
106
+		$wp_path_rel_to_home = str_ireplace($home, '', $siteurl); /* $siteurl - $home */
107
+		$pos = strripos(str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']), trailingslashit($wp_path_rel_to_home));
108
+		$home_path = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos);
109
+		$home_path = trailingslashit($home_path);
110 110
 	} else {
111 111
 		$home_path = ABSPATH;
112 112
 	}
113 113
 
114
-	return str_replace( '\\', '/', $home_path );
114
+	return str_replace('\\', '/', $home_path);
115 115
 }
116 116
 
117 117
 /**
@@ -124,30 +124,30 @@  discard block
 block discarded – undo
124 124
  * @param int    $levels Optional. Levels of folders to follow, Default 100 (PHP Loop limit).
125 125
  * @return bool|array False on failure, Else array of files
126 126
  */
127
-function list_files( $folder = '', $levels = 100 ) {
128
-	if ( empty($folder) )
127
+function list_files($folder = '', $levels = 100) {
128
+	if (empty($folder))
129 129
 		return false;
130 130
 
131
-	if ( ! $levels )
131
+	if ( ! $levels)
132 132
 		return false;
133 133
 
134 134
 	$files = array();
135
-	if ( $dir = @opendir( $folder ) ) {
136
-		while (($file = readdir( $dir ) ) !== false ) {
137
-			if ( in_array($file, array('.', '..') ) )
135
+	if ($dir = @opendir($folder)) {
136
+		while (($file = readdir($dir)) !== false) {
137
+			if (in_array($file, array('.', '..')))
138 138
 				continue;
139
-			if ( is_dir( $folder . '/' . $file ) ) {
140
-				$files2 = list_files( $folder . '/' . $file, $levels - 1);
141
-				if ( $files2 )
142
-					$files = array_merge($files, $files2 );
139
+			if (is_dir($folder.'/'.$file)) {
140
+				$files2 = list_files($folder.'/'.$file, $levels - 1);
141
+				if ($files2)
142
+					$files = array_merge($files, $files2);
143 143
 				else
144
-					$files[] = $folder . '/' . $file . '/';
144
+					$files[] = $folder.'/'.$file.'/';
145 145
 			} else {
146
-				$files[] = $folder . '/' . $file;
146
+				$files[] = $folder.'/'.$file;
147 147
 			}
148 148
 		}
149 149
 	}
150
-	@closedir( $dir );
150
+	@closedir($dir);
151 151
 	return $files;
152 152
 }
153 153
 
@@ -164,35 +164,35 @@  discard block
 block discarded – undo
164 164
  * @param string $dir      Optional. Directory to store the file in. Default empty.
165 165
  * @return string a writable filename
166 166
  */
167
-function wp_tempnam( $filename = '', $dir = '' ) {
168
-	if ( empty( $dir ) ) {
167
+function wp_tempnam($filename = '', $dir = '') {
168
+	if (empty($dir)) {
169 169
 		$dir = get_temp_dir();
170 170
 	}
171 171
 
172
-	if ( empty( $filename ) || '.' == $filename || '/' == $filename || '\\' == $filename ) {
172
+	if (empty($filename) || '.' == $filename || '/' == $filename || '\\' == $filename) {
173 173
 		$filename = time();
174 174
 	}
175 175
 
176 176
 	// Use the basename of the given file without the extension as the name for the temporary directory
177
-	$temp_filename = basename( $filename );
178
-	$temp_filename = preg_replace( '|\.[^.]*$|', '', $temp_filename );
177
+	$temp_filename = basename($filename);
178
+	$temp_filename = preg_replace('|\.[^.]*$|', '', $temp_filename);
179 179
 
180 180
 	// If the folder is falsey, use its parent directory name instead.
181
-	if ( ! $temp_filename ) {
182
-		return wp_tempnam( dirname( $filename ), $dir );
181
+	if ( ! $temp_filename) {
182
+		return wp_tempnam(dirname($filename), $dir);
183 183
 	}
184 184
 
185 185
 	// Suffix some random data to avoid filename conflicts
186
-	$temp_filename .= '-' . wp_generate_password( 6, false );
186
+	$temp_filename .= '-'.wp_generate_password(6, false);
187 187
 	$temp_filename .= '.tmp';
188
-	$temp_filename = $dir . wp_unique_filename( $dir, $temp_filename );
188
+	$temp_filename = $dir.wp_unique_filename($dir, $temp_filename);
189 189
 
190
-	$fp = @fopen( $temp_filename, 'x' );
191
-	if ( ! $fp && is_writable( $dir ) && file_exists( $temp_filename ) ) {
192
-		return wp_tempnam( $filename, $dir );
190
+	$fp = @fopen($temp_filename, 'x');
191
+	if ( ! $fp && is_writable($dir) && file_exists($temp_filename)) {
192
+		return wp_tempnam($filename, $dir);
193 193
 	}
194
-	if ( $fp ) {
195
-		fclose( $fp );
194
+	if ($fp) {
195
+		fclose($fp);
196 196
 	}
197 197
 
198 198
 	return $temp_filename;
@@ -209,21 +209,21 @@  discard block
 block discarded – undo
209 209
  * @param array $allowed_files Array of allowed files to edit, $file must match an entry exactly
210 210
  * @return string|null
211 211
  */
212
-function validate_file_to_edit( $file, $allowed_files = '' ) {
213
-	$code = validate_file( $file, $allowed_files );
212
+function validate_file_to_edit($file, $allowed_files = '') {
213
+	$code = validate_file($file, $allowed_files);
214 214
 
215
-	if (!$code )
215
+	if ( ! $code)
216 216
 		return $file;
217 217
 
218
-	switch ( $code ) {
218
+	switch ($code) {
219 219
 		case 1 :
220
-			wp_die( __( 'Sorry, that file cannot be edited.' ) );
220
+			wp_die(__('Sorry, that file cannot be edited.'));
221 221
 
222 222
 		// case 2 :
223 223
 		// wp_die( __('Sorry, can&#8217;t call files with their real path.' ));
224 224
 
225 225
 		case 3 :
226
-			wp_die( __( 'Sorry, that file cannot be edited.' ) );
226
+			wp_die(__('Sorry, that file cannot be edited.'));
227 227
 	}
228 228
 }
229 229
 
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
  * @return array On success, returns an associative array of file attributes. On failure, returns
244 244
  *               $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
245 245
  */
246
-function _wp_handle_upload( &$file, $overrides, $time, $action ) {
246
+function _wp_handle_upload(&$file, $overrides, $time, $action) {
247 247
 	// The default error handler.
248
-	if ( ! function_exists( 'wp_handle_upload_error' ) ) {
249
-		function wp_handle_upload_error( &$file, $message ) {
250
-			return array( 'error' => $message );
248
+	if ( ! function_exists('wp_handle_upload_error')) {
249
+		function wp_handle_upload_error(&$file, $message) {
250
+			return array('error' => $message);
251 251
 		}
252 252
 	}
253 253
 
@@ -261,24 +261,24 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @param array $file An array of data for a single file.
263 263
 	 */
264
-	$file = apply_filters( "{$action}_prefilter", $file );
264
+	$file = apply_filters("{$action}_prefilter", $file);
265 265
 
266 266
 	// You may define your own function and pass the name in $overrides['upload_error_handler']
267 267
 	$upload_error_handler = 'wp_handle_upload_error';
268
-	if ( isset( $overrides['upload_error_handler'] ) ) {
268
+	if (isset($overrides['upload_error_handler'])) {
269 269
 		$upload_error_handler = $overrides['upload_error_handler'];
270 270
 	}
271 271
 
272 272
 	// You may have had one or more 'wp_handle_upload_prefilter' functions error out the file. Handle that gracefully.
273
-	if ( isset( $file['error'] ) && ! is_numeric( $file['error'] ) && $file['error'] ) {
274
-		return call_user_func_array( $upload_error_handler, array( &$file, $file['error'] ) );
273
+	if (isset($file['error']) && ! is_numeric($file['error']) && $file['error']) {
274
+		return call_user_func_array($upload_error_handler, array(&$file, $file['error']));
275 275
 	}
276 276
 
277 277
 	// Install user overrides. Did we mention that this voids your warranty?
278 278
 
279 279
 	// You may define your own function and pass the name in $overrides['unique_filename_callback']
280 280
 	$unique_filename_callback = null;
281
-	if ( isset( $overrides['unique_filename_callback'] ) ) {
281
+	if (isset($overrides['unique_filename_callback'])) {
282 282
 		$unique_filename_callback = $overrides['unique_filename_callback'];
283 283
 	}
284 284
 
@@ -286,72 +286,72 @@  discard block
 block discarded – undo
286 286
 	 * This may not have orignially been intended to be overrideable,
287 287
 	 * but historically has been.
288 288
 	 */
289
-	if ( isset( $overrides['upload_error_strings'] ) ) {
289
+	if (isset($overrides['upload_error_strings'])) {
290 290
 		$upload_error_strings = $overrides['upload_error_strings'];
291 291
 	} else {
292 292
 		// Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
293 293
 		$upload_error_strings = array(
294 294
 			false,
295
-			__( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.' ),
296
-			__( 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.' ),
297
-			__( 'The uploaded file was only partially uploaded.' ),
298
-			__( 'No file was uploaded.' ),
295
+			__('The uploaded file exceeds the upload_max_filesize directive in php.ini.'),
296
+			__('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'),
297
+			__('The uploaded file was only partially uploaded.'),
298
+			__('No file was uploaded.'),
299 299
 			'',
300
-			__( 'Missing a temporary folder.' ),
301
-			__( 'Failed to write file to disk.' ),
302
-			__( 'File upload stopped by extension.' )
300
+			__('Missing a temporary folder.'),
301
+			__('Failed to write file to disk.'),
302
+			__('File upload stopped by extension.')
303 303
 		);
304 304
 	}
305 305
 
306 306
 	// All tests are on by default. Most can be turned off by $overrides[{test_name}] = false;
307
-	$test_form = isset( $overrides['test_form'] ) ? $overrides['test_form'] : true;
308
-	$test_size = isset( $overrides['test_size'] ) ? $overrides['test_size'] : true;
307
+	$test_form = isset($overrides['test_form']) ? $overrides['test_form'] : true;
308
+	$test_size = isset($overrides['test_size']) ? $overrides['test_size'] : true;
309 309
 
310 310
 	// If you override this, you must provide $ext and $type!!
311
-	$test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true;
312
-	$mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false;
311
+	$test_type = isset($overrides['test_type']) ? $overrides['test_type'] : true;
312
+	$mimes = isset($overrides['mimes']) ? $overrides['mimes'] : false;
313 313
 
314 314
 	// A correct form post will pass this test.
315
-	if ( $test_form && ( ! isset( $_POST['action'] ) || ( $_POST['action'] != $action ) ) ) {
316
-		return call_user_func_array( $upload_error_handler, array( &$file, __( 'Invalid form submission.' ) ) );
315
+	if ($test_form && ( ! isset($_POST['action']) || ($_POST['action'] != $action))) {
316
+		return call_user_func_array($upload_error_handler, array(&$file, __('Invalid form submission.')));
317 317
 	}
318 318
 	// A successful upload will pass this test. It makes no sense to override this one.
319
-	if ( isset( $file['error'] ) && $file['error'] > 0 ) {
320
-		return call_user_func_array( $upload_error_handler, array( &$file, $upload_error_strings[ $file['error'] ] ) );
319
+	if (isset($file['error']) && $file['error'] > 0) {
320
+		return call_user_func_array($upload_error_handler, array(&$file, $upload_error_strings[$file['error']]));
321 321
 	}
322 322
 
323
-	$test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize( $file['tmp_name'] );
323
+	$test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize($file['tmp_name']);
324 324
 	// A non-empty file will pass this test.
325
-	if ( $test_size && ! ( $test_file_size > 0 ) ) {
326
-		if ( is_multisite() ) {
327
-			$error_msg = __( 'File is empty. Please upload something more substantial.' );
325
+	if ($test_size && ! ($test_file_size > 0)) {
326
+		if (is_multisite()) {
327
+			$error_msg = __('File is empty. Please upload something more substantial.');
328 328
 		} else {
329
-			$error_msg = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' );
329
+			$error_msg = __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.');
330 330
 		}
331
-		return call_user_func_array( $upload_error_handler, array( &$file, $error_msg ) );
331
+		return call_user_func_array($upload_error_handler, array(&$file, $error_msg));
332 332
 	}
333 333
 
334 334
 	// A properly uploaded file will pass this test. There should be no reason to override this one.
335
-	$test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_file( $file['tmp_name'] );
336
-	if ( ! $test_uploaded_file ) {
337
-		return call_user_func_array( $upload_error_handler, array( &$file, __( 'Specified file failed upload test.' ) ) );
335
+	$test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file($file['tmp_name']) : @ is_file($file['tmp_name']);
336
+	if ( ! $test_uploaded_file) {
337
+		return call_user_func_array($upload_error_handler, array(&$file, __('Specified file failed upload test.')));
338 338
 	}
339 339
 
340 340
 	// A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
341
-	if ( $test_type ) {
342
-		$wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $mimes );
343
-		$ext = empty( $wp_filetype['ext'] ) ? '' : $wp_filetype['ext'];
344
-		$type = empty( $wp_filetype['type'] ) ? '' : $wp_filetype['type'];
345
-		$proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename'];
341
+	if ($test_type) {
342
+		$wp_filetype = wp_check_filetype_and_ext($file['tmp_name'], $file['name'], $mimes);
343
+		$ext = empty($wp_filetype['ext']) ? '' : $wp_filetype['ext'];
344
+		$type = empty($wp_filetype['type']) ? '' : $wp_filetype['type'];
345
+		$proper_filename = empty($wp_filetype['proper_filename']) ? '' : $wp_filetype['proper_filename'];
346 346
 
347 347
 		// Check to see if wp_check_filetype_and_ext() determined the filename was incorrect
348
-		if ( $proper_filename ) {
348
+		if ($proper_filename) {
349 349
 			$file['name'] = $proper_filename;
350 350
 		}
351
-		if ( ( ! $type || !$ext ) && ! current_user_can( 'unfiltered_upload' ) ) {
352
-			return call_user_func_array( $upload_error_handler, array( &$file, __( 'Sorry, this file type is not permitted for security reasons.' ) ) );
351
+		if (( ! $type || ! $ext) && ! current_user_can('unfiltered_upload')) {
352
+			return call_user_func_array($upload_error_handler, array(&$file, __('Sorry, this file type is not permitted for security reasons.')));
353 353
 		}
354
-		if ( ! $type ) {
354
+		if ( ! $type) {
355 355
 			$type = $file['type'];
356 356
 		}
357 357
 	} else {
@@ -362,41 +362,41 @@  discard block
 block discarded – undo
362 362
 	 * A writable uploads dir will pass this test. Again, there's no point
363 363
 	 * overriding this one.
364 364
 	 */
365
-	if ( ! ( ( $uploads = wp_upload_dir( $time ) ) && false === $uploads['error'] ) ) {
366
-		return call_user_func_array( $upload_error_handler, array( &$file, $uploads['error'] ) );
365
+	if ( ! (($uploads = wp_upload_dir($time)) && false === $uploads['error'])) {
366
+		return call_user_func_array($upload_error_handler, array(&$file, $uploads['error']));
367 367
 	}
368 368
 
369
-	$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
369
+	$filename = wp_unique_filename($uploads['path'], $file['name'], $unique_filename_callback);
370 370
 
371 371
 	// Move the file to the uploads dir.
372
-	$new_file = $uploads['path'] . "/$filename";
373
-	if ( 'wp_handle_upload' === $action ) {
374
-		$move_new_file = @ move_uploaded_file( $file['tmp_name'], $new_file );
372
+	$new_file = $uploads['path']."/$filename";
373
+	if ('wp_handle_upload' === $action) {
374
+		$move_new_file = @ move_uploaded_file($file['tmp_name'], $new_file);
375 375
 	} else {
376 376
 		// use copy and unlink because rename breaks streams.
377
-		$move_new_file = @ copy( $file['tmp_name'], $new_file );
378
-		unlink( $file['tmp_name'] );
377
+		$move_new_file = @ copy($file['tmp_name'], $new_file);
378
+		unlink($file['tmp_name']);
379 379
 	}
380 380
 
381
-	if ( false === $move_new_file ) {
382
-		if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) {
383
-			$error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
381
+	if (false === $move_new_file) {
382
+		if (0 === strpos($uploads['basedir'], ABSPATH)) {
383
+			$error_path = str_replace(ABSPATH, '', $uploads['basedir']).$uploads['subdir'];
384 384
 		} else {
385
-			$error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
385
+			$error_path = basename($uploads['basedir']).$uploads['subdir'];
386 386
 		}
387
-		return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $error_path ) );
387
+		return $upload_error_handler($file, sprintf(__('The uploaded file could not be moved to %s.'), $error_path));
388 388
 	}
389 389
 
390 390
 	// Set correct file permissions.
391
-	$stat = stat( dirname( $new_file ));
391
+	$stat = stat(dirname($new_file));
392 392
 	$perms = $stat['mode'] & 0000666;
393
-	@ chmod( $new_file, $perms );
393
+	@ chmod($new_file, $perms);
394 394
 
395 395
 	// Compute the URL.
396
-	$url = $uploads['url'] . "/$filename";
396
+	$url = $uploads['url']."/$filename";
397 397
 
398
-	if ( is_multisite() ) {
399
-		delete_transient( 'dirsize_cache' );
398
+	if (is_multisite()) {
399
+		delete_transient('dirsize_cache');
400 400
 	}
401 401
 
402 402
 	/**
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
 	 * }
414 414
 	 * @param string $context The type of upload action. Values include 'upload' or 'sideload'.
415 415
 	 */
416
-	return apply_filters( 'wp_handle_upload', array(
416
+	return apply_filters('wp_handle_upload', array(
417 417
 		'file' => $new_file,
418 418
 		'url'  => $url,
419 419
 		'type' => $type
420
-	), 'wp_handle_sideload' === $action ? 'sideload' : 'upload' );
420
+	), 'wp_handle_sideload' === $action ? 'sideload' : 'upload');
421 421
 }
422 422
 
423 423
 /**
@@ -437,17 +437,17 @@  discard block
 block discarded – undo
437 437
  * @return array On success, returns an associative array of file attributes. On failure, returns
438 438
  *               $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
439 439
  */
440
-function wp_handle_upload( &$file, $overrides = false, $time = null ) {
440
+function wp_handle_upload(&$file, $overrides = false, $time = null) {
441 441
 	/*
442 442
 	 *  $_POST['action'] must be set and its value must equal $overrides['action']
443 443
 	 *  or this:
444 444
 	 */
445 445
 	$action = 'wp_handle_upload';
446
-	if ( isset( $overrides['action'] ) ) {
446
+	if (isset($overrides['action'])) {
447 447
 		$action = $overrides['action'];
448 448
 	}
449 449
 
450
-	return _wp_handle_upload( $file, $overrides, $time, $action );
450
+	return _wp_handle_upload($file, $overrides, $time, $action);
451 451
 }
452 452
 
453 453
 /**
@@ -466,16 +466,16 @@  discard block
 block discarded – undo
466 466
  * @return array On success, returns an associative array of file attributes. On failure, returns
467 467
  *               $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
468 468
  */
469
-function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
469
+function wp_handle_sideload(&$file, $overrides = false, $time = null) {
470 470
 	/*
471 471
 	 *  $_POST['action'] must be set and its value must equal $overrides['action']
472 472
 	 *  or this:
473 473
 	 */
474 474
 	$action = 'wp_handle_sideload';
475
-	if ( isset( $overrides['action'] ) ) {
475
+	if (isset($overrides['action'])) {
476 476
 		$action = $overrides['action'];
477 477
 	}
478
-	return _wp_handle_upload( $file, $overrides, $time, $action );
478
+	return _wp_handle_upload($file, $overrides, $time, $action);
479 479
 }
480 480
 
481 481
 
@@ -489,34 +489,34 @@  discard block
 block discarded – undo
489 489
  * @param int $timeout The timeout for the request to download the file default 300 seconds
490 490
  * @return mixed WP_Error on failure, string Filename on success.
491 491
  */
492
-function download_url( $url, $timeout = 300 ) {
492
+function download_url($url, $timeout = 300) {
493 493
 	//WARNING: The file is not automatically deleted, The script must unlink() the file.
494
-	if ( ! $url )
494
+	if ( ! $url)
495 495
 		return new WP_Error('http_no_url', __('Invalid URL Provided.'));
496 496
 
497
-	$url_filename = basename( parse_url( $url, PHP_URL_PATH ) );
497
+	$url_filename = basename(parse_url($url, PHP_URL_PATH));
498 498
 
499
-	$tmpfname = wp_tempnam( $url_filename );
500
-	if ( ! $tmpfname )
499
+	$tmpfname = wp_tempnam($url_filename);
500
+	if ( ! $tmpfname)
501 501
 		return new WP_Error('http_no_file', __('Could not create Temporary file.'));
502 502
 
503
-	$response = wp_safe_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) );
503
+	$response = wp_safe_remote_get($url, array('timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname));
504 504
 
505
-	if ( is_wp_error( $response ) ) {
506
-		unlink( $tmpfname );
505
+	if (is_wp_error($response)) {
506
+		unlink($tmpfname);
507 507
 		return $response;
508 508
 	}
509 509
 
510
-	if ( 200 != wp_remote_retrieve_response_code( $response ) ){
511
-		unlink( $tmpfname );
512
-		return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
510
+	if (200 != wp_remote_retrieve_response_code($response)) {
511
+		unlink($tmpfname);
512
+		return new WP_Error('http_404', trim(wp_remote_retrieve_response_message($response)));
513 513
 	}
514 514
 
515
-	$content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
516
-	if ( $content_md5 ) {
517
-		$md5_check = verify_file_md5( $tmpfname, $content_md5 );
518
-		if ( is_wp_error( $md5_check ) ) {
519
-			unlink( $tmpfname );
515
+	$content_md5 = wp_remote_retrieve_header($response, 'content-md5');
516
+	if ($content_md5) {
517
+		$md5_check = verify_file_md5($tmpfname, $content_md5);
518
+		if (is_wp_error($md5_check)) {
519
+			unlink($tmpfname);
520 520
 			return $md5_check;
521 521
 		}
522 522
 	}
@@ -533,20 +533,20 @@  discard block
 block discarded – undo
533 533
  * @param string $expected_md5 The expected MD5 of the file, either a base64 encoded raw md5, or a hex-encoded md5
534 534
  * @return bool|object WP_Error on failure, true on success, false when the MD5 format is unknown/unexpected
535 535
  */
536
-function verify_file_md5( $filename, $expected_md5 ) {
537
-	if ( 32 == strlen( $expected_md5 ) )
538
-		$expected_raw_md5 = pack( 'H*', $expected_md5 );
539
-	elseif ( 24 == strlen( $expected_md5 ) )
540
-		$expected_raw_md5 = base64_decode( $expected_md5 );
536
+function verify_file_md5($filename, $expected_md5) {
537
+	if (32 == strlen($expected_md5))
538
+		$expected_raw_md5 = pack('H*', $expected_md5);
539
+	elseif (24 == strlen($expected_md5))
540
+		$expected_raw_md5 = base64_decode($expected_md5);
541 541
 	else
542 542
 		return false; // unknown format
543 543
 
544
-	$file_md5 = md5_file( $filename, true );
544
+	$file_md5 = md5_file($filename, true);
545 545
 
546
-	if ( $file_md5 === $expected_raw_md5 )
546
+	if ($file_md5 === $expected_raw_md5)
547 547
 		return true;
548 548
 
549
-	return new WP_Error( 'md5_mismatch', sprintf( __( 'The checksum of the file (%1$s) does not match the expected checksum value (%2$s).' ), bin2hex( $file_md5 ), bin2hex( $expected_raw_md5 ) ) );
549
+	return new WP_Error('md5_mismatch', sprintf(__('The checksum of the file (%1$s) does not match the expected checksum value (%2$s).'), bin2hex($file_md5), bin2hex($expected_raw_md5)));
550 550
 }
551 551
 
552 552
 /**
@@ -567,27 +567,27 @@  discard block
 block discarded – undo
567 567
 function unzip_file($file, $to) {
568 568
 	global $wp_filesystem;
569 569
 
570
-	if ( ! $wp_filesystem || !is_object($wp_filesystem) )
570
+	if ( ! $wp_filesystem || ! is_object($wp_filesystem))
571 571
 		return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
572 572
 
573 573
 	// Unzip can use a lot of memory, but not this much hopefully.
574
-	wp_raise_memory_limit( 'admin' );
574
+	wp_raise_memory_limit('admin');
575 575
 
576 576
 	$needed_dirs = array();
577 577
 	$to = trailingslashit($to);
578 578
 
579 579
 	// Determine any parent dir's needed (of the upgrade directory)
580
-	if ( ! $wp_filesystem->is_dir($to) ) { //Only do parents if no children exist
580
+	if ( ! $wp_filesystem->is_dir($to)) { //Only do parents if no children exist
581 581
 		$path = preg_split('![/\\\]!', untrailingslashit($to));
582
-		for ( $i = count($path); $i >= 0; $i-- ) {
583
-			if ( empty($path[$i]) )
582
+		for ($i = count($path); $i >= 0; $i--) {
583
+			if (empty($path[$i]))
584 584
 				continue;
585 585
 
586
-			$dir = implode('/', array_slice($path, 0, $i+1) );
587
-			if ( preg_match('!^[a-z]:$!i', $dir) ) // Skip it if it looks like a Windows Drive letter.
586
+			$dir = implode('/', array_slice($path, 0, $i + 1));
587
+			if (preg_match('!^[a-z]:$!i', $dir)) // Skip it if it looks like a Windows Drive letter.
588 588
 				continue;
589 589
 
590
-			if ( ! $wp_filesystem->is_dir($dir) )
590
+			if ( ! $wp_filesystem->is_dir($dir))
591 591
 				$needed_dirs[] = $dir;
592 592
 			else
593 593
 				break; // A folder exists, therefor, we dont need the check the levels below this
@@ -601,12 +601,12 @@  discard block
 block discarded – undo
601 601
 	 *
602 602
 	 * @param bool $ziparchive Whether to use ZipArchive. Default true.
603 603
 	 */
604
-	if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) {
604
+	if (class_exists('ZipArchive', false) && apply_filters('unzip_file_use_ziparchive', true)) {
605 605
 		$result = _unzip_file_ziparchive($file, $to, $needed_dirs);
606
-		if ( true === $result ) {
606
+		if (true === $result) {
607 607
 			return $result;
608
-		} elseif ( is_wp_error($result) ) {
609
-			if ( 'incompatible_archive' != $result->get_error_code() )
608
+		} elseif (is_wp_error($result)) {
609
+			if ('incompatible_archive' != $result->get_error_code())
610 610
 				return $result;
611 611
 		}
612 612
 	}
@@ -629,32 +629,32 @@  discard block
 block discarded – undo
629 629
  * @param array $needed_dirs A partial list of required folders needed to be created.
630 630
  * @return mixed WP_Error on failure, True on success
631 631
  */
632
-function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
632
+function _unzip_file_ziparchive($file, $to, $needed_dirs = array()) {
633 633
 	global $wp_filesystem;
634 634
 
635 635
 	$z = new ZipArchive();
636 636
 
637
-	$zopen = $z->open( $file, ZIPARCHIVE::CHECKCONS );
638
-	if ( true !== $zopen )
639
-		return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) );
637
+	$zopen = $z->open($file, ZIPARCHIVE::CHECKCONS);
638
+	if (true !== $zopen)
639
+		return new WP_Error('incompatible_archive', __('Incompatible Archive.'), array('ziparchive_error' => $zopen));
640 640
 
641 641
 	$uncompressed_size = 0;
642 642
 
643
-	for ( $i = 0; $i < $z->numFiles; $i++ ) {
644
-		if ( ! $info = $z->statIndex($i) )
645
-			return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
643
+	for ($i = 0; $i < $z->numFiles; $i++) {
644
+		if ( ! $info = $z->statIndex($i))
645
+			return new WP_Error('stat_failed_ziparchive', __('Could not retrieve file from archive.'));
646 646
 
647
-		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory
647
+		if ('__MACOSX/' === substr($info['name'], 0, 9)) // Skip the OS X-created __MACOSX directory
648 648
 			continue;
649 649
 
650 650
 		$uncompressed_size += $info['size'];
651 651
 
652
-		if ( '/' === substr( $info['name'], -1 ) ) {
652
+		if ('/' === substr($info['name'], -1)) {
653 653
 			// Directory.
654
-			$needed_dirs[] = $to . untrailingslashit( $info['name'] );
655
-		} elseif ( '.' !== $dirname = dirname( $info['name'] ) ) {
654
+			$needed_dirs[] = $to.untrailingslashit($info['name']);
655
+		} elseif ('.' !== $dirname = dirname($info['name'])) {
656 656
 			// Path to a file.
657
-			$needed_dirs[] = $to . untrailingslashit( $dirname );
657
+			$needed_dirs[] = $to.untrailingslashit($dirname);
658 658
 		}
659 659
 	}
660 660
 
@@ -663,22 +663,22 @@  discard block
 block discarded – undo
663 663
 	 * A disk that has zero free bytes has bigger problems.
664 664
 	 * Require we have enough space to unzip the file and copy its contents, with a 10% buffer.
665 665
 	 */
666
-	if ( wp_doing_cron() ) {
667
-		$available_space = @disk_free_space( WP_CONTENT_DIR );
668
-		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space )
669
-			return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
666
+	if (wp_doing_cron()) {
667
+		$available_space = @disk_free_space(WP_CONTENT_DIR);
668
+		if ($available_space && ($uncompressed_size * 2.1) > $available_space)
669
+			return new WP_Error('disk_full_unzip_file', __('Could not copy files. You may have run out of disk space.'), compact('uncompressed_size', 'available_space'));
670 670
 	}
671 671
 
672 672
 	$needed_dirs = array_unique($needed_dirs);
673
-	foreach ( $needed_dirs as $dir ) {
673
+	foreach ($needed_dirs as $dir) {
674 674
 		// Check the parent folders of the folders all exist within the creation array.
675
-		if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
675
+		if (untrailingslashit($to) == $dir) // Skip over the working directory, We know this exists (or will exist)
676 676
 			continue;
677
-		if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
677
+		if (strpos($dir, $to) === false) // If the directory is not within the working directory, Skip it
678 678
 			continue;
679 679
 
680 680
 		$parent_folder = dirname($dir);
681
-		while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) {
681
+		while ( ! empty($parent_folder) && untrailingslashit($to) != $parent_folder && ! in_array($parent_folder, $needed_dirs)) {
682 682
 			$needed_dirs[] = $parent_folder;
683 683
 			$parent_folder = dirname($parent_folder);
684 684
 		}
@@ -686,30 +686,30 @@  discard block
 block discarded – undo
686 686
 	asort($needed_dirs);
687 687
 
688 688
 	// Create those directories if need be:
689
-	foreach ( $needed_dirs as $_dir ) {
689
+	foreach ($needed_dirs as $_dir) {
690 690
 		// Only check to see if the Dir exists upon creation failure. Less I/O this way.
691
-		if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
692
-			return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
691
+		if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir)) {
692
+			return new WP_Error('mkdir_failed_ziparchive', __('Could not create directory.'), substr($_dir, strlen($to)));
693 693
 		}
694 694
 	}
695 695
 	unset($needed_dirs);
696 696
 
697
-	for ( $i = 0; $i < $z->numFiles; $i++ ) {
698
-		if ( ! $info = $z->statIndex($i) )
699
-			return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
697
+	for ($i = 0; $i < $z->numFiles; $i++) {
698
+		if ( ! $info = $z->statIndex($i))
699
+			return new WP_Error('stat_failed_ziparchive', __('Could not retrieve file from archive.'));
700 700
 
701
-		if ( '/' == substr($info['name'], -1) ) // directory
701
+		if ('/' == substr($info['name'], -1)) // directory
702 702
 			continue;
703 703
 
704
-		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
704
+		if ('__MACOSX/' === substr($info['name'], 0, 9)) // Don't extract the OS X-created __MACOSX directory files
705 705
 			continue;
706 706
 
707 707
 		$contents = $z->getFromIndex($i);
708
-		if ( false === $contents )
709
-			return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
708
+		if (false === $contents)
709
+			return new WP_Error('extract_failed_ziparchive', __('Could not extract file from archive.'), $info['name']);
710 710
 
711
-		if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) )
712
-			return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] );
711
+		if ( ! $wp_filesystem->put_contents($to.$info['name'], $contents, FS_CHMOD_FILE))
712
+			return new WP_Error('copy_failed_ziparchive', __('Could not copy file.'), $info['name']);
713 713
 	}
714 714
 
715 715
 	$z->close();
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 
738 738
 	mbstring_binary_safe_encoding();
739 739
 
740
-	require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php');
740
+	require_once(ABSPATH.'wp-admin/includes/class-pclzip.php');
741 741
 
742 742
 	$archive = new PclZip($file);
743 743
 
@@ -746,22 +746,22 @@  discard block
 block discarded – undo
746 746
 	reset_mbstring_encoding();
747 747
 
748 748
 	// Is the archive valid?
749
-	if ( !is_array($archive_files) )
749
+	if ( ! is_array($archive_files))
750 750
 		return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true));
751 751
 
752
-	if ( 0 == count($archive_files) )
753
-		return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) );
752
+	if (0 == count($archive_files))
753
+		return new WP_Error('empty_archive_pclzip', __('Empty archive.'));
754 754
 
755 755
 	$uncompressed_size = 0;
756 756
 
757 757
 	// Determine any children directories needed (From within the archive)
758
-	foreach ( $archive_files as $file ) {
759
-		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory
758
+	foreach ($archive_files as $file) {
759
+		if ('__MACOSX/' === substr($file['filename'], 0, 9)) // Skip the OS X-created __MACOSX directory
760 760
 			continue;
761 761
 
762 762
 		$uncompressed_size += $file['size'];
763 763
 
764
-		$needed_dirs[] = $to . untrailingslashit( $file['folder'] ? $file['filename'] : dirname($file['filename']) );
764
+		$needed_dirs[] = $to.untrailingslashit($file['folder'] ? $file['filename'] : dirname($file['filename']));
765 765
 	}
766 766
 
767 767
 	/*
@@ -769,22 +769,22 @@  discard block
 block discarded – undo
769 769
 	 * A disk that has zero free bytes has bigger problems.
770 770
 	 * Require we have enough space to unzip the file and copy its contents, with a 10% buffer.
771 771
 	 */
772
-	if ( wp_doing_cron() ) {
773
-		$available_space = @disk_free_space( WP_CONTENT_DIR );
774
-		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space )
775
-			return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
772
+	if (wp_doing_cron()) {
773
+		$available_space = @disk_free_space(WP_CONTENT_DIR);
774
+		if ($available_space && ($uncompressed_size * 2.1) > $available_space)
775
+			return new WP_Error('disk_full_unzip_file', __('Could not copy files. You may have run out of disk space.'), compact('uncompressed_size', 'available_space'));
776 776
 	}
777 777
 
778 778
 	$needed_dirs = array_unique($needed_dirs);
779
-	foreach ( $needed_dirs as $dir ) {
779
+	foreach ($needed_dirs as $dir) {
780 780
 		// Check the parent folders of the folders all exist within the creation array.
781
-		if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
781
+		if (untrailingslashit($to) == $dir) // Skip over the working directory, We know this exists (or will exist)
782 782
 			continue;
783
-		if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
783
+		if (strpos($dir, $to) === false) // If the directory is not within the working directory, Skip it
784 784
 			continue;
785 785
 
786 786
 		$parent_folder = dirname($dir);
787
-		while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) {
787
+		while ( ! empty($parent_folder) && untrailingslashit($to) != $parent_folder && ! in_array($parent_folder, $needed_dirs)) {
788 788
 			$needed_dirs[] = $parent_folder;
789 789
 			$parent_folder = dirname($parent_folder);
790 790
 		}
@@ -792,23 +792,23 @@  discard block
 block discarded – undo
792 792
 	asort($needed_dirs);
793 793
 
794 794
 	// Create those directories if need be:
795
-	foreach ( $needed_dirs as $_dir ) {
795
+	foreach ($needed_dirs as $_dir) {
796 796
 		// Only check to see if the dir exists upon creation failure. Less I/O this way.
797
-		if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) )
798
-			return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
797
+		if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir))
798
+			return new WP_Error('mkdir_failed_pclzip', __('Could not create directory.'), substr($_dir, strlen($to)));
799 799
 	}
800 800
 	unset($needed_dirs);
801 801
 
802 802
 	// Extract the files from the zip
803
-	foreach ( $archive_files as $file ) {
804
-		if ( $file['folder'] )
803
+	foreach ($archive_files as $file) {
804
+		if ($file['folder'])
805 805
 			continue;
806 806
 
807
-		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
807
+		if ('__MACOSX/' === substr($file['filename'], 0, 9)) // Don't extract the OS X-created __MACOSX directory files
808 808
 			continue;
809 809
 
810
-		if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
811
-			return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
810
+		if ( ! $wp_filesystem->put_contents($to.$file['filename'], $file['content'], FS_CHMOD_FILE))
811
+			return new WP_Error('copy_failed_pclzip', __('Could not copy file.'), $file['filename']);
812 812
 	}
813 813
 	return true;
814 814
 }
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
  * @param array $skip_list a list of files/folders to skip copying
827 827
  * @return mixed WP_Error on failure, True on success.
828 828
  */
829
-function copy_dir($from, $to, $skip_list = array() ) {
829
+function copy_dir($from, $to, $skip_list = array()) {
830 830
 	global $wp_filesystem;
831 831
 
832 832
 	$dirlist = $wp_filesystem->dirlist($from);
@@ -834,32 +834,32 @@  discard block
 block discarded – undo
834 834
 	$from = trailingslashit($from);
835 835
 	$to = trailingslashit($to);
836 836
 
837
-	foreach ( (array) $dirlist as $filename => $fileinfo ) {
838
-		if ( in_array( $filename, $skip_list ) )
837
+	foreach ((array) $dirlist as $filename => $fileinfo) {
838
+		if (in_array($filename, $skip_list))
839 839
 			continue;
840 840
 
841
-		if ( 'f' == $fileinfo['type'] ) {
842
-			if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
841
+		if ('f' == $fileinfo['type']) {
842
+			if ( ! $wp_filesystem->copy($from.$filename, $to.$filename, true, FS_CHMOD_FILE)) {
843 843
 				// If copy failed, chmod file to 0644 and try again.
844
-				$wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE );
845
-				if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
846
-					return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename );
844
+				$wp_filesystem->chmod($to.$filename, FS_CHMOD_FILE);
845
+				if ( ! $wp_filesystem->copy($from.$filename, $to.$filename, true, FS_CHMOD_FILE))
846
+					return new WP_Error('copy_failed_copy_dir', __('Could not copy file.'), $to.$filename);
847 847
 			}
848
-		} elseif ( 'd' == $fileinfo['type'] ) {
849
-			if ( !$wp_filesystem->is_dir($to . $filename) ) {
850
-				if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
851
-					return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename );
848
+		} elseif ('d' == $fileinfo['type']) {
849
+			if ( ! $wp_filesystem->is_dir($to.$filename)) {
850
+				if ( ! $wp_filesystem->mkdir($to.$filename, FS_CHMOD_DIR))
851
+					return new WP_Error('mkdir_failed_copy_dir', __('Could not create directory.'), $to.$filename);
852 852
 			}
853 853
 
854 854
 			// generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list
855 855
 			$sub_skip_list = array();
856
-			foreach ( $skip_list as $skip_item ) {
857
-				if ( 0 === strpos( $skip_item, $filename . '/' ) )
858
-					$sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item );
856
+			foreach ($skip_list as $skip_item) {
857
+				if (0 === strpos($skip_item, $filename.'/'))
858
+					$sub_skip_list[] = preg_replace('!^'.preg_quote($filename, '!').'/!i', '', $skip_item);
859 859
 			}
860 860
 
861
-			$result = copy_dir($from . $filename, $to . $filename, $sub_skip_list);
862
-			if ( is_wp_error($result) )
861
+			$result = copy_dir($from.$filename, $to.$filename, $sub_skip_list);
862
+			if (is_wp_error($result))
863 863
 				return $result;
864 864
 		}
865 865
 	}
@@ -883,17 +883,17 @@  discard block
 block discarded – undo
883 883
  * @param bool         $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
884 884
  * @return null|bool false on failure, true on success.
885 885
  */
886
-function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_ownership = false ) {
886
+function WP_Filesystem($args = false, $context = false, $allow_relaxed_file_ownership = false) {
887 887
 	global $wp_filesystem;
888 888
 
889
-	require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
889
+	require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php');
890 890
 
891
-	$method = get_filesystem_method( $args, $context, $allow_relaxed_file_ownership );
891
+	$method = get_filesystem_method($args, $context, $allow_relaxed_file_ownership);
892 892
 
893
-	if ( ! $method )
893
+	if ( ! $method)
894 894
 		return false;
895 895
 
896
-	if ( ! class_exists( "WP_Filesystem_$method" ) ) {
896
+	if ( ! class_exists("WP_Filesystem_$method")) {
897 897
 
898 898
 		/**
899 899
 		 * Filters the path for a specific filesystem method class file.
@@ -905,9 +905,9 @@  discard block
 block discarded – undo
905 905
 		 * @param string $path   Path to the specific filesystem method class file.
906 906
 		 * @param string $method The filesystem method to use.
907 907
 		 */
908
-		$abstraction_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method );
908
+		$abstraction_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method);
909 909
 
910
-		if ( ! file_exists($abstraction_file) )
910
+		if ( ! file_exists($abstraction_file))
911 911
 			return;
912 912
 
913 913
 		require_once($abstraction_file);
@@ -917,22 +917,22 @@  discard block
 block discarded – undo
917 917
 	$wp_filesystem = new $method($args);
918 918
 
919 919
 	//Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
920
-	if ( ! defined('FS_CONNECT_TIMEOUT') )
920
+	if ( ! defined('FS_CONNECT_TIMEOUT'))
921 921
 		define('FS_CONNECT_TIMEOUT', 30);
922
-	if ( ! defined('FS_TIMEOUT') )
922
+	if ( ! defined('FS_TIMEOUT'))
923 923
 		define('FS_TIMEOUT', 30);
924 924
 
925
-	if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
925
+	if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code())
926 926
 		return false;
927 927
 
928
-	if ( !$wp_filesystem->connect() )
928
+	if ( ! $wp_filesystem->connect())
929 929
 		return false; //There was an error connecting to the server.
930 930
 
931 931
 	// Set the permission constants if not already set.
932
-	if ( ! defined('FS_CHMOD_DIR') )
933
-		define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) );
934
-	if ( ! defined('FS_CHMOD_FILE') )
935
-		define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
932
+	if ( ! defined('FS_CHMOD_DIR'))
933
+		define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755));
934
+	if ( ! defined('FS_CHMOD_FILE'))
935
+		define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644));
936 936
 
937 937
 	return true;
938 938
 }
@@ -963,39 +963,39 @@  discard block
 block discarded – undo
963 963
  *                                             Default false.
964 964
  * @return string The transport to use, see description for valid return values.
965 965
  */
966
-function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_file_ownership = false ) {
966
+function get_filesystem_method($args = array(), $context = '', $allow_relaxed_file_ownership = false) {
967 967
 	$method = defined('FS_METHOD') ? FS_METHOD : false; // Please ensure that this is either 'direct', 'ssh2', 'ftpext' or 'ftpsockets'
968 968
 
969
-	if ( ! $context ) {
969
+	if ( ! $context) {
970 970
 		$context = WP_CONTENT_DIR;
971 971
 	}
972 972
 
973 973
 	// If the directory doesn't exist (wp-content/languages) then use the parent directory as we'll create it.
974
-	if ( WP_LANG_DIR == $context && ! is_dir( $context ) ) {
975
-		$context = dirname( $context );
974
+	if (WP_LANG_DIR == $context && ! is_dir($context)) {
975
+		$context = dirname($context);
976 976
 	}
977 977
 
978
-	$context = trailingslashit( $context );
978
+	$context = trailingslashit($context);
979 979
 
980
-	if ( ! $method ) {
980
+	if ( ! $method) {
981 981
 
982
-		$temp_file_name = $context . 'temp-write-test-' . time();
982
+		$temp_file_name = $context.'temp-write-test-'.time();
983 983
 		$temp_handle = @fopen($temp_file_name, 'w');
984
-		if ( $temp_handle ) {
984
+		if ($temp_handle) {
985 985
 
986 986
 			// Attempt to determine the file owner of the WordPress files, and that of newly created files
987 987
 			$wp_file_owner = $temp_file_owner = false;
988
-			if ( function_exists('fileowner') ) {
989
-				$wp_file_owner = @fileowner( __FILE__ );
990
-				$temp_file_owner = @fileowner( $temp_file_name );
988
+			if (function_exists('fileowner')) {
989
+				$wp_file_owner = @fileowner(__FILE__);
990
+				$temp_file_owner = @fileowner($temp_file_name);
991 991
 			}
992 992
 
993
-			if ( $wp_file_owner !== false && $wp_file_owner === $temp_file_owner ) {
993
+			if ($wp_file_owner !== false && $wp_file_owner === $temp_file_owner) {
994 994
 				// WordPress is creating files as the same owner as the WordPress files,
995 995
 				// this means it's safe to modify & create new files via PHP.
996 996
 				$method = 'direct';
997 997
 				$GLOBALS['_wp_filesystem_direct_method'] = 'file_owner';
998
-			} elseif ( $allow_relaxed_file_ownership ) {
998
+			} elseif ($allow_relaxed_file_ownership) {
999 999
 				// The $context directory is writable, and $allow_relaxed_file_ownership is set, this means we can modify files
1000 1000
 				// safely in this directory. This mode doesn't create new files, only alter existing ones.
1001 1001
 				$method = 'direct';
@@ -1007,9 +1007,9 @@  discard block
 block discarded – undo
1007 1007
 		}
1008 1008
  	}
1009 1009
 
1010
-	if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2';
1011
-	if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
1012
-	if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
1010
+	if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents')) $method = 'ssh2';
1011
+	if ( ! $method && extension_loaded('ftp')) $method = 'ftpext';
1012
+	if ( ! $method && (extension_loaded('sockets') || function_exists('fsockopen'))) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
1013 1013
 
1014 1014
 	/**
1015 1015
 	 * Filters the filesystem method to use.
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 	 * @param string $context Full path to the directory that is tested for being writable.
1022 1022
 	 * @param bool   $allow_relaxed_file_ownership Whether to allow Group/World writable.
1023 1023
 	 */
1024
-	return apply_filters( 'filesystem_method', $method, $args, $context, $allow_relaxed_file_ownership );
1024
+	return apply_filters('filesystem_method', $method, $args, $context, $allow_relaxed_file_ownership);
1025 1025
 }
1026 1026
 
1027 1027
 /**
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
  *
1053 1053
  * @return bool False on failure, true on success.
1054 1054
  */
1055
-function request_filesystem_credentials( $form_post, $type = '', $error = false, $context = '', $extra_fields = null, $allow_relaxed_file_ownership = false ) {
1055
+function request_filesystem_credentials($form_post, $type = '', $error = false, $context = '', $extra_fields = null, $allow_relaxed_file_ownership = false) {
1056 1056
 	global $pagenow;
1057 1057
 
1058 1058
 	/**
@@ -1075,26 +1075,26 @@  discard block
 block discarded – undo
1075 1075
 	 *                                             Default false.
1076 1076
 	 * @param array  $extra_fields                 Extra POST fields.
1077 1077
 	 */
1078
-	$req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership );
1079
-	if ( '' !== $req_cred )
1078
+	$req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership);
1079
+	if ('' !== $req_cred)
1080 1080
 		return $req_cred;
1081 1081
 
1082
-	if ( empty($type) ) {
1083
-		$type = get_filesystem_method( array(), $context, $allow_relaxed_file_ownership );
1082
+	if (empty($type)) {
1083
+		$type = get_filesystem_method(array(), $context, $allow_relaxed_file_ownership);
1084 1084
 	}
1085 1085
 
1086
-	if ( 'direct' == $type )
1086
+	if ('direct' == $type)
1087 1087
 		return true;
1088 1088
 
1089
-	if ( is_null( $extra_fields ) )
1090
-		$extra_fields = array( 'version', 'locale' );
1089
+	if (is_null($extra_fields))
1090
+		$extra_fields = array('version', 'locale');
1091 1091
 
1092
-	$credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => ''));
1092
+	$credentials = get_option('ftp_credentials', array('hostname' => '', 'username' => ''));
1093 1093
 
1094
-	$submitted_form = wp_unslash( $_POST );
1094
+	$submitted_form = wp_unslash($_POST);
1095 1095
 
1096 1096
 	// Verify nonce, or unset submitted form field values on failure
1097
-	if ( ! isset( $_POST['_fs_nonce'] ) || ! wp_verify_nonce( $_POST['_fs_nonce'], 'filesystem-credentials' ) ) {
1097
+	if ( ! isset($_POST['_fs_nonce']) || ! wp_verify_nonce($_POST['_fs_nonce'], 'filesystem-credentials')) {
1098 1098
 		unset(
1099 1099
 			$submitted_form['hostname'],
1100 1100
 			$submitted_form['username'],
@@ -1106,70 +1106,70 @@  discard block
 block discarded – undo
1106 1106
 	}
1107 1107
 
1108 1108
 	// If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option)
1109
-	$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($submitted_form['hostname']) ? $submitted_form['hostname'] : $credentials['hostname']);
1110
-	$credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($submitted_form['username']) ? $submitted_form['username'] : $credentials['username']);
1111
-	$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($submitted_form['password']) ? $submitted_form['password'] : '');
1109
+	$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : ( ! empty($submitted_form['hostname']) ? $submitted_form['hostname'] : $credentials['hostname']);
1110
+	$credentials['username'] = defined('FTP_USER') ? FTP_USER : ( ! empty($submitted_form['username']) ? $submitted_form['username'] : $credentials['username']);
1111
+	$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : ( ! empty($submitted_form['password']) ? $submitted_form['password'] : '');
1112 1112
 
1113 1113
 	// Check to see if we are setting the public/private keys for ssh
1114
-	$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($submitted_form['public_key']) ? $submitted_form['public_key'] : '');
1115
-	$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($submitted_form['private_key']) ? $submitted_form['private_key'] : '');
1114
+	$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : ( ! empty($submitted_form['public_key']) ? $submitted_form['public_key'] : '');
1115
+	$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : ( ! empty($submitted_form['private_key']) ? $submitted_form['private_key'] : '');
1116 1116
 
1117 1117
 	// Sanitize the hostname, Some people might pass in odd-data:
1118 1118
 	$credentials['hostname'] = preg_replace('|\w+://|', '', $credentials['hostname']); //Strip any schemes off
1119 1119
 
1120
-	if ( strpos($credentials['hostname'], ':') ) {
1121
-		list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2);
1122
-		if ( ! is_numeric($credentials['port']) )
1120
+	if (strpos($credentials['hostname'], ':')) {
1121
+		list($credentials['hostname'], $credentials['port']) = explode(':', $credentials['hostname'], 2);
1122
+		if ( ! is_numeric($credentials['port']))
1123 1123
 			unset($credentials['port']);
1124 1124
 	} else {
1125 1125
 		unset($credentials['port']);
1126 1126
 	}
1127 1127
 
1128
-	if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) {
1128
+	if ((defined('FTP_SSH') && FTP_SSH) || (defined('FS_METHOD') && 'ssh2' == FS_METHOD)) {
1129 1129
 		$credentials['connection_type'] = 'ssh';
1130
-	} elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { //Only the FTP Extension understands SSL
1130
+	} elseif ((defined('FTP_SSL') && FTP_SSL) && 'ftpext' == $type) { //Only the FTP Extension understands SSL
1131 1131
 		$credentials['connection_type'] = 'ftps';
1132
-	} elseif ( ! empty( $submitted_form['connection_type'] ) ) {
1132
+	} elseif ( ! empty($submitted_form['connection_type'])) {
1133 1133
 		$credentials['connection_type'] = $submitted_form['connection_type'];
1134
-	} elseif ( ! isset( $credentials['connection_type'] ) ) { //All else fails (And it's not defaulted to something else saved), Default to FTP
1134
+	} elseif ( ! isset($credentials['connection_type'])) { //All else fails (And it's not defaulted to something else saved), Default to FTP
1135 1135
 		$credentials['connection_type'] = 'ftp';
1136 1136
 	}
1137 1137
 	if ( ! $error &&
1138 1138
 			(
1139
-				( !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) ||
1140
-				( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) )
1141
-			) ) {
1139
+				( ! empty($credentials['password']) && ! empty($credentials['username']) && ! empty($credentials['hostname'])) ||
1140
+				('ssh' == $credentials['connection_type'] && ! empty($credentials['public_key']) && ! empty($credentials['private_key']))
1141
+			)) {
1142 1142
 		$stored_credentials = $credentials;
1143
-		if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code.
1144
-			$stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
1143
+		if ( ! empty($stored_credentials['port'])) //save port as part of hostname to simplify above code.
1144
+			$stored_credentials['hostname'] .= ':'.$stored_credentials['port'];
1145 1145
 
1146 1146
 		unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']);
1147
-		if ( ! wp_installing() ) {
1148
-			update_option( 'ftp_credentials', $stored_credentials );
1147
+		if ( ! wp_installing()) {
1148
+			update_option('ftp_credentials', $stored_credentials);
1149 1149
 		}
1150 1150
 		return $credentials;
1151 1151
 	}
1152
-	$hostname = isset( $credentials['hostname'] ) ? $credentials['hostname'] : '';
1153
-	$username = isset( $credentials['username'] ) ? $credentials['username'] : '';
1154
-	$public_key = isset( $credentials['public_key'] ) ? $credentials['public_key'] : '';
1155
-	$private_key = isset( $credentials['private_key'] ) ? $credentials['private_key'] : '';
1156
-	$port = isset( $credentials['port'] ) ? $credentials['port'] : '';
1157
-	$connection_type = isset( $credentials['connection_type'] ) ? $credentials['connection_type'] : '';
1158
-
1159
-	if ( $error ) {
1152
+	$hostname = isset($credentials['hostname']) ? $credentials['hostname'] : '';
1153
+	$username = isset($credentials['username']) ? $credentials['username'] : '';
1154
+	$public_key = isset($credentials['public_key']) ? $credentials['public_key'] : '';
1155
+	$private_key = isset($credentials['private_key']) ? $credentials['private_key'] : '';
1156
+	$port = isset($credentials['port']) ? $credentials['port'] : '';
1157
+	$connection_type = isset($credentials['connection_type']) ? $credentials['connection_type'] : '';
1158
+
1159
+	if ($error) {
1160 1160
 		$error_string = __('<strong>ERROR:</strong> There was an error connecting to the server, Please verify the settings are correct.');
1161
-		if ( is_wp_error($error) )
1162
-			$error_string = esc_html( $error->get_error_message() );
1163
-		echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
1161
+		if (is_wp_error($error))
1162
+			$error_string = esc_html($error->get_error_message());
1163
+		echo '<div id="message" class="error"><p>'.$error_string.'</p></div>';
1164 1164
 	}
1165 1165
 
1166 1166
 	$types = array();
1167
-	if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') )
1168
-		$types[ 'ftp' ] = __('FTP');
1169
-	if ( extension_loaded('ftp') ) //Only this supports FTPS
1170
-		$types[ 'ftps' ] = __('FTPS (SSL)');
1171
-	if ( extension_loaded('ssh2') && function_exists('stream_get_contents') )
1172
-		$types[ 'ssh' ] = __('SSH2');
1167
+	if (extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen'))
1168
+		$types['ftp'] = __('FTP');
1169
+	if (extension_loaded('ftp')) //Only this supports FTPS
1170
+		$types['ftps'] = __('FTPS (SSL)');
1171
+	if (extension_loaded('ssh2') && function_exists('stream_get_contents'))
1172
+		$types['ssh'] = __('SSH2');
1173 1173
 
1174 1174
 	/**
1175 1175
 	 * Filters the connection types to output to the filesystem credentials form.
@@ -1184,26 +1184,26 @@  discard block
 block discarded – undo
1184 1184
 	 * @param string $context     Full path to the directory that is tested
1185 1185
 	 *                            for being writable.
1186 1186
 	 */
1187
-	$types = apply_filters( 'fs_ftp_connection_types', $types, $credentials, $type, $error, $context );
1187
+	$types = apply_filters('fs_ftp_connection_types', $types, $credentials, $type, $error, $context);
1188 1188
 
1189 1189
 ?>
1190
-<form action="<?php echo esc_url( $form_post ) ?>" method="post">
1190
+<form action="<?php echo esc_url($form_post) ?>" method="post">
1191 1191
 <div id="request-filesystem-credentials-form" class="request-filesystem-credentials-form">
1192 1192
 <?php
1193 1193
 // Print a H1 heading in the FTP credentials modal dialog, default is a H2.
1194 1194
 $heading_tag = 'h2';
1195
-if ( 'plugins.php' === $pagenow || 'plugin-install.php' === $pagenow ) {
1195
+if ('plugins.php' === $pagenow || 'plugin-install.php' === $pagenow) {
1196 1196
 	$heading_tag = 'h1';
1197 1197
 }
1198
-echo "<$heading_tag id='request-filesystem-credentials-title'>" . __( 'Connection Information' ) . "</$heading_tag>";
1198
+echo "<$heading_tag id='request-filesystem-credentials-title'>".__('Connection Information')."</$heading_tag>";
1199 1199
 ?>
1200 1200
 <p id="request-filesystem-credentials-desc"><?php
1201 1201
 	$label_user = __('Username');
1202 1202
 	$label_pass = __('Password');
1203 1203
 	_e('To perform the requested action, WordPress needs to access your web server.');
1204 1204
 	echo ' ';
1205
-	if ( ( isset( $types['ftp'] ) || isset( $types['ftps'] ) ) ) {
1206
-		if ( isset( $types['ssh'] ) ) {
1205
+	if ((isset($types['ftp']) || isset($types['ftps']))) {
1206
+		if (isset($types['ssh'])) {
1207 1207
 			_e('Please enter your FTP or SSH credentials to proceed.');
1208 1208
 			$label_user = __('FTP/SSH Username');
1209 1209
 			$label_pass = __('FTP/SSH Password');
@@ -1217,29 +1217,29 @@  discard block
 block discarded – undo
1217 1217
 	_e('If you do not remember your credentials, you should contact your web host.');
1218 1218
 ?></p>
1219 1219
 <label for="hostname">
1220
-	<span class="field-title"><?php _e( 'Hostname' ) ?></span>
1221
-	<input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> />
1220
+	<span class="field-title"><?php _e('Hostname') ?></span>
1221
+	<input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e('example: www.wordpress.org') ?>" value="<?php echo esc_attr($hostname); if ( ! empty($port)) echo ":$port"; ?>"<?php disabled(defined('FTP_HOST')); ?> />
1222 1222
 </label>
1223 1223
 <div class="ftp-username">
1224 1224
 	<label for="username">
1225 1225
 		<span class="field-title"><?php echo $label_user; ?></span>
1226
-		<input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled( defined('FTP_USER') ); ?> />
1226
+		<input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled(defined('FTP_USER')); ?> />
1227 1227
 	</label>
1228 1228
 </div>
1229 1229
 <div class="ftp-password">
1230 1230
 	<label for="password">
1231 1231
 		<span class="field-title"><?php echo $label_pass; ?></span>
1232
-		<input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> />
1233
-		<em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em>
1232
+		<input name="password" type="password" id="password" value="<?php if (defined('FTP_PASS')) echo '*****'; ?>"<?php disabled(defined('FTP_PASS')); ?> />
1233
+		<em><?php if ( ! defined('FTP_PASS')) _e('This password will not be stored on the server.'); ?></em>
1234 1234
 	</label>
1235 1235
 </div>
1236 1236
 <fieldset>
1237
-<legend><?php _e( 'Connection Type' ); ?></legend>
1237
+<legend><?php _e('Connection Type'); ?></legend>
1238 1238
 <?php
1239
-	$disabled = disabled( ( defined( 'FTP_SSL' ) && FTP_SSL ) || ( defined( 'FTP_SSH' ) && FTP_SSH ), true, false );
1240
-	foreach ( $types as $name => $text ) : ?>
1241
-	<label for="<?php echo esc_attr( $name ) ?>">
1242
-		<input type="radio" name="connection_type" id="<?php echo esc_attr( $name ) ?>" value="<?php echo esc_attr( $name ) ?>"<?php checked( $name, $connection_type ); echo $disabled; ?> />
1239
+	$disabled = disabled((defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false);
1240
+	foreach ($types as $name => $text) : ?>
1241
+	<label for="<?php echo esc_attr($name) ?>">
1242
+		<input type="radio" name="connection_type" id="<?php echo esc_attr($name) ?>" value="<?php echo esc_attr($name) ?>"<?php checked($name, $connection_type); echo $disabled; ?> />
1243 1243
 		<?php echo $text; ?>
1244 1244
 	</label>
1245 1245
 <?php
@@ -1247,36 +1247,36 @@  discard block
 block discarded – undo
1247 1247
 ?>
1248 1248
 </fieldset>
1249 1249
 <?php
1250
-if ( isset( $types['ssh'] ) ) {
1250
+if (isset($types['ssh'])) {
1251 1251
 	$hidden_class = '';
1252
-	if ( 'ssh' != $connection_type || empty( $connection_type ) ) {
1252
+	if ('ssh' != $connection_type || empty($connection_type)) {
1253 1253
 		$hidden_class = ' class="hidden"';
1254 1254
 	}
1255 1255
 ?>
1256 1256
 <fieldset id="ssh-keys"<?php echo $hidden_class; ?>>
1257
-<legend><?php _e( 'Authentication Keys' ); ?></legend>
1257
+<legend><?php _e('Authentication Keys'); ?></legend>
1258 1258
 <label for="public_key">
1259 1259
 	<span class="field-title"><?php _e('Public Key:') ?></span>
1260
-	<input name="public_key" type="text" id="public_key" aria-describedby="auth-keys-desc" value="<?php echo esc_attr($public_key) ?>"<?php disabled( defined('FTP_PUBKEY') ); ?> />
1260
+	<input name="public_key" type="text" id="public_key" aria-describedby="auth-keys-desc" value="<?php echo esc_attr($public_key) ?>"<?php disabled(defined('FTP_PUBKEY')); ?> />
1261 1261
 </label>
1262 1262
 <label for="private_key">
1263 1263
 	<span class="field-title"><?php _e('Private Key:') ?></span>
1264
-	<input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> />
1264
+	<input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled(defined('FTP_PRIKEY')); ?> />
1265 1265
 </label>
1266
-<p id="auth-keys-desc"><?php _e( 'Enter the location on the server where the public and private keys are located. If a passphrase is needed, enter that in the password field above.' ) ?></p>
1266
+<p id="auth-keys-desc"><?php _e('Enter the location on the server where the public and private keys are located. If a passphrase is needed, enter that in the password field above.') ?></p>
1267 1267
 </fieldset>
1268 1268
 <?php
1269 1269
 }
1270 1270
 
1271
-foreach ( (array) $extra_fields as $field ) {
1272
-	if ( isset( $submitted_form[ $field ] ) )
1273
-		echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( $submitted_form[ $field ] ) . '" />';
1271
+foreach ((array) $extra_fields as $field) {
1272
+	if (isset($submitted_form[$field]))
1273
+		echo '<input type="hidden" name="'.esc_attr($field).'" value="'.esc_attr($submitted_form[$field]).'" />';
1274 1274
 }
1275 1275
 ?>
1276 1276
 	<p class="request-filesystem-credentials-action-buttons">
1277
-		<?php wp_nonce_field( 'filesystem-credentials', '_fs_nonce', false, true ); ?>
1278
-		<button class="button cancel-button" data-js-action="close" type="button"><?php _e( 'Cancel' ); ?></button>
1279
-		<?php submit_button( __( 'Proceed' ), '', 'upgrade', false ); ?>
1277
+		<?php wp_nonce_field('filesystem-credentials', '_fs_nonce', false, true); ?>
1278
+		<button class="button cancel-button" data-js-action="close" type="button"><?php _e('Cancel'); ?></button>
1279
+		<?php submit_button(__('Proceed'), '', 'upgrade', false); ?>
1280 1280
 	</p>
1281 1281
 </div>
1282 1282
 </form>
@@ -1292,10 +1292,10 @@  discard block
 block discarded – undo
1292 1292
 function wp_print_request_filesystem_credentials_modal() {
1293 1293
 	$filesystem_method = get_filesystem_method();
1294 1294
 	ob_start();
1295
-	$filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() );
1295
+	$filesystem_credentials_are_stored = request_filesystem_credentials(self_admin_url());
1296 1296
 	ob_end_clean();
1297
-	$request_filesystem_credentials = ( $filesystem_method != 'direct' && ! $filesystem_credentials_are_stored );
1298
-	if ( ! $request_filesystem_credentials ) {
1297
+	$request_filesystem_credentials = ($filesystem_method != 'direct' && ! $filesystem_credentials_are_stored);
1298
+	if ( ! $request_filesystem_credentials) {
1299 1299
 		return;
1300 1300
 	}
1301 1301
 	?>
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
 		<div class="notification-dialog-background"></div>
1304 1304
 		<div class="notification-dialog" role="dialog" aria-labelledby="request-filesystem-credentials-title" tabindex="0">
1305 1305
 			<div class="request-filesystem-credentials-dialog-content">
1306
-				<?php request_filesystem_credentials( site_url() ); ?>
1306
+				<?php request_filesystem_credentials(site_url()); ?>
1307 1307
 			</div>
1308 1308
 		</div>
1309 1309
 	</div>
Please login to merge, or discard this patch.
Braces   +208 added lines, -119 removed lines patch added patch discarded remove patch
@@ -125,23 +125,27 @@  discard block
 block discarded – undo
125 125
  * @return bool|array False on failure, Else array of files
126 126
  */
127 127
 function list_files( $folder = '', $levels = 100 ) {
128
-	if ( empty($folder) )
129
-		return false;
128
+	if ( empty($folder) ) {
129
+			return false;
130
+	}
130 131
 
131
-	if ( ! $levels )
132
-		return false;
132
+	if ( ! $levels ) {
133
+			return false;
134
+	}
133 135
 
134 136
 	$files = array();
135 137
 	if ( $dir = @opendir( $folder ) ) {
136 138
 		while (($file = readdir( $dir ) ) !== false ) {
137
-			if ( in_array($file, array('.', '..') ) )
138
-				continue;
139
+			if ( in_array($file, array('.', '..') ) ) {
140
+							continue;
141
+			}
139 142
 			if ( is_dir( $folder . '/' . $file ) ) {
140 143
 				$files2 = list_files( $folder . '/' . $file, $levels - 1);
141
-				if ( $files2 )
142
-					$files = array_merge($files, $files2 );
143
-				else
144
-					$files[] = $folder . '/' . $file . '/';
144
+				if ( $files2 ) {
145
+									$files = array_merge($files, $files2 );
146
+				} else {
147
+									$files[] = $folder . '/' . $file . '/';
148
+				}
145 149
 			} else {
146 150
 				$files[] = $folder . '/' . $file;
147 151
 			}
@@ -212,8 +216,9 @@  discard block
 block discarded – undo
212 216
 function validate_file_to_edit( $file, $allowed_files = '' ) {
213 217
 	$code = validate_file( $file, $allowed_files );
214 218
 
215
-	if (!$code )
216
-		return $file;
219
+	if (!$code ) {
220
+			return $file;
221
+	}
217 222
 
218 223
 	switch ( $code ) {
219 224
 		case 1 :
@@ -491,14 +496,16 @@  discard block
 block discarded – undo
491 496
  */
492 497
 function download_url( $url, $timeout = 300 ) {
493 498
 	//WARNING: The file is not automatically deleted, The script must unlink() the file.
494
-	if ( ! $url )
495
-		return new WP_Error('http_no_url', __('Invalid URL Provided.'));
499
+	if ( ! $url ) {
500
+			return new WP_Error('http_no_url', __('Invalid URL Provided.'));
501
+	}
496 502
 
497 503
 	$url_filename = basename( parse_url( $url, PHP_URL_PATH ) );
498 504
 
499 505
 	$tmpfname = wp_tempnam( $url_filename );
500
-	if ( ! $tmpfname )
501
-		return new WP_Error('http_no_file', __('Could not create Temporary file.'));
506
+	if ( ! $tmpfname ) {
507
+			return new WP_Error('http_no_file', __('Could not create Temporary file.'));
508
+	}
502 509
 
503 510
 	$response = wp_safe_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) );
504 511
 
@@ -534,17 +541,20 @@  discard block
 block discarded – undo
534 541
  * @return bool|object WP_Error on failure, true on success, false when the MD5 format is unknown/unexpected
535 542
  */
536 543
 function verify_file_md5( $filename, $expected_md5 ) {
537
-	if ( 32 == strlen( $expected_md5 ) )
538
-		$expected_raw_md5 = pack( 'H*', $expected_md5 );
539
-	elseif ( 24 == strlen( $expected_md5 ) )
540
-		$expected_raw_md5 = base64_decode( $expected_md5 );
541
-	else
542
-		return false; // unknown format
544
+	if ( 32 == strlen( $expected_md5 ) ) {
545
+			$expected_raw_md5 = pack( 'H*', $expected_md5 );
546
+	} elseif ( 24 == strlen( $expected_md5 ) ) {
547
+			$expected_raw_md5 = base64_decode( $expected_md5 );
548
+	} else {
549
+			return false;
550
+	}
551
+	// unknown format
543 552
 
544 553
 	$file_md5 = md5_file( $filename, true );
545 554
 
546
-	if ( $file_md5 === $expected_raw_md5 )
547
-		return true;
555
+	if ( $file_md5 === $expected_raw_md5 ) {
556
+			return true;
557
+	}
548 558
 
549 559
 	return new WP_Error( 'md5_mismatch', sprintf( __( 'The checksum of the file (%1$s) does not match the expected checksum value (%2$s).' ), bin2hex( $file_md5 ), bin2hex( $expected_raw_md5 ) ) );
550 560
 }
@@ -567,8 +577,9 @@  discard block
 block discarded – undo
567 577
 function unzip_file($file, $to) {
568 578
 	global $wp_filesystem;
569 579
 
570
-	if ( ! $wp_filesystem || !is_object($wp_filesystem) )
571
-		return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
580
+	if ( ! $wp_filesystem || !is_object($wp_filesystem) ) {
581
+			return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
582
+	}
572 583
 
573 584
 	// Unzip can use a lot of memory, but not this much hopefully.
574 585
 	wp_raise_memory_limit( 'admin' );
@@ -580,17 +591,22 @@  discard block
 block discarded – undo
580 591
 	if ( ! $wp_filesystem->is_dir($to) ) { //Only do parents if no children exist
581 592
 		$path = preg_split('![/\\\]!', untrailingslashit($to));
582 593
 		for ( $i = count($path); $i >= 0; $i-- ) {
583
-			if ( empty($path[$i]) )
584
-				continue;
594
+			if ( empty($path[$i]) ) {
595
+							continue;
596
+			}
585 597
 
586 598
 			$dir = implode('/', array_slice($path, 0, $i+1) );
587
-			if ( preg_match('!^[a-z]:$!i', $dir) ) // Skip it if it looks like a Windows Drive letter.
599
+			if ( preg_match('!^[a-z]:$!i', $dir) ) {
600
+				// Skip it if it looks like a Windows Drive letter.
588 601
 				continue;
602
+			}
589 603
 
590
-			if ( ! $wp_filesystem->is_dir($dir) )
591
-				$needed_dirs[] = $dir;
592
-			else
593
-				break; // A folder exists, therefor, we dont need the check the levels below this
604
+			if ( ! $wp_filesystem->is_dir($dir) ) {
605
+							$needed_dirs[] = $dir;
606
+			} else {
607
+							break;
608
+			}
609
+			// A folder exists, therefor, we dont need the check the levels below this
594 610
 		}
595 611
 	}
596 612
 
@@ -606,8 +622,9 @@  discard block
 block discarded – undo
606 622
 		if ( true === $result ) {
607 623
 			return $result;
608 624
 		} elseif ( is_wp_error($result) ) {
609
-			if ( 'incompatible_archive' != $result->get_error_code() )
610
-				return $result;
625
+			if ( 'incompatible_archive' != $result->get_error_code() ) {
626
+							return $result;
627
+			}
611 628
 		}
612 629
 	}
613 630
 	// Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file.
@@ -635,17 +652,21 @@  discard block
 block discarded – undo
635 652
 	$z = new ZipArchive();
636 653
 
637 654
 	$zopen = $z->open( $file, ZIPARCHIVE::CHECKCONS );
638
-	if ( true !== $zopen )
639
-		return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) );
655
+	if ( true !== $zopen ) {
656
+			return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) );
657
+	}
640 658
 
641 659
 	$uncompressed_size = 0;
642 660
 
643 661
 	for ( $i = 0; $i < $z->numFiles; $i++ ) {
644
-		if ( ! $info = $z->statIndex($i) )
645
-			return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
662
+		if ( ! $info = $z->statIndex($i) ) {
663
+					return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
664
+		}
646 665
 
647
-		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory
666
+		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) {
667
+			// Skip the OS X-created __MACOSX directory
648 668
 			continue;
669
+		}
649 670
 
650 671
 		$uncompressed_size += $info['size'];
651 672
 
@@ -665,17 +686,22 @@  discard block
 block discarded – undo
665 686
 	 */
666 687
 	if ( wp_doing_cron() ) {
667 688
 		$available_space = @disk_free_space( WP_CONTENT_DIR );
668
-		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space )
669
-			return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
689
+		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
690
+					return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
691
+		}
670 692
 	}
671 693
 
672 694
 	$needed_dirs = array_unique($needed_dirs);
673 695
 	foreach ( $needed_dirs as $dir ) {
674 696
 		// Check the parent folders of the folders all exist within the creation array.
675
-		if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
697
+		if ( untrailingslashit($to) == $dir ) {
698
+			// Skip over the working directory, We know this exists (or will exist)
676 699
 			continue;
677
-		if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
700
+		}
701
+		if ( strpos($dir, $to) === false ) {
702
+			// If the directory is not within the working directory, Skip it
678 703
 			continue;
704
+		}
679 705
 
680 706
 		$parent_folder = dirname($dir);
681 707
 		while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) {
@@ -695,21 +721,28 @@  discard block
 block discarded – undo
695 721
 	unset($needed_dirs);
696 722
 
697 723
 	for ( $i = 0; $i < $z->numFiles; $i++ ) {
698
-		if ( ! $info = $z->statIndex($i) )
699
-			return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
724
+		if ( ! $info = $z->statIndex($i) ) {
725
+					return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
726
+		}
700 727
 
701
-		if ( '/' == substr($info['name'], -1) ) // directory
728
+		if ( '/' == substr($info['name'], -1) ) {
729
+			// directory
702 730
 			continue;
731
+		}
703 732
 
704
-		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
733
+		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) {
734
+			// Don't extract the OS X-created __MACOSX directory files
705 735
 			continue;
736
+		}
706 737
 
707 738
 		$contents = $z->getFromIndex($i);
708
-		if ( false === $contents )
709
-			return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
739
+		if ( false === $contents ) {
740
+					return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
741
+		}
710 742
 
711
-		if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) )
712
-			return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] );
743
+		if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) ) {
744
+					return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] );
745
+		}
713 746
 	}
714 747
 
715 748
 	$z->close();
@@ -746,18 +779,22 @@  discard block
 block discarded – undo
746 779
 	reset_mbstring_encoding();
747 780
 
748 781
 	// Is the archive valid?
749
-	if ( !is_array($archive_files) )
750
-		return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true));
782
+	if ( !is_array($archive_files) ) {
783
+			return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true));
784
+	}
751 785
 
752
-	if ( 0 == count($archive_files) )
753
-		return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) );
786
+	if ( 0 == count($archive_files) ) {
787
+			return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) );
788
+	}
754 789
 
755 790
 	$uncompressed_size = 0;
756 791
 
757 792
 	// Determine any children directories needed (From within the archive)
758 793
 	foreach ( $archive_files as $file ) {
759
-		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory
794
+		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) {
795
+			// Skip the OS X-created __MACOSX directory
760 796
 			continue;
797
+		}
761 798
 
762 799
 		$uncompressed_size += $file['size'];
763 800
 
@@ -771,17 +808,22 @@  discard block
 block discarded – undo
771 808
 	 */
772 809
 	if ( wp_doing_cron() ) {
773 810
 		$available_space = @disk_free_space( WP_CONTENT_DIR );
774
-		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space )
775
-			return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
811
+		if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
812
+					return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
813
+		}
776 814
 	}
777 815
 
778 816
 	$needed_dirs = array_unique($needed_dirs);
779 817
 	foreach ( $needed_dirs as $dir ) {
780 818
 		// Check the parent folders of the folders all exist within the creation array.
781
-		if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
819
+		if ( untrailingslashit($to) == $dir ) {
820
+			// Skip over the working directory, We know this exists (or will exist)
782 821
 			continue;
783
-		if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
822
+		}
823
+		if ( strpos($dir, $to) === false ) {
824
+			// If the directory is not within the working directory, Skip it
784 825
 			continue;
826
+		}
785 827
 
786 828
 		$parent_folder = dirname($dir);
787 829
 		while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) {
@@ -794,21 +836,26 @@  discard block
 block discarded – undo
794 836
 	// Create those directories if need be:
795 837
 	foreach ( $needed_dirs as $_dir ) {
796 838
 		// Only check to see if the dir exists upon creation failure. Less I/O this way.
797
-		if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) )
798
-			return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
839
+		if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
840
+					return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
841
+		}
799 842
 	}
800 843
 	unset($needed_dirs);
801 844
 
802 845
 	// Extract the files from the zip
803 846
 	foreach ( $archive_files as $file ) {
804
-		if ( $file['folder'] )
805
-			continue;
847
+		if ( $file['folder'] ) {
848
+					continue;
849
+		}
806 850
 
807
-		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
851
+		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) {
852
+			// Don't extract the OS X-created __MACOSX directory files
808 853
 			continue;
854
+		}
809 855
 
810
-		if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
811
-			return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
856
+		if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) {
857
+					return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
858
+		}
812 859
 	}
813 860
 	return true;
814 861
 }
@@ -835,32 +882,37 @@  discard block
 block discarded – undo
835 882
 	$to = trailingslashit($to);
836 883
 
837 884
 	foreach ( (array) $dirlist as $filename => $fileinfo ) {
838
-		if ( in_array( $filename, $skip_list ) )
839
-			continue;
885
+		if ( in_array( $filename, $skip_list ) ) {
886
+					continue;
887
+		}
840 888
 
841 889
 		if ( 'f' == $fileinfo['type'] ) {
842 890
 			if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
843 891
 				// If copy failed, chmod file to 0644 and try again.
844 892
 				$wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE );
845
-				if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
846
-					return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename );
893
+				if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
894
+									return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename );
895
+				}
847 896
 			}
848 897
 		} elseif ( 'd' == $fileinfo['type'] ) {
849 898
 			if ( !$wp_filesystem->is_dir($to . $filename) ) {
850
-				if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
851
-					return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename );
899
+				if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) {
900
+									return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename );
901
+				}
852 902
 			}
853 903
 
854 904
 			// generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list
855 905
 			$sub_skip_list = array();
856 906
 			foreach ( $skip_list as $skip_item ) {
857
-				if ( 0 === strpos( $skip_item, $filename . '/' ) )
858
-					$sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item );
907
+				if ( 0 === strpos( $skip_item, $filename . '/' ) ) {
908
+									$sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item );
909
+				}
859 910
 			}
860 911
 
861 912
 			$result = copy_dir($from . $filename, $to . $filename, $sub_skip_list);
862
-			if ( is_wp_error($result) )
863
-				return $result;
913
+			if ( is_wp_error($result) ) {
914
+							return $result;
915
+			}
864 916
 		}
865 917
 	}
866 918
 	return true;
@@ -890,8 +942,9 @@  discard block
 block discarded – undo
890 942
 
891 943
 	$method = get_filesystem_method( $args, $context, $allow_relaxed_file_ownership );
892 944
 
893
-	if ( ! $method )
894
-		return false;
945
+	if ( ! $method ) {
946
+			return false;
947
+	}
895 948
 
896 949
 	if ( ! class_exists( "WP_Filesystem_$method" ) ) {
897 950
 
@@ -907,8 +960,9 @@  discard block
 block discarded – undo
907 960
 		 */
908 961
 		$abstraction_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method );
909 962
 
910
-		if ( ! file_exists($abstraction_file) )
911
-			return;
963
+		if ( ! file_exists($abstraction_file) ) {
964
+					return;
965
+		}
912 966
 
913 967
 		require_once($abstraction_file);
914 968
 	}
@@ -917,22 +971,29 @@  discard block
 block discarded – undo
917 971
 	$wp_filesystem = new $method($args);
918 972
 
919 973
 	//Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
920
-	if ( ! defined('FS_CONNECT_TIMEOUT') )
921
-		define('FS_CONNECT_TIMEOUT', 30);
922
-	if ( ! defined('FS_TIMEOUT') )
923
-		define('FS_TIMEOUT', 30);
974
+	if ( ! defined('FS_CONNECT_TIMEOUT') ) {
975
+			define('FS_CONNECT_TIMEOUT', 30);
976
+	}
977
+	if ( ! defined('FS_TIMEOUT') ) {
978
+			define('FS_TIMEOUT', 30);
979
+	}
924 980
 
925
-	if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
926
-		return false;
981
+	if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) {
982
+			return false;
983
+	}
927 984
 
928
-	if ( !$wp_filesystem->connect() )
929
-		return false; //There was an error connecting to the server.
985
+	if ( !$wp_filesystem->connect() ) {
986
+			return false;
987
+	}
988
+	//There was an error connecting to the server.
930 989
 
931 990
 	// Set the permission constants if not already set.
932
-	if ( ! defined('FS_CHMOD_DIR') )
933
-		define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) );
934
-	if ( ! defined('FS_CHMOD_FILE') )
935
-		define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
991
+	if ( ! defined('FS_CHMOD_DIR') ) {
992
+			define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) );
993
+	}
994
+	if ( ! defined('FS_CHMOD_FILE') ) {
995
+			define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
996
+	}
936 997
 
937 998
 	return true;
938 999
 }
@@ -1007,9 +1068,16 @@  discard block
 block discarded – undo
1007 1068
 		}
1008 1069
  	}
1009 1070
 
1010
-	if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2';
1011
-	if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
1012
-	if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
1071
+	if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) {
1072
+		$method = 'ssh2';
1073
+	}
1074
+	if ( ! $method && extension_loaded('ftp') ) {
1075
+		$method = 'ftpext';
1076
+	}
1077
+	if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) {
1078
+		$method = 'ftpsockets';
1079
+	}
1080
+	//Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
1013 1081
 
1014 1082
 	/**
1015 1083
 	 * Filters the filesystem method to use.
@@ -1076,18 +1144,21 @@  discard block
 block discarded – undo
1076 1144
 	 * @param array  $extra_fields                 Extra POST fields.
1077 1145
 	 */
1078 1146
 	$req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership );
1079
-	if ( '' !== $req_cred )
1080
-		return $req_cred;
1147
+	if ( '' !== $req_cred ) {
1148
+			return $req_cred;
1149
+	}
1081 1150
 
1082 1151
 	if ( empty($type) ) {
1083 1152
 		$type = get_filesystem_method( array(), $context, $allow_relaxed_file_ownership );
1084 1153
 	}
1085 1154
 
1086
-	if ( 'direct' == $type )
1087
-		return true;
1155
+	if ( 'direct' == $type ) {
1156
+			return true;
1157
+	}
1088 1158
 
1089
-	if ( is_null( $extra_fields ) )
1090
-		$extra_fields = array( 'version', 'locale' );
1159
+	if ( is_null( $extra_fields ) ) {
1160
+			$extra_fields = array( 'version', 'locale' );
1161
+	}
1091 1162
 
1092 1163
 	$credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => ''));
1093 1164
 
@@ -1119,8 +1190,9 @@  discard block
 block discarded – undo
1119 1190
 
1120 1191
 	if ( strpos($credentials['hostname'], ':') ) {
1121 1192
 		list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2);
1122
-		if ( ! is_numeric($credentials['port']) )
1123
-			unset($credentials['port']);
1193
+		if ( ! is_numeric($credentials['port']) ) {
1194
+					unset($credentials['port']);
1195
+		}
1124 1196
 	} else {
1125 1197
 		unset($credentials['port']);
1126 1198
 	}
@@ -1140,8 +1212,10 @@  discard block
 block discarded – undo
1140 1212
 				( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) )
1141 1213
 			) ) {
1142 1214
 		$stored_credentials = $credentials;
1143
-		if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code.
1215
+		if ( !empty($stored_credentials['port']) ) {
1216
+			//save port as part of hostname to simplify above code.
1144 1217
 			$stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
1218
+		}
1145 1219
 
1146 1220
 		unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']);
1147 1221
 		if ( ! wp_installing() ) {
@@ -1158,18 +1232,23 @@  discard block
 block discarded – undo
1158 1232
 
1159 1233
 	if ( $error ) {
1160 1234
 		$error_string = __('<strong>ERROR:</strong> There was an error connecting to the server, Please verify the settings are correct.');
1161
-		if ( is_wp_error($error) )
1162
-			$error_string = esc_html( $error->get_error_message() );
1235
+		if ( is_wp_error($error) ) {
1236
+					$error_string = esc_html( $error->get_error_message() );
1237
+		}
1163 1238
 		echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
1164 1239
 	}
1165 1240
 
1166 1241
 	$types = array();
1167
-	if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') )
1168
-		$types[ 'ftp' ] = __('FTP');
1169
-	if ( extension_loaded('ftp') ) //Only this supports FTPS
1242
+	if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') ) {
1243
+			$types[ 'ftp' ] = __('FTP');
1244
+	}
1245
+	if ( extension_loaded('ftp') ) {
1246
+		//Only this supports FTPS
1170 1247
 		$types[ 'ftps' ] = __('FTPS (SSL)');
1171
-	if ( extension_loaded('ssh2') && function_exists('stream_get_contents') )
1172
-		$types[ 'ssh' ] = __('SSH2');
1248
+	}
1249
+	if ( extension_loaded('ssh2') && function_exists('stream_get_contents') ) {
1250
+			$types[ 'ssh' ] = __('SSH2');
1251
+	}
1173 1252
 
1174 1253
 	/**
1175 1254
 	 * Filters the connection types to output to the filesystem credentials form.
@@ -1218,7 +1297,10 @@  discard block
 block discarded – undo
1218 1297
 ?></p>
1219 1298
 <label for="hostname">
1220 1299
 	<span class="field-title"><?php _e( 'Hostname' ) ?></span>
1221
-	<input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> />
1300
+	<input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) {
1301
+	echo ":$port";
1302
+}
1303
+?>"<?php disabled( defined('FTP_HOST') ); ?> />
1222 1304
 </label>
1223 1305
 <div class="ftp-username">
1224 1306
 	<label for="username">
@@ -1229,8 +1311,14 @@  discard block
 block discarded – undo
1229 1311
 <div class="ftp-password">
1230 1312
 	<label for="password">
1231 1313
 		<span class="field-title"><?php echo $label_pass; ?></span>
1232
-		<input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> />
1233
-		<em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em>
1314
+		<input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) {
1315
+	echo '*****';
1316
+}
1317
+?>"<?php disabled( defined('FTP_PASS') ); ?> />
1318
+		<em><?php if ( ! defined('FTP_PASS') ) {
1319
+	_e( 'This password will not be stored on the server.' );
1320
+}
1321
+?></em>
1234 1322
 	</label>
1235 1323
 </div>
1236 1324
 <fieldset>
@@ -1269,9 +1357,10 @@  discard block
 block discarded – undo
1269 1357
 }
1270 1358
 
1271 1359
 foreach ( (array) $extra_fields as $field ) {
1272
-	if ( isset( $submitted_form[ $field ] ) )
1273
-		echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( $submitted_form[ $field ] ) . '" />';
1274
-}
1360
+	if ( isset( $submitted_form[ $field ] ) ) {
1361
+			echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( $submitted_form[ $field ] ) . '" />';
1362
+	}
1363
+	}
1275 1364
 ?>
1276 1365
 	<p class="request-filesystem-credentials-action-buttons">
1277 1366
 		<?php wp_nonce_field( 'filesystem-credentials', '_fs_nonce', false, true ); ?>
Please login to merge, or discard this patch.
src/wp-admin/includes/misc.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
  *
190 190
  * @global WP_Rewrite $wp_rewrite
191 191
  *
192
- * @return bool True if web.config was updated successfully
192
+ * @return null|boolean True if web.config was updated successfully
193 193
  */
194 194
 function iis7_save_url_rewrite_rules(){
195 195
 	if ( is_multisite() )
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
  *
276 276
  * @since 2.0.0
277 277
  *
278
- * @param array $vars An array of globals to reset.
278
+ * @param string[] $vars An array of globals to reset.
279 279
  */
280 280
 function wp_reset_vars( $vars ) {
281 281
 	foreach ( $vars as $var ) {
Please login to merge, or discard this patch.
Spacing   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @param bool $got_rewrite Whether Apache and mod_rewrite are present.
30 30
 	 */
31
-	return apply_filters( 'got_rewrite', $got_rewrite );
31
+	return apply_filters('got_rewrite', $got_rewrite);
32 32
 }
33 33
 
34 34
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
  * @return bool Whether the server supports URL rewriting.
44 44
  */
45 45
 function got_url_rewrite() {
46
-	$got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks() );
46
+	$got_url_rewrite = (got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks());
47 47
 
48 48
 	/**
49 49
 	 * Filters whether URL rewriting is available.
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @param bool $got_url_rewrite Whether URL rewriting is available.
54 54
 	 */
55
-	return apply_filters( 'got_url_rewrite', $got_url_rewrite );
55
+	return apply_filters('got_url_rewrite', $got_url_rewrite);
56 56
 }
57 57
 
58 58
 /**
@@ -64,22 +64,22 @@  discard block
 block discarded – undo
64 64
  * @param string $marker
65 65
  * @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
66 66
  */
67
-function extract_from_markers( $filename, $marker ) {
68
-	$result = array ();
67
+function extract_from_markers($filename, $marker) {
68
+	$result = array();
69 69
 
70
-	if (!file_exists( $filename ) ) {
70
+	if ( ! file_exists($filename)) {
71 71
 		return $result;
72 72
 	}
73 73
 
74
-	if ( $markerdata = explode( "\n", implode( '', file( $filename ) ) ));
74
+	if ($markerdata = explode("\n", implode('', file($filename))));
75 75
 	{
76 76
 		$state = false;
77
-		foreach ( $markerdata as $markerline ) {
78
-			if (strpos($markerline, '# END ' . $marker) !== false)
77
+		foreach ($markerdata as $markerline) {
78
+			if (strpos($markerline, '# END '.$marker) !== false)
79 79
 				$state = false;
80
-			if ( $state )
80
+			if ($state)
81 81
 				$result[] = $markerline;
82
-			if (strpos($markerline, '# BEGIN ' . $marker) !== false)
82
+			if (strpos($markerline, '# BEGIN '.$marker) !== false)
83 83
 				$state = true;
84 84
 		}
85 85
 	}
@@ -101,52 +101,52 @@  discard block
 block discarded – undo
101 101
  * @param array|string $insertion The new content to insert.
102 102
  * @return bool True on write success, false on failure.
103 103
  */
104
-function insert_with_markers( $filename, $marker, $insertion ) {
105
-	if ( ! file_exists( $filename ) ) {
106
-		if ( ! is_writable( dirname( $filename ) ) ) {
104
+function insert_with_markers($filename, $marker, $insertion) {
105
+	if ( ! file_exists($filename)) {
106
+		if ( ! is_writable(dirname($filename))) {
107 107
 			return false;
108 108
 		}
109
-		if ( ! touch( $filename ) ) {
109
+		if ( ! touch($filename)) {
110 110
 			return false;
111 111
 		}
112
-	} elseif ( ! is_writeable( $filename ) ) {
112
+	} elseif ( ! is_writeable($filename)) {
113 113
 		return false;
114 114
 	}
115 115
 
116
-	if ( ! is_array( $insertion ) ) {
117
-		$insertion = explode( "\n", $insertion );
116
+	if ( ! is_array($insertion)) {
117
+		$insertion = explode("\n", $insertion);
118 118
 	}
119 119
 
120 120
 	$start_marker = "# BEGIN {$marker}";
121 121
 	$end_marker   = "# END {$marker}";
122 122
 
123
-	$fp = fopen( $filename, 'r+' );
124
-	if ( ! $fp ) {
123
+	$fp = fopen($filename, 'r+');
124
+	if ( ! $fp) {
125 125
 		return false;
126 126
 	}
127 127
 
128 128
 	// Attempt to get a lock. If the filesystem supports locking, this will block until the lock is acquired.
129
-	flock( $fp, LOCK_EX );
129
+	flock($fp, LOCK_EX);
130 130
 
131 131
 	$lines = array();
132
-	while ( ! feof( $fp ) ) {
133
-		$lines[] = rtrim( fgets( $fp ), "\r\n" );
132
+	while ( ! feof($fp)) {
133
+		$lines[] = rtrim(fgets($fp), "\r\n");
134 134
 	}
135 135
 
136 136
 	// Split out the existing file into the preceding lines, and those that appear after the marker
137 137
 	$pre_lines = $post_lines = $existing_lines = array();
138 138
 	$found_marker = $found_end_marker = false;
139
-	foreach ( $lines as $line ) {
140
-		if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) {
139
+	foreach ($lines as $line) {
140
+		if ( ! $found_marker && false !== strpos($line, $start_marker)) {
141 141
 			$found_marker = true;
142 142
 			continue;
143
-		} elseif ( ! $found_end_marker && false !== strpos( $line, $end_marker ) ) {
143
+		} elseif ( ! $found_end_marker && false !== strpos($line, $end_marker)) {
144 144
 			$found_end_marker = true;
145 145
 			continue;
146 146
 		}
147
-		if ( ! $found_marker ) {
147
+		if ( ! $found_marker) {
148 148
 			$pre_lines[] = $line;
149
-		} elseif ( $found_marker && $found_end_marker ) {
149
+		} elseif ($found_marker && $found_end_marker) {
150 150
 			$post_lines[] = $line;
151 151
 		} else {
152 152
 			$existing_lines[] = $line;
@@ -154,31 +154,31 @@  discard block
 block discarded – undo
154 154
 	}
155 155
 
156 156
 	// Check to see if there was a change
157
-	if ( $existing_lines === $insertion ) {
158
-		flock( $fp, LOCK_UN );
159
-		fclose( $fp );
157
+	if ($existing_lines === $insertion) {
158
+		flock($fp, LOCK_UN);
159
+		fclose($fp);
160 160
 
161 161
 		return true;
162 162
 	}
163 163
 
164 164
 	// Generate the new file data
165
-	$new_file_data = implode( "\n", array_merge(
165
+	$new_file_data = implode("\n", array_merge(
166 166
 		$pre_lines,
167
-		array( $start_marker ),
167
+		array($start_marker),
168 168
 		$insertion,
169
-		array( $end_marker ),
169
+		array($end_marker),
170 170
 		$post_lines
171
-	) );
171
+	));
172 172
 
173 173
 	// Write to the start of the file, and truncate it to that length
174
-	fseek( $fp, 0 );
175
-	$bytes = fwrite( $fp, $new_file_data );
176
-	if ( $bytes ) {
177
-		ftruncate( $fp, ftell( $fp ) );
174
+	fseek($fp, 0);
175
+	$bytes = fwrite($fp, $new_file_data);
176
+	if ($bytes) {
177
+		ftruncate($fp, ftell($fp));
178 178
 	}
179
-	fflush( $fp );
180
-	flock( $fp, LOCK_UN );
181
-	fclose( $fp );
179
+	fflush($fp);
180
+	flock($fp, LOCK_UN);
181
+	fclose($fp);
182 182
 
183 183
 	return (bool) $bytes;
184 184
 }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
  * @global WP_Rewrite $wp_rewrite
195 195
  */
196 196
 function save_mod_rewrite_rules() {
197
-	if ( is_multisite() )
197
+	if (is_multisite())
198 198
 		return;
199 199
 
200 200
 	global $wp_rewrite;
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
 	 * If the file doesn't already exist check for write access to the directory
207 207
 	 * and whether we have some rules. Else check for write access to the file.
208 208
 	 */
209
-	if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
210
-		if ( got_mod_rewrite() ) {
211
-			$rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
212
-			return insert_with_markers( $htaccess_file, 'WordPress', $rules );
209
+	if (( ! file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
210
+		if (got_mod_rewrite()) {
211
+			$rules = explode("\n", $wp_rewrite->mod_rewrite_rules());
212
+			return insert_with_markers($htaccess_file, 'WordPress', $rules);
213 213
 		}
214 214
 	}
215 215
 
@@ -226,19 +226,19 @@  discard block
 block discarded – undo
226 226
  *
227 227
  * @return bool True if web.config was updated successfully
228 228
  */
229
-function iis7_save_url_rewrite_rules(){
230
-	if ( is_multisite() )
229
+function iis7_save_url_rewrite_rules() {
230
+	if (is_multisite())
231 231
 		return;
232 232
 
233 233
 	global $wp_rewrite;
234 234
 
235 235
 	$home_path = get_home_path();
236
-	$web_config_file = $home_path . 'web.config';
236
+	$web_config_file = $home_path.'web.config';
237 237
 
238 238
 	// Using win_is_writable() instead of is_writable() because of a bug in Windows PHP
239
-	if ( iis7_supports_permalinks() && ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) ) {
239
+	if (iis7_supports_permalinks() && (( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || win_is_writable($web_config_file))) {
240 240
 		$rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', '');
241
-		if ( ! empty($rule) ) {
241
+		if ( ! empty($rule)) {
242 242
 			return iis7_add_rewrite_rule($web_config_file, $rule);
243 243
 		} else {
244 244
 			return iis7_delete_rewrite_rule($web_config_file);
@@ -254,19 +254,19 @@  discard block
 block discarded – undo
254 254
  *
255 255
  * @param string $file
256 256
  */
257
-function update_recently_edited( $file ) {
258
-	$oldfiles = (array ) get_option( 'recently_edited' );
259
-	if ( $oldfiles ) {
260
-		$oldfiles = array_reverse( $oldfiles );
257
+function update_recently_edited($file) {
258
+	$oldfiles = (array) get_option('recently_edited');
259
+	if ($oldfiles) {
260
+		$oldfiles = array_reverse($oldfiles);
261 261
 		$oldfiles[] = $file;
262
-		$oldfiles = array_reverse( $oldfiles );
263
-		$oldfiles = array_unique( $oldfiles );
264
-		if ( 5 < count( $oldfiles ))
265
-			array_pop( $oldfiles );
262
+		$oldfiles = array_reverse($oldfiles);
263
+		$oldfiles = array_unique($oldfiles);
264
+		if (5 < count($oldfiles))
265
+			array_pop($oldfiles);
266 266
 	} else {
267 267
 		$oldfiles[] = $file;
268 268
 	}
269
-	update_option( 'recently_edited', $oldfiles );
269
+	update_option('recently_edited', $oldfiles);
270 270
 }
271 271
 
272 272
 /**
@@ -277,12 +277,12 @@  discard block
 block discarded – undo
277 277
  * @param string $old_value
278 278
  * @param string $value
279 279
  */
280
-function update_home_siteurl( $old_value, $value ) {
281
-	if ( wp_installing() )
280
+function update_home_siteurl($old_value, $value) {
281
+	if (wp_installing())
282 282
 		return;
283 283
 
284
-	if ( is_multisite() && ms_is_switched() ) {
285
-		delete_option( 'rewrite_rules' );
284
+	if (is_multisite() && ms_is_switched()) {
285
+		delete_option('rewrite_rules');
286 286
 	} else {
287 287
 		flush_rewrite_rules();
288 288
 	}
@@ -300,16 +300,16 @@  discard block
 block discarded – undo
300 300
  *
301 301
  * @param array $vars An array of globals to reset.
302 302
  */
303
-function wp_reset_vars( $vars ) {
304
-	foreach ( $vars as $var ) {
305
-		if ( empty( $_POST[ $var ] ) ) {
306
-			if ( empty( $_GET[ $var ] ) ) {
307
-				$GLOBALS[ $var ] = '';
303
+function wp_reset_vars($vars) {
304
+	foreach ($vars as $var) {
305
+		if (empty($_POST[$var])) {
306
+			if (empty($_GET[$var])) {
307
+				$GLOBALS[$var] = '';
308 308
 			} else {
309
-				$GLOBALS[ $var ] = $_GET[ $var ];
309
+				$GLOBALS[$var] = $_GET[$var];
310 310
 			}
311 311
 		} else {
312
-			$GLOBALS[ $var ] = $_POST[ $var ];
312
+			$GLOBALS[$var] = $_POST[$var];
313 313
 		}
314 314
 	}
315 315
 }
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
  * @param string|WP_Error $message
323 323
  */
324 324
 function show_message($message) {
325
-	if ( is_wp_error($message) ){
326
-		if ( $message->get_error_data() && is_string( $message->get_error_data() ) )
327
-			$message = $message->get_error_message() . ': ' . $message->get_error_data();
325
+	if (is_wp_error($message)) {
326
+		if ($message->get_error_data() && is_string($message->get_error_data()))
327
+			$message = $message->get_error_message().': '.$message->get_error_data();
328 328
 		else
329 329
 			$message = $message->get_error_message();
330 330
 	}
@@ -339,25 +339,25 @@  discard block
 block discarded – undo
339 339
  * @param string $content
340 340
  * @return array
341 341
  */
342
-function wp_doc_link_parse( $content ) {
343
-	if ( !is_string( $content ) || empty( $content ) )
342
+function wp_doc_link_parse($content) {
343
+	if ( ! is_string($content) || empty($content))
344 344
 		return array();
345 345
 
346
-	if ( !function_exists('token_get_all') )
346
+	if ( ! function_exists('token_get_all'))
347 347
 		return array();
348 348
 
349
-	$tokens = token_get_all( $content );
350
-	$count = count( $tokens );
349
+	$tokens = token_get_all($content);
350
+	$count = count($tokens);
351 351
 	$functions = array();
352 352
 	$ignore_functions = array();
353
-	for ( $t = 0; $t < $count - 2; $t++ ) {
354
-		if ( ! is_array( $tokens[ $t ] ) ) {
353
+	for ($t = 0; $t < $count - 2; $t++) {
354
+		if ( ! is_array($tokens[$t])) {
355 355
 			continue;
356 356
 		}
357 357
 
358
-		if ( T_STRING == $tokens[ $t ][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) {
358
+		if (T_STRING == $tokens[$t][0] && ('(' == $tokens[$t + 1] || '(' == $tokens[$t + 2])) {
359 359
 			// If it's a function or class defined locally, there's not going to be any docs available
360
-			if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) {
360
+			if ((isset($tokens[$t - 2][1]) && in_array($tokens[$t - 2][1], array('function', 'class'))) || (isset($tokens[$t - 2][0]) && T_OBJECT_OPERATOR == $tokens[$t - 1][0])) {
361 361
 				$ignore_functions[] = $tokens[$t][1];
362 362
 			}
363 363
 			// Add this to our stack of unique references
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 		}
366 366
 	}
367 367
 
368
-	$functions = array_unique( $functions );
369
-	sort( $functions );
368
+	$functions = array_unique($functions);
369
+	sort($functions);
370 370
 
371 371
 	/**
372 372
 	 * Filters the list of functions and classes to be ignored from the documentation lookup.
@@ -375,13 +375,13 @@  discard block
 block discarded – undo
375 375
 	 *
376 376
 	 * @param array $ignore_functions Functions and classes to be ignored.
377 377
 	 */
378
-	$ignore_functions = apply_filters( 'documentation_ignore_functions', $ignore_functions );
378
+	$ignore_functions = apply_filters('documentation_ignore_functions', $ignore_functions);
379 379
 
380
-	$ignore_functions = array_unique( $ignore_functions );
380
+	$ignore_functions = array_unique($ignore_functions);
381 381
 
382 382
 	$out = array();
383
-	foreach ( $functions as $function ) {
384
-		if ( in_array( $function, $ignore_functions ) )
383
+	foreach ($functions as $function) {
384
+		if (in_array($function, $ignore_functions))
385 385
 			continue;
386 386
 		$out[] = $function;
387 387
 	}
@@ -396,28 +396,28 @@  discard block
 block discarded – undo
396 396
  */
397 397
 function set_screen_options() {
398 398
 
399
-	if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) {
400
-		check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
399
+	if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
400
+		check_admin_referer('screen-options-nonce', 'screenoptionnonce');
401 401
 
402
-		if ( !$user = wp_get_current_user() )
402
+		if ( ! $user = wp_get_current_user())
403 403
 			return;
404 404
 		$option = $_POST['wp_screen_options']['option'];
405 405
 		$value = $_POST['wp_screen_options']['value'];
406 406
 
407
-		if ( $option != sanitize_key( $option ) )
407
+		if ($option != sanitize_key($option))
408 408
 			return;
409 409
 
410 410
 		$map_option = $option;
411 411
 		$type = str_replace('edit_', '', $map_option);
412 412
 		$type = str_replace('_per_page', '', $type);
413
-		if ( in_array( $type, get_taxonomies() ) )
413
+		if (in_array($type, get_taxonomies()))
414 414
 			$map_option = 'edit_tags_per_page';
415
-		elseif ( in_array( $type, get_post_types() ) )
415
+		elseif (in_array($type, get_post_types()))
416 416
 			$map_option = 'edit_per_page';
417 417
 		else
418 418
 			$option = str_replace('-', '_', $option);
419 419
 
420
-		switch ( $map_option ) {
420
+		switch ($map_option) {
421 421
 			case 'edit_per_page':
422 422
 			case 'users_per_page':
423 423
 			case 'edit_comments_per_page':
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 			case 'themes_network_per_page':
433 433
 			case 'site_themes_network_per_page':
434 434
 				$value = (int) $value;
435
-				if ( $value < 1 || $value > 999 )
435
+				if ($value < 1 || $value > 999)
436 436
 					return;
437 437
 				break;
438 438
 			default:
@@ -453,21 +453,21 @@  discard block
 block discarded – undo
453 453
 				 * @param string   $option The option name.
454 454
 				 * @param int      $value  The number of rows to use.
455 455
 				 */
456
-				$value = apply_filters( 'set-screen-option', false, $option, $value );
456
+				$value = apply_filters('set-screen-option', false, $option, $value);
457 457
 
458
-				if ( false === $value )
458
+				if (false === $value)
459 459
 					return;
460 460
 				break;
461 461
 		}
462 462
 
463 463
 		update_user_meta($user->ID, $option, $value);
464 464
 
465
-		$url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() );
466
-		if ( isset( $_POST['mode'] ) ) {
467
-			$url = add_query_arg( array( 'mode' => $_POST['mode'] ), $url );
465
+		$url = remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer());
466
+		if (isset($_POST['mode'])) {
467
+			$url = add_query_arg(array('mode' => $_POST['mode']), $url);
468 468
 		}
469 469
 
470
-		wp_safe_redirect( $url );
470
+		wp_safe_redirect($url);
471 471
 		exit;
472 472
 	}
473 473
 }
@@ -481,18 +481,18 @@  discard block
 block discarded – undo
481 481
  * @param string $filename The file path to the configuration file
482 482
  */
483 483
 function iis7_rewrite_rule_exists($filename) {
484
-	if ( ! file_exists($filename) )
484
+	if ( ! file_exists($filename))
485 485
 		return false;
486
-	if ( ! class_exists( 'DOMDocument', false ) ) {
486
+	if ( ! class_exists('DOMDocument', false)) {
487 487
 		return false;
488 488
 	}
489 489
 
490 490
 	$doc = new DOMDocument();
491
-	if ( $doc->load($filename) === false )
491
+	if ($doc->load($filename) === false)
492 492
 		return false;
493 493
 	$xpath = new DOMXPath($doc);
494 494
 	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
495
-	if ( $rules->length == 0 )
495
+	if ($rules->length == 0)
496 496
 		return false;
497 497
 	else
498 498
 		return true;
@@ -508,21 +508,21 @@  discard block
 block discarded – undo
508 508
  */
509 509
 function iis7_delete_rewrite_rule($filename) {
510 510
 	// If configuration file does not exist then rules also do not exist so there is nothing to delete
511
-	if ( ! file_exists($filename) )
511
+	if ( ! file_exists($filename))
512 512
 		return true;
513 513
 
514
-	if ( ! class_exists( 'DOMDocument', false ) ) {
514
+	if ( ! class_exists('DOMDocument', false)) {
515 515
 		return false;
516 516
 	}
517 517
 
518 518
 	$doc = new DOMDocument();
519 519
 	$doc->preserveWhiteSpace = false;
520 520
 
521
-	if ( $doc -> load($filename) === false )
521
+	if ($doc -> load($filename) === false)
522 522
 		return false;
523 523
 	$xpath = new DOMXPath($doc);
524 524
 	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
525
-	if ( $rules->length > 0 ) {
525
+	if ($rules->length > 0) {
526 526
 		$child = $rules->item(0);
527 527
 		$parent = $child->parentNode;
528 528
 		$parent->removeChild($child);
@@ -542,13 +542,13 @@  discard block
 block discarded – undo
542 542
  * @return bool
543 543
  */
544 544
 function iis7_add_rewrite_rule($filename, $rewrite_rule) {
545
-	if ( ! class_exists( 'DOMDocument', false ) ) {
545
+	if ( ! class_exists('DOMDocument', false)) {
546 546
 		return false;
547 547
 	}
548 548
 
549 549
 	// If configuration file does not exist then we create one.
550
-	if ( ! file_exists($filename) ) {
551
-		$fp = fopen( $filename, 'w');
550
+	if ( ! file_exists($filename)) {
551
+		$fp = fopen($filename, 'w');
552 552
 		fwrite($fp, '<configuration/>');
553 553
 		fclose($fp);
554 554
 	}
@@ -556,25 +556,25 @@  discard block
 block discarded – undo
556 556
 	$doc = new DOMDocument();
557 557
 	$doc->preserveWhiteSpace = false;
558 558
 
559
-	if ( $doc->load($filename) === false )
559
+	if ($doc->load($filename) === false)
560 560
 		return false;
561 561
 
562 562
 	$xpath = new DOMXPath($doc);
563 563
 
564 564
 	// First check if the rule already exists as in that case there is no need to re-add it
565 565
 	$wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
566
-	if ( $wordpress_rules->length > 0 )
566
+	if ($wordpress_rules->length > 0)
567 567
 		return true;
568 568
 
569 569
 	// Check the XPath to the rewrite rule and create XML nodes if they do not exist
570 570
 	$xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules');
571
-	if ( $xmlnodes->length > 0 ) {
571
+	if ($xmlnodes->length > 0) {
572 572
 		$rules_node = $xmlnodes->item(0);
573 573
 	} else {
574 574
 		$rules_node = $doc->createElement('rules');
575 575
 
576 576
 		$xmlnodes = $xpath->query('/configuration/system.webServer/rewrite');
577
-		if ( $xmlnodes->length > 0 ) {
577
+		if ($xmlnodes->length > 0) {
578 578
 			$rewrite_node = $xmlnodes->item(0);
579 579
 			$rewrite_node->appendChild($rules_node);
580 580
 		} else {
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 			$rewrite_node->appendChild($rules_node);
583 583
 
584 584
 			$xmlnodes = $xpath->query('/configuration/system.webServer');
585
-			if ( $xmlnodes->length > 0 ) {
585
+			if ($xmlnodes->length > 0) {
586 586
 				$system_webServer_node = $xmlnodes->item(0);
587 587
 				$system_webServer_node->appendChild($rewrite_node);
588 588
 			} else {
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 				$system_webServer_node->appendChild($rewrite_node);
591 591
 
592 592
 				$xmlnodes = $xpath->query('/configuration');
593
-				if ( $xmlnodes->length > 0 ) {
593
+				if ($xmlnodes->length > 0) {
594 594
 					$config_node = $xmlnodes->item(0);
595 595
 					$config_node->appendChild($system_webServer_node);
596 596
 				} else {
@@ -638,42 +638,42 @@  discard block
 block discarded – undo
638 638
  *
639 639
  * @param int $user_id User ID.
640 640
  */
641
-function admin_color_scheme_picker( $user_id ) {
641
+function admin_color_scheme_picker($user_id) {
642 642
 	global $_wp_admin_css_colors;
643 643
 
644
-	ksort( $_wp_admin_css_colors );
644
+	ksort($_wp_admin_css_colors);
645 645
 
646
-	if ( isset( $_wp_admin_css_colors['fresh'] ) ) {
646
+	if (isset($_wp_admin_css_colors['fresh'])) {
647 647
 		// Set Default ('fresh') and Light should go first.
648
-		$_wp_admin_css_colors = array_filter( array_merge( array( 'fresh' => '', 'light' => '' ), $_wp_admin_css_colors ) );
648
+		$_wp_admin_css_colors = array_filter(array_merge(array('fresh' => '', 'light' => ''), $_wp_admin_css_colors));
649 649
 	}
650 650
 
651
-	$current_color = get_user_option( 'admin_color', $user_id );
651
+	$current_color = get_user_option('admin_color', $user_id);
652 652
 
653
-	if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) {
653
+	if (empty($current_color) || ! isset($_wp_admin_css_colors[$current_color])) {
654 654
 		$current_color = 'fresh';
655 655
 	}
656 656
 
657 657
 	?>
658 658
 	<fieldset id="color-picker" class="scheme-list">
659
-		<legend class="screen-reader-text"><span><?php _e( 'Admin Color Scheme' ); ?></span></legend>
659
+		<legend class="screen-reader-text"><span><?php _e('Admin Color Scheme'); ?></span></legend>
660 660
 		<?php
661
-		wp_nonce_field( 'save-color-scheme', 'color-nonce', false );
662
-		foreach ( $_wp_admin_css_colors as $color => $color_info ) :
661
+		wp_nonce_field('save-color-scheme', 'color-nonce', false);
662
+		foreach ($_wp_admin_css_colors as $color => $color_info) :
663 663
 
664 664
 			?>
665
-			<div class="color-option <?php echo ( $color == $current_color ) ? 'selected' : ''; ?>">
666
-				<input name="admin_color" id="admin_color_<?php echo esc_attr( $color ); ?>" type="radio" value="<?php echo esc_attr( $color ); ?>" class="tog" <?php checked( $color, $current_color ); ?> />
667
-				<input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" />
668
-				<input type="hidden" class="icon_colors" value="<?php echo esc_attr( wp_json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
669
-				<label for="admin_color_<?php echo esc_attr( $color ); ?>"><?php echo esc_html( $color_info->name ); ?></label>
665
+			<div class="color-option <?php echo ($color == $current_color) ? 'selected' : ''; ?>">
666
+				<input name="admin_color" id="admin_color_<?php echo esc_attr($color); ?>" type="radio" value="<?php echo esc_attr($color); ?>" class="tog" <?php checked($color, $current_color); ?> />
667
+				<input type="hidden" class="css_url" value="<?php echo esc_url($color_info->url); ?>" />
668
+				<input type="hidden" class="icon_colors" value="<?php echo esc_attr(wp_json_encode(array('icons' => $color_info->icon_colors))); ?>" />
669
+				<label for="admin_color_<?php echo esc_attr($color); ?>"><?php echo esc_html($color_info->name); ?></label>
670 670
 				<table class="color-palette">
671 671
 					<tr>
672 672
 					<?php
673 673
 
674
-					foreach ( $color_info->colors as $html_color ) {
674
+					foreach ($color_info->colors as $html_color) {
675 675
 						?>
676
-						<td style="background-color: <?php echo esc_attr( $html_color ); ?>">&nbsp;</td>
676
+						<td style="background-color: <?php echo esc_attr($html_color); ?>">&nbsp;</td>
677 677
 						<?php
678 678
 					}
679 679
 
@@ -697,30 +697,30 @@  discard block
 block discarded – undo
697 697
 function wp_color_scheme_settings() {
698 698
 	global $_wp_admin_css_colors;
699 699
 
700
-	$color_scheme = get_user_option( 'admin_color' );
700
+	$color_scheme = get_user_option('admin_color');
701 701
 
702 702
 	// It's possible to have a color scheme set that is no longer registered.
703
-	if ( empty( $_wp_admin_css_colors[ $color_scheme ] ) ) {
703
+	if (empty($_wp_admin_css_colors[$color_scheme])) {
704 704
 		$color_scheme = 'fresh';
705 705
 	}
706 706
 
707
-	if ( ! empty( $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) {
708
-		$icon_colors = $_wp_admin_css_colors[ $color_scheme ]->icon_colors;
709
-	} elseif ( ! empty( $_wp_admin_css_colors['fresh']->icon_colors ) ) {
707
+	if ( ! empty($_wp_admin_css_colors[$color_scheme]->icon_colors)) {
708
+		$icon_colors = $_wp_admin_css_colors[$color_scheme]->icon_colors;
709
+	} elseif ( ! empty($_wp_admin_css_colors['fresh']->icon_colors)) {
710 710
 		$icon_colors = $_wp_admin_css_colors['fresh']->icon_colors;
711 711
 	} else {
712 712
 		// Fall back to the default set of icon colors if the default scheme is missing.
713
-		$icon_colors = array( 'base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff' );
713
+		$icon_colors = array('base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff');
714 714
 	}
715 715
 
716
-	echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
716
+	echo '<script type="text/javascript">var _wpColorScheme = '.wp_json_encode(array('icons' => $icon_colors)).";</script>\n";
717 717
 }
718 718
 
719 719
 /**
720 720
  * @since 3.3.0
721 721
  */
722 722
 function _ipad_meta() {
723
-	if ( wp_is_mobile() ) {
723
+	if (wp_is_mobile()) {
724 724
 		?>
725 725
 		<meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1">
726 726
 		<?php
@@ -737,18 +737,18 @@  discard block
 block discarded – undo
737 737
  * @param string $screen_id The screen id.
738 738
  * @return array The Heartbeat response.
739 739
  */
740
-function wp_check_locked_posts( $response, $data, $screen_id ) {
740
+function wp_check_locked_posts($response, $data, $screen_id) {
741 741
 	$checked = array();
742 742
 
743
-	if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
744
-		foreach ( $data['wp-check-locked-posts'] as $key ) {
745
-			if ( ! $post_id = absint( substr( $key, 5 ) ) )
743
+	if (array_key_exists('wp-check-locked-posts', $data) && is_array($data['wp-check-locked-posts'])) {
744
+		foreach ($data['wp-check-locked-posts'] as $key) {
745
+			if ( ! $post_id = absint(substr($key, 5)))
746 746
 				continue;
747 747
 
748
-			if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) {
749
-				$send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) );
748
+			if (($user_id = wp_check_post_lock($post_id)) && ($user = get_userdata($user_id)) && current_user_can('edit_post', $post_id)) {
749
+				$send = array('text' => sprintf(__('%s is currently editing'), $user->display_name));
750 750
 
751
-				if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) )
751
+				if (($avatar = get_avatar($user->ID, 18)) && preg_match("|src='([^']+)'|", $avatar, $matches))
752 752
 					$send['avatar_src'] = $matches[1];
753 753
 
754 754
 				$checked[$key] = $send;
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 		}
757 757
 	}
758 758
 
759
-	if ( ! empty( $checked ) )
759
+	if ( ! empty($checked))
760 760
 		$response['wp-check-locked-posts'] = $checked;
761 761
 
762 762
 	return $response;
@@ -772,31 +772,31 @@  discard block
 block discarded – undo
772 772
  * @param string $screen_id The screen id.
773 773
  * @return array The Heartbeat response.
774 774
  */
775
-function wp_refresh_post_lock( $response, $data, $screen_id ) {
776
-	if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) {
775
+function wp_refresh_post_lock($response, $data, $screen_id) {
776
+	if (array_key_exists('wp-refresh-post-lock', $data)) {
777 777
 		$received = $data['wp-refresh-post-lock'];
778 778
 		$send = array();
779 779
 
780
-		if ( ! $post_id = absint( $received['post_id'] ) )
780
+		if ( ! $post_id = absint($received['post_id']))
781 781
 			return $response;
782 782
 
783
-		if ( ! current_user_can('edit_post', $post_id) )
783
+		if ( ! current_user_can('edit_post', $post_id))
784 784
 			return $response;
785 785
 
786
-		if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
786
+		if (($user_id = wp_check_post_lock($post_id)) && ($user = get_userdata($user_id))) {
787 787
 			$error = array(
788
-				'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name )
788
+				'text' => sprintf(__('%s has taken over and is currently editing.'), $user->display_name)
789 789
 			);
790 790
 
791
-			if ( $avatar = get_avatar( $user->ID, 64 ) ) {
792
-				if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) )
791
+			if ($avatar = get_avatar($user->ID, 64)) {
792
+				if (preg_match("|src='([^']+)'|", $avatar, $matches))
793 793
 					$error['avatar_src'] = $matches[1];
794 794
 			}
795 795
 
796 796
 			$send['lock_error'] = $error;
797 797
 		} else {
798
-			if ( $new_lock = wp_set_post_lock( $post_id ) )
799
-				$send['new_lock'] = implode( ':', $new_lock );
798
+			if ($new_lock = wp_set_post_lock($post_id))
799
+				$send['new_lock'] = implode(':', $new_lock);
800 800
 		}
801 801
 
802 802
 		$response['wp-refresh-post-lock'] = $send;
@@ -815,16 +815,16 @@  discard block
 block discarded – undo
815 815
  * @param string $screen_id The screen id.
816 816
  * @return array The Heartbeat response.
817 817
  */
818
-function wp_refresh_post_nonces( $response, $data, $screen_id ) {
819
-	if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
818
+function wp_refresh_post_nonces($response, $data, $screen_id) {
819
+	if (array_key_exists('wp-refresh-post-nonces', $data)) {
820 820
 		$received = $data['wp-refresh-post-nonces'];
821
-		$response['wp-refresh-post-nonces'] = array( 'check' => 1 );
821
+		$response['wp-refresh-post-nonces'] = array('check' => 1);
822 822
 
823
-		if ( ! $post_id = absint( $received['post_id'] ) ) {
823
+		if ( ! $post_id = absint($received['post_id'])) {
824 824
 			return $response;
825 825
 		}
826 826
 
827
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
827
+		if ( ! current_user_can('edit_post', $post_id)) {
828 828
 			return $response;
829 829
 		}
830 830
 
@@ -833,10 +833,10 @@  discard block
 block discarded – undo
833 833
 				'getpermalinknonce' => wp_create_nonce('getpermalink'),
834 834
 				'samplepermalinknonce' => wp_create_nonce('samplepermalink'),
835 835
 				'closedpostboxesnonce' => wp_create_nonce('closedpostboxes'),
836
-				'_ajax_linking_nonce' => wp_create_nonce( 'internal-linking' ),
837
-				'_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ),
836
+				'_ajax_linking_nonce' => wp_create_nonce('internal-linking'),
837
+				'_wpnonce' => wp_create_nonce('update-post_'.$post_id),
838 838
 			),
839
-			'heartbeatNonce' => wp_create_nonce( 'heartbeat-nonce' ),
839
+			'heartbeatNonce' => wp_create_nonce('heartbeat-nonce'),
840 840
 		);
841 841
 	}
842 842
 
@@ -853,10 +853,10 @@  discard block
 block discarded – undo
853 853
  * @param array $settings An array of Heartbeat settings.
854 854
  * @return array Filtered Heartbeat settings.
855 855
  */
856
-function wp_heartbeat_set_suspension( $settings ) {
856
+function wp_heartbeat_set_suspension($settings) {
857 857
 	global $pagenow;
858 858
 
859
-	if ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) {
859
+	if ('post.php' === $pagenow || 'post-new.php' === $pagenow) {
860 860
 		$settings['suspension'] = 'disable';
861 861
 	}
862 862
 
@@ -872,19 +872,19 @@  discard block
 block discarded – undo
872 872
  * @param array $data     The $_POST data sent.
873 873
  * @return array The Heartbeat response.
874 874
  */
875
-function heartbeat_autosave( $response, $data ) {
876
-	if ( ! empty( $data['wp_autosave'] ) ) {
877
-		$saved = wp_autosave( $data['wp_autosave'] );
878
-
879
-		if ( is_wp_error( $saved ) ) {
880
-			$response['wp_autosave'] = array( 'success' => false, 'message' => $saved->get_error_message() );
881
-		} elseif ( empty( $saved ) ) {
882
-			$response['wp_autosave'] = array( 'success' => false, 'message' => __( 'Error while saving.' ) );
875
+function heartbeat_autosave($response, $data) {
876
+	if ( ! empty($data['wp_autosave'])) {
877
+		$saved = wp_autosave($data['wp_autosave']);
878
+
879
+		if (is_wp_error($saved)) {
880
+			$response['wp_autosave'] = array('success' => false, 'message' => $saved->get_error_message());
881
+		} elseif (empty($saved)) {
882
+			$response['wp_autosave'] = array('success' => false, 'message' => __('Error while saving.'));
883 883
 		} else {
884 884
 			/* translators: draft saved date format, see https://secure.php.net/date */
885
-			$draft_saved_date_format = __( 'g:i:s a' );
885
+			$draft_saved_date_format = __('g:i:s a');
886 886
 			/* translators: %s: date and time */
887
-			$response['wp_autosave'] = array( 'success' => true, 'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ) );
887
+			$response['wp_autosave'] = array('success' => true, 'message' => sprintf(__('Draft saved at %s.'), date_i18n($draft_saved_date_format)));
888 888
 		}
889 889
 	}
890 890
 
@@ -902,15 +902,15 @@  discard block
 block discarded – undo
902 902
 function wp_admin_canonical_url() {
903 903
 	$removable_query_args = wp_removable_query_args();
904 904
 
905
-	if ( empty( $removable_query_args ) ) {
905
+	if (empty($removable_query_args)) {
906 906
 		return;
907 907
 	}
908 908
 
909 909
 	// Ensure we're using an absolute URL.
910
-	$current_url  = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
911
-	$filtered_url = remove_query_arg( $removable_query_args, $current_url );
910
+	$current_url  = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
911
+	$filtered_url = remove_query_arg($removable_query_args, $current_url);
912 912
 	?>
913
-	<link id="wp-admin-canonical" rel="canonical" href="<?php echo esc_url( $filtered_url ); ?>" />
913
+	<link id="wp-admin-canonical" rel="canonical" href="<?php echo esc_url($filtered_url); ?>" />
914 914
 	<script>
915 915
 		if ( window.history.replaceState ) {
916 916
 			window.history.replaceState( null, null, document.getElementById( 'wp-admin-canonical' ).href + window.location.hash );
Please login to merge, or discard this patch.
Braces   +99 added lines, -69 removed lines patch added patch discarded remove patch
@@ -75,12 +75,15 @@  discard block
 block discarded – undo
75 75
 	{
76 76
 		$state = false;
77 77
 		foreach ( $markerdata as $markerline ) {
78
-			if (strpos($markerline, '# END ' . $marker) !== false)
79
-				$state = false;
80
-			if ( $state )
81
-				$result[] = $markerline;
82
-			if (strpos($markerline, '# BEGIN ' . $marker) !== false)
83
-				$state = true;
78
+			if (strpos($markerline, '# END ' . $marker) !== false) {
79
+							$state = false;
80
+			}
81
+			if ( $state ) {
82
+							$result[] = $markerline;
83
+			}
84
+			if (strpos($markerline, '# BEGIN ' . $marker) !== false) {
85
+							$state = true;
86
+			}
84 87
 		}
85 88
 	}
86 89
 
@@ -194,8 +197,9 @@  discard block
 block discarded – undo
194 197
  * @global WP_Rewrite $wp_rewrite
195 198
  */
196 199
 function save_mod_rewrite_rules() {
197
-	if ( is_multisite() )
198
-		return;
200
+	if ( is_multisite() ) {
201
+			return;
202
+	}
199 203
 
200 204
 	global $wp_rewrite;
201 205
 
@@ -227,8 +231,9 @@  discard block
 block discarded – undo
227 231
  * @return bool True if web.config was updated successfully
228 232
  */
229 233
 function iis7_save_url_rewrite_rules(){
230
-	if ( is_multisite() )
231
-		return;
234
+	if ( is_multisite() ) {
235
+			return;
236
+	}
232 237
 
233 238
 	global $wp_rewrite;
234 239
 
@@ -261,8 +266,9 @@  discard block
 block discarded – undo
261 266
 		$oldfiles[] = $file;
262 267
 		$oldfiles = array_reverse( $oldfiles );
263 268
 		$oldfiles = array_unique( $oldfiles );
264
-		if ( 5 < count( $oldfiles ))
265
-			array_pop( $oldfiles );
269
+		if ( 5 < count( $oldfiles )) {
270
+					array_pop( $oldfiles );
271
+		}
266 272
 	} else {
267 273
 		$oldfiles[] = $file;
268 274
 	}
@@ -278,8 +284,9 @@  discard block
 block discarded – undo
278 284
  * @param string $value
279 285
  */
280 286
 function update_home_siteurl( $old_value, $value ) {
281
-	if ( wp_installing() )
282
-		return;
287
+	if ( wp_installing() ) {
288
+			return;
289
+	}
283 290
 
284 291
 	if ( is_multisite() && ms_is_switched() ) {
285 292
 		delete_option( 'rewrite_rules' );
@@ -323,10 +330,11 @@  discard block
 block discarded – undo
323 330
  */
324 331
 function show_message($message) {
325 332
 	if ( is_wp_error($message) ){
326
-		if ( $message->get_error_data() && is_string( $message->get_error_data() ) )
327
-			$message = $message->get_error_message() . ': ' . $message->get_error_data();
328
-		else
329
-			$message = $message->get_error_message();
333
+		if ( $message->get_error_data() && is_string( $message->get_error_data() ) ) {
334
+					$message = $message->get_error_message() . ': ' . $message->get_error_data();
335
+		} else {
336
+					$message = $message->get_error_message();
337
+		}
330 338
 	}
331 339
 	echo "<p>$message</p>\n";
332 340
 	wp_ob_end_flush_all();
@@ -340,11 +348,13 @@  discard block
 block discarded – undo
340 348
  * @return array
341 349
  */
342 350
 function wp_doc_link_parse( $content ) {
343
-	if ( !is_string( $content ) || empty( $content ) )
344
-		return array();
351
+	if ( !is_string( $content ) || empty( $content ) ) {
352
+			return array();
353
+	}
345 354
 
346
-	if ( !function_exists('token_get_all') )
347
-		return array();
355
+	if ( !function_exists('token_get_all') ) {
356
+			return array();
357
+	}
348 358
 
349 359
 	$tokens = token_get_all( $content );
350 360
 	$count = count( $tokens );
@@ -381,8 +391,9 @@  discard block
 block discarded – undo
381 391
 
382 392
 	$out = array();
383 393
 	foreach ( $functions as $function ) {
384
-		if ( in_array( $function, $ignore_functions ) )
385
-			continue;
394
+		if ( in_array( $function, $ignore_functions ) ) {
395
+					continue;
396
+		}
386 397
 		$out[] = $function;
387 398
 	}
388 399
 
@@ -399,23 +410,26 @@  discard block
 block discarded – undo
399 410
 	if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) {
400 411
 		check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
401 412
 
402
-		if ( !$user = wp_get_current_user() )
403
-			return;
413
+		if ( !$user = wp_get_current_user() ) {
414
+					return;
415
+		}
404 416
 		$option = $_POST['wp_screen_options']['option'];
405 417
 		$value = $_POST['wp_screen_options']['value'];
406 418
 
407
-		if ( $option != sanitize_key( $option ) )
408
-			return;
419
+		if ( $option != sanitize_key( $option ) ) {
420
+					return;
421
+		}
409 422
 
410 423
 		$map_option = $option;
411 424
 		$type = str_replace('edit_', '', $map_option);
412 425
 		$type = str_replace('_per_page', '', $type);
413
-		if ( in_array( $type, get_taxonomies() ) )
414
-			$map_option = 'edit_tags_per_page';
415
-		elseif ( in_array( $type, get_post_types() ) )
416
-			$map_option = 'edit_per_page';
417
-		else
418
-			$option = str_replace('-', '_', $option);
426
+		if ( in_array( $type, get_taxonomies() ) ) {
427
+					$map_option = 'edit_tags_per_page';
428
+		} elseif ( in_array( $type, get_post_types() ) ) {
429
+					$map_option = 'edit_per_page';
430
+		} else {
431
+					$option = str_replace('-', '_', $option);
432
+		}
419 433
 
420 434
 		switch ( $map_option ) {
421 435
 			case 'edit_per_page':
@@ -432,8 +446,9 @@  discard block
 block discarded – undo
432 446
 			case 'themes_network_per_page':
433 447
 			case 'site_themes_network_per_page':
434 448
 				$value = (int) $value;
435
-				if ( $value < 1 || $value > 999 )
436
-					return;
449
+				if ( $value < 1 || $value > 999 ) {
450
+									return;
451
+				}
437 452
 				break;
438 453
 			default:
439 454
 
@@ -455,8 +470,9 @@  discard block
 block discarded – undo
455 470
 				 */
456 471
 				$value = apply_filters( 'set-screen-option', false, $option, $value );
457 472
 
458
-				if ( false === $value )
459
-					return;
473
+				if ( false === $value ) {
474
+									return;
475
+				}
460 476
 				break;
461 477
 		}
462 478
 
@@ -481,22 +497,25 @@  discard block
 block discarded – undo
481 497
  * @param string $filename The file path to the configuration file
482 498
  */
483 499
 function iis7_rewrite_rule_exists($filename) {
484
-	if ( ! file_exists($filename) )
485
-		return false;
500
+	if ( ! file_exists($filename) ) {
501
+			return false;
502
+	}
486 503
 	if ( ! class_exists( 'DOMDocument', false ) ) {
487 504
 		return false;
488 505
 	}
489 506
 
490 507
 	$doc = new DOMDocument();
491
-	if ( $doc->load($filename) === false )
492
-		return false;
508
+	if ( $doc->load($filename) === false ) {
509
+			return false;
510
+	}
493 511
 	$xpath = new DOMXPath($doc);
494 512
 	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
495
-	if ( $rules->length == 0 )
496
-		return false;
497
-	else
498
-		return true;
499
-}
513
+	if ( $rules->length == 0 ) {
514
+			return false;
515
+	} else {
516
+			return true;
517
+	}
518
+	}
500 519
 
501 520
 /**
502 521
  * Delete WordPress rewrite rule from web.config file if it exists there
@@ -508,8 +527,9 @@  discard block
 block discarded – undo
508 527
  */
509 528
 function iis7_delete_rewrite_rule($filename) {
510 529
 	// If configuration file does not exist then rules also do not exist so there is nothing to delete
511
-	if ( ! file_exists($filename) )
512
-		return true;
530
+	if ( ! file_exists($filename) ) {
531
+			return true;
532
+	}
513 533
 
514 534
 	if ( ! class_exists( 'DOMDocument', false ) ) {
515 535
 		return false;
@@ -518,8 +538,9 @@  discard block
 block discarded – undo
518 538
 	$doc = new DOMDocument();
519 539
 	$doc->preserveWhiteSpace = false;
520 540
 
521
-	if ( $doc -> load($filename) === false )
522
-		return false;
541
+	if ( $doc -> load($filename) === false ) {
542
+			return false;
543
+	}
523 544
 	$xpath = new DOMXPath($doc);
524 545
 	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
525 546
 	if ( $rules->length > 0 ) {
@@ -556,15 +577,17 @@  discard block
 block discarded – undo
556 577
 	$doc = new DOMDocument();
557 578
 	$doc->preserveWhiteSpace = false;
558 579
 
559
-	if ( $doc->load($filename) === false )
560
-		return false;
580
+	if ( $doc->load($filename) === false ) {
581
+			return false;
582
+	}
561 583
 
562 584
 	$xpath = new DOMXPath($doc);
563 585
 
564 586
 	// First check if the rule already exists as in that case there is no need to re-add it
565 587
 	$wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
566
-	if ( $wordpress_rules->length > 0 )
567
-		return true;
588
+	if ( $wordpress_rules->length > 0 ) {
589
+			return true;
590
+	}
568 591
 
569 592
 	// Check the XPath to the rewrite rule and create XML nodes if they do not exist
570 593
 	$xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules');
@@ -742,22 +765,25 @@  discard block
 block discarded – undo
742 765
 
743 766
 	if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
744 767
 		foreach ( $data['wp-check-locked-posts'] as $key ) {
745
-			if ( ! $post_id = absint( substr( $key, 5 ) ) )
746
-				continue;
768
+			if ( ! $post_id = absint( substr( $key, 5 ) ) ) {
769
+							continue;
770
+			}
747 771
 
748 772
 			if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) {
749 773
 				$send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) );
750 774
 
751
-				if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) )
752
-					$send['avatar_src'] = $matches[1];
775
+				if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) {
776
+									$send['avatar_src'] = $matches[1];
777
+				}
753 778
 
754 779
 				$checked[$key] = $send;
755 780
 			}
756 781
 		}
757 782
 	}
758 783
 
759
-	if ( ! empty( $checked ) )
760
-		$response['wp-check-locked-posts'] = $checked;
784
+	if ( ! empty( $checked ) ) {
785
+			$response['wp-check-locked-posts'] = $checked;
786
+	}
761 787
 
762 788
 	return $response;
763 789
 }
@@ -777,11 +803,13 @@  discard block
 block discarded – undo
777 803
 		$received = $data['wp-refresh-post-lock'];
778 804
 		$send = array();
779 805
 
780
-		if ( ! $post_id = absint( $received['post_id'] ) )
781
-			return $response;
806
+		if ( ! $post_id = absint( $received['post_id'] ) ) {
807
+					return $response;
808
+		}
782 809
 
783
-		if ( ! current_user_can('edit_post', $post_id) )
784
-			return $response;
810
+		if ( ! current_user_can('edit_post', $post_id) ) {
811
+					return $response;
812
+		}
785 813
 
786 814
 		if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
787 815
 			$error = array(
@@ -789,14 +817,16 @@  discard block
 block discarded – undo
789 817
 			);
790 818
 
791 819
 			if ( $avatar = get_avatar( $user->ID, 64 ) ) {
792
-				if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) )
793
-					$error['avatar_src'] = $matches[1];
820
+				if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) {
821
+									$error['avatar_src'] = $matches[1];
822
+				}
794 823
 			}
795 824
 
796 825
 			$send['lock_error'] = $error;
797 826
 		} else {
798
-			if ( $new_lock = wp_set_post_lock( $post_id ) )
799
-				$send['new_lock'] = implode( ':', $new_lock );
827
+			if ( $new_lock = wp_set_post_lock( $post_id ) ) {
828
+							$send['new_lock'] = implode( ':', $new_lock );
829
+			}
800 830
 		}
801 831
 
802 832
 		$response['wp-refresh-post-lock'] = $send;
Please login to merge, or discard this patch.