@@ -10,7 +10,7 @@ |
||
10 | 10 | * |
11 | 11 | * @param Fleet $objFleet |
12 | 12 | * @param bool $start |
13 | - * @param null $result |
|
13 | + * @param integer $result |
|
14 | 14 | * |
15 | 15 | * @return mixed |
16 | 16 | */ |
@@ -19,15 +19,11 @@ discard block |
||
19 | 19 | // ------------------------------------------------------------------ |
20 | 20 | function flt_flyingFleetsSort($a, $b) { |
21 | 21 | // Сравниваем время флотов - кто раньше, тот и первый обрабатывается |
22 | - return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : |
|
23 | - // Если время - одинаковое, сравниваем события флотов |
|
22 | + return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов |
|
24 | 23 | // Если события - одинаковые, то флоты равны |
25 | - ($a['fleet_event'] == $b['fleet_event'] ? 0 : |
|
26 | - // Если события разные - первыми считаем прибывающие флоты |
|
27 | - ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : |
|
28 | - // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
29 | - ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : |
|
30 | - // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
24 | + ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты |
|
25 | + ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
26 | + ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
31 | 27 | // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска |
32 | 28 | ( |
33 | 29 | 0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий |
@@ -45,13 +41,13 @@ discard block |
||
45 | 41 | $handler = fopen('event.log', 'a+'); |
46 | 42 | } |
47 | 43 | |
48 | - fwrite($handler, date(FMT_DATE_TIME_SQL, time()) . ' ' . $msg . "\r\n"); |
|
44 | + fwrite($handler, date(FMT_DATE_TIME_SQL, time()).' '.$msg."\r\n"); |
|
49 | 45 | } |
50 | 46 | |
51 | 47 | // ------------------------------------------------------------------ |
52 | 48 | function flt_flying_fleet_handler($skip_fleet_update = false) { |
53 | 49 | if (true) { |
54 | - if(!defined('IN_AJAX')) { |
|
50 | + if (!defined('IN_AJAX')) { |
|
55 | 51 | print('<div style="color: red; font-size: 300%">Fleet handler is disabled</div>'); |
56 | 52 | pdump('Fleet handler is disabled'); |
57 | 53 | } |
@@ -177,7 +173,7 @@ discard block |
||
177 | 173 | MT_EXPLORE => 'flt_mission_explore', |
178 | 174 | ); |
179 | 175 | foreach ($missions_used as $mission_id => $cork) { |
180 | - require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX); |
|
176 | + require_once(SN_ROOT_PHYSICAL."includes/includes/{$mission_files[$mission_id]}".DOT_PHP_EX); |
|
181 | 177 | } |
182 | 178 | |
183 | 179 | //log_file('Обработка миссий'); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | 'shield' => 10, |
36 | 36 | 'armor' => 400, |
37 | 37 | 'attack' => 5, |
38 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
38 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
39 | 39 | ), |
40 | 40 | SHIP_CARGO_BIG => array( |
41 | 41 | 'name' => 'big_ship_cargo', |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'shield' => 25, |
56 | 56 | 'armor' => 1200, |
57 | 57 | 'attack' => 5, |
58 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
58 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
59 | 59 | 'engine' => array( |
60 | 60 | array( |
61 | 61 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'shield' => 50, |
84 | 84 | 'armor' => 3000, |
85 | 85 | 'attack' => 10, |
86 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
86 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
87 | 87 | 'engine' => array( |
88 | 88 | array( |
89 | 89 | 'tech' => TECH_ENGINE_ION, |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'shield' => 200, |
112 | 112 | 'armor' => 70000, |
113 | 113 | 'attack' => 50, |
114 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
114 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
115 | 115 | 'engine' => array( |
116 | 116 | array( |
117 | 117 | 'tech' => TECH_ENGINE_HYPER, |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | 'shield' => 100, |
141 | 141 | 'armor' => 3000, |
142 | 142 | 'attack' => 50, |
143 | - 'amplify' => array(SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21, ), |
|
143 | + 'amplify' => array(SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21,), |
|
144 | 144 | 'engine' => array( |
145 | 145 | array( |
146 | 146 | 'tech' => TECH_ENGINE_ION, |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | 'shield' => 10, |
169 | 169 | 'armor' => 1600, |
170 | 170 | 'attack' => 1, |
171 | - 'amplify' => array(SHIP_SPY => 500.05, SHIP_SATTELITE_SOLAR => 1050, ), |
|
171 | + 'amplify' => array(SHIP_SPY => 500.05, SHIP_SATTELITE_SOLAR => 1050,), |
|
172 | 172 | 'engine' => array( |
173 | 173 | array( |
174 | 174 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | 'shield' => 0.01, |
197 | 197 | 'armor' => 100, |
198 | 198 | 'attack' => 0.01, |
199 | - 'amplify' => array( SHIP_SPY => 1,), |
|
199 | + 'amplify' => array(SHIP_SPY => 1,), |
|
200 | 200 | 'engine' => array( |
201 | 201 | array( |
202 | 202 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | 'factor' => 1, |
221 | 221 | ), |
222 | 222 | P_UNIT_PRODUCTION => array( |
223 | - RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor);}, |
|
223 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor); }, |
|
224 | 224 | ), |
225 | 225 | P_MINING_IS_MANAGED => true, |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | 'shield' => 10, |
230 | 230 | 'armor' => 200, |
231 | 231 | 'attack' => 1, |
232 | - 'amplify' => array(SHIP_SPY => 1, ), |
|
232 | + 'amplify' => array(SHIP_SPY => 1,), |
|
233 | 233 | 'engine' => array( |
234 | 234 | array( |
235 | 235 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | 'shield' => 10, |
262 | 262 | 'armor' => 400, |
263 | 263 | 'attack' => 50, |
264 | - 'amplify' => array(SHIP_CARGO_SMALL => 16.4, SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21, ), |
|
264 | + 'amplify' => array(SHIP_CARGO_SMALL => 16.4, SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21,), |
|
265 | 265 | 'engine' => array( |
266 | 266 | array( |
267 | 267 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | 'shield' => 25, |
291 | 291 | 'armor' => 1000, |
292 | 292 | 'attack' => 150, |
293 | - 'amplify' => array(SHIP_CARGO_SMALL => 8.2, SHIP_SPY => 3.33367, SHIP_SATTELITE_SOLAR => 7, ), |
|
293 | + 'amplify' => array(SHIP_CARGO_SMALL => 8.2, SHIP_SPY => 3.33367, SHIP_SATTELITE_SOLAR => 7,), |
|
294 | 294 | 'engine' => array( |
295 | 295 | array( |
296 | 296 | 'tech' => TECH_ENGINE_ION, |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | 'shield' => 50, |
350 | 350 | 'armor' => 2700, |
351 | 351 | 'attack' => 400, |
352 | - 'amplify' => array(SHIP_SMALL_FIGHTER_LIGHT => 6.15, SHIP_SPY => 1.25013, SHIP_SATTELITE_SOLAR => 2.625, UNIT_DEF_TURRET_MISSILE => 5.5, ), |
|
352 | + 'amplify' => array(SHIP_SMALL_FIGHTER_LIGHT => 6.15, SHIP_SPY => 1.25013, SHIP_SATTELITE_SOLAR => 2.625, UNIT_DEF_TURRET_MISSILE => 5.5,), |
|
353 | 353 | 'engine' => array( |
354 | 354 | array( |
355 | 355 | 'tech' => TECH_ENGINE_ION, |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | 'shield' => 200, |
409 | 409 | 'armor' => 6000, |
410 | 410 | 'attack' => 1000, |
411 | - 'amplify' => array(SHIP_SPY => 0.50005, SHIP_SATTELITE_SOLAR => 1.05, UNIT_DEF_TURRET_MISSILE => 1.76, ), |
|
411 | + 'amplify' => array(SHIP_SPY => 0.50005, SHIP_SATTELITE_SOLAR => 1.05, UNIT_DEF_TURRET_MISSILE => 1.76,), |
|
412 | 412 | 'engine' => array( |
413 | 413 | array( |
414 | 414 | 'tech' => TECH_ENGINE_HYPER, |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | 'shield' => 500, |
505 | 505 | 'armor' => 11000, |
506 | 506 | 'attack' => 2000, |
507 | - 'amplify' => array(SHIP_SPY => 0.25003, SHIP_SATTELITE_SOLAR => 0.525, SHIP_LARGE_BATTLESHIP => 7.4, UNIT_DEF_TURRET_LASER_SMALL => 1.125, ), |
|
507 | + 'amplify' => array(SHIP_SPY => 0.25003, SHIP_SATTELITE_SOLAR => 0.525, SHIP_LARGE_BATTLESHIP => 7.4, UNIT_DEF_TURRET_LASER_SMALL => 1.125,), |
|
508 | 508 | 'engine' => array( |
509 | 509 | array( |
510 | 510 | 'tech' => TECH_ENGINE_HYPER, |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | 'shield' => 20, |
609 | 609 | 'armor' => 200, |
610 | 610 | 'attack' => 80, |
611 | - 'amplify' => array(SHIP_SPY => 7, ), |
|
611 | + 'amplify' => array(SHIP_SPY => 7,), |
|
612 | 612 | ), |
613 | 613 | UNIT_DEF_TURRET_LASER_SMALL => array( |
614 | 614 | 'name' => 'small_laser', |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | 'shield' => 25, |
627 | 627 | 'armor' => 200, |
628 | 628 | 'attack' => 100, |
629 | - 'amplify' => array(SHIP_SPY => 5, ), |
|
629 | + 'amplify' => array(SHIP_SPY => 5,), |
|
630 | 630 | ), |
631 | 631 | UNIT_DEF_TURRET_LASER_BIG => array( |
632 | 632 | 'name' => 'big_laser', |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | 'shield' => 100, |
645 | 645 | 'armor' => 800, |
646 | 646 | 'attack' => 250, |
647 | - 'amplify' => array(SHIP_SPY => 2, ), |
|
647 | + 'amplify' => array(SHIP_SPY => 2,), |
|
648 | 648 | ), |
649 | 649 | UNIT_DEF_TURRET_GAUSS => array( |
650 | 650 | 'name' => 'gauss_canyon', |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | 'armor' => 3500, |
663 | 663 | 'shield' => 200, |
664 | 664 | 'attack' => 1100, |
665 | - 'amplify' => array(SHIP_SPY => 0.5, ), |
|
665 | + 'amplify' => array(SHIP_SPY => 0.5,), |
|
666 | 666 | ), |
667 | 667 | UNIT_DEF_TURRET_ION => array( |
668 | 668 | 'name' => 'ionic_canyon', |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | 'shield' => 500, |
681 | 681 | 'armor' => 800, |
682 | 682 | 'attack' => 150, |
683 | - 'amplify' => array(SHIP_SPY => 3.3, ), |
|
683 | + 'amplify' => array(SHIP_SPY => 3.3,), |
|
684 | 684 | ), |
685 | 685 | UNIT_DEF_TURRET_PLASMA => array( |
686 | 686 | 'name' => 'buster_canyon', |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | 'shield' => 300, |
699 | 699 | 'armor' => 10000, |
700 | 700 | 'attack' => 3000, |
701 | - 'amplify' => array(SHIP_SPY => 0.17, ), |
|
701 | + 'amplify' => array(SHIP_SPY => 0.17,), |
|
702 | 702 | ), |
703 | 703 | |
704 | 704 | UNIT_DEF_SHIELD_SMALL => array( |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | 'shield' => 2000, |
719 | 719 | 'armor' => 2000, |
720 | 720 | 'attack' => 1, |
721 | - 'amplify' => array(SHIP_SPY => 500, ), |
|
721 | + 'amplify' => array(SHIP_SPY => 500,), |
|
722 | 722 | ), |
723 | 723 | UNIT_DEF_SHIELD_BIG => array( |
724 | 724 | 'name' => 'big_protection_shield', |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | 'shield' => 2000, |
738 | 738 | 'armor' => 10000, |
739 | 739 | 'attack' => 1, |
740 | - 'amplify' => array(SHIP_SPY => 500, ), |
|
740 | + 'amplify' => array(SHIP_SPY => 500,), |
|
741 | 741 | ), |
742 | 742 | UNIT_DEF_SHIELD_PLANET => array( |
743 | 743 | 'name' => 'planet_protector', |
@@ -239,6 +239,9 @@ |
||
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | + /** |
|
243 | + * @param string $arrayName |
|
244 | + */ |
|
242 | 245 | protected function mergeArraySpecial($arrayName) { |
243 | 246 | global $sn_mvc; |
244 | 247 |
@@ -73,10 +73,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -286,7 +286,6 @@ discard block |
||
286 | 286 | /** |
287 | 287 | * Функция пытается залогиниться по всем известным провайдерам |
288 | 288 | * |
289 | - * @param null $result |
|
290 | 289 | */ |
291 | 290 | public function login() { |
292 | 291 | if(empty(sn_module::$sn_module_list['auth'])) { |
@@ -823,10 +822,17 @@ discard block |
||
823 | 822 | |
824 | 823 | // OK v4.5 |
825 | 824 | // TODO - REMEMBER_ME |
825 | + |
|
826 | + /** |
|
827 | + * @param integer $period |
|
828 | + */ |
|
826 | 829 | protected static function cookie_set($value, $impersonate = false, $period = null) { |
827 | 830 | sn_setcookie($impersonate ? SN_COOKIE_U_I : SN_COOKIE_U, $value, $period === null ? SN_TIME_NOW + PERIOD_YEAR : $period, SN_ROOT_RELATIVE); |
828 | 831 | } |
829 | 832 | |
833 | + /** |
|
834 | + * @param string $message |
|
835 | + */ |
|
830 | 836 | protected static function flog($message, $die = false) { |
831 | 837 | if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
832 | 838 | return; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | // Проверить наличие такого имени в истории имён |
225 | 225 | do { |
226 | 226 | sn_db_transaction_rollback(); |
227 | - $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
|
227 | + $this->player_suggested_name = 'Emperor '.mt_rand($max_user_id + 1, $max_user_id + 1000); |
|
228 | 228 | sn_db_transaction_start(); |
229 | 229 | } while (db_player_name_exists($this->player_suggested_name)); |
230 | 230 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | if ($player_name_submitted) { |
234 | 234 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
235 | 235 | if ($this->register_status == LOGIN_SUCCESS) { |
236 | - sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
|
236 | + sys_redirect(SN_ROOT_VIRTUAL.'overview.php'); |
|
237 | 237 | } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
238 | 238 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
239 | 239 | } |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | ); |
260 | 260 | |
261 | 261 | if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
262 | - $prohibited_characters = array_map(function ($value) { |
|
263 | - return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
|
262 | + $prohibited_characters = array_map(function($value) { |
|
263 | + return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'"; |
|
264 | 264 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
265 | 265 | $template_result[F_PLAYER_REGISTER_MESSAGE] .= implode(', ', $prohibited_characters); |
266 | 266 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | |
308 | 308 | foreach ($this->providers as $provider_id => $provider) { |
309 | 309 | $login_status = $provider->login(); // OK v4.5 |
310 | - self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
|
310 | + self::flog(($provider->manifest['name'].'->'.'login_try - ').(empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
|
311 | 311 | if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
312 | 312 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
313 | 313 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | if (!$this->is_player_register) { |
348 | 348 | // Нет - отправляем на процесс регистрации |
349 | 349 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
350 | - sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
|
350 | + sys_redirect(SN_ROOT_VIRTUAL.'index.php?page=player_register&player_register=1'.($partner_id ? '&id_ref='.$partner_id : '')); |
|
351 | 351 | } |
352 | 352 | } else { |
353 | 353 | // Да, есть доступные игроки, которые так же прописаны в базе |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | } |
408 | 408 | |
409 | 409 | if ($redirect === true) { |
410 | - sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
|
410 | + sys_redirect(SN_ROOT_RELATIVE.(empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
|
411 | 411 | } elseif ($redirect !== false) { |
412 | 412 | sys_redirect($redirect); |
413 | 413 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | $user['vacation'] = SN_TIME_NOW; |
703 | 703 | } |
704 | 704 | |
705 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; |
|
705 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; |
|
706 | 706 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; |
707 | 707 | |
708 | 708 | $result[F_BANNED_STATUS] = $user['banaday']; |
@@ -710,9 +710,9 @@ discard block |
||
710 | 710 | |
711 | 711 | $proxy_safe = static::$db->db_escape(self::$device->ip_v4_proxy_chain); |
712 | 712 | |
713 | - DBStaticUser::db_user_set_by_id($user['id'], "`onlinetime` = " . SN_TIME_NOW . ", |
|
714 | - `banaday` = " . static::$db->db_escape($user['banaday']) . ", `vacation` = " . static::$db->db_escape($user['vacation']) . ", |
|
715 | - `user_lastip` = '" . static::$db->db_escape($user['user_lastip']) . "', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = " . self::$device->browser_id |
|
713 | + DBStaticUser::db_user_set_by_id($user['id'], "`onlinetime` = ".SN_TIME_NOW.", |
|
714 | + `banaday` = " . static::$db->db_escape($user['banaday']).", `vacation` = ".static::$db->db_escape($user['vacation']).", |
|
715 | + `user_lastip` = '" . static::$db->db_escape($user['user_lastip'])."', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = ".self::$device->browser_id |
|
716 | 716 | ); |
717 | 717 | } |
718 | 718 | |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | */ |
806 | 806 | // OK v4 |
807 | 807 | public static function password_encode($password, $salt) { |
808 | - return md5($password . $salt); |
|
808 | + return md5($password.$salt); |
|
809 | 809 | } |
810 | 810 | /** |
811 | 811 | * Генерирует соль |
@@ -831,10 +831,10 @@ discard block |
||
831 | 831 | } |
832 | 832 | list($called, $caller) = debug_backtrace(false); |
833 | 833 | $caller_name = |
834 | - (!empty($caller['class']) ? $caller['class'] : '') . |
|
835 | - (!empty($caller['type']) ? $caller['type'] : '') . |
|
836 | - (!empty($caller['function']) ? $caller['function'] : '') . |
|
837 | - (!empty($called['line']) ? ':' . $called['line'] : ''); |
|
834 | + (!empty($caller['class']) ? $caller['class'] : ''). |
|
835 | + (!empty($caller['type']) ? $caller['type'] : ''). |
|
836 | + (!empty($caller['function']) ? $caller['function'] : ''). |
|
837 | + (!empty($called['line']) ? ':'.$called['line'] : ''); |
|
838 | 838 | |
839 | 839 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
840 | 840 | |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | if ($die) { |
843 | 843 | // pdump($caller); |
844 | 844 | // pdump(debug_backtrace(false)); |
845 | - $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
845 | + $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
846 | 846 | } |
847 | 847 | } |
848 | 848 |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | |
22 | 22 | function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) { |
23 | 23 | $unit_list = sn_get_groups($mode); |
24 | - if(empty($unit_list)) { |
|
24 | + if (empty($unit_list)) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 | $name_list = classLocale::$lang['tech']; |
28 | 28 | |
29 | - foreach($unit_list as $unit_id) { |
|
29 | + foreach ($unit_list as $unit_id) { |
|
30 | 30 | $template->assign_block_vars('unit', array( |
31 | 31 | 'ID' => $unit_id, |
32 | 32 | 'NAME' => $name_list[$unit_id], |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { return sn_function_call(__FUNCTION__, array($unit_id, $unit_amount, $mode)); } |
40 | 40 | |
41 | 41 | function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { |
42 | - if($unit_amount && in_array($unit_id, sn_get_groups($mode))) { |
|
42 | + if ($unit_amount && in_array($unit_id, sn_get_groups($mode))) { |
|
43 | 43 | $unit_amount = round($unit_amount); |
44 | 44 | $unit_name = get_unit_param($unit_id, P_NAME); |
45 | 45 | $result = "{$unit_name} = GREATEST(0, {$unit_name} + ({$unit_amount}))"; |
@@ -16,7 +16,7 @@ |
||
16 | 16 | $query = db_user_list("`authlevel` > 0 ORDER BY `authlevel` ASC"); |
17 | 17 | |
18 | 18 | // while($row = db_fetch($query)) |
19 | - foreach($query as $row) { |
|
19 | + foreach ($query as $row) { |
|
20 | 20 | $template_result['.']['contact'][] = array( |
21 | 21 | 'NAME' => $row['username'], |
22 | 22 | 'LEVEL' => classLocale::$lang['user_level'][$row['authlevel']], |
@@ -171,6 +171,10 @@ discard block |
||
171 | 171 | * @return bool |
172 | 172 | */ |
173 | 173 | // OK v4.5 |
174 | + |
|
175 | + /** |
|
176 | + * @param string $account_name_unsafe |
|
177 | + */ |
|
174 | 178 | public function db_get_by_name($account_name_unsafe) { |
175 | 179 | $this->reset(); |
176 | 180 | |
@@ -207,6 +211,11 @@ discard block |
||
207 | 211 | * |
208 | 212 | */ |
209 | 213 | // OK v4.5 |
214 | + |
|
215 | + /** |
|
216 | + * @param string $account_name_unsafe |
|
217 | + * @param string $email_unsafe |
|
218 | + */ |
|
210 | 219 | public function db_get_by_name_or_email($account_name_unsafe, $email_unsafe) { |
211 | 220 | $this->reset(); |
212 | 221 | |
@@ -223,6 +232,13 @@ discard block |
||
223 | 232 | * @throws Exception |
224 | 233 | */ |
225 | 234 | // OK v4.5 |
235 | + |
|
236 | + /** |
|
237 | + * @param string $account_name_unsafe |
|
238 | + * @param string $password_raw |
|
239 | + * @param string $email_unsafe |
|
240 | + * @param string $language_unsafe |
|
241 | + */ |
|
226 | 242 | public function db_create($account_name_unsafe, $password_raw, $email_unsafe, $language_unsafe = null, $salt_unsafe = null) { |
227 | 243 | $this->reset(); |
228 | 244 | |
@@ -317,6 +333,11 @@ discard block |
||
317 | 333 | * @return int|string |
318 | 334 | */ |
319 | 335 | // OK 4.8 |
336 | + |
|
337 | + /** |
|
338 | + * @param integer $change_type |
|
339 | + * @param double $metamatter |
|
340 | + */ |
|
320 | 341 | protected function db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe) { |
321 | 342 | $provider_id_safe = intval(core_auth::$main_provider->provider_id); |
322 | 343 | //$account_id_safe = $this->db->db_escape($this->account_id); |
@@ -79,8 +79,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -188,6 +188,11 @@ discard block |
||
188 | 188 | */ |
189 | 189 | // OK v4 |
190 | 190 | // TODO - вынести в отдельный класс |
191 | +/** |
|
192 | + * @param string $db_id_field_name |
|
193 | + * @param string $db_table_name |
|
194 | + * @param string $db_value_field_name |
|
195 | + */ |
|
191 | 196 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
192 | 197 | $current_value_safe = db_escape($current_value_unsafe); |
193 | 198 | $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true); |
@@ -220,7 +225,7 @@ discard block |
||
220 | 225 | |
221 | 226 | /** |
222 | 227 | * @param $user |
223 | - * @param $username_safe |
|
228 | + * @param string $username_safe |
|
224 | 229 | */ |
225 | 230 | function db_player_name_history_replace($user, $username_safe) { |
226 | 231 | doquery("REPLACE INTO {{player_name_history}} SET `player_id` = {$user['id']}, `player_name` = '{$username_safe}'"); |
@@ -228,7 +233,7 @@ discard block |
||
228 | 233 | |
229 | 234 | |
230 | 235 | /** |
231 | - * @param $username_safe |
|
236 | + * @param string $username_safe |
|
232 | 237 | * |
233 | 238 | * @return array|bool|mysqli_result|null |
234 | 239 | */ |
@@ -485,12 +490,12 @@ discard block |
||
485 | 490 | |
486 | 491 | |
487 | 492 | /** |
488 | - * @param $user_id |
|
489 | - * @param $change_type |
|
493 | + * @param integer $user_id |
|
494 | + * @param integer $change_type |
|
490 | 495 | * @param $dark_matter |
491 | - * @param $comment |
|
496 | + * @param string $comment |
|
492 | 497 | * @param $row |
493 | - * @param $page_url |
|
498 | + * @param string $page_url |
|
494 | 499 | */ |
495 | 500 | function db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment, $row, $page_url) { |
496 | 501 | doquery( |
@@ -506,7 +511,7 @@ discard block |
||
506 | 511 | /** |
507 | 512 | * @param $user_id_safe |
508 | 513 | * |
509 | - * @return array|bool|mysqli_result|null |
|
514 | + * @return integer |
|
510 | 515 | */ |
511 | 516 | function db_referral_get_by_id($user_id_safe) { |
512 | 517 | $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", true); |
@@ -534,9 +539,9 @@ discard block |
||
534 | 539 | |
535 | 540 | // Quests *********************************************************************************************************** |
536 | 541 | /** |
537 | - * @param $query_add_select |
|
542 | + * @param string $query_add_select |
|
538 | 543 | * @param $query_add_from |
539 | - * @param $query_add_where |
|
544 | + * @param string $query_add_where |
|
540 | 545 | * |
541 | 546 | * @return array|bool|mysqli_result|null |
542 | 547 | */ |
@@ -580,11 +585,11 @@ discard block |
||
580 | 585 | } |
581 | 586 | |
582 | 587 | /** |
583 | - * @param $quest_name |
|
584 | - * @param $quest_type |
|
585 | - * @param $quest_description |
|
588 | + * @param string $quest_name |
|
589 | + * @param integer $quest_type |
|
590 | + * @param string $quest_description |
|
586 | 591 | * @param $quest_conditions |
587 | - * @param $quest_rewards |
|
592 | + * @param string $quest_rewards |
|
588 | 593 | * @param $quest_id |
589 | 594 | */ |
590 | 595 | function db_quest_update($quest_name, $quest_type, $quest_description, $quest_conditions, $quest_rewards, $quest_id) { |
@@ -607,7 +612,7 @@ discard block |
||
607 | 612 | /** |
608 | 613 | * @param $banner |
609 | 614 | * @param $banned |
610 | - * @param $reason |
|
615 | + * @param string $reason |
|
611 | 616 | * @param $ban_until |
612 | 617 | */ |
613 | 618 | function db_ban_insert($banner, $banned, $reason, $ban_until) { |
@@ -630,7 +635,7 @@ discard block |
||
630 | 635 | /** |
631 | 636 | * @param $banner |
632 | 637 | * @param $banned |
633 | - * @param $reason |
|
638 | + * @param string $reason |
|
634 | 639 | */ |
635 | 640 | function db_ban_insert_unset($banner, $banned, $reason) { |
636 | 641 | doquery( |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | |
18 | 18 | function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) { |
19 | 19 | return doquery( |
20 | - "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') . |
|
20 | + "SELECT p.*, u.username".($table_parent_columns ? ', p1.name AS parent_name' : ''). |
|
21 | 21 | " FROM {{planets}} AS p |
22 | 22 | LEFT JOIN {{users}} AS u ON u.id = p.id_owner" . |
23 | - ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : '') . |
|
24 | - " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
|
23 | + ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : ''). |
|
24 | + " WHERE ".($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | function db_planet_list_search($searchtext) { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | ORDER BY |
122 | 122 | sp.`{$Rank}_rank`, subject.{$source['id']} |
123 | 123 | LIMIT |
124 | - " . $start . ",100;"; |
|
124 | + ".$start.",100;"; |
|
125 | 125 | } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
126 | 126 | $query_str = |
127 | 127 | "SELECT |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | ORDER BY |
135 | 135 | subject.{$Rank} DESC, subject.{$source['id']} |
136 | 136 | LIMIT |
137 | - " . $start . ",100;"; |
|
137 | + ".$start.",100;"; |
|
138 | 138 | } |
139 | 139 | } else { |
140 | 140 | // TODO |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ORDER BY |
152 | 152 | sp.`{$Rank}_rank`, subject.id |
153 | 153 | LIMIT |
154 | - " . $start . ",100;"; |
|
154 | + ".$start.",100;"; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return doquery($query_str); |
@@ -374,9 +374,9 @@ discard block |
||
374 | 374 | */ |
375 | 375 | function db_payment_list_get($flt_payer, $flt_status, $flt_test, $flt_module) { |
376 | 376 | $extra_conditions = |
377 | - ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : '') . |
|
378 | - ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : '') . |
|
379 | - ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : '') . |
|
377 | + ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : ''). |
|
378 | + ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : ''). |
|
379 | + ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : ''). |
|
380 | 380 | ($flt_module ? "AND payment_module_name = '{$flt_module}' " : ''); |
381 | 381 | $query = doquery("SELECT * FROM `{{payment}}` WHERE 1 {$extra_conditions} ORDER BY payment_id DESC;"); |
382 | 382 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | |
405 | 405 | // Log Online ************************************************************************************************************* |
406 | 406 | function db_log_online_insert() { |
407 | - doquery("INSERT IGNORE INTO {{log_users_online}} SET online_count = " . classSupernova::$config->var_online_user_count); |
|
407 | + doquery("INSERT IGNORE INTO {{log_users_online}} SET online_count = ".classSupernova::$config->var_online_user_count); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | // Log ************************************************************************************************************* |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | `ban_user_id` = '{$banned['id']}', |
613 | 613 | `ban_user_name` = '{$banned['username']}', |
614 | 614 | `ban_reason` = '{$reason}', |
615 | - `ban_time` = " . SN_TIME_NOW . ", |
|
615 | + `ban_time` = ".SN_TIME_NOW.", |
|
616 | 616 | `ban_until` = {$ban_until}, |
617 | 617 | `ban_issuer_id` = '{$banner['id']}', |
618 | 618 | `ban_issuer_name` = '{$banner['username']}', |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | `ban_user_name` = '{$banned['username']}', |
635 | 635 | `ban_reason` = '{$reason}', |
636 | 636 | `ban_time` = 0, |
637 | - `ban_until` = " . SN_TIME_NOW . ", |
|
637 | + `ban_until` = ".SN_TIME_NOW.", |
|
638 | 638 | `ban_issuer_id` = '{$banner['id']}', |
639 | 639 | `ban_issuer_name` = '{$banner['username']}', |
640 | 640 | `ban_issuer_email` = '{$banner['email']}' |
@@ -693,9 +693,9 @@ discard block |
||
693 | 693 | function db_ube_report_get_best_battles() { |
694 | 694 | $query = doquery("SELECT * |
695 | 695 | FROM {{ube_report}} |
696 | - WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS . " DAY)) |
|
696 | + WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS." DAY)) |
|
697 | 697 | ORDER BY `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC |
698 | - LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW . ";"); |
|
698 | + LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW.";"); |
|
699 | 699 | |
700 | 700 | return $query; |
701 | 701 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | 'factor' => 1.5, |
16 | 16 | ), |
17 | 17 | P_UNIT_PRODUCTION => array( |
18 | - RES_METAL => function ($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
19 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
18 | + RES_METAL => function($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
19 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
20 | 20 | ), |
21 | 21 | P_MINING_IS_MANAGED => true, |
22 | 22 | ), |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | 'factor' => 1.6, |
34 | 34 | ), |
35 | 35 | P_UNIT_PRODUCTION => array( |
36 | - RES_CRYSTAL => function ($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
37 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
36 | + RES_CRYSTAL => function($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
37 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
38 | 38 | ), |
39 | 39 | P_MINING_IS_MANAGED => true, |
40 | 40 | ), |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | 'factor' => 1.5, |
52 | 52 | ), |
53 | 53 | P_UNIT_PRODUCTION => array( |
54 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28);}, |
|
55 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
54 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
55 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
56 | 56 | ), |
57 | 57 | P_MINING_IS_MANAGED => true, |
58 | 58 | ), |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'factor' => 1.5, |
70 | 70 | ), |
71 | 71 | P_UNIT_PRODUCTION => array( |
72 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
72 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
73 | 73 | ), |
74 | 74 | P_MINING_IS_MANAGED => true, |
75 | 75 | ), |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | 'factor' => 1.8, |
88 | 88 | ), |
89 | 89 | P_UNIT_PRODUCTION => array( |
90 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
91 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, null, TECH_ENERGY), $level) * (0.1 * $production_factor);}, |
|
90 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
91 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, null, TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
92 | 92 | ), |
93 | 93 | P_MINING_IS_MANAGED => true, |
94 | 94 | ), |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'factor' => 2, |
106 | 106 | ), |
107 | 107 | 'storage' => array( |
108 | - RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
108 | + RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
109 | 109 | ), |
110 | 110 | ), |
111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'factor' => 2, |
122 | 122 | ), |
123 | 123 | 'storage' => array( |
124 | - RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
124 | + RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
125 | 125 | ), |
126 | 126 | ), |
127 | 127 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'factor' => 2, |
138 | 138 | ), |
139 | 139 | 'storage' => array( |
140 | - RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
140 | + RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
141 | 141 | ), |
142 | 142 | ), |
143 | 143 |