GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 78ace2...4b54c6 )
by gyeong-won
09:15
created
libs/phpmailer/smtp.php 4 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -107,6 +107,7 @@  discard block
 block discarded – undo
107 107
    * SMTP CODE SUCCESS: 220
108 108
    * SMTP CODE FAILURE: 421
109 109
    * @access public
110
+   * @param string $host
110 111
    * @return bool
111 112
    */
112 113
   public function Connect($host,$port=0,$tval=30) {
@@ -205,6 +206,8 @@  discard block
 block discarded – undo
205 206
    * Performs SMTP authentication.  Must be run after running the
206 207
    * Hello() method.  Returns true if successfully authenticated.
207 208
    * @access public
209
+   * @param string $username
210
+   * @param string $password
208 211
    * @return bool
209 212
    */
210 213
   public function Authenticate($username, $password) {
@@ -321,6 +324,7 @@  discard block
 block discarded – undo
321 324
    * SMTP CODE FAILURE: 451,554
322 325
    * SMTP CODE ERROR  : 500,501,503,421
323 326
    * @access public
327
+   * @param string $msg_data
324 328
    * @return bool
325 329
    */
326 330
   public function Data($msg_data) {
@@ -489,6 +493,8 @@  discard block
 block discarded – undo
489 493
   /**
490 494
    * Sends a HELO/EHLO command.
491 495
    * @access private
496
+   * @param string $hello
497
+   * @param string $host
492 498
    * @return bool
493 499
    */
494 500
   private function SendHello($hello, $host) {
@@ -529,6 +535,7 @@  discard block
 block discarded – undo
529 535
    * SMTP CODE SUCCESS: 552,451,452
530 536
    * SMTP CODE SUCCESS: 500,501,421
531 537
    * @access public
538
+   * @param string $from
532 539
    * @return bool
533 540
    */
534 541
   public function Mail($from) {
Please login to merge, or discard this patch.
Indentation   +470 added lines, -470 removed lines patch added patch discarded remove patch
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
    * @return void
86 86
    */
87 87
   public function __construct() {
88
-    $this->smtp_conn = 0;
89
-    $this->error = null;
90
-    $this->helo_rply = null;
88
+	$this->smtp_conn = 0;
89
+	$this->error = null;
90
+	$this->helo_rply = null;
91 91
 
92
-    $this->do_debug = 0;
92
+	$this->do_debug = 0;
93 93
   }
94 94
 
95 95
   /////////////////////////////////////////////////
@@ -110,50 +110,50 @@  discard block
 block discarded – undo
110 110
    * @return bool
111 111
    */
112 112
   public function Connect($host,$port=0,$tval=30) {
113
-    // set the error val to null so there is no confusion
114
-    $this->error = null;
115
-
116
-    // make sure we are __not__ connected
117
-    if($this->connected()) {
118
-      // already connected, generate error
119
-      $this->error = array("error" => "Already connected to a server");
120
-      return false;
121
-    }
122
-
123
-    if(empty($port)) {
124
-      $port = $this->SMTP_PORT;
125
-    }
126
-
127
-    // connect to the smtp server
128
-    $this->smtp_conn = @fsockopen($host,    // the host of the server
129
-                                 $port,    // the port to use
130
-                                 $errno,   // error number if any
131
-                                 $errstr,  // error message if any
132
-                                 $tval);   // give up after ? secs
133
-    // verify we connected properly
134
-    if(empty($this->smtp_conn)) {
135
-      $this->error = array("error" => "Failed to connect to server",
136
-                           "errno" => $errno,
137
-                           "errstr" => $errstr);
138
-      if($this->do_debug >= 1) {
139
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
140
-      }
141
-      return false;
142
-    }
143
-
144
-    // SMTP server can take longer to respond, give longer timeout for first read
145
-    // Windows does not have support for this timeout function
146
-    if(substr(PHP_OS, 0, 3) != "WIN")
147
-     socket_set_timeout($this->smtp_conn, $tval, 0);
148
-
149
-    // get any announcement
150
-    $announce = $this->get_lines();
151
-
152
-    if($this->do_debug >= 2) {
153
-      echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
154
-    }
155
-
156
-    return true;
113
+	// set the error val to null so there is no confusion
114
+	$this->error = null;
115
+
116
+	// make sure we are __not__ connected
117
+	if($this->connected()) {
118
+	  // already connected, generate error
119
+	  $this->error = array("error" => "Already connected to a server");
120
+	  return false;
121
+	}
122
+
123
+	if(empty($port)) {
124
+	  $port = $this->SMTP_PORT;
125
+	}
126
+
127
+	// connect to the smtp server
128
+	$this->smtp_conn = @fsockopen($host,    // the host of the server
129
+								 $port,    // the port to use
130
+								 $errno,   // error number if any
131
+								 $errstr,  // error message if any
132
+								 $tval);   // give up after ? secs
133
+	// verify we connected properly
134
+	if(empty($this->smtp_conn)) {
135
+	  $this->error = array("error" => "Failed to connect to server",
136
+						   "errno" => $errno,
137
+						   "errstr" => $errstr);
138
+	  if($this->do_debug >= 1) {
139
+		echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
140
+	  }
141
+	  return false;
142
+	}
143
+
144
+	// SMTP server can take longer to respond, give longer timeout for first read
145
+	// Windows does not have support for this timeout function
146
+	if(substr(PHP_OS, 0, 3) != "WIN")
147
+	 socket_set_timeout($this->smtp_conn, $tval, 0);
148
+
149
+	// get any announcement
150
+	$announce = $this->get_lines();
151
+
152
+	if($this->do_debug >= 2) {
153
+	  echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
154
+	}
155
+
156
+	return true;
157 157
   }
158 158
 
159 159
   /**
@@ -166,39 +166,39 @@  discard block
 block discarded – undo
166 166
    * @return bool success
167 167
    */
168 168
   public function StartTLS() {
169
-    $this->error = null; # to avoid confusion
170
-
171
-    if(!$this->connected()) {
172
-      $this->error = array("error" => "Called StartTLS() without being connected");
173
-      return false;
174
-    }
175
-
176
-    fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
177
-
178
-    $rply = $this->get_lines();
179
-    $code = substr($rply,0,3);
180
-
181
-    if($this->do_debug >= 2) {
182
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
183
-    }
184
-
185
-    if($code != 220) {
186
-      $this->error =
187
-         array("error"     => "STARTTLS not accepted from server",
188
-               "smtp_code" => $code,
189
-               "smtp_msg"  => substr($rply,4));
190
-      if($this->do_debug >= 1) {
191
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
192
-      }
193
-      return false;
194
-    }
195
-
196
-    //Begin encrypted connection
197
-    if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
198
-      return false;
199
-    }
200
-
201
-    return true;
169
+	$this->error = null; # to avoid confusion
170
+
171
+	if(!$this->connected()) {
172
+	  $this->error = array("error" => "Called StartTLS() without being connected");
173
+	  return false;
174
+	}
175
+
176
+	fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
177
+
178
+	$rply = $this->get_lines();
179
+	$code = substr($rply,0,3);
180
+
181
+	if($this->do_debug >= 2) {
182
+	  echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
183
+	}
184
+
185
+	if($code != 220) {
186
+	  $this->error =
187
+		 array("error"     => "STARTTLS not accepted from server",
188
+			   "smtp_code" => $code,
189
+			   "smtp_msg"  => substr($rply,4));
190
+	  if($this->do_debug >= 1) {
191
+		echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
192
+	  }
193
+	  return false;
194
+	}
195
+
196
+	//Begin encrypted connection
197
+	if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
198
+	  return false;
199
+	}
200
+
201
+	return true;
202 202
   }
203 203
 
204 204
   /**
@@ -208,58 +208,58 @@  discard block
 block discarded – undo
208 208
    * @return bool
209 209
    */
210 210
   public function Authenticate($username, $password) {
211
-    // Start authentication
212
-    fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
213
-
214
-    $rply = $this->get_lines();
215
-    $code = substr($rply,0,3);
216
-
217
-    if($code != 334) {
218
-      $this->error =
219
-        array("error" => "AUTH not accepted from server",
220
-              "smtp_code" => $code,
221
-              "smtp_msg" => substr($rply,4));
222
-      if($this->do_debug >= 1) {
223
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
224
-      }
225
-      return false;
226
-    }
227
-
228
-    // Send encoded username
229
-    fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
230
-
231
-    $rply = $this->get_lines();
232
-    $code = substr($rply,0,3);
233
-
234
-    if($code != 334) {
235
-      $this->error =
236
-        array("error" => "Username not accepted from server",
237
-              "smtp_code" => $code,
238
-              "smtp_msg" => substr($rply,4));
239
-      if($this->do_debug >= 1) {
240
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
241
-      }
242
-      return false;
243
-    }
244
-
245
-    // Send encoded password
246
-    fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
247
-
248
-    $rply = $this->get_lines();
249
-    $code = substr($rply,0,3);
250
-
251
-    if($code != 235) {
252
-      $this->error =
253
-        array("error" => "Password not accepted from server",
254
-              "smtp_code" => $code,
255
-              "smtp_msg" => substr($rply,4));
256
-      if($this->do_debug >= 1) {
257
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
258
-      }
259
-      return false;
260
-    }
261
-
262
-    return true;
211
+	// Start authentication
212
+	fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
213
+
214
+	$rply = $this->get_lines();
215
+	$code = substr($rply,0,3);
216
+
217
+	if($code != 334) {
218
+	  $this->error =
219
+		array("error" => "AUTH not accepted from server",
220
+			  "smtp_code" => $code,
221
+			  "smtp_msg" => substr($rply,4));
222
+	  if($this->do_debug >= 1) {
223
+		echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
224
+	  }
225
+	  return false;
226
+	}
227
+
228
+	// Send encoded username
229
+	fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
230
+
231
+	$rply = $this->get_lines();
232
+	$code = substr($rply,0,3);
233
+
234
+	if($code != 334) {
235
+	  $this->error =
236
+		array("error" => "Username not accepted from server",
237
+			  "smtp_code" => $code,
238
+			  "smtp_msg" => substr($rply,4));
239
+	  if($this->do_debug >= 1) {
240
+		echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
241
+	  }
242
+	  return false;
243
+	}
244
+
245
+	// Send encoded password
246
+	fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
247
+
248
+	$rply = $this->get_lines();
249
+	$code = substr($rply,0,3);
250
+
251
+	if($code != 235) {
252
+	  $this->error =
253
+		array("error" => "Password not accepted from server",
254
+			  "smtp_code" => $code,
255
+			  "smtp_msg" => substr($rply,4));
256
+	  if($this->do_debug >= 1) {
257
+		echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
258
+	  }
259
+	  return false;
260
+	}
261
+
262
+	return true;
263 263
   }
264 264
 
265 265
   /**
@@ -268,19 +268,19 @@  discard block
 block discarded – undo
268 268
    * @return bool
269 269
    */
270 270
   public function Connected() {
271
-    if(!empty($this->smtp_conn)) {
272
-      $sock_status = socket_get_status($this->smtp_conn);
273
-      if($sock_status["eof"]) {
274
-        // the socket is valid but we are not connected
275
-        if($this->do_debug >= 1) {
276
-            echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
277
-        }
278
-        $this->Close();
279
-        return false;
280
-      }
281
-      return true; // everything looks good
282
-    }
283
-    return false;
271
+	if(!empty($this->smtp_conn)) {
272
+	  $sock_status = socket_get_status($this->smtp_conn);
273
+	  if($sock_status["eof"]) {
274
+		// the socket is valid but we are not connected
275
+		if($this->do_debug >= 1) {
276
+			echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
277
+		}
278
+		$this->Close();
279
+		return false;
280
+	  }
281
+	  return true; // everything looks good
282
+	}
283
+	return false;
284 284
   }
285 285
 
286 286
   /**
@@ -291,13 +291,13 @@  discard block
 block discarded – undo
291 291
    * @return void
292 292
    */
293 293
   public function Close() {
294
-    $this->error = null; // so there is no confusion
295
-    $this->helo_rply = null;
296
-    if(!empty($this->smtp_conn)) {
297
-      // close the connection and cleanup
298
-      fclose($this->smtp_conn);
299
-      $this->smtp_conn = 0;
300
-    }
294
+	$this->error = null; // so there is no confusion
295
+	$this->helo_rply = null;
296
+	if(!empty($this->smtp_conn)) {
297
+	  // close the connection and cleanup
298
+	  fclose($this->smtp_conn);
299
+	  $this->smtp_conn = 0;
300
+	}
301 301
   }
302 302
 
303 303
   /////////////////////////////////////////////////
@@ -324,35 +324,35 @@  discard block
 block discarded – undo
324 324
    * @return bool
325 325
    */
326 326
   public function Data($msg_data) {
327
-    $this->error = null; // so no confusion is caused
328
-
329
-    if(!$this->connected()) {
330
-      $this->error = array(
331
-              "error" => "Called Data() without being connected");
332
-      return false;
333
-    }
334
-
335
-    fputs($this->smtp_conn,"DATA" . $this->CRLF);
336
-
337
-    $rply = $this->get_lines();
338
-    $code = substr($rply,0,3);
339
-
340
-    if($this->do_debug >= 2) {
341
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
342
-    }
343
-
344
-    if($code != 354) {
345
-      $this->error =
346
-        array("error" => "DATA command not accepted from server",
347
-              "smtp_code" => $code,
348
-              "smtp_msg" => substr($rply,4));
349
-      if($this->do_debug >= 1) {
350
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
351
-      }
352
-      return false;
353
-    }
354
-
355
-    /* the server is ready to accept data!
327
+	$this->error = null; // so no confusion is caused
328
+
329
+	if(!$this->connected()) {
330
+	  $this->error = array(
331
+			  "error" => "Called Data() without being connected");
332
+	  return false;
333
+	}
334
+
335
+	fputs($this->smtp_conn,"DATA" . $this->CRLF);
336
+
337
+	$rply = $this->get_lines();
338
+	$code = substr($rply,0,3);
339
+
340
+	if($this->do_debug >= 2) {
341
+	  echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
342
+	}
343
+
344
+	if($code != 354) {
345
+	  $this->error =
346
+		array("error" => "DATA command not accepted from server",
347
+			  "smtp_code" => $code,
348
+			  "smtp_msg" => substr($rply,4));
349
+	  if($this->do_debug >= 1) {
350
+		echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
351
+	  }
352
+	  return false;
353
+	}
354
+
355
+	/* the server is ready to accept data!
356 356
      * according to rfc 821 we should not send more than 1000
357 357
      * including the CRLF
358 358
      * characters on a single line so we will break the data up
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
      * line. NOTE: this does not count towards limit.
364 364
      */
365 365
 
366
-    // normalize the line breaks so we know the explode works
367
-    $msg_data = str_replace("\r\n","\n",$msg_data);
368
-    $msg_data = str_replace("\r","\n",$msg_data);
369
-    $lines = explode("\n",$msg_data);
366
+	// normalize the line breaks so we know the explode works
367
+	$msg_data = str_replace("\r\n","\n",$msg_data);
368
+	$msg_data = str_replace("\r","\n",$msg_data);
369
+	$lines = explode("\n",$msg_data);
370 370
 
371
-    /* we need to find a good way to determine is headers are
371
+	/* we need to find a good way to determine is headers are
372 372
      * in the msg_data or if it is a straight msg body
373 373
      * currently I am assuming rfc 822 definitions of msg headers
374 374
      * and if the first field of the first line (':' sperated)
@@ -377,76 +377,76 @@  discard block
 block discarded – undo
377 377
      * headers.
378 378
      */
379 379
 
380
-    $field = substr($lines[0],0,strpos($lines[0],":"));
381
-    $in_headers = false;
382
-    if(!empty($field) && !strstr($field," ")) {
383
-      $in_headers = true;
384
-    }
385
-
386
-    $max_line_length = 998; // used below; set here for ease in change
387
-
388
-    while(list(,$line) = @each($lines)) {
389
-      $lines_out = null;
390
-      if($line == "" && $in_headers) {
391
-        $in_headers = false;
392
-      }
393
-      // ok we need to break this line up into several smaller lines
394
-      while(strlen($line) > $max_line_length) {
395
-        $pos = strrpos(substr($line,0,$max_line_length)," ");
396
-
397
-        // Patch to fix DOS attack
398
-        if(!$pos) {
399
-          $pos = $max_line_length - 1;
400
-          $lines_out[] = substr($line,0,$pos);
401
-          $line = substr($line,$pos);
402
-        } else {
403
-          $lines_out[] = substr($line,0,$pos);
404
-          $line = substr($line,$pos + 1);
405
-        }
406
-
407
-        /* if we are processing headers we need to
380
+	$field = substr($lines[0],0,strpos($lines[0],":"));
381
+	$in_headers = false;
382
+	if(!empty($field) && !strstr($field," ")) {
383
+	  $in_headers = true;
384
+	}
385
+
386
+	$max_line_length = 998; // used below; set here for ease in change
387
+
388
+	while(list(,$line) = @each($lines)) {
389
+	  $lines_out = null;
390
+	  if($line == "" && $in_headers) {
391
+		$in_headers = false;
392
+	  }
393
+	  // ok we need to break this line up into several smaller lines
394
+	  while(strlen($line) > $max_line_length) {
395
+		$pos = strrpos(substr($line,0,$max_line_length)," ");
396
+
397
+		// Patch to fix DOS attack
398
+		if(!$pos) {
399
+		  $pos = $max_line_length - 1;
400
+		  $lines_out[] = substr($line,0,$pos);
401
+		  $line = substr($line,$pos);
402
+		} else {
403
+		  $lines_out[] = substr($line,0,$pos);
404
+		  $line = substr($line,$pos + 1);
405
+		}
406
+
407
+		/* if we are processing headers we need to
408 408
          * add a LWSP-char to the front of the new line
409 409
          * rfc 822 on long msg headers
410 410
          */
411
-        if($in_headers) {
412
-          $line = "\t" . $line;
413
-        }
414
-      }
415
-      $lines_out[] = $line;
416
-
417
-      // send the lines to the server
418
-      while(list(,$line_out) = @each($lines_out)) {
419
-        if(strlen($line_out) > 0)
420
-        {
421
-          if(substr($line_out, 0, 1) == ".") {
422
-            $line_out = "." . $line_out;
423
-          }
424
-        }
425
-        fputs($this->smtp_conn,$line_out . $this->CRLF);
426
-      }
427
-    }
428
-
429
-    // message data has been sent
430
-    fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
431
-
432
-    $rply = $this->get_lines();
433
-    $code = substr($rply,0,3);
434
-
435
-    if($this->do_debug >= 2) {
436
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
437
-    }
438
-
439
-    if($code != 250) {
440
-      $this->error =
441
-        array("error" => "DATA not accepted from server",
442
-              "smtp_code" => $code,
443
-              "smtp_msg" => substr($rply,4));
444
-      if($this->do_debug >= 1) {
445
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
446
-      }
447
-      return false;
448
-    }
449
-    return true;
411
+		if($in_headers) {
412
+		  $line = "\t" . $line;
413
+		}
414
+	  }
415
+	  $lines_out[] = $line;
416
+
417
+	  // send the lines to the server
418
+	  while(list(,$line_out) = @each($lines_out)) {
419
+		if(strlen($line_out) > 0)
420
+		{
421
+		  if(substr($line_out, 0, 1) == ".") {
422
+			$line_out = "." . $line_out;
423
+		  }
424
+		}
425
+		fputs($this->smtp_conn,$line_out . $this->CRLF);
426
+	  }
427
+	}
428
+
429
+	// message data has been sent
430
+	fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
431
+
432
+	$rply = $this->get_lines();
433
+	$code = substr($rply,0,3);
434
+
435
+	if($this->do_debug >= 2) {
436
+	  echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
437
+	}
438
+
439
+	if($code != 250) {
440
+	  $this->error =
441
+		array("error" => "DATA not accepted from server",
442
+			  "smtp_code" => $code,
443
+			  "smtp_msg" => substr($rply,4));
444
+	  if($this->do_debug >= 1) {
445
+		echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
446
+	  }
447
+	  return false;
448
+	}
449
+	return true;
450 450
   }
451 451
 
452 452
   /**
@@ -462,28 +462,28 @@  discard block
 block discarded – undo
462 462
    * @return bool
463 463
    */
464 464
   public function Hello($host = '') {
465
-    $this->error = null; // so no confusion is caused
466
-
467
-    if(!$this->connected()) {
468
-      $this->error = array(
469
-            "error" => "Called Hello() without being connected");
470
-      return false;
471
-    }
472
-
473
-    // if hostname for HELO was not specified send default
474
-    if(empty($host)) {
475
-      // determine appropriate default to send to server
476
-      $host = "localhost";
477
-    }
478
-
479
-    // Send extended hello first (RFC 2821)
480
-    if(!$this->SendHello("EHLO", $host)) {
481
-      if(!$this->SendHello("HELO", $host)) {
482
-          return false;
483
-    }
484
-    }
485
-
486
-    return true;
465
+	$this->error = null; // so no confusion is caused
466
+
467
+	if(!$this->connected()) {
468
+	  $this->error = array(
469
+			"error" => "Called Hello() without being connected");
470
+	  return false;
471
+	}
472
+
473
+	// if hostname for HELO was not specified send default
474
+	if(empty($host)) {
475
+	  // determine appropriate default to send to server
476
+	  $host = "localhost";
477
+	}
478
+
479
+	// Send extended hello first (RFC 2821)
480
+	if(!$this->SendHello("EHLO", $host)) {
481
+	  if(!$this->SendHello("HELO", $host)) {
482
+		  return false;
483
+	}
484
+	}
485
+
486
+	return true;
487 487
   }
488 488
 
489 489
   /**
@@ -492,29 +492,29 @@  discard block
 block discarded – undo
492 492
    * @return bool
493 493
    */
494 494
   private function SendHello($hello, $host) {
495
-    fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
495
+	fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
496 496
 
497
-    $rply = $this->get_lines();
498
-    $code = substr($rply,0,3);
497
+	$rply = $this->get_lines();
498
+	$code = substr($rply,0,3);
499 499
 
500
-    if($this->do_debug >= 2) {
501
-      echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />';
502
-    }
500
+	if($this->do_debug >= 2) {
501
+	  echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />';
502
+	}
503 503
 
504
-    if($code != 250) {
505
-      $this->error =
506
-        array("error" => $hello . " not accepted from server",
507
-              "smtp_code" => $code,
508
-              "smtp_msg" => substr($rply,4));
509
-      if($this->do_debug >= 1) {
510
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
511
-      }
512
-      return false;
513
-    }
504
+	if($code != 250) {
505
+	  $this->error =
506
+		array("error" => $hello . " not accepted from server",
507
+			  "smtp_code" => $code,
508
+			  "smtp_msg" => substr($rply,4));
509
+	  if($this->do_debug >= 1) {
510
+		echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
511
+	  }
512
+	  return false;
513
+	}
514 514
 
515
-    $this->helo_rply = $rply;
515
+	$this->helo_rply = $rply;
516 516
 
517
-    return true;
517
+	return true;
518 518
   }
519 519
 
520 520
   /**
@@ -532,35 +532,35 @@  discard block
 block discarded – undo
532 532
    * @return bool
533 533
    */
534 534
   public function Mail($from) {
535
-    $this->error = null; // so no confusion is caused
536
-
537
-    if(!$this->connected()) {
538
-      $this->error = array(
539
-              "error" => "Called Mail() without being connected");
540
-      return false;
541
-    }
542
-
543
-    $useVerp = ($this->do_verp ? "XVERP" : "");
544
-    fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
545
-
546
-    $rply = $this->get_lines();
547
-    $code = substr($rply,0,3);
548
-
549
-    if($this->do_debug >= 2) {
550
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
551
-    }
552
-
553
-    if($code != 250) {
554
-      $this->error =
555
-        array("error" => "MAIL not accepted from server",
556
-              "smtp_code" => $code,
557
-              "smtp_msg" => substr($rply,4));
558
-      if($this->do_debug >= 1) {
559
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
560
-      }
561
-      return false;
562
-    }
563
-    return true;
535
+	$this->error = null; // so no confusion is caused
536
+
537
+	if(!$this->connected()) {
538
+	  $this->error = array(
539
+			  "error" => "Called Mail() without being connected");
540
+	  return false;
541
+	}
542
+
543
+	$useVerp = ($this->do_verp ? "XVERP" : "");
544
+	fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
545
+
546
+	$rply = $this->get_lines();
547
+	$code = substr($rply,0,3);
548
+
549
+	if($this->do_debug >= 2) {
550
+	  echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
551
+	}
552
+
553
+	if($code != 250) {
554
+	  $this->error =
555
+		array("error" => "MAIL not accepted from server",
556
+			  "smtp_code" => $code,
557
+			  "smtp_msg" => substr($rply,4));
558
+	  if($this->do_debug >= 1) {
559
+		echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
560
+	  }
561
+	  return false;
562
+	}
563
+	return true;
564 564
   }
565 565
 
566 566
   /**
@@ -575,44 +575,44 @@  discard block
 block discarded – undo
575 575
    * @return bool
576 576
    */
577 577
   public function Quit($close_on_error=true) {
578
-    $this->error = null; // so there is no confusion
579
-
580
-    if(!$this->connected()) {
581
-      $this->error = array(
582
-              "error" => "Called Quit() without being connected");
583
-      return false;
584
-    }
585
-
586
-    // send the quit command to the server
587
-    fputs($this->smtp_conn,"quit" . $this->CRLF);
588
-
589
-    // get any good-bye messages
590
-    $byemsg = $this->get_lines();
591
-
592
-    if($this->do_debug >= 2) {
593
-      echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />';
594
-    }
595
-
596
-    $rval = true;
597
-    $e = null;
598
-
599
-    $code = substr($byemsg,0,3);
600
-    if($code != 221) {
601
-      // use e as a tmp var cause Close will overwrite $this->error
602
-      $e = array("error" => "SMTP server rejected quit command",
603
-                 "smtp_code" => $code,
604
-                 "smtp_rply" => substr($byemsg,4));
605
-      $rval = false;
606
-      if($this->do_debug >= 1) {
607
-        echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />';
608
-      }
609
-    }
610
-
611
-    if(empty($e) || $close_on_error) {
612
-      $this->Close();
613
-    }
614
-
615
-    return $rval;
578
+	$this->error = null; // so there is no confusion
579
+
580
+	if(!$this->connected()) {
581
+	  $this->error = array(
582
+			  "error" => "Called Quit() without being connected");
583
+	  return false;
584
+	}
585
+
586
+	// send the quit command to the server
587
+	fputs($this->smtp_conn,"quit" . $this->CRLF);
588
+
589
+	// get any good-bye messages
590
+	$byemsg = $this->get_lines();
591
+
592
+	if($this->do_debug >= 2) {
593
+	  echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />';
594
+	}
595
+
596
+	$rval = true;
597
+	$e = null;
598
+
599
+	$code = substr($byemsg,0,3);
600
+	if($code != 221) {
601
+	  // use e as a tmp var cause Close will overwrite $this->error
602
+	  $e = array("error" => "SMTP server rejected quit command",
603
+				 "smtp_code" => $code,
604
+				 "smtp_rply" => substr($byemsg,4));
605
+	  $rval = false;
606
+	  if($this->do_debug >= 1) {
607
+		echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />';
608
+	  }
609
+	}
610
+
611
+	if(empty($e) || $close_on_error) {
612
+	  $this->Close();
613
+	}
614
+
615
+	return $rval;
616 616
   }
617 617
 
618 618
   /**
@@ -628,34 +628,34 @@  discard block
 block discarded – undo
628 628
    * @return bool
629 629
    */
630 630
   public function Recipient($to) {
631
-    $this->error = null; // so no confusion is caused
632
-
633
-    if(!$this->connected()) {
634
-      $this->error = array(
635
-              "error" => "Called Recipient() without being connected");
636
-      return false;
637
-    }
638
-
639
-    fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
640
-
641
-    $rply = $this->get_lines();
642
-    $code = substr($rply,0,3);
643
-
644
-    if($this->do_debug >= 2) {
645
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
646
-    }
647
-
648
-    if($code != 250 && $code != 251) {
649
-      $this->error =
650
-        array("error" => "RCPT not accepted from server",
651
-              "smtp_code" => $code,
652
-              "smtp_msg" => substr($rply,4));
653
-      if($this->do_debug >= 1) {
654
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
655
-      }
656
-      return false;
657
-    }
658
-    return true;
631
+	$this->error = null; // so no confusion is caused
632
+
633
+	if(!$this->connected()) {
634
+	  $this->error = array(
635
+			  "error" => "Called Recipient() without being connected");
636
+	  return false;
637
+	}
638
+
639
+	fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
640
+
641
+	$rply = $this->get_lines();
642
+	$code = substr($rply,0,3);
643
+
644
+	if($this->do_debug >= 2) {
645
+	  echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
646
+	}
647
+
648
+	if($code != 250 && $code != 251) {
649
+	  $this->error =
650
+		array("error" => "RCPT not accepted from server",
651
+			  "smtp_code" => $code,
652
+			  "smtp_msg" => substr($rply,4));
653
+	  if($this->do_debug >= 1) {
654
+		echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
655
+	  }
656
+	  return false;
657
+	}
658
+	return true;
659 659
   }
660 660
 
661 661
   /**
@@ -671,35 +671,35 @@  discard block
 block discarded – undo
671 671
    * @return bool
672 672
    */
673 673
   public function Reset() {
674
-    $this->error = null; // so no confusion is caused
675
-
676
-    if(!$this->connected()) {
677
-      $this->error = array(
678
-              "error" => "Called Reset() without being connected");
679
-      return false;
680
-    }
681
-
682
-    fputs($this->smtp_conn,"RSET" . $this->CRLF);
683
-
684
-    $rply = $this->get_lines();
685
-    $code = substr($rply,0,3);
686
-
687
-    if($this->do_debug >= 2) {
688
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
689
-    }
690
-
691
-    if($code != 250) {
692
-      $this->error =
693
-        array("error" => "RSET failed",
694
-              "smtp_code" => $code,
695
-              "smtp_msg" => substr($rply,4));
696
-      if($this->do_debug >= 1) {
697
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
698
-      }
699
-      return false;
700
-    }
701
-
702
-    return true;
674
+	$this->error = null; // so no confusion is caused
675
+
676
+	if(!$this->connected()) {
677
+	  $this->error = array(
678
+			  "error" => "Called Reset() without being connected");
679
+	  return false;
680
+	}
681
+
682
+	fputs($this->smtp_conn,"RSET" . $this->CRLF);
683
+
684
+	$rply = $this->get_lines();
685
+	$code = substr($rply,0,3);
686
+
687
+	if($this->do_debug >= 2) {
688
+	  echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
689
+	}
690
+
691
+	if($code != 250) {
692
+	  $this->error =
693
+		array("error" => "RSET failed",
694
+			  "smtp_code" => $code,
695
+			  "smtp_msg" => substr($rply,4));
696
+	  if($this->do_debug >= 1) {
697
+		echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
698
+	  }
699
+	  return false;
700
+	}
701
+
702
+	return true;
703 703
   }
704 704
 
705 705
   /**
@@ -719,34 +719,34 @@  discard block
 block discarded – undo
719 719
    * @return bool
720 720
    */
721 721
   public function SendAndMail($from) {
722
-    $this->error = null; // so no confusion is caused
723
-
724
-    if(!$this->connected()) {
725
-      $this->error = array(
726
-          "error" => "Called SendAndMail() without being connected");
727
-      return false;
728
-    }
729
-
730
-    fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
731
-
732
-    $rply = $this->get_lines();
733
-    $code = substr($rply,0,3);
734
-
735
-    if($this->do_debug >= 2) {
736
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
737
-    }
738
-
739
-    if($code != 250) {
740
-      $this->error =
741
-        array("error" => "SAML not accepted from server",
742
-              "smtp_code" => $code,
743
-              "smtp_msg" => substr($rply,4));
744
-      if($this->do_debug >= 1) {
745
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
746
-      }
747
-      return false;
748
-    }
749
-    return true;
722
+	$this->error = null; // so no confusion is caused
723
+
724
+	if(!$this->connected()) {
725
+	  $this->error = array(
726
+		  "error" => "Called SendAndMail() without being connected");
727
+	  return false;
728
+	}
729
+
730
+	fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
731
+
732
+	$rply = $this->get_lines();
733
+	$code = substr($rply,0,3);
734
+
735
+	if($this->do_debug >= 2) {
736
+	  echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
737
+	}
738
+
739
+	if($code != 250) {
740
+	  $this->error =
741
+		array("error" => "SAML not accepted from server",
742
+			  "smtp_code" => $code,
743
+			  "smtp_msg" => substr($rply,4));
744
+	  if($this->do_debug >= 1) {
745
+		echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
746
+	  }
747
+	  return false;
748
+	}
749
+	return true;
750 750
   }
751 751
 
752 752
   /**
@@ -763,22 +763,22 @@  discard block
 block discarded – undo
763 763
    * @return bool
764 764
    */
765 765
   public function Turn() {
766
-    $this->error = array("error" => "This method, TURN, of the SMTP ".
767
-                                    "is not implemented");
768
-    if($this->do_debug >= 1) {
769
-      echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />';
770
-    }
771
-    return false;
766
+	$this->error = array("error" => "This method, TURN, of the SMTP ".
767
+									"is not implemented");
768
+	if($this->do_debug >= 1) {
769
+	  echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />';
770
+	}
771
+	return false;
772 772
   }
773 773
 
774 774
   /**
775
-  * Get the current error
775
+   * Get the current error
776 776
    * @access public
777
-  * @return array
777
+   * @return array
778 778
    */
779 779
   public function getError() {
780
-    return $this->error;
781
-    }
780
+	return $this->error;
781
+	}
782 782
 
783 783
   /////////////////////////////////////////////////
784 784
   // INTERNAL FUNCTIONS
@@ -794,20 +794,20 @@  discard block
 block discarded – undo
794 794
    * @return string
795 795
    */
796 796
   private function get_lines() {
797
-    $data = "";
798
-    while($str = @fgets($this->smtp_conn,515)) {
799
-      if($this->do_debug >= 4) {
800
-        echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />';
801
-        echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />';
802
-      }
803
-      $data .= $str;
804
-      if($this->do_debug >= 4) {
805
-        echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />';
806
-      }
807
-      // if 4th character is a space, we are done reading, break the loop
808
-      if(substr($str,3,1) == " ") { break; }
809
-    }
810
-    return $data;
797
+	$data = "";
798
+	while($str = @fgets($this->smtp_conn,515)) {
799
+	  if($this->do_debug >= 4) {
800
+		echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />';
801
+		echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />';
802
+	  }
803
+	  $data .= $str;
804
+	  if($this->do_debug >= 4) {
805
+		echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />';
806
+	  }
807
+	  // if 4th character is a space, we are done reading, break the loop
808
+	  if(substr($str,3,1) == " ") { break; }
809
+	}
810
+	return $data;
811 811
   }
812 812
 
813 813
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -143,8 +143,9 @@
 block discarded – undo
143 143
 
144 144
     // SMTP server can take longer to respond, give longer timeout for first read
145 145
     // Windows does not have support for this timeout function
146
-    if(substr(PHP_OS, 0, 3) != "WIN")
147
-     socket_set_timeout($this->smtp_conn, $tval, 0);
146
+    if(substr(PHP_OS, 0, 3) != "WIN") {
147
+         socket_set_timeout($this->smtp_conn, $tval, 0);
148
+    }
148 149
 
149 150
     // get any announcement
150 151
     $announce = $this->get_lines();
Please login to merge, or discard this patch.
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
    *  Sets whether debugging is turned on
64 64
    *  @var bool
65 65
    */
66
-  public $do_debug;       // the level of debug to perform
66
+  public $do_debug; // the level of debug to perform
67 67
 
68 68
   /**
69 69
    *  Sets VERP use on/off (default is off)
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
   // PROPERTIES, PRIVATE AND PROTECTED
76 76
   /////////////////////////////////////////////////
77 77
 
78
-  private $smtp_conn;      // the socket to the server
79
-  private $error;          // error if any on the last call
80
-  private $helo_rply;      // the reply the server sent to us for HELO
78
+  private $smtp_conn; // the socket to the server
79
+  private $error; // error if any on the last call
80
+  private $helo_rply; // the reply the server sent to us for HELO
81 81
 
82 82
   /**
83 83
    * Initialize the class so that the data is in a known state.
@@ -109,48 +109,48 @@  discard block
 block discarded – undo
109 109
    * @access public
110 110
    * @return bool
111 111
    */
112
-  public function Connect($host,$port=0,$tval=30) {
112
+  public function Connect($host, $port = 0, $tval = 30) {
113 113
     // set the error val to null so there is no confusion
114 114
     $this->error = null;
115 115
 
116 116
     // make sure we are __not__ connected
117
-    if($this->connected()) {
117
+    if ($this->connected()) {
118 118
       // already connected, generate error
119 119
       $this->error = array("error" => "Already connected to a server");
120 120
       return false;
121 121
     }
122 122
 
123
-    if(empty($port)) {
123
+    if (empty($port)) {
124 124
       $port = $this->SMTP_PORT;
125 125
     }
126 126
 
127 127
     // connect to the smtp server
128
-    $this->smtp_conn = @fsockopen($host,    // the host of the server
129
-                                 $port,    // the port to use
130
-                                 $errno,   // error number if any
131
-                                 $errstr,  // error message if any
132
-                                 $tval);   // give up after ? secs
128
+    $this->smtp_conn = @fsockopen($host, // the host of the server
129
+                                 $port, // the port to use
130
+                                 $errno, // error number if any
131
+                                 $errstr, // error message if any
132
+                                 $tval); // give up after ? secs
133 133
     // verify we connected properly
134
-    if(empty($this->smtp_conn)) {
134
+    if (empty($this->smtp_conn)) {
135 135
       $this->error = array("error" => "Failed to connect to server",
136 136
                            "errno" => $errno,
137 137
                            "errstr" => $errstr);
138
-      if($this->do_debug >= 1) {
139
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
138
+      if ($this->do_debug >= 1) {
139
+        echo "SMTP -> ERROR: ".$this->error["error"].": $errstr ($errno)".$this->CRLF.'<br />';
140 140
       }
141 141
       return false;
142 142
     }
143 143
 
144 144
     // SMTP server can take longer to respond, give longer timeout for first read
145 145
     // Windows does not have support for this timeout function
146
-    if(substr(PHP_OS, 0, 3) != "WIN")
146
+    if (substr(PHP_OS, 0, 3) != "WIN")
147 147
      socket_set_timeout($this->smtp_conn, $tval, 0);
148 148
 
149 149
     // get any announcement
150 150
     $announce = $this->get_lines();
151 151
 
152
-    if($this->do_debug >= 2) {
153
-      echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
152
+    if ($this->do_debug >= 2) {
153
+      echo "SMTP -> FROM SERVER:".$announce.$this->CRLF.'<br />';
154 154
     }
155 155
 
156 156
     return true;
@@ -168,33 +168,33 @@  discard block
 block discarded – undo
168 168
   public function StartTLS() {
169 169
     $this->error = null; # to avoid confusion
170 170
 
171
-    if(!$this->connected()) {
171
+    if (!$this->connected()) {
172 172
       $this->error = array("error" => "Called StartTLS() without being connected");
173 173
       return false;
174 174
     }
175 175
 
176
-    fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
176
+    fputs($this->smtp_conn, "STARTTLS".$this->CRLF);
177 177
 
178 178
     $rply = $this->get_lines();
179
-    $code = substr($rply,0,3);
179
+    $code = substr($rply, 0, 3);
180 180
 
181
-    if($this->do_debug >= 2) {
182
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
181
+    if ($this->do_debug >= 2) {
182
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
183 183
     }
184 184
 
185
-    if($code != 220) {
185
+    if ($code != 220) {
186 186
       $this->error =
187 187
          array("error"     => "STARTTLS not accepted from server",
188 188
                "smtp_code" => $code,
189
-               "smtp_msg"  => substr($rply,4));
190
-      if($this->do_debug >= 1) {
191
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
189
+               "smtp_msg"  => substr($rply, 4));
190
+      if ($this->do_debug >= 1) {
191
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
192 192
       }
193 193
       return false;
194 194
     }
195 195
 
196 196
     //Begin encrypted connection
197
-    if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
197
+    if (!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
198 198
       return false;
199 199
     }
200 200
 
@@ -209,52 +209,52 @@  discard block
 block discarded – undo
209 209
    */
210 210
   public function Authenticate($username, $password) {
211 211
     // Start authentication
212
-    fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
212
+    fputs($this->smtp_conn, "AUTH LOGIN".$this->CRLF);
213 213
 
214 214
     $rply = $this->get_lines();
215
-    $code = substr($rply,0,3);
215
+    $code = substr($rply, 0, 3);
216 216
 
217
-    if($code != 334) {
217
+    if ($code != 334) {
218 218
       $this->error =
219 219
         array("error" => "AUTH not accepted from server",
220 220
               "smtp_code" => $code,
221
-              "smtp_msg" => substr($rply,4));
222
-      if($this->do_debug >= 1) {
223
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
221
+              "smtp_msg" => substr($rply, 4));
222
+      if ($this->do_debug >= 1) {
223
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
224 224
       }
225 225
       return false;
226 226
     }
227 227
 
228 228
     // Send encoded username
229
-    fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
229
+    fputs($this->smtp_conn, base64_encode($username).$this->CRLF);
230 230
 
231 231
     $rply = $this->get_lines();
232
-    $code = substr($rply,0,3);
232
+    $code = substr($rply, 0, 3);
233 233
 
234
-    if($code != 334) {
234
+    if ($code != 334) {
235 235
       $this->error =
236 236
         array("error" => "Username not accepted from server",
237 237
               "smtp_code" => $code,
238
-              "smtp_msg" => substr($rply,4));
239
-      if($this->do_debug >= 1) {
240
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
238
+              "smtp_msg" => substr($rply, 4));
239
+      if ($this->do_debug >= 1) {
240
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
241 241
       }
242 242
       return false;
243 243
     }
244 244
 
245 245
     // Send encoded password
246
-    fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
246
+    fputs($this->smtp_conn, base64_encode($password).$this->CRLF);
247 247
 
248 248
     $rply = $this->get_lines();
249
-    $code = substr($rply,0,3);
249
+    $code = substr($rply, 0, 3);
250 250
 
251
-    if($code != 235) {
251
+    if ($code != 235) {
252 252
       $this->error =
253 253
         array("error" => "Password not accepted from server",
254 254
               "smtp_code" => $code,
255
-              "smtp_msg" => substr($rply,4));
256
-      if($this->do_debug >= 1) {
257
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
255
+              "smtp_msg" => substr($rply, 4));
256
+      if ($this->do_debug >= 1) {
257
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
258 258
       }
259 259
       return false;
260 260
     }
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
    * @return bool
269 269
    */
270 270
   public function Connected() {
271
-    if(!empty($this->smtp_conn)) {
271
+    if (!empty($this->smtp_conn)) {
272 272
       $sock_status = socket_get_status($this->smtp_conn);
273
-      if($sock_status["eof"]) {
273
+      if ($sock_status["eof"]) {
274 274
         // the socket is valid but we are not connected
275
-        if($this->do_debug >= 1) {
276
-            echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
275
+        if ($this->do_debug >= 1) {
276
+            echo "SMTP -> NOTICE:".$this->CRLF."EOF caught while checking if connected";
277 277
         }
278 278
         $this->Close();
279 279
         return false;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
   public function Close() {
294 294
     $this->error = null; // so there is no confusion
295 295
     $this->helo_rply = null;
296
-    if(!empty($this->smtp_conn)) {
296
+    if (!empty($this->smtp_conn)) {
297 297
       // close the connection and cleanup
298 298
       fclose($this->smtp_conn);
299 299
       $this->smtp_conn = 0;
@@ -326,28 +326,28 @@  discard block
 block discarded – undo
326 326
   public function Data($msg_data) {
327 327
     $this->error = null; // so no confusion is caused
328 328
 
329
-    if(!$this->connected()) {
329
+    if (!$this->connected()) {
330 330
       $this->error = array(
331 331
               "error" => "Called Data() without being connected");
332 332
       return false;
333 333
     }
334 334
 
335
-    fputs($this->smtp_conn,"DATA" . $this->CRLF);
335
+    fputs($this->smtp_conn, "DATA".$this->CRLF);
336 336
 
337 337
     $rply = $this->get_lines();
338
-    $code = substr($rply,0,3);
338
+    $code = substr($rply, 0, 3);
339 339
 
340
-    if($this->do_debug >= 2) {
341
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
340
+    if ($this->do_debug >= 2) {
341
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
342 342
     }
343 343
 
344
-    if($code != 354) {
344
+    if ($code != 354) {
345 345
       $this->error =
346 346
         array("error" => "DATA command not accepted from server",
347 347
               "smtp_code" => $code,
348
-              "smtp_msg" => substr($rply,4));
349
-      if($this->do_debug >= 1) {
350
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
348
+              "smtp_msg" => substr($rply, 4));
349
+      if ($this->do_debug >= 1) {
350
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
351 351
       }
352 352
       return false;
353 353
     }
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
      */
365 365
 
366 366
     // normalize the line breaks so we know the explode works
367
-    $msg_data = str_replace("\r\n","\n",$msg_data);
368
-    $msg_data = str_replace("\r","\n",$msg_data);
369
-    $lines = explode("\n",$msg_data);
367
+    $msg_data = str_replace("\r\n", "\n", $msg_data);
368
+    $msg_data = str_replace("\r", "\n", $msg_data);
369
+    $lines = explode("\n", $msg_data);
370 370
 
371 371
     /* we need to find a good way to determine is headers are
372 372
      * in the msg_data or if it is a straight msg body
@@ -377,72 +377,72 @@  discard block
 block discarded – undo
377 377
      * headers.
378 378
      */
379 379
 
380
-    $field = substr($lines[0],0,strpos($lines[0],":"));
380
+    $field = substr($lines[0], 0, strpos($lines[0], ":"));
381 381
     $in_headers = false;
382
-    if(!empty($field) && !strstr($field," ")) {
382
+    if (!empty($field) && !strstr($field, " ")) {
383 383
       $in_headers = true;
384 384
     }
385 385
 
386 386
     $max_line_length = 998; // used below; set here for ease in change
387 387
 
388
-    while(list(,$line) = @each($lines)) {
388
+    while (list(,$line) = @each($lines)) {
389 389
       $lines_out = null;
390
-      if($line == "" && $in_headers) {
390
+      if ($line == "" && $in_headers) {
391 391
         $in_headers = false;
392 392
       }
393 393
       // ok we need to break this line up into several smaller lines
394
-      while(strlen($line) > $max_line_length) {
395
-        $pos = strrpos(substr($line,0,$max_line_length)," ");
394
+      while (strlen($line) > $max_line_length) {
395
+        $pos = strrpos(substr($line, 0, $max_line_length), " ");
396 396
 
397 397
         // Patch to fix DOS attack
398
-        if(!$pos) {
398
+        if (!$pos) {
399 399
           $pos = $max_line_length - 1;
400
-          $lines_out[] = substr($line,0,$pos);
401
-          $line = substr($line,$pos);
400
+          $lines_out[] = substr($line, 0, $pos);
401
+          $line = substr($line, $pos);
402 402
         } else {
403
-          $lines_out[] = substr($line,0,$pos);
404
-          $line = substr($line,$pos + 1);
403
+          $lines_out[] = substr($line, 0, $pos);
404
+          $line = substr($line, $pos + 1);
405 405
         }
406 406
 
407 407
         /* if we are processing headers we need to
408 408
          * add a LWSP-char to the front of the new line
409 409
          * rfc 822 on long msg headers
410 410
          */
411
-        if($in_headers) {
412
-          $line = "\t" . $line;
411
+        if ($in_headers) {
412
+          $line = "\t".$line;
413 413
         }
414 414
       }
415 415
       $lines_out[] = $line;
416 416
 
417 417
       // send the lines to the server
418
-      while(list(,$line_out) = @each($lines_out)) {
419
-        if(strlen($line_out) > 0)
418
+      while (list(,$line_out) = @each($lines_out)) {
419
+        if (strlen($line_out) > 0)
420 420
         {
421
-          if(substr($line_out, 0, 1) == ".") {
422
-            $line_out = "." . $line_out;
421
+          if (substr($line_out, 0, 1) == ".") {
422
+            $line_out = ".".$line_out;
423 423
           }
424 424
         }
425
-        fputs($this->smtp_conn,$line_out . $this->CRLF);
425
+        fputs($this->smtp_conn, $line_out.$this->CRLF);
426 426
       }
427 427
     }
428 428
 
429 429
     // message data has been sent
430
-    fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
430
+    fputs($this->smtp_conn, $this->CRLF.".".$this->CRLF);
431 431
 
432 432
     $rply = $this->get_lines();
433
-    $code = substr($rply,0,3);
433
+    $code = substr($rply, 0, 3);
434 434
 
435
-    if($this->do_debug >= 2) {
436
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
435
+    if ($this->do_debug >= 2) {
436
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
437 437
     }
438 438
 
439
-    if($code != 250) {
439
+    if ($code != 250) {
440 440
       $this->error =
441 441
         array("error" => "DATA not accepted from server",
442 442
               "smtp_code" => $code,
443
-              "smtp_msg" => substr($rply,4));
444
-      if($this->do_debug >= 1) {
445
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
443
+              "smtp_msg" => substr($rply, 4));
444
+      if ($this->do_debug >= 1) {
445
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
446 446
       }
447 447
       return false;
448 448
     }
@@ -464,21 +464,21 @@  discard block
 block discarded – undo
464 464
   public function Hello($host = '') {
465 465
     $this->error = null; // so no confusion is caused
466 466
 
467
-    if(!$this->connected()) {
467
+    if (!$this->connected()) {
468 468
       $this->error = array(
469 469
             "error" => "Called Hello() without being connected");
470 470
       return false;
471 471
     }
472 472
 
473 473
     // if hostname for HELO was not specified send default
474
-    if(empty($host)) {
474
+    if (empty($host)) {
475 475
       // determine appropriate default to send to server
476 476
       $host = "localhost";
477 477
     }
478 478
 
479 479
     // Send extended hello first (RFC 2821)
480
-    if(!$this->SendHello("EHLO", $host)) {
481
-      if(!$this->SendHello("HELO", $host)) {
480
+    if (!$this->SendHello("EHLO", $host)) {
481
+      if (!$this->SendHello("HELO", $host)) {
482 482
           return false;
483 483
     }
484 484
     }
@@ -492,22 +492,22 @@  discard block
 block discarded – undo
492 492
    * @return bool
493 493
    */
494 494
   private function SendHello($hello, $host) {
495
-    fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
495
+    fputs($this->smtp_conn, $hello." ".$host.$this->CRLF);
496 496
 
497 497
     $rply = $this->get_lines();
498
-    $code = substr($rply,0,3);
498
+    $code = substr($rply, 0, 3);
499 499
 
500
-    if($this->do_debug >= 2) {
501
-      echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />';
500
+    if ($this->do_debug >= 2) {
501
+      echo "SMTP -> FROM SERVER: ".$rply.$this->CRLF.'<br />';
502 502
     }
503 503
 
504
-    if($code != 250) {
504
+    if ($code != 250) {
505 505
       $this->error =
506
-        array("error" => $hello . " not accepted from server",
506
+        array("error" => $hello." not accepted from server",
507 507
               "smtp_code" => $code,
508
-              "smtp_msg" => substr($rply,4));
509
-      if($this->do_debug >= 1) {
510
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
508
+              "smtp_msg" => substr($rply, 4));
509
+      if ($this->do_debug >= 1) {
510
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
511 511
       }
512 512
       return false;
513 513
     }
@@ -534,29 +534,29 @@  discard block
 block discarded – undo
534 534
   public function Mail($from) {
535 535
     $this->error = null; // so no confusion is caused
536 536
 
537
-    if(!$this->connected()) {
537
+    if (!$this->connected()) {
538 538
       $this->error = array(
539 539
               "error" => "Called Mail() without being connected");
540 540
       return false;
541 541
     }
542 542
 
543 543
     $useVerp = ($this->do_verp ? "XVERP" : "");
544
-    fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
544
+    fputs($this->smtp_conn, "MAIL FROM:<".$from.">".$useVerp.$this->CRLF);
545 545
 
546 546
     $rply = $this->get_lines();
547
-    $code = substr($rply,0,3);
547
+    $code = substr($rply, 0, 3);
548 548
 
549
-    if($this->do_debug >= 2) {
550
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
549
+    if ($this->do_debug >= 2) {
550
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
551 551
     }
552 552
 
553
-    if($code != 250) {
553
+    if ($code != 250) {
554 554
       $this->error =
555 555
         array("error" => "MAIL not accepted from server",
556 556
               "smtp_code" => $code,
557
-              "smtp_msg" => substr($rply,4));
558
-      if($this->do_debug >= 1) {
559
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
557
+              "smtp_msg" => substr($rply, 4));
558
+      if ($this->do_debug >= 1) {
559
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
560 560
       }
561 561
       return false;
562 562
     }
@@ -574,41 +574,41 @@  discard block
 block discarded – undo
574 574
    * @access public
575 575
    * @return bool
576 576
    */
577
-  public function Quit($close_on_error=true) {
577
+  public function Quit($close_on_error = true) {
578 578
     $this->error = null; // so there is no confusion
579 579
 
580
-    if(!$this->connected()) {
580
+    if (!$this->connected()) {
581 581
       $this->error = array(
582 582
               "error" => "Called Quit() without being connected");
583 583
       return false;
584 584
     }
585 585
 
586 586
     // send the quit command to the server
587
-    fputs($this->smtp_conn,"quit" . $this->CRLF);
587
+    fputs($this->smtp_conn, "quit".$this->CRLF);
588 588
 
589 589
     // get any good-bye messages
590 590
     $byemsg = $this->get_lines();
591 591
 
592
-    if($this->do_debug >= 2) {
593
-      echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />';
592
+    if ($this->do_debug >= 2) {
593
+      echo "SMTP -> FROM SERVER:".$byemsg.$this->CRLF.'<br />';
594 594
     }
595 595
 
596 596
     $rval = true;
597 597
     $e = null;
598 598
 
599
-    $code = substr($byemsg,0,3);
600
-    if($code != 221) {
599
+    $code = substr($byemsg, 0, 3);
600
+    if ($code != 221) {
601 601
       // use e as a tmp var cause Close will overwrite $this->error
602 602
       $e = array("error" => "SMTP server rejected quit command",
603 603
                  "smtp_code" => $code,
604
-                 "smtp_rply" => substr($byemsg,4));
604
+                 "smtp_rply" => substr($byemsg, 4));
605 605
       $rval = false;
606
-      if($this->do_debug >= 1) {
607
-        echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />';
606
+      if ($this->do_debug >= 1) {
607
+        echo "SMTP -> ERROR: ".$e["error"].": ".$byemsg.$this->CRLF.'<br />';
608 608
       }
609 609
     }
610 610
 
611
-    if(empty($e) || $close_on_error) {
611
+    if (empty($e) || $close_on_error) {
612 612
       $this->Close();
613 613
     }
614 614
 
@@ -630,28 +630,28 @@  discard block
 block discarded – undo
630 630
   public function Recipient($to) {
631 631
     $this->error = null; // so no confusion is caused
632 632
 
633
-    if(!$this->connected()) {
633
+    if (!$this->connected()) {
634 634
       $this->error = array(
635 635
               "error" => "Called Recipient() without being connected");
636 636
       return false;
637 637
     }
638 638
 
639
-    fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
639
+    fputs($this->smtp_conn, "RCPT TO:<".$to.">".$this->CRLF);
640 640
 
641 641
     $rply = $this->get_lines();
642
-    $code = substr($rply,0,3);
642
+    $code = substr($rply, 0, 3);
643 643
 
644
-    if($this->do_debug >= 2) {
645
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
644
+    if ($this->do_debug >= 2) {
645
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
646 646
     }
647 647
 
648
-    if($code != 250 && $code != 251) {
648
+    if ($code != 250 && $code != 251) {
649 649
       $this->error =
650 650
         array("error" => "RCPT not accepted from server",
651 651
               "smtp_code" => $code,
652
-              "smtp_msg" => substr($rply,4));
653
-      if($this->do_debug >= 1) {
654
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
652
+              "smtp_msg" => substr($rply, 4));
653
+      if ($this->do_debug >= 1) {
654
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
655 655
       }
656 656
       return false;
657 657
     }
@@ -673,28 +673,28 @@  discard block
 block discarded – undo
673 673
   public function Reset() {
674 674
     $this->error = null; // so no confusion is caused
675 675
 
676
-    if(!$this->connected()) {
676
+    if (!$this->connected()) {
677 677
       $this->error = array(
678 678
               "error" => "Called Reset() without being connected");
679 679
       return false;
680 680
     }
681 681
 
682
-    fputs($this->smtp_conn,"RSET" . $this->CRLF);
682
+    fputs($this->smtp_conn, "RSET".$this->CRLF);
683 683
 
684 684
     $rply = $this->get_lines();
685
-    $code = substr($rply,0,3);
685
+    $code = substr($rply, 0, 3);
686 686
 
687
-    if($this->do_debug >= 2) {
688
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
687
+    if ($this->do_debug >= 2) {
688
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
689 689
     }
690 690
 
691
-    if($code != 250) {
691
+    if ($code != 250) {
692 692
       $this->error =
693 693
         array("error" => "RSET failed",
694 694
               "smtp_code" => $code,
695
-              "smtp_msg" => substr($rply,4));
696
-      if($this->do_debug >= 1) {
697
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
695
+              "smtp_msg" => substr($rply, 4));
696
+      if ($this->do_debug >= 1) {
697
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
698 698
       }
699 699
       return false;
700 700
     }
@@ -721,28 +721,28 @@  discard block
 block discarded – undo
721 721
   public function SendAndMail($from) {
722 722
     $this->error = null; // so no confusion is caused
723 723
 
724
-    if(!$this->connected()) {
724
+    if (!$this->connected()) {
725 725
       $this->error = array(
726 726
           "error" => "Called SendAndMail() without being connected");
727 727
       return false;
728 728
     }
729 729
 
730
-    fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
730
+    fputs($this->smtp_conn, "SAML FROM:".$from.$this->CRLF);
731 731
 
732 732
     $rply = $this->get_lines();
733
-    $code = substr($rply,0,3);
733
+    $code = substr($rply, 0, 3);
734 734
 
735
-    if($this->do_debug >= 2) {
736
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
735
+    if ($this->do_debug >= 2) {
736
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
737 737
     }
738 738
 
739
-    if($code != 250) {
739
+    if ($code != 250) {
740 740
       $this->error =
741 741
         array("error" => "SAML not accepted from server",
742 742
               "smtp_code" => $code,
743
-              "smtp_msg" => substr($rply,4));
744
-      if($this->do_debug >= 1) {
745
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
743
+              "smtp_msg" => substr($rply, 4));
744
+      if ($this->do_debug >= 1) {
745
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
746 746
       }
747 747
       return false;
748 748
     }
@@ -765,8 +765,8 @@  discard block
 block discarded – undo
765 765
   public function Turn() {
766 766
     $this->error = array("error" => "This method, TURN, of the SMTP ".
767 767
                                     "is not implemented");
768
-    if($this->do_debug >= 1) {
769
-      echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />';
768
+    if ($this->do_debug >= 1) {
769
+      echo "SMTP -> NOTICE: ".$this->error["error"].$this->CRLF.'<br />';
770 770
     }
771 771
     return false;
772 772
   }
@@ -795,17 +795,17 @@  discard block
 block discarded – undo
795 795
    */
796 796
   private function get_lines() {
797 797
     $data = "";
798
-    while($str = @fgets($this->smtp_conn,515)) {
799
-      if($this->do_debug >= 4) {
800
-        echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />';
801
-        echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />';
798
+    while ($str = @fgets($this->smtp_conn, 515)) {
799
+      if ($this->do_debug >= 4) {
800
+        echo "SMTP -> get_lines(): \$data was \"$data\"".$this->CRLF.'<br />';
801
+        echo "SMTP -> get_lines(): \$str is \"$str\"".$this->CRLF.'<br />';
802 802
       }
803 803
       $data .= $str;
804
-      if($this->do_debug >= 4) {
805
-        echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />';
804
+      if ($this->do_debug >= 4) {
805
+        echo "SMTP -> get_lines(): \$data is \"$data\"".$this->CRLF.'<br />';
806 806
       }
807 807
       // if 4th character is a space, we are done reading, break the loop
808
-      if(substr($str,3,1) == " ") { break; }
808
+      if (substr($str, 3, 1) == " ") { break; }
809 809
     }
810 810
     return $data;
811 811
   }
Please login to merge, or discard this patch.
libs/tar.class.php 4 patches
Doc Comments   +24 added lines patch added patch discarded remove patch
@@ -84,6 +84,10 @@  discard block
 block discarded – undo
84 84
     // Computes the unsigned Checksum of a file's header
85 85
     // to try to ensure valid file
86 86
     // PRIVATE ACCESS FUNCTION
87
+
88
+    /**
89
+     * @param string $bytestring
90
+     */
87 91
     function __computeUnsignedChecksum($bytestring) {
88 92
         for($i=0; $i<512; $i++)
89 93
             $unsigned_chksum += ord($bytestring[$i]);
@@ -97,6 +101,10 @@  discard block
 block discarded – undo
97 101
 
98 102
     // Converts a NULL padded string to a non-NULL padded string
99 103
     // PRIVATE ACCESS FUNCTION
104
+
105
+    /**
106
+     * @param string $string
107
+     */
100 108
     function __parseNullPaddedString($string) {
101 109
         $position = strpos($string,chr(0));
102 110
 		if(!$position)
@@ -357,6 +365,10 @@  discard block
 block discarded – undo
357 365
 
358 366
 
359 367
     // Open a TAR file
368
+
369
+    /**
370
+     * @param string $filename
371
+     */
360 372
     function openTAR($filename) {
361 373
         // Clear any values from previous tar archives
362 374
         unset($this->filename);
@@ -393,6 +405,10 @@  discard block
 block discarded – undo
393 405
 
394 406
 
395 407
     // Retrieves information about a file in the current tar archive
408
+
409
+    /**
410
+     * @param string $filename
411
+     */
396 412
     function getFile($filename) {
397 413
         if($this->numFiles > 0) {
398 414
             foreach($this->files as $key => $information) {
@@ -467,6 +483,10 @@  discard block
 block discarded – undo
467 483
 
468 484
 
469 485
     // Add a file to the tar archive
486
+
487
+    /**
488
+     * @param string $filename
489
+     */
470 490
     function addFile($filename,$from=null,$to=null) {
471 491
         // Make sure the file we are adding exists!
472 492
         if(!file_exists($filename))
@@ -555,6 +575,10 @@  discard block
 block discarded – undo
555 575
 
556 576
 
557 577
     // Saves tar archive to a different file than the current file
578
+
579
+    /**
580
+     * @param boolean $useGzip
581
+     */
558 582
     function toTar($filename,$useGzip) {
559 583
         if(!$filename)
560 584
             return false;
Please login to merge, or discard this patch.
Indentation   +431 added lines, -431 removed lines patch added patch discarded remove patch
@@ -63,99 +63,99 @@  discard block
 block discarded – undo
63 63
 */
64 64
 
65 65
 class tar {
66
-    // Unprocessed Archive Information
67
-    var $filename;
68
-    var $isGzipped;
69
-    var $tar_file;
70
-
71
-    // Processed Archive Information
72
-    var $files;
73
-    var $directories;
74
-    var $numFiles;
75
-    var $numDirectories;
76
-
77
-
78
-    // Class Constructor -- Does nothing...
79
-    function tar() {
80
-        return true;
81
-    }
82
-
83
-
84
-    // Computes the unsigned Checksum of a file's header
85
-    // to try to ensure valid file
86
-    // PRIVATE ACCESS FUNCTION
87
-    function __computeUnsignedChecksum($bytestring) {
88
-        for($i=0; $i<512; $i++)
89
-            $unsigned_chksum += ord($bytestring[$i]);
90
-        for($i=0; $i<8; $i++)
91
-            $unsigned_chksum -= ord($bytestring[148 + $i]);
92
-        $unsigned_chksum += ord(" ") * 8;
93
-
94
-        return $unsigned_chksum;
95
-    }
96
-
97
-
98
-    // Converts a NULL padded string to a non-NULL padded string
99
-    // PRIVATE ACCESS FUNCTION
100
-    function __parseNullPaddedString($string) {
101
-        $position = strpos($string,chr(0));
66
+	// Unprocessed Archive Information
67
+	var $filename;
68
+	var $isGzipped;
69
+	var $tar_file;
70
+
71
+	// Processed Archive Information
72
+	var $files;
73
+	var $directories;
74
+	var $numFiles;
75
+	var $numDirectories;
76
+
77
+
78
+	// Class Constructor -- Does nothing...
79
+	function tar() {
80
+		return true;
81
+	}
82
+
83
+
84
+	// Computes the unsigned Checksum of a file's header
85
+	// to try to ensure valid file
86
+	// PRIVATE ACCESS FUNCTION
87
+	function __computeUnsignedChecksum($bytestring) {
88
+		for($i=0; $i<512; $i++)
89
+			$unsigned_chksum += ord($bytestring[$i]);
90
+		for($i=0; $i<8; $i++)
91
+			$unsigned_chksum -= ord($bytestring[148 + $i]);
92
+		$unsigned_chksum += ord(" ") * 8;
93
+
94
+		return $unsigned_chksum;
95
+	}
96
+
97
+
98
+	// Converts a NULL padded string to a non-NULL padded string
99
+	// PRIVATE ACCESS FUNCTION
100
+	function __parseNullPaddedString($string) {
101
+		$position = strpos($string,chr(0));
102 102
 		if(!$position)
103 103
 		{
104 104
 			$position = strlen($string);
105 105
 		}
106
-        return substr($string,0,$position);
107
-    }
106
+		return substr($string,0,$position);
107
+	}
108 108
 
109 109
 
110
-    // This function parses the current TAR file
111
-    // PRIVATE ACCESS FUNCTION
112
-    function __parseTar() {
113
-        // Read Files from archive
114
-        $tar_length = strlen($this->tar_file);
115
-        $main_offset = 0;
110
+	// This function parses the current TAR file
111
+	// PRIVATE ACCESS FUNCTION
112
+	function __parseTar() {
113
+		// Read Files from archive
114
+		$tar_length = strlen($this->tar_file);
115
+		$main_offset = 0;
116 116
 		$flag_longlink = false;
117
-        while($main_offset < $tar_length) {
118
-            // If we read a block of 512 nulls, we are at the end of the archive
119
-            if(substr($this->tar_file,$main_offset,512) == str_repeat(chr(0),512))
120
-                break;
117
+		while($main_offset < $tar_length) {
118
+			// If we read a block of 512 nulls, we are at the end of the archive
119
+			if(substr($this->tar_file,$main_offset,512) == str_repeat(chr(0),512))
120
+				break;
121 121
 
122
-            // Parse file name
123
-            $file_name      = $this->__parseNullPaddedString(substr($this->tar_file,$main_offset,100));
122
+			// Parse file name
123
+			$file_name      = $this->__parseNullPaddedString(substr($this->tar_file,$main_offset,100));
124 124
 
125
-            // Parse the file mode
126
-            $file_mode      = substr($this->tar_file,$main_offset + 100,8);
125
+			// Parse the file mode
126
+			$file_mode      = substr($this->tar_file,$main_offset + 100,8);
127 127
 
128
-            // Parse the file user ID
129
-            $file_uid       = octdec(substr($this->tar_file,$main_offset + 108,8));
128
+			// Parse the file user ID
129
+			$file_uid       = octdec(substr($this->tar_file,$main_offset + 108,8));
130 130
 
131
-            // Parse the file group ID
132
-            $file_gid       = octdec(substr($this->tar_file,$main_offset + 116,8));
131
+			// Parse the file group ID
132
+			$file_gid       = octdec(substr($this->tar_file,$main_offset + 116,8));
133 133
 
134
-            // Parse the file size
135
-            $file_size      = octdec(substr($this->tar_file,$main_offset + 124,12));
134
+			// Parse the file size
135
+			$file_size      = octdec(substr($this->tar_file,$main_offset + 124,12));
136 136
 
137
-            // Parse the file update time - unix timestamp format
138
-            $file_time      = octdec(substr($this->tar_file,$main_offset + 136,12));
137
+			// Parse the file update time - unix timestamp format
138
+			$file_time      = octdec(substr($this->tar_file,$main_offset + 136,12));
139 139
 
140
-            // Parse Checksum
141
-            $file_chksum        = octdec(substr($this->tar_file,$main_offset + 148,6));
140
+			// Parse Checksum
141
+			$file_chksum        = octdec(substr($this->tar_file,$main_offset + 148,6));
142 142
 
143
-            // Parse user name
144
-            $file_uname     = $this->__parseNullPaddedString(substr($this->tar_file,$main_offset + 265,32));
143
+			// Parse user name
144
+			$file_uname     = $this->__parseNullPaddedString(substr($this->tar_file,$main_offset + 265,32));
145 145
 
146
-            // Parse Group name
147
-            $file_gname     = $this->__parseNullPaddedString(substr($this->tar_file,$main_offset + 297,32));
146
+			// Parse Group name
147
+			$file_gname     = $this->__parseNullPaddedString(substr($this->tar_file,$main_offset + 297,32));
148 148
 
149
-            $file_type = substr($this->tar_file,$main_offset + 156,1);
149
+			$file_type = substr($this->tar_file,$main_offset + 156,1);
150 150
 
151
-            // Make sure our file is valid
152
-            if($this->__computeUnsignedChecksum(substr($this->tar_file,$main_offset,512)) != $file_chksum)
153
-                return false;
151
+			// Make sure our file is valid
152
+			if($this->__computeUnsignedChecksum(substr($this->tar_file,$main_offset,512)) != $file_chksum)
153
+				return false;
154 154
 
155
-            // Parse File Contents
156
-            $file_contents      = substr($this->tar_file,$main_offset + 512,$file_size);
155
+			// Parse File Contents
156
+			$file_contents      = substr($this->tar_file,$main_offset + 512,$file_size);
157 157
 
158
-            /*  ### Unused Header Information ###
158
+			/*  ### Unused Header Information ###
159 159
                 $activeFile["typeflag"]     = substr($this->tar_file,$main_offset + 156,1);
160 160
                 $activeFile["linkname"]     = substr($this->tar_file,$main_offset + 157,100);
161 161
                 $activeFile["magic"]        = substr($this->tar_file,$main_offset + 257,6);
@@ -228,363 +228,363 @@  discard block
 block discarded – undo
228 228
 				$flag_longlink = false;
229 229
 			}
230 230
 
231
-            // Move our offset the number of blocks we have processed
232
-            $main_offset += 512 + (ceil($file_size / 512) * 512);
233
-        }
234
-
235
-        return true;
236
-    }
237
-
238
-
239
-    // Read a non gzipped tar file in for processing
240
-    // PRIVATE ACCESS FUNCTION
241
-    function __readTar($filename='') {
242
-        // Set the filename to load
243
-        if(!$filename)
244
-            $filename = $this->filename;
245
-
246
-        // Read in the TAR file
247
-        $fp = fopen($filename,"rb");
248
-        $this->tar_file = fread($fp,filesize($filename));
249
-        fclose($fp);
250
-
251
-        if($this->tar_file[0] == chr(31) && $this->tar_file[1] == chr(139) && $this->tar_file[2] == chr(8)) {
252
-            if(!function_exists("gzinflate"))
253
-                return false;
254
-
255
-            $this->isGzipped = TRUE;
256
-
257
-            $this->tar_file = gzinflate(substr($this->tar_file,10,-4));
258
-        }
259
-
260
-        // Parse the TAR file
261
-        $this->__parseTar();
262
-
263
-        return true;
264
-    }
265
-
266
-
267
-    // Generates a TAR file from the processed data
268
-    // PRIVATE ACCESS FUNCTION
269
-    function __generateTAR() {
270
-        // Clear any data currently in $this->tar_file
271
-        unset($this->tar_file);
272
-
273
-        // Generate Records for each directory, if we have directories
274
-        if($this->numDirectories > 0) {
275
-            foreach($this->directories as $key => $information) {
276
-                unset($header);
277
-
278
-                // Generate tar header for this directory
279
-                // Filename, Permissions, UID, GID, size, Time, checksum, typeflag, linkname, magic, version, user name, group name, devmajor, devminor, prefix, end
280
-                $header .= str_pad($information["name"],100,chr(0));
281
-                $header .= str_pad(decoct($information["mode"]),7,"0",STR_PAD_LEFT) . chr(0);
282
-                $header .= str_pad(decoct($information["user_id"]),7,"0",STR_PAD_LEFT) . chr(0);
283
-                $header .= str_pad(decoct($information["group_id"]),7,"0",STR_PAD_LEFT) . chr(0);
284
-                $header .= str_pad(decoct(0),11,"0",STR_PAD_LEFT) . chr(0);
285
-                $header .= str_pad(decoct($information["time"]),11,"0",STR_PAD_LEFT) . chr(0);
286
-                $header .= str_repeat(" ",8);
287
-                $header .= "5";
288
-                $header .= str_repeat(chr(0),100);
289
-                $header .= str_pad("ustar",6,chr(32));
290
-                $header .= chr(32) . chr(0);
291
-                $header .= str_pad("",32,chr(0));
292
-                $header .= str_pad("",32,chr(0));
293
-                $header .= str_repeat(chr(0),8);
294
-                $header .= str_repeat(chr(0),8);
295
-                $header .= str_repeat(chr(0),155);
296
-                $header .= str_repeat(chr(0),12);
297
-
298
-                // Compute header checksum
299
-                $checksum = str_pad(decoct($this->__computeUnsignedChecksum($header)),6,"0",STR_PAD_LEFT);
300
-                for($i=0; $i<6; $i++) {
301
-                    $header[(148 + $i)] = substr($checksum,$i,1);
302
-                }
303
-                $header[154] = chr(0);
304
-                $header[155] = chr(32);
305
-
306
-                // Add new tar formatted data to tar file contents
307
-                $this->tar_file .= $header;
308
-            }
309
-        }
310
-
311
-        // Generate Records for each file, if we have files (We should...)
312
-        if($this->numFiles > 0) {
313
-            foreach($this->files as $key => $information) {
314
-                unset($header);
315
-
316
-                // Generate the TAR header for this file
317
-                // Filename, Permissions, UID, GID, size, Time, checksum, typeflag, linkname, magic, version, user name, group name, devmajor, devminor, prefix, end
318
-                $header .= str_pad($information["name"],100,chr(0));
319
-                $header .= str_pad(decoct($information["mode"]),7,"0",STR_PAD_LEFT) . chr(0);
320
-                $header .= str_pad(decoct($information["user_id"]),7,"0",STR_PAD_LEFT) . chr(0);
321
-                $header .= str_pad(decoct($information["group_id"]),7,"0",STR_PAD_LEFT) . chr(0);
322
-                $header .= str_pad(decoct($information["size"]),11,"0",STR_PAD_LEFT) . chr(0);
323
-                $header .= str_pad(decoct($information["time"]),11,"0",STR_PAD_LEFT) . chr(0);
324
-                $header .= str_repeat(" ",8);
325
-                $header .= "0";
326
-                $header .= str_repeat(chr(0),100);
327
-                $header .= str_pad("ustar",6,chr(32));
328
-                $header .= chr(32) . chr(0);
329
-                $header .= str_pad($information["user_name"],32,chr(0));    // How do I get a file's user name from PHP?
330
-                $header .= str_pad($information["group_name"],32,chr(0));   // How do I get a file's group name from PHP?
331
-                $header .= str_repeat(chr(0),8);
332
-                $header .= str_repeat(chr(0),8);
333
-                $header .= str_repeat(chr(0),155);
334
-                $header .= str_repeat(chr(0),12);
335
-
336
-                // Compute header checksum
337
-                $checksum = str_pad(decoct($this->__computeUnsignedChecksum($header)),6,"0",STR_PAD_LEFT);
338
-                for($i=0; $i<6; $i++) {
339
-                    $header[(148 + $i)] = substr($checksum,$i,1);
340
-                }
341
-                $header[154] = chr(0);
342
-                $header[155] = chr(32);
343
-
344
-                // Pad file contents to byte count divisible by 512
345
-                $file_contents = str_pad($information["file"],(ceil($information["size"] / 512) * 512),chr(0));
346
-
347
-                // Add new tar formatted data to tar file contents
348
-                $this->tar_file .= $header . $file_contents;
349
-            }
350
-        }
351
-
352
-        // Add 512 bytes of NULLs to designate EOF
353
-        $this->tar_file .= str_repeat(chr(0),512);
354
-
355
-        return true;
356
-    }
357
-
358
-
359
-    // Open a TAR file
360
-    function openTAR($filename) {
361
-        // Clear any values from previous tar archives
362
-        unset($this->filename);
363
-        unset($this->isGzipped);
364
-        unset($this->tar_file);
365
-        unset($this->files);
366
-        unset($this->directories);
367
-        unset($this->numFiles);
368
-        unset($this->numDirectories);
369
-
370
-        // If the tar file doesn't exist...
371
-        if(!file_exists($filename))
372
-            return false;
373
-
374
-        $this->filename = $filename;
375
-
376
-        // Parse this file
377
-        $this->__readTar();
378
-
379
-        return true;
380
-    }
381
-
382
-
383
-    // Appends a tar file to the end of the currently opened tar file
384
-    function appendTar($filename) {
385
-        // If the tar file doesn't exist...
386
-        if(!file_exists($filename))
387
-            return false;
388
-
389
-        $this->__readTar($filename);
390
-
391
-        return true;
392
-    }
393
-
394
-
395
-    // Retrieves information about a file in the current tar archive
396
-    function getFile($filename) {
397
-        if($this->numFiles > 0) {
398
-            foreach($this->files as $key => $information) {
399
-                if($information["name"] == $filename)
400
-                    return $information;
401
-            }
402
-        }
403
-
404
-        return false;
405
-    }
406
-
407
-
408
-    // Retrieves information about a directory in the current tar archive
409
-    function getDirectory($dirname) {
410
-        if($this->numDirectories > 0) {
411
-            foreach($this->directories as $key => $information) {
412
-                if($information["name"] == $dirname)
413
-                    return $information;
414
-            }
415
-        }
416
-
417
-        return false;
418
-    }
419
-
420
-
421
-    // Check if this tar archive contains a specific file
422
-    function containsFile($filename) {
423
-        if($this->numFiles > 0) {
424
-            foreach($this->files as $key => $information) {
425
-                if($information["name"] == $filename)
426
-                    return true;
427
-            }
428
-        }
429
-
430
-        return false;
431
-    }
432
-
433
-
434
-    // Check if this tar archive contains a specific directory
435
-    function containsDirectory($dirname) {
436
-        if($this->numDirectories > 0) {
437
-            foreach($this->directories as $key => $information) {
438
-                if($information["name"] == $dirname)
439
-                    return true;
440
-            }
441
-        }
442
-
443
-        return false;
444
-    }
445
-
446
-
447
-    // Add a directory to this tar archive
448
-    function addDirectory($dirname) {
449
-        if(!file_exists($dirname))
450
-            return false;
451
-
452
-        // Get directory information
453
-        $file_information = stat($dirname);
454
-
455
-        // Add directory to processed data
456
-        $this->numDirectories++;
457
-        $activeDir      = &$this->directories[];
458
-        $activeDir["name"]  = $dirname;
459
-        $activeDir["mode"]  = $file_information["mode"];
460
-        $activeDir["time"]  = $file_information["time"];
461
-        $activeDir["user_id"]   = $file_information["uid"];
462
-        $activeDir["group_id"]  = $file_information["gid"];
463
-        $activeDir["checksum"]  = $checksum;
464
-
465
-        return true;
466
-    }
467
-
468
-
469
-    // Add a file to the tar archive
470
-    function addFile($filename,$from=null,$to=null) {
471
-        // Make sure the file we are adding exists!
472
-        if(!file_exists($filename))
473
-            return false;
474
-
475
-        if(filesize($filename)==0)
476
-            return false;
477
-
478
-        // Make sure there are no other files in the archive that have this same filename
479
-        if($this->containsFile($filename))
480
-            return false;
481
-
482
-        // Get file information
483
-        $file_information = stat($filename);
484
-
485
-        // Read in the file's contents
486
-        $fp = fopen($filename,"rb");
487
-        $file_contents = fread($fp,filesize($filename));
488
-        fclose($fp);
489
-
490
-        if($from && $to){
491
-            $file_contents = str_replace($from,$to,$file_contents);
492
-            $file_information["size"] = strlen($file_contents);
493
-        }
494
-
495
-        // Add file to processed data
496
-        $this->numFiles++;
497
-        $activeFile         = &$this->files[];
498
-        $activeFile["name"]     = $filename;
499
-        $activeFile["mode"]     = $file_information["mode"];
500
-        $activeFile["user_id"]      = $file_information["uid"];
501
-        $activeFile["group_id"]     = $file_information["gid"];
502
-        $activeFile["size"]     = $file_information["size"];
503
-        $activeFile["time"]     = $file_information["mtime"];
504
-        $activeFile["checksum"]     = $checksum;
505
-        $activeFile["user_name"]    = "";
506
-        $activeFile["group_name"]   = "";
507
-        $activeFile["file"]     = $file_contents;
508
-
509
-        return true;
510
-    }
511
-
512
-
513
-    // Remove a file from the tar archive
514
-    function removeFile($filename) {
515
-        if($this->numFiles > 0) {
516
-            foreach($this->files as $key => $information) {
517
-                if($information["name"] == $filename) {
518
-                    $this->numFiles--;
519
-                    unset($this->files[$key]);
520
-                    return true;
521
-                }
522
-            }
523
-        }
524
-
525
-        return false;
526
-    }
527
-
528
-
529
-    // Remove a directory from the tar archive
530
-    function removeDirectory($dirname) {
531
-        if($this->numDirectories > 0) {
532
-            foreach($this->directories as $key => $information) {
533
-                if($information["name"] == $dirname) {
534
-                    $this->numDirectories--;
535
-                    unset($this->directories[$key]);
536
-                    return true;
537
-                }
538
-            }
539
-        }
540
-
541
-        return false;
542
-    }
543
-
544
-
545
-    // Write the currently loaded tar archive to disk
546
-    function saveTar() {
547
-        if(!$this->filename)
548
-            return false;
549
-
550
-        // Write tar to current file using specified gzip compression
551
-        $this->toTar($this->filename,$this->isGzipped);
552
-
553
-        return true;
554
-    }
555
-
556
-
557
-    // Saves tar archive to a different file than the current file
558
-    function toTar($filename,$useGzip) {
559
-        if(!$filename)
560
-            return false;
561
-
562
-        // Encode processed files into TAR file format
563
-        $this->__generateTar();
564
-
565
-        // GZ Compress the data if we need to
566
-        if($useGzip) {
567
-            // Make sure we have gzip support
568
-            if(!function_exists("gzencode"))
569
-                return false;
570
-
571
-            $file = gzencode($this->tar_file);
572
-        } else {
573
-            $file = $this->tar_file;
574
-        }
575
-
576
-        // Write the TAR file
577
-        $fp = fopen($filename,"wb");
578
-        fwrite($fp,$file);
579
-        fclose($fp);
580
-
581
-        return true;
582
-    }
583
-
584
-
585
-    function toTarStream() {
586
-        $this->__generateTar();
587
-        return $this->tar_file;
588
-    }
231
+			// Move our offset the number of blocks we have processed
232
+			$main_offset += 512 + (ceil($file_size / 512) * 512);
233
+		}
234
+
235
+		return true;
236
+	}
237
+
238
+
239
+	// Read a non gzipped tar file in for processing
240
+	// PRIVATE ACCESS FUNCTION
241
+	function __readTar($filename='') {
242
+		// Set the filename to load
243
+		if(!$filename)
244
+			$filename = $this->filename;
245
+
246
+		// Read in the TAR file
247
+		$fp = fopen($filename,"rb");
248
+		$this->tar_file = fread($fp,filesize($filename));
249
+		fclose($fp);
250
+
251
+		if($this->tar_file[0] == chr(31) && $this->tar_file[1] == chr(139) && $this->tar_file[2] == chr(8)) {
252
+			if(!function_exists("gzinflate"))
253
+				return false;
254
+
255
+			$this->isGzipped = TRUE;
256
+
257
+			$this->tar_file = gzinflate(substr($this->tar_file,10,-4));
258
+		}
259
+
260
+		// Parse the TAR file
261
+		$this->__parseTar();
262
+
263
+		return true;
264
+	}
265
+
266
+
267
+	// Generates a TAR file from the processed data
268
+	// PRIVATE ACCESS FUNCTION
269
+	function __generateTAR() {
270
+		// Clear any data currently in $this->tar_file
271
+		unset($this->tar_file);
272
+
273
+		// Generate Records for each directory, if we have directories
274
+		if($this->numDirectories > 0) {
275
+			foreach($this->directories as $key => $information) {
276
+				unset($header);
277
+
278
+				// Generate tar header for this directory
279
+				// Filename, Permissions, UID, GID, size, Time, checksum, typeflag, linkname, magic, version, user name, group name, devmajor, devminor, prefix, end
280
+				$header .= str_pad($information["name"],100,chr(0));
281
+				$header .= str_pad(decoct($information["mode"]),7,"0",STR_PAD_LEFT) . chr(0);
282
+				$header .= str_pad(decoct($information["user_id"]),7,"0",STR_PAD_LEFT) . chr(0);
283
+				$header .= str_pad(decoct($information["group_id"]),7,"0",STR_PAD_LEFT) . chr(0);
284
+				$header .= str_pad(decoct(0),11,"0",STR_PAD_LEFT) . chr(0);
285
+				$header .= str_pad(decoct($information["time"]),11,"0",STR_PAD_LEFT) . chr(0);
286
+				$header .= str_repeat(" ",8);
287
+				$header .= "5";
288
+				$header .= str_repeat(chr(0),100);
289
+				$header .= str_pad("ustar",6,chr(32));
290
+				$header .= chr(32) . chr(0);
291
+				$header .= str_pad("",32,chr(0));
292
+				$header .= str_pad("",32,chr(0));
293
+				$header .= str_repeat(chr(0),8);
294
+				$header .= str_repeat(chr(0),8);
295
+				$header .= str_repeat(chr(0),155);
296
+				$header .= str_repeat(chr(0),12);
297
+
298
+				// Compute header checksum
299
+				$checksum = str_pad(decoct($this->__computeUnsignedChecksum($header)),6,"0",STR_PAD_LEFT);
300
+				for($i=0; $i<6; $i++) {
301
+					$header[(148 + $i)] = substr($checksum,$i,1);
302
+				}
303
+				$header[154] = chr(0);
304
+				$header[155] = chr(32);
305
+
306
+				// Add new tar formatted data to tar file contents
307
+				$this->tar_file .= $header;
308
+			}
309
+		}
310
+
311
+		// Generate Records for each file, if we have files (We should...)
312
+		if($this->numFiles > 0) {
313
+			foreach($this->files as $key => $information) {
314
+				unset($header);
315
+
316
+				// Generate the TAR header for this file
317
+				// Filename, Permissions, UID, GID, size, Time, checksum, typeflag, linkname, magic, version, user name, group name, devmajor, devminor, prefix, end
318
+				$header .= str_pad($information["name"],100,chr(0));
319
+				$header .= str_pad(decoct($information["mode"]),7,"0",STR_PAD_LEFT) . chr(0);
320
+				$header .= str_pad(decoct($information["user_id"]),7,"0",STR_PAD_LEFT) . chr(0);
321
+				$header .= str_pad(decoct($information["group_id"]),7,"0",STR_PAD_LEFT) . chr(0);
322
+				$header .= str_pad(decoct($information["size"]),11,"0",STR_PAD_LEFT) . chr(0);
323
+				$header .= str_pad(decoct($information["time"]),11,"0",STR_PAD_LEFT) . chr(0);
324
+				$header .= str_repeat(" ",8);
325
+				$header .= "0";
326
+				$header .= str_repeat(chr(0),100);
327
+				$header .= str_pad("ustar",6,chr(32));
328
+				$header .= chr(32) . chr(0);
329
+				$header .= str_pad($information["user_name"],32,chr(0));    // How do I get a file's user name from PHP?
330
+				$header .= str_pad($information["group_name"],32,chr(0));   // How do I get a file's group name from PHP?
331
+				$header .= str_repeat(chr(0),8);
332
+				$header .= str_repeat(chr(0),8);
333
+				$header .= str_repeat(chr(0),155);
334
+				$header .= str_repeat(chr(0),12);
335
+
336
+				// Compute header checksum
337
+				$checksum = str_pad(decoct($this->__computeUnsignedChecksum($header)),6,"0",STR_PAD_LEFT);
338
+				for($i=0; $i<6; $i++) {
339
+					$header[(148 + $i)] = substr($checksum,$i,1);
340
+				}
341
+				$header[154] = chr(0);
342
+				$header[155] = chr(32);
343
+
344
+				// Pad file contents to byte count divisible by 512
345
+				$file_contents = str_pad($information["file"],(ceil($information["size"] / 512) * 512),chr(0));
346
+
347
+				// Add new tar formatted data to tar file contents
348
+				$this->tar_file .= $header . $file_contents;
349
+			}
350
+		}
351
+
352
+		// Add 512 bytes of NULLs to designate EOF
353
+		$this->tar_file .= str_repeat(chr(0),512);
354
+
355
+		return true;
356
+	}
357
+
358
+
359
+	// Open a TAR file
360
+	function openTAR($filename) {
361
+		// Clear any values from previous tar archives
362
+		unset($this->filename);
363
+		unset($this->isGzipped);
364
+		unset($this->tar_file);
365
+		unset($this->files);
366
+		unset($this->directories);
367
+		unset($this->numFiles);
368
+		unset($this->numDirectories);
369
+
370
+		// If the tar file doesn't exist...
371
+		if(!file_exists($filename))
372
+			return false;
373
+
374
+		$this->filename = $filename;
375
+
376
+		// Parse this file
377
+		$this->__readTar();
378
+
379
+		return true;
380
+	}
381
+
382
+
383
+	// Appends a tar file to the end of the currently opened tar file
384
+	function appendTar($filename) {
385
+		// If the tar file doesn't exist...
386
+		if(!file_exists($filename))
387
+			return false;
388
+
389
+		$this->__readTar($filename);
390
+
391
+		return true;
392
+	}
393
+
394
+
395
+	// Retrieves information about a file in the current tar archive
396
+	function getFile($filename) {
397
+		if($this->numFiles > 0) {
398
+			foreach($this->files as $key => $information) {
399
+				if($information["name"] == $filename)
400
+					return $information;
401
+			}
402
+		}
403
+
404
+		return false;
405
+	}
406
+
407
+
408
+	// Retrieves information about a directory in the current tar archive
409
+	function getDirectory($dirname) {
410
+		if($this->numDirectories > 0) {
411
+			foreach($this->directories as $key => $information) {
412
+				if($information["name"] == $dirname)
413
+					return $information;
414
+			}
415
+		}
416
+
417
+		return false;
418
+	}
419
+
420
+
421
+	// Check if this tar archive contains a specific file
422
+	function containsFile($filename) {
423
+		if($this->numFiles > 0) {
424
+			foreach($this->files as $key => $information) {
425
+				if($information["name"] == $filename)
426
+					return true;
427
+			}
428
+		}
429
+
430
+		return false;
431
+	}
432
+
433
+
434
+	// Check if this tar archive contains a specific directory
435
+	function containsDirectory($dirname) {
436
+		if($this->numDirectories > 0) {
437
+			foreach($this->directories as $key => $information) {
438
+				if($information["name"] == $dirname)
439
+					return true;
440
+			}
441
+		}
442
+
443
+		return false;
444
+	}
445
+
446
+
447
+	// Add a directory to this tar archive
448
+	function addDirectory($dirname) {
449
+		if(!file_exists($dirname))
450
+			return false;
451
+
452
+		// Get directory information
453
+		$file_information = stat($dirname);
454
+
455
+		// Add directory to processed data
456
+		$this->numDirectories++;
457
+		$activeDir      = &$this->directories[];
458
+		$activeDir["name"]  = $dirname;
459
+		$activeDir["mode"]  = $file_information["mode"];
460
+		$activeDir["time"]  = $file_information["time"];
461
+		$activeDir["user_id"]   = $file_information["uid"];
462
+		$activeDir["group_id"]  = $file_information["gid"];
463
+		$activeDir["checksum"]  = $checksum;
464
+
465
+		return true;
466
+	}
467
+
468
+
469
+	// Add a file to the tar archive
470
+	function addFile($filename,$from=null,$to=null) {
471
+		// Make sure the file we are adding exists!
472
+		if(!file_exists($filename))
473
+			return false;
474
+
475
+		if(filesize($filename)==0)
476
+			return false;
477
+
478
+		// Make sure there are no other files in the archive that have this same filename
479
+		if($this->containsFile($filename))
480
+			return false;
481
+
482
+		// Get file information
483
+		$file_information = stat($filename);
484
+
485
+		// Read in the file's contents
486
+		$fp = fopen($filename,"rb");
487
+		$file_contents = fread($fp,filesize($filename));
488
+		fclose($fp);
489
+
490
+		if($from && $to){
491
+			$file_contents = str_replace($from,$to,$file_contents);
492
+			$file_information["size"] = strlen($file_contents);
493
+		}
494
+
495
+		// Add file to processed data
496
+		$this->numFiles++;
497
+		$activeFile         = &$this->files[];
498
+		$activeFile["name"]     = $filename;
499
+		$activeFile["mode"]     = $file_information["mode"];
500
+		$activeFile["user_id"]      = $file_information["uid"];
501
+		$activeFile["group_id"]     = $file_information["gid"];
502
+		$activeFile["size"]     = $file_information["size"];
503
+		$activeFile["time"]     = $file_information["mtime"];
504
+		$activeFile["checksum"]     = $checksum;
505
+		$activeFile["user_name"]    = "";
506
+		$activeFile["group_name"]   = "";
507
+		$activeFile["file"]     = $file_contents;
508
+
509
+		return true;
510
+	}
511
+
512
+
513
+	// Remove a file from the tar archive
514
+	function removeFile($filename) {
515
+		if($this->numFiles > 0) {
516
+			foreach($this->files as $key => $information) {
517
+				if($information["name"] == $filename) {
518
+					$this->numFiles--;
519
+					unset($this->files[$key]);
520
+					return true;
521
+				}
522
+			}
523
+		}
524
+
525
+		return false;
526
+	}
527
+
528
+
529
+	// Remove a directory from the tar archive
530
+	function removeDirectory($dirname) {
531
+		if($this->numDirectories > 0) {
532
+			foreach($this->directories as $key => $information) {
533
+				if($information["name"] == $dirname) {
534
+					$this->numDirectories--;
535
+					unset($this->directories[$key]);
536
+					return true;
537
+				}
538
+			}
539
+		}
540
+
541
+		return false;
542
+	}
543
+
544
+
545
+	// Write the currently loaded tar archive to disk
546
+	function saveTar() {
547
+		if(!$this->filename)
548
+			return false;
549
+
550
+		// Write tar to current file using specified gzip compression
551
+		$this->toTar($this->filename,$this->isGzipped);
552
+
553
+		return true;
554
+	}
555
+
556
+
557
+	// Saves tar archive to a different file than the current file
558
+	function toTar($filename,$useGzip) {
559
+		if(!$filename)
560
+			return false;
561
+
562
+		// Encode processed files into TAR file format
563
+		$this->__generateTar();
564
+
565
+		// GZ Compress the data if we need to
566
+		if($useGzip) {
567
+			// Make sure we have gzip support
568
+			if(!function_exists("gzencode"))
569
+				return false;
570
+
571
+			$file = gzencode($this->tar_file);
572
+		} else {
573
+			$file = $this->tar_file;
574
+		}
575
+
576
+		// Write the TAR file
577
+		$fp = fopen($filename,"wb");
578
+		fwrite($fp,$file);
579
+		fclose($fp);
580
+
581
+		return true;
582
+	}
583
+
584
+
585
+	function toTarStream() {
586
+		$this->__generateTar();
587
+		return $this->tar_file;
588
+	}
589 589
 }
590 590
 ?>
Please login to merge, or discard this patch.
Braces   +60 added lines, -44 removed lines patch added patch discarded remove patch
@@ -85,10 +85,12 @@  discard block
 block discarded – undo
85 85
     // to try to ensure valid file
86 86
     // PRIVATE ACCESS FUNCTION
87 87
     function __computeUnsignedChecksum($bytestring) {
88
-        for($i=0; $i<512; $i++)
89
-            $unsigned_chksum += ord($bytestring[$i]);
90
-        for($i=0; $i<8; $i++)
91
-            $unsigned_chksum -= ord($bytestring[148 + $i]);
88
+        for($i=0; $i<512; $i++) {
89
+                    $unsigned_chksum += ord($bytestring[$i]);
90
+        }
91
+        for($i=0; $i<8; $i++) {
92
+                    $unsigned_chksum -= ord($bytestring[148 + $i]);
93
+        }
92 94
         $unsigned_chksum += ord(" ") * 8;
93 95
 
94 96
         return $unsigned_chksum;
@@ -116,8 +118,9 @@  discard block
 block discarded – undo
116 118
 		$flag_longlink = false;
117 119
         while($main_offset < $tar_length) {
118 120
             // If we read a block of 512 nulls, we are at the end of the archive
119
-            if(substr($this->tar_file,$main_offset,512) == str_repeat(chr(0),512))
120
-                break;
121
+            if(substr($this->tar_file,$main_offset,512) == str_repeat(chr(0),512)) {
122
+                            break;
123
+            }
121 124
 
122 125
             // Parse file name
123 126
             $file_name      = $this->__parseNullPaddedString(substr($this->tar_file,$main_offset,100));
@@ -149,8 +152,9 @@  discard block
 block discarded – undo
149 152
             $file_type = substr($this->tar_file,$main_offset + 156,1);
150 153
 
151 154
             // Make sure our file is valid
152
-            if($this->__computeUnsignedChecksum(substr($this->tar_file,$main_offset,512)) != $file_chksum)
153
-                return false;
155
+            if($this->__computeUnsignedChecksum(substr($this->tar_file,$main_offset,512)) != $file_chksum) {
156
+                            return false;
157
+            }
154 158
 
155 159
             // Parse File Contents
156 160
             $file_contents      = substr($this->tar_file,$main_offset + 512,$file_size);
@@ -170,8 +174,7 @@  discard block
 block discarded – undo
170 174
 			{
171 175
 				$flag_longlink = true;
172 176
 				$longlink_name = $this->__parseNullPaddedString($file_contents);
173
-			}
174
-			elseif($file_type == '0') {
177
+			} elseif($file_type == '0') {
175 178
 				// Increment number of files
176 179
 				$this->numFiles++;
177 180
 
@@ -182,8 +185,7 @@  discard block
 block discarded – undo
182 185
 				if($flag_longlink)
183 186
 				{
184 187
 					$activeFile["name"]     = $longlink_name;
185
-				}
186
-				else
188
+				} else
187 189
 				{
188 190
 					$activeFile["name"]     = $file_name;
189 191
 				}
@@ -211,8 +213,7 @@  discard block
 block discarded – undo
211 213
 				if($flag_longlink)
212 214
 				{
213 215
 					$activeDir["name"]     = $longlink_name;
214
-				}
215
-				else
216
+				} else
216 217
 				{
217 218
 					$activeDir["name"]     = $file_name;
218 219
 				}
@@ -240,8 +241,9 @@  discard block
 block discarded – undo
240 241
     // PRIVATE ACCESS FUNCTION
241 242
     function __readTar($filename='') {
242 243
         // Set the filename to load
243
-        if(!$filename)
244
-            $filename = $this->filename;
244
+        if(!$filename) {
245
+                    $filename = $this->filename;
246
+        }
245 247
 
246 248
         // Read in the TAR file
247 249
         $fp = fopen($filename,"rb");
@@ -249,8 +251,9 @@  discard block
 block discarded – undo
249 251
         fclose($fp);
250 252
 
251 253
         if($this->tar_file[0] == chr(31) && $this->tar_file[1] == chr(139) && $this->tar_file[2] == chr(8)) {
252
-            if(!function_exists("gzinflate"))
253
-                return false;
254
+            if(!function_exists("gzinflate")) {
255
+                            return false;
256
+            }
254 257
 
255 258
             $this->isGzipped = TRUE;
256 259
 
@@ -368,8 +371,9 @@  discard block
 block discarded – undo
368 371
         unset($this->numDirectories);
369 372
 
370 373
         // If the tar file doesn't exist...
371
-        if(!file_exists($filename))
372
-            return false;
374
+        if(!file_exists($filename)) {
375
+                    return false;
376
+        }
373 377
 
374 378
         $this->filename = $filename;
375 379
 
@@ -383,8 +387,9 @@  discard block
 block discarded – undo
383 387
     // Appends a tar file to the end of the currently opened tar file
384 388
     function appendTar($filename) {
385 389
         // If the tar file doesn't exist...
386
-        if(!file_exists($filename))
387
-            return false;
390
+        if(!file_exists($filename)) {
391
+                    return false;
392
+        }
388 393
 
389 394
         $this->__readTar($filename);
390 395
 
@@ -396,8 +401,9 @@  discard block
 block discarded – undo
396 401
     function getFile($filename) {
397 402
         if($this->numFiles > 0) {
398 403
             foreach($this->files as $key => $information) {
399
-                if($information["name"] == $filename)
400
-                    return $information;
404
+                if($information["name"] == $filename) {
405
+                                    return $information;
406
+                }
401 407
             }
402 408
         }
403 409
 
@@ -409,8 +415,9 @@  discard block
 block discarded – undo
409 415
     function getDirectory($dirname) {
410 416
         if($this->numDirectories > 0) {
411 417
             foreach($this->directories as $key => $information) {
412
-                if($information["name"] == $dirname)
413
-                    return $information;
418
+                if($information["name"] == $dirname) {
419
+                                    return $information;
420
+                }
414 421
             }
415 422
         }
416 423
 
@@ -422,8 +429,9 @@  discard block
 block discarded – undo
422 429
     function containsFile($filename) {
423 430
         if($this->numFiles > 0) {
424 431
             foreach($this->files as $key => $information) {
425
-                if($information["name"] == $filename)
426
-                    return true;
432
+                if($information["name"] == $filename) {
433
+                                    return true;
434
+                }
427 435
             }
428 436
         }
429 437
 
@@ -435,8 +443,9 @@  discard block
 block discarded – undo
435 443
     function containsDirectory($dirname) {
436 444
         if($this->numDirectories > 0) {
437 445
             foreach($this->directories as $key => $information) {
438
-                if($information["name"] == $dirname)
439
-                    return true;
446
+                if($information["name"] == $dirname) {
447
+                                    return true;
448
+                }
440 449
             }
441 450
         }
442 451
 
@@ -446,8 +455,9 @@  discard block
 block discarded – undo
446 455
 
447 456
     // Add a directory to this tar archive
448 457
     function addDirectory($dirname) {
449
-        if(!file_exists($dirname))
450
-            return false;
458
+        if(!file_exists($dirname)) {
459
+                    return false;
460
+        }
451 461
 
452 462
         // Get directory information
453 463
         $file_information = stat($dirname);
@@ -469,15 +479,18 @@  discard block
 block discarded – undo
469 479
     // Add a file to the tar archive
470 480
     function addFile($filename,$from=null,$to=null) {
471 481
         // Make sure the file we are adding exists!
472
-        if(!file_exists($filename))
473
-            return false;
482
+        if(!file_exists($filename)) {
483
+                    return false;
484
+        }
474 485
 
475
-        if(filesize($filename)==0)
476
-            return false;
486
+        if(filesize($filename)==0) {
487
+                    return false;
488
+        }
477 489
 
478 490
         // Make sure there are no other files in the archive that have this same filename
479
-        if($this->containsFile($filename))
480
-            return false;
491
+        if($this->containsFile($filename)) {
492
+                    return false;
493
+        }
481 494
 
482 495
         // Get file information
483 496
         $file_information = stat($filename);
@@ -544,8 +557,9 @@  discard block
 block discarded – undo
544 557
 
545 558
     // Write the currently loaded tar archive to disk
546 559
     function saveTar() {
547
-        if(!$this->filename)
548
-            return false;
560
+        if(!$this->filename) {
561
+                    return false;
562
+        }
549 563
 
550 564
         // Write tar to current file using specified gzip compression
551 565
         $this->toTar($this->filename,$this->isGzipped);
@@ -556,8 +570,9 @@  discard block
 block discarded – undo
556 570
 
557 571
     // Saves tar archive to a different file than the current file
558 572
     function toTar($filename,$useGzip) {
559
-        if(!$filename)
560
-            return false;
573
+        if(!$filename) {
574
+                    return false;
575
+        }
561 576
 
562 577
         // Encode processed files into TAR file format
563 578
         $this->__generateTar();
@@ -565,8 +580,9 @@  discard block
 block discarded – undo
565 580
         // GZ Compress the data if we need to
566 581
         if($useGzip) {
567 582
             // Make sure we have gzip support
568
-            if(!function_exists("gzencode"))
569
-                return false;
583
+            if(!function_exists("gzencode")) {
584
+                            return false;
585
+            }
570 586
 
571 587
             $file = gzencode($this->tar_file);
572 588
         } else {
Please login to merge, or discard this patch.
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
     // to try to ensure valid file
86 86
     // PRIVATE ACCESS FUNCTION
87 87
     function __computeUnsignedChecksum($bytestring) {
88
-        for($i=0; $i<512; $i++)
88
+        for ($i = 0; $i < 512; $i++)
89 89
             $unsigned_chksum += ord($bytestring[$i]);
90
-        for($i=0; $i<8; $i++)
90
+        for ($i = 0; $i < 8; $i++)
91 91
             $unsigned_chksum -= ord($bytestring[148 + $i]);
92 92
         $unsigned_chksum += ord(" ") * 8;
93 93
 
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
     // Converts a NULL padded string to a non-NULL padded string
99 99
     // PRIVATE ACCESS FUNCTION
100 100
     function __parseNullPaddedString($string) {
101
-        $position = strpos($string,chr(0));
102
-		if(!$position)
101
+        $position = strpos($string, chr(0));
102
+		if (!$position)
103 103
 		{
104 104
 			$position = strlen($string);
105 105
 		}
106
-        return substr($string,0,$position);
106
+        return substr($string, 0, $position);
107 107
     }
108 108
 
109 109
 
@@ -114,46 +114,46 @@  discard block
 block discarded – undo
114 114
         $tar_length = strlen($this->tar_file);
115 115
         $main_offset = 0;
116 116
 		$flag_longlink = false;
117
-        while($main_offset < $tar_length) {
117
+        while ($main_offset < $tar_length) {
118 118
             // If we read a block of 512 nulls, we are at the end of the archive
119
-            if(substr($this->tar_file,$main_offset,512) == str_repeat(chr(0),512))
119
+            if (substr($this->tar_file, $main_offset, 512) == str_repeat(chr(0), 512))
120 120
                 break;
121 121
 
122 122
             // Parse file name
123
-            $file_name      = $this->__parseNullPaddedString(substr($this->tar_file,$main_offset,100));
123
+            $file_name      = $this->__parseNullPaddedString(substr($this->tar_file, $main_offset, 100));
124 124
 
125 125
             // Parse the file mode
126
-            $file_mode      = substr($this->tar_file,$main_offset + 100,8);
126
+            $file_mode      = substr($this->tar_file, $main_offset + 100, 8);
127 127
 
128 128
             // Parse the file user ID
129
-            $file_uid       = octdec(substr($this->tar_file,$main_offset + 108,8));
129
+            $file_uid       = octdec(substr($this->tar_file, $main_offset + 108, 8));
130 130
 
131 131
             // Parse the file group ID
132
-            $file_gid       = octdec(substr($this->tar_file,$main_offset + 116,8));
132
+            $file_gid       = octdec(substr($this->tar_file, $main_offset + 116, 8));
133 133
 
134 134
             // Parse the file size
135
-            $file_size      = octdec(substr($this->tar_file,$main_offset + 124,12));
135
+            $file_size      = octdec(substr($this->tar_file, $main_offset + 124, 12));
136 136
 
137 137
             // Parse the file update time - unix timestamp format
138
-            $file_time      = octdec(substr($this->tar_file,$main_offset + 136,12));
138
+            $file_time      = octdec(substr($this->tar_file, $main_offset + 136, 12));
139 139
 
140 140
             // Parse Checksum
141
-            $file_chksum        = octdec(substr($this->tar_file,$main_offset + 148,6));
141
+            $file_chksum = octdec(substr($this->tar_file, $main_offset + 148, 6));
142 142
 
143 143
             // Parse user name
144
-            $file_uname     = $this->__parseNullPaddedString(substr($this->tar_file,$main_offset + 265,32));
144
+            $file_uname     = $this->__parseNullPaddedString(substr($this->tar_file, $main_offset + 265, 32));
145 145
 
146 146
             // Parse Group name
147
-            $file_gname     = $this->__parseNullPaddedString(substr($this->tar_file,$main_offset + 297,32));
147
+            $file_gname     = $this->__parseNullPaddedString(substr($this->tar_file, $main_offset + 297, 32));
148 148
 
149
-            $file_type = substr($this->tar_file,$main_offset + 156,1);
149
+            $file_type = substr($this->tar_file, $main_offset + 156, 1);
150 150
 
151 151
             // Make sure our file is valid
152
-            if($this->__computeUnsignedChecksum(substr($this->tar_file,$main_offset,512)) != $file_chksum)
152
+            if ($this->__computeUnsignedChecksum(substr($this->tar_file, $main_offset, 512)) != $file_chksum)
153 153
                 return false;
154 154
 
155 155
             // Parse File Contents
156
-            $file_contents      = substr($this->tar_file,$main_offset + 512,$file_size);
156
+            $file_contents = substr($this->tar_file, $main_offset + 512, $file_size);
157 157
 
158 158
             /*  ### Unused Header Information ###
159 159
                 $activeFile["typeflag"]     = substr($this->tar_file,$main_offset + 156,1);
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
                 $activeFile["endheader"]    = substr($this->tar_file,$main_offset + 500,12);
167 167
             */
168 168
 
169
-			if(strtolower($file_type) == 'l' || $file_name == '././@LongLink')
169
+			if (strtolower($file_type) == 'l' || $file_name == '././@LongLink')
170 170
 			{
171 171
 				$flag_longlink = true;
172 172
 				$longlink_name = $this->__parseNullPaddedString($file_contents);
173 173
 			}
174
-			elseif($file_type == '0') {
174
+			elseif ($file_type == '0') {
175 175
 				// Increment number of files
176 176
 				$this->numFiles++;
177 177
 
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
 				$activeFile = &$this->files[];
180 180
 
181 181
 				// Asign Values
182
-				if($flag_longlink)
182
+				if ($flag_longlink)
183 183
 				{
184
-					$activeFile["name"]     = $longlink_name;
184
+					$activeFile["name"] = $longlink_name;
185 185
 				}
186 186
 				else
187 187
 				{
188
-					$activeFile["name"]     = $file_name;
188
+					$activeFile["name"] = $file_name;
189 189
 				}
190 190
 				$activeFile["type"]     = $file_type;
191 191
 				$activeFile["mode"]     = $file_mode;
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 				$activeFile["user_name"]    = $file_uname;
197 197
 				$activeFile["group_name"]   = $file_gname;
198 198
 				$activeFile["checksum"]     = $file_chksum;
199
-				$activeFile["file"]     = $file_contents;
199
+				$activeFile["file"] = $file_contents;
200 200
 
201 201
 				$flag_longlink = false;
202 202
 
203
-			} elseif($file_type == '5') {
203
+			} elseif ($file_type == '5') {
204 204
 				// Increment number of directories
205 205
 				$this->numDirectories++;
206 206
 
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 				$activeDir = &$this->directories[];
209 209
 
210 210
 				// Assign values
211
-				if($flag_longlink)
211
+				if ($flag_longlink)
212 212
 				{
213
-					$activeDir["name"]     = $longlink_name;
213
+					$activeDir["name"] = $longlink_name;
214 214
 				}
215 215
 				else
216 216
 				{
@@ -238,23 +238,23 @@  discard block
 block discarded – undo
238 238
 
239 239
     // Read a non gzipped tar file in for processing
240 240
     // PRIVATE ACCESS FUNCTION
241
-    function __readTar($filename='') {
241
+    function __readTar($filename = '') {
242 242
         // Set the filename to load
243
-        if(!$filename)
243
+        if (!$filename)
244 244
             $filename = $this->filename;
245 245
 
246 246
         // Read in the TAR file
247
-        $fp = fopen($filename,"rb");
248
-        $this->tar_file = fread($fp,filesize($filename));
247
+        $fp = fopen($filename, "rb");
248
+        $this->tar_file = fread($fp, filesize($filename));
249 249
         fclose($fp);
250 250
 
251
-        if($this->tar_file[0] == chr(31) && $this->tar_file[1] == chr(139) && $this->tar_file[2] == chr(8)) {
252
-            if(!function_exists("gzinflate"))
251
+        if ($this->tar_file[0] == chr(31) && $this->tar_file[1] == chr(139) && $this->tar_file[2] == chr(8)) {
252
+            if (!function_exists("gzinflate"))
253 253
                 return false;
254 254
 
255 255
             $this->isGzipped = TRUE;
256 256
 
257
-            $this->tar_file = gzinflate(substr($this->tar_file,10,-4));
257
+            $this->tar_file = gzinflate(substr($this->tar_file, 10, -4));
258 258
         }
259 259
 
260 260
         // Parse the TAR file
@@ -271,34 +271,34 @@  discard block
 block discarded – undo
271 271
         unset($this->tar_file);
272 272
 
273 273
         // Generate Records for each directory, if we have directories
274
-        if($this->numDirectories > 0) {
275
-            foreach($this->directories as $key => $information) {
274
+        if ($this->numDirectories > 0) {
275
+            foreach ($this->directories as $key => $information) {
276 276
                 unset($header);
277 277
 
278 278
                 // Generate tar header for this directory
279 279
                 // Filename, Permissions, UID, GID, size, Time, checksum, typeflag, linkname, magic, version, user name, group name, devmajor, devminor, prefix, end
280
-                $header .= str_pad($information["name"],100,chr(0));
281
-                $header .= str_pad(decoct($information["mode"]),7,"0",STR_PAD_LEFT) . chr(0);
282
-                $header .= str_pad(decoct($information["user_id"]),7,"0",STR_PAD_LEFT) . chr(0);
283
-                $header .= str_pad(decoct($information["group_id"]),7,"0",STR_PAD_LEFT) . chr(0);
284
-                $header .= str_pad(decoct(0),11,"0",STR_PAD_LEFT) . chr(0);
285
-                $header .= str_pad(decoct($information["time"]),11,"0",STR_PAD_LEFT) . chr(0);
286
-                $header .= str_repeat(" ",8);
280
+                $header .= str_pad($information["name"], 100, chr(0));
281
+                $header .= str_pad(decoct($information["mode"]), 7, "0", STR_PAD_LEFT).chr(0);
282
+                $header .= str_pad(decoct($information["user_id"]), 7, "0", STR_PAD_LEFT).chr(0);
283
+                $header .= str_pad(decoct($information["group_id"]), 7, "0", STR_PAD_LEFT).chr(0);
284
+                $header .= str_pad(decoct(0), 11, "0", STR_PAD_LEFT).chr(0);
285
+                $header .= str_pad(decoct($information["time"]), 11, "0", STR_PAD_LEFT).chr(0);
286
+                $header .= str_repeat(" ", 8);
287 287
                 $header .= "5";
288
-                $header .= str_repeat(chr(0),100);
289
-                $header .= str_pad("ustar",6,chr(32));
290
-                $header .= chr(32) . chr(0);
291
-                $header .= str_pad("",32,chr(0));
292
-                $header .= str_pad("",32,chr(0));
293
-                $header .= str_repeat(chr(0),8);
294
-                $header .= str_repeat(chr(0),8);
295
-                $header .= str_repeat(chr(0),155);
296
-                $header .= str_repeat(chr(0),12);
288
+                $header .= str_repeat(chr(0), 100);
289
+                $header .= str_pad("ustar", 6, chr(32));
290
+                $header .= chr(32).chr(0);
291
+                $header .= str_pad("", 32, chr(0));
292
+                $header .= str_pad("", 32, chr(0));
293
+                $header .= str_repeat(chr(0), 8);
294
+                $header .= str_repeat(chr(0), 8);
295
+                $header .= str_repeat(chr(0), 155);
296
+                $header .= str_repeat(chr(0), 12);
297 297
 
298 298
                 // Compute header checksum
299
-                $checksum = str_pad(decoct($this->__computeUnsignedChecksum($header)),6,"0",STR_PAD_LEFT);
300
-                for($i=0; $i<6; $i++) {
301
-                    $header[(148 + $i)] = substr($checksum,$i,1);
299
+                $checksum = str_pad(decoct($this->__computeUnsignedChecksum($header)), 6, "0", STR_PAD_LEFT);
300
+                for ($i = 0; $i < 6; $i++) {
301
+                    $header[(148 + $i)] = substr($checksum, $i, 1);
302 302
                 }
303 303
                 $header[154] = chr(0);
304 304
                 $header[155] = chr(32);
@@ -309,48 +309,48 @@  discard block
 block discarded – undo
309 309
         }
310 310
 
311 311
         // Generate Records for each file, if we have files (We should...)
312
-        if($this->numFiles > 0) {
313
-            foreach($this->files as $key => $information) {
312
+        if ($this->numFiles > 0) {
313
+            foreach ($this->files as $key => $information) {
314 314
                 unset($header);
315 315
 
316 316
                 // Generate the TAR header for this file
317 317
                 // Filename, Permissions, UID, GID, size, Time, checksum, typeflag, linkname, magic, version, user name, group name, devmajor, devminor, prefix, end
318
-                $header .= str_pad($information["name"],100,chr(0));
319
-                $header .= str_pad(decoct($information["mode"]),7,"0",STR_PAD_LEFT) . chr(0);
320
-                $header .= str_pad(decoct($information["user_id"]),7,"0",STR_PAD_LEFT) . chr(0);
321
-                $header .= str_pad(decoct($information["group_id"]),7,"0",STR_PAD_LEFT) . chr(0);
322
-                $header .= str_pad(decoct($information["size"]),11,"0",STR_PAD_LEFT) . chr(0);
323
-                $header .= str_pad(decoct($information["time"]),11,"0",STR_PAD_LEFT) . chr(0);
324
-                $header .= str_repeat(" ",8);
318
+                $header .= str_pad($information["name"], 100, chr(0));
319
+                $header .= str_pad(decoct($information["mode"]), 7, "0", STR_PAD_LEFT).chr(0);
320
+                $header .= str_pad(decoct($information["user_id"]), 7, "0", STR_PAD_LEFT).chr(0);
321
+                $header .= str_pad(decoct($information["group_id"]), 7, "0", STR_PAD_LEFT).chr(0);
322
+                $header .= str_pad(decoct($information["size"]), 11, "0", STR_PAD_LEFT).chr(0);
323
+                $header .= str_pad(decoct($information["time"]), 11, "0", STR_PAD_LEFT).chr(0);
324
+                $header .= str_repeat(" ", 8);
325 325
                 $header .= "0";
326
-                $header .= str_repeat(chr(0),100);
327
-                $header .= str_pad("ustar",6,chr(32));
328
-                $header .= chr(32) . chr(0);
329
-                $header .= str_pad($information["user_name"],32,chr(0));    // How do I get a file's user name from PHP?
330
-                $header .= str_pad($information["group_name"],32,chr(0));   // How do I get a file's group name from PHP?
331
-                $header .= str_repeat(chr(0),8);
332
-                $header .= str_repeat(chr(0),8);
333
-                $header .= str_repeat(chr(0),155);
334
-                $header .= str_repeat(chr(0),12);
326
+                $header .= str_repeat(chr(0), 100);
327
+                $header .= str_pad("ustar", 6, chr(32));
328
+                $header .= chr(32).chr(0);
329
+                $header .= str_pad($information["user_name"], 32, chr(0)); // How do I get a file's user name from PHP?
330
+                $header .= str_pad($information["group_name"], 32, chr(0)); // How do I get a file's group name from PHP?
331
+                $header .= str_repeat(chr(0), 8);
332
+                $header .= str_repeat(chr(0), 8);
333
+                $header .= str_repeat(chr(0), 155);
334
+                $header .= str_repeat(chr(0), 12);
335 335
 
336 336
                 // Compute header checksum
337
-                $checksum = str_pad(decoct($this->__computeUnsignedChecksum($header)),6,"0",STR_PAD_LEFT);
338
-                for($i=0; $i<6; $i++) {
339
-                    $header[(148 + $i)] = substr($checksum,$i,1);
337
+                $checksum = str_pad(decoct($this->__computeUnsignedChecksum($header)), 6, "0", STR_PAD_LEFT);
338
+                for ($i = 0; $i < 6; $i++) {
339
+                    $header[(148 + $i)] = substr($checksum, $i, 1);
340 340
                 }
341 341
                 $header[154] = chr(0);
342 342
                 $header[155] = chr(32);
343 343
 
344 344
                 // Pad file contents to byte count divisible by 512
345
-                $file_contents = str_pad($information["file"],(ceil($information["size"] / 512) * 512),chr(0));
345
+                $file_contents = str_pad($information["file"], (ceil($information["size"] / 512) * 512), chr(0));
346 346
 
347 347
                 // Add new tar formatted data to tar file contents
348
-                $this->tar_file .= $header . $file_contents;
348
+                $this->tar_file .= $header.$file_contents;
349 349
             }
350 350
         }
351 351
 
352 352
         // Add 512 bytes of NULLs to designate EOF
353
-        $this->tar_file .= str_repeat(chr(0),512);
353
+        $this->tar_file .= str_repeat(chr(0), 512);
354 354
 
355 355
         return true;
356 356
     }
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
         unset($this->numDirectories);
369 369
 
370 370
         // If the tar file doesn't exist...
371
-        if(!file_exists($filename))
371
+        if (!file_exists($filename))
372 372
             return false;
373 373
 
374 374
         $this->filename = $filename;
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
     // Appends a tar file to the end of the currently opened tar file
384 384
     function appendTar($filename) {
385 385
         // If the tar file doesn't exist...
386
-        if(!file_exists($filename))
386
+        if (!file_exists($filename))
387 387
             return false;
388 388
 
389 389
         $this->__readTar($filename);
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 
395 395
     // Retrieves information about a file in the current tar archive
396 396
     function getFile($filename) {
397
-        if($this->numFiles > 0) {
398
-            foreach($this->files as $key => $information) {
399
-                if($information["name"] == $filename)
397
+        if ($this->numFiles > 0) {
398
+            foreach ($this->files as $key => $information) {
399
+                if ($information["name"] == $filename)
400 400
                     return $information;
401 401
             }
402 402
         }
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
 
408 408
     // Retrieves information about a directory in the current tar archive
409 409
     function getDirectory($dirname) {
410
-        if($this->numDirectories > 0) {
411
-            foreach($this->directories as $key => $information) {
412
-                if($information["name"] == $dirname)
410
+        if ($this->numDirectories > 0) {
411
+            foreach ($this->directories as $key => $information) {
412
+                if ($information["name"] == $dirname)
413 413
                     return $information;
414 414
             }
415 415
         }
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 
421 421
     // Check if this tar archive contains a specific file
422 422
     function containsFile($filename) {
423
-        if($this->numFiles > 0) {
424
-            foreach($this->files as $key => $information) {
425
-                if($information["name"] == $filename)
423
+        if ($this->numFiles > 0) {
424
+            foreach ($this->files as $key => $information) {
425
+                if ($information["name"] == $filename)
426 426
                     return true;
427 427
             }
428 428
         }
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
 
434 434
     // Check if this tar archive contains a specific directory
435 435
     function containsDirectory($dirname) {
436
-        if($this->numDirectories > 0) {
437
-            foreach($this->directories as $key => $information) {
438
-                if($information["name"] == $dirname)
436
+        if ($this->numDirectories > 0) {
437
+            foreach ($this->directories as $key => $information) {
438
+                if ($information["name"] == $dirname)
439 439
                     return true;
440 440
             }
441 441
         }
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 
447 447
     // Add a directory to this tar archive
448 448
     function addDirectory($dirname) {
449
-        if(!file_exists($dirname))
449
+        if (!file_exists($dirname))
450 450
             return false;
451 451
 
452 452
         // Get directory information
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 
455 455
         // Add directory to processed data
456 456
         $this->numDirectories++;
457
-        $activeDir      = &$this->directories[];
457
+        $activeDir = &$this->directories[];
458 458
         $activeDir["name"]  = $dirname;
459 459
         $activeDir["mode"]  = $file_information["mode"];
460 460
         $activeDir["time"]  = $file_information["time"];
@@ -467,34 +467,34 @@  discard block
 block discarded – undo
467 467
 
468 468
 
469 469
     // Add a file to the tar archive
470
-    function addFile($filename,$from=null,$to=null) {
470
+    function addFile($filename, $from = null, $to = null) {
471 471
         // Make sure the file we are adding exists!
472
-        if(!file_exists($filename))
472
+        if (!file_exists($filename))
473 473
             return false;
474 474
 
475
-        if(filesize($filename)==0)
475
+        if (filesize($filename) == 0)
476 476
             return false;
477 477
 
478 478
         // Make sure there are no other files in the archive that have this same filename
479
-        if($this->containsFile($filename))
479
+        if ($this->containsFile($filename))
480 480
             return false;
481 481
 
482 482
         // Get file information
483 483
         $file_information = stat($filename);
484 484
 
485 485
         // Read in the file's contents
486
-        $fp = fopen($filename,"rb");
487
-        $file_contents = fread($fp,filesize($filename));
486
+        $fp = fopen($filename, "rb");
487
+        $file_contents = fread($fp, filesize($filename));
488 488
         fclose($fp);
489 489
 
490
-        if($from && $to){
491
-            $file_contents = str_replace($from,$to,$file_contents);
490
+        if ($from && $to) {
491
+            $file_contents = str_replace($from, $to, $file_contents);
492 492
             $file_information["size"] = strlen($file_contents);
493 493
         }
494 494
 
495 495
         // Add file to processed data
496 496
         $this->numFiles++;
497
-        $activeFile         = &$this->files[];
497
+        $activeFile = &$this->files[];
498 498
         $activeFile["name"]     = $filename;
499 499
         $activeFile["mode"]     = $file_information["mode"];
500 500
         $activeFile["user_id"]      = $file_information["uid"];
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
         $activeFile["checksum"]     = $checksum;
505 505
         $activeFile["user_name"]    = "";
506 506
         $activeFile["group_name"]   = "";
507
-        $activeFile["file"]     = $file_contents;
507
+        $activeFile["file"] = $file_contents;
508 508
 
509 509
         return true;
510 510
     }
@@ -512,9 +512,9 @@  discard block
 block discarded – undo
512 512
 
513 513
     // Remove a file from the tar archive
514 514
     function removeFile($filename) {
515
-        if($this->numFiles > 0) {
516
-            foreach($this->files as $key => $information) {
517
-                if($information["name"] == $filename) {
515
+        if ($this->numFiles > 0) {
516
+            foreach ($this->files as $key => $information) {
517
+                if ($information["name"] == $filename) {
518 518
                     $this->numFiles--;
519 519
                     unset($this->files[$key]);
520 520
                     return true;
@@ -528,9 +528,9 @@  discard block
 block discarded – undo
528 528
 
529 529
     // Remove a directory from the tar archive
530 530
     function removeDirectory($dirname) {
531
-        if($this->numDirectories > 0) {
532
-            foreach($this->directories as $key => $information) {
533
-                if($information["name"] == $dirname) {
531
+        if ($this->numDirectories > 0) {
532
+            foreach ($this->directories as $key => $information) {
533
+                if ($information["name"] == $dirname) {
534 534
                     $this->numDirectories--;
535 535
                     unset($this->directories[$key]);
536 536
                     return true;
@@ -544,28 +544,28 @@  discard block
 block discarded – undo
544 544
 
545 545
     // Write the currently loaded tar archive to disk
546 546
     function saveTar() {
547
-        if(!$this->filename)
547
+        if (!$this->filename)
548 548
             return false;
549 549
 
550 550
         // Write tar to current file using specified gzip compression
551
-        $this->toTar($this->filename,$this->isGzipped);
551
+        $this->toTar($this->filename, $this->isGzipped);
552 552
 
553 553
         return true;
554 554
     }
555 555
 
556 556
 
557 557
     // Saves tar archive to a different file than the current file
558
-    function toTar($filename,$useGzip) {
559
-        if(!$filename)
558
+    function toTar($filename, $useGzip) {
559
+        if (!$filename)
560 560
             return false;
561 561
 
562 562
         // Encode processed files into TAR file format
563 563
         $this->__generateTar();
564 564
 
565 565
         // GZ Compress the data if we need to
566
-        if($useGzip) {
566
+        if ($useGzip) {
567 567
             // Make sure we have gzip support
568
-            if(!function_exists("gzencode"))
568
+            if (!function_exists("gzencode"))
569 569
                 return false;
570 570
 
571 571
             $file = gzencode($this->tar_file);
@@ -574,8 +574,8 @@  discard block
 block discarded – undo
574 574
         }
575 575
 
576 576
         // Write the TAR file
577
-        $fp = fopen($filename,"wb");
578
-        fwrite($fp,$file);
577
+        $fp = fopen($filename, "wb");
578
+        fwrite($fp, $file);
579 579
         fclose($fp);
580 580
 
581 581
         return true;
Please login to merge, or discard this patch.
modules/addon/addon.admin.model.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
141 141
 	 * @param string $addon Name to get information
142 142
 	 * @param int $site_srl Site srl
143 143
 	 * @param string $gtype site or global
144
-	 * @return object Returns a information
144
+	 * @return null|stdClass Returns a information
145 145
 	 */
146 146
 	function getAddonInfoXml($addon, $site_srl = 0, $gtype = 'site')
147 147
 	{
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	function getAddonPath($addon_name)
28 28
 	{
29 29
 		$class_path = sprintf('./addons/%s/', $addon_name);
30
-		if(is_dir($class_path))
30
+		if (is_dir($class_path))
31 31
 		{
32 32
 			return $class_path;
33 33
 		}
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		$addonList = $this->getAddonList(0, 'site');
45 45
 
46 46
 		$oAutoinstallModel = getModel('autoinstall');
47
-		foreach($addonList as $key => $addon)
47
+		foreach ($addonList as $key => $addon)
48 48
 		{
49 49
 			// get easyinstall remove url
50 50
 			$packageSrl = $oAutoinstallModel->getPackageSrlByPath($addon->path);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 			$addonList[$key]->need_update = $package[$packageSrl]->need_update;
56 56
 
57 57
 			// get easyinstall update url
58
-			if($addonList[$key]->need_update == 'Y')
58
+			if ($addonList[$key]->need_update == 'Y')
59 59
 			{
60 60
 				$addonList[$key]->update_url = $oAutoinstallModel->getUpdateUrlByPackageSrl($packageSrl);
61 61
 			}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		// Downloaded and installed add-on to the list of Wanted
79 79
 		$searched_list = FileHandler::readDir('./addons', '/^([a-zA-Z0-9-_]+)$/');
80 80
 		$searched_count = count($searched_list);
81
-		if(!$searched_count)
81
+		if (!$searched_count)
82 82
 		{
83 83
 			return;
84 84
 		}
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 
88 88
 		$oAddonAdminController = getAdminController('addon');
89 89
 
90
-		for($i = 0; $i < $searched_count; $i++)
90
+		for ($i = 0; $i < $searched_count; $i++)
91 91
 		{
92 92
 			// Add the name of
93 93
 			$addon_name = $searched_list[$i];
94
-			if($addon_name == "smartphone")
94
+			if ($addon_name == "smartphone")
95 95
 			{
96 96
 				continue;
97 97
 			}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 			// Wanted information on the add-on
101 101
 			$info = $this->getAddonInfoXml($addon_name, $site_srl, $gtype);
102 102
 			
103
-			if(!$info) $info = new stdClass();
103
+			if (!$info) $info = new stdClass();
104 104
 
105 105
 			$info->addon = $addon_name;
106 106
 			$info->path = $path;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 			$info->mactivated = FALSE;
109 109
 			$info->fixed = FALSE;
110 110
 			// Check if a permossion is granted entered in DB
111
-			if(!in_array($addon_name, array_keys($inserted_addons)))
111
+			if (!in_array($addon_name, array_keys($inserted_addons)))
112 112
 			{
113 113
 				// If not, type in the DB type (model, perhaps because of the hate doing this haneungeo .. ㅡ. ㅜ)
114 114
 				$oAddonAdminController->doInsert($addon_name, $site_srl, $type);
@@ -116,15 +116,15 @@  discard block
 block discarded – undo
116 116
 			}
117 117
 			else
118 118
 			{
119
-				if($inserted_addons[$addon_name]->is_used == 'Y')
119
+				if ($inserted_addons[$addon_name]->is_used == 'Y')
120 120
 				{
121 121
 					$info->activated = TRUE;
122 122
 				}
123
-				if($inserted_addons[$addon_name]->is_used_m == 'Y')
123
+				if ($inserted_addons[$addon_name]->is_used_m == 'Y')
124 124
 				{
125 125
 					$info->mactivated = TRUE;
126 126
 				}
127
-				if($gtype == 'global' && $inserted_addons[$addon_name]->is_fixed == 'Y')
127
+				if ($gtype == 'global' && $inserted_addons[$addon_name]->is_fixed == 'Y')
128 128
 				{
129 129
 					$info->fixed = TRUE;
130 130
 				}
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
 	{
148 148
 		// Get a path of the requested module. Return if not exists.
149 149
 		$addon_path = $this->getAddonPath($addon);
150
-		if(!$addon_path)
150
+		if (!$addon_path)
151 151
 		{
152 152
 			return;
153 153
 		}
154 154
 
155 155
 		// Read the xml file for module skin information
156 156
 		$xml_file = sprintf("%sconf/info.xml", FileHandler::getRealpath($addon_path));
157
-		if(!file_exists($xml_file))
157
+		if (!file_exists($xml_file))
158 158
 		{
159 159
 			return;
160 160
 		}
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		$tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file);
164 164
 		$xml_obj = $tmp_xml_obj->addon;
165 165
 
166
-		if(!$xml_obj)
166
+		if (!$xml_obj)
167 167
 		{
168 168
 			return;
169 169
 		}
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		// DB is set to bring history
172 172
 		$db_args = new stdClass();
173 173
 		$db_args->addon = $addon;
174
-		if($gtype == 'global')
174
+		if ($gtype == 'global')
175 175
 		{
176 176
 			$output = executeQuery('addon.getAddonInfo', $db_args);
177 177
 		}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		$extra_vals = unserialize($output->data->extra_vars);
184 184
 
185 185
 		$addon_info = new stdClass();
186
-		if($extra_vals->mid_list)
186
+		if ($extra_vals->mid_list)
187 187
 		{
188 188
 			$addon_info->mid_list = $extra_vals->mid_list;
189 189
 		}
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
 			$addon_info->mid_list = array();
193 193
 		}
194 194
 
195
-		if($extra_vals->xe_run_method)
195
+		if ($extra_vals->xe_run_method)
196 196
 		{
197 197
 			$addon_info->xe_run_method = $extra_vals->xe_run_method;
198 198
 		}
199 199
 
200 200
 		// Add information
201
-		if($xml_obj->version && $xml_obj->attrs->version == '0.2')
201
+		if ($xml_obj->version && $xml_obj->attrs->version == '0.2')
202 202
 		{
203 203
 			// addon format v0.2
204 204
 			$date_obj = new stdClass();
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 			$addon_info->license = $xml_obj->license->body;
214 214
 			$addon_info->license_link = $xml_obj->license->attrs->link;
215 215
 
216
-			if(!is_array($xml_obj->author))
216
+			if (!is_array($xml_obj->author))
217 217
 			{
218 218
 				$author_list = array();
219 219
 				$author_list[] = $xml_obj->author;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 			}
225 225
 
226 226
 			$addon_info->author = array();
227
-			foreach($author_list as $author)
227
+			foreach ($author_list as $author)
228 228
 			{
229 229
 				$author_obj = new stdClass();
230 230
 				$author_obj->name = $author->name->body;
@@ -234,39 +234,39 @@  discard block
 block discarded – undo
234 234
 			}
235 235
 
236 236
 			// Expand the variable order
237
-			if($xml_obj->extra_vars)
237
+			if ($xml_obj->extra_vars)
238 238
 			{
239 239
 				$extra_var_groups = $xml_obj->extra_vars->group;
240
-				if(!$extra_var_groups)
240
+				if (!$extra_var_groups)
241 241
 				{
242 242
 					$extra_var_groups = $xml_obj->extra_vars;
243 243
 				}
244
-				if(!is_array($extra_var_groups))
244
+				if (!is_array($extra_var_groups))
245 245
 				{
246 246
 					$extra_var_groups = array($extra_var_groups);
247 247
 				}
248 248
 
249
-				foreach($extra_var_groups as $group)
249
+				foreach ($extra_var_groups as $group)
250 250
 				{
251 251
 					$extra_vars = $group->var;
252
-					if(!is_array($group->var))
252
+					if (!is_array($group->var))
253 253
 					{
254 254
 						$extra_vars = array($group->var);
255 255
 					}
256 256
 
257
-					foreach($extra_vars as $key => $val)
257
+					foreach ($extra_vars as $key => $val)
258 258
 					{
259
-						if(!$val)
259
+						if (!$val)
260 260
 						{
261 261
 							continue;
262 262
 						}
263 263
 
264 264
 						$obj = new stdClass();
265
-						if(!$val->attrs)
265
+						if (!$val->attrs)
266 266
 						{
267 267
 							$val->attrs = new stdClass();
268 268
 						}
269
-						if(!$val->attrs->type)
269
+						if (!$val->attrs->type)
270 270
 						{
271 271
 							$val->attrs->type = 'text';
272 272
 						}
@@ -276,26 +276,26 @@  discard block
 block discarded – undo
276 276
 						$obj->title = $val->title->body;
277 277
 						$obj->type = $val->attrs->type;
278 278
 						$obj->description = $val->description->body;
279
-						if($obj->name)
279
+						if ($obj->name)
280 280
 						{
281 281
 							$obj->value = $extra_vals->{$obj->name};
282 282
 						}
283
-						if(strpos($obj->value, '|@|') != FALSE)
283
+						if (strpos($obj->value, '|@|') != FALSE)
284 284
 						{
285 285
 							$obj->value = explode('|@|', $obj->value);
286 286
 						}
287
-						if($obj->type == 'mid_list' && !is_array($obj->value))
287
+						if ($obj->type == 'mid_list' && !is_array($obj->value))
288 288
 						{
289 289
 							$obj->value = array($obj->value);
290 290
 						}
291 291
 
292 292
 						// 'Select'type obtained from the option list.
293
-						if($val->options && !is_array($val->options))
293
+						if ($val->options && !is_array($val->options))
294 294
 						{
295 295
 							$val->options = array($val->options);
296 296
 						}
297 297
 
298
-						for($i = 0, $c = count($val->options); $i < $c; $i++)
298
+						for ($i = 0, $c = count($val->options); $i < $c; $i++)
299 299
 						{
300 300
 							$obj->options[$i] = new stdClass();
301 301
 							$obj->options[$i]->title = $val->options[$i]->title->body;
@@ -328,30 +328,30 @@  discard block
 block discarded – undo
328 328
 			$addon_info->author = array();
329 329
 			$addon_info->author[] = $author_obj;
330 330
 
331
-			if($xml_obj->extra_vars)
331
+			if ($xml_obj->extra_vars)
332 332
 			{
333 333
 				// Expand the variable order
334 334
 				$extra_var_groups = $xml_obj->extra_vars->group;
335
-				if(!$extra_var_groups)
335
+				if (!$extra_var_groups)
336 336
 				{
337 337
 					$extra_var_groups = $xml_obj->extra_vars;
338 338
 				}
339
-				if(!is_array($extra_var_groups))
339
+				if (!is_array($extra_var_groups))
340 340
 				{
341 341
 					$extra_var_groups = array($extra_var_groups);
342 342
 				}
343
-				foreach($extra_var_groups as $group)
343
+				foreach ($extra_var_groups as $group)
344 344
 				{
345 345
 					$extra_vars = $group->var;
346
-					if(!is_array($group->var))
346
+					if (!is_array($group->var))
347 347
 					{
348 348
 						$extra_vars = array($group->var);
349 349
 					}
350 350
 
351 351
 					$addon_info->extra_vars = array();
352
-					foreach($extra_vars as $key => $val)
352
+					foreach ($extra_vars as $key => $val)
353 353
 					{
354
-						if(!$val)
354
+						if (!$val)
355 355
 						{
356 356
 							continue;
357 357
 						}
@@ -363,26 +363,26 @@  discard block
 block discarded – undo
363 363
 						$obj->title = $val->title->body;
364 364
 						$obj->type = $val->type->body ? $val->type->body : 'text';
365 365
 						$obj->description = $val->description->body;
366
-						if($obj->name)
366
+						if ($obj->name)
367 367
 						{
368 368
 							$obj->value = $extra_vals->{$obj->name};
369 369
 						}
370
-						if(strpos($obj->value, '|@|') != false)
370
+						if (strpos($obj->value, '|@|') != false)
371 371
 						{
372 372
 							$obj->value = explode('|@|', $obj->value);
373 373
 						}
374
-						if($obj->type == 'mid_list' && !is_array($obj->value))
374
+						if ($obj->type == 'mid_list' && !is_array($obj->value))
375 375
 						{
376 376
 							$obj->value = array($obj->value);
377 377
 						}
378 378
 						// 'Select'type obtained from the option list.
379
-						if($val->options && !is_array($val->options))
379
+						if ($val->options && !is_array($val->options))
380 380
 						{
381 381
 							$val->options = array($val->options);
382 382
 						}
383 383
 
384 384
 						$obj->options = array();
385
-						for($i = 0, $c = count($val->options); $i < $c; $i++)
385
+						for ($i = 0, $c = count($val->options); $i < $c; $i++)
386 386
 						{
387 387
 							$obj->options[$i]->title = $val->options[$i]->title->body;
388 388
 							$obj->options[$i]->value = $val->options[$i]->value->body;
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 	{
407 407
 		$args = new stdClass();
408 408
 		$args->list_order = 'addon';
409
-		if($gtype == 'global')
409
+		if ($gtype == 'global')
410 410
 		{
411 411
 			$output = executeQueryArray('addon.getAddons', $args);
412 412
 		}
@@ -415,14 +415,14 @@  discard block
 block discarded – undo
415 415
 			$args->site_srl = $site_srl;
416 416
 			$output = executeQueryArray('addon.getSiteAddons', $args);
417 417
 		}
418
-		if(!$output->data)
418
+		if (!$output->data)
419 419
 		{
420 420
 			return array();
421 421
 		}
422 422
 
423 423
 		$activated_count = count($output->data);
424 424
 		$addon_list = array();
425
-		for($i = 0; $i < $activated_count; $i++)
425
+		for ($i = 0; $i < $activated_count; $i++)
426 426
 		{
427 427
 			$addon = $output->data[$i];
428 428
 			$addon_list[$addon->addon] = $addon;
@@ -443,9 +443,9 @@  discard block
 block discarded – undo
443 443
 	{
444 444
 		$args = new stdClass();
445 445
 		$args->addon = $addon;
446
-		if($gtype == 'global')
446
+		if ($gtype == 'global')
447 447
 		{
448
-			if($type == "pc")
448
+			if ($type == "pc")
449 449
 			{
450 450
 				$output = executeQuery('addon.getAddonIsActivated', $args);
451 451
 			}
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 		else
458 458
 		{
459 459
 			$args->site_srl = $site_srl;
460
-			if($type == "pc")
460
+			if ($type == "pc")
461 461
 			{
462 462
 				$output = executeQuery('addon.getSiteAddonIsActivated', $args);
463 463
 			}
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 				$output = executeQuery('addon.getSiteMAddonIsActivated', $args);
467 467
 			}
468 468
 		}
469
-		if($output->data->count > 0)
469
+		if ($output->data->count > 0)
470 470
 		{
471 471
 			return TRUE;
472 472
 		}
Please login to merge, or discard this patch.
Braces   +12 added lines, -19 removed lines patch added patch discarded remove patch
@@ -100,7 +100,9 @@  discard block
 block discarded – undo
100 100
 			// Wanted information on the add-on
101 101
 			$info = $this->getAddonInfoXml($addon_name, $site_srl, $gtype);
102 102
 			
103
-			if(!$info) $info = new stdClass();
103
+			if(!$info) {
104
+				$info = new stdClass();
105
+			}
104 106
 
105 107
 			$info->addon = $addon_name;
106 108
 			$info->path = $path;
@@ -113,8 +115,7 @@  discard block
 block discarded – undo
113 115
 				// If not, type in the DB type (model, perhaps because of the hate doing this haneungeo .. ㅡ. ㅜ)
114 116
 				$oAddonAdminController->doInsert($addon_name, $site_srl, $type);
115 117
 				// Is activated
116
-			}
117
-			else
118
+			} else
118 119
 			{
119 120
 				if($inserted_addons[$addon_name]->is_used == 'Y')
120 121
 				{
@@ -174,8 +175,7 @@  discard block
 block discarded – undo
174 175
 		if($gtype == 'global')
175 176
 		{
176 177
 			$output = executeQuery('addon.getAddonInfo', $db_args);
177
-		}
178
-		else
178
+		} else
179 179
 		{
180 180
 			$db_args->site_srl = $site_srl;
181 181
 			$output = executeQuery('addon.getSiteAddonInfo', $db_args);
@@ -186,8 +186,7 @@  discard block
 block discarded – undo
186 186
 		if($extra_vals->mid_list)
187 187
 		{
188 188
 			$addon_info->mid_list = $extra_vals->mid_list;
189
-		}
190
-		else
189
+		} else
191 190
 		{
192 191
 			$addon_info->mid_list = array();
193 192
 		}
@@ -217,8 +216,7 @@  discard block
 block discarded – undo
217 216
 			{
218 217
 				$author_list = array();
219 218
 				$author_list[] = $xml_obj->author;
220
-			}
221
-			else
219
+			} else
222 220
 			{
223 221
 				$author_list = $xml_obj->author;
224 222
 			}
@@ -306,8 +304,7 @@  discard block
 block discarded – undo
306 304
 					}
307 305
 				}
308 306
 			}
309
-		}
310
-		else
307
+		} else
311 308
 		{
312 309
 			// addon format 0.1
313 310
 			$addon_info = new stdClass();
@@ -409,8 +406,7 @@  discard block
 block discarded – undo
409 406
 		if($gtype == 'global')
410 407
 		{
411 408
 			$output = executeQueryArray('addon.getAddons', $args);
412
-		}
413
-		else
409
+		} else
414 410
 		{
415 411
 			$args->site_srl = $site_srl;
416 412
 			$output = executeQueryArray('addon.getSiteAddons', $args);
@@ -448,20 +444,17 @@  discard block
 block discarded – undo
448 444
 			if($type == "pc")
449 445
 			{
450 446
 				$output = executeQuery('addon.getAddonIsActivated', $args);
451
-			}
452
-			else
447
+			} else
453 448
 			{
454 449
 				$output = executeQuery('addon.getMAddonIsActivated', $args);
455 450
 			}
456
-		}
457
-		else
451
+		} else
458 452
 		{
459 453
 			$args->site_srl = $site_srl;
460 454
 			if($type == "pc")
461 455
 			{
462 456
 				$output = executeQuery('addon.getSiteAddonIsActivated', $args);
463
-			}
464
-			else
457
+			} else
465 458
 			{
466 459
 				$output = executeQuery('addon.getSiteMAddonIsActivated', $args);
467 460
 			}
Please login to merge, or discard this patch.
modules/admin/admin.admin.controller.php 3 patches
Doc Comments   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 	/**
15 15
 	 * initialization
16
-	 * @return void
16
+	 * @return ModuleObject|null
17 17
 	 */
18 18
 	function init()
19 19
 	{
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
 	/**
54 54
 	 * Regenerate all cache files
55
-	 * @return void
55
+	 * @return Object|null
56 56
 	 */
57 57
 	function procAdminRecompileCacheFile()
58 58
 	{
@@ -207,6 +207,9 @@  discard block
 block discarded – undo
207 207
 		return new Object();
208 208
 	}
209 209
 
210
+	/**
211
+	 * @param stdClass $designInfo
212
+	 */
210 213
 	function makeDefaultDesignFile($designInfo, $site_srl = 0)
211 214
 	{
212 215
 		$buff = array();
@@ -433,6 +436,8 @@  discard block
 block discarded – undo
433 436
 
434 437
 	/**
435 438
 	 * Insert favorite
439
+	 * @param string $siteSrl
440
+	 * @param string $module
436 441
 	 * @return object query result
437 442
 	 */
438 443
 	function _insertFavorite($siteSrl, $module, $type = 'module')
@@ -471,7 +476,7 @@  discard block
 block discarded – undo
471 476
 
472 477
 	/**
473 478
 	 * Remove admin icon
474
-	 * @return object|void
479
+	 * @return Object|null
475 480
 	 */
476 481
 	function procAdminRemoveIcons()
477 482
 	{
Please login to merge, or discard this patch.
Braces   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -181,8 +181,7 @@  discard block
 block discarded – undo
181 181
 		if(is_readable($siteDesignFile))
182 182
 		{
183 183
 			include($siteDesignFile);
184
-		}
185
-		else
184
+		} else
186 185
 		{
187 186
 			$designInfo = new stdClass();
188 187
 		}
@@ -198,7 +197,9 @@  discard block
 block discarded – undo
198 197
 				$moduleName = 'page';
199 198
 			}
200 199
 
201
-			if(!isset($designInfo->module->{$moduleName})) $designInfo->module->{$moduleName} = new stdClass();
200
+			if(!isset($designInfo->module->{$moduleName})) {
201
+				$designInfo->module->{$moduleName} = new stdClass();
202
+			}
202 203
 			$designInfo->module->{$moduleName}->{$skinTarget} = $skinName;
203 204
 		}
204 205
 
@@ -337,8 +338,7 @@  discard block
 block discarded – undo
337 338
 		if($isAgree == 'true')
338 339
 		{
339 340
 			$_SESSION['enviroment_gather'] = 'Y';
340
-		}
341
-		else
341
+		} else
342 342
 		{
343 343
 			$_SESSION['enviroment_gather'] = 'N';
344 344
 		}
@@ -374,12 +374,10 @@  discard block
 block discarded – undo
374 374
 			if($type == 3)
375 375
 			{
376 376
 				$ext = 'png';
377
-			}
378
-			elseif($type == 2)
377
+			} elseif($type == 2)
379 378
 			{
380 379
 				$ext = 'jpg';
381
-			}
382
-			else
380
+			} else
383 381
 			{
384 382
 				$ext = 'gif';
385 383
 			}
@@ -392,8 +390,7 @@  discard block
 block discarded – undo
392 390
 		if($adminTitle)
393 391
 		{
394 392
 			$oAdminConfig->adminTitle = strip_tags($adminTitle);
395
-		}
396
-		else
393
+		} else
397 394
 		{
398 395
 			unset($oAdminConfig->adminTitle);
399 396
 		}
@@ -488,8 +485,7 @@  discard block
 block discarded – undo
488 485
 		if($file_exist)
489 486
 		{
490 487
 			@FileHandler::removeFile(_XE_PATH_ . 'files/attach/xeicon/' . $virtual_site . $iconname);
491
-		}
492
-		else
488
+		} else
493 489
 		{
494 490
 			return new Object(-1, 'fail_to_delete');
495 491
 		}
@@ -533,7 +529,9 @@  discard block
 block discarded – undo
533 529
 		if(!in_array(Context::getRequestMethod(), array('XMLRPC','JSON')))
534 530
 		{
535 531
 			$returnUrl = Context::get('success_return_url');
536
-			if(!$returnUrl) $returnUrl = getNotEncodedUrl('', 'act', 'dispAdminConfigGeneral');
532
+			if(!$returnUrl) {
533
+				$returnUrl = getNotEncodedUrl('', 'act', 'dispAdminConfigGeneral');
534
+			}
537 535
 			header('location:' . $returnUrl);
538 536
 			return;
539 537
 		}
@@ -577,7 +575,9 @@  discard block
 block discarded – undo
577 575
 		if(!in_array(Context::getRequestMethod(), array('XMLRPC','JSON')))
578 576
 		{
579 577
 			$returnUrl = Context::get('success_return_url');
580
-			if(!$returnUrl) $returnUrl = getNotEncodedUrl('', 'act', 'dispAdminConfigGeneral');
578
+			if(!$returnUrl) {
579
+				$returnUrl = getNotEncodedUrl('', 'act', 'dispAdminConfigGeneral');
580
+			}
581 581
 			header('location:' . $returnUrl);
582 582
 			return;
583 583
 		}
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 		// forbit access if the user is not an administrator
21 21
 		$oMemberModel = getModel('member');
22 22
 		$logged_info = $oMemberModel->getLoggedInfo();
23
-		if($logged_info->is_admin != 'Y')
23
+		if ($logged_info->is_admin != 'Y')
24 24
 		{
25 25
 			return $this->stop("msg_is_not_administrator");
26 26
 		}
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 	function procAdminMenuReset()
34 34
 	{
35 35
 		$menuSrl = Context::get('menu_srl');
36
-		if(!$menuSrl)
36
+		if (!$menuSrl)
37 37
 		{
38 38
 			return $this->stop('msg_invalid_request');
39 39
 		}
40 40
 
41 41
 		$oMenuAdminController = getAdminController('menu');
42 42
 		$output = $oMenuAdminController->deleteMenu($menuSrl);
43
-		if(!$output->toBool())
43
+		if (!$output->toBool())
44 44
 		{
45 45
 			return $output;
46 46
 		}
@@ -57,27 +57,27 @@  discard block
 block discarded – undo
57 57
 	function procAdminRecompileCacheFile()
58 58
 	{
59 59
 		// rename cache dir
60
-		$temp_cache_dir = './files/cache_' . $_SERVER['REQUEST_TIME'];
60
+		$temp_cache_dir = './files/cache_'.$_SERVER['REQUEST_TIME'];
61 61
 		FileHandler::rename('./files/cache', $temp_cache_dir);
62 62
 		FileHandler::makeDir('./files/cache');
63 63
 
64 64
 		// remove module extend cache
65
-		FileHandler::removeFile(_XE_PATH_ . 'files/config/module_extend.php');
65
+		FileHandler::removeFile(_XE_PATH_.'files/config/module_extend.php');
66 66
 
67 67
 		// remove debug files
68
-		FileHandler::removeFile(_XE_PATH_ . 'files/_debug_message.php');
69
-		FileHandler::removeFile(_XE_PATH_ . 'files/_debug_db_query.php');
70
-		FileHandler::removeFile(_XE_PATH_ . 'files/_db_slow_query.php');
68
+		FileHandler::removeFile(_XE_PATH_.'files/_debug_message.php');
69
+		FileHandler::removeFile(_XE_PATH_.'files/_debug_db_query.php');
70
+		FileHandler::removeFile(_XE_PATH_.'files/_db_slow_query.php');
71 71
 
72 72
 		$oModuleModel = getModel('module');
73 73
 		$module_list = $oModuleModel->getModuleList();
74 74
 
75 75
 		// call recompileCache for each module
76
-		foreach($module_list as $module)
76
+		foreach ($module_list as $module)
77 77
 		{
78 78
 			$oModule = NULL;
79 79
 			$oModule = getClass($module->module);
80
-			if(method_exists($oModule, 'recompileCache'))
80
+			if (method_exists($oModule, 'recompileCache'))
81 81
 			{
82 82
 				$oModule->recompileCache();
83 83
 			}
@@ -88,37 +88,37 @@  discard block
 block discarded – undo
88 88
 		$oObjectCacheHandler = CacheHandler::getInstance('object');
89 89
 		$oTemplateCacheHandler = CacheHandler::getInstance('template');
90 90
 
91
-		if($oObjectCacheHandler->isSupport())
91
+		if ($oObjectCacheHandler->isSupport())
92 92
 		{
93 93
 			$truncated[] = $oObjectCacheHandler->truncate();
94 94
 		}
95 95
 
96
-		if($oTemplateCacheHandler->isSupport())
96
+		if ($oTemplateCacheHandler->isSupport())
97 97
 		{
98 98
 			$truncated[] = $oTemplateCacheHandler->truncate();
99 99
 		}
100 100
 
101
-		if(count($truncated) && in_array(FALSE, $truncated))
101
+		if (count($truncated) && in_array(FALSE, $truncated))
102 102
 		{
103 103
 			return new Object(-1, 'msg_self_restart_cache_engine');
104 104
 		}
105 105
 
106 106
 		// remove cache dir
107 107
 		$tmp_cache_list = FileHandler::readDir('./files', '/(^cache_[0-9]+)/');
108
-		if($tmp_cache_list)
108
+		if ($tmp_cache_list)
109 109
 		{
110
-			foreach($tmp_cache_list as $tmp_dir)
110
+			foreach ($tmp_cache_list as $tmp_dir)
111 111
 			{
112
-				if($tmp_dir)
112
+				if ($tmp_dir)
113 113
 				{
114
-					FileHandler::removeDir('./files/' . $tmp_dir);
114
+					FileHandler::removeDir('./files/'.$tmp_dir);
115 115
 				}
116 116
 			}
117 117
 		}
118 118
 
119 119
 		// remove duplicate indexes (only for CUBRID)
120 120
 		$db_type = Context::getDBType();
121
-		if($db_type == 'cubrid')
121
+		if ($db_type == 'cubrid')
122 122
 		{
123 123
 			$db = DB::getInstance();
124 124
 			$db->deleteDuplicateIndexes();
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
 		$oMemberController = getController('member');
141 141
 		$oMemberController->procMemberLogout();
142 142
 
143
-		header('Location: ' . getNotEncodedUrl('', 'module', 'admin'));
143
+		header('Location: '.getNotEncodedUrl('', 'module', 'admin'));
144 144
 	}
145 145
 
146 146
 	public function procAdminInsertDefaultDesignInfo()
147 147
 	{
148 148
 		$vars = Context::getRequestVars();
149
-		if(!$vars->site_srl)
149
+		if (!$vars->site_srl)
150 150
 		{
151 151
 			$vars->site_srl = 0;
152 152
 		}
@@ -158,27 +158,27 @@  discard block
 block discarded – undo
158 158
 
159 159
 	public function updateDefaultDesignInfo($vars)
160 160
 	{
161
-		$siteDesignPath = _XE_PATH_ . 'files/site_design/';
161
+		$siteDesignPath = _XE_PATH_.'files/site_design/';
162 162
 
163 163
 		$vars->module_skin = json_decode($vars->module_skin);
164 164
 
165
-		if(!is_dir($siteDesignPath))
165
+		if (!is_dir($siteDesignPath))
166 166
 		{
167 167
 			FileHandler::makeDir($siteDesignPath);
168 168
 		}
169 169
 
170
-		$siteDesignFile = _XE_PATH_ . 'files/site_design/design_' . $vars->site_srl . '.php';
170
+		$siteDesignFile = _XE_PATH_.'files/site_design/design_'.$vars->site_srl.'.php';
171 171
 
172 172
 		$layoutTarget = 'layout_srl';
173 173
 		$skinTarget = 'skin';
174 174
 
175
-		if($vars->target_type == 'M')
175
+		if ($vars->target_type == 'M')
176 176
 		{
177 177
 			$layoutTarget = 'mlayout_srl';
178 178
 			$skinTarget = 'mskin';
179 179
 		}
180 180
 
181
-		if(is_readable($siteDesignFile))
181
+		if (is_readable($siteDesignFile))
182 182
 		{
183 183
 			include($siteDesignFile);
184 184
 		}
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
 
192 192
 		$designInfo->{$layoutTarget} = $layoutSrl;
193 193
 
194
-		foreach($vars->module_skin as $moduleName => $skinName)
194
+		foreach ($vars->module_skin as $moduleName => $skinName)
195 195
 		{
196
-			if($moduleName == 'ARTICLE')
196
+			if ($moduleName == 'ARTICLE')
197 197
 			{
198 198
 				$moduleName = 'page';
199 199
 			}
200 200
 
201
-			if(!isset($designInfo->module->{$moduleName})) $designInfo->module->{$moduleName} = new stdClass();
201
+			if (!isset($designInfo->module->{$moduleName})) $designInfo->module->{$moduleName} = new stdClass();
202 202
 			$designInfo->module->{$moduleName}->{$skinTarget} = $skinName;
203 203
 		}
204 204
 
@@ -213,28 +213,28 @@  discard block
 block discarded – undo
213 213
 		$buff[] = '<?php if(!defined("__XE__")) exit();';
214 214
 		$buff[] = '$designInfo = new stdClass;';
215 215
 
216
-		if($designInfo->layout_srl)
216
+		if ($designInfo->layout_srl)
217 217
 		{
218 218
 			$buff[] = sprintf('$designInfo->layout_srl = %s; ', $designInfo->layout_srl);
219 219
 		}
220 220
 
221
-		if($designInfo->mlayout_srl)
221
+		if ($designInfo->mlayout_srl)
222 222
 		{
223 223
 			$buff[] = sprintf('$designInfo->mlayout_srl = %s;', $designInfo->mlayout_srl);
224 224
 		}
225 225
 
226 226
 		$buff[] = '$designInfo->module = new stdClass;';
227 227
 
228
-		foreach($designInfo->module as $moduleName => $skinInfo)
228
+		foreach ($designInfo->module as $moduleName => $skinInfo)
229 229
 		{
230 230
 			$buff[] = sprintf('$designInfo->module->%s = new stdClass;', $moduleName);
231
-			foreach($skinInfo as $target => $skinName)
231
+			foreach ($skinInfo as $target => $skinName)
232 232
 			{
233 233
 				$buff[] = sprintf('$designInfo->module->%s->%s = \'%s\';', $moduleName, $target, $skinName);
234 234
 			}
235 235
 		}
236 236
 
237
-		$siteDesignFile = _XE_PATH_ . 'files/site_design/design_' . $site_srl . '.php';
237
+		$siteDesignFile = _XE_PATH_.'files/site_design/design_'.$site_srl.'.php';
238 238
 		FileHandler::writeFile($siteDesignFile, implode(PHP_EOL, $buff));
239 239
 	}
240 240
 
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
 		// check favorite exists
251 251
 		$oModel = getAdminModel('admin');
252 252
 		$output = $oModel->isExistsFavorite($siteSrl, $moduleName);
253
-		if(!$output->toBool())
253
+		if (!$output->toBool())
254 254
 		{
255 255
 			return $output;
256 256
 		}
257 257
 
258 258
 		// if exists, delete favorite
259
-		if($output->get('result'))
259
+		if ($output->get('result'))
260 260
 		{
261 261
 			$favoriteSrl = $output->get('favoriteSrl');
262 262
 			$output = $this->_deleteFavorite($favoriteSrl);
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 			$result = 'on';
270 270
 		}
271 271
 
272
-		if(!$output->toBool())
272
+		if (!$output->toBool())
273 273
 		{
274 274
 			return $output;
275 275
 		}
@@ -287,31 +287,31 @@  discard block
 block discarded – undo
287 287
 	{
288 288
 		$oModel = getAdminModel('admin');
289 289
 		$output = $oModel->getFavoriteList();
290
-		if(!$output->toBool())
290
+		if (!$output->toBool())
291 291
 		{
292 292
 			return $output;
293 293
 		}
294 294
 
295 295
 		$favoriteList = $output->get('favoriteList');
296
-		if(!$favoriteList)
296
+		if (!$favoriteList)
297 297
 		{
298 298
 			return new Object();
299 299
 		}
300 300
 
301 301
 		$deleteTargets = array();
302
-		foreach($favoriteList as $favorite)
302
+		foreach ($favoriteList as $favorite)
303 303
 		{
304
-			if($favorite->type == 'module')
304
+			if ($favorite->type == 'module')
305 305
 			{
306
-				$modulePath = _XE_PATH_ . 'modules/' . $favorite->module;
307
-				if(!is_dir($modulePath))
306
+				$modulePath = _XE_PATH_.'modules/'.$favorite->module;
307
+				if (!is_dir($modulePath))
308 308
 				{
309 309
 					$deleteTargets[] = $favorite->admin_favorite_srl;
310 310
 				}
311 311
 			}
312 312
 		}
313 313
 
314
-		if(!count($deleteTargets))
314
+		if (!count($deleteTargets))
315 315
 		{
316 316
 			return new Object();
317 317
 		}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		$args = new stdClass();
320 320
 		$args->admin_favorite_srls = $deleteTargets;
321 321
 		$output = executeQuery('admin.deleteFavorites', $args);
322
-		if(!$output->toBool())
322
+		if (!$output->toBool())
323 323
 		{
324 324
 			return $output;
325 325
 		}
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	function procAdminEnviromentGatheringAgreement()
335 335
 	{
336 336
 		$isAgree = Context::get('is_agree');
337
-		if($isAgree == 'true')
337
+		if ($isAgree == 'true')
338 338
 		{
339 339
 			$_SESSION['enviroment_gather'] = 'Y';
340 340
 		}
@@ -359,23 +359,23 @@  discard block
 block discarded – undo
359 359
 		$oModuleModel = getModel('module');
360 360
 		$oAdminConfig = $oModuleModel->getModuleConfig('admin');
361 361
 
362
-		if(!is_object($oAdminConfig))
362
+		if (!is_object($oAdminConfig))
363 363
 		{
364 364
 			$oAdminConfig = new stdClass();
365 365
 		}
366 366
 
367
-		if($file['tmp_name'])
367
+		if ($file['tmp_name'])
368 368
 		{
369 369
 			$target_path = 'files/attach/images/admin/';
370 370
 			FileHandler::makeDir($target_path);
371 371
 
372 372
 			// Get file information
373 373
 			list($width, $height, $type, $attrs) = @getimagesize($file['tmp_name']);
374
-			if($type == 3)
374
+			if ($type == 3)
375 375
 			{
376 376
 				$ext = 'png';
377 377
 			}
378
-			elseif($type == 2)
378
+			elseif ($type == 2)
379 379
 			{
380 380
 				$ext = 'jpg';
381 381
 			}
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 
390 390
 			$oAdminConfig->adminLogo = $target_filename;
391 391
 		}
392
-		if($adminTitle)
392
+		if ($adminTitle)
393 393
 		{
394 394
 			$oAdminConfig->adminTitle = strip_tags($adminTitle);
395 395
 		}
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 			unset($oAdminConfig->adminTitle);
399 399
 		}
400 400
 
401
-		if($oAdminConfig)
401
+		if ($oAdminConfig)
402 402
 		{
403 403
 			$oModuleController = getController('module');
404 404
 			$oModuleController->insertModuleConfig('admin', $oAdminConfig);
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 		$oModuleModel = getModel('module');
420 420
 		$oAdminConfig = $oModuleModel->getModuleConfig('admin');
421 421
 
422
-		FileHandler::removeFile(_XE_PATH_ . $oAdminConfig->adminLogo);
422
+		FileHandler::removeFile(_XE_PATH_.$oAdminConfig->adminLogo);
423 423
 		unset($oAdminConfig->adminLogo);
424 424
 
425 425
 		$oModuleController = getController('module');
@@ -478,16 +478,16 @@  discard block
 block discarded – undo
478 478
 
479 479
 		$site_info = Context::get('site_module_info');
480 480
 		$virtual_site = '';
481
-		if($site_info->site_srl) 
481
+		if ($site_info->site_srl) 
482 482
 		{
483
-			$virtual_site = $site_info->site_srl . '/';
483
+			$virtual_site = $site_info->site_srl.'/';
484 484
 		}
485 485
 
486 486
 		$iconname = Context::get('iconname');
487
-		$file_exist = FileHandler::readFile(_XE_PATH_ . 'files/attach/xeicon/' . $virtual_site . $iconname);
488
-		if($file_exist)
487
+		$file_exist = FileHandler::readFile(_XE_PATH_.'files/attach/xeicon/'.$virtual_site.$iconname);
488
+		if ($file_exist)
489 489
 		{
490
-			@FileHandler::removeFile(_XE_PATH_ . 'files/attach/xeicon/' . $virtual_site . $iconname);
490
+			@FileHandler::removeFile(_XE_PATH_.'files/attach/xeicon/'.$virtual_site.$iconname);
491 491
 		}
492 492
 		else
493 493
 		{
@@ -508,33 +508,33 @@  discard block
 block discarded – undo
508 508
 		$db_info->sitelock_message = $vars->sitelock_message;
509 509
 
510 510
 		$whitelist = $vars->sitelock_whitelist;
511
-		$whitelist = preg_replace("/[\r|\n|\r\n]+/",",",$whitelist);
512
-		$whitelist = preg_replace("/\s+/","",$whitelist);
513
-		if(preg_match('/(<\?|<\?php|\?>)/xsm', $whitelist))
511
+		$whitelist = preg_replace("/[\r|\n|\r\n]+/", ",", $whitelist);
512
+		$whitelist = preg_replace("/\s+/", "", $whitelist);
513
+		if (preg_match('/(<\?|<\?php|\?>)/xsm', $whitelist))
514 514
 		{
515 515
 			$whitelist = '';
516 516
 		}
517
-		$whitelist .= ',127.0.0.1,' . $_SERVER['REMOTE_ADDR'];
518
-		$whitelist = explode(',',trim($whitelist, ','));
517
+		$whitelist .= ',127.0.0.1,'.$_SERVER['REMOTE_ADDR'];
518
+		$whitelist = explode(',', trim($whitelist, ','));
519 519
 		$whitelist = array_unique($whitelist);
520 520
 
521
-		if(!IpFilter::validate($whitelist)) {
521
+		if (!IpFilter::validate($whitelist)) {
522 522
 			return new Object(-1, 'msg_invalid_ip');
523 523
 		}
524 524
 
525 525
 		$db_info->sitelock_whitelist = $whitelist;
526 526
 
527 527
 		$oInstallController = getController('install');
528
-		if(!$oInstallController->makeConfigFile())
528
+		if (!$oInstallController->makeConfigFile())
529 529
 		{
530 530
 			return new Object(-1, 'msg_invalid_request');
531 531
 		}
532 532
 
533
-		if(!in_array(Context::getRequestMethod(), array('XMLRPC','JSON')))
533
+		if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON')))
534 534
 		{
535 535
 			$returnUrl = Context::get('success_return_url');
536
-			if(!$returnUrl) $returnUrl = getNotEncodedUrl('', 'act', 'dispAdminConfigGeneral');
537
-			header('location:' . $returnUrl);
536
+			if (!$returnUrl) $returnUrl = getNotEncodedUrl('', 'act', 'dispAdminConfigGeneral');
537
+			header('location:'.$returnUrl);
538 538
 			return;
539 539
 		}
540 540
 	}
@@ -565,20 +565,20 @@  discard block
 block discarded – undo
565 565
 		$db_info->embed_white_iframe = $white_iframe;
566 566
 
567 567
 		$oInstallController = getController('install');
568
-		if(!$oInstallController->makeConfigFile())
568
+		if (!$oInstallController->makeConfigFile())
569 569
 		{
570 570
 			return new Object(-1, 'msg_invalid_request');
571 571
 		}
572 572
 
573
-		require_once(_XE_PATH_ . 'classes/security/EmbedFilter.class.php');
573
+		require_once(_XE_PATH_.'classes/security/EmbedFilter.class.php');
574 574
 		$oEmbedFilter = EmbedFilter::getInstance();
575 575
 		$oEmbedFilter->_makeWhiteDomainList($whitelist);
576 576
 
577
-		if(!in_array(Context::getRequestMethod(), array('XMLRPC','JSON')))
577
+		if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON')))
578 578
 		{
579 579
 			$returnUrl = Context::get('success_return_url');
580
-			if(!$returnUrl) $returnUrl = getNotEncodedUrl('', 'act', 'dispAdminConfigGeneral');
581
-			header('location:' . $returnUrl);
580
+			if (!$returnUrl) $returnUrl = getNotEncodedUrl('', 'act', 'dispAdminConfigGeneral');
581
+			header('location:'.$returnUrl);
582 582
 			return;
583 583
 		}
584 584
 	}
Please login to merge, or discard this patch.
modules/admin/admin.admin.model.php 4 patches
Doc Comments   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 	/**
277 277
 	 * Add file list to Object after sftp connect
278
-	 * @return void|Object
278
+	 * @return Object|null
279 279
 	 */
280 280
 	function getSFTPList()
281 281
 	{
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
 	/**
318 318
 	 * Add file list to Object after ftp connect
319
-	 * @return void|Object
319
+	 * @return Object|null
320 320
 	 */
321 321
 	function getAdminFTPList()
322 322
 	{
@@ -867,6 +867,7 @@  discard block
 block discarded – undo
867 867
 	 * Returns a list of all sites that contain modules
868 868
 	 * For each site domain and site_srl are retrieved
869 869
 	 *
870
+	 * @param string $domain
870 871
 	 * @return array
871 872
 	 */
872 873
 	function getAllSitesThatHaveModules($domain = NULL)
@@ -945,6 +946,11 @@  discard block
 block discarded – undo
945 946
 		return $this->iconUrlCheck('mobicon.png', 'mobiconSample.png', $default);
946 947
 	}
947 948
 
949
+	/**
950
+	 * @param string $iconname
951
+	 * @param string $default_icon_name
952
+	 * @param boolean $default
953
+	 */
948 954
 	function iconUrlCheck($iconname, $default_icon_name, $default)
949 955
 	{
950 956
 		$site_info = Context::get('site_module_info');
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -956,10 +956,10 @@
 block discarded – undo
956 956
 
957 957
 		$file_exsit = FileHandler::readFile(_XE_PATH_ . 'files/attach/xeicon/' . $virtual_site . $iconname);
958 958
 		if(!$file_exsit && $default === true)
959
-        {
960
-            $icon_url = './modules/admin/tpl/img/' . $default_icon_name;
961
-        }
962
-        elseif($file_exsit)
959
+		{
960
+			$icon_url = './modules/admin/tpl/img/' . $default_icon_name;
961
+		}
962
+		elseif($file_exsit)
963 963
 		{
964 964
 			$default_url = Context::getDefaultUrl();
965 965
 			if($default_url && substr_compare($default_url, '/', -1) === 0) $default_url = substr($default_url, 0, -1);
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -30,18 +30,18 @@  discard block
 block discarded – undo
30 30
 	{
31 31
 		$ftp_info = Context::getRequestVars();
32 32
 
33
-		if(!$ftp_info->ftp_host)
33
+		if (!$ftp_info->ftp_host)
34 34
 		{
35 35
 			$ftp_info->ftp_host = "127.0.0.1";
36 36
 		}
37 37
 
38
-		if(!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port))
38
+		if (!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port))
39 39
 		{
40 40
 			$ftp_info->ftp_port = '22';
41 41
 		}
42 42
 
43 43
 		$connection = ssh2_connect($ftp_info->ftp_host, $ftp_info->ftp_port);
44
-		if(!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password))
44
+		if (!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password))
45 45
 		{
46 46
 			return new Object(-1, 'msg_ftp_invalid_auth_info');
47 47
 		}
@@ -58,29 +58,29 @@  discard block
 block discarded – undo
58 58
 		$path_candidate = array();
59 59
 
60 60
 		$temp = '';
61
-		foreach($path_info as $path)
61
+		foreach ($path_info as $path)
62 62
 		{
63
-			$temp = '/' . $path . $temp;
63
+			$temp = '/'.$path.$temp;
64 64
 			$path_candidate[] = $temp;
65 65
 		}
66 66
 
67 67
 		// try
68
-		foreach($path_candidate as $path)
68
+		foreach ($path_candidate as $path)
69 69
 		{
70 70
 			// upload check file
71
-			if(!@ssh2_scp_send($connection, FileHandler::getRealPath('./files/cache/ftp_check'), $path . 'ftp_check.html'))
71
+			if (!@ssh2_scp_send($connection, FileHandler::getRealPath('./files/cache/ftp_check'), $path.'ftp_check.html'))
72 72
 			{
73 73
 				continue;
74 74
 			}
75 75
 
76 76
 			// get check file
77
-			$result = FileHandler::getRemoteResource(getNotencodedFullUrl() . 'ftp_check.html');
77
+			$result = FileHandler::getRemoteResource(getNotencodedFullUrl().'ftp_check.html');
78 78
 
79 79
 			// delete temp check file
80
-			@ssh2_sftp_unlink($sftp, $path . 'ftp_check.html');
80
+			@ssh2_sftp_unlink($sftp, $path.'ftp_check.html');
81 81
 
82 82
 			// found
83
-			if($result == $pin)
83
+			if ($result == $pin)
84 84
 			{
85 85
 				$found_path = $path;
86 86
 				break;
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
 		FileHandler::removeFile('./files/cache/ftp_check', $pin);
91 91
 
92
-		if($found_path)
92
+		if ($found_path)
93 93
 		{
94 94
 			$this->add('found_path', $found_path);
95 95
 		}
@@ -99,24 +99,24 @@  discard block
 block discarded – undo
99 99
 	{
100 100
 		$ftp_info = Context::getRequestVars();
101 101
 
102
-		if(!$ftp_info->ftp_host)
102
+		if (!$ftp_info->ftp_host)
103 103
 		{
104 104
 			$ftp_info->ftp_host = "127.0.0.1";
105 105
 		}
106 106
 
107
-		if(!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port))
107
+		if (!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port))
108 108
 		{
109 109
 			$ftp_info->ftp_port = '22';
110 110
 		}
111 111
 
112 112
 		$connection = ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port);
113
-		if(!$connection)
113
+		if (!$connection)
114 114
 		{
115 115
 			return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host'));
116 116
 		}
117 117
 
118 118
 		$login_result = @ftp_login($connection, $ftp_info->ftp_user, $ftp_info->ftp_password);
119
-		if(!$login_result)
119
+		if (!$login_result)
120 120
 		{
121 121
 			ftp_close($connection);
122 122
 			return new Object(-1, 'msg_ftp_invalid_auth_info');
@@ -133,29 +133,29 @@  discard block
 block discarded – undo
133 133
 		$path_candidate = array();
134 134
 
135 135
 		$temp = '';
136
-		foreach($path_info as $path)
136
+		foreach ($path_info as $path)
137 137
 		{
138
-			$temp = '/' . $path . $temp;
138
+			$temp = '/'.$path.$temp;
139 139
 			$path_candidate[] = $temp;
140 140
 		}
141 141
 
142 142
 		// try
143
-		foreach($path_candidate as $path)
143
+		foreach ($path_candidate as $path)
144 144
 		{
145 145
 			// upload check file
146
-			if(!ftp_put($connection, $path . 'ftp_check.html', FileHandler::getRealPath('./files/cache/ftp_check'), FTP_BINARY))
146
+			if (!ftp_put($connection, $path.'ftp_check.html', FileHandler::getRealPath('./files/cache/ftp_check'), FTP_BINARY))
147 147
 			{
148 148
 				continue;
149 149
 			}
150 150
 
151 151
 			// get check file
152
-			$result = FileHandler::getRemoteResource(getNotencodedFullUrl() . 'ftp_check.html');
152
+			$result = FileHandler::getRemoteResource(getNotencodedFullUrl().'ftp_check.html');
153 153
 
154 154
 			// delete temp check file
155
-			ftp_delete($connection, $path . 'ftp_check.html');
155
+			ftp_delete($connection, $path.'ftp_check.html');
156 156
 
157 157
 			// found
158
-			if($result == $pin)
158
+			if ($result == $pin)
159 159
 			{
160 160
 				$found_path = $path;
161 161
 				break;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 		FileHandler::removeFile('./files/cache/ftp_check', $pin);
166 166
 
167
-		if($found_path)
167
+		if ($found_path)
168 168
 		{
169 169
 			$this->add('found_path', $found_path);
170 170
 		}
@@ -175,39 +175,39 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	function getAdminFTPPath()
177 177
 	{
178
-		Context::loadLang(_XE_PATH_ . 'modules/autoinstall/lang');
178
+		Context::loadLang(_XE_PATH_.'modules/autoinstall/lang');
179 179
 		@set_time_limit(5);
180
-		require_once(_XE_PATH_ . 'libs/ftp.class.php');
180
+		require_once(_XE_PATH_.'libs/ftp.class.php');
181 181
 
182 182
 		$ftp_info = Context::getRequestVars();
183 183
 
184
-		if(!$ftp_info->ftp_user || !$ftp_info->ftp_password)
184
+		if (!$ftp_info->ftp_user || !$ftp_info->ftp_password)
185 185
 		{
186 186
 			return new Object(1, 'msg_ftp_invalid_auth_info');
187 187
 		}
188 188
 
189
-		if(!$ftp_info->ftp_host)
189
+		if (!$ftp_info->ftp_host)
190 190
 		{
191 191
 			$ftp_info->ftp_host = '127.0.0.1';
192 192
 		}
193 193
 
194
-		if(!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port))
194
+		if (!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port))
195 195
 		{
196 196
 			$ftp_info->ftp_port = '21';
197 197
 		}
198 198
 
199
-		if($ftp_info->sftp == 'Y')
199
+		if ($ftp_info->sftp == 'Y')
200 200
 		{
201
-			if(!function_exists('ssh2_sftp'))
201
+			if (!function_exists('ssh2_sftp'))
202 202
 			{
203 203
 				return new Object(-1, 'disable_sftp_support');
204 204
 			}
205 205
 			return $this->getSFTPPath();
206 206
 		}
207 207
 
208
-		if($ftp_info->ftp_pasv == 'N')
208
+		if ($ftp_info->ftp_pasv == 'N')
209 209
 		{
210
-			if(function_exists('ftp_connect'))
210
+			if (function_exists('ftp_connect'))
211 211
 			{
212 212
 				return $this->getFTPPath();
213 213
 			}
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 		}
216 216
 
217 217
 		$oFTP = new ftp();
218
-		if(!$oFTP->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port))
218
+		if (!$oFTP->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port))
219 219
 		{
220 220
 			return new Object(1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host'));
221 221
 		}
222 222
 
223
-		if(!$oFTP->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password))
223
+		if (!$oFTP->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password))
224 224
 		{
225 225
 			return new Object(1, 'msg_ftp_invalid_auth_info');
226 226
 		}
@@ -236,29 +236,29 @@  discard block
 block discarded – undo
236 236
 		$path_candidate = array();
237 237
 
238 238
 		$temp = '';
239
-		foreach($path_info as $path)
239
+		foreach ($path_info as $path)
240 240
 		{
241
-			$temp = '/' . $path . $temp;
241
+			$temp = '/'.$path.$temp;
242 242
 			$path_candidate[] = $temp;
243 243
 		}
244 244
 
245 245
 		// try
246
-		foreach($path_candidate as $path)
246
+		foreach ($path_candidate as $path)
247 247
 		{
248 248
 			// upload check file
249
-			if(!$oFTP->ftp_put($path . 'ftp_check.html', FileHandler::getRealPath('./files/cache/ftp_check')))
249
+			if (!$oFTP->ftp_put($path.'ftp_check.html', FileHandler::getRealPath('./files/cache/ftp_check')))
250 250
 			{
251 251
 				continue;
252 252
 			}
253 253
 
254 254
 			// get check file
255
-			$result = FileHandler::getRemoteResource(getNotencodedFullUrl() . 'ftp_check.html');
255
+			$result = FileHandler::getRemoteResource(getNotencodedFullUrl().'ftp_check.html');
256 256
 
257 257
 			// delete temp check file
258
-			$oFTP->ftp_delete($path . 'ftp_check.html');
258
+			$oFTP->ftp_delete($path.'ftp_check.html');
259 259
 
260 260
 			// found
261
-			if($result == $pin)
261
+			if ($result == $pin)
262 262
 			{
263 263
 				$found_path = $path;
264 264
 				break;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 
268 268
 		FileHandler::removeFile('./files/cache/ftp_check', $pin);
269 269
 
270
-		if($found_path)
270
+		if ($found_path)
271 271
 		{
272 272
 			$this->add('found_path', $found_path);
273 273
 		}
@@ -280,27 +280,27 @@  discard block
 block discarded – undo
280 280
 	function getSFTPList()
281 281
 	{
282 282
 		$ftp_info = Context::getRequestVars();
283
-		if(!$ftp_info->ftp_host)
283
+		if (!$ftp_info->ftp_host)
284 284
 		{
285 285
 			$ftp_info->ftp_host = "127.0.0.1";
286 286
 		}
287 287
 		$connection = ssh2_connect($ftp_info->ftp_host, $ftp_info->ftp_port);
288
-		if(!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password))
288
+		if (!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password))
289 289
 		{
290 290
 			return new Object(-1, 'msg_ftp_invalid_auth_info');
291 291
 		}
292 292
 
293 293
 		$sftp = ssh2_sftp($connection);
294
-		$curpwd = "ssh2.sftp://$sftp" . $this->pwd;
294
+		$curpwd = "ssh2.sftp://$sftp".$this->pwd;
295 295
 		$dh = @opendir($curpwd);
296
-		if(!$dh)
296
+		if (!$dh)
297 297
 		{
298 298
 			return new Object(-1, 'msg_ftp_invalid_path');
299 299
 		}
300 300
 		$list = array();
301
-		while(($file = readdir($dh)) !== FALSE)
301
+		while (($file = readdir($dh)) !== FALSE)
302 302
 		{
303
-			if(is_dir($curpwd . $file))
303
+			if (is_dir($curpwd.$file))
304 304
 			{
305 305
 				$file .= "/";
306 306
 			}
@@ -320,32 +320,32 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	function getAdminFTPList()
322 322
 	{
323
-		Context::loadLang(_XE_PATH_ . 'modules/autoinstall/lang');
323
+		Context::loadLang(_XE_PATH_.'modules/autoinstall/lang');
324 324
 		@set_time_limit(5);
325 325
 
326
-		require_once(_XE_PATH_ . 'libs/ftp.class.php');
326
+		require_once(_XE_PATH_.'libs/ftp.class.php');
327 327
 
328 328
 		$ftp_info = Context::getRequestVars();
329
-		if(!$ftp_info->ftp_user || !$ftp_info->ftp_password)
329
+		if (!$ftp_info->ftp_user || !$ftp_info->ftp_password)
330 330
 		{
331 331
 			return new Object(-1, 'msg_ftp_invalid_auth_info');
332 332
 		}
333 333
 
334 334
 		$this->pwd = $ftp_info->ftp_root_path;
335 335
 
336
-		if(!$ftp_info->ftp_host)
336
+		if (!$ftp_info->ftp_host)
337 337
 		{
338 338
 			$ftp_info->ftp_host = "127.0.0.1";
339 339
 		}
340 340
 
341
-		if(!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port))
341
+		if (!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port))
342 342
 		{
343 343
 			$ftp_info->ftp_port = "21";
344 344
 		}
345 345
 
346
-		if($ftp_info->sftp == 'Y')
346
+		if ($ftp_info->sftp == 'Y')
347 347
 		{
348
-			if(!function_exists('ssh2_sftp'))
348
+			if (!function_exists('ssh2_sftp'))
349 349
 			{
350 350
 				return new Object(-1, 'disable_sftp_support');
351 351
 			}
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
 		}
354 354
 
355 355
 		$oFtp = new ftp();
356
-		if($oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port))
356
+		if ($oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port))
357 357
 		{
358
-			if($oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password))
358
+			if ($oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password))
359 359
 			{
360 360
 				$_list = $oFtp->ftp_rawlist($this->pwd);
361 361
 				$oFtp->ftp_quit();
@@ -367,17 +367,17 @@  discard block
 block discarded – undo
367 367
 		}
368 368
 		$list = array();
369 369
 
370
-		if($_list)
370
+		if ($_list)
371 371
 		{
372
-			foreach($_list as $k => $v)
372
+			foreach ($_list as $k => $v)
373 373
 			{
374 374
 				$src = new stdClass();
375 375
 				$src->data = $v;
376 376
 				$res = Context::convertEncoding($src);
377 377
 				$v = $res->data;
378
-				if(strpos($v, 'd') === 0 || strpos($v, '<DIR>'))
378
+				if (strpos($v, 'd') === 0 || strpos($v, '<DIR>'))
379 379
 				{
380
-					$list[] = substr(strrchr($v, ' '), 1) . '/';
380
+					$list[] = substr(strrchr($v, ' '), 1).'/';
381 381
 				}
382 382
 			}
383 383
 		}
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 			, 'module' => array('addon', 'admin', 'autoinstall', 'comment', 'communication', 'counter', 'document', 'editor', 'file', 'importer', 'install', 'integration_search', 'layout', 'member', 'menu', 'message', 'module', 'opage', 'page', 'point', 'poll', 'rss', 'session', 'spamfilter', 'tag', 'trackback', 'trash', 'widget')
401 401
 			, 'addon' => array('autolink', 'blogapi', 'captcha', 'counter', 'member_communication', 'member_extra_info', 'mobile', 'openid_delegation_id', 'point_level_icon', 'resize_image')
402 402
 			, 'layout' => array('default')
403
-			, 'widget' => array('content', 'language_select', 'login_info','mcontent')
403
+			, 'widget' => array('content', 'language_select', 'login_info', 'mcontent')
404 404
 			, 'widgetstyle' => array(),
405 405
 		);
406 406
 		$info = array();
@@ -420,86 +420,86 @@  discard block
 block discarded – undo
420 420
 		$info['use_ssl'] = $db_info->use_ssl;
421 421
 		
422 422
 		$info['phpext'] = '';
423
-		foreach(get_loaded_extensions() as $ext)
423
+		foreach (get_loaded_extensions() as $ext)
424 424
 		{
425 425
 			$ext = strtolower($ext);
426
-			if(in_array($ext, $skip['ext']))
426
+			if (in_array($ext, $skip['ext']))
427 427
 			{
428 428
 				continue;
429 429
 			}
430
-			$info['phpext'] .= '|' . $ext;
430
+			$info['phpext'] .= '|'.$ext;
431 431
 		}
432 432
 		$info['phpext'] = substr($info['phpext'], 1);
433 433
 
434 434
 		$info['module'] = '';
435 435
 		$oModuleModel = getModel('module');
436 436
 		$module_list = $oModuleModel->getModuleList();
437
-		if($module_list) foreach($module_list as $module)
437
+		if ($module_list) foreach ($module_list as $module)
438 438
 		{
439
-			if(in_array($module->module, $skip['module']))
439
+			if (in_array($module->module, $skip['module']))
440 440
 			{
441 441
 				continue;
442 442
 			}
443
-			$info['module'] .= '|' . $module->module;
443
+			$info['module'] .= '|'.$module->module;
444 444
 		}
445 445
 		$info['module'] = substr($info['module'], 1);
446 446
 
447 447
 		$info['addon'] = '';
448 448
 		$oAddonAdminModel = getAdminModel('addon');
449 449
 		$addon_list = $oAddonAdminModel->getAddonList();
450
-		if($addon_list) foreach($addon_list as $addon)
450
+		if ($addon_list) foreach ($addon_list as $addon)
451 451
 		{
452
-			if(in_array($addon->addon, $skip['addon']))
452
+			if (in_array($addon->addon, $skip['addon']))
453 453
 			{
454 454
 				continue;
455 455
 			}
456
-			$info['addon'] .= '|' . $addon->addon;
456
+			$info['addon'] .= '|'.$addon->addon;
457 457
 		}
458 458
 		$info['addon'] = substr($info['addon'], 1);
459 459
 
460 460
 		$info['layout'] = "";
461 461
 		$oLayoutModel = getModel('layout');
462 462
 		$layout_list = $oLayoutModel->getDownloadedLayoutList();
463
-		if($layout_list) foreach($layout_list as $layout)
463
+		if ($layout_list) foreach ($layout_list as $layout)
464 464
 		{
465
-			if(in_array($layout->layout, $skip['layout']))
465
+			if (in_array($layout->layout, $skip['layout']))
466 466
 			{
467 467
 				continue;
468 468
 			}
469
-			$info['layout'] .= '|' . $layout->layout;
469
+			$info['layout'] .= '|'.$layout->layout;
470 470
 		}
471 471
 		$info['layout'] = substr($info['layout'], 1);
472 472
 
473 473
 		$info['widget'] = "";
474 474
 		$oWidgetModel = getModel('widget');
475 475
 		$widget_list = $oWidgetModel->getDownloadedWidgetList();
476
-		if($widget_list) foreach($widget_list as $widget)
476
+		if ($widget_list) foreach ($widget_list as $widget)
477 477
 		{
478
-			if(in_array($widget->widget, $skip['widget']))
478
+			if (in_array($widget->widget, $skip['widget']))
479 479
 			{
480 480
 				continue;
481 481
 			}
482
-			$info['widget'] .= '|' . $widget->widget;
482
+			$info['widget'] .= '|'.$widget->widget;
483 483
 		}
484 484
 		$info['widget'] = substr($info['widget'], 1);
485 485
 
486 486
 		$info['widgetstyle'] = "";
487 487
 		$oWidgetModel = getModel('widget');
488 488
 		$widgetstyle_list = $oWidgetModel->getDownloadedWidgetStyleList();
489
-		if($widgetstyle_list) foreach($widgetstyle_list as $widgetstyle)
489
+		if ($widgetstyle_list) foreach ($widgetstyle_list as $widgetstyle)
490 490
 		{
491
-			if(in_array($widgetstyle->widgetStyle, $skip['widgetstyle']))
491
+			if (in_array($widgetstyle->widgetStyle, $skip['widgetstyle']))
492 492
 			{
493 493
 				continue;
494 494
 			}
495
-			$info['widgetstyle'] .= '|' . $widgetstyle->widgetStyle;
495
+			$info['widgetstyle'] .= '|'.$widgetstyle->widgetStyle;
496 496
 		}
497 497
 		$info['widgetstyle'] = substr($info['widgetstyle'], 1);
498 498
 
499 499
 		$param = '';
500
-		foreach($info as $k => $v)
500
+		foreach ($info as $k => $v)
501 501
 		{
502
-			if($v)
502
+			if ($v)
503 503
 			{
504 504
 				$param .= sprintf('&%s=%s', $k, urlencode($v));
505 505
 			}
@@ -515,13 +515,13 @@  discard block
 block discarded – undo
515 515
 	 */
516 516
 	function getThemeList()
517 517
 	{
518
-		$path = _XE_PATH_ . 'themes';
518
+		$path = _XE_PATH_.'themes';
519 519
 		$list = FileHandler::readDir($path);
520 520
 
521 521
 		$theme_info = array();
522
-		if(count($list) > 0)
522
+		if (count($list) > 0)
523 523
 		{
524
-			foreach($list as $val)
524
+			foreach ($list as $val)
525 525
 			{
526 526
 				$theme_info[$val] = $this->getThemeInfo($val);
527 527
 			}
@@ -538,20 +538,20 @@  discard block
 block discarded – undo
538 538
 	 */
539 539
 	function getThemeInfo($theme_name, $layout_list = NULL)
540 540
 	{
541
-		if($GLOBALS['__ThemeInfo__'][$theme_name])
541
+		if ($GLOBALS['__ThemeInfo__'][$theme_name])
542 542
 		{
543 543
 			return $GLOBALS['__ThemeInfo__'][$theme_name];
544 544
 		}
545 545
 
546
-		$info_file = _XE_PATH_ . 'themes/' . $theme_name . '/conf/info.xml';
547
-		if(!file_exists($info_file))
546
+		$info_file = _XE_PATH_.'themes/'.$theme_name.'/conf/info.xml';
547
+		if (!file_exists($info_file))
548 548
 		{
549 549
 			return;
550 550
 		}
551 551
 
552 552
 		$oXmlParser = new XmlParser();
553 553
 		$_xml_obj = $oXmlParser->loadXmlFile($info_file);
554
-		if(!$_xml_obj->theme)
554
+		if (!$_xml_obj->theme)
555 555
 		{
556 556
 			return;
557 557
 		}
@@ -562,16 +562,16 @@  discard block
 block discarded – undo
562 562
 		$theme_info = new stdClass();
563 563
 		$theme_info->name = $theme_name;
564 564
 		$theme_info->title = $xml_obj->title->body;
565
-		$thumbnail = './themes/' . $theme_name . '/thumbnail.png';
565
+		$thumbnail = './themes/'.$theme_name.'/thumbnail.png';
566 566
 		$theme_info->thumbnail = (FileHandler::exists($thumbnail)) ? $thumbnail : NULL;
567 567
 		$theme_info->version = $xml_obj->version->body;
568 568
 		$date_obj = new stdClass();
569 569
 		sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d);
570 570
 		$theme_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
571 571
 		$theme_info->description = $xml_obj->description->body;
572
-		$theme_info->path = './themes/' . $theme_name . '/';
572
+		$theme_info->path = './themes/'.$theme_name.'/';
573 573
 
574
-		if(!is_array($xml_obj->publisher))
574
+		if (!is_array($xml_obj->publisher))
575 575
 		{
576 576
 			$publisher_list = array();
577 577
 			$publisher_list[] = $xml_obj->publisher;
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 		}
583 583
 
584 584
 		$theme_info->publisher = array();
585
-		foreach($publisher_list as $publisher)
585
+		foreach ($publisher_list as $publisher)
586 586
 		{
587 587
 			$publisher_obj = new stdClass();
588 588
 			$publisher_obj->name = $publisher->name->body;
@@ -595,10 +595,10 @@  discard block
 block discarded – undo
595 595
 		$layout_path = $layout->directory->attrs->path;
596 596
 		$layout_parse = explode('/', $layout_path);
597 597
 		$layout_info = new stdClass();
598
-		switch($layout_parse[1])
598
+		switch ($layout_parse[1])
599 599
 		{
600 600
 			case 'themes' :
601
-					$layout_info->name = $theme_name . '|@|' . $layout_parse[count($layout_parse) - 1];
601
+					$layout_info->name = $theme_name.'|@|'.$layout_parse[count($layout_parse) - 1];
602 602
 					break;
603 603
 
604 604
 			case 'layouts' :
@@ -615,11 +615,11 @@  discard block
 block discarded – undo
615 615
 		$oLayoutModel = getModel('layout');
616 616
 		$layout_info_list = array();
617 617
 		$layout_list = $oLayoutModel->getLayoutList($site_info->site_srl);
618
-		if($layout_list)
618
+		if ($layout_list)
619 619
 		{
620
-			foreach($layout_list as $val)
620
+			foreach ($layout_list as $val)
621 621
 			{
622
-				if($val->layout == $layout_info->name)
622
+				if ($val->layout == $layout_info->name)
623 623
 				{
624 624
 					$is_new_layout = FALSE;
625 625
 					$layout_info->layout_srl = $val->layout_srl;
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 			}
629 629
 		}
630 630
 
631
-		if($is_new_layout)
631
+		if ($is_new_layout)
632 632
 		{
633 633
 			$site_module_info = Context::get('site_module_info');
634 634
 			$args = new stdClass();
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 		$theme_info->layout_info = $layout_info;
647 647
 
648 648
 		$skin_infos = $xml_obj->skininfos;
649
-		if(is_array($skin_infos->skininfo))
649
+		if (is_array($skin_infos->skininfo))
650 650
 		{
651 651
 			$skin_list = $skin_infos->skininfo;
652 652
 		}
@@ -657,17 +657,17 @@  discard block
 block discarded – undo
657 657
 
658 658
 		$oModuleModel = getModel('module');
659 659
 		$skins = array();
660
-		foreach($skin_list as $val)
660
+		foreach ($skin_list as $val)
661 661
 		{
662 662
 			$skin_info = new stdClass();
663 663
 			unset($skin_parse);
664 664
 			$skin_parse = explode('/', $val->directory->attrs->path);
665
-			switch($skin_parse[1])
665
+			switch ($skin_parse[1])
666 666
 			{
667 667
 				case 'themes' :
668 668
 						$is_theme = TRUE;
669 669
 						$module_name = $skin_parse[count($skin_parse) - 1];
670
-						$skin_info->name = $theme_name . '|@|' . $module_name;
670
+						$skin_info->name = $theme_name.'|@|'.$module_name;
671 671
 						break;
672 672
 
673 673
 				case 'modules' :
@@ -681,9 +681,9 @@  discard block
 block discarded – undo
681 681
 			$skin_info->is_theme = $is_theme;
682 682
 			$skins[$module_name] = $skin_info;
683 683
 
684
-			if($is_theme)
684
+			if ($is_theme)
685 685
 			{
686
-				if(!$GLOBALS['__ThemeModuleSkin__'][$module_name])
686
+				if (!$GLOBALS['__ThemeModuleSkin__'][$module_name])
687 687
 				{
688 688
 					$GLOBALS['__ThemeModuleSkin__'][$module_name] = array();
689 689
 					$GLOBALS['__ThemeModuleSkin__'][$module_name]['skins'] = array();
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 	 */
706 706
 	function getModulesSkinList()
707 707
 	{
708
-		if($GLOBALS['__ThemeModuleSkin__']['__IS_PARSE__'])
708
+		if ($GLOBALS['__ThemeModuleSkin__']['__IS_PARSE__'])
709 709
 		{
710 710
 			return $GLOBALS['__ThemeModuleSkin__'];
711 711
 		}
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 		sort($searched_list);
714 714
 
715 715
 		$searched_count = count($searched_list);
716
-		if(!$searched_count)
716
+		if (!$searched_count)
717 717
 		{
718 718
 			return;
719 719
 		}
@@ -721,13 +721,13 @@  discard block
 block discarded – undo
721 721
 		$exceptionModule = array('editor', 'poll', 'homepage', 'textyle');
722 722
 
723 723
 		$oModuleModel = getModel('module');
724
-		foreach($searched_list as $val)
724
+		foreach ($searched_list as $val)
725 725
 		{
726
-			$skin_list = $oModuleModel->getSkins(_XE_PATH_ . 'modules/' . $val);
726
+			$skin_list = $oModuleModel->getSkins(_XE_PATH_.'modules/'.$val);
727 727
 
728
-			if(is_array($skin_list) && count($skin_list) > 0 && !in_array($val, $exceptionModule))
728
+			if (is_array($skin_list) && count($skin_list) > 0 && !in_array($val, $exceptionModule))
729 729
 			{
730
-				if(!$GLOBALS['__ThemeModuleSkin__'][$val])
730
+				if (!$GLOBALS['__ThemeModuleSkin__'][$val])
731 731
 				{
732 732
 					$GLOBALS['__ThemeModuleSkin__'][$val] = array();
733 733
 					$moduleInfo = $oModuleModel->getModuleInfoXml($val);
@@ -752,22 +752,22 @@  discard block
 block discarded – undo
752 752
 		$cacheFile = sprintf('./files/cache/menu/admin_lang/adminMenu.%s.lang.php', $currentLang);
753 753
 
754 754
 		// Update if no cache file exists or it is older than xml file
755
-		if(!is_readable($cacheFile))
755
+		if (!is_readable($cacheFile))
756 756
 		{
757 757
 			$lang = new stdClass();
758 758
 			$oModuleModel = getModel('module');
759 759
 			$installed_module_list = $oModuleModel->getModulesXmlInfo();
760 760
 
761 761
 			$this->gnbLangBuffer = '<?php $lang = new stdClass();';
762
-			foreach($installed_module_list AS $key => $value)
762
+			foreach ($installed_module_list AS $key => $value)
763 763
 			{
764 764
 				$moduleActionInfo = $oModuleModel->getModuleActionXml($value->module);
765
-				if(is_object($moduleActionInfo->menu))
765
+				if (is_object($moduleActionInfo->menu))
766 766
 				{
767
-					foreach($moduleActionInfo->menu AS $key2 => $value2)
767
+					foreach ($moduleActionInfo->menu AS $key2 => $value2)
768 768
 					{
769 769
 						$lang->menu_gnb_sub[$key2] = $value2->title;
770
-						$this->gnbLangBuffer .=sprintf('$lang->menu_gnb_sub[\'%s\'] = \'%s\';', $key2, $value2->title);
770
+						$this->gnbLangBuffer .= sprintf('$lang->menu_gnb_sub[\'%s\'] = \'%s\';', $key2, $value2->title);
771 771
 					}
772 772
 				}
773 773
 			}
@@ -793,19 +793,19 @@  discard block
 block discarded – undo
793 793
 		$args = new stdClass();
794 794
 		$args->site_srl = $siteSrl;
795 795
 		$output = executeQueryArray('admin.getFavoriteList', $args);
796
-		if(!$output->toBool())
796
+		if (!$output->toBool())
797 797
 		{
798 798
 			return $output;
799 799
 		}
800
-		if(!$output->data)
800
+		if (!$output->data)
801 801
 		{
802 802
 			return new Object();
803 803
 		}
804 804
 
805
-		if($isGetModuleInfo && is_array($output->data))
805
+		if ($isGetModuleInfo && is_array($output->data))
806 806
 		{
807 807
 			$oModuleModel = getModel('module');
808
-			foreach($output->data AS $key => $value)
808
+			foreach ($output->data AS $key => $value)
809 809
 			{
810 810
 				$moduleInfo = $oModuleModel->getModuleInfoXml($value->module);
811 811
 				$output->data[$key]->admin_index_act = $moduleInfo->admin_index_act;
@@ -830,13 +830,13 @@  discard block
 block discarded – undo
830 830
 		$args->site_srl = $siteSrl;
831 831
 		$args->module = $module;
832 832
 		$output = executeQuery('admin.getFavorite', $args);
833
-		if(!$output->toBool())
833
+		if (!$output->toBool())
834 834
 		{
835 835
 			return $output;
836 836
 		}
837 837
 
838 838
 		$returnObject = new Object();
839
-		if($output->data)
839
+		if ($output->data)
840 840
 		{
841 841
 			$returnObject->add('result', TRUE);
842 842
 			$returnObject->add('favoriteSrl', $output->data->admin_favorite_srl);
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 	 */
856 856
 	function getSiteAllList()
857 857
 	{
858
-		if(Context::get('domain'))
858
+		if (Context::get('domain'))
859 859
 		{
860 860
 			$domain = Context::get('domain');
861 861
 		}
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
 	function getAllSitesThatHaveModules($domain = NULL)
873 873
 	{
874 874
 		$args = new stdClass();
875
-		if($domain)
875
+		if ($domain)
876 876
 		{
877 877
 			$args->domain = $domain;
878 878
 		}
@@ -880,31 +880,31 @@  discard block
 block discarded – undo
880 880
 
881 881
 		$siteList = array();
882 882
 		$output = executeQueryArray('admin.getSiteAllList', $args, $columnList);
883
-		if($output->toBool())
883
+		if ($output->toBool())
884 884
 		{
885 885
 			$siteList = $output->data;
886 886
 		}
887 887
 
888 888
 		$oModuleModel = getModel('module');
889
-		foreach($siteList as $key => $value)
889
+		foreach ($siteList as $key => $value)
890 890
 		{
891 891
 			$args->site_srl = $value->site_srl;
892 892
 			$list = $oModuleModel->getModuleSrlList($args);
893 893
 
894
-			if(!is_array($list))
894
+			if (!is_array($list))
895 895
 			{
896 896
 				$list = array($list);
897 897
 			}
898 898
 
899
-			foreach($list as $k => $v)
899
+			foreach ($list as $k => $v)
900 900
 			{
901
-				if(!is_dir(_XE_PATH_ . 'modules/' . $v->module))
901
+				if (!is_dir(_XE_PATH_.'modules/'.$v->module))
902 902
 				{
903 903
 					unset($list[$k]);
904 904
 				}
905 905
 			}
906 906
 
907
-			if(!count($list))
907
+			if (!count($list))
908 908
 			{
909 909
 				unset($siteList[$key]);
910 910
 			}
@@ -921,13 +921,13 @@  discard block
 block discarded – undo
921 921
 	{
922 922
 		$args = new stdClass();
923 923
 
924
-		if($date)
924
+		if ($date)
925 925
 		{
926 926
 			$args->regDate = date('Ymd', strtotime($date));
927 927
 		}
928 928
 
929 929
 		$output = executeQuery('admin.getSiteCountByDate', $args);
930
-		if(!$output->toBool())
930
+		if (!$output->toBool())
931 931
 		{
932 932
 			return 0;
933 933
 		}
@@ -949,21 +949,21 @@  discard block
 block discarded – undo
949 949
 	{
950 950
 		$site_info = Context::get('site_module_info');
951 951
 		$virtual_site = '';
952
-		if($site_info->site_srl) 
952
+		if ($site_info->site_srl) 
953 953
 		{
954
-			$virtual_site = $site_info->site_srl . '/';
954
+			$virtual_site = $site_info->site_srl.'/';
955 955
 		}
956 956
 
957
-		$file_exsit = FileHandler::readFile(_XE_PATH_ . 'files/attach/xeicon/' . $virtual_site . $iconname);
958
-		if(!$file_exsit && $default === true)
957
+		$file_exsit = FileHandler::readFile(_XE_PATH_.'files/attach/xeicon/'.$virtual_site.$iconname);
958
+		if (!$file_exsit && $default === true)
959 959
         {
960
-            $icon_url = './modules/admin/tpl/img/' . $default_icon_name;
960
+            $icon_url = './modules/admin/tpl/img/'.$default_icon_name;
961 961
         }
962
-        elseif($file_exsit)
962
+        elseif ($file_exsit)
963 963
 		{
964 964
 			$default_url = Context::getDefaultUrl();
965
-			if($default_url && substr_compare($default_url, '/', -1) === 0) $default_url = substr($default_url, 0, -1);
966
-			$icon_url = $default_url . '/files/attach/xeicon/' . $virtual_site . $iconname;
965
+			if ($default_url && substr_compare($default_url, '/', -1) === 0) $default_url = substr($default_url, 0, -1);
966
+			$icon_url = $default_url.'/files/attach/xeicon/'.$virtual_site.$iconname;
967 967
 		}
968 968
 		return $icon_url;
969 969
 	}
Please login to merge, or discard this patch.
Braces   +26 added lines, -22 removed lines patch added patch discarded remove patch
@@ -303,8 +303,7 @@  discard block
 block discarded – undo
303 303
 			if(is_dir($curpwd . $file))
304 304
 			{
305 305
 				$file .= "/";
306
-			}
307
-			else
306
+			} else
308 307
 			{
309 308
 				continue;
310 309
 			}
@@ -359,8 +358,7 @@  discard block
 block discarded – undo
359 358
 			{
360 359
 				$_list = $oFtp->ftp_rawlist($this->pwd);
361 360
 				$oFtp->ftp_quit();
362
-			}
363
-			else
361
+			} else
364 362
 			{
365 363
 				return new Object(-1, 'msg_ftp_invalid_auth_info');
366 364
 			}
@@ -380,8 +378,7 @@  discard block
 block discarded – undo
380 378
 					$list[] = substr(strrchr($v, ' '), 1) . '/';
381 379
 				}
382 380
 			}
383
-		}
384
-		else
381
+		} else
385 382
 		{
386 383
 			return new Object(-1, 'msg_ftp_no_directory');
387 384
 		}
@@ -434,11 +431,13 @@  discard block
 block discarded – undo
434 431
 		$info['module'] = '';
435 432
 		$oModuleModel = getModel('module');
436 433
 		$module_list = $oModuleModel->getModuleList();
437
-		if($module_list) foreach($module_list as $module)
434
+		if($module_list) {
435
+			foreach($module_list as $module)
438 436
 		{
439 437
 			if(in_array($module->module, $skip['module']))
440 438
 			{
441 439
 				continue;
440
+		}
442 441
 			}
443 442
 			$info['module'] .= '|' . $module->module;
444 443
 		}
@@ -447,11 +446,13 @@  discard block
 block discarded – undo
447 446
 		$info['addon'] = '';
448 447
 		$oAddonAdminModel = getAdminModel('addon');
449 448
 		$addon_list = $oAddonAdminModel->getAddonList();
450
-		if($addon_list) foreach($addon_list as $addon)
449
+		if($addon_list) {
450
+			foreach($addon_list as $addon)
451 451
 		{
452 452
 			if(in_array($addon->addon, $skip['addon']))
453 453
 			{
454 454
 				continue;
455
+		}
455 456
 			}
456 457
 			$info['addon'] .= '|' . $addon->addon;
457 458
 		}
@@ -460,11 +461,13 @@  discard block
 block discarded – undo
460 461
 		$info['layout'] = "";
461 462
 		$oLayoutModel = getModel('layout');
462 463
 		$layout_list = $oLayoutModel->getDownloadedLayoutList();
463
-		if($layout_list) foreach($layout_list as $layout)
464
+		if($layout_list) {
465
+			foreach($layout_list as $layout)
464 466
 		{
465 467
 			if(in_array($layout->layout, $skip['layout']))
466 468
 			{
467 469
 				continue;
470
+		}
468 471
 			}
469 472
 			$info['layout'] .= '|' . $layout->layout;
470 473
 		}
@@ -473,11 +476,13 @@  discard block
 block discarded – undo
473 476
 		$info['widget'] = "";
474 477
 		$oWidgetModel = getModel('widget');
475 478
 		$widget_list = $oWidgetModel->getDownloadedWidgetList();
476
-		if($widget_list) foreach($widget_list as $widget)
479
+		if($widget_list) {
480
+			foreach($widget_list as $widget)
477 481
 		{
478 482
 			if(in_array($widget->widget, $skip['widget']))
479 483
 			{
480 484
 				continue;
485
+		}
481 486
 			}
482 487
 			$info['widget'] .= '|' . $widget->widget;
483 488
 		}
@@ -486,11 +491,13 @@  discard block
 block discarded – undo
486 491
 		$info['widgetstyle'] = "";
487 492
 		$oWidgetModel = getModel('widget');
488 493
 		$widgetstyle_list = $oWidgetModel->getDownloadedWidgetStyleList();
489
-		if($widgetstyle_list) foreach($widgetstyle_list as $widgetstyle)
494
+		if($widgetstyle_list) {
495
+			foreach($widgetstyle_list as $widgetstyle)
490 496
 		{
491 497
 			if(in_array($widgetstyle->widgetStyle, $skip['widgetstyle']))
492 498
 			{
493 499
 				continue;
500
+		}
494 501
 			}
495 502
 			$info['widgetstyle'] .= '|' . $widgetstyle->widgetStyle;
496 503
 		}
@@ -575,8 +582,7 @@  discard block
 block discarded – undo
575 582
 		{
576 583
 			$publisher_list = array();
577 584
 			$publisher_list[] = $xml_obj->publisher;
578
-		}
579
-		else
585
+		} else
580 586
 		{
581 587
 			$publisher_list = $xml_obj->publisher;
582 588
 		}
@@ -649,8 +655,7 @@  discard block
 block discarded – undo
649 655
 		if(is_array($skin_infos->skininfo))
650 656
 		{
651 657
 			$skin_list = $skin_infos->skininfo;
652
-		}
653
-		else
658
+		} else
654 659
 		{
655 660
 			$skin_list = array($skin_infos->skininfo);
656 661
 		}
@@ -773,8 +778,7 @@  discard block
 block discarded – undo
773 778
 			}
774 779
 			$this->gnbLangBuffer .= ' ?>';
775 780
 			FileHandler::writeFile($cacheFile, $this->gnbLangBuffer);
776
-		}
777
-		else
781
+		} else
778 782
 		{
779 783
 			include $cacheFile;
780 784
 		}
@@ -840,8 +844,7 @@  discard block
 block discarded – undo
840 844
 		{
841 845
 			$returnObject->add('result', TRUE);
842 846
 			$returnObject->add('favoriteSrl', $output->data->admin_favorite_srl);
843
-		}
844
-		else
847
+		} else
845 848
 		{
846 849
 			$returnObject->add('result', FALSE);
847 850
 		}
@@ -958,11 +961,12 @@  discard block
 block discarded – undo
958 961
 		if(!$file_exsit && $default === true)
959 962
         {
960 963
             $icon_url = './modules/admin/tpl/img/' . $default_icon_name;
961
-        }
962
-        elseif($file_exsit)
964
+        } elseif($file_exsit)
963 965
 		{
964 966
 			$default_url = Context::getDefaultUrl();
965
-			if($default_url && substr_compare($default_url, '/', -1) === 0) $default_url = substr($default_url, 0, -1);
967
+			if($default_url && substr_compare($default_url, '/', -1) === 0) {
968
+				$default_url = substr($default_url, 0, -1);
969
+			}
966 970
 			$icon_url = $default_url . '/files/attach/xeicon/' . $virtual_site . $iconname;
967 971
 		}
968 972
 		return $icon_url;
Please login to merge, or discard this patch.
modules/admin/admin.admin.view.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 
42 42
 	/**
43 43
 	 * Initilization
44
-	 * @return void
44
+	 * @return ModuleObject|null
45 45
 	 */
46 46
 	function init()
47 47
 	{
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -566,7 +566,7 @@
 block discarded – undo
566 566
 	/**
567 567
 	 * Retrun server environment to XML string
568 568
 	 * @return object
569
-	*/
569
+	 */
570 570
 	function dispAdminViewServerEnv()
571 571
 	{
572 572
 		$info = array();
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	{
29 29
 		$db_info = Context::getDBInfo();
30 30
 
31
-		if(strpos($db_info->default_url, 'xn--') !== FALSE)
31
+		if (strpos($db_info->default_url, 'xn--') !== FALSE)
32 32
 		{
33 33
 			$xe_default_url = Context::decodeIdna($db_info->default_url);
34 34
 		}
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 		// forbit access if the user is not an administrator
49 49
 		$oMemberModel = getModel('member');
50 50
 		$logged_info = $oMemberModel->getLoggedInfo();
51
-		if($logged_info->is_admin != 'Y')
51
+		if ($logged_info->is_admin != 'Y')
52 52
 		{
53 53
 			return $this->stop("msg_is_not_administrator");
54 54
 		}
55 55
 
56 56
 		// change into administration layout
57
-		$this->setTemplatePath($this->module_path . 'tpl');
57
+		$this->setTemplatePath($this->module_path.'tpl');
58 58
 		$this->setLayoutPath($this->getTemplatePath());
59 59
 		$this->setLayoutFile('layout.html');
60 60
 
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
 		Context::set('use_db_session', $db_info->use_db_session == 'N' ? 'N' : 'Y');
75 75
 		Context::set('use_mobile_view', $db_info->use_mobile_view == 'Y' ? 'Y' : 'N');
76 76
 		Context::set('use_ssl', $db_info->use_ssl ? $db_info->use_ssl : "none");
77
-		if($db_info->http_port)
77
+		if ($db_info->http_port)
78 78
 		{
79 79
 			Context::set('http_port', $db_info->http_port);
80 80
 		}
81
-		if($db_info->https_port)
81
+		if ($db_info->https_port)
82 82
 		{
83 83
 			Context::set('https_port', $db_info->https_port);
84 84
 		}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	function checkEasyinstall()
95 95
 	{
96 96
 		$lastTime = (int) FileHandler::readFile($this->easyinstallCheckFile);
97
-		if($lastTime > $_SERVER['REQUEST_TIME'] - 60 * 60 * 24 * 30)
97
+		if ($lastTime > $_SERVER['REQUEST_TIME'] - 60 * 60 * 24 * 30)
98 98
 		{
99 99
 			return;
100 100
 		}
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
 		$lUpdateDoc = $xml_lUpdate->parse($buff);
109 109
 		$updateDate = $lUpdateDoc->response->updatedate->body;
110 110
 
111
-		if(!$updateDate)
111
+		if (!$updateDate)
112 112
 		{
113 113
 			$this->_markingCheckEasyinstall();
114 114
 			return;
115 115
 		}
116 116
 
117 117
 		$item = $oAutoinstallModel->getLatestPackage();
118
-		if(!$item || $item->updatedate < $updateDate)
118
+		if (!$item || $item->updatedate < $updateDate)
119 119
 		{
120 120
 			$oController = getAdminController('autoinstall');
121 121
 			$oController->_updateinfo();
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
 		// Check is_shortcut column
146 146
 		$oDB = DB::getInstance();
147
-		if(!$oDB->isColumnExists('menu_item', 'is_shortcut'))
147
+		if (!$oDB->isColumnExists('menu_item', 'is_shortcut'))
148 148
 		{
149 149
 			return;
150 150
 		}
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 		$currentAct = Context::get('act');
163 163
 		$subMenuTitle = '';
164 164
 
165
-		foreach((array) $moduleActionInfo->menu as $key => $value)
165
+		foreach ((array) $moduleActionInfo->menu as $key => $value)
166 166
 		{
167
-			if(isset($value->acts) && is_array($value->acts) && in_array($currentAct, $value->acts))
167
+			if (isset($value->acts) && is_array($value->acts) && in_array($currentAct, $value->acts))
168 168
 			{
169 169
 				$subMenuTitle = $value->title;
170 170
 				break;
@@ -173,21 +173,21 @@  discard block
 block discarded – undo
173 173
 		// get current menu's srl(=parentSrl)
174 174
 		$parentSrl = 0;
175 175
 		$oMenuAdminConroller = getAdminController('menu');
176
-		foreach((array) $menu->list as $parentKey => $parentMenu)
176
+		foreach ((array) $menu->list as $parentKey => $parentMenu)
177 177
 		{
178
-			if(!is_array($parentMenu['list']) || !count($parentMenu['list']))
178
+			if (!is_array($parentMenu['list']) || !count($parentMenu['list']))
179 179
 			{
180 180
 				continue;
181 181
 			}
182
-			if($parentMenu['href'] == '#' && count($parentMenu['list']))
182
+			if ($parentMenu['href'] == '#' && count($parentMenu['list']))
183 183
 			{
184 184
 				$firstChild = current($parentMenu['list']);
185 185
 				$menu->list[$parentKey]['href'] = $firstChild['href'];
186 186
 			}
187 187
 
188
-			foreach($parentMenu['list'] as $childKey => $childMenu)
188
+			foreach ($parentMenu['list'] as $childKey => $childMenu)
189 189
 			{
190
-				if($subMenuTitle == $childMenu['text'] && $parentSrl == 0)
190
+				if ($subMenuTitle == $childMenu['text'] && $parentSrl == 0)
191 191
 				{
192 192
 					$parentSrl = $childMenu['parent_srl'];
193 193
 				}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		$gnbTitleInfo->adminTitle = $objConfig->adminTitle ? $objConfig->adminTitle : 'XE Admin';
201 201
 		$gnbTitleInfo->adminLogo = $objConfig->adminLogo ? $objConfig->adminLogo : 'modules/admin/tpl/img/xe.h1.png';
202 202
 
203
-		$browserTitle = ($subMenuTitle ? $subMenuTitle : 'Dashboard') . ' - ' . $gnbTitleInfo->adminTitle;
203
+		$browserTitle = ($subMenuTitle ? $subMenuTitle : 'Dashboard').' - '.$gnbTitleInfo->adminTitle;
204 204
 
205 205
 		// Get list of favorite
206 206
 		$oAdminAdminModel = getAdminModel('admin');
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		// move from index method, because use in admin footer
212 212
 		$newest_news_url = sprintf("http://news.xpressengine.com/%s/news.php?version=%s&package=%s", _XE_LOCATION_, __XE_VERSION__, _XE_PACKAGE_);
213 213
 		$cache_file = sprintf("%sfiles/cache/newest_news.%s.cache.php", _XE_PATH_, _XE_LOCATION_);
214
-		if(!file_exists($cache_file) || filemtime($cache_file) + 60 * 60 < $_SERVER['REQUEST_TIME'])
214
+		if (!file_exists($cache_file) || filemtime($cache_file) + 60 * 60 < $_SERVER['REQUEST_TIME'])
215 215
 		{
216 216
 			// Considering if data cannot be retrieved due to network problem, modify filemtime to prevent trying to reload again when refreshing administration page
217 217
 			// Ensure to access the administration page even though news cannot be displayed
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
 			FileHandler::getRemoteFile($newest_news_url, $cache_file, null, 1, 'GET', 'text/html', array('REQUESTURL' => getFullUrl('')));
220 220
 		}
221 221
 
222
-		if(file_exists($cache_file))
222
+		if (file_exists($cache_file))
223 223
 		{
224 224
 			$oXml = new XmlParser();
225 225
 			$buff = $oXml->parse(FileHandler::readFile($cache_file));
226 226
 
227 227
 			$item = $buff->zbxe_news->item;
228
-			if($item)
228
+			if ($item)
229 229
 			{
230
-				if(!is_array($item))
230
+				if (!is_array($item))
231 231
 				{
232 232
 					$item = array($item);
233 233
 				}
234 234
 
235
-				foreach($item as $key => $val)
235
+				foreach ($item as $key => $val)
236 236
 				{
237 237
 					$obj = new stdClass();
238 238
 					$obj->title = $val->body;
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 					$news[] = $obj;
242 242
 				}
243 243
 				Context::set('news', $news);
244
-				if(isset($news) && is_array($news))
244
+				if (isset($news) && is_array($news))
245 245
 				{
246 246
 					Context::set('latestVersion', array_shift($news));
247 247
 				}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	function dispAdminIndex()
265 265
 	{
266 266
 		$db_info = Context::getDBInfo();
267
-		Context::set('db_info',$db_info);
267
+		Context::set('db_info', $db_info);
268 268
 
269 269
 		// Get statistics
270 270
 		$args = new stdClass();
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
 		$args = new stdClass();
302 302
 		$args->list_count = 5;
303 303
 		$output = $oCommentModel->getNewestCommentList($args, $columnList);
304
-		if(is_array($output))
304
+		if (is_array($output))
305 305
 		{
306
-			foreach($output AS $key => $value)
306
+			foreach ($output AS $key => $value)
307 307
 			{
308 308
 				$value->content = strip_tags($value->content);
309 309
 			}
@@ -314,17 +314,17 @@  discard block
 block discarded – undo
314 314
 		// Get list of modules
315 315
 		$oModuleModel = getModel('module');
316 316
 		$module_list = $oModuleModel->getModuleList();
317
-		if(is_array($module_list))
317
+		if (is_array($module_list))
318 318
 		{
319 319
 			$needUpdate = FALSE;
320 320
 			$addTables = FALSE;
321
-			foreach($module_list AS $key => $value)
321
+			foreach ($module_list AS $key => $value)
322 322
 			{
323
-				if($value->need_install)
323
+				if ($value->need_install)
324 324
 				{
325 325
 					$addTables = TRUE;
326 326
 				}
327
-				if($value->need_update)
327
+				if ($value->need_update)
328 328
 				{
329 329
 					$needUpdate = TRUE;
330 330
 				}
@@ -335,12 +335,12 @@  discard block
 block discarded – undo
335 335
 		$oAutoinstallAdminModel = getAdminModel('autoinstall');
336 336
 		$needUpdateList = $oAutoinstallAdminModel->getNeedUpdateList();
337 337
 
338
-		if(is_array($needUpdateList))
338
+		if (is_array($needUpdateList))
339 339
 		{
340
-			foreach($needUpdateList AS $key => $value)
340
+			foreach ($needUpdateList AS $key => $value)
341 341
 			{
342 342
 				$helpUrl = './admin/help/index.html#';
343
-				switch($value->type)
343
+				switch ($value->type)
344 344
 				{
345 345
 					case 'addon':
346 346
 						$helpUrl .= 'UMAN_terminology_addon';
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 
368 368
 		$site_module_info = Context::get('site_module_info');
369 369
 		$oAddonAdminModel = getAdminModel('addon');
370
-		$counterAddonActivated = $oAddonAdminModel->isActivatedAddon('counter', $site_module_info->site_srl );
371
-		if(!$counterAddonActivated)
370
+		$counterAddonActivated = $oAddonAdminModel->isActivatedAddon('counter', $site_module_info->site_srl);
371
+		if (!$counterAddonActivated)
372 372
 		{
373 373
 			$columnList = array('member_srl', 'nick_name', 'user_name', 'user_id', 'email_address');
374 374
 			$args = new stdClass;
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
 
392 392
 		// gathering enviroment check
393 393
 		$mainVersion = join('.', array_slice(explode('.', __XE_VERSION__), 0, 2));
394
-		$path = FileHandler::getRealPath('./files/env/' . $mainVersion);
394
+		$path = FileHandler::getRealPath('./files/env/'.$mainVersion);
395 395
 		$isEnviromentGatheringAgreement = FALSE;
396
-		if(file_exists($path))
396
+		if (file_exists($path))
397 397
 		{
398 398
 			$isEnviromentGatheringAgreement = TRUE;
399 399
 		}
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 		$isLicenseAgreement = FALSE;
404 404
 		$path = FileHandler::getRealPath('./files/env/license_agreement');
405 405
 		$isLicenseAgreement = FALSE;
406
-		if(file_exists($path))
406
+		if (file_exists($path))
407 407
 		{
408 408
 			$isLicenseAgreement = TRUE;
409 409
 		}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 
426 426
 		Context::set('selected_lang', $db_info->lang_type);
427 427
 
428
-		if(strpos($db_info->default_url, 'xn--') !== FALSE)
428
+		if (strpos($db_info->default_url, 'xn--') !== FALSE)
429 429
 		{
430 430
 			$db_info->default_url = Context::decodeIdna($db_info->default_url);
431 431
 		}
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
 
435 435
 		// site lock
436 436
 		Context::set('IP', $_SERVER['REMOTE_ADDR']);
437
-		if(!$db_info->sitelock_title) $db_info->sitelock_title = 'Maintenance in progress...';
438
-		if(!in_array('127.0.0.1', $db_info->sitelock_whitelist)) $db_info->sitelock_whitelist[] = '127.0.0.1';
439
-		if(!in_array($_SERVER['REMOTE_ADDR'], $db_info->sitelock_whitelist)) $db_info->sitelock_whitelist[] = $_SERVER['REMOTE_ADDR'];
437
+		if (!$db_info->sitelock_title) $db_info->sitelock_title = 'Maintenance in progress...';
438
+		if (!in_array('127.0.0.1', $db_info->sitelock_whitelist)) $db_info->sitelock_whitelist[] = '127.0.0.1';
439
+		if (!in_array($_SERVER['REMOTE_ADDR'], $db_info->sitelock_whitelist)) $db_info->sitelock_whitelist[] = $_SERVER['REMOTE_ADDR'];
440 440
 		$db_info->sitelock_whitelist = array_unique($db_info->sitelock_whitelist);
441 441
 		Context::set('remote_addr', $_SERVER['REMOTE_ADDR']);
442 442
 		Context::set('use_sitelock', $db_info->use_sitelock);
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 		Context::set('sitelock_whitelist', $whitelist);
448 448
 
449 449
 
450
-		if($db_info->admin_ip_list) $admin_ip_list = implode("\r\n", $db_info->admin_ip_list);
450
+		if ($db_info->admin_ip_list) $admin_ip_list = implode("\r\n", $db_info->admin_ip_list);
451 451
 		else $admin_ip_list = '';
452 452
 		Context::set('admin_ip_list', $admin_ip_list);
453 453
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 		Context::set('htmlFooter', htmlspecialchars($config->htmlFooter));
471 471
 
472 472
 		// embed filter
473
-		require_once(_XE_PATH_ . 'classes/security/EmbedFilter.class.php');
473
+		require_once(_XE_PATH_.'classes/security/EmbedFilter.class.php');
474 474
 		$oEmbedFilter = EmbedFilter::getInstance();
475 475
 		context::set('embed_white_object', implode(PHP_EOL, $oEmbedFilter->whiteUrlList));
476 476
 		context::set('embed_white_iframe', implode(PHP_EOL, $oEmbedFilter->whiteIframeUrlList));
@@ -529,36 +529,36 @@  discard block
 block discarded – undo
529 529
 	 */
530 530
 	function showSendEnv()
531 531
 	{
532
-		if(Context::getResponseMethod() != 'HTML')
532
+		if (Context::getResponseMethod() != 'HTML')
533 533
 		{
534 534
 			return;
535 535
 		}
536 536
 
537 537
 		$server = 'http://collect.xpressengine.com/env/img.php?';
538 538
 		$path = './files/env/';
539
-		$install_env = $path . 'install';
539
+		$install_env = $path.'install';
540 540
 		$mainVersion = join('.', array_slice(explode('.', __XE_VERSION__), 0, 2));
541 541
 
542
-		if(file_exists(FileHandler::getRealPath($install_env)))
542
+		if (file_exists(FileHandler::getRealPath($install_env)))
543 543
 		{
544 544
 			$oAdminAdminModel = getAdminModel('admin');
545 545
 			$params = $oAdminAdminModel->getEnv('INSTALL');
546
-			$img = sprintf('<img src="%s" alt="" style="height:0px;width:0px" />', $server . $params);
546
+			$img = sprintf('<img src="%s" alt="" style="height:0px;width:0px" />', $server.$params);
547 547
 			Context::addHtmlFooter($img);
548 548
 
549
-			FileHandler::writeFile($path . $mainVersion, '1');
549
+			FileHandler::writeFile($path.$mainVersion, '1');
550 550
 		}
551
-		else if(isset($_SESSION['enviroment_gather']) && !file_exists(FileHandler::getRealPath($path . $mainVersion)))
551
+		else if (isset($_SESSION['enviroment_gather']) && !file_exists(FileHandler::getRealPath($path.$mainVersion)))
552 552
 		{
553
-			if($_SESSION['enviroment_gather'] == 'Y')
553
+			if ($_SESSION['enviroment_gather'] == 'Y')
554 554
 			{
555 555
 				$oAdminAdminModel = getAdminModel('admin');
556 556
 				$params = $oAdminAdminModel->getEnv();
557
-				$img = sprintf('<img src="%s" alt="" style="height:0px;width:0px" />', $server . $params);
557
+				$img = sprintf('<img src="%s" alt="" style="height:0px;width:0px" />', $server.$params);
558 558
 				Context::addHtmlFooter($img);
559 559
 			}
560 560
 
561
-			FileHandler::writeFile($path . $mainVersion, '1');
561
+			FileHandler::writeFile($path.$mainVersion, '1');
562 562
 			unset($_SESSION['enviroment_gather']);
563 563
 		}
564 564
 	}
@@ -576,64 +576,64 @@  discard block
 block discarded – undo
576 576
 		$tmp = explode("&", $envInfo);
577 577
 		$arrInfo = array();
578 578
 		$xe_check_env = array();
579
-		foreach($tmp as $value) {
579
+		foreach ($tmp as $value) {
580 580
 			$arr = explode("=", $value);
581
-			if($arr[0]=="type") {
581
+			if ($arr[0] == "type") {
582 582
 				continue;
583
-			}elseif($arr[0]=="phpext" ) {
583
+			}elseif ($arr[0] == "phpext") {
584 584
 				$str = urldecode($arr[1]);
585
-				$xe_check_env[$arr[0]]= str_replace("|", ", ", $str);
586
-			} elseif($arr[0]=="module" ) {
585
+				$xe_check_env[$arr[0]] = str_replace("|", ", ", $str);
586
+			} elseif ($arr[0] == "module") {
587 587
 				$str = urldecode($arr[1]);
588 588
 				$arrModuleName = explode("|", $str);
589 589
 				$oModuleModel = getModel("module");
590 590
 				$mInfo = array();
591
-				foreach($arrModuleName as $moduleName) {
591
+				foreach ($arrModuleName as $moduleName) {
592 592
 					$moduleInfo = $oModuleModel->getModuleInfoXml($moduleName);
593 593
 					$mInfo[] = "{$moduleName}({$moduleInfo->version})";
594 594
 				}
595
-				$xe_check_env[$arr[0]]= join(", ", $mInfo);
596
-			} elseif($arr[0]=="addon") {
595
+				$xe_check_env[$arr[0]] = join(", ", $mInfo);
596
+			} elseif ($arr[0] == "addon") {
597 597
 				$str = urldecode($arr[1]);
598 598
 				$arrAddonName = explode("|", $str);
599 599
 				$oAddonModel = getAdminModel("addon");
600 600
 				$mInfo = array();
601
-				foreach($arrAddonName as $addonName) {
601
+				foreach ($arrAddonName as $addonName) {
602 602
 					$addonInfo = $oAddonModel->getAddonInfoXml($addonName);
603 603
 					$mInfo[] = "{$addonName}({$addonInfo->version})";
604 604
 				}
605
-				$xe_check_env[$arr[0]]= join(", ", $mInfo);
606
-			} elseif($arr[0]=="widget") {
605
+				$xe_check_env[$arr[0]] = join(", ", $mInfo);
606
+			} elseif ($arr[0] == "widget") {
607 607
 				$str = urldecode($arr[1]);
608 608
 				$arrWidgetName = explode("|", $str);
609 609
 				$oWidgetModel = getModel("widget");
610 610
 				$mInfo = array();
611
-				foreach($arrWidgetName as $widgetName) {
611
+				foreach ($arrWidgetName as $widgetName) {
612 612
 					$widgetInfo = $oWidgetModel->getWidgetInfo($widgetName);
613 613
 					$mInfo[] = "{$widgetName}({$widgetInfo->version})";
614 614
 				}
615
-				$xe_check_env[$arr[0]]= join(", ", $mInfo);
616
-			} elseif($arr[0]=="widgetstyle") {
615
+				$xe_check_env[$arr[0]] = join(", ", $mInfo);
616
+			} elseif ($arr[0] == "widgetstyle") {
617 617
 				$str = urldecode($arr[1]);
618 618
 				$arrWidgetstyleName = explode("|", $str);
619 619
 				$oWidgetModel = getModel("widget");
620 620
 				$mInfo = array();
621
-				foreach($arrWidgetstyleName as $widgetstyleName) {
621
+				foreach ($arrWidgetstyleName as $widgetstyleName) {
622 622
 					$widgetstyleInfo = $oWidgetModel->getWidgetStyleInfo($widgetstyleName);
623 623
 					$mInfo[] = "{$widgetstyleName}({$widgetstyleInfo->version})";
624 624
 				}
625
-				$xe_check_env[$arr[0]]= join(", ", $mInfo);
625
+				$xe_check_env[$arr[0]] = join(", ", $mInfo);
626 626
 
627
-			} elseif($arr[0]=="layout") {
627
+			} elseif ($arr[0] == "layout") {
628 628
 				$str = urldecode($arr[1]);
629 629
 				$arrLayoutName = explode("|", $str);
630 630
 				$oLayoutModel = getModel("layout");
631 631
 				$mInfo = array();
632
-				foreach($arrLayoutName as $layoutName) {
632
+				foreach ($arrLayoutName as $layoutName) {
633 633
 					$layoutInfo = $oLayoutModel->getLayoutInfo($layoutName);
634 634
 					$mInfo[] = "{$layoutName}({$layoutInfo->version})";
635 635
 				}
636
-				$xe_check_env[$arr[0]]= join(", ", $mInfo);
636
+				$xe_check_env[$arr[0]] = join(", ", $mInfo);
637 637
 			} else {
638 638
 				$xe_check_env[$arr[0]] = urldecode($arr[1]);
639 639
 			}
@@ -647,15 +647,15 @@  discard block
 block discarded – undo
647 647
 		$php_core['memory_limit'] = "{$ini_info['memory_limit']['local_value']}";
648 648
 		$info['PHP_Core'] = $php_core;
649 649
 
650
-		$str_info = "[XE Server Environment " . date("Y-m-d") . "]\n\n";
650
+		$str_info = "[XE Server Environment ".date("Y-m-d")."]\n\n";
651 651
 		$str_info .= "realpath : ".realpath('./')."\n";
652
-		foreach( $info as $key=>$value )
652
+		foreach ($info as $key=>$value)
653 653
 		{
654
-			if( is_array( $value ) == false ) {
654
+			if (is_array($value) == false) {
655 655
 				$str_info .= "{$key} : {$value}\n";
656 656
 			} else {
657 657
 				//$str_info .= "\n{$key} \n";
658
-				foreach( $value as $key2=>$value2 )
658
+				foreach ($value as $key2=>$value2)
659 659
 					$str_info .= "{$key2} : {$value2}\n";
660 660
 			}
661 661
 		}
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 		Context::set('use_rewrite', $useRewrite); 
673 673
 
674 674
 		// nginx 체크, rewrite 사용법 안내
675
-		if($useRewrite == 'N' && stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) Context::set('use_nginx', 'Y');
675
+		if ($useRewrite == 'N' && stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) Context::set('use_nginx', 'Y');
676 676
 		
677 677
 		Context::set('useable', $oInstallController->checkInstallEnv());
678 678
 		$this->setTemplateFile('check_env.html');
Please login to merge, or discard this patch.
Braces   +23 added lines, -13 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
 		if(strpos($db_info->default_url, 'xn--') !== FALSE)
32 32
 		{
33 33
 			$xe_default_url = Context::decodeIdna($db_info->default_url);
34
-		}
35
-		else
34
+		} else
36 35
 		{
37 36
 			$xe_default_url = $db_info->default_url;
38 37
 		}
@@ -434,9 +433,15 @@  discard block
 block discarded – undo
434 433
 
435 434
 		// site lock
436 435
 		Context::set('IP', $_SERVER['REMOTE_ADDR']);
437
-		if(!$db_info->sitelock_title) $db_info->sitelock_title = 'Maintenance in progress...';
438
-		if(!in_array('127.0.0.1', $db_info->sitelock_whitelist)) $db_info->sitelock_whitelist[] = '127.0.0.1';
439
-		if(!in_array($_SERVER['REMOTE_ADDR'], $db_info->sitelock_whitelist)) $db_info->sitelock_whitelist[] = $_SERVER['REMOTE_ADDR'];
436
+		if(!$db_info->sitelock_title) {
437
+			$db_info->sitelock_title = 'Maintenance in progress...';
438
+		}
439
+		if(!in_array('127.0.0.1', $db_info->sitelock_whitelist)) {
440
+			$db_info->sitelock_whitelist[] = '127.0.0.1';
441
+		}
442
+		if(!in_array($_SERVER['REMOTE_ADDR'], $db_info->sitelock_whitelist)) {
443
+			$db_info->sitelock_whitelist[] = $_SERVER['REMOTE_ADDR'];
444
+		}
440 445
 		$db_info->sitelock_whitelist = array_unique($db_info->sitelock_whitelist);
441 446
 		Context::set('remote_addr', $_SERVER['REMOTE_ADDR']);
442 447
 		Context::set('use_sitelock', $db_info->use_sitelock);
@@ -447,8 +452,11 @@  discard block
 block discarded – undo
447 452
 		Context::set('sitelock_whitelist', $whitelist);
448 453
 
449 454
 
450
-		if($db_info->admin_ip_list) $admin_ip_list = implode("\r\n", $db_info->admin_ip_list);
451
-		else $admin_ip_list = '';
455
+		if($db_info->admin_ip_list) {
456
+			$admin_ip_list = implode("\r\n", $db_info->admin_ip_list);
457
+		} else {
458
+			$admin_ip_list = '';
459
+		}
452 460
 		Context::set('admin_ip_list', $admin_ip_list);
453 461
 
454 462
 		Context::set('lang_selected', Context::loadLangSelected());
@@ -547,8 +555,7 @@  discard block
 block discarded – undo
547 555
 			Context::addHtmlFooter($img);
548 556
 
549 557
 			FileHandler::writeFile($path . $mainVersion, '1');
550
-		}
551
-		else if(isset($_SESSION['enviroment_gather']) && !file_exists(FileHandler::getRealPath($path . $mainVersion)))
558
+		} else if(isset($_SESSION['enviroment_gather']) && !file_exists(FileHandler::getRealPath($path . $mainVersion)))
552 559
 		{
553 560
 			if($_SESSION['enviroment_gather'] == 'Y')
554 561
 			{
@@ -580,7 +587,7 @@  discard block
 block discarded – undo
580 587
 			$arr = explode("=", $value);
581 588
 			if($arr[0]=="type") {
582 589
 				continue;
583
-			}elseif($arr[0]=="phpext" ) {
590
+			} elseif($arr[0]=="phpext" ) {
584 591
 				$str = urldecode($arr[1]);
585 592
 				$xe_check_env[$arr[0]]= str_replace("|", ", ", $str);
586 593
 			} elseif($arr[0]=="module" ) {
@@ -655,8 +662,9 @@  discard block
 block discarded – undo
655 662
 				$str_info .= "{$key} : {$value}\n";
656 663
 			} else {
657 664
 				//$str_info .= "\n{$key} \n";
658
-				foreach( $value as $key2=>$value2 )
659
-					$str_info .= "{$key2} : {$value2}\n";
665
+				foreach( $value as $key2=>$value2 ) {
666
+									$str_info .= "{$key2} : {$value2}\n";
667
+				}
660 668
 			}
661 669
 		}
662 670
 
@@ -672,7 +680,9 @@  discard block
 block discarded – undo
672 680
 		Context::set('use_rewrite', $useRewrite); 
673 681
 
674 682
 		// nginx 체크, rewrite 사용법 안내
675
-		if($useRewrite == 'N' && stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) Context::set('use_nginx', 'Y');
683
+		if($useRewrite == 'N' && stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) {
684
+			Context::set('use_nginx', 'Y');
685
+		}
676 686
 		
677 687
 		Context::set('useable', $oInstallController->checkInstallEnv());
678 688
 		$this->setTemplateFile('check_env.html');
Please login to merge, or discard this patch.
modules/adminlogging/adminlogging.controller.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
 	/**
16 16
 	 * Initialization
17
-	 * @return void
17
+	 * @return ModuleObject|null
18 18
 	 */
19 19
 	function init()
20 20
 	{
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 		// forbit access if the user is not an administrator
22 22
 		$oMemberModel = getModel('member');
23 23
 		$logged_info = $oMemberModel->getLoggedInfo();
24
-		if($logged_info->is_admin != 'Y')
24
+		if ($logged_info->is_admin != 'Y')
25 25
 		{
26 26
 			return $this->stop("msg_is_not_administrator");
27 27
 		}
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 */
34 34
 	function insertLog($module, $act)
35 35
 	{
36
-		if(!$module || !$act)
36
+		if (!$module || !$act)
37 37
 		{
38 38
 			return;
39 39
 		}
Please login to merge, or discard this patch.
modules/autoinstall/autoinstall.admin.controller.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -332,6 +332,7 @@
 block discarded – undo
332 332
 	/**
333 333
 	 * Uninstall package by package serial number
334 334
 	 *
335
+	 * @param string $package_srl
335 336
 	 * @return Object
336 337
 	 */
337 338
 	function uninstallPackageByPackageSrl($package_srl)
Please login to merge, or discard this patch.
Braces   +13 added lines, -26 removed lines patch added patch discarded remove patch
@@ -104,8 +104,7 @@  discard block
 block discarded – undo
104 104
 			if($type == "core")
105 105
 			{
106 106
 				$version = __XE_VERSION__;
107
-			}
108
-			else
107
+			} else
109 108
 			{
110 109
 				$config_file = NULL;
111 110
 				switch($type)
@@ -161,8 +160,7 @@  discard block
 block discarded – undo
161 160
 			if(version_compare($args->version, $args->current_version, ">"))
162 161
 			{
163 162
 				$args->need_update = "Y";
164
-			}
165
-			else
163
+			} else
166 164
 			{
167 165
 				$args->need_update = "N";
168 166
 			}
@@ -187,8 +185,7 @@  discard block
 block discarded – undo
187 185
 		if(!$_SESSION['ftp_password'])
188 186
 		{
189 187
 			$ftp_password = Context::get('ftp_password');
190
-		}
191
-		else
188
+		} else
192 189
 		{
193 190
 			$ftp_password = $_SESSION['ftp_password'];
194 191
 		}
@@ -200,16 +197,13 @@  discard block
 block discarded – undo
200 197
 			if($oAdminModel->checkUseDirectModuleInstall($package)->toBool())
201 198
 			{
202 199
 				$oModuleInstaller = new DirectModuleInstaller($package);
203
-			}
204
-			else if($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
200
+			} else if($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
205 201
 			{
206 202
 				$oModuleInstaller = new SFTPModuleInstaller($package);
207
-			}
208
-			else if(function_exists(ftp_connect))
203
+			} else if(function_exists(ftp_connect))
209 204
 			{
210 205
 				$oModuleInstaller = new PHPFTPModuleInstaller($package);
211
-			}
212
-			else
206
+			} else
213 207
 			{
214 208
 				$oModuleInstaller = new FTPModuleInstaller($package);
215 209
 			}
@@ -230,8 +224,7 @@  discard block
 block discarded – undo
230 224
 		if(Context::get('return_url'))
231 225
 		{
232 226
 			$this->setRedirectUrl(Context::get('return_url'));
233
-		}
234
-		else
227
+		} else
235 228
 		{
236 229
 			$this->setRedirectUrl(preg_replace('/act=[^&]*/', 'act=dispAutoinstallAdminIndex', Context::get('error_return_url')));
237 230
 		}
@@ -265,8 +258,7 @@  discard block
 block discarded – undo
265 258
 			if($oModel->getPackage($args->package_srl))
266 259
 			{
267 260
 				$output = executeQuery("autoinstall.updatePackage", $args);
268
-			}
269
-			else
261
+			} else
270 262
 			{
271 263
 				$output = executeQuery("autoinstall.insertPackage", $args);
272 264
 				if(!$output->toBool())
@@ -322,8 +314,7 @@  discard block
 block discarded – undo
322 314
 		if(Context::get('return_url'))
323 315
 		{
324 316
 			$this->setRedirectUrl(Context::get('return_url'));
325
-		}
326
-		else
317
+		} else
327 318
 		{
328 319
 			$this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminInstalledPackages'));
329 320
 		}
@@ -362,8 +353,7 @@  discard block
 block discarded – undo
362 353
 		if(!$_SESSION['ftp_password'])
363 354
 		{
364 355
 			$ftp_password = Context::get('ftp_password');
365
-		}
366
-		else
356
+		} else
367 357
 		{
368 358
 			$ftp_password = $_SESSION['ftp_password'];
369 359
 		}
@@ -373,16 +363,13 @@  discard block
 block discarded – undo
373 363
 		if($oAdminModel->checkUseDirectModuleInstall($package)->toBool())
374 364
 		{
375 365
 			$oModuleInstaller = new DirectModuleInstaller($package);
376
-		}
377
-		else if($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
366
+		} else if($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
378 367
 		{
379 368
 			$oModuleInstaller = new SFTPModuleInstaller($package);
380
-		}
381
-		else if(function_exists('ftp_connect'))
369
+		} else if(function_exists('ftp_connect'))
382 370
 		{
383 371
 			$oModuleInstaller = new PHPFTPModuleInstaller($package);
384
-		}
385
-		else
372
+		} else
386 373
 		{
387 374
 			$oModuleInstaller = new FTPModuleInstaller($package);
388 375
 		}
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4
-require_once(_XE_PATH_ . 'modules/autoinstall/autoinstall.lib.php');
4
+require_once(_XE_PATH_.'modules/autoinstall/autoinstall.lib.php');
5 5
 
6 6
 /**
7 7
  * autoinstall module admin controller class
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	{
65 65
 		$oModel = getModel('autoinstall');
66 66
 		$item = $oModel->getLatestPackage();
67
-		if($item)
67
+		if ($item)
68 68
 		{
69 69
 			$params["updatedate"] = $item->updatedate;
70 70
 		}
@@ -92,23 +92,23 @@  discard block
 block discarded – undo
92 92
 		executeQuery("autoinstall.deleteInstalledPackage");
93 93
 		$oModel = getModel('autoinstall');
94 94
 		$packages = $oModel->getPackages();
95
-		foreach($packages as $package)
95
+		foreach ($packages as $package)
96 96
 		{
97 97
 			$real_path = FileHandler::getRealPath($package->path);
98
-			if(!file_exists($real_path))
98
+			if (!file_exists($real_path))
99 99
 			{
100 100
 				continue;
101 101
 			}
102 102
 
103 103
 			$type = $oModel->getTypeFromPath($package->path);
104
-			if($type == "core")
104
+			if ($type == "core")
105 105
 			{
106 106
 				$version = __XE_VERSION__;
107 107
 			}
108 108
 			else
109 109
 			{
110 110
 				$config_file = NULL;
111
-				switch($type)
111
+				switch ($type)
112 112
 				{
113 113
 					case "m.layout":
114 114
 						$type = "layout";
@@ -138,15 +138,15 @@  discard block
 block discarded – undo
138 138
 						break;
139 139
 				}
140 140
 
141
-				if(!$config_file)
141
+				if (!$config_file)
142 142
 				{
143 143
 					continue;
144 144
 				}
145 145
 
146 146
 				$xml = new XmlParser();
147
-				$xmlDoc = $xml->loadXmlFile($real_path . $config_file);
147
+				$xmlDoc = $xml->loadXmlFile($real_path.$config_file);
148 148
 
149
-				if(!$xmlDoc)
149
+				if (!$xmlDoc)
150 150
 				{
151 151
 					continue;
152 152
 				}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			$args->package_srl = $package->package_srl;
159 159
 			$args->version = $package->version;
160 160
 			$args->current_version = $version;
161
-			if(version_compare($args->version, $args->current_version, ">"))
161
+			if (version_compare($args->version, $args->current_version, ">"))
162 162
 			{
163 163
 				$args->need_update = "Y";
164 164
 			}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		$oAdminModel = getAdminModel('autoinstall');
185 185
 		$packages = explode(',', $package_srls);
186 186
 		$ftp_info = Context::getFTPInfo();
187
-		if(!$_SESSION['ftp_password'])
187
+		if (!$_SESSION['ftp_password'])
188 188
 		{
189 189
 			$ftp_password = Context::get('ftp_password');
190 190
 		}
@@ -194,18 +194,18 @@  discard block
 block discarded – undo
194 194
 		}
195 195
 
196 196
 		$isSftpSupported = function_exists(ssh2_sftp);
197
-		foreach($packages as $package_srl)
197
+		foreach ($packages as $package_srl)
198 198
 		{
199 199
 			$package = $oModel->getPackage($package_srl);
200
-			if($oAdminModel->checkUseDirectModuleInstall($package)->toBool())
200
+			if ($oAdminModel->checkUseDirectModuleInstall($package)->toBool())
201 201
 			{
202 202
 				$oModuleInstaller = new DirectModuleInstaller($package);
203 203
 			}
204
-			else if($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
204
+			else if ($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
205 205
 			{
206 206
 				$oModuleInstaller = new SFTPModuleInstaller($package);
207 207
 			}
208
-			else if(function_exists(ftp_connect))
208
+			else if (function_exists(ftp_connect))
209 209
 			{
210 210
 				$oModuleInstaller = new PHPFTPModuleInstaller($package);
211 211
 			}
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$oModuleInstaller->setServerUrl(_XE_DOWNLOAD_SERVER_);
218 218
 			$oModuleInstaller->setPassword($ftp_password);
219 219
 			$output = $oModuleInstaller->install();
220
-			if(!$output->toBool())
220
+			if (!$output->toBool())
221 221
 			{
222 222
 				return $output;
223 223
 			}
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
 		$this->setMessage('success_installed', 'update');
229 229
 
230
-		if(Context::get('return_url'))
230
+		if (Context::get('return_url'))
231 231
 		{
232 232
 			$this->setRedirectUrl(Context::get('return_url'));
233 233
 		}
@@ -246,30 +246,30 @@  discard block
 block discarded – undo
246 246
 	function updatePackages(&$xmlDoc)
247 247
 	{
248 248
 		$oModel = getModel('autoinstall');
249
-		if(!$xmlDoc->response->packages->item)
249
+		if (!$xmlDoc->response->packages->item)
250 250
 		{
251 251
 			return;
252 252
 		}
253
-		if(!is_array($xmlDoc->response->packages->item))
253
+		if (!is_array($xmlDoc->response->packages->item))
254 254
 		{
255 255
 			$xmlDoc->response->packages->item = array($xmlDoc->response->packages->item);
256 256
 		}
257 257
 		$targets = array('package_srl', 'updatedate', 'latest_item_srl', 'path', 'version', 'category_srl', 'have_instance');
258
-		foreach($xmlDoc->response->packages->item as $item)
258
+		foreach ($xmlDoc->response->packages->item as $item)
259 259
 		{
260 260
 			$args = new stdClass();
261
-			foreach($targets as $target)
261
+			foreach ($targets as $target)
262 262
 			{
263 263
 				$args->{$target} = $item->{$target}->body;
264 264
 			}
265
-			if($oModel->getPackage($args->package_srl))
265
+			if ($oModel->getPackage($args->package_srl))
266 266
 			{
267 267
 				$output = executeQuery("autoinstall.updatePackage", $args);
268 268
 			}
269 269
 			else
270 270
 			{
271 271
 				$output = executeQuery("autoinstall.insertPackage", $args);
272
-				if(!$output->toBool())
272
+				if (!$output->toBool())
273 273
 				{
274 274
 					$output = executeQuery("autoinstall.deletePackage", $args);
275 275
 					$output = executeQuery("autoinstall.insertPackage", $args);
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
 	{
289 289
 		executeQuery("autoinstall.deleteCategory");
290 290
 		$oModel = getModel('autoinstall');
291
-		if(!is_array($xmlDoc->response->categorylist->item))
291
+		if (!is_array($xmlDoc->response->categorylist->item))
292 292
 		{
293 293
 			$xmlDoc->response->categorylist->item = array($xmlDoc->response->categorylist->item);
294 294
 		}
295 295
 		$list_order = 0;
296
-		foreach($xmlDoc->response->categorylist->item as $item)
296
+		foreach ($xmlDoc->response->categorylist->item as $item)
297 297
 		{
298 298
 			$args = new stdClass();
299 299
 			$args->category_srl = $item->category_srl->body;
@@ -314,12 +314,12 @@  discard block
 block discarded – undo
314 314
 		$package_srl = Context::get('package_srl');
315 315
 
316 316
 		$output = $this->uninstallPackageByPackageSrl($package_srl);
317
-		if($output->toBool()==FALSE)
317
+		if ($output->toBool() == FALSE)
318 318
 		{
319 319
 			return $output;
320 320
 		}
321 321
 
322
-		if(Context::get('return_url'))
322
+		if (Context::get('return_url'))
323 323
 		{
324 324
 			$this->setRedirectUrl(Context::get('return_url'));
325 325
 		}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 
360 360
 		$oAdminModel = getAdminModel('autoinstall');
361 361
 
362
-		if(!$_SESSION['ftp_password'])
362
+		if (!$_SESSION['ftp_password'])
363 363
 		{
364 364
 			$ftp_password = Context::get('ftp_password');
365 365
 		}
@@ -370,15 +370,15 @@  discard block
 block discarded – undo
370 370
 		$ftp_info = Context::getFTPInfo();
371 371
 
372 372
 		$isSftpSupported = function_exists(ssh2_sftp);
373
-		if($oAdminModel->checkUseDirectModuleInstall($package)->toBool())
373
+		if ($oAdminModel->checkUseDirectModuleInstall($package)->toBool())
374 374
 		{
375 375
 			$oModuleInstaller = new DirectModuleInstaller($package);
376 376
 		}
377
-		else if($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
377
+		else if ($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
378 378
 		{
379 379
 			$oModuleInstaller = new SFTPModuleInstaller($package);
380 380
 		}
381
-		else if(function_exists('ftp_connect'))
381
+		else if (function_exists('ftp_connect'))
382 382
 		{
383 383
 			$oModuleInstaller = new PHPFTPModuleInstaller($package);
384 384
 		}
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 
392 392
 		$oModuleInstaller->setPassword($ftp_password);
393 393
 		$output = $oModuleInstaller->uninstall();
394
-		if(!$output->toBool())
394
+		if (!$output->toBool())
395 395
 		{
396 396
 			return $output;
397 397
 		}
Please login to merge, or discard this patch.
modules/autoinstall/autoinstall.admin.model.php 3 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -15,6 +15,9 @@  discard block
 block discarded – undo
15 15
 
16 16
 	/**
17 17
 	 * Pre process parameters
18
+	 * @param string $order_target
19
+	 * @param string $order_type
20
+	 * @param string $page
18 21
 	 */
19 22
 	function preProcParam(&$order_target, &$order_type, &$page)
20 23
 	{
@@ -115,6 +118,10 @@  discard block
 block discarded – undo
115 118
 
116 119
 	/**
117 120
 	 * Get Package List
121
+	 * @param string $type
122
+	 * @param string $search_keyword
123
+	 * @param integer $category_srl
124
+	 * @param string $parent_program
118 125
 	 */
119 126
 	function getPackageList($type, $order_target = 'newest', $order_type = 'desc', $page = '1', $search_keyword = NULL, $category_srl = NULL, $parent_program = NULL)
120 127
 	{
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -19,19 +19,19 @@  discard block
 block discarded – undo
19 19
 	function preProcParam(&$order_target, &$order_type, &$page)
20 20
 	{
21 21
 		$order_target_array = array('newest' => 1, 'download' => 1, 'popular' => 1);
22
-		if(!isset($order_target_array[$order_target]))
22
+		if (!isset($order_target_array[$order_target]))
23 23
 		{
24 24
 			$order_target = 'newest';
25 25
 		}
26 26
 
27 27
 		$order_type_array = array('asc' => 1, 'desc' => 1);
28
-		if(!isset($order_type_array[$order_type]))
28
+		if (!isset($order_type_array[$order_type]))
29 29
 		{
30 30
 			$order_type = 'desc';
31 31
 		}
32 32
 
33 33
 		$page = (int) $page;
34
-		if($page < 1)
34
+		if ($page < 1)
35 35
 		{
36 36
 			$page = 1;
37 37
 		}
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
 
64 64
 		$type_array = array('M' => 1, 'P' => 1);
65 65
 		$type = Context::get('type');
66
-		if(!isset($type_array[$type]))
66
+		if (!isset($type_array[$type]))
67 67
 		{
68 68
 			$type = 'P';
69 69
 		}
70 70
 
71
-		if($type == 'P')
71
+		if ($type == 'P')
72 72
 		{
73 73
 			$category_srl = $this->layout_category_srl;
74 74
 		}
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 
96 96
 		$type_array = array('M' => 1, 'P' => 1);
97 97
 		$type = Context::get('type');
98
-		if(!isset($type_array[$type]))
98
+		if (!isset($type_array[$type]))
99 99
 		{
100 100
 			$type = 'P';
101 101
 		}
102 102
 
103
-		if($type == 'P')
103
+		if ($type == 'P')
104 104
 		{
105 105
 			$category_srl = $this->module_skin_category_srl;
106 106
 		}
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	function getPackageList($type, $order_target = 'newest', $order_type = 'desc', $page = '1', $search_keyword = NULL, $category_srl = NULL, $parent_program = NULL)
120 120
 	{
121
-		if($type == 'menu')
121
+		if ($type == 'menu')
122 122
 		{
123 123
 			$params["act"] = "getResourceapiMenuPackageList";
124 124
 		}
125
-		elseif($type == 'skin')
125
+		elseif ($type == 'skin')
126 126
 		{
127 127
 			$params["act"] = "getResourceapiSkinPackageList";
128 128
 			$params['parent_program'] = $parent_program;
@@ -137,18 +137,18 @@  discard block
 block discarded – undo
137 137
 		$params["order_type"] = $order_type;
138 138
 		$params["page"] = $page;
139 139
 
140
-		if($category_srl)
140
+		if ($category_srl)
141 141
 		{
142 142
 			$params["category_srl"] = $category_srl;
143 143
 		}
144 144
 
145
-		if($search_keyword)
145
+		if ($search_keyword)
146 146
 		{
147 147
 			$params["search_keyword"] = $search_keyword;
148 148
 		}
149 149
 
150 150
 		$xmlDoc = XmlGenerater::getXmlDoc($params);
151
-		if($xmlDoc && $xmlDoc->response->packagelist->item)
151
+		if ($xmlDoc && $xmlDoc->response->packagelist->item)
152 152
 		{
153 153
 			$item_list = $oAdminView->rearranges($xmlDoc->response->packagelist->item);
154 154
 			$this->add('item_list', $item_list);
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
 		
170 170
 		$is_authed = 0;
171 171
 		$output = $oAdminModel->checkUseDirectModuleInstall($package);
172
-		if($output->toBool()==TRUE)
172
+		if ($output->toBool() == TRUE)
173 173
 		{
174 174
 			$is_authed = 1;
175 175
 		}
176 176
 		else
177 177
 		{
178 178
 			$ftp_info = Context::getFTPInfo();
179
-			if(!$ftp_info->ftp_root_path)
179
+			if (!$ftp_info->ftp_root_path)
180 180
 			{
181 181
 				$is_authed = -1;
182 182
 			}
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
 	{
197 197
 		$oModel = getModel('autoinstall');
198 198
 		$output = executeQueryArray('autoinstall.getNeedUpdate');
199
-		if(!is_array($output->data))
199
+		if (!is_array($output->data))
200 200
 		{
201 201
 			return NULL;
202 202
 		}
203 203
 
204 204
 		$result = array();
205 205
 		$xml = new XmlParser();
206
-		foreach($output->data as $package)
206
+		foreach ($output->data as $package)
207 207
 		{
208 208
 			$packageSrl = $package->package_srl;
209 209
 
@@ -213,27 +213,27 @@  discard block
 block discarded – undo
213 213
 			$packageInfo->type = $oModel->getTypeFromPath($package->path);
214 214
 			$packageInfo->url = $oModel->getUpdateUrlByPackageSrl($package->package_srl);
215 215
 
216
-			if($packageInfo->type == 'core')
216
+			if ($packageInfo->type == 'core')
217 217
 			{
218 218
 				$title = 'XpressEngine';
219 219
 			}
220 220
 			else
221 221
 			{
222 222
 				$configFile = $oModel->getConfigFilePath($packageInfo->type);
223
-				$xmlDoc = $xml->loadXmlFile(FileHandler::getRealPath($package->path) . $configFile);
223
+				$xmlDoc = $xml->loadXmlFile(FileHandler::getRealPath($package->path).$configFile);
224 224
 
225
-				if($xmlDoc)
225
+				if ($xmlDoc)
226 226
 				{
227 227
 					$type = $packageInfo->type;
228
-					if($type == "drcomponent")
228
+					if ($type == "drcomponent")
229 229
 					{
230 230
 						$type = "component";
231 231
 					}
232
-					if($type == "style" || $type == "m.skin")
232
+					if ($type == "style" || $type == "m.skin")
233 233
 					{
234 234
 						$type = "skin";
235 235
 					}
236
-					if($type == "m.layout")
236
+					if ($type == "m.layout")
237 237
 					{
238 238
 						$type = "layout";
239 239
 					}
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 		$oModel = getModel('autoinstall');
268 268
 
269 269
 		$targetpackages = array();
270
-		if($xmlDoc)
270
+		if ($xmlDoc)
271 271
 		{
272 272
 			$xmlPackage = $xmlDoc->response->package;
273 273
 			$package = new stdClass();
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
 			$package->package_description = $xmlPackage->package_description->body;
277 277
 			$package->version = $xmlPackage->version->body;
278 278
 			$package->path = $xmlPackage->path->body;
279
-			if($xmlPackage->depends)
279
+			if ($xmlPackage->depends)
280 280
 			{
281
-				if(!is_array($xmlPackage->depends->item))
281
+				if (!is_array($xmlPackage->depends->item))
282 282
 				{
283 283
 					$xmlPackage->depends->item = array($xmlPackage->depends->item);
284 284
 				}
285 285
 
286 286
 				$package->depends = array();
287
-				foreach($xmlPackage->depends->item as $item)
287
+				foreach ($xmlPackage->depends->item as $item)
288 288
 				{
289 289
 					$dep_item = new stdClass();
290 290
 					$dep_item->package_srl = $item->package_srl->body;
@@ -297,23 +297,23 @@  discard block
 block discarded – undo
297 297
 
298 298
 				$packages = $oModel->getInstalledPackages(array_keys($targetpackages));
299 299
 				$package->deplist = "";
300
-				foreach($package->depends as $key => $dep)
300
+				foreach ($package->depends as $key => $dep)
301 301
 				{
302
-					if(!$packages[$dep->package_srl])
302
+					if (!$packages[$dep->package_srl])
303 303
 					{
304 304
 						$package->depends[$key]->installed = FALSE;
305
-						$package->package_srl .= "," . $dep->package_srl;
305
+						$package->package_srl .= ",".$dep->package_srl;
306 306
 					}
307 307
 					else
308 308
 					{
309 309
 						$package->depends[$key]->installed = TRUE;
310 310
 						$package->depends[$key]->cur_version = $packages[$dep->package_srl]->current_version;
311
-						if(version_compare($dep->version, $packages[$dep->package_srl]->current_version, ">"))
311
+						if (version_compare($dep->version, $packages[$dep->package_srl]->current_version, ">"))
312 312
 						{
313 313
 							$package->depends[$key]->need_update = TRUE;
314
-							$package->package_srl .= "," . $dep->package_srl;
314
+							$package->package_srl .= ",".$dep->package_srl;
315 315
 
316
-							if($dep->path === '.')
316
+							if ($dep->path === '.')
317 317
 							{
318 318
 								$package->contain_core = TRUE;
319 319
 								$package->contain_core_version = $dep->version;
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
 			}
329 329
 
330 330
 			$installedPackage = $oModel->getInstalledPackage($packageSrl);
331
-			if($installedPackage)
331
+			if ($installedPackage)
332 332
 			{
333 333
 				$package->installed = TRUE;
334 334
 				$package->cur_version = $installedPackage->current_version;
335 335
 				$package->need_update = version_compare($package->version, $installedPackage->current_version, ">");
336 336
 			}
337 337
 
338
-			if($package->path === '.')
338
+			if ($package->path === '.')
339 339
 			{
340 340
 				$package->contain_core = TRUE;
341 341
 				$package->contain_core_version = $package->version;
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	public function getAutoInstallAdminInstallInfo()
352 352
 	{
353 353
 		$packageSrl = Context::get('package_srl');
354
-		if(!$packageSrl)
354
+		if (!$packageSrl)
355 355
 		{
356 356
 			return new Object(-1, 'msg_invalid_request');
357 357
 		}
@@ -365,23 +365,23 @@  discard block
 block discarded – undo
365 365
 		$directModuleInstall = TRUE;
366 366
 		$arrUnwritableDir = array();
367 367
 		$output = $this->isWritableDir($package->path);
368
-		if($output->toBool()==FALSE)
368
+		if ($output->toBool() == FALSE)
369 369
 		{
370 370
 			$directModuleInstall = FALSE;
371 371
 			$arrUnwritableDir[] = $output->get('path');
372 372
 		}
373 373
 
374
-		foreach($package->depends as $dep)
374
+		foreach ($package->depends as $dep)
375 375
 		{
376 376
 			$output = $this->isWritableDir($dep->path);
377
-			if($output->toBool()==FALSE)
377
+			if ($output->toBool() == FALSE)
378 378
 			{
379 379
 				$directModuleInstall = FALSE;
380 380
 				$arrUnwritableDir[] = $output->get('path');
381 381
 			}
382 382
 		}
383 383
 
384
-		if($directModuleInstall==FALSE)
384
+		if ($directModuleInstall == FALSE)
385 385
 		{
386 386
 			$output = new Object(-1, 'msg_direct_inall_invalid');
387 387
 			$output->add('path', $arrUnwritableDir);
@@ -396,17 +396,17 @@  discard block
 block discarded – undo
396 396
 		$path_list = explode('/', dirname($path));
397 397
 		$real_path = './';
398 398
 
399
-		while($path_list)
399
+		while ($path_list)
400 400
 		{
401
-			$check_path = realpath($real_path . implode('/', $path_list));
402
-			if(FileHandler::isDir($check_path))
401
+			$check_path = realpath($real_path.implode('/', $path_list));
402
+			if (FileHandler::isDir($check_path))
403 403
 			{
404 404
 				break;
405 405
 			}
406 406
 			array_pop($path_list);
407 407
 		}
408 408
 
409
-		if(FileHandler::isWritableDir($check_path)==FALSE)
409
+		if (FileHandler::isWritableDir($check_path) == FALSE)
410 410
 		{
411 411
 			$output = new Object(-1, 'msg_unwritable_directory');
412 412
 			$output->add('path', FileHandler::getRealPath($check_path));
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -71,8 +71,7 @@  discard block
 block discarded – undo
71 71
 		if($type == 'P')
72 72
 		{
73 73
 			$category_srl = $this->layout_category_srl;
74
-		}
75
-		else
74
+		} else
76 75
 		{
77 76
 			$category_srl = $this->mobile_layout_category_srl;
78 77
 		}
@@ -103,8 +102,7 @@  discard block
 block discarded – undo
103 102
 		if($type == 'P')
104 103
 		{
105 104
 			$category_srl = $this->module_skin_category_srl;
106
-		}
107
-		else
105
+		} else
108 106
 		{
109 107
 			$category_srl = $this->module_mobile_skin_category_srl;
110 108
 		}
@@ -121,13 +119,11 @@  discard block
 block discarded – undo
121 119
 		if($type == 'menu')
122 120
 		{
123 121
 			$params["act"] = "getResourceapiMenuPackageList";
124
-		}
125
-		elseif($type == 'skin')
122
+		} elseif($type == 'skin')
126 123
 		{
127 124
 			$params["act"] = "getResourceapiSkinPackageList";
128 125
 			$params['parent_program'] = $parent_program;
129
-		}
130
-		else
126
+		} else
131 127
 		{
132 128
 			$params["act"] = "getResourceapiPackagelist";
133 129
 		}
@@ -172,15 +168,13 @@  discard block
 block discarded – undo
172 168
 		if($output->toBool()==TRUE)
173 169
 		{
174 170
 			$is_authed = 1;
175
-		}
176
-		else
171
+		} else
177 172
 		{
178 173
 			$ftp_info = Context::getFTPInfo();
179 174
 			if(!$ftp_info->ftp_root_path)
180 175
 			{
181 176
 				$is_authed = -1;
182
-			}
183
-			else
177
+			} else
184 178
 			{
185 179
 				$is_authed = (int) isset($_SESSION['ftp_password']);
186 180
 			}
@@ -216,8 +210,7 @@  discard block
 block discarded – undo
216 210
 			if($packageInfo->type == 'core')
217 211
 			{
218 212
 				$title = 'XpressEngine';
219
-			}
220
-			else
213
+			} else
221 214
 			{
222 215
 				$configFile = $oModel->getConfigFilePath($packageInfo->type);
223 216
 				$xmlDoc = $xml->loadXmlFile(FileHandler::getRealPath($package->path) . $configFile);
@@ -238,8 +231,7 @@  discard block
 block discarded – undo
238 231
 						$type = "layout";
239 232
 					}
240 233
 					$title = $xmlDoc->{$type}->title->body;
241
-				}
242
-				else
234
+				} else
243 235
 				{
244 236
 					$pathInfo = explode('/', $package->path);
245 237
 					$title = $pathInfo[count($pathInfo) - 1];
@@ -303,8 +295,7 @@  discard block
 block discarded – undo
303 295
 					{
304 296
 						$package->depends[$key]->installed = FALSE;
305 297
 						$package->package_srl .= "," . $dep->package_srl;
306
-					}
307
-					else
298
+					} else
308 299
 					{
309 300
 						$package->depends[$key]->installed = TRUE;
310 301
 						$package->depends[$key]->cur_version = $packages[$dep->package_srl]->current_version;
@@ -318,8 +309,7 @@  discard block
 block discarded – undo
318 309
 								$package->contain_core = TRUE;
319 310
 								$package->contain_core_version = $dep->version;
320 311
 							}
321
-						}
322
-						else
312
+						} else
323 313
 						{
324 314
 							$package->need_update = FALSE;
325 315
 						}
Please login to merge, or discard this patch.