Completed
Push — master ( c0c536...fdb3a7 )
by Stephen
20:33
created
src/wp-admin/includes/class-ftp-sockets.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -94,6 +94,9 @@
 block discarded – undo
94 94
 		return $result;
95 95
 	}
96 96
 
97
+	/**
98
+	 * @param string $cmd
99
+	 */
97 100
 	function _exec($cmd, $fnction="_exec") {
98 101
 		if(!$this->_ready) {
99 102
 			$this->PushError($fnction,'Connect first');
Please login to merge, or discard this patch.
Braces   +47 added lines, -17 removed lines patch added patch discarded remove patch
@@ -59,7 +59,9 @@  discard block
 block discarded – undo
59 59
 			$this->PushError('_connect','socket create failed',socket_strerror(socket_last_error($sock)));
60 60
 			return FALSE;
61 61
 		}
62
-		if(!$this->_settimeout($sock)) return FALSE;
62
+		if(!$this->_settimeout($sock)) {
63
+			return FALSE;
64
+		}
63 65
 		$this->SendMSG("Connecting to \"".$host.":".$port."\"");
64 66
 		if (!($res = @socket_connect($sock, $host, $port))) {
65 67
 			$this->PushError('_connect','socket connect failed',socket_strerror(socket_last_error($sock)));
@@ -89,7 +91,9 @@  discard block
 block discarded – undo
89 91
 				$go = !preg_match("/^([0-9]{3})(-.+\\1)? [^".CRLF."]+".CRLF."$/Us", $this->_message, $regs);
90 92
 			}
91 93
 		} while($go);
92
-		if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
94
+		if($this->LocalEcho) {
95
+			echo "GET < ".rtrim($this->_message, CRLF).CRLF;
96
+		}
93 97
 		$this->_code=(int)$regs[1];
94 98
 		return $result;
95 99
 	}
@@ -99,19 +103,25 @@  discard block
 block discarded – undo
99 103
 			$this->PushError($fnction,'Connect first');
100 104
 			return FALSE;
101 105
 		}
102
-		if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
106
+		if($this->LocalEcho) {
107
+			echo "PUT > ",$cmd,CRLF;
108
+		}
103 109
 		$status=@socket_write($this->_ftp_control_sock, $cmd.CRLF);
104 110
 		if($status===false) {
105 111
 			$this->PushError($fnction,'socket write failed', socket_strerror(socket_last_error($this->stream)));
106 112
 			return FALSE;
107 113
 		}
108 114
 		$this->_lastaction=time();
109
-		if(!$this->_readmsg($fnction)) return FALSE;
115
+		if(!$this->_readmsg($fnction)) {
116
+			return FALSE;
117
+		}
110 118
 		return TRUE;
111 119
 	}
112 120
 
113 121
 	function _data_prepare($mode=FTP_ASCII) {
114
-		if(!$this->_settype($mode)) return FALSE;
122
+		if(!$this->_settype($mode)) {
123
+			return FALSE;
124
+		}
115 125
 		$this->SendMSG("Creating data socket");
116 126
 		$this->_ftp_data_sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
117 127
 		if ($this->_ftp_data_sock < 0) {
@@ -139,8 +149,9 @@  discard block
 block discarded – undo
139 149
 				$this->PushError("_data_prepare","socket_connect", socket_strerror(socket_last_error($this->_ftp_data_sock)));
140 150
 				$this->_data_close();
141 151
 				return FALSE;
152
+			} else {
153
+				$this->_ftp_temp_sock=$this->_ftp_data_sock;
142 154
 			}
143
-			else $this->_ftp_temp_sock=$this->_ftp_data_sock;
144 155
 		} else {
145 156
 			if(!@socket_getsockname($this->_ftp_control_sock, $addr, $port)) {
146 157
 				$this->PushError("_data_prepare","can't get control socket information", socket_strerror(socket_last_error($this->_ftp_control_sock)));
@@ -176,8 +187,11 @@  discard block
 block discarded – undo
176 187
 
177 188
 	function _data_read($mode=FTP_ASCII, $fp=NULL) {
178 189
 		$NewLine=$this->_eol_code[$this->OS_local];
179
-		if(is_resource($fp)) $out=0;
180
-		else $out="";
190
+		if(is_resource($fp)) {
191
+			$out=0;
192
+		} else {
193
+			$out="";
194
+		}
181 195
 		if(!$this->_passive) {
182 196
 			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
183 197
 			$this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock);
@@ -189,18 +203,28 @@  discard block
 block discarded – undo
189 203
 		}
190 204
 
191 205
 		while(($block=@socket_read($this->_ftp_temp_sock, $this->_ftp_buff_size, PHP_BINARY_READ))!==false) {
192
-			if($block==="") break;
193
-			if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
194
-			if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block));
195
-			else $out.=$block;
206
+			if($block==="") {
207
+				break;
208
+			}
209
+			if($mode!=FTP_BINARY) {
210
+				$block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
211
+			}
212
+			if(is_resource($fp)) {
213
+				$out+=fwrite($fp, $block, strlen($block));
214
+			} else {
215
+				$out.=$block;
216
+			}
196 217
 		}
197 218
 		return $out;
198 219
 	}
199 220
 
200 221
 	function _data_write($mode=FTP_ASCII, $fp=NULL) {
201 222
 		$NewLine=$this->_eol_code[$this->OS_local];
202
-		if(is_resource($fp)) $out=0;
203
-		else $out="";
223
+		if(is_resource($fp)) {
224
+			$out=0;
225
+		} else {
226
+			$out="";
227
+		}
204 228
 		if(!$this->_passive) {
205 229
 			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
206 230
 			$this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock);
@@ -213,14 +237,20 @@  discard block
 block discarded – undo
213 237
 		if(is_resource($fp)) {
214 238
 			while(!feof($fp)) {
215 239
 				$block=fread($fp, $this->_ftp_buff_size);
216
-				if(!$this->_data_write_block($mode, $block)) return false;
240
+				if(!$this->_data_write_block($mode, $block)) {
241
+					return false;
242
+				}
217 243
 			}
218
-		} elseif(!$this->_data_write_block($mode, $fp)) return false;
244
+		} elseif(!$this->_data_write_block($mode, $fp)) {
245
+			return false;
246
+		}
219 247
 		return true;
220 248
 	}
221 249
 
222 250
 	function _data_write_block($mode, $block) {
223
-		if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
251
+		if($mode!=FTP_BINARY) {
252
+			$block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
253
+		}
224 254
 		do {
225 255
 			if(($t=@socket_write($this->_ftp_temp_sock, $block))===FALSE) {
226 256
 				$this->PushError("_data_write","socket_write", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
Please login to merge, or discard this patch.
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
  */
28 28
 class ftp extends ftp_base {
29 29
 
30
-	function __construct($verb=FALSE, $le=FALSE) {
30
+	function __construct($verb = FALSE, $le = FALSE) {
31 31
 		parent::__construct(true, $verb, $le);
32 32
 	}
33 33
 
34
-	function ftp($verb=FALSE, $le=FALSE) {
34
+	function ftp($verb = FALSE, $le = FALSE) {
35 35
 		$this->__construct($verb, $le);
36 36
 	}
37 37
 
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
 // <!-- --------------------------------------------------------------------------------------- -->
41 41
 
42 42
 	function _settimeout($sock) {
43
-		if(!@socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
44
-			$this->PushError('_connect','socket set receive timeout',socket_strerror(socket_last_error($sock)));
43
+		if ( ! @socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
44
+			$this->PushError('_connect', 'socket set receive timeout', socket_strerror(socket_last_error($sock)));
45 45
 			@socket_close($sock);
46 46
 			return FALSE;
47 47
 		}
48
-		if(!@socket_set_option($sock, SOL_SOCKET , SO_SNDTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
49
-			$this->PushError('_connect','socket set send timeout',socket_strerror(socket_last_error($sock)));
48
+		if ( ! @socket_set_option($sock, SOL_SOCKET, SO_SNDTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
49
+			$this->PushError('_connect', 'socket set send timeout', socket_strerror(socket_last_error($sock)));
50 50
 			@socket_close($sock);
51 51
 			return FALSE;
52 52
 		}
@@ -55,118 +55,118 @@  discard block
 block discarded – undo
55 55
 
56 56
 	function _connect($host, $port) {
57 57
 		$this->SendMSG("Creating socket");
58
-		if(!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
59
-			$this->PushError('_connect','socket create failed',socket_strerror(socket_last_error($sock)));
58
+		if ( ! ($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
59
+			$this->PushError('_connect', 'socket create failed', socket_strerror(socket_last_error($sock)));
60 60
 			return FALSE;
61 61
 		}
62
-		if(!$this->_settimeout($sock)) return FALSE;
62
+		if ( ! $this->_settimeout($sock)) return FALSE;
63 63
 		$this->SendMSG("Connecting to \"".$host.":".$port."\"");
64
-		if (!($res = @socket_connect($sock, $host, $port))) {
65
-			$this->PushError('_connect','socket connect failed',socket_strerror(socket_last_error($sock)));
64
+		if ( ! ($res = @socket_connect($sock, $host, $port))) {
65
+			$this->PushError('_connect', 'socket connect failed', socket_strerror(socket_last_error($sock)));
66 66
 			@socket_close($sock);
67 67
 			return FALSE;
68 68
 		}
69
-		$this->_connected=true;
69
+		$this->_connected = true;
70 70
 		return $sock;
71 71
 	}
72 72
 
73
-	function _readmsg($fnction="_readmsg"){
74
-		if(!$this->_connected) {
75
-			$this->PushError($fnction,'Connect first');
73
+	function _readmsg($fnction = "_readmsg") {
74
+		if ( ! $this->_connected) {
75
+			$this->PushError($fnction, 'Connect first');
76 76
 			return FALSE;
77 77
 		}
78
-		$result=true;
79
-		$this->_message="";
80
-		$this->_code=0;
81
-		$go=true;
78
+		$result = true;
79
+		$this->_message = "";
80
+		$this->_code = 0;
81
+		$go = true;
82 82
 		do {
83
-			$tmp=@socket_read($this->_ftp_control_sock, 4096, PHP_BINARY_READ);
84
-			if($tmp===false) {
85
-				$go=$result=false;
86
-				$this->PushError($fnction,'Read failed', socket_strerror(socket_last_error($this->_ftp_control_sock)));
83
+			$tmp = @socket_read($this->_ftp_control_sock, 4096, PHP_BINARY_READ);
84
+			if ($tmp === false) {
85
+				$go = $result = false;
86
+				$this->PushError($fnction, 'Read failed', socket_strerror(socket_last_error($this->_ftp_control_sock)));
87 87
 			} else {
88
-				$this->_message.=$tmp;
89
-				$go = !preg_match("/^([0-9]{3})(-.+\\1)? [^".CRLF."]+".CRLF."$/Us", $this->_message, $regs);
88
+				$this->_message .= $tmp;
89
+				$go = ! preg_match("/^([0-9]{3})(-.+\\1)? [^".CRLF."]+".CRLF."$/Us", $this->_message, $regs);
90 90
 			}
91
-		} while($go);
92
-		if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
93
-		$this->_code=(int)$regs[1];
91
+		} while ($go);
92
+		if ($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
93
+		$this->_code = (int) $regs[1];
94 94
 		return $result;
95 95
 	}
96 96
 
97
-	function _exec($cmd, $fnction="_exec") {
98
-		if(!$this->_ready) {
99
-			$this->PushError($fnction,'Connect first');
97
+	function _exec($cmd, $fnction = "_exec") {
98
+		if ( ! $this->_ready) {
99
+			$this->PushError($fnction, 'Connect first');
100 100
 			return FALSE;
101 101
 		}
102
-		if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
103
-		$status=@socket_write($this->_ftp_control_sock, $cmd.CRLF);
104
-		if($status===false) {
105
-			$this->PushError($fnction,'socket write failed', socket_strerror(socket_last_error($this->stream)));
102
+		if ($this->LocalEcho) echo "PUT > ", $cmd, CRLF;
103
+		$status = @socket_write($this->_ftp_control_sock, $cmd.CRLF);
104
+		if ($status === false) {
105
+			$this->PushError($fnction, 'socket write failed', socket_strerror(socket_last_error($this->stream)));
106 106
 			return FALSE;
107 107
 		}
108
-		$this->_lastaction=time();
109
-		if(!$this->_readmsg($fnction)) return FALSE;
108
+		$this->_lastaction = time();
109
+		if ( ! $this->_readmsg($fnction)) return FALSE;
110 110
 		return TRUE;
111 111
 	}
112 112
 
113
-	function _data_prepare($mode=FTP_ASCII) {
114
-		if(!$this->_settype($mode)) return FALSE;
113
+	function _data_prepare($mode = FTP_ASCII) {
114
+		if ( ! $this->_settype($mode)) return FALSE;
115 115
 		$this->SendMSG("Creating data socket");
116 116
 		$this->_ftp_data_sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
117 117
 		if ($this->_ftp_data_sock < 0) {
118
-			$this->PushError('_data_prepare','socket create failed',socket_strerror(socket_last_error($this->_ftp_data_sock)));
118
+			$this->PushError('_data_prepare', 'socket create failed', socket_strerror(socket_last_error($this->_ftp_data_sock)));
119 119
 			return FALSE;
120 120
 		}
121
-		if(!$this->_settimeout($this->_ftp_data_sock)) {
121
+		if ( ! $this->_settimeout($this->_ftp_data_sock)) {
122 122
 			$this->_data_close();
123 123
 			return FALSE;
124 124
 		}
125
-		if($this->_passive) {
126
-			if(!$this->_exec("PASV", "pasv")) {
125
+		if ($this->_passive) {
126
+			if ( ! $this->_exec("PASV", "pasv")) {
127 127
 				$this->_data_close();
128 128
 				return FALSE;
129 129
 			}
130
-			if(!$this->_checkCode()) {
130
+			if ( ! $this->_checkCode()) {
131 131
 				$this->_data_close();
132 132
 				return FALSE;
133 133
 			}
134 134
 			$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));
135
-			$this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3];
136
-			$this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]);
135
+			$this->_datahost = $ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3];
136
+			$this->_dataport = (((int) $ip_port[4]) << 8) + ((int) $ip_port[5]);
137 137
 			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
138
-			if(!@socket_connect($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) {
139
-				$this->PushError("_data_prepare","socket_connect", socket_strerror(socket_last_error($this->_ftp_data_sock)));
138
+			if ( ! @socket_connect($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) {
139
+				$this->PushError("_data_prepare", "socket_connect", socket_strerror(socket_last_error($this->_ftp_data_sock)));
140 140
 				$this->_data_close();
141 141
 				return FALSE;
142 142
 			}
143
-			else $this->_ftp_temp_sock=$this->_ftp_data_sock;
143
+			else $this->_ftp_temp_sock = $this->_ftp_data_sock;
144 144
 		} else {
145
-			if(!@socket_getsockname($this->_ftp_control_sock, $addr, $port)) {
146
-				$this->PushError("_data_prepare","can't get control socket information", socket_strerror(socket_last_error($this->_ftp_control_sock)));
145
+			if ( ! @socket_getsockname($this->_ftp_control_sock, $addr, $port)) {
146
+				$this->PushError("_data_prepare", "can't get control socket information", socket_strerror(socket_last_error($this->_ftp_control_sock)));
147 147
 				$this->_data_close();
148 148
 				return FALSE;
149 149
 			}
150
-			if(!@socket_bind($this->_ftp_data_sock,$addr)){
151
-				$this->PushError("_data_prepare","can't bind data socket", socket_strerror(socket_last_error($this->_ftp_data_sock)));
150
+			if ( ! @socket_bind($this->_ftp_data_sock, $addr)) {
151
+				$this->PushError("_data_prepare", "can't bind data socket", socket_strerror(socket_last_error($this->_ftp_data_sock)));
152 152
 				$this->_data_close();
153 153
 				return FALSE;
154 154
 			}
155
-			if(!@socket_listen($this->_ftp_data_sock)) {
156
-				$this->PushError("_data_prepare","can't listen data socket", socket_strerror(socket_last_error($this->_ftp_data_sock)));
155
+			if ( ! @socket_listen($this->_ftp_data_sock)) {
156
+				$this->PushError("_data_prepare", "can't listen data socket", socket_strerror(socket_last_error($this->_ftp_data_sock)));
157 157
 				$this->_data_close();
158 158
 				return FALSE;
159 159
 			}
160
-			if(!@socket_getsockname($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) {
161
-				$this->PushError("_data_prepare","can't get data socket information", socket_strerror(socket_last_error($this->_ftp_data_sock)));
160
+			if ( ! @socket_getsockname($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) {
161
+				$this->PushError("_data_prepare", "can't get data socket information", socket_strerror(socket_last_error($this->_ftp_data_sock)));
162 162
 				$this->_data_close();
163 163
 				return FALSE;
164 164
 			}
165
-			if(!$this->_exec('PORT '.str_replace('.',',',$this->_datahost.'.'.($this->_dataport>>8).'.'.($this->_dataport&0x00FF)), "_port")) {
165
+			if ( ! $this->_exec('PORT '.str_replace('.', ',', $this->_datahost.'.'.($this->_dataport >> 8).'.'.($this->_dataport & 0x00FF)), "_port")) {
166 166
 				$this->_data_close();
167 167
 				return FALSE;
168 168
 			}
169
-			if(!$this->_checkCode()) {
169
+			if ( ! $this->_checkCode()) {
170 170
 				$this->_data_close();
171 171
 				return FALSE;
172 172
 			}
@@ -174,61 +174,61 @@  discard block
 block discarded – undo
174 174
 		return TRUE;
175 175
 	}
176 176
 
177
-	function _data_read($mode=FTP_ASCII, $fp=NULL) {
178
-		$NewLine=$this->_eol_code[$this->OS_local];
179
-		if(is_resource($fp)) $out=0;
180
-		else $out="";
181
-		if(!$this->_passive) {
177
+	function _data_read($mode = FTP_ASCII, $fp = NULL) {
178
+		$NewLine = $this->_eol_code[$this->OS_local];
179
+		if (is_resource($fp)) $out = 0;
180
+		else $out = "";
181
+		if ( ! $this->_passive) {
182 182
 			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
183
-			$this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock);
184
-			if($this->_ftp_temp_sock===FALSE) {
185
-				$this->PushError("_data_read","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
183
+			$this->_ftp_temp_sock = socket_accept($this->_ftp_data_sock);
184
+			if ($this->_ftp_temp_sock === FALSE) {
185
+				$this->PushError("_data_read", "socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
186 186
 				$this->_data_close();
187 187
 				return FALSE;
188 188
 			}
189 189
 		}
190 190
 
191
-		while(($block=@socket_read($this->_ftp_temp_sock, $this->_ftp_buff_size, PHP_BINARY_READ))!==false) {
192
-			if($block==="") break;
193
-			if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
194
-			if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block));
195
-			else $out.=$block;
191
+		while (($block = @socket_read($this->_ftp_temp_sock, $this->_ftp_buff_size, PHP_BINARY_READ)) !== false) {
192
+			if ($block === "") break;
193
+			if ($mode != FTP_BINARY) $block = preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
194
+			if (is_resource($fp)) $out += fwrite($fp, $block, strlen($block));
195
+			else $out .= $block;
196 196
 		}
197 197
 		return $out;
198 198
 	}
199 199
 
200
-	function _data_write($mode=FTP_ASCII, $fp=NULL) {
201
-		$NewLine=$this->_eol_code[$this->OS_local];
202
-		if(is_resource($fp)) $out=0;
203
-		else $out="";
204
-		if(!$this->_passive) {
200
+	function _data_write($mode = FTP_ASCII, $fp = NULL) {
201
+		$NewLine = $this->_eol_code[$this->OS_local];
202
+		if (is_resource($fp)) $out = 0;
203
+		else $out = "";
204
+		if ( ! $this->_passive) {
205 205
 			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
206
-			$this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock);
207
-			if($this->_ftp_temp_sock===FALSE) {
208
-				$this->PushError("_data_write","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
206
+			$this->_ftp_temp_sock = socket_accept($this->_ftp_data_sock);
207
+			if ($this->_ftp_temp_sock === FALSE) {
208
+				$this->PushError("_data_write", "socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
209 209
 				$this->_data_close();
210 210
 				return false;
211 211
 			}
212 212
 		}
213
-		if(is_resource($fp)) {
214
-			while(!feof($fp)) {
215
-				$block=fread($fp, $this->_ftp_buff_size);
216
-				if(!$this->_data_write_block($mode, $block)) return false;
213
+		if (is_resource($fp)) {
214
+			while ( ! feof($fp)) {
215
+				$block = fread($fp, $this->_ftp_buff_size);
216
+				if ( ! $this->_data_write_block($mode, $block)) return false;
217 217
 			}
218
-		} elseif(!$this->_data_write_block($mode, $fp)) return false;
218
+		} elseif ( ! $this->_data_write_block($mode, $fp)) return false;
219 219
 		return true;
220 220
 	}
221 221
 
222 222
 	function _data_write_block($mode, $block) {
223
-		if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
223
+		if ($mode != FTP_BINARY) $block = preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
224 224
 		do {
225
-			if(($t=@socket_write($this->_ftp_temp_sock, $block))===FALSE) {
226
-				$this->PushError("_data_write","socket_write", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
225
+			if (($t = @socket_write($this->_ftp_temp_sock, $block)) === FALSE) {
226
+				$this->PushError("_data_write", "socket_write", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
227 227
 				$this->_data_close();
228 228
 				return FALSE;
229 229
 			}
230
-			$block=substr($block, $t);
231
-		} while(!empty($block));
230
+			$block = substr($block, $t);
231
+		} while ( ! empty($block));
232 232
 		return true;
233 233
 	}
234 234
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 	}
241 241
 
242 242
 	function _quit() {
243
-		if($this->_connected) {
243
+		if ($this->_connected) {
244 244
 			@socket_close($this->_ftp_control_sock);
245
-			$this->_connected=false;
245
+			$this->_connected = false;
246 246
 			$this->SendMSG("Socket closed");
247 247
 		}
248 248
 	}
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.
Spacing   +380 added lines, -381 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,29 +877,29 @@  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";
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.
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   +3781 added lines, -3781 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,37 +1829,37 @@  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
-    $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
+	$last = strtolower(substr($v_memory_limit, -1));
1843 1843
 
1844
-    if($last == 'g')
1845
-        //$v_memory_limit = $v_memory_limit*1024*1024*1024;
1846
-        $v_memory_limit = $v_memory_limit*1073741824;
1847
-    if($last == 'm')
1848
-        //$v_memory_limit = $v_memory_limit*1024*1024;
1849
-        $v_memory_limit = $v_memory_limit*1048576;
1850
-    if($last == 'k')
1851
-        $v_memory_limit = $v_memory_limit*1024;
1844
+	if($last == 'g')
1845
+		//$v_memory_limit = $v_memory_limit*1024*1024*1024;
1846
+		$v_memory_limit = $v_memory_limit*1073741824;
1847
+	if($last == 'm')
1848
+		//$v_memory_limit = $v_memory_limit*1024*1024;
1849
+		$v_memory_limit = $v_memory_limit*1048576;
1850
+	if($last == 'k')
1851
+		$v_memory_limit = $v_memory_limit*1024;
1852 1852
 
1853
-    $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
1853
+	$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
1854 1854
 
1855 1855
 
1856
-    // ----- Sanity check : No threshold if value lower than 1M
1857
-    if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
1858
-      unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
1859
-    }
1856
+	// ----- Sanity check : No threshold if value lower than 1M
1857
+	if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
1858
+	  unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
1859
+	}
1860 1860
 
1861
-    // ----- Return
1862
-    return $v_result;
1861
+	// ----- Return
1862
+	return $v_result;
1863 1863
   }
1864 1864
   // --------------------------------------------------------------------------------
1865 1865
 
@@ -1873,116 +1873,116 @@  discard block
 block discarded – undo
1873 1873
   // --------------------------------------------------------------------------------
1874 1874
   function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
1875 1875
   {
1876
-    $v_result=1;
1876
+	$v_result=1;
1877 1877
 
1878
-    // ----- For each file in the list check the attributes
1879
-    foreach ($p_file_list as $v_key => $v_value) {
1878
+	// ----- For each file in the list check the attributes
1879
+	foreach ($p_file_list as $v_key => $v_value) {
1880 1880
 
1881
-      // ----- Check if the option is supported
1882
-      if (!isset($v_requested_options[$v_key])) {
1883
-        // ----- Error log
1884
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1881
+	  // ----- Check if the option is supported
1882
+	  if (!isset($v_requested_options[$v_key])) {
1883
+		// ----- Error log
1884
+		PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1885 1885
 
1886
-        // ----- Return
1887
-        return PclZip::errorCode();
1888
-      }
1886
+		// ----- Return
1887
+		return PclZip::errorCode();
1888
+	  }
1889 1889
 
1890
-      // ----- Look for attribute
1891
-      switch ($v_key) {
1892
-        case PCLZIP_ATT_FILE_NAME :
1893
-          if (!is_string($v_value)) {
1894
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1895
-            return PclZip::errorCode();
1896
-          }
1890
+	  // ----- Look for attribute
1891
+	  switch ($v_key) {
1892
+		case PCLZIP_ATT_FILE_NAME :
1893
+		  if (!is_string($v_value)) {
1894
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1895
+			return PclZip::errorCode();
1896
+		  }
1897 1897
 
1898
-          $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
1898
+		  $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
1899 1899
 
1900
-          if ($p_filedescr['filename'] == '') {
1901
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
1902
-            return PclZip::errorCode();
1903
-          }
1900
+		  if ($p_filedescr['filename'] == '') {
1901
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
1902
+			return PclZip::errorCode();
1903
+		  }
1904 1904
 
1905
-        break;
1905
+		break;
1906 1906
 
1907
-        case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1908
-          if (!is_string($v_value)) {
1909
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1910
-            return PclZip::errorCode();
1911
-          }
1907
+		case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1908
+		  if (!is_string($v_value)) {
1909
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1910
+			return PclZip::errorCode();
1911
+		  }
1912 1912
 
1913
-          $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
1913
+		  $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
1914 1914
 
1915
-          if ($p_filedescr['new_short_name'] == '') {
1916
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
1917
-            return PclZip::errorCode();
1918
-          }
1919
-        break;
1915
+		  if ($p_filedescr['new_short_name'] == '') {
1916
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
1917
+			return PclZip::errorCode();
1918
+		  }
1919
+		break;
1920 1920
 
1921
-        case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1922
-          if (!is_string($v_value)) {
1923
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1924
-            return PclZip::errorCode();
1925
-          }
1921
+		case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1922
+		  if (!is_string($v_value)) {
1923
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1924
+			return PclZip::errorCode();
1925
+		  }
1926 1926
 
1927
-          $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
1927
+		  $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
1928 1928
 
1929
-          if ($p_filedescr['new_full_name'] == '') {
1930
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
1931
-            return PclZip::errorCode();
1932
-          }
1933
-        break;
1929
+		  if ($p_filedescr['new_full_name'] == '') {
1930
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
1931
+			return PclZip::errorCode();
1932
+		  }
1933
+		break;
1934 1934
 
1935
-        // ----- Look for options that takes a string
1936
-        case PCLZIP_ATT_FILE_COMMENT :
1937
-          if (!is_string($v_value)) {
1938
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1939
-            return PclZip::errorCode();
1940
-          }
1935
+		// ----- Look for options that takes a string
1936
+		case PCLZIP_ATT_FILE_COMMENT :
1937
+		  if (!is_string($v_value)) {
1938
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1939
+			return PclZip::errorCode();
1940
+		  }
1941 1941
 
1942
-          $p_filedescr['comment'] = $v_value;
1943
-        break;
1942
+		  $p_filedescr['comment'] = $v_value;
1943
+		break;
1944 1944
 
1945
-        case PCLZIP_ATT_FILE_MTIME :
1946
-          if (!is_integer($v_value)) {
1947
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
1948
-            return PclZip::errorCode();
1949
-          }
1945
+		case PCLZIP_ATT_FILE_MTIME :
1946
+		  if (!is_integer($v_value)) {
1947
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
1948
+			return PclZip::errorCode();
1949
+		  }
1950 1950
 
1951
-          $p_filedescr['mtime'] = $v_value;
1952
-        break;
1951
+		  $p_filedescr['mtime'] = $v_value;
1952
+		break;
1953 1953
 
1954
-        case PCLZIP_ATT_FILE_CONTENT :
1955
-          $p_filedescr['content'] = $v_value;
1956
-        break;
1954
+		case PCLZIP_ATT_FILE_CONTENT :
1955
+		  $p_filedescr['content'] = $v_value;
1956
+		break;
1957 1957
 
1958
-        default :
1959
-          // ----- Error log
1960
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1961
-		                           "Unknown parameter '".$v_key."'");
1958
+		default :
1959
+		  // ----- Error log
1960
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1961
+								   "Unknown parameter '".$v_key."'");
1962 1962
 
1963
-          // ----- Return
1964
-          return PclZip::errorCode();
1965
-      }
1963
+		  // ----- Return
1964
+		  return PclZip::errorCode();
1965
+	  }
1966 1966
 
1967
-      // ----- Look for mandatory options
1968
-      if ($v_requested_options !== false) {
1969
-        for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1970
-          // ----- Look for mandatory option
1971
-          if ($v_requested_options[$key] == 'mandatory') {
1972
-            // ----- Look if present
1973
-            if (!isset($p_file_list[$key])) {
1974
-              PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1975
-              return PclZip::errorCode();
1976
-            }
1977
-          }
1978
-        }
1979
-      }
1967
+	  // ----- Look for mandatory options
1968
+	  if ($v_requested_options !== false) {
1969
+		for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1970
+		  // ----- Look for mandatory option
1971
+		  if ($v_requested_options[$key] == 'mandatory') {
1972
+			// ----- Look if present
1973
+			if (!isset($p_file_list[$key])) {
1974
+			  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1975
+			  return PclZip::errorCode();
1976
+			}
1977
+		  }
1978
+		}
1979
+	  }
1980 1980
 
1981
-    // end foreach
1982
-    }
1981
+	// end foreach
1982
+	}
1983 1983
 
1984
-    // ----- Return
1985
-    return $v_result;
1984
+	// ----- Return
1985
+	return $v_result;
1986 1986
   }
1987 1987
   // --------------------------------------------------------------------------------
1988 1988
 
@@ -2002,120 +2002,120 @@  discard block
 block discarded – undo
2002 2002
   // --------------------------------------------------------------------------------
2003 2003
   function privFileDescrExpand(&$p_filedescr_list, &$p_options)
2004 2004
   {
2005
-    $v_result=1;
2006
-
2007
-    // ----- Create a result list
2008
-    $v_result_list = array();
2009
-
2010
-    // ----- Look each entry
2011
-    for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
2012
-
2013
-      // ----- Get filedescr
2014
-      $v_descr = $p_filedescr_list[$i];
2015
-
2016
-      // ----- Reduce the filename
2017
-      $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
2018
-      $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
2019
-
2020
-      // ----- Look for real file or folder
2021
-      if (file_exists($v_descr['filename'])) {
2022
-        if (@is_file($v_descr['filename'])) {
2023
-          $v_descr['type'] = 'file';
2024
-        }
2025
-        else if (@is_dir($v_descr['filename'])) {
2026
-          $v_descr['type'] = 'folder';
2027
-        }
2028
-        else if (@is_link($v_descr['filename'])) {
2029
-          // skip
2030
-          continue;
2031
-        }
2032
-        else {
2033
-          // skip
2034
-          continue;
2035
-        }
2036
-      }
2005
+	$v_result=1;
2006
+
2007
+	// ----- Create a result list
2008
+	$v_result_list = array();
2009
+
2010
+	// ----- Look each entry
2011
+	for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
2012
+
2013
+	  // ----- Get filedescr
2014
+	  $v_descr = $p_filedescr_list[$i];
2015
+
2016
+	  // ----- Reduce the filename
2017
+	  $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
2018
+	  $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
2019
+
2020
+	  // ----- Look for real file or folder
2021
+	  if (file_exists($v_descr['filename'])) {
2022
+		if (@is_file($v_descr['filename'])) {
2023
+		  $v_descr['type'] = 'file';
2024
+		}
2025
+		else if (@is_dir($v_descr['filename'])) {
2026
+		  $v_descr['type'] = 'folder';
2027
+		}
2028
+		else if (@is_link($v_descr['filename'])) {
2029
+		  // skip
2030
+		  continue;
2031
+		}
2032
+		else {
2033
+		  // skip
2034
+		  continue;
2035
+		}
2036
+	  }
2037 2037
 
2038
-      // ----- Look for string added as file
2039
-      else if (isset($v_descr['content'])) {
2040
-        $v_descr['type'] = 'virtual_file';
2041
-      }
2038
+	  // ----- Look for string added as file
2039
+	  else if (isset($v_descr['content'])) {
2040
+		$v_descr['type'] = 'virtual_file';
2041
+	  }
2042 2042
 
2043
-      // ----- Missing file
2044
-      else {
2045
-        // ----- Error log
2046
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
2043
+	  // ----- Missing file
2044
+	  else {
2045
+		// ----- Error log
2046
+		PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
2047 2047
 
2048
-        // ----- Return
2049
-        return PclZip::errorCode();
2050
-      }
2048
+		// ----- Return
2049
+		return PclZip::errorCode();
2050
+	  }
2051 2051
 
2052
-      // ----- Calculate the stored filename
2053
-      $this->privCalculateStoredFilename($v_descr, $p_options);
2054
-
2055
-      // ----- Add the descriptor in result list
2056
-      $v_result_list[sizeof($v_result_list)] = $v_descr;
2057
-
2058
-      // ----- Look for folder
2059
-      if ($v_descr['type'] == 'folder') {
2060
-        // ----- List of items in folder
2061
-        $v_dirlist_descr = array();
2062
-        $v_dirlist_nb = 0;
2063
-        if ($v_folder_handler = @opendir($v_descr['filename'])) {
2064
-          while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
2065
-
2066
-            // ----- Skip '.' and '..'
2067
-            if (($v_item_handler == '.') || ($v_item_handler == '..')) {
2068
-                continue;
2069
-            }
2070
-
2071
-            // ----- Compose the full filename
2072
-            $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
2073
-
2074
-            // ----- Look for different stored filename
2075
-            // Because the name of the folder was changed, the name of the
2076
-            // files/sub-folders also change
2077
-            if (($v_descr['stored_filename'] != $v_descr['filename'])
2078
-                 && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2079
-              if ($v_descr['stored_filename'] != '') {
2080
-                $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2081
-              }
2082
-              else {
2083
-                $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
2084
-              }
2085
-            }
2086
-
2087
-            $v_dirlist_nb++;
2088
-          }
2052
+	  // ----- Calculate the stored filename
2053
+	  $this->privCalculateStoredFilename($v_descr, $p_options);
2054
+
2055
+	  // ----- Add the descriptor in result list
2056
+	  $v_result_list[sizeof($v_result_list)] = $v_descr;
2057
+
2058
+	  // ----- Look for folder
2059
+	  if ($v_descr['type'] == 'folder') {
2060
+		// ----- List of items in folder
2061
+		$v_dirlist_descr = array();
2062
+		$v_dirlist_nb = 0;
2063
+		if ($v_folder_handler = @opendir($v_descr['filename'])) {
2064
+		  while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
2065
+
2066
+			// ----- Skip '.' and '..'
2067
+			if (($v_item_handler == '.') || ($v_item_handler == '..')) {
2068
+				continue;
2069
+			}
2070
+
2071
+			// ----- Compose the full filename
2072
+			$v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
2073
+
2074
+			// ----- Look for different stored filename
2075
+			// Because the name of the folder was changed, the name of the
2076
+			// files/sub-folders also change
2077
+			if (($v_descr['stored_filename'] != $v_descr['filename'])
2078
+				 && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2079
+			  if ($v_descr['stored_filename'] != '') {
2080
+				$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2081
+			  }
2082
+			  else {
2083
+				$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
2084
+			  }
2085
+			}
2086
+
2087
+			$v_dirlist_nb++;
2088
+		  }
2089 2089
 
2090
-          @closedir($v_folder_handler);
2091
-        }
2092
-        else {
2093
-          // TBC : unable to open folder in read mode
2094
-        }
2095
-
2096
-        // ----- Expand each element of the list
2097
-        if ($v_dirlist_nb != 0) {
2098
-          // ----- Expand
2099
-          if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
2100
-            return $v_result;
2101
-          }
2090
+		  @closedir($v_folder_handler);
2091
+		}
2092
+		else {
2093
+		  // TBC : unable to open folder in read mode
2094
+		}
2095
+
2096
+		// ----- Expand each element of the list
2097
+		if ($v_dirlist_nb != 0) {
2098
+		  // ----- Expand
2099
+		  if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
2100
+			return $v_result;
2101
+		  }
2102 2102
 
2103
-          // ----- Concat the resulting list
2104
-          $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2105
-        }
2106
-        else {
2107
-        }
2103
+		  // ----- Concat the resulting list
2104
+		  $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2105
+		}
2106
+		else {
2107
+		}
2108 2108
 
2109
-        // ----- Free local array
2110
-        unset($v_dirlist_descr);
2111
-      }
2112
-    }
2109
+		// ----- Free local array
2110
+		unset($v_dirlist_descr);
2111
+	  }
2112
+	}
2113 2113
 
2114
-    // ----- Get the result list
2115
-    $p_filedescr_list = $v_result_list;
2114
+	// ----- Get the result list
2115
+	$p_filedescr_list = $v_result_list;
2116 2116
 
2117
-    // ----- Return
2118
-    return $v_result;
2117
+	// ----- Return
2118
+	return $v_result;
2119 2119
   }
2120 2120
   // --------------------------------------------------------------------------------
2121 2121
 
@@ -2127,30 +2127,30 @@  discard block
 block discarded – undo
2127 2127
   // --------------------------------------------------------------------------------
2128 2128
   function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
2129 2129
   {
2130
-    $v_result=1;
2131
-    $v_list_detail = array();
2130
+	$v_result=1;
2131
+	$v_list_detail = array();
2132 2132
 
2133
-    // ----- Magic quotes trick
2134
-    $this->privDisableMagicQuotes();
2133
+	// ----- Magic quotes trick
2134
+	$this->privDisableMagicQuotes();
2135 2135
 
2136
-    // ----- Open the file in write mode
2137
-    if (($v_result = $this->privOpenFd('wb')) != 1)
2138
-    {
2139
-      // ----- Return
2140
-      return $v_result;
2141
-    }
2136
+	// ----- Open the file in write mode
2137
+	if (($v_result = $this->privOpenFd('wb')) != 1)
2138
+	{
2139
+	  // ----- Return
2140
+	  return $v_result;
2141
+	}
2142 2142
 
2143
-    // ----- Add the list of files
2144
-    $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
2143
+	// ----- Add the list of files
2144
+	$v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
2145 2145
 
2146
-    // ----- Close
2147
-    $this->privCloseFd();
2146
+	// ----- Close
2147
+	$this->privCloseFd();
2148 2148
 
2149
-    // ----- Magic quotes trick
2150
-    $this->privSwapBackMagicQuotes();
2149
+	// ----- Magic quotes trick
2150
+	$this->privSwapBackMagicQuotes();
2151 2151
 
2152
-    // ----- Return
2153
-    return $v_result;
2152
+	// ----- Return
2153
+	return $v_result;
2154 2154
   }
2155 2155
   // --------------------------------------------------------------------------------
2156 2156
 
@@ -2162,175 +2162,175 @@  discard block
 block discarded – undo
2162 2162
   // --------------------------------------------------------------------------------
2163 2163
   function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
2164 2164
   {
2165
-    $v_result=1;
2166
-    $v_list_detail = array();
2165
+	$v_result=1;
2166
+	$v_list_detail = array();
2167 2167
 
2168
-    // ----- Look if the archive exists or is empty
2169
-    if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2170
-    {
2168
+	// ----- Look if the archive exists or is empty
2169
+	if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2170
+	{
2171 2171
 
2172
-      // ----- Do a create
2173
-      $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
2172
+	  // ----- Do a create
2173
+	  $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
2174 2174
 
2175
-      // ----- Return
2176
-      return $v_result;
2177
-    }
2178
-    // ----- Magic quotes trick
2179
-    $this->privDisableMagicQuotes();
2175
+	  // ----- Return
2176
+	  return $v_result;
2177
+	}
2178
+	// ----- Magic quotes trick
2179
+	$this->privDisableMagicQuotes();
2180 2180
 
2181
-    // ----- Open the zip file
2182
-    if (($v_result=$this->privOpenFd('rb')) != 1)
2183
-    {
2184
-      // ----- Magic quotes trick
2185
-      $this->privSwapBackMagicQuotes();
2181
+	// ----- Open the zip file
2182
+	if (($v_result=$this->privOpenFd('rb')) != 1)
2183
+	{
2184
+	  // ----- Magic quotes trick
2185
+	  $this->privSwapBackMagicQuotes();
2186 2186
 
2187
-      // ----- Return
2188
-      return $v_result;
2189
-    }
2187
+	  // ----- Return
2188
+	  return $v_result;
2189
+	}
2190 2190
 
2191
-    // ----- Read the central directory informations
2192
-    $v_central_dir = array();
2193
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2194
-    {
2195
-      $this->privCloseFd();
2196
-      $this->privSwapBackMagicQuotes();
2197
-      return $v_result;
2198
-    }
2191
+	// ----- Read the central directory informations
2192
+	$v_central_dir = array();
2193
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2194
+	{
2195
+	  $this->privCloseFd();
2196
+	  $this->privSwapBackMagicQuotes();
2197
+	  return $v_result;
2198
+	}
2199 2199
 
2200
-    // ----- Go to beginning of File
2201
-    @rewind($this->zip_fd);
2200
+	// ----- Go to beginning of File
2201
+	@rewind($this->zip_fd);
2202 2202
 
2203
-    // ----- Creates a temporay file
2204
-    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2203
+	// ----- Creates a temporay file
2204
+	$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2205 2205
 
2206
-    // ----- Open the temporary file in write mode
2207
-    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2208
-    {
2209
-      $this->privCloseFd();
2210
-      $this->privSwapBackMagicQuotes();
2206
+	// ----- Open the temporary file in write mode
2207
+	if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2208
+	{
2209
+	  $this->privCloseFd();
2210
+	  $this->privSwapBackMagicQuotes();
2211 2211
 
2212
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2212
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2213 2213
 
2214
-      // ----- Return
2215
-      return PclZip::errorCode();
2216
-    }
2214
+	  // ----- Return
2215
+	  return PclZip::errorCode();
2216
+	}
2217 2217
 
2218
-    // ----- Copy the files from the archive to the temporary file
2219
-    // TBC : Here I should better append the file and go back to erase the central dir
2220
-    $v_size = $v_central_dir['offset'];
2221
-    while ($v_size != 0)
2222
-    {
2223
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2224
-      $v_buffer = fread($this->zip_fd, $v_read_size);
2225
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2226
-      $v_size -= $v_read_size;
2227
-    }
2218
+	// ----- Copy the files from the archive to the temporary file
2219
+	// TBC : Here I should better append the file and go back to erase the central dir
2220
+	$v_size = $v_central_dir['offset'];
2221
+	while ($v_size != 0)
2222
+	{
2223
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2224
+	  $v_buffer = fread($this->zip_fd, $v_read_size);
2225
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2226
+	  $v_size -= $v_read_size;
2227
+	}
2228 2228
 
2229
-    // ----- Swap the file descriptor
2230
-    // Here is a trick : I swap the temporary fd with the zip fd, in order to use
2231
-    // the following methods on the temporary fil and not the real archive
2232
-    $v_swap = $this->zip_fd;
2233
-    $this->zip_fd = $v_zip_temp_fd;
2234
-    $v_zip_temp_fd = $v_swap;
2235
-
2236
-    // ----- Add the files
2237
-    $v_header_list = array();
2238
-    if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2239
-    {
2240
-      fclose($v_zip_temp_fd);
2241
-      $this->privCloseFd();
2242
-      @unlink($v_zip_temp_name);
2243
-      $this->privSwapBackMagicQuotes();
2244
-
2245
-      // ----- Return
2246
-      return $v_result;
2247
-    }
2229
+	// ----- Swap the file descriptor
2230
+	// Here is a trick : I swap the temporary fd with the zip fd, in order to use
2231
+	// the following methods on the temporary fil and not the real archive
2232
+	$v_swap = $this->zip_fd;
2233
+	$this->zip_fd = $v_zip_temp_fd;
2234
+	$v_zip_temp_fd = $v_swap;
2235
+
2236
+	// ----- Add the files
2237
+	$v_header_list = array();
2238
+	if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2239
+	{
2240
+	  fclose($v_zip_temp_fd);
2241
+	  $this->privCloseFd();
2242
+	  @unlink($v_zip_temp_name);
2243
+	  $this->privSwapBackMagicQuotes();
2244
+
2245
+	  // ----- Return
2246
+	  return $v_result;
2247
+	}
2248 2248
 
2249
-    // ----- Store the offset of the central dir
2250
-    $v_offset = @ftell($this->zip_fd);
2251
-
2252
-    // ----- Copy the block of file headers from the old archive
2253
-    $v_size = $v_central_dir['size'];
2254
-    while ($v_size != 0)
2255
-    {
2256
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2257
-      $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2258
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2259
-      $v_size -= $v_read_size;
2260
-    }
2249
+	// ----- Store the offset of the central dir
2250
+	$v_offset = @ftell($this->zip_fd);
2251
+
2252
+	// ----- Copy the block of file headers from the old archive
2253
+	$v_size = $v_central_dir['size'];
2254
+	while ($v_size != 0)
2255
+	{
2256
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2257
+	  $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2258
+	  @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2259
+	  $v_size -= $v_read_size;
2260
+	}
2261 2261
 
2262
-    // ----- Create the Central Dir files header
2263
-    for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2264
-    {
2265
-      // ----- Create the file header
2266
-      if ($v_header_list[$i]['status'] == 'ok') {
2267
-        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2268
-          fclose($v_zip_temp_fd);
2269
-          $this->privCloseFd();
2270
-          @unlink($v_zip_temp_name);
2271
-          $this->privSwapBackMagicQuotes();
2272
-
2273
-          // ----- Return
2274
-          return $v_result;
2275
-        }
2276
-        $v_count++;
2277
-      }
2262
+	// ----- Create the Central Dir files header
2263
+	for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2264
+	{
2265
+	  // ----- Create the file header
2266
+	  if ($v_header_list[$i]['status'] == 'ok') {
2267
+		if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2268
+		  fclose($v_zip_temp_fd);
2269
+		  $this->privCloseFd();
2270
+		  @unlink($v_zip_temp_name);
2271
+		  $this->privSwapBackMagicQuotes();
2272
+
2273
+		  // ----- Return
2274
+		  return $v_result;
2275
+		}
2276
+		$v_count++;
2277
+	  }
2278 2278
 
2279
-      // ----- Transform the header to a 'usable' info
2280
-      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2281
-    }
2279
+	  // ----- Transform the header to a 'usable' info
2280
+	  $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2281
+	}
2282 2282
 
2283
-    // ----- Zip file comment
2284
-    $v_comment = $v_central_dir['comment'];
2285
-    if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2286
-      $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2287
-    }
2288
-    if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
2289
-      $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
2290
-    }
2291
-    if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
2292
-      $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2293
-    }
2283
+	// ----- Zip file comment
2284
+	$v_comment = $v_central_dir['comment'];
2285
+	if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2286
+	  $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2287
+	}
2288
+	if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
2289
+	  $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
2290
+	}
2291
+	if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
2292
+	  $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2293
+	}
2294 2294
 
2295
-    // ----- Calculate the size of the central header
2296
-    $v_size = @ftell($this->zip_fd)-$v_offset;
2295
+	// ----- Calculate the size of the central header
2296
+	$v_size = @ftell($this->zip_fd)-$v_offset;
2297 2297
 
2298
-    // ----- Create the central dir footer
2299
-    if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2300
-    {
2301
-      // ----- Reset the file list
2302
-      unset($v_header_list);
2303
-      $this->privSwapBackMagicQuotes();
2298
+	// ----- Create the central dir footer
2299
+	if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2300
+	{
2301
+	  // ----- Reset the file list
2302
+	  unset($v_header_list);
2303
+	  $this->privSwapBackMagicQuotes();
2304 2304
 
2305
-      // ----- Return
2306
-      return $v_result;
2307
-    }
2305
+	  // ----- Return
2306
+	  return $v_result;
2307
+	}
2308 2308
 
2309
-    // ----- Swap back the file descriptor
2310
-    $v_swap = $this->zip_fd;
2311
-    $this->zip_fd = $v_zip_temp_fd;
2312
-    $v_zip_temp_fd = $v_swap;
2309
+	// ----- Swap back the file descriptor
2310
+	$v_swap = $this->zip_fd;
2311
+	$this->zip_fd = $v_zip_temp_fd;
2312
+	$v_zip_temp_fd = $v_swap;
2313 2313
 
2314
-    // ----- Close
2315
-    $this->privCloseFd();
2314
+	// ----- Close
2315
+	$this->privCloseFd();
2316 2316
 
2317
-    // ----- Close the temporary file
2318
-    @fclose($v_zip_temp_fd);
2317
+	// ----- Close the temporary file
2318
+	@fclose($v_zip_temp_fd);
2319 2319
 
2320
-    // ----- Magic quotes trick
2321
-    $this->privSwapBackMagicQuotes();
2320
+	// ----- Magic quotes trick
2321
+	$this->privSwapBackMagicQuotes();
2322 2322
 
2323
-    // ----- Delete the zip file
2324
-    // TBC : I should test the result ...
2325
-    @unlink($this->zipname);
2323
+	// ----- Delete the zip file
2324
+	// TBC : I should test the result ...
2325
+	@unlink($this->zipname);
2326 2326
 
2327
-    // ----- Rename the temporary file
2328
-    // TBC : I should test the result ...
2329
-    //@rename($v_zip_temp_name, $this->zipname);
2330
-    PclZipUtilRename($v_zip_temp_name, $this->zipname);
2327
+	// ----- Rename the temporary file
2328
+	// TBC : I should test the result ...
2329
+	//@rename($v_zip_temp_name, $this->zipname);
2330
+	PclZipUtilRename($v_zip_temp_name, $this->zipname);
2331 2331
 
2332
-    // ----- Return
2333
-    return $v_result;
2332
+	// ----- Return
2333
+	return $v_result;
2334 2334
   }
2335 2335
   // --------------------------------------------------------------------------------
2336 2336
 
@@ -2341,30 +2341,30 @@  discard block
 block discarded – undo
2341 2341
   // --------------------------------------------------------------------------------
2342 2342
   function privOpenFd($p_mode)
2343 2343
   {
2344
-    $v_result=1;
2344
+	$v_result=1;
2345 2345
 
2346
-    // ----- Look if already open
2347
-    if ($this->zip_fd != 0)
2348
-    {
2349
-      // ----- Error log
2350
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2346
+	// ----- Look if already open
2347
+	if ($this->zip_fd != 0)
2348
+	{
2349
+	  // ----- Error log
2350
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2351 2351
 
2352
-      // ----- Return
2353
-      return PclZip::errorCode();
2354
-    }
2352
+	  // ----- Return
2353
+	  return PclZip::errorCode();
2354
+	}
2355 2355
 
2356
-    // ----- Open the zip file
2357
-    if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2358
-    {
2359
-      // ----- Error log
2360
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2356
+	// ----- Open the zip file
2357
+	if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2358
+	{
2359
+	  // ----- Error log
2360
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2361 2361
 
2362
-      // ----- Return
2363
-      return PclZip::errorCode();
2364
-    }
2362
+	  // ----- Return
2363
+	  return PclZip::errorCode();
2364
+	}
2365 2365
 
2366
-    // ----- Return
2367
-    return $v_result;
2366
+	// ----- Return
2367
+	return $v_result;
2368 2368
   }
2369 2369
   // --------------------------------------------------------------------------------
2370 2370
 
@@ -2375,14 +2375,14 @@  discard block
 block discarded – undo
2375 2375
   // --------------------------------------------------------------------------------
2376 2376
   function privCloseFd()
2377 2377
   {
2378
-    $v_result=1;
2378
+	$v_result=1;
2379 2379
 
2380
-    if ($this->zip_fd != 0)
2381
-      @fclose($this->zip_fd);
2382
-    $this->zip_fd = 0;
2380
+	if ($this->zip_fd != 0)
2381
+	  @fclose($this->zip_fd);
2382
+	$this->zip_fd = 0;
2383 2383
 
2384
-    // ----- Return
2385
-    return $v_result;
2384
+	// ----- Return
2385
+	return $v_result;
2386 2386
   }
2387 2387
   // --------------------------------------------------------------------------------
2388 2388
 
@@ -2402,56 +2402,56 @@  discard block
 block discarded – undo
2402 2402
 //  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
2403 2403
   function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
2404 2404
   {
2405
-    $v_result=1;
2406
-
2407
-    // ----- Add the files
2408
-    $v_header_list = array();
2409
-    if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2410
-    {
2411
-      // ----- Return
2412
-      return $v_result;
2413
-    }
2405
+	$v_result=1;
2406
+
2407
+	// ----- Add the files
2408
+	$v_header_list = array();
2409
+	if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2410
+	{
2411
+	  // ----- Return
2412
+	  return $v_result;
2413
+	}
2414 2414
 
2415
-    // ----- Store the offset of the central dir
2416
-    $v_offset = @ftell($this->zip_fd);
2417
-
2418
-    // ----- Create the Central Dir files header
2419
-    for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2420
-    {
2421
-      // ----- Create the file header
2422
-      if ($v_header_list[$i]['status'] == 'ok') {
2423
-        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2424
-          // ----- Return
2425
-          return $v_result;
2426
-        }
2427
-        $v_count++;
2428
-      }
2415
+	// ----- Store the offset of the central dir
2416
+	$v_offset = @ftell($this->zip_fd);
2417
+
2418
+	// ----- Create the Central Dir files header
2419
+	for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2420
+	{
2421
+	  // ----- Create the file header
2422
+	  if ($v_header_list[$i]['status'] == 'ok') {
2423
+		if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2424
+		  // ----- Return
2425
+		  return $v_result;
2426
+		}
2427
+		$v_count++;
2428
+	  }
2429 2429
 
2430
-      // ----- Transform the header to a 'usable' info
2431
-      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2432
-    }
2430
+	  // ----- Transform the header to a 'usable' info
2431
+	  $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2432
+	}
2433 2433
 
2434
-    // ----- Zip file comment
2435
-    $v_comment = '';
2436
-    if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2437
-      $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2438
-    }
2434
+	// ----- Zip file comment
2435
+	$v_comment = '';
2436
+	if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2437
+	  $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2438
+	}
2439 2439
 
2440
-    // ----- Calculate the size of the central header
2441
-    $v_size = @ftell($this->zip_fd)-$v_offset;
2440
+	// ----- Calculate the size of the central header
2441
+	$v_size = @ftell($this->zip_fd)-$v_offset;
2442 2442
 
2443
-    // ----- Create the central dir footer
2444
-    if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
2445
-    {
2446
-      // ----- Reset the file list
2447
-      unset($v_header_list);
2443
+	// ----- Create the central dir footer
2444
+	if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
2445
+	{
2446
+	  // ----- Reset the file list
2447
+	  unset($v_header_list);
2448 2448
 
2449
-      // ----- Return
2450
-      return $v_result;
2451
-    }
2449
+	  // ----- Return
2450
+	  return $v_result;
2451
+	}
2452 2452
 
2453
-    // ----- Return
2454
-    return $v_result;
2453
+	// ----- Return
2454
+	return $v_result;
2455 2455
   }
2456 2456
   // --------------------------------------------------------------------------------
2457 2457
 
@@ -2466,57 +2466,57 @@  discard block
 block discarded – undo
2466 2466
   // --------------------------------------------------------------------------------
2467 2467
   function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
2468 2468
   {
2469
-    $v_result=1;
2470
-    $v_header = array();
2469
+	$v_result=1;
2470
+	$v_header = array();
2471 2471
 
2472
-    // ----- Recuperate the current number of elt in list
2473
-    $v_nb = sizeof($p_result_list);
2472
+	// ----- Recuperate the current number of elt in list
2473
+	$v_nb = sizeof($p_result_list);
2474 2474
 
2475
-    // ----- Loop on the files
2476
-    for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2477
-      // ----- Format the filename
2478
-      $p_filedescr_list[$j]['filename']
2479
-      = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
2475
+	// ----- Loop on the files
2476
+	for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2477
+	  // ----- Format the filename
2478
+	  $p_filedescr_list[$j]['filename']
2479
+	  = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
2480 2480
 
2481 2481
 
2482
-      // ----- Skip empty file names
2483
-      // TBC : Can this be possible ? not checked in DescrParseAtt ?
2484
-      if ($p_filedescr_list[$j]['filename'] == "") {
2485
-        continue;
2486
-      }
2482
+	  // ----- Skip empty file names
2483
+	  // TBC : Can this be possible ? not checked in DescrParseAtt ?
2484
+	  if ($p_filedescr_list[$j]['filename'] == "") {
2485
+		continue;
2486
+	  }
2487 2487
 
2488
-      // ----- Check the filename
2489
-      if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
2490
-          && (!file_exists($p_filedescr_list[$j]['filename']))) {
2491
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2492
-        return PclZip::errorCode();
2493
-      }
2488
+	  // ----- Check the filename
2489
+	  if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
2490
+		  && (!file_exists($p_filedescr_list[$j]['filename']))) {
2491
+		PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2492
+		return PclZip::errorCode();
2493
+	  }
2494 2494
 
2495
-      // ----- Look if it is a file or a dir with no all path remove option
2496
-      // or a dir with all its path removed
2495
+	  // ----- Look if it is a file or a dir with no all path remove option
2496
+	  // or a dir with all its path removed
2497 2497
 //      if (   (is_file($p_filedescr_list[$j]['filename']))
2498 2498
 //          || (   is_dir($p_filedescr_list[$j]['filename'])
2499
-      if (   ($p_filedescr_list[$j]['type'] == 'file')
2500
-          || ($p_filedescr_list[$j]['type'] == 'virtual_file')
2501
-          || (   ($p_filedescr_list[$j]['type'] == 'folder')
2502
-              && (   !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2503
-                  || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2504
-          ) {
2505
-
2506
-        // ----- Add the file
2507
-        $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
2508
-                                       $p_options);
2509
-        if ($v_result != 1) {
2510
-          return $v_result;
2511
-        }
2512
-
2513
-        // ----- Store the file infos
2514
-        $p_result_list[$v_nb++] = $v_header;
2515
-      }
2516
-    }
2499
+	  if (   ($p_filedescr_list[$j]['type'] == 'file')
2500
+		  || ($p_filedescr_list[$j]['type'] == 'virtual_file')
2501
+		  || (   ($p_filedescr_list[$j]['type'] == 'folder')
2502
+			  && (   !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2503
+				  || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2504
+		  ) {
2505
+
2506
+		// ----- Add the file
2507
+		$v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
2508
+									   $p_options);
2509
+		if ($v_result != 1) {
2510
+		  return $v_result;
2511
+		}
2512
+
2513
+		// ----- Store the file infos
2514
+		$p_result_list[$v_nb++] = $v_header;
2515
+	  }
2516
+	}
2517 2517
 
2518
-    // ----- Return
2519
-    return $v_result;
2518
+	// ----- Return
2519
+	return $v_result;
2520 2520
   }
2521 2521
   // --------------------------------------------------------------------------------
2522 2522
 
@@ -2528,22 +2528,22 @@  discard block
 block discarded – undo
2528 2528
   // --------------------------------------------------------------------------------
2529 2529
   function privAddFile($p_filedescr, &$p_header, &$p_options)
2530 2530
   {
2531
-    $v_result=1;
2531
+	$v_result=1;
2532 2532
 
2533
-    // ----- Working variable
2534
-    $p_filename = $p_filedescr['filename'];
2533
+	// ----- Working variable
2534
+	$p_filename = $p_filedescr['filename'];
2535 2535
 
2536
-    // TBC : Already done in the fileAtt check ... ?
2537
-    if ($p_filename == "") {
2538
-      // ----- Error log
2539
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2536
+	// TBC : Already done in the fileAtt check ... ?
2537
+	if ($p_filename == "") {
2538
+	  // ----- Error log
2539
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2540 2540
 
2541
-      // ----- Return
2542
-      return PclZip::errorCode();
2543
-    }
2541
+	  // ----- Return
2542
+	  return PclZip::errorCode();
2543
+	}
2544 2544
 
2545
-    // ----- Look for a stored different filename
2546
-    /* TBC : Removed
2545
+	// ----- Look for a stored different filename
2546
+	/* TBC : Removed
2547 2547
     if (isset($p_filedescr['stored_filename'])) {
2548 2548
       $v_stored_filename = $p_filedescr['stored_filename'];
2549 2549
     }
@@ -2552,242 +2552,242 @@  discard block
 block discarded – undo
2552 2552
     }
2553 2553
     */
2554 2554
 
2555
-    // ----- Set the file properties
2556
-    clearstatcache();
2557
-    $p_header['version'] = 20;
2558
-    $p_header['version_extracted'] = 10;
2559
-    $p_header['flag'] = 0;
2560
-    $p_header['compression'] = 0;
2561
-    $p_header['crc'] = 0;
2562
-    $p_header['compressed_size'] = 0;
2563
-    $p_header['filename_len'] = strlen($p_filename);
2564
-    $p_header['extra_len'] = 0;
2565
-    $p_header['disk'] = 0;
2566
-    $p_header['internal'] = 0;
2567
-    $p_header['offset'] = 0;
2568
-    $p_header['filename'] = $p_filename;
2555
+	// ----- Set the file properties
2556
+	clearstatcache();
2557
+	$p_header['version'] = 20;
2558
+	$p_header['version_extracted'] = 10;
2559
+	$p_header['flag'] = 0;
2560
+	$p_header['compression'] = 0;
2561
+	$p_header['crc'] = 0;
2562
+	$p_header['compressed_size'] = 0;
2563
+	$p_header['filename_len'] = strlen($p_filename);
2564
+	$p_header['extra_len'] = 0;
2565
+	$p_header['disk'] = 0;
2566
+	$p_header['internal'] = 0;
2567
+	$p_header['offset'] = 0;
2568
+	$p_header['filename'] = $p_filename;
2569 2569
 // TBC : Removed    $p_header['stored_filename'] = $v_stored_filename;
2570
-    $p_header['stored_filename'] = $p_filedescr['stored_filename'];
2571
-    $p_header['extra'] = '';
2572
-    $p_header['status'] = 'ok';
2573
-    $p_header['index'] = -1;
2574
-
2575
-    // ----- Look for regular file
2576
-    if ($p_filedescr['type']=='file') {
2577
-      $p_header['external'] = 0x00000000;
2578
-      $p_header['size'] = filesize($p_filename);
2579
-    }
2570
+	$p_header['stored_filename'] = $p_filedescr['stored_filename'];
2571
+	$p_header['extra'] = '';
2572
+	$p_header['status'] = 'ok';
2573
+	$p_header['index'] = -1;
2574
+
2575
+	// ----- Look for regular file
2576
+	if ($p_filedescr['type']=='file') {
2577
+	  $p_header['external'] = 0x00000000;
2578
+	  $p_header['size'] = filesize($p_filename);
2579
+	}
2580 2580
 
2581
-    // ----- Look for regular folder
2582
-    else if ($p_filedescr['type']=='folder') {
2583
-      $p_header['external'] = 0x00000010;
2584
-      $p_header['mtime'] = filemtime($p_filename);
2585
-      $p_header['size'] = filesize($p_filename);
2586
-    }
2581
+	// ----- Look for regular folder
2582
+	else if ($p_filedescr['type']=='folder') {
2583
+	  $p_header['external'] = 0x00000010;
2584
+	  $p_header['mtime'] = filemtime($p_filename);
2585
+	  $p_header['size'] = filesize($p_filename);
2586
+	}
2587 2587
 
2588
-    // ----- Look for virtual file
2589
-    else if ($p_filedescr['type'] == 'virtual_file') {
2590
-      $p_header['external'] = 0x00000000;
2591
-      $p_header['size'] = strlen($p_filedescr['content']);
2592
-    }
2588
+	// ----- Look for virtual file
2589
+	else if ($p_filedescr['type'] == 'virtual_file') {
2590
+	  $p_header['external'] = 0x00000000;
2591
+	  $p_header['size'] = strlen($p_filedescr['content']);
2592
+	}
2593 2593
 
2594 2594
 
2595
-    // ----- Look for filetime
2596
-    if (isset($p_filedescr['mtime'])) {
2597
-      $p_header['mtime'] = $p_filedescr['mtime'];
2598
-    }
2599
-    else if ($p_filedescr['type'] == 'virtual_file') {
2600
-      $p_header['mtime'] = time();
2601
-    }
2602
-    else {
2603
-      $p_header['mtime'] = filemtime($p_filename);
2604
-    }
2595
+	// ----- Look for filetime
2596
+	if (isset($p_filedescr['mtime'])) {
2597
+	  $p_header['mtime'] = $p_filedescr['mtime'];
2598
+	}
2599
+	else if ($p_filedescr['type'] == 'virtual_file') {
2600
+	  $p_header['mtime'] = time();
2601
+	}
2602
+	else {
2603
+	  $p_header['mtime'] = filemtime($p_filename);
2604
+	}
2605 2605
 
2606
-    // ------ Look for file comment
2607
-    if (isset($p_filedescr['comment'])) {
2608
-      $p_header['comment_len'] = strlen($p_filedescr['comment']);
2609
-      $p_header['comment'] = $p_filedescr['comment'];
2610
-    }
2611
-    else {
2612
-      $p_header['comment_len'] = 0;
2613
-      $p_header['comment'] = '';
2614
-    }
2606
+	// ------ Look for file comment
2607
+	if (isset($p_filedescr['comment'])) {
2608
+	  $p_header['comment_len'] = strlen($p_filedescr['comment']);
2609
+	  $p_header['comment'] = $p_filedescr['comment'];
2610
+	}
2611
+	else {
2612
+	  $p_header['comment_len'] = 0;
2613
+	  $p_header['comment'] = '';
2614
+	}
2615 2615
 
2616
-    // ----- Look for pre-add callback
2617
-    if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
2618
-
2619
-      // ----- Generate a local information
2620
-      $v_local_header = array();
2621
-      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2622
-
2623
-      // ----- Call the callback
2624
-      // Here I do not use call_user_func() because I need to send a reference to the
2625
-      // header.
2626
-      $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
2627
-      if ($v_result == 0) {
2628
-        // ----- Change the file status
2629
-        $p_header['status'] = "skipped";
2630
-        $v_result = 1;
2631
-      }
2616
+	// ----- Look for pre-add callback
2617
+	if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
2618
+
2619
+	  // ----- Generate a local information
2620
+	  $v_local_header = array();
2621
+	  $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2622
+
2623
+	  // ----- Call the callback
2624
+	  // Here I do not use call_user_func() because I need to send a reference to the
2625
+	  // header.
2626
+	  $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
2627
+	  if ($v_result == 0) {
2628
+		// ----- Change the file status
2629
+		$p_header['status'] = "skipped";
2630
+		$v_result = 1;
2631
+	  }
2632 2632
 
2633
-      // ----- Update the informations
2634
-      // Only some fields can be modified
2635
-      if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
2636
-        $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
2637
-      }
2638
-    }
2633
+	  // ----- Update the informations
2634
+	  // Only some fields can be modified
2635
+	  if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
2636
+		$p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
2637
+	  }
2638
+	}
2639 2639
 
2640
-    // ----- Look for empty stored filename
2641
-    if ($p_header['stored_filename'] == "") {
2642
-      $p_header['status'] = "filtered";
2643
-    }
2640
+	// ----- Look for empty stored filename
2641
+	if ($p_header['stored_filename'] == "") {
2642
+	  $p_header['status'] = "filtered";
2643
+	}
2644 2644
 
2645
-    // ----- Check the path length
2646
-    if (strlen($p_header['stored_filename']) > 0xFF) {
2647
-      $p_header['status'] = 'filename_too_long';
2648
-    }
2645
+	// ----- Check the path length
2646
+	if (strlen($p_header['stored_filename']) > 0xFF) {
2647
+	  $p_header['status'] = 'filename_too_long';
2648
+	}
2649 2649
 
2650
-    // ----- Look if no error, or file not skipped
2651
-    if ($p_header['status'] == 'ok') {
2652
-
2653
-      // ----- Look for a file
2654
-      if ($p_filedescr['type'] == 'file') {
2655
-        // ----- Look for using temporary file to zip
2656
-        if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
2657
-            && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2658
-                || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2659
-                    && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
2660
-          $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2661
-          if ($v_result < PCLZIP_ERR_NO_ERROR) {
2662
-            return $v_result;
2663
-          }
2664
-        }
2650
+	// ----- Look if no error, or file not skipped
2651
+	if ($p_header['status'] == 'ok') {
2652
+
2653
+	  // ----- Look for a file
2654
+	  if ($p_filedescr['type'] == 'file') {
2655
+		// ----- Look for using temporary file to zip
2656
+		if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
2657
+			&& (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2658
+				|| (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2659
+					&& ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
2660
+		  $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2661
+		  if ($v_result < PCLZIP_ERR_NO_ERROR) {
2662
+			return $v_result;
2663
+		  }
2664
+		}
2665 2665
 
2666
-        // ----- Use "in memory" zip algo
2667
-        else {
2666
+		// ----- Use "in memory" zip algo
2667
+		else {
2668 2668
 
2669
-        // ----- Open the source file
2670
-        if (($v_file = @fopen($p_filename, "rb")) == 0) {
2671
-          PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2672
-          return PclZip::errorCode();
2673
-        }
2669
+		// ----- Open the source file
2670
+		if (($v_file = @fopen($p_filename, "rb")) == 0) {
2671
+		  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2672
+		  return PclZip::errorCode();
2673
+		}
2674 2674
 
2675
-        // ----- Read the file content
2676
-        $v_content = @fread($v_file, $p_header['size']);
2675
+		// ----- Read the file content
2676
+		$v_content = @fread($v_file, $p_header['size']);
2677 2677
 
2678
-        // ----- Close the file
2679
-        @fclose($v_file);
2678
+		// ----- Close the file
2679
+		@fclose($v_file);
2680 2680
 
2681
-        // ----- Calculate the CRC
2682
-        $p_header['crc'] = @crc32($v_content);
2681
+		// ----- Calculate the CRC
2682
+		$p_header['crc'] = @crc32($v_content);
2683 2683
 
2684
-        // ----- Look for no compression
2685
-        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2686
-          // ----- Set header parameters
2687
-          $p_header['compressed_size'] = $p_header['size'];
2688
-          $p_header['compression'] = 0;
2689
-        }
2684
+		// ----- Look for no compression
2685
+		if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2686
+		  // ----- Set header parameters
2687
+		  $p_header['compressed_size'] = $p_header['size'];
2688
+		  $p_header['compression'] = 0;
2689
+		}
2690 2690
 
2691
-        // ----- Look for normal compression
2692
-        else {
2693
-          // ----- Compress the content
2694
-          $v_content = @gzdeflate($v_content);
2691
+		// ----- Look for normal compression
2692
+		else {
2693
+		  // ----- Compress the content
2694
+		  $v_content = @gzdeflate($v_content);
2695 2695
 
2696
-          // ----- Set header parameters
2697
-          $p_header['compressed_size'] = strlen($v_content);
2698
-          $p_header['compression'] = 8;
2699
-        }
2696
+		  // ----- Set header parameters
2697
+		  $p_header['compressed_size'] = strlen($v_content);
2698
+		  $p_header['compression'] = 8;
2699
+		}
2700 2700
 
2701
-        // ----- Call the header generation
2702
-        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2703
-          @fclose($v_file);
2704
-          return $v_result;
2705
-        }
2701
+		// ----- Call the header generation
2702
+		if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2703
+		  @fclose($v_file);
2704
+		  return $v_result;
2705
+		}
2706 2706
 
2707
-        // ----- Write the compressed (or not) content
2708
-        @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2707
+		// ----- Write the compressed (or not) content
2708
+		@fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2709 2709
 
2710
-        }
2710
+		}
2711 2711
 
2712
-      }
2712
+	  }
2713 2713
 
2714
-      // ----- Look for a virtual file (a file from string)
2715
-      else if ($p_filedescr['type'] == 'virtual_file') {
2714
+	  // ----- Look for a virtual file (a file from string)
2715
+	  else if ($p_filedescr['type'] == 'virtual_file') {
2716 2716
 
2717
-        $v_content = $p_filedescr['content'];
2717
+		$v_content = $p_filedescr['content'];
2718 2718
 
2719
-        // ----- Calculate the CRC
2720
-        $p_header['crc'] = @crc32($v_content);
2719
+		// ----- Calculate the CRC
2720
+		$p_header['crc'] = @crc32($v_content);
2721 2721
 
2722
-        // ----- Look for no compression
2723
-        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2724
-          // ----- Set header parameters
2725
-          $p_header['compressed_size'] = $p_header['size'];
2726
-          $p_header['compression'] = 0;
2727
-        }
2722
+		// ----- Look for no compression
2723
+		if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2724
+		  // ----- Set header parameters
2725
+		  $p_header['compressed_size'] = $p_header['size'];
2726
+		  $p_header['compression'] = 0;
2727
+		}
2728 2728
 
2729
-        // ----- Look for normal compression
2730
-        else {
2731
-          // ----- Compress the content
2732
-          $v_content = @gzdeflate($v_content);
2729
+		// ----- Look for normal compression
2730
+		else {
2731
+		  // ----- Compress the content
2732
+		  $v_content = @gzdeflate($v_content);
2733 2733
 
2734
-          // ----- Set header parameters
2735
-          $p_header['compressed_size'] = strlen($v_content);
2736
-          $p_header['compression'] = 8;
2737
-        }
2734
+		  // ----- Set header parameters
2735
+		  $p_header['compressed_size'] = strlen($v_content);
2736
+		  $p_header['compression'] = 8;
2737
+		}
2738 2738
 
2739
-        // ----- Call the header generation
2740
-        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2741
-          @fclose($v_file);
2742
-          return $v_result;
2743
-        }
2739
+		// ----- Call the header generation
2740
+		if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2741
+		  @fclose($v_file);
2742
+		  return $v_result;
2743
+		}
2744 2744
 
2745
-        // ----- Write the compressed (or not) content
2746
-        @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2747
-      }
2745
+		// ----- Write the compressed (or not) content
2746
+		@fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2747
+	  }
2748 2748
 
2749
-      // ----- Look for a directory
2750
-      else if ($p_filedescr['type'] == 'folder') {
2751
-        // ----- Look for directory last '/'
2752
-        if (@substr($p_header['stored_filename'], -1) != '/') {
2753
-          $p_header['stored_filename'] .= '/';
2754
-        }
2755
-
2756
-        // ----- Set the file properties
2757
-        $p_header['size'] = 0;
2758
-        //$p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
2759
-        $p_header['external'] = 0x00000010;   // Value for a folder : to be checked
2760
-
2761
-        // ----- Call the header generation
2762
-        if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
2763
-        {
2764
-          return $v_result;
2765
-        }
2766
-      }
2767
-    }
2749
+	  // ----- Look for a directory
2750
+	  else if ($p_filedescr['type'] == 'folder') {
2751
+		// ----- Look for directory last '/'
2752
+		if (@substr($p_header['stored_filename'], -1) != '/') {
2753
+		  $p_header['stored_filename'] .= '/';
2754
+		}
2755
+
2756
+		// ----- Set the file properties
2757
+		$p_header['size'] = 0;
2758
+		//$p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
2759
+		$p_header['external'] = 0x00000010;   // Value for a folder : to be checked
2760
+
2761
+		// ----- Call the header generation
2762
+		if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
2763
+		{
2764
+		  return $v_result;
2765
+		}
2766
+	  }
2767
+	}
2768 2768
 
2769
-    // ----- Look for post-add callback
2770
-    if (isset($p_options[PCLZIP_CB_POST_ADD])) {
2769
+	// ----- Look for post-add callback
2770
+	if (isset($p_options[PCLZIP_CB_POST_ADD])) {
2771 2771
 
2772
-      // ----- Generate a local information
2773
-      $v_local_header = array();
2774
-      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2772
+	  // ----- Generate a local information
2773
+	  $v_local_header = array();
2774
+	  $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2775 2775
 
2776
-      // ----- Call the callback
2777
-      // Here I do not use call_user_func() because I need to send a reference to the
2778
-      // header.
2779
-      $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
2780
-      if ($v_result == 0) {
2781
-        // ----- Ignored
2782
-        $v_result = 1;
2783
-      }
2776
+	  // ----- Call the callback
2777
+	  // Here I do not use call_user_func() because I need to send a reference to the
2778
+	  // header.
2779
+	  $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
2780
+	  if ($v_result == 0) {
2781
+		// ----- Ignored
2782
+		$v_result = 1;
2783
+	  }
2784 2784
 
2785
-      // ----- Update the informations
2786
-      // Nothing can be modified
2787
-    }
2785
+	  // ----- Update the informations
2786
+	  // Nothing can be modified
2787
+	}
2788 2788
 
2789
-    // ----- Return
2790
-    return $v_result;
2789
+	// ----- Return
2790
+	return $v_result;
2791 2791
   }
2792 2792
   // --------------------------------------------------------------------------------
2793 2793
 
@@ -2799,105 +2799,105 @@  discard block
 block discarded – undo
2799 2799
   // --------------------------------------------------------------------------------
2800 2800
   function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
2801 2801
   {
2802
-    $v_result=PCLZIP_ERR_NO_ERROR;
2802
+	$v_result=PCLZIP_ERR_NO_ERROR;
2803 2803
 
2804
-    // ----- Working variable
2805
-    $p_filename = $p_filedescr['filename'];
2804
+	// ----- Working variable
2805
+	$p_filename = $p_filedescr['filename'];
2806 2806
 
2807 2807
 
2808
-    // ----- Open the source file
2809
-    if (($v_file = @fopen($p_filename, "rb")) == 0) {
2810
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2811
-      return PclZip::errorCode();
2812
-    }
2808
+	// ----- Open the source file
2809
+	if (($v_file = @fopen($p_filename, "rb")) == 0) {
2810
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2811
+	  return PclZip::errorCode();
2812
+	}
2813 2813
 
2814
-    // ----- Creates a compressed temporary file
2815
-    $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2816
-    if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
2817
-      fclose($v_file);
2818
-      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2819
-      return PclZip::errorCode();
2820
-    }
2814
+	// ----- Creates a compressed temporary file
2815
+	$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2816
+	if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
2817
+	  fclose($v_file);
2818
+	  PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2819
+	  return PclZip::errorCode();
2820
+	}
2821 2821
 
2822
-    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2823
-    $v_size = filesize($p_filename);
2824
-    while ($v_size != 0) {
2825
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2826
-      $v_buffer = @fread($v_file, $v_read_size);
2827
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2828
-      @gzputs($v_file_compressed, $v_buffer, $v_read_size);
2829
-      $v_size -= $v_read_size;
2830
-    }
2822
+	// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2823
+	$v_size = filesize($p_filename);
2824
+	while ($v_size != 0) {
2825
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2826
+	  $v_buffer = @fread($v_file, $v_read_size);
2827
+	  //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2828
+	  @gzputs($v_file_compressed, $v_buffer, $v_read_size);
2829
+	  $v_size -= $v_read_size;
2830
+	}
2831 2831
 
2832
-    // ----- Close the file
2833
-    @fclose($v_file);
2834
-    @gzclose($v_file_compressed);
2832
+	// ----- Close the file
2833
+	@fclose($v_file);
2834
+	@gzclose($v_file_compressed);
2835 2835
 
2836
-    // ----- Check the minimum file size
2837
-    if (filesize($v_gzip_temp_name) < 18) {
2838
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
2839
-      return PclZip::errorCode();
2840
-    }
2836
+	// ----- Check the minimum file size
2837
+	if (filesize($v_gzip_temp_name) < 18) {
2838
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
2839
+	  return PclZip::errorCode();
2840
+	}
2841 2841
 
2842
-    // ----- Extract the compressed attributes
2843
-    if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
2844
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2845
-      return PclZip::errorCode();
2846
-    }
2842
+	// ----- Extract the compressed attributes
2843
+	if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
2844
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2845
+	  return PclZip::errorCode();
2846
+	}
2847 2847
 
2848
-    // ----- Read the gzip file header
2849
-    $v_binary_data = @fread($v_file_compressed, 10);
2850
-    $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
2848
+	// ----- Read the gzip file header
2849
+	$v_binary_data = @fread($v_file_compressed, 10);
2850
+	$v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
2851 2851
 
2852
-    // ----- Check some parameters
2853
-    $v_data_header['os'] = bin2hex($v_data_header['os']);
2852
+	// ----- Check some parameters
2853
+	$v_data_header['os'] = bin2hex($v_data_header['os']);
2854 2854
 
2855
-    // ----- Read the gzip file footer
2856
-    @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
2857
-    $v_binary_data = @fread($v_file_compressed, 8);
2858
-    $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
2855
+	// ----- Read the gzip file footer
2856
+	@fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
2857
+	$v_binary_data = @fread($v_file_compressed, 8);
2858
+	$v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
2859 2859
 
2860
-    // ----- Set the attributes
2861
-    $p_header['compression'] = ord($v_data_header['cm']);
2862
-    //$p_header['mtime'] = $v_data_header['mtime'];
2863
-    $p_header['crc'] = $v_data_footer['crc'];
2864
-    $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
2860
+	// ----- Set the attributes
2861
+	$p_header['compression'] = ord($v_data_header['cm']);
2862
+	//$p_header['mtime'] = $v_data_header['mtime'];
2863
+	$p_header['crc'] = $v_data_footer['crc'];
2864
+	$p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
2865 2865
 
2866
-    // ----- Close the file
2867
-    @fclose($v_file_compressed);
2866
+	// ----- Close the file
2867
+	@fclose($v_file_compressed);
2868 2868
 
2869
-    // ----- Call the header generation
2870
-    if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2871
-      return $v_result;
2872
-    }
2869
+	// ----- Call the header generation
2870
+	if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2871
+	  return $v_result;
2872
+	}
2873 2873
 
2874
-    // ----- Add the compressed data
2875
-    if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
2876
-    {
2877
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2878
-      return PclZip::errorCode();
2879
-    }
2874
+	// ----- Add the compressed data
2875
+	if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
2876
+	{
2877
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2878
+	  return PclZip::errorCode();
2879
+	}
2880 2880
 
2881
-    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2882
-    fseek($v_file_compressed, 10);
2883
-    $v_size = $p_header['compressed_size'];
2884
-    while ($v_size != 0)
2885
-    {
2886
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2887
-      $v_buffer = @fread($v_file_compressed, $v_read_size);
2888
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2889
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2890
-      $v_size -= $v_read_size;
2891
-    }
2881
+	// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2882
+	fseek($v_file_compressed, 10);
2883
+	$v_size = $p_header['compressed_size'];
2884
+	while ($v_size != 0)
2885
+	{
2886
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2887
+	  $v_buffer = @fread($v_file_compressed, $v_read_size);
2888
+	  //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2889
+	  @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2890
+	  $v_size -= $v_read_size;
2891
+	}
2892 2892
 
2893
-    // ----- Close the file
2894
-    @fclose($v_file_compressed);
2893
+	// ----- Close the file
2894
+	@fclose($v_file_compressed);
2895 2895
 
2896
-    // ----- Unlink the temporary file
2897
-    @unlink($v_gzip_temp_name);
2896
+	// ----- Unlink the temporary file
2897
+	@unlink($v_gzip_temp_name);
2898 2898
 
2899
-    // ----- Return
2900
-    return $v_result;
2899
+	// ----- Return
2900
+	return $v_result;
2901 2901
   }
2902 2902
   // --------------------------------------------------------------------------------
2903 2903
 
@@ -2911,107 +2911,107 @@  discard block
 block discarded – undo
2911 2911
   // --------------------------------------------------------------------------------
2912 2912
   function privCalculateStoredFilename(&$p_filedescr, &$p_options)
2913 2913
   {
2914
-    $v_result=1;
2915
-
2916
-    // ----- Working variables
2917
-    $p_filename = $p_filedescr['filename'];
2918
-    if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
2919
-      $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2920
-    }
2921
-    else {
2922
-      $p_add_dir = '';
2923
-    }
2924
-    if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
2925
-      $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2926
-    }
2927
-    else {
2928
-      $p_remove_dir = '';
2929
-    }
2930
-    if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
2931
-      $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2932
-    }
2933
-    else {
2934
-      $p_remove_all_dir = 0;
2935
-    }
2914
+	$v_result=1;
2936 2915
 
2916
+	// ----- Working variables
2917
+	$p_filename = $p_filedescr['filename'];
2918
+	if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
2919
+	  $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2920
+	}
2921
+	else {
2922
+	  $p_add_dir = '';
2923
+	}
2924
+	if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
2925
+	  $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2926
+	}
2927
+	else {
2928
+	  $p_remove_dir = '';
2929
+	}
2930
+	if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
2931
+	  $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2932
+	}
2933
+	else {
2934
+	  $p_remove_all_dir = 0;
2935
+	}
2937 2936
 
2938
-    // ----- Look for full name change
2939
-    if (isset($p_filedescr['new_full_name'])) {
2940
-      // ----- Remove drive letter if any
2941
-      $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
2942
-    }
2943 2937
 
2944
-    // ----- Look for path and/or short name change
2945
-    else {
2938
+	// ----- Look for full name change
2939
+	if (isset($p_filedescr['new_full_name'])) {
2940
+	  // ----- Remove drive letter if any
2941
+	  $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
2942
+	}
2946 2943
 
2947
-      // ----- Look for short name change
2948
-      // Its when we cahnge just the filename but not the path
2949
-      if (isset($p_filedescr['new_short_name'])) {
2950
-        $v_path_info = pathinfo($p_filename);
2951
-        $v_dir = '';
2952
-        if ($v_path_info['dirname'] != '') {
2953
-          $v_dir = $v_path_info['dirname'].'/';
2954
-        }
2955
-        $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2956
-      }
2957
-      else {
2958
-        // ----- Calculate the stored filename
2959
-        $v_stored_filename = $p_filename;
2960
-      }
2944
+	// ----- Look for path and/or short name change
2945
+	else {
2946
+
2947
+	  // ----- Look for short name change
2948
+	  // Its when we cahnge just the filename but not the path
2949
+	  if (isset($p_filedescr['new_short_name'])) {
2950
+		$v_path_info = pathinfo($p_filename);
2951
+		$v_dir = '';
2952
+		if ($v_path_info['dirname'] != '') {
2953
+		  $v_dir = $v_path_info['dirname'].'/';
2954
+		}
2955
+		$v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2956
+	  }
2957
+	  else {
2958
+		// ----- Calculate the stored filename
2959
+		$v_stored_filename = $p_filename;
2960
+	  }
2961 2961
 
2962
-      // ----- Look for all path to remove
2963
-      if ($p_remove_all_dir) {
2964
-        $v_stored_filename = basename($p_filename);
2965
-      }
2966
-      // ----- Look for partial path remove
2967
-      else if ($p_remove_dir != "") {
2968
-        if (substr($p_remove_dir, -1) != '/')
2969
-          $p_remove_dir .= "/";
2962
+	  // ----- Look for all path to remove
2963
+	  if ($p_remove_all_dir) {
2964
+		$v_stored_filename = basename($p_filename);
2965
+	  }
2966
+	  // ----- Look for partial path remove
2967
+	  else if ($p_remove_dir != "") {
2968
+		if (substr($p_remove_dir, -1) != '/')
2969
+		  $p_remove_dir .= "/";
2970 2970
 
2971
-        if (   (substr($p_filename, 0, 2) == "./")
2972
-            || (substr($p_remove_dir, 0, 2) == "./")) {
2971
+		if (   (substr($p_filename, 0, 2) == "./")
2972
+			|| (substr($p_remove_dir, 0, 2) == "./")) {
2973 2973
 
2974
-          if (   (substr($p_filename, 0, 2) == "./")
2975
-              && (substr($p_remove_dir, 0, 2) != "./")) {
2976
-            $p_remove_dir = "./".$p_remove_dir;
2977
-          }
2978
-          if (   (substr($p_filename, 0, 2) != "./")
2979
-              && (substr($p_remove_dir, 0, 2) == "./")) {
2980
-            $p_remove_dir = substr($p_remove_dir, 2);
2981
-          }
2982
-        }
2974
+		  if (   (substr($p_filename, 0, 2) == "./")
2975
+			  && (substr($p_remove_dir, 0, 2) != "./")) {
2976
+			$p_remove_dir = "./".$p_remove_dir;
2977
+		  }
2978
+		  if (   (substr($p_filename, 0, 2) != "./")
2979
+			  && (substr($p_remove_dir, 0, 2) == "./")) {
2980
+			$p_remove_dir = substr($p_remove_dir, 2);
2981
+		  }
2982
+		}
2983 2983
 
2984
-        $v_compare = PclZipUtilPathInclusion($p_remove_dir,
2985
-                                             $v_stored_filename);
2986
-        if ($v_compare > 0) {
2987
-          if ($v_compare == 2) {
2988
-            $v_stored_filename = "";
2989
-          }
2990
-          else {
2991
-            $v_stored_filename = substr($v_stored_filename,
2992
-                                        strlen($p_remove_dir));
2993
-          }
2994
-        }
2995
-      }
2984
+		$v_compare = PclZipUtilPathInclusion($p_remove_dir,
2985
+											 $v_stored_filename);
2986
+		if ($v_compare > 0) {
2987
+		  if ($v_compare == 2) {
2988
+			$v_stored_filename = "";
2989
+		  }
2990
+		  else {
2991
+			$v_stored_filename = substr($v_stored_filename,
2992
+										strlen($p_remove_dir));
2993
+		  }
2994
+		}
2995
+	  }
2996 2996
 
2997
-      // ----- Remove drive letter if any
2998
-      $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
2997
+	  // ----- Remove drive letter if any
2998
+	  $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
2999 2999
 
3000
-      // ----- Look for path to add
3001
-      if ($p_add_dir != "") {
3002
-        if (substr($p_add_dir, -1) == "/")
3003
-          $v_stored_filename = $p_add_dir.$v_stored_filename;
3004
-        else
3005
-          $v_stored_filename = $p_add_dir."/".$v_stored_filename;
3006
-      }
3007
-    }
3000
+	  // ----- Look for path to add
3001
+	  if ($p_add_dir != "") {
3002
+		if (substr($p_add_dir, -1) == "/")
3003
+		  $v_stored_filename = $p_add_dir.$v_stored_filename;
3004
+		else
3005
+		  $v_stored_filename = $p_add_dir."/".$v_stored_filename;
3006
+	  }
3007
+	}
3008 3008
 
3009
-    // ----- Filename (reduce the path of stored name)
3010
-    $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
3011
-    $p_filedescr['stored_filename'] = $v_stored_filename;
3009
+	// ----- Filename (reduce the path of stored name)
3010
+	$v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
3011
+	$p_filedescr['stored_filename'] = $v_stored_filename;
3012 3012
 
3013
-    // ----- Return
3014
-    return $v_result;
3013
+	// ----- Return
3014
+	return $v_result;
3015 3015
   }
3016 3016
   // --------------------------------------------------------------------------------
3017 3017
 
@@ -3023,40 +3023,40 @@  discard block
 block discarded – undo
3023 3023
   // --------------------------------------------------------------------------------
3024 3024
   function privWriteFileHeader(&$p_header)
3025 3025
   {
3026
-    $v_result=1;
3026
+	$v_result=1;
3027 3027
 
3028
-    // ----- Store the offset position of the file
3029
-    $p_header['offset'] = ftell($this->zip_fd);
3028
+	// ----- Store the offset position of the file
3029
+	$p_header['offset'] = ftell($this->zip_fd);
3030 3030
 
3031
-    // ----- Transform UNIX mtime to DOS format mdate/mtime
3032
-    $v_date = getdate($p_header['mtime']);
3033
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3034
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3031
+	// ----- Transform UNIX mtime to DOS format mdate/mtime
3032
+	$v_date = getdate($p_header['mtime']);
3033
+	$v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3034
+	$v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3035 3035
 
3036
-    // ----- Packed data
3037
-    $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
3038
-	                      $p_header['version_extracted'], $p_header['flag'],
3039
-                          $p_header['compression'], $v_mtime, $v_mdate,
3040
-                          $p_header['crc'], $p_header['compressed_size'],
3036
+	// ----- Packed data
3037
+	$v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
3038
+						  $p_header['version_extracted'], $p_header['flag'],
3039
+						  $p_header['compression'], $v_mtime, $v_mdate,
3040
+						  $p_header['crc'], $p_header['compressed_size'],
3041 3041
 						  $p_header['size'],
3042
-                          strlen($p_header['stored_filename']),
3042
+						  strlen($p_header['stored_filename']),
3043 3043
 						  $p_header['extra_len']);
3044 3044
 
3045
-    // ----- Write the first 148 bytes of the header in the archive
3046
-    fputs($this->zip_fd, $v_binary_data, 30);
3045
+	// ----- Write the first 148 bytes of the header in the archive
3046
+	fputs($this->zip_fd, $v_binary_data, 30);
3047 3047
 
3048
-    // ----- Write the variable fields
3049
-    if (strlen($p_header['stored_filename']) != 0)
3050
-    {
3051
-      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3052
-    }
3053
-    if ($p_header['extra_len'] != 0)
3054
-    {
3055
-      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3056
-    }
3048
+	// ----- Write the variable fields
3049
+	if (strlen($p_header['stored_filename']) != 0)
3050
+	{
3051
+	  fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3052
+	}
3053
+	if ($p_header['extra_len'] != 0)
3054
+	{
3055
+	  fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3056
+	}
3057 3057
 
3058
-    // ----- Return
3059
-    return $v_result;
3058
+	// ----- Return
3059
+	return $v_result;
3060 3060
   }
3061 3061
   // --------------------------------------------------------------------------------
3062 3062
 
@@ -3068,48 +3068,48 @@  discard block
 block discarded – undo
3068 3068
   // --------------------------------------------------------------------------------
3069 3069
   function privWriteCentralFileHeader(&$p_header)
3070 3070
   {
3071
-    $v_result=1;
3071
+	$v_result=1;
3072 3072
 
3073
-    // TBC
3074
-    //for(reset($p_header); $key = key($p_header); next($p_header)) {
3075
-    //}
3073
+	// TBC
3074
+	//for(reset($p_header); $key = key($p_header); next($p_header)) {
3075
+	//}
3076 3076
 
3077
-    // ----- Transform UNIX mtime to DOS format mdate/mtime
3078
-    $v_date = getdate($p_header['mtime']);
3079
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3080
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3077
+	// ----- Transform UNIX mtime to DOS format mdate/mtime
3078
+	$v_date = getdate($p_header['mtime']);
3079
+	$v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3080
+	$v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3081 3081
 
3082 3082
 
3083
-    // ----- Packed data
3084
-    $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
3085
-	                      $p_header['version'], $p_header['version_extracted'],
3086
-                          $p_header['flag'], $p_header['compression'],
3083
+	// ----- Packed data
3084
+	$v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
3085
+						  $p_header['version'], $p_header['version_extracted'],
3086
+						  $p_header['flag'], $p_header['compression'],
3087 3087
 						  $v_mtime, $v_mdate, $p_header['crc'],
3088
-                          $p_header['compressed_size'], $p_header['size'],
3089
-                          strlen($p_header['stored_filename']),
3088
+						  $p_header['compressed_size'], $p_header['size'],
3089
+						  strlen($p_header['stored_filename']),
3090 3090
 						  $p_header['extra_len'], $p_header['comment_len'],
3091
-                          $p_header['disk'], $p_header['internal'],
3091
+						  $p_header['disk'], $p_header['internal'],
3092 3092
 						  $p_header['external'], $p_header['offset']);
3093 3093
 
3094
-    // ----- Write the 42 bytes of the header in the zip file
3095
-    fputs($this->zip_fd, $v_binary_data, 46);
3094
+	// ----- Write the 42 bytes of the header in the zip file
3095
+	fputs($this->zip_fd, $v_binary_data, 46);
3096 3096
 
3097
-    // ----- Write the variable fields
3098
-    if (strlen($p_header['stored_filename']) != 0)
3099
-    {
3100
-      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3101
-    }
3102
-    if ($p_header['extra_len'] != 0)
3103
-    {
3104
-      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3105
-    }
3106
-    if ($p_header['comment_len'] != 0)
3107
-    {
3108
-      fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
3109
-    }
3097
+	// ----- Write the variable fields
3098
+	if (strlen($p_header['stored_filename']) != 0)
3099
+	{
3100
+	  fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3101
+	}
3102
+	if ($p_header['extra_len'] != 0)
3103
+	{
3104
+	  fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3105
+	}
3106
+	if ($p_header['comment_len'] != 0)
3107
+	{
3108
+	  fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
3109
+	}
3110 3110
 
3111
-    // ----- Return
3112
-    return $v_result;
3111
+	// ----- Return
3112
+	return $v_result;
3113 3113
   }
3114 3114
   // --------------------------------------------------------------------------------
3115 3115
 
@@ -3121,24 +3121,24 @@  discard block
 block discarded – undo
3121 3121
   // --------------------------------------------------------------------------------
3122 3122
   function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
3123 3123
   {
3124
-    $v_result=1;
3124
+	$v_result=1;
3125 3125
 
3126
-    // ----- Packed data
3127
-    $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
3128
-	                      $p_nb_entries, $p_size,
3126
+	// ----- Packed data
3127
+	$v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
3128
+						  $p_nb_entries, $p_size,
3129 3129
 						  $p_offset, strlen($p_comment));
3130 3130
 
3131
-    // ----- Write the 22 bytes of the header in the zip file
3132
-    fputs($this->zip_fd, $v_binary_data, 22);
3131
+	// ----- Write the 22 bytes of the header in the zip file
3132
+	fputs($this->zip_fd, $v_binary_data, 22);
3133 3133
 
3134
-    // ----- Write the variable fields
3135
-    if (strlen($p_comment) != 0)
3136
-    {
3137
-      fputs($this->zip_fd, $p_comment, strlen($p_comment));
3138
-    }
3134
+	// ----- Write the variable fields
3135
+	if (strlen($p_comment) != 0)
3136
+	{
3137
+	  fputs($this->zip_fd, $p_comment, strlen($p_comment));
3138
+	}
3139 3139
 
3140
-    // ----- Return
3141
-    return $v_result;
3140
+	// ----- Return
3141
+	return $v_result;
3142 3142
   }
3143 3143
   // --------------------------------------------------------------------------------
3144 3144
 
@@ -3150,69 +3150,69 @@  discard block
 block discarded – undo
3150 3150
   // --------------------------------------------------------------------------------
3151 3151
   function privList(&$p_list)
3152 3152
   {
3153
-    $v_result=1;
3153
+	$v_result=1;
3154 3154
 
3155
-    // ----- Magic quotes trick
3156
-    $this->privDisableMagicQuotes();
3155
+	// ----- Magic quotes trick
3156
+	$this->privDisableMagicQuotes();
3157 3157
 
3158
-    // ----- Open the zip file
3159
-    if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
3160
-    {
3161
-      // ----- Magic quotes trick
3162
-      $this->privSwapBackMagicQuotes();
3158
+	// ----- Open the zip file
3159
+	if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
3160
+	{
3161
+	  // ----- Magic quotes trick
3162
+	  $this->privSwapBackMagicQuotes();
3163 3163
 
3164
-      // ----- Error log
3165
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3164
+	  // ----- Error log
3165
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3166 3166
 
3167
-      // ----- Return
3168
-      return PclZip::errorCode();
3169
-    }
3167
+	  // ----- Return
3168
+	  return PclZip::errorCode();
3169
+	}
3170 3170
 
3171
-    // ----- Read the central directory informations
3172
-    $v_central_dir = array();
3173
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3174
-    {
3175
-      $this->privSwapBackMagicQuotes();
3176
-      return $v_result;
3177
-    }
3171
+	// ----- Read the central directory informations
3172
+	$v_central_dir = array();
3173
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3174
+	{
3175
+	  $this->privSwapBackMagicQuotes();
3176
+	  return $v_result;
3177
+	}
3178 3178
 
3179
-    // ----- Go to beginning of Central Dir
3180
-    @rewind($this->zip_fd);
3181
-    if (@fseek($this->zip_fd, $v_central_dir['offset']))
3182
-    {
3183
-      $this->privSwapBackMagicQuotes();
3179
+	// ----- Go to beginning of Central Dir
3180
+	@rewind($this->zip_fd);
3181
+	if (@fseek($this->zip_fd, $v_central_dir['offset']))
3182
+	{
3183
+	  $this->privSwapBackMagicQuotes();
3184 3184
 
3185
-      // ----- Error log
3186
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3185
+	  // ----- Error log
3186
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3187 3187
 
3188
-      // ----- Return
3189
-      return PclZip::errorCode();
3190
-    }
3188
+	  // ----- Return
3189
+	  return PclZip::errorCode();
3190
+	}
3191 3191
 
3192
-    // ----- Read each entry
3193
-    for ($i=0; $i<$v_central_dir['entries']; $i++)
3194
-    {
3195
-      // ----- Read the file header
3196
-      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3197
-      {
3198
-        $this->privSwapBackMagicQuotes();
3199
-        return $v_result;
3200
-      }
3201
-      $v_header['index'] = $i;
3192
+	// ----- Read each entry
3193
+	for ($i=0; $i<$v_central_dir['entries']; $i++)
3194
+	{
3195
+	  // ----- Read the file header
3196
+	  if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3197
+	  {
3198
+		$this->privSwapBackMagicQuotes();
3199
+		return $v_result;
3200
+	  }
3201
+	  $v_header['index'] = $i;
3202 3202
 
3203
-      // ----- Get the only interesting attributes
3204
-      $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
3205
-      unset($v_header);
3206
-    }
3203
+	  // ----- Get the only interesting attributes
3204
+	  $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
3205
+	  unset($v_header);
3206
+	}
3207 3207
 
3208
-    // ----- Close the zip file
3209
-    $this->privCloseFd();
3208
+	// ----- Close the zip file
3209
+	$this->privCloseFd();
3210 3210
 
3211
-    // ----- Magic quotes trick
3212
-    $this->privSwapBackMagicQuotes();
3211
+	// ----- Magic quotes trick
3212
+	$this->privSwapBackMagicQuotes();
3213 3213
 
3214
-    // ----- Return
3215
-    return $v_result;
3214
+	// ----- Return
3215
+	return $v_result;
3216 3216
   }
3217 3217
   // --------------------------------------------------------------------------------
3218 3218
 
@@ -3237,24 +3237,24 @@  discard block
 block discarded – undo
3237 3237
   // --------------------------------------------------------------------------------
3238 3238
   function privConvertHeader2FileInfo($p_header, &$p_info)
3239 3239
   {
3240
-    $v_result=1;
3241
-
3242
-    // ----- Get the interesting attributes
3243
-    $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
3244
-    $p_info['filename'] = $v_temp_path;
3245
-    $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
3246
-    $p_info['stored_filename'] = $v_temp_path;
3247
-    $p_info['size'] = $p_header['size'];
3248
-    $p_info['compressed_size'] = $p_header['compressed_size'];
3249
-    $p_info['mtime'] = $p_header['mtime'];
3250
-    $p_info['comment'] = $p_header['comment'];
3251
-    $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
3252
-    $p_info['index'] = $p_header['index'];
3253
-    $p_info['status'] = $p_header['status'];
3254
-    $p_info['crc'] = $p_header['crc'];
3255
-
3256
-    // ----- Return
3257
-    return $v_result;
3240
+	$v_result=1;
3241
+
3242
+	// ----- Get the interesting attributes
3243
+	$v_temp_path = PclZipUtilPathReduction($p_header['filename']);
3244
+	$p_info['filename'] = $v_temp_path;
3245
+	$v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
3246
+	$p_info['stored_filename'] = $v_temp_path;
3247
+	$p_info['size'] = $p_header['size'];
3248
+	$p_info['compressed_size'] = $p_header['compressed_size'];
3249
+	$p_info['mtime'] = $p_header['mtime'];
3250
+	$p_info['comment'] = $p_header['comment'];
3251
+	$p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
3252
+	$p_info['index'] = $p_header['index'];
3253
+	$p_info['status'] = $p_header['status'];
3254
+	$p_info['crc'] = $p_header['crc'];
3255
+
3256
+	// ----- Return
3257
+	return $v_result;
3258 3258
   }
3259 3259
   // --------------------------------------------------------------------------------
3260 3260
 
@@ -3276,122 +3276,122 @@  discard block
 block discarded – undo
3276 3276
   // --------------------------------------------------------------------------------
3277 3277
   function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3278 3278
   {
3279
-    $v_result=1;
3279
+	$v_result=1;
3280 3280
 
3281
-    // ----- Magic quotes trick
3282
-    $this->privDisableMagicQuotes();
3281
+	// ----- Magic quotes trick
3282
+	$this->privDisableMagicQuotes();
3283 3283
 
3284
-    // ----- Check the path
3285
-    if (   ($p_path == "")
3286
-	    || (   (substr($p_path, 0, 1) != "/")
3287
-		    && (substr($p_path, 0, 3) != "../")
3284
+	// ----- Check the path
3285
+	if (   ($p_path == "")
3286
+		|| (   (substr($p_path, 0, 1) != "/")
3287
+			&& (substr($p_path, 0, 3) != "../")
3288 3288
 			&& (substr($p_path,1,2)!=":/")))
3289
-      $p_path = "./".$p_path;
3290
-
3291
-    // ----- Reduce the path last (and duplicated) '/'
3292
-    if (($p_path != "./") && ($p_path != "/"))
3293
-    {
3294
-      // ----- Look for the path end '/'
3295
-      while (substr($p_path, -1) == "/")
3296
-      {
3297
-        $p_path = substr($p_path, 0, strlen($p_path)-1);
3298
-      }
3299
-    }
3289
+	  $p_path = "./".$p_path;
3290
+
3291
+	// ----- Reduce the path last (and duplicated) '/'
3292
+	if (($p_path != "./") && ($p_path != "/"))
3293
+	{
3294
+	  // ----- Look for the path end '/'
3295
+	  while (substr($p_path, -1) == "/")
3296
+	  {
3297
+		$p_path = substr($p_path, 0, strlen($p_path)-1);
3298
+	  }
3299
+	}
3300 3300
 
3301
-    // ----- Look for path to remove format (should end by /)
3302
-    if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
3303
-    {
3304
-      $p_remove_path .= '/';
3305
-    }
3306
-    $p_remove_path_size = strlen($p_remove_path);
3301
+	// ----- Look for path to remove format (should end by /)
3302
+	if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
3303
+	{
3304
+	  $p_remove_path .= '/';
3305
+	}
3306
+	$p_remove_path_size = strlen($p_remove_path);
3307 3307
 
3308
-    // ----- Open the zip file
3309
-    if (($v_result = $this->privOpenFd('rb')) != 1)
3310
-    {
3311
-      $this->privSwapBackMagicQuotes();
3312
-      return $v_result;
3313
-    }
3308
+	// ----- Open the zip file
3309
+	if (($v_result = $this->privOpenFd('rb')) != 1)
3310
+	{
3311
+	  $this->privSwapBackMagicQuotes();
3312
+	  return $v_result;
3313
+	}
3314 3314
 
3315
-    // ----- Read the central directory informations
3316
-    $v_central_dir = array();
3317
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3318
-    {
3319
-      // ----- Close the zip file
3320
-      $this->privCloseFd();
3321
-      $this->privSwapBackMagicQuotes();
3315
+	// ----- Read the central directory informations
3316
+	$v_central_dir = array();
3317
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3318
+	{
3319
+	  // ----- Close the zip file
3320
+	  $this->privCloseFd();
3321
+	  $this->privSwapBackMagicQuotes();
3322 3322
 
3323
-      return $v_result;
3324
-    }
3323
+	  return $v_result;
3324
+	}
3325 3325
 
3326
-    // ----- Start at beginning of Central Dir
3327
-    $v_pos_entry = $v_central_dir['offset'];
3326
+	// ----- Start at beginning of Central Dir
3327
+	$v_pos_entry = $v_central_dir['offset'];
3328 3328
 
3329
-    // ----- Read each entry
3330
-    $j_start = 0;
3331
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3332
-    {
3329
+	// ----- Read each entry
3330
+	$j_start = 0;
3331
+	for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3332
+	{
3333 3333
 
3334
-      // ----- Read next Central dir entry
3335
-      @rewind($this->zip_fd);
3336
-      if (@fseek($this->zip_fd, $v_pos_entry))
3337
-      {
3338
-        // ----- Close the zip file
3339
-        $this->privCloseFd();
3340
-        $this->privSwapBackMagicQuotes();
3334
+	  // ----- Read next Central dir entry
3335
+	  @rewind($this->zip_fd);
3336
+	  if (@fseek($this->zip_fd, $v_pos_entry))
3337
+	  {
3338
+		// ----- Close the zip file
3339
+		$this->privCloseFd();
3340
+		$this->privSwapBackMagicQuotes();
3341 3341
 
3342
-        // ----- Error log
3343
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3342
+		// ----- Error log
3343
+		PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3344 3344
 
3345
-        // ----- Return
3346
-        return PclZip::errorCode();
3347
-      }
3345
+		// ----- Return
3346
+		return PclZip::errorCode();
3347
+	  }
3348 3348
 
3349
-      // ----- Read the file header
3350
-      $v_header = array();
3351
-      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3352
-      {
3353
-        // ----- Close the zip file
3354
-        $this->privCloseFd();
3355
-        $this->privSwapBackMagicQuotes();
3349
+	  // ----- Read the file header
3350
+	  $v_header = array();
3351
+	  if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3352
+	  {
3353
+		// ----- Close the zip file
3354
+		$this->privCloseFd();
3355
+		$this->privSwapBackMagicQuotes();
3356 3356
 
3357
-        return $v_result;
3358
-      }
3357
+		return $v_result;
3358
+	  }
3359 3359
 
3360
-      // ----- Store the index
3361
-      $v_header['index'] = $i;
3360
+	  // ----- Store the index
3361
+	  $v_header['index'] = $i;
3362 3362
 
3363
-      // ----- Store the file position
3364
-      $v_pos_entry = ftell($this->zip_fd);
3363
+	  // ----- Store the file position
3364
+	  $v_pos_entry = ftell($this->zip_fd);
3365 3365
 
3366
-      // ----- Look for the specific extract rules
3367
-      $v_extract = false;
3366
+	  // ----- Look for the specific extract rules
3367
+	  $v_extract = false;
3368 3368
 
3369
-      // ----- Look for extract by name rule
3370
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
3371
-          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3369
+	  // ----- Look for extract by name rule
3370
+	  if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
3371
+		  && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3372 3372
 
3373
-          // ----- Look if the filename is in the list
3374
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3373
+		  // ----- Look if the filename is in the list
3374
+		  for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3375 3375
 
3376
-              // ----- Look for a directory
3377
-              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3376
+			  // ----- Look for a directory
3377
+			  if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3378 3378
 
3379
-                  // ----- Look if the directory is in the filename path
3380
-                  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3381
-                      && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3382
-                      $v_extract = true;
3383
-                  }
3384
-              }
3385
-              // ----- Look for a filename
3386
-              elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
3387
-                  $v_extract = true;
3388
-              }
3389
-          }
3390
-      }
3379
+				  // ----- Look if the directory is in the filename path
3380
+				  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3381
+					  && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3382
+					  $v_extract = true;
3383
+				  }
3384
+			  }
3385
+			  // ----- Look for a filename
3386
+			  elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
3387
+				  $v_extract = true;
3388
+			  }
3389
+		  }
3390
+	  }
3391 3391
 
3392
-      // ----- Look for extract by ereg rule
3393
-      // ereg() is deprecated with PHP 5.3
3394
-      /*
3392
+	  // ----- Look for extract by ereg rule
3393
+	  // ereg() is deprecated with PHP 5.3
3394
+	  /*
3395 3395
       else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
3396 3396
                && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
3397 3397
 
@@ -3401,207 +3401,207 @@  discard block
 block discarded – undo
3401 3401
       }
3402 3402
       */
3403 3403
 
3404
-      // ----- Look for extract by preg rule
3405
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
3406
-               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3404
+	  // ----- Look for extract by preg rule
3405
+	  else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
3406
+			   && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3407 3407
 
3408
-          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
3409
-              $v_extract = true;
3410
-          }
3411
-      }
3408
+		  if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
3409
+			  $v_extract = true;
3410
+		  }
3411
+	  }
3412 3412
 
3413
-      // ----- Look for extract by index rule
3414
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3415
-               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3413
+	  // ----- Look for extract by index rule
3414
+	  else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3415
+			   && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3416 3416
 
3417
-          // ----- Look if the index is in the list
3418
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3417
+		  // ----- Look if the index is in the list
3418
+		  for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3419 3419
 
3420
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3421
-                  $v_extract = true;
3422
-              }
3423
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3424
-                  $j_start = $j+1;
3425
-              }
3420
+			  if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3421
+				  $v_extract = true;
3422
+			  }
3423
+			  if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3424
+				  $j_start = $j+1;
3425
+			  }
3426 3426
 
3427
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3428
-                  break;
3429
-              }
3430
-          }
3431
-      }
3427
+			  if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3428
+				  break;
3429
+			  }
3430
+		  }
3431
+	  }
3432 3432
 
3433
-      // ----- Look for no rule, which means extract all the archive
3434
-      else {
3435
-          $v_extract = true;
3436
-      }
3433
+	  // ----- Look for no rule, which means extract all the archive
3434
+	  else {
3435
+		  $v_extract = true;
3436
+	  }
3437 3437
 
3438 3438
 	  // ----- Check compression method
3439 3439
 	  if (   ($v_extract)
3440
-	      && (   ($v_header['compression'] != 8)
3441
-		      && ($v_header['compression'] != 0))) {
3442
-          $v_header['status'] = 'unsupported_compression';
3440
+		  && (   ($v_header['compression'] != 8)
3441
+			  && ($v_header['compression'] != 0))) {
3442
+		  $v_header['status'] = 'unsupported_compression';
3443 3443
 
3444
-          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3445
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3446
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3444
+		  // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3445
+		  if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3446
+			  && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3447 3447
 
3448
-              $this->privSwapBackMagicQuotes();
3448
+			  $this->privSwapBackMagicQuotes();
3449 3449
 
3450
-              PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3451
-			                       "Filename '".$v_header['stored_filename']."' is "
3452
-				  	    	  	   ."compressed by an unsupported compression "
3453
-				  	    	  	   ."method (".$v_header['compression'].") ");
3450
+			  PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3451
+								   "Filename '".$v_header['stored_filename']."' is "
3452
+				  			  	   ."compressed by an unsupported compression "
3453
+				  			  	   ."method (".$v_header['compression'].") ");
3454 3454
 
3455
-              return PclZip::errorCode();
3455
+			  return PclZip::errorCode();
3456 3456
 		  }
3457 3457
 	  }
3458 3458
 
3459 3459
 	  // ----- Check encrypted files
3460 3460
 	  if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
3461
-          $v_header['status'] = 'unsupported_encryption';
3461
+		  $v_header['status'] = 'unsupported_encryption';
3462 3462
 
3463
-          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3464
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3465
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3463
+		  // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3464
+		  if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3465
+			  && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3466 3466
 
3467
-              $this->privSwapBackMagicQuotes();
3467
+			  $this->privSwapBackMagicQuotes();
3468 3468
 
3469
-              PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3470
-			                       "Unsupported encryption for "
3471
-				  	    	  	   ." filename '".$v_header['stored_filename']
3469
+			  PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3470
+								   "Unsupported encryption for "
3471
+				  			  	   ." filename '".$v_header['stored_filename']
3472 3472
 								   ."'");
3473 3473
 
3474
-              return PclZip::errorCode();
3474
+			  return PclZip::errorCode();
3475 3475
 		  }
3476
-    }
3476
+	}
3477 3477
 
3478
-      // ----- Look for real extraction
3479
-      if (($v_extract) && ($v_header['status'] != 'ok')) {
3480
-          $v_result = $this->privConvertHeader2FileInfo($v_header,
3481
-		                                        $p_file_list[$v_nb_extracted++]);
3482
-          if ($v_result != 1) {
3483
-              $this->privCloseFd();
3484
-              $this->privSwapBackMagicQuotes();
3485
-              return $v_result;
3486
-          }
3478
+	  // ----- Look for real extraction
3479
+	  if (($v_extract) && ($v_header['status'] != 'ok')) {
3480
+		  $v_result = $this->privConvertHeader2FileInfo($v_header,
3481
+												$p_file_list[$v_nb_extracted++]);
3482
+		  if ($v_result != 1) {
3483
+			  $this->privCloseFd();
3484
+			  $this->privSwapBackMagicQuotes();
3485
+			  return $v_result;
3486
+		  }
3487 3487
 
3488
-          $v_extract = false;
3489
-      }
3488
+		  $v_extract = false;
3489
+	  }
3490 3490
 
3491
-      // ----- Look for real extraction
3492
-      if ($v_extract)
3493
-      {
3491
+	  // ----- Look for real extraction
3492
+	  if ($v_extract)
3493
+	  {
3494 3494
 
3495
-        // ----- Go to the file position
3496
-        @rewind($this->zip_fd);
3497
-        if (@fseek($this->zip_fd, $v_header['offset']))
3498
-        {
3499
-          // ----- Close the zip file
3500
-          $this->privCloseFd();
3495
+		// ----- Go to the file position
3496
+		@rewind($this->zip_fd);
3497
+		if (@fseek($this->zip_fd, $v_header['offset']))
3498
+		{
3499
+		  // ----- Close the zip file
3500
+		  $this->privCloseFd();
3501 3501
 
3502
-          $this->privSwapBackMagicQuotes();
3502
+		  $this->privSwapBackMagicQuotes();
3503 3503
 
3504
-          // ----- Error log
3505
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3504
+		  // ----- Error log
3505
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3506 3506
 
3507
-          // ----- Return
3508
-          return PclZip::errorCode();
3509
-        }
3507
+		  // ----- Return
3508
+		  return PclZip::errorCode();
3509
+		}
3510 3510
 
3511
-        // ----- Look for extraction as string
3512
-        if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
3511
+		// ----- Look for extraction as string
3512
+		if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
3513 3513
 
3514
-          $v_string = '';
3514
+		  $v_string = '';
3515 3515
 
3516
-          // ----- Extracting the file
3517
-          $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
3518
-          if ($v_result1 < 1) {
3519
-            $this->privCloseFd();
3520
-            $this->privSwapBackMagicQuotes();
3521
-            return $v_result1;
3522
-          }
3516
+		  // ----- Extracting the file
3517
+		  $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
3518
+		  if ($v_result1 < 1) {
3519
+			$this->privCloseFd();
3520
+			$this->privSwapBackMagicQuotes();
3521
+			return $v_result1;
3522
+		  }
3523 3523
 
3524
-          // ----- Get the only interesting attributes
3525
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
3526
-          {
3527
-            // ----- Close the zip file
3528
-            $this->privCloseFd();
3529
-            $this->privSwapBackMagicQuotes();
3524
+		  // ----- Get the only interesting attributes
3525
+		  if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
3526
+		  {
3527
+			// ----- Close the zip file
3528
+			$this->privCloseFd();
3529
+			$this->privSwapBackMagicQuotes();
3530 3530
 
3531
-            return $v_result;
3532
-          }
3531
+			return $v_result;
3532
+		  }
3533 3533
 
3534
-          // ----- Set the file content
3535
-          $p_file_list[$v_nb_extracted]['content'] = $v_string;
3534
+		  // ----- Set the file content
3535
+		  $p_file_list[$v_nb_extracted]['content'] = $v_string;
3536 3536
 
3537
-          // ----- Next extracted file
3538
-          $v_nb_extracted++;
3537
+		  // ----- Next extracted file
3538
+		  $v_nb_extracted++;
3539 3539
 
3540
-          // ----- Look for user callback abort
3541
-          if ($v_result1 == 2) {
3542
-          	break;
3543
-          }
3544
-        }
3545
-        // ----- Look for extraction in standard output
3546
-        elseif (   (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3547
-		        && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3548
-          // ----- Extracting the file in standard output
3549
-          $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
3550
-          if ($v_result1 < 1) {
3551
-            $this->privCloseFd();
3552
-            $this->privSwapBackMagicQuotes();
3553
-            return $v_result1;
3554
-          }
3540
+		  // ----- Look for user callback abort
3541
+		  if ($v_result1 == 2) {
3542
+		  	break;
3543
+		  }
3544
+		}
3545
+		// ----- Look for extraction in standard output
3546
+		elseif (   (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3547
+				&& ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3548
+		  // ----- Extracting the file in standard output
3549
+		  $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
3550
+		  if ($v_result1 < 1) {
3551
+			$this->privCloseFd();
3552
+			$this->privSwapBackMagicQuotes();
3553
+			return $v_result1;
3554
+		  }
3555 3555
 
3556
-          // ----- Get the only interesting attributes
3557
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
3558
-            $this->privCloseFd();
3559
-            $this->privSwapBackMagicQuotes();
3560
-            return $v_result;
3561
-          }
3556
+		  // ----- Get the only interesting attributes
3557
+		  if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
3558
+			$this->privCloseFd();
3559
+			$this->privSwapBackMagicQuotes();
3560
+			return $v_result;
3561
+		  }
3562 3562
 
3563
-          // ----- Look for user callback abort
3564
-          if ($v_result1 == 2) {
3565
-          	break;
3566
-          }
3567
-        }
3568
-        // ----- Look for normal extraction
3569
-        else {
3570
-          // ----- Extracting the file
3571
-          $v_result1 = $this->privExtractFile($v_header,
3572
-		                                      $p_path, $p_remove_path,
3563
+		  // ----- Look for user callback abort
3564
+		  if ($v_result1 == 2) {
3565
+		  	break;
3566
+		  }
3567
+		}
3568
+		// ----- Look for normal extraction
3569
+		else {
3570
+		  // ----- Extracting the file
3571
+		  $v_result1 = $this->privExtractFile($v_header,
3572
+											  $p_path, $p_remove_path,
3573 3573
 											  $p_remove_all_path,
3574 3574
 											  $p_options);
3575
-          if ($v_result1 < 1) {
3576
-            $this->privCloseFd();
3577
-            $this->privSwapBackMagicQuotes();
3578
-            return $v_result1;
3579
-          }
3575
+		  if ($v_result1 < 1) {
3576
+			$this->privCloseFd();
3577
+			$this->privSwapBackMagicQuotes();
3578
+			return $v_result1;
3579
+		  }
3580 3580
 
3581
-          // ----- Get the only interesting attributes
3582
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
3583
-          {
3584
-            // ----- Close the zip file
3585
-            $this->privCloseFd();
3586
-            $this->privSwapBackMagicQuotes();
3581
+		  // ----- Get the only interesting attributes
3582
+		  if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
3583
+		  {
3584
+			// ----- Close the zip file
3585
+			$this->privCloseFd();
3586
+			$this->privSwapBackMagicQuotes();
3587 3587
 
3588
-            return $v_result;
3589
-          }
3588
+			return $v_result;
3589
+		  }
3590 3590
 
3591
-          // ----- Look for user callback abort
3592
-          if ($v_result1 == 2) {
3593
-          	break;
3594
-          }
3595
-        }
3596
-      }
3597
-    }
3591
+		  // ----- Look for user callback abort
3592
+		  if ($v_result1 == 2) {
3593
+		  	break;
3594
+		  }
3595
+		}
3596
+	  }
3597
+	}
3598 3598
 
3599
-    // ----- Close the zip file
3600
-    $this->privCloseFd();
3601
-    $this->privSwapBackMagicQuotes();
3599
+	// ----- Close the zip file
3600
+	$this->privCloseFd();
3601
+	$this->privSwapBackMagicQuotes();
3602 3602
 
3603
-    // ----- Return
3604
-    return $v_result;
3603
+	// ----- Return
3604
+	return $v_result;
3605 3605
   }
3606 3606
   // --------------------------------------------------------------------------------
3607 3607
 
@@ -3616,344 +3616,344 @@  discard block
 block discarded – undo
3616 3616
   // --------------------------------------------------------------------------------
3617 3617
   function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3618 3618
   {
3619
-    $v_result=1;
3619
+	$v_result=1;
3620 3620
 
3621
-    // ----- Read the file header
3622
-    if (($v_result = $this->privReadFileHeader($v_header)) != 1)
3623
-    {
3624
-      // ----- Return
3625
-      return $v_result;
3626
-    }
3621
+	// ----- Read the file header
3622
+	if (($v_result = $this->privReadFileHeader($v_header)) != 1)
3623
+	{
3624
+	  // ----- Return
3625
+	  return $v_result;
3626
+	}
3627 3627
 
3628 3628
 
3629
-    // ----- Check that the file header is coherent with $p_entry info
3630
-    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
3631
-        // TBC
3632
-    }
3629
+	// ----- Check that the file header is coherent with $p_entry info
3630
+	if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
3631
+		// TBC
3632
+	}
3633 3633
 
3634
-    // ----- Look for all path to remove
3635
-    if ($p_remove_all_path == true) {
3636
-        // ----- Look for folder entry that not need to be extracted
3637
-        if (($p_entry['external']&0x00000010)==0x00000010) {
3634
+	// ----- Look for all path to remove
3635
+	if ($p_remove_all_path == true) {
3636
+		// ----- Look for folder entry that not need to be extracted
3637
+		if (($p_entry['external']&0x00000010)==0x00000010) {
3638 3638
 
3639
-            $p_entry['status'] = "filtered";
3639
+			$p_entry['status'] = "filtered";
3640 3640
 
3641
-            return $v_result;
3642
-        }
3641
+			return $v_result;
3642
+		}
3643 3643
 
3644
-        // ----- Get the basename of the path
3645
-        $p_entry['filename'] = basename($p_entry['filename']);
3646
-    }
3644
+		// ----- Get the basename of the path
3645
+		$p_entry['filename'] = basename($p_entry['filename']);
3646
+	}
3647 3647
 
3648
-    // ----- Look for path to remove
3649
-    else if ($p_remove_path != "")
3650
-    {
3651
-      if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
3652
-      {
3648
+	// ----- Look for path to remove
3649
+	else if ($p_remove_path != "")
3650
+	{
3651
+	  if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
3652
+	  {
3653 3653
 
3654
-        // ----- Change the file status
3655
-        $p_entry['status'] = "filtered";
3654
+		// ----- Change the file status
3655
+		$p_entry['status'] = "filtered";
3656 3656
 
3657
-        // ----- Return
3658
-        return $v_result;
3659
-      }
3657
+		// ----- Return
3658
+		return $v_result;
3659
+	  }
3660 3660
 
3661
-      $p_remove_path_size = strlen($p_remove_path);
3662
-      if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
3663
-      {
3661
+	  $p_remove_path_size = strlen($p_remove_path);
3662
+	  if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
3663
+	  {
3664 3664
 
3665
-        // ----- Remove the path
3666
-        $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
3665
+		// ----- Remove the path
3666
+		$p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
3667 3667
 
3668
-      }
3669
-    }
3668
+	  }
3669
+	}
3670 3670
 
3671
-    // ----- Add the path
3672
-    if ($p_path != '') {
3673
-      $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3674
-    }
3671
+	// ----- Add the path
3672
+	if ($p_path != '') {
3673
+	  $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3674
+	}
3675 3675
 
3676
-    // ----- Check a base_dir_restriction
3677
-    if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
3678
-      $v_inclusion
3679
-      = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
3680
-                                $p_entry['filename']);
3681
-      if ($v_inclusion == 0) {
3676
+	// ----- Check a base_dir_restriction
3677
+	if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
3678
+	  $v_inclusion
3679
+	  = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
3680
+								$p_entry['filename']);
3681
+	  if ($v_inclusion == 0) {
3682 3682
 
3683
-        PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
3684
-			                     "Filename '".$p_entry['filename']."' is "
3683
+		PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
3684
+								 "Filename '".$p_entry['filename']."' is "
3685 3685
 								 ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
3686 3686
 
3687
-        return PclZip::errorCode();
3688
-      }
3689
-    }
3687
+		return PclZip::errorCode();
3688
+	  }
3689
+	}
3690 3690
 
3691
-    // ----- Look for pre-extract callback
3692
-    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3693
-
3694
-      // ----- Generate a local information
3695
-      $v_local_header = array();
3696
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3697
-
3698
-      // ----- Call the callback
3699
-      // Here I do not use call_user_func() because I need to send a reference to the
3700
-      // header.
3701
-      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3702
-      if ($v_result == 0) {
3703
-        // ----- Change the file status
3704
-        $p_entry['status'] = "skipped";
3705
-        $v_result = 1;
3706
-      }
3691
+	// ----- Look for pre-extract callback
3692
+	if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3693
+
3694
+	  // ----- Generate a local information
3695
+	  $v_local_header = array();
3696
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3697
+
3698
+	  // ----- Call the callback
3699
+	  // Here I do not use call_user_func() because I need to send a reference to the
3700
+	  // header.
3701
+	  $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3702
+	  if ($v_result == 0) {
3703
+		// ----- Change the file status
3704
+		$p_entry['status'] = "skipped";
3705
+		$v_result = 1;
3706
+	  }
3707 3707
 
3708
-      // ----- Look for abort result
3709
-      if ($v_result == 2) {
3710
-        // ----- This status is internal and will be changed in 'skipped'
3711
-        $p_entry['status'] = "aborted";
3712
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
3713
-      }
3708
+	  // ----- Look for abort result
3709
+	  if ($v_result == 2) {
3710
+		// ----- This status is internal and will be changed in 'skipped'
3711
+		$p_entry['status'] = "aborted";
3712
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
3713
+	  }
3714 3714
 
3715
-      // ----- Update the informations
3716
-      // Only some fields can be modified
3717
-      $p_entry['filename'] = $v_local_header['filename'];
3718
-    }
3715
+	  // ----- Update the informations
3716
+	  // Only some fields can be modified
3717
+	  $p_entry['filename'] = $v_local_header['filename'];
3718
+	}
3719 3719
 
3720 3720
 
3721
-    // ----- Look if extraction should be done
3722
-    if ($p_entry['status'] == 'ok') {
3721
+	// ----- Look if extraction should be done
3722
+	if ($p_entry['status'] == 'ok') {
3723 3723
 
3724
-    // ----- Look for specific actions while the file exist
3725
-    if (file_exists($p_entry['filename']))
3726
-    {
3724
+	// ----- Look for specific actions while the file exist
3725
+	if (file_exists($p_entry['filename']))
3726
+	{
3727 3727
 
3728
-      // ----- Look if file is a directory
3729
-      if (is_dir($p_entry['filename']))
3730
-      {
3728
+	  // ----- Look if file is a directory
3729
+	  if (is_dir($p_entry['filename']))
3730
+	  {
3731 3731
 
3732
-        // ----- Change the file status
3733
-        $p_entry['status'] = "already_a_directory";
3732
+		// ----- Change the file status
3733
+		$p_entry['status'] = "already_a_directory";
3734 3734
 
3735
-        // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3736
-        // For historical reason first PclZip implementation does not stop
3737
-        // when this kind of error occurs.
3738
-        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3739
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3735
+		// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3736
+		// For historical reason first PclZip implementation does not stop
3737
+		// when this kind of error occurs.
3738
+		if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3739
+			&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3740 3740
 
3741
-            PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3742
-			                     "Filename '".$p_entry['filename']."' is "
3741
+			PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3742
+								 "Filename '".$p_entry['filename']."' is "
3743 3743
 								 ."already used by an existing directory");
3744 3744
 
3745
-            return PclZip::errorCode();
3746
-		    }
3747
-      }
3748
-      // ----- Look if file is write protected
3749
-      else if (!is_writeable($p_entry['filename']))
3750
-      {
3745
+			return PclZip::errorCode();
3746
+			}
3747
+	  }
3748
+	  // ----- Look if file is write protected
3749
+	  else if (!is_writeable($p_entry['filename']))
3750
+	  {
3751 3751
 
3752
-        // ----- Change the file status
3753
-        $p_entry['status'] = "write_protected";
3752
+		// ----- Change the file status
3753
+		$p_entry['status'] = "write_protected";
3754 3754
 
3755
-        // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3756
-        // For historical reason first PclZip implementation does not stop
3757
-        // when this kind of error occurs.
3758
-        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3759
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3755
+		// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3756
+		// For historical reason first PclZip implementation does not stop
3757
+		// when this kind of error occurs.
3758
+		if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3759
+			&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3760 3760
 
3761
-            PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3762
-			                     "Filename '".$p_entry['filename']."' exists "
3761
+			PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3762
+								 "Filename '".$p_entry['filename']."' exists "
3763 3763
 								 ."and is write protected");
3764 3764
 
3765
-            return PclZip::errorCode();
3766
-		    }
3767
-      }
3765
+			return PclZip::errorCode();
3766
+			}
3767
+	  }
3768 3768
 
3769
-      // ----- Look if the extracted file is older
3770
-      else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3771
-      {
3772
-        // ----- Change the file status
3773
-        if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3774
-		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3769
+	  // ----- Look if the extracted file is older
3770
+	  else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3771
+	  {
3772
+		// ----- Change the file status
3773
+		if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3774
+			&& ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3775 3775
 	  	  }
3776
-		    else {
3777
-            $p_entry['status'] = "newer_exist";
3778
-
3779
-            // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3780
-            // For historical reason first PclZip implementation does not stop
3781
-            // when this kind of error occurs.
3782
-            if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3783
-		        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3784
-
3785
-                PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3786
-			             "Newer version of '".$p_entry['filename']."' exists "
3787
-					    ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
3788
-
3789
-                return PclZip::errorCode();
3790
-		      }
3791
-		    }
3792
-      }
3793
-      else {
3794
-      }
3795
-    }
3776
+			else {
3777
+			$p_entry['status'] = "newer_exist";
3778
+
3779
+			// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3780
+			// For historical reason first PclZip implementation does not stop
3781
+			// when this kind of error occurs.
3782
+			if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3783
+				&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3784
+
3785
+				PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3786
+						 "Newer version of '".$p_entry['filename']."' exists "
3787
+						."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
3788
+
3789
+				return PclZip::errorCode();
3790
+			  }
3791
+			}
3792
+	  }
3793
+	  else {
3794
+	  }
3795
+	}
3796 3796
 
3797
-    // ----- Check the directory availability and create it if necessary
3798
-    else {
3799
-      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3800
-        $v_dir_to_check = $p_entry['filename'];
3801
-      else if (!strstr($p_entry['filename'], "/"))
3802
-        $v_dir_to_check = "";
3803
-      else
3804
-        $v_dir_to_check = dirname($p_entry['filename']);
3805
-
3806
-        if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3807
-
3808
-          // ----- Change the file status
3809
-          $p_entry['status'] = "path_creation_fail";
3810
-
3811
-          // ----- Return
3812
-          //return $v_result;
3813
-          $v_result = 1;
3814
-        }
3815
-      }
3816
-    }
3797
+	// ----- Check the directory availability and create it if necessary
3798
+	else {
3799
+	  if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3800
+		$v_dir_to_check = $p_entry['filename'];
3801
+	  else if (!strstr($p_entry['filename'], "/"))
3802
+		$v_dir_to_check = "";
3803
+	  else
3804
+		$v_dir_to_check = dirname($p_entry['filename']);
3805
+
3806
+		if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3807
+
3808
+		  // ----- Change the file status
3809
+		  $p_entry['status'] = "path_creation_fail";
3817 3810
 
3818
-    // ----- Look if extraction should be done
3819
-    if ($p_entry['status'] == 'ok') {
3811
+		  // ----- Return
3812
+		  //return $v_result;
3813
+		  $v_result = 1;
3814
+		}
3815
+	  }
3816
+	}
3820 3817
 
3821
-      // ----- Do the extraction (if not a folder)
3822
-      if (!(($p_entry['external']&0x00000010)==0x00000010))
3823
-      {
3824
-        // ----- Look for not compressed file
3825
-        if ($p_entry['compression'] == 0) {
3818
+	// ----- Look if extraction should be done
3819
+	if ($p_entry['status'] == 'ok') {
3826 3820
 
3827
-    		  // ----- Opening destination file
3828
-          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
3829
-          {
3821
+	  // ----- Do the extraction (if not a folder)
3822
+	  if (!(($p_entry['external']&0x00000010)==0x00000010))
3823
+	  {
3824
+		// ----- Look for not compressed file
3825
+		if ($p_entry['compression'] == 0) {
3830 3826
 
3831
-            // ----- Change the file status
3832
-            $p_entry['status'] = "write_error";
3827
+			  // ----- Opening destination file
3828
+		  if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
3829
+		  {
3833 3830
 
3834
-            // ----- Return
3835
-            return $v_result;
3836
-          }
3831
+			// ----- Change the file status
3832
+			$p_entry['status'] = "write_error";
3833
+
3834
+			// ----- Return
3835
+			return $v_result;
3836
+		  }
3837 3837
 
3838 3838
 
3839
-          // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3840
-          $v_size = $p_entry['compressed_size'];
3841
-          while ($v_size != 0)
3842
-          {
3843
-            $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3844
-            $v_buffer = @fread($this->zip_fd, $v_read_size);
3845
-            /* Try to speed up the code
3839
+		  // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3840
+		  $v_size = $p_entry['compressed_size'];
3841
+		  while ($v_size != 0)
3842
+		  {
3843
+			$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3844
+			$v_buffer = @fread($this->zip_fd, $v_read_size);
3845
+			/* Try to speed up the code
3846 3846
             $v_binary_data = pack('a'.$v_read_size, $v_buffer);
3847 3847
             @fwrite($v_dest_file, $v_binary_data, $v_read_size);
3848 3848
             */
3849
-            @fwrite($v_dest_file, $v_buffer, $v_read_size);
3850
-            $v_size -= $v_read_size;
3851
-          }
3849
+			@fwrite($v_dest_file, $v_buffer, $v_read_size);
3850
+			$v_size -= $v_read_size;
3851
+		  }
3852 3852
 
3853
-          // ----- Closing the destination file
3854
-          fclose($v_dest_file);
3853
+		  // ----- Closing the destination file
3854
+		  fclose($v_dest_file);
3855 3855
 
3856
-          // ----- Change the file mtime
3857
-          touch($p_entry['filename'], $p_entry['mtime']);
3856
+		  // ----- Change the file mtime
3857
+		  touch($p_entry['filename'], $p_entry['mtime']);
3858 3858
 
3859 3859
 
3860
-        }
3861
-        else {
3862
-          // ----- TBC
3863
-          // Need to be finished
3864
-          if (($p_entry['flag'] & 1) == 1) {
3865
-            PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
3866
-            return PclZip::errorCode();
3867
-          }
3860
+		}
3861
+		else {
3862
+		  // ----- TBC
3863
+		  // Need to be finished
3864
+		  if (($p_entry['flag'] & 1) == 1) {
3865
+			PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
3866
+			return PclZip::errorCode();
3867
+		  }
3868 3868
 
3869 3869
 
3870
-          // ----- Look for using temporary file to unzip
3871
-          if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
3872
-              && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
3873
-                  || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3874
-                      && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
3875
-            $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
3876
-            if ($v_result < PCLZIP_ERR_NO_ERROR) {
3877
-              return $v_result;
3878
-            }
3879
-          }
3870
+		  // ----- Look for using temporary file to unzip
3871
+		  if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
3872
+			  && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
3873
+				  || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3874
+					  && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
3875
+			$v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
3876
+			if ($v_result < PCLZIP_ERR_NO_ERROR) {
3877
+			  return $v_result;
3878
+			}
3879
+		  }
3880 3880
 
3881
-          // ----- Look for extract in memory
3882
-          else {
3881
+		  // ----- Look for extract in memory
3882
+		  else {
3883 3883
 
3884 3884
 
3885
-            // ----- Read the compressed file in a buffer (one shot)
3886
-            $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
3885
+			// ----- Read the compressed file in a buffer (one shot)
3886
+			$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
3887 3887
 
3888
-            // ----- Decompress the file
3889
-            $v_file_content = @gzinflate($v_buffer);
3890
-            unset($v_buffer);
3891
-            if ($v_file_content === FALSE) {
3888
+			// ----- Decompress the file
3889
+			$v_file_content = @gzinflate($v_buffer);
3890
+			unset($v_buffer);
3891
+			if ($v_file_content === FALSE) {
3892 3892
 
3893
-              // ----- Change the file status
3894
-              // TBC
3895
-              $p_entry['status'] = "error";
3893
+			  // ----- Change the file status
3894
+			  // TBC
3895
+			  $p_entry['status'] = "error";
3896 3896
 
3897
-              return $v_result;
3898
-            }
3897
+			  return $v_result;
3898
+			}
3899 3899
 
3900
-            // ----- Opening destination file
3901
-            if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
3900
+			// ----- Opening destination file
3901
+			if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
3902 3902
 
3903
-              // ----- Change the file status
3904
-              $p_entry['status'] = "write_error";
3903
+			  // ----- Change the file status
3904
+			  $p_entry['status'] = "write_error";
3905 3905
 
3906
-              return $v_result;
3907
-            }
3906
+			  return $v_result;
3907
+			}
3908 3908
 
3909
-            // ----- Write the uncompressed data
3910
-            @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
3911
-            unset($v_file_content);
3909
+			// ----- Write the uncompressed data
3910
+			@fwrite($v_dest_file, $v_file_content, $p_entry['size']);
3911
+			unset($v_file_content);
3912 3912
 
3913
-            // ----- Closing the destination file
3914
-            @fclose($v_dest_file);
3913
+			// ----- Closing the destination file
3914
+			@fclose($v_dest_file);
3915 3915
 
3916
-          }
3916
+		  }
3917 3917
 
3918
-          // ----- Change the file mtime
3919
-          @touch($p_entry['filename'], $p_entry['mtime']);
3920
-        }
3918
+		  // ----- Change the file mtime
3919
+		  @touch($p_entry['filename'], $p_entry['mtime']);
3920
+		}
3921 3921
 
3922
-        // ----- Look for chmod option
3923
-        if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
3922
+		// ----- Look for chmod option
3923
+		if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
3924 3924
 
3925
-          // ----- Change the mode of the file
3926
-          @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
3927
-        }
3925
+		  // ----- Change the mode of the file
3926
+		  @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
3927
+		}
3928 3928
 
3929
-      }
3930
-    }
3929
+	  }
3930
+	}
3931 3931
 
3932 3932
   	// ----- Change abort status
3933 3933
   	if ($p_entry['status'] == "aborted") {
3934
-        $p_entry['status'] = "skipped";
3934
+		$p_entry['status'] = "skipped";
3935 3935
   	}
3936 3936
 
3937
-    // ----- Look for post-extract callback
3938
-    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3937
+	// ----- Look for post-extract callback
3938
+	elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3939 3939
 
3940
-      // ----- Generate a local information
3941
-      $v_local_header = array();
3942
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3940
+	  // ----- Generate a local information
3941
+	  $v_local_header = array();
3942
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3943 3943
 
3944
-      // ----- Call the callback
3945
-      // Here I do not use call_user_func() because I need to send a reference to the
3946
-      // header.
3947
-      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
3944
+	  // ----- Call the callback
3945
+	  // Here I do not use call_user_func() because I need to send a reference to the
3946
+	  // header.
3947
+	  $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
3948 3948
 
3949
-      // ----- Look for abort result
3950
-      if ($v_result == 2) {
3951
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
3952
-      }
3953
-    }
3949
+	  // ----- Look for abort result
3950
+	  if ($v_result == 2) {
3951
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
3952
+	  }
3953
+	}
3954 3954
 
3955
-    // ----- Return
3956
-    return $v_result;
3955
+	// ----- Return
3956
+	return $v_result;
3957 3957
   }
3958 3958
   // --------------------------------------------------------------------------------
3959 3959
 
@@ -3965,71 +3965,71 @@  discard block
 block discarded – undo
3965 3965
   // --------------------------------------------------------------------------------
3966 3966
   function privExtractFileUsingTempFile(&$p_entry, &$p_options)
3967 3967
   {
3968
-    $v_result=1;
3969
-
3970
-    // ----- Creates a temporary file
3971
-    $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
3972
-    if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
3973
-      fclose($v_file);
3974
-      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3975
-      return PclZip::errorCode();
3976
-    }
3968
+	$v_result=1;
3969
+
3970
+	// ----- Creates a temporary file
3971
+	$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
3972
+	if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
3973
+	  fclose($v_file);
3974
+	  PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3975
+	  return PclZip::errorCode();
3976
+	}
3977 3977
 
3978 3978
 
3979
-    // ----- Write gz file format header
3980
-    $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
3981
-    @fwrite($v_dest_file, $v_binary_data, 10);
3979
+	// ----- Write gz file format header
3980
+	$v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
3981
+	@fwrite($v_dest_file, $v_binary_data, 10);
3982 3982
 
3983
-    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3984
-    $v_size = $p_entry['compressed_size'];
3985
-    while ($v_size != 0)
3986
-    {
3987
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3988
-      $v_buffer = @fread($this->zip_fd, $v_read_size);
3989
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
3990
-      @fwrite($v_dest_file, $v_buffer, $v_read_size);
3991
-      $v_size -= $v_read_size;
3992
-    }
3983
+	// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3984
+	$v_size = $p_entry['compressed_size'];
3985
+	while ($v_size != 0)
3986
+	{
3987
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3988
+	  $v_buffer = @fread($this->zip_fd, $v_read_size);
3989
+	  //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
3990
+	  @fwrite($v_dest_file, $v_buffer, $v_read_size);
3991
+	  $v_size -= $v_read_size;
3992
+	}
3993 3993
 
3994
-    // ----- Write gz file format footer
3995
-    $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
3996
-    @fwrite($v_dest_file, $v_binary_data, 8);
3994
+	// ----- Write gz file format footer
3995
+	$v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
3996
+	@fwrite($v_dest_file, $v_binary_data, 8);
3997 3997
 
3998
-    // ----- Close the temporary file
3999
-    @fclose($v_dest_file);
3998
+	// ----- Close the temporary file
3999
+	@fclose($v_dest_file);
4000 4000
 
4001
-    // ----- Opening destination file
4002
-    if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
4003
-      $p_entry['status'] = "write_error";
4004
-      return $v_result;
4005
-    }
4001
+	// ----- Opening destination file
4002
+	if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
4003
+	  $p_entry['status'] = "write_error";
4004
+	  return $v_result;
4005
+	}
4006 4006
 
4007
-    // ----- Open the temporary gz file
4008
-    if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
4009
-      @fclose($v_dest_file);
4010
-      $p_entry['status'] = "read_error";
4011
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4012
-      return PclZip::errorCode();
4013
-    }
4007
+	// ----- Open the temporary gz file
4008
+	if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
4009
+	  @fclose($v_dest_file);
4010
+	  $p_entry['status'] = "read_error";
4011
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4012
+	  return PclZip::errorCode();
4013
+	}
4014 4014
 
4015 4015
 
4016
-    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
4017
-    $v_size = $p_entry['size'];
4018
-    while ($v_size != 0) {
4019
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4020
-      $v_buffer = @gzread($v_src_file, $v_read_size);
4021
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4022
-      @fwrite($v_dest_file, $v_buffer, $v_read_size);
4023
-      $v_size -= $v_read_size;
4024
-    }
4025
-    @fclose($v_dest_file);
4026
-    @gzclose($v_src_file);
4016
+	// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
4017
+	$v_size = $p_entry['size'];
4018
+	while ($v_size != 0) {
4019
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4020
+	  $v_buffer = @gzread($v_src_file, $v_read_size);
4021
+	  //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4022
+	  @fwrite($v_dest_file, $v_buffer, $v_read_size);
4023
+	  $v_size -= $v_read_size;
4024
+	}
4025
+	@fclose($v_dest_file);
4026
+	@gzclose($v_src_file);
4027 4027
 
4028
-    // ----- Delete the temporary file
4029
-    @unlink($v_gzip_temp_name);
4028
+	// ----- Delete the temporary file
4029
+	@unlink($v_gzip_temp_name);
4030 4030
 
4031
-    // ----- Return
4032
-    return $v_result;
4031
+	// ----- Return
4032
+	return $v_result;
4033 4033
   }
4034 4034
   // --------------------------------------------------------------------------------
4035 4035
 
@@ -4041,106 +4041,106 @@  discard block
 block discarded – undo
4041 4041
   // --------------------------------------------------------------------------------
4042 4042
   function privExtractFileInOutput(&$p_entry, &$p_options)
4043 4043
   {
4044
-    $v_result=1;
4044
+	$v_result=1;
4045 4045
 
4046
-    // ----- Read the file header
4047
-    if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
4048
-      return $v_result;
4049
-    }
4046
+	// ----- Read the file header
4047
+	if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
4048
+	  return $v_result;
4049
+	}
4050 4050
 
4051 4051
 
4052
-    // ----- Check that the file header is coherent with $p_entry info
4053
-    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4054
-        // TBC
4055
-    }
4052
+	// ----- Check that the file header is coherent with $p_entry info
4053
+	if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4054
+		// TBC
4055
+	}
4056 4056
 
4057
-    // ----- Look for pre-extract callback
4058
-    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4057
+	// ----- Look for pre-extract callback
4058
+	if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4059 4059
 
4060
-      // ----- Generate a local information
4061
-      $v_local_header = array();
4062
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4060
+	  // ----- Generate a local information
4061
+	  $v_local_header = array();
4062
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4063 4063
 
4064
-      // ----- Call the callback
4065
-      // Here I do not use call_user_func() because I need to send a reference to the
4066
-      // header.
4064
+	  // ----- Call the callback
4065
+	  // Here I do not use call_user_func() because I need to send a reference to the
4066
+	  // header.
4067 4067
 //      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4068
-      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4069
-      if ($v_result == 0) {
4070
-        // ----- Change the file status
4071
-        $p_entry['status'] = "skipped";
4072
-        $v_result = 1;
4073
-      }
4068
+	  $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4069
+	  if ($v_result == 0) {
4070
+		// ----- Change the file status
4071
+		$p_entry['status'] = "skipped";
4072
+		$v_result = 1;
4073
+	  }
4074 4074
 
4075
-      // ----- Look for abort result
4076
-      if ($v_result == 2) {
4077
-        // ----- This status is internal and will be changed in 'skipped'
4078
-        $p_entry['status'] = "aborted";
4079
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4080
-      }
4075
+	  // ----- Look for abort result
4076
+	  if ($v_result == 2) {
4077
+		// ----- This status is internal and will be changed in 'skipped'
4078
+		$p_entry['status'] = "aborted";
4079
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
4080
+	  }
4081 4081
 
4082
-      // ----- Update the informations
4083
-      // Only some fields can be modified
4084
-      $p_entry['filename'] = $v_local_header['filename'];
4085
-    }
4082
+	  // ----- Update the informations
4083
+	  // Only some fields can be modified
4084
+	  $p_entry['filename'] = $v_local_header['filename'];
4085
+	}
4086 4086
 
4087
-    // ----- Trace
4087
+	// ----- Trace
4088 4088
 
4089
-    // ----- Look if extraction should be done
4090
-    if ($p_entry['status'] == 'ok') {
4089
+	// ----- Look if extraction should be done
4090
+	if ($p_entry['status'] == 'ok') {
4091 4091
 
4092
-      // ----- Do the extraction (if not a folder)
4093
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4094
-        // ----- Look for not compressed file
4095
-        if ($p_entry['compressed_size'] == $p_entry['size']) {
4092
+	  // ----- Do the extraction (if not a folder)
4093
+	  if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4094
+		// ----- Look for not compressed file
4095
+		if ($p_entry['compressed_size'] == $p_entry['size']) {
4096 4096
 
4097
-          // ----- Read the file in a buffer (one shot)
4098
-          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4097
+		  // ----- Read the file in a buffer (one shot)
4098
+		  $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4099 4099
 
4100
-          // ----- Send the file to the output
4101
-          echo $v_buffer;
4102
-          unset($v_buffer);
4103
-        }
4104
-        else {
4100
+		  // ----- Send the file to the output
4101
+		  echo $v_buffer;
4102
+		  unset($v_buffer);
4103
+		}
4104
+		else {
4105 4105
 
4106
-          // ----- Read the compressed file in a buffer (one shot)
4107
-          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4106
+		  // ----- Read the compressed file in a buffer (one shot)
4107
+		  $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4108 4108
 
4109
-          // ----- Decompress the file
4110
-          $v_file_content = gzinflate($v_buffer);
4111
-          unset($v_buffer);
4109
+		  // ----- Decompress the file
4110
+		  $v_file_content = gzinflate($v_buffer);
4111
+		  unset($v_buffer);
4112 4112
 
4113
-          // ----- Send the file to the output
4114
-          echo $v_file_content;
4115
-          unset($v_file_content);
4116
-        }
4117
-      }
4118
-    }
4113
+		  // ----- Send the file to the output
4114
+		  echo $v_file_content;
4115
+		  unset($v_file_content);
4116
+		}
4117
+	  }
4118
+	}
4119 4119
 
4120 4120
 	// ----- Change abort status
4121 4121
 	if ($p_entry['status'] == "aborted") {
4122
-      $p_entry['status'] = "skipped";
4122
+	  $p_entry['status'] = "skipped";
4123 4123
 	}
4124 4124
 
4125
-    // ----- Look for post-extract callback
4126
-    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4125
+	// ----- Look for post-extract callback
4126
+	elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4127 4127
 
4128
-      // ----- Generate a local information
4129
-      $v_local_header = array();
4130
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4128
+	  // ----- Generate a local information
4129
+	  $v_local_header = array();
4130
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4131 4131
 
4132
-      // ----- Call the callback
4133
-      // Here I do not use call_user_func() because I need to send a reference to the
4134
-      // header.
4135
-      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4132
+	  // ----- Call the callback
4133
+	  // Here I do not use call_user_func() because I need to send a reference to the
4134
+	  // header.
4135
+	  $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4136 4136
 
4137
-      // ----- Look for abort result
4138
-      if ($v_result == 2) {
4139
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4140
-      }
4141
-    }
4137
+	  // ----- Look for abort result
4138
+	  if ($v_result == 2) {
4139
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
4140
+	  }
4141
+	}
4142 4142
 
4143
-    return $v_result;
4143
+	return $v_result;
4144 4144
   }
4145 4145
   // --------------------------------------------------------------------------------
4146 4146
 
@@ -4152,116 +4152,116 @@  discard block
 block discarded – undo
4152 4152
   // --------------------------------------------------------------------------------
4153 4153
   function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4154 4154
   {
4155
-    $v_result=1;
4156
-
4157
-    // ----- Read the file header
4158
-    $v_header = array();
4159
-    if (($v_result = $this->privReadFileHeader($v_header)) != 1)
4160
-    {
4161
-      // ----- Return
4162
-      return $v_result;
4163
-    }
4155
+	$v_result=1;
4156
+
4157
+	// ----- Read the file header
4158
+	$v_header = array();
4159
+	if (($v_result = $this->privReadFileHeader($v_header)) != 1)
4160
+	{
4161
+	  // ----- Return
4162
+	  return $v_result;
4163
+	}
4164 4164
 
4165 4165
 
4166
-    // ----- Check that the file header is coherent with $p_entry info
4167
-    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4168
-        // TBC
4169
-    }
4166
+	// ----- Check that the file header is coherent with $p_entry info
4167
+	if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4168
+		// TBC
4169
+	}
4170 4170
 
4171
-    // ----- Look for pre-extract callback
4172
-    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4173
-
4174
-      // ----- Generate a local information
4175
-      $v_local_header = array();
4176
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4177
-
4178
-      // ----- Call the callback
4179
-      // Here I do not use call_user_func() because I need to send a reference to the
4180
-      // header.
4181
-      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4182
-      if ($v_result == 0) {
4183
-        // ----- Change the file status
4184
-        $p_entry['status'] = "skipped";
4185
-        $v_result = 1;
4186
-      }
4171
+	// ----- Look for pre-extract callback
4172
+	if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4173
+
4174
+	  // ----- Generate a local information
4175
+	  $v_local_header = array();
4176
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4177
+
4178
+	  // ----- Call the callback
4179
+	  // Here I do not use call_user_func() because I need to send a reference to the
4180
+	  // header.
4181
+	  $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4182
+	  if ($v_result == 0) {
4183
+		// ----- Change the file status
4184
+		$p_entry['status'] = "skipped";
4185
+		$v_result = 1;
4186
+	  }
4187 4187
 
4188
-      // ----- Look for abort result
4189
-      if ($v_result == 2) {
4190
-        // ----- This status is internal and will be changed in 'skipped'
4191
-        $p_entry['status'] = "aborted";
4192
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4193
-      }
4188
+	  // ----- Look for abort result
4189
+	  if ($v_result == 2) {
4190
+		// ----- This status is internal and will be changed in 'skipped'
4191
+		$p_entry['status'] = "aborted";
4192
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
4193
+	  }
4194 4194
 
4195
-      // ----- Update the informations
4196
-      // Only some fields can be modified
4197
-      $p_entry['filename'] = $v_local_header['filename'];
4198
-    }
4195
+	  // ----- Update the informations
4196
+	  // Only some fields can be modified
4197
+	  $p_entry['filename'] = $v_local_header['filename'];
4198
+	}
4199 4199
 
4200 4200
 
4201
-    // ----- Look if extraction should be done
4202
-    if ($p_entry['status'] == 'ok') {
4201
+	// ----- Look if extraction should be done
4202
+	if ($p_entry['status'] == 'ok') {
4203 4203
 
4204
-      // ----- Do the extraction (if not a folder)
4205
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4206
-        // ----- Look for not compressed file
4204
+	  // ----- Do the extraction (if not a folder)
4205
+	  if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4206
+		// ----- Look for not compressed file
4207 4207
   //      if ($p_entry['compressed_size'] == $p_entry['size'])
4208
-        if ($p_entry['compression'] == 0) {
4208
+		if ($p_entry['compression'] == 0) {
4209 4209
 
4210
-          // ----- Reading the file
4211
-          $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4212
-        }
4213
-        else {
4210
+		  // ----- Reading the file
4211
+		  $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4212
+		}
4213
+		else {
4214 4214
 
4215
-          // ----- Reading the file
4216
-          $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
4215
+		  // ----- Reading the file
4216
+		  $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
4217 4217
 
4218
-          // ----- Decompress the file
4219
-          if (($p_string = @gzinflate($v_data)) === FALSE) {
4220
-              // TBC
4221
-          }
4222
-        }
4218
+		  // ----- Decompress the file
4219
+		  if (($p_string = @gzinflate($v_data)) === FALSE) {
4220
+			  // TBC
4221
+		  }
4222
+		}
4223 4223
 
4224
-        // ----- Trace
4225
-      }
4226
-      else {
4227
-          // TBC : error : can not extract a folder in a string
4228
-      }
4224
+		// ----- Trace
4225
+	  }
4226
+	  else {
4227
+		  // TBC : error : can not extract a folder in a string
4228
+	  }
4229 4229
 
4230
-    }
4230
+	}
4231 4231
 
4232 4232
   	// ----- Change abort status
4233 4233
   	if ($p_entry['status'] == "aborted") {
4234
-        $p_entry['status'] = "skipped";
4234
+		$p_entry['status'] = "skipped";
4235 4235
   	}
4236 4236
 
4237
-    // ----- Look for post-extract callback
4238
-    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4237
+	// ----- Look for post-extract callback
4238
+	elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4239 4239
 
4240
-      // ----- Generate a local information
4241
-      $v_local_header = array();
4242
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4240
+	  // ----- Generate a local information
4241
+	  $v_local_header = array();
4242
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4243 4243
 
4244
-      // ----- Swap the content to header
4245
-      $v_local_header['content'] = $p_string;
4246
-      $p_string = '';
4244
+	  // ----- Swap the content to header
4245
+	  $v_local_header['content'] = $p_string;
4246
+	  $p_string = '';
4247 4247
 
4248
-      // ----- Call the callback
4249
-      // Here I do not use call_user_func() because I need to send a reference to the
4250
-      // header.
4251
-      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4248
+	  // ----- Call the callback
4249
+	  // Here I do not use call_user_func() because I need to send a reference to the
4250
+	  // header.
4251
+	  $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4252 4252
 
4253
-      // ----- Swap back the content to header
4254
-      $p_string = $v_local_header['content'];
4255
-      unset($v_local_header['content']);
4253
+	  // ----- Swap back the content to header
4254
+	  $p_string = $v_local_header['content'];
4255
+	  unset($v_local_header['content']);
4256 4256
 
4257
-      // ----- Look for abort result
4258
-      if ($v_result == 2) {
4259
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4260
-      }
4261
-    }
4257
+	  // ----- Look for abort result
4258
+	  if ($v_result == 2) {
4259
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
4260
+	  }
4261
+	}
4262 4262
 
4263
-    // ----- Return
4264
-    return $v_result;
4263
+	// ----- Return
4264
+	return $v_result;
4265 4265
   }
4266 4266
   // --------------------------------------------------------------------------------
4267 4267
 
@@ -4273,98 +4273,98 @@  discard block
 block discarded – undo
4273 4273
   // --------------------------------------------------------------------------------
4274 4274
   function privReadFileHeader(&$p_header)
4275 4275
   {
4276
-    $v_result=1;
4276
+	$v_result=1;
4277 4277
 
4278
-    // ----- Read the 4 bytes signature
4279
-    $v_binary_data = @fread($this->zip_fd, 4);
4280
-    $v_data = unpack('Vid', $v_binary_data);
4278
+	// ----- Read the 4 bytes signature
4279
+	$v_binary_data = @fread($this->zip_fd, 4);
4280
+	$v_data = unpack('Vid', $v_binary_data);
4281 4281
 
4282
-    // ----- Check signature
4283
-    if ($v_data['id'] != 0x04034b50)
4284
-    {
4282
+	// ----- Check signature
4283
+	if ($v_data['id'] != 0x04034b50)
4284
+	{
4285 4285
 
4286
-      // ----- Error log
4287
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4286
+	  // ----- Error log
4287
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4288 4288
 
4289
-      // ----- Return
4290
-      return PclZip::errorCode();
4291
-    }
4289
+	  // ----- Return
4290
+	  return PclZip::errorCode();
4291
+	}
4292 4292
 
4293
-    // ----- Read the first 42 bytes of the header
4294
-    $v_binary_data = fread($this->zip_fd, 26);
4293
+	// ----- Read the first 42 bytes of the header
4294
+	$v_binary_data = fread($this->zip_fd, 26);
4295 4295
 
4296
-    // ----- Look for invalid block size
4297
-    if (strlen($v_binary_data) != 26)
4298
-    {
4299
-      $p_header['filename'] = "";
4300
-      $p_header['status'] = "invalid_header";
4296
+	// ----- Look for invalid block size
4297
+	if (strlen($v_binary_data) != 26)
4298
+	{
4299
+	  $p_header['filename'] = "";
4300
+	  $p_header['status'] = "invalid_header";
4301 4301
 
4302
-      // ----- Error log
4303
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4302
+	  // ----- Error log
4303
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4304 4304
 
4305
-      // ----- Return
4306
-      return PclZip::errorCode();
4307
-    }
4305
+	  // ----- Return
4306
+	  return PclZip::errorCode();
4307
+	}
4308 4308
 
4309
-    // ----- Extract the values
4310
-    $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
4309
+	// ----- Extract the values
4310
+	$v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
4311 4311
 
4312
-    // ----- Get filename
4313
-    $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
4312
+	// ----- Get filename
4313
+	$p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
4314 4314
 
4315
-    // ----- Get extra_fields
4316
-    if ($v_data['extra_len'] != 0) {
4317
-      $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4318
-    }
4319
-    else {
4320
-      $p_header['extra'] = '';
4321
-    }
4315
+	// ----- Get extra_fields
4316
+	if ($v_data['extra_len'] != 0) {
4317
+	  $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4318
+	}
4319
+	else {
4320
+	  $p_header['extra'] = '';
4321
+	}
4322 4322
 
4323
-    // ----- Extract properties
4324
-    $p_header['version_extracted'] = $v_data['version'];
4325
-    $p_header['compression'] = $v_data['compression'];
4326
-    $p_header['size'] = $v_data['size'];
4327
-    $p_header['compressed_size'] = $v_data['compressed_size'];
4328
-    $p_header['crc'] = $v_data['crc'];
4329
-    $p_header['flag'] = $v_data['flag'];
4330
-    $p_header['filename_len'] = $v_data['filename_len'];
4331
-
4332
-    // ----- Recuperate date in UNIX format
4333
-    $p_header['mdate'] = $v_data['mdate'];
4334
-    $p_header['mtime'] = $v_data['mtime'];
4335
-    if ($p_header['mdate'] && $p_header['mtime'])
4336
-    {
4337
-      // ----- Extract time
4338
-      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4339
-      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4340
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4341
-
4342
-      // ----- Extract date
4343
-      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4344
-      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4345
-      $v_day = $p_header['mdate'] & 0x001F;
4346
-
4347
-      // ----- Get UNIX date format
4348
-      $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4323
+	// ----- Extract properties
4324
+	$p_header['version_extracted'] = $v_data['version'];
4325
+	$p_header['compression'] = $v_data['compression'];
4326
+	$p_header['size'] = $v_data['size'];
4327
+	$p_header['compressed_size'] = $v_data['compressed_size'];
4328
+	$p_header['crc'] = $v_data['crc'];
4329
+	$p_header['flag'] = $v_data['flag'];
4330
+	$p_header['filename_len'] = $v_data['filename_len'];
4331
+
4332
+	// ----- Recuperate date in UNIX format
4333
+	$p_header['mdate'] = $v_data['mdate'];
4334
+	$p_header['mtime'] = $v_data['mtime'];
4335
+	if ($p_header['mdate'] && $p_header['mtime'])
4336
+	{
4337
+	  // ----- Extract time
4338
+	  $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4339
+	  $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4340
+	  $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4341
+
4342
+	  // ----- Extract date
4343
+	  $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4344
+	  $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4345
+	  $v_day = $p_header['mdate'] & 0x001F;
4346
+
4347
+	  // ----- Get UNIX date format
4348
+	  $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4349 4349
 
4350
-    }
4351
-    else
4352
-    {
4353
-      $p_header['mtime'] = time();
4354
-    }
4350
+	}
4351
+	else
4352
+	{
4353
+	  $p_header['mtime'] = time();
4354
+	}
4355 4355
 
4356
-    // TBC
4357
-    //for(reset($v_data); $key = key($v_data); next($v_data)) {
4358
-    //}
4356
+	// TBC
4357
+	//for(reset($v_data); $key = key($v_data); next($v_data)) {
4358
+	//}
4359 4359
 
4360
-    // ----- Set the stored filename
4361
-    $p_header['stored_filename'] = $p_header['filename'];
4360
+	// ----- Set the stored filename
4361
+	$p_header['stored_filename'] = $p_header['filename'];
4362 4362
 
4363
-    // ----- Set the status field
4364
-    $p_header['status'] = "ok";
4363
+	// ----- Set the status field
4364
+	$p_header['status'] = "ok";
4365 4365
 
4366
-    // ----- Return
4367
-    return $v_result;
4366
+	// ----- Return
4367
+	return $v_result;
4368 4368
   }
4369 4369
   // --------------------------------------------------------------------------------
4370 4370
 
@@ -4376,101 +4376,101 @@  discard block
 block discarded – undo
4376 4376
   // --------------------------------------------------------------------------------
4377 4377
   function privReadCentralFileHeader(&$p_header)
4378 4378
   {
4379
-    $v_result=1;
4379
+	$v_result=1;
4380 4380
 
4381
-    // ----- Read the 4 bytes signature
4382
-    $v_binary_data = @fread($this->zip_fd, 4);
4383
-    $v_data = unpack('Vid', $v_binary_data);
4381
+	// ----- Read the 4 bytes signature
4382
+	$v_binary_data = @fread($this->zip_fd, 4);
4383
+	$v_data = unpack('Vid', $v_binary_data);
4384 4384
 
4385
-    // ----- Check signature
4386
-    if ($v_data['id'] != 0x02014b50)
4387
-    {
4385
+	// ----- Check signature
4386
+	if ($v_data['id'] != 0x02014b50)
4387
+	{
4388 4388
 
4389
-      // ----- Error log
4390
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4389
+	  // ----- Error log
4390
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4391 4391
 
4392
-      // ----- Return
4393
-      return PclZip::errorCode();
4394
-    }
4392
+	  // ----- Return
4393
+	  return PclZip::errorCode();
4394
+	}
4395 4395
 
4396
-    // ----- Read the first 42 bytes of the header
4397
-    $v_binary_data = fread($this->zip_fd, 42);
4396
+	// ----- Read the first 42 bytes of the header
4397
+	$v_binary_data = fread($this->zip_fd, 42);
4398 4398
 
4399
-    // ----- Look for invalid block size
4400
-    if (strlen($v_binary_data) != 42)
4401
-    {
4402
-      $p_header['filename'] = "";
4403
-      $p_header['status'] = "invalid_header";
4399
+	// ----- Look for invalid block size
4400
+	if (strlen($v_binary_data) != 42)
4401
+	{
4402
+	  $p_header['filename'] = "";
4403
+	  $p_header['status'] = "invalid_header";
4404 4404
 
4405
-      // ----- Error log
4406
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4405
+	  // ----- Error log
4406
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4407 4407
 
4408
-      // ----- Return
4409
-      return PclZip::errorCode();
4410
-    }
4408
+	  // ----- Return
4409
+	  return PclZip::errorCode();
4410
+	}
4411 4411
 
4412
-    // ----- Extract the values
4413
-    $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);
4414
-
4415
-    // ----- Get filename
4416
-    if ($p_header['filename_len'] != 0)
4417
-      $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4418
-    else
4419
-      $p_header['filename'] = '';
4420
-
4421
-    // ----- Get extra
4422
-    if ($p_header['extra_len'] != 0)
4423
-      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4424
-    else
4425
-      $p_header['extra'] = '';
4426
-
4427
-    // ----- Get comment
4428
-    if ($p_header['comment_len'] != 0)
4429
-      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4430
-    else
4431
-      $p_header['comment'] = '';
4432
-
4433
-    // ----- Extract properties
4434
-
4435
-    // ----- Recuperate date in UNIX format
4436
-    //if ($p_header['mdate'] && $p_header['mtime'])
4437
-    // TBC : bug : this was ignoring time with 0/0/0
4438
-    if (1)
4439
-    {
4440
-      // ----- Extract time
4441
-      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4442
-      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4443
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4444
-
4445
-      // ----- Extract date
4446
-      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4447
-      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4448
-      $v_day = $p_header['mdate'] & 0x001F;
4449
-
4450
-      // ----- Get UNIX date format
4451
-      $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4412
+	// ----- Extract the values
4413
+	$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);
4414
+
4415
+	// ----- Get filename
4416
+	if ($p_header['filename_len'] != 0)
4417
+	  $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4418
+	else
4419
+	  $p_header['filename'] = '';
4420
+
4421
+	// ----- Get extra
4422
+	if ($p_header['extra_len'] != 0)
4423
+	  $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4424
+	else
4425
+	  $p_header['extra'] = '';
4426
+
4427
+	// ----- Get comment
4428
+	if ($p_header['comment_len'] != 0)
4429
+	  $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4430
+	else
4431
+	  $p_header['comment'] = '';
4432
+
4433
+	// ----- Extract properties
4434
+
4435
+	// ----- Recuperate date in UNIX format
4436
+	//if ($p_header['mdate'] && $p_header['mtime'])
4437
+	// TBC : bug : this was ignoring time with 0/0/0
4438
+	if (1)
4439
+	{
4440
+	  // ----- Extract time
4441
+	  $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4442
+	  $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4443
+	  $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4444
+
4445
+	  // ----- Extract date
4446
+	  $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4447
+	  $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4448
+	  $v_day = $p_header['mdate'] & 0x001F;
4449
+
4450
+	  // ----- Get UNIX date format
4451
+	  $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4452 4452
 
4453
-    }
4454
-    else
4455
-    {
4456
-      $p_header['mtime'] = time();
4457
-    }
4453
+	}
4454
+	else
4455
+	{
4456
+	  $p_header['mtime'] = time();
4457
+	}
4458 4458
 
4459
-    // ----- Set the stored filename
4460
-    $p_header['stored_filename'] = $p_header['filename'];
4459
+	// ----- Set the stored filename
4460
+	$p_header['stored_filename'] = $p_header['filename'];
4461 4461
 
4462
-    // ----- Set default status to ok
4463
-    $p_header['status'] = 'ok';
4462
+	// ----- Set default status to ok
4463
+	$p_header['status'] = 'ok';
4464 4464
 
4465
-    // ----- Look if it is a directory
4466
-    if (substr($p_header['filename'], -1) == '/') {
4467
-      //$p_header['external'] = 0x41FF0010;
4468
-      $p_header['external'] = 0x00000010;
4469
-    }
4465
+	// ----- Look if it is a directory
4466
+	if (substr($p_header['filename'], -1) == '/') {
4467
+	  //$p_header['external'] = 0x41FF0010;
4468
+	  $p_header['external'] = 0x00000010;
4469
+	}
4470 4470
 
4471 4471
 
4472
-    // ----- Return
4473
-    return $v_result;
4472
+	// ----- Return
4473
+	return $v_result;
4474 4474
   }
4475 4475
   // --------------------------------------------------------------------------------
4476 4476
 
@@ -4484,7 +4484,7 @@  discard block
 block discarded – undo
4484 4484
   // --------------------------------------------------------------------------------
4485 4485
   function privCheckFileHeaders(&$p_local_header, &$p_central_header)
4486 4486
   {
4487
-    $v_result=1;
4487
+	$v_result=1;
4488 4488
 
4489 4489
   	// ----- Check the static values
4490 4490
   	// TBC
@@ -4503,13 +4503,13 @@  discard block
 block discarded – undo
4503 4503
 
4504 4504
   	// ----- Look for flag bit 3
4505 4505
   	if (($p_local_header['flag'] & 8) == 8) {
4506
-          $p_local_header['size'] = $p_central_header['size'];
4507
-          $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
4508
-          $p_local_header['crc'] = $p_central_header['crc'];
4506
+		  $p_local_header['size'] = $p_central_header['size'];
4507
+		  $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
4508
+		  $p_local_header['crc'] = $p_central_header['crc'];
4509 4509
   	}
4510 4510
 
4511
-    // ----- Return
4512
-    return $v_result;
4511
+	// ----- Return
4512
+	return $v_result;
4513 4513
   }
4514 4514
   // --------------------------------------------------------------------------------
4515 4515
 
@@ -4521,152 +4521,152 @@  discard block
 block discarded – undo
4521 4521
   // --------------------------------------------------------------------------------
4522 4522
   function privReadEndCentralDir(&$p_central_dir)
4523 4523
   {
4524
-    $v_result=1;
4525
-
4526
-    // ----- Go to the end of the zip file
4527
-    $v_size = filesize($this->zipname);
4528
-    @fseek($this->zip_fd, $v_size);
4529
-    if (@ftell($this->zip_fd) != $v_size)
4530
-    {
4531
-      // ----- Error log
4532
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4533
-
4534
-      // ----- Return
4535
-      return PclZip::errorCode();
4536
-    }
4524
+	$v_result=1;
4525
+
4526
+	// ----- Go to the end of the zip file
4527
+	$v_size = filesize($this->zipname);
4528
+	@fseek($this->zip_fd, $v_size);
4529
+	if (@ftell($this->zip_fd) != $v_size)
4530
+	{
4531
+	  // ----- Error log
4532
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4533
+
4534
+	  // ----- Return
4535
+	  return PclZip::errorCode();
4536
+	}
4537 4537
 
4538
-    // ----- First try : look if this is an archive with no commentaries (most of the time)
4539
-    // in this case the end of central dir is at 22 bytes of the file end
4540
-    $v_found = 0;
4541
-    if ($v_size > 26) {
4542
-      @fseek($this->zip_fd, $v_size-22);
4543
-      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4544
-      {
4545
-        // ----- Error log
4546
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4547
-
4548
-        // ----- Return
4549
-        return PclZip::errorCode();
4550
-      }
4538
+	// ----- First try : look if this is an archive with no commentaries (most of the time)
4539
+	// in this case the end of central dir is at 22 bytes of the file end
4540
+	$v_found = 0;
4541
+	if ($v_size > 26) {
4542
+	  @fseek($this->zip_fd, $v_size-22);
4543
+	  if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4544
+	  {
4545
+		// ----- Error log
4546
+		PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4547
+
4548
+		// ----- Return
4549
+		return PclZip::errorCode();
4550
+	  }
4551 4551
 
4552
-      // ----- Read for bytes
4553
-      $v_binary_data = @fread($this->zip_fd, 4);
4554
-      $v_data = @unpack('Vid', $v_binary_data);
4552
+	  // ----- Read for bytes
4553
+	  $v_binary_data = @fread($this->zip_fd, 4);
4554
+	  $v_data = @unpack('Vid', $v_binary_data);
4555 4555
 
4556
-      // ----- Check signature
4557
-      if ($v_data['id'] == 0x06054b50) {
4558
-        $v_found = 1;
4559
-      }
4556
+	  // ----- Check signature
4557
+	  if ($v_data['id'] == 0x06054b50) {
4558
+		$v_found = 1;
4559
+	  }
4560 4560
 
4561
-      $v_pos = ftell($this->zip_fd);
4562
-    }
4561
+	  $v_pos = ftell($this->zip_fd);
4562
+	}
4563 4563
 
4564
-    // ----- Go back to the maximum possible size of the Central Dir End Record
4565
-    if (!$v_found) {
4566
-      $v_maximum_size = 65557; // 0xFFFF + 22;
4567
-      if ($v_maximum_size > $v_size)
4568
-        $v_maximum_size = $v_size;
4569
-      @fseek($this->zip_fd, $v_size-$v_maximum_size);
4570
-      if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4571
-      {
4572
-        // ----- Error log
4573
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4574
-
4575
-        // ----- Return
4576
-        return PclZip::errorCode();
4577
-      }
4564
+	// ----- Go back to the maximum possible size of the Central Dir End Record
4565
+	if (!$v_found) {
4566
+	  $v_maximum_size = 65557; // 0xFFFF + 22;
4567
+	  if ($v_maximum_size > $v_size)
4568
+		$v_maximum_size = $v_size;
4569
+	  @fseek($this->zip_fd, $v_size-$v_maximum_size);
4570
+	  if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4571
+	  {
4572
+		// ----- Error log
4573
+		PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4574
+
4575
+		// ----- Return
4576
+		return PclZip::errorCode();
4577
+	  }
4578 4578
 
4579
-      // ----- Read byte per byte in order to find the signature
4580
-      $v_pos = ftell($this->zip_fd);
4581
-      $v_bytes = 0x00000000;
4582
-      while ($v_pos < $v_size)
4583
-      {
4584
-        // ----- Read a byte
4585
-        $v_byte = @fread($this->zip_fd, 1);
4586
-
4587
-        // -----  Add the byte
4588
-        //$v_bytes = ($v_bytes << 8) | Ord($v_byte);
4589
-        // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
4590
-        // Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
4591
-        $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
4592
-
4593
-        // ----- Compare the bytes
4594
-        if ($v_bytes == 0x504b0506)
4595
-        {
4596
-          $v_pos++;
4597
-          break;
4598
-        }
4599
-
4600
-        $v_pos++;
4601
-      }
4579
+	  // ----- Read byte per byte in order to find the signature
4580
+	  $v_pos = ftell($this->zip_fd);
4581
+	  $v_bytes = 0x00000000;
4582
+	  while ($v_pos < $v_size)
4583
+	  {
4584
+		// ----- Read a byte
4585
+		$v_byte = @fread($this->zip_fd, 1);
4586
+
4587
+		// -----  Add the byte
4588
+		//$v_bytes = ($v_bytes << 8) | Ord($v_byte);
4589
+		// Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
4590
+		// Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
4591
+		$v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
4592
+
4593
+		// ----- Compare the bytes
4594
+		if ($v_bytes == 0x504b0506)
4595
+		{
4596
+		  $v_pos++;
4597
+		  break;
4598
+		}
4599
+
4600
+		$v_pos++;
4601
+	  }
4602 4602
 
4603
-      // ----- Look if not found end of central dir
4604
-      if ($v_pos == $v_size)
4605
-      {
4603
+	  // ----- Look if not found end of central dir
4604
+	  if ($v_pos == $v_size)
4605
+	  {
4606 4606
 
4607
-        // ----- Error log
4608
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
4607
+		// ----- Error log
4608
+		PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
4609 4609
 
4610
-        // ----- Return
4611
-        return PclZip::errorCode();
4612
-      }
4613
-    }
4610
+		// ----- Return
4611
+		return PclZip::errorCode();
4612
+	  }
4613
+	}
4614 4614
 
4615
-    // ----- Read the first 18 bytes of the header
4616
-    $v_binary_data = fread($this->zip_fd, 18);
4615
+	// ----- Read the first 18 bytes of the header
4616
+	$v_binary_data = fread($this->zip_fd, 18);
4617 4617
 
4618
-    // ----- Look for invalid block size
4619
-    if (strlen($v_binary_data) != 18)
4620
-    {
4618
+	// ----- Look for invalid block size
4619
+	if (strlen($v_binary_data) != 18)
4620
+	{
4621 4621
 
4622
-      // ----- Error log
4623
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4622
+	  // ----- Error log
4623
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4624 4624
 
4625
-      // ----- Return
4626
-      return PclZip::errorCode();
4627
-    }
4625
+	  // ----- Return
4626
+	  return PclZip::errorCode();
4627
+	}
4628 4628
 
4629
-    // ----- Extract the values
4630
-    $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
4629
+	// ----- Extract the values
4630
+	$v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
4631 4631
 
4632
-    // ----- Check the global size
4633
-    if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
4632
+	// ----- Check the global size
4633
+	if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
4634 4634
 
4635 4635
 	  // ----- Removed in release 2.2 see readme file
4636 4636
 	  // The check of the file size is a little too strict.
4637 4637
 	  // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
4638 4638
 	  // While decrypted, zip has training 0 bytes
4639 4639
 	  if (0) {
4640
-      // ----- Error log
4641
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
4642
-	                       'The central dir is not at the end of the archive.'
4640
+	  // ----- Error log
4641
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
4642
+						   'The central dir is not at the end of the archive.'
4643 4643
 						   .' Some trailing bytes exists after the archive.');
4644 4644
 
4645
-      // ----- Return
4646
-      return PclZip::errorCode();
4645
+	  // ----- Return
4646
+	  return PclZip::errorCode();
4647 4647
 	  }
4648
-    }
4648
+	}
4649 4649
 
4650
-    // ----- Get comment
4651
-    if ($v_data['comment_size'] != 0) {
4652
-      $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4653
-    }
4654
-    else
4655
-      $p_central_dir['comment'] = '';
4656
-
4657
-    $p_central_dir['entries'] = $v_data['entries'];
4658
-    $p_central_dir['disk_entries'] = $v_data['disk_entries'];
4659
-    $p_central_dir['offset'] = $v_data['offset'];
4660
-    $p_central_dir['size'] = $v_data['size'];
4661
-    $p_central_dir['disk'] = $v_data['disk'];
4662
-    $p_central_dir['disk_start'] = $v_data['disk_start'];
4663
-
4664
-    // TBC
4665
-    //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
4666
-    //}
4667
-
4668
-    // ----- Return
4669
-    return $v_result;
4650
+	// ----- Get comment
4651
+	if ($v_data['comment_size'] != 0) {
4652
+	  $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4653
+	}
4654
+	else
4655
+	  $p_central_dir['comment'] = '';
4656
+
4657
+	$p_central_dir['entries'] = $v_data['entries'];
4658
+	$p_central_dir['disk_entries'] = $v_data['disk_entries'];
4659
+	$p_central_dir['offset'] = $v_data['offset'];
4660
+	$p_central_dir['size'] = $v_data['size'];
4661
+	$p_central_dir['disk'] = $v_data['disk'];
4662
+	$p_central_dir['disk_start'] = $v_data['disk_start'];
4663
+
4664
+	// TBC
4665
+	//for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
4666
+	//}
4667
+
4668
+	// ----- Return
4669
+	return $v_result;
4670 4670
   }
4671 4671
   // --------------------------------------------------------------------------------
4672 4672
 
@@ -4678,96 +4678,96 @@  discard block
 block discarded – undo
4678 4678
   // --------------------------------------------------------------------------------
4679 4679
   function privDeleteByRule(&$p_result_list, &$p_options)
4680 4680
   {
4681
-    $v_result=1;
4682
-    $v_list_detail = array();
4683
-
4684
-    // ----- Open the zip file
4685
-    if (($v_result=$this->privOpenFd('rb')) != 1)
4686
-    {
4687
-      // ----- Return
4688
-      return $v_result;
4689
-    }
4681
+	$v_result=1;
4682
+	$v_list_detail = array();
4683
+
4684
+	// ----- Open the zip file
4685
+	if (($v_result=$this->privOpenFd('rb')) != 1)
4686
+	{
4687
+	  // ----- Return
4688
+	  return $v_result;
4689
+	}
4690 4690
 
4691
-    // ----- Read the central directory informations
4692
-    $v_central_dir = array();
4693
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
4694
-    {
4695
-      $this->privCloseFd();
4696
-      return $v_result;
4697
-    }
4691
+	// ----- Read the central directory informations
4692
+	$v_central_dir = array();
4693
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
4694
+	{
4695
+	  $this->privCloseFd();
4696
+	  return $v_result;
4697
+	}
4698 4698
 
4699
-    // ----- Go to beginning of File
4700
-    @rewind($this->zip_fd);
4699
+	// ----- Go to beginning of File
4700
+	@rewind($this->zip_fd);
4701 4701
 
4702
-    // ----- Scan all the files
4703
-    // ----- Start at beginning of Central Dir
4704
-    $v_pos_entry = $v_central_dir['offset'];
4705
-    @rewind($this->zip_fd);
4706
-    if (@fseek($this->zip_fd, $v_pos_entry))
4707
-    {
4708
-      // ----- Close the zip file
4709
-      $this->privCloseFd();
4702
+	// ----- Scan all the files
4703
+	// ----- Start at beginning of Central Dir
4704
+	$v_pos_entry = $v_central_dir['offset'];
4705
+	@rewind($this->zip_fd);
4706
+	if (@fseek($this->zip_fd, $v_pos_entry))
4707
+	{
4708
+	  // ----- Close the zip file
4709
+	  $this->privCloseFd();
4710 4710
 
4711
-      // ----- Error log
4712
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4711
+	  // ----- Error log
4712
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4713 4713
 
4714
-      // ----- Return
4715
-      return PclZip::errorCode();
4716
-    }
4714
+	  // ----- Return
4715
+	  return PclZip::errorCode();
4716
+	}
4717 4717
 
4718
-    // ----- Read each entry
4719
-    $v_header_list = array();
4720
-    $j_start = 0;
4721
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4722
-    {
4718
+	// ----- Read each entry
4719
+	$v_header_list = array();
4720
+	$j_start = 0;
4721
+	for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4722
+	{
4723 4723
 
4724
-      // ----- Read the file header
4725
-      $v_header_list[$v_nb_extracted] = array();
4726
-      if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
4727
-      {
4728
-        // ----- Close the zip file
4729
-        $this->privCloseFd();
4724
+	  // ----- Read the file header
4725
+	  $v_header_list[$v_nb_extracted] = array();
4726
+	  if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
4727
+	  {
4728
+		// ----- Close the zip file
4729
+		$this->privCloseFd();
4730 4730
 
4731
-        return $v_result;
4732
-      }
4731
+		return $v_result;
4732
+	  }
4733 4733
 
4734 4734
 
4735
-      // ----- Store the index
4736
-      $v_header_list[$v_nb_extracted]['index'] = $i;
4737
-
4738
-      // ----- Look for the specific extract rules
4739
-      $v_found = false;
4740
-
4741
-      // ----- Look for extract by name rule
4742
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
4743
-          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4744
-
4745
-          // ----- Look if the filename is in the list
4746
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4747
-
4748
-              // ----- Look for a directory
4749
-              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4750
-
4751
-                  // ----- Look if the directory is in the filename path
4752
-                  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4753
-                      && (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])) {
4754
-                      $v_found = true;
4755
-                  }
4756
-                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4757
-                          && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4758
-                      $v_found = true;
4759
-                  }
4760
-              }
4761
-              // ----- Look for a filename
4762
-              elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
4763
-                  $v_found = true;
4764
-              }
4765
-          }
4766
-      }
4735
+	  // ----- Store the index
4736
+	  $v_header_list[$v_nb_extracted]['index'] = $i;
4737
+
4738
+	  // ----- Look for the specific extract rules
4739
+	  $v_found = false;
4740
+
4741
+	  // ----- Look for extract by name rule
4742
+	  if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
4743
+		  && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4744
+
4745
+		  // ----- Look if the filename is in the list
4746
+		  for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4747
+
4748
+			  // ----- Look for a directory
4749
+			  if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4750
+
4751
+				  // ----- Look if the directory is in the filename path
4752
+				  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4753
+					  && (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])) {
4754
+					  $v_found = true;
4755
+				  }
4756
+				  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4757
+						  && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4758
+					  $v_found = true;
4759
+				  }
4760
+			  }
4761
+			  // ----- Look for a filename
4762
+			  elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
4763
+				  $v_found = true;
4764
+			  }
4765
+		  }
4766
+	  }
4767 4767
 
4768
-      // ----- Look for extract by ereg rule
4769
-      // ereg() is deprecated with PHP 5.3
4770
-      /*
4768
+	  // ----- Look for extract by ereg rule
4769
+	  // ereg() is deprecated with PHP 5.3
4770
+	  /*
4771 4771
       else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
4772 4772
                && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
4773 4773
 
@@ -4777,201 +4777,201 @@  discard block
 block discarded – undo
4777 4777
       }
4778 4778
       */
4779 4779
 
4780
-      // ----- Look for extract by preg rule
4781
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
4782
-               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4780
+	  // ----- Look for extract by preg rule
4781
+	  else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
4782
+			   && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4783 4783
 
4784
-          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4785
-              $v_found = true;
4786
-          }
4787
-      }
4784
+		  if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4785
+			  $v_found = true;
4786
+		  }
4787
+	  }
4788 4788
 
4789
-      // ----- Look for extract by index rule
4790
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4791
-               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4789
+	  // ----- Look for extract by index rule
4790
+	  else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4791
+			   && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4792 4792
 
4793
-          // ----- Look if the index is in the list
4794
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4793
+		  // ----- Look if the index is in the list
4794
+		  for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4795 4795
 
4796
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4797
-                  $v_found = true;
4798
-              }
4799
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4800
-                  $j_start = $j+1;
4801
-              }
4796
+			  if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4797
+				  $v_found = true;
4798
+			  }
4799
+			  if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4800
+				  $j_start = $j+1;
4801
+			  }
4802 4802
 
4803
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4804
-                  break;
4805
-              }
4806
-          }
4807
-      }
4808
-      else {
4809
-      	$v_found = true;
4810
-      }
4803
+			  if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4804
+				  break;
4805
+			  }
4806
+		  }
4807
+	  }
4808
+	  else {
4809
+	  	$v_found = true;
4810
+	  }
4811 4811
 
4812
-      // ----- Look for deletion
4813
-      if ($v_found)
4814
-      {
4815
-        unset($v_header_list[$v_nb_extracted]);
4816
-      }
4817
-      else
4818
-      {
4819
-        $v_nb_extracted++;
4820
-      }
4821
-    }
4812
+	  // ----- Look for deletion
4813
+	  if ($v_found)
4814
+	  {
4815
+		unset($v_header_list[$v_nb_extracted]);
4816
+	  }
4817
+	  else
4818
+	  {
4819
+		$v_nb_extracted++;
4820
+	  }
4821
+	}
4822 4822
 
4823
-    // ----- Look if something need to be deleted
4824
-    if ($v_nb_extracted > 0) {
4825
-
4826
-        // ----- Creates a temporay file
4827
-        $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
4828
-
4829
-        // ----- Creates a temporary zip archive
4830
-        $v_temp_zip = new PclZip($v_zip_temp_name);
4831
-
4832
-        // ----- Open the temporary zip file in write mode
4833
-        if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
4834
-            $this->privCloseFd();
4835
-
4836
-            // ----- Return
4837
-            return $v_result;
4838
-        }
4839
-
4840
-        // ----- Look which file need to be kept
4841
-        for ($i=0; $i<sizeof($v_header_list); $i++) {
4842
-
4843
-            // ----- Calculate the position of the header
4844
-            @rewind($this->zip_fd);
4845
-            if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
4846
-                // ----- Close the zip file
4847
-                $this->privCloseFd();
4848
-                $v_temp_zip->privCloseFd();
4849
-                @unlink($v_zip_temp_name);
4850
-
4851
-                // ----- Error log
4852
-                PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4853
-
4854
-                // ----- Return
4855
-                return PclZip::errorCode();
4856
-            }
4857
-
4858
-            // ----- Read the file header
4859
-            $v_local_header = array();
4860
-            if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
4861
-                // ----- Close the zip file
4862
-                $this->privCloseFd();
4863
-                $v_temp_zip->privCloseFd();
4864
-                @unlink($v_zip_temp_name);
4865
-
4866
-                // ----- Return
4867
-                return $v_result;
4868
-            }
4869
-
4870
-            // ----- Check that local file header is same as central file header
4871
-            if ($this->privCheckFileHeaders($v_local_header,
4872
-			                                $v_header_list[$i]) != 1) {
4873
-                // TBC
4874
-            }
4875
-            unset($v_local_header);
4876
-
4877
-            // ----- Write the file header
4878
-            if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
4879
-                // ----- Close the zip file
4880
-                $this->privCloseFd();
4881
-                $v_temp_zip->privCloseFd();
4882
-                @unlink($v_zip_temp_name);
4883
-
4884
-                // ----- Return
4885
-                return $v_result;
4886
-            }
4887
-
4888
-            // ----- Read/write the data block
4889
-            if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
4890
-                // ----- Close the zip file
4891
-                $this->privCloseFd();
4892
-                $v_temp_zip->privCloseFd();
4893
-                @unlink($v_zip_temp_name);
4894
-
4895
-                // ----- Return
4896
-                return $v_result;
4897
-            }
4898
-        }
4899
-
4900
-        // ----- Store the offset of the central dir
4901
-        $v_offset = @ftell($v_temp_zip->zip_fd);
4902
-
4903
-        // ----- Re-Create the Central Dir files header
4904
-        for ($i=0; $i<sizeof($v_header_list); $i++) {
4905
-            // ----- Create the file header
4906
-            if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4907
-                $v_temp_zip->privCloseFd();
4908
-                $this->privCloseFd();
4909
-                @unlink($v_zip_temp_name);
4910
-
4911
-                // ----- Return
4912
-                return $v_result;
4913
-            }
4914
-
4915
-            // ----- Transform the header to a 'usable' info
4916
-            $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
4917
-        }
4918
-
4919
-
4920
-        // ----- Zip file comment
4921
-        $v_comment = '';
4922
-        if (isset($p_options[PCLZIP_OPT_COMMENT])) {
4923
-          $v_comment = $p_options[PCLZIP_OPT_COMMENT];
4924
-        }
4925
-
4926
-        // ----- Calculate the size of the central header
4927
-        $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
4928
-
4929
-        // ----- Create the central dir footer
4930
-        if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
4931
-            // ----- Reset the file list
4932
-            unset($v_header_list);
4933
-            $v_temp_zip->privCloseFd();
4934
-            $this->privCloseFd();
4935
-            @unlink($v_zip_temp_name);
4936
-
4937
-            // ----- Return
4938
-            return $v_result;
4939
-        }
4940
-
4941
-        // ----- Close
4942
-        $v_temp_zip->privCloseFd();
4943
-        $this->privCloseFd();
4944
-
4945
-        // ----- Delete the zip file
4946
-        // TBC : I should test the result ...
4947
-        @unlink($this->zipname);
4948
-
4949
-        // ----- Rename the temporary file
4950
-        // TBC : I should test the result ...
4951
-        //@rename($v_zip_temp_name, $this->zipname);
4952
-        PclZipUtilRename($v_zip_temp_name, $this->zipname);
4953
-
4954
-        // ----- Destroy the temporary archive
4955
-        unset($v_temp_zip);
4956
-    }
4823
+	// ----- Look if something need to be deleted
4824
+	if ($v_nb_extracted > 0) {
4825
+
4826
+		// ----- Creates a temporay file
4827
+		$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
4828
+
4829
+		// ----- Creates a temporary zip archive
4830
+		$v_temp_zip = new PclZip($v_zip_temp_name);
4831
+
4832
+		// ----- Open the temporary zip file in write mode
4833
+		if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
4834
+			$this->privCloseFd();
4835
+
4836
+			// ----- Return
4837
+			return $v_result;
4838
+		}
4839
+
4840
+		// ----- Look which file need to be kept
4841
+		for ($i=0; $i<sizeof($v_header_list); $i++) {
4842
+
4843
+			// ----- Calculate the position of the header
4844
+			@rewind($this->zip_fd);
4845
+			if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
4846
+				// ----- Close the zip file
4847
+				$this->privCloseFd();
4848
+				$v_temp_zip->privCloseFd();
4849
+				@unlink($v_zip_temp_name);
4850
+
4851
+				// ----- Error log
4852
+				PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4853
+
4854
+				// ----- Return
4855
+				return PclZip::errorCode();
4856
+			}
4857
+
4858
+			// ----- Read the file header
4859
+			$v_local_header = array();
4860
+			if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
4861
+				// ----- Close the zip file
4862
+				$this->privCloseFd();
4863
+				$v_temp_zip->privCloseFd();
4864
+				@unlink($v_zip_temp_name);
4865
+
4866
+				// ----- Return
4867
+				return $v_result;
4868
+			}
4869
+
4870
+			// ----- Check that local file header is same as central file header
4871
+			if ($this->privCheckFileHeaders($v_local_header,
4872
+											$v_header_list[$i]) != 1) {
4873
+				// TBC
4874
+			}
4875
+			unset($v_local_header);
4876
+
4877
+			// ----- Write the file header
4878
+			if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
4879
+				// ----- Close the zip file
4880
+				$this->privCloseFd();
4881
+				$v_temp_zip->privCloseFd();
4882
+				@unlink($v_zip_temp_name);
4883
+
4884
+				// ----- Return
4885
+				return $v_result;
4886
+			}
4887
+
4888
+			// ----- Read/write the data block
4889
+			if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
4890
+				// ----- Close the zip file
4891
+				$this->privCloseFd();
4892
+				$v_temp_zip->privCloseFd();
4893
+				@unlink($v_zip_temp_name);
4894
+
4895
+				// ----- Return
4896
+				return $v_result;
4897
+			}
4898
+		}
4899
+
4900
+		// ----- Store the offset of the central dir
4901
+		$v_offset = @ftell($v_temp_zip->zip_fd);
4902
+
4903
+		// ----- Re-Create the Central Dir files header
4904
+		for ($i=0; $i<sizeof($v_header_list); $i++) {
4905
+			// ----- Create the file header
4906
+			if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4907
+				$v_temp_zip->privCloseFd();
4908
+				$this->privCloseFd();
4909
+				@unlink($v_zip_temp_name);
4910
+
4911
+				// ----- Return
4912
+				return $v_result;
4913
+			}
4914
+
4915
+			// ----- Transform the header to a 'usable' info
4916
+			$v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
4917
+		}
4918
+
4919
+
4920
+		// ----- Zip file comment
4921
+		$v_comment = '';
4922
+		if (isset($p_options[PCLZIP_OPT_COMMENT])) {
4923
+		  $v_comment = $p_options[PCLZIP_OPT_COMMENT];
4924
+		}
4925
+
4926
+		// ----- Calculate the size of the central header
4927
+		$v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
4928
+
4929
+		// ----- Create the central dir footer
4930
+		if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
4931
+			// ----- Reset the file list
4932
+			unset($v_header_list);
4933
+			$v_temp_zip->privCloseFd();
4934
+			$this->privCloseFd();
4935
+			@unlink($v_zip_temp_name);
4936
+
4937
+			// ----- Return
4938
+			return $v_result;
4939
+		}
4940
+
4941
+		// ----- Close
4942
+		$v_temp_zip->privCloseFd();
4943
+		$this->privCloseFd();
4944
+
4945
+		// ----- Delete the zip file
4946
+		// TBC : I should test the result ...
4947
+		@unlink($this->zipname);
4948
+
4949
+		// ----- Rename the temporary file
4950
+		// TBC : I should test the result ...
4951
+		//@rename($v_zip_temp_name, $this->zipname);
4952
+		PclZipUtilRename($v_zip_temp_name, $this->zipname);
4953
+
4954
+		// ----- Destroy the temporary archive
4955
+		unset($v_temp_zip);
4956
+	}
4957 4957
 
4958
-    // ----- Remove every files : reset the file
4959
-    else if ($v_central_dir['entries'] != 0) {
4960
-        $this->privCloseFd();
4958
+	// ----- Remove every files : reset the file
4959
+	else if ($v_central_dir['entries'] != 0) {
4960
+		$this->privCloseFd();
4961 4961
 
4962
-        if (($v_result = $this->privOpenFd('wb')) != 1) {
4963
-          return $v_result;
4964
-        }
4962
+		if (($v_result = $this->privOpenFd('wb')) != 1) {
4963
+		  return $v_result;
4964
+		}
4965 4965
 
4966
-        if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
4967
-          return $v_result;
4968
-        }
4966
+		if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
4967
+		  return $v_result;
4968
+		}
4969 4969
 
4970
-        $this->privCloseFd();
4971
-    }
4970
+		$this->privCloseFd();
4971
+	}
4972 4972
 
4973
-    // ----- Return
4974
-    return $v_result;
4973
+	// ----- Return
4974
+	return $v_result;
4975 4975
   }
4976 4976
   // --------------------------------------------------------------------------------
4977 4977
 
@@ -4988,49 +4988,49 @@  discard block
 block discarded – undo
4988 4988
   // --------------------------------------------------------------------------------
4989 4989
   function privDirCheck($p_dir, $p_is_dir=false)
4990 4990
   {
4991
-    $v_result = 1;
4991
+	$v_result = 1;
4992 4992
 
4993 4993
 
4994
-    // ----- Remove the final '/'
4995
-    if (($p_is_dir) && (substr($p_dir, -1)=='/'))
4996
-    {
4997
-      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
4998
-    }
4994
+	// ----- Remove the final '/'
4995
+	if (($p_is_dir) && (substr($p_dir, -1)=='/'))
4996
+	{
4997
+	  $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
4998
+	}
4999 4999
 
5000
-    // ----- Check the directory availability
5001
-    if ((is_dir($p_dir)) || ($p_dir == ""))
5002
-    {
5003
-      return 1;
5004
-    }
5000
+	// ----- Check the directory availability
5001
+	if ((is_dir($p_dir)) || ($p_dir == ""))
5002
+	{
5003
+	  return 1;
5004
+	}
5005 5005
 
5006
-    // ----- Extract parent directory
5007
-    $p_parent_dir = dirname($p_dir);
5008
-
5009
-    // ----- Just a check
5010
-    if ($p_parent_dir != $p_dir)
5011
-    {
5012
-      // ----- Look for parent directory
5013
-      if ($p_parent_dir != "")
5014
-      {
5015
-        if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
5016
-        {
5017
-          return $v_result;
5018
-        }
5019
-      }
5020
-    }
5006
+	// ----- Extract parent directory
5007
+	$p_parent_dir = dirname($p_dir);
5008
+
5009
+	// ----- Just a check
5010
+	if ($p_parent_dir != $p_dir)
5011
+	{
5012
+	  // ----- Look for parent directory
5013
+	  if ($p_parent_dir != "")
5014
+	  {
5015
+		if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
5016
+		{
5017
+		  return $v_result;
5018
+		}
5019
+	  }
5020
+	}
5021 5021
 
5022
-    // ----- Create the directory
5023
-    if (!@mkdir($p_dir, 0777))
5024
-    {
5025
-      // ----- Error log
5026
-      PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
5022
+	// ----- Create the directory
5023
+	if (!@mkdir($p_dir, 0777))
5024
+	{
5025
+	  // ----- Error log
5026
+	  PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
5027 5027
 
5028
-      // ----- Return
5029
-      return PclZip::errorCode();
5030
-    }
5028
+	  // ----- Return
5029
+	  return PclZip::errorCode();
5030
+	}
5031 5031
 
5032
-    // ----- Return
5033
-    return $v_result;
5032
+	// ----- Return
5033
+	return $v_result;
5034 5034
   }
5035 5035
   // --------------------------------------------------------------------------------
5036 5036
 
@@ -5043,180 +5043,180 @@  discard block
 block discarded – undo
5043 5043
   // --------------------------------------------------------------------------------
5044 5044
   function privMerge(&$p_archive_to_add)
5045 5045
   {
5046
-    $v_result=1;
5046
+	$v_result=1;
5047 5047
 
5048
-    // ----- Look if the archive_to_add exists
5049
-    if (!is_file($p_archive_to_add->zipname))
5050
-    {
5048
+	// ----- Look if the archive_to_add exists
5049
+	if (!is_file($p_archive_to_add->zipname))
5050
+	{
5051 5051
 
5052
-      // ----- Nothing to merge, so merge is a success
5053
-      $v_result = 1;
5052
+	  // ----- Nothing to merge, so merge is a success
5053
+	  $v_result = 1;
5054 5054
 
5055
-      // ----- Return
5056
-      return $v_result;
5057
-    }
5055
+	  // ----- Return
5056
+	  return $v_result;
5057
+	}
5058 5058
 
5059
-    // ----- Look if the archive exists
5060
-    if (!is_file($this->zipname))
5061
-    {
5059
+	// ----- Look if the archive exists
5060
+	if (!is_file($this->zipname))
5061
+	{
5062 5062
 
5063
-      // ----- Do a duplicate
5064
-      $v_result = $this->privDuplicate($p_archive_to_add->zipname);
5063
+	  // ----- Do a duplicate
5064
+	  $v_result = $this->privDuplicate($p_archive_to_add->zipname);
5065 5065
 
5066
-      // ----- Return
5067
-      return $v_result;
5068
-    }
5066
+	  // ----- Return
5067
+	  return $v_result;
5068
+	}
5069 5069
 
5070
-    // ----- Open the zip file
5071
-    if (($v_result=$this->privOpenFd('rb')) != 1)
5072
-    {
5073
-      // ----- Return
5074
-      return $v_result;
5075
-    }
5070
+	// ----- Open the zip file
5071
+	if (($v_result=$this->privOpenFd('rb')) != 1)
5072
+	{
5073
+	  // ----- Return
5074
+	  return $v_result;
5075
+	}
5076 5076
 
5077
-    // ----- Read the central directory informations
5078
-    $v_central_dir = array();
5079
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
5080
-    {
5081
-      $this->privCloseFd();
5082
-      return $v_result;
5083
-    }
5077
+	// ----- Read the central directory informations
5078
+	$v_central_dir = array();
5079
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
5080
+	{
5081
+	  $this->privCloseFd();
5082
+	  return $v_result;
5083
+	}
5084 5084
 
5085
-    // ----- Go to beginning of File
5086
-    @rewind($this->zip_fd);
5085
+	// ----- Go to beginning of File
5086
+	@rewind($this->zip_fd);
5087 5087
 
5088
-    // ----- Open the archive_to_add file
5089
-    if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5090
-    {
5091
-      $this->privCloseFd();
5088
+	// ----- Open the archive_to_add file
5089
+	if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5090
+	{
5091
+	  $this->privCloseFd();
5092 5092
 
5093
-      // ----- Return
5094
-      return $v_result;
5095
-    }
5093
+	  // ----- Return
5094
+	  return $v_result;
5095
+	}
5096 5096
 
5097
-    // ----- Read the central directory informations
5098
-    $v_central_dir_to_add = array();
5099
-    if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
5100
-    {
5101
-      $this->privCloseFd();
5102
-      $p_archive_to_add->privCloseFd();
5097
+	// ----- Read the central directory informations
5098
+	$v_central_dir_to_add = array();
5099
+	if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
5100
+	{
5101
+	  $this->privCloseFd();
5102
+	  $p_archive_to_add->privCloseFd();
5103 5103
 
5104
-      return $v_result;
5105
-    }
5104
+	  return $v_result;
5105
+	}
5106 5106
 
5107
-    // ----- Go to beginning of File
5108
-    @rewind($p_archive_to_add->zip_fd);
5107
+	// ----- Go to beginning of File
5108
+	@rewind($p_archive_to_add->zip_fd);
5109 5109
 
5110
-    // ----- Creates a temporay file
5111
-    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
5110
+	// ----- Creates a temporay file
5111
+	$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
5112 5112
 
5113
-    // ----- Open the temporary file in write mode
5114
-    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
5115
-    {
5116
-      $this->privCloseFd();
5117
-      $p_archive_to_add->privCloseFd();
5113
+	// ----- Open the temporary file in write mode
5114
+	if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
5115
+	{
5116
+	  $this->privCloseFd();
5117
+	  $p_archive_to_add->privCloseFd();
5118 5118
 
5119
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5119
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5120 5120
 
5121
-      // ----- Return
5122
-      return PclZip::errorCode();
5123
-    }
5121
+	  // ----- Return
5122
+	  return PclZip::errorCode();
5123
+	}
5124 5124
 
5125
-    // ----- Copy the files from the archive to the temporary file
5126
-    // TBC : Here I should better append the file and go back to erase the central dir
5127
-    $v_size = $v_central_dir['offset'];
5128
-    while ($v_size != 0)
5129
-    {
5130
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5131
-      $v_buffer = fread($this->zip_fd, $v_read_size);
5132
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5133
-      $v_size -= $v_read_size;
5134
-    }
5125
+	// ----- Copy the files from the archive to the temporary file
5126
+	// TBC : Here I should better append the file and go back to erase the central dir
5127
+	$v_size = $v_central_dir['offset'];
5128
+	while ($v_size != 0)
5129
+	{
5130
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5131
+	  $v_buffer = fread($this->zip_fd, $v_read_size);
5132
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5133
+	  $v_size -= $v_read_size;
5134
+	}
5135 5135
 
5136
-    // ----- Copy the files from the archive_to_add into the temporary file
5137
-    $v_size = $v_central_dir_to_add['offset'];
5138
-    while ($v_size != 0)
5139
-    {
5140
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5141
-      $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5142
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5143
-      $v_size -= $v_read_size;
5144
-    }
5136
+	// ----- Copy the files from the archive_to_add into the temporary file
5137
+	$v_size = $v_central_dir_to_add['offset'];
5138
+	while ($v_size != 0)
5139
+	{
5140
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5141
+	  $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5142
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5143
+	  $v_size -= $v_read_size;
5144
+	}
5145 5145
 
5146
-    // ----- Store the offset of the central dir
5147
-    $v_offset = @ftell($v_zip_temp_fd);
5148
-
5149
-    // ----- Copy the block of file headers from the old archive
5150
-    $v_size = $v_central_dir['size'];
5151
-    while ($v_size != 0)
5152
-    {
5153
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5154
-      $v_buffer = @fread($this->zip_fd, $v_read_size);
5155
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5156
-      $v_size -= $v_read_size;
5157
-    }
5146
+	// ----- Store the offset of the central dir
5147
+	$v_offset = @ftell($v_zip_temp_fd);
5148
+
5149
+	// ----- Copy the block of file headers from the old archive
5150
+	$v_size = $v_central_dir['size'];
5151
+	while ($v_size != 0)
5152
+	{
5153
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5154
+	  $v_buffer = @fread($this->zip_fd, $v_read_size);
5155
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5156
+	  $v_size -= $v_read_size;
5157
+	}
5158 5158
 
5159
-    // ----- Copy the block of file headers from the archive_to_add
5160
-    $v_size = $v_central_dir_to_add['size'];
5161
-    while ($v_size != 0)
5162
-    {
5163
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5164
-      $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5165
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5166
-      $v_size -= $v_read_size;
5167
-    }
5159
+	// ----- Copy the block of file headers from the archive_to_add
5160
+	$v_size = $v_central_dir_to_add['size'];
5161
+	while ($v_size != 0)
5162
+	{
5163
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5164
+	  $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5165
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5166
+	  $v_size -= $v_read_size;
5167
+	}
5168 5168
 
5169
-    // ----- Merge the file comments
5170
-    $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
5169
+	// ----- Merge the file comments
5170
+	$v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
5171 5171
 
5172
-    // ----- Calculate the size of the (new) central header
5173
-    $v_size = @ftell($v_zip_temp_fd)-$v_offset;
5172
+	// ----- Calculate the size of the (new) central header
5173
+	$v_size = @ftell($v_zip_temp_fd)-$v_offset;
5174 5174
 
5175
-    // ----- Swap the file descriptor
5176
-    // Here is a trick : I swap the temporary fd with the zip fd, in order to use
5177
-    // the following methods on the temporary fil and not the real archive fd
5178
-    $v_swap = $this->zip_fd;
5179
-    $this->zip_fd = $v_zip_temp_fd;
5180
-    $v_zip_temp_fd = $v_swap;
5175
+	// ----- Swap the file descriptor
5176
+	// Here is a trick : I swap the temporary fd with the zip fd, in order to use
5177
+	// the following methods on the temporary fil and not the real archive fd
5178
+	$v_swap = $this->zip_fd;
5179
+	$this->zip_fd = $v_zip_temp_fd;
5180
+	$v_zip_temp_fd = $v_swap;
5181 5181
 
5182
-    // ----- Create the central dir footer
5183
-    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5184
-    {
5185
-      $this->privCloseFd();
5186
-      $p_archive_to_add->privCloseFd();
5187
-      @fclose($v_zip_temp_fd);
5188
-      $this->zip_fd = null;
5182
+	// ----- Create the central dir footer
5183
+	if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5184
+	{
5185
+	  $this->privCloseFd();
5186
+	  $p_archive_to_add->privCloseFd();
5187
+	  @fclose($v_zip_temp_fd);
5188
+	  $this->zip_fd = null;
5189 5189
 
5190
-      // ----- Reset the file list
5191
-      unset($v_header_list);
5190
+	  // ----- Reset the file list
5191
+	  unset($v_header_list);
5192 5192
 
5193
-      // ----- Return
5194
-      return $v_result;
5195
-    }
5193
+	  // ----- Return
5194
+	  return $v_result;
5195
+	}
5196 5196
 
5197
-    // ----- Swap back the file descriptor
5198
-    $v_swap = $this->zip_fd;
5199
-    $this->zip_fd = $v_zip_temp_fd;
5200
-    $v_zip_temp_fd = $v_swap;
5197
+	// ----- Swap back the file descriptor
5198
+	$v_swap = $this->zip_fd;
5199
+	$this->zip_fd = $v_zip_temp_fd;
5200
+	$v_zip_temp_fd = $v_swap;
5201 5201
 
5202
-    // ----- Close
5203
-    $this->privCloseFd();
5204
-    $p_archive_to_add->privCloseFd();
5202
+	// ----- Close
5203
+	$this->privCloseFd();
5204
+	$p_archive_to_add->privCloseFd();
5205 5205
 
5206
-    // ----- Close the temporary file
5207
-    @fclose($v_zip_temp_fd);
5206
+	// ----- Close the temporary file
5207
+	@fclose($v_zip_temp_fd);
5208 5208
 
5209
-    // ----- Delete the zip file
5210
-    // TBC : I should test the result ...
5211
-    @unlink($this->zipname);
5209
+	// ----- Delete the zip file
5210
+	// TBC : I should test the result ...
5211
+	@unlink($this->zipname);
5212 5212
 
5213
-    // ----- Rename the temporary file
5214
-    // TBC : I should test the result ...
5215
-    //@rename($v_zip_temp_name, $this->zipname);
5216
-    PclZipUtilRename($v_zip_temp_name, $this->zipname);
5213
+	// ----- Rename the temporary file
5214
+	// TBC : I should test the result ...
5215
+	//@rename($v_zip_temp_name, $this->zipname);
5216
+	PclZipUtilRename($v_zip_temp_name, $this->zipname);
5217 5217
 
5218
-    // ----- Return
5219
-    return $v_result;
5218
+	// ----- Return
5219
+	return $v_result;
5220 5220
   }
5221 5221
   // --------------------------------------------------------------------------------
5222 5222
 
@@ -5228,56 +5228,56 @@  discard block
 block discarded – undo
5228 5228
   // --------------------------------------------------------------------------------
5229 5229
   function privDuplicate($p_archive_filename)
5230 5230
   {
5231
-    $v_result=1;
5231
+	$v_result=1;
5232 5232
 
5233
-    // ----- Look if the $p_archive_filename exists
5234
-    if (!is_file($p_archive_filename))
5235
-    {
5233
+	// ----- Look if the $p_archive_filename exists
5234
+	if (!is_file($p_archive_filename))
5235
+	{
5236 5236
 
5237
-      // ----- Nothing to duplicate, so duplicate is a success.
5238
-      $v_result = 1;
5237
+	  // ----- Nothing to duplicate, so duplicate is a success.
5238
+	  $v_result = 1;
5239 5239
 
5240
-      // ----- Return
5241
-      return $v_result;
5242
-    }
5240
+	  // ----- Return
5241
+	  return $v_result;
5242
+	}
5243 5243
 
5244
-    // ----- Open the zip file
5245
-    if (($v_result=$this->privOpenFd('wb')) != 1)
5246
-    {
5247
-      // ----- Return
5248
-      return $v_result;
5249
-    }
5244
+	// ----- Open the zip file
5245
+	if (($v_result=$this->privOpenFd('wb')) != 1)
5246
+	{
5247
+	  // ----- Return
5248
+	  return $v_result;
5249
+	}
5250 5250
 
5251
-    // ----- Open the temporary file in write mode
5252
-    if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
5253
-    {
5254
-      $this->privCloseFd();
5251
+	// ----- Open the temporary file in write mode
5252
+	if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
5253
+	{
5254
+	  $this->privCloseFd();
5255 5255
 
5256
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5256
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5257 5257
 
5258
-      // ----- Return
5259
-      return PclZip::errorCode();
5260
-    }
5258
+	  // ----- Return
5259
+	  return PclZip::errorCode();
5260
+	}
5261 5261
 
5262
-    // ----- Copy the files from the archive to the temporary file
5263
-    // TBC : Here I should better append the file and go back to erase the central dir
5264
-    $v_size = filesize($p_archive_filename);
5265
-    while ($v_size != 0)
5266
-    {
5267
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5268
-      $v_buffer = fread($v_zip_temp_fd, $v_read_size);
5269
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
5270
-      $v_size -= $v_read_size;
5271
-    }
5262
+	// ----- Copy the files from the archive to the temporary file
5263
+	// TBC : Here I should better append the file and go back to erase the central dir
5264
+	$v_size = filesize($p_archive_filename);
5265
+	while ($v_size != 0)
5266
+	{
5267
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5268
+	  $v_buffer = fread($v_zip_temp_fd, $v_read_size);
5269
+	  @fwrite($this->zip_fd, $v_buffer, $v_read_size);
5270
+	  $v_size -= $v_read_size;
5271
+	}
5272 5272
 
5273
-    // ----- Close
5274
-    $this->privCloseFd();
5273
+	// ----- Close
5274
+	$this->privCloseFd();
5275 5275
 
5276
-    // ----- Close the temporary file
5277
-    @fclose($v_zip_temp_fd);
5276
+	// ----- Close the temporary file
5277
+	@fclose($v_zip_temp_fd);
5278 5278
 
5279
-    // ----- Return
5280
-    return $v_result;
5279
+	// ----- Return
5280
+	return $v_result;
5281 5281
   }
5282 5282
   // --------------------------------------------------------------------------------
5283 5283
 
@@ -5288,13 +5288,13 @@  discard block
 block discarded – undo
5288 5288
   // --------------------------------------------------------------------------------
5289 5289
   function privErrorLog($p_error_code=0, $p_error_string='')
5290 5290
   {
5291
-    if (PCLZIP_ERROR_EXTERNAL == 1) {
5292
-      PclError($p_error_code, $p_error_string);
5293
-    }
5294
-    else {
5295
-      $this->error_code = $p_error_code;
5296
-      $this->error_string = $p_error_string;
5297
-    }
5291
+	if (PCLZIP_ERROR_EXTERNAL == 1) {
5292
+	  PclError($p_error_code, $p_error_string);
5293
+	}
5294
+	else {
5295
+	  $this->error_code = $p_error_code;
5296
+	  $this->error_string = $p_error_string;
5297
+	}
5298 5298
   }
5299 5299
   // --------------------------------------------------------------------------------
5300 5300
 
@@ -5305,13 +5305,13 @@  discard block
 block discarded – undo
5305 5305
   // --------------------------------------------------------------------------------
5306 5306
   function privErrorReset()
5307 5307
   {
5308
-    if (PCLZIP_ERROR_EXTERNAL == 1) {
5309
-      PclErrorReset();
5310
-    }
5311
-    else {
5312
-      $this->error_code = 0;
5313
-      $this->error_string = '';
5314
-    }
5308
+	if (PCLZIP_ERROR_EXTERNAL == 1) {
5309
+	  PclErrorReset();
5310
+	}
5311
+	else {
5312
+	  $this->error_code = 0;
5313
+	  $this->error_string = '';
5314
+	}
5315 5315
   }
5316 5316
   // --------------------------------------------------------------------------------
5317 5317
 
@@ -5323,17 +5323,17 @@  discard block
 block discarded – undo
5323 5323
   // --------------------------------------------------------------------------------
5324 5324
   function privDisableMagicQuotes()
5325 5325
   {
5326
-    $v_result=1;
5326
+	$v_result=1;
5327 5327
 
5328
-    // ----- Look if function exists
5329
-    if (   (!function_exists("get_magic_quotes_runtime"))
5330
-	    || (!function_exists("set_magic_quotes_runtime"))) {
5331
-      return $v_result;
5328
+	// ----- Look if function exists
5329
+	if (   (!function_exists("get_magic_quotes_runtime"))
5330
+		|| (!function_exists("set_magic_quotes_runtime"))) {
5331
+	  return $v_result;
5332 5332
 	}
5333 5333
 
5334
-    // ----- Look if already done
5335
-    if ($this->magic_quotes_status != -1) {
5336
-      return $v_result;
5334
+	// ----- Look if already done
5335
+	if ($this->magic_quotes_status != -1) {
5336
+	  return $v_result;
5337 5337
 	}
5338 5338
 
5339 5339
 	// ----- Get and memorize the magic_quote value
@@ -5344,8 +5344,8 @@  discard block
 block discarded – undo
5344 5344
 	  @set_magic_quotes_runtime(0);
5345 5345
 	}
5346 5346
 
5347
-    // ----- Return
5348
-    return $v_result;
5347
+	// ----- Return
5348
+	return $v_result;
5349 5349
   }
5350 5350
   // --------------------------------------------------------------------------------
5351 5351
 
@@ -5357,17 +5357,17 @@  discard block
 block discarded – undo
5357 5357
   // --------------------------------------------------------------------------------
5358 5358
   function privSwapBackMagicQuotes()
5359 5359
   {
5360
-    $v_result=1;
5360
+	$v_result=1;
5361 5361
 
5362
-    // ----- Look if function exists
5363
-    if (   (!function_exists("get_magic_quotes_runtime"))
5364
-	    || (!function_exists("set_magic_quotes_runtime"))) {
5365
-      return $v_result;
5362
+	// ----- Look if function exists
5363
+	if (   (!function_exists("get_magic_quotes_runtime"))
5364
+		|| (!function_exists("set_magic_quotes_runtime"))) {
5365
+	  return $v_result;
5366 5366
 	}
5367 5367
 
5368
-    // ----- Look if something to do
5369
-    if ($this->magic_quotes_status != -1) {
5370
-      return $v_result;
5368
+	// ----- Look if something to do
5369
+	if ($this->magic_quotes_status != -1) {
5370
+	  return $v_result;
5371 5371
 	}
5372 5372
 
5373 5373
 	// ----- Swap back magic_quotes
@@ -5375,8 +5375,8 @@  discard block
 block discarded – undo
5375 5375
   	  @set_magic_quotes_runtime($this->magic_quotes_status);
5376 5376
 	}
5377 5377
 
5378
-    // ----- Return
5379
-    return $v_result;
5378
+	// ----- Return
5379
+	return $v_result;
5380 5380
   }
5381 5381
   // --------------------------------------------------------------------------------
5382 5382
 
@@ -5392,67 +5392,67 @@  discard block
 block discarded – undo
5392 5392
   // --------------------------------------------------------------------------------
5393 5393
   function PclZipUtilPathReduction($p_dir)
5394 5394
   {
5395
-    $v_result = "";
5396
-
5397
-    // ----- Look for not empty path
5398
-    if ($p_dir != "") {
5399
-      // ----- Explode path by directory names
5400
-      $v_list = explode("/", $p_dir);
5401
-
5402
-      // ----- Study directories from last to first
5403
-      $v_skip = 0;
5404
-      for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5405
-        // ----- Look for current path
5406
-        if ($v_list[$i] == ".") {
5407
-          // ----- Ignore this directory
5408
-          // Should be the first $i=0, but no check is done
5409
-        }
5410
-        else if ($v_list[$i] == "..") {
5395
+	$v_result = "";
5396
+
5397
+	// ----- Look for not empty path
5398
+	if ($p_dir != "") {
5399
+	  // ----- Explode path by directory names
5400
+	  $v_list = explode("/", $p_dir);
5401
+
5402
+	  // ----- Study directories from last to first
5403
+	  $v_skip = 0;
5404
+	  for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5405
+		// ----- Look for current path
5406
+		if ($v_list[$i] == ".") {
5407
+		  // ----- Ignore this directory
5408
+		  // Should be the first $i=0, but no check is done
5409
+		}
5410
+		else if ($v_list[$i] == "..") {
5411 5411
 		  $v_skip++;
5412
-        }
5413
-        else if ($v_list[$i] == "") {
5412
+		}
5413
+		else if ($v_list[$i] == "") {
5414 5414
 		  // ----- First '/' i.e. root slash
5415 5415
 		  if ($i == 0) {
5416
-            $v_result = "/".$v_result;
5417
-		    if ($v_skip > 0) {
5418
-		        // ----- It is an invalid path, so the path is not modified
5419
-		        // TBC
5420
-		        $v_result = $p_dir;
5421
-                $v_skip = 0;
5422
-		    }
5416
+			$v_result = "/".$v_result;
5417
+			if ($v_skip > 0) {
5418
+				// ----- It is an invalid path, so the path is not modified
5419
+				// TBC
5420
+				$v_result = $p_dir;
5421
+				$v_skip = 0;
5422
+			}
5423 5423
 		  }
5424 5424
 		  // ----- Last '/' i.e. indicates a directory
5425 5425
 		  else if ($i == (sizeof($v_list)-1)) {
5426
-            $v_result = $v_list[$i];
5426
+			$v_result = $v_list[$i];
5427 5427
 		  }
5428 5428
 		  // ----- Double '/' inside the path
5429 5429
 		  else {
5430
-            // ----- Ignore only the double '//' in path,
5431
-            // but not the first and last '/'
5430
+			// ----- Ignore only the double '//' in path,
5431
+			// but not the first and last '/'
5432 5432
 		  }
5433
-        }
5434
-        else {
5433
+		}
5434
+		else {
5435 5435
 		  // ----- Look for item to skip
5436 5436
 		  if ($v_skip > 0) {
5437
-		    $v_skip--;
5437
+			$v_skip--;
5438 5438
 		  }
5439 5439
 		  else {
5440
-            $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5440
+			$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5441 5441
 		  }
5442
-        }
5443
-      }
5442
+		}
5443
+	  }
5444 5444
 
5445
-      // ----- Look for skip
5446
-      if ($v_skip > 0) {
5447
-        while ($v_skip > 0) {
5448
-            $v_result = '../'.$v_result;
5449
-            $v_skip--;
5450
-        }
5451
-      }
5452
-    }
5445
+	  // ----- Look for skip
5446
+	  if ($v_skip > 0) {
5447
+		while ($v_skip > 0) {
5448
+			$v_result = '../'.$v_result;
5449
+			$v_skip--;
5450
+		}
5451
+	  }
5452
+	}
5453 5453
 
5454
-    // ----- Return
5455
-    return $v_result;
5454
+	// ----- Return
5455
+	return $v_result;
5456 5456
   }
5457 5457
   // --------------------------------------------------------------------------------
5458 5458
 
@@ -5473,67 +5473,67 @@  discard block
 block discarded – undo
5473 5473
   // --------------------------------------------------------------------------------
5474 5474
   function PclZipUtilPathInclusion($p_dir, $p_path)
5475 5475
   {
5476
-    $v_result = 1;
5476
+	$v_result = 1;
5477 5477
 
5478
-    // ----- Look for path beginning by ./
5479
-    if (   ($p_dir == '.')
5480
-        || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5481
-      $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5482
-    }
5483
-    if (   ($p_path == '.')
5484
-        || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5485
-      $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5486
-    }
5478
+	// ----- Look for path beginning by ./
5479
+	if (   ($p_dir == '.')
5480
+		|| ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5481
+	  $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5482
+	}
5483
+	if (   ($p_path == '.')
5484
+		|| ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5485
+	  $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5486
+	}
5487 5487
 
5488
-    // ----- Explode dir and path by directory separator
5489
-    $v_list_dir = explode("/", $p_dir);
5490
-    $v_list_dir_size = sizeof($v_list_dir);
5491
-    $v_list_path = explode("/", $p_path);
5492
-    $v_list_path_size = sizeof($v_list_path);
5493
-
5494
-    // ----- Study directories paths
5495
-    $i = 0;
5496
-    $j = 0;
5497
-    while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
5498
-
5499
-      // ----- Look for empty dir (path reduction)
5500
-      if ($v_list_dir[$i] == '') {
5501
-        $i++;
5502
-        continue;
5503
-      }
5504
-      if ($v_list_path[$j] == '') {
5505
-        $j++;
5506
-        continue;
5507
-      }
5488
+	// ----- Explode dir and path by directory separator
5489
+	$v_list_dir = explode("/", $p_dir);
5490
+	$v_list_dir_size = sizeof($v_list_dir);
5491
+	$v_list_path = explode("/", $p_path);
5492
+	$v_list_path_size = sizeof($v_list_path);
5493
+
5494
+	// ----- Study directories paths
5495
+	$i = 0;
5496
+	$j = 0;
5497
+	while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
5498
+
5499
+	  // ----- Look for empty dir (path reduction)
5500
+	  if ($v_list_dir[$i] == '') {
5501
+		$i++;
5502
+		continue;
5503
+	  }
5504
+	  if ($v_list_path[$j] == '') {
5505
+		$j++;
5506
+		continue;
5507
+	  }
5508 5508
 
5509
-      // ----- Compare the items
5510
-      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
5511
-        $v_result = 0;
5512
-      }
5509
+	  // ----- Compare the items
5510
+	  if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
5511
+		$v_result = 0;
5512
+	  }
5513 5513
 
5514
-      // ----- Next items
5515
-      $i++;
5516
-      $j++;
5517
-    }
5514
+	  // ----- Next items
5515
+	  $i++;
5516
+	  $j++;
5517
+	}
5518 5518
 
5519
-    // ----- Look if everything seems to be the same
5520
-    if ($v_result) {
5521
-      // ----- Skip all the empty items
5522
-      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5523
-      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5519
+	// ----- Look if everything seems to be the same
5520
+	if ($v_result) {
5521
+	  // ----- Skip all the empty items
5522
+	  while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5523
+	  while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5524 5524
 
5525
-      if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5526
-        // ----- There are exactly the same
5527
-        $v_result = 2;
5528
-      }
5529
-      else if ($i < $v_list_dir_size) {
5530
-        // ----- The path is shorter than the dir
5531
-        $v_result = 0;
5532
-      }
5533
-    }
5525
+	  if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5526
+		// ----- There are exactly the same
5527
+		$v_result = 2;
5528
+	  }
5529
+	  else if ($i < $v_list_dir_size) {
5530
+		// ----- The path is shorter than the dir
5531
+		$v_result = 0;
5532
+	  }
5533
+	}
5534 5534
 
5535
-    // ----- Return
5536
-    return $v_result;
5535
+	// ----- Return
5536
+	return $v_result;
5537 5537
   }
5538 5538
   // --------------------------------------------------------------------------------
5539 5539
 
@@ -5550,51 +5550,51 @@  discard block
 block discarded – undo
5550 5550
   // --------------------------------------------------------------------------------
5551 5551
   function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5552 5552
   {
5553
-    $v_result = 1;
5554
-
5555
-    if ($p_mode==0)
5556
-    {
5557
-      while ($p_size != 0)
5558
-      {
5559
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5560
-        $v_buffer = @fread($p_src, $v_read_size);
5561
-        @fwrite($p_dest, $v_buffer, $v_read_size);
5562
-        $p_size -= $v_read_size;
5563
-      }
5564
-    }
5565
-    else if ($p_mode==1)
5566
-    {
5567
-      while ($p_size != 0)
5568
-      {
5569
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5570
-        $v_buffer = @gzread($p_src, $v_read_size);
5571
-        @fwrite($p_dest, $v_buffer, $v_read_size);
5572
-        $p_size -= $v_read_size;
5573
-      }
5574
-    }
5575
-    else if ($p_mode==2)
5576
-    {
5577
-      while ($p_size != 0)
5578
-      {
5579
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5580
-        $v_buffer = @fread($p_src, $v_read_size);
5581
-        @gzwrite($p_dest, $v_buffer, $v_read_size);
5582
-        $p_size -= $v_read_size;
5583
-      }
5584
-    }
5585
-    else if ($p_mode==3)
5586
-    {
5587
-      while ($p_size != 0)
5588
-      {
5589
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5590
-        $v_buffer = @gzread($p_src, $v_read_size);
5591
-        @gzwrite($p_dest, $v_buffer, $v_read_size);
5592
-        $p_size -= $v_read_size;
5593
-      }
5594
-    }
5553
+	$v_result = 1;
5554
+
5555
+	if ($p_mode==0)
5556
+	{
5557
+	  while ($p_size != 0)
5558
+	  {
5559
+		$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5560
+		$v_buffer = @fread($p_src, $v_read_size);
5561
+		@fwrite($p_dest, $v_buffer, $v_read_size);
5562
+		$p_size -= $v_read_size;
5563
+	  }
5564
+	}
5565
+	else if ($p_mode==1)
5566
+	{
5567
+	  while ($p_size != 0)
5568
+	  {
5569
+		$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5570
+		$v_buffer = @gzread($p_src, $v_read_size);
5571
+		@fwrite($p_dest, $v_buffer, $v_read_size);
5572
+		$p_size -= $v_read_size;
5573
+	  }
5574
+	}
5575
+	else if ($p_mode==2)
5576
+	{
5577
+	  while ($p_size != 0)
5578
+	  {
5579
+		$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5580
+		$v_buffer = @fread($p_src, $v_read_size);
5581
+		@gzwrite($p_dest, $v_buffer, $v_read_size);
5582
+		$p_size -= $v_read_size;
5583
+	  }
5584
+	}
5585
+	else if ($p_mode==3)
5586
+	{
5587
+	  while ($p_size != 0)
5588
+	  {
5589
+		$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5590
+		$v_buffer = @gzread($p_src, $v_read_size);
5591
+		@gzwrite($p_dest, $v_buffer, $v_read_size);
5592
+		$p_size -= $v_read_size;
5593
+	  }
5594
+	}
5595 5595
 
5596
-    // ----- Return
5597
-    return $v_result;
5596
+	// ----- Return
5597
+	return $v_result;
5598 5598
   }
5599 5599
   // --------------------------------------------------------------------------------
5600 5600
 
@@ -5612,22 +5612,22 @@  discard block
 block discarded – undo
5612 5612
   // --------------------------------------------------------------------------------
5613 5613
   function PclZipUtilRename($p_src, $p_dest)
5614 5614
   {
5615
-    $v_result = 1;
5615
+	$v_result = 1;
5616 5616
 
5617
-    // ----- Try to rename the files
5618
-    if (!@rename($p_src, $p_dest)) {
5617
+	// ----- Try to rename the files
5618
+	if (!@rename($p_src, $p_dest)) {
5619 5619
 
5620
-      // ----- Try to copy & unlink the src
5621
-      if (!@copy($p_src, $p_dest)) {
5622
-        $v_result = 0;
5623
-      }
5624
-      else if (!@unlink($p_src)) {
5625
-        $v_result = 0;
5626
-      }
5627
-    }
5620
+	  // ----- Try to copy & unlink the src
5621
+	  if (!@copy($p_src, $p_dest)) {
5622
+		$v_result = 0;
5623
+	  }
5624
+	  else if (!@unlink($p_src)) {
5625
+		$v_result = 0;
5626
+	  }
5627
+	}
5628 5628
 
5629
-    // ----- Return
5630
-    return $v_result;
5629
+	// ----- Return
5630
+	return $v_result;
5631 5631
   }
5632 5632
   // --------------------------------------------------------------------------------
5633 5633
 
@@ -5643,20 +5643,20 @@  discard block
 block discarded – undo
5643 5643
   function PclZipUtilOptionText($p_option)
5644 5644
   {
5645 5645
 
5646
-    $v_list = get_defined_constants();
5647
-    for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5648
-	    $v_prefix = substr($v_key, 0, 10);
5649
-	    if ((   ($v_prefix == 'PCLZIP_OPT')
5650
-           || ($v_prefix == 'PCLZIP_CB_')
5651
-           || ($v_prefix == 'PCLZIP_ATT'))
5652
-	        && ($v_list[$v_key] == $p_option)) {
5653
-        return $v_key;
5654
-	    }
5655
-    }
5646
+	$v_list = get_defined_constants();
5647
+	for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5648
+		$v_prefix = substr($v_key, 0, 10);
5649
+		if ((   ($v_prefix == 'PCLZIP_OPT')
5650
+		   || ($v_prefix == 'PCLZIP_CB_')
5651
+		   || ($v_prefix == 'PCLZIP_ATT'))
5652
+			&& ($v_list[$v_key] == $p_option)) {
5653
+		return $v_key;
5654
+		}
5655
+	}
5656 5656
 
5657
-    $v_result = 'Unknown';
5657
+	$v_result = 'Unknown';
5658 5658
 
5659
-    return $v_result;
5659
+	return $v_result;
5660 5660
   }
5661 5661
   // --------------------------------------------------------------------------------
5662 5662
 
@@ -5673,17 +5673,17 @@  discard block
 block discarded – undo
5673 5673
   // --------------------------------------------------------------------------------
5674 5674
   function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
5675 5675
   {
5676
-    if (stristr(php_uname(), 'windows')) {
5677
-      // ----- Look for potential disk letter
5678
-      if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5679
-          $p_path = substr($p_path, $v_position+1);
5680
-      }
5681
-      // ----- Change potential windows directory separator
5682
-      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5683
-          $p_path = strtr($p_path, '\\', '/');
5684
-      }
5685
-    }
5686
-    return $p_path;
5676
+	if (stristr(php_uname(), 'windows')) {
5677
+	  // ----- Look for potential disk letter
5678
+	  if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5679
+		  $p_path = substr($p_path, $v_position+1);
5680
+	  }
5681
+	  // ----- Change potential windows directory separator
5682
+	  if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5683
+		  $p_path = strtr($p_path, '\\', '/');
5684
+	  }
5685
+	}
5686
+	return $p_path;
5687 5687
   }
5688 5688
   // --------------------------------------------------------------------------------
5689 5689
 
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])) {
@@ -1841,16 +1841,16 @@  discard block
 block discarded – undo
1841 1841
     $v_memory_limit = trim($v_memory_limit);
1842 1842
     $last = strtolower(substr($v_memory_limit, -1));
1843 1843
 
1844
-    if($last == 'g')
1844
+    if ($last == 'g')
1845 1845
         //$v_memory_limit = $v_memory_limit*1024*1024*1024;
1846
-        $v_memory_limit = $v_memory_limit*1073741824;
1847
-    if($last == 'm')
1846
+        $v_memory_limit = $v_memory_limit * 1073741824;
1847
+    if ($last == 'm')
1848 1848
         //$v_memory_limit = $v_memory_limit*1024*1024;
1849
-        $v_memory_limit = $v_memory_limit*1048576;
1850
-    if($last == 'k')
1851
-        $v_memory_limit = $v_memory_limit*1024;
1849
+        $v_memory_limit = $v_memory_limit * 1048576;
1850
+    if ($last == 'k')
1851
+        $v_memory_limit = $v_memory_limit * 1024;
1852 1852
 
1853
-    $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
1853
+    $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit * PCLZIP_TEMPORARY_FILE_RATIO);
1854 1854
 
1855 1855
 
1856 1856
     // ----- Sanity check : No threshold if value lower than 1M
@@ -1871,15 +1871,15 @@  discard block
 block discarded – undo
1871 1871
   //   1 on success.
1872 1872
   //   0 on failure.
1873 1873
   // --------------------------------------------------------------------------------
1874
-  function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
1874
+  function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options = false)
1875 1875
   {
1876
-    $v_result=1;
1876
+    $v_result = 1;
1877 1877
 
1878 1878
     // ----- For each file in the list check the attributes
1879 1879
     foreach ($p_file_list as $v_key => $v_value) {
1880 1880
 
1881 1881
       // ----- Check if the option is supported
1882
-      if (!isset($v_requested_options[$v_key])) {
1882
+      if ( ! isset($v_requested_options[$v_key])) {
1883 1883
         // ----- Error log
1884 1884
         PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1885 1885
 
@@ -1890,7 +1890,7 @@  discard block
 block discarded – undo
1890 1890
       // ----- Look for attribute
1891 1891
       switch ($v_key) {
1892 1892
         case PCLZIP_ATT_FILE_NAME :
1893
-          if (!is_string($v_value)) {
1893
+          if ( ! is_string($v_value)) {
1894 1894
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1895 1895
             return PclZip::errorCode();
1896 1896
           }
@@ -1905,7 +1905,7 @@  discard block
 block discarded – undo
1905 1905
         break;
1906 1906
 
1907 1907
         case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1908
-          if (!is_string($v_value)) {
1908
+          if ( ! is_string($v_value)) {
1909 1909
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1910 1910
             return PclZip::errorCode();
1911 1911
           }
@@ -1919,7 +1919,7 @@  discard block
 block discarded – undo
1919 1919
         break;
1920 1920
 
1921 1921
         case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1922
-          if (!is_string($v_value)) {
1922
+          if ( ! is_string($v_value)) {
1923 1923
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1924 1924
             return PclZip::errorCode();
1925 1925
           }
@@ -1934,7 +1934,7 @@  discard block
 block discarded – undo
1934 1934
 
1935 1935
         // ----- Look for options that takes a string
1936 1936
         case PCLZIP_ATT_FILE_COMMENT :
1937
-          if (!is_string($v_value)) {
1937
+          if ( ! is_string($v_value)) {
1938 1938
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1939 1939
             return PclZip::errorCode();
1940 1940
           }
@@ -1943,7 +1943,7 @@  discard block
 block discarded – undo
1943 1943
         break;
1944 1944
 
1945 1945
         case PCLZIP_ATT_FILE_MTIME :
1946
-          if (!is_integer($v_value)) {
1946
+          if ( ! is_integer($v_value)) {
1947 1947
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
1948 1948
             return PclZip::errorCode();
1949 1949
           }
@@ -1966,11 +1966,11 @@  discard block
 block discarded – undo
1966 1966
 
1967 1967
       // ----- Look for mandatory options
1968 1968
       if ($v_requested_options !== false) {
1969
-        for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1969
+        for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) {
1970 1970
           // ----- Look for mandatory option
1971 1971
           if ($v_requested_options[$key] == 'mandatory') {
1972 1972
             // ----- Look if present
1973
-            if (!isset($p_file_list[$key])) {
1973
+            if ( ! isset($p_file_list[$key])) {
1974 1974
               PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1975 1975
               return PclZip::errorCode();
1976 1976
             }
@@ -2002,13 +2002,13 @@  discard block
 block discarded – undo
2002 2002
   // --------------------------------------------------------------------------------
2003 2003
   function privFileDescrExpand(&$p_filedescr_list, &$p_options)
2004 2004
   {
2005
-    $v_result=1;
2005
+    $v_result = 1;
2006 2006
 
2007 2007
     // ----- Create a result list
2008 2008
     $v_result_list = array();
2009 2009
 
2010 2010
     // ----- Look each entry
2011
-    for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
2011
+    for ($i = 0; $i < sizeof($p_filedescr_list); $i++) {
2012 2012
 
2013 2013
       // ----- Get filedescr
2014 2014
       $v_descr = $p_filedescr_list[$i];
@@ -2075,7 +2075,7 @@  discard block
 block discarded – undo
2075 2075
             // Because the name of the folder was changed, the name of the
2076 2076
             // files/sub-folders also change
2077 2077
             if (($v_descr['stored_filename'] != $v_descr['filename'])
2078
-                 && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2078
+                 && ( ! isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2079 2079
               if ($v_descr['stored_filename'] != '') {
2080 2080
                 $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2081 2081
               }
@@ -2127,7 +2127,7 @@  discard block
 block discarded – undo
2127 2127
   // --------------------------------------------------------------------------------
2128 2128
   function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
2129 2129
   {
2130
-    $v_result=1;
2130
+    $v_result = 1;
2131 2131
     $v_list_detail = array();
2132 2132
 
2133 2133
     // ----- Magic quotes trick
@@ -2162,11 +2162,11 @@  discard block
 block discarded – undo
2162 2162
   // --------------------------------------------------------------------------------
2163 2163
   function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
2164 2164
   {
2165
-    $v_result=1;
2165
+    $v_result = 1;
2166 2166
     $v_list_detail = array();
2167 2167
 
2168 2168
     // ----- Look if the archive exists or is empty
2169
-    if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2169
+    if (( ! is_file($this->zipname)) || (filesize($this->zipname) == 0))
2170 2170
     {
2171 2171
 
2172 2172
       // ----- Do a create
@@ -2179,7 +2179,7 @@  discard block
 block discarded – undo
2179 2179
     $this->privDisableMagicQuotes();
2180 2180
 
2181 2181
     // ----- Open the zip file
2182
-    if (($v_result=$this->privOpenFd('rb')) != 1)
2182
+    if (($v_result = $this->privOpenFd('rb')) != 1)
2183 2183
     {
2184 2184
       // ----- Magic quotes trick
2185 2185
       $this->privSwapBackMagicQuotes();
@@ -2260,7 +2260,7 @@  discard block
 block discarded – undo
2260 2260
     }
2261 2261
 
2262 2262
     // ----- Create the Central Dir files header
2263
-    for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2263
+    for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++)
2264 2264
     {
2265 2265
       // ----- Create the file header
2266 2266
       if ($v_header_list[$i]['status'] == 'ok') {
@@ -2293,10 +2293,10 @@  discard block
 block discarded – undo
2293 2293
     }
2294 2294
 
2295 2295
     // ----- Calculate the size of the central header
2296
-    $v_size = @ftell($this->zip_fd)-$v_offset;
2296
+    $v_size = @ftell($this->zip_fd) - $v_offset;
2297 2297
 
2298 2298
     // ----- Create the central dir footer
2299
-    if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2299
+    if (($v_result = $this->privWriteCentralHeader($v_count + $v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2300 2300
     {
2301 2301
       // ----- Reset the file list
2302 2302
       unset($v_header_list);
@@ -2341,7 +2341,7 @@  discard block
 block discarded – undo
2341 2341
   // --------------------------------------------------------------------------------
2342 2342
   function privOpenFd($p_mode)
2343 2343
   {
2344
-    $v_result=1;
2344
+    $v_result = 1;
2345 2345
 
2346 2346
     // ----- Look if already open
2347 2347
     if ($this->zip_fd != 0)
@@ -2375,7 +2375,7 @@  discard block
 block discarded – undo
2375 2375
   // --------------------------------------------------------------------------------
2376 2376
   function privCloseFd()
2377 2377
   {
2378
-    $v_result=1;
2378
+    $v_result = 1;
2379 2379
 
2380 2380
     if ($this->zip_fd != 0)
2381 2381
       @fclose($this->zip_fd);
@@ -2402,7 +2402,7 @@  discard block
 block discarded – undo
2402 2402
 //  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
2403 2403
   function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
2404 2404
   {
2405
-    $v_result=1;
2405
+    $v_result = 1;
2406 2406
 
2407 2407
     // ----- Add the files
2408 2408
     $v_header_list = array();
@@ -2416,7 +2416,7 @@  discard block
 block discarded – undo
2416 2416
     $v_offset = @ftell($this->zip_fd);
2417 2417
 
2418 2418
     // ----- Create the Central Dir files header
2419
-    for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2419
+    for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++)
2420 2420
     {
2421 2421
       // ----- Create the file header
2422 2422
       if ($v_header_list[$i]['status'] == 'ok') {
@@ -2438,7 +2438,7 @@  discard block
 block discarded – undo
2438 2438
     }
2439 2439
 
2440 2440
     // ----- Calculate the size of the central header
2441
-    $v_size = @ftell($this->zip_fd)-$v_offset;
2441
+    $v_size = @ftell($this->zip_fd) - $v_offset;
2442 2442
 
2443 2443
     // ----- Create the central dir footer
2444 2444
     if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
@@ -2466,14 +2466,14 @@  discard block
 block discarded – undo
2466 2466
   // --------------------------------------------------------------------------------
2467 2467
   function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
2468 2468
   {
2469
-    $v_result=1;
2469
+    $v_result = 1;
2470 2470
     $v_header = array();
2471 2471
 
2472 2472
     // ----- Recuperate the current number of elt in list
2473 2473
     $v_nb = sizeof($p_result_list);
2474 2474
 
2475 2475
     // ----- Loop on the files
2476
-    for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2476
+    for ($j = 0; ($j < sizeof($p_filedescr_list)) && ($v_result == 1); $j++) {
2477 2477
       // ----- Format the filename
2478 2478
       $p_filedescr_list[$j]['filename']
2479 2479
       = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
@@ -2486,8 +2486,8 @@  discard block
 block discarded – undo
2486 2486
       }
2487 2487
 
2488 2488
       // ----- Check the filename
2489
-      if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
2490
-          && (!file_exists($p_filedescr_list[$j]['filename']))) {
2489
+      if (($p_filedescr_list[$j]['type'] != 'virtual_file')
2490
+          && ( ! file_exists($p_filedescr_list[$j]['filename']))) {
2491 2491
         PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2492 2492
         return PclZip::errorCode();
2493 2493
       }
@@ -2496,11 +2496,11 @@  discard block
 block discarded – undo
2496 2496
       // or a dir with all its path removed
2497 2497
 //      if (   (is_file($p_filedescr_list[$j]['filename']))
2498 2498
 //          || (   is_dir($p_filedescr_list[$j]['filename'])
2499
-      if (   ($p_filedescr_list[$j]['type'] == 'file')
2499
+      if (($p_filedescr_list[$j]['type'] == 'file')
2500 2500
           || ($p_filedescr_list[$j]['type'] == 'virtual_file')
2501
-          || (   ($p_filedescr_list[$j]['type'] == 'folder')
2502
-              && (   !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2503
-                  || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2501
+          || (($p_filedescr_list[$j]['type'] == 'folder')
2502
+              && ( ! isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2503
+                  || ! $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2504 2504
           ) {
2505 2505
 
2506 2506
         // ----- Add the file
@@ -2528,7 +2528,7 @@  discard block
 block discarded – undo
2528 2528
   // --------------------------------------------------------------------------------
2529 2529
   function privAddFile($p_filedescr, &$p_header, &$p_options)
2530 2530
   {
2531
-    $v_result=1;
2531
+    $v_result = 1;
2532 2532
 
2533 2533
     // ----- Working variable
2534 2534
     $p_filename = $p_filedescr['filename'];
@@ -2573,13 +2573,13 @@  discard block
 block discarded – undo
2573 2573
     $p_header['index'] = -1;
2574 2574
 
2575 2575
     // ----- Look for regular file
2576
-    if ($p_filedescr['type']=='file') {
2576
+    if ($p_filedescr['type'] == 'file') {
2577 2577
       $p_header['external'] = 0x00000000;
2578 2578
       $p_header['size'] = filesize($p_filename);
2579 2579
     }
2580 2580
 
2581 2581
     // ----- Look for regular folder
2582
-    else if ($p_filedescr['type']=='folder') {
2582
+    else if ($p_filedescr['type'] == 'folder') {
2583 2583
       $p_header['external'] = 0x00000010;
2584 2584
       $p_header['mtime'] = filemtime($p_filename);
2585 2585
       $p_header['size'] = filesize($p_filename);
@@ -2653,10 +2653,10 @@  discard block
 block discarded – undo
2653 2653
       // ----- Look for a file
2654 2654
       if ($p_filedescr['type'] == 'file') {
2655 2655
         // ----- Look for using temporary file to zip
2656
-        if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
2656
+        if (( ! isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
2657 2657
             && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2658 2658
                 || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2659
-                    && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
2659
+                    && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])))) {
2660 2660
           $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2661 2661
           if ($v_result < PCLZIP_ERR_NO_ERROR) {
2662 2662
             return $v_result;
@@ -2756,7 +2756,7 @@  discard block
 block discarded – undo
2756 2756
         // ----- Set the file properties
2757 2757
         $p_header['size'] = 0;
2758 2758
         //$p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
2759
-        $p_header['external'] = 0x00000010;   // Value for a folder : to be checked
2759
+        $p_header['external'] = 0x00000010; // Value for a folder : to be checked
2760 2760
 
2761 2761
         // ----- Call the header generation
2762 2762
         if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
@@ -2799,7 +2799,7 @@  discard block
 block discarded – undo
2799 2799
   // --------------------------------------------------------------------------------
2800 2800
   function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
2801 2801
   {
2802
-    $v_result=PCLZIP_ERR_NO_ERROR;
2802
+    $v_result = PCLZIP_ERR_NO_ERROR;
2803 2803
 
2804 2804
     // ----- Working variable
2805 2805
     $p_filename = $p_filedescr['filename'];
@@ -2853,7 +2853,7 @@  discard block
 block discarded – undo
2853 2853
     $v_data_header['os'] = bin2hex($v_data_header['os']);
2854 2854
 
2855 2855
     // ----- Read the gzip file footer
2856
-    @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
2856
+    @fseek($v_file_compressed, filesize($v_gzip_temp_name) - 8);
2857 2857
     $v_binary_data = @fread($v_file_compressed, 8);
2858 2858
     $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
2859 2859
 
@@ -2861,7 +2861,7 @@  discard block
 block discarded – undo
2861 2861
     $p_header['compression'] = ord($v_data_header['cm']);
2862 2862
     //$p_header['mtime'] = $v_data_header['mtime'];
2863 2863
     $p_header['crc'] = $v_data_footer['crc'];
2864
-    $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
2864
+    $p_header['compressed_size'] = filesize($v_gzip_temp_name) - 18;
2865 2865
 
2866 2866
     // ----- Close the file
2867 2867
     @fclose($v_file_compressed);
@@ -2911,7 +2911,7 @@  discard block
 block discarded – undo
2911 2911
   // --------------------------------------------------------------------------------
2912 2912
   function privCalculateStoredFilename(&$p_filedescr, &$p_options)
2913 2913
   {
2914
-    $v_result=1;
2914
+    $v_result = 1;
2915 2915
 
2916 2916
     // ----- Working variables
2917 2917
     $p_filename = $p_filedescr['filename'];
@@ -2968,14 +2968,14 @@  discard block
 block discarded – undo
2968 2968
         if (substr($p_remove_dir, -1) != '/')
2969 2969
           $p_remove_dir .= "/";
2970 2970
 
2971
-        if (   (substr($p_filename, 0, 2) == "./")
2971
+        if ((substr($p_filename, 0, 2) == "./")
2972 2972
             || (substr($p_remove_dir, 0, 2) == "./")) {
2973 2973
 
2974
-          if (   (substr($p_filename, 0, 2) == "./")
2974
+          if ((substr($p_filename, 0, 2) == "./")
2975 2975
               && (substr($p_remove_dir, 0, 2) != "./")) {
2976 2976
             $p_remove_dir = "./".$p_remove_dir;
2977 2977
           }
2978
-          if (   (substr($p_filename, 0, 2) != "./")
2978
+          if ((substr($p_filename, 0, 2) != "./")
2979 2979
               && (substr($p_remove_dir, 0, 2) == "./")) {
2980 2980
             $p_remove_dir = substr($p_remove_dir, 2);
2981 2981
           }
@@ -3023,15 +3023,15 @@  discard block
 block discarded – undo
3023 3023
   // --------------------------------------------------------------------------------
3024 3024
   function privWriteFileHeader(&$p_header)
3025 3025
   {
3026
-    $v_result=1;
3026
+    $v_result = 1;
3027 3027
 
3028 3028
     // ----- Store the offset position of the file
3029 3029
     $p_header['offset'] = ftell($this->zip_fd);
3030 3030
 
3031 3031
     // ----- Transform UNIX mtime to DOS format mdate/mtime
3032 3032
     $v_date = getdate($p_header['mtime']);
3033
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3034
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3033
+    $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2;
3034
+    $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday'];
3035 3035
 
3036 3036
     // ----- Packed data
3037 3037
     $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
@@ -3068,7 +3068,7 @@  discard block
 block discarded – undo
3068 3068
   // --------------------------------------------------------------------------------
3069 3069
   function privWriteCentralFileHeader(&$p_header)
3070 3070
   {
3071
-    $v_result=1;
3071
+    $v_result = 1;
3072 3072
 
3073 3073
     // TBC
3074 3074
     //for(reset($p_header); $key = key($p_header); next($p_header)) {
@@ -3076,8 +3076,8 @@  discard block
 block discarded – undo
3076 3076
 
3077 3077
     // ----- Transform UNIX mtime to DOS format mdate/mtime
3078 3078
     $v_date = getdate($p_header['mtime']);
3079
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3080
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3079
+    $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2;
3080
+    $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday'];
3081 3081
 
3082 3082
 
3083 3083
     // ----- Packed data
@@ -3121,7 +3121,7 @@  discard block
 block discarded – undo
3121 3121
   // --------------------------------------------------------------------------------
3122 3122
   function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
3123 3123
   {
3124
-    $v_result=1;
3124
+    $v_result = 1;
3125 3125
 
3126 3126
     // ----- Packed data
3127 3127
     $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
@@ -3150,7 +3150,7 @@  discard block
 block discarded – undo
3150 3150
   // --------------------------------------------------------------------------------
3151 3151
   function privList(&$p_list)
3152 3152
   {
3153
-    $v_result=1;
3153
+    $v_result = 1;
3154 3154
 
3155 3155
     // ----- Magic quotes trick
3156 3156
     $this->privDisableMagicQuotes();
@@ -3190,7 +3190,7 @@  discard block
 block discarded – undo
3190 3190
     }
3191 3191
 
3192 3192
     // ----- Read each entry
3193
-    for ($i=0; $i<$v_central_dir['entries']; $i++)
3193
+    for ($i = 0; $i < $v_central_dir['entries']; $i++)
3194 3194
     {
3195 3195
       // ----- Read the file header
3196 3196
       if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
@@ -3237,7 +3237,7 @@  discard block
 block discarded – undo
3237 3237
   // --------------------------------------------------------------------------------
3238 3238
   function privConvertHeader2FileInfo($p_header, &$p_info)
3239 3239
   {
3240
-    $v_result=1;
3240
+    $v_result = 1;
3241 3241
 
3242 3242
     // ----- Get the interesting attributes
3243 3243
     $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
@@ -3248,7 +3248,7 @@  discard block
 block discarded – undo
3248 3248
     $p_info['compressed_size'] = $p_header['compressed_size'];
3249 3249
     $p_info['mtime'] = $p_header['mtime'];
3250 3250
     $p_info['comment'] = $p_header['comment'];
3251
-    $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
3251
+    $p_info['folder'] = (($p_header['external'] & 0x00000010) == 0x00000010);
3252 3252
     $p_info['index'] = $p_header['index'];
3253 3253
     $p_info['status'] = $p_header['status'];
3254 3254
     $p_info['crc'] = $p_header['crc'];
@@ -3276,16 +3276,16 @@  discard block
 block discarded – undo
3276 3276
   // --------------------------------------------------------------------------------
3277 3277
   function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3278 3278
   {
3279
-    $v_result=1;
3279
+    $v_result = 1;
3280 3280
 
3281 3281
     // ----- Magic quotes trick
3282 3282
     $this->privDisableMagicQuotes();
3283 3283
 
3284 3284
     // ----- Check the path
3285
-    if (   ($p_path == "")
3286
-	    || (   (substr($p_path, 0, 1) != "/")
3285
+    if (($p_path == "")
3286
+	    || ((substr($p_path, 0, 1) != "/")
3287 3287
 		    && (substr($p_path, 0, 3) != "../")
3288
-			&& (substr($p_path,1,2)!=":/")))
3288
+			&& (substr($p_path, 1, 2) != ":/")))
3289 3289
       $p_path = "./".$p_path;
3290 3290
 
3291 3291
     // ----- Reduce the path last (and duplicated) '/'
@@ -3294,7 +3294,7 @@  discard block
 block discarded – undo
3294 3294
       // ----- Look for the path end '/'
3295 3295
       while (substr($p_path, -1) == "/")
3296 3296
       {
3297
-        $p_path = substr($p_path, 0, strlen($p_path)-1);
3297
+        $p_path = substr($p_path, 0, strlen($p_path) - 1);
3298 3298
       }
3299 3299
     }
3300 3300
 
@@ -3328,7 +3328,7 @@  discard block
 block discarded – undo
3328 3328
 
3329 3329
     // ----- Read each entry
3330 3330
     $j_start = 0;
3331
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3331
+    for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++)
3332 3332
     {
3333 3333
 
3334 3334
       // ----- Read next Central dir entry
@@ -3367,17 +3367,17 @@  discard block
 block discarded – undo
3367 3367
       $v_extract = false;
3368 3368
 
3369 3369
       // ----- Look for extract by name rule
3370
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
3370
+      if ((isset($p_options[PCLZIP_OPT_BY_NAME]))
3371 3371
           && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3372 3372
 
3373 3373
           // ----- Look if the filename is in the list
3374
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3374
+          for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && ( ! $v_extract); $j++) {
3375 3375
 
3376 3376
               // ----- Look for a directory
3377 3377
               if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3378 3378
 
3379 3379
                   // ----- Look if the directory is in the filename path
3380
-                  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3380
+                  if ((strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3381 3381
                       && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3382 3382
                       $v_extract = true;
3383 3383
                   }
@@ -3402,7 +3402,7 @@  discard block
 block discarded – undo
3402 3402
       */
3403 3403
 
3404 3404
       // ----- Look for extract by preg rule
3405
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
3405
+      else if ((isset($p_options[PCLZIP_OPT_BY_PREG]))
3406 3406
                && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3407 3407
 
3408 3408
           if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
@@ -3411,20 +3411,20 @@  discard block
 block discarded – undo
3411 3411
       }
3412 3412
 
3413 3413
       // ----- Look for extract by index rule
3414
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3414
+      else if ((isset($p_options[PCLZIP_OPT_BY_INDEX]))
3415 3415
                && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3416 3416
 
3417 3417
           // ----- Look if the index is in the list
3418
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3418
+          for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && ( ! $v_extract); $j++) {
3419 3419
 
3420
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3420
+              if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3421 3421
                   $v_extract = true;
3422 3422
               }
3423
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3424
-                  $j_start = $j+1;
3423
+              if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3424
+                  $j_start = $j + 1;
3425 3425
               }
3426 3426
 
3427
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3427
+              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) {
3428 3428
                   break;
3429 3429
               }
3430 3430
           }
@@ -3436,14 +3436,14 @@  discard block
 block discarded – undo
3436 3436
       }
3437 3437
 
3438 3438
 	  // ----- Check compression method
3439
-	  if (   ($v_extract)
3440
-	      && (   ($v_header['compression'] != 8)
3439
+	  if (($v_extract)
3440
+	      && (($v_header['compression'] != 8)
3441 3441
 		      && ($v_header['compression'] != 0))) {
3442 3442
           $v_header['status'] = 'unsupported_compression';
3443 3443
 
3444 3444
           // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3445
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3446
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3445
+          if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3446
+		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3447 3447
 
3448 3448
               $this->privSwapBackMagicQuotes();
3449 3449
 
@@ -3461,8 +3461,8 @@  discard block
 block discarded – undo
3461 3461
           $v_header['status'] = 'unsupported_encryption';
3462 3462
 
3463 3463
           // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3464
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3465
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3464
+          if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3465
+		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3466 3466
 
3467 3467
               $this->privSwapBackMagicQuotes();
3468 3468
 
@@ -3543,7 +3543,7 @@  discard block
 block discarded – undo
3543 3543
           }
3544 3544
         }
3545 3545
         // ----- Look for extraction in standard output
3546
-        elseif (   (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3546
+        elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3547 3547
 		        && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3548 3548
           // ----- Extracting the file in standard output
3549 3549
           $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
@@ -3616,7 +3616,7 @@  discard block
 block discarded – undo
3616 3616
   // --------------------------------------------------------------------------------
3617 3617
   function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3618 3618
   {
3619
-    $v_result=1;
3619
+    $v_result = 1;
3620 3620
 
3621 3621
     // ----- Read the file header
3622 3622
     if (($v_result = $this->privReadFileHeader($v_header)) != 1)
@@ -3634,7 +3634,7 @@  discard block
 block discarded – undo
3634 3634
     // ----- Look for all path to remove
3635 3635
     if ($p_remove_all_path == true) {
3636 3636
         // ----- Look for folder entry that not need to be extracted
3637
-        if (($p_entry['external']&0x00000010)==0x00000010) {
3637
+        if (($p_entry['external'] & 0x00000010) == 0x00000010) {
3638 3638
 
3639 3639
             $p_entry['status'] = "filtered";
3640 3640
 
@@ -3735,8 +3735,8 @@  discard block
 block discarded – undo
3735 3735
         // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3736 3736
         // For historical reason first PclZip implementation does not stop
3737 3737
         // when this kind of error occurs.
3738
-        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3739
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3738
+        if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3739
+		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3740 3740
 
3741 3741
             PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3742 3742
 			                     "Filename '".$p_entry['filename']."' is "
@@ -3746,7 +3746,7 @@  discard block
 block discarded – undo
3746 3746
 		    }
3747 3747
       }
3748 3748
       // ----- Look if file is write protected
3749
-      else if (!is_writeable($p_entry['filename']))
3749
+      else if ( ! is_writeable($p_entry['filename']))
3750 3750
       {
3751 3751
 
3752 3752
         // ----- Change the file status
@@ -3755,8 +3755,8 @@  discard block
 block discarded – undo
3755 3755
         // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3756 3756
         // For historical reason first PclZip implementation does not stop
3757 3757
         // when this kind of error occurs.
3758
-        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3759
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3758
+        if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3759
+		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3760 3760
 
3761 3761
             PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3762 3762
 			                     "Filename '".$p_entry['filename']."' exists "
@@ -3770,8 +3770,8 @@  discard block
 block discarded – undo
3770 3770
       else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3771 3771
       {
3772 3772
         // ----- Change the file status
3773
-        if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3774
-		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3773
+        if ((isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3774
+		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER] === true)) {
3775 3775
 	  	  }
3776 3776
 		    else {
3777 3777
             $p_entry['status'] = "newer_exist";
@@ -3779,8 +3779,8 @@  discard block
 block discarded – undo
3779 3779
             // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3780 3780
             // For historical reason first PclZip implementation does not stop
3781 3781
             // when this kind of error occurs.
3782
-            if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3783
-		        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3782
+            if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3783
+		        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3784 3784
 
3785 3785
                 PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3786 3786
 			             "Newer version of '".$p_entry['filename']."' exists "
@@ -3796,14 +3796,14 @@  discard block
 block discarded – undo
3796 3796
 
3797 3797
     // ----- Check the directory availability and create it if necessary
3798 3798
     else {
3799
-      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3799
+      if ((($p_entry['external'] & 0x00000010) == 0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3800 3800
         $v_dir_to_check = $p_entry['filename'];
3801
-      else if (!strstr($p_entry['filename'], "/"))
3801
+      else if ( ! strstr($p_entry['filename'], "/"))
3802 3802
         $v_dir_to_check = "";
3803 3803
       else
3804 3804
         $v_dir_to_check = dirname($p_entry['filename']);
3805 3805
 
3806
-        if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3806
+        if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external'] & 0x00000010) == 0x00000010))) != 1) {
3807 3807
 
3808 3808
           // ----- Change the file status
3809 3809
           $p_entry['status'] = "path_creation_fail";
@@ -3819,7 +3819,7 @@  discard block
 block discarded – undo
3819 3819
     if ($p_entry['status'] == 'ok') {
3820 3820
 
3821 3821
       // ----- Do the extraction (if not a folder)
3822
-      if (!(($p_entry['external']&0x00000010)==0x00000010))
3822
+      if ( ! (($p_entry['external'] & 0x00000010) == 0x00000010))
3823 3823
       {
3824 3824
         // ----- Look for not compressed file
3825 3825
         if ($p_entry['compression'] == 0) {
@@ -3868,10 +3868,10 @@  discard block
 block discarded – undo
3868 3868
 
3869 3869
 
3870 3870
           // ----- Look for using temporary file to unzip
3871
-          if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
3871
+          if (( ! isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
3872 3872
               && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
3873 3873
                   || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3874
-                      && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
3874
+                      && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])))) {
3875 3875
             $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
3876 3876
             if ($v_result < PCLZIP_ERR_NO_ERROR) {
3877 3877
               return $v_result;
@@ -3965,7 +3965,7 @@  discard block
 block discarded – undo
3965 3965
   // --------------------------------------------------------------------------------
3966 3966
   function privExtractFileUsingTempFile(&$p_entry, &$p_options)
3967 3967
   {
3968
-    $v_result=1;
3968
+    $v_result = 1;
3969 3969
 
3970 3970
     // ----- Creates a temporary file
3971 3971
     $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
@@ -4041,7 +4041,7 @@  discard block
 block discarded – undo
4041 4041
   // --------------------------------------------------------------------------------
4042 4042
   function privExtractFileInOutput(&$p_entry, &$p_options)
4043 4043
   {
4044
-    $v_result=1;
4044
+    $v_result = 1;
4045 4045
 
4046 4046
     // ----- Read the file header
4047 4047
     if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
@@ -4090,7 +4090,7 @@  discard block
 block discarded – undo
4090 4090
     if ($p_entry['status'] == 'ok') {
4091 4091
 
4092 4092
       // ----- Do the extraction (if not a folder)
4093
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4093
+      if ( ! (($p_entry['external'] & 0x00000010) == 0x00000010)) {
4094 4094
         // ----- Look for not compressed file
4095 4095
         if ($p_entry['compressed_size'] == $p_entry['size']) {
4096 4096
 
@@ -4152,7 +4152,7 @@  discard block
 block discarded – undo
4152 4152
   // --------------------------------------------------------------------------------
4153 4153
   function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4154 4154
   {
4155
-    $v_result=1;
4155
+    $v_result = 1;
4156 4156
 
4157 4157
     // ----- Read the file header
4158 4158
     $v_header = array();
@@ -4202,7 +4202,7 @@  discard block
 block discarded – undo
4202 4202
     if ($p_entry['status'] == 'ok') {
4203 4203
 
4204 4204
       // ----- Do the extraction (if not a folder)
4205
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4205
+      if ( ! (($p_entry['external'] & 0x00000010) == 0x00000010)) {
4206 4206
         // ----- Look for not compressed file
4207 4207
   //      if ($p_entry['compressed_size'] == $p_entry['size'])
4208 4208
         if ($p_entry['compression'] == 0) {
@@ -4273,7 +4273,7 @@  discard block
 block discarded – undo
4273 4273
   // --------------------------------------------------------------------------------
4274 4274
   function privReadFileHeader(&$p_header)
4275 4275
   {
4276
-    $v_result=1;
4276
+    $v_result = 1;
4277 4277
 
4278 4278
     // ----- Read the 4 bytes signature
4279 4279
     $v_binary_data = @fread($this->zip_fd, 4);
@@ -4337,7 +4337,7 @@  discard block
 block discarded – undo
4337 4337
       // ----- Extract time
4338 4338
       $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4339 4339
       $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4340
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4340
+      $v_seconde = ($p_header['mtime'] & 0x001F) * 2;
4341 4341
 
4342 4342
       // ----- Extract date
4343 4343
       $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
@@ -4376,7 +4376,7 @@  discard block
 block discarded – undo
4376 4376
   // --------------------------------------------------------------------------------
4377 4377
   function privReadCentralFileHeader(&$p_header)
4378 4378
   {
4379
-    $v_result=1;
4379
+    $v_result = 1;
4380 4380
 
4381 4381
     // ----- Read the 4 bytes signature
4382 4382
     $v_binary_data = @fread($this->zip_fd, 4);
@@ -4440,7 +4440,7 @@  discard block
 block discarded – undo
4440 4440
       // ----- Extract time
4441 4441
       $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4442 4442
       $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4443
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4443
+      $v_seconde = ($p_header['mtime'] & 0x001F) * 2;
4444 4444
 
4445 4445
       // ----- Extract date
4446 4446
       $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
@@ -4484,7 +4484,7 @@  discard block
 block discarded – undo
4484 4484
   // --------------------------------------------------------------------------------
4485 4485
   function privCheckFileHeaders(&$p_local_header, &$p_central_header)
4486 4486
   {
4487
-    $v_result=1;
4487
+    $v_result = 1;
4488 4488
 
4489 4489
   	// ----- Check the static values
4490 4490
   	// TBC
@@ -4521,7 +4521,7 @@  discard block
 block discarded – undo
4521 4521
   // --------------------------------------------------------------------------------
4522 4522
   function privReadEndCentralDir(&$p_central_dir)
4523 4523
   {
4524
-    $v_result=1;
4524
+    $v_result = 1;
4525 4525
 
4526 4526
     // ----- Go to the end of the zip file
4527 4527
     $v_size = filesize($this->zipname);
@@ -4539,8 +4539,8 @@  discard block
 block discarded – undo
4539 4539
     // in this case the end of central dir is at 22 bytes of the file end
4540 4540
     $v_found = 0;
4541 4541
     if ($v_size > 26) {
4542
-      @fseek($this->zip_fd, $v_size-22);
4543
-      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4542
+      @fseek($this->zip_fd, $v_size - 22);
4543
+      if (($v_pos = @ftell($this->zip_fd)) != ($v_size - 22))
4544 4544
       {
4545 4545
         // ----- Error log
4546 4546
         PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
@@ -4562,12 +4562,12 @@  discard block
 block discarded – undo
4562 4562
     }
4563 4563
 
4564 4564
     // ----- Go back to the maximum possible size of the Central Dir End Record
4565
-    if (!$v_found) {
4565
+    if ( ! $v_found) {
4566 4566
       $v_maximum_size = 65557; // 0xFFFF + 22;
4567 4567
       if ($v_maximum_size > $v_size)
4568 4568
         $v_maximum_size = $v_size;
4569
-      @fseek($this->zip_fd, $v_size-$v_maximum_size);
4570
-      if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4569
+      @fseek($this->zip_fd, $v_size - $v_maximum_size);
4570
+      if (@ftell($this->zip_fd) != ($v_size - $v_maximum_size))
4571 4571
       {
4572 4572
         // ----- Error log
4573 4573
         PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
@@ -4588,7 +4588,7 @@  discard block
 block discarded – undo
4588 4588
         //$v_bytes = ($v_bytes << 8) | Ord($v_byte);
4589 4589
         // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
4590 4590
         // Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
4591
-        $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
4591
+        $v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
4592 4592
 
4593 4593
         // ----- Compare the bytes
4594 4594
         if ($v_bytes == 0x504b0506)
@@ -4678,11 +4678,11 @@  discard block
 block discarded – undo
4678 4678
   // --------------------------------------------------------------------------------
4679 4679
   function privDeleteByRule(&$p_result_list, &$p_options)
4680 4680
   {
4681
-    $v_result=1;
4681
+    $v_result = 1;
4682 4682
     $v_list_detail = array();
4683 4683
 
4684 4684
     // ----- Open the zip file
4685
-    if (($v_result=$this->privOpenFd('rb')) != 1)
4685
+    if (($v_result = $this->privOpenFd('rb')) != 1)
4686 4686
     {
4687 4687
       // ----- Return
4688 4688
       return $v_result;
@@ -4718,7 +4718,7 @@  discard block
 block discarded – undo
4718 4718
     // ----- Read each entry
4719 4719
     $v_header_list = array();
4720 4720
     $j_start = 0;
4721
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4721
+    for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++)
4722 4722
     {
4723 4723
 
4724 4724
       // ----- Read the file header
@@ -4739,21 +4739,21 @@  discard block
 block discarded – undo
4739 4739
       $v_found = false;
4740 4740
 
4741 4741
       // ----- Look for extract by name rule
4742
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
4742
+      if ((isset($p_options[PCLZIP_OPT_BY_NAME]))
4743 4743
           && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4744 4744
 
4745 4745
           // ----- Look if the filename is in the list
4746
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4746
+          for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && ( ! $v_found); $j++) {
4747 4747
 
4748 4748
               // ----- Look for a directory
4749 4749
               if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4750 4750
 
4751 4751
                   // ----- Look if the directory is in the filename path
4752
-                  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4752
+                  if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4753 4753
                       && (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])) {
4754 4754
                       $v_found = true;
4755 4755
                   }
4756
-                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4756
+                  elseif ((($v_header_list[$v_nb_extracted]['external'] & 0x00000010) == 0x00000010) /* Indicates a folder */
4757 4757
                           && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4758 4758
                       $v_found = true;
4759 4759
                   }
@@ -4778,7 +4778,7 @@  discard block
 block discarded – undo
4778 4778
       */
4779 4779
 
4780 4780
       // ----- Look for extract by preg rule
4781
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
4781
+      else if ((isset($p_options[PCLZIP_OPT_BY_PREG]))
4782 4782
                && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4783 4783
 
4784 4784
           if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
@@ -4787,20 +4787,20 @@  discard block
 block discarded – undo
4787 4787
       }
4788 4788
 
4789 4789
       // ----- Look for extract by index rule
4790
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4790
+      else if ((isset($p_options[PCLZIP_OPT_BY_INDEX]))
4791 4791
                && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4792 4792
 
4793 4793
           // ----- Look if the index is in the list
4794
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4794
+          for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && ( ! $v_found); $j++) {
4795 4795
 
4796
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4796
+              if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4797 4797
                   $v_found = true;
4798 4798
               }
4799
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4800
-                  $j_start = $j+1;
4799
+              if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4800
+                  $j_start = $j + 1;
4801 4801
               }
4802 4802
 
4803
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4803
+              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) {
4804 4804
                   break;
4805 4805
               }
4806 4806
           }
@@ -4838,11 +4838,11 @@  discard block
 block discarded – undo
4838 4838
         }
4839 4839
 
4840 4840
         // ----- Look which file need to be kept
4841
-        for ($i=0; $i<sizeof($v_header_list); $i++) {
4841
+        for ($i = 0; $i < sizeof($v_header_list); $i++) {
4842 4842
 
4843 4843
             // ----- Calculate the position of the header
4844 4844
             @rewind($this->zip_fd);
4845
-            if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
4845
+            if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
4846 4846
                 // ----- Close the zip file
4847 4847
                 $this->privCloseFd();
4848 4848
                 $v_temp_zip->privCloseFd();
@@ -4901,7 +4901,7 @@  discard block
 block discarded – undo
4901 4901
         $v_offset = @ftell($v_temp_zip->zip_fd);
4902 4902
 
4903 4903
         // ----- Re-Create the Central Dir files header
4904
-        for ($i=0; $i<sizeof($v_header_list); $i++) {
4904
+        for ($i = 0; $i < sizeof($v_header_list); $i++) {
4905 4905
             // ----- Create the file header
4906 4906
             if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4907 4907
                 $v_temp_zip->privCloseFd();
@@ -4924,7 +4924,7 @@  discard block
 block discarded – undo
4924 4924
         }
4925 4925
 
4926 4926
         // ----- Calculate the size of the central header
4927
-        $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
4927
+        $v_size = @ftell($v_temp_zip->zip_fd) - $v_offset;
4928 4928
 
4929 4929
         // ----- Create the central dir footer
4930 4930
         if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
@@ -4986,15 +4986,15 @@  discard block
 block discarded – undo
4986 4986
   //    1 : OK
4987 4987
   //   -1 : Unable to create directory
4988 4988
   // --------------------------------------------------------------------------------
4989
-  function privDirCheck($p_dir, $p_is_dir=false)
4989
+  function privDirCheck($p_dir, $p_is_dir = false)
4990 4990
   {
4991 4991
     $v_result = 1;
4992 4992
 
4993 4993
 
4994 4994
     // ----- Remove the final '/'
4995
-    if (($p_is_dir) && (substr($p_dir, -1)=='/'))
4995
+    if (($p_is_dir) && (substr($p_dir, -1) == '/'))
4996 4996
     {
4997
-      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
4997
+      $p_dir = substr($p_dir, 0, strlen($p_dir) - 1);
4998 4998
     }
4999 4999
 
5000 5000
     // ----- Check the directory availability
@@ -5020,7 +5020,7 @@  discard block
 block discarded – undo
5020 5020
     }
5021 5021
 
5022 5022
     // ----- Create the directory
5023
-    if (!@mkdir($p_dir, 0777))
5023
+    if ( ! @mkdir($p_dir, 0777))
5024 5024
     {
5025 5025
       // ----- Error log
5026 5026
       PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
@@ -5043,10 +5043,10 @@  discard block
 block discarded – undo
5043 5043
   // --------------------------------------------------------------------------------
5044 5044
   function privMerge(&$p_archive_to_add)
5045 5045
   {
5046
-    $v_result=1;
5046
+    $v_result = 1;
5047 5047
 
5048 5048
     // ----- Look if the archive_to_add exists
5049
-    if (!is_file($p_archive_to_add->zipname))
5049
+    if ( ! is_file($p_archive_to_add->zipname))
5050 5050
     {
5051 5051
 
5052 5052
       // ----- Nothing to merge, so merge is a success
@@ -5057,7 +5057,7 @@  discard block
 block discarded – undo
5057 5057
     }
5058 5058
 
5059 5059
     // ----- Look if the archive exists
5060
-    if (!is_file($this->zipname))
5060
+    if ( ! is_file($this->zipname))
5061 5061
     {
5062 5062
 
5063 5063
       // ----- Do a duplicate
@@ -5068,7 +5068,7 @@  discard block
 block discarded – undo
5068 5068
     }
5069 5069
 
5070 5070
     // ----- Open the zip file
5071
-    if (($v_result=$this->privOpenFd('rb')) != 1)
5071
+    if (($v_result = $this->privOpenFd('rb')) != 1)
5072 5072
     {
5073 5073
       // ----- Return
5074 5074
       return $v_result;
@@ -5086,7 +5086,7 @@  discard block
 block discarded – undo
5086 5086
     @rewind($this->zip_fd);
5087 5087
 
5088 5088
     // ----- Open the archive_to_add file
5089
-    if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5089
+    if (($v_result = $p_archive_to_add->privOpenFd('rb')) != 1)
5090 5090
     {
5091 5091
       $this->privCloseFd();
5092 5092
 
@@ -5170,7 +5170,7 @@  discard block
 block discarded – undo
5170 5170
     $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
5171 5171
 
5172 5172
     // ----- Calculate the size of the (new) central header
5173
-    $v_size = @ftell($v_zip_temp_fd)-$v_offset;
5173
+    $v_size = @ftell($v_zip_temp_fd) - $v_offset;
5174 5174
 
5175 5175
     // ----- Swap the file descriptor
5176 5176
     // Here is a trick : I swap the temporary fd with the zip fd, in order to use
@@ -5180,7 +5180,7 @@  discard block
 block discarded – undo
5180 5180
     $v_zip_temp_fd = $v_swap;
5181 5181
 
5182 5182
     // ----- Create the central dir footer
5183
-    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5183
+    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries'] + $v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5184 5184
     {
5185 5185
       $this->privCloseFd();
5186 5186
       $p_archive_to_add->privCloseFd();
@@ -5228,10 +5228,10 @@  discard block
 block discarded – undo
5228 5228
   // --------------------------------------------------------------------------------
5229 5229
   function privDuplicate($p_archive_filename)
5230 5230
   {
5231
-    $v_result=1;
5231
+    $v_result = 1;
5232 5232
 
5233 5233
     // ----- Look if the $p_archive_filename exists
5234
-    if (!is_file($p_archive_filename))
5234
+    if ( ! is_file($p_archive_filename))
5235 5235
     {
5236 5236
 
5237 5237
       // ----- Nothing to duplicate, so duplicate is a success.
@@ -5242,7 +5242,7 @@  discard block
 block discarded – undo
5242 5242
     }
5243 5243
 
5244 5244
     // ----- Open the zip file
5245
-    if (($v_result=$this->privOpenFd('wb')) != 1)
5245
+    if (($v_result = $this->privOpenFd('wb')) != 1)
5246 5246
     {
5247 5247
       // ----- Return
5248 5248
       return $v_result;
@@ -5286,7 +5286,7 @@  discard block
 block discarded – undo
5286 5286
   // Description :
5287 5287
   // Parameters :
5288 5288
   // --------------------------------------------------------------------------------
5289
-  function privErrorLog($p_error_code=0, $p_error_string='')
5289
+  function privErrorLog($p_error_code = 0, $p_error_string = '')
5290 5290
   {
5291 5291
     if (PCLZIP_ERROR_EXTERNAL == 1) {
5292 5292
       PclError($p_error_code, $p_error_string);
@@ -5323,11 +5323,11 @@  discard block
 block discarded – undo
5323 5323
   // --------------------------------------------------------------------------------
5324 5324
   function privDisableMagicQuotes()
5325 5325
   {
5326
-    $v_result=1;
5326
+    $v_result = 1;
5327 5327
 
5328 5328
     // ----- Look if function exists
5329
-    if (   (!function_exists("get_magic_quotes_runtime"))
5330
-	    || (!function_exists("set_magic_quotes_runtime"))) {
5329
+    if (( ! function_exists("get_magic_quotes_runtime"))
5330
+	    || ( ! function_exists("set_magic_quotes_runtime"))) {
5331 5331
       return $v_result;
5332 5332
 	}
5333 5333
 
@@ -5357,11 +5357,11 @@  discard block
 block discarded – undo
5357 5357
   // --------------------------------------------------------------------------------
5358 5358
   function privSwapBackMagicQuotes()
5359 5359
   {
5360
-    $v_result=1;
5360
+    $v_result = 1;
5361 5361
 
5362 5362
     // ----- Look if function exists
5363
-    if (   (!function_exists("get_magic_quotes_runtime"))
5364
-	    || (!function_exists("set_magic_quotes_runtime"))) {
5363
+    if (( ! function_exists("get_magic_quotes_runtime"))
5364
+	    || ( ! function_exists("set_magic_quotes_runtime"))) {
5365 5365
       return $v_result;
5366 5366
 	}
5367 5367
 
@@ -5401,7 +5401,7 @@  discard block
 block discarded – undo
5401 5401
 
5402 5402
       // ----- Study directories from last to first
5403 5403
       $v_skip = 0;
5404
-      for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5404
+      for ($i = sizeof($v_list) - 1; $i >= 0; $i--) {
5405 5405
         // ----- Look for current path
5406 5406
         if ($v_list[$i] == ".") {
5407 5407
           // ----- Ignore this directory
@@ -5422,7 +5422,7 @@  discard block
 block discarded – undo
5422 5422
 		    }
5423 5423
 		  }
5424 5424
 		  // ----- Last '/' i.e. indicates a directory
5425
-		  else if ($i == (sizeof($v_list)-1)) {
5425
+		  else if ($i == (sizeof($v_list) - 1)) {
5426 5426
             $v_result = $v_list[$i];
5427 5427
 		  }
5428 5428
 		  // ----- Double '/' inside the path
@@ -5437,7 +5437,7 @@  discard block
 block discarded – undo
5437 5437
 		    $v_skip--;
5438 5438
 		  }
5439 5439
 		  else {
5440
-            $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5440
+            $v_result = $v_list[$i].($i != (sizeof($v_list) - 1) ? "/".$v_result : "");
5441 5441
 		  }
5442 5442
         }
5443 5443
       }
@@ -5476,12 +5476,12 @@  discard block
 block discarded – undo
5476 5476
     $v_result = 1;
5477 5477
 
5478 5478
     // ----- Look for path beginning by ./
5479
-    if (   ($p_dir == '.')
5480
-        || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5479
+    if (($p_dir == '.')
5480
+        || ((strlen($p_dir) >= 2) && (substr($p_dir, 0, 2) == './'))) {
5481 5481
       $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5482 5482
     }
5483
-    if (   ($p_path == '.')
5484
-        || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5483
+    if (($p_path == '.')
5484
+        || ((strlen($p_path) >= 2) && (substr($p_path, 0, 2) == './'))) {
5485 5485
       $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5486 5486
     }
5487 5487
 
@@ -5507,7 +5507,7 @@  discard block
 block discarded – undo
5507 5507
       }
5508 5508
 
5509 5509
       // ----- Compare the items
5510
-      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
5510
+      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ($v_list_path[$j] != '')) {
5511 5511
         $v_result = 0;
5512 5512
       }
5513 5513
 
@@ -5548,11 +5548,11 @@  discard block
 block discarded – undo
5548 5548
   //             3 : src & dest gzip
5549 5549
   // Return Values :
5550 5550
   // --------------------------------------------------------------------------------
5551
-  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5551
+  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode = 0)
5552 5552
   {
5553 5553
     $v_result = 1;
5554 5554
 
5555
-    if ($p_mode==0)
5555
+    if ($p_mode == 0)
5556 5556
     {
5557 5557
       while ($p_size != 0)
5558 5558
       {
@@ -5562,7 +5562,7 @@  discard block
 block discarded – undo
5562 5562
         $p_size -= $v_read_size;
5563 5563
       }
5564 5564
     }
5565
-    else if ($p_mode==1)
5565
+    else if ($p_mode == 1)
5566 5566
     {
5567 5567
       while ($p_size != 0)
5568 5568
       {
@@ -5572,7 +5572,7 @@  discard block
 block discarded – undo
5572 5572
         $p_size -= $v_read_size;
5573 5573
       }
5574 5574
     }
5575
-    else if ($p_mode==2)
5575
+    else if ($p_mode == 2)
5576 5576
     {
5577 5577
       while ($p_size != 0)
5578 5578
       {
@@ -5582,7 +5582,7 @@  discard block
 block discarded – undo
5582 5582
         $p_size -= $v_read_size;
5583 5583
       }
5584 5584
     }
5585
-    else if ($p_mode==3)
5585
+    else if ($p_mode == 3)
5586 5586
     {
5587 5587
       while ($p_size != 0)
5588 5588
       {
@@ -5615,13 +5615,13 @@  discard block
 block discarded – undo
5615 5615
     $v_result = 1;
5616 5616
 
5617 5617
     // ----- Try to rename the files
5618
-    if (!@rename($p_src, $p_dest)) {
5618
+    if ( ! @rename($p_src, $p_dest)) {
5619 5619
 
5620 5620
       // ----- Try to copy & unlink the src
5621
-      if (!@copy($p_src, $p_dest)) {
5621
+      if ( ! @copy($p_src, $p_dest)) {
5622 5622
         $v_result = 0;
5623 5623
       }
5624
-      else if (!@unlink($p_src)) {
5624
+      else if ( ! @unlink($p_src)) {
5625 5625
         $v_result = 0;
5626 5626
       }
5627 5627
     }
@@ -5646,7 +5646,7 @@  discard block
 block discarded – undo
5646 5646
     $v_list = get_defined_constants();
5647 5647
     for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5648 5648
 	    $v_prefix = substr($v_key, 0, 10);
5649
-	    if ((   ($v_prefix == 'PCLZIP_OPT')
5649
+	    if ((($v_prefix == 'PCLZIP_OPT')
5650 5650
            || ($v_prefix == 'PCLZIP_CB_')
5651 5651
            || ($v_prefix == 'PCLZIP_ATT'))
5652 5652
 	        && ($v_list[$v_key] == $p_option)) {
@@ -5671,15 +5671,15 @@  discard block
 block discarded – undo
5671 5671
   // Return Values :
5672 5672
   //   The path translated.
5673 5673
   // --------------------------------------------------------------------------------
5674
-  function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
5674
+  function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true)
5675 5675
   {
5676 5676
     if (stristr(php_uname(), 'windows')) {
5677 5677
       // ----- Look for potential disk letter
5678 5678
       if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5679
-          $p_path = substr($p_path, $v_position+1);
5679
+          $p_path = substr($p_path, $v_position + 1);
5680 5680
       }
5681 5681
       // ----- Change potential windows directory separator
5682
-      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5682
+      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) {
5683 5683
           $p_path = strtr($p_path, '\\', '/');
5684 5684
       }
5685 5685
     }
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
 
@@ -1841,14 +1819,17 @@  discard block
 block discarded – undo
1841 1819
     $v_memory_limit = trim($v_memory_limit);
1842 1820
     $last = strtolower(substr($v_memory_limit, -1));
1843 1821
 
1844
-    if($last == 'g')
1845
-        //$v_memory_limit = $v_memory_limit*1024*1024*1024;
1822
+    if($last == 'g') {
1823
+            //$v_memory_limit = $v_memory_limit*1024*1024*1024;
1846 1824
         $v_memory_limit = $v_memory_limit*1073741824;
1847
-    if($last == 'm')
1848
-        //$v_memory_limit = $v_memory_limit*1024*1024;
1825
+    }
1826
+    if($last == 'm') {
1827
+            //$v_memory_limit = $v_memory_limit*1024*1024;
1849 1828
         $v_memory_limit = $v_memory_limit*1048576;
1850
-    if($last == 'k')
1851
-        $v_memory_limit = $v_memory_limit*1024;
1829
+    }
1830
+    if($last == 'k') {
1831
+            $v_memory_limit = $v_memory_limit*1024;
1832
+    }
1852 1833
 
1853 1834
     $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
1854 1835
 
@@ -2021,15 +2002,12 @@  discard block
 block discarded – undo
2021 2002
       if (file_exists($v_descr['filename'])) {
2022 2003
         if (@is_file($v_descr['filename'])) {
2023 2004
           $v_descr['type'] = 'file';
2024
-        }
2025
-        else if (@is_dir($v_descr['filename'])) {
2005
+        } else if (@is_dir($v_descr['filename'])) {
2026 2006
           $v_descr['type'] = 'folder';
2027
-        }
2028
-        else if (@is_link($v_descr['filename'])) {
2007
+        } else if (@is_link($v_descr['filename'])) {
2029 2008
           // skip
2030 2009
           continue;
2031
-        }
2032
-        else {
2010
+        } else {
2033 2011
           // skip
2034 2012
           continue;
2035 2013
         }
@@ -2078,8 +2056,7 @@  discard block
 block discarded – undo
2078 2056
                  && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2079 2057
               if ($v_descr['stored_filename'] != '') {
2080 2058
                 $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2081
-              }
2082
-              else {
2059
+              } else {
2083 2060
                 $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
2084 2061
               }
2085 2062
             }
@@ -2088,8 +2065,7 @@  discard block
 block discarded – undo
2088 2065
           }
2089 2066
 
2090 2067
           @closedir($v_folder_handler);
2091
-        }
2092
-        else {
2068
+        } else {
2093 2069
           // TBC : unable to open folder in read mode
2094 2070
         }
2095 2071
 
@@ -2102,8 +2078,7 @@  discard block
 block discarded – undo
2102 2078
 
2103 2079
           // ----- Concat the resulting list
2104 2080
           $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2105
-        }
2106
-        else {
2081
+        } else {
2107 2082
         }
2108 2083
 
2109 2084
         // ----- Free local array
@@ -2377,8 +2352,9 @@  discard block
 block discarded – undo
2377 2352
   {
2378 2353
     $v_result=1;
2379 2354
 
2380
-    if ($this->zip_fd != 0)
2381
-      @fclose($this->zip_fd);
2355
+    if ($this->zip_fd != 0) {
2356
+          @fclose($this->zip_fd);
2357
+    }
2382 2358
     $this->zip_fd = 0;
2383 2359
 
2384 2360
     // ----- Return
@@ -2595,11 +2571,9 @@  discard block
 block discarded – undo
2595 2571
     // ----- Look for filetime
2596 2572
     if (isset($p_filedescr['mtime'])) {
2597 2573
       $p_header['mtime'] = $p_filedescr['mtime'];
2598
-    }
2599
-    else if ($p_filedescr['type'] == 'virtual_file') {
2574
+    } else if ($p_filedescr['type'] == 'virtual_file') {
2600 2575
       $p_header['mtime'] = time();
2601
-    }
2602
-    else {
2576
+    } else {
2603 2577
       $p_header['mtime'] = filemtime($p_filename);
2604 2578
     }
2605 2579
 
@@ -2607,8 +2581,7 @@  discard block
 block discarded – undo
2607 2581
     if (isset($p_filedescr['comment'])) {
2608 2582
       $p_header['comment_len'] = strlen($p_filedescr['comment']);
2609 2583
       $p_header['comment'] = $p_filedescr['comment'];
2610
-    }
2611
-    else {
2584
+    } else {
2612 2585
       $p_header['comment_len'] = 0;
2613 2586
       $p_header['comment'] = '';
2614 2587
     }
@@ -2917,20 +2890,17 @@  discard block
 block discarded – undo
2917 2890
     $p_filename = $p_filedescr['filename'];
2918 2891
     if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
2919 2892
       $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2920
-    }
2921
-    else {
2893
+    } else {
2922 2894
       $p_add_dir = '';
2923 2895
     }
2924 2896
     if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
2925 2897
       $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2926
-    }
2927
-    else {
2898
+    } else {
2928 2899
       $p_remove_dir = '';
2929 2900
     }
2930 2901
     if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
2931 2902
       $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2932
-    }
2933
-    else {
2903
+    } else {
2934 2904
       $p_remove_all_dir = 0;
2935 2905
     }
2936 2906
 
@@ -2953,8 +2923,7 @@  discard block
 block discarded – undo
2953 2923
           $v_dir = $v_path_info['dirname'].'/';
2954 2924
         }
2955 2925
         $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2956
-      }
2957
-      else {
2926
+      } else {
2958 2927
         // ----- Calculate the stored filename
2959 2928
         $v_stored_filename = $p_filename;
2960 2929
       }
@@ -2965,8 +2934,9 @@  discard block
 block discarded – undo
2965 2934
       }
2966 2935
       // ----- Look for partial path remove
2967 2936
       else if ($p_remove_dir != "") {
2968
-        if (substr($p_remove_dir, -1) != '/')
2969
-          $p_remove_dir .= "/";
2937
+        if (substr($p_remove_dir, -1) != '/') {
2938
+                  $p_remove_dir .= "/";
2939
+        }
2970 2940
 
2971 2941
         if (   (substr($p_filename, 0, 2) == "./")
2972 2942
             || (substr($p_remove_dir, 0, 2) == "./")) {
@@ -2986,8 +2956,7 @@  discard block
 block discarded – undo
2986 2956
         if ($v_compare > 0) {
2987 2957
           if ($v_compare == 2) {
2988 2958
             $v_stored_filename = "";
2989
-          }
2990
-          else {
2959
+          } else {
2991 2960
             $v_stored_filename = substr($v_stored_filename,
2992 2961
                                         strlen($p_remove_dir));
2993 2962
           }
@@ -2999,10 +2968,11 @@  discard block
 block discarded – undo
2999 2968
 
3000 2969
       // ----- Look for path to add
3001 2970
       if ($p_add_dir != "") {
3002
-        if (substr($p_add_dir, -1) == "/")
3003
-          $v_stored_filename = $p_add_dir.$v_stored_filename;
3004
-        else
3005
-          $v_stored_filename = $p_add_dir."/".$v_stored_filename;
2971
+        if (substr($p_add_dir, -1) == "/") {
2972
+                  $v_stored_filename = $p_add_dir.$v_stored_filename;
2973
+        } else {
2974
+                  $v_stored_filename = $p_add_dir."/".$v_stored_filename;
2975
+        }
3006 2976
       }
3007 2977
     }
3008 2978
 
@@ -3285,8 +3255,9 @@  discard block
 block discarded – undo
3285 3255
     if (   ($p_path == "")
3286 3256
 	    || (   (substr($p_path, 0, 1) != "/")
3287 3257
 		    && (substr($p_path, 0, 3) != "../")
3288
-			&& (substr($p_path,1,2)!=":/")))
3289
-      $p_path = "./".$p_path;
3258
+			&& (substr($p_path,1,2)!=":/"))) {
3259
+          $p_path = "./".$p_path;
3260
+    }
3290 3261
 
3291 3262
     // ----- Reduce the path last (and duplicated) '/'
3292 3263
     if (($p_path != "./") && ($p_path != "/"))
@@ -3772,8 +3743,7 @@  discard block
 block discarded – undo
3772 3743
         // ----- Change the file status
3773 3744
         if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3774 3745
 		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3775
-	  	  }
3776
-		    else {
3746
+	  	  } else {
3777 3747
             $p_entry['status'] = "newer_exist";
3778 3748
 
3779 3749
             // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
@@ -3789,19 +3759,19 @@  discard block
 block discarded – undo
3789 3759
                 return PclZip::errorCode();
3790 3760
 		      }
3791 3761
 		    }
3792
-      }
3793
-      else {
3762
+      } else {
3794 3763
       }
3795 3764
     }
3796 3765
 
3797 3766
     // ----- Check the directory availability and create it if necessary
3798 3767
     else {
3799
-      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3800
-        $v_dir_to_check = $p_entry['filename'];
3801
-      else if (!strstr($p_entry['filename'], "/"))
3802
-        $v_dir_to_check = "";
3803
-      else
3804
-        $v_dir_to_check = dirname($p_entry['filename']);
3768
+      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) {
3769
+              $v_dir_to_check = $p_entry['filename'];
3770
+      } else if (!strstr($p_entry['filename'], "/")) {
3771
+              $v_dir_to_check = "";
3772
+      } else {
3773
+              $v_dir_to_check = dirname($p_entry['filename']);
3774
+      }
3805 3775
 
3806 3776
         if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3807 3777
 
@@ -3857,8 +3827,7 @@  discard block
 block discarded – undo
3857 3827
           touch($p_entry['filename'], $p_entry['mtime']);
3858 3828
 
3859 3829
 
3860
-        }
3861
-        else {
3830
+        } else {
3862 3831
           // ----- TBC
3863 3832
           // Need to be finished
3864 3833
           if (($p_entry['flag'] & 1) == 1) {
@@ -4100,8 +4069,7 @@  discard block
 block discarded – undo
4100 4069
           // ----- Send the file to the output
4101 4070
           echo $v_buffer;
4102 4071
           unset($v_buffer);
4103
-        }
4104
-        else {
4072
+        } else {
4105 4073
 
4106 4074
           // ----- Read the compressed file in a buffer (one shot)
4107 4075
           $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
@@ -4209,8 +4177,7 @@  discard block
 block discarded – undo
4209 4177
 
4210 4178
           // ----- Reading the file
4211 4179
           $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4212
-        }
4213
-        else {
4180
+        } else {
4214 4181
 
4215 4182
           // ----- Reading the file
4216 4183
           $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
@@ -4222,8 +4189,7 @@  discard block
 block discarded – undo
4222 4189
         }
4223 4190
 
4224 4191
         // ----- Trace
4225
-      }
4226
-      else {
4192
+      } else {
4227 4193
           // TBC : error : can not extract a folder in a string
4228 4194
       }
4229 4195
 
@@ -4315,8 +4281,7 @@  discard block
 block discarded – undo
4315 4281
     // ----- Get extra_fields
4316 4282
     if ($v_data['extra_len'] != 0) {
4317 4283
       $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4318
-    }
4319
-    else {
4284
+    } else {
4320 4285
       $p_header['extra'] = '';
4321 4286
     }
4322 4287
 
@@ -4347,8 +4312,7 @@  discard block
 block discarded – undo
4347 4312
       // ----- Get UNIX date format
4348 4313
       $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4349 4314
 
4350
-    }
4351
-    else
4315
+    } else
4352 4316
     {
4353 4317
       $p_header['mtime'] = time();
4354 4318
     }
@@ -4413,22 +4377,25 @@  discard block
 block discarded – undo
4413 4377
     $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);
4414 4378
 
4415 4379
     // ----- Get filename
4416
-    if ($p_header['filename_len'] != 0)
4417
-      $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4418
-    else
4419
-      $p_header['filename'] = '';
4380
+    if ($p_header['filename_len'] != 0) {
4381
+          $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4382
+    } else {
4383
+          $p_header['filename'] = '';
4384
+    }
4420 4385
 
4421 4386
     // ----- Get extra
4422
-    if ($p_header['extra_len'] != 0)
4423
-      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4424
-    else
4425
-      $p_header['extra'] = '';
4387
+    if ($p_header['extra_len'] != 0) {
4388
+          $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4389
+    } else {
4390
+          $p_header['extra'] = '';
4391
+    }
4426 4392
 
4427 4393
     // ----- Get comment
4428
-    if ($p_header['comment_len'] != 0)
4429
-      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4430
-    else
4431
-      $p_header['comment'] = '';
4394
+    if ($p_header['comment_len'] != 0) {
4395
+          $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4396
+    } else {
4397
+          $p_header['comment'] = '';
4398
+    }
4432 4399
 
4433 4400
     // ----- Extract properties
4434 4401
 
@@ -4450,8 +4417,7 @@  discard block
 block discarded – undo
4450 4417
       // ----- Get UNIX date format
4451 4418
       $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4452 4419
 
4453
-    }
4454
-    else
4420
+    } else
4455 4421
     {
4456 4422
       $p_header['mtime'] = time();
4457 4423
     }
@@ -4564,8 +4530,9 @@  discard block
 block discarded – undo
4564 4530
     // ----- Go back to the maximum possible size of the Central Dir End Record
4565 4531
     if (!$v_found) {
4566 4532
       $v_maximum_size = 65557; // 0xFFFF + 22;
4567
-      if ($v_maximum_size > $v_size)
4568
-        $v_maximum_size = $v_size;
4533
+      if ($v_maximum_size > $v_size) {
4534
+              $v_maximum_size = $v_size;
4535
+      }
4569 4536
       @fseek($this->zip_fd, $v_size-$v_maximum_size);
4570 4537
       if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4571 4538
       {
@@ -4650,9 +4617,9 @@  discard block
 block discarded – undo
4650 4617
     // ----- Get comment
4651 4618
     if ($v_data['comment_size'] != 0) {
4652 4619
       $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4620
+    } else {
4621
+          $p_central_dir['comment'] = '';
4653 4622
     }
4654
-    else
4655
-      $p_central_dir['comment'] = '';
4656 4623
 
4657 4624
     $p_central_dir['entries'] = $v_data['entries'];
4658 4625
     $p_central_dir['disk_entries'] = $v_data['disk_entries'];
@@ -4752,8 +4719,7 @@  discard block
 block discarded – undo
4752 4719
                   if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4753 4720
                       && (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])) {
4754 4721
                       $v_found = true;
4755
-                  }
4756
-                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4722
+                  } elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4757 4723
                           && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4758 4724
                       $v_found = true;
4759 4725
                   }
@@ -4804,8 +4770,7 @@  discard block
 block discarded – undo
4804 4770
                   break;
4805 4771
               }
4806 4772
           }
4807
-      }
4808
-      else {
4773
+      } else {
4809 4774
       	$v_found = true;
4810 4775
       }
4811 4776
 
@@ -4813,8 +4778,7 @@  discard block
 block discarded – undo
4813 4778
       if ($v_found)
4814 4779
       {
4815 4780
         unset($v_header_list[$v_nb_extracted]);
4816
-      }
4817
-      else
4781
+      } else
4818 4782
       {
4819 4783
         $v_nb_extracted++;
4820 4784
       }
@@ -5290,8 +5254,7 @@  discard block
 block discarded – undo
5290 5254
   {
5291 5255
     if (PCLZIP_ERROR_EXTERNAL == 1) {
5292 5256
       PclError($p_error_code, $p_error_string);
5293
-    }
5294
-    else {
5257
+    } else {
5295 5258
       $this->error_code = $p_error_code;
5296 5259
       $this->error_string = $p_error_string;
5297 5260
     }
@@ -5307,8 +5270,7 @@  discard block
 block discarded – undo
5307 5270
   {
5308 5271
     if (PCLZIP_ERROR_EXTERNAL == 1) {
5309 5272
       PclErrorReset();
5310
-    }
5311
-    else {
5273
+    } else {
5312 5274
       $this->error_code = 0;
5313 5275
       $this->error_string = '';
5314 5276
     }
@@ -5406,11 +5368,9 @@  discard block
 block discarded – undo
5406 5368
         if ($v_list[$i] == ".") {
5407 5369
           // ----- Ignore this directory
5408 5370
           // Should be the first $i=0, but no check is done
5409
-        }
5410
-        else if ($v_list[$i] == "..") {
5371
+        } else if ($v_list[$i] == "..") {
5411 5372
 		  $v_skip++;
5412
-        }
5413
-        else if ($v_list[$i] == "") {
5373
+        } else if ($v_list[$i] == "") {
5414 5374
 		  // ----- First '/' i.e. root slash
5415 5375
 		  if ($i == 0) {
5416 5376
             $v_result = "/".$v_result;
@@ -5430,13 +5390,11 @@  discard block
 block discarded – undo
5430 5390
             // ----- Ignore only the double '//' in path,
5431 5391
             // but not the first and last '/'
5432 5392
 		  }
5433
-        }
5434
-        else {
5393
+        } else {
5435 5394
 		  // ----- Look for item to skip
5436 5395
 		  if ($v_skip > 0) {
5437 5396
 		    $v_skip--;
5438
-		  }
5439
-		  else {
5397
+		  } else {
5440 5398
             $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5441 5399
 		  }
5442 5400
         }
@@ -5519,14 +5477,17 @@  discard block
 block discarded – undo
5519 5477
     // ----- Look if everything seems to be the same
5520 5478
     if ($v_result) {
5521 5479
       // ----- Skip all the empty items
5522
-      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5523
-      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5480
+      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) {
5481
+      	$j++;
5482
+      }
5483
+      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) {
5484
+      	$i++;
5485
+      }
5524 5486
 
5525 5487
       if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5526 5488
         // ----- There are exactly the same
5527 5489
         $v_result = 2;
5528
-      }
5529
-      else if ($i < $v_list_dir_size) {
5490
+      } else if ($i < $v_list_dir_size) {
5530 5491
         // ----- The path is shorter than the dir
5531 5492
         $v_result = 0;
5532 5493
       }
@@ -5561,8 +5522,7 @@  discard block
 block discarded – undo
5561 5522
         @fwrite($p_dest, $v_buffer, $v_read_size);
5562 5523
         $p_size -= $v_read_size;
5563 5524
       }
5564
-    }
5565
-    else if ($p_mode==1)
5525
+    } else if ($p_mode==1)
5566 5526
     {
5567 5527
       while ($p_size != 0)
5568 5528
       {
@@ -5571,8 +5531,7 @@  discard block
 block discarded – undo
5571 5531
         @fwrite($p_dest, $v_buffer, $v_read_size);
5572 5532
         $p_size -= $v_read_size;
5573 5533
       }
5574
-    }
5575
-    else if ($p_mode==2)
5534
+    } else if ($p_mode==2)
5576 5535
     {
5577 5536
       while ($p_size != 0)
5578 5537
       {
@@ -5581,8 +5540,7 @@  discard block
 block discarded – undo
5581 5540
         @gzwrite($p_dest, $v_buffer, $v_read_size);
5582 5541
         $p_size -= $v_read_size;
5583 5542
       }
5584
-    }
5585
-    else if ($p_mode==3)
5543
+    } else if ($p_mode==3)
5586 5544
     {
5587 5545
       while ($p_size != 0)
5588 5546
       {
@@ -5620,8 +5578,7 @@  discard block
 block discarded – undo
5620 5578
       // ----- Try to copy & unlink the src
5621 5579
       if (!@copy($p_src, $p_dest)) {
5622 5580
         $v_result = 0;
5623
-      }
5624
-      else if (!@unlink($p_src)) {
5581
+      } else if (!@unlink($p_src)) {
5625 5582
         $v_result = 0;
5626 5583
       }
5627 5584
     }
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-filesystem-base.php 4 patches
Doc Comments   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	 * @since 2.5.0
375 375
 	 *
376 376
 	 * @param string $mode string The *nix-style file permission.
377
-	 * @return int octal representation
377
+	 * @return string octal representation
378 378
 	 */
379 379
 	public function getnumchmodfromh( $mode ) {
380 380
 		$realmode = '';
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 	 * @since 2.5.0
444 444
 	 * @abstract
445 445
 	 * @param string $file Name of the file to read.
446
-	 * @return mixed|bool Returns the read data or false on failure.
446
+	 * @return boolean Returns the read data or false on failure.
447 447
 	 */
448 448
 	public function get_contents( $file ) {
449 449
 		return false;
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 	 * @since 2.5.0
456 456
 	 * @abstract
457 457
 	 * @param string $file Path to the file.
458
-	 * @return array|bool the file contents in an array or false on failure.
458
+	 * @return boolean the file contents in an array or false on failure.
459 459
 	 */
460 460
 	public function get_contents_array( $file ) {
461 461
 		return false;
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 	 *
481 481
 	 * @since 2.5.0
482 482
 	 * @abstract
483
-	 * @return string|bool The current working directory on success, or false on failure.
483
+	 * @return boolean The current working directory on success, or false on failure.
484 484
 	 */
485 485
 	public function cwd() {
486 486
 		return false;
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 	 * @since 2.5.0
493 493
 	 * @abstract
494 494
 	 * @param string $dir The new current directory.
495
-	 * @return bool|string
495
+	 * @return boolean
496 496
 	 */
497 497
 	public function chdir( $dir ) {
498 498
 		return false;
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 	 * @param string $file      Path to the file.
507 507
 	 * @param mixed  $group     A group name or number.
508 508
 	 * @param bool   $recursive Optional. If set True changes file group recursively. Defaults to False.
509
-	 * @return bool|string
509
+	 * @return boolean
510 510
 	 */
511 511
 	public function chgrp( $file, $group, $recursive = false ) {
512 512
 		return false;
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 	 * @param string $file      Path to the file.
521 521
 	 * @param int    $mode      Optional. The permissions as octal number, usually 0644 for files, 0755 for dirs.
522 522
 	 * @param bool   $recursive Optional. If set True changes file group recursively. Defaults to False.
523
-	 * @return bool|string
523
+	 * @return boolean
524 524
 	 */
525 525
 	public function chmod( $file, $mode = false, $recursive = false ) {
526 526
 		return false;
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	 * @since 2.5.0
533 533
 	 * @abstract
534 534
 	 * @param string $file Path to the file.
535
-	 * @return string|bool Username of the user or false on error.
535
+	 * @return boolean Username of the user or false on error.
536 536
 	 */
537 537
 	public function owner( $file ) {
538 538
 		return false;
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 	 * @since 2.5.0
545 545
 	 * @abstract
546 546
 	 * @param string $file Path to the file.
547
-	 * @return string|bool The group or false on error.
547
+	 * @return boolean The group or false on error.
548 548
 	 */
549 549
 	public function group( $file ) {
550 550
 		return false;
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 	 * @since 2.5.0
664 664
 	 * @abstract
665 665
 	 * @param string $file Path to file.
666
-	 * @return int|bool Unix timestamp representing last access time.
666
+	 * @return boolean Unix timestamp representing last access time.
667 667
 	 */
668 668
 	public function atime( $file ) {
669 669
 		return false;
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 	 * @since 2.5.0
676 676
 	 * @abstract
677 677
 	 * @param string $file Path to file.
678
-	 * @return int|bool Unix timestamp representing modification time.
678
+	 * @return boolean Unix timestamp representing modification time.
679 679
 	 */
680 680
 	public function mtime( $file ) {
681 681
 		return false;
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 	 * @since 2.5.0
688 688
 	 * @abstract
689 689
 	 * @param string $file Path to file.
690
-	 * @return int|bool Size of the file in bytes.
690
+	 * @return boolean Size of the file in bytes.
691 691
 	 */
692 692
 	public function size( $file ) {
693 693
 		return false;
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 	 *                               Default true.
755 755
 	 * @param bool   $recursive      Optional. Whether to recursively include file details in nested directories.
756 756
 	 *                               Default false.
757
-	 * @return array|bool {
757
+	 * @return boolean {
758 758
 	 *     Array of files. False if unable to list directory contents.
759 759
 	 *
760 760
 	 *     @type string $name        Name of the file/directory.
Please login to merge, or discard this patch.
Spacing   +89 added lines, -92 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	public function abspath() {
61 61
 		$folder = $this->find_folder(ABSPATH);
62 62
 		// Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
63
-		if ( ! $folder && $this->is_dir( '/' . WPINC ) )
63
+		if ( ! $folder && $this->is_dir('/'.WPINC))
64 64
 			$folder = '/';
65 65
 		return $folder;
66 66
 	}
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
 	 * @param string $theme The Theme stylesheet or template for the directory.
99 99
 	 * @return string The location of the remote path.
100 100
 	 */
101
-	public function wp_themes_dir( $theme = false ) {
102
-		$theme_root = get_theme_root( $theme );
101
+	public function wp_themes_dir($theme = false) {
102
+		$theme_root = get_theme_root($theme);
103 103
 
104 104
 		// Account for relative theme roots
105
-		if ( '/themes' == $theme_root || ! is_dir( $theme_root ) )
106
-			$theme_root = WP_CONTENT_DIR . $theme_root;
105
+		if ('/themes' == $theme_root || ! is_dir($theme_root))
106
+			$theme_root = WP_CONTENT_DIR.$theme_root;
107 107
 
108
-		return $this->find_folder( $theme_root );
108
+		return $this->find_folder($theme_root);
109 109
 	}
110 110
 
111 111
 	/**
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 	 *                     Default false.
138 138
 	 * @return string The location of the remote path.
139 139
 	 */
140
-	public function find_base_dir( $base = '.', $echo = false ) {
141
-		_deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
140
+	public function find_base_dir($base = '.', $echo = false) {
141
+		_deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()');
142 142
 		$this->verbose = $echo;
143 143
 		return $this->abspath();
144 144
 	}
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 * @param bool   $echo True to display debug information.
160 160
 	 * @return string The location of the remote path.
161 161
 	 */
162
-	public function get_base_dir( $base = '.', $echo = false ) {
163
-		_deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
162
+	public function get_base_dir($base = '.', $echo = false) {
163
+		_deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()');
164 164
 		$this->verbose = $echo;
165 165
 		return $this->abspath();
166 166
 	}
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	 * @param string $folder the folder to locate.
178 178
 	 * @return string|false The location of the remote path, false on failure.
179 179
 	 */
180
-	public function find_folder( $folder ) {
181
-		if ( isset( $this->cache[ $folder ] ) )
182
-			return $this->cache[ $folder ];
180
+	public function find_folder($folder) {
181
+		if (isset($this->cache[$folder]))
182
+			return $this->cache[$folder];
183 183
 
184
-		if ( stripos($this->method, 'ftp') !== false ) {
184
+		if (stripos($this->method, 'ftp') !== false) {
185 185
 			$constant_overrides = array(
186 186
 				'FTP_BASE' => ABSPATH,
187 187
 				'FTP_CONTENT_DIR' => WP_CONTENT_DIR,
@@ -190,28 +190,28 @@  discard block
 block discarded – undo
190 190
 			);
191 191
 
192 192
 			// Direct matches ( folder = CONSTANT/ )
193
-			foreach ( $constant_overrides as $constant => $dir ) {
194
-				if ( ! defined( $constant ) )
193
+			foreach ($constant_overrides as $constant => $dir) {
194
+				if ( ! defined($constant))
195 195
 					continue;
196
-				if ( $folder === $dir )
197
-					return trailingslashit( constant( $constant ) );
196
+				if ($folder === $dir)
197
+					return trailingslashit(constant($constant));
198 198
 			}
199 199
 
200 200
 			// Prefix Matches ( folder = CONSTANT/subdir )
201
-			foreach ( $constant_overrides as $constant => $dir ) {
202
-				if ( ! defined( $constant ) )
201
+			foreach ($constant_overrides as $constant => $dir) {
202
+				if ( ! defined($constant))
203 203
 					continue;
204
-				if ( 0 === stripos( $folder, $dir ) ) { // $folder starts with $dir
205
-					$potential_folder = preg_replace( '#^' . preg_quote( $dir, '#' ) . '/#i', trailingslashit( constant( $constant ) ), $folder );
206
-					$potential_folder = trailingslashit( $potential_folder );
204
+				if (0 === stripos($folder, $dir)) { // $folder starts with $dir
205
+					$potential_folder = preg_replace('#^'.preg_quote($dir, '#').'/#i', trailingslashit(constant($constant)), $folder);
206
+					$potential_folder = trailingslashit($potential_folder);
207 207
 
208
-					if ( $this->is_dir( $potential_folder ) ) {
209
-						$this->cache[ $folder ] = $potential_folder;
208
+					if ($this->is_dir($potential_folder)) {
209
+						$this->cache[$folder] = $potential_folder;
210 210
 						return $potential_folder;
211 211
 					}
212 212
 				}
213 213
 			}
214
-		} elseif ( 'direct' == $this->method ) {
214
+		} elseif ('direct' == $this->method) {
215 215
 			$folder = str_replace('\\', '/', $folder); // Windows path sanitisation
216 216
 			return trailingslashit($folder);
217 217
 		}
@@ -219,16 +219,16 @@  discard block
 block discarded – undo
219 219
 		$folder = preg_replace('|^([a-z]{1}):|i', '', $folder); // Strip out windows drive letter if it's there.
220 220
 		$folder = str_replace('\\', '/', $folder); // Windows path sanitisation
221 221
 
222
-		if ( isset($this->cache[ $folder ] ) )
223
-			return $this->cache[ $folder ];
222
+		if (isset($this->cache[$folder]))
223
+			return $this->cache[$folder];
224 224
 
225
-		if ( $this->exists($folder) ) { // Folder exists at that absolute path.
225
+		if ($this->exists($folder)) { // Folder exists at that absolute path.
226 226
 			$folder = trailingslashit($folder);
227
-			$this->cache[ $folder ] = $folder;
227
+			$this->cache[$folder] = $folder;
228 228
 			return $folder;
229 229
 		}
230
-		if ( $return = $this->search_for_folder($folder) )
231
-			$this->cache[ $folder ] = $return;
230
+		if ($return = $this->search_for_folder($folder))
231
+			$this->cache[$folder] = $return;
232 232
 		return $return;
233 233
 	}
234 234
 
@@ -245,26 +245,26 @@  discard block
 block discarded – undo
245 245
 	 * @param bool   $loop   If the function has recursed, Internal use only.
246 246
 	 * @return string|false The location of the remote path, false to cease looping.
247 247
 	 */
248
-	public function search_for_folder( $folder, $base = '.', $loop = false ) {
249
-		if ( empty( $base ) || '.' == $base )
248
+	public function search_for_folder($folder, $base = '.', $loop = false) {
249
+		if (empty($base) || '.' == $base)
250 250
 			$base = trailingslashit($this->cwd());
251 251
 
252 252
 		$folder = untrailingslashit($folder);
253 253
 
254
-		if ( $this->verbose ) {
254
+		if ($this->verbose) {
255 255
 			/* translators: 1: folder to locate, 2: folder to start searching from */
256
-			printf( "\n" . __( 'Looking for %1$s in %2$s' ) . "<br/>\n", $folder, $base );
256
+			printf("\n".__('Looking for %1$s in %2$s')."<br/>\n", $folder, $base);
257 257
 		}
258 258
 
259 259
 		$folder_parts = explode('/', $folder);
260
-		$folder_part_keys = array_keys( $folder_parts );
261
-		$last_index = array_pop( $folder_part_keys );
262
-		$last_path = $folder_parts[ $last_index ];
260
+		$folder_part_keys = array_keys($folder_parts);
261
+		$last_index = array_pop($folder_part_keys);
262
+		$last_path = $folder_parts[$last_index];
263 263
 
264
-		$files = $this->dirlist( $base );
264
+		$files = $this->dirlist($base);
265 265
 
266
-		foreach ( $folder_parts as $index => $key ) {
267
-			if ( $index == $last_index )
266
+		foreach ($folder_parts as $index => $key) {
267
+			if ($index == $last_index)
268 268
 				continue; // We want this to be caught by the next code block.
269 269
 
270 270
 			/*
@@ -274,40 +274,40 @@  discard block
 block discarded – undo
274 274
 			 * folder level, and see if that matches, and so on. If it reaches the end, and still
275 275
 			 * cant find it, it'll return false for the entire function.
276 276
 			 */
277
-			if ( isset($files[ $key ]) ){
277
+			if (isset($files[$key])) {
278 278
 
279 279
 				// Let's try that folder:
280 280
 				$newdir = trailingslashit(path_join($base, $key));
281
-				if ( $this->verbose ) {
281
+				if ($this->verbose) {
282 282
 					/* translators: %s: directory name */
283
-					printf( "\n" . __( 'Changing to %s' ) . "<br/>\n", $newdir );
283
+					printf("\n".__('Changing to %s')."<br/>\n", $newdir);
284 284
 				}
285 285
 
286 286
 				// Only search for the remaining path tokens in the directory, not the full path again.
287
-				$newfolder = implode( '/', array_slice( $folder_parts, $index + 1 ) );
288
-				if ( $ret = $this->search_for_folder( $newfolder, $newdir, $loop) )
287
+				$newfolder = implode('/', array_slice($folder_parts, $index + 1));
288
+				if ($ret = $this->search_for_folder($newfolder, $newdir, $loop))
289 289
 					return $ret;
290 290
 			}
291 291
 		}
292 292
 
293 293
 		// Only check this as a last resort, to prevent locating the incorrect install.
294 294
 		// All above procedures will fail quickly if this is the right branch to take.
295
-		if (isset( $files[ $last_path ] ) ) {
296
-			if ( $this->verbose ) {
295
+		if (isset($files[$last_path])) {
296
+			if ($this->verbose) {
297 297
 				/* translators: %s: directory name */
298
-				printf( "\n" . __( 'Found %s' ) . "<br/>\n",  $base . $last_path );
298
+				printf("\n".__('Found %s')."<br/>\n", $base.$last_path);
299 299
 			}
300
-			return trailingslashit($base . $last_path);
300
+			return trailingslashit($base.$last_path);
301 301
 		}
302 302
 
303 303
 		// Prevent this function from looping again.
304 304
 		// No need to proceed if we've just searched in /
305
-		if ( $loop || '/' == $base )
305
+		if ($loop || '/' == $base)
306 306
 			return false;
307 307
 
308 308
 		// As an extra last resort, Change back to / if the folder wasn't found.
309 309
 		// This comes into effect when the CWD is /home/user/ but WP is at /var/www/....
310
-		return $this->search_for_folder( $folder, '/', true );
310
+		return $this->search_for_folder($folder, '/', true);
311 311
 
312 312
 	}
313 313
 
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 	 * @param string $file String filename.
325 325
 	 * @return string The *nix-style representation of permissions.
326 326
 	 */
327
-	public function gethchmod( $file ){
328
-		$perms = intval( $this->getchmod( $file ), 8 );
327
+	public function gethchmod($file) {
328
+		$perms = intval($this->getchmod($file), 8);
329 329
 		if (($perms & 0xC000) == 0xC000) // Socket
330 330
 			$info = 's';
331 331
 		elseif (($perms & 0xA000) == 0xA000) // Symbolic Link
@@ -347,22 +347,19 @@  discard block
 block discarded – undo
347 347
 		$info .= (($perms & 0x0100) ? 'r' : '-');
348 348
 		$info .= (($perms & 0x0080) ? 'w' : '-');
349 349
 		$info .= (($perms & 0x0040) ?
350
-					(($perms & 0x0800) ? 's' : 'x' ) :
351
-					(($perms & 0x0800) ? 'S' : '-'));
350
+					(($perms & 0x0800) ? 's' : 'x') : (($perms & 0x0800) ? 'S' : '-'));
352 351
 
353 352
 		// Group
354 353
 		$info .= (($perms & 0x0020) ? 'r' : '-');
355 354
 		$info .= (($perms & 0x0010) ? 'w' : '-');
356 355
 		$info .= (($perms & 0x0008) ?
357
-					(($perms & 0x0400) ? 's' : 'x' ) :
358
-					(($perms & 0x0400) ? 'S' : '-'));
356
+					(($perms & 0x0400) ? 's' : 'x') : (($perms & 0x0400) ? 'S' : '-'));
359 357
 
360 358
 		// World
361 359
 		$info .= (($perms & 0x0004) ? 'r' : '-');
362 360
 		$info .= (($perms & 0x0002) ? 'w' : '-');
363 361
 		$info .= (($perms & 0x0001) ?
364
-					(($perms & 0x0200) ? 't' : 'x' ) :
365
-					(($perms & 0x0200) ? 'T' : '-'));
362
+					(($perms & 0x0200) ? 't' : 'x') : (($perms & 0x0200) ? 'T' : '-'));
366 363
 		return $info;
367 364
 	}
368 365
 
@@ -374,7 +371,7 @@  discard block
 block discarded – undo
374 371
 	 * @param string $file
375 372
 	 * @return string the last 3 characters of the octal number
376 373
 	 */
377
-	public function getchmod( $file ) {
374
+	public function getchmod($file) {
378 375
 		return '777';
379 376
 	}
380 377
 
@@ -392,12 +389,12 @@  discard block
 block discarded – undo
392 389
 	 * @param string $mode string The *nix-style file permission.
393 390
 	 * @return int octal representation
394 391
 	 */
395
-	public function getnumchmodfromh( $mode ) {
392
+	public function getnumchmodfromh($mode) {
396 393
 		$realmode = '';
397
-		$legal =  array('', 'w', 'r', 'x', '-');
394
+		$legal = array('', 'w', 'r', 'x', '-');
398 395
 		$attarray = preg_split('//', $mode);
399 396
 
400
-		for ( $i = 0, $c = count( $attarray ); $i < $c; $i++ ) {
397
+		for ($i = 0, $c = count($attarray); $i < $c; $i++) {
401 398
 		   if ($key = array_search($attarray[$i], $legal)) {
402 399
 			   $realmode .= $legal[$key];
403 400
 		   }
@@ -405,7 +402,7 @@  discard block
 block discarded – undo
405 402
 
406 403
 		$mode = str_pad($realmode, 10, '-', STR_PAD_LEFT);
407 404
 		$trans = array('-'=>'0', 'r'=>'4', 'w'=>'2', 'x'=>'1');
408
-		$mode = strtr($mode,$trans);
405
+		$mode = strtr($mode, $trans);
409 406
 
410 407
 		$newmode = $mode[0];
411 408
 		$newmode .= $mode[1] + $mode[2] + $mode[3];
@@ -423,8 +420,8 @@  discard block
 block discarded – undo
423 420
 	 * @param string $text String to test against.
424 421
 	 * @return bool true if string is binary, false otherwise.
425 422
 	 */
426
-	public function is_binary( $text ) {
427
-		return (bool) preg_match( '|[^\x20-\x7E]|', $text ); // chr(32)..chr(127)
423
+	public function is_binary($text) {
424
+		return (bool) preg_match('|[^\x20-\x7E]|', $text); // chr(32)..chr(127)
428 425
 	}
429 426
 
430 427
 	/**
@@ -440,7 +437,7 @@  discard block
 block discarded – undo
440 437
 	 * @param bool   $recursive Optional. If set True changes file owner recursivly. Defaults to False.
441 438
 	 * @return bool Returns true on success or false on failure.
442 439
 	 */
443
-	public function chown( $file, $owner, $recursive = false ) {
440
+	public function chown($file, $owner, $recursive = false) {
444 441
 		return false;
445 442
 	}
446 443
 
@@ -467,7 +464,7 @@  discard block
 block discarded – undo
467 464
 	 * @param string $file Name of the file to read.
468 465
 	 * @return mixed|bool Returns the read data or false on failure.
469 466
 	 */
470
-	public function get_contents( $file ) {
467
+	public function get_contents($file) {
471 468
 		return false;
472 469
 	}
473 470
 
@@ -481,7 +478,7 @@  discard block
 block discarded – undo
481 478
 	 * @param string $file Path to the file.
482 479
 	 * @return array|bool the file contents in an array or false on failure.
483 480
 	 */
484
-	public function get_contents_array( $file ) {
481
+	public function get_contents_array($file) {
485 482
 		return false;
486 483
 	}
487 484
 
@@ -497,7 +494,7 @@  discard block
 block discarded – undo
497 494
 	 * @param int    $mode     Optional. The file permissions as octal number, usually 0644.
498 495
 	 * @return bool False on failure.
499 496
 	 */
500
-	public function put_contents( $file, $contents, $mode = false ) {
497
+	public function put_contents($file, $contents, $mode = false) {
501 498
 		return false;
502 499
 	}
503 500
 
@@ -524,7 +521,7 @@  discard block
 block discarded – undo
524 521
 	 * @param string $dir The new current directory.
525 522
 	 * @return bool|string
526 523
 	 */
527
-	public function chdir( $dir ) {
524
+	public function chdir($dir) {
528 525
 		return false;
529 526
 	}
530 527
 
@@ -540,7 +537,7 @@  discard block
 block discarded – undo
540 537
 	 * @param bool   $recursive Optional. If set True changes file group recursively. Defaults to False.
541 538
 	 * @return bool|string
542 539
 	 */
543
-	public function chgrp( $file, $group, $recursive = false ) {
540
+	public function chgrp($file, $group, $recursive = false) {
544 541
 		return false;
545 542
 	}
546 543
 
@@ -556,7 +553,7 @@  discard block
 block discarded – undo
556 553
 	 * @param bool   $recursive Optional. If set True changes file group recursively. Defaults to False.
557 554
 	 * @return bool|string
558 555
 	 */
559
-	public function chmod( $file, $mode = false, $recursive = false ) {
556
+	public function chmod($file, $mode = false, $recursive = false) {
560 557
 		return false;
561 558
 	}
562 559
 
@@ -570,7 +567,7 @@  discard block
 block discarded – undo
570 567
 	 * @param string $file Path to the file.
571 568
 	 * @return string|bool Username of the user or false on error.
572 569
 	 */
573
-	public function owner( $file ) {
570
+	public function owner($file) {
574 571
 		return false;
575 572
 	}
576 573
 
@@ -584,7 +581,7 @@  discard block
 block discarded – undo
584 581
 	 * @param string $file Path to the file.
585 582
 	 * @return string|bool The group or false on error.
586 583
 	 */
587
-	public function group( $file ) {
584
+	public function group($file) {
588 585
 		return false;
589 586
 	}
590 587
 
@@ -603,7 +600,7 @@  discard block
 block discarded – undo
603 600
 	 *                            Default false.
604 601
 	 * @return bool True if file copied successfully, False otherwise.
605 602
 	 */
606
-	public function copy( $source, $destination, $overwrite = false, $mode = false ) {
603
+	public function copy($source, $destination, $overwrite = false, $mode = false) {
607 604
 		return false;
608 605
 	}
609 606
 
@@ -620,7 +617,7 @@  discard block
 block discarded – undo
620 617
 	 *                            Default false.
621 618
 	 * @return bool True if file copied successfully, False otherwise.
622 619
 	 */
623
-	public function move( $source, $destination, $overwrite = false ) {
620
+	public function move($source, $destination, $overwrite = false) {
624 621
 		return false;
625 622
 	}
626 623
 
@@ -638,7 +635,7 @@  discard block
 block discarded – undo
638 635
 	 *                          Default false.
639 636
 	 * @return bool True if the file or directory was deleted, false on failure.
640 637
 	 */
641
-	public function delete( $file, $recursive = false, $type = false ) {
638
+	public function delete($file, $recursive = false, $type = false) {
642 639
 		return false;
643 640
 	}
644 641
 
@@ -652,7 +649,7 @@  discard block
 block discarded – undo
652 649
 	 * @param string $file Path to file/directory.
653 650
 	 * @return bool Whether $file exists or not.
654 651
 	 */
655
-	public function exists( $file ) {
652
+	public function exists($file) {
656 653
 		return false;
657 654
 	}
658 655
 
@@ -666,7 +663,7 @@  discard block
 block discarded – undo
666 663
 	 * @param string $file File path.
667 664
 	 * @return bool Whether $file is a file.
668 665
 	 */
669
-	public function is_file( $file ) {
666
+	public function is_file($file) {
670 667
 		return false;
671 668
 	}
672 669
 
@@ -680,7 +677,7 @@  discard block
 block discarded – undo
680 677
 	 * @param string $path Directory path.
681 678
 	 * @return bool Whether $path is a directory.
682 679
 	 */
683
-	public function is_dir( $path ) {
680
+	public function is_dir($path) {
684 681
 		return false;
685 682
 	}
686 683
 
@@ -694,7 +691,7 @@  discard block
 block discarded – undo
694 691
 	 * @param string $file Path to file.
695 692
 	 * @return bool Whether $file is readable.
696 693
 	 */
697
-	public function is_readable( $file ) {
694
+	public function is_readable($file) {
698 695
 		return false;
699 696
 	}
700 697
 
@@ -708,7 +705,7 @@  discard block
 block discarded – undo
708 705
 	 * @param string $file Path to file.
709 706
 	 * @return bool Whether $file is writable.
710 707
 	 */
711
-	public function is_writable( $file ) {
708
+	public function is_writable($file) {
712 709
 		return false;
713 710
 	}
714 711
 
@@ -722,7 +719,7 @@  discard block
 block discarded – undo
722 719
 	 * @param string $file Path to file.
723 720
 	 * @return int|bool Unix timestamp representing last access time.
724 721
 	 */
725
-	public function atime( $file ) {
722
+	public function atime($file) {
726 723
 		return false;
727 724
 	}
728 725
 
@@ -736,7 +733,7 @@  discard block
 block discarded – undo
736 733
 	 * @param string $file Path to file.
737 734
 	 * @return int|bool Unix timestamp representing modification time.
738 735
 	 */
739
-	public function mtime( $file ) {
736
+	public function mtime($file) {
740 737
 		return false;
741 738
 	}
742 739
 
@@ -750,7 +747,7 @@  discard block
 block discarded – undo
750 747
 	 * @param string $file Path to file.
751 748
 	 * @return int|bool Size of the file in bytes.
752 749
 	 */
753
-	public function size( $file ) {
750
+	public function size($file) {
754 751
 		return false;
755 752
 	}
756 753
 
@@ -770,7 +767,7 @@  discard block
 block discarded – undo
770 767
 	 *                      Default 0.
771 768
 	 * @return bool Whether operation was successful or not.
772 769
 	 */
773
-	public function touch( $file, $time = 0, $atime = 0 ) {
770
+	public function touch($file, $time = 0, $atime = 0) {
774 771
 		return false;
775 772
 	}
776 773
 
@@ -790,7 +787,7 @@  discard block
 block discarded – undo
790 787
 	 *                      Default false.
791 788
 	 * @return bool False if directory cannot be created, true otherwise.
792 789
 	 */
793
-	public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
790
+	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
794 791
 		return false;
795 792
 	}
796 793
 
@@ -806,7 +803,7 @@  discard block
 block discarded – undo
806 803
 	 *                          Default false.
807 804
 	 * @return bool Whether directory is deleted successfully or not.
808 805
 	 */
809
-	public function rmdir( $path, $recursive = false ) {
806
+	public function rmdir($path, $recursive = false) {
810 807
 		return false;
811 808
 	}
812 809
 
@@ -837,7 +834,7 @@  discard block
 block discarded – undo
837 834
 	 *     @type mixed  $files       If a directory and $recursive is true, contains another array of files.
838 835
 	 * }
839 836
 	 */
840
-	public function dirlist( $path, $include_hidden = true, $recursive = false ) {
837
+	public function dirlist($path, $include_hidden = true, $recursive = false) {
841 838
 		return false;
842 839
 	}
843 840
 
Please login to merge, or discard this patch.
Braces   +54 added lines, -32 removed lines patch added patch discarded remove patch
@@ -60,8 +60,9 @@  discard block
 block discarded – undo
60 60
 	public function abspath() {
61 61
 		$folder = $this->find_folder(ABSPATH);
62 62
 		// Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
63
-		if ( ! $folder && $this->is_dir( '/' . WPINC ) )
64
-			$folder = '/';
63
+		if ( ! $folder && $this->is_dir( '/' . WPINC ) ) {
64
+					$folder = '/';
65
+		}
65 66
 		return $folder;
66 67
 	}
67 68
 
@@ -102,8 +103,9 @@  discard block
 block discarded – undo
102 103
 		$theme_root = get_theme_root( $theme );
103 104
 
104 105
 		// Account for relative theme roots
105
-		if ( '/themes' == $theme_root || ! is_dir( $theme_root ) )
106
-			$theme_root = WP_CONTENT_DIR . $theme_root;
106
+		if ( '/themes' == $theme_root || ! is_dir( $theme_root ) ) {
107
+					$theme_root = WP_CONTENT_DIR . $theme_root;
108
+		}
107 109
 
108 110
 		return $this->find_folder( $theme_root );
109 111
 	}
@@ -178,8 +180,9 @@  discard block
 block discarded – undo
178 180
 	 * @return string|false The location of the remote path, false on failure.
179 181
 	 */
180 182
 	public function find_folder( $folder ) {
181
-		if ( isset( $this->cache[ $folder ] ) )
182
-			return $this->cache[ $folder ];
183
+		if ( isset( $this->cache[ $folder ] ) ) {
184
+					return $this->cache[ $folder ];
185
+		}
183 186
 
184 187
 		if ( stripos($this->method, 'ftp') !== false ) {
185 188
 			$constant_overrides = array(
@@ -191,16 +194,19 @@  discard block
 block discarded – undo
191 194
 
192 195
 			// Direct matches ( folder = CONSTANT/ )
193 196
 			foreach ( $constant_overrides as $constant => $dir ) {
194
-				if ( ! defined( $constant ) )
195
-					continue;
196
-				if ( $folder === $dir )
197
-					return trailingslashit( constant( $constant ) );
197
+				if ( ! defined( $constant ) ) {
198
+									continue;
199
+				}
200
+				if ( $folder === $dir ) {
201
+									return trailingslashit( constant( $constant ) );
202
+				}
198 203
 			}
199 204
 
200 205
 			// Prefix Matches ( folder = CONSTANT/subdir )
201 206
 			foreach ( $constant_overrides as $constant => $dir ) {
202
-				if ( ! defined( $constant ) )
203
-					continue;
207
+				if ( ! defined( $constant ) ) {
208
+									continue;
209
+				}
204 210
 				if ( 0 === stripos( $folder, $dir ) ) { // $folder starts with $dir
205 211
 					$potential_folder = preg_replace( '#^' . preg_quote( $dir, '#' ) . '/#i', trailingslashit( constant( $constant ) ), $folder );
206 212
 					$potential_folder = trailingslashit( $potential_folder );
@@ -219,16 +225,18 @@  discard block
 block discarded – undo
219 225
 		$folder = preg_replace('|^([a-z]{1}):|i', '', $folder); // Strip out windows drive letter if it's there.
220 226
 		$folder = str_replace('\\', '/', $folder); // Windows path sanitisation
221 227
 
222
-		if ( isset($this->cache[ $folder ] ) )
223
-			return $this->cache[ $folder ];
228
+		if ( isset($this->cache[ $folder ] ) ) {
229
+					return $this->cache[ $folder ];
230
+		}
224 231
 
225 232
 		if ( $this->exists($folder) ) { // Folder exists at that absolute path.
226 233
 			$folder = trailingslashit($folder);
227 234
 			$this->cache[ $folder ] = $folder;
228 235
 			return $folder;
229 236
 		}
230
-		if ( $return = $this->search_for_folder($folder) )
231
-			$this->cache[ $folder ] = $return;
237
+		if ( $return = $this->search_for_folder($folder) ) {
238
+					$this->cache[ $folder ] = $return;
239
+		}
232 240
 		return $return;
233 241
 	}
234 242
 
@@ -246,8 +254,9 @@  discard block
 block discarded – undo
246 254
 	 * @return string|false The location of the remote path, false to cease looping.
247 255
 	 */
248 256
 	public function search_for_folder( $folder, $base = '.', $loop = false ) {
249
-		if ( empty( $base ) || '.' == $base )
250
-			$base = trailingslashit($this->cwd());
257
+		if ( empty( $base ) || '.' == $base ) {
258
+					$base = trailingslashit($this->cwd());
259
+		}
251 260
 
252 261
 		$folder = untrailingslashit($folder);
253 262
 
@@ -264,8 +273,10 @@  discard block
 block discarded – undo
264 273
 		$files = $this->dirlist( $base );
265 274
 
266 275
 		foreach ( $folder_parts as $index => $key ) {
267
-			if ( $index == $last_index )
268
-				continue; // We want this to be caught by the next code block.
276
+			if ( $index == $last_index ) {
277
+							continue;
278
+			}
279
+			// We want this to be caught by the next code block.
269 280
 
270 281
 			/*
271 282
 			 * Working from /home/ to /user/ to /wordpress/ see if that file exists within
@@ -285,8 +296,9 @@  discard block
 block discarded – undo
285 296
 
286 297
 				// Only search for the remaining path tokens in the directory, not the full path again.
287 298
 				$newfolder = implode( '/', array_slice( $folder_parts, $index + 1 ) );
288
-				if ( $ret = $this->search_for_folder( $newfolder, $newdir, $loop) )
289
-					return $ret;
299
+				if ( $ret = $this->search_for_folder( $newfolder, $newdir, $loop) ) {
300
+									return $ret;
301
+				}
290 302
 			}
291 303
 		}
292 304
 
@@ -302,8 +314,9 @@  discard block
 block discarded – undo
302 314
 
303 315
 		// Prevent this function from looping again.
304 316
 		// No need to proceed if we've just searched in /
305
-		if ( $loop || '/' == $base )
306
-			return false;
317
+		if ( $loop || '/' == $base ) {
318
+					return false;
319
+		}
307 320
 
308 321
 		// As an extra last resort, Change back to / if the folder wasn't found.
309 322
 		// This comes into effect when the CWD is /home/user/ but WP is at /var/www/....
@@ -326,22 +339,31 @@  discard block
 block discarded – undo
326 339
 	 */
327 340
 	public function gethchmod( $file ){
328 341
 		$perms = intval( $this->getchmod( $file ), 8 );
329
-		if (($perms & 0xC000) == 0xC000) // Socket
342
+		if (($perms & 0xC000) == 0xC000) {
343
+			// Socket
330 344
 			$info = 's';
331
-		elseif (($perms & 0xA000) == 0xA000) // Symbolic Link
345
+		} elseif (($perms & 0xA000) == 0xA000) {
346
+			// Symbolic Link
332 347
 			$info = 'l';
333
-		elseif (($perms & 0x8000) == 0x8000) // Regular
348
+		} elseif (($perms & 0x8000) == 0x8000) {
349
+			// Regular
334 350
 			$info = '-';
335
-		elseif (($perms & 0x6000) == 0x6000) // Block special
351
+		} elseif (($perms & 0x6000) == 0x6000) {
352
+			// Block special
336 353
 			$info = 'b';
337
-		elseif (($perms & 0x4000) == 0x4000) // Directory
354
+		} elseif (($perms & 0x4000) == 0x4000) {
355
+			// Directory
338 356
 			$info = 'd';
339
-		elseif (($perms & 0x2000) == 0x2000) // Character special
357
+		} elseif (($perms & 0x2000) == 0x2000) {
358
+			// Character special
340 359
 			$info = 'c';
341
-		elseif (($perms & 0x1000) == 0x1000) // FIFO pipe
360
+		} elseif (($perms & 0x1000) == 0x1000) {
361
+			// FIFO pipe
342 362
 			$info = 'p';
343
-		else // Unknown
363
+		} else {
364
+			// Unknown
344 365
 			$info = 'u';
366
+		}
345 367
 
346 368
 		// Owner
347 369
 		$info .= (($perms & 0x0100) ? 'r' : '-');
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -384,7 +384,7 @@
 block discarded – undo
384 384
 	 *
385 385
 	 * Converts '-rw-r--r--' to 0644
386 386
 	 * From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
387
- 	 *
387
+	 *
388 388
 	 * @link https://secure.php.net/manual/en/function.chmod.php#49614
389 389
 	 *
390 390
 	 * @access public
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-filesystem-ftpext.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@
 block discarded – undo
126 126
 	/**
127 127
 	 * @param string $file
128 128
 	 * @param string $contents
129
-	 * @param bool|int $mode
129
+	 * @param string|boolean $mode
130 130
 	 * @return bool
131 131
 	 */
132 132
 	public function put_contents($file, $contents, $mode = false ) {
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -22,44 +22,44 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param array $opt
24 24
 	 */
25
-	public function __construct( $opt = '' ) {
25
+	public function __construct($opt = '') {
26 26
 		$this->method = 'ftpext';
27 27
 		$this->errors = new WP_Error();
28 28
 
29 29
 		// Check if possible to use ftp functions.
30
-		if ( ! extension_loaded('ftp') ) {
30
+		if ( ! extension_loaded('ftp')) {
31 31
 			$this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available'));
32 32
 			return;
33 33
 		}
34 34
 
35 35
 		// This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
36 36
 
37
-		if ( ! defined('FS_TIMEOUT') )
37
+		if ( ! defined('FS_TIMEOUT'))
38 38
 			define('FS_TIMEOUT', 240);
39 39
 
40
-		if ( empty($opt['port']) )
40
+		if (empty($opt['port']))
41 41
 			$this->options['port'] = 21;
42 42
 		else
43 43
 			$this->options['port'] = $opt['port'];
44 44
 
45
-		if ( empty($opt['hostname']) )
45
+		if (empty($opt['hostname']))
46 46
 			$this->errors->add('empty_hostname', __('FTP hostname is required'));
47 47
 		else
48 48
 			$this->options['hostname'] = $opt['hostname'];
49 49
 
50 50
 		// Check if the options provided are OK.
51
-		if ( empty($opt['username']) )
51
+		if (empty($opt['username']))
52 52
 			$this->errors->add('empty_username', __('FTP username is required'));
53 53
 		else
54 54
 			$this->options['username'] = $opt['username'];
55 55
 
56
-		if ( empty($opt['password']) )
56
+		if (empty($opt['password']))
57 57
 			$this->errors->add('empty_password', __('FTP password is required'));
58 58
 		else
59 59
 			$this->options['password'] = $opt['password'];
60 60
 
61 61
 		$this->options['ssl'] = false;
62
-		if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] )
62
+		if (isset($opt['connection_type']) && 'ftps' == $opt['connection_type'])
63 63
 			$this->options['ssl'] = true;
64 64
 	}
65 65
 
@@ -69,25 +69,25 @@  discard block
 block discarded – undo
69 69
 	 * @return bool
70 70
 	 */
71 71
 	public function connect() {
72
-		if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') )
72
+		if (isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect'))
73 73
 			$this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
74 74
 		else
75 75
 			$this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
76 76
 
77
-		if ( ! $this->link ) {
78
-			$this->errors->add( 'connect',
77
+		if ( ! $this->link) {
78
+			$this->errors->add('connect',
79 79
 				/* translators: %s: hostname:port */
80
-				sprintf( __( 'Failed to connect to FTP Server %s' ),
81
-					$this->options['hostname'] . ':' . $this->options['port']
80
+				sprintf(__('Failed to connect to FTP Server %s'),
81
+					$this->options['hostname'].':'.$this->options['port']
82 82
 				)
83 83
 			);
84 84
 			return false;
85 85
 		}
86 86
 
87
-		if ( ! @ftp_login( $this->link,$this->options['username'], $this->options['password'] ) ) {
88
-			$this->errors->add( 'auth',
87
+		if ( ! @ftp_login($this->link, $this->options['username'], $this->options['password'])) {
88
+			$this->errors->add('auth',
89 89
 				/* translators: %s: username */
90
-				sprintf( __( 'Username/Password incorrect for %s' ),
90
+				sprintf(__('Username/Password incorrect for %s'),
91 91
 					$this->options['username']
92 92
 				)
93 93
 			);
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 		}
96 96
 
97 97
 		// Set the Connection to use Passive FTP
98
-		@ftp_pasv( $this->link, true );
99
-		if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT )
98
+		@ftp_pasv($this->link, true);
99
+		if (@ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT)
100 100
 			@ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT);
101 101
 
102 102
 		return true;
@@ -112,25 +112,25 @@  discard block
 block discarded – undo
112 112
 	 * @return string|false File contents on success, false if no temp file could be opened,
113 113
 	 *                      or if the file couldn't be retrieved.
114 114
 	 */
115
-	public function get_contents( $file ) {
115
+	public function get_contents($file) {
116 116
 		$tempfile = wp_tempnam($file);
117 117
 		$temp = fopen($tempfile, 'w+');
118 118
 
119
-		if ( ! $temp ) {
120
-			unlink( $tempfile );
119
+		if ( ! $temp) {
120
+			unlink($tempfile);
121 121
 			return false;
122 122
 		}
123 123
 		
124
-		if ( ! @ftp_fget( $this->link, $temp, $file, FTP_BINARY ) ) {
125
-			fclose( $temp );
126
-			unlink( $tempfile );
124
+		if ( ! @ftp_fget($this->link, $temp, $file, FTP_BINARY)) {
125
+			fclose($temp);
126
+			unlink($tempfile);
127 127
 			return false;
128 128
 		}
129 129
 		
130
-		fseek( $temp, 0 ); // Skip back to the start of the file being written to
130
+		fseek($temp, 0); // Skip back to the start of the file being written to
131 131
 		$contents = '';
132 132
 
133
-		while ( ! feof($temp) )
133
+		while ( ! feof($temp))
134 134
 			$contents .= fread($temp, 8192);
135 135
 
136 136
 		fclose($temp);
@@ -156,28 +156,28 @@  discard block
 block discarded – undo
156 156
 	 * @param bool|int $mode
157 157
 	 * @return bool
158 158
 	 */
159
-	public function put_contents($file, $contents, $mode = false ) {
159
+	public function put_contents($file, $contents, $mode = false) {
160 160
 		$tempfile = wp_tempnam($file);
161
-		$temp = fopen( $tempfile, 'wb+' );
162
-		if ( ! $temp )
161
+		$temp = fopen($tempfile, 'wb+');
162
+		if ( ! $temp)
163 163
 			return false;
164 164
 
165 165
 		mbstring_binary_safe_encoding();
166 166
 
167
-		$data_length = strlen( $contents );
168
-		$bytes_written = fwrite( $temp, $contents );
167
+		$data_length = strlen($contents);
168
+		$bytes_written = fwrite($temp, $contents);
169 169
 
170 170
 		reset_mbstring_encoding();
171 171
 
172
-		if ( $data_length !== $bytes_written ) {
173
-			fclose( $temp );
174
-			unlink( $tempfile );
172
+		if ($data_length !== $bytes_written) {
173
+			fclose($temp);
174
+			unlink($tempfile);
175 175
 			return false;
176 176
 		}
177 177
 
178
-		fseek( $temp, 0 ); // Skip back to the start of the file being written to
178
+		fseek($temp, 0); // Skip back to the start of the file being written to
179 179
 
180
-		$ret = @ftp_fput( $this->link, $file, $temp, FTP_BINARY );
180
+		$ret = @ftp_fput($this->link, $file, $temp, FTP_BINARY);
181 181
 
182 182
 		fclose($temp);
183 183
 		unlink($tempfile);
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 */
195 195
 	public function cwd() {
196 196
 		$cwd = @ftp_pwd($this->link);
197
-		if ( $cwd )
197
+		if ($cwd)
198 198
 			$cwd = trailingslashit($cwd);
199 199
 		return $cwd;
200 200
 	}
@@ -218,26 +218,26 @@  discard block
 block discarded – undo
218 218
 	 * @return bool
219 219
 	 */
220 220
 	public function chmod($file, $mode = false, $recursive = false) {
221
-		if ( ! $mode ) {
222
-			if ( $this->is_file($file) )
221
+		if ( ! $mode) {
222
+			if ($this->is_file($file))
223 223
 				$mode = FS_CHMOD_FILE;
224
-			elseif ( $this->is_dir($file) )
224
+			elseif ($this->is_dir($file))
225 225
 				$mode = FS_CHMOD_DIR;
226 226
 			else
227 227
 				return false;
228 228
 		}
229 229
 
230 230
 		// chmod any sub-objects if recursive.
231
-		if ( $recursive && $this->is_dir($file) ) {
231
+		if ($recursive && $this->is_dir($file)) {
232 232
 			$filelist = $this->dirlist($file);
233
-			foreach ( (array)$filelist as $filename => $filemeta )
234
-				$this->chmod($file . '/' . $filename, $mode, $recursive);
233
+			foreach ((array) $filelist as $filename => $filemeta)
234
+				$this->chmod($file.'/'.$filename, $mode, $recursive);
235 235
 		}
236 236
 
237 237
 		// chmod the file or directory
238
-		if ( ! function_exists('ftp_chmod') )
239
-			return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
240
-		return (bool)@ftp_chmod($this->link, $mode, $file);
238
+		if ( ! function_exists('ftp_chmod'))
239
+			return (bool) @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
240
+		return (bool) @ftp_chmod($this->link, $mode, $file);
241 241
 	}
242 242
 
243 243
 	/**
@@ -282,10 +282,10 @@  discard block
 block discarded – undo
282 282
 	 * @return bool
283 283
 	 */
284 284
 	public function copy($source, $destination, $overwrite = false, $mode = false) {
285
-		if ( ! $overwrite && $this->exists($destination) )
285
+		if ( ! $overwrite && $this->exists($destination))
286 286
 			return false;
287 287
 		$content = $this->get_contents($source);
288
-		if ( false === $content )
288
+		if (false === $content)
289 289
 			return false;
290 290
 		return $this->put_contents($destination, $content, $mode);
291 291
 	}
@@ -311,17 +311,17 @@  discard block
 block discarded – undo
311 311
 	 * @return bool
312 312
 	 */
313 313
 	public function delete($file, $recursive = false, $type = false) {
314
-		if ( empty($file) )
314
+		if (empty($file))
315 315
 			return false;
316
-		if ( 'f' == $type || $this->is_file($file) )
316
+		if ('f' == $type || $this->is_file($file))
317 317
 			return @ftp_delete($this->link, $file);
318
-		if ( !$recursive )
318
+		if ( ! $recursive)
319 319
 			return @ftp_rmdir($this->link, $file);
320 320
 
321
-		$filelist = $this->dirlist( trailingslashit($file) );
322
-		if ( !empty($filelist) )
323
-			foreach ( $filelist as $delete_file )
324
-				$this->delete( trailingslashit($file) . $delete_file['name'], $recursive, $delete_file['type'] );
321
+		$filelist = $this->dirlist(trailingslashit($file));
322
+		if ( ! empty($filelist))
323
+			foreach ($filelist as $delete_file)
324
+				$this->delete(trailingslashit($file).$delete_file['name'], $recursive, $delete_file['type']);
325 325
 		return @ftp_rmdir($this->link, $file);
326 326
 	}
327 327
 
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
 	public function exists($file) {
335 335
 		$list = @ftp_nlist($this->link, $file);
336 336
 
337
-		if ( empty( $list ) && $this->is_dir( $file ) ) {
337
+		if (empty($list) && $this->is_dir($file)) {
338 338
 			return true; // File is an empty directory.
339 339
 		}
340 340
 
341
-		return !empty($list); //empty list = no file, so invert.
341
+		return ! empty($list); //empty list = no file, so invert.
342 342
 	}
343 343
 
344 344
 	/**
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	 * @return bool
349 349
 	 */
350 350
 	public function is_file($file) {
351
-		return $this->exists($file) && !$this->is_dir($file);
351
+		return $this->exists($file) && ! $this->is_dir($file);
352 352
 	}
353 353
 
354 354
 	/**
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
 	 */
360 360
 	public function is_dir($path) {
361 361
 		$cwd = $this->cwd();
362
-		$result = @ftp_chdir($this->link, trailingslashit($path) );
363
-		if ( $result && $path == $this->cwd() || $this->cwd() != $cwd ) {
362
+		$result = @ftp_chdir($this->link, trailingslashit($path));
363
+		if ($result && $path == $this->cwd() || $this->cwd() != $cwd) {
364 364
 			@ftp_chdir($this->link, $cwd);
365 365
 			return true;
366 366
 		}
@@ -438,10 +438,10 @@  discard block
 block discarded – undo
438 438
 	 */
439 439
 	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
440 440
 		$path = untrailingslashit($path);
441
-		if ( empty($path) )
441
+		if (empty($path))
442 442
 			return false;
443 443
 
444
-		if ( !@ftp_mkdir($this->link, $path) )
444
+		if ( ! @ftp_mkdir($this->link, $path))
445 445
 			return false;
446 446
 		$this->chmod($path, $chmod);
447 447
 		return true;
@@ -467,17 +467,17 @@  discard block
 block discarded – undo
467 467
 	 */
468 468
 	public function parselisting($line) {
469 469
 		static $is_windows = null;
470
-		if ( is_null($is_windows) )
471
-			$is_windows = stripos( ftp_systype($this->link), 'win') !== false;
470
+		if (is_null($is_windows))
471
+			$is_windows = stripos(ftp_systype($this->link), 'win') !== false;
472 472
 
473
-		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) ) {
473
+		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)) {
474 474
 			$b = array();
475
-			if ( $lucifer[3] < 70 )
476
-				$lucifer[3] +=2000;
475
+			if ($lucifer[3] < 70)
476
+				$lucifer[3] += 2000;
477 477
 			else
478 478
 				$lucifer[3] += 1900; // 4digit year fix
479
-			$b['isdir'] = ( $lucifer[7] == '<DIR>');
480
-			if ( $b['isdir'] )
479
+			$b['isdir'] = ($lucifer[7] == '<DIR>');
480
+			if ($b['isdir'])
481 481
 				$b['type'] = 'd';
482 482
 			else
483 483
 				$b['type'] = 'f';
@@ -490,27 +490,27 @@  discard block
 block discarded – undo
490 490
 			$b['time'] = @mktime($lucifer[4] + (strcasecmp($lucifer[6], "PM") == 0 ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]);
491 491
 			$b['am/pm'] = $lucifer[6];
492 492
 			$b['name'] = $lucifer[8];
493
-		} elseif ( !$is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) {
493
+		} elseif ( ! $is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) {
494 494
 			//echo $line."\n";
495 495
 			$lcount = count($lucifer);
496
-			if ( $lcount < 8 )
496
+			if ($lcount < 8)
497 497
 				return '';
498 498
 			$b = array();
499 499
 			$b['isdir'] = $lucifer[0]{0} === 'd';
500 500
 			$b['islink'] = $lucifer[0]{0} === 'l';
501
-			if ( $b['isdir'] )
501
+			if ($b['isdir'])
502 502
 				$b['type'] = 'd';
503
-			elseif ( $b['islink'] )
503
+			elseif ($b['islink'])
504 504
 				$b['type'] = 'l';
505 505
 			else
506 506
 				$b['type'] = 'f';
507 507
 			$b['perms'] = $lucifer[0];
508
-			$b['permsn'] = $this->getnumchmodfromh( $b['perms'] );
508
+			$b['permsn'] = $this->getnumchmodfromh($b['perms']);
509 509
 			$b['number'] = $lucifer[1];
510 510
 			$b['owner'] = $lucifer[2];
511 511
 			$b['group'] = $lucifer[3];
512 512
 			$b['size'] = $lucifer[4];
513
-			if ( $lcount == 8 ) {
513
+			if ($lcount == 8) {
514 514
 				sscanf($lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day']);
515 515
 				sscanf($lucifer[6], '%d:%d', $b['hour'], $b['minute']);
516 516
 				$b['time'] = @mktime($b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year']);
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 			} else {
519 519
 				$b['month'] = $lucifer[5];
520 520
 				$b['day'] = $lucifer[6];
521
-				if ( preg_match('/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2) ) {
521
+				if (preg_match('/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2)) {
522 522
 					$b['year'] = date("Y");
523 523
 					$b['hour'] = $l2[1];
524 524
 					$b['minute'] = $l2[2];
@@ -527,14 +527,14 @@  discard block
 block discarded – undo
527 527
 					$b['hour'] = 0;
528 528
 					$b['minute'] = 0;
529 529
 				}
530
-				$b['time'] = strtotime( sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute']) );
530
+				$b['time'] = strtotime(sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute']));
531 531
 				$b['name'] = $lucifer[8];
532 532
 			}
533 533
 		}
534 534
 
535 535
 		// Replace symlinks formatted as "source -> target" with just the source name
536
-		if ( isset( $b['islink'] ) && $b['islink'] ) {
537
-			$b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] );
536
+		if (isset($b['islink']) && $b['islink']) {
537
+			$b['name'] = preg_replace('/(\s*->\s*.*)$/', '', $b['name']);
538 538
 		}
539 539
 
540 540
 		return $b;
@@ -549,50 +549,50 @@  discard block
 block discarded – undo
549 549
 	 * @return bool|array
550 550
 	 */
551 551
 	public function dirlist($path = '.', $include_hidden = true, $recursive = false) {
552
-		if ( $this->is_file($path) ) {
552
+		if ($this->is_file($path)) {
553 553
 			$limit_file = basename($path);
554
-			$path = dirname($path) . '/';
554
+			$path = dirname($path).'/';
555 555
 		} else {
556 556
 			$limit_file = false;
557 557
 		}
558 558
 
559 559
 		$pwd = @ftp_pwd($this->link);
560
-		if ( ! @ftp_chdir($this->link, $path) ) // Cant change to folder = folder doesn't exist
560
+		if ( ! @ftp_chdir($this->link, $path)) // Cant change to folder = folder doesn't exist
561 561
 			return false;
562 562
 		$list = @ftp_rawlist($this->link, '-a', false);
563 563
 		@ftp_chdir($this->link, $pwd);
564 564
 
565
-		if ( empty($list) ) // Empty array = non-existent folder (real folder will show . at least)
565
+		if (empty($list)) // Empty array = non-existent folder (real folder will show . at least)
566 566
 			return false;
567 567
 
568 568
 		$dirlist = array();
569
-		foreach ( $list as $k => $v ) {
569
+		foreach ($list as $k => $v) {
570 570
 			$entry = $this->parselisting($v);
571
-			if ( empty($entry) )
571
+			if (empty($entry))
572 572
 				continue;
573 573
 
574
-			if ( '.' == $entry['name'] || '..' == $entry['name'] )
574
+			if ('.' == $entry['name'] || '..' == $entry['name'])
575 575
 				continue;
576 576
 
577
-			if ( ! $include_hidden && '.' == $entry['name'][0] )
577
+			if ( ! $include_hidden && '.' == $entry['name'][0])
578 578
 				continue;
579 579
 
580
-			if ( $limit_file && $entry['name'] != $limit_file)
580
+			if ($limit_file && $entry['name'] != $limit_file)
581 581
 				continue;
582 582
 
583
-			$dirlist[ $entry['name'] ] = $entry;
583
+			$dirlist[$entry['name']] = $entry;
584 584
 		}
585 585
 
586 586
 		$ret = array();
587
-		foreach ( (array)$dirlist as $struc ) {
588
-			if ( 'd' == $struc['type'] ) {
589
-				if ( $recursive )
590
-					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
587
+		foreach ((array) $dirlist as $struc) {
588
+			if ('d' == $struc['type']) {
589
+				if ($recursive)
590
+					$struc['files'] = $this->dirlist($path.'/'.$struc['name'], $include_hidden, $recursive);
591 591
 				else
592 592
 					$struc['files'] = array();
593 593
 			}
594 594
 
595
-			$ret[ $struc['name'] ] = $struc;
595
+			$ret[$struc['name']] = $struc;
596 596
 		}
597 597
 		return $ret;
598 598
 	}
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	 * @access public
602 602
 	 */
603 603
 	public function __destruct() {
604
-		if ( $this->link )
604
+		if ($this->link)
605 605
 			ftp_close($this->link);
606 606
 	}
607 607
 }
Please login to merge, or discard this patch.
Braces   +130 added lines, -92 removed lines patch added patch discarded remove patch
@@ -34,33 +34,39 @@  discard block
 block discarded – undo
34 34
 
35 35
 		// This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
36 36
 
37
-		if ( ! defined('FS_TIMEOUT') )
38
-			define('FS_TIMEOUT', 240);
37
+		if ( ! defined('FS_TIMEOUT') ) {
38
+					define('FS_TIMEOUT', 240);
39
+		}
39 40
 
40
-		if ( empty($opt['port']) )
41
-			$this->options['port'] = 21;
42
-		else
43
-			$this->options['port'] = $opt['port'];
41
+		if ( empty($opt['port']) ) {
42
+					$this->options['port'] = 21;
43
+		} else {
44
+					$this->options['port'] = $opt['port'];
45
+		}
44 46
 
45
-		if ( empty($opt['hostname']) )
46
-			$this->errors->add('empty_hostname', __('FTP hostname is required'));
47
-		else
48
-			$this->options['hostname'] = $opt['hostname'];
47
+		if ( empty($opt['hostname']) ) {
48
+					$this->errors->add('empty_hostname', __('FTP hostname is required'));
49
+		} else {
50
+					$this->options['hostname'] = $opt['hostname'];
51
+		}
49 52
 
50 53
 		// Check if the options provided are OK.
51
-		if ( empty($opt['username']) )
52
-			$this->errors->add('empty_username', __('FTP username is required'));
53
-		else
54
-			$this->options['username'] = $opt['username'];
54
+		if ( empty($opt['username']) ) {
55
+					$this->errors->add('empty_username', __('FTP username is required'));
56
+		} else {
57
+					$this->options['username'] = $opt['username'];
58
+		}
55 59
 
56
-		if ( empty($opt['password']) )
57
-			$this->errors->add('empty_password', __('FTP password is required'));
58
-		else
59
-			$this->options['password'] = $opt['password'];
60
+		if ( empty($opt['password']) ) {
61
+					$this->errors->add('empty_password', __('FTP password is required'));
62
+		} else {
63
+					$this->options['password'] = $opt['password'];
64
+		}
60 65
 
61 66
 		$this->options['ssl'] = false;
62
-		if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] )
63
-			$this->options['ssl'] = true;
67
+		if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] ) {
68
+					$this->options['ssl'] = true;
69
+		}
64 70
 	}
65 71
 
66 72
 	/**
@@ -69,10 +75,11 @@  discard block
 block discarded – undo
69 75
 	 * @return bool
70 76
 	 */
71 77
 	public function connect() {
72
-		if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') )
73
-			$this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
74
-		else
75
-			$this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
78
+		if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) {
79
+					$this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
80
+		} else {
81
+					$this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
82
+		}
76 83
 
77 84
 		if ( ! $this->link ) {
78 85
 			$this->errors->add( 'connect',
@@ -96,8 +103,9 @@  discard block
 block discarded – undo
96 103
 
97 104
 		// Set the Connection to use Passive FTP
98 105
 		@ftp_pasv( $this->link, true );
99
-		if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT )
100
-			@ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT);
106
+		if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT ) {
107
+					@ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT);
108
+		}
101 109
 
102 110
 		return true;
103 111
 	}
@@ -130,8 +138,9 @@  discard block
 block discarded – undo
130 138
 		fseek( $temp, 0 ); // Skip back to the start of the file being written to
131 139
 		$contents = '';
132 140
 
133
-		while ( ! feof($temp) )
134
-			$contents .= fread($temp, 8192);
141
+		while ( ! feof($temp) ) {
142
+					$contents .= fread($temp, 8192);
143
+		}
135 144
 
136 145
 		fclose($temp);
137 146
 		unlink($tempfile);
@@ -159,8 +168,9 @@  discard block
 block discarded – undo
159 168
 	public function put_contents($file, $contents, $mode = false ) {
160 169
 		$tempfile = wp_tempnam($file);
161 170
 		$temp = fopen( $tempfile, 'wb+' );
162
-		if ( ! $temp )
163
-			return false;
171
+		if ( ! $temp ) {
172
+					return false;
173
+		}
164 174
 
165 175
 		mbstring_binary_safe_encoding();
166 176
 
@@ -194,8 +204,9 @@  discard block
 block discarded – undo
194 204
 	 */
195 205
 	public function cwd() {
196 206
 		$cwd = @ftp_pwd($this->link);
197
-		if ( $cwd )
198
-			$cwd = trailingslashit($cwd);
207
+		if ( $cwd ) {
208
+					$cwd = trailingslashit($cwd);
209
+		}
199 210
 		return $cwd;
200 211
 	}
201 212
 
@@ -219,24 +230,27 @@  discard block
 block discarded – undo
219 230
 	 */
220 231
 	public function chmod($file, $mode = false, $recursive = false) {
221 232
 		if ( ! $mode ) {
222
-			if ( $this->is_file($file) )
223
-				$mode = FS_CHMOD_FILE;
224
-			elseif ( $this->is_dir($file) )
225
-				$mode = FS_CHMOD_DIR;
226
-			else
227
-				return false;
233
+			if ( $this->is_file($file) ) {
234
+							$mode = FS_CHMOD_FILE;
235
+			} elseif ( $this->is_dir($file) ) {
236
+							$mode = FS_CHMOD_DIR;
237
+			} else {
238
+							return false;
239
+			}
228 240
 		}
229 241
 
230 242
 		// chmod any sub-objects if recursive.
231 243
 		if ( $recursive && $this->is_dir($file) ) {
232 244
 			$filelist = $this->dirlist($file);
233
-			foreach ( (array)$filelist as $filename => $filemeta )
234
-				$this->chmod($file . '/' . $filename, $mode, $recursive);
245
+			foreach ( (array)$filelist as $filename => $filemeta ) {
246
+							$this->chmod($file . '/' . $filename, $mode, $recursive);
247
+			}
235 248
 		}
236 249
 
237 250
 		// chmod the file or directory
238
-		if ( ! function_exists('ftp_chmod') )
239
-			return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
251
+		if ( ! function_exists('ftp_chmod') ) {
252
+					return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
253
+		}
240 254
 		return (bool)@ftp_chmod($this->link, $mode, $file);
241 255
 	}
242 256
 
@@ -282,11 +296,13 @@  discard block
 block discarded – undo
282 296
 	 * @return bool
283 297
 	 */
284 298
 	public function copy($source, $destination, $overwrite = false, $mode = false) {
285
-		if ( ! $overwrite && $this->exists($destination) )
286
-			return false;
299
+		if ( ! $overwrite && $this->exists($destination) ) {
300
+					return false;
301
+		}
287 302
 		$content = $this->get_contents($source);
288
-		if ( false === $content )
289
-			return false;
303
+		if ( false === $content ) {
304
+					return false;
305
+		}
290 306
 		return $this->put_contents($destination, $content, $mode);
291 307
 	}
292 308
 
@@ -311,17 +327,21 @@  discard block
 block discarded – undo
311 327
 	 * @return bool
312 328
 	 */
313 329
 	public function delete($file, $recursive = false, $type = false) {
314
-		if ( empty($file) )
315
-			return false;
316
-		if ( 'f' == $type || $this->is_file($file) )
317
-			return @ftp_delete($this->link, $file);
318
-		if ( !$recursive )
319
-			return @ftp_rmdir($this->link, $file);
330
+		if ( empty($file) ) {
331
+					return false;
332
+		}
333
+		if ( 'f' == $type || $this->is_file($file) ) {
334
+					return @ftp_delete($this->link, $file);
335
+		}
336
+		if ( !$recursive ) {
337
+					return @ftp_rmdir($this->link, $file);
338
+		}
320 339
 
321 340
 		$filelist = $this->dirlist( trailingslashit($file) );
322
-		if ( !empty($filelist) )
323
-			foreach ( $filelist as $delete_file )
341
+		if ( !empty($filelist) ) {
342
+					foreach ( $filelist as $delete_file )
324 343
 				$this->delete( trailingslashit($file) . $delete_file['name'], $recursive, $delete_file['type'] );
344
+		}
325 345
 		return @ftp_rmdir($this->link, $file);
326 346
 	}
327 347
 
@@ -438,11 +458,13 @@  discard block
 block discarded – undo
438 458
 	 */
439 459
 	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
440 460
 		$path = untrailingslashit($path);
441
-		if ( empty($path) )
442
-			return false;
461
+		if ( empty($path) ) {
462
+					return false;
463
+		}
443 464
 
444
-		if ( !@ftp_mkdir($this->link, $path) )
445
-			return false;
465
+		if ( !@ftp_mkdir($this->link, $path) ) {
466
+					return false;
467
+		}
446 468
 		$this->chmod($path, $chmod);
447 469
 		return true;
448 470
 	}
@@ -467,20 +489,24 @@  discard block
 block discarded – undo
467 489
 	 */
468 490
 	public function parselisting($line) {
469 491
 		static $is_windows = null;
470
-		if ( is_null($is_windows) )
471
-			$is_windows = stripos( ftp_systype($this->link), 'win') !== false;
492
+		if ( is_null($is_windows) ) {
493
+					$is_windows = stripos( ftp_systype($this->link), 'win') !== false;
494
+		}
472 495
 
473 496
 		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) ) {
474 497
 			$b = array();
475
-			if ( $lucifer[3] < 70 )
476
-				$lucifer[3] +=2000;
477
-			else
478
-				$lucifer[3] += 1900; // 4digit year fix
498
+			if ( $lucifer[3] < 70 ) {
499
+							$lucifer[3] +=2000;
500
+			} else {
501
+							$lucifer[3] += 1900;
502
+			}
503
+			// 4digit year fix
479 504
 			$b['isdir'] = ( $lucifer[7] == '<DIR>');
480
-			if ( $b['isdir'] )
481
-				$b['type'] = 'd';
482
-			else
483
-				$b['type'] = 'f';
505
+			if ( $b['isdir'] ) {
506
+							$b['type'] = 'd';
507
+			} else {
508
+							$b['type'] = 'f';
509
+			}
484 510
 			$b['size'] = $lucifer[7];
485 511
 			$b['month'] = $lucifer[1];
486 512
 			$b['day'] = $lucifer[2];
@@ -493,17 +519,19 @@  discard block
 block discarded – undo
493 519
 		} elseif ( !$is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) {
494 520
 			//echo $line."\n";
495 521
 			$lcount = count($lucifer);
496
-			if ( $lcount < 8 )
497
-				return '';
522
+			if ( $lcount < 8 ) {
523
+							return '';
524
+			}
498 525
 			$b = array();
499 526
 			$b['isdir'] = $lucifer[0]{0} === 'd';
500 527
 			$b['islink'] = $lucifer[0]{0} === 'l';
501
-			if ( $b['isdir'] )
502
-				$b['type'] = 'd';
503
-			elseif ( $b['islink'] )
504
-				$b['type'] = 'l';
505
-			else
506
-				$b['type'] = 'f';
528
+			if ( $b['isdir'] ) {
529
+							$b['type'] = 'd';
530
+			} elseif ( $b['islink'] ) {
531
+							$b['type'] = 'l';
532
+			} else {
533
+							$b['type'] = 'f';
534
+			}
507 535
 			$b['perms'] = $lucifer[0];
508 536
 			$b['permsn'] = $this->getnumchmodfromh( $b['perms'] );
509 537
 			$b['number'] = $lucifer[1];
@@ -557,28 +585,36 @@  discard block
 block discarded – undo
557 585
 		}
558 586
 
559 587
 		$pwd = @ftp_pwd($this->link);
560
-		if ( ! @ftp_chdir($this->link, $path) ) // Cant change to folder = folder doesn't exist
588
+		if ( ! @ftp_chdir($this->link, $path) ) {
589
+			// Cant change to folder = folder doesn't exist
561 590
 			return false;
591
+		}
562 592
 		$list = @ftp_rawlist($this->link, '-a', false);
563 593
 		@ftp_chdir($this->link, $pwd);
564 594
 
565
-		if ( empty($list) ) // Empty array = non-existent folder (real folder will show . at least)
595
+		if ( empty($list) ) {
596
+			// Empty array = non-existent folder (real folder will show . at least)
566 597
 			return false;
598
+		}
567 599
 
568 600
 		$dirlist = array();
569 601
 		foreach ( $list as $k => $v ) {
570 602
 			$entry = $this->parselisting($v);
571
-			if ( empty($entry) )
572
-				continue;
603
+			if ( empty($entry) ) {
604
+							continue;
605
+			}
573 606
 
574
-			if ( '.' == $entry['name'] || '..' == $entry['name'] )
575
-				continue;
607
+			if ( '.' == $entry['name'] || '..' == $entry['name'] ) {
608
+							continue;
609
+			}
576 610
 
577
-			if ( ! $include_hidden && '.' == $entry['name'][0] )
578
-				continue;
611
+			if ( ! $include_hidden && '.' == $entry['name'][0] ) {
612
+							continue;
613
+			}
579 614
 
580
-			if ( $limit_file && $entry['name'] != $limit_file)
581
-				continue;
615
+			if ( $limit_file && $entry['name'] != $limit_file) {
616
+							continue;
617
+			}
582 618
 
583 619
 			$dirlist[ $entry['name'] ] = $entry;
584 620
 		}
@@ -586,10 +622,11 @@  discard block
 block discarded – undo
586 622
 		$ret = array();
587 623
 		foreach ( (array)$dirlist as $struc ) {
588 624
 			if ( 'd' == $struc['type'] ) {
589
-				if ( $recursive )
590
-					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
591
-				else
592
-					$struc['files'] = array();
625
+				if ( $recursive ) {
626
+									$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
627
+				} else {
628
+									$struc['files'] = array();
629
+				}
593 630
 			}
594 631
 
595 632
 			$ret[ $struc['name'] ] = $struc;
@@ -601,7 +638,8 @@  discard block
 block discarded – undo
601 638
 	 * @access public
602 639
 	 */
603 640
 	public function __destruct() {
604
-		if ( $this->link )
605
-			ftp_close($this->link);
641
+		if ( $this->link ) {
642
+					ftp_close($this->link);
643
+		}
606 644
 	}
607 645
 }
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.
Spacing   +79 added lines, -79 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,18 +115,18 @@  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+') )
124
+		if ( ! $temphandle = fopen($temp, 'w+'))
125 125
 			return false;
126 126
 
127 127
 		mbstring_binary_safe_encoding();
128 128
 
129
-		if ( ! $this->ftp->fget($temphandle, $file) ) {
129
+		if ( ! $this->ftp->fget($temphandle, $file)) {
130 130
 			fclose($temphandle);
131 131
 			unlink($temp);
132 132
 
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 
138 138
 		reset_mbstring_encoding();
139 139
 
140
-		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
140
+		fseek($temphandle, 0); // Skip back to the start of the file being written to
141 141
 		$contents = '';
142 142
 
143
-		while ( ! feof($temphandle) )
143
+		while ( ! feof($temphandle))
144 144
 			$contents .= fread($temphandle, 8192);
145 145
 
146 146
 		fclose($temphandle);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @return array
156 156
 	 */
157 157
 	public function get_contents_array($file) {
158
-		return explode("\n", $this->get_contents($file) );
158
+		return explode("\n", $this->get_contents($file));
159 159
 	}
160 160
 
161 161
 	/**
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 	 * @param int|bool $mode
167 167
 	 * @return bool
168 168
 	 */
169
-	public function put_contents($file, $contents, $mode = false ) {
170
-		$temp = wp_tempnam( $file );
171
-		if ( ! $temphandle = @fopen($temp, 'w+') ) {
169
+	public function put_contents($file, $contents, $mode = false) {
170
+		$temp = wp_tempnam($file);
171
+		if ( ! $temphandle = @fopen($temp, 'w+')) {
172 172
 			unlink($temp);
173 173
 			return false;
174 174
 		}
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
 		// The FTP class uses string functions internally during file download/upload
177 177
 		mbstring_binary_safe_encoding();
178 178
 
179
-		$bytes_written = fwrite( $temphandle, $contents );
180
-		if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) {
181
-			fclose( $temphandle );
182
-			unlink( $temp );
179
+		$bytes_written = fwrite($temphandle, $contents);
180
+		if (false === $bytes_written || $bytes_written != strlen($contents)) {
181
+			fclose($temphandle);
182
+			unlink($temp);
183 183
 
184 184
 			reset_mbstring_encoding();
185 185
 
186 186
 			return false;
187 187
 		}
188 188
 
189
-		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
189
+		fseek($temphandle, 0); // Skip back to the start of the file being written to
190 190
 
191 191
 		$ret = $this->ftp->fput($file, $temphandle);
192 192
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	public function cwd() {
209 209
 		$cwd = $this->ftp->pwd();
210
-		if ( $cwd )
210
+		if ($cwd)
211 211
 			$cwd = trailingslashit($cwd);
212 212
 		return $cwd;
213 213
 	}
@@ -230,21 +230,21 @@  discard block
 block discarded – undo
230 230
 	 * @param bool $recursive
231 231
 	 * @return bool
232 232
 	 */
233
-	public function chmod($file, $mode = false, $recursive = false ) {
234
-		if ( ! $mode ) {
235
-			if ( $this->is_file($file) )
233
+	public function chmod($file, $mode = false, $recursive = false) {
234
+		if ( ! $mode) {
235
+			if ($this->is_file($file))
236 236
 				$mode = FS_CHMOD_FILE;
237
-			elseif ( $this->is_dir($file) )
237
+			elseif ($this->is_dir($file))
238 238
 				$mode = FS_CHMOD_DIR;
239 239
 			else
240 240
 				return false;
241 241
 		}
242 242
 
243 243
 		// chmod any sub-objects if recursive.
244
-		if ( $recursive && $this->is_dir($file) ) {
244
+		if ($recursive && $this->is_dir($file)) {
245 245
 			$filelist = $this->dirlist($file);
246
-			foreach ( (array)$filelist as $filename => $filemeta )
247
-				$this->chmod($file . '/' . $filename, $mode, $recursive);
246
+			foreach ((array) $filelist as $filename => $filemeta)
247
+				$this->chmod($file.'/'.$filename, $mode, $recursive);
248 248
 		}
249 249
 
250 250
 		// chmod the file or directory
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 	 * @return bool
295 295
 	 */
296 296
 	public function copy($source, $destination, $overwrite = false, $mode = false) {
297
-		if ( ! $overwrite && $this->exists($destination) )
297
+		if ( ! $overwrite && $this->exists($destination))
298 298
 			return false;
299 299
 
300 300
 		$content = $this->get_contents($source);
301
-		if ( false === $content )
301
+		if (false === $content)
302 302
 			return false;
303 303
 
304 304
 		return $this->put_contents($destination, $content, $mode);
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 	 * @param bool   $overwrite
313 313
 	 * @return bool
314 314
 	 */
315
-	public function move($source, $destination, $overwrite = false ) {
315
+	public function move($source, $destination, $overwrite = false) {
316 316
 		return $this->ftp->rename($source, $destination);
317 317
 	}
318 318
 
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 	 * @return bool
326 326
 	 */
327 327
 	public function delete($file, $recursive = false, $type = false) {
328
-		if ( empty($file) )
328
+		if (empty($file))
329 329
 			return false;
330
-		if ( 'f' == $type || $this->is_file($file) )
330
+		if ('f' == $type || $this->is_file($file))
331 331
 			return $this->ftp->delete($file);
332
-		if ( !$recursive )
332
+		if ( ! $recursive)
333 333
 			return $this->ftp->rmdir($file);
334 334
 
335 335
 		return $this->ftp->mdel($file);
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
 	 * @param string $file
342 342
 	 * @return bool
343 343
 	 */
344
-	public function exists( $file ) {
345
-		$list = $this->ftp->nlist( $file );
344
+	public function exists($file) {
345
+		$list = $this->ftp->nlist($file);
346 346
 
347
-		if ( empty( $list ) && $this->is_dir( $file ) ) {
347
+		if (empty($list) && $this->is_dir($file)) {
348 348
 			return true; // File is an empty directory.
349 349
 		}
350 350
 
351
-		return !empty( $list ); //empty list = no file, so invert.
351
+		return ! empty($list); //empty list = no file, so invert.
352 352
 		// Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
353 353
 	}
354 354
 
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 	 * @return bool
360 360
 	 */
361 361
 	public function is_file($file) {
362
-		if ( $this->is_dir($file) )
362
+		if ($this->is_dir($file))
363 363
 			return false;
364
-		if ( $this->exists($file) )
364
+		if ($this->exists($file))
365 365
 			return true;
366 366
 		return false;
367 367
 	}
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	 */
375 375
 	public function is_dir($path) {
376 376
 		$cwd = $this->cwd();
377
-		if ( $this->chdir($path) ) {
377
+		if ($this->chdir($path)) {
378 378
 			$this->chdir($cwd);
379 379
 			return true;
380 380
 		}
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 * @param int $atime
438 438
 	 * @return bool
439 439
 	 */
440
-	public function touch($file, $time = 0, $atime = 0 ) {
440
+	public function touch($file, $time = 0, $atime = 0) {
441 441
 		return false;
442 442
 	}
443 443
 
@@ -450,14 +450,14 @@  discard block
 block discarded – undo
450 450
 	 * @param mixed  $chgrp
451 451
 	 * @return bool
452 452
 	 */
453
-	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false ) {
453
+	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
454 454
 		$path = untrailingslashit($path);
455
-		if ( empty($path) )
455
+		if (empty($path))
456 456
 			return false;
457 457
 
458
-		if ( ! $this->ftp->mkdir($path) )
458
+		if ( ! $this->ftp->mkdir($path))
459 459
 			return false;
460
-		if ( ! $chmod )
460
+		if ( ! $chmod)
461 461
 			$chmod = FS_CHMOD_DIR;
462 462
 		$this->chmod($path, $chmod);
463 463
 		return true;
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 	 * @param string $path
470 470
 	 * @param bool $recursive
471 471
 	 */
472
-	public function rmdir($path, $recursive = false ) {
472
+	public function rmdir($path, $recursive = false) {
473 473
 		$this->delete($path, $recursive);
474 474
 	}
475 475
 
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 	 * @param bool   $recursive
482 482
 	 * @return bool|array
483 483
 	 */
484
-	public function dirlist($path = '.', $include_hidden = true, $recursive = false ) {
485
-		if ( $this->is_file($path) ) {
484
+	public function dirlist($path = '.', $include_hidden = true, $recursive = false) {
485
+		if ($this->is_file($path)) {
486 486
 			$limit_file = basename($path);
487
-			$path = dirname($path) . '/';
487
+			$path = dirname($path).'/';
488 488
 		} else {
489 489
 			$limit_file = false;
490 490
 		}
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 		mbstring_binary_safe_encoding();
493 493
 
494 494
 		$list = $this->ftp->dirlist($path);
495
-		if ( empty( $list ) && ! $this->exists( $path ) ) {
495
+		if (empty($list) && ! $this->exists($path)) {
496 496
 
497 497
 			reset_mbstring_encoding();
498 498
 
@@ -500,32 +500,32 @@  discard block
 block discarded – undo
500 500
 		}
501 501
 
502 502
 		$ret = array();
503
-		foreach ( $list as $struc ) {
503
+		foreach ($list as $struc) {
504 504
 
505
-			if ( '.' == $struc['name'] || '..' == $struc['name'] )
505
+			if ('.' == $struc['name'] || '..' == $struc['name'])
506 506
 				continue;
507 507
 
508
-			if ( ! $include_hidden && '.' == $struc['name'][0] )
508
+			if ( ! $include_hidden && '.' == $struc['name'][0])
509 509
 				continue;
510 510
 
511
-			if ( $limit_file && $struc['name'] != $limit_file )
511
+			if ($limit_file && $struc['name'] != $limit_file)
512 512
 				continue;
513 513
 
514
-			if ( 'd' == $struc['type'] ) {
515
-				if ( $recursive )
516
-					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
514
+			if ('d' == $struc['type']) {
515
+				if ($recursive)
516
+					$struc['files'] = $this->dirlist($path.'/'.$struc['name'], $include_hidden, $recursive);
517 517
 				else
518 518
 					$struc['files'] = array();
519 519
 			}
520 520
 
521 521
 			// Replace symlinks formatted as "source -> target" with just the source name
522
-			if ( $struc['islink'] )
523
-				$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
522
+			if ($struc['islink'])
523
+				$struc['name'] = preg_replace('/(\s*->\s*.*)$/', '', $struc['name']);
524 524
 
525 525
 			// Add the Octal representation of the file permissions
526
-			$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
526
+			$struc['permsn'] = $this->getnumchmodfromh($struc['perms']);
527 527
 
528
-			$ret[ $struc['name'] ] = $struc;
528
+			$ret[$struc['name']] = $struc;
529 529
 		}
530 530
 
531 531
 		reset_mbstring_encoding();
Please login to merge, or discard this patch.
Braces   +93 added lines, -67 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,13 +121,15 @@  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
 
124
-		if ( ! $temphandle = fopen($temp, 'w+') )
125
-			return false;
130
+		if ( ! $temphandle = fopen($temp, 'w+') ) {
131
+					return false;
132
+		}
126 133
 
127 134
 		mbstring_binary_safe_encoding();
128 135
 
@@ -140,8 +147,9 @@  discard block
 block discarded – undo
140 147
 		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
141 148
 		$contents = '';
142 149
 
143
-		while ( ! feof($temphandle) )
144
-			$contents .= fread($temphandle, 8192);
150
+		while ( ! feof($temphandle) ) {
151
+					$contents .= fread($temphandle, 8192);
152
+		}
145 153
 
146 154
 		fclose($temphandle);
147 155
 		unlink($temp);
@@ -207,8 +215,9 @@  discard block
 block discarded – undo
207 215
 	 */
208 216
 	public function cwd() {
209 217
 		$cwd = $this->ftp->pwd();
210
-		if ( $cwd )
211
-			$cwd = trailingslashit($cwd);
218
+		if ( $cwd ) {
219
+					$cwd = trailingslashit($cwd);
220
+		}
212 221
 		return $cwd;
213 222
 	}
214 223
 
@@ -232,19 +241,21 @@  discard block
 block discarded – undo
232 241
 	 */
233 242
 	public function chmod($file, $mode = false, $recursive = false ) {
234 243
 		if ( ! $mode ) {
235
-			if ( $this->is_file($file) )
236
-				$mode = FS_CHMOD_FILE;
237
-			elseif ( $this->is_dir($file) )
238
-				$mode = FS_CHMOD_DIR;
239
-			else
240
-				return false;
244
+			if ( $this->is_file($file) ) {
245
+							$mode = FS_CHMOD_FILE;
246
+			} elseif ( $this->is_dir($file) ) {
247
+							$mode = FS_CHMOD_DIR;
248
+			} else {
249
+							return false;
250
+			}
241 251
 		}
242 252
 
243 253
 		// chmod any sub-objects if recursive.
244 254
 		if ( $recursive && $this->is_dir($file) ) {
245 255
 			$filelist = $this->dirlist($file);
246
-			foreach ( (array)$filelist as $filename => $filemeta )
247
-				$this->chmod($file . '/' . $filename, $mode, $recursive);
256
+			foreach ( (array)$filelist as $filename => $filemeta ) {
257
+							$this->chmod($file . '/' . $filename, $mode, $recursive);
258
+			}
248 259
 		}
249 260
 
250 261
 		// chmod the file or directory
@@ -294,12 +305,14 @@  discard block
 block discarded – undo
294 305
 	 * @return bool
295 306
 	 */
296 307
 	public function copy($source, $destination, $overwrite = false, $mode = false) {
297
-		if ( ! $overwrite && $this->exists($destination) )
298
-			return false;
308
+		if ( ! $overwrite && $this->exists($destination) ) {
309
+					return false;
310
+		}
299 311
 
300 312
 		$content = $this->get_contents($source);
301
-		if ( false === $content )
302
-			return false;
313
+		if ( false === $content ) {
314
+					return false;
315
+		}
303 316
 
304 317
 		return $this->put_contents($destination, $content, $mode);
305 318
 	}
@@ -325,12 +338,15 @@  discard block
 block discarded – undo
325 338
 	 * @return bool
326 339
 	 */
327 340
 	public function delete($file, $recursive = false, $type = false) {
328
-		if ( empty($file) )
329
-			return false;
330
-		if ( 'f' == $type || $this->is_file($file) )
331
-			return $this->ftp->delete($file);
332
-		if ( !$recursive )
333
-			return $this->ftp->rmdir($file);
341
+		if ( empty($file) ) {
342
+					return false;
343
+		}
344
+		if ( 'f' == $type || $this->is_file($file) ) {
345
+					return $this->ftp->delete($file);
346
+		}
347
+		if ( !$recursive ) {
348
+					return $this->ftp->rmdir($file);
349
+		}
334 350
 
335 351
 		return $this->ftp->mdel($file);
336 352
 	}
@@ -359,10 +375,12 @@  discard block
 block discarded – undo
359 375
 	 * @return bool
360 376
 	 */
361 377
 	public function is_file($file) {
362
-		if ( $this->is_dir($file) )
363
-			return false;
364
-		if ( $this->exists($file) )
365
-			return true;
378
+		if ( $this->is_dir($file) ) {
379
+					return false;
380
+		}
381
+		if ( $this->exists($file) ) {
382
+					return true;
383
+		}
366 384
 		return false;
367 385
 	}
368 386
 
@@ -452,13 +470,16 @@  discard block
 block discarded – undo
452 470
 	 */
453 471
 	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false ) {
454 472
 		$path = untrailingslashit($path);
455
-		if ( empty($path) )
456
-			return false;
473
+		if ( empty($path) ) {
474
+					return false;
475
+		}
457 476
 
458
-		if ( ! $this->ftp->mkdir($path) )
459
-			return false;
460
-		if ( ! $chmod )
461
-			$chmod = FS_CHMOD_DIR;
477
+		if ( ! $this->ftp->mkdir($path) ) {
478
+					return false;
479
+		}
480
+		if ( ! $chmod ) {
481
+					$chmod = FS_CHMOD_DIR;
482
+		}
462 483
 		$this->chmod($path, $chmod);
463 484
 		return true;
464 485
 	}
@@ -502,25 +523,30 @@  discard block
 block discarded – undo
502 523
 		$ret = array();
503 524
 		foreach ( $list as $struc ) {
504 525
 
505
-			if ( '.' == $struc['name'] || '..' == $struc['name'] )
506
-				continue;
526
+			if ( '.' == $struc['name'] || '..' == $struc['name'] ) {
527
+							continue;
528
+			}
507 529
 
508
-			if ( ! $include_hidden && '.' == $struc['name'][0] )
509
-				continue;
530
+			if ( ! $include_hidden && '.' == $struc['name'][0] ) {
531
+							continue;
532
+			}
510 533
 
511
-			if ( $limit_file && $struc['name'] != $limit_file )
512
-				continue;
534
+			if ( $limit_file && $struc['name'] != $limit_file ) {
535
+							continue;
536
+			}
513 537
 
514 538
 			if ( 'd' == $struc['type'] ) {
515
-				if ( $recursive )
516
-					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
517
-				else
518
-					$struc['files'] = array();
539
+				if ( $recursive ) {
540
+									$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
541
+				} else {
542
+									$struc['files'] = array();
543
+				}
519 544
 			}
520 545
 
521 546
 			// Replace symlinks formatted as "source -> target" with just the source name
522
-			if ( $struc['islink'] )
523
-				$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
547
+			if ( $struc['islink'] ) {
548
+							$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
549
+			}
524 550
 
525 551
 			// Add the Octal representation of the file permissions
526 552
 			$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
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.
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() && ( ! defined( 'DOING_AJAX' ) || ! 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 The search input id
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 $input_id ?>"><?php echo $text; ?>:</label>
363 370
 	<input type="search" id="<?php echo $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
 
@@ -456,8 +464,9 @@  discard block
 block discarded – undo
456 464
 			$two = '2';
457 465
 		}
458 466
 
459
-		if ( empty( $this->_actions ) )
460
-			return;
467
+		if ( empty( $this->_actions ) ) {
468
+					return;
469
+		}
461 470
 
462 471
 		echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
463 472
 		echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n";
@@ -484,14 +493,17 @@  discard block
 block discarded – undo
484 493
 	 * @return string|false The action name or False if no action was selected
485 494
 	 */
486 495
 	public function current_action() {
487
-		if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) )
488
-			return false;
496
+		if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) {
497
+					return false;
498
+		}
489 499
 
490
-		if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
491
-			return $_REQUEST['action'];
500
+		if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) {
501
+					return $_REQUEST['action'];
502
+		}
492 503
 
493
-		if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
494
-			return $_REQUEST['action2'];
504
+		if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) {
505
+					return $_REQUEST['action2'];
506
+		}
495 507
 
496 508
 		return false;
497 509
 	}
@@ -510,8 +522,9 @@  discard block
 block discarded – undo
510 522
 		$action_count = count( $actions );
511 523
 		$i = 0;
512 524
 
513
-		if ( !$action_count )
514
-			return '';
525
+		if ( !$action_count ) {
526
+					return '';
527
+		}
515 528
 
516 529
 		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
517 530
 		foreach ( $actions as $action => $link ) {
@@ -579,8 +592,9 @@  discard block
 block discarded – undo
579 592
 
580 593
 		$month_count = count( $months );
581 594
 
582
-		if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
583
-			return;
595
+		if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
596
+					return;
597
+		}
584 598
 
585 599
 		$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
586 600
 ?>
@@ -589,8 +603,9 @@  discard block
 block discarded – undo
589 603
 			<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
590 604
 <?php
591 605
 		foreach ( $months as $arc_row ) {
592
-			if ( 0 == $arc_row->year )
593
-				continue;
606
+			if ( 0 == $arc_row->year ) {
607
+							continue;
608
+			}
594 609
 
595 610
 			$month = zeroise( $arc_row->month, 2 );
596 611
 			$year = $arc_row->year;
@@ -622,8 +637,9 @@  discard block
 block discarded – undo
622 637
 <?php
623 638
 			foreach ( $this->modes as $mode => $title ) {
624 639
 				$classes = array( 'view-' . $mode );
625
-				if ( $current_mode === $mode )
626
-					$classes[] = 'current';
640
+				if ( $current_mode === $mode ) {
641
+									$classes[] = 'current';
642
+				}
627 643
 				printf(
628 644
 					"<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
629 645
 					esc_url( add_query_arg( 'mode', $mode ) ),
@@ -699,8 +715,9 @@  discard block
 block discarded – undo
699 715
 	public function get_pagenum() {
700 716
 		$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
701 717
 
702
-		if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
703
-			$pagenum = $this->_pagination_args['total_pages'];
718
+		if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) {
719
+					$pagenum = $this->_pagination_args['total_pages'];
720
+		}
704 721
 
705 722
 		return max( 1, $pagenum );
706 723
 	}
@@ -717,8 +734,9 @@  discard block
 block discarded – undo
717 734
 	 */
718 735
 	protected function get_items_per_page( $option, $default = 20 ) {
719 736
 		$per_page = (int) get_user_option( $option );
720
-		if ( empty( $per_page ) || $per_page < 1 )
721
-			$per_page = $default;
737
+		if ( empty( $per_page ) || $per_page < 1 ) {
738
+					$per_page = $default;
739
+		}
722 740
 
723 741
 		/**
724 742
 		 * Filter 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.
Spacing   +269 added lines, -269 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() && ( ! defined( 'DOING_AJAX' ) || ! 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() && ( ! defined('DOING_AJAX') || ! 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 search button text
344 344
 	 * @param string $input_id The search input id
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 362
 	<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
363 363
 	<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
364
-	<?php submit_button( $text, 'button', '', false, array('id' => 'search-submit') ); ?>
364
+	<?php submit_button($text, 'button', '', 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
 			$no_new_actions = $this->_actions = $this->get_bulk_actions();
440 440
 			/**
441 441
 			 * Filters the list table Bulk Actions drop-down.
@@ -449,29 +449,29 @@  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 );
453
-			$this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
452
+			$this->_actions = apply_filters("bulk_actions-{$this->screen->id}", $this->_actions);
453
+			$this->_actions = array_intersect_assoc($this->_actions, $no_new_actions);
454 454
 			$two = '';
455 455
 		} else {
456 456
 			$two = '2';
457 457
 		}
458 458
 
459
-		if ( empty( $this->_actions ) )
459
+		if (empty($this->_actions))
460 460
 			return;
461 461
 
462
-		echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
463
-		echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n";
464
-		echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>\n";
462
+		echo '<label for="bulk-action-selector-'.esc_attr($which).'" class="screen-reader-text">'.__('Select bulk action').'</label>';
463
+		echo '<select name="action'.$two.'" id="bulk-action-selector-'.esc_attr($which)."\">\n";
464
+		echo '<option value="-1">'.__('Bulk Actions')."</option>\n";
465 465
 
466
-		foreach ( $this->_actions as $name => $title ) {
466
+		foreach ($this->_actions as $name => $title) {
467 467
 			$class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
468 468
 
469
-			echo "\t" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>\n";
469
+			echo "\t".'<option value="'.$name.'"'.$class.'>'.$title."</option>\n";
470 470
 		}
471 471
 
472 472
 		echo "</select>\n";
473 473
 
474
-		submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
474
+		submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
475 475
 		echo "\n";
476 476
 	}
477 477
 
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
 	 * @return string|false The action name or False if no action was selected
485 485
 	 */
486 486
 	public function current_action() {
487
-		if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) )
487
+		if (isset($_REQUEST['filter_action']) && ! empty($_REQUEST['filter_action']))
488 488
 			return false;
489 489
 
490
-		if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
490
+		if (isset($_REQUEST['action']) && -1 != $_REQUEST['action'])
491 491
 			return $_REQUEST['action'];
492 492
 
493
-		if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
493
+		if (isset($_REQUEST['action2']) && -1 != $_REQUEST['action2'])
494 494
 			return $_REQUEST['action2'];
495 495
 
496 496
 		return false;
@@ -506,22 +506,22 @@  discard block
 block discarded – undo
506 506
 	 * @param bool $always_visible Whether the actions should be always visible
507 507
 	 * @return string
508 508
 	 */
509
-	protected function row_actions( $actions, $always_visible = false ) {
510
-		$action_count = count( $actions );
509
+	protected function row_actions($actions, $always_visible = false) {
510
+		$action_count = count($actions);
511 511
 		$i = 0;
512 512
 
513
-		if ( !$action_count )
513
+		if ( ! $action_count)
514 514
 			return '';
515 515
 
516
-		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
517
-		foreach ( $actions as $action => $link ) {
516
+		$out = '<div class="'.($always_visible ? 'row-actions visible' : 'row-actions').'">';
517
+		foreach ($actions as $action => $link) {
518 518
 			++$i;
519
-			( $i == $action_count ) ? $sep = '' : $sep = ' | ';
519
+			($i == $action_count) ? $sep = '' : $sep = ' | ';
520 520
 			$out .= "<span class='$action'>$link$sep</span>";
521 521
 		}
522 522
 		$out .= '</div>';
523 523
 
524
-		$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>';
524
+		$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">'.__('Show more details').'</span></button>';
525 525
 
526 526
 		return $out;
527 527
 	}
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	 *
538 538
 	 * @param string $post_type
539 539
 	 */
540
-	protected function months_dropdown( $post_type ) {
540
+	protected function months_dropdown($post_type) {
541 541
 		global $wpdb, $wp_locale;
542 542
 
543 543
 		/**
@@ -548,24 +548,24 @@  discard block
 block discarded – undo
548 548
 		 * @param bool   $disable   Whether to disable the drop-down. Default false.
549 549
 		 * @param string $post_type The post type.
550 550
 		 */
551
-		if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) {
551
+		if (apply_filters('disable_months_dropdown', false, $post_type)) {
552 552
 			return;
553 553
 		}
554 554
 
555 555
 		$extra_checks = "AND post_status != 'auto-draft'";
556
-		if ( ! isset( $_GET['post_status'] ) || 'trash' !== $_GET['post_status'] ) {
556
+		if ( ! isset($_GET['post_status']) || 'trash' !== $_GET['post_status']) {
557 557
 			$extra_checks .= " AND post_status != 'trash'";
558
-		} elseif ( isset( $_GET['post_status'] ) ) {
559
-			$extra_checks = $wpdb->prepare( ' AND post_status = %s', $_GET['post_status'] );
558
+		} elseif (isset($_GET['post_status'])) {
559
+			$extra_checks = $wpdb->prepare(' AND post_status = %s', $_GET['post_status']);
560 560
 		}
561 561
 
562
-		$months = $wpdb->get_results( $wpdb->prepare( "
562
+		$months = $wpdb->get_results($wpdb->prepare("
563 563
 			SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
564 564
 			FROM $wpdb->posts
565 565
 			WHERE post_type = %s
566 566
 			$extra_checks
567 567
 			ORDER BY post_date DESC
568
-		", $post_type ) );
568
+		", $post_type));
569 569
 
570 570
 		/**
571 571
 		 * Filters the 'Months' drop-down results.
@@ -575,31 +575,31 @@  discard block
 block discarded – undo
575 575
 		 * @param object $months    The months drop-down query results.
576 576
 		 * @param string $post_type The post type.
577 577
 		 */
578
-		$months = apply_filters( 'months_dropdown_results', $months, $post_type );
578
+		$months = apply_filters('months_dropdown_results', $months, $post_type);
579 579
 
580
-		$month_count = count( $months );
580
+		$month_count = count($months);
581 581
 
582
-		if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
582
+		if ( ! $month_count || (1 == $month_count && 0 == $months[0]->month))
583 583
 			return;
584 584
 
585
-		$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
585
+		$m = isset($_GET['m']) ? (int) $_GET['m'] : 0;
586 586
 ?>
587
-		<label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date' ); ?></label>
587
+		<label for="filter-by-date" class="screen-reader-text"><?php _e('Filter by date'); ?></label>
588 588
 		<select name="m" id="filter-by-date">
589
-			<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
589
+			<option<?php selected($m, 0); ?> value="0"><?php _e('All dates'); ?></option>
590 590
 <?php
591
-		foreach ( $months as $arc_row ) {
592
-			if ( 0 == $arc_row->year )
591
+		foreach ($months as $arc_row) {
592
+			if (0 == $arc_row->year)
593 593
 				continue;
594 594
 
595
-			$month = zeroise( $arc_row->month, 2 );
595
+			$month = zeroise($arc_row->month, 2);
596 596
 			$year = $arc_row->year;
597 597
 
598
-			printf( "<option %s value='%s'>%s</option>\n",
599
-				selected( $m, $year . $month, false ),
600
-				esc_attr( $arc_row->year . $month ),
598
+			printf("<option %s value='%s'>%s</option>\n",
599
+				selected($m, $year.$month, false),
600
+				esc_attr($arc_row->year.$month),
601 601
 				/* translators: 1: month name, 2: 4-digit year */
602
-				sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
602
+				sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year)
603 603
 			);
604 604
 		}
605 605
 ?>
@@ -615,19 +615,19 @@  discard block
 block discarded – undo
615 615
 	 *
616 616
 	 * @param string $current_mode
617 617
 	 */
618
-	protected function view_switcher( $current_mode ) {
618
+	protected function view_switcher($current_mode) {
619 619
 ?>
620
-		<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
620
+		<input type="hidden" name="mode" value="<?php echo esc_attr($current_mode); ?>" />
621 621
 		<div class="view-switch">
622 622
 <?php
623
-			foreach ( $this->modes as $mode => $title ) {
624
-				$classes = array( 'view-' . $mode );
625
-				if ( $current_mode === $mode )
623
+			foreach ($this->modes as $mode => $title) {
624
+				$classes = array('view-'.$mode);
625
+				if ($current_mode === $mode)
626 626
 					$classes[] = 'current';
627 627
 				printf(
628 628
 					"<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
629
-					esc_url( add_query_arg( 'mode', $mode ) ),
630
-					implode( ' ', $classes ),
629
+					esc_url(add_query_arg('mode', $mode)),
630
+					implode(' ', $classes),
631 631
 					$title
632 632
 				);
633 633
 			}
@@ -645,45 +645,45 @@  discard block
 block discarded – undo
645 645
 	 * @param int $post_id          The post ID.
646 646
 	 * @param int $pending_comments Number of pending comments.
647 647
 	 */
648
-	protected function comments_bubble( $post_id, $pending_comments ) {
648
+	protected function comments_bubble($post_id, $pending_comments) {
649 649
 		$approved_comments = get_comments_number();
650 650
 
651
-		$approved_comments_number = number_format_i18n( $approved_comments );
652
-		$pending_comments_number = number_format_i18n( $pending_comments );
651
+		$approved_comments_number = number_format_i18n($approved_comments);
652
+		$pending_comments_number = number_format_i18n($pending_comments);
653 653
 
654
-		$approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number );
655
-		$approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number );
656
-		$pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number );
654
+		$approved_only_phrase = sprintf(_n('%s comment', '%s comments', $approved_comments), $approved_comments_number);
655
+		$approved_phrase = sprintf(_n('%s approved comment', '%s approved comments', $approved_comments), $approved_comments_number);
656
+		$pending_phrase = sprintf(_n('%s pending comment', '%s pending comments', $pending_comments), $pending_comments_number);
657 657
 
658 658
 		// No comments at all.
659
-		if ( ! $approved_comments && ! $pending_comments ) {
660
-			printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
661
-				__( 'No comments' )
659
+		if ( ! $approved_comments && ! $pending_comments) {
660
+			printf('<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
661
+				__('No comments')
662 662
 			);
663 663
 		// Approved comments have different display depending on some conditions.
664
-		} elseif ( $approved_comments ) {
665
-			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>',
666
-				esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'approved' ), admin_url( 'edit-comments.php' ) ) ),
664
+		} elseif ($approved_comments) {
665
+			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>',
666
+				esc_url(add_query_arg(array('p' => $post_id, 'comment_status' => 'approved'), admin_url('edit-comments.php'))),
667 667
 				$approved_comments_number,
668 668
 				$pending_comments ? $approved_phrase : $approved_only_phrase
669 669
 			);
670 670
 		} else {
671
-			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
+			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>',
672 672
 				$approved_comments_number,
673
-				$pending_comments ? __( 'No approved comments' ) : __( 'No comments' )
673
+				$pending_comments ? __('No approved comments') : __('No comments')
674 674
 			);
675 675
 		}
676 676
 
677
-		if ( $pending_comments ) {
678
-			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>',
679
-				esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'moderated' ), admin_url( 'edit-comments.php' ) ) ),
677
+		if ($pending_comments) {
678
+			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>',
679
+				esc_url(add_query_arg(array('p' => $post_id, 'comment_status' => 'moderated'), admin_url('edit-comments.php'))),
680 680
 				$pending_comments_number,
681 681
 				$pending_phrase
682 682
 			);
683 683
 		} else {
684
-			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
+			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>',
685 685
 				$pending_comments_number,
686
-				$approved_comments ? __( 'No pending comments' ) : __( 'No comments' )
686
+				$approved_comments ? __('No pending comments') : __('No comments')
687 687
 			);
688 688
 		}
689 689
 	}
@@ -697,12 +697,12 @@  discard block
 block discarded – undo
697 697
 	 * @return int
698 698
 	 */
699 699
 	public function get_pagenum() {
700
-		$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
700
+		$pagenum = isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 0;
701 701
 
702
-		if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
702
+		if (isset($this->_pagination_args['total_pages']) && $pagenum > $this->_pagination_args['total_pages'])
703 703
 			$pagenum = $this->_pagination_args['total_pages'];
704 704
 
705
-		return max( 1, $pagenum );
705
+		return max(1, $pagenum);
706 706
 	}
707 707
 
708 708
 	/**
@@ -715,9 +715,9 @@  discard block
 block discarded – undo
715 715
 	 * @param int    $default
716 716
 	 * @return int
717 717
 	 */
718
-	protected function get_items_per_page( $option, $default = 20 ) {
719
-		$per_page = (int) get_user_option( $option );
720
-		if ( empty( $per_page ) || $per_page < 1 )
718
+	protected function get_items_per_page($option, $default = 20) {
719
+		$per_page = (int) get_user_option($option);
720
+		if (empty($per_page) || $per_page < 1)
721 721
 			$per_page = $default;
722 722
 
723 723
 		/**
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 		 *
734 734
 		 * @param int $per_page Number of items to be displayed. Default 20.
735 735
 		 */
736
-		return (int) apply_filters( $option, $per_page );
736
+		return (int) apply_filters($option, $per_page);
737 737
 	}
738 738
 
739 739
 	/**
@@ -744,30 +744,30 @@  discard block
 block discarded – undo
744 744
 	 *
745 745
 	 * @param string $which
746 746
 	 */
747
-	protected function pagination( $which ) {
748
-		if ( empty( $this->_pagination_args ) ) {
747
+	protected function pagination($which) {
748
+		if (empty($this->_pagination_args)) {
749 749
 			return;
750 750
 		}
751 751
 
752 752
 		$total_items = $this->_pagination_args['total_items'];
753 753
 		$total_pages = $this->_pagination_args['total_pages'];
754 754
 		$infinite_scroll = false;
755
-		if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
755
+		if (isset($this->_pagination_args['infinite_scroll'])) {
756 756
 			$infinite_scroll = $this->_pagination_args['infinite_scroll'];
757 757
 		}
758 758
 
759
-		if ( 'top' === $which && $total_pages > 1 ) {
760
-			$this->screen->render_screen_reader_content( 'heading_pagination' );
759
+		if ('top' === $which && $total_pages > 1) {
760
+			$this->screen->render_screen_reader_content('heading_pagination');
761 761
 		}
762 762
 
763
-		$output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
763
+		$output = '<span class="displaying-num">'.sprintf(_n('%s item', '%s items', $total_items), number_format_i18n($total_items)).'</span>';
764 764
 
765 765
 		$current = $this->get_pagenum();
766 766
 		$removable_query_args = wp_removable_query_args();
767 767
 
768
-		$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
768
+		$current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
769 769
 
770
-		$current_url = remove_query_arg( $removable_query_args, $current_url );
770
+		$current_url = remove_query_arg($removable_query_args, $current_url);
771 771
 
772 772
 		$page_links = array();
773 773
 
@@ -776,81 +776,81 @@  discard block
 block discarded – undo
776 776
 
777 777
 		$disable_first = $disable_last = $disable_prev = $disable_next = false;
778 778
 
779
- 		if ( $current == 1 ) {
779
+ 		if ($current == 1) {
780 780
 			$disable_first = true;
781 781
 			$disable_prev = true;
782 782
  		}
783
-		if ( $current == 2 ) {
783
+		if ($current == 2) {
784 784
 			$disable_first = true;
785 785
 		}
786
- 		if ( $current == $total_pages ) {
786
+ 		if ($current == $total_pages) {
787 787
 			$disable_last = true;
788 788
 			$disable_next = true;
789 789
  		}
790
-		if ( $current == $total_pages - 1 ) {
790
+		if ($current == $total_pages - 1) {
791 791
 			$disable_last = true;
792 792
 		}
793 793
 
794
-		if ( $disable_first ) {
794
+		if ($disable_first) {
795 795
 			$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&laquo;</span>';
796 796
 		} else {
797
-			$page_links[] = sprintf( "<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
798
-				esc_url( remove_query_arg( 'paged', $current_url ) ),
799
-				__( 'First page' ),
797
+			$page_links[] = sprintf("<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
798
+				esc_url(remove_query_arg('paged', $current_url)),
799
+				__('First page'),
800 800
 				'&laquo;'
801 801
 			);
802 802
 		}
803 803
 
804
-		if ( $disable_prev ) {
804
+		if ($disable_prev) {
805 805
 			$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&lsaquo;</span>';
806 806
 		} else {
807
-			$page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
808
-				esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
809
-				__( 'Previous page' ),
807
+			$page_links[] = sprintf("<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
808
+				esc_url(add_query_arg('paged', max(1, $current - 1), $current_url)),
809
+				__('Previous page'),
810 810
 				'&lsaquo;'
811 811
 			);
812 812
 		}
813 813
 
814
-		if ( 'bottom' === $which ) {
814
+		if ('bottom' === $which) {
815 815
 			$html_current_page  = $current;
816
-			$total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input">';
816
+			$total_pages_before = '<span class="screen-reader-text">'.__('Current Page').'</span><span id="table-paging" class="paging-input">';
817 817
 		} else {
818
-			$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' />",
819
-				'<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
818
+			$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' />",
819
+				'<label for="current-page-selector" class="screen-reader-text">'.__('Current Page').'</label>',
820 820
 				$current,
821
-				strlen( $total_pages )
821
+				strlen($total_pages)
822 822
 			);
823 823
 		}
824
-		$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
825
-		$page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;
824
+		$html_total_pages = sprintf("<span class='total-pages'>%s</span>", number_format_i18n($total_pages));
825
+		$page_links[] = $total_pages_before.sprintf(_x('%1$s of %2$s', 'paging'), $html_current_page, $html_total_pages).$total_pages_after;
826 826
 
827
-		if ( $disable_next ) {
827
+		if ($disable_next) {
828 828
 			$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&rsaquo;</span>';
829 829
 		} else {
830
-			$page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
831
-				esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
832
-				__( 'Next page' ),
830
+			$page_links[] = sprintf("<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
831
+				esc_url(add_query_arg('paged', min($total_pages, $current + 1), $current_url)),
832
+				__('Next page'),
833 833
 				'&rsaquo;'
834 834
 			);
835 835
 		}
836 836
 
837
-		if ( $disable_last ) {
837
+		if ($disable_last) {
838 838
 			$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&raquo;</span>';
839 839
 		} else {
840
-			$page_links[] = sprintf( "<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
841
-				esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
842
-				__( 'Last page' ),
840
+			$page_links[] = sprintf("<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
841
+				esc_url(add_query_arg('paged', $total_pages, $current_url)),
842
+				__('Last page'),
843 843
 				'&raquo;'
844 844
 			);
845 845
 		}
846 846
 
847 847
 		$pagination_links_class = 'pagination-links';
848
-		if ( ! empty( $infinite_scroll ) ) {
848
+		if ( ! empty($infinite_scroll)) {
849 849
 			$pagination_links_class = ' hide-if-js';
850 850
 		}
851
-		$output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
851
+		$output .= "\n<span class='$pagination_links_class'>".join("\n", $page_links).'</span>';
852 852
 
853
-		if ( $total_pages ) {
853
+		if ($total_pages) {
854 854
 			$page_class = $total_pages < 2 ? ' one-page' : '';
855 855
 		} else {
856 856
 			$page_class = ' no-pages';
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 	 * @return array
872 872
 	 */
873 873
 	public function get_columns() {
874
-		die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' );
874
+		die('function WP_List_Table::get_columns() must be over-ridden in a sub-class.');
875 875
 	}
876 876
 
877 877
 	/**
@@ -903,14 +903,14 @@  discard block
 block discarded – undo
903 903
 		$columns = $this->get_columns();
904 904
 		$column = '';
905 905
 
906
-		if ( empty( $columns ) ) {
906
+		if (empty($columns)) {
907 907
 			return $column;
908 908
 		}
909 909
 
910 910
 		// We need a primary defined so responsive views show something,
911 911
 		// so let's fall back to the first non-checkbox column.
912
-		foreach ( $columns as $col => $column_name ) {
913
-			if ( 'cb' === $col ) {
912
+		foreach ($columns as $col => $column_name) {
913
+			if ('cb' === $col) {
914 914
 				continue;
915 915
 			}
916 916
 
@@ -942,12 +942,12 @@  discard block
 block discarded – undo
942 942
 	 * @return string The name of the primary column.
943 943
 	 */
944 944
 	protected function get_primary_column_name() {
945
-		$columns = get_column_headers( $this->screen );
945
+		$columns = get_column_headers($this->screen);
946 946
 		$default = $this->get_default_primary_column_name();
947 947
 
948 948
 		// If the primary column doesn't exist fall back to the
949 949
 		// first non-checkbox column.
950
-		if ( ! isset( $columns[ $default ] ) ) {
950
+		if ( ! isset($columns[$default])) {
951 951
 			$default = WP_List_Table::get_default_primary_column_name();
952 952
 		}
953 953
 
@@ -959,9 +959,9 @@  discard block
 block discarded – undo
959 959
 		 * @param string $default Column name default for the specific list table, e.g. 'name'.
960 960
 		 * @param string $context Screen ID for specific list table, e.g. 'plugins'.
961 961
 		 */
962
-		$column  = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
962
+		$column  = apply_filters('list_table_primary_column', $default, $this->screen->id);
963 963
 
964
-		if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
964
+		if (empty($column) || ! isset($columns[$column])) {
965 965
 			$column = $default;
966 966
 		}
967 967
 
@@ -978,19 +978,19 @@  discard block
 block discarded – undo
978 978
 	 */
979 979
 	protected function get_column_info() {
980 980
 		// $_column_headers is already set / cached
981
-		if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) {
981
+		if (isset($this->_column_headers) && is_array($this->_column_headers)) {
982 982
 			// Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
983 983
 			// In 4.3, we added a fourth argument for primary column.
984
-			$column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
985
-			foreach ( $this->_column_headers as $key => $value ) {
986
-				$column_headers[ $key ] = $value;
984
+			$column_headers = array(array(), array(), array(), $this->get_primary_column_name());
985
+			foreach ($this->_column_headers as $key => $value) {
986
+				$column_headers[$key] = $value;
987 987
 			}
988 988
 
989 989
 			return $column_headers;
990 990
 		}
991 991
 
992
-		$columns = get_column_headers( $this->screen );
993
-		$hidden = get_hidden_columns( $this->screen );
992
+		$columns = get_column_headers($this->screen);
993
+		$hidden = get_hidden_columns($this->screen);
994 994
 
995 995
 		$sortable_columns = $this->get_sortable_columns();
996 996
 		/**
@@ -1003,22 +1003,22 @@  discard block
 block discarded – undo
1003 1003
 		 *
1004 1004
 		 * @param array $sortable_columns An array of sortable columns.
1005 1005
 		 */
1006
-		$_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
1006
+		$_sortable = apply_filters("manage_{$this->screen->id}_sortable_columns", $sortable_columns);
1007 1007
 
1008 1008
 		$sortable = array();
1009
-		foreach ( $_sortable as $id => $data ) {
1010
-			if ( empty( $data ) )
1009
+		foreach ($_sortable as $id => $data) {
1010
+			if (empty($data))
1011 1011
 				continue;
1012 1012
 
1013 1013
 			$data = (array) $data;
1014
-			if ( !isset( $data[1] ) )
1014
+			if ( ! isset($data[1]))
1015 1015
 				$data[1] = false;
1016 1016
 
1017 1017
 			$sortable[$id] = $data;
1018 1018
 		}
1019 1019
 
1020 1020
 		$primary = $this->get_primary_column_name();
1021
-		$this->_column_headers = array( $columns, $hidden, $sortable, $primary );
1021
+		$this->_column_headers = array($columns, $hidden, $sortable, $primary);
1022 1022
 
1023 1023
 		return $this->_column_headers;
1024 1024
 	}
@@ -1032,9 +1032,9 @@  discard block
 block discarded – undo
1032 1032
 	 * @return int
1033 1033
 	 */
1034 1034
 	public function get_column_count() {
1035
-		list ( $columns, $hidden ) = $this->get_column_info();
1036
-		$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
1037
-		return count( $columns ) - count( $hidden );
1035
+		list ($columns, $hidden) = $this->get_column_info();
1036
+		$hidden = array_intersect(array_keys($columns), array_filter($hidden));
1037
+		return count($columns) - count($hidden);
1038 1038
 	}
1039 1039
 
1040 1040
 	/**
@@ -1047,51 +1047,51 @@  discard block
 block discarded – undo
1047 1047
 	 *
1048 1048
 	 * @param bool $with_id Whether to set the id attribute or not
1049 1049
 	 */
1050
-	public function print_column_headers( $with_id = true ) {
1051
-		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
1050
+	public function print_column_headers($with_id = true) {
1051
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
1052 1052
 
1053
-		$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
1054
-		$current_url = remove_query_arg( 'paged', $current_url );
1053
+		$current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
1054
+		$current_url = remove_query_arg('paged', $current_url);
1055 1055
 
1056
-		if ( isset( $_GET['orderby'] ) ) {
1056
+		if (isset($_GET['orderby'])) {
1057 1057
 			$current_orderby = $_GET['orderby'];
1058 1058
 		} else {
1059 1059
 			$current_orderby = '';
1060 1060
 		}
1061 1061
 
1062
-		if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) {
1062
+		if (isset($_GET['order']) && 'desc' === $_GET['order']) {
1063 1063
 			$current_order = 'desc';
1064 1064
 		} else {
1065 1065
 			$current_order = 'asc';
1066 1066
 		}
1067 1067
 
1068
-		if ( ! empty( $columns['cb'] ) ) {
1068
+		if ( ! empty($columns['cb'])) {
1069 1069
 			static $cb_counter = 1;
1070
-			$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
1071
-				. '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
1070
+			$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-'.$cb_counter.'">'.__('Select All').'</label>'
1071
+				. '<input id="cb-select-all-'.$cb_counter.'" type="checkbox" />';
1072 1072
 			$cb_counter++;
1073 1073
 		}
1074 1074
 
1075
-		foreach ( $columns as $column_key => $column_display_name ) {
1076
-			$class = array( 'manage-column', "column-$column_key" );
1075
+		foreach ($columns as $column_key => $column_display_name) {
1076
+			$class = array('manage-column', "column-$column_key");
1077 1077
 
1078
-			if ( in_array( $column_key, $hidden ) ) {
1078
+			if (in_array($column_key, $hidden)) {
1079 1079
 				$class[] = 'hidden';
1080 1080
 			}
1081 1081
 
1082
-			if ( 'cb' === $column_key )
1082
+			if ('cb' === $column_key)
1083 1083
 				$class[] = 'check-column';
1084
-			elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) )
1084
+			elseif (in_array($column_key, array('posts', 'comments', 'links')))
1085 1085
 				$class[] = 'num';
1086 1086
 
1087
-			if ( $column_key === $primary ) {
1087
+			if ($column_key === $primary) {
1088 1088
 				$class[] = 'column-primary';
1089 1089
 			}
1090 1090
 
1091
-			if ( isset( $sortable[$column_key] ) ) {
1092
-				list( $orderby, $desc_first ) = $sortable[$column_key];
1091
+			if (isset($sortable[$column_key])) {
1092
+				list($orderby, $desc_first) = $sortable[$column_key];
1093 1093
 
1094
-				if ( $current_orderby === $orderby ) {
1094
+				if ($current_orderby === $orderby) {
1095 1095
 					$order = 'asc' === $current_order ? 'desc' : 'asc';
1096 1096
 					$class[] = 'sorted';
1097 1097
 					$class[] = $current_order;
@@ -1101,15 +1101,15 @@  discard block
 block discarded – undo
1101 1101
 					$class[] = $desc_first ? 'asc' : 'desc';
1102 1102
 				}
1103 1103
 
1104
-				$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
+				$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>';
1105 1105
 			}
1106 1106
 
1107
-			$tag = ( 'cb' === $column_key ) ? 'td' : 'th';
1108
-			$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
1107
+			$tag = ('cb' === $column_key) ? 'td' : 'th';
1108
+			$scope = ('th' === $tag) ? 'scope="col"' : '';
1109 1109
 			$id = $with_id ? "id='$column_key'" : '';
1110 1110
 
1111
-			if ( !empty( $class ) )
1112
-				$class = "class='" . join( ' ', $class ) . "'";
1111
+			if ( ! empty($class))
1112
+				$class = "class='".join(' ', $class)."'";
1113 1113
 
1114 1114
 			echo "<$tag $scope $id $class>$column_display_name</$tag>";
1115 1115
 		}
@@ -1124,11 +1124,11 @@  discard block
 block discarded – undo
1124 1124
 	public function display() {
1125 1125
 		$singular = $this->_args['singular'];
1126 1126
 
1127
-		$this->display_tablenav( 'top' );
1127
+		$this->display_tablenav('top');
1128 1128
 
1129
-		$this->screen->render_screen_reader_content( 'heading_list' );
1129
+		$this->screen->render_screen_reader_content('heading_list');
1130 1130
 ?>
1131
-<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
1131
+<table class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>">
1132 1132
 	<thead>
1133 1133
 	<tr>
1134 1134
 		<?php $this->print_column_headers(); ?>
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 	</thead>
1137 1137
 
1138 1138
 	<tbody id="the-list"<?php
1139
-		if ( $singular ) {
1139
+		if ($singular) {
1140 1140
 			echo " data-wp-lists='list:$singular'";
1141 1141
 		} ?>>
1142 1142
 		<?php $this->display_rows_or_placeholder(); ?>
@@ -1144,13 +1144,13 @@  discard block
 block discarded – undo
1144 1144
 
1145 1145
 	<tfoot>
1146 1146
 	<tr>
1147
-		<?php $this->print_column_headers( false ); ?>
1147
+		<?php $this->print_column_headers(false); ?>
1148 1148
 	</tr>
1149 1149
 	</tfoot>
1150 1150
 
1151 1151
 </table>
1152 1152
 <?php
1153
-		$this->display_tablenav( 'bottom' );
1153
+		$this->display_tablenav('bottom');
1154 1154
 	}
1155 1155
 
1156 1156
 	/**
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
 	 * @return array List of CSS classes for the table tag.
1163 1163
 	 */
1164 1164
 	protected function get_table_classes() {
1165
-		return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] );
1165
+		return array('widefat', 'fixed', 'striped', $this->_args['plural']);
1166 1166
 	}
1167 1167
 
1168 1168
 	/**
@@ -1172,20 +1172,20 @@  discard block
 block discarded – undo
1172 1172
 	 * @access protected
1173 1173
 	 * @param string $which
1174 1174
 	 */
1175
-	protected function display_tablenav( $which ) {
1176
-		if ( 'top' === $which ) {
1177
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
1175
+	protected function display_tablenav($which) {
1176
+		if ('top' === $which) {
1177
+			wp_nonce_field('bulk-'.$this->_args['plural']);
1178 1178
 		}
1179 1179
 		?>
1180
-	<div class="tablenav <?php echo esc_attr( $which ); ?>">
1180
+	<div class="tablenav <?php echo esc_attr($which); ?>">
1181 1181
 
1182
-		<?php if ( $this->has_items() ): ?>
1182
+		<?php if ($this->has_items()): ?>
1183 1183
 		<div class="alignleft actions bulkactions">
1184
-			<?php $this->bulk_actions( $which ); ?>
1184
+			<?php $this->bulk_actions($which); ?>
1185 1185
 		</div>
1186 1186
 		<?php endif;
1187
-		$this->extra_tablenav( $which );
1188
-		$this->pagination( $which );
1187
+		$this->extra_tablenav($which);
1188
+		$this->pagination($which);
1189 1189
 ?>
1190 1190
 
1191 1191
 		<br class="clear" />
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 	 *
1202 1202
 	 * @param string $which
1203 1203
 	 */
1204
-	protected function extra_tablenav( $which ) {}
1204
+	protected function extra_tablenav($which) {}
1205 1205
 
1206 1206
 	/**
1207 1207
 	 * Generate the tbody element for the list table.
@@ -1210,10 +1210,10 @@  discard block
 block discarded – undo
1210 1210
 	 * @access public
1211 1211
 	 */
1212 1212
 	public function display_rows_or_placeholder() {
1213
-		if ( $this->has_items() ) {
1213
+		if ($this->has_items()) {
1214 1214
 			$this->display_rows();
1215 1215
 		} else {
1216
-			echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
1216
+			echo '<tr class="no-items"><td class="colspanchange" colspan="'.$this->get_column_count().'">';
1217 1217
 			$this->no_items();
1218 1218
 			echo '</td></tr>';
1219 1219
 		}
@@ -1226,8 +1226,8 @@  discard block
 block discarded – undo
1226 1226
 	 * @access public
1227 1227
 	 */
1228 1228
 	public function display_rows() {
1229
-		foreach ( $this->items as $item )
1230
-			$this->single_row( $item );
1229
+		foreach ($this->items as $item)
1230
+			$this->single_row($item);
1231 1231
 	}
1232 1232
 
1233 1233
 	/**
@@ -1238,9 +1238,9 @@  discard block
 block discarded – undo
1238 1238
 	 *
1239 1239
 	 * @param object $item The current item
1240 1240
 	 */
1241
-	public function single_row( $item ) {
1241
+	public function single_row($item) {
1242 1242
 		echo '<tr>';
1243
-		$this->single_row_columns( $item );
1243
+		$this->single_row_columns($item);
1244 1244
 		echo '</tr>';
1245 1245
 	}
1246 1246
 
@@ -1249,13 +1249,13 @@  discard block
 block discarded – undo
1249 1249
 	 * @param object $item
1250 1250
 	 * @param string $column_name
1251 1251
 	 */
1252
-	protected function column_default( $item, $column_name ) {}
1252
+	protected function column_default($item, $column_name) {}
1253 1253
 
1254 1254
 	/**
1255 1255
 	 *
1256 1256
 	 * @param object $item
1257 1257
 	 */
1258
-	protected function column_cb( $item ) {}
1258
+	protected function column_cb($item) {}
1259 1259
 
1260 1260
 	/**
1261 1261
 	 * Generates the columns for a single row of the table
@@ -1265,46 +1265,46 @@  discard block
 block discarded – undo
1265 1265
 	 *
1266 1266
 	 * @param object $item The current item
1267 1267
 	 */
1268
-	protected function single_row_columns( $item ) {
1269
-		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
1268
+	protected function single_row_columns($item) {
1269
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
1270 1270
 
1271
-		foreach ( $columns as $column_name => $column_display_name ) {
1271
+		foreach ($columns as $column_name => $column_display_name) {
1272 1272
 			$classes = "$column_name column-$column_name";
1273
-			if ( $primary === $column_name ) {
1273
+			if ($primary === $column_name) {
1274 1274
 				$classes .= ' has-row-actions column-primary';
1275 1275
 			}
1276 1276
 
1277
-			if ( in_array( $column_name, $hidden ) ) {
1277
+			if (in_array($column_name, $hidden)) {
1278 1278
 				$classes .= ' hidden';
1279 1279
 			}
1280 1280
 
1281 1281
 			// Comments column uses HTML in the display name with screen reader text.
1282 1282
 			// Instead of using esc_attr(), we strip tags to get closer to a user-friendly string.
1283
-			$data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"';
1283
+			$data = 'data-colname="'.wp_strip_all_tags($column_display_name).'"';
1284 1284
 
1285 1285
 			$attributes = "class='$classes' $data";
1286 1286
 
1287
-			if ( 'cb' === $column_name ) {
1287
+			if ('cb' === $column_name) {
1288 1288
 				echo '<th scope="row" class="check-column">';
1289
-				echo $this->column_cb( $item );
1289
+				echo $this->column_cb($item);
1290 1290
 				echo '</th>';
1291
-			} elseif ( method_exists( $this, '_column_' . $column_name ) ) {
1291
+			} elseif (method_exists($this, '_column_'.$column_name)) {
1292 1292
 				echo call_user_func(
1293
-					array( $this, '_column_' . $column_name ),
1293
+					array($this, '_column_'.$column_name),
1294 1294
 					$item,
1295 1295
 					$classes,
1296 1296
 					$data,
1297 1297
 					$primary
1298 1298
 				);
1299
-			} elseif ( method_exists( $this, 'column_' . $column_name ) ) {
1299
+			} elseif (method_exists($this, 'column_'.$column_name)) {
1300 1300
 				echo "<td $attributes>";
1301
-				echo call_user_func( array( $this, 'column_' . $column_name ), $item );
1302
-				echo $this->handle_row_actions( $item, $column_name, $primary );
1301
+				echo call_user_func(array($this, 'column_'.$column_name), $item);
1302
+				echo $this->handle_row_actions($item, $column_name, $primary);
1303 1303
 				echo "</td>";
1304 1304
 			} else {
1305 1305
 				echo "<td $attributes>";
1306
-				echo $this->column_default( $item, $column_name );
1307
-				echo $this->handle_row_actions( $item, $column_name, $primary );
1306
+				echo $this->column_default($item, $column_name);
1307
+				echo $this->handle_row_actions($item, $column_name, $primary);
1308 1308
 				echo "</td>";
1309 1309
 			}
1310 1310
 		}
@@ -1321,8 +1321,8 @@  discard block
 block discarded – undo
1321 1321
 	 * @param string $primary     Primary column name.
1322 1322
 	 * @return string The row actions HTML, or an empty string if the current column is the primary column.
1323 1323
 	 */
1324
-	protected function handle_row_actions( $item, $column_name, $primary ) {
1325
-		return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>' : '';
1324
+	protected function handle_row_actions($item, $column_name, $primary) {
1325
+		return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">'.__('Show more details').'</span></button>' : '';
1326 1326
  	}
1327 1327
 
1328 1328
 	/**
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
 		$this->prepare_items();
1336 1336
 
1337 1337
 		ob_start();
1338
-		if ( ! empty( $_REQUEST['no_placeholder'] ) ) {
1338
+		if ( ! empty($_REQUEST['no_placeholder'])) {
1339 1339
 			$this->display_rows();
1340 1340
 		} else {
1341 1341
 			$this->display_rows_or_placeholder();
@@ -1343,20 +1343,20 @@  discard block
 block discarded – undo
1343 1343
 
1344 1344
 		$rows = ob_get_clean();
1345 1345
 
1346
-		$response = array( 'rows' => $rows );
1346
+		$response = array('rows' => $rows);
1347 1347
 
1348
-		if ( isset( $this->_pagination_args['total_items'] ) ) {
1348
+		if (isset($this->_pagination_args['total_items'])) {
1349 1349
 			$response['total_items_i18n'] = sprintf(
1350
-				_n( '%s item', '%s items', $this->_pagination_args['total_items'] ),
1351
-				number_format_i18n( $this->_pagination_args['total_items'] )
1350
+				_n('%s item', '%s items', $this->_pagination_args['total_items']),
1351
+				number_format_i18n($this->_pagination_args['total_items'])
1352 1352
 			);
1353 1353
 		}
1354
-		if ( isset( $this->_pagination_args['total_pages'] ) ) {
1354
+		if (isset($this->_pagination_args['total_pages'])) {
1355 1355
 			$response['total_pages'] = $this->_pagination_args['total_pages'];
1356
-			$response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
1356
+			$response['total_pages_i18n'] = number_format_i18n($this->_pagination_args['total_pages']);
1357 1357
 		}
1358 1358
 
1359
-		die( wp_json_encode( $response ) );
1359
+		die(wp_json_encode($response));
1360 1360
 	}
1361 1361
 
1362 1362
 	/**
@@ -1366,13 +1366,13 @@  discard block
 block discarded – undo
1366 1366
 	 */
1367 1367
 	public function _js_vars() {
1368 1368
 		$args = array(
1369
-			'class'  => get_class( $this ),
1369
+			'class'  => get_class($this),
1370 1370
 			'screen' => array(
1371 1371
 				'id'   => $this->screen->id,
1372 1372
 				'base' => $this->screen->base,
1373 1373
 			)
1374 1374
 		);
1375 1375
 
1376
-		printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) );
1376
+		printf("<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode($args));
1377 1377
 	}
1378 1378
 }
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,83 +98,83 @@  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
 			'totals' => $totals,
154
-		) );
154
+		));
155 155
 
156
-		if ( $orderby ) {
157
-			$orderby = ucfirst( $orderby );
158
-			$order = strtoupper( $order );
156
+		if ($orderby) {
157
+			$orderby = ucfirst($orderby);
158
+			$order = strtoupper($order);
159 159
 
160
-			if ( $orderby === 'Name' ) {
161
-				if ( 'ASC' === $order ) {
162
-					$this->items = array_reverse( $this->items );
160
+			if ($orderby === 'Name') {
161
+				if ('ASC' === $order) {
162
+					$this->items = array_reverse($this->items);
163 163
 				}
164 164
 			} else {
165
-				uasort( $this->items, array( $this, '_order_callback' ) );
165
+				uasort($this->items, array($this, '_order_callback'));
166 166
 			}
167 167
 		}
168 168
 
169
-		$start = ( $page - 1 ) * $themes_per_page;
169
+		$start = ($page - 1) * $themes_per_page;
170 170
 
171
-		if ( $total_this_page > $themes_per_page )
172
-			$this->items = array_slice( $this->items, $start, $themes_per_page, true );
171
+		if ($total_this_page > $themes_per_page)
172
+			$this->items = array_slice($this->items, $start, $themes_per_page, true);
173 173
 
174
-		$this->set_pagination_args( array(
174
+		$this->set_pagination_args(array(
175 175
 			'total_items' => $total_this_page,
176 176
 			'per_page' => $themes_per_page,
177
-		) );
177
+		));
178 178
 	}
179 179
 
180 180
 	/**
@@ -182,21 +182,21 @@  discard block
 block discarded – undo
182 182
 	 * @param WP_Theme $theme
183 183
 	 * @return bool
184 184
 	 */
185
-	public function _search_callback( $theme ) {
185
+	public function _search_callback($theme) {
186 186
 		static $term = null;
187
-		if ( is_null( $term ) )
188
-			$term = wp_unslash( $_REQUEST['s'] );
187
+		if (is_null($term))
188
+			$term = wp_unslash($_REQUEST['s']);
189 189
 
190
-		foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) {
190
+		foreach (array('Name', 'Description', 'Author', 'Author', 'AuthorURI') as $field) {
191 191
 			// Don't mark up; Do translate.
192
-			if ( false !== stripos( $theme->display( $field, false, true ), $term ) )
192
+			if (false !== stripos($theme->display($field, false, true), $term))
193 193
 				return true;
194 194
 		}
195 195
 
196
-		if ( false !== stripos( $theme->get_stylesheet(), $term ) )
196
+		if (false !== stripos($theme->get_stylesheet(), $term))
197 197
 			return true;
198 198
 
199
-		if ( false !== stripos( $theme->get_template(), $term ) )
199
+		if (false !== stripos($theme->get_template(), $term))
200 200
 			return true;
201 201
 
202 202
 		return false;
@@ -210,29 +210,29 @@  discard block
 block discarded – undo
210 210
 	 * @param array $theme_b
211 211
 	 * @return int
212 212
 	 */
213
-	public function _order_callback( $theme_a, $theme_b ) {
213
+	public function _order_callback($theme_a, $theme_b) {
214 214
 		global $orderby, $order;
215 215
 
216
-		$a = $theme_a[ $orderby ];
217
-		$b = $theme_b[ $orderby ];
216
+		$a = $theme_a[$orderby];
217
+		$b = $theme_b[$orderby];
218 218
 
219
-		if ( $a == $b )
219
+		if ($a == $b)
220 220
 			return 0;
221 221
 
222
-		if ( 'DESC' === $order )
223
-			return ( $a < $b ) ? 1 : -1;
222
+		if ('DESC' === $order)
223
+			return ($a < $b) ? 1 : -1;
224 224
 		else
225
-			return ( $a < $b ) ? -1 : 1;
225
+			return ($a < $b) ? -1 : 1;
226 226
 	}
227 227
 
228 228
 	/**
229 229
 	 * @access public
230 230
 	 */
231 231
 	public function no_items() {
232
-		if ( $this->has_items ) {
233
-			_e( 'No themes found.' );
232
+		if ($this->has_items) {
233
+			_e('No themes found.');
234 234
 		} else {
235
-			_e( 'You do not appear to have any themes available at this time.' );
235
+			_e('You do not appear to have any themes available at this time.');
236 236
 		}
237 237
 	}
238 238
 
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 	public function get_columns() {
244 244
 		return array(
245 245
 			'cb'          => '<input type="checkbox" />',
246
-			'name'        => __( 'Theme' ),
247
-			'description' => __( 'Description' ),
246
+			'name'        => __('Theme'),
247
+			'description' => __('Description'),
248 248
 		);
249 249
 	}
250 250
 
@@ -280,38 +280,38 @@  discard block
 block discarded – undo
280 280
 		global $totals, $status;
281 281
 
282 282
 		$status_links = array();
283
-		foreach ( $totals as $type => $count ) {
284
-			if ( !$count )
283
+		foreach ($totals as $type => $count) {
284
+			if ( ! $count)
285 285
 				continue;
286 286
 
287
-			switch ( $type ) {
287
+			switch ($type) {
288 288
 				case 'all':
289
-					$text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'themes' );
289
+					$text = _nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'themes');
290 290
 					break;
291 291
 				case 'enabled':
292
-					$text = _n( 'Enabled <span class="count">(%s)</span>', 'Enabled <span class="count">(%s)</span>', $count );
292
+					$text = _n('Enabled <span class="count">(%s)</span>', 'Enabled <span class="count">(%s)</span>', $count);
293 293
 					break;
294 294
 				case 'disabled':
295
-					$text = _n( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', $count );
295
+					$text = _n('Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', $count);
296 296
 					break;
297 297
 				case 'upgrade':
298
-					$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
298
+					$text = _n('Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count);
299 299
 					break;
300 300
 				case 'broken' :
301
-					$text = _n( 'Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count );
301
+					$text = _n('Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count);
302 302
 					break;
303 303
 			}
304 304
 
305
-			if ( $this->is_site_themes )
306
-				$url = 'site-themes.php?id=' . $this->site_id;
305
+			if ($this->is_site_themes)
306
+				$url = 'site-themes.php?id='.$this->site_id;
307 307
 			else
308 308
 				$url = 'themes.php';
309 309
 
310
-			if ( 'search' != $type ) {
311
-				$status_links[$type] = sprintf( "<a href='%s' %s>%s</a>",
312
-					esc_url( add_query_arg('theme_status', $type, $url) ),
313
-					( $type === $status ) ? ' class="current"' : '',
314
-					sprintf( $text, number_format_i18n( $count ) )
310
+			if ('search' != $type) {
311
+				$status_links[$type] = sprintf("<a href='%s' %s>%s</a>",
312
+					esc_url(add_query_arg('theme_status', $type, $url)),
313
+					($type === $status) ? ' class="current"' : '',
314
+					sprintf($text, number_format_i18n($count))
315 315
 				);
316 316
 			}
317 317
 		}
@@ -328,15 +328,15 @@  discard block
 block discarded – undo
328 328
 		global $status;
329 329
 
330 330
 		$actions = array();
331
-		if ( 'enabled' != $status )
332
-			$actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' );
333
-		if ( 'disabled' != $status )
334
-			$actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' );
335
-		if ( ! $this->is_site_themes ) {
336
-			if ( current_user_can( 'update_themes' ) )
337
-				$actions['update-selected'] = __( 'Update' );
338
-			if ( current_user_can( 'delete_themes' ) )
339
-				$actions['delete-selected'] = __( 'Delete' );
331
+		if ('enabled' != $status)
332
+			$actions['enable-selected'] = $this->is_site_themes ? __('Enable') : __('Network Enable');
333
+		if ('disabled' != $status)
334
+			$actions['disable-selected'] = $this->is_site_themes ? __('Disable') : __('Network Disable');
335
+		if ( ! $this->is_site_themes) {
336
+			if (current_user_can('update_themes'))
337
+				$actions['update-selected'] = __('Update');
338
+			if (current_user_can('delete_themes'))
339
+				$actions['delete-selected'] = __('Delete');
340 340
 		}
341 341
 		return $actions;
342 342
 	}
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
 	 * @access public
346 346
 	 */
347 347
 	public function display_rows() {
348
-		foreach ( $this->items as $theme )
349
-			$this->single_row( $theme );
348
+		foreach ($this->items as $theme)
349
+			$this->single_row($theme);
350 350
 	}
351 351
 
352 352
 	/**
@@ -357,11 +357,11 @@  discard block
 block discarded – undo
357 357
 	 *
358 358
 	 * @param WP_Theme $theme The current WP_Theme object.
359 359
 	 */
360
-	public function column_cb( $theme ) {
361
-		$checkbox_id = 'checkbox_' . md5( $theme->get('Name') );
360
+	public function column_cb($theme) {
361
+		$checkbox_id = 'checkbox_'.md5($theme->get('Name'));
362 362
 		?>
363
-		<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ) ?>" id="<?php echo $checkbox_id ?>" />
364
-		<label class="screen-reader-text" for="<?php echo $checkbox_id ?>" ><?php _e( 'Select' ) ?>  <?php echo $theme->display( 'Name' ) ?></label>
363
+		<input type="checkbox" name="checked[]" value="<?php echo esc_attr($theme->get_stylesheet()) ?>" id="<?php echo $checkbox_id ?>" />
364
+		<label class="screen-reader-text" for="<?php echo $checkbox_id ?>" ><?php _e('Select') ?>  <?php echo $theme->display('Name') ?></label>
365 365
 		<?php
366 366
 	}
367 367
 
@@ -377,17 +377,17 @@  discard block
 block discarded – undo
377 377
 	 *
378 378
 	 * @param WP_Theme $theme The current WP_Theme object.
379 379
 	 */
380
-	public function column_name( $theme ) {
380
+	public function column_name($theme) {
381 381
 		global $status, $page, $s;
382 382
 
383 383
 		$context = $status;
384 384
 
385
-		if ( $this->is_site_themes ) {
385
+		if ($this->is_site_themes) {
386 386
 			$url = "site-themes.php?id={$this->site_id}&amp;";
387
-			$allowed = $theme->is_allowed( 'site', $this->site_id );
387
+			$allowed = $theme->is_allowed('site', $this->site_id);
388 388
 		} else {
389 389
 			$url = 'themes.php?';
390
-			$allowed = $theme->is_allowed( 'network' );
390
+			$allowed = $theme->is_allowed('network');
391 391
 		}
392 392
 
393 393
 		// Pre-order.
@@ -399,85 +399,85 @@  discard block
 block discarded – undo
399 399
 		);
400 400
 
401 401
 		$stylesheet = $theme->get_stylesheet();
402
-		$theme_key = urlencode( $stylesheet );
402
+		$theme_key = urlencode($stylesheet);
403 403
 
404
-		if ( ! $allowed ) {
405
-			if ( ! $theme->errors() ) {
406
-				$url = add_query_arg( array(
404
+		if ( ! $allowed) {
405
+			if ( ! $theme->errors()) {
406
+				$url = add_query_arg(array(
407 407
 					'action' => 'enable',
408 408
 					'theme'  => $theme_key,
409 409
 					'paged'  => $page,
410 410
 					's'      => $s,
411
-				), $url );
411
+				), $url);
412 412
 
413
-				if ( $this->is_site_themes ) {
413
+				if ($this->is_site_themes) {
414 414
 					/* translators: %s: theme name */
415
-					$aria_label = sprintf( __( 'Enable %s' ), $theme->display( 'Name' ) );
415
+					$aria_label = sprintf(__('Enable %s'), $theme->display('Name'));
416 416
 				} else {
417 417
 					/* translators: %s: theme name */
418
-					$aria_label = sprintf( __( 'Network Enable %s' ), $theme->display( 'Name' ) );
418
+					$aria_label = sprintf(__('Network Enable %s'), $theme->display('Name'));
419 419
 				}
420 420
 
421
-				$actions['enable'] = sprintf( '<a href="%s" class="edit" aria-label="%s">%s</a>',
422
-					esc_url( wp_nonce_url( $url, 'enable-theme_' . $stylesheet ) ),
423
-					esc_attr( $aria_label ),
424
-					( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) )
421
+				$actions['enable'] = sprintf('<a href="%s" class="edit" aria-label="%s">%s</a>',
422
+					esc_url(wp_nonce_url($url, 'enable-theme_'.$stylesheet)),
423
+					esc_attr($aria_label),
424
+					($this->is_site_themes ? __('Enable') : __('Network Enable'))
425 425
 				);
426 426
 			}
427 427
 		} else {
428
-			$url = add_query_arg( array(
428
+			$url = add_query_arg(array(
429 429
 				'action' => 'disable',
430 430
 				'theme'  => $theme_key,
431 431
 				'paged'  => $page,
432 432
 				's'      => $s,
433
-			), $url );
433
+			), $url);
434 434
 
435
-			if ( $this->is_site_themes ) {
435
+			if ($this->is_site_themes) {
436 436
 				/* translators: %s: theme name */
437
-				$aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) );
437
+				$aria_label = sprintf(__('Disable %s'), $theme->display('Name'));
438 438
 			} else {
439 439
 				/* translators: %s: theme name */
440
-				$aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) );
440
+				$aria_label = sprintf(__('Network Disable %s'), $theme->display('Name'));
441 441
 			}
442 442
 
443
-			$actions['disable'] = sprintf( '<a href="%s" aria-label="%s">%s</a>',
444
-				esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ),
445
-				esc_attr( $aria_label ),
446
-				( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) )
443
+			$actions['disable'] = sprintf('<a href="%s" aria-label="%s">%s</a>',
444
+				esc_url(wp_nonce_url($url, 'disable-theme_'.$stylesheet)),
445
+				esc_attr($aria_label),
446
+				($this->is_site_themes ? __('Disable') : __('Network Disable'))
447 447
 			);
448 448
 		}
449 449
 
450
-		if ( current_user_can('edit_themes') ) {
451
-			$url = add_query_arg( array(
450
+		if (current_user_can('edit_themes')) {
451
+			$url = add_query_arg(array(
452 452
 				'theme' => $theme_key,
453
-			), 'theme-editor.php' );
453
+			), 'theme-editor.php');
454 454
 
455 455
 			/* translators: %s: theme name */
456
-			$aria_label = sprintf( __( 'Open %s in the Theme Editor' ), $theme->display( 'Name' ) );
456
+			$aria_label = sprintf(__('Open %s in the Theme Editor'), $theme->display('Name'));
457 457
 
458
-			$actions['edit'] = sprintf( '<a href="%s" class="edit" aria-label="%s">%s</a>',
459
-				esc_url( $url ),
460
-				esc_attr( $aria_label ),
461
-				__( 'Edit' )
458
+			$actions['edit'] = sprintf('<a href="%s" class="edit" aria-label="%s">%s</a>',
459
+				esc_url($url),
460
+				esc_attr($aria_label),
461
+				__('Edit')
462 462
 			);
463 463
 		}
464 464
 
465
-		if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) {
466
-			$url = add_query_arg( array(
465
+		if ( ! $allowed && current_user_can('delete_themes') && ! $this->is_site_themes && $stylesheet != get_option('stylesheet') && $stylesheet != get_option('template')) {
466
+			$url = add_query_arg(array(
467 467
 				'action'       => 'delete-selected',
468 468
 				'checked[]'    => $theme_key,
469 469
 				'theme_status' => $context,
470 470
 				'paged'        => $page,
471 471
 				's'            => $s,
472
-			), 'themes.php' );
472
+			), 'themes.php');
473 473
 
474 474
 			/* translators: %s: theme name */
475
-			$aria_label = sprintf( __( 'Delete %s' ), $theme->display( 'Name' ) );
475
+			$aria_label = sprintf(__('Delete %s'), $theme->display('Name'));
476 476
 
477
-			$actions['delete'] = sprintf( '<a href="%s" class="delete" aria-label="%s">%s</a>',
478
-				esc_url( wp_nonce_url( $url, 'bulk-themes' ) ),
479
-				esc_attr( $aria_label ),
480
-				__( 'Delete' )
477
+			$actions['delete'] = sprintf('<a href="%s" class="delete" aria-label="%s">%s</a>',
478
+				esc_url(wp_nonce_url($url, 'bulk-themes')),
479
+				esc_attr($aria_label),
480
+				__('Delete')
481 481
 			);
482 482
 		}
483 483
 		/**
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 		 * @param WP_Theme $theme   The current WP_Theme object.
503 503
 		 * @param string   $context Status of the theme.
504 504
 		 */
505
-		$actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme, $context );
505
+		$actions = apply_filters('theme_action_links', array_filter($actions), $theme, $context);
506 506
 
507 507
 		/**
508 508
 		 * Filters the action links of a specific theme in the Multisite themes
@@ -518,9 +518,9 @@  discard block
 block discarded – undo
518 518
 		 * @param WP_Theme $theme   The current WP_Theme object.
519 519
 		 * @param string   $context Status of the theme.
520 520
 		 */
521
-		$actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme, $context );
521
+		$actions = apply_filters("theme_action_links_$stylesheet", $actions, $theme, $context);
522 522
 
523
-		echo $this->row_actions( $actions, true );
523
+		echo $this->row_actions($actions, true);
524 524
 	}
525 525
 
526 526
 	/**
@@ -534,42 +534,42 @@  discard block
 block discarded – undo
534 534
 	 *
535 535
 	 * @param WP_Theme $theme The current WP_Theme object.
536 536
 	 */
537
-	public function column_description( $theme ) {
537
+	public function column_description($theme) {
538 538
 		global $status, $totals;
539
-		if ( $theme->errors() ) {
540
-			$pre = $status === 'broken' ? __( 'Broken Theme:' ) . ' ' : '';
541
-			echo '<p><strong class="error-message">' . $pre . $theme->errors()->get_error_message() . '</strong></p>';
539
+		if ($theme->errors()) {
540
+			$pre = $status === 'broken' ? __('Broken Theme:').' ' : '';
541
+			echo '<p><strong class="error-message">'.$pre.$theme->errors()->get_error_message().'</strong></p>';
542 542
 		}
543 543
 
544
-		if ( $this->is_site_themes ) {
545
-			$allowed = $theme->is_allowed( 'site', $this->site_id );
544
+		if ($this->is_site_themes) {
545
+			$allowed = $theme->is_allowed('site', $this->site_id);
546 546
 		} else {
547
-			$allowed = $theme->is_allowed( 'network' );
547
+			$allowed = $theme->is_allowed('network');
548 548
 		}
549 549
 
550 550
 		$class = ! $allowed ? 'inactive' : 'active';
551
-		if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) )
551
+		if ( ! empty($totals['upgrade']) && ! empty($theme->update))
552 552
 			$class .= ' update';
553 553
 
554
-		echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div>
554
+		echo "<div class='theme-description'><p>".$theme->display('Description')."</p></div>
555 555
 			<div class='$class second theme-version-author-uri'>";
556 556
 
557 557
 		$stylesheet = $theme->get_stylesheet();
558 558
 		$theme_meta = array();
559 559
 
560
-		if ( $theme->get('Version') ) {
561
-			$theme_meta[] = sprintf( __( 'Version %s' ), $theme->display('Version') );
560
+		if ($theme->get('Version')) {
561
+			$theme_meta[] = sprintf(__('Version %s'), $theme->display('Version'));
562 562
 		}
563
-		$theme_meta[] = sprintf( __( 'By %s' ), $theme->display('Author') );
563
+		$theme_meta[] = sprintf(__('By %s'), $theme->display('Author'));
564 564
 
565
-		if ( $theme->get('ThemeURI') ) {
565
+		if ($theme->get('ThemeURI')) {
566 566
 			/* translators: %s: theme name */
567
-			$aria_label = sprintf( __( 'Visit %s homepage' ), $theme->display( 'Name' ) );
567
+			$aria_label = sprintf(__('Visit %s homepage'), $theme->display('Name'));
568 568
 
569
-			$theme_meta[] = sprintf( '<a href="%s" aria-label="%s">%s</a>',
570
-				$theme->display( 'ThemeURI' ),
571
-				esc_attr( $aria_label ),
572
-				__( 'Visit Theme Site' )
569
+			$theme_meta[] = sprintf('<a href="%s" aria-label="%s">%s</a>',
570
+				$theme->display('ThemeURI'),
571
+				esc_attr($aria_label),
572
+				__('Visit Theme Site')
573 573
 			);
574 574
 		}
575 575
 		/**
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
 		 * @param WP_Theme $theme      WP_Theme object.
586 586
 		 * @param string   $status     Status of the theme.
587 587
 		 */
588
-		$theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status );
589
-		echo implode( ' | ', $theme_meta );
588
+		$theme_meta = apply_filters('theme_row_meta', $theme_meta, $stylesheet, $theme, $status);
589
+		echo implode(' | ', $theme_meta);
590 590
 
591 591
 		echo '</div>';
592 592
 	}
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 * @param WP_Theme $theme       The current WP_Theme object.
601 601
 	 * @param string   $column_name The current column name.
602 602
 	 */
603
-	public function column_default( $theme, $column_name ) {
603
+	public function column_default($theme, $column_name) {
604 604
 		$stylesheet = $theme->get_stylesheet();
605 605
 
606 606
 		/**
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 		 * @param string   $stylesheet  Directory name of the theme.
613 613
 		 * @param WP_Theme $theme       Current WP_Theme object.
614 614
 		 */
615
-		do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
615
+		do_action('manage_themes_custom_column', $column_name, $stylesheet, $theme);
616 616
 	}
617 617
 
618 618
 	/**
@@ -623,28 +623,28 @@  discard block
 block discarded – undo
623 623
 	 *
624 624
 	 * @param WP_Theme $item The current WP_Theme object.
625 625
 	 */
626
-	public function single_row_columns( $item ) {
627
-		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
626
+	public function single_row_columns($item) {
627
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
628 628
 
629
-		foreach ( $columns as $column_name => $column_display_name ) {
629
+		foreach ($columns as $column_name => $column_display_name) {
630 630
 			$extra_classes = '';
631
-			if ( in_array( $column_name, $hidden ) ) {
631
+			if (in_array($column_name, $hidden)) {
632 632
 				$extra_classes .= ' hidden';
633 633
 			}
634 634
 
635
-			switch ( $column_name ) {
635
+			switch ($column_name) {
636 636
 				case 'cb':
637 637
 					echo '<th scope="row" class="check-column">';
638 638
 
639
-					$this->column_cb( $item );
639
+					$this->column_cb($item);
640 640
 
641 641
 					echo '</th>';
642 642
 					break;
643 643
 
644 644
 				case 'name':
645
-					echo "<td class='theme-title column-primary{$extra_classes}'><strong>" . $item->display('Name') . "</strong>";
645
+					echo "<td class='theme-title column-primary{$extra_classes}'><strong>".$item->display('Name')."</strong>";
646 646
 
647
-					$this->column_name( $item );
647
+					$this->column_name($item);
648 648
 
649 649
 					echo "</td>";
650 650
 					break;
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 				case 'description':
653 653
 					echo "<td class='column-description desc{$extra_classes}'>";
654 654
 
655
-					$this->column_description( $item );
655
+					$this->column_description($item);
656 656
 
657 657
 					echo '</td>';
658 658
 					break;
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 				default:
661 661
 					echo "<td class='$column_name column-$column_name{$extra_classes}'>";
662 662
 
663
-					$this->column_default( $item, $column_name );
663
+					$this->column_default($item, $column_name);
664 664
 
665 665
 					echo "</td>";
666 666
 					break;
@@ -674,33 +674,33 @@  discard block
 block discarded – undo
674 674
 	 *
675 675
 	 * @param WP_Theme $theme
676 676
 	 */
677
-	public function single_row( $theme ) {
677
+	public function single_row($theme) {
678 678
 		global $status, $totals;
679 679
 
680
-		if ( $this->is_site_themes ) {
681
-			$allowed = $theme->is_allowed( 'site', $this->site_id );
680
+		if ($this->is_site_themes) {
681
+			$allowed = $theme->is_allowed('site', $this->site_id);
682 682
 		} else {
683
-			$allowed = $theme->is_allowed( 'network' );
683
+			$allowed = $theme->is_allowed('network');
684 684
 		}
685 685
 
686 686
 		$stylesheet = $theme->get_stylesheet();
687 687
 
688 688
 		$class = ! $allowed ? 'inactive' : 'active';
689
-		if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) {
689
+		if ( ! empty($totals['upgrade']) && ! empty($theme->update)) {
690 690
 			$class .= ' update';
691 691
 		}
692 692
 
693
-		printf( '<tr class="%s" data-slug="%s">',
694
-			esc_attr( $class ),
695
-			esc_attr( $stylesheet )
693
+		printf('<tr class="%s" data-slug="%s">',
694
+			esc_attr($class),
695
+			esc_attr($stylesheet)
696 696
 		);
697 697
 
698
-		$this->single_row_columns( $theme );
698
+		$this->single_row_columns($theme);
699 699
 
700 700
 		echo "</tr>";
701 701
 
702
-		if ( $this->is_site_themes )
703
-			remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' );
702
+		if ($this->is_site_themes)
703
+			remove_action("after_theme_row_$stylesheet", 'wp_theme_update_row');
704 704
 
705 705
 		/**
706 706
 		 * Fires after each row in the Multisite themes list table.
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 		 * @param WP_Theme $theme      Current WP_Theme object.
712 712
 		 * @param string   $status     Status of the theme.
713 713
 		 */
714
-		do_action( 'after_theme_row', $stylesheet, $theme, $status );
714
+		do_action('after_theme_row', $stylesheet, $theme, $status);
715 715
 
716 716
 		/**
717 717
 		 * Fires after each specific row in the Multisite themes list table.
@@ -726,6 +726,6 @@  discard block
 block discarded – undo
726 726
 		 * @param WP_Theme $theme      Current WP_Theme object.
727 727
 		 * @param string   $status     Status of the theme.
728 728
 		 */
729
-		do_action( "after_theme_row_$stylesheet", $stylesheet, $theme, $status );
729
+		do_action("after_theme_row_$stylesheet", $stylesheet, $theme, $status);
730 730
 	}
731 731
 }
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.
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
 	}
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
 	 * @global string $mode
149 149
 	 * @param string $which
150 150
 	 */
151
-	protected function pagination( $which ) {
151
+	protected function pagination($which) {
152 152
 		global $mode;
153 153
 
154
-		parent::pagination ( $which );
154
+		parent::pagination($which);
155 155
 
156
-		if ( 'top' === $which ) {
157
-			$this->view_switcher( $mode );
156
+		if ('top' === $which) {
157
+			$this->view_switcher($mode);
158 158
 		}
159 159
 	}
160 160
 
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 	public function get_columns() {
166 166
 		$users_columns = array(
167 167
 			'cb'         => '<input type="checkbox" />',
168
-			'username'   => __( 'Username' ),
169
-			'name'       => __( 'Name' ),
170
-			'email'      => __( 'Email' ),
171
-			'registered' => _x( 'Registered', 'user' ),
172
-			'blogs'      => __( 'Sites' )
168
+			'username'   => __('Username'),
169
+			'name'       => __('Name'),
170
+			'email'      => __('Email'),
171
+			'registered' => _x('Registered', 'user'),
172
+			'blogs'      => __('Sites')
173 173
 		);
174 174
 		/**
175 175
 		 * Filter the columns displayed in the Network Admin Users list table.
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		 * @param array $users_columns An array of user columns. Default 'cb', 'username',
180 180
 		 *                             'name', 'email', 'registered', 'blogs'.
181 181
 		 */
182
-		return apply_filters( 'wpmu_users_columns', $users_columns );
182
+		return apply_filters('wpmu_users_columns', $users_columns);
183 183
 	}
184 184
 
185 185
 	/**
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @param WP_User $user The current WP_User object.
205 205
 	 */
206
-	public function column_cb( $user ) {
207
-		if ( is_super_admin( $user->ID ) ) {
206
+	public function column_cb($user) {
207
+		if (is_super_admin($user->ID)) {
208 208
 			return;
209 209
 		}
210 210
 		?>
211
-		<label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label>
212
-		<input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" />
211
+		<label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf(__('Select %s'), $user->user_login); ?></label>
212
+		<input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr($user->ID) ?>" />
213 213
 		<?php
214 214
 	}
215 215
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @param WP_User $user The current WP_User object.
223 223
 	 */
224
-	public function column_id( $user ) {
224
+	public function column_id($user) {
225 225
 		echo $user->ID;
226 226
 	}
227 227
 
@@ -233,16 +233,16 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @param WP_User $user The current WP_User object.
235 235
 	 */
236
-	public function column_username( $user ) {
236
+	public function column_username($user) {
237 237
 		$super_admins = get_super_admins();
238
-		$avatar	= get_avatar( $user->user_email, 32 );
239
-		$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
238
+		$avatar = get_avatar($user->user_email, 32);
239
+		$edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user->ID)));
240 240
 
241 241
 		echo $avatar;
242 242
 
243 243
 		?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php
244
-		if ( in_array( $user->user_login, $super_admins ) ) {
245
-			echo ' - ' . __( 'Super Admin' );
244
+		if (in_array($user->user_login, $super_admins)) {
245
+			echo ' - '.__('Super Admin');
246 246
 		}
247 247
 		?></strong>
248 248
 	<?php
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @param WP_User $user The current WP_User object.
258 258
 	 */
259
-	public function column_name( $user ) {
259
+	public function column_name($user) {
260 260
 		echo "$user->first_name $user->last_name";
261 261
 	}
262 262
 
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	 *
269 269
 	 * @param WP_User $user The current WP_User object.
270 270
 	 */
271
-	public function column_email( $user ) {
272
-		echo "<a href='" . esc_url( "mailto:$user->user_email" ) . "'>$user->user_email</a>";
271
+	public function column_email($user) {
272
+		echo "<a href='".esc_url("mailto:$user->user_email")."'>$user->user_email</a>";
273 273
 	}
274 274
 
275 275
 	/**
@@ -282,14 +282,14 @@  discard block
 block discarded – undo
282 282
 	 *
283 283
 	 * @param WP_User $user The current WP_User object.
284 284
 	 */
285
-	public function column_registered( $user ) {
285
+	public function column_registered($user) {
286 286
 		global $mode;
287
-		if ( 'list' === $mode ) {
288
-			$date = __( 'Y/m/d' );
287
+		if ('list' === $mode) {
288
+			$date = __('Y/m/d');
289 289
 		} else {
290
-			$date = __( 'Y/m/d g:i:s a' );
290
+			$date = __('Y/m/d g:i:s a');
291 291
 		}
292
-		echo mysql2date( $date, $user->user_registered );
292
+		echo mysql2date($date, $user->user_registered);
293 293
 	}
294 294
 
295 295
 	/**
@@ -301,10 +301,10 @@  discard block
 block discarded – undo
301 301
 	 * @param string  $data
302 302
 	 * @param string  $primary
303 303
 	 */
304
-	protected function _column_blogs( $user, $classes, $data, $primary ) {
304
+	protected function _column_blogs($user, $classes, $data, $primary) {
305 305
 		echo '<td class="', $classes, ' has-row-actions" ', $data, '>';
306
-		echo $this->column_blogs( $user );
307
-		echo $this->handle_row_actions( $user, 'blogs', $primary );
306
+		echo $this->column_blogs($user);
307
+		echo $this->handle_row_actions($user, 'blogs', $primary);
308 308
 		echo '</td>';
309 309
 	}
310 310
 
@@ -316,39 +316,39 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @param WP_User $user The current WP_User object.
318 318
 	 */
319
-	public function column_blogs( $user ) {
320
-		$blogs = get_blogs_of_user( $user->ID, true );
321
-		if ( ! is_array( $blogs ) ) {
319
+	public function column_blogs($user) {
320
+		$blogs = get_blogs_of_user($user->ID, true);
321
+		if ( ! is_array($blogs)) {
322 322
 			return;
323 323
 		}
324 324
 
325
-		foreach ( $blogs as $val ) {
326
-			if ( ! can_edit_network( $val->site_id ) ) {
325
+		foreach ($blogs as $val) {
326
+			if ( ! can_edit_network($val->site_id)) {
327 327
 				continue;
328 328
 			}
329 329
 
330
-			$path	= ( $val->path === '/' ) ? '' : $val->path;
331
-			echo '<span class="site-' . $val->site_id . '" >';
332
-			echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . get_current_site()->domain, '', $val->domain . $path ) . '</a>';
330
+			$path = ($val->path === '/') ? '' : $val->path;
331
+			echo '<span class="site-'.$val->site_id.'" >';
332
+			echo '<a href="'.esc_url(network_admin_url('site-info.php?id='.$val->userblog_id)).'">'.str_replace('.'.get_current_site()->domain, '', $val->domain.$path).'</a>';
333 333
 			echo ' <small class="row-actions">';
334 334
 			$actions = array();
335
-			$actions['edit'] = '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a>';
335
+			$actions['edit'] = '<a href="'.esc_url(network_admin_url('site-info.php?id='.$val->userblog_id)).'">'.__('Edit').'</a>';
336 336
 
337 337
 			$class = '';
338
-			if ( $val->spam == 1 ) {
338
+			if ($val->spam == 1) {
339 339
 				$class .= 'site-spammed ';
340 340
 			}
341
-			if ( $val->mature == 1 ) {
341
+			if ($val->mature == 1) {
342 342
 				$class .= 'site-mature ';
343 343
 			}
344
-			if ( $val->deleted == 1 ) {
344
+			if ($val->deleted == 1) {
345 345
 				$class .= 'site-deleted ';
346 346
 			}
347
-			if ( $val->archived == 1 ) {
347
+			if ($val->archived == 1) {
348 348
 				$class .= 'site-archived ';
349 349
 			}
350 350
 
351
-			$actions['view'] = '<a class="' . $class . '" href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'View' ) . '</a>';
351
+			$actions['view'] = '<a class="'.$class.'" href="'.esc_url(get_home_url($val->userblog_id)).'">'.__('View').'</a>';
352 352
 
353 353
 			/**
354 354
 			 * Filter the action links displayed next the sites a user belongs to
@@ -360,13 +360,13 @@  discard block
 block discarded – undo
360 360
 			 *                           Default 'Edit', 'View'.
361 361
 			 * @param int   $userblog_id The site ID.
362 362
 			 */
363
-			$actions = apply_filters( 'ms_user_list_site_actions', $actions, $val->userblog_id );
363
+			$actions = apply_filters('ms_user_list_site_actions', $actions, $val->userblog_id);
364 364
 
365
-			$i=0;
366
-			$action_count = count( $actions );
367
-			foreach ( $actions as $action => $link ) {
365
+			$i = 0;
366
+			$action_count = count($actions);
367
+			foreach ($actions as $action => $link) {
368 368
 				++$i;
369
-				$sep = ( $i == $action_count ) ? '' : ' | ';
369
+				$sep = ($i == $action_count) ? '' : ' | ';
370 370
 				echo "<span class='$action'>$link$sep</span>";
371 371
 			}
372 372
 			echo '</small></span><br/>';
@@ -382,26 +382,26 @@  discard block
 block discarded – undo
382 382
 	 * @param WP_User $user       The current WP_User object.
383 383
 	 * @param string $column_name The current column name.
384 384
 	 */
385
-	public function column_default( $user, $column_name ) {
385
+	public function column_default($user, $column_name) {
386 386
 		/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
387
-		echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
387
+		echo apply_filters('manage_users_custom_column', '', $column_name, $user->ID);
388 388
 	}
389 389
 
390 390
 	public function display_rows() {
391
-		foreach ( $this->items as $user ) {
391
+		foreach ($this->items as $user) {
392 392
 			$class = '';
393 393
 
394
-			$status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
394
+			$status_list = array('spam' => 'site-spammed', 'deleted' => 'site-deleted');
395 395
 
396
-			foreach ( $status_list as $status => $col ) {
397
-				if ( $user->$status ) {
396
+			foreach ($status_list as $status => $col) {
397
+				if ($user->$status) {
398 398
 					$class .= " $col";
399 399
 				}
400 400
 			}
401 401
 
402 402
 			?>
403
-			<tr class="<?php echo trim( $class ); ?>">
404
-				<?php $this->single_row_columns( $user ); ?>
403
+			<tr class="<?php echo trim($class); ?>">
404
+				<?php $this->single_row_columns($user); ?>
405 405
 			</tr>
406 406
 			<?php
407 407
 		}
@@ -430,19 +430,19 @@  discard block
 block discarded – undo
430 430
 	 * @param string $primary     Primary column name.
431 431
 	 * @return string Row actions output for users in Multisite.
432 432
 	 */
433
-	protected function handle_row_actions( $user, $column_name, $primary ) {
434
-		if ( $primary !== $column_name ) {
433
+	protected function handle_row_actions($user, $column_name, $primary) {
434
+		if ($primary !== $column_name) {
435 435
 			return '';
436 436
 		}
437 437
 
438 438
 		$super_admins = get_super_admins();
439
-		$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
439
+		$edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user->ID)));
440 440
 
441 441
 		$actions = array();
442
-		$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
442
+		$actions['edit'] = '<a href="'.$edit_link.'">'.__('Edit').'</a>';
443 443
 
444
-		if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {
445
-			$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>';
444
+		if (current_user_can('delete_user', $user->ID) && ! in_array($user->user_login, $super_admins)) {
445
+			$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>';
446 446
 		}
447 447
 
448 448
 		/**
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 		 *                         Default 'Edit', 'Delete'.
455 455
 		 * @param WP_User $user    WP_User object.
456 456
 		 */
457
-		$actions = apply_filters( 'ms_user_row_actions', $actions, $user );
458
-		return $this->row_actions( $actions );
457
+		$actions = apply_filters('ms_user_row_actions', $actions, $user);
458
+		return $this->row_actions($actions);
459 459
 	}
460 460
 }
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.