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 ( cac676...2c1c8e )
by gyeong-won
24:40 queued 13:58
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.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.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.
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.
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 BaseObject(-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 BaseObject(-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 BaseObject(-1, 'msg_unwritable_directory');
412 412
 			$output->add('path', FileHandler::getRealPath($check_path));
Please login to merge, or discard this patch.
modules/board/board.admin.model.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 
22 22
 	/**
23 23
 	 * Get the board module admin simple setting page
24
-	 * @return void
24
+	 * @return null|string
25 25
 	 */
26 26
 	public function getBoardAdminSimpleSetup($moduleSrl, $setupUrl)
27 27
 	{
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 */
26 26
 	public function getBoardAdminSimpleSetup($moduleSrl, $setupUrl)
27 27
 	{
28
-		if(!$moduleSrl)
28
+		if (!$moduleSrl)
29 29
 		{
30 30
 			return;
31 31
 		}
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		$oModuleModel = getModel('module');
36 36
 		$moduleInfo = $oModuleModel->getModuleInfoByModuleSrl($moduleSrl);
37 37
 		$moduleInfo->use_status = explode('|@|', $moduleInfo->use_status);
38
-		if($moduleInfo)
38
+		if ($moduleInfo)
39 39
 		{
40 40
 			Context::set('module_info', $moduleInfo);
41 41
 		}
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		Context::set('document_status_list', $documentStatusList);
47 47
 
48 48
 		// set order target list
49
-		foreach($this->order_target AS $key)
49
+		foreach ($this->order_target AS $key)
50 50
 		{
51 51
 			$order_target[$key] = Context::getLang($key);
52 52
 		}
Please login to merge, or discard this patch.
modules/board/board.api.php 3 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -87,6 +87,9 @@  discard block
 block discarded – undo
87 87
 		$oModule->add('comment_list',$this->arrangeComment(Context::get('comment_list')));
88 88
 	}
89 89
 
90
+	/**
91
+	 * @param string $content_list
92
+	 */
90 93
 	function arrangeContentList($content_list) {
91 94
 		$output = array();
92 95
 		if(count($content_list)) {
@@ -120,6 +123,9 @@  discard block
 block discarded – undo
120 123
 		return $output;
121 124
 	}
122 125
 
126
+	/**
127
+	 * @param string $comment_list
128
+	 */
123 129
 	function arrangeComment($comment_list) {
124 130
 		$output = array();
125 131
 		if(count($comment_list) > 0 ) {
@@ -133,6 +139,9 @@  discard block
 block discarded – undo
133 139
 	}
134 140
 
135 141
 
142
+	/**
143
+	 * @param string $file_list
144
+	 */
136 145
 	function arrangeFile($file_list) {
137 146
 		$output = array();
138 147
 		if(count($file_list) > 0) {
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @brief notice list
19 19
 	 **/
20 20
 	function dispBoardNoticeList(&$oModule) {
21
-		 $oModule->add('notice_list',$this->arrangeContentList(Context::get('notice_list')));
21
+		 $oModule->add('notice_list', $this->arrangeContentList(Context::get('notice_list')));
22 22
 	}
23 23
 
24 24
 
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
 		$api_type = Context::get('api_type');
30 30
 		$document_list = $this->arrangeContentList(Context::get('document_list'));
31 31
 
32
-		if($api_type =='summary')
32
+		if ($api_type == 'summary')
33 33
 		{
34 34
 			$content_cut_size = Context::get('content_cut_size');
35
-			$content_cut_size = $content_cut_size?$content_cut_size:50;
36
-			foreach($document_list as $k=>$v)
35
+			$content_cut_size = $content_cut_size ? $content_cut_size : 50;
36
+			foreach ($document_list as $k=>$v)
37 37
 			{
38 38
 				$oDocument = new documentItem();
39 39
 				$oDocument->setAttribute($v, false);
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 			}
43 43
 		}
44 44
 
45
-		$oModule->add('document_list',$document_list);
46
-		$oModule->add('page_navigation',Context::get('page_navigation'));
45
+		$oModule->add('document_list', $document_list);
46
+		$oModule->add('page_navigation', Context::get('page_navigation'));
47 47
 	}
48 48
 
49 49
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @brief category list
52 52
 	 **/
53 53
 	function dispBoardCategoryList(&$oModule) {
54
-		$oModule->add('category_list',Context::get('category_list'));
54
+		$oModule->add('category_list', Context::get('category_list'));
55 55
 	}
56 56
 
57 57
 	/**
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	function dispBoardContentView(&$oModule) {
61 61
 		$oDocument = Context::get('oDocument');
62 62
 		$extra_vars = $oDocument->getExtraVars();
63
-		if($oDocument->isGranted())
63
+		if ($oDocument->isGranted())
64 64
 		{
65
-			$oDocument->add('extra_vars',$this->arrangeExtraVars($extra_vars));
65
+			$oDocument->add('extra_vars', $this->arrangeExtraVars($extra_vars));
66 66
 		}
67
-		$oModule->add('oDocument',$this->arrangeContent($oDocument));
67
+		$oModule->add('oDocument', $this->arrangeContent($oDocument));
68 68
 	}
69 69
 
70 70
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 **/
74 74
 	function dispBoardContentFileList(&$oModule) {
75 75
 		$oDocument = Context::get('oDocument');
76
-		if($oDocument->isAccessible())
76
+		if ($oDocument->isAccessible())
77 77
 		{
78 78
 			$oModule->add('file_list', $this->arrangeFile(Context::get('file_list')));
79 79
 		}
@@ -88,20 +88,20 @@  discard block
 block discarded – undo
88 88
 	 * @brief tag list
89 89
 	 **/
90 90
 	function dispBoardTagList(&$oModule) {
91
-		$oModule->add('tag_list',Context::get('tag_list'));
91
+		$oModule->add('tag_list', Context::get('tag_list'));
92 92
 	}
93 93
 
94 94
 	/**
95 95
 	 * @brief comments list
96 96
 	 **/
97 97
 	function dispBoardContentCommentList(&$oModule) {
98
-		$oModule->add('comment_list',$this->arrangeComment(Context::get('comment_list')));
98
+		$oModule->add('comment_list', $this->arrangeComment(Context::get('comment_list')));
99 99
 	}
100 100
 
101 101
 	function arrangeContentList($content_list) {
102 102
 		$output = array();
103
-		if(count($content_list)) {
104
-			foreach($content_list as $key => $val) $output[] = $this->arrangeContent($val);
103
+		if (count($content_list)) {
104
+			foreach ($content_list as $key => $val) $output[] = $this->arrangeContent($val);
105 105
 		}
106 106
 		return $output;
107 107
 	}
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
 	function arrangeContent($content) {
111 111
 		$oBoardView = getView('board');
112 112
 		$output = new stdClass;
113
-		if($content){
114
-			$output = $content->gets('document_srl','category_srl','member_srl','nick_name','title','content','tags','readed_count','voted_count','blamed_count','comment_count','regdate','last_update','extra_vars','status');
113
+		if ($content) {
114
+			$output = $content->gets('document_srl', 'category_srl', 'member_srl', 'nick_name', 'title', 'content', 'tags', 'readed_count', 'voted_count', 'blamed_count', 'comment_count', 'regdate', 'last_update', 'extra_vars', 'status');
115 115
 
116
-			if(!$oBoardView->grant->view)
116
+			if (!$oBoardView->grant->view)
117 117
 			{
118 118
 				unset($output->content);
119 119
 				unset($output->tags);
120 120
 				unset($output->extra_vars);
121 121
 			}
122
-			if(!$content->isAccessible())
122
+			if (!$content->isAccessible())
123 123
 			{
124 124
 				$output->content = Context::getLang('msg_is_secret');
125 125
 			}
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 
138 138
 	function arrangeComment($comment_list) {
139 139
 		$output = array();
140
-		if(count($comment_list) > 0 ) {
141
-			foreach($comment_list as $key => $val){
140
+		if (count($comment_list) > 0) {
141
+			foreach ($comment_list as $key => $val) {
142 142
 				$item = null;
143
-				$item = $val->gets('comment_srl','parent_srl','depth','nick_name','content','is_secret','voted_count','blamed_count','regdate','last_update');
144
-				if(!$val->isAccessible())
143
+				$item = $val->gets('comment_srl', 'parent_srl', 'depth', 'nick_name', 'content', 'is_secret', 'voted_count', 'blamed_count', 'regdate', 'last_update');
144
+				if (!$val->isAccessible())
145 145
 				{
146 146
 					$item->content = Context::getLang('msg_is_secret');
147 147
 				}
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 
155 155
 	function arrangeFile($file_list) {
156 156
 		$output = array();
157
-		if(count($file_list) > 0) {
158
-			foreach($file_list as $key => $val){
157
+		if (count($file_list) > 0) {
158
+			foreach ($file_list as $key => $val) {
159 159
 				$item = new stdClass;
160 160
 				$item->download_count = $val->download_count;
161 161
 				$item->source_filename = $val->source_filename;
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 
170 170
 	function arrangeExtraVars($list) {
171 171
 		$output = array();
172
-		if(count($list)) {
173
-			foreach($list as $key => $val){
172
+		if (count($list)) {
173
+			foreach ($list as $key => $val) {
174 174
 				$item = new stdClass;
175 175
 				$item->name = $val->name;
176 176
 				$item->type = $val->type;
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -76,8 +76,7 @@  discard block
 block discarded – undo
76 76
 		if($oDocument->isAccessible())
77 77
 		{
78 78
 			$oModule->add('file_list', $this->arrangeFile(Context::get('file_list')));
79
-		}
80
-		else
79
+		} else
81 80
 		{
82 81
 			$oModule->add('file_list', array());
83 82
 		}
@@ -101,7 +100,9 @@  discard block
 block discarded – undo
101 100
 	function arrangeContentList($content_list) {
102 101
 		$output = array();
103 102
 		if(count($content_list)) {
104
-			foreach($content_list as $key => $val) $output[] = $this->arrangeContent($val);
103
+			foreach($content_list as $key => $val) {
104
+				$output[] = $this->arrangeContent($val);
105
+			}
105 106
 		}
106 107
 		return $output;
107 108
 	}
Please login to merge, or discard this patch.
modules/board/board.view.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -747,6 +747,9 @@
 block discarded – undo
747 747
 		$this->setTemplateFile('write_form');
748 748
 	}
749 749
 
750
+	/**
751
+	 * @param ModuleObject $oDocumentModel
752
+	 */
750 753
 	function _getStatusNameList(&$oDocumentModel)
751 754
 	{
752 755
 		$resultList = array();
Please login to merge, or discard this patch.
Braces   +62 added lines, -38 removed lines patch added patch discarded remove patch
@@ -53,18 +53,15 @@  discard block
 block discarded – undo
53 53
 			if($this->module_info->hide_category)
54 54
 			{
55 55
 				$this->module_info->use_category = ($this->module_info->hide_category == 'Y') ? 'N' : 'Y';
56
-			}
57
-			else if($this->module_info->use_category)
56
+			} else if($this->module_info->use_category)
58 57
 			{
59 58
 				$this->module_info->hide_category = ($this->module_info->use_category == 'Y') ? 'N' : 'Y';
60
-			}
61
-			else
59
+			} else
62 60
 			{
63 61
 				$this->module_info->hide_category = 'N';
64 62
 				$this->module_info->use_category = 'Y';
65 63
 			}
66
-		}
67
-		else
64
+		} else
68 65
 		{
69 66
 			$this->module_info->hide_category = 'Y';
70 67
 			$this->module_info->use_category = 'N';
@@ -84,8 +81,7 @@  discard block
 block discarded – undo
84 81
 				$this->grant->write_comment = FALSE;
85 82
 				$this->grant->view = FALSE;
86 83
 			}
87
-		}
88
-		else
84
+		} else
89 85
 		{
90 86
 			$this->consultation = FALSE;
91 87
 		}
@@ -160,13 +156,17 @@  discard block
 block discarded – undo
160 156
 		 * add extra vaiables to the search options
161 157
 		 **/
162 158
 		// use search options on the template (the search options key has been declared, based on the language selected)
163
-		foreach($this->search_option as $opt) $search_option[$opt] = Context::getLang($opt);
159
+		foreach($this->search_option as $opt) {
160
+			$search_option[$opt] = Context::getLang($opt);
161
+		}
164 162
 		$extra_keys = Context::get('extra_keys');
165 163
 		if($extra_keys)
166 164
 		{
167 165
 			foreach($extra_keys as $key => $val)
168 166
 			{
169
-				if($val->search == 'Y') $search_option['extra_vars'.$val->idx] = $val->name;
167
+				if($val->search == 'Y') {
168
+					$search_option['extra_vars'.$val->idx] = $val->name;
169
+				}
170 170
 			}
171 171
 		}
172 172
 		// remove a search option that is not public in member config
@@ -175,8 +175,9 @@  discard block
 block discarded – undo
175 175
 		{
176 176
 			if(in_array($signupFormElement->title, $search_option))
177 177
 			{
178
-				if($signupFormElement->isPublic == 'N')
179
-					unset($search_option[$signupFormElement->name]);
178
+				if($signupFormElement->isPublic == 'N') {
179
+									unset($search_option[$signupFormElement->name]);
180
+				}
180 181
 			}
181 182
 		}
182 183
 		Context::set('search_option', $search_option);
@@ -194,7 +195,9 @@  discard block
 block discarded – undo
194 195
 		// list config, columnList setting
195 196
 		$oBoardModel = getModel('board');
196 197
 		$this->listConfig = $oBoardModel->getListConfig($this->module_info->module_srl);
197
-		if(!$this->listConfig) $this->listConfig = array();
198
+		if(!$this->listConfig) {
199
+			$this->listConfig = array();
200
+		}
198 201
 		$this->_makeListColumnList();
199 202
 
200 203
 		// display the notice list
@@ -265,7 +268,9 @@  discard block
 block discarded – undo
265 268
 				}
266 269
 
267 270
 				// check the manage grant
268
-				if($this->grant->manager) $oDocument->setGrant();
271
+				if($this->grant->manager) {
272
+					$oDocument->setGrant();
273
+				}
269 274
 
270 275
 				// if the consultation function is enabled, and the document is not a notice
271 276
 				if($this->consultation && !$oDocument->isNotice())
@@ -286,8 +291,7 @@  discard block
 block discarded – undo
286 291
 					}
287 292
 				}
288 293
 
289
-			}
290
-			else
294
+			} else
291 295
 			{
292 296
 				// if the document is not existed, then alert a warning message
293 297
 				Context::set('document_srl','',true);
@@ -297,8 +301,7 @@  discard block
 block discarded – undo
297 301
 		/**
298 302
 		 * if the document is not existed, get an empty document
299 303
 		 **/
300
-		}
301
-		else
304
+		} else
302 305
 		{
303 306
 			$oDocument = $oDocumentModel->getDocument(0);
304 307
 		}
@@ -313,8 +316,7 @@  discard block
 block discarded – undo
313 316
 				$oDocument = $oDocumentModel->getDocument(0);
314 317
 				Context::set('document_srl','',true);
315 318
 				$this->alertMessage('msg_not_permitted');
316
-			}
317
-			else
319
+			} else
318 320
 			{
319 321
 				// add the document title to the browser
320 322
 				Context::addBrowserTitle($oDocument->getTitleText());
@@ -368,13 +370,16 @@  discard block
 block discarded – undo
368 370
 		$downloadGrantCount = 0;
369 371
 		if(is_array($file_module_config->download_grant))
370 372
 		{
371
-			foreach($file_module_config->download_grant AS $value)
372
-				if($value) $downloadGrantCount++;
373
+			foreach($file_module_config->download_grant AS $value) {
374
+							if($value) $downloadGrantCount++;
375
+			}
373 376
 		}
374 377
 
375 378
 		if(is_array($file_module_config->download_grant) && $downloadGrantCount>0)
376 379
 		{
377
-			if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
380
+			if(!Context::get('is_logged')) {
381
+				return $this->stop('msg_not_permitted_download');
382
+			}
378 383
 			$logged_info = Context::get('logged_info');
379 384
 			if($logged_info->is_admin != 'Y')
380 385
 			{
@@ -397,7 +402,9 @@  discard block
 block discarded – undo
397 402
 							break;
398 403
 						}
399 404
 					}
400
-					if(!$is_permitted) return $this->stop('msg_not_permitted_download');
405
+					if(!$is_permitted) {
406
+						return $this->stop('msg_not_permitted_download');
407
+					}
401 408
 				}
402 409
 			}
403 410
 		}
@@ -560,7 +567,9 @@  discard block
 block discarded – undo
560 567
 				'allow_trackback', 'notify_message', 'status', 'comment_status');
561 568
 		$this->columnList = array_intersect($configColumList, $tableColumnList);
562 569
 
563
-		if(in_array('summary', $configColumList)) array_push($this->columnList, 'content');
570
+		if(in_array('summary', $configColumList)) {
571
+			array_push($this->columnList, 'content');
572
+		}
564 573
 
565 574
 		// default column list add
566 575
 		$defaultColumn = array('document_srl', 'module_srl', 'category_srl', 'lang_code', 'member_srl', 'last_update', 'comment_count', 'trackback_count', 'uploaded_count', 'status', 'regdate', 'title_bold', 'title_color');
@@ -654,8 +663,7 @@  discard block
 block discarded – undo
654 663
 			{
655 664
 				$logged_info = Context::get('logged_info');
656 665
 				$group_srls = array_keys($logged_info->group_list);
657
-			}
658
-			else
666
+			} else
659 667
 			{
660 668
 				$group_srls = array();
661 669
 			}
@@ -672,10 +680,14 @@  discard block
 block discarded – undo
672 680
 					{
673 681
 						$category_group_srls = explode(',',$category->group_srls);
674 682
 						$is_granted = FALSE;
675
-						if(count(array_intersect($group_srls, $category_group_srls))) $is_granted = TRUE;
683
+						if(count(array_intersect($group_srls, $category_group_srls))) {
684
+							$is_granted = TRUE;
685
+						}
676 686
 
677 687
 					}
678
-					if($is_granted) $category_list[$category_srl] = $category;
688
+					if($is_granted) {
689
+						$category_list[$category_srl] = $category;
690
+					}
679 691
 				}
680 692
 			}
681 693
 			Context::set('category_list', $category_list);
@@ -686,7 +698,9 @@  discard block
 block discarded – undo
686 698
 		$oDocument = $oDocumentModel->getDocument(0, $this->grant->manager);
687 699
 		$oDocument->setDocument($document_srl);
688 700
 
689
-		if($oDocument->get('module_srl') == $oDocument->get('member_srl')) $savedDoc = TRUE;
701
+		if($oDocument->get('module_srl') == $oDocument->get('member_srl')) {
702
+			$savedDoc = TRUE;
703
+		}
690 704
 		$oDocument->add('module_srl', $this->module_srl);
691 705
 
692 706
 		if($oDocument->isExists() && $this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false)
@@ -712,17 +726,20 @@  discard block
 block discarded – undo
712 726
 				if( !$logged_info )
713 727
 				{
714 728
 					return $this->dispBoardMessage('msg_not_permitted');
715
-				}
716
-				else if (($oPointModel->getPoint($logged_info->member_srl) + $pointForInsert )< 0 )
729
+				} else if (($oPointModel->getPoint($logged_info->member_srl) + $pointForInsert )< 0 )
717 730
 				{
718 731
 					return $this->dispBoardMessage('msg_not_enough_point');
719 732
 				}
720 733
 			}
721 734
 		}
722
-		if(!$oDocument->get('status')) $oDocument->add('status', $oDocumentModel->getDefaultStatus());
735
+		if(!$oDocument->get('status')) {
736
+			$oDocument->add('status', $oDocumentModel->getDefaultStatus());
737
+		}
723 738
 
724 739
 		$statusList = $this->_getStatusNameList($oDocumentModel);
725
-		if(count($statusList) > 0) Context::set('status_list', $statusList);
740
+		if(count($statusList) > 0) {
741
+			Context::set('status_list', $statusList);
742
+		}
726 743
 
727 744
 		// get Document status config value
728 745
 		Context::set('document_srl',$document_srl);
@@ -733,13 +750,18 @@  discard block
 block discarded – undo
733 750
 		$oDocumentController->addXmlJsFilter($this->module_info->module_srl);
734 751
 
735 752
 		// if the document exists, then setup extra variabels on context
736
-		if($oDocument->isExists() && !$savedDoc) Context::set('extra_keys', $oDocument->getExtraVars());
753
+		if($oDocument->isExists() && !$savedDoc) {
754
+			Context::set('extra_keys', $oDocument->getExtraVars());
755
+		}
737 756
 
738 757
 		/**
739 758
 		 * add JS filters
740 759
 		 **/
741
-		if(Context::get('logged_info')->is_admin=='Y') Context::addJsFilter($this->module_path.'tpl/filter', 'insert_admin.xml');
742
-		else Context::addJsFilter($this->module_path.'tpl/filter', 'insert.xml');
760
+		if(Context::get('logged_info')->is_admin=='Y') {
761
+			Context::addJsFilter($this->module_path.'tpl/filter', 'insert_admin.xml');
762
+		} else {
763
+			Context::addJsFilter($this->module_path.'tpl/filter', 'insert.xml');
764
+		}
743 765
 
744 766
 		$oSecurity = new Security();
745 767
 		$oSecurity->encodeHTML('category_list.text', 'category_list.title');
@@ -1054,7 +1076,9 @@  discard block
 block discarded – undo
1054 1076
 	function dispBoardMessage($msg_code)
1055 1077
 	{
1056 1078
 		$msg = Context::getLang($msg_code);
1057
-		if(!$msg) $msg = $msg_code;
1079
+		if(!$msg) {
1080
+			$msg = $msg_code;
1081
+		}
1058 1082
 		Context::set('message', $msg);
1059 1083
 		$this->setTemplateFile('message');
1060 1084
 	}
Please login to merge, or discard this patch.
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
 		/**
24 24
 		 * setup the module general information
25 25
 		 **/
26
-		if($this->module_info->list_count)
26
+		if ($this->module_info->list_count)
27 27
 		{
28 28
 			$this->list_count = $this->module_info->list_count;
29 29
 		}
30
-		if($this->module_info->search_list_count)
30
+		if ($this->module_info->search_list_count)
31 31
 		{
32 32
 			$this->search_list_count = $this->module_info->search_list_count;
33 33
 		}
34
-		if($this->module_info->page_count)
34
+		if ($this->module_info->page_count)
35 35
 		{
36 36
 			$this->page_count = $this->module_info->page_count;
37 37
 		}
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
 		$oDocumentModel = getModel('document');
42 42
 
43 43
 		$statusList = $this->_getStatusNameList($oDocumentModel);
44
-		if(isset($statusList['SECRET']))
44
+		if (isset($statusList['SECRET']))
45 45
 		{
46 46
 			$this->module_info->secret = 'Y';
47 47
 		}
48 48
 
49 49
 		// use_category <=1.5.x, hide_category >=1.7.x
50 50
 		$count_category = count($oDocumentModel->getCategoryList($this->module_info->module_srl));
51
-		if($count_category)
51
+		if ($count_category)
52 52
 		{
53
-			if($this->module_info->hide_category)
53
+			if ($this->module_info->hide_category)
54 54
 			{
55 55
 				$this->module_info->use_category = ($this->module_info->hide_category == 'Y') ? 'N' : 'Y';
56 56
 			}
57
-			else if($this->module_info->use_category)
57
+			else if ($this->module_info->use_category)
58 58
 			{
59 59
 				$this->module_info->hide_category = ($this->module_info->use_category == 'Y') ? 'N' : 'Y';
60 60
 			}
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 		 * check the consultation function, if the user is admin then swich off consultation function
75 75
 		 * if the user is not logged, then disppear write document/write comment./ view document
76 76
 		 **/
77
-		if($this->module_info->consultation == 'Y' && !$this->grant->manager && !$this->grant->consultation_read)
77
+		if ($this->module_info->consultation == 'Y' && !$this->grant->manager && !$this->grant->consultation_read)
78 78
 		{
79 79
 			$this->consultation = TRUE;
80
-			if(!Context::get('is_logged'))
80
+			if (!Context::get('is_logged'))
81 81
 			{
82 82
 				$this->grant->list = FALSE;
83 83
 				$this->grant->write_document = FALSE;
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 		 * setup the template path based on the skin
95 95
 		 * the default skin is default
96 96
 		 **/
97
-		$template_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin);
98
-		if(!is_dir($template_path)||!$this->module_info->skin)
97
+		$template_path = sprintf("%sskins/%s/", $this->module_path, $this->module_info->skin);
98
+		if (!is_dir($template_path) || !$this->module_info->skin)
99 99
 		{
100 100
 			$this->module_info->skin = 'default';
101
-			$template_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin);
101
+			$template_path = sprintf("%sskins/%s/", $this->module_path, $this->module_info->skin);
102 102
 		}
103 103
 		$this->setTemplatePath($template_path);
104 104
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		 **/
115 115
 		if (is_array($extra_keys))
116 116
 		{
117
-			foreach($extra_keys as $val)
117
+			foreach ($extra_keys as $val)
118 118
 			{
119 119
 				$this->order_target[] = $val->eid;
120 120
 			}
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
 
128 128
 		// remove [document_srl]_cpage from get_vars
129 129
 		$args = Context::getRequestVars();
130
-		foreach($args as $name => $value)
130
+		foreach ($args as $name => $value)
131 131
 		{
132
-			if(preg_match('/[0-9]+_cpage/', $name))
132
+			if (preg_match('/[0-9]+_cpage/', $name))
133 133
 			{
134 134
 				Context::set($name, '', TRUE);
135 135
 				Context::set($name, $value);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		/**
146 146
 		 * check the access grant (all the grant has been set by the module object)
147 147
 		 **/
148
-		if(!$this->grant->access || !$this->grant->list)
148
+		if (!$this->grant->access || !$this->grant->list)
149 149
 		{
150 150
 			return $this->dispBoardMessage('msg_not_permitted');
151 151
 		}
@@ -160,22 +160,22 @@  discard block
 block discarded – undo
160 160
 		 * add extra vaiables to the search options
161 161
 		 **/
162 162
 		// use search options on the template (the search options key has been declared, based on the language selected)
163
-		foreach($this->search_option as $opt) $search_option[$opt] = Context::getLang($opt);
163
+		foreach ($this->search_option as $opt) $search_option[$opt] = Context::getLang($opt);
164 164
 		$extra_keys = Context::get('extra_keys');
165
-		if($extra_keys)
165
+		if ($extra_keys)
166 166
 		{
167
-			foreach($extra_keys as $key => $val)
167
+			foreach ($extra_keys as $key => $val)
168 168
 			{
169
-				if($val->search == 'Y') $search_option['extra_vars'.$val->idx] = $val->name;
169
+				if ($val->search == 'Y') $search_option['extra_vars'.$val->idx] = $val->name;
170 170
 			}
171 171
 		}
172 172
 		// remove a search option that is not public in member config
173 173
 		$memberConfig = getModel('module')->getModuleConfig('member');
174
-		foreach($memberConfig->signupForm as $signupFormElement)
174
+		foreach ($memberConfig->signupForm as $signupFormElement)
175 175
 		{
176
-			if(in_array($signupFormElement->title, $search_option))
176
+			if (in_array($signupFormElement->title, $search_option))
177 177
 			{
178
-				if($signupFormElement->isPublic == 'N')
178
+				if ($signupFormElement->isPublic == 'N')
179 179
 					unset($search_option[$signupFormElement->name]);
180 180
 			}
181 181
 		}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$oDocumentModel = getModel('document');
185 185
 		$statusNameList = $this->_getStatusNameList($oDocumentModel);
186
-		if(count($statusNameList) > 0)
186
+		if (count($statusNameList) > 0)
187 187
 		{
188 188
 			Context::set('status_list', $statusNameList);
189 189
 		}
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		// list config, columnList setting
195 195
 		$oBoardModel = getModel('board');
196 196
 		$this->listConfig = $oBoardModel->getListConfig($this->module_info->module_srl);
197
-		if(!$this->listConfig) $this->listConfig = array();
197
+		if (!$this->listConfig) $this->listConfig = array();
198 198
 		$this->_makeListColumnList();
199 199
 
200 200
 		// display the notice list
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 	/**
219 219
 	 * @brief display the category list
220 220
 	 **/
221
-	function dispBoardCategoryList(){
221
+	function dispBoardCategoryList() {
222 222
 		// check if the use_category option is enabled
223
-		if($this->module_info->use_category=='Y')
223
+		if ($this->module_info->use_category == 'Y')
224 224
 		{
225 225
 			// check the grant
226
-			if(!$this->grant->list)
226
+			if (!$this->grant->list)
227 227
 			{
228 228
 				Context::set('category_list', array());
229 229
 				return;
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	/**
241 241
 	 * @brief display the board conent view
242 242
 	 **/
243
-	function dispBoardContentView(){
243
+	function dispBoardContentView() {
244 244
 		// get the variable value
245 245
 		$document_srl = Context::get('document_srl');
246 246
 		$page = Context::get('page');
@@ -251,36 +251,36 @@  discard block
 block discarded – undo
251 251
 		/**
252 252
 		 * if the document exists, then get the document information
253 253
 		 **/
254
-		if($document_srl)
254
+		if ($document_srl)
255 255
 		{
256 256
 			$oDocument = $oDocumentModel->getDocument($document_srl, false, true);
257 257
 
258 258
 			// if the document is existed
259
-			if($oDocument->isExists())
259
+			if ($oDocument->isExists())
260 260
 			{
261 261
 				// if the module srl is not consistent
262
-				if($oDocument->get('module_srl')!=$this->module_info->module_srl )
262
+				if ($oDocument->get('module_srl') != $this->module_info->module_srl)
263 263
 				{
264 264
 					return $this->stop('msg_invalid_request');
265 265
 				}
266 266
 
267 267
 				// check the manage grant
268
-				if($this->grant->manager) $oDocument->setGrant();
268
+				if ($this->grant->manager) $oDocument->setGrant();
269 269
 
270 270
 				// if the consultation function is enabled, and the document is not a notice
271
-				if($this->consultation && !$oDocument->isNotice())
271
+				if ($this->consultation && !$oDocument->isNotice())
272 272
 				{
273 273
 					$logged_info = Context::get('logged_info');
274
-					if(abs($oDocument->get('member_srl')) != $logged_info->member_srl)
274
+					if (abs($oDocument->get('member_srl')) != $logged_info->member_srl)
275 275
 					{
276 276
 						$oDocument = $oDocumentModel->getDocument(0);
277 277
 					}
278 278
 				}
279 279
 
280 280
 				// if the document is TEMP saved, check Grant
281
-				if($oDocument->getStatus() == 'TEMP')
281
+				if ($oDocument->getStatus() == 'TEMP')
282 282
 				{
283
-					if(!$oDocument->isGranted())
283
+					if (!$oDocument->isGranted())
284 284
 					{
285 285
 						$oDocument = $oDocumentModel->getDocument(0);
286 286
 					}
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			else
291 291
 			{
292 292
 				// if the document is not existed, then alert a warning message
293
-				Context::set('document_srl','',true);
293
+				Context::set('document_srl', '', true);
294 294
 				$this->alertMessage('msg_not_founded');
295 295
 			}
296 296
 
@@ -306,12 +306,12 @@  discard block
 block discarded – undo
306 306
 		/**
307 307
 		 *check the document view grant
308 308
 		 **/
309
-		if($oDocument->isExists())
309
+		if ($oDocument->isExists())
310 310
 		{
311
-			if(!$this->grant->view && !$oDocument->isGranted())
311
+			if (!$this->grant->view && !$oDocument->isGranted())
312 312
 			{
313 313
 				$oDocument = $oDocumentModel->getDocument(0);
314
-				Context::set('document_srl','',true);
314
+				Context::set('document_srl', '', true);
315 315
 				$this->alertMessage('msg_not_permitted');
316 316
 			}
317 317
 			else
@@ -320,15 +320,15 @@  discard block
 block discarded – undo
320 320
 				Context::addBrowserTitle($oDocument->getTitleText());
321 321
 
322 322
 				// update the document view count (if the document is not secret)
323
-				if(!$oDocument->isSecret() || $oDocument->isGranted())
323
+				if (!$oDocument->isSecret() || $oDocument->isGranted())
324 324
 				{
325 325
 					$oDocument->updateReadedCount();
326 326
 				}
327 327
 
328 328
 				// disappear the document if it is secret
329
-				if($oDocument->isSecret() && !$oDocument->isGranted())
329
+				if ($oDocument->isSecret() && !$oDocument->isGranted())
330 330
 				{
331
-					$oDocument->add('content',Context::getLang('thisissecret'));
331
+					$oDocument->add('content', Context::getLang('thisissecret'));
332 332
 				}
333 333
 			}
334 334
 		}
@@ -348,11 +348,11 @@  discard block
 block discarded – undo
348 348
 	/**
349 349
 	 * @brief  display the document file list (can be used by API)
350 350
 	 **/
351
-	function dispBoardContentFileList(){
351
+	function dispBoardContentFileList() {
352 352
 		/**
353 353
 		 * check the access grant (all the grant has been set by the module object)
354 354
 		 **/
355
-		if(!$this->grant->access)
355
+		if (!$this->grant->access)
356 356
 		{
357 357
 			return $this->dispBoardMessage('msg_not_permitted');
358 358
 		}
@@ -363,41 +363,41 @@  discard block
 block discarded – undo
363 363
 		// Check if a permission for file download is granted
364 364
 		// Get configurations (using module model object)
365 365
 		$oModuleModel = getModel('module');
366
-		$file_module_config = $oModuleModel->getModulePartConfig('file',$this->module_srl);
366
+		$file_module_config = $oModuleModel->getModulePartConfig('file', $this->module_srl);
367 367
 		
368 368
 		$downloadGrantCount = 0;
369
-		if(is_array($file_module_config->download_grant))
369
+		if (is_array($file_module_config->download_grant))
370 370
 		{
371
-			foreach($file_module_config->download_grant AS $value)
372
-				if($value) $downloadGrantCount++;
371
+			foreach ($file_module_config->download_grant AS $value)
372
+				if ($value) $downloadGrantCount++;
373 373
 		}
374 374
 
375
-		if(is_array($file_module_config->download_grant) && $downloadGrantCount>0)
375
+		if (is_array($file_module_config->download_grant) && $downloadGrantCount > 0)
376 376
 		{
377
-			if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
377
+			if (!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
378 378
 			$logged_info = Context::get('logged_info');
379
-			if($logged_info->is_admin != 'Y')
379
+			if ($logged_info->is_admin != 'Y')
380 380
 			{
381
-				$oModuleModel =& getModel('module');
381
+				$oModuleModel = & getModel('module');
382 382
 				$columnList = array('module_srl', 'site_srl');
383 383
 				$module_info = $oModuleModel->getModuleInfoByModuleSrl($this->module_srl, $columnList);
384 384
 
385
-				if(!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl))
385
+				if (!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl))
386 386
 				{
387
-					$oMemberModel =& getModel('member');
387
+					$oMemberModel = & getModel('member');
388 388
 					$member_groups = $oMemberModel->getMemberGroups($logged_info->member_srl, $module_info->site_srl);
389 389
 
390 390
 					$is_permitted = false;
391
-					for($i=0;$i<count($file_module_config->download_grant);$i++)
391
+					for ($i = 0; $i < count($file_module_config->download_grant); $i++)
392 392
 					{
393 393
 						$group_srl = $file_module_config->download_grant[$i];
394
-						if($member_groups[$group_srl])
394
+						if ($member_groups[$group_srl])
395 395
 						{
396 396
 							$is_permitted = true;
397 397
 							break;
398 398
 						}
399 399
 					}
400
-					if(!$is_permitted) return $this->stop('msg_not_permitted_download');
400
+					if (!$is_permitted) return $this->stop('msg_not_permitted_download');
401 401
 				}
402 402
 			}
403 403
 		}
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		$document_srl = Context::get('document_srl');
407 407
 		$oDocument = $oDocumentModel->getDocument($document_srl);
408 408
 		Context::set('oDocument', $oDocument);
409
-		Context::set('file_list',$oDocument->getUploadedFiles());
409
+		Context::set('file_list', $oDocument->getUploadedFiles());
410 410
 
411 411
 		$oSecurity = new Security();
412 412
 		$oSecurity->encodeHTML('file_list..source_filename');
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 	/**
416 416
 	 * @brief display the document comment list (can be used by API)
417 417
 	 **/
418
-	function dispBoardContentCommentList(){
418
+	function dispBoardContentCommentList() {
419 419
 		// check document view grant
420 420
 		$this->dispBoardContentView();
421 421
 
@@ -425,26 +425,26 @@  discard block
 block discarded – undo
425 425
 		$comment_list = $oDocument->getComments();
426 426
 
427 427
 		// setup the comment list
428
-		if(is_array($comment_list))
428
+		if (is_array($comment_list))
429 429
 		{
430
-			foreach($comment_list as $key => $val)
430
+			foreach ($comment_list as $key => $val)
431 431
 			{
432
-				if(!$val->isAccessible())
432
+				if (!$val->isAccessible())
433 433
 				{
434
-					$val->add('content',Context::getLang('thisissecret'));
434
+					$val->add('content', Context::getLang('thisissecret'));
435 435
 				}
436 436
 			}
437 437
 		}
438
-		Context::set('comment_list',$comment_list);
438
+		Context::set('comment_list', $comment_list);
439 439
 
440 440
 	}
441 441
 
442 442
 	/**
443 443
 	 * @brief display notice list (can be used by API)
444 444
 	 **/
445
-	function dispBoardNoticeList(){
445
+	function dispBoardNoticeList() {
446 446
 		// check the grant
447
-		if(!$this->grant->list)
447
+		if (!$this->grant->list)
448 448
 		{
449 449
 			Context::set('notice_list', array());
450 450
 			return;
@@ -460,15 +460,15 @@  discard block
 block discarded – undo
460 460
 	/**
461 461
 	 * @brief display board content list
462 462
 	 **/
463
-	function dispBoardContentList(){
463
+	function dispBoardContentList() {
464 464
 		// check the grant
465
-		if(!$this->grant->list)
465
+		if (!$this->grant->list)
466 466
 		{
467 467
 			Context::set('document_list', array());
468 468
 			Context::set('total_count', 0);
469 469
 			Context::set('total_page', 1);
470 470
 			Context::set('page', 1);
471
-			Context::set('page_navigation', new PageHandler(0,0,1,10));
471
+			Context::set('page_navigation', new PageHandler(0, 0, 1, 10));
472 472
 			return;
473 473
 		}
474 474
 
@@ -486,17 +486,17 @@  discard block
 block discarded – undo
486 486
 		$args->search_keyword = Context::get('search_keyword');
487 487
 
488 488
 		$search_option = Context::get('search_option');
489
-		if($search_option==FALSE)
489
+		if ($search_option == FALSE)
490 490
 		{
491 491
 			$search_option = $this->search_option;
492 492
 		}
493
-		if(isset($search_option[$args->search_target])==FALSE)
493
+		if (isset($search_option[$args->search_target]) == FALSE)
494 494
 		{
495 495
 			$args->search_target = '';
496 496
 		}
497 497
 
498 498
 		// if the category is enabled, then get the category
499
-		if($this->module_info->use_category=='Y')
499
+		if ($this->module_info->use_category == 'Y')
500 500
 		{
501 501
 			$args->category_srl = Context::get('category');
502 502
 		}
@@ -504,21 +504,21 @@  discard block
 block discarded – undo
504 504
 		// setup the sort index and order index
505 505
 		$args->sort_index = Context::get('sort_index');
506 506
 		$args->order_type = Context::get('order_type');
507
-		if(!in_array($args->sort_index, $this->order_target))
507
+		if (!in_array($args->sort_index, $this->order_target))
508 508
 		{
509
-			$args->sort_index = $this->module_info->order_target?$this->module_info->order_target:'list_order';
509
+			$args->sort_index = $this->module_info->order_target ? $this->module_info->order_target : 'list_order';
510 510
 		}
511
-		if(!in_array($args->order_type, array('asc','desc')))
511
+		if (!in_array($args->order_type, array('asc', 'desc')))
512 512
 		{
513
-			$args->order_type = $this->module_info->order_type?$this->module_info->order_type:'asc';
513
+			$args->order_type = $this->module_info->order_type ? $this->module_info->order_type : 'asc';
514 514
 		}
515 515
 
516 516
 		// set the current page of documents
517 517
 		$document_srl = Context::get('document_srl');
518
-		if(!$args->page && $document_srl)
518
+		if (!$args->page && $document_srl)
519 519
 		{
520 520
 			$oDocument = $oDocumentModel->getDocument($document_srl);
521
-			if($oDocument->isExists() && !$oDocument->isNotice())
521
+			if ($oDocument->isExists() && !$oDocument->isNotice())
522 522
 			{
523 523
 				$page = $oDocumentModel->getDocumentPage($oDocument, $args);
524 524
 				Context::set('page', $page);
@@ -527,21 +527,21 @@  discard block
 block discarded – undo
527 527
 		}
528 528
 
529 529
 		// setup the list count to be serach list count, if the category or search keyword has been set
530
-		if($args->category_srl || $args->search_keyword)
530
+		if ($args->category_srl || $args->search_keyword)
531 531
 		{
532 532
 			$args->list_count = $this->search_list_count;
533 533
 		}
534 534
 
535 535
 		// if the consultation function is enabled,  the get the logged user information
536
-		if($this->consultation)
536
+		if ($this->consultation)
537 537
 		{
538 538
 			$logged_info = Context::get('logged_info');
539 539
 			$args->member_srl = $logged_info->member_srl;
540 540
 
541
-			if($this->module_info->use_anonymous === 'Y')
541
+			if ($this->module_info->use_anonymous === 'Y')
542 542
 			{
543 543
 				unset($args->member_srl);
544
-				$args->member_srls = $logged_info->member_srl . ',' . $logged_info->member_srl * -1;
544
+				$args->member_srls = $logged_info->member_srl.','.$logged_info->member_srl * -1;
545 545
 			}
546 546
 		}
547 547
 
@@ -567,18 +567,18 @@  discard block
 block discarded – undo
567 567
 				'allow_trackback', 'notify_message', 'status', 'comment_status');
568 568
 		$this->columnList = array_intersect($configColumList, $tableColumnList);
569 569
 
570
-		if(in_array('summary', $configColumList)) array_push($this->columnList, 'content');
570
+		if (in_array('summary', $configColumList)) array_push($this->columnList, 'content');
571 571
 
572 572
 		// default column list add
573 573
 		$defaultColumn = array('document_srl', 'module_srl', 'category_srl', 'lang_code', 'member_srl', 'last_update', 'comment_count', 'trackback_count', 'uploaded_count', 'status', 'regdate', 'title_bold', 'title_color');
574 574
 
575 575
 		//TODO guestbook, blog style supports legacy codes.
576
-		if($this->module_info->skin == 'xe_guestbook' || $this->module_info->default_style == 'blog')
576
+		if ($this->module_info->skin == 'xe_guestbook' || $this->module_info->default_style == 'blog')
577 577
 		{
578 578
 			$defaultColumn = $tableColumnList;
579 579
 		}
580 580
 
581
-		if (in_array('last_post', $configColumList)){
581
+		if (in_array('last_post', $configColumList)) {
582 582
 			array_push($this->columnList, 'last_updater');
583 583
 		}
584 584
 
@@ -590,9 +590,9 @@  discard block
 block discarded – undo
590 590
 		$this->columnList = array_unique(array_merge($this->columnList, $defaultColumn));
591 591
 
592 592
 		// add table name
593
-		foreach($this->columnList as $no => $value)
593
+		foreach ($this->columnList as $no => $value)
594 594
 		{
595
-			$this->columnList[$no] = 'documents.' . $value;
595
+			$this->columnList[$no] = 'documents.'.$value;
596 596
 		}
597 597
 	}
598 598
 
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	function dispBoardTagList()
603 603
 	{
604 604
 		// check if there is not grant fot view list, then alert an warning message
605
-		if(!$this->grant->list)
605
+		if (!$this->grant->list)
606 606
 		{
607 607
 			return $this->dispBoardMessage('msg_not_permitted');
608 608
 		}
@@ -616,14 +616,14 @@  discard block
 block discarded – undo
616 616
 		$output = $oTagModel->getTagList($obj);
617 617
 
618 618
 		// automatically order
619
-		if(count($output->data))
619
+		if (count($output->data))
620 620
 		{
621 621
 			$numbers = array_keys($output->data);
622 622
 			shuffle($numbers);
623 623
 
624
-			if(count($output->data))
624
+			if (count($output->data))
625 625
 			{
626
-				foreach($numbers as $k => $v)
626
+				foreach ($numbers as $k => $v)
627 627
 				{
628 628
 					$tag_list[] = $output->data[$v];
629 629
 				}
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 	function dispBoardWrite()
645 645
 	{
646 646
 		// check grant
647
-		if(!$this->grant->write_document)
647
+		if (!$this->grant->write_document)
648 648
 		{
649 649
 			return $this->dispBoardMessage('msg_not_permitted');
650 650
 		}
@@ -654,10 +654,10 @@  discard block
 block discarded – undo
654 654
 		/**
655 655
 		 * check if the category option is enabled not not
656 656
 		 **/
657
-		if($this->module_info->use_category=='Y')
657
+		if ($this->module_info->use_category == 'Y')
658 658
 		{
659 659
 			// get the user group information
660
-			if(Context::get('is_logged'))
660
+			if (Context::get('is_logged'))
661 661
 			{
662 662
 				$logged_info = Context::get('logged_info');
663 663
 				$group_srls = array_keys($logged_info->group_list);
@@ -670,19 +670,19 @@  discard block
 block discarded – undo
670 670
 
671 671
 			// check the grant after obtained the category list
672 672
 			$normal_category_list = $oDocumentModel->getCategoryList($this->module_srl);
673
-			if(count($normal_category_list))
673
+			if (count($normal_category_list))
674 674
 			{
675
-				foreach($normal_category_list as $category_srl => $category)
675
+				foreach ($normal_category_list as $category_srl => $category)
676 676
 				{
677 677
 					$is_granted = TRUE;
678
-					if($category->group_srls)
678
+					if ($category->group_srls)
679 679
 					{
680
-						$category_group_srls = explode(',',$category->group_srls);
680
+						$category_group_srls = explode(',', $category->group_srls);
681 681
 						$is_granted = FALSE;
682
-						if(count(array_intersect($group_srls, $category_group_srls))) $is_granted = TRUE;
682
+						if (count(array_intersect($group_srls, $category_group_srls))) $is_granted = TRUE;
683 683
 
684 684
 					}
685
-					if($is_granted) $category_list[$category_srl] = $category;
685
+					if ($is_granted) $category_list[$category_srl] = $category;
686 686
 				}
687 687
 			}
688 688
 			Context::set('category_list', $category_list);
@@ -693,46 +693,46 @@  discard block
 block discarded – undo
693 693
 		$oDocument = $oDocumentModel->getDocument(0, $this->grant->manager);
694 694
 		$oDocument->setDocument($document_srl);
695 695
 
696
-		if($oDocument->get('module_srl') == $oDocument->get('member_srl')) $savedDoc = TRUE;
696
+		if ($oDocument->get('module_srl') == $oDocument->get('member_srl')) $savedDoc = TRUE;
697 697
 		$oDocument->add('module_srl', $this->module_srl);
698 698
 
699
-		if($oDocument->isExists() && $this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false)
699
+		if ($oDocument->isExists() && $this->module_info->protect_content == "Y" && $oDocument->get('comment_count') > 0 && $this->grant->manager == false)
700 700
 		{
701 701
 			return new BaseObject(-1, 'msg_protect_content');
702 702
 		}
703 703
 
704 704
 		// if the document is not granted, then back to the password input form
705 705
 		$oModuleModel = getModel('module');
706
-		if($oDocument->isExists()&&!$oDocument->isGranted())
706
+		if ($oDocument->isExists() && !$oDocument->isGranted())
707 707
 		{
708 708
 			return $this->setTemplateFile('input_password_form');
709 709
 		}
710 710
 
711
-		if(!$oDocument->isExists())
711
+		if (!$oDocument->isExists())
712 712
 		{
713
-			$point_config = $oModuleModel->getModulePartConfig('point',$this->module_srl);
713
+			$point_config = $oModuleModel->getModulePartConfig('point', $this->module_srl);
714 714
 			$logged_info = Context::get('logged_info');
715 715
 			$oPointModel = getModel('point');
716 716
 			$pointForInsert = $point_config["insert_document"];
717
-			if($pointForInsert < 0)
717
+			if ($pointForInsert < 0)
718 718
 			{
719
-				if( !$logged_info )
719
+				if (!$logged_info)
720 720
 				{
721 721
 					return $this->dispBoardMessage('msg_not_permitted');
722 722
 				}
723
-				else if (($oPointModel->getPoint($logged_info->member_srl) + $pointForInsert )< 0 )
723
+				else if (($oPointModel->getPoint($logged_info->member_srl) + $pointForInsert) < 0)
724 724
 				{
725 725
 					return $this->dispBoardMessage('msg_not_enough_point');
726 726
 				}
727 727
 			}
728 728
 		}
729
-		if(!$oDocument->get('status')) $oDocument->add('status', $oDocumentModel->getDefaultStatus());
729
+		if (!$oDocument->get('status')) $oDocument->add('status', $oDocumentModel->getDefaultStatus());
730 730
 
731 731
 		$statusList = $this->_getStatusNameList($oDocumentModel);
732
-		if(count($statusList) > 0) Context::set('status_list', $statusList);
732
+		if (count($statusList) > 0) Context::set('status_list', $statusList);
733 733
 
734 734
 		// get Document status config value
735
-		Context::set('document_srl',$document_srl);
735
+		Context::set('document_srl', $document_srl);
736 736
 		Context::set('oDocument', $oDocument);
737 737
 
738 738
 		// apply xml_js_filter on header
@@ -740,12 +740,12 @@  discard block
 block discarded – undo
740 740
 		$oDocumentController->addXmlJsFilter($this->module_info->module_srl);
741 741
 
742 742
 		// if the document exists, then setup extra variabels on context
743
-		if($oDocument->isExists() && !$savedDoc) Context::set('extra_keys', $oDocument->getExtraVars());
743
+		if ($oDocument->isExists() && !$savedDoc) Context::set('extra_keys', $oDocument->getExtraVars());
744 744
 
745 745
 		/**
746 746
 		 * add JS filters
747 747
 		 **/
748
-		if(Context::get('logged_info')->is_admin=='Y') Context::addJsFilter($this->module_path.'tpl/filter', 'insert_admin.xml');
748
+		if (Context::get('logged_info')->is_admin == 'Y') Context::addJsFilter($this->module_path.'tpl/filter', 'insert_admin.xml');
749 749
 		else Context::addJsFilter($this->module_path.'tpl/filter', 'insert.xml');
750 750
 
751 751
 		$oSecurity = new Security();
@@ -757,14 +757,14 @@  discard block
 block discarded – undo
757 757
 	function _getStatusNameList(&$oDocumentModel)
758 758
 	{
759 759
 		$resultList = array();
760
-		if(!empty($this->module_info->use_status))
760
+		if (!empty($this->module_info->use_status))
761 761
 		{
762 762
 			$statusNameList = $oDocumentModel->getStatusNameList();
763 763
 			$statusList = explode('|@|', $this->module_info->use_status);
764 764
 
765
-			if(is_array($statusList))
765
+			if (is_array($statusList))
766 766
 			{
767
-				foreach($statusList as $key => $value)
767
+				foreach ($statusList as $key => $value)
768 768
 				{
769 769
 					$resultList[$value] = $statusNameList[$value];
770 770
 				}
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 	function dispBoardDelete()
780 780
 	{
781 781
 		// check grant
782
-		if(!$this->grant->write_document)
782
+		if (!$this->grant->write_document)
783 783
 		{
784 784
 			return $this->dispBoardMessage('msg_not_permitted');
785 785
 		}
@@ -788,30 +788,30 @@  discard block
 block discarded – undo
788 788
 		$document_srl = Context::get('document_srl');
789 789
 
790 790
 		// if document exists, get the document information
791
-		if($document_srl)
791
+		if ($document_srl)
792 792
 		{
793 793
 			$oDocumentModel = getModel('document');
794 794
 			$oDocument = $oDocumentModel->getDocument($document_srl);
795 795
 		}
796 796
 
797 797
 		// if the document is not existed, then back to the board content page
798
-		if(!$oDocument || !$oDocument->isExists())
798
+		if (!$oDocument || !$oDocument->isExists())
799 799
 		{
800 800
 			return $this->dispBoardContent();
801 801
 		}
802 802
 
803 803
 		// if the document is not granted, then back to the password input form
804
-		if(!$oDocument->isGranted())
804
+		if (!$oDocument->isGranted())
805 805
 		{
806 806
 			return $this->setTemplateFile('input_password_form');
807 807
 		}
808 808
 
809
-		if($this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false)
809
+		if ($this->module_info->protect_content == "Y" && $oDocument->get('comment_count') > 0 && $this->grant->manager == false)
810 810
 		{
811 811
 			return $this->dispBoardMessage('msg_protect_content');
812 812
 		}
813 813
 
814
-		Context::set('oDocument',$oDocument);
814
+		Context::set('oDocument', $oDocument);
815 815
 
816 816
 		/**
817 817
 		 * add JS filters
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 		$document_srl = Context::get('document_srl');
830 830
 
831 831
 		// check grant
832
-		if(!$this->grant->write_comment)
832
+		if (!$this->grant->write_comment)
833 833
 		{
834 834
 			return $this->dispBoardMessage('msg_not_permitted');
835 835
 		}
@@ -837,13 +837,13 @@  discard block
 block discarded – undo
837 837
 		// get the document information
838 838
 		$oDocumentModel = getModel('document');
839 839
 		$oDocument = $oDocumentModel->getDocument($document_srl);
840
-		if(!$oDocument->isExists())
840
+		if (!$oDocument->isExists())
841 841
 		{
842 842
 			return $this->dispBoardMessage('msg_invalid_request');
843 843
 		}
844 844
 
845 845
 		// Check allow comment
846
-		if(!$oDocument->allowComment())
846
+		if (!$oDocument->allowComment())
847 847
 		{
848 848
 			return $this->dispBoardMessage('msg_not_allow_comment');
849 849
 		}
@@ -855,9 +855,9 @@  discard block
 block discarded – undo
855 855
 		$oComment->add('module_srl', $this->module_srl);
856 856
 
857 857
 		// setup document variables on context
858
-		Context::set('oDocument',$oDocument);
859
-		Context::set('oSourceComment',$oSourceComment);
860
-		Context::set('oComment',$oComment);
858
+		Context::set('oDocument', $oDocument);
859
+		Context::set('oSourceComment', $oSourceComment);
860
+		Context::set('oComment', $oComment);
861 861
 
862 862
 		/**
863 863
 		 * add JS filter
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
 	function dispBoardReplyComment()
874 874
 	{
875 875
 		// check grant
876
-		if(!$this->grant->write_comment)
876
+		if (!$this->grant->write_comment)
877 877
 		{
878 878
 			return $this->dispBoardMessage('msg_not_permitted');
879 879
 		}
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 		$parent_srl = Context::get('comment_srl');
883 883
 
884 884
 		// if the parent comment is not existed
885
-		if(!$parent_srl)
885
+		if (!$parent_srl)
886 886
 		{
887 887
 			return new BaseObject(-1, 'msg_invalid_request');
888 888
 		}
@@ -892,11 +892,11 @@  discard block
 block discarded – undo
892 892
 		$oSourceComment = $oCommentModel->getComment($parent_srl, $this->grant->manager);
893 893
 
894 894
 		// if the comment is not existed, opoup an error message
895
-		if(!$oSourceComment->isExists())
895
+		if (!$oSourceComment->isExists())
896 896
 		{
897 897
 			return $this->dispBoardMessage('msg_invalid_request');
898 898
 		}
899
-		if(Context::get('document_srl') && $oSourceComment->get('document_srl') != Context::get('document_srl'))
899
+		if (Context::get('document_srl') && $oSourceComment->get('document_srl') != Context::get('document_srl'))
900 900
 		{
901 901
 			return $this->dispBoardMessage('msg_invalid_request');
902 902
 		}
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 		// Check allow comment
905 905
 		$oDocumentModel = getModel('document');
906 906
 		$oDocument = $oDocumentModel->getDocument($oSourceComment->get('document_srl'));
907
-		if(!$oDocument->allowComment())
907
+		if (!$oDocument->allowComment())
908 908
 		{
909 909
 			return $this->dispBoardMessage('msg_not_allow_comment');
910 910
 		}
@@ -915,9 +915,9 @@  discard block
 block discarded – undo
915 915
 		$oComment->add('document_srl', $oSourceComment->get('document_srl'));
916 916
 
917 917
 		// setup comment variables
918
-		Context::set('oSourceComment',$oSourceComment);
919
-		Context::set('oComment',$oComment);
920
-		Context::set('module_srl',$this->module_info->module_srl);
918
+		Context::set('oSourceComment', $oSourceComment);
919
+		Context::set('oComment', $oComment);
920
+		Context::set('module_srl', $this->module_info->module_srl);
921 921
 
922 922
 		/**
923 923
 		 * add JS filters
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 	function dispBoardModifyComment()
934 934
 	{
935 935
 		// check grant
936
-		if(!$this->grant->write_comment)
936
+		if (!$this->grant->write_comment)
937 937
 		{
938 938
 			return $this->dispBoardMessage('msg_not_permitted');
939 939
 		}
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 		$comment_srl = Context::get('comment_srl');
944 944
 
945 945
 		// if the comment is not existed
946
-		if(!$comment_srl)
946
+		if (!$comment_srl)
947 947
 		{
948 948
 			return new BaseObject(-1, 'msg_invalid_request');
949 949
 		}
@@ -953,13 +953,13 @@  discard block
 block discarded – undo
953 953
 		$oComment = $oCommentModel->getComment($comment_srl, $this->grant->manager);
954 954
 
955 955
 		// if the comment is not exited, alert an error message
956
-		if(!$oComment->isExists())
956
+		if (!$oComment->isExists())
957 957
 		{
958 958
 			return $this->dispBoardMessage('msg_invalid_request');
959 959
 		}
960 960
 
961 961
 		// if the comment is not granted, then back to the password input form
962
-		if(!$oComment->isGranted())
962
+		if (!$oComment->isGranted())
963 963
 		{
964 964
 			return $this->setTemplateFile('input_password_form');
965 965
 		}
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 	function dispBoardDeleteComment()
983 983
 	{
984 984
 		// check grant
985
-		if(!$this->grant->write_comment)
985
+		if (!$this->grant->write_comment)
986 986
 		{
987 987
 			return $this->dispBoardMessage('msg_not_permitted');
988 988
 		}
@@ -991,25 +991,25 @@  discard block
 block discarded – undo
991 991
 		$comment_srl = Context::get('comment_srl');
992 992
 
993 993
 		// if the comment exists, then get the comment information
994
-		if($comment_srl)
994
+		if ($comment_srl)
995 995
 		{
996 996
 			$oCommentModel = getModel('comment');
997 997
 			$oComment = $oCommentModel->getComment($comment_srl, $this->grant->manager);
998 998
 		}
999 999
 
1000 1000
 		// if the comment is not existed, then back to the board content page
1001
-		if(!$oComment->isExists() )
1001
+		if (!$oComment->isExists())
1002 1002
 		{
1003 1003
 			return $this->dispBoardContent();
1004 1004
 		}
1005 1005
 
1006 1006
 		// if the comment is not granted, then back to the password input form
1007
-		if(!$oComment->isGranted())
1007
+		if (!$oComment->isGranted())
1008 1008
 		{
1009 1009
 			return $this->setTemplateFile('input_password_form');
1010 1010
 		}
1011 1011
 
1012
-		Context::set('oComment',$oComment);
1012
+		Context::set('oComment', $oComment);
1013 1013
 
1014 1014
 		/**
1015 1015
 		 * add JS filters
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 	{
1027 1027
 		$oTrackbackModel = getModel('trackback');
1028 1028
 
1029
-		if(!$oTrackbackModel)
1029
+		if (!$oTrackbackModel)
1030 1030
 		{
1031 1031
 			return;
1032 1032
 		}
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 		$trackback = $output->data;
1041 1041
 
1042 1042
 		// if no trackback, then display the board content
1043
-		if(!$trackback)
1043
+		if (!$trackback)
1044 1044
 		{
1045 1045
 			return $this->dispBoardContent();
1046 1046
 		}
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
 	function dispBoardMessage($msg_code)
1062 1062
 	{
1063 1063
 		$msg = Context::getLang($msg_code);
1064
-		if(!$msg) $msg = $msg_code;
1064
+		if (!$msg) $msg = $msg_code;
1065 1065
 		Context::set('message', $msg);
1066 1066
 		$this->setTemplateFile('message');
1067 1067
 	}
@@ -1072,8 +1072,8 @@  discard block
 block discarded – undo
1072 1072
 	 **/
1073 1073
 	function alertMessage($message)
1074 1074
 	{
1075
-		$script =  sprintf('<script> jQuery(function(){ alert("%s"); } );</script>', Context::getLang($message));
1076
-		Context::addHtmlFooter( $script );
1075
+		$script = sprintf('<script> jQuery(function(){ alert("%s"); } );</script>', Context::getLang($message));
1076
+		Context::addHtmlFooter($script);
1077 1077
 	}
1078 1078
 
1079 1079
 }
Please login to merge, or discard this patch.