@@ -116,12 +116,12 @@ |
||
116 | 116 | * @return static |
117 | 117 | */ |
118 | 118 | public static function convertToVector($coordinates, $prefix = '') { |
119 | - $galaxy = !empty($coordinates[$prefix . 'galaxy']) ? intval($coordinates[$prefix . 'galaxy']) : 0; |
|
120 | - $system = !empty($coordinates[$prefix . 'system']) ? intval($coordinates[$prefix . 'system']) : 0; |
|
121 | - $planet = !empty($coordinates[$prefix . 'planet']) ? intval($coordinates[$prefix . 'planet']) : 0; |
|
122 | - $type = !empty($coordinates[$prefix . 'type']) |
|
123 | - ? intval($coordinates[$prefix . 'type']) |
|
124 | - : (!empty($coordinates[$prefix . 'planet_type']) ? intval($coordinates[$prefix . 'planet_type']) : 0); |
|
119 | + $galaxy = !empty($coordinates[$prefix.'galaxy']) ? intval($coordinates[$prefix.'galaxy']) : 0; |
|
120 | + $system = !empty($coordinates[$prefix.'system']) ? intval($coordinates[$prefix.'system']) : 0; |
|
121 | + $planet = !empty($coordinates[$prefix.'planet']) ? intval($coordinates[$prefix.'planet']) : 0; |
|
122 | + $type = !empty($coordinates[$prefix.'type']) |
|
123 | + ? intval($coordinates[$prefix.'type']) |
|
124 | + : (!empty($coordinates[$prefix.'planet_type']) ? intval($coordinates[$prefix.'planet_type']) : 0); |
|
125 | 125 | |
126 | 126 | return new static($galaxy, $system, $planet, $type); |
127 | 127 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | 'checkSpeedPercentOld' => FLIGHT_FLEET_SPEED_WRONG, |
11 | 11 | 'checkTargetInUniverse' => FLIGHT_VECTOR_BEYOND_UNIVERSE, |
12 | 12 | 'checkTargetNotSource' => FLIGHT_VECTOR_SAME_SOURCE, |
13 | - 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, // tODO |
|
13 | + 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, // tODO |
|
14 | 14 | 'checkTargetNoVacation' => FLIGHT_PLAYER_VACATION, |
15 | 15 | 'checkFleetNotEmpty' => FLIGHT_SHIPS_NO_SHIPS, |
16 | 16 | // 'checkUnitsPositive' => FLIGHT_SHIPS_NEGATIVE, // Unused - 'cause it's not allowed to put negative units into Unit class |
@@ -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 |
@@ -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', |
@@ -104,21 +104,21 @@ discard block |
||
104 | 104 | 'LEVEL' => 'submenu', |
105 | 105 | 'TYPE' => 'lang', |
106 | 106 | 'ITEM' => 'tech[UNIT_STRUCTURES]', |
107 | - 'LINK' => 'buildings.php?mode=' . QUE_STRUCTURES, |
|
107 | + 'LINK' => 'buildings.php?mode='.QUE_STRUCTURES, |
|
108 | 108 | 'ICON' => true, |
109 | 109 | ), |
110 | 110 | 'menu_planet_shipyard' => array( |
111 | 111 | 'LEVEL' => 'submenu', |
112 | 112 | 'TYPE' => 'lang', |
113 | 113 | 'ITEM' => 'Shipyard', |
114 | - 'LINK' => 'buildings.php?mode=' . SUBQUE_FLEET, |
|
114 | + 'LINK' => 'buildings.php?mode='.SUBQUE_FLEET, |
|
115 | 115 | 'ICON' => true, |
116 | 116 | ), |
117 | 117 | 'menu_planet_defense' => array( |
118 | 118 | 'LEVEL' => 'submenu', |
119 | 119 | 'TYPE' => 'lang', |
120 | 120 | 'ITEM' => 'Defense', |
121 | - 'LINK' => 'buildings.php?mode=' . SUBQUE_DEFENSE, |
|
121 | + 'LINK' => 'buildings.php?mode='.SUBQUE_DEFENSE, |
|
122 | 122 | 'ICON' => true, |
123 | 123 | ), |
124 | 124 | 'menu_planet_resources' => array( |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | 'LEVEL' => 'submenu', |
148 | 148 | 'TYPE' => 'lang', |
149 | 149 | 'ITEM' => 'Research', |
150 | - 'LINK' => 'buildings.php?mode=' . QUE_RESEARCH, |
|
150 | + 'LINK' => 'buildings.php?mode='.QUE_RESEARCH, |
|
151 | 151 | 'ICON' => true, |
152 | 152 | ), |
153 | 153 | 'menu_empire_techtree' => array( |
@@ -233,14 +233,14 @@ discard block |
||
233 | 233 | 'LEVEL' => 'submenu', |
234 | 234 | 'TYPE' => 'lang', |
235 | 235 | 'ITEM' => 'tech[UNIT_MERCENARIES]', |
236 | - 'LINK' => 'officer.php?mode=' . UNIT_MERCENARIES, |
|
236 | + 'LINK' => 'officer.php?mode='.UNIT_MERCENARIES, |
|
237 | 237 | 'ICON' => true, |
238 | 238 | ), |
239 | 239 | 'menu_empire_schematics' => array( |
240 | 240 | 'LEVEL' => 'submenu', |
241 | 241 | 'TYPE' => 'lang', |
242 | 242 | 'ITEM' => 'tech[UNIT_PLANS]', |
243 | - 'LINK' => 'officer.php?mode=' . UNIT_PLANS, |
|
243 | + 'LINK' => 'officer.php?mode='.UNIT_PLANS, |
|
244 | 244 | 'ICON' => true, |
245 | 245 | ), |
246 | 246 | 'menu_empire_artifacts' => array( |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | 'LEVEL' => 'submenu', |
271 | 271 | 'TYPE' => 'lang', |
272 | 272 | 'ITEM' => 'Chat', |
273 | - 'LINK' => 'index.php?page=chat&mode=' . CHAT_MODE_COMMON, |
|
273 | + 'LINK' => 'index.php?page=chat&mode='.CHAT_MODE_COMMON, |
|
274 | 274 | 'ICON' => true, |
275 | 275 | ), |
276 | 276 | 'menu_ally_chat' => array( |
277 | 277 | 'LEVEL' => 'submenu', |
278 | 278 | 'TYPE' => 'lang', |
279 | 279 | 'ITEM' => 'AllyChat', |
280 | - 'LINK' => 'index.php?page=chat&mode=' . CHAT_MODE_ALLY, |
|
280 | + 'LINK' => 'index.php?page=chat&mode='.CHAT_MODE_ALLY, |
|
281 | 281 | 'ICON' => true, |
282 | 282 | 'DISABLED' => classSupernova::$config->game_mode == GAME_BLITZ, |
283 | 283 | ), |
@@ -458,8 +458,8 @@ discard block |
||
458 | 458 | ), |
459 | 459 | 'menu_admin_version_info' => array( |
460 | 460 | 'TYPE' => 'text', |
461 | - 'ITEM' => (classSupernova::$config->server_updater_check_last ? date(FMT_DATE, classSupernova::$config->server_updater_check_last) : '') . '<div class="' . |
|
462 | - $sn_version_check_class[classSupernova::$config->server_updater_check_result] . '">' . classLocale::$lang['adm_opt_ver_response_short'][classSupernova::$config->server_updater_check_result] . '</div>', |
|
461 | + 'ITEM' => (classSupernova::$config->server_updater_check_last ? date(FMT_DATE, classSupernova::$config->server_updater_check_last) : '').'<div class="'. |
|
462 | + $sn_version_check_class[classSupernova::$config->server_updater_check_result].'">'.classLocale::$lang['adm_opt_ver_response_short'][classSupernova::$config->server_updater_check_result].'</div>', |
|
463 | 463 | ), |
464 | 464 | |
465 | 465 | 'USER_AUTHLEVEL_NAME' => array( |
@@ -547,13 +547,13 @@ discard block |
||
547 | 547 | 'menu_admin_planet_list_planets' => array( |
548 | 548 | 'TYPE' => 'lang', |
549 | 549 | 'ITEM' => 'adm_pltlst', |
550 | - 'LINK' => 'admin/adm_planet_list.php?planet_type=' . PT_PLANET, |
|
550 | + 'LINK' => 'admin/adm_planet_list.php?planet_type='.PT_PLANET, |
|
551 | 551 | 'AUTH_LEVEL' => 3, |
552 | 552 | ), |
553 | 553 | 'menu_admin_planet_list_moons' => array( |
554 | 554 | 'TYPE' => 'lang', |
555 | 555 | 'ITEM' => 'adm_moonlst', |
556 | - 'LINK' => 'admin/adm_planet_list.php?planet_type=' . PT_MOON, |
|
556 | + 'LINK' => 'admin/adm_planet_list.php?planet_type='.PT_MOON, |
|
557 | 557 | 'AUTH_LEVEL' => 3, |
558 | 558 | ), |
559 | 559 | 'menu_admin_planet_moon_add' => array( |
@@ -121,6 +121,9 @@ discard block |
||
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | + /** |
|
125 | + * @param string $filter |
|
126 | + */ |
|
124 | 127 | public static function queryCacheSetByFilter($location_type, $filter, $record_id) { |
125 | 128 | SnCache::$queries[$location_type][$filter][$record_id] = &SnCache::getDataRefByLocationAndId($location_type, $record_id); |
126 | 129 | } |
@@ -160,14 +163,23 @@ discard block |
||
160 | 163 | return true; // Не всегда - от результата |
161 | 164 | } |
162 | 165 | |
166 | + /** |
|
167 | + * @param integer $locationType |
|
168 | + */ |
|
163 | 169 | public static function getData($locationType = LOC_NONE) { |
164 | 170 | return $locationType == LOC_NONE ? static::$data : static::$data[$locationType]; |
165 | 171 | } |
166 | 172 | |
173 | + /** |
|
174 | + * @param integer $locationType |
|
175 | + */ |
|
167 | 176 | public static function cacheUnsetElement($locationType, $recordId) { |
168 | 177 | static::$data[$locationType][$recordId] = null; |
169 | 178 | } |
170 | 179 | |
180 | + /** |
|
181 | + * @param integer $locationType |
|
182 | + */ |
|
171 | 183 | public static function isArrayLocation($locationType) { |
172 | 184 | return is_array(static::$data[$locationType]); |
173 | 185 | } |
@@ -190,6 +202,9 @@ discard block |
||
190 | 202 | } |
191 | 203 | } |
192 | 204 | |
205 | + /** |
|
206 | + * @param integer $unit_snid |
|
207 | + */ |
|
193 | 208 | public static function getUnitLocator($location_type, $location_id, $unit_snid) { |
194 | 209 | return $unit_snid ? static::$locator[LOC_UNIT][$location_type][$location_id][$unit_snid] : static::$locator[LOC_UNIT][$location_type][$location_id]; |
195 | 210 | } |
@@ -222,14 +237,23 @@ discard block |
||
222 | 237 | return static::$locks; |
223 | 238 | } |
224 | 239 | |
240 | + /** |
|
241 | + * @param string $filter |
|
242 | + */ |
|
225 | 243 | public static function getQueriesByLocationAndFilter($locationType, $filter) { |
226 | 244 | return !empty(static::$queries[$locationType][$filter]) && is_array(static::$queries[$locationType][$filter]) ? static::$queries[$locationType][$filter] : array(); |
227 | 245 | } |
228 | 246 | |
247 | + /** |
|
248 | + * @param string $filter |
|
249 | + */ |
|
229 | 250 | public static function isQueryCacheByLocationAndFilterEmpty($locationType, $filter) { |
230 | 251 | return !isset(SnCache::$queries[$locationType][$filter]) || SnCache::$queries[$locationType][$filter] === null; |
231 | 252 | } |
232 | 253 | |
254 | + /** |
|
255 | + * @param string $filter |
|
256 | + */ |
|
233 | 257 | public static function queryCacheResetByLocationAndFilter($locationType, $filter) { |
234 | 258 | SnCache::$queries[$locationType][$filter] = array(); |
235 | 259 | } |
@@ -59,7 +59,7 @@ |
||
59 | 59 | if ($hard && !empty(static::$data[$location_type])) { |
60 | 60 | // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях |
61 | 61 | // TODO - replace with setNull |
62 | - array_walk(static::$data[$location_type], function (&$item) { $item = null; }); |
|
62 | + array_walk(static::$data[$location_type], function(&$item) { $item = null; }); |
|
63 | 63 | } |
64 | 64 | static::$locator[$location_type] = array(); |
65 | 65 | static::$queries[$location_type] = array(); |
@@ -81,6 +81,10 @@ discard block |
||
81 | 81 | // ------------------------------------------------------------------------- |
82 | 82 | // Here comes low-level functions - those that directly works with cacher engines |
83 | 83 | // ------------------------------------------------------------------------- |
84 | + |
|
85 | + /** |
|
86 | + * @param string $name |
|
87 | + */ |
|
84 | 88 | public function __set($name, $value) { |
85 | 89 | switch ($name) { |
86 | 90 | case '_MODE': |
@@ -132,6 +136,9 @@ discard block |
||
132 | 136 | return null; |
133 | 137 | } |
134 | 138 | |
139 | + /** |
|
140 | + * @param string $name |
|
141 | + */ |
|
135 | 142 | public function __isset($name) { |
136 | 143 | switch (self::$mode) { |
137 | 144 | case CACHER_NO_CACHE: |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | default: |
99 | 99 | switch (self::$mode) { |
100 | 100 | case CACHER_NO_CACHE: |
101 | - self::$data[$this->prefix . $name] = $value; |
|
101 | + self::$data[$this->prefix.$name] = $value; |
|
102 | 102 | break; |
103 | 103 | |
104 | 104 | case CACHER_XCACHE: |
105 | - xcache_set($this->prefix . $name, $value); |
|
105 | + xcache_set($this->prefix.$name, $value); |
|
106 | 106 | break; |
107 | 107 | } |
108 | 108 | break; |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | default: |
123 | 123 | switch (self::$mode) { |
124 | 124 | case CACHER_NO_CACHE: |
125 | - return self::$data[$this->prefix . $name]; |
|
125 | + return self::$data[$this->prefix.$name]; |
|
126 | 126 | break; |
127 | 127 | |
128 | 128 | case CACHER_XCACHE: |
129 | - return xcache_get($this->prefix . $name); |
|
129 | + return xcache_get($this->prefix.$name); |
|
130 | 130 | break; |
131 | 131 | |
132 | 132 | } |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | public function __isset($name) { |
140 | 140 | switch (self::$mode) { |
141 | 141 | case CACHER_NO_CACHE: |
142 | - return isset(self::$data[$this->prefix . $name]); |
|
142 | + return isset(self::$data[$this->prefix.$name]); |
|
143 | 143 | break; |
144 | 144 | |
145 | 145 | case CACHER_XCACHE: |
146 | - return xcache_isset($this->prefix . $name) && ($this->__get($name) !== null); |
|
146 | + return xcache_isset($this->prefix.$name) && ($this->__get($name) !== null); |
|
147 | 147 | break; |
148 | 148 | } |
149 | 149 | |
@@ -153,25 +153,25 @@ discard block |
||
153 | 153 | public function __unset($name) { |
154 | 154 | switch (self::$mode) { |
155 | 155 | case CACHER_NO_CACHE: |
156 | - unset(self::$data[$this->prefix . $name]); |
|
156 | + unset(self::$data[$this->prefix.$name]); |
|
157 | 157 | break; |
158 | 158 | |
159 | 159 | case CACHER_XCACHE: |
160 | - xcache_unset($this->prefix . $name); |
|
160 | + xcache_unset($this->prefix.$name); |
|
161 | 161 | break; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | 165 | public function unset_by_prefix($prefix_unset = '') { |
166 | 166 | static $array_clear; |
167 | - !$array_clear ? $array_clear = function (&$v, $k, $p) { |
|
167 | + !$array_clear ? $array_clear = function(&$v, $k, $p) { |
|
168 | 168 | strpos($k, $p) === 0 ? $v = null : false; |
169 | 169 | } : false; |
170 | 170 | |
171 | 171 | switch (self::$mode) { |
172 | 172 | case CACHER_NO_CACHE: |
173 | 173 | // array_walk(self::$data, create_function('&$v,$k,$p', 'if(strpos($k, $p) === 0)$v = NULL;'), $this->prefix.$prefix_unset); |
174 | - array_walk(self::$data, $array_clear, $this->prefix . $prefix_unset); |
|
174 | + array_walk(self::$data, $array_clear, $this->prefix.$prefix_unset); |
|
175 | 175 | |
176 | 176 | return true; |
177 | 177 | break; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | |
184 | - return xcache_unset_by_prefix($this->prefix . $prefix_unset); |
|
184 | + return xcache_unset_by_prefix($this->prefix.$prefix_unset); |
|
185 | 185 | break; |
186 | 186 | } |
187 | 187 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | if ($this->$name[0] === null) { |
220 | 220 | for ($i = count($name) - 1; $i > 0; $i--) { |
221 | 221 | $cName = "{$name[$i]}_COUNT"; |
222 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
222 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
223 | 223 | if ($this->$cName1 == null || $i == 1) { |
224 | 224 | $this->$cName++; |
225 | 225 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | |
265 | 265 | for ($i = 1; $i < count($name); $i++) { |
266 | 266 | $cName = "{$name[$i]}_COUNT"; |
267 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
267 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
268 | 268 | |
269 | 269 | if ($i == 1 || $this->$cName1 === null) { |
270 | 270 | $this->$cName--; |
@@ -173,6 +173,9 @@ |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | |
176 | + /** |
|
177 | + * @param string $path |
|
178 | + */ |
|
176 | 179 | protected function lng_try_filepath($path, $file_path_relative) { |
177 | 180 | $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
178 | 181 | return file_exists($file_path) ? $file_path : false; |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | |
36 | 36 | $this->container = array(); |
37 | 37 | |
38 | - if(classSupernova::$cache->_MODE != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
38 | + if (classSupernova::$cache->_MODE != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
39 | 39 | $this->cache = classSupernova::$cache; |
40 | 40 | classSupernova::log_file('locale.__constructor: Cache is present'); |
41 | 41 | //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug! |
42 | 42 | } |
43 | 43 | |
44 | - if($enable_stat_usage && empty($this->stat_usage)) { |
|
44 | + if ($enable_stat_usage && empty($this->stat_usage)) { |
|
45 | 45 | $this->enable_stat_usage = $enable_stat_usage; |
46 | 46 | $this->usage_stat_load(); |
47 | 47 | // TODO shutdown function |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | unset($fallback[$this->active]); |
68 | 68 | |
69 | 69 | // Проходим по оставшимся локалям |
70 | - foreach($fallback as $try_language) { |
|
70 | + foreach ($fallback as $try_language) { |
|
71 | 71 | // Если нет такой строки - пытаемся вытащить из кэша |
72 | - if(!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
73 | - $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset); |
|
72 | + if (!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
73 | + $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix.$try_language.'_'.$offset); |
|
74 | 74 | // Записываем результат работы кэша |
75 | 75 | $locale_cache_statistic['queries']++; |
76 | 76 | isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['hits']++ : $locale_cache_statistic['misses']++; |
77 | -!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix . $try_language . '_' . $offset : false; |
|
77 | +!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix.$try_language.'_'.$offset : false; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Если мы как-то где-то нашли строку... |
81 | - if(isset($this->container[$try_language][$offset])) { |
|
81 | + if (isset($this->container[$try_language][$offset])) { |
|
82 | 82 | // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер |
83 | 83 | $this[$offset] = $this->container[$try_language][$offset]; |
84 | 84 | $locale_cache_statistic['fallbacks']++; |
@@ -94,16 +94,16 @@ discard block |
||
94 | 94 | $this->container[$this->active][] = $value; |
95 | 95 | } else { |
96 | 96 | $this->container[$this->active][$offset] = $value; |
97 | - if($this->cache) { |
|
98 | - $this->cache->__set($this->cache_prefix_lang . $offset, $value); |
|
97 | + if ($this->cache) { |
|
98 | + $this->cache->__set($this->cache_prefix_lang.$offset, $value); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | 102 | public function offsetExists($offset) { |
103 | 103 | // Шорткат если у нас уже есть строка в памяти PHP |
104 | - if(!isset($this->container[$this->active][$offset])) { |
|
104 | + if (!isset($this->container[$this->active][$offset])) { |
|
105 | 105 | // pdump($this->cache_prefix_lang . $offset); |
106 | - if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
106 | + if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang.$offset))) { |
|
107 | 107 | // pdump($this->cache_prefix_lang . $offset); |
108 | 108 | // Если нету такой строки - делаем фоллбэк |
109 | 109 | $this->locale_string_fallback($offset); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | public function offsetGet($offset) { |
121 | 121 | $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null; |
122 | - if($this->enable_stat_usage) { |
|
122 | + if ($this->enable_stat_usage) { |
|
123 | 123 | $this->usage_stat_log($offset, $value); |
124 | 124 | } |
125 | 125 | return $value; |
@@ -134,25 +134,25 @@ discard block |
||
134 | 134 | |
135 | 135 | |
136 | 136 | public function usage_stat_load() { |
137 | - $this->stat_usage = classSupernova::$cache->lng_stat_usage = array(); // TODO for debug |
|
138 | - if(empty($this->stat_usage)) { |
|
137 | + $this->stat_usage = classSupernova::$cache->lng_stat_usage = array(); // TODO for debug |
|
138 | + if (empty($this->stat_usage)) { |
|
139 | 139 | $query = doquery("SELECT * FROM {{lng_usage_stat}}"); |
140 | - while($row = db_fetch($query)) { |
|
141 | - $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty']; |
|
140 | + while ($row = db_fetch($query)) { |
|
141 | + $this->stat_usage[$row['lang_code'].':'.$row['string_id'].':'.$row['file'].':'.$row['line']] = $row['is_empty']; |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
145 | 145 | public function usage_stat_save() { |
146 | - if(!empty($this->stat_usage_new)) { |
|
146 | + if (!empty($this->stat_usage_new)) { |
|
147 | 147 | classSupernova::$cache->lng_stat_usage = $this->stat_usage; |
148 | 148 | doquery("SELECT 1 FROM {{lng_usage_stat}} LIMIT 1"); |
149 | - foreach($this->stat_usage_new as &$value) { |
|
150 | - foreach($value as &$value2) { |
|
151 | - $value2 = '"' . db_escape($value2) . '"'; |
|
149 | + foreach ($this->stat_usage_new as &$value) { |
|
150 | + foreach ($value as &$value2) { |
|
151 | + $value2 = '"'.db_escape($value2).'"'; |
|
152 | 152 | } |
153 | - $value = '(' . implode(',', $value) .')'; |
|
153 | + $value = '('.implode(',', $value).')'; |
|
154 | 154 | } |
155 | - doquery("REPLACE INTO {{lng_usage_stat}} (lang_code,string_id,`file`,line,is_empty,locale) VALUES " . implode(',', $this->stat_usage_new)); |
|
155 | + doquery("REPLACE INTO {{lng_usage_stat}} (lang_code,string_id,`file`,line,is_empty,locale) VALUES ".implode(',', $this->stat_usage_new)); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | public function usage_stat_log(&$offset, &$value) { |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | |
163 | 163 | $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1)); |
164 | 164 | |
165 | - $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line']; |
|
166 | - if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
165 | + $string_id = $this->active.':'.$offset.':'.$file.':'.$trace[1]['line']; |
|
166 | + if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
167 | 167 | $this->stat_usage[$string_id] = empty($value); |
168 | 168 | $this->stat_usage_new[] = array( |
169 | 169 | 'lang_code' => $this->active, |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | 'file' => $file, |
172 | 172 | 'line' => $trace[1]['line'], |
173 | 173 | 'is_empty' => intval(empty($value)), |
174 | - 'locale' => '' . $value, |
|
174 | + 'locale' => ''.$value, |
|
175 | 175 | ); |
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | 179 | |
180 | 180 | protected function lng_try_filepath($path, $file_path_relative) { |
181 | - $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
|
181 | + $file_path = SN_ROOT_PHYSICAL.($path && file_exists(SN_ROOT_PHYSICAL.$path.$file_path_relative) ? $path : '').$file_path_relative; |
|
182 | 182 | return file_exists($file_path) ? $file_path : false; |
183 | 183 | } |
184 | 184 | |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | |
201 | 201 | classSupernova::log_file("locale.include: Loading data from domain '{$filename}'", 1); |
202 | 202 | |
203 | - $cache_file_key = $this->cache_prefix_lang . '__' . $filename; |
|
203 | + $cache_file_key = $this->cache_prefix_lang.'__'.$filename; |
|
204 | 204 | |
205 | 205 | // Подключен ли внешний кэш? |
206 | - if($this->cache) { |
|
206 | + if ($this->cache) { |
|
207 | 207 | // Загружен ли уже данный файл? |
208 | 208 | $cache_file_status = $this->cache->__get($cache_file_key); |
209 | - classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is " . ($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0); |
|
210 | - if($cache_file_status) { |
|
209 | + classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is ".($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0); |
|
210 | + if ($cache_file_status) { |
|
211 | 211 | // Если да - повторять загрузку нет смысла |
212 | 212 | return null; |
213 | 213 | } |
@@ -221,47 +221,47 @@ discard block |
||
221 | 221 | $this->make_fallback($language); |
222 | 222 | |
223 | 223 | $file_path = ''; |
224 | - foreach($this->fallback as $lang_try) { |
|
225 | - if(!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
224 | + foreach ($this->fallback as $lang_try) { |
|
225 | + if (!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | |
229 | - if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
229 | + if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
230 | 230 | break; |
231 | 231 | } |
232 | 232 | |
233 | - if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
233 | + if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
234 | 234 | break; |
235 | 235 | } |
236 | 236 | |
237 | 237 | $file_path = ''; |
238 | 238 | } |
239 | 239 | |
240 | - if($file_path) { |
|
240 | + if ($file_path) { |
|
241 | 241 | $a_lang_array = array(); |
242 | 242 | include($file_path); |
243 | 243 | |
244 | - if(!empty($a_lang_array)) { |
|
244 | + if (!empty($a_lang_array)) { |
|
245 | 245 | $this->merge($a_lang_array); |
246 | 246 | |
247 | 247 | // Загрузка данных из файла в кэш |
248 | - if($this->cache) { |
|
248 | + if ($this->cache) { |
|
249 | 249 | classSupernova::log_file("Locale: loading '{$filename}' into cache"); |
250 | - foreach($a_lang_array as $key => $value) { |
|
251 | - $value_cache_key = $this->cache_prefix_lang . $key; |
|
252 | - if($this->cache->__isset($value_cache_key)) { |
|
253 | - if(is_array($value)) { |
|
250 | + foreach ($a_lang_array as $key => $value) { |
|
251 | + $value_cache_key = $this->cache_prefix_lang.$key; |
|
252 | + if ($this->cache->__isset($value_cache_key)) { |
|
253 | + if (is_array($value)) { |
|
254 | 254 | $alt_value = $this->cache->__get($value_cache_key); |
255 | 255 | $value = array_replace_recursive($alt_value, $value); |
256 | 256 | // pdump($alt_value, $alt_value); |
257 | 257 | } |
258 | 258 | } |
259 | - $this->cache->__set($this->cache_prefix_lang . $key, $value); |
|
259 | + $this->cache->__set($this->cache_prefix_lang.$key, $value); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - if($this->cache) { |
|
264 | + if ($this->cache) { |
|
265 | 265 | $this->cache->__set($cache_file_key, true); |
266 | 266 | } |
267 | 267 | |
@@ -274,14 +274,14 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | public function lng_load_i18n($i18n) { |
277 | - if(!isset($i18n)) { |
|
277 | + if (!isset($i18n)) { |
|
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
281 | - foreach($i18n as $i18n_data) { |
|
282 | - if(is_string($i18n_data)) { |
|
281 | + foreach ($i18n as $i18n_data) { |
|
282 | + if (is_string($i18n_data)) { |
|
283 | 283 | $this->lng_include($i18n_data); |
284 | - } elseif(is_array($i18n_data)) { |
|
284 | + } elseif (is_array($i18n_data)) { |
|
285 | 285 | $this->lng_include($i18n_data['file'], $i18n_data['path']); |
286 | 286 | } |
287 | 287 | } |
@@ -299,27 +299,27 @@ discard block |
||
299 | 299 | |
300 | 300 | classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'"); |
301 | 301 | |
302 | - if($language_new == $this->active) { |
|
302 | + if ($language_new == $this->active) { |
|
303 | 303 | classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1); |
304 | 304 | return false; |
305 | 305 | } |
306 | 306 | |
307 | 307 | $this->active = $language = $language_new; |
308 | - $this->cache_prefix_lang = $this->cache_prefix . $this->active . '_'; |
|
308 | + $this->cache_prefix_lang = $this->cache_prefix.$this->active.'_'; |
|
309 | 309 | |
310 | 310 | $this['LANG_INFO'] = $this->lng_get_info($this->active); |
311 | 311 | $this->make_fallback($this->active); |
312 | 312 | |
313 | - if($this->cache) { |
|
314 | - $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT'); |
|
315 | - classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is " . ($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0); |
|
316 | - if($cache_lang_init_status) { |
|
313 | + if ($this->cache) { |
|
314 | + $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang.'__INIT'); |
|
315 | + classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is ".($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0); |
|
316 | + if ($cache_lang_init_status) { |
|
317 | 317 | return false; |
318 | 318 | } |
319 | 319 | |
320 | 320 | // Чистим текущие локализации из кэша. Достаточно почистить только флаги инициализации языкового кэша и загрузки файлов - они начинаются с '__' |
321 | 321 | classSupernova::log_file("locale.switch: Cache - invalidating data"); |
322 | - $this->cache->unset_by_prefix($this->cache_prefix_lang . '__'); |
|
322 | + $this->cache->unset_by_prefix($this->cache_prefix_lang.'__'); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | $this->lng_include('system'); |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | // Loading global language files |
330 | 330 | $this->lng_load_i18n(classSupernova::$sn_mvc['i18n']['']); |
331 | 331 | |
332 | - if($this->cache) { |
|
333 | - classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT'); |
|
334 | - $this->cache->__set($this->cache_prefix_lang . '__INIT', true); |
|
332 | + if ($this->cache) { |
|
333 | + classSupernova::log_file("locale.switch: Cache - setting flag ".$this->cache_prefix_lang.'__INIT'); |
|
334 | + $this->cache->__set($this->cache_prefix_lang.'__INIT', true); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | classSupernova::log_file("locale.switch: Complete - EXIT"); |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | |
342 | 342 | |
343 | 343 | public function lng_get_info($entry) { |
344 | - $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php'; |
|
344 | + $file_name = SN_ROOT_PHYSICAL.'language/'.$entry.'/language.mo.php'; |
|
345 | 345 | $lang_info = array(); |
346 | - if(file_exists($file_name)) { |
|
346 | + if (file_exists($file_name)) { |
|
347 | 347 | include($file_name); |
348 | 348 | } |
349 | 349 | |
@@ -351,15 +351,15 @@ discard block |
||
351 | 351 | } |
352 | 352 | |
353 | 353 | public function lng_get_list() { |
354 | - if(empty($this->lang_list)) { |
|
354 | + if (empty($this->lang_list)) { |
|
355 | 355 | $this->lang_list = array(); |
356 | 356 | |
357 | - $path = SN_ROOT_PHYSICAL . 'language/'; |
|
357 | + $path = SN_ROOT_PHYSICAL.'language/'; |
|
358 | 358 | $dir = dir($path); |
359 | - while(false !== ($entry = $dir->read())) { |
|
360 | - if(is_dir($path . $entry) && $entry[0] != '.') { |
|
359 | + while (false !== ($entry = $dir->read())) { |
|
360 | + if (is_dir($path.$entry) && $entry[0] != '.') { |
|
361 | 361 | $lang_info = $this->lng_get_info($entry); |
362 | - if($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
362 | + if ($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
363 | 363 | $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info; |
364 | 364 | } |
365 | 365 | } |
@@ -70,6 +70,9 @@ discard block |
||
70 | 70 | $this->numqueries = 0; |
71 | 71 | } |
72 | 72 | |
73 | + /** |
|
74 | + * @param string $mes |
|
75 | + */ |
|
73 | 76 | function add($mes) { |
74 | 77 | $this->log .= $mes; |
75 | 78 | $this->numqueries++; |
@@ -185,6 +188,9 @@ discard block |
||
185 | 188 | return $error_backtrace; |
186 | 189 | } |
187 | 190 | |
191 | + /** |
|
192 | + * @param string $die_message |
|
193 | + */ |
|
188 | 194 | function error_fatal($die_message, $details = 'There is a fatal error on page') { |
189 | 195 | // TODO - Записывать детали ошибки в лог-файл |
190 | 196 | die($die_message); |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | |
31 | 31 | defined('INSIDE') || die(); |
32 | 32 | |
33 | -if(php_sapi_name() == "cli") { |
|
33 | +if (php_sapi_name() == "cli") { |
|
34 | 34 | // In cli-mode |
35 | 35 | define('__DEBUG_CRLF', "\r\n"); |
36 | - define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF); |
|
36 | + define('__DEBUG_LINE', '-------------------------------------------------'.__DEBUG_CRLF); |
|
37 | 37 | } else { |
38 | 38 | // Not in cli-mode |
39 | 39 | define('__DEBUG_CRLF', '<br />'); |
@@ -50,17 +50,17 @@ discard block |
||
50 | 50 | function log_file($message, $ident_change = 0) { |
51 | 51 | static $ident = 0; |
52 | 52 | |
53 | - if(!defined('SN_DEBUG_LOG')) { |
|
53 | + if (!defined('SN_DEBUG_LOG')) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - if($this->log_file_handler === null) { |
|
58 | - $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
|
57 | + if ($this->log_file_handler === null) { |
|
58 | + $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL.'/.logs/supernova.log', 'a+'); |
|
59 | 59 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
60 | 60 | } |
61 | 61 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
62 | - if($this->log_file_handler) { |
|
63 | - @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
|
62 | + if ($this->log_file_handler) { |
|
63 | + @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()).str_repeat(' ', $ident + 1).$message."\r\n"); |
|
64 | 64 | } |
65 | 65 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
66 | 66 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | function echo_log() { |
83 | - echo '<br><table><tr><td class=k colspan=4><a href="' . SN_ROOT_PHYSICAL . "admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>"; |
|
83 | + echo '<br><table><tr><td class=k colspan=4><a href="'.SN_ROOT_PHYSICAL."admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>"; |
|
84 | 84 | die(); |
85 | 85 | } |
86 | 86 | |
@@ -90,25 +90,25 @@ discard block |
||
90 | 90 | $result = array(); |
91 | 91 | $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++; |
92 | 92 | $result[] = "tID {$transaction_id}"; |
93 | - foreach($backtrace as $a_trace) { |
|
94 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
93 | + foreach ($backtrace as $a_trace) { |
|
94 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | $function = |
98 | 98 | ($a_trace['type'] |
99 | 99 | ? ($a_trace['type'] == '->' |
100 | - ? "({$a_trace['class']})" . get_class($a_trace['object']) |
|
100 | + ? "({$a_trace['class']})".get_class($a_trace['object']) |
|
101 | 101 | : $a_trace['class'] |
102 | - ) . $a_trace['type'] |
|
102 | + ).$a_trace['type'] |
|
103 | 103 | : '' |
104 | - ) . $a_trace['function'] . '()'; |
|
104 | + ).$a_trace['function'].'()'; |
|
105 | 105 | |
106 | 106 | $file = str_replace(SN_ROOT_PHYSICAL, '', str_replace('\\', '/', $a_trace['file'])); |
107 | 107 | |
108 | 108 | // $result[] = "{$function} ({$a_trace['line']})'{$file}'"; |
109 | 109 | $result[] = "{$function} - '{$file}' Line {$a_trace['line']}"; |
110 | 110 | |
111 | - if(!$long_comment) { |
|
111 | + if (!$long_comment) { |
|
112 | 112 | break; |
113 | 113 | } |
114 | 114 | } |
@@ -122,26 +122,26 @@ discard block |
||
122 | 122 | function dump($dump = false, $force_base = false, $deadlock = false) { |
123 | 123 | global $user, $planetrow; |
124 | 124 | |
125 | - if($dump === false) { |
|
125 | + if ($dump === false) { |
|
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | 129 | $error_backtrace = array(); |
130 | 130 | $base_dump = false; |
131 | 131 | |
132 | - if($force_base === true) { |
|
132 | + if ($force_base === true) { |
|
133 | 133 | $base_dump = true; |
134 | 134 | } |
135 | 135 | |
136 | - if($dump === true) { |
|
136 | + if ($dump === true) { |
|
137 | 137 | $base_dump = true; |
138 | 138 | } else { |
139 | - if(!is_array($dump)) { |
|
139 | + if (!is_array($dump)) { |
|
140 | 140 | $dump = array('var' => $dump); |
141 | 141 | } |
142 | 142 | |
143 | - foreach($dump as $dump_var_name => $dump_var) { |
|
144 | - if($dump_var_name == 'base_dump') { |
|
143 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
144 | + if ($dump_var_name == 'base_dump') { |
|
145 | 145 | $base_dump = $dump_var; |
146 | 146 | } else { |
147 | 147 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -149,22 +149,21 @@ discard block |
||
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
152 | + if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
153 | 153 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
154 | 154 | $error_backtrace['locks'] = SnCache::getLocks(); |
155 | 155 | $error_backtrace['cSN_data'] = SnCache::getData(); |
156 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
157 | - foreach($location as $location_id => &$location_data) { |
|
158 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
159 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
156 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
157 | + foreach ($location as $location_id => &$location_data) { |
|
158 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
160 | 159 | } |
161 | 160 | } |
162 | 161 | $error_backtrace['cSN_queries'] = SnCache::getQueries(); |
163 | 162 | } |
164 | 163 | |
165 | - if($base_dump) { |
|
166 | - if(is_array($this->log_array) && count($this->log_array) > 0) { |
|
167 | - foreach($this->log_array as $log) { |
|
164 | + if ($base_dump) { |
|
165 | + if (is_array($this->log_array) && count($this->log_array) > 0) { |
|
166 | + foreach ($this->log_array as $log) { |
|
168 | 167 | $error_backtrace['queries'][] = $log; |
169 | 168 | } |
170 | 169 | } |
@@ -193,14 +192,14 @@ discard block |
||
193 | 192 | function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
194 | 193 | global $sys_stop_log_hit, $sys_log_disabled, $user; |
195 | 194 | |
196 | - if(empty(classSupernova::$db->connected)) { |
|
195 | + if (empty(classSupernova::$db->connected)) { |
|
197 | 196 | // TODO - писать ошибку в файл |
198 | 197 | die('SQL server currently unavailable. Please contact Administration...'); |
199 | 198 | } |
200 | 199 | |
201 | 200 | sn_db_transaction_rollback(); |
202 | 201 | |
203 | - if(classSupernova::$config->debug == 1) { |
|
202 | + if (classSupernova::$config->debug == 1) { |
|
204 | 203 | echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>"; |
205 | 204 | echo "<table>{$this->log}</table>"; |
206 | 205 | } |
@@ -212,16 +211,16 @@ discard block |
||
212 | 211 | |
213 | 212 | $userId = empty($user['id']) ? 0 : $user['id']; |
214 | 213 | |
215 | - if(!$sys_log_disabled) { |
|
214 | + if (!$sys_log_disabled) { |
|
216 | 215 | $query = "INSERT INTO `{{logs}}` SET |
217 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "', |
|
218 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
219 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
216 | + `log_time` = '" . time()."', `log_code` = '".db_escape($error_code)."', `log_sender` = '".db_escape($userId)."', |
|
217 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
218 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
220 | 219 | // ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";"; |
221 | - ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";"; |
|
222 | - doquery($query, '', false, true) or die($fatal_error . classSupernova::$db->db_error()); |
|
220 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
221 | + doquery($query, '', false, true) or die($fatal_error.classSupernova::$db->db_error()); |
|
223 | 222 | |
224 | - $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . classSupernova::$db->db_insert_id() . "</b>"; |
|
223 | + $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>".classSupernova::$db->db_insert_id()."</b>"; |
|
225 | 224 | |
226 | 225 | $sys_stop_log_hit = true; |
227 | 226 | $sys_log_disabled = true; |
@@ -231,7 +230,7 @@ discard block |
||
231 | 230 | ob_start(); |
232 | 231 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
233 | 232 | |
234 | - foreach($error_backtrace as $name => $value) { |
|
233 | + foreach ($error_backtrace as $name => $value) { |
|
235 | 234 | print(__DEBUG_LINE); |
236 | 235 | pdump($value, $name); |
237 | 236 | } |
@@ -243,7 +242,7 @@ discard block |
||
243 | 242 | function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
244 | 243 | global $user, $sys_log_disabled; |
245 | 244 | |
246 | - if(empty(classSupernova::$db->connected)) { |
|
245 | + if (empty(classSupernova::$db->connected)) { |
|
247 | 246 | // TODO - писать ошибку в файл |
248 | 247 | die('SQL server currently unavailable. Please contact Administration...'); |
249 | 248 | } |
@@ -252,12 +251,12 @@ discard block |
||
252 | 251 | |
253 | 252 | $userId = empty($user['id']) ? 0 : $user['id']; |
254 | 253 | |
255 | - if(!$sys_log_disabled) { |
|
254 | + if (!$sys_log_disabled) { |
|
256 | 255 | $query = "INSERT INTO `{{logs}}` SET |
257 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "', |
|
258 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
259 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
260 | - ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";"; |
|
256 | + `log_time` = '" . time()."', `log_code` = '".db_escape($log_code)."', `log_sender` = '".db_escape($userId)."', |
|
257 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
258 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
259 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
261 | 260 | doquery($query, '', false, true); |
262 | 261 | } else { |
263 | 262 | // // TODO Здесь надо писать в файло |
@@ -270,11 +269,11 @@ discard block |
||
270 | 269 | // Dump variables nicer then var_dump() |
271 | 270 | |
272 | 271 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
273 | - if(isset($varname)) { |
|
272 | + if (isset($varname)) { |
|
274 | 273 | $varname .= " = "; |
275 | 274 | } |
276 | 275 | |
277 | - if($level == -1) { |
|
276 | + if ($level == -1) { |
|
278 | 277 | $trans[' '] = '∴'; |
279 | 278 | $trans["\t"] = '⇒'; |
280 | 279 | $trans["\n"] = '¶;'; |
@@ -283,31 +282,31 @@ discard block |
||
283 | 282 | |
284 | 283 | return strtr(htmlspecialchars($value), $trans); |
285 | 284 | } |
286 | - if($level == 0) { |
|
285 | + if ($level == 0) { |
|
287 | 286 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
288 | - $dumper = mt_rand(10, 99) . '|' . $varname; |
|
287 | + $dumper = mt_rand(10, 99).'|'.$varname; |
|
289 | 288 | } |
290 | 289 | |
291 | 290 | $type = gettype($value); |
292 | 291 | $dumper .= $type; |
293 | 292 | |
294 | - if($type == 'string') { |
|
295 | - $dumper .= '(' . strlen($value) . ')'; |
|
293 | + if ($type == 'string') { |
|
294 | + $dumper .= '('.strlen($value).')'; |
|
296 | 295 | $value = dump($value, '', -1); |
297 | - } elseif($type == 'boolean') { |
|
296 | + } elseif ($type == 'boolean') { |
|
298 | 297 | $value = ($value ? 'true' : 'false'); |
299 | - } elseif($type == 'object') { |
|
298 | + } elseif ($type == 'object') { |
|
300 | 299 | $props = get_class_vars(get_class($value)); |
301 | - $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
|
302 | - foreach($props as $key => $val) { |
|
303 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
|
300 | + $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
|
301 | + foreach ($props as $key => $val) { |
|
302 | + $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => '; |
|
304 | 303 | $dumper .= dump($value->$key, '', $level + 1); |
305 | 304 | } |
306 | 305 | $value = ''; |
307 | - } elseif($type == 'array') { |
|
308 | - $dumper .= '(' . count($value) . ')'; |
|
309 | - foreach($value as $key => $val) { |
|
310 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
|
306 | + } elseif ($type == 'array') { |
|
307 | + $dumper .= '('.count($value).')'; |
|
308 | + foreach ($value as $key => $val) { |
|
309 | + $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, '', -1).' => '; |
|
311 | 310 | $dumper .= dump($val, '', $level + 1); |
312 | 311 | } |
313 | 312 | $value = ''; |
@@ -326,24 +325,24 @@ discard block |
||
326 | 325 | // $backtrace = $backtrace[1]; |
327 | 326 | |
328 | 327 | $caller = ''; |
329 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
330 | - $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
|
331 | - (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
|
332 | - $backtrace[1]['function'] . |
|
328 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
329 | + $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : ''). |
|
330 | + (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : ''). |
|
331 | + $backtrace[1]['function']. |
|
333 | 332 | (!empty($backtrace[0]['file']) |
334 | 333 | ? ( |
335 | - ' (' . substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN) . |
|
336 | - (!empty($backtrace[0]['line']) ? ':' . $backtrace[0]['line'] : '') . |
|
334 | + ' ('.substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN). |
|
335 | + (!empty($backtrace[0]['line']) ? ':'.$backtrace[0]['line'] : ''). |
|
337 | 336 | ')' |
338 | 337 | ) |
339 | 338 | : '' |
340 | 339 | ); |
341 | - $caller = "\r\n" . $caller; |
|
340 | + $caller = "\r\n".$caller; |
|
342 | 341 | } |
343 | 342 | |
344 | - print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">' . |
|
345 | - dump($value, $varname) . |
|
346 | - $caller . |
|
343 | + print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">'. |
|
344 | + dump($value, $varname). |
|
345 | + $caller. |
|
347 | 346 | '</pre>' |
348 | 347 | ); |
349 | 348 | } |
@@ -353,24 +352,24 @@ discard block |
||
353 | 352 | } |
354 | 353 | |
355 | 354 | function pr($prePrint = false) { |
356 | - if($prePrint) { |
|
355 | + if ($prePrint) { |
|
357 | 356 | print(__DEBUG_CRLF); |
358 | 357 | } |
359 | - print(mt_rand() . __DEBUG_CRLF); |
|
358 | + print(mt_rand().__DEBUG_CRLF); |
|
360 | 359 | } |
361 | 360 | |
362 | 361 | function pc($prePrint = false) { |
363 | 362 | global $_PRINT_COUNT_VALUE; |
364 | 363 | $_PRINT_COUNT_VALUE++; |
365 | 364 | |
366 | - if($prePrint) { |
|
365 | + if ($prePrint) { |
|
367 | 366 | print(__DEBUG_CRLF); |
368 | 367 | } |
369 | - print($_PRINT_COUNT_VALUE . __DEBUG_CRLF); |
|
368 | + print($_PRINT_COUNT_VALUE.__DEBUG_CRLF); |
|
370 | 369 | } |
371 | 370 | |
372 | 371 | function prep($message) { |
373 | - print('<pre>' . $message . '</pre>'); |
|
372 | + print('<pre>'.$message.'</pre>'); |
|
374 | 373 | } |
375 | 374 | |
376 | 375 | function backtrace_no_arg() { |
@@ -393,5 +392,5 @@ discard block |
||
393 | 392 | */ |
394 | 393 | function pdie($message = '') { |
395 | 394 | $backtrace = debug_backtrace(); |
396 | - die(__DEBUG_LINE . ($message ? $message . ' @ ' : '') . $backtrace[0]['file'] . ':' . $backtrace[0]['line']); |
|
395 | + die(__DEBUG_LINE.($message ? $message.' @ ' : '').$backtrace[0]['file'].':'.$backtrace[0]['line']); |
|
397 | 396 | } |