Completed
Push — work-fleets ( 71ccb1...0d1d7f )
by SuperNova.WS
06:04
created
includes/classes/functions_template.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         'template_data'     => trim(@file_get_contents($this->template->files[$handle])),
92 92
       );
93 93
 
94
-      $sql = 'INSERT INTO ' . STYLES_TEMPLATE_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
94
+      $sql = 'INSERT INTO '.STYLES_TEMPLATE_DATA_TABLE.' '.$db->sql_build_array('INSERT', $sql_ary);
95 95
       $db->sql_query($sql);
96 96
     }
97 97
   }
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 
139 139
     preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches);
140 140
     $include_blocks = $matches[1];
141
-    if($include_blocks)
141
+    if ($include_blocks)
142 142
     {
143
-      foreach($include_blocks as &$included_file)
143
+      foreach ($include_blocks as &$included_file)
144 144
       {
145 145
         $included_file .= '.tpl.html';
146 146
       }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
       {
170 170
         case 'BEGIN':
171 171
           $this->block_else_level[] = false;
172
-          $compile_blocks[] = '<?php ' . $this->compile_tag_block($block_val[2]) . ' ?>';
172
+          $compile_blocks[] = '<?php '.$this->compile_tag_block($block_val[2]).' ?>';
173 173
         break;
174 174
 
175 175
         case 'BEGINELSE':
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 
180 180
         case 'END':
181 181
           array_pop($this->block_names);
182
-          $compile_blocks[] = '<?php ' . ((array_pop($this->block_else_level)) ? '}' : '}}') . ' ?>';
182
+          $compile_blocks[] = '<?php '.((array_pop($this->block_else_level)) ? '}' : '}}').' ?>';
183 183
         break;
184 184
 
185 185
         case 'IF':
186
-          $compile_blocks[] = '<?php ' . $this->compile_tag_if($block_val[2], false) . ' ?>';
186
+          $compile_blocks[] = '<?php '.$this->compile_tag_if($block_val[2], false).' ?>';
187 187
         break;
188 188
 
189 189
         case 'ELSE':
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         break;
192 192
 
193 193
         case 'ELSEIF':
194
-          $compile_blocks[] = '<?php ' . $this->compile_tag_if($block_val[2], true) . ' ?>';
194
+          $compile_blocks[] = '<?php '.$this->compile_tag_if($block_val[2], true).' ?>';
195 195
         break;
196 196
 
197 197
         case 'ENDIF':
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
         break;
200 200
 
201 201
         case 'DEFINE':
202
-          $compile_blocks[] = '<?php ' . $this->compile_tag_define($block_val[2], true) . ' ?>';
202
+          $compile_blocks[] = '<?php '.$this->compile_tag_define($block_val[2], true).' ?>';
203 203
         break;
204 204
 
205 205
         case 'UNDEFINE':
206
-          $compile_blocks[] = '<?php ' . $this->compile_tag_define($block_val[2], false) . ' ?>';
206
+          $compile_blocks[] = '<?php '.$this->compile_tag_define($block_val[2], false).' ?>';
207 207
         break;
208 208
 
209 209
         case 'INCLUDE':
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             $file = $temp;
235 235
           }
236 236
 
237
-          $compile_blocks[] = '<?php ' . $this->compile_tag_include($temp) . ' ?>';
237
+          $compile_blocks[] = '<?php '.$this->compile_tag_include($temp).' ?>';
238 238
 
239 239
           // No point in checking variable includes
240 240
           if ($file)
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
         break;
245 245
 
246 246
         case 'INCLUDEPHP':
247
-          $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php ' . $this->compile_tag_include_php(array_shift($includephp_blocks)) . ' ?>' : '';
247
+          $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php '.$this->compile_tag_include_php(array_shift($includephp_blocks)).' ?>' : '';
248 248
         break;
249 249
 
250 250
         case 'PHP':
251
-          $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php ' . array_shift($php_blocks) . ' ?>' : '';
251
+          $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php '.array_shift($php_blocks).' ?>' : '';
252 252
         break;
253 253
 
254 254
         default:
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
     for ($i = 0, $size = sizeof($text_blocks); $i < $size; $i++)
264 264
     {
265 265
       $trim_check_text = trim($text_blocks[$i]);
266
-      $template_php .= (!$no_echo) ? (($trim_check_text != '') ? $text_blocks[$i] : '') . ((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '') : (($trim_check_text != '') ? $text_blocks[$i] : '') . ((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '');
266
+      $template_php .= (!$no_echo) ? (($trim_check_text != '') ? $text_blocks[$i] : '').((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '') : (($trim_check_text != '') ? $text_blocks[$i] : '').((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '');
267 267
     }
268 268
 
269 269
     // Remove unused opening/closing tags
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
     // we'll strip out such occurences, minimising such switching
279 279
     if ($no_echo)
280 280
     {
281
-      return "\$$echo_var .= '" . $template_php . "'";
281
+      return "\$$echo_var .= '".$template_php."'";
282 282
     }
283 283
 
284 284
     return $template_php;
@@ -373,30 +373,30 @@  discard block
 block discarded – undo
373 373
 
374 374
       if ($match[2] < 0)
375 375
       {
376
-        $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')';
376
+        $loop_start = '($_'.$tag_args.'_count '.$match[2].' < 0 ? 0 : $_'.$tag_args.'_count '.$match[2].')';
377 377
       }
378 378
       else
379 379
       {
380
-        $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')';
380
+        $loop_start = '($_'.$tag_args.'_count < '.$match[2].' ? $_'.$tag_args.'_count : '.$match[2].')';
381 381
       }
382 382
 
383 383
       if (strlen($match[3]) < 1 || $match[3] == -1)
384 384
       {
385
-        $loop_end = '$_' . $tag_args . '_count';
385
+        $loop_end = '$_'.$tag_args.'_count';
386 386
       }
387 387
       else if ($match[3] >= 0)
388 388
       {
389
-        $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')';
389
+        $loop_end = '('.($match[3] + 1).' > $_'.$tag_args.'_count ? $_'.$tag_args.'_count : '.($match[3] + 1).')';
390 390
       }
391 391
       else //if ($match[3] < -1)
392 392
       {
393
-        $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1);
393
+        $loop_end = '$_'.$tag_args.'_count'.($match[3] + 1);
394 394
       }
395 395
     }
396 396
     else
397 397
     {
398 398
       $loop_start = 0;
399
-      $loop_end = '$_' . $tag_args . '_count';
399
+      $loop_end = '$_'.$tag_args.'_count';
400 400
     }
401 401
 
402 402
     $tag_template_php = '';
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
     if (sizeof($block) < 2)
416 416
     {
417 417
       // Block is not nested.
418
-      $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;";
418
+      $tag_template_php = '$_'.$tag_args."_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;";
419 419
       $varref = "\$this->_tpldata['$tag_args']";
420 420
     }
421 421
     else
@@ -429,10 +429,10 @@  discard block
 block discarded – undo
429 429
       $varref = $this->generate_block_data_ref($namespace, false);
430 430
 
431 431
       // Create the for loop code to iterate over this block.
432
-      $tag_template_php = '$_' . $tag_args . '_count = (isset(' . $varref . ')) ? sizeof(' . $varref . ') : 0;';
432
+      $tag_template_php = '$_'.$tag_args.'_count = (isset('.$varref.')) ? sizeof('.$varref.') : 0;';
433 433
     }
434 434
 
435
-    $tag_template_php .= 'if ($_' . $tag_args . '_count) {';
435
+    $tag_template_php .= 'if ($_'.$tag_args.'_count) {';
436 436
 
437 437
     /**
438 438
     * 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
@@ -444,10 +444,10 @@  discard block
 block discarded – undo
444 444
     * </code>
445 445
     */
446 446
 
447
-    $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){';
447
+    $tag_template_php .= 'for ($_'.$tag_args.'_i = '.$loop_start.'; $_'.$tag_args.'_i < '.$loop_end.'; ++$_'.$tag_args.'_i){';
448 448
 //    $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;';
449
-    $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];';
450
-    $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];';
449
+    $tag_template_php .= '$_'.$tag_args.'_val = &'.$varref.'[$_'.$tag_args.'_i];';
450
+    $tag_template_php .= '$this->_block_value["'.$tag_args.'"] = &'.$varref.'[$_'.$tag_args.'_i];';
451 451
 
452 452
     return $tag_template_php;
453 453
   }
@@ -551,10 +551,10 @@  discard block
 block discarded – undo
551 551
         break;
552 552
 
553 553
         case 'is':
554
-          $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1;
554
+          $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1;
555 555
           $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
556 556
 
557
-          $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1));
557
+          $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1));
558 558
 
559 559
           array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens);
560 560
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
         default:
566 566
           if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs))
567 567
           {
568
-            $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] . '\']');
568
+            $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].'\']');
569 569
           }
570 570
           else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
571 571
           {
@@ -582,20 +582,20 @@  discard block
 block discarded – undo
582 582
               $varref = $this->generate_block_data_ref($namespace, true);
583 583
 
584 584
               // Add the block reference for the last child.
585
-              $varref .= "['" . $block . "']";
585
+              $varref .= "['".$block."']";
586 586
             }
587 587
             else
588 588
             {
589 589
               $varref = '$this->_tpldata';
590 590
 
591 591
               // Add the block reference for the last child.
592
-              $varref .= "['" . $blocks[0] . "']";
592
+              $varref .= "['".$blocks[0]."']";
593 593
             }
594 594
             $token = "sizeof($varref)";
595 595
           }
596 596
           else if (!empty($token))
597 597
           {
598
-            $token = '(' . $token . ')';
598
+            $token = '('.$token.')';
599 599
           }
600 600
 
601 601
         break;
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
     {
608 608
       $tokens = array('false');
609 609
     }
610
-    return (($elseif) ? '} else if (' : 'if (') . (implode(' ', $tokens) . ') { ');
610
+    return (($elseif) ? '} else if (' : 'if (').(implode(' ', $tokens).') { ');
611 611
   }
612 612
 
613 613
   /**
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 
626 626
     if (!$op)
627 627
     {
628
-      return 'unset(' . (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ');';
628
+      return 'unset('.(($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true).'[\''.$match[2].'\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$match[2].'\']').');';
629 629
     }
630 630
 
631 631
     // Are we a string?
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
       $match[4] = $this->compile($match[4]);
638 638
 
639 639
       // Now replace the php code
640
-      $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'";
640
+      $match[4] = "'".str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4])."'";
641 641
     }
642 642
     else
643 643
     {
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
       }
661 661
     }
662 662
 
663
-    return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ' = ' . $match[4] . ';';
663
+    return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true).'[\''.$match[2].'\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$match[2].'\']').' = '.$match[4].';';
664 664
   }
665 665
 
666 666
   /**
@@ -801,24 +801,24 @@  discard block
 block discarded – undo
801 801
       // Build up the string with everything but the last child.
802 802
       for ($i = 0; $i < $blockcount; $i++)
803 803
       {
804
-        $varref .= "['" . $blocks[$i] . "'][\$_" . $blocks[$i] . '_i]';
804
+        $varref .= "['".$blocks[$i]."'][\$_".$blocks[$i].'_i]';
805 805
       }
806 806
       // Add the block reference for the last child.
807
-      $varref .= "['" . $blocks[$blockcount] . "']";
807
+      $varref .= "['".$blocks[$blockcount]."']";
808 808
       // Add the iterator for the last child if requried.
809 809
       if ($include_last_iterator)
810 810
       {
811
-        $varref .= '[$_' . $blocks[$blockcount] . '_i]';
811
+        $varref .= '[$_'.$blocks[$blockcount].'_i]';
812 812
       }
813 813
       return $varref;
814 814
     }
815 815
     else if ($include_last_iterator)
816 816
     {
817
-      return '$_'. $blocks[$blockcount] . '_val';
817
+      return '$_'.$blocks[$blockcount].'_val';
818 818
     }
819 819
     else
820 820
     {
821
-      return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']';
821
+      return '$_'.$blocks[$blockcount - 1].'_val[\''.$blocks[$blockcount].'\']';
822 822
     }
823 823
   }
824 824
 
@@ -828,14 +828,14 @@  discard block
 block discarded – undo
828 828
   */
829 829
   function compile_write($handle, $data)
830 830
   {
831
-    $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX;
831
+    $filename = $this->template->cachepath.str_replace('/', '.', $this->template->filename[$handle]).DOT_PHP_EX;
832 832
 
833
-    $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data);
833
+    $data = "<?php if (!defined('INSIDE')) exit;".((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>'.$data);
834 834
 
835 835
     if ($fp = @fopen($filename, 'wb'))
836 836
     {
837 837
       @flock($fp, LOCK_EX);
838
-      @fwrite ($fp, $data);
838
+      @fwrite($fp, $data);
839 839
       @flock($fp, LOCK_UN);
840 840
       @fclose($fp);
841 841
 
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
   */
853 853
   private function minify($html)
854 854
   {
855
-    if(!classSupernova::$config->tpl_minifier)
855
+    if (!classSupernova::$config->tpl_minifier)
856 856
     {
857 857
       return $html;
858 858
     }
@@ -862,14 +862,14 @@  discard block
 block discarded – undo
862 862
     $html = preg_replace('/(<script[^>]*?>.*?<\/script>)/si', '#pre#', $html);
863 863
     $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags
864 864
     $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space
865
-    if(!empty($pre[0]))
865
+    if (!empty($pre[0]))
866 866
     {
867
-      foreach($pre[0] as $tag)
867
+      foreach ($pre[0] as $tag)
868 868
       {
869 869
         $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside
870 870
         $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one
871 871
         $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one
872
-        $html = preg_replace('/#pre#/', $tag, $html,1);
872
+        $html = preg_replace('/#pre#/', $tag, $html, 1);
873 873
       }
874 874
     }
875 875
 
Please login to merge, or discard this patch.
includes/classes/sn_module_payment.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
   public function compile_request($request) {
451 451
     global $user;
452 452
 
453
-    if(!(classSupernova::$auth->account instanceof Account)) {
453
+    if (!(classSupernova::$auth->account instanceof Account)) {
454 454
       // TODO - throw new Exception(lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT);
455 455
     }
456 456
     $this->account = classSupernova::$auth->account;
@@ -471,15 +471,15 @@  discard block
 block discarded – undo
471 471
     $this->payment_currency = classSupernova::$config->payment_currency_default;
472 472
     $this->payment_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_currency);
473 473
 
474
-    if(empty($this->payment_external_currency) && !empty($this->config['currency'])) {
474
+    if (empty($this->payment_external_currency) && !empty($this->config['currency'])) {
475 475
       $this->payment_external_currency = $this->config['currency'];
476 476
     }
477
-    if(empty($this->payment_external_currency)) {
477
+    if (empty($this->payment_external_currency)) {
478 478
       throw new Exception(classLocale::$lang['pay_error_internal_no_external_currency_set'], SN_PAYMENT_ERROR_INTERNAL_NO_EXTERNAL_CURRENCY_SET);
479 479
     }
480 480
 
481 481
     $this->payment_external_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_external_currency);
482
-    if($this->payment_external_amount < 0.01) {
482
+    if ($this->payment_external_amount < 0.01) {
483 483
       throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT);
484 484
     }
485 485
 
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
     $this->generate_description();
489 489
 
490 490
     $this->db_insert();
491
-    if(!$this->is_exists) {
491
+    if (!$this->is_exists) {
492 492
       throw new Exception(classLocale::$lang['pay_msg_request_error_db_payment_create'], SN_PAYMENT_REQUEST_DB_ERROR_PAYMENT_CREATE);
493 493
     }
494 494
   }
@@ -500,26 +500,26 @@  discard block
 block discarded – undo
500 500
    * @throws Exception
501 501
    */
502 502
   protected function payment_request_process($options = array()) {
503
-    if(!$this->manifest['active']) {
503
+    if (!$this->manifest['active']) {
504 504
       throw new Exception(classLocale::$lang['pay_msg_module_disabled'], SN_MODULE_DISABLED);
505 505
     }
506 506
 
507 507
     // Если есть payment_id - загружаем под него данные
508
-    if(!empty($this->payment_params['payment_id'])) {
508
+    if (!empty($this->payment_params['payment_id'])) {
509 509
       $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']);
510
-      if(!$this->request_payment_id) {
510
+      if (!$this->request_payment_id) {
511 511
         throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG);
512 512
       }
513 513
 
514
-      if(!$this->db_get_by_id($this->request_payment_id)) {
514
+      if (!$this->db_get_by_id($this->request_payment_id)) {
515 515
         throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG);
516 516
       }
517 517
 
518 518
       // Проверяем - был ли этот платеж обработан?
519 519
       // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed
520
-      if($this->payment_status != PAYMENT_STATUS_NONE) {
520
+      if ($this->payment_status != PAYMENT_STATUS_NONE) {
521 521
         sn_db_transaction_rollback();
522
-        sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id);
522
+        sys_redirect(SN_ROOT_VIRTUAL.'metamatter.php?payment_id='.$this->payment_id);
523 523
         die();
524 524
       }
525 525
     }
@@ -527,89 +527,89 @@  discard block
 block discarded – undo
527 527
     // Пытаемся получить из запроса ИД аккаунта
528 528
     $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0;
529 529
     // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id
530
-    if(empty($request_account_id) && !empty($this->payment_account_id)) {
530
+    if (empty($request_account_id) && !empty($this->payment_account_id)) {
531 531
       $request_account_id = $this->payment_account_id;
532 532
     }
533 533
     // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать
534
-    if(empty($request_account_id)) {
534
+    if (empty($request_account_id)) {
535 535
       // TODO - аккаунт
536 536
       throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
537 537
     }
538 538
     // Если нет записи в таблице - тогда берем payment_account_id из запроса
539
-    if(empty($this->payment_account_id)) {
539
+    if (empty($this->payment_account_id)) {
540 540
       $this->payment_account_id = $request_account_id;
541 541
     }
542 542
     // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать
543
-    if($this->payment_account_id != $request_account_id) {
543
+    if ($this->payment_account_id != $request_account_id) {
544 544
       // TODO - Поменять сообщение об ошибке
545 545
       throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
546 546
     }
547 547
     // Проверяем существование аккаунта с данным ИД
548
-    if(!$this->account->db_get_by_id($this->payment_account_id)) {
549
-      throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'] . ' ID ' . $this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
548
+    if (!$this->account->db_get_by_id($this->payment_account_id)) {
549
+      throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'].' ID '.$this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
550 550
     }
551 551
 
552 552
     // TODO Проверка на сервер_ид - как бы и не нужна, наверное?
553
-    if(!empty($this->payment_params['server_id'])) {
553
+    if (!empty($this->payment_params['server_id'])) {
554 554
       $this->request_server_id = sys_get_param_str($this->payment_params['server_id']);
555
-      if(SN_ROOT_VIRTUAL != $this->request_server_id) {
556
-        throw new Exception(classLocale::$lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG);
555
+      if (SN_ROOT_VIRTUAL != $this->request_server_id) {
556
+        throw new Exception(classLocale::$lang['pay_msg_request_server_wrong']." {$this->request_server_id} вместо ".SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG);
557 557
       }
558 558
     }
559 559
 
560 560
     // Сверка количества оплаченной ММ с учётом бонусов
561
-    if(!empty($this->payment_params['payment_dark_matter_gained'])) {
561
+    if (!empty($this->payment_params['payment_dark_matter_gained'])) {
562 562
       $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']);
563
-      if($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) {
564
-        throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'] . " пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID);
563
+      if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) {
564
+        throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid']." пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID);
565 565
       }
566 566
       empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false;
567 567
     }
568
-    if(empty($this->payment_dark_matter_paid)) {
568
+    if (empty($this->payment_dark_matter_paid)) {
569 569
       // TODO - обратный расчёт из gained
570 570
     }
571 571
 
572 572
     // Проверка наличия внешнего ИД платежа
573
-    if(!empty($this->payment_params['payment_external_id'])) {
573
+    if (!empty($this->payment_params['payment_external_id'])) {
574 574
       $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']);
575
-      if(empty($request_payment_external_id)) {
575
+      if (empty($request_payment_external_id)) {
576 576
         throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG);
577
-      } elseif(!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) {
577
+      } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) {
578 578
         // TODO - Может быть поменять сообщение
579 579
         throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG);
580 580
       }
581 581
       $this->payment_external_id = $request_payment_external_id;
582 582
     }
583 583
     // Сверка суммы, запрошенной СН к оплате
584
-    if(!empty($this->payment_params['payment_external_money'])) {
584
+    if (!empty($this->payment_params['payment_external_money'])) {
585 585
       $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']);
586
-      if($request_money_out != $this->payment_external_amount && $this->is_loaded) {
587
-        throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
586
+      if ($request_money_out != $this->payment_external_amount && $this->is_loaded) {
587
+        throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid']." пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
588 588
       }
589 589
       empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false;
590 590
     }
591 591
     // Заполняем поле валюты платёжной системы
592
-    if(!empty($this->payment_params['payment_external_currency'])) {
592
+    if (!empty($this->payment_params['payment_external_currency'])) {
593 593
       $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']);
594
-      if(empty($this->payment_external_currency)) {
594
+      if (empty($this->payment_external_currency)) {
595 595
         // TODO - поменять сообщение
596
-        throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
596
+        throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid']." {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
597 597
       }
598 598
     }
599
-    if(empty($this->payment_external_currency)) {
599
+    if (empty($this->payment_external_currency)) {
600 600
       $this->payment_external_currency = $this->config['currency'];
601 601
     }
602 602
 
603 603
     // Заполнение внутренней суммы и валюты из внешних данных
604
-    if(empty($this->payment_currency)) {
604
+    if (empty($this->payment_currency)) {
605 605
       $this->payment_currency = classSupernova::$config->payment_currency_default;
606 606
     }
607
-    if(empty($this->payment_amount) && !empty($this->payment_external_currency)) {
607
+    if (empty($this->payment_amount) && !empty($this->payment_external_currency)) {
608 608
       $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency);
609 609
     }
610 610
 
611 611
     // TODO - Тестовый режим
612
-    if(!empty($this->payment_params['test'])) {
612
+    if (!empty($this->payment_params['test'])) {
613 613
       $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']);
614 614
     }
615 615
 
@@ -636,21 +636,21 @@  discard block
 block discarded – undo
636 636
     sn_db_transaction_start();
637 637
     try {
638 638
       $response = $this->payment_request_process();
639
-    } catch(Exception $e) {
639
+    } catch (Exception $e) {
640 640
       $response['result'] = $e->getCode();
641 641
       $response['message'] = $e->getMessage();
642 642
     }
643 643
 
644
-    if($response['result'] == SN_PAYMENT_REQUEST_OK) {
644
+    if ($response['result'] == SN_PAYMENT_REQUEST_OK) {
645 645
       sn_db_transaction_commit();
646
-      classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT);
646
+      classSupernova::$debug->warning('Результат операции: код '.$response['result'].' сообщение "'.$response['message'].'"', 'Успешный платёж', LOG_INFO_PAYMENT);
647 647
     } else {
648 648
       sn_db_transaction_rollback();
649
-      classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Ошибка платежа', LOG_INFO_PAYMENT, true);
649
+      classSupernova::$debug->warning('Результат операции: код '.$response['result'].' сообщение "'.$response['message'].'"', 'Ошибка платежа', LOG_INFO_PAYMENT, true);
650 650
     }
651 651
 
652 652
     // Переводим код результата из СН в код платежной системы
653
-    if(is_array($this->result_translations) && !empty($this->result_translations)) {
653
+    if (is_array($this->result_translations) && !empty($this->result_translations)) {
654 654
       $response['result'] = isset($this->result_translations[$response['result']]) ? $this->result_translations[$response['result']] : $this->result_translations[SN_PAYMENT_REQUEST_UNDEFINED_ERROR];
655 655
     }
656 656
 
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
     $currency_from = strtolower($currency_from);
674 674
     $currency_to = strtolower($currency_to);
675 675
 
676
-    if($currency_from != $currency_to) {
676
+    if ($currency_from != $currency_to) {
677 677
       $exchange_from = get_exchange_rate($currency_from);
678 678
       $exchange_to = get_exchange_rate($currency_to);
679 679
 
@@ -697,10 +697,10 @@  discard block
 block discarded – undo
697 697
   public static function bonus_calculate($dark_matter, $direct = true, $return_bonus = false) {
698 698
     $bonus = 0;
699 699
     $dark_matter_new = $dark_matter;
700
-    if(!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) {
701
-      if($direct) {
702
-        foreach(self::$bonus_table as $dm_for_bonus => $multiplier) {
703
-          if($dm_for_bonus <= $dark_matter) {
700
+    if (!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) {
701
+      if ($direct) {
702
+        foreach (self::$bonus_table as $dm_for_bonus => $multiplier) {
703
+          if ($dm_for_bonus <= $dark_matter) {
704 704
             $dark_matter_new = $dark_matter * (1 + $multiplier);
705 705
             $bonus = $multiplier;
706 706
           } else {
@@ -708,9 +708,9 @@  discard block
 block discarded – undo
708 708
           }
709 709
         }
710 710
       } else {
711
-        foreach(self::$bonus_table as $dm_for_bonus => $multiplier) {
711
+        foreach (self::$bonus_table as $dm_for_bonus => $multiplier) {
712 712
           $temp = $dm_for_bonus * (1 + $multiplier);
713
-          if($dark_matter >= $temp) {
713
+          if ($dark_matter >= $temp) {
714 714
             $dark_matter_new = round($dark_matter / (1 + $multiplier));
715 715
             $bonus = $multiplier;
716 716
           } else {
@@ -764,30 +764,30 @@  discard block
 block discarded – undo
764 764
     );
765 765
 
766 766
     $replace = false;
767
-    if($this->payment_id) {
767
+    if ($this->payment_id) {
768 768
       $payment['payment_id'] = $this->payment_id;
769 769
       $replace = true;
770 770
     }
771 771
 
772 772
     $query = array();
773
-    foreach($payment as $key => $value) {
774
-      $value = is_string($value) ? '"' . db_escape($value) . '"' : $value;
773
+    foreach ($payment as $key => $value) {
774
+      $value = is_string($value) ? '"'.db_escape($value).'"' : $value;
775 775
       $query[] = "`{$key}` = {$value}";
776 776
     }
777 777
 
778
-    $this->db->doquery(($replace ? 'REPLACE' : 'INSERT') . ' INTO `{{payment}}` SET ' . implode(',', $query) . ';');
778
+    $this->db->doquery(($replace ? 'REPLACE' : 'INSERT').' INTO `{{payment}}` SET '.implode(',', $query).';');
779 779
 
780 780
     return $this->db_get_by_id($this->db->db_insert_id());
781 781
   }
782 782
 
783 783
 
784 784
   function payment_adjust_mm_new() {
785
-    if(!$this->payment_test) {
785
+    if (!$this->payment_test) {
786 786
       // Not a test payment. Adding DM to account
787 787
       $this->account = new Account($this->db);
788 788
       $this->account->db_get_by_id($this->payment_account_id);
789 789
       $result = $this->account->metamatter_change(RPG_PURCHASE, $this->payment_dark_matter_gained, $this->payment_comment);
790
-      if(!$result) {
790
+      if (!$result) {
791 791
         throw new Exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST);
792 792
       }
793 793
     }
@@ -796,25 +796,25 @@  discard block
 block discarded – undo
796 796
   function payment_cancel(&$payment) {
797 797
     die('{НЕ РАБОТАЕТ! СООБЩИТЕ АДМИНИСТРАЦИИ!}');
798 798
 
799
-    if(!isset($payment['payment_status'])) {
799
+    if (!isset($payment['payment_status'])) {
800 800
       throw new exception(classLocale::$lang['pay_msg_request_payment_not_found'], SN_PAYMENT_REQUEST_ORDER_NOT_FOUND);
801 801
     }
802 802
 
803
-    if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
804
-      $safe_comment = db_escape($payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment']);
803
+    if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
804
+      $safe_comment = db_escape($payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'].' '.$payment['payment_comment']);
805 805
 
806
-      if(!$payment['payment_test']) {
806
+      if (!$payment['payment_test']) {
807 807
         $result = $this->account->metamatter_change(RPG_PURCHASE_CANCEL, -$payment['payment_dark_matter_gained'], $payment['payment_comment']);
808
-        if(!$result) {
808
+        if (!$result) {
809 809
           throw new exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST);
810 810
         }
811 811
       }
812 812
       $payment['payment_status'] = PAYMENT_STATUS_CANCELED;
813 813
       db_payment_update($payment, $safe_comment);
814 814
       throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_complete'], SN_PAYMENT_REQUEST_OK);
815
-    } elseif($payment['payment_status'] == PAYMENT_STATUS_CANCELED) {
815
+    } elseif ($payment['payment_status'] == PAYMENT_STATUS_CANCELED) {
816 816
       throw new exception(classLocale::$lang['pay_msg_request_payment_cancelled_already'], SN_PAYMENT_REQUEST_OK);
817
-    } elseif($payment['payment_status'] == PAYMENT_STATUS_NONE) {
817
+    } elseif ($payment['payment_status'] == PAYMENT_STATUS_NONE) {
818 818
       throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_not_complete'], SN_PAYMENT_REQUEST_PAYMENT_NOT_COMPLETE);
819 819
     }
820 820
   }
@@ -828,8 +828,8 @@  discard block
 block discarded – undo
828 828
 
829 829
   protected function db_complete_payment() {
830 830
     // TODO - поле payment_processed
831
-    if($this->payment_status == PAYMENT_STATUS_NONE) {
832
-      if(!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) {
831
+    if ($this->payment_status == PAYMENT_STATUS_NONE) {
832
+      if (!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) {
833 833
         $this->payment_adjust_mm_new();
834 834
         $this->payment_status = PAYMENT_STATUS_COMPLETE;
835 835
       } else {
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
   protected function db_assign_payment($payment = null) {
877 877
     $this->payment_reset();
878 878
 
879
-    if(is_array($payment) && isset($payment['payment_id'])) {
879
+    if (is_array($payment) && isset($payment['payment_id'])) {
880 880
       $this->payment_id = $payment['payment_id'];
881 881
       $this->payment_status = $payment['payment_status'];
882 882
       $this->payment_date = $payment['payment_date'];
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
   protected function generate_description() {
919 919
     // TODO - системная локализация
920 920
     $this->description_generated = array(
921
-      PAYMENT_DESCRIPTION_100 => substr("{$this->payment_dark_matter_gained} ММ аккаунт [{$this->account->account_name}] ID {$this->account->account_id} на " . SN_ROOT_VIRTUAL, 0, 100),
922
-      PAYMENT_DESCRIPTION_250 => substr("Оплата {$this->payment_dark_matter_gained} ММ для аккаунта [{$this->payment_user_name}] ID {$this->payment_user_id} на сервере " . SN_ROOT_VIRTUAL, 0, 250),
923
-      PAYMENT_DESCRIPTION_MAX => ($this->payment_test ? "ТЕСТОВЫЙ ПЛАТЕЖ! " : '') .
924
-        "Платеж от аккаунта '{$this->payment_account_name}' ID {$this->payment_account_id} игрока '{$this->payment_user_name}' ID {$this->payment_user_id} на сервере " . SN_ROOT_VIRTUAL .
925
-        " сумма {$this->payment_amount} {$this->payment_currency} за {$this->payment_dark_matter_paid} ММ (начислено {$this->payment_dark_matter_gained} ММ)" .
921
+      PAYMENT_DESCRIPTION_100 => substr("{$this->payment_dark_matter_gained} ММ аккаунт [{$this->account->account_name}] ID {$this->account->account_id} на ".SN_ROOT_VIRTUAL, 0, 100),
922
+      PAYMENT_DESCRIPTION_250 => substr("Оплата {$this->payment_dark_matter_gained} ММ для аккаунта [{$this->payment_user_name}] ID {$this->payment_user_id} на сервере ".SN_ROOT_VIRTUAL, 0, 250),
923
+      PAYMENT_DESCRIPTION_MAX => ($this->payment_test ? "ТЕСТОВЫЙ ПЛАТЕЖ! " : '').
924
+        "Платеж от аккаунта '{$this->payment_account_name}' ID {$this->payment_account_id} игрока '{$this->payment_user_name}' ID {$this->payment_user_id} на сервере ".SN_ROOT_VIRTUAL.
925
+        " сумма {$this->payment_amount} {$this->payment_currency} за {$this->payment_dark_matter_paid} ММ (начислено {$this->payment_dark_matter_gained} ММ)".
926 926
         " через '{$this->manifest['name']}' сумма {$this->payment_external_amount} {$this->payment_external_currency}",
927 927
     );
928 928
   }
Please login to merge, or discard this patch.
includes/classes/db_mysql_v4.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
     !mysql_select_db($settings['name'])
53 53
       ? classSupernova::$debug->error_fatal('DB error - cannot find DB on server', $this->mysql_error())
54 54
       : false;
55
-    !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL ' . self::DB_MYSQL_TRANSACTION_REPEATABLE_READ . ';')
55
+    !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL '.self::DB_MYSQL_TRANSACTION_REPEATABLE_READ.';')
56 56
       ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level', $this->mysql_error())
57 57
       : false;
58 58
 
Please login to merge, or discard this patch.
includes/classes/UnitResourceLoot.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
   public static function _init($group_name = '') {
27 27
     parent::_init($group_name);
28 28
 
29
-    foreach(static::$_group_unit_id_list as $resource_id) {
29
+    foreach (static::$_group_unit_id_list as $resource_id) {
30 30
       static::$_group_pnames[$resource_id] = pname_resource_name($resource_id);
31 31
     }
32 32
 
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 
49 49
     !is_array($resource_array) ? $resource_array = array() : false;
50 50
 
51
-    foreach($resource_array as $resource_id => $resource_actual_delta) {
52
-      if(!$resource_actual_delta) {
51
+    foreach ($resource_array as $resource_id => $resource_actual_delta) {
52
+      if (!$resource_actual_delta) {
53 53
         // No delta - no changes
54 54
         continue;
55 55
       }
56 56
 
57
-      $result[$prefix . static::$_group_pnames[$resource_id]] = $resource_actual_delta;
57
+      $result[$prefix.static::$_group_pnames[$resource_id]] = $resource_actual_delta;
58 58
     }
59 59
 
60 60
     return $result;
Please login to merge, or discard this patch.
includes/classes/db_mysql_v5.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,19 +39,19 @@
 block discarded – undo
39 39
 
40 40
     @$this->link = mysqli_connect($settings['server'], $settings['user'], $settings['pass'], $settings['name']);
41 41
     if (!is_object($this->link) || $this->link->connect_error) {
42
-      classSupernova::$debug->error_fatal('DB Error - cannot connect to server error #' . $this->link->connect_errno, $this->link->connect_error);
42
+      classSupernova::$debug->error_fatal('DB Error - cannot connect to server error #'.$this->link->connect_errno, $this->link->connect_error);
43 43
     }
44 44
 
45 45
 
46 46
     !$this->mysql_query("/*!40101 SET NAMES 'utf8' */")
47
-      ? classSupernova::$debug->error_fatal('DB error - cannot set names 1 error #' . $this->link->errno, $this->link->error)
47
+      ? classSupernova::$debug->error_fatal('DB error - cannot set names 1 error #'.$this->link->errno, $this->link->error)
48 48
       : false;
49 49
     !$this->mysql_query("SET NAMES 'utf8';")
50
-      ? classSupernova::$debug->error_fatal('DB error - cannot set names 2 error #' . $this->link->errno, $this->link->error)
50
+      ? classSupernova::$debug->error_fatal('DB error - cannot set names 2 error #'.$this->link->errno, $this->link->error)
51 51
       : false;
52 52
 
53
-    !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL ' . self::DB_MYSQL_TRANSACTION_REPEATABLE_READ . ';')
54
-      ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level error #' . $this->link->errno, $this->link->error)
53
+    !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL '.self::DB_MYSQL_TRANSACTION_REPEATABLE_READ.';')
54
+      ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level error #'.$this->link->errno, $this->link->error)
55 55
       : false;
56 56
 
57 57
     $this->connected = true;
Please login to merge, or discard this patch.
includes/classes/user_options.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -122,31 +122,31 @@  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
-        $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')";
128
+        $this->to_write[$key] = "({$this->user_id}, '".db_escape($key)."', '".db_escape($value)."')";
129 129
       }
130 130
 
131
-      doquery("REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) VALUES " . implode(',', $this->to_write));
131
+      doquery("REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) VALUES ".implode(',', $this->to_write));
132 132
 
133 133
       $this->to_write = array();
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
       // pdump("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") ");
144 144
 
145 145
       $this->to_delete = array();
146 146
       $update_cache = true;
147 147
     }
148 148
 
149
-    if($update_cache) {
149
+    if ($update_cache) {
150 150
       global $sn_cache;
151 151
 
152 152
       $field_name = $this->cached_name();
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
     $this->load();
168 168
   }
169 169
   protected function cached_name() {
170
-    return 'options_' . $this->user_id;
170
+    return 'options_'.$this->user_id;
171 171
   }
172 172
 
173 173
   protected function load() {
174 174
     global $sn_cache;
175 175
 
176
-    if($this->loaded) {
176
+    if ($this->loaded) {
177 177
       return;
178 178
     }
179 179
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     $this->to_write = array();
182 182
     $this->to_delete = array();
183 183
 
184
-    if(!$this->user_id) {
184
+    if (!$this->user_id) {
185 185
       $this->loaded = true;
186 186
       return;
187 187
     }
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
     $field_name = $this->cached_name();
190 190
     $a_data = $sn_cache->$field_name;
191 191
 
192
-    if(!empty($a_data)) {
192
+    if (!empty($a_data)) {
193 193
       $this->data = array_replace_recursive($this->data, $a_data);
194 194
       return;
195 195
     }
196 196
 
197 197
     $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
198
-    while($row = db_fetch($query)) {
198
+    while ($row = db_fetch($query)) {
199 199
       // $this->data[$row['option_id']] = $row['value'];
200 200
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
201 201
     }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
   }
273 273
 
274 274
   protected function cached_name() {
275
-    return 'options_' . $this->user_id;
275
+    return 'options_'.$this->user_id;
276 276
   }
277 277
 
278 278
   // TODO - serialize/unserialize options
@@ -280,14 +280,14 @@  discard block
 block discarded – undo
280 280
     // Если в массиве индекса только один элемент - значит это просто индекс
281 281
     is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false;
282 282
 
283
-    if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) {
283
+    if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) {
284 284
       $this->load();
285 285
     }
286 286
 
287
-    if(is_array($option_id)) {
287
+    if (is_array($option_id)) {
288 288
       $result = $this->data;
289
-      foreach($option_id as $sub_key) {
290
-        if(!isset($result) || !isset($result[$sub_key])) {
289
+      foreach ($option_id as $sub_key) {
290
+        if (!isset($result) || !isset($result[$sub_key])) {
291 291
           $result = null;
292 292
           break;
293 293
         }
@@ -307,12 +307,12 @@  discard block
 block discarded – undo
307 307
   public function __set($option, $value = null) {
308 308
     global $sn_cache;
309 309
 
310
-    if(empty($option) || !$this->user_id) {
310
+    if (empty($option) || !$this->user_id) {
311 311
       return;
312 312
     }
313 313
 
314 314
     // Если в массиве индекса только один элемент - значит это просто индекс
315
-    if(is_array($option) && count($option) == 1) {
315
+    if (is_array($option) && count($option) == 1) {
316 316
       // Разворачиваем его в индекс
317 317
       $option = array(reset($option) => $value);
318 318
       unset($value);
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
 
322 322
     $to_write = array();
323 323
     // Адресация многомерного массива через массив индексов в $option
324
-    if(is_array($option) && isset($value)) {
324
+    if (is_array($option) && isset($value)) {
325 325
       $a_data = &$this->data;
326
-      foreach($option as $option_id) {
326
+      foreach ($option as $option_id) {
327 327
         !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false;
328 328
         $a_data = &$a_data[$option_id];
329 329
       }
330
-      if($a_data != $value) {
330
+      if ($a_data != $value) {
331 331
         $a_data = $value;
332 332
         $to_write[reset($option)] = null;
333 333
       }
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
       // Пакетная запись из массива ключ -> значение
336 336
       !is_array($option) ? $option = array($option => $value) : false;
337 337
 
338
-      foreach($option as $option_id => $option_value) {
339
-        if($this->data[$option_id] !== $option_value) {
338
+      foreach ($option as $option_id => $option_value) {
339
+        if ($this->data[$option_id] !== $option_value) {
340 340
           // TODO - вынести отдельно в обработчик
341
-          if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON &&  $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) {
342
-            sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
341
+          if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) {
342
+            sn_setcookie(SN_COOKIE.'_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
343 343
           }
344 344
 
345 345
           $this->data[$option_id] = $option_value;
@@ -348,42 +348,42 @@  discard block
 block discarded – undo
348 348
       }
349 349
     }
350 350
 
351
-    if(!empty($to_write)) {
351
+    if (!empty($to_write)) {
352 352
       $field_name = $this->cached_name();
353 353
       $sn_cache->$field_name = $this->data;
354 354
 
355
-      foreach($to_write as $option_id => &$option_value) {
355
+      foreach ($to_write as $option_id => &$option_value) {
356 356
         $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД
357
-        $to_write[$option_id] = "({$this->user_id}, '" . db_escape($option_id) . "', '" . db_escape($option_value) . "')";
357
+        $to_write[$option_id] = "({$this->user_id}, '".db_escape($option_id)."', '".db_escape($option_value)."')";
358 358
       }
359 359
 
360
-      doquery("REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) VALUES " . implode(',', $to_write));
360
+      doquery("REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) VALUES ".implode(',', $to_write));
361 361
     }
362 362
   }
363 363
 
364 364
   protected function load() {
365 365
     global $sn_cache;
366 366
 
367
-    if($this->loaded) {
367
+    if ($this->loaded) {
368 368
       return;
369 369
     }
370 370
 
371 371
     $this->data = $this->defaults;
372 372
 
373
-    if(!$this->user_id) {
373
+    if (!$this->user_id) {
374 374
       return;
375 375
     }
376 376
 
377 377
     $field_name = $this->cached_name();
378 378
     $a_data = $sn_cache->$field_name;
379 379
 
380
-    if(!empty($a_data)) {
380
+    if (!empty($a_data)) {
381 381
       $this->data = array_replace($this->data, $a_data);
382 382
       return;
383 383
     }
384 384
 
385 385
     $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
386
-    while($row = db_fetch($query)) {
386
+    while ($row = db_fetch($query)) {
387 387
       // $this->data[$row['option_id']] = $row['value'];
388 388
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
389 389
     }
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
     return $this->__get($offset);
400 400
   }
401 401
   public function offsetSet($offset, $value) {
402
-    if(!is_null($offset)) {
402
+    if (!is_null($offset)) {
403 403
       // $this->data[$offset] = $value;
404 404
       $this->__set($offset, $value);
405 405
     } else {
Please login to merge, or discard this patch.
includes/classes/PlayerToAccountTranslate.php 1 patch
Spacing   +6 added lines, -6 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
     }
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
     $account_translation = array();
89 89
 
90 90
     $query = static::$db->doquery(
91
-      "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " .
92
-      ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') .
91
+      "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} ".
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.
includes/classes/Account.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
     $this->reset();
80 80
     $this->db = is_object($db) ? $db : classSupernova::$db;
81 81
 
82
-    foreach($this->table_check as $table_name) {
83
-      if(empty($this->db->table_list[$table_name])) {
82
+    foreach ($this->table_check as $table_name) {
83
+      if (empty($this->db->table_list[$table_name])) {
84 84
         die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br />
85 85
               В противном случае - сообщите Администрации сервера об ошибке.<br/>
86 86
               Не хватает таблицы для работы системы авторизации: ' . $table_name);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
    */
105 105
   // OK v4.6
106 106
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
107
-    if(!$this->password_check($old_password_unsafe)) {
107
+    if (!$this->password_check($old_password_unsafe)) {
108 108
       return false;
109 109
     }
110 110
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
   // OK v4.5
126 126
   public function assign_from_db_row($row) {
127 127
     $this->reset();
128
-    if(empty($row) || !is_array($row)) {
128
+    if (empty($row) || !is_array($row)) {
129 129
       return false;
130 130
     }
131 131
     $this->account_id = $row['account_id'];
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
         `account_email` = LOWER('{$email_safe}'),
243 243
         `account_language` = '{$language_safe}'"
244 244
     );
245
-    if(!$result) {
245
+    if (!$result) {
246 246
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
247 247
     }
248 248
 
249
-    if(!($account_id = $this->db->db_insert_id())) {
249
+    if (!($account_id = $this->db->db_insert_id())) {
250 250
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
251 251
     }
252 252
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
       WHERE `account_id` = '{$account_id_safe}'"
277 277
     ) ? true : false;
278 278
 
279
-    if($result) {
279
+    if ($result) {
280 280
       $result = $this->db_get_by_id($this->account_id);
281 281
     }
282 282
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
   public function metamatter_change($change_type, $metamatter, $comment = '', $already_changed = false) {
364 364
     global $mm_change_legit;
365 365
 
366
-    if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
366
+    if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
367 367
       classSupernova::$debug->error('Ошибка при попытке манипуляции с ММ');
368 368
 
369 369
       return false;
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 
374 374
     $mm_change_legit = true;
375 375
     // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER);
376
-    if($already_changed) {
376
+    if ($already_changed) {
377 377
       $metamatter_total_delta = 0;
378 378
       $result = -1;
379 379
     } else {
@@ -383,17 +383,17 @@  discard block
 block discarded – undo
383 383
       $result = $this->db->doquery(
384 384
         "UPDATE {{account}}
385 385
         SET
386
-          `account_metamatter` = `account_metamatter` + '{$metamatter}'" .
387
-        ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') .
386
+          `account_metamatter` = `account_metamatter` + '{$metamatter}'".
387
+        ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->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
         classSupernova::$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
       classSupernova::$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 = db_referral_get_by_id($user_id_safe);
422
-      if($old_referral['id']) {
422
+      if ($old_referral['id']) {
423 423
         $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM;
424 424
         db_referral_update_dm($user_id_safe, $dark_matter_from_metamatter);
425 425
         $new_referral = db_referral_get_by_id($user_id_safe);
426 426
 
427 427
         $partner_bonus = floor($new_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) : 0);
428
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) {
428
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$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
       }
Please login to merge, or discard this patch.
includes/classes/module.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
   }
74 74
 
75 75
   function loadModuleRootConfig() {
76
-    require SN_ROOT_PHYSICAL . 'config.php';
76
+    require SN_ROOT_PHYSICAL.'config.php';
77 77
 
78
-    $module_config_array = get_class($this) . '_config';
79
-    if(!empty($$module_config_array) && is_array($$module_config_array)) {
78
+    $module_config_array = get_class($this).'_config';
79
+    if (!empty($$module_config_array) && is_array($$module_config_array)) {
80 80
       $this->config = $$module_config_array;
81 81
 
82 82
       return true;
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
 
95 95
     // TODO: Load configuration from DB. Manifest setting
96 96
     // Trying to load configuration from file
97
-    if(!$config_exists = $this->loadModuleRootConfig()) {
97
+    if (!$config_exists = $this->loadModuleRootConfig()) {
98 98
       // Конфигурация может лежать в config_path в манифеста или в корне модуля
99
-      if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) {
99
+      if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'].'/config.php')) {
100 100
         $config_exists = true;
101
-      } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) {
101
+      } elseif (file_exists($config_filename = dirname($filename).'/config.php')) {
102 102
         $config_exists = true;
103 103
       }
104 104
 
105
-      if($config_exists) {
105
+      if ($config_exists) {
106 106
         include($config_filename);
107
-        $module_config_array = $class_module_name . '_config';
107
+        $module_config_array = $class_module_name.'_config';
108 108
         $this->config = $$module_config_array;
109 109
       }
110 110
     }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
     // Checking module status - is it installed and active
121 121
     $this->check_status();
122
-    if(!$this->manifest['active']) {
122
+    if (!$this->manifest['active']) {
123 123
       return;
124 124
     }
125 125
 
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 
140 140
   protected function setSystemConstants() {
141 141
     // Setting constants - if any
142
-    if(empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) {
142
+    if (empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) {
143 143
       return;
144 144
     }
145 145
 
146
-    foreach($this->manifest['constants'] as $constant_name => $constant_value) {
146
+    foreach ($this->manifest['constants'] as $constant_name => $constant_value) {
147 147
       !defined($constant_name) ? define($constant_name, $constant_value) : false;
148 148
     }
149 149
   }
@@ -155,48 +155,48 @@  discard block
 block discarded – undo
155 155
     // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays)
156 156
     // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]'
157 157
     $this->manifest['vars'] = $this->__assign_vars();
158
-    if(empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) {
158
+    if (empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) {
159 159
       return;
160 160
     }
161 161
 
162 162
     $vars_assigned = array();
163
-    foreach($this->manifest['vars'] as $var_name => $var_value) {
163
+    foreach ($this->manifest['vars'] as $var_name => $var_value) {
164 164
       $sub_vars = explode('[', str_replace(']', '', $var_name));
165 165
       $var_name = $sub_vars[0];
166 166
 
167
-      if(!isset($vars_assigned[$var_name])) {
167
+      if (!isset($vars_assigned[$var_name])) {
168 168
         $vars_assigned[$var_name] = true;
169 169
         global $$var_name;
170 170
       }
171 171
 
172 172
       $pointer = &$$var_name;
173
-      if(($n = count($sub_vars)) > 1) {
174
-        for($i = 1; $i < $n; $i++) {
175
-          if(defined($sub_vars[$i])) {
173
+      if (($n = count($sub_vars)) > 1) {
174
+        for ($i = 1; $i < $n; $i++) {
175
+          if (defined($sub_vars[$i])) {
176 176
             $sub_vars[$i] = constant($sub_vars[$i]);
177 177
           }
178 178
 
179
-          if(!isset($pointer[$sub_vars[$i]]) && $i != $n) {
179
+          if (!isset($pointer[$sub_vars[$i]]) && $i != $n) {
180 180
             $pointer[$sub_vars[$i]] = array();
181 181
           }
182 182
           $pointer = &$pointer[$sub_vars[$i]];
183 183
         }
184 184
       }
185 185
 
186
-      if(!isset($pointer) || !is_array($pointer)) {
186
+      if (!isset($pointer) || !is_array($pointer)) {
187 187
         $pointer = $var_value;
188
-      } elseif(is_array($$var_name)) {
188
+      } elseif (is_array($$var_name)) {
189 189
         $pointer = array_merge_recursive_numeric($pointer, $var_value);
190 190
       }
191 191
     }
192 192
   }
193 193
 
194 194
   protected function mergeMenu(&$sn_menu_extra, &$menu_patch) {
195
-    if(!is_array($menu_patch)) {
195
+    if (!is_array($menu_patch)) {
196 196
       return;
197 197
     }
198 198
 
199
-    foreach($menu_patch as $menu_item_name => $menu_item_data) {
199
+    foreach ($menu_patch as $menu_item_name => $menu_item_data) {
200 200
       $sn_menu_extra[$menu_item_name] = $menu_item_data;
201 201
     }
202 202
   }
@@ -205,34 +205,34 @@  discard block
 block discarded – undo
205 205
     // Overriding function if any
206 206
     sn_sys_handler_add(classSupernova::$functions, $this->manifest['functions'], $this);
207 207
 
208
-    foreach(classSupernova::$sn_mvc as $handler_type => &$handler_data) {
208
+    foreach (classSupernova::$sn_mvc as $handler_type => &$handler_data) {
209 209
       sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type);
210 210
     }
211 211
   }
212 212
 
213 213
   protected function mergeNavbarButton() {
214
-    if(empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) {
214
+    if (empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) {
215 215
       return;
216 216
     }
217 217
 
218
-    foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) {
218
+    foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) {
219 219
       classSupernova::$sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative;
220 220
     }
221 221
   }
222 222
 
223 223
   protected function mergeI18N() {
224 224
     $arrayName = 'i18n';
225
-    if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
225
+    if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
226 226
       return;
227 227
     }
228 228
 
229
-    foreach($this->manifest[$arrayName] as $pageName => &$contentList) {
230
-      foreach($contentList as &$i18n_file_data) {
231
-        if(is_array($i18n_file_data) && !$i18n_file_data['path']) {
229
+    foreach ($this->manifest[$arrayName] as $pageName => &$contentList) {
230
+      foreach ($contentList as &$i18n_file_data) {
231
+        if (is_array($i18n_file_data) && !$i18n_file_data['path']) {
232 232
           $i18n_file_data['path'] = $this->manifest['root_relative'];
233 233
         }
234 234
       }
235
-      if(!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) {
235
+      if (!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) {
236 236
         classSupernova::$sn_mvc[$arrayName][$pageName] = array();
237 237
       }
238 238
       classSupernova::$sn_mvc[$arrayName][$pageName] += $contentList;
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
   }
241 241
 
242 242
   protected function mergeArraySpecial($arrayName) {
243
-    if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
243
+    if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
244 244
       return;
245 245
     }
246 246
 
247
-    foreach($this->manifest[$arrayName] as $pageName => &$contentList) {
247
+    foreach ($this->manifest[$arrayName] as $pageName => &$contentList) {
248 248
       !isset(classSupernova::$sn_mvc[$arrayName][$pageName]) ? classSupernova::$sn_mvc[$arrayName][$pageName] = array() : false;
249
-      foreach($contentList as $contentName => &$content) {
249
+      foreach ($contentList as $contentName => &$content) {
250 250
         classSupernova::$sn_mvc[$arrayName][$pageName][$contentName] = $content;
251 251
       }
252 252
     }
Please login to merge, or discard this patch.