Passed
Push — master ( bc874f...230097 )
by SuperNova.WS
04:01
created
classes/template.php 5 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -103,6 +103,7 @@
 block discarded – undo
103 103
   /**
104 104
   * Set custom template location (able to use directory outside of phpBB)
105 105
   * @access public
106
+  * @param string $template_path
106 107
   */
107 108
   function set_custom_template($template_path, $template_name, $fallback_template_path = false)
108 109
   {
Please login to merge, or discard this patch.
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 class template
26 26
 {
27 27
   /** variable that holds all the data we'll be substituting into
28
-  * the compiled templates. Takes form:
29
-  * --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value
30
-  * if it's a root-level variable, it'll be like this:
31
-  * --> $this->_tpldata[.][0][varname] == value
32
-  */
28
+   * the compiled templates. Takes form:
29
+   * --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value
30
+   * if it's a root-level variable, it'll be like this:
31
+   * --> $this->_tpldata[.][0][varname] == value
32
+   */
33 33
   var $_tpldata = array('.' => array(0 => array()));
34 34
   var $_rootref;
35 35
 //  var $_block_counter = array();
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
   var $parsed = false;
61 61
 
62 62
   /**
63
-  * Set template location
64
-  * @access public
65
-  */
63
+   * Set template location
64
+   * @access public
65
+   */
66 66
   function set_template()
67 67
   {
68 68
     global $phpbb_root_path, $user;
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
   }
102 102
 
103 103
   /**
104
-  * Set custom template location (able to use directory outside of phpBB)
105
-  * @access public
106
-  */
104
+   * Set custom template location (able to use directory outside of phpBB)
105
+   * @access public
106
+   */
107 107
   function set_custom_template($template_path, $template_name, $fallback_template_path = false)
108 108
   {
109 109
     global $phpbb_root_path, $user;
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
   }
143 143
 
144 144
   /**
145
-  * Sets the template filenames for handles. $filename_array
146
-  * should be a hash of handle => filename pairs.
147
-  * @access public
148
-  */
145
+   * Sets the template filenames for handles. $filename_array
146
+   * should be a hash of handle => filename pairs.
147
+   * @access public
148
+   */
149 149
   function set_filenames($filename_array)
150 150
   {
151 151
     if (!is_array($filename_array))
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
   }
173 173
 
174 174
   /**
175
-  * Destroy template data set
176
-  * @access public
177
-  */
175
+   * Destroy template data set
176
+   * @access public
177
+   */
178 178
   function destroy()
179 179
   {
180 180
     $this->_tpldata = array('.' => array(0 => array()));
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
   }
183 183
 
184 184
   /**
185
-  * Reset/empty complete block
186
-  * @access public
187
-  */
185
+   * Reset/empty complete block
186
+   * @access public
187
+   */
188 188
   function destroy_block_vars($blockname)
189 189
   {
190 190
     if (strpos($blockname, '.') !== false)
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
   }
213 213
 
214 214
   /**
215
-  * Display handle
216
-  * @access public
217
-  */
215
+   * Display handle
216
+   * @access public
217
+   */
218 218
   function display($handle, $include_once = true)
219 219
   {
220 220
     global $user, $phpbb_hook, $lang, $config;
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
   }
249 249
 
250 250
   /**
251
-  * Display the handle and assign the output to a template variable or return the compiled result.
252
-  * @access public
253
-  */
251
+   * Display the handle and assign the output to a template variable or return the compiled result.
252
+   * @access public
253
+   */
254 254
   function assign_display($handle, $template_var = '', $return_content = true, $include_once = false)
255 255
   {
256 256
     ob_start();
@@ -268,9 +268,9 @@  discard block
 block discarded – undo
268 268
   }
269 269
 
270 270
   /**
271
-  * Load a compiled template if possible, if not, recompile it
272
-  * @access private
273
-  */
271
+   * Load a compiled template if possible, if not, recompile it
272
+   * @access private
273
+   */
274 274
   function _tpl_load(&$handle)
275 275
   {
276 276
     global $user, $config;
@@ -453,9 +453,9 @@  discard block
 block discarded – undo
453 453
   }
454 454
 
455 455
   /**
456
-  * Assign key variable pairs from an array
457
-  * @access public
458
-  */
456
+   * Assign key variable pairs from an array
457
+   * @access public
458
+   */
459 459
   function assign_vars($vararray)
460 460
   {
461 461
     foreach ($vararray as $key => $val)
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
   }
468 468
 
469 469
   /**
470
-  * Assign a single variable to a single key
471
-  * @access public
472
-  */
470
+   * Assign a single variable to a single key
471
+   * @access public
472
+   */
473 473
   function assign_var($varname, $varval)
474 474
   {
475 475
     $this->_rootref[$varname] = $varval;
@@ -478,9 +478,9 @@  discard block
 block discarded – undo
478 478
   }
479 479
 
480 480
   /**
481
-  * Assign key variable pairs from an array to a specified block
482
-  * @access public
483
-  */
481
+   * Assign key variable pairs from an array to a specified block
482
+   * @access public
483
+   */
484 484
   function assign_block_vars($blockname, $vararray)
485 485
   {
486 486
     if (strpos($blockname, '.') !== false)
@@ -545,33 +545,33 @@  discard block
 block discarded – undo
545 545
   }
546 546
 
547 547
   /**
548
-  * Change already assigned key variable pair (one-dimensional - single loop entry)
549
-  *
550
-  * An example of how to use this function:
551
-  * {@example alter_block_array.php}
552
-  *
553
-  * @param  string  $blockname  the blockname, for example 'loop'
554
-  * @param  array $vararray the var array to insert/add or merge
555
-  * @param  mixed $key    Key to search for
556
-  *
557
-  * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]
558
-  *
559
-  * int: Position [the position to change or insert at directly given]
560
-  *
561
-  * If key is false the position is set to 0
562
-  * If key is true the position is set to the last entry
563
-  *
564
-  * @param  string  $mode   Mode to execute (valid modes are 'insert' and 'change')
565
-  *
566
-  * If insert, the vararray is inserted at the given position (position counting from zero).
567
-  * If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new value).
568
-  *
569
-  * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array)
570
-  * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars)
571
-  *
572
-  * @return bool false on error, true on success
573
-  * @access public
574
-  */
548
+   * Change already assigned key variable pair (one-dimensional - single loop entry)
549
+   *
550
+   * An example of how to use this function:
551
+   * {@example alter_block_array.php}
552
+   *
553
+   * @param  string  $blockname  the blockname, for example 'loop'
554
+   * @param  array $vararray the var array to insert/add or merge
555
+   * @param  mixed $key    Key to search for
556
+   *
557
+   * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]
558
+   *
559
+   * int: Position [the position to change or insert at directly given]
560
+   *
561
+   * If key is false the position is set to 0
562
+   * If key is true the position is set to the last entry
563
+   *
564
+   * @param  string  $mode   Mode to execute (valid modes are 'insert' and 'change')
565
+   *
566
+   * If insert, the vararray is inserted at the given position (position counting from zero).
567
+   * If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new value).
568
+   *
569
+   * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array)
570
+   * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars)
571
+   *
572
+   * @return bool false on error, true on success
573
+   * @access public
574
+   */
575 575
   function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert')
576 576
   {
577 577
     if (strpos($blockname, '.') !== false)
@@ -655,9 +655,9 @@  discard block
 block discarded – undo
655 655
   }
656 656
 
657 657
   /**
658
-  * Include a separate template
659
-  * @access private
660
-  */
658
+   * Include a separate template
659
+   * @access private
660
+   */
661 661
   function _tpl_include($filename, $include = true)
662 662
   {
663 663
     global $lang, $config;
@@ -686,9 +686,9 @@  discard block
 block discarded – undo
686 686
   }
687 687
 
688 688
   /**
689
-  * Include a php-file
690
-  * @access private
691
-  */
689
+   * Include a php-file
690
+   * @access private
691
+   */
692 692
   function _php_include($filename)
693 693
   {
694 694
     global $phpbb_root_path;
@@ -705,9 +705,9 @@  discard block
 block discarded – undo
705 705
   }
706 706
 
707 707
   /**
708
-  * Assign key variable pairs from an array with block support
709
-  * @access public
710
-  */
708
+   * Assign key variable pairs from an array with block support
709
+   * @access public
710
+   */
711 711
   function assign_recursive($values, $name = '')
712 712
   {
713 713
     if(isset($values['.']))
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
       // Re-position template blocks
629 629
       for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--)
630 630
       {
631
-        $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i-1];
631
+        $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i - 1];
632 632
         $this->_tpldata[$blockname][$i]['S_ROW_COUNT'] = $i;
633 633
       }
634 634
 
@@ -710,13 +710,13 @@  discard block
 block discarded – undo
710 710
   */
711 711
   function assign_recursive($values, $name = '')
712 712
   {
713
-    if(isset($values['.']))
713
+    if (isset($values['.']))
714 714
     {
715 715
       $values_extra = $values['.'];
716 716
       unset($values['.']);
717 717
     }
718 718
 
719
-    if(!$name)
719
+    if (!$name)
720 720
     {
721 721
       $this->assign_vars($values);
722 722
     }
@@ -725,12 +725,12 @@  discard block
 block discarded – undo
725 725
       $this->assign_block_vars($name, $values);
726 726
     }
727 727
 
728
-    if(isset($values_extra))
728
+    if (isset($values_extra))
729 729
     {
730
-      foreach($values_extra as $sub_array_name => $sub_array)
730
+      foreach ($values_extra as $sub_array_name => $sub_array)
731 731
       {
732 732
         $new_name = $name . ($name ? '.' : '') . $sub_array_name;
733
-        foreach($sub_array as $sub_element)
733
+        foreach ($sub_array as $sub_element)
734 734
         {
735 735
           $this->assign_recursive($sub_element, $new_name);
736 736
         }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
       // Search array to get correct position
587 587
       list($search_key, $search_value) = @each($key);
588 588
 
589
-      $key = NULL;
589
+      $key = null;
590 590
       foreach ($this->_tpldata[$blockname] as $i => $val_ary)
591 591
       {
592 592
         if ($val_ary[$search_key] === $search_value)
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
       }
598 598
 
599 599
       // key/value pair not found
600
-      if ($key === NULL)
600
+      if ($key === null)
601 601
       {
602 602
         return false;
603 603
       }
Please login to merge, or discard this patch.
Braces   +29 added lines, -58 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
 * Base Template class.
23 23
 * @package phpBB3
24 24
 */
25
-class template
26
-{
25
+class template {
27 26
   /** variable that holds all the data we'll be substituting into
28 27
   * the compiled templates. Takes form:
29 28
   * --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value
@@ -63,8 +62,7 @@  discard block
 block discarded – undo
63 62
   * Set template location
64 63
   * @access public
65 64
   */
66
-  function set_template()
67
-  {
65
+  function set_template() {
68 66
     global $phpbb_root_path, $user;
69 67
 
70 68
     if (file_exists($phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'))
@@ -89,8 +87,7 @@  discard block
 block discarded – undo
89 87
       {
90 88
         $this->inherit_root = $phpbb_root_path . 'styles/' . $user->theme['template_inherit_path'] . '/template';
91 89
       }
92
-    }
93
-    else
90
+    } else
94 91
     {
95 92
       trigger_error('Template path could not be found: styles/' . $user->theme['template_path'] . '/template', E_USER_ERROR);
96 93
     }
@@ -104,8 +101,7 @@  discard block
 block discarded – undo
104 101
   * Set custom template location (able to use directory outside of phpBB)
105 102
   * @access public
106 103
   */
107
-  function set_custom_template($template_path, $template_name, $fallback_template_path = false)
108
-  {
104
+  function set_custom_template($template_path, $template_name, $fallback_template_path = false) {
109 105
     global $phpbb_root_path, $user;
110 106
 
111 107
     // Make sure $template_path has no ending slash
@@ -126,8 +122,7 @@  discard block
 block discarded – undo
126 122
 
127 123
       $this->inherit_root = $fallback_template_path;
128 124
       $this->orig_tpl_inherits_id = true;
129
-    }
130
-    else
125
+    } else
131 126
     {
132 127
       $this->orig_tpl_inherits_id = false;
133 128
     }
@@ -146,8 +141,7 @@  discard block
 block discarded – undo
146 141
   * should be a hash of handle => filename pairs.
147 142
   * @access public
148 143
   */
149
-  function set_filenames($filename_array)
150
-  {
144
+  function set_filenames($filename_array) {
151 145
     if (!is_array($filename_array))
152 146
     {
153 147
       return false;
@@ -175,8 +169,7 @@  discard block
 block discarded – undo
175 169
   * Destroy template data set
176 170
   * @access public
177 171
   */
178
-  function destroy()
179
-  {
172
+  function destroy() {
180 173
     $this->_tpldata = array('.' => array(0 => array()));
181 174
     $this->_rootref = &$this->_tpldata['.'][0];
182 175
   }
@@ -185,8 +178,7 @@  discard block
 block discarded – undo
185 178
   * Reset/empty complete block
186 179
   * @access public
187 180
   */
188
-  function destroy_block_vars($blockname)
189
-  {
181
+  function destroy_block_vars($blockname) {
190 182
     if (strpos($blockname, '.') !== false)
191 183
     {
192 184
       // Nested block.
@@ -201,8 +193,7 @@  discard block
 block discarded – undo
201 193
       }
202 194
 
203 195
       unset($str[$blocks[$blockcount]]);
204
-    }
205
-    else
196
+    } else
206 197
     {
207 198
       // Top-level block.
208 199
       unset($this->_tpldata[$blockname]);
@@ -215,8 +206,7 @@  discard block
 block discarded – undo
215 206
   * Display handle
216 207
   * @access public
217 208
   */
218
-  function display($handle, $include_once = true)
219
-  {
209
+  function display($handle, $include_once = true) {
220 210
     global $user, $phpbb_hook, $lang, $config;
221 211
 
222 212
     if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $include_once))
@@ -238,8 +228,7 @@  discard block
 block discarded – undo
238 228
     if ($filename = $this->_tpl_load($handle))
239 229
     {
240 230
       ($include_once) ? include_once($filename) : include($filename);
241
-    }
242
-    else
231
+    } else
243 232
     {
244 233
       eval(' ?>' . $this->compiled_code[$handle] . '<?php ');
245 234
     }
@@ -251,8 +240,7 @@  discard block
 block discarded – undo
251 240
   * Display the handle and assign the output to a template variable or return the compiled result.
252 241
   * @access public
253 242
   */
254
-  function assign_display($handle, $template_var = '', $return_content = true, $include_once = false)
255
-  {
243
+  function assign_display($handle, $template_var = '', $return_content = true, $include_once = false) {
256 244
     ob_start();
257 245
     $this->display($handle, $include_once);
258 246
     $contents = ob_get_clean();
@@ -271,8 +259,7 @@  discard block
 block discarded – undo
271 259
   * Load a compiled template if possible, if not, recompile it
272 260
   * @access private
273 261
   */
274
-  function _tpl_load(&$handle)
275
-  {
262
+  function _tpl_load(&$handle) {
276 263
     global $user, $config;
277 264
 
278 265
     if (!isset($this->filename[$handle]))
@@ -293,8 +280,7 @@  discard block
 block discarded – undo
293 280
     if (!file_exists($filename) || @filesize($filename) === 0)
294 281
     {
295 282
       $recompile = true;
296
-    }
297
-    else if ($config->load_tplcompile)
283
+    } else if ($config->load_tplcompile)
298 284
     {
299 285
       // No way around it: we need to check inheritance here
300 286
       if ($user->theme['template_inherits_id'] && !file_exists($this->files[$handle]))
@@ -382,15 +368,13 @@  discard block
 block discarded – undo
382 368
               $this->files[$row['template_filename']] = $file;
383 369
               $this->files_inherit[$row['template_filename']] = $file;
384 370
               $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id'];
385
-            }
386
-            else if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'])
371
+            } else if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'])
387 372
             {
388 373
               // Ok, we have a situation. There is a file in the subtemplate, but nothing in the DB. We have to fix that.
389 374
               $force_reload = true;
390 375
               $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id'];
391 376
             }
392
-          }
393
-          else
377
+          } else
394 378
           {
395 379
             $this->files_template[$row['template_filename']] = $user->theme['template_id'];
396 380
           }
@@ -400,8 +384,7 @@  discard block
 block discarded – undo
400 384
             if ($row['template_filename'] == $this->filename[$handle])
401 385
             {
402 386
               $compile->_tpl_load_file($handle, true);
403
-            }
404
-            else
387
+            } else
405 388
             {
406 389
               $this->files[$row['template_filename']] = $file;
407 390
               $this->filename[$row['template_filename']] = $row['template_filename'];
@@ -416,8 +399,7 @@  discard block
 block discarded – undo
416 399
           {
417 400
             $this->compiled_code[$handle] = $compile->compile(trim($row['template_data']));
418 401
             $compile->compile_write($handle, $this->compiled_code[$handle]);
419
-          }
420
-          else
402
+          } else
421 403
           {
422 404
             // Only bother compiling if it doesn't already exist
423 405
             if (!file_exists($this->cachepath . str_replace('/', '.', $row['template_filename']) . DOT_PHP_EX))
@@ -428,8 +410,7 @@  discard block
 block discarded – undo
428 410
             }
429 411
           }
430 412
         }
431
-      }
432
-      else
413
+      } else
433 414
       {
434 415
         $file = $this->root . '/' . $row['template_filename'];
435 416
 
@@ -456,8 +437,7 @@  discard block
 block discarded – undo
456 437
   * Assign key variable pairs from an array
457 438
   * @access public
458 439
   */
459
-  function assign_vars($vararray)
460
-  {
440
+  function assign_vars($vararray) {
461 441
     foreach ($vararray as $key => $val)
462 442
     {
463 443
       $this->_rootref[$key] = $val;
@@ -470,8 +450,7 @@  discard block
 block discarded – undo
470 450
   * Assign a single variable to a single key
471 451
   * @access public
472 452
   */
473
-  function assign_var($varname, $varval)
474
-  {
453
+  function assign_var($varname, $varval) {
475 454
     $this->_rootref[$varname] = $varval;
476 455
 
477 456
     return true;
@@ -481,8 +460,7 @@  discard block
 block discarded – undo
481 460
   * Assign key variable pairs from an array to a specified block
482 461
   * @access public
483 462
   */
484
-  function assign_block_vars($blockname, $vararray)
485
-  {
463
+  function assign_block_vars($blockname, $vararray) {
486 464
     if (strpos($blockname, '.') !== false)
487 465
     {
488 466
       // Nested block.
@@ -517,8 +495,7 @@  discard block
 block discarded – undo
517 495
       // We're adding a new iteration to this block with the given
518 496
       // variable assignments.
519 497
       $str[$blocks[$blockcount]][] = $vararray;
520
-    }
521
-    else
498
+    } else
522 499
     {
523 500
       // Top-level block.
524 501
       $s_row_count = (isset($this->_tpldata[$blockname])) ? sizeof($this->_tpldata[$blockname]) : 0;
@@ -572,8 +549,7 @@  discard block
 block discarded – undo
572 549
   * @return bool false on error, true on success
573 550
   * @access public
574 551
   */
575
-  function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert')
576
-  {
552
+  function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert') {
577 553
     if (strpos($blockname, '.') !== false)
578 554
     {
579 555
       // Nested blocks are not supported
@@ -618,8 +594,7 @@  discard block
 block discarded – undo
618 594
         $key = sizeof($this->_tpldata[$blockname]);
619 595
         unset($this->_tpldata[$blockname][($key - 1)]['S_LAST_ROW']);
620 596
         $vararray['S_LAST_ROW'] = true;
621
-      }
622
-      else if ($key === 0)
597
+      } else if ($key === 0)
623 598
       {
624 599
         unset($this->_tpldata[$blockname][0]['S_FIRST_ROW']);
625 600
         $vararray['S_FIRST_ROW'] = true;
@@ -658,8 +633,7 @@  discard block
 block discarded – undo
658 633
   * Include a separate template
659 634
   * @access private
660 635
   */
661
-  function _tpl_include($filename, $include = true)
662
-  {
636
+  function _tpl_include($filename, $include = true) {
663 637
     global $lang, $config;
664 638
 
665 639
     $handle = $filename;
@@ -689,8 +663,7 @@  discard block
 block discarded – undo
689 663
   * Include a php-file
690 664
   * @access private
691 665
   */
692
-  function _php_include($filename)
693
-  {
666
+  function _php_include($filename) {
694 667
     global $phpbb_root_path;
695 668
 
696 669
     $file = $phpbb_root_path . $filename;
@@ -708,8 +681,7 @@  discard block
 block discarded – undo
708 681
   * Assign key variable pairs from an array with block support
709 682
   * @access public
710 683
   */
711
-  function assign_recursive($values, $name = '')
712
-  {
684
+  function assign_recursive($values, $name = '') {
713 685
     if(isset($values['.']))
714 686
     {
715 687
       $values_extra = $values['.'];
@@ -719,8 +691,7 @@  discard block
 block discarded – undo
719 691
     if(!$name)
720 692
     {
721 693
       $this->assign_vars($values);
722
-    }
723
-    else
694
+    } else
724 695
     {
725 696
       $this->assign_block_vars($name, $values);
726 697
     }
Please login to merge, or discard this patch.
classes/template_compile.php 4 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -47,6 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
   /**
49 49
   * constuctor
50
+  * @param template $template
50 51
   */
51 52
   function template_compile(&$template)
52 53
   {
@@ -463,6 +464,7 @@  discard block
 block discarded – undo
463 464
   * Compile IF tags - much of this is from Smarty with
464 465
   * some adaptions for our block level methods
465 466
   * @access private
467
+  * @param boolean $elseif
466 468
   */
467 469
   function compile_tag_if($tag_args, $elseif)
468 470
   {
@@ -620,6 +622,7 @@  discard block
 block discarded – undo
620 622
   /**
621 623
   * Compile DEFINE tags
622 624
   * @access private
625
+  * @param boolean $op
623 626
   */
624 627
   function compile_tag_define($tag_args, $op)
625 628
   {
@@ -698,6 +701,7 @@  discard block
 block discarded – undo
698 701
   * parse expression
699 702
   * This is from Smarty
700 703
   * @access private
704
+  * @param string $is_arg
701 705
   */
702 706
   function _parse_is_expr($is_arg, $tokens)
703 707
   {
@@ -794,6 +798,8 @@  discard block
 block discarded – undo
794 798
   * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
795 799
   * NOTE: does not expect a trailing "." on the blockname.
796 800
   * @access private
801
+  * @param string $blockname
802
+  * @param boolean $include_last_iterator
797 803
   */
798 804
   function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
799 805
   {
@@ -832,6 +838,7 @@  discard block
 block discarded – undo
832 838
   /**
833 839
   * Write compiled file to cache directory
834 840
   * @access private
841
+  * @param string $data
835 842
   */
836 843
   function compile_write($handle, $data)
837 844
   {
@@ -857,6 +864,7 @@  discard block
 block discarded – undo
857 864
   /**
858 865
   * Minifies template w/i PHP code by removing extra spaces
859 866
   * @access private
867
+  * @return string
860 868
   */
861 869
   function minify($html)
862 870
   {
Please login to merge, or discard this patch.
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
   var $block_else_level = array();
47 47
 
48 48
   /**
49
-  * constuctor
50
-  */
49
+   * constuctor
50
+   */
51 51
   function template_compile(&$template)
52 52
   {
53 53
     $this->template = &$template;
54 54
   }
55 55
 
56 56
   /**
57
-  * Load template source from file
58
-  * @access private
59
-  */
57
+   * Load template source from file
58
+   * @access private
59
+   */
60 60
   function _tpl_load_file($handle, $store_in_db = false)
61 61
   {
62 62
     // Try and open template for read
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
   }
100 100
 
101 101
   /**
102
-  * Remove any PHP tags that do not belong, these regular expressions are derived from
103
-  * the ones that exist in zend_language_scanner.l
104
-  * @access private
105
-  */
102
+   * Remove any PHP tags that do not belong, these regular expressions are derived from
103
+   * the ones that exist in zend_language_scanner.l
104
+   * @access private
105
+   */
106 106
   function remove_php_tags(&$code)
107 107
   {
108 108
     // This matches the information gathered from the internal PHP lexer
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
   }
117 117
 
118 118
   /**
119
-  * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
120
-  * @access private
121
-  */
119
+   * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
120
+   * @access private
121
+   */
122 122
   function compile($code, $no_echo = false, $echo_var = '')
123 123
   {
124 124
     global $config;
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
   }
290 290
 
291 291
   /**
292
-  * Compile variables
293
-  * @access private
294
-  */
292
+   * Compile variables
293
+   * @access private
294
+   */
295 295
   function compile_var_tags(&$text_blocks)
296 296
   {
297 297
     // including $lang variable
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
   }
355 355
 
356 356
   /**
357
-  * Compile blocks
358
-  * @access private
359
-  */
357
+   * Compile blocks
358
+   * @access private
359
+   */
360 360
   function compile_tag_block($tag_args)
361 361
   {
362 362
     $no_nesting = false;
@@ -442,14 +442,14 @@  discard block
 block discarded – undo
442 442
     $tag_template_php .= 'if ($_' . $tag_args . '_count) {';
443 443
 
444 444
     /**
445
-    * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory
446
-    * <code>
447
-    * if (!$offset)
448
-    * {
449
-    *   $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){';
450
-    * }
451
-    * </code>
452
-    */
445
+     * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory
446
+     * <code>
447
+     * if (!$offset)
448
+     * {
449
+     *   $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){';
450
+     * }
451
+     * </code>
452
+     */
453 453
 
454 454
     $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){';
455 455
 //    $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;';
@@ -460,10 +460,10 @@  discard block
 block discarded – undo
460 460
   }
461 461
 
462 462
   /**
463
-  * Compile IF tags - much of this is from Smarty with
464
-  * some adaptions for our block level methods
465
-  * @access private
466
-  */
463
+   * Compile IF tags - much of this is from Smarty with
464
+   * some adaptions for our block level methods
465
+   * @access private
466
+   */
467 467
   function compile_tag_if($tag_args, $elseif)
468 468
   {
469 469
     // Tokenize args for 'if' tag.
@@ -618,9 +618,9 @@  discard block
 block discarded – undo
618 618
   }
619 619
 
620 620
   /**
621
-  * Compile DEFINE tags
622
-  * @access private
623
-  */
621
+   * Compile DEFINE tags
622
+   * @access private
623
+   */
624 624
   function compile_tag_define($tag_args, $op)
625 625
   {
626 626
     preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match);
@@ -671,9 +671,9 @@  discard block
 block discarded – undo
671 671
   }
672 672
 
673 673
   /**
674
-  * Compile INCLUDE tag
675
-  * @access private
676
-  */
674
+   * Compile INCLUDE tag
675
+   * @access private
676
+   */
677 677
   function compile_tag_include($tag_args)
678 678
   {
679 679
     // Process dynamic includes
@@ -686,19 +686,19 @@  discard block
 block discarded – undo
686 686
   }
687 687
 
688 688
   /**
689
-  * Compile INCLUDE_PHP tag
690
-  * @access private
691
-  */
689
+   * Compile INCLUDE_PHP tag
690
+   * @access private
691
+   */
692 692
   function compile_tag_include_php($tag_args)
693 693
   {
694 694
     return "\$this->_php_include('$tag_args');";
695 695
   }
696 696
 
697 697
   /**
698
-  * parse expression
699
-  * This is from Smarty
700
-  * @access private
701
-  */
698
+   * parse expression
699
+   * This is from Smarty
700
+   * @access private
701
+   */
702 702
   function _parse_is_expr($is_arg, $tokens)
703 703
   {
704 704
     $expr_end = 0;
@@ -763,13 +763,13 @@  discard block
 block discarded – undo
763 763
   }
764 764
 
765 765
   /**
766
-  * Generates a reference to the given variable inside the given (possibly nested)
767
-  * block namespace. This is a string of the form:
768
-  * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . '
769
-  * It's ready to be inserted into an "echo" line in one of the templates.
770
-  * NOTE: expects a trailing "." on the namespace.
771
-  * @access private
772
-  */
766
+   * Generates a reference to the given variable inside the given (possibly nested)
767
+   * block namespace. This is a string of the form:
768
+   * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . '
769
+   * It's ready to be inserted into an "echo" line in one of the templates.
770
+   * NOTE: expects a trailing "." on the namespace.
771
+   * @access private
772
+   */
773 773
   function generate_block_varref($namespace, $varname, $echo = true, $defop = false)
774 774
   {
775 775
     // Strip the trailing period.
@@ -787,14 +787,14 @@  discard block
 block discarded – undo
787 787
   }
788 788
 
789 789
   /**
790
-  * Generates a reference to the array of data values for the given
791
-  * (possibly nested) block namespace. This is a string of the form:
792
-  * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
793
-  *
794
-  * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
795
-  * NOTE: does not expect a trailing "." on the blockname.
796
-  * @access private
797
-  */
790
+   * Generates a reference to the array of data values for the given
791
+   * (possibly nested) block namespace. This is a string of the form:
792
+   * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
793
+   *
794
+   * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
795
+   * NOTE: does not expect a trailing "." on the blockname.
796
+   * @access private
797
+   */
798 798
   function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
799 799
   {
800 800
     // Get an array of the blocks involved.
@@ -830,9 +830,9 @@  discard block
 block discarded – undo
830 830
   }
831 831
 
832 832
   /**
833
-  * Write compiled file to cache directory
834
-  * @access private
835
-  */
833
+   * Write compiled file to cache directory
834
+   * @access private
835
+   */
836 836
   function compile_write($handle, $data)
837 837
   {
838 838
     $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX;
@@ -855,9 +855,9 @@  discard block
 block discarded – undo
855 855
 
856 856
   // Gorlum's minifier BOF
857 857
   /**
858
-  * Minifies template w/i PHP code by removing extra spaces
859
-  * @access private
860
-  */
858
+   * Minifies template w/i PHP code by removing extra spaces
859
+   * @access private
860
+   */
861 861
   function minify($html)
862 862
   {
863 863
     global $config;
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 
143 143
     preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches);
144 144
     $include_blocks = $matches[1];
145
-    if($include_blocks)
145
+    if ($include_blocks)
146 146
     {
147
-      foreach($include_blocks as &$included_file)
147
+      foreach ($include_blocks as &$included_file)
148 148
       {
149 149
         $included_file .= '.tpl.html';
150 150
       }
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 
454 454
     $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){';
455 455
 //    $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;';
456
-    $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];';
457
-    $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];';
456
+    $tag_template_php .= '$_' . $tag_args . '_val = &' . $varref . '[$_' . $tag_args . '_i];';
457
+    $tag_template_php .= '$this->_block_value["' . $tag_args . '"] = &' . $varref . '[$_' . $tag_args . '_i];';
458 458
 
459 459
     return $tag_template_php;
460 460
   }
@@ -558,10 +558,10 @@  discard block
 block discarded – undo
558 558
         break;
559 559
 
560 560
         case 'is':
561
-          $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1;
561
+          $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1;
562 562
           $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
563 563
 
564
-          $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1));
564
+          $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1));
565 565
 
566 566
           array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens);
567 567
 
@@ -821,11 +821,11 @@  discard block
 block discarded – undo
821 821
     }
822 822
     else if ($include_last_iterator)
823 823
     {
824
-      return '$_'. $blocks[$blockcount] . '_val';
824
+      return '$_' . $blocks[$blockcount] . '_val';
825 825
     }
826 826
     else
827 827
     {
828
-      return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']';
828
+      return '$_' . $blocks[$blockcount - 1] . '_val[\'' . $blocks[$blockcount] . '\']';
829 829
     }
830 830
   }
831 831
 
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
     if ($fp = @fopen($filename, 'wb'))
843 843
     {
844 844
       @flock($fp, LOCK_EX);
845
-      @fwrite ($fp, $data);
845
+      @fwrite($fp, $data);
846 846
       @flock($fp, LOCK_UN);
847 847
       @fclose($fp);
848 848
 
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
   {
863 863
     global $config;
864 864
 
865
-    if(!$config->tpl_minifier)
865
+    if (!$config->tpl_minifier)
866 866
     {
867 867
       return $html;
868 868
     }
@@ -874,14 +874,14 @@  discard block
 block discarded – undo
874 874
     //$html = preg_replace('/[\r\n\t]+/', ' ', $html);
875 875
     $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags
876 876
     $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space
877
-    if(!empty($pre[0]))
877
+    if (!empty($pre[0]))
878 878
     {
879
-      foreach($pre[0] as $tag)
879
+      foreach ($pre[0] as $tag)
880 880
       {
881 881
         $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside
882 882
         $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one
883 883
         $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one
884
-        $html = preg_replace('/#pre#/', $tag, $html,1);
884
+        $html = preg_replace('/#pre#/', $tag, $html, 1);
885 885
       }
886 886
     }
887 887
 
Please login to merge, or discard this patch.
Braces   +34 added lines, -68 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
 *
38 38
 * @package phpBB3
39 39
 */
40
-class template_compile
41
-{
40
+class template_compile {
42 41
   var $template;
43 42
 
44 43
   // Various storage arrays
@@ -48,8 +47,7 @@  discard block
 block discarded – undo
48 47
   /**
49 48
   * constuctor
50 49
   */
51
-  function template_compile(&$template)
52
-  {
50
+  function template_compile(&$template) {
53 51
     $this->template = &$template;
54 52
   }
55 53
 
@@ -57,8 +55,7 @@  discard block
 block discarded – undo
57 55
   * Load template source from file
58 56
   * @access private
59 57
   */
60
-  function _tpl_load_file($handle, $store_in_db = false)
61
-  {
58
+  function _tpl_load_file($handle, $store_in_db = false) {
62 59
     // Try and open template for read
63 60
     if (!file_exists($this->template->files[$handle]))
64 61
     {
@@ -66,8 +63,7 @@  discard block
 block discarded – undo
66 63
       {
67 64
         return;
68 65
         trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR);
69
-      }
70
-      else
66
+      } else
71 67
       {
72 68
         $this->template->files[$handle] = $this->template->files_inherit[$handle];
73 69
       }
@@ -103,8 +99,7 @@  discard block
 block discarded – undo
103 99
   * the ones that exist in zend_language_scanner.l
104 100
   * @access private
105 101
   */
106
-  function remove_php_tags(&$code)
107
-  {
102
+  function remove_php_tags(&$code) {
108 103
     // This matches the information gathered from the internal PHP lexer
109 104
     $match = array(
110 105
       '#<([\?%])=?.*?\1>#s',
@@ -119,8 +114,7 @@  discard block
 block discarded – undo
119 114
   * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
120 115
   * @access private
121 116
   */
122
-  function compile($code, $no_echo = false, $echo_var = '')
123
-  {
117
+  function compile($code, $no_echo = false, $echo_var = '') {
124 118
     global $config;
125 119
 
126 120
     if ($echo_var)
@@ -225,15 +219,13 @@  discard block
 block discarded – undo
225 219
               $var = substr($temp, 2, -1);
226 220
               //$file = $this->template->_tpldata['DEFINE']['.'][$var];
227 221
               $temp = "\$this->_tpldata['DEFINE']['.']['$var']";
228
-            }
229
-            else
222
+            } else
230 223
             {
231 224
               $var = substr($temp, 1, -1);
232 225
               //$file = $this->template->_rootref[$var];
233 226
               $temp = "\$this->_rootref['$var']";
234 227
             }
235
-          }
236
-          else
228
+          } else
237 229
           {
238 230
             $file = $temp;
239 231
           }
@@ -292,8 +284,7 @@  discard block
 block discarded – undo
292 284
   * Compile variables
293 285
   * @access private
294 286
   */
295
-  function compile_var_tags(&$text_blocks)
296
-  {
287
+  function compile_var_tags(&$text_blocks) {
297 288
     // including $lang variable
298 289
     global $lang, $config;
299 290
 
@@ -357,8 +348,7 @@  discard block
 block discarded – undo
357 348
   * Compile blocks
358 349
   * @access private
359 350
   */
360
-  function compile_tag_block($tag_args)
361
-  {
351
+  function compile_tag_block($tag_args) {
362 352
     $no_nesting = false;
363 353
 
364 354
     // Is the designer wanting to call another loop in a loop?
@@ -381,8 +371,7 @@  discard block
 block discarded – undo
381 371
       if ($match[2] < 0)
382 372
       {
383 373
         $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')';
384
-      }
385
-      else
374
+      } else
386 375
       {
387 376
         $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')';
388 377
       }
@@ -390,17 +379,14 @@  discard block
 block discarded – undo
390 379
       if (strlen($match[3]) < 1 || $match[3] == -1)
391 380
       {
392 381
         $loop_end = '$_' . $tag_args . '_count';
393
-      }
394
-      else if ($match[3] >= 0)
382
+      } else if ($match[3] >= 0)
395 383
       {
396 384
         $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')';
397
-      }
398
-      else //if ($match[3] < -1)
385
+      } else //if ($match[3] < -1)
399 386
       {
400 387
         $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1);
401 388
       }
402
-    }
403
-    else
389
+    } else
404 390
     {
405 391
       $loop_start = 0;
406 392
       $loop_end = '$_' . $tag_args . '_count';
@@ -413,8 +399,7 @@  discard block
 block discarded – undo
413 399
     {
414 400
       // We need to implode $no_nesting times from the end...
415 401
       $block = array_slice($this->block_names, -$no_nesting);
416
-    }
417
-    else
402
+    } else
418 403
     {
419 404
       $block = $this->block_names;
420 405
     }
@@ -424,8 +409,7 @@  discard block
 block discarded – undo
424 409
       // Block is not nested.
425 410
       $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;";
426 411
       $varref = "\$this->_tpldata['$tag_args']";
427
-    }
428
-    else
412
+    } else
429 413
     {
430 414
       // This block is nested.
431 415
       // Generate a namespace string for this block.
@@ -464,8 +448,7 @@  discard block
 block discarded – undo
464 448
   * some adaptions for our block level methods
465 449
   * @access private
466 450
   */
467
-  function compile_tag_if($tag_args, $elseif)
468
-  {
451
+  function compile_tag_if($tag_args, $elseif) {
469 452
     // Tokenize args for 'if' tag.
470 453
     preg_match_all('/(?:
471 454
       "[^"\\\\]*(?:\\\\.[^"\\\\]*)*"         |
@@ -573,8 +556,7 @@  discard block
 block discarded – undo
573 556
           if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs))
574 557
           {
575 558
             $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']');
576
-          }
577
-          else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
559
+          } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
578 560
           {
579 561
             // Allow checking if loops are set with .loopname
580 562
             // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example
@@ -590,8 +572,7 @@  discard block
 block discarded – undo
590 572
 
591 573
               // Add the block reference for the last child.
592 574
               $varref .= "['" . $block . "']";
593
-            }
594
-            else
575
+            } else
595 576
             {
596 577
               $varref = '$this->_tpldata';
597 578
 
@@ -599,8 +580,7 @@  discard block
 block discarded – undo
599 580
               $varref .= "['" . $blocks[0] . "']";
600 581
             }
601 582
             $token = "sizeof($varref)";
602
-          }
603
-          else if (!empty($token))
583
+          } else if (!empty($token))
604 584
           {
605 585
             $token = '(' . $token . ')';
606 586
           }
@@ -621,8 +601,7 @@  discard block
 block discarded – undo
621 601
   * Compile DEFINE tags
622 602
   * @access private
623 603
   */
624
-  function compile_tag_define($tag_args, $op)
625
-  {
604
+  function compile_tag_define($tag_args, $op) {
626 605
     preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match);
627 606
 
628 607
     if (empty($match[2]) || (!isset($match[4]) && $op))
@@ -645,8 +624,7 @@  discard block
 block discarded – undo
645 624
 
646 625
       // Now replace the php code
647 626
       $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'";
648
-    }
649
-    else
627
+    } else
650 628
     {
651 629
       preg_match('#true|false|\.#i', $match[4], $type);
652 630
 
@@ -674,8 +652,7 @@  discard block
 block discarded – undo
674 652
   * Compile INCLUDE tag
675 653
   * @access private
676 654
   */
677
-  function compile_tag_include($tag_args)
678
-  {
655
+  function compile_tag_include($tag_args) {
679 656
     // Process dynamic includes
680 657
     if ($tag_args[0] == '$')
681 658
     {
@@ -689,8 +666,7 @@  discard block
 block discarded – undo
689 666
   * Compile INCLUDE_PHP tag
690 667
   * @access private
691 668
   */
692
-  function compile_tag_include_php($tag_args)
693
-  {
669
+  function compile_tag_include_php($tag_args) {
694 670
     return "\$this->_php_include('$tag_args');";
695 671
   }
696 672
 
@@ -699,8 +675,7 @@  discard block
 block discarded – undo
699 675
   * This is from Smarty
700 676
   * @access private
701 677
   */
702
-  function _parse_is_expr($is_arg, $tokens)
703
-  {
678
+  function _parse_is_expr($is_arg, $tokens) {
704 679
     $expr_end = 0;
705 680
     $negate_expr = false;
706 681
 
@@ -708,8 +683,7 @@  discard block
 block discarded – undo
708 683
     {
709 684
       $negate_expr = true;
710 685
       $expr_type = array_shift($tokens);
711
-    }
712
-    else
686
+    } else
713 687
     {
714 688
       $expr_type = $first_token;
715 689
     }
@@ -722,8 +696,7 @@  discard block
 block discarded – undo
722 696
           $expr_end++;
723 697
           $expr_arg = $tokens[$expr_end++];
724 698
           $expr = "!(($is_arg / $expr_arg) % $expr_arg)";
725
-        }
726
-        else
699
+        } else
727 700
         {
728 701
           $expr = "!($is_arg & 1)";
729 702
         }
@@ -735,8 +708,7 @@  discard block
 block discarded – undo
735 708
           $expr_end++;
736 709
           $expr_arg = $tokens[$expr_end++];
737 710
           $expr = "(($is_arg / $expr_arg) % $expr_arg)";
738
-        }
739
-        else
711
+        } else
740 712
         {
741 713
           $expr = "($is_arg & 1)";
742 714
         }
@@ -770,8 +742,7 @@  discard block
 block discarded – undo
770 742
   * NOTE: expects a trailing "." on the namespace.
771 743
   * @access private
772 744
   */
773
-  function generate_block_varref($namespace, $varname, $echo = true, $defop = false)
774
-  {
745
+  function generate_block_varref($namespace, $varname, $echo = true, $defop = false) {
775 746
     // Strip the trailing period.
776 747
     $namespace = substr($namespace, 0, -1);
777 748
 
@@ -795,8 +766,7 @@  discard block
 block discarded – undo
795 766
   * NOTE: does not expect a trailing "." on the blockname.
796 767
   * @access private
797 768
   */
798
-  function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
799
-  {
769
+  function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) {
800 770
     // Get an array of the blocks involved.
801 771
     $blocks = explode('.', $blockname);
802 772
     $blockcount = sizeof($blocks) - 1;
@@ -818,12 +788,10 @@  discard block
 block discarded – undo
818 788
         $varref .= '[$_' . $blocks[$blockcount] . '_i]';
819 789
       }
820 790
       return $varref;
821
-    }
822
-    else if ($include_last_iterator)
791
+    } else if ($include_last_iterator)
823 792
     {
824 793
       return '$_'. $blocks[$blockcount] . '_val';
825
-    }
826
-    else
794
+    } else
827 795
     {
828 796
       return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']';
829 797
     }
@@ -833,8 +801,7 @@  discard block
 block discarded – undo
833 801
   * Write compiled file to cache directory
834 802
   * @access private
835 803
   */
836
-  function compile_write($handle, $data)
837
-  {
804
+  function compile_write($handle, $data) {
838 805
     $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX;
839 806
 
840 807
     $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data);
@@ -858,8 +825,7 @@  discard block
 block discarded – undo
858 825
   * Minifies template w/i PHP code by removing extra spaces
859 826
   * @access private
860 827
   */
861
-  function minify($html)
862
-  {
828
+  function minify($html) {
863 829
     global $config;
864 830
 
865 831
     if(!$config->tpl_minifier)
Please login to merge, or discard this patch.
classes/userOptions.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -151,6 +151,9 @@
 block discarded – undo
151 151
   }
152 152
 
153 153
 
154
+  /**
155
+   * @param integer $user_id
156
+   */
154 157
   public function __construct($user_id) {
155 158
     $this->user_change($user_id);
156 159
   }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 
123 123
     $update_cache = false;
124 124
 
125
-    if(!empty($this->to_write)) {
126
-      foreach($this->to_write as $key => $cork) {
125
+    if (!empty($this->to_write)) {
126
+      foreach ($this->to_write as $key => $cork) {
127 127
         $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД
128 128
         $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')";
129 129
       }
@@ -134,18 +134,18 @@  discard block
 block discarded – undo
134 134
       $update_cache = true;
135 135
     }
136 136
 
137
-    if(!empty($this->to_delete)) {
138
-      foreach($this->to_delete as $key => &$value) {
139
-        $value = is_string($key) ? "'". db_escape($key) . "'" : $key;
137
+    if (!empty($this->to_delete)) {
138
+      foreach ($this->to_delete as $key => &$value) {
139
+        $value = is_string($key) ? "'" . db_escape($key) . "'" : $key;
140 140
       }
141 141
 
142
-      doquery("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") ");
142
+      doquery("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (" . implode(',', $this->to_delete) . ") ");
143 143
 
144 144
       $this->to_delete = array();
145 145
       $update_cache = true;
146 146
     }
147 147
 
148
-    if($update_cache) {
148
+    if ($update_cache) {
149 149
       global $sn_cache;
150 150
 
151 151
       $field_name = $this->cached_name();
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
   protected function load() {
173 173
     global $sn_cache;
174 174
 
175
-    if($this->loaded) {
175
+    if ($this->loaded) {
176 176
       return;
177 177
     }
178 178
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     $this->to_write = array();
181 181
     $this->to_delete = array();
182 182
 
183
-    if(!$this->user_id) {
183
+    if (!$this->user_id) {
184 184
       $this->loaded = true;
185 185
       return;
186 186
     }
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
     $field_name = $this->cached_name();
189 189
     $a_data = $sn_cache->$field_name;
190 190
 
191
-    if(!empty($a_data)) {
191
+    if (!empty($a_data)) {
192 192
       $this->data = array_replace_recursive($this->data, $a_data);
193 193
       return;
194 194
     }
195 195
 
196 196
     $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
197
-    while($row = db_fetch($query)) {
197
+    while ($row = db_fetch($query)) {
198 198
       // $this->data[$row['option_id']] = $row['value'];
199 199
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
200 200
     }
Please login to merge, or discard this patch.
classes/auth_abstract.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
    */
36 36
   // OK 4.9
37 37
   public function __construct($filename = __FILE__) {
38
-    if($this->provider_id == ACCOUNT_PROVIDER_NONE) {
38
+    if ($this->provider_id == ACCOUNT_PROVIDER_NONE) {
39 39
       die('У всех провайдеров должен быть $provider_id!');
40 40
     }
41 41
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
   // OK 4.6
134 134
   public function player_name_suggest() {
135 135
     $name = '';
136
-    if(is_object($this->account) && !empty($this->account->account_email)) {
136
+    if (is_object($this->account) && !empty($this->account->account_email)) {
137 137
       list($name) = explode('@', $this->account->account_email);
138 138
     }
139 139
 
Please login to merge, or discard this patch.
classes/Pimple/Container.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
 
240 240
         $factory = $this->values[$id];
241 241
 
242
-        $extended = function ($c) use ($callable, $factory) {
242
+        $extended = function($c) use ($callable, $factory) {
243 243
             return $callable($factory($c), $c);
244 244
         };
245 245
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
  *
32 32
  * @author  Fabien Potencier
33 33
  */
34
-class Container implements \ArrayAccess
35
-{
34
+class Container implements \ArrayAccess {
36 35
     private $values = array();
37 36
     private $factories;
38 37
     private $protected;
@@ -47,8 +46,7 @@  discard block
 block discarded – undo
47 46
      *
48 47
      * @param array $values The parameters or objects.
49 48
      */
50
-    public function __construct(array $values = array())
51
-    {
49
+    public function __construct(array $values = array()) {
52 50
         $this->factories = new \SplObjectStorage();
53 51
         $this->protected = new \SplObjectStorage();
54 52
 
@@ -71,8 +69,7 @@  discard block
 block discarded – undo
71 69
      *
72 70
      * @throws \RuntimeException Prevent override of a frozen service
73 71
      */
74
-    public function offsetSet($id, $value)
75
-    {
72
+    public function offsetSet($id, $value) {
76 73
         if (isset($this->frozen[$id])) {
77 74
             throw new \RuntimeException(sprintf('Cannot override frozen service "%s".', $id));
78 75
         }
@@ -90,8 +87,7 @@  discard block
 block discarded – undo
90 87
      *
91 88
      * @throws \InvalidArgumentException if the identifier is not defined
92 89
      */
93
-    public function offsetGet($id)
94
-    {
90
+    public function offsetGet($id) {
95 91
         if (!isset($this->keys[$id])) {
96 92
             throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
97 93
         }
@@ -125,8 +121,7 @@  discard block
 block discarded – undo
125 121
      *
126 122
      * @return bool
127 123
      */
128
-    public function offsetExists($id)
129
-    {
124
+    public function offsetExists($id) {
130 125
         return isset($this->keys[$id]);
131 126
     }
132 127
 
@@ -135,8 +130,7 @@  discard block
 block discarded – undo
135 130
      *
136 131
      * @param string $id The unique identifier for the parameter or object
137 132
      */
138
-    public function offsetUnset($id)
139
-    {
133
+    public function offsetUnset($id) {
140 134
         if (isset($this->keys[$id])) {
141 135
             if (is_object($this->values[$id])) {
142 136
                 unset($this->factories[$this->values[$id]], $this->protected[$this->values[$id]]);
@@ -155,8 +149,7 @@  discard block
 block discarded – undo
155 149
      *
156 150
      * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object
157 151
      */
158
-    public function factory($callable)
159
-    {
152
+    public function factory($callable) {
160 153
         if (!method_exists($callable, '__invoke')) {
161 154
             throw new \InvalidArgumentException('Service definition is not a Closure or invokable object.');
162 155
         }
@@ -177,8 +170,7 @@  discard block
 block discarded – undo
177 170
      *
178 171
      * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object
179 172
      */
180
-    public function protect($callable)
181
-    {
173
+    public function protect($callable) {
182 174
         if (!method_exists($callable, '__invoke')) {
183 175
             throw new \InvalidArgumentException('Callable is not a Closure or invokable object.');
184 176
         }
@@ -197,8 +189,7 @@  discard block
 block discarded – undo
197 189
      *
198 190
      * @throws \InvalidArgumentException if the identifier is not defined
199 191
      */
200
-    public function raw($id)
201
-    {
192
+    public function raw($id) {
202 193
         if (!isset($this->keys[$id])) {
203 194
             throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
204 195
         }
@@ -223,8 +214,7 @@  discard block
 block discarded – undo
223 214
      *
224 215
      * @throws \InvalidArgumentException if the identifier is not defined or not a service definition
225 216
      */
226
-    public function extend($id, $callable)
227
-    {
217
+    public function extend($id, $callable) {
228 218
         if (!isset($this->keys[$id])) {
229 219
             throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
230 220
         }
@@ -256,8 +246,7 @@  discard block
 block discarded – undo
256 246
      *
257 247
      * @return array An array of value names
258 248
      */
259
-    public function keys()
260
-    {
249
+    public function keys() {
261 250
         return array_keys($this->values);
262 251
     }
263 252
 
@@ -269,8 +258,7 @@  discard block
 block discarded – undo
269 258
      *
270 259
      * @return static
271 260
      */
272
-    public function register(ServiceProviderInterface $provider, array $values = array())
273
-    {
261
+    public function register(ServiceProviderInterface $provider, array $values = array()) {
274 262
         $provider->register($this);
275 263
 
276 264
         foreach ($values as $key => $value) {
Please login to merge, or discard this patch.
includes/functions/sys_bbcode.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -131,7 +131,6 @@
 block discarded – undo
131 131
 //  return cht_message_parse($text, $escaped, $author_auth);
132 132
 }
133 133
 
134
-function sys_bbcodeUnParse($text, $escaped = false, $author_auth = 0)
135
-{
134
+function sys_bbcodeUnParse($text, $escaped = false, $author_auth = 0) {
136 135
   return str_replace('<br />', $escaped ? '\r\n' : "\r\n", $text);
137 136
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -105,23 +105,23 @@
 block discarded – undo
105 105
 
106 106
   !empty($config->url_faq) ? $msg = str_replace('faq://', $config->url_faq, $msg) : false;
107 107
 
108
-  foreach(classSupernova::$design['bbcodes'] as $auth_level => $replaces) {
109
-    if($auth_level > $author_auth) {
108
+  foreach (classSupernova::$design['bbcodes'] as $auth_level => $replaces) {
109
+    if ($auth_level > $author_auth) {
110 110
       continue;
111 111
     }
112 112
 
113
-    foreach($replaces as $key => $html) {
114
-      $msg = preg_replace(''.$key.'', $html, $msg);
113
+    foreach ($replaces as $key => $html) {
114
+      $msg = preg_replace('' . $key . '', $html, $msg);
115 115
     }
116 116
   }
117 117
 
118
-  foreach(classSupernova::$design['smiles'] as $auth_level => $replaces) {
119
-    if($auth_level > $author_auth) {
118
+  foreach (classSupernova::$design['smiles'] as $auth_level => $replaces) {
119
+    if ($auth_level > $author_auth) {
120 120
       continue;
121 121
     }
122 122
 
123
-    foreach($replaces as $key => $imgName) {
124
-      $msg = preg_replace("#" . addcslashes($key, '()[]{}') . "#isU","<img src=\"design/images/smileys/".$imgName.".gif\" align=\"absmiddle\" title=\"".$key."\" alt=\"".$key."\">",$msg);
123
+    foreach ($replaces as $key => $imgName) {
124
+      $msg = preg_replace("#" . addcslashes($key, '()[]{}') . "#isU", "<img src=\"design/images/smileys/" . $imgName . ".gif\" align=\"absmiddle\" title=\"" . $key . "\" alt=\"" . $key . "\">", $msg);
125 125
     }
126 126
   }
127 127
 
Please login to merge, or discard this patch.
classes/PlayerToAccountTranslate.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
   protected static $is_init = false;
20 20
 
21 21
   protected static function init() {
22
-    if(!empty(static::$db)) {
22
+    if (!empty(static::$db)) {
23 23
       return;
24 24
     }
25 25
     static::$db = classSupernova::$db;
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
     $provider_id_safe = intval($provider_id_unsafe);
67 67
     !is_array($account_list) ? $account_list = array($account_list) : false;
68 68
 
69
-    foreach($account_list as $provider_account_id_unsafe) {
69
+    foreach ($account_list as $provider_account_id_unsafe) {
70 70
       $provider_account_id_safe = intval($provider_account_id_unsafe);
71 71
 
72 72
       // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером
73 73
       $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE");
74
-      while($row = static::$db->db_fetch($query)) {
74
+      while ($row = static::$db->db_fetch($query)) {
75 75
         $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true;
76 76
       }
77 77
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
       "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " .
92 92
       ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') .
93 93
       "ORDER BY `timestamp` FOR UPDATE");
94
-    while($row = static::$db->db_fetch($query)) {
94
+    while ($row = static::$db->db_fetch($query)) {
95 95
       $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row;
96 96
     }
97 97
 
Please login to merge, or discard this patch.
classes/Pimple/ServiceProviderInterface.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@
 block discarded – undo
32 32
  * @author  Fabien Potencier
33 33
  * @author  Dominik Zogg
34 34
  */
35
-interface ServiceProviderInterface
36
-{
35
+interface ServiceProviderInterface {
37 36
     /**
38 37
      * Registers services on the given container.
39 38
      *
Please login to merge, or discard this patch.
classes/Account.php 2 patches
Doc Comments   +23 added lines patch added patch discarded remove patch
@@ -179,6 +179,10 @@  discard block
 block discarded – undo
179 179
    * @return bool
180 180
    */
181 181
   // OK v4.5
182
+
183
+  /**
184
+   * @param string $account_name_unsafe
185
+   */
182 186
   public function db_get_by_name($account_name_unsafe) {
183 187
     $this->reset();
184 188
 
@@ -217,6 +221,11 @@  discard block
 block discarded – undo
217 221
    *
218 222
    */
219 223
   // OK v4.5
224
+
225
+  /**
226
+   * @param string $account_name_unsafe
227
+   * @param string $email_unsafe
228
+   */
220 229
   public function db_get_by_name_or_email($account_name_unsafe, $email_unsafe) {
221 230
     $this->reset();
222 231
 
@@ -232,6 +241,13 @@  discard block
 block discarded – undo
232 241
    * @throws Exception
233 242
    */
234 243
   // OK v4.5
244
+
245
+  /**
246
+   * @param string $account_name_unsafe
247
+   * @param string $password_raw
248
+   * @param string $email_unsafe
249
+   * @param string $language_unsafe
250
+   */
235 251
   public function db_create($account_name_unsafe, $password_raw, $email_unsafe, $language_unsafe = null, $salt_unsafe = null) {
236 252
     $this->reset();
237 253
 
@@ -326,6 +342,10 @@  discard block
 block discarded – undo
326 342
    * @return int|string
327 343
    */
328 344
   // OK 4.8
345
+
346
+  /**
347
+   * @param double $metamatter
348
+   */
329 349
   protected function db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe) {
330 350
     $provider_id_safe = intval(core_auth::$main_provider->provider_id);
331 351
     //$account_id_safe = $this->db->db_escape($this->account_id);
@@ -493,6 +513,9 @@  discard block
 block discarded – undo
493 513
     return false;
494 514
   }
495 515
 
516
+  /**
517
+   * @param string $password
518
+   */
496 519
   protected function password_encode_for_cookie($password) {
497 520
     return md5("{$password}--" . $this->secret_word);
498 521
   }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
     $this->cookie_name_impersonate = $this->cookie_name . AUTH_COOKIE_IMPERSONATE_SUFFIX;
89 89
     $this->secret_word = classSupernova::$sn_secret_word;
90 90
 
91
-    foreach($this->table_check as $table_name) {
92
-      if(empty($this->db->table_list[$table_name])) {
91
+    foreach ($this->table_check as $table_name) {
92
+      if (empty($this->db->table_list[$table_name])) {
93 93
         die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br />
94 94
               В противном случае - сообщите Администрации сервера об ошибке.<br/>
95 95
               Не хватает таблицы для работы системы авторизации: ' . $table_name);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
    */
114 114
   // OK v4.6
115 115
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
116
-    if(!$this->password_check($old_password_unsafe)) {
116
+    if (!$this->password_check($old_password_unsafe)) {
117 117
       return false;
118 118
     }
119 119
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
   // OK v4.5
135 135
   public function assign_from_db_row($row) {
136 136
     $this->reset();
137
-    if(empty($row) || !is_array($row)) {
137
+    if (empty($row) || !is_array($row)) {
138 138
       return false;
139 139
     }
140 140
     $this->account_id = $row['account_id'];
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     $this->reset();
200 200
 
201 201
     $email_safe = $this->db->db_escape($email_unsafe);
202
-    if($email_safe) {
202
+    if ($email_safe) {
203 203
       $account_row = $this->db->doquery("SELECT * FROM {{account}} WHERE LOWER(`account_email`) = LOWER('{$email_safe}') FOR UPDATE;", true);
204 204
 
205 205
       return $this->assign_from_db_row($account_row);
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
         `account_email` = LOWER('{$email_safe}'),
252 252
         `account_language` = '{$language_safe}'"
253 253
     );
254
-    if(!$result) {
254
+    if (!$result) {
255 255
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
256 256
     }
257 257
 
258
-    if(!($account_id = $this->db->db_insert_id())) {
258
+    if (!($account_id = $this->db->db_insert_id())) {
259 259
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
260 260
     }
261 261
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
       WHERE `account_id` = '{$account_id_safe}'"
286 286
     ) ? true : false;
287 287
 
288
-    if($result) {
288
+    if ($result) {
289 289
       $result = $this->db_get_by_id($this->account_id);
290 290
     }
291 291
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
   public function metamatter_change($change_type, $metamatter, $comment = false, $already_changed = false) {
366 366
     global $debug, $mm_change_legit, $config;
367 367
 
368
-    if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
368
+    if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
369 369
       $debug->error('Ошибка при попытке манипуляции с ММ');
370 370
       return false;
371 371
     }
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 
375 375
     $mm_change_legit = true;
376 376
     // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER);
377
-    if($already_changed) {
377
+    if ($already_changed) {
378 378
       $metamatter_total_delta = 0;
379 379
       $result = -1;
380 380
     } else {
@@ -387,13 +387,13 @@  discard block
 block discarded – undo
387 387
           ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$config->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') .
388 388
         " WHERE `account_id` = {$account_id_safe}"
389 389
       );
390
-      if(!$result) {
390
+      if (!$result) {
391 391
         $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
392 392
       }
393 393
       $result = classSupernova::$db->db_affected_rows();
394 394
     }
395 395
 
396
-    if(empty(core_auth::$user['id'])) {
396
+    if (empty(core_auth::$user['id'])) {
397 397
       $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id);
398 398
       reset($user_list);
399 399
       $user_id_unsafe = key($user_list);
@@ -402,30 +402,30 @@  discard block
 block discarded – undo
402 402
     }
403 403
     $user_id_safe = $this->db->db_escape($user_id_unsafe);
404 404
 
405
-    if(!$result) {
405
+    if (!$result) {
406 406
       $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
407 407
     }
408 408
 
409
-    if(!$already_changed) {
409
+    if (!$already_changed) {
410 410
       $this->account_metamatter += $metamatter;
411 411
       $this->account_metamatter_total += $metamatter_total_delta;
412 412
     }
413 413
 
414
-    if(is_array($comment)) {
414
+    if (is_array($comment)) {
415 415
       $comment = call_user_func_array('sprintf', $comment);
416 416
     }
417 417
 
418 418
     $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe);
419 419
 
420
-    if($metamatter > 0 && !empty($user_id_safe)) {
420
+    if ($metamatter > 0 && !empty($user_id_safe)) {
421 421
       $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", '', true);
422
-      if($old_referral['id']) {
422
+      if ($old_referral['id']) {
423 423
         $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM;
424 424
         doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter_from_metamatter}' WHERE `id` = {$user_id_safe} LIMIT 1;");
425 425
         $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1;", '', true);
426 426
 
427 427
         $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0);
428
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
428
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
429 429
           rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}");
430 430
         }
431 431
       }
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
    * @throws Exception
442 442
    */
443 443
   public function cookieSet($rememberMe = false, $domain = null) {
444
-    if(!$this->is_exists) {
444
+    if (!$this->is_exists) {
445 445
       throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR);
446 446
     }
447 447
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
   // OK v4.1
461 461
   public function cookieClear($domain = null) {
462 462
     // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё
463
-    if(!empty($_COOKIE[$this->cookie_name_impersonate])) {
463
+    if (!empty($_COOKIE[$this->cookie_name_impersonate])) {
464 464
       sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $domain);
465 465
       sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $domain);
466 466
     } else {
@@ -470,14 +470,14 @@  discard block
 block discarded – undo
470 470
 
471 471
   public function cookieLogin(&$rememberMe = false) {
472 472
     // Пытаемся войти по куке
473
-    if(!empty($_COOKIE[$this->cookie_name])) {
474
-      if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) {
473
+    if (!empty($_COOKIE[$this->cookie_name])) {
474
+      if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) {
475 475
         list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]);
476 476
       } else {
477 477
         list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]);
478 478
       }
479 479
 
480
-      if(
480
+      if (
481 481
         $this->db_get_by_id($account_id_unsafe)
482 482
         && ($this->password_encode_for_cookie($this->account_password) == $cookie_password_hash_salted)
483 483
       ) {
Please login to merge, or discard this patch.