@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | protected static $cacheObject; |
47 | 47 | |
48 | 48 | public function __construct($prefIn = 'CACHE_', $init_mode = false) { |
49 | - if(!($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')))) { |
|
49 | + if (!($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')))) { |
|
50 | 50 | throw new UnexpectedValueException('Wrong work mode or current mode does not supported on your server'); |
51 | 51 | } |
52 | 52 | |
53 | 53 | $this->prefix = $prefIn; |
54 | - if(extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) { |
|
55 | - if(self::$mode === CACHER_NOT_INIT) { |
|
54 | + if (extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) { |
|
55 | + if (self::$mode === CACHER_NOT_INIT) { |
|
56 | 56 | self::$mode = CACHER_XCACHE; |
57 | 57 | } |
58 | 58 | } else { |
59 | - if(self::$mode === CACHER_NOT_INIT) { |
|
59 | + if (self::$mode === CACHER_NOT_INIT) { |
|
60 | 60 | self::$mode = CACHER_NO_CACHE; |
61 | - if(!self::$data) { |
|
61 | + if (!self::$data) { |
|
62 | 62 | self::$data = array(); |
63 | 63 | } |
64 | 64 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | public static function getInstance($prefIn = 'CACHE_', $table_name = '') { |
69 | - if(!isset(self::$cacheObject)) { |
|
69 | + if (!isset(self::$cacheObject)) { |
|
70 | 70 | $className = get_class(); |
71 | 71 | self::$cacheObject = new $className($prefIn); |
72 | 72 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // Here comes low-level functions - those that directly works with cacher engines |
84 | 84 | // ------------------------------------------------------------------------- |
85 | 85 | public function __set($name, $value) { |
86 | - switch($name) { |
|
86 | + switch ($name) { |
|
87 | 87 | case '_MODE': |
88 | 88 | throw new UnexpectedValueException('You can not change cacher mode on-the-fly!'); |
89 | 89 | break; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | break; |
94 | 94 | |
95 | 95 | default: |
96 | - switch(self::$mode) { |
|
96 | + switch (self::$mode) { |
|
97 | 97 | case CACHER_NO_CACHE: |
98 | 98 | self::$data[$this->prefix . $name] = $value; |
99 | 99 | break; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | public function __get($name) { |
110 | - switch($name) { |
|
110 | + switch ($name) { |
|
111 | 111 | case '_MODE': |
112 | 112 | return self::$mode; |
113 | 113 | break; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | break; |
118 | 118 | |
119 | 119 | default: |
120 | - switch(self::$mode) { |
|
120 | + switch (self::$mode) { |
|
121 | 121 | case CACHER_NO_CACHE: |
122 | 122 | return self::$data[$this->prefix . $name]; |
123 | 123 | break; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | public function __isset($name) { |
137 | - switch(self::$mode) { |
|
137 | + switch (self::$mode) { |
|
138 | 138 | case CACHER_NO_CACHE: |
139 | 139 | return isset(self::$data[$this->prefix . $name]); |
140 | 140 | break; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | public function __unset($name) { |
151 | - switch(self::$mode) { |
|
151 | + switch (self::$mode) { |
|
152 | 152 | case CACHER_NO_CACHE: |
153 | 153 | unset(self::$data[$this->prefix . $name]); |
154 | 154 | break; |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | |
162 | 162 | public function unset_by_prefix($prefix_unset = '') { |
163 | 163 | static $array_clear; |
164 | - !$array_clear ? $array_clear = function (&$v, $k, $p) { |
|
164 | + !$array_clear ? $array_clear = function(&$v, $k, $p) { |
|
165 | 165 | strpos($k, $p) === 0 ? $v = null : false; |
166 | 166 | } : false; |
167 | 167 | |
168 | - switch(self::$mode) { |
|
168 | + switch (self::$mode) { |
|
169 | 169 | case CACHER_NO_CACHE: |
170 | 170 | // array_walk(self::$data, create_function('&$v,$k,$p', 'if(strpos($k, $p) === 0)$v = NULL;'), $this->prefix.$prefix_unset); |
171 | 171 | array_walk(self::$data, $array_clear, $this->prefix . $prefix_unset); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | break; |
175 | 175 | |
176 | 176 | case CACHER_XCACHE: |
177 | - if(!function_exists('xcache_unset_by_prefix')) { |
|
177 | + if (!function_exists('xcache_unset_by_prefix')) { |
|
178 | 178 | return false; |
179 | 179 | } |
180 | 180 | |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | protected function make_element_name($args, $diff = 0) { |
192 | 192 | $num_args = count($args); |
193 | 193 | |
194 | - if($num_args < 1) { |
|
194 | + if ($num_args < 1) { |
|
195 | 195 | return false; |
196 | 196 | } |
197 | 197 | |
198 | 198 | $name = ''; |
199 | 199 | $aName = array(); |
200 | - for($i = 0; $i <= $num_args - 1 - $diff; $i++) { |
|
200 | + for ($i = 0; $i <= $num_args - 1 - $diff; $i++) { |
|
201 | 201 | $name .= "[{$args[$i]}]"; |
202 | 202 | array_unshift($aName, $name); |
203 | 203 | } |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | $args = func_get_args(); |
210 | 210 | $name = $this->make_element_name($args, 1); |
211 | 211 | |
212 | - if(!$name) { |
|
212 | + if (!$name) { |
|
213 | 213 | return null; |
214 | 214 | } |
215 | 215 | |
216 | - if($this->$name[0] === null) { |
|
217 | - for($i = count($name) - 1; $i > 0; $i--) { |
|
216 | + if ($this->$name[0] === null) { |
|
217 | + for ($i = count($name) - 1; $i > 0; $i--) { |
|
218 | 218 | $cName = "{$name[$i]}_COUNT"; |
219 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
220 | - if($this->$cName1 == null || $i == 1) { |
|
219 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
220 | + if ($this->$cName1 == null || $i == 1) { |
|
221 | 221 | $this->$cName++; |
222 | 222 | } |
223 | 223 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | public function array_get() { |
232 | 232 | $name = $this->make_element_name(func_get_args()); |
233 | - if(!$name) { |
|
233 | + if (!$name) { |
|
234 | 234 | return null; |
235 | 235 | } |
236 | 236 | |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | |
240 | 240 | public function array_count() { |
241 | 241 | $name = $this->make_element_name(func_get_args()); |
242 | - if(!$name) { |
|
242 | + if (!$name) { |
|
243 | 243 | return 0; |
244 | 244 | } |
245 | 245 | $cName = "{$name[0]}_COUNT"; |
246 | 246 | $retVal = $this->$cName; |
247 | - if(!$retVal) { |
|
247 | + if (!$retVal) { |
|
248 | 248 | $retVal = null; |
249 | 249 | } |
250 | 250 | |
@@ -254,18 +254,18 @@ discard block |
||
254 | 254 | public function array_unset() { |
255 | 255 | $name = $this->make_element_name(func_get_args()); |
256 | 256 | |
257 | - if(!$name) { |
|
257 | + if (!$name) { |
|
258 | 258 | return false; |
259 | 259 | } |
260 | 260 | $this->unset_by_prefix($name[0]); |
261 | 261 | |
262 | - for($i = 1; $i < count($name); $i++) { |
|
262 | + for ($i = 1; $i < count($name); $i++) { |
|
263 | 263 | $cName = "{$name[$i]}_COUNT"; |
264 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
264 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
265 | 265 | |
266 | - if($i == 1 || $this->$cName1 === null) { |
|
266 | + if ($i == 1 || $this->$cName1 === null) { |
|
267 | 267 | $this->$cName--; |
268 | - if($this->$cName <= 0) { |
|
268 | + if ($this->$cName <= 0) { |
|
269 | 269 | unset($this->$cName); |
270 | 270 | } |
271 | 271 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | } |
276 | 276 | |
277 | 277 | public function dumpData() { |
278 | - switch(self::$mode) { |
|
278 | + switch (self::$mode) { |
|
279 | 279 | case CACHER_NO_CACHE: |
280 | 280 | return dump(self::$data, $this->prefix); |
281 | 281 | break; |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | $this->sql_index_field = "{$table_name}_name"; |
327 | 327 | $this->sql_value_field = "{$table_name}_value"; |
328 | 328 | |
329 | - if(!$this->_DB_LOADED) { |
|
329 | + if (!$this->_DB_LOADED) { |
|
330 | 330 | $this->db_loadAll(); |
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
334 | 334 | public static function getInstance($gamePrefix = 'sn_', $table_name = '') { |
335 | - if(!isset(self::$cacheObject)) { |
|
335 | + if (!isset(self::$cacheObject)) { |
|
336 | 336 | $className = get_class(); |
337 | 337 | self::$cacheObject = new $className($gamePrefix, $table_name); |
338 | 338 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | public function db_loadItem($index) { |
344 | 344 | $result = null; |
345 | - if($index) { |
|
345 | + if ($index) { |
|
346 | 346 | $index_safe = db_escape($index); |
347 | 347 | $result = doquery("SELECT `{$this->sql_value_field}` FROM `{{{$this->table_name}}}` WHERE `{$this->sql_index_field}` = '{$index_safe}' FOR UPDATE", true); |
348 | 348 | // В две строки - что бы быть уверенным в порядке выполнения |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $this->loadDefaults(); |
358 | 358 | |
359 | 359 | $query = doquery("SELECT * FROM {{{$this->table_name}}} FOR UPDATE;"); |
360 | - while($row = db_fetch($query)) { |
|
360 | + while ($row = db_fetch($query)) { |
|
361 | 361 | $this->$row[$this->sql_index_field] = $row[$this->sql_value_field]; |
362 | 362 | } |
363 | 363 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | public function loadDefaults() { |
368 | - foreach($this->defaults as $defName => $defValue) { |
|
368 | + foreach ($this->defaults as $defName => $defValue) { |
|
369 | 369 | $this->$defName = $defValue; |
370 | 370 | } |
371 | 371 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | } |
382 | 382 | |
383 | 383 | public function db_saveItem($item_list, $value = null) { |
384 | - if(empty($item_list)) { |
|
384 | + if (empty($item_list)) { |
|
385 | 385 | return; |
386 | 386 | } |
387 | 387 | |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | |
390 | 390 | // Сначала записываем данные в базу - что бы поймать все блокировки |
391 | 391 | $qry = array(); |
392 | - foreach($item_list as $item_name => $item_value) { |
|
393 | - if($item_name) { |
|
392 | + foreach ($item_list as $item_name => $item_value) { |
|
393 | + if ($item_name) { |
|
394 | 394 | $item_value = db_escape($item_value === null ? $this->$item_name : $item_value); |
395 | 395 | $item_name = db_escape($item_name); |
396 | 396 | $qry[] = "('{$item_name}', '{$item_value}')"; |
@@ -399,8 +399,8 @@ discard block |
||
399 | 399 | doquery("REPLACE INTO `{{" . $this->table_name . "}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES " . implode(',', $qry) . ";"); |
400 | 400 | |
401 | 401 | // И только после взятия блокировок - меняем значения в кэше |
402 | - foreach($item_list as $item_name => $item_value) { |
|
403 | - if($item_name && $item_value !== null) { |
|
402 | + foreach ($item_list as $item_name => $item_value) { |
|
403 | + if ($item_name && $item_value !== null) { |
|
404 | 404 | $this->$item_name = $item_value; |
405 | 405 | } |
406 | 406 | } |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | 'advGoogleLeftMenuCode' => '(Place here code for banner)', |
588 | 588 | |
589 | 589 | // Alliance bonus calculations |
590 | - 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
590 | + 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
591 | 591 | 'ali_bonus_brackets' => 10, // Brackets count for ALI_BONUS_BY_RANK |
592 | - 'ali_bonus_brackets_divisor' => 10,// Bonus divisor for ALI_BONUS_BY_RANK |
|
592 | + 'ali_bonus_brackets_divisor' => 10, // Bonus divisor for ALI_BONUS_BY_RANK |
|
593 | 593 | 'ali_bonus_divisor' => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS |
594 | 594 | 'ali_bonus_members' => 10, // Minumum alliace size to start using bonus |
595 | 595 | |
@@ -620,25 +620,25 @@ discard block |
||
620 | 620 | 'deuterium_basic_income' => 0, |
621 | 621 | 'eco_scale_storage' => 1, |
622 | 622 | 'eco_stockman_fleet' => '', // Black Market - Starting amount of s/h ship merchant to sell |
623 | - 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
623 | + 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
624 | 624 | 'empire_mercenary_base_period' => PERIOD_MONTH, // Base |
625 | 625 | 'empire_mercenary_temporary' => 0, // Temporary empire-wide mercenaries |
626 | 626 | 'energy_basic_income' => 0, |
627 | 627 | |
628 | 628 | // Bashing protection settings |
629 | - 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
630 | - 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
631 | - 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
632 | - 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
633 | - 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
629 | + 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
630 | + 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
631 | + 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
632 | + 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
633 | + 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
634 | 634 | |
635 | 635 | 'Fleet_Cdr' => 30, |
636 | 636 | 'fleet_speed' => 1, |
637 | 637 | |
638 | 638 | 'fleet_update_interval' => 4, |
639 | 639 | |
640 | - 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
641 | - 'game_counter' => 0, // Does built-in page hit counter is on? |
|
640 | + 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
641 | + 'game_counter' => 0, // Does built-in page hit counter is on? |
|
642 | 642 | // Defaults |
643 | 643 | 'game_default_language' => 'ru', |
644 | 644 | 'game_default_skin' => 'skins/EpicBlue/', |
@@ -652,13 +652,13 @@ discard block |
||
652 | 652 | 'game_maxSystem' => 199, |
653 | 653 | 'game_maxPlanet' => 15, |
654 | 654 | // Game global settings |
655 | - 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
655 | + 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
656 | 656 | 'game_name' => 'SuperNova', // Server name (would be on banners and on top of left menu) |
657 | 657 | |
658 | 658 | 'game_news_actual' => 259200, // How long announcement would be marked as "New". In seconds. Default - 3 days |
659 | - 'game_news_overview' => 3, // How much last news to show in Overview page |
|
659 | + 'game_news_overview' => 3, // How much last news to show in Overview page |
|
660 | 660 | // Noob protection |
661 | - 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
661 | + 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
662 | 662 | 'game_noob_points' => 5000, // Below this point user threated as noob. 0 to disable |
663 | 663 | |
664 | 664 | 'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccounts) |
@@ -707,8 +707,8 @@ discard block |
||
707 | 707 | 'payment_currency_exchange_wmu' => 30, |
708 | 708 | 'payment_currency_exchange_wmz' => 1, |
709 | 709 | |
710 | - 'payment_lot_price' => 1, // Lot price in default currency |
|
711 | - 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
710 | + 'payment_lot_price' => 1, // Lot price in default currency |
|
711 | + 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
712 | 712 | |
713 | 713 | 'planet_teleport_cost' => 50000, // |
714 | 714 | 'planet_teleport_timeout' => 86400, // |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | 'resource_multiplier' => 1, |
727 | 727 | |
728 | 728 | //Roleplay system |
729 | - 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
729 | + 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
730 | 730 | 'rpg_bonus_minimum' => 10000, // Minimum DM ammount for starting paying bonuses to affiliate |
731 | 731 | |
732 | 732 | // Black Market - General |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | } |
814 | 814 | |
815 | 815 | public static function getInstance($gamePrefix = 'sn_', $table_name = 'config') { |
816 | - if(!isset(self::$cacheObject)) { |
|
816 | + if (!isset(self::$cacheObject)) { |
|
817 | 817 | $className = get_class(); |
818 | 818 | self::$cacheObject = new $className($gamePrefix, $table_name); |
819 | 819 | } |