@@ -1,26 +1,26 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * chat.php |
|
| 4 | - * Main chat window |
|
| 5 | - * |
|
| 6 | - * Changelog: |
|
| 7 | - * 4.0 copyright © 2009-2012 Gorlum for http://supernova.ws |
|
| 8 | - * [!] Another rewrite |
|
| 9 | - * [+] preMVC-compatible |
|
| 10 | - * 3.0 copyright © 2009-2011 Gorlum for http://supernova.ws |
|
| 11 | - * [!] Almost full rewrote |
|
| 12 | - * [+] Complies with PCG1 |
|
| 13 | - * 2.0 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
| 14 | - * [+] Rewrote to remove unnecessary code dupes |
|
| 15 | - * 1.5 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
| 16 | - * [~] More DDoS-realted fixes |
|
| 17 | - * 1.4 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
| 18 | - * [~] DDoS-realted fixes |
|
| 19 | - * 1.3 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
| 20 | - * [~] Security checks for SQL-injection |
|
| 21 | - * 1.2 by Ihor |
|
| 22 | - * 1.0 Shoutbox copyright © 2008 by e-Zobar for XNova |
|
| 23 | - **/ |
|
| 3 | + * chat.php |
|
| 4 | + * Main chat window |
|
| 5 | + * |
|
| 6 | + * Changelog: |
|
| 7 | + * 4.0 copyright © 2009-2012 Gorlum for http://supernova.ws |
|
| 8 | + * [!] Another rewrite |
|
| 9 | + * [+] preMVC-compatible |
|
| 10 | + * 3.0 copyright © 2009-2011 Gorlum for http://supernova.ws |
|
| 11 | + * [!] Almost full rewrote |
|
| 12 | + * [+] Complies with PCG1 |
|
| 13 | + * 2.0 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
| 14 | + * [+] Rewrote to remove unnecessary code dupes |
|
| 15 | + * 1.5 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
| 16 | + * [~] More DDoS-realted fixes |
|
| 17 | + * 1.4 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
| 18 | + * [~] DDoS-realted fixes |
|
| 19 | + * 1.3 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
| 20 | + * [~] Security checks for SQL-injection |
|
| 21 | + * 1.2 by Ihor |
|
| 22 | + * 1.0 Shoutbox copyright © 2008 by e-Zobar for XNova |
|
| 23 | + **/ |
|
| 24 | 24 | /* |
| 25 | 25 | $sn_mvc['model']['chat'][] = 'sn_chat_model'; |
| 26 | 26 | $sn_mvc['model']['chat_add'][] = 'sn_chat_add_model'; |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | // @version 1.0 |
| 4 | 4 | // @copyright 2008 by Chlorel for XNova |
| 5 | 5 | |
| 6 | -if(SN_IN_FLEET !== true) { |
|
| 6 | +if (SN_IN_FLEET !== true) { |
|
| 7 | 7 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
| 8 | 8 | } |
| 9 | 9 | |
@@ -19,25 +19,25 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // Test de coherance de la destination (voir si elle se trouve dans les limites de l'univers connu |
| 21 | 21 | $errorlist = ''; |
| 22 | - if(!$galaxy || $galaxy > $config->game_maxGalaxy || $galaxy < 1) { |
|
| 22 | + if (!$galaxy || $galaxy > $config->game_maxGalaxy || $galaxy < 1) { |
|
| 23 | 23 | $errorlist .= $lang['fl_limit_galaxy']; |
| 24 | 24 | } |
| 25 | - if(!$system || $system > $config->game_maxSystem || $system < 1) { |
|
| 25 | + if (!$system || $system > $config->game_maxSystem || $system < 1) { |
|
| 26 | 26 | $errorlist .= $lang['fl_limit_system']; |
| 27 | 27 | } |
| 28 | - if(!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE)) { |
|
| 28 | + if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE)) { |
|
| 29 | 29 | $errorlist .= $lang['fl_limit_planet']; |
| 30 | 30 | } |
| 31 | - if($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) { |
|
| 31 | + if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) { |
|
| 32 | 32 | $errorlist .= $lang['fl_ownpl_err']; |
| 33 | 33 | } |
| 34 | - if(!$planet_type) { |
|
| 34 | + if (!$planet_type) { |
|
| 35 | 35 | $errorlist .= $lang['fl_no_planettype']; |
| 36 | 36 | } |
| 37 | - if($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) { |
|
| 37 | + if ($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) { |
|
| 38 | 38 | $errorlist .= $lang['fl_fleet_err_pl']; |
| 39 | 39 | } |
| 40 | - if(empty($missiontype[$target_mission])) { |
|
| 40 | + if (empty($missiontype[$target_mission])) { |
|
| 41 | 41 | $errorlist .= $lang['fl_bad_mission']; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $TransDeuterium = max(0, sys_get_param_float('resource2')); |
| 47 | 47 | $StorageNeeded = $TransMetal + $TransCrystal + $TransDeuterium; |
| 48 | 48 | |
| 49 | - if(!$StorageNeeded && $target_mission == MT_TRANSPORT) { |
|
| 49 | + if (!$StorageNeeded && $target_mission == MT_TRANSPORT) { |
|
| 50 | 50 | $errorlist .= $lang['fl_noenoughtgoods']; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -55,41 +55,41 @@ discard block |
||
| 55 | 55 | $user = db_user_by_id($user['id'], true); |
| 56 | 56 | $planetrow = db_planet_by_id($planetrow['id'], true); |
| 57 | 57 | |
| 58 | - if($target_mission == MT_EXPLORE) { |
|
| 59 | - if($MaxExpeditions == 0) { |
|
| 58 | + if ($target_mission == MT_EXPLORE) { |
|
| 59 | + if ($MaxExpeditions == 0) { |
|
| 60 | 60 | $errorlist .= $lang['fl_expe_notech']; |
| 61 | - } elseif($FlyingExpeditions >= $MaxExpeditions) { |
|
| 61 | + } elseif ($FlyingExpeditions >= $MaxExpeditions) { |
|
| 62 | 62 | $errorlist .= $lang['fl_expe_max']; |
| 63 | 63 | } |
| 64 | 64 | } else { |
| 65 | - if($TargetPlanet['id_owner']) { |
|
| 66 | - if($target_mission == MT_COLONIZE) { |
|
| 65 | + if ($TargetPlanet['id_owner']) { |
|
| 66 | + if ($target_mission == MT_COLONIZE) { |
|
| 67 | 67 | $errorlist .= $lang['fl_colonized']; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if($TargetPlanet['id_owner'] == $planetrow['id_owner']) { |
|
| 71 | - if($target_mission == MT_ATTACK) { |
|
| 70 | + if ($TargetPlanet['id_owner'] == $planetrow['id_owner']) { |
|
| 71 | + if ($target_mission == MT_ATTACK) { |
|
| 72 | 72 | $errorlist .= $lang['fl_no_self_attack']; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if($target_mission == MT_SPY) { |
|
| 75 | + if ($target_mission == MT_SPY) { |
|
| 76 | 76 | $errorlist .= $lang['fl_no_self_spy']; |
| 77 | 77 | } |
| 78 | 78 | } else { |
| 79 | - if($target_mission == MT_RELOCATE) { |
|
| 79 | + if ($target_mission == MT_RELOCATE) { |
|
| 80 | 80 | $errorlist .= $lang['fl_only_stay_at_home']; |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | } else { |
| 84 | - if($target_mission < MT_COLONIZE) { |
|
| 84 | + if ($target_mission < MT_COLONIZE) { |
|
| 85 | 85 | $errorlist .= $lang['fl_unknow_target']; |
| 86 | 86 | } else { |
| 87 | - if($target_mission == MT_DESTROY) { |
|
| 87 | + if ($target_mission == MT_DESTROY) { |
|
| 88 | 88 | $errorlist .= $lang['fl_nomoon']; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if($target_mission == MT_RECYCLE) { |
|
| 92 | - if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) { |
|
| 91 | + if ($target_mission == MT_RECYCLE) { |
|
| 92 | + if ($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) { |
|
| 93 | 93 | $errorlist .= $lang['fl_nodebris']; |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
| 101 | - if(sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) { |
|
| 101 | + if (sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) { |
|
| 102 | 102 | $captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id']); |
| 103 | 103 | // mrc_get_level($user, $planetrow, UNIT_CAPTAIN, true); |
| 104 | - if(!$captain) { |
|
| 104 | + if (!$captain) { |
|
| 105 | 105 | $errorlist .= $lang['module_unit_captain_error_no_captain']; |
| 106 | - } elseif($captain['unit_location_type'] == LOC_PLANET) { |
|
| 107 | - if($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { |
|
| 106 | + } elseif ($captain['unit_location_type'] == LOC_PLANET) { |
|
| 107 | + if ($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { |
|
| 108 | 108 | $errorlist .= $lang['module_unit_captain_error_captain_already_bound']; |
| 109 | 109 | } |
| 110 | 110 | } else { |
@@ -112,14 +112,14 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if($errorlist) { |
|
| 115 | + if ($errorlist) { |
|
| 116 | 116 | sn_db_transaction_rollback(); |
| 117 | 117 | message("<span class='error'><ul>{$errorlist}</ul></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, false); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // On verifie s'il y a assez de vaisseaux sur la planete ! |
| 121 | - foreach($fleetarray as $Ship => $Count) { |
|
| 122 | - if($Count > mrc_get_level($user, $planetrow, $Ship)) { |
|
| 121 | + foreach ($fleetarray as $Ship => $Count) { |
|
| 122 | + if ($Count > mrc_get_level($user, $planetrow, $Ship)) { |
|
| 123 | 123 | message("<span class='error'><b>{$lang['fl_fleet_err']}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -130,10 +130,10 @@ discard block |
||
| 130 | 130 | //But is it acs?? |
| 131 | 131 | //Well all acs fleets must have a fleet code. |
| 132 | 132 | //The co-ords must be the same as where the acs fleet is going. |
| 133 | - if($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") { |
|
| 133 | + if ($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") { |
|
| 134 | 134 | //ACS attack must exist (if acs fleet has arrived this will also return false (2 checks in 1!!!) |
| 135 | 135 | $aks = db_acs_get_by_group_id($fleet_group); |
| 136 | - if(!$aks) { |
|
| 136 | + if (!$aks) { |
|
| 137 | 137 | $fleet_group = 0; |
| 138 | 138 | } else { |
| 139 | 139 | //Also it must be mission type 2 |
@@ -144,31 +144,31 @@ discard block |
||
| 144 | 144 | $planet = $aks['planet']; |
| 145 | 145 | $planet_type = $aks['planet_type']; |
| 146 | 146 | } |
| 147 | - } elseif($target_mission == MT_AKS) { |
|
| 147 | + } elseif ($target_mission == MT_AKS) { |
|
| 148 | 148 | //Check that a failed acs attack isn't being sent, if it is, make it an attack fleet. |
| 149 | 149 | $target_mission = MT_ATTACK; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
| 152 | + if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
| 153 | 153 | $TargetPlanet = array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'id_owner' => 0); |
| 154 | 154 | } |
| 155 | 155 | $options = array('fleet_speed_percent' => $speed_percent, 'fleet_group' => $fleet_group, 'resources' => $StorageNeeded); |
| 156 | 156 | $cant_attack = flt_can_attack($planetrow, $TargetPlanet, $fleetarray, $target_mission, $options); |
| 157 | 157 | |
| 158 | - if($cant_attack !== ATTACK_ALLOWED) { |
|
| 158 | + if ($cant_attack !== ATTACK_ALLOWED) { |
|
| 159 | 159 | message("<span class='error'><b>{$lang['fl_attack_error'][$cant_attack]}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 99); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); |
| 163 | - if(!in_array($speed_percent, $speed_possible)) { |
|
| 163 | + if (!in_array($speed_percent, $speed_possible)) { |
|
| 164 | 164 | message("<span class='error'><b>" . $lang['fl_cheat_speed'] . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | $mission_time_in_seconds = 0; |
| 168 | 168 | $arrival_time = SN_TIME_NOW + $time_to_travel; |
| 169 | - if($target_mission == MT_AKS && $aks) { |
|
| 169 | + if ($target_mission == MT_AKS && $aks) { |
|
| 170 | 170 | // if($fleet_start_time > $aks['ankunft']) { |
| 171 | - if($arrival_time > $aks['ankunft']) { |
|
| 171 | + if ($arrival_time > $aks['ankunft']) { |
|
| 172 | 172 | message($lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME, $arrival_time) . " AKS arrival: " . date(FMT_DATE_TIME, $aks['ankunft']), $lang['fl_error']); |
| 173 | 173 | } |
| 174 | 174 | $group_sync_delta_time = $aks['ankunft'] - $arrival_time; |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | // Set return time to ACS return time + fleet's time to travel |
| 178 | 178 | $return_time = $aks['ankunft'] + $time_to_travel; |
| 179 | 179 | } else { |
| 180 | - if($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) { |
|
| 180 | + if ($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) { |
|
| 181 | 181 | $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : ($target_mission == MT_HOLD ? 12 : 0); |
| 182 | - if($max_duration) { |
|
| 182 | + if ($max_duration) { |
|
| 183 | 183 | $mission_time_in_hours = sys_get_param_id('missiontime'); |
| 184 | - if($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) { |
|
| 184 | + if ($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) { |
|
| 185 | 185 | $debug->warning('Supplying wrong mission time', 'Hack attempt', 302, array('base_dump' => true)); |
| 186 | 186 | die(); |
| 187 | 187 | } |
@@ -195,19 +195,19 @@ discard block |
||
| 195 | 195 | $FleetStorage = 0; |
| 196 | 196 | |
| 197 | 197 | $db_changeset = array(); |
| 198 | - foreach($fleetarray as $Ship => $Count) { |
|
| 198 | + foreach ($fleetarray as $Ship => $Count) { |
|
| 199 | 199 | $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count; |
| 200 | 200 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($Ship, -$Count, $user, $planetrow['id']); |
| 201 | 201 | } |
| 202 | 202 | $FleetStorage -= $consumption; |
| 203 | 203 | |
| 204 | - if($StorageNeeded > $FleetStorage) { |
|
| 204 | + if ($StorageNeeded > $FleetStorage) { |
|
| 205 | 205 | message("<span class='error'><b>" . $lang['fl_nostoragespa'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
| 206 | 206 | } |
| 207 | - if($planetrow['deuterium'] < $TransDeuterium + $consumption) { |
|
| 207 | + if ($planetrow['deuterium'] < $TransDeuterium + $consumption) { |
|
| 208 | 208 | message("<font color=\"red\"><b>" . $lang['fl_no_deuterium'] . pretty_number($TransDeuterium + $consumption - $planetrow['deuterium']) . "</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
| 209 | 209 | } |
| 210 | - if(($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) { |
|
| 210 | + if (($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) { |
|
| 211 | 211 | message("<font color=\"red\"><b>" . $lang['fl_no_resources'] . "</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
| 212 | 212 | } |
| 213 | 213 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | $template = gettemplate('fleet3', true); |
| 239 | 239 | |
| 240 | - if(is_array($captain)) { |
|
| 240 | + if (is_array($captain)) { |
|
| 241 | 241 | db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$objFleet->dbId}"); |
| 242 | 242 | } |
| 243 | 243 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | 'START_LEFT' => floor($return_time + 1 - SN_TIME_NOW), |
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | - if(!empty($TargetPlanet)) { |
|
| 253 | + if (!empty($TargetPlanet)) { |
|
| 254 | 254 | $template_route += array( |
| 255 | 255 | 'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], |
| 256 | 256 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), |
@@ -263,8 +263,8 @@ discard block |
||
| 263 | 263 | $template->assign_block_vars('fleets', $template_route); |
| 264 | 264 | |
| 265 | 265 | $sn_groups_fleet = sn_get_groups('fleet'); |
| 266 | - foreach($fleetarray as $ship_id => $ship_count) { |
|
| 267 | - if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
| 266 | + foreach ($fleetarray as $ship_id => $ship_count) { |
|
| 267 | + if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
| 268 | 268 | // $ship_base_data = get_ship_data($ship_id, $user); |
| 269 | 269 | $template->assign_block_vars('fleets.ships', array( |
| 270 | 270 | 'ID' => $ship_id, |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | 'START_NAME' => $planetrow['name'], |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - if(!empty($TargetPlanet)) { |
|
| 30 | + if (!empty($TargetPlanet)) { |
|
| 31 | 31 | $template_route += array( |
| 32 | 32 | 'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], |
| 33 | 33 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | $template->assign_block_vars('fleets', $template_route); |
| 39 | 39 | |
| 40 | 40 | $sn_groups_fleet = sn_get_groups('fleet'); |
| 41 | - foreach($fleetarray as $ship_id => $ship_count) { |
|
| 42 | - if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
| 41 | + foreach ($fleetarray as $ship_id => $ship_count) { |
|
| 42 | + if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
| 43 | 43 | // $ship_base_data = get_ship_data($ship_id, $user); |
| 44 | 44 | $template->assign_block_vars('fleets.ships', array( |
| 45 | 45 | 'ID' => $ship_id, |
@@ -57,11 +57,10 @@ discard block |
||
| 57 | 57 | $fleet_capacity += get_unit_param($Ship, P_CAPACITY) * $Count; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : |
|
| 61 | - (isset($missiontype[MT_HOLD]) ? 12 : 0); |
|
| 62 | - if($max_duration) { |
|
| 60 | + $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : (isset($missiontype[MT_HOLD]) ? 12 : 0); |
|
| 61 | + if ($max_duration) { |
|
| 63 | 62 | $config_game_speed_expedition = ($target_mission == MT_EXPLORE && $config->game_speed_expedition ? $config->game_speed_expedition : 1); |
| 64 | - for($i = 1; $i <= $max_duration; $i++) { |
|
| 63 | + for ($i = 1; $i <= $max_duration; $i++) { |
|
| 65 | 64 | $template->assign_block_vars('duration', array( |
| 66 | 65 | 'ID' => $i, |
| 67 | 66 | 'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)), |
@@ -80,7 +79,7 @@ discard block |
||
| 80 | 79 | // $TableTitle = uni_render_planet_full($planetrow) . ' => ' . uni_render_planet_full($temp); |
| 81 | 80 | |
| 82 | 81 | $sn_group_resources = sn_get_groups('resources'); |
| 83 | - for($i = 0; $i<3; $i++) { |
|
| 82 | + for ($i = 0; $i < 3; $i++) { |
|
| 84 | 83 | $amount = $planetrow[$sn_group_resources[$i]] - ($i == 2 ? $consumption : 0); |
| 85 | 84 | $template->assign_block_vars('resources', array( |
| 86 | 85 | 'ID' => $i, |
@@ -90,7 +89,7 @@ discard block |
||
| 90 | 89 | )); |
| 91 | 90 | } |
| 92 | 91 | |
| 93 | - if(sn_module::$sn_module['unit_captain']->manifest['active'] && ($captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) { |
|
| 92 | + if (sn_module::$sn_module['unit_captain']->manifest['active'] && ($captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) { |
|
| 94 | 93 | $template->assign_vars(array( |
| 95 | 94 | 'CAPTAIN_ID' => $captain['unit_id'], |
| 96 | 95 | 'CAPTAIN_LEVEL' => $captain['captain_level'], |
@@ -111,9 +110,9 @@ discard block |
||
| 111 | 110 | // 'TableTitle' => $TableTitle, |
| 112 | 111 | |
| 113 | 112 | 'speedallsmin' => sys_get_param_float('speedallsmin'), |
| 114 | - 'speed' => sys_get_param_int('speed') , |
|
| 113 | + 'speed' => sys_get_param_int('speed'), |
|
| 115 | 114 | |
| 116 | - 'fleet_group' => sys_get_param_id('fleet_group') , |
|
| 115 | + 'fleet_group' => sys_get_param_id('fleet_group'), |
|
| 117 | 116 | 'acs_target_mr' => sys_get_param_str('acs_target_mr'), |
| 118 | 117 | |
| 119 | 118 | 'MAX_DURATION' => $max_duration, |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | require SN_ROOT_PHYSICAL . 'config.php'; |
| 77 | 77 | |
| 78 | 78 | $module_config_array = get_class($this) . '_config'; |
| 79 | - if(!empty($$module_config_array) && is_array($$module_config_array)) { |
|
| 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,15 +94,15 @@ 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 | 107 | $module_config_array = $class_module_name . '_config'; |
| 108 | 108 | $this->config = $$module_config_array; |
@@ -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); |
| 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 | } |
@@ -199,18 +199,18 @@ discard block |
||
| 199 | 199 | // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ |
| 200 | 200 | // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно |
| 201 | 201 | |
| 202 | - if(sys_get_param('login_player_register_logout')) { |
|
| 202 | + if (sys_get_param('login_player_register_logout')) { |
|
| 203 | 203 | $this->logout(); |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | $original_suggest = ''; |
| 207 | 207 | // Смотрим - есть ли у нас данные от пользователя |
| 208 | - if(($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
| 208 | + if (($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
| 209 | 209 | // Попытка регистрации нового игрока из данных, введенных пользователем |
| 210 | 210 | $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name'); |
| 211 | 211 | } else { |
| 212 | - foreach($this->providers_authorised as $provider) { |
|
| 213 | - if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
| 212 | + foreach ($this->providers_authorised as $provider) { |
|
| 213 | + if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
| 214 | 214 | $original_suggest = $provider->player_name_suggest(); |
| 215 | 215 | break; |
| 216 | 216 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру |
| 221 | - if(!$this->player_suggested_name) { |
|
| 221 | + if (!$this->player_suggested_name) { |
|
| 222 | 222 | $max_user_id = db_player_get_max_id(); // 4.5 |
| 223 | 223 | // TODO - предлагать имя игрока по локали |
| 224 | 224 | |
@@ -227,15 +227,15 @@ discard block |
||
| 227 | 227 | sn_db_transaction_rollback(); |
| 228 | 228 | $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
| 229 | 229 | sn_db_transaction_start(); |
| 230 | - } while(db_player_name_exists($this->player_suggested_name)); |
|
| 230 | + } while (db_player_name_exists($this->player_suggested_name)); |
|
| 231 | 231 | |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - if($player_name_submitted) { |
|
| 234 | + if ($player_name_submitted) { |
|
| 235 | 235 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
| 236 | - if($this->register_status == LOGIN_SUCCESS) { |
|
| 236 | + if ($this->register_status == LOGIN_SUCCESS) { |
|
| 237 | 237 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
| 238 | - } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
| 238 | + } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
| 239 | 239 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
| 240 | 240 | } |
| 241 | 241 | // if(self::$login_status != LOGIN_SUCCESS) { |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | : false |
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
| 262 | + if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
| 263 | 263 | $prohibited_characters = array_map(function($value) { |
| 264 | 264 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
| 265 | 265 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
@@ -293,27 +293,27 @@ discard block |
||
| 293 | 293 | global $lang; |
| 294 | 294 | |
| 295 | 295 | // !self::$is_init ? self::init() : false; |
| 296 | - if(empty(sn_module::$sn_module_list['auth'])) { |
|
| 296 | + if (empty(sn_module::$sn_module_list['auth'])) { |
|
| 297 | 297 | die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}'); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false; |
| 301 | 301 | !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false; |
| 302 | - !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false; |
|
| 302 | + !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false; |
|
| 303 | 303 | |
| 304 | 304 | $this->auth_reset(); // OK v4.5 |
| 305 | 305 | |
| 306 | 306 | $this->providers = array(); |
| 307 | - foreach(sn_module::$sn_module_list['auth'] as $module_name => $module) { |
|
| 307 | + foreach (sn_module::$sn_module_list['auth'] as $module_name => $module) { |
|
| 308 | 308 | $this->providers[$module->provider_id] = $module; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым! |
| 312 | 312 | |
| 313 | - foreach($this->providers as $provider_id => $provider) { |
|
| 313 | + foreach ($this->providers as $provider_id => $provider) { |
|
| 314 | 314 | $login_status = $provider->login(); // OK v4.5 |
| 315 | 315 | self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
| 316 | - if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
| 316 | + if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
| 317 | 317 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
| 318 | 318 | |
| 319 | 319 | $this->user_id_to_provider = array_replace_recursive( |
@@ -321,15 +321,15 @@ discard block |
||
| 321 | 321 | // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
| 322 | 322 | PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
| 323 | 323 | ); |
| 324 | - } elseif($login_status != LOGIN_UNDEFINED) { |
|
| 324 | + } elseif ($login_status != LOGIN_UNDEFINED) { |
|
| 325 | 325 | $this->provider_error_list[$provider_id] = $login_status; |
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if(empty($this->providers_authorised)) { |
|
| 329 | + if (empty($this->providers_authorised)) { |
|
| 330 | 330 | // Ни один аккаунт не авторизирован |
| 331 | 331 | // Проверяем - есть ли у нас ошибки в аккаунтах? |
| 332 | - if(!empty($this->provider_error_list)) { |
|
| 332 | + if (!empty($this->provider_error_list)) { |
|
| 333 | 333 | // Если есть - выводим их |
| 334 | 334 | self::$login_status = reset($this->provider_error_list); |
| 335 | 335 | } |
@@ -344,12 +344,12 @@ discard block |
||
| 344 | 344 | // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users` |
| 345 | 345 | |
| 346 | 346 | // Остались ли у нас в списке доступные игроки? |
| 347 | - if(empty($this->accessible_user_row_list)) { |
|
| 347 | + if (empty($this->accessible_user_row_list)) { |
|
| 348 | 348 | // Нет ни одного игрока ни на одном авторизированном аккаунте |
| 349 | 349 | // Надо регать нового игрока |
| 350 | 350 | |
| 351 | 351 | // Сейчас происходит процесс регистрации игрока? |
| 352 | - if(!$this->is_player_register) { |
|
| 352 | + if (!$this->is_player_register) { |
|
| 353 | 353 | // Нет - отправляем на процесс регистрации |
| 354 | 354 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
| 355 | 355 | sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | // Да, есть доступные игроки, которые так же прописаны в базе |
| 359 | 359 | $this->get_active_user(); // 4.5 |
| 360 | 360 | |
| 361 | - if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
| 361 | + if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
| 362 | 362 | $a_user = db_user_by_id($this->is_impersonating); |
| 363 | 363 | $this->impersonator_username = $a_user['username']; |
| 364 | 364 | } |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | //Прописываем текущего игрока на все авторизированные аккаунты |
| 368 | 368 | // TODO - ИЛИ ВСЕХ ИГРОКОВ?? |
| 369 | - if(empty($this->is_impersonating)) { |
|
| 370 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
| 371 | - if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
| 369 | + if (empty($this->is_impersonating)) { |
|
| 370 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
| 371 | + if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
| 372 | 372 | // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
| 373 | 373 | PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
| 374 | 374 | $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true; |
@@ -378,9 +378,9 @@ discard block |
||
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - if(empty(self::$user['id'])) { |
|
| 381 | + if (empty(self::$user['id'])) { |
|
| 382 | 382 | self::cookie_set(''); // OK 4.5 |
| 383 | - } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
| 383 | + } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
| 384 | 384 | self::cookie_set(self::$user['id']); // OK 4.5 |
| 385 | 385 | } |
| 386 | 386 | |
@@ -399,21 +399,21 @@ discard block |
||
| 399 | 399 | */ |
| 400 | 400 | // OK v4.7 |
| 401 | 401 | public function logout($redirect = true) { |
| 402 | - if(!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
| 402 | + if (!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
| 403 | 403 | self::cookie_set($_COOKIE[SN_COOKIE_U_I]); |
| 404 | 404 | self::cookie_set(0, true); |
| 405 | 405 | self::$main_provider->logout(); |
| 406 | 406 | } else { |
| 407 | - foreach($this->providers as $provider_name => $provider) { |
|
| 407 | + foreach ($this->providers as $provider_name => $provider) { |
|
| 408 | 408 | $provider->logout(); |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | self::cookie_set(0); |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - if($redirect === true) { |
|
| 414 | + if ($redirect === true) { |
|
| 415 | 415 | sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
| 416 | - } elseif($redirect !== false) { |
|
| 416 | + } elseif ($redirect !== false) { |
|
| 417 | 417 | sys_redirect($redirect); |
| 418 | 418 | } |
| 419 | 419 | } |
@@ -424,15 +424,15 @@ discard block |
||
| 424 | 424 | * @param $user_selected |
| 425 | 425 | */ |
| 426 | 426 | public function impersonate($user_selected) { |
| 427 | - if($_COOKIE[SN_COOKIE_U_I]) { |
|
| 427 | + if ($_COOKIE[SN_COOKIE_U_I]) { |
|
| 428 | 428 | die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
| 431 | + if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
| 432 | 432 | die('You can\'t impersonate - too low level'); // TODO: Log it |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - if($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
| 435 | + if ($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
| 436 | 436 | die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it |
| 437 | 437 | } |
| 438 | 438 | |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]); |
| 441 | 441 | $account_to_impersonate = new Account(self::$main_provider->db); |
| 442 | 442 | $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']); |
| 443 | - if(!$account_to_impersonate->is_exists) { |
|
| 443 | + if (!$account_to_impersonate->is_exists) { |
|
| 444 | 444 | die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it |
| 445 | 445 | } |
| 446 | 446 | self::$main_provider->impersonate($account_to_impersonate); |
@@ -466,12 +466,12 @@ discard block |
||
| 466 | 466 | public function password_check($password_unsafe) { |
| 467 | 467 | $result = false; |
| 468 | 468 | |
| 469 | - if(empty($this->providers_authorised)) { |
|
| 469 | + if (empty($this->providers_authorised)) { |
|
| 470 | 470 | // TODO - такого быть не может! |
| 471 | 471 | self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
| 472 | 472 | } else { |
| 473 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
| 474 | - if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
| 473 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
| 474 | + if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
| 475 | 475 | $result = $result || $provider->password_check($password_unsafe); |
| 476 | 476 | } |
| 477 | 477 | } |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | public function password_change($old_password_unsafe, $new_password_unsafe) { |
| 493 | 493 | global $lang; |
| 494 | 494 | |
| 495 | - if(empty($this->providers_authorised)) { |
|
| 495 | + if (empty($this->providers_authorised)) { |
|
| 496 | 496 | // TODO - такого быть не может! |
| 497 | 497 | self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
| 498 | 498 | return false; |
@@ -505,8 +505,8 @@ discard block |
||
| 505 | 505 | $salt_unsafe = self::password_salt_generate(); |
| 506 | 506 | |
| 507 | 507 | $providers_changed_password = array(); |
| 508 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
| 509 | - if( |
|
| 508 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
| 509 | + if ( |
|
| 510 | 510 | !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE) |
| 511 | 511 | || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe) |
| 512 | 512 | ) { |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id); |
| 519 | 519 | |
| 520 | 520 | // Рассылаем уведомления о смене пароля в ЛС |
| 521 | - foreach($account_translation as $user_id => $provider_info) { |
|
| 521 | + foreach ($account_translation as $user_id => $provider_info) { |
|
| 522 | 522 | // TODO - УКазывать тип аккаунта, на котором сменён пароль |
| 523 | 523 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, |
| 524 | 524 | $lang['sys_administration'], $lang['sys_login_register_message_title'], |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | sn_db_transaction_start(); |
| 566 | 566 | // Проверить наличие такого имени в истории имён |
| 567 | 567 | |
| 568 | - if(db_player_name_exists($player_name_unsafe)) { |
|
| 568 | + if (db_player_name_exists($player_name_unsafe)) { |
|
| 569 | 569 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR); |
| 570 | 570 | } |
| 571 | 571 | |
@@ -573,11 +573,11 @@ discard block |
||
| 573 | 573 | $player_language = ''; |
| 574 | 574 | $player_email = ''; |
| 575 | 575 | // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
| 576 | - foreach($this->providers_authorised as $provider) { |
|
| 577 | - if(!$player_language && $provider->account->account_language) { |
|
| 576 | + foreach ($this->providers_authorised as $provider) { |
|
| 577 | + if (!$player_language && $provider->account->account_language) { |
|
| 578 | 578 | $player_language = $provider->account->account_language; |
| 579 | 579 | } |
| 580 | - if(!$player_email && $provider->account->account_email) { |
|
| 580 | + if (!$player_email && $provider->account->account_email) { |
|
| 581 | 581 | $player_email = $provider->account->account_email; |
| 582 | 582 | } |
| 583 | 583 | } |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | )); |
| 594 | 594 | // Зарегестрировать на него аккаунты из self::$accounts_authorised |
| 595 | 595 | $a_user = self::$user; |
| 596 | - foreach($this->providers_authorised as $provider) { |
|
| 596 | + foreach ($this->providers_authorised as $provider) { |
|
| 597 | 597 | // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор |
| 598 | 598 | // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
| 599 | 599 | // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']); |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | |
| 606 | 606 | sn_db_transaction_commit(); |
| 607 | 607 | $this->register_status = LOGIN_SUCCESS; |
| 608 | - } catch(Exception $e) { |
|
| 608 | + } catch (Exception $e) { |
|
| 609 | 609 | sn_db_transaction_rollback(); |
| 610 | 610 | |
| 611 | 611 | // Если старое имя занято |
@@ -624,10 +624,10 @@ discard block |
||
| 624 | 624 | // Пробиваем все ИД игроков по базе - есть ли вообще такие записи |
| 625 | 625 | // Вообще-то это не особо нужно - у нас по определению стоят констраинты |
| 626 | 626 | // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров |
| 627 | - foreach($this->user_id_to_provider as $user_id => $cork) { |
|
| 627 | + foreach ($this->user_id_to_provider as $user_id => $cork) { |
|
| 628 | 628 | $user = db_user_by_id($user_id); |
| 629 | 629 | // Если записи игрока в БД не существует? |
| 630 | - if(empty($user['id'])) { |
|
| 630 | + if (empty($user['id'])) { |
|
| 631 | 631 | // Удаляем этого и переходим к следующему |
| 632 | 632 | unset($this->user_id_to_provider[$user_id]); |
| 633 | 633 | // Де-регистрируем игрока из таблицы трансляции игроков |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | // OK v4.5 |
| 649 | 649 | protected function get_active_user() { |
| 650 | 650 | // Проверяем куку "текущего игрока" из браузера |
| 651 | - if( |
|
| 651 | + if ( |
|
| 652 | 652 | // Кука не пустая |
| 653 | 653 | ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U]) |
| 654 | 654 | // И в куке находится ID |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов |
| 676 | - if(empty(self::$user['id'])) { |
|
| 676 | + if (empty(self::$user['id'])) { |
|
| 677 | 677 | // Берем первого из доступных |
| 678 | 678 | // TODO - default_user |
| 679 | 679 | self::$user = reset($this->accessible_user_row_list); |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | |
| 698 | 698 | $result = array(); |
| 699 | 699 | |
| 700 | - if($user_id && empty($this->is_impersonating)) { |
|
| 700 | + if ($user_id && empty($this->is_impersonating)) { |
|
| 701 | 701 | // self::db_counter_insert(); |
| 702 | 702 | self::$device->db_counter_insert($user_id); |
| 703 | 703 | |
@@ -705,12 +705,12 @@ discard block |
||
| 705 | 705 | |
| 706 | 706 | sys_user_options_unpack($user); |
| 707 | 707 | |
| 708 | - if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
| 708 | + if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
| 709 | 709 | $user['banaday'] = 0; |
| 710 | 710 | $user['vacation'] = SN_TIME_NOW; |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; |
|
| 713 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; |
|
| 714 | 714 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; |
| 715 | 715 | |
| 716 | 716 | $result[F_BANNED_STATUS] = $user['banaday']; |
@@ -724,9 +724,9 @@ discard block |
||
| 724 | 724 | ); |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | - if($extra = $config->security_ban_extra) { |
|
| 727 | + if ($extra = $config->security_ban_extra) { |
|
| 728 | 728 | $extra = explode(',', $extra); |
| 729 | - array_walk($extra,'trim'); |
|
| 729 | + array_walk($extra, 'trim'); |
|
| 730 | 730 | in_array(self::$device->device_id, $extra) and die(); |
| 731 | 731 | } |
| 732 | 732 | |
@@ -762,21 +762,21 @@ discard block |
||
| 762 | 762 | protected function register_player_name_validate($player_name_unsafe) { |
| 763 | 763 | // TODO - переделать под RAW-строки |
| 764 | 764 | // Если имя игрока пустое - NO GO! |
| 765 | - if(trim($player_name_unsafe) == '') { |
|
| 765 | + if (trim($player_name_unsafe) == '') { |
|
| 766 | 766 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR); |
| 767 | 767 | } |
| 768 | 768 | // Проверяем, что бы в начале и конце не было пустых символов |
| 769 | - if($player_name_unsafe != trim($player_name_unsafe)) { |
|
| 769 | + if ($player_name_unsafe != trim($player_name_unsafe)) { |
|
| 770 | 770 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR); |
| 771 | 771 | } |
| 772 | 772 | // Если логин имеет запрещенные символы - NO GO! |
| 773 | - if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
| 773 | + if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
| 774 | 774 | // TODO - выдавать в сообщение об ошибке список запрещенных символов |
| 775 | 775 | // TODO - заранее извещать игрока, какие символы являются запрещенными |
| 776 | 776 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
| 777 | 777 | } |
| 778 | 778 | // Если логин меньше минимальной длины - NO GO! |
| 779 | - if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
| 779 | + if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
| 780 | 780 | // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока |
| 781 | 781 | // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени |
| 782 | 782 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR); |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | protected static function flog($message, $die = false) { |
| 837 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
| 837 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
| 838 | 838 | return; |
| 839 | 839 | } |
| 840 | 840 | list($called, $caller) = debug_backtrace(false); |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
| 848 | 848 | |
| 849 | 849 | classSupernova::log_file("$message - $caller_name"); |
| 850 | - if($die) { |
|
| 850 | + if ($die) { |
|
| 851 | 851 | // pdump($caller); |
| 852 | 852 | // pdump(debug_backtrace(false)); |
| 853 | 853 | $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
@@ -14,24 +14,24 @@ discard block |
||
| 14 | 14 | function sn_function_call($func_name, $func_arg = array()) { |
| 15 | 15 | // All data in classSupernova::$functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>') |
| 16 | 16 | |
| 17 | - if(is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) { |
|
| 17 | + if (is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) { |
|
| 18 | 18 | // Chain-callable functions should be made as following: |
| 19 | 19 | // 1. Never use incomplete calls with parameters "by default" |
| 20 | 20 | // 2. Reserve last parameter for cumulative result |
| 21 | 21 | // 3. Use same format for original value and cumulative result (if there is original value) |
| 22 | 22 | // 4. Honor cumulative result |
| 23 | 23 | // 5. Return cumulative result |
| 24 | - foreach(classSupernova::$functions[$func_name] as $func_chain_name) { |
|
| 24 | + foreach (classSupernova::$functions[$func_name] as $func_chain_name) { |
|
| 25 | 25 | // По идее - это уже тут не нужно, потому что оно все должно быть callable к этому моменту |
| 26 | 26 | // Но для старых модулей... |
| 27 | - if(is_callable($func_chain_name)) { |
|
| 27 | + if (is_callable($func_chain_name)) { |
|
| 28 | 28 | $result = call_user_func_array($func_chain_name, $func_arg); |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | } else { |
| 32 | 32 | // TODO: This is left for backward compatibility. Appropriate code should be rewrote! |
| 33 | 33 | $func_name = isset(classSupernova::$functions[$func_name]) && is_callable(classSupernova::$functions[$func_name]) ? classSupernova::$functions[$func_name] : ('sn_' . $func_name); |
| 34 | - if(is_callable($func_name)) { |
|
| 34 | + if (is_callable($func_name)) { |
|
| 35 | 35 | $result = call_user_func_array($func_name, $func_arg); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | * @param string $page_name - имя страницы, для которого должен был быть выполнен хук |
| 47 | 47 | */ |
| 48 | 48 | function execute_hooks(&$hook_list, &$template, $hook_type = null, $page_name = null) { |
| 49 | - if(!empty($hook_list)) { |
|
| 50 | - foreach($hook_list as $hook) { |
|
| 51 | - if(is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
| 49 | + if (!empty($hook_list)) { |
|
| 50 | + foreach ($hook_list as $hook) { |
|
| 51 | + if (is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
| 52 | 52 | $template = call_user_func($hook_call, $template, $hook_type, $page_name); |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) { |
| 150 | 150 | $n = floatval($n); |
| 151 | - if(is_int($floor)) { |
|
| 151 | + if (is_int($floor)) { |
|
| 152 | 152 | $n = round($n, $floor); // , PHP_ROUND_HALF_DOWN |
| 153 | - } elseif($floor === true) { |
|
| 153 | + } elseif ($floor === true) { |
|
| 154 | 154 | $n = floor($n); |
| 155 | 155 | $floor = 0; |
| 156 | 156 | } else { |
@@ -160,14 +160,14 @@ discard block |
||
| 160 | 160 | $ret = $n; |
| 161 | 161 | |
| 162 | 162 | $suffix = ''; |
| 163 | - if($limit) { |
|
| 164 | - if($ret > 0) { |
|
| 165 | - while($ret > $limit) { |
|
| 163 | + if ($limit) { |
|
| 164 | + if ($ret > 0) { |
|
| 165 | + while ($ret > $limit) { |
|
| 166 | 166 | $suffix .= 'k'; |
| 167 | 167 | $ret = round($ret / 1000); |
| 168 | 168 | } |
| 169 | 169 | } else { |
| 170 | - while($ret < -$limit) { |
|
| 170 | + while ($ret < -$limit) { |
|
| 171 | 171 | $suffix .= 'k'; |
| 172 | 172 | $ret = round($ret / 1000); |
| 173 | 173 | } |
@@ -177,16 +177,16 @@ discard block |
||
| 177 | 177 | $ret = number_format($ret, $floor, ',', '.'); |
| 178 | 178 | $ret .= $suffix; |
| 179 | 179 | |
| 180 | - if($color !== false) { |
|
| 181 | - if($color === true) { |
|
| 180 | + if ($color !== false) { |
|
| 181 | + if ($color === true) { |
|
| 182 | 182 | $class = $n == 0 ? 'zero' : ($n > 0 ? 'positive' : 'negative'); |
| 183 | - } elseif($color >= 0) { |
|
| 183 | + } elseif ($color >= 0) { |
|
| 184 | 184 | $class = $n == $color ? 'zero' : ($n < $color ? 'positive' : 'negative'); |
| 185 | 185 | } else { |
| 186 | 186 | $class = ($n == -$color) ? 'zero' : ($n < -$color ? 'negative' : 'positive'); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if(!isset($style)) { |
|
| 189 | + if (!isset($style)) { |
|
| 190 | 190 | $ret = "<span class='{$class}'>{$ret}</span>"; |
| 191 | 191 | } else { |
| 192 | 192 | $ret = $style ? $ret = $class : $ret = array('text' => $ret, 'class' => $class); |
@@ -311,11 +311,11 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | function sys_get_param_phone($param_name, $default = '') { |
| 313 | 313 | $phone_raw = sys_get_param_str_unsafe($param_name, $default = ''); |
| 314 | - if($phone_raw) { |
|
| 314 | + if ($phone_raw) { |
|
| 315 | 315 | $phone = $phone_raw[0] == '+' ? '+' : ''; |
| 316 | - for($i = 0; $i < strlen($phone_raw); $i++) { |
|
| 316 | + for ($i = 0; $i < strlen($phone_raw); $i++) { |
|
| 317 | 317 | $ord = ord($phone_raw[$i]); |
| 318 | - if($ord >= 48 && $ord <= 57) { |
|
| 318 | + if ($ord >= 48 && $ord <= 57) { |
|
| 319 | 319 | $phone .= $phone_raw[$i]; |
| 320 | 320 | } |
| 321 | 321 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | function CheckAbandonPlanetState(&$planet) { |
| 335 | - if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) { |
|
| 335 | + if ($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) { |
|
| 336 | 336 | db_planet_delete_by_id($planet['id']); |
| 337 | 337 | } |
| 338 | 338 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | global $config; |
| 342 | 342 | |
| 343 | 343 | static $rate, $sn_group_resources_all, $sn_group_resources_loot; |
| 344 | - if(!$rate) { |
|
| 344 | + if (!$rate) { |
|
| 345 | 345 | $sn_group_resources_all = sn_get_groups('resources_all'); |
| 346 | 346 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
| 347 | 347 | |
@@ -351,19 +351,19 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | $unit_cost_data = get_unit_param($unit_id, 'cost'); |
| 354 | - if(!is_array($unit_cost_data)) { |
|
| 354 | + if (!is_array($unit_cost_data)) { |
|
| 355 | 355 | return array('total' => 0); |
| 356 | 356 | } |
| 357 | 357 | $factor = isset($unit_cost_data['factor']) ? $unit_cost_data['factor'] : 1; |
| 358 | 358 | $cost_array = array(BUILD_CREATE => array(), 'total' => 0); |
| 359 | 359 | $unit_level = $unit_level > 0 ? $unit_level : 0; |
| 360 | - foreach($unit_cost_data as $resource_id => $resource_amount) { |
|
| 361 | - if(!in_array($resource_id, $sn_group_resources_all)) { |
|
| 360 | + foreach ($unit_cost_data as $resource_id => $resource_amount) { |
|
| 361 | + if (!in_array($resource_id, $sn_group_resources_all)) { |
|
| 362 | 362 | continue; |
| 363 | 363 | } |
| 364 | 364 | // $cost_array[BUILD_CREATE][$resource_id] = $resource_amount * ($factor == 1 ? $unit_level : ((pow($factor, $unit_level) - $factor) / ($factor - 1))); |
| 365 | 365 | $cost_array[BUILD_CREATE][$resource_id] = round($resource_amount * ($factor == 1 ? $unit_level : ((1 - pow($factor, $unit_level)) / (1 - $factor)))); |
| 366 | - if(in_array($resource_id, $sn_group_resources_loot)) { |
|
| 366 | + if (in_array($resource_id, $sn_group_resources_loot)) { |
|
| 367 | 367 | $cost_array['total'] += $cost_array[BUILD_CREATE][$resource_id] * $rate[$resource_id]; |
| 368 | 368 | } |
| 369 | 369 | } |
@@ -438,19 +438,19 @@ discard block |
||
| 438 | 438 | $mercenary_level = 0; |
| 439 | 439 | $unit_db_name = pname_resource_name($unit_id); |
| 440 | 440 | |
| 441 | - if(in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
| 441 | + if (in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
| 442 | 442 | $unit = classSupernova::db_get_unit_by_location($user['id'], LOC_USER, $user['id'], $unit_id); |
| 443 | 443 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
| 444 | - } elseif(in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
| 444 | + } elseif (in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
| 445 | 445 | $unit = classSupernova::db_get_unit_by_location(is_array($user) ? $user['id'] : $planet['id_owner'], LOC_PLANET, $planet['id'], $unit_id); |
| 446 | 446 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
| 447 | - } elseif(in_array($unit_id, sn_get_groups('governors'))) { |
|
| 447 | + } elseif (in_array($unit_id, sn_get_groups('governors'))) { |
|
| 448 | 448 | $mercenary_level = $unit_id == $planet['PLANET_GOVERNOR_ID'] ? $planet['PLANET_GOVERNOR_LEVEL'] : 0; |
| 449 | - } elseif($unit_id == RES_DARK_MATTER) { |
|
| 449 | + } elseif ($unit_id == RES_DARK_MATTER) { |
|
| 450 | 450 | $mercenary_level = $user[$unit_db_name] + ($plain || $user['user_as_ally'] ? 0 : classSupernova::$auth->account->account_metamatter); |
| 451 | - } elseif($unit_id == RES_METAMATTER) { |
|
| 451 | + } elseif ($unit_id == RES_METAMATTER) { |
|
| 452 | 452 | $mercenary_level = classSupernova::$auth->account->account_metamatter; //$user[$unit_db_name]; |
| 453 | - } elseif(in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
| 453 | + } elseif (in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
| 454 | 454 | $mercenary_level = !empty($planet) ? $planet[$unit_db_name] : $user[$unit_db_name]; |
| 455 | 455 | } |
| 456 | 456 | |
@@ -460,19 +460,19 @@ discard block |
||
| 460 | 460 | function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) { return sn_function_call(__FUNCTION__, array(&$user, $planet, $mercenaries, $value)); } |
| 461 | 461 | |
| 462 | 462 | function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) { |
| 463 | - if(!is_array($mercenaries)) { |
|
| 463 | + if (!is_array($mercenaries)) { |
|
| 464 | 464 | $mercenaries = array($mercenaries); |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | $base_value = isset($base_value) ? $base_value : $value; |
| 468 | 468 | |
| 469 | - foreach($mercenaries as $mercenary_id) { |
|
| 469 | + foreach ($mercenaries as $mercenary_id) { |
|
| 470 | 470 | $mercenary_level = mrc_get_level($user, $planet, $mercenary_id); |
| 471 | 471 | |
| 472 | 472 | $mercenary = get_unit_param($mercenary_id); |
| 473 | 473 | $mercenary_bonus = $mercenary['bonus']; |
| 474 | 474 | |
| 475 | - switch($mercenary['bonus_type']) { |
|
| 475 | + switch ($mercenary['bonus_type']) { |
|
| 476 | 476 | case BONUS_PERCENT_CUMULATIVE: |
| 477 | 477 | $value *= 1 + $mercenary_level * $mercenary_bonus / 100; |
| 478 | 478 | break; |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | $allowed_length = strlen($allowed_chars); |
| 504 | 504 | |
| 505 | 505 | $random_string = ''; |
| 506 | - for($i = 0; $i < $length; $i++) { |
|
| 506 | + for ($i = 0; $i < $length; $i++) { |
|
| 507 | 507 | $random_string .= $allowed_chars[mt_rand(0, $allowed_length - 1)]; |
| 508 | 508 | } |
| 509 | 509 | |
@@ -523,12 +523,12 @@ discard block |
||
| 523 | 523 | |
| 524 | 524 | $options = ''; |
| 525 | 525 | $option_list = array(); |
| 526 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
| 526 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
| 527 | 527 | $option_list[$option_group_id] = array(); |
| 528 | - foreach($option_group as $option_name => $option_value) { |
|
| 529 | - if(!isset($user[$option_name])) { |
|
| 528 | + foreach ($option_group as $option_name => $option_value) { |
|
| 529 | + if (!isset($user[$option_name])) { |
|
| 530 | 530 | $user[$option_name] = $option_value; |
| 531 | - } elseif($user[$option_name] == '') { |
|
| 531 | + } elseif ($user[$option_name] == '') { |
|
| 532 | 532 | $user[$option_name] = 0; |
| 533 | 533 | } |
| 534 | 534 | $options .= "{$option_name}^{$user[$option_name]}|"; |
@@ -548,16 +548,16 @@ discard block |
||
| 548 | 548 | $option_list = array(); |
| 549 | 549 | $option_string_list = explode('|', $user['options']); |
| 550 | 550 | |
| 551 | - foreach($option_string_list as $option_string) { |
|
| 551 | + foreach ($option_string_list as $option_string) { |
|
| 552 | 552 | list($option_name, $option_value) = explode('^', $option_string); |
| 553 | 553 | $option_list[$option_name] = $option_value; |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | $final_list = array(); |
| 557 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
| 557 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
| 558 | 558 | $final_list[$option_group_id] = array(); |
| 559 | - foreach($option_group as $option_name => $option_value) { |
|
| 560 | - if(!isset($option_list[$option_name])) { |
|
| 559 | + foreach ($option_group as $option_name => $option_value) { |
|
| 560 | + if (!isset($option_list[$option_name])) { |
|
| 561 | 561 | $option_list[$option_name] = $option_value; |
| 562 | 562 | } |
| 563 | 563 | $user[$option_name] = $final_list[$option_group_id][$option_name] = $option_list[$option_name]; |
@@ -571,12 +571,12 @@ discard block |
||
| 571 | 571 | |
| 572 | 572 | function sys_unit_str2arr($fleet_string) { |
| 573 | 573 | $fleet_array = array(); |
| 574 | - if(!empty($fleet_string)) { |
|
| 574 | + if (!empty($fleet_string)) { |
|
| 575 | 575 | $arrTemp = explode(';', $fleet_string); |
| 576 | - foreach($arrTemp as $temp) { |
|
| 577 | - if($temp) { |
|
| 576 | + foreach ($arrTemp as $temp) { |
|
| 577 | + if ($temp) { |
|
| 578 | 578 | $temp = explode(',', $temp); |
| 579 | - if(!empty($temp[0]) && !empty($temp[1])) { |
|
| 579 | + if (!empty($temp[0]) && !empty($temp[1])) { |
|
| 580 | 580 | $fleet_array[$temp[0]] += $temp[1]; |
| 581 | 581 | } |
| 582 | 582 | } |
@@ -588,13 +588,13 @@ discard block |
||
| 588 | 588 | |
| 589 | 589 | function sys_unit_arr2str($unit_list) { |
| 590 | 590 | $fleet_string = array(); |
| 591 | - if(isset($unit_list)) { |
|
| 592 | - if(!is_array($unit_list)) { |
|
| 591 | + if (isset($unit_list)) { |
|
| 592 | + if (!is_array($unit_list)) { |
|
| 593 | 593 | $unit_list = array($unit_list => 1); |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - foreach($unit_list as $unit_id => $unit_count) { |
|
| 597 | - if($unit_id && $unit_count) { |
|
| 596 | + foreach ($unit_list as $unit_id => $unit_count) { |
|
| 597 | + if ($unit_id && $unit_count) { |
|
| 598 | 598 | $fleet_string[] = "{$unit_id},{$unit_count}"; |
| 599 | 599 | } |
| 600 | 600 | } |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | $body = str_replace("\r\n", "\n", $body); |
| 622 | 622 | $body = str_replace("\n", "\r\n", $body); |
| 623 | 623 | |
| 624 | - if($html) { |
|
| 624 | + if ($html) { |
|
| 625 | 625 | $body = '<html><head><base href="' . SN_ROOT_VIRTUAL . '"></head><body>' . nl2br($body) . '</body></html>'; |
| 626 | 626 | } |
| 627 | 627 | |
@@ -665,21 +665,21 @@ discard block |
||
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | function sn_ali_fill_user_ally(&$user) { |
| 668 | - if(!$user['ally_id']) { |
|
| 668 | + if (!$user['ally_id']) { |
|
| 669 | 669 | return; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | - if(!isset($user['ally'])) { |
|
| 672 | + if (!isset($user['ally'])) { |
|
| 673 | 673 | $user['ally'] = db_ally_get_by_id($user['ally_id']); |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | - if(!isset($user['ally']['player'])) { |
|
| 676 | + if (!isset($user['ally']['player'])) { |
|
| 677 | 677 | $user['ally']['player'] = db_user_by_id($user['ally']['ally_user_id'], true, '*', false); |
| 678 | 678 | } |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | function sn_get_url_contents($url) { |
| 682 | - if(function_exists('curl_init')) { |
|
| 682 | + if (function_exists('curl_init')) { |
|
| 683 | 683 | $crl = curl_init(); |
| 684 | 684 | $timeout = 5; |
| 685 | 685 | curl_setopt($crl, CURLOPT_URL, $url); |
@@ -714,10 +714,10 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | function get_ship_data($ship_id, $user) { |
| 716 | 716 | $ship_data = array(); |
| 717 | - if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
| 718 | - foreach(get_unit_param($ship_id, 'engine') as $engine_info) { |
|
| 717 | + if (in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
| 718 | + foreach (get_unit_param($ship_id, 'engine') as $engine_info) { |
|
| 719 | 719 | $tech_level = intval(mrc_get_level($user, false, $engine_info['tech'])); |
| 720 | - if(empty($ship_data) || $tech_level >= $engine_info['min_level']) { |
|
| 720 | + if (empty($ship_data) || $tech_level >= $engine_info['min_level']) { |
|
| 721 | 721 | $ship_data = $engine_info; |
| 722 | 722 | $ship_data['tech_level'] = $tech_level; |
| 723 | 723 | } |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | return $ship_data; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | -if(!function_exists('strptime')) { |
|
| 732 | +if (!function_exists('strptime')) { |
|
| 733 | 733 | function strptime($date, $format) { |
| 734 | 734 | $masks = array( |
| 735 | 735 | '%d' => '(?P<d>[0-9]{2})', |
@@ -742,12 +742,12 @@ discard block |
||
| 742 | 742 | ); |
| 743 | 743 | |
| 744 | 744 | $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
| 745 | - if(preg_match($rexep, $date, $out)) { |
|
| 745 | + if (preg_match($rexep, $date, $out)) { |
|
| 746 | 746 | $ret = array( |
| 747 | - "tm_sec" => (int)$out['S'], |
|
| 748 | - "tm_min" => (int)$out['M'], |
|
| 749 | - "tm_hour" => (int)$out['H'], |
|
| 750 | - "tm_mday" => (int)$out['d'], |
|
| 747 | + "tm_sec" => (int) $out['S'], |
|
| 748 | + "tm_min" => (int) $out['M'], |
|
| 749 | + "tm_hour" => (int) $out['H'], |
|
| 750 | + "tm_mday" => (int) $out['d'], |
|
| 751 | 751 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
| 752 | 752 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
| 753 | 753 | ); |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | function sn_sys_sector_buy($redirect = 'overview.php') { |
| 763 | 763 | global $lang, $user, $planetrow; |
| 764 | 764 | |
| 765 | - if(!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
| 765 | + if (!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
| 766 | 766 | return; |
| 767 | 767 | } |
| 768 | 768 | |
@@ -775,9 +775,9 @@ discard block |
||
| 775 | 775 | // $planetrow = $planetrow['planet']; |
| 776 | 776 | $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true); |
| 777 | 777 | $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER]; |
| 778 | - if($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
| 778 | + if ($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
| 779 | 779 | $planet_name_text = uni_render_planet($planetrow); |
| 780 | - if(rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf($lang['sys_sector_purchase_log'], |
|
| 780 | + if (rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf($lang['sys_sector_purchase_log'], |
|
| 781 | 781 | $user['username'], $user['id'], $planet_name_text, $lang['sys_planet_type'][$planetrow['planet_type']], $planetrow['id'], $sector_cost) |
| 782 | 782 | )) { |
| 783 | 783 | $sector_db_name = pname_resource_name(UNIT_SECTOR); |
@@ -792,30 +792,30 @@ discard block |
||
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') { |
| 795 | - if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) { |
|
| 796 | - foreach($handler_list as $function_name => $function_data) { |
|
| 797 | - if(is_string($function_data)) { |
|
| 795 | + if (isset($handler_list) && is_array($handler_list) && !empty($handler_list)) { |
|
| 796 | + foreach ($handler_list as $function_name => $function_data) { |
|
| 797 | + if (is_string($function_data)) { |
|
| 798 | 798 | $override_with = &$function_data; |
| 799 | - } elseif(isset($function_data['callable'])) { |
|
| 799 | + } elseif (isset($function_data['callable'])) { |
|
| 800 | 800 | $override_with = &$function_data['callable']; |
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | $overwrite = $override_with[0] == '*'; |
| 804 | - if($overwrite) { |
|
| 804 | + if ($overwrite) { |
|
| 805 | 805 | $override_with = substr($override_with, 1); |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - if(($point_position = strpos($override_with, '.')) === false && $class_module_name) { |
|
| 808 | + if (($point_position = strpos($override_with, '.')) === false && $class_module_name) { |
|
| 809 | 809 | $override_with = array($class_module_name, $override_with); |
| 810 | - } elseif($point_position == 0) { |
|
| 810 | + } elseif ($point_position == 0) { |
|
| 811 | 811 | $override_with = substr($override_with, 1); |
| 812 | - } elseif($point_position > 0) { |
|
| 812 | + } elseif ($point_position > 0) { |
|
| 813 | 813 | $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1)); |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | - if($overwrite) { |
|
| 816 | + if ($overwrite) { |
|
| 817 | 817 | $functions[$function_name] = array(); |
| 818 | - } elseif(!isset($functions[$function_name])) { |
|
| 818 | + } elseif (!isset($functions[$function_name])) { |
|
| 819 | 819 | $functions[$function_name] = array(); |
| 820 | 820 | $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : ''); |
| 821 | 821 | $functions[$function_name][] = $sn_function_name; |
@@ -831,15 +831,15 @@ discard block |
||
| 831 | 831 | function player_nick_render_to_html($result, $options = false) { |
| 832 | 832 | // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string |
| 833 | 833 | |
| 834 | - if(is_string($result) && strpos($result, ':{i:')) { |
|
| 834 | + if (is_string($result) && strpos($result, ':{i:')) { |
|
| 835 | 835 | $result = player_nick_uncompact($result); |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - if(is_array($result)) { |
|
| 839 | - if(isset($result['id'])) { |
|
| 838 | + if (is_array($result)) { |
|
| 839 | + if (isset($result['id'])) { |
|
| 840 | 840 | $result = player_nick_render_current_to_array($result, $options); |
| 841 | 841 | } |
| 842 | - if(!isset($result[NICK_HTML])) { |
|
| 842 | + if (!isset($result[NICK_HTML])) { |
|
| 843 | 843 | $result = player_nick_render_array_to_html($result); |
| 844 | 844 | } |
| 845 | 845 | unset($result[NICK_HTML]); |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | try { |
| 863 | 863 | $result = unserialize($nick_string); |
| 864 | 864 | // ksort($result); // Всегда ksort-ый в player_nick_compact() |
| 865 | - } catch(exception $e) { |
|
| 865 | + } catch (exception $e) { |
|
| 866 | 866 | $result = strpos($nick_string, ':{i:') ? null : $nick_string; // fallback if it is already string - for old chat strings, for example |
| 867 | 867 | } |
| 868 | 868 | |
@@ -875,20 +875,20 @@ discard block |
||
| 875 | 875 | global $config, $user; |
| 876 | 876 | |
| 877 | 877 | // ALL STRING ARE UNSAFE!!! |
| 878 | - if(isset($nick_array[NICK_BIRTHSDAY])) { |
|
| 878 | + if (isset($nick_array[NICK_BIRTHSDAY])) { |
|
| 879 | 879 | $result[NICK_BIRTHSDAY] = '<img src="design/images/birthday.png" />'; |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | - if(isset($nick_array[NICK_VACATION])) { |
|
| 882 | + if (isset($nick_array[NICK_VACATION])) { |
|
| 883 | 883 | $result[NICK_VACATION] = '<img src="design/images/icon_vacation.png" />'; |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | - if(isset($nick_array[NICK_GENDER])) { |
|
| 886 | + if (isset($nick_array[NICK_GENDER])) { |
|
| 887 | 887 | $result[NICK_GENDER] = '<img src="' . ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH) . 'images/gender_' . $nick_array[NICK_GENDER] . '.png" />'; |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - if(isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
| 891 | - switch($nick_array[NICK_AUTH_LEVEL]) { |
|
| 890 | + if (isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
| 891 | + switch ($nick_array[NICK_AUTH_LEVEL]) { |
|
| 892 | 892 | case 4: |
| 893 | 893 | $highlight = $config->chat_highlight_developer; |
| 894 | 894 | break; |
@@ -909,20 +909,20 @@ discard block |
||
| 909 | 909 | $highlight = isset($nick_array[NICK_PREMIUM]) ? $config->chat_highlight_premium : ''; |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | - if($highlight) { |
|
| 912 | + if ($highlight) { |
|
| 913 | 913 | list($result[NICK_HIGHLIGHT], $result[NICK_HIGHLIGHT_END]) = explode('$1', $highlight); |
| 914 | 914 | } |
| 915 | 915 | // $result = preg_replace("#(.+)#", $highlight, $result); |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | - if(isset($nick_array[NICK_CLASS])) { |
|
| 918 | + if (isset($nick_array[NICK_CLASS])) { |
|
| 919 | 919 | $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] . '>'; |
| 920 | 920 | $result[NICK_CLASS_END] = '</span>'; |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | $result[NICK_NICK] = sys_safe_output($nick_array[NICK_NICK]); |
| 924 | 924 | |
| 925 | - if(isset($nick_array[NICK_ALLY])) { |
|
| 925 | + if (isset($nick_array[NICK_ALLY])) { |
|
| 926 | 926 | $result[NICK_ALLY] = '[' . sys_safe_output($nick_array[NICK_ALLY]) . ']'; |
| 927 | 927 | } |
| 928 | 928 | |
@@ -946,32 +946,32 @@ discard block |
||
| 946 | 946 | */ |
| 947 | 947 | |
| 948 | 948 | |
| 949 | - if($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
|
| 949 | + if ($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
|
| 950 | 950 | $result[NICK_BIRTHSDAY] = ''; |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - if($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
| 953 | + if ($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
| 954 | 954 | $result[NICK_GENDER] = $render_user['gender'] == GENDER_UNKNOWN ? 'unknown' : ($render_user['gender'] == GENDER_FEMALE ? 'female' : 'male'); |
| 955 | 955 | } |
| 956 | 956 | |
| 957 | - if(($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
| 957 | + if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
| 958 | 958 | $result[NICK_VACATION] = $render_user['vacation']; |
| 959 | 959 | } |
| 960 | 960 | |
| 961 | - if($options === true || (isset($options['color']) && $options['color'])) { |
|
| 962 | - if($user_auth_level = $render_user['authlevel']) { |
|
| 961 | + if ($options === true || (isset($options['color']) && $options['color'])) { |
|
| 962 | + if ($user_auth_level = $render_user['authlevel']) { |
|
| 963 | 963 | $result[NICK_AUTH_LEVEL] = $user_auth_level; |
| 964 | 964 | } |
| 965 | - if($user_premium = mrc_get_level($render_user, false, UNIT_PREMIUM)) { |
|
| 965 | + if ($user_premium = mrc_get_level($render_user, false, UNIT_PREMIUM)) { |
|
| 966 | 966 | $result[NICK_PREMIUM] = $user_premium; |
| 967 | 967 | } |
| 968 | 968 | } |
| 969 | 969 | |
| 970 | - if((isset($options['class']) && $options['class'])) { |
|
| 970 | + if ((isset($options['class']) && $options['class'])) { |
|
| 971 | 971 | $result[NICK_CLASS] = (isset($result_options[NICK_CLASS]) ? ' ' . $result_options[NICK_CLASS] : '') . $options['class']; |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | - if($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
| 974 | + if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
| 975 | 975 | $result[NICK_ALLY] = $render_user['ally_tag']; |
| 976 | 976 | } |
| 977 | 977 | |
@@ -989,25 +989,25 @@ discard block |
||
| 989 | 989 | |
| 990 | 990 | $user_skip_list = array(); |
| 991 | 991 | |
| 992 | - if($config->stats_hide_admins) { |
|
| 992 | + if ($config->stats_hide_admins) { |
|
| 993 | 993 | $user_skip_list[] = '`authlevel` > 0'; |
| 994 | 994 | } |
| 995 | 995 | |
| 996 | - if($config->stats_hide_player_list) { |
|
| 996 | + if ($config->stats_hide_player_list) { |
|
| 997 | 997 | $temp = explode(',', $config->stats_hide_player_list); |
| 998 | - foreach($temp as $user_id) { |
|
| 998 | + foreach ($temp as $user_id) { |
|
| 999 | 999 | $user_id = floatval($user_id); |
| 1000 | - if($user_id) { |
|
| 1000 | + if ($user_id) { |
|
| 1001 | 1001 | $user_skip_list[] = '`id` = ' . $user_id; |
| 1002 | 1002 | } |
| 1003 | 1003 | } |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | - if(!empty($user_skip_list)) { |
|
| 1006 | + if (!empty($user_skip_list)) { |
|
| 1007 | 1007 | $user_skip_list = implode(' OR ', $user_skip_list); |
| 1008 | 1008 | $user_skip_query = db_user_list($user_skip_list); |
| 1009 | - if(!empty($user_skip_query)) { |
|
| 1010 | - foreach($user_skip_query as $user_skip_row) { |
|
| 1009 | + if (!empty($user_skip_query)) { |
|
| 1010 | + foreach ($user_skip_query as $user_skip_row) { |
|
| 1011 | 1011 | $result[$user_skip_row['id']] = $user_skip_row['id']; |
| 1012 | 1012 | } |
| 1013 | 1013 | } |
@@ -1038,7 +1038,7 @@ discard block |
||
| 1038 | 1038 | |
| 1039 | 1039 | function sn_sn_get_groups($groups, &$result) { |
| 1040 | 1040 | $result = is_array($result) ? $result : array(); |
| 1041 | - foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) { |
|
| 1041 | + foreach ($groups = is_array($groups) ? $groups : array($groups) as $group_name) { |
|
| 1042 | 1042 | $result += is_array($a_group = get_unit_param(UNIT_GROUP, $group_name)) ? $a_group : array(); |
| 1043 | 1043 | } |
| 1044 | 1044 | |
@@ -1066,8 +1066,8 @@ discard block |
||
| 1066 | 1066 | $sn_data_unit = get_unit_param($unit_id); |
| 1067 | 1067 | |
| 1068 | 1068 | $result = is_array($result) ? $result : array(); |
| 1069 | - if($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && $config->empire_mercenary_temporary)) { |
|
| 1070 | - foreach($sn_data_unit[$field] as $require_id => $require_level) { |
|
| 1069 | + if ($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && $config->empire_mercenary_temporary)) { |
|
| 1070 | + foreach ($sn_data_unit[$field] as $require_id => $require_level) { |
|
| 1071 | 1071 | $level_got = mrc_get_level($user, $planetrow, $require_id); |
| 1072 | 1072 | $level_basic = mrc_get_level($user, $planetrow, $require_id, false, true); |
| 1073 | 1073 | $result[] = array( |
@@ -1091,16 +1091,16 @@ discard block |
||
| 1091 | 1091 | |
| 1092 | 1092 | $ranks = array(); |
| 1093 | 1093 | |
| 1094 | - if($ally['ranklist']) { |
|
| 1094 | + if ($ally['ranklist']) { |
|
| 1095 | 1095 | $str_ranks = explode(';', $ally['ranklist']); |
| 1096 | - foreach($str_ranks as $str_rank) { |
|
| 1097 | - if(!$str_rank) { |
|
| 1096 | + foreach ($str_ranks as $str_rank) { |
|
| 1097 | + if (!$str_rank) { |
|
| 1098 | 1098 | continue; |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | $tmp = explode(',', $str_rank); |
| 1102 | 1102 | $rank_id = count($ranks); |
| 1103 | - foreach($ally_rights as $key => $value) { |
|
| 1103 | + foreach ($ally_rights as $key => $value) { |
|
| 1104 | 1104 | $ranks[$rank_id][$value] = $tmp[$key]; |
| 1105 | 1105 | } |
| 1106 | 1106 | } |
@@ -1116,8 +1116,8 @@ discard block |
||
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | function array_merge_recursive_numeric($array1, $array2) { |
| 1119 | - if(!empty($array2) && is_array($array2)) { |
|
| 1120 | - foreach($array2 as $key => $value) { |
|
| 1119 | + if (!empty($array2) && is_array($array2)) { |
|
| 1120 | + foreach ($array2 as $key => $value) { |
|
| 1121 | 1121 | // if(!isset($array1[$key]) || !is_array($array1[$key])) { |
| 1122 | 1122 | // $array1[$key] = $value; |
| 1123 | 1123 | // } else { |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | |
| 1133 | 1133 | function sn_sys_array_cumulative_sum(&$array) { |
| 1134 | 1134 | $accum = 0; |
| 1135 | - foreach($array as &$value) { |
|
| 1135 | + foreach ($array as &$value) { |
|
| 1136 | 1136 | $accum += $value; |
| 1137 | 1137 | $value = $accum; |
| 1138 | 1138 | } |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | $sn_data_density = sn_get_groups('planet_density'); |
| 1143 | 1143 | $density_price_chart = array(); |
| 1144 | 1144 | |
| 1145 | - foreach($sn_data_density as $density_id => $density_data) { |
|
| 1145 | + foreach ($sn_data_density as $density_id => $density_data) { |
|
| 1146 | 1146 | // Отсекаем записи с RARITY = 0 - служебные записи и супер-ядра |
| 1147 | 1147 | $density_data[UNIT_PLANET_DENSITY_RARITY] ? $density_price_chart[$density_id] = $density_data[UNIT_PLANET_DENSITY_RARITY] : false; |
| 1148 | 1148 | } |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | |
| 1151 | 1151 | $total_rarity = array_sum($density_price_chart); |
| 1152 | 1152 | |
| 1153 | - foreach($density_price_chart as &$density_data) { |
|
| 1153 | + foreach ($density_price_chart as &$density_data) { |
|
| 1154 | 1154 | $density_data = ceil($total_rarity / $density_data * $planet_row['field_max'] * PLANET_DENSITY_TO_DARK_MATTER_RATE); |
| 1155 | 1155 | } |
| 1156 | 1156 | |
@@ -1158,18 +1158,18 @@ discard block |
||
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | function sn_sys_planet_core_transmute(&$user, &$planetrow) { |
| 1161 | - if(!sys_get_param_str('transmute')) { |
|
| 1161 | + if (!sys_get_param_str('transmute')) { |
|
| 1162 | 1162 | return array(); |
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | global $lang; |
| 1166 | 1166 | |
| 1167 | 1167 | try { |
| 1168 | - if($planetrow['planet_type'] != PT_PLANET) { |
|
| 1168 | + if ($planetrow['planet_type'] != PT_PLANET) { |
|
| 1169 | 1169 | throw new exception($lang['ov_core_err_not_a_planet'], ERR_ERROR); |
| 1170 | 1170 | } |
| 1171 | 1171 | |
| 1172 | - if($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
| 1172 | + if ($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
| 1173 | 1173 | throw new exception($lang['ov_core_err_same_density'], ERR_WARNING); |
| 1174 | 1174 | } |
| 1175 | 1175 | |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | $planet_density_index = $planetrow['density_index']; |
| 1184 | 1184 | |
| 1185 | 1185 | $density_price_chart = planet_density_price_chart($planetrow); |
| 1186 | - if(!isset($density_price_chart[$new_density_index])) { |
|
| 1186 | + if (!isset($density_price_chart[$new_density_index])) { |
|
| 1187 | 1187 | // Hack attempt |
| 1188 | 1188 | throw new exception($lang['ov_core_err_denisty_type_wrong'], ERR_ERROR); |
| 1189 | 1189 | } |
@@ -1192,13 +1192,13 @@ discard block |
||
| 1192 | 1192 | // $transmute_cost = get_unit_param(UNIT_PLANET_DENSITY, 'cost'); |
| 1193 | 1193 | // $transmute_cost = $transmute_cost[RES_DARK_MATTER] * $density_price_chart[$new_density_index]; |
| 1194 | 1194 | $transmute_cost = $density_price_chart[$new_density_index]; |
| 1195 | - if($user_dark_matter < $transmute_cost) { |
|
| 1195 | + if ($user_dark_matter < $transmute_cost) { |
|
| 1196 | 1196 | throw new exception($lang['ov_core_err_no_dark_matter'], ERR_ERROR); |
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | $sn_data_planet_density = sn_get_groups('planet_density'); |
| 1200 | - foreach($sn_data_planet_density as $key => $value) { |
|
| 1201 | - if($key == $new_density_index) { |
|
| 1200 | + foreach ($sn_data_planet_density as $key => $value) { |
|
| 1201 | + if ($key == $new_density_index) { |
|
| 1202 | 1202 | break; |
| 1203 | 1203 | } |
| 1204 | 1204 | $prev_density_index = $key; |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | 'STATUS' => ERR_NONE, |
| 1230 | 1230 | 'MESSAGE' => sprintf($lang['ov_core_err_none'], $lang['uni_planet_density_types'][$planet_density_index], $lang['uni_planet_density_types'][$new_density_index], $new_density), |
| 1231 | 1231 | ); |
| 1232 | - } catch(exception $e) { |
|
| 1232 | + } catch (exception $e) { |
|
| 1233 | 1233 | sn_db_transaction_rollback(); |
| 1234 | 1234 | $result = array( |
| 1235 | 1235 | 'STATUS' => $e->getCode(), |
@@ -1242,8 +1242,8 @@ discard block |
||
| 1242 | 1242 | |
| 1243 | 1243 | function sn_module_get_active_count($group = '*') { |
| 1244 | 1244 | $active_modules = 0; |
| 1245 | - if(isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) { |
|
| 1246 | - foreach(sn_module::$sn_module_list[$group] as $payment_module) { |
|
| 1245 | + if (isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) { |
|
| 1246 | + foreach (sn_module::$sn_module_list[$group] as $payment_module) { |
|
| 1247 | 1247 | $active_modules += $payment_module->manifest['active']; |
| 1248 | 1248 | } |
| 1249 | 1249 | } |
@@ -1254,7 +1254,7 @@ discard block |
||
| 1254 | 1254 | function get_resource_exchange() { |
| 1255 | 1255 | static $rates; |
| 1256 | 1256 | |
| 1257 | - if(!$rates) { |
|
| 1257 | + if (!$rates) { |
|
| 1258 | 1258 | global $config; |
| 1259 | 1259 | |
| 1260 | 1260 | $rates = array( |
@@ -1264,7 +1264,7 @@ discard block |
||
| 1264 | 1264 | RES_DARK_MATTER => 'rpg_exchange_darkMatter', |
| 1265 | 1265 | ); |
| 1266 | 1266 | |
| 1267 | - foreach($rates as &$rate) { |
|
| 1267 | + foreach ($rates as &$rate) { |
|
| 1268 | 1268 | $rate = $config->$rate; |
| 1269 | 1269 | } |
| 1270 | 1270 | } |
@@ -1275,12 +1275,12 @@ discard block |
||
| 1275 | 1275 | function get_unit_cost_in(&$cost, $in_resource = RES_METAL) { |
| 1276 | 1276 | static $rates; |
| 1277 | 1277 | |
| 1278 | - if(!$rates) { |
|
| 1278 | + if (!$rates) { |
|
| 1279 | 1279 | $rates = get_resource_exchange(); |
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | $metal_cost = 0; |
| 1283 | - foreach($cost as $resource_id => $resource_value) { |
|
| 1283 | + foreach ($cost as $resource_id => $resource_value) { |
|
| 1284 | 1284 | $metal_cost += $rates[$resource_id] * $resource_value; |
| 1285 | 1285 | } |
| 1286 | 1286 | |
@@ -1290,8 +1290,8 @@ discard block |
||
| 1290 | 1290 | function get_player_max_expeditons(&$user, $astrotech = -1) { return sn_function_call(__FUNCTION__, array(&$user, $astrotech, &$result)); } |
| 1291 | 1291 | |
| 1292 | 1292 | function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) { |
| 1293 | - if($astrotech == -1) { |
|
| 1294 | - if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) { |
|
| 1293 | + if ($astrotech == -1) { |
|
| 1294 | + if (!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) { |
|
| 1295 | 1295 | $astrotech = mrc_get_level($user, false, TECH_ASTROTECH); |
| 1296 | 1296 | $user[UNIT_PLAYER_EXPEDITIONS_MAX] = $astrotech >= 1 ? floor(sqrt($astrotech - 1)) : 0; |
| 1297 | 1297 | } |
@@ -1309,8 +1309,8 @@ discard block |
||
| 1309 | 1309 | function get_player_max_colonies(&$user, $astrotech = -1) { |
| 1310 | 1310 | global $config; |
| 1311 | 1311 | |
| 1312 | - if($astrotech == -1) { |
|
| 1313 | - if(!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 1312 | + if ($astrotech == -1) { |
|
| 1313 | + if (!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 1314 | 1314 | |
| 1315 | 1315 | $expeditions = get_player_max_expeditons($user); |
| 1316 | 1316 | $astrotech = mrc_get_level($user, false, TECH_ASTROTECH); |
@@ -1355,10 +1355,10 @@ discard block |
||
| 1355 | 1355 | |
| 1356 | 1356 | // pdump($powerup_unit, '$powerup_unit'); |
| 1357 | 1357 | $level_current = $term_original = $time_left = 0; |
| 1358 | - if($is_upgrade) { |
|
| 1358 | + if ($is_upgrade) { |
|
| 1359 | 1359 | $time_finish = strtotime($powerup_unit['unit_time_finish']); |
| 1360 | 1360 | $time_left = max(0, $time_finish - SN_TIME_NOW); |
| 1361 | - if($time_left > 0) { |
|
| 1361 | + if ($time_left > 0) { |
|
| 1362 | 1362 | $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']); |
| 1363 | 1363 | $level_current = $powerup_unit['unit_level']; |
| 1364 | 1364 | } |
@@ -1366,22 +1366,22 @@ discard block |
||
| 1366 | 1366 | |
| 1367 | 1367 | $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK]; |
| 1368 | 1368 | $original_cost = 0; |
| 1369 | - for($i = 1; $i <= $level_max; $i++) { |
|
| 1369 | + for ($i = 1; $i <= $level_max; $i++) { |
|
| 1370 | 1370 | $base_cost = eco_get_total_cost($powerup_id, $i); |
| 1371 | 1371 | $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER]; |
| 1372 | - foreach($sn_powerup_buy_discounts as $period => $discount) { |
|
| 1372 | + foreach ($sn_powerup_buy_discounts as $period => $discount) { |
|
| 1373 | 1373 | $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH); |
| 1374 | 1374 | $result[$i][$period] = $upgrade_price; |
| 1375 | 1375 | $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost; |
| 1376 | 1376 | } |
| 1377 | 1377 | } |
| 1378 | 1378 | |
| 1379 | - if($is_upgrade && $time_left) { |
|
| 1379 | + if ($is_upgrade && $time_left) { |
|
| 1380 | 1380 | $term_original = round($term_original / PERIOD_DAY); |
| 1381 | 1381 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
| 1382 | 1382 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
| 1383 | 1383 | |
| 1384 | - array_walk_recursive($result, function (&$value) use ($cost_left) { |
|
| 1384 | + array_walk_recursive($result, function(&$value) use ($cost_left) { |
|
| 1385 | 1385 | $value -= $cost_left; |
| 1386 | 1386 | }); |
| 1387 | 1387 | } |
@@ -1439,7 +1439,7 @@ discard block |
||
| 1439 | 1439 | |
| 1440 | 1440 | function print_rr($var, $capture = false) { |
| 1441 | 1441 | $print = '<pre>' . htmlspecialchars(print_r($var, true)) . '</pre>'; |
| 1442 | - if($capture) { |
|
| 1442 | + if ($capture) { |
|
| 1443 | 1443 | return $print; |
| 1444 | 1444 | } else { |
| 1445 | 1445 | print($print); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Защита от двойного инита |
| 4 | -if(defined('INIT')) { |
|
| 4 | +if (defined('INIT')) { |
|
| 5 | 5 | return; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | version_compare(PHP_VERSION, '5.3.2') < 0 ? die('FATAL ERROR: SuperNova REQUIRE PHP version > 5.3.2') : false; |
| 21 | 21 | |
| 22 | 22 | // Бенчмарк |
| 23 | -register_shutdown_function(function () { |
|
| 24 | - if(defined('IN_AJAX')) { |
|
| 23 | +register_shutdown_function(function() { |
|
| 24 | + if (defined('IN_AJAX')) { |
|
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '') . |
| 32 | 32 | (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: ' . classSupernova::$db->time_mysql_total . 'ms' : '') . |
| 33 | 33 | '</div>'); |
| 34 | - if($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) { |
|
| 34 | + if ($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) { |
|
| 35 | 35 | echo '<a href="badqrys.txt" target="_blank" style="color:red">', 'HACK ALERT!', '</a>'; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if(!empty($locale_cache_statistic['misses'])) { |
|
| 38 | + if (!empty($locale_cache_statistic['misses'])) { |
|
| 39 | 39 | print('<!--'); |
| 40 | 40 | pdump($locale_cache_statistic); |
| 41 | 41 | print('-->'); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | define('SN_TIME_NOW_GMT_STRING', gmdate(DATE_ATOM, SN_TIME_NOW)); |
| 57 | 57 | |
| 58 | -if(strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) { |
|
| 58 | +if (strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) { |
|
| 59 | 59 | define('SN_GOOGLE', true); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | $debug = new debug(); |
| 106 | 106 | classSupernova::debug_set_handler($debug); |
| 107 | 107 | |
| 108 | -spl_autoload_register(function ($class) { |
|
| 109 | - if(file_exists(SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php')) { |
|
| 108 | +spl_autoload_register(function($class) { |
|
| 109 | + if (file_exists(SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php')) { |
|
| 110 | 110 | require_once SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php'; |
| 111 | 111 | } |
| 112 | 112 | }); |
| 113 | 113 | |
| 114 | -spl_autoload_register(function ($class) { |
|
| 115 | - if(file_exists(SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php')) { |
|
| 114 | +spl_autoload_register(function($class) { |
|
| 115 | + if (file_exists(SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php')) { |
|
| 116 | 116 | require_once SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php'; |
| 117 | 117 | } |
| 118 | 118 | }); |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | sn_sys_load_php_files(SN_ROOT_PHYSICAL . "includes/functions/", PHP_EX); |
| 179 | 179 | |
| 180 | -spl_autoload_register(function ($class) { |
|
| 181 | - if(file_exists('includes/classes/' . $class . '.php')) { |
|
| 180 | +spl_autoload_register(function($class) { |
|
| 181 | + if (file_exists('includes/classes/' . $class . '.php')) { |
|
| 182 | 182 | require_once 'includes/classes/' . $class . '.php'; |
| 183 | - } elseif(file_exists('includes/classes/UBE/' . $class . '.php')) { |
|
| 183 | + } elseif (file_exists('includes/classes/UBE/' . $class . '.php')) { |
|
| 184 | 184 | require_once 'includes/classes/UBE/' . $class . '.php'; |
| 185 | 185 | } else { |
| 186 | 186 | // die("Can't find {$class} class"); |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | // Но нужно, пока у нас есть не MVC-страницы |
| 215 | 215 | $sn_page_data = $sn_data['pages'][$sn_page_name]; |
| 216 | 216 | $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX; |
| 217 | -if($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
| 217 | +if ($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
| 218 | 218 | require_once($sn_page_name_file); |
| 219 | - if(is_array($sn_page_data['options'])) { |
|
| 219 | + if (is_array($sn_page_data['options'])) { |
|
| 220 | 220 | $supernova->options = array_merge($supernova->options, $sn_page_data['options']); |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -231,10 +231,10 @@ discard block |
||
| 231 | 231 | $load_order = array(); |
| 232 | 232 | $sn_req = array(); |
| 233 | 233 | |
| 234 | -foreach(sn_module::$sn_module as $loaded_module_name => $module_data) { |
|
| 234 | +foreach (sn_module::$sn_module as $loaded_module_name => $module_data) { |
|
| 235 | 235 | $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000; |
| 236 | - if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
| 237 | - foreach($module_data->manifest['require'] as $require_name) { |
|
| 236 | + if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
| 237 | + foreach ($module_data->manifest['require'] as $require_name) { |
|
| 238 | 238 | $sn_req[$loaded_module_name][$require_name] = 0; |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -247,10 +247,10 @@ discard block |
||
| 247 | 247 | do { |
| 248 | 248 | $prev_order = $load_order; |
| 249 | 249 | |
| 250 | - foreach($sn_req as $loaded_module_name => &$req_data) { |
|
| 250 | + foreach ($sn_req as $loaded_module_name => &$req_data) { |
|
| 251 | 251 | $level = 1; |
| 252 | - foreach($req_data as $req_name => &$req_level) { |
|
| 253 | - if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
| 252 | + foreach ($req_data as $req_name => &$req_level) { |
|
| 253 | + if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
| 254 | 254 | $level = $req_level = -1; |
| 255 | 255 | break; |
| 256 | 256 | } else { |
@@ -258,20 +258,20 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | $req_level = $load_order[$req_name]; |
| 260 | 260 | } |
| 261 | - if($level > $load_order[$loaded_module_name] || $level == -1) { |
|
| 261 | + if ($level > $load_order[$loaded_module_name] || $level == -1) { |
|
| 262 | 262 | $load_order[$loaded_module_name] = $level; |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | -} while($prev_order != $load_order); |
|
| 265 | +} while ($prev_order != $load_order); |
|
| 266 | 266 | |
| 267 | 267 | asort($load_order); |
| 268 | 268 | |
| 269 | 269 | // Инициализируем модули |
| 270 | 270 | // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти |
| 271 | -foreach($load_order as $loaded_module_name => $load_order_order) { |
|
| 272 | - if($load_order_order >= 0) { |
|
| 271 | +foreach ($load_order as $loaded_module_name => $load_order_order) { |
|
| 272 | + if ($load_order_order >= 0) { |
|
| 273 | 273 | sn_module::$sn_module[$loaded_module_name]->check_status(); |
| 274 | - if(!sn_module::$sn_module[$loaded_module_name]->manifest['active']) { |
|
| 274 | + if (!sn_module::$sn_module[$loaded_module_name]->manifest['active']) { |
|
| 275 | 275 | unset(sn_module::$sn_module[$loaded_module_name]); |
| 276 | 276 | continue; |
| 277 | 277 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | unset($sn_req); |
| 289 | 289 | |
| 290 | 290 | // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу |
| 291 | -if(!isset($sn_data['pages'][$sn_page_name])) { |
|
| 291 | +if (!isset($sn_data['pages'][$sn_page_name])) { |
|
| 292 | 292 | $sn_page_name = ''; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -296,6 +296,6 @@ discard block |
||
| 296 | 296 | $lang = new classLocale($config->server_locale_log_usage); |
| 297 | 297 | $lang->lng_switch(sys_get_param_str('lang')); |
| 298 | 298 | |
| 299 | -if(!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) { |
|
| 299 | +if (!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) { |
|
| 300 | 300 | require_once "init_secondary.php"; |
| 301 | 301 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | function gettemplatename($u_dpath) { |
| 11 | 11 | static $template_names = array(); |
| 12 | 12 | |
| 13 | - if(!isset($template_names[$u_dpath])) { |
|
| 13 | + if (!isset($template_names[$u_dpath])) { |
|
| 14 | 14 | $template_names[$u_dpath] = file_exists(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') ? sys_file_read(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') : TEMPLATE_NAME; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | * @param $sn_menu_extra |
| 53 | 53 | */ |
| 54 | 54 | function tpl_menu_merge_extra(&$sn_menu, &$sn_menu_extra) { |
| 55 | - if(empty($sn_menu) || empty($sn_menu_extra)) { |
|
| 55 | + if (empty($sn_menu) || empty($sn_menu_extra)) { |
|
| 56 | 56 | return; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - foreach($sn_menu_extra as $menu_item_id => $menu_item) { |
|
| 60 | - if(empty($menu_item['LOCATION'])) { |
|
| 59 | + foreach ($sn_menu_extra as $menu_item_id => $menu_item) { |
|
| 60 | + if (empty($menu_item['LOCATION'])) { |
|
| 61 | 61 | $sn_menu[$menu_item_id] = $menu_item; |
| 62 | 62 | continue; |
| 63 | 63 | } |
@@ -66,16 +66,16 @@ discard block |
||
| 66 | 66 | unset($menu_item['LOCATION']); |
| 67 | 67 | |
| 68 | 68 | $is_positioned = $item_location[0]; |
| 69 | - if($is_positioned == '+' || $is_positioned == '-') { |
|
| 69 | + if ($is_positioned == '+' || $is_positioned == '-') { |
|
| 70 | 70 | $item_location = substr($item_location, 1); |
| 71 | 71 | } else { |
| 72 | 72 | $is_positioned = ''; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if($item_location) { |
|
| 75 | + if ($item_location) { |
|
| 76 | 76 | $menu_keys = array_keys($sn_menu); |
| 77 | 77 | $insert_position = array_search($item_location, $menu_keys); |
| 78 | - if($insert_position === false) { |
|
| 78 | + if ($insert_position === false) { |
|
| 79 | 79 | $insert_position = count($sn_menu) - 1; |
| 80 | 80 | $is_positioned = '+'; |
| 81 | 81 | $item_location = ''; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $spliced = array_splice($sn_menu, $insert_position, count($sn_menu) - $insert_position); |
| 89 | 89 | $sn_menu[$menu_item_id] = $menu_item; |
| 90 | 90 | |
| 91 | - if(!$is_positioned && $item_location) { |
|
| 91 | + if (!$is_positioned && $item_location) { |
|
| 92 | 92 | unset($spliced[$item_location]); |
| 93 | 93 | } |
| 94 | 94 | $sn_menu = array_merge($sn_menu, $spliced); |
@@ -104,24 +104,24 @@ discard block |
||
| 104 | 104 | function tpl_menu_assign_to_template(&$sn_menu, &$template) { |
| 105 | 105 | global $lang; |
| 106 | 106 | |
| 107 | - if(empty($sn_menu) || !is_array($sn_menu)) { |
|
| 107 | + if (empty($sn_menu) || !is_array($sn_menu)) { |
|
| 108 | 108 | return; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - foreach($sn_menu as $menu_item_id => $menu_item) { |
|
| 112 | - if(!$menu_item) { |
|
| 111 | + foreach ($sn_menu as $menu_item_id => $menu_item) { |
|
| 112 | + if (!$menu_item) { |
|
| 113 | 113 | continue; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if(is_string($menu_item_id)) { |
|
| 116 | + if (is_string($menu_item_id)) { |
|
| 117 | 117 | $menu_item['ID'] = $menu_item_id; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if($menu_item['TYPE'] == 'lang') { |
|
| 120 | + if ($menu_item['TYPE'] == 'lang') { |
|
| 121 | 121 | $lang_string = &$lang; |
| 122 | - if(preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) { |
|
| 123 | - for($i = 1; $i < count($matches); $i++) { |
|
| 124 | - if(defined($matches[$i])) { |
|
| 122 | + if (preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) { |
|
| 123 | + for ($i = 1; $i < count($matches); $i++) { |
|
| 124 | + if (defined($matches[$i])) { |
|
| 125 | 125 | $matches[$i] = constant($matches[$i]); |
| 126 | 126 | } |
| 127 | 127 | $lang_string = &$lang_string[$matches[$i]]; |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | $menu_item['ALT'] = htmlentities($menu_item['ALT']); |
| 134 | 134 | $menu_item['TITLE'] = htmlentities($menu_item['TITLE']); |
| 135 | 135 | |
| 136 | - if(!empty($menu_item['ICON'])) { |
|
| 137 | - if(is_string($menu_item['ICON'])) { |
|
| 136 | + if (!empty($menu_item['ICON'])) { |
|
| 137 | + if (is_string($menu_item['ICON'])) { |
|
| 138 | 138 | $menu_item['ICON_PATH'] = $menu_item['ICON']; |
| 139 | 139 | } else { |
| 140 | 140 | $menu_item['ICON'] = $menu_item_id; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | 'MENU_START_HIDE' => !empty($_COOKIE[SN_COOKIE . '_menu_hidden']) || defined('SN_GOOGLE'), |
| 165 | 165 | )); |
| 166 | 166 | |
| 167 | - if(isset($template_result['MENU_CUSTOMIZE'])) { |
|
| 167 | + if (isset($template_result['MENU_CUSTOMIZE'])) { |
|
| 168 | 168 | $template->assign_vars(array( |
| 169 | 169 | 'PLAYER_OPTION_MENU_SHOW_ON_BUTTON' => classSupernova::$user_options[PLAYER_OPTION_MENU_SHOW_ON_BUTTON], |
| 170 | 170 | 'PLAYER_OPTION_MENU_HIDE_ON_BUTTON' => classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_ON_BUTTON], |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | )); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if(defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) { |
|
| 181 | + if (defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) { |
|
| 182 | 182 | tpl_menu_merge_extra($sn_menu_admin, $sn_menu_admin_extra); |
| 183 | 183 | tpl_menu_assign_to_template($sn_menu_admin, $template); |
| 184 | 184 | } else { |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $in_admin = defined('IN_ADMIN') && IN_ADMIN === true; |
| 219 | 219 | $is_login = defined('LOGIN_LOGOUT') && LOGIN_LOGOUT === true; |
| 220 | 220 | |
| 221 | - if(is_object($page)) { |
|
| 221 | + if (is_object($page)) { |
|
| 222 | 222 | isset($page->_rootref['MENU']) ? $isDisplayMenu = $page->_rootref['MENU'] : false; |
| 223 | 223 | isset($page->_rootref['NAVBAR']) ? $isDisplayTopNav = $page->_rootref['NAVBAR'] : false; |
| 224 | 224 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | !isset($page->_rootref['PAGE_HEADER']) && $title ? $page->assign_var('PAGE_HEADER', $title) : false; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if(empty($user['id']) || !is_numeric($user['id'])) { |
|
| 229 | + if (empty($user['id']) || !is_numeric($user['id'])) { |
|
| 230 | 230 | $isDisplayMenu = false; |
| 231 | 231 | $isDisplayTopNav = false; |
| 232 | 232 | } |
@@ -238,10 +238,10 @@ discard block |
||
| 238 | 238 | $user_time_measured_unix = intval(isset($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) ? strtotime($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) : 0); |
| 239 | 239 | |
| 240 | 240 | $font_size = !empty($_COOKIE[SN_COOKIE_F]) ? $_COOKIE[SN_COOKIE_F] : classSupernova::$user_options[PLAYER_OPTION_BASE_FONT_SIZE]; |
| 241 | - if(strpos($font_size, '%') !== false) { |
|
| 241 | + if (strpos($font_size, '%') !== false) { |
|
| 242 | 242 | // Размер шрифта в процентах |
| 243 | 243 | $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%'; |
| 244 | - } elseif(strpos($font_size, 'px') !== false) { |
|
| 244 | + } elseif (strpos($font_size, 'px') !== false) { |
|
| 245 | 245 | // Размер шрифта в пикселях |
| 246 | 246 | $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px'; |
| 247 | 247 | } else { |
@@ -253,10 +253,10 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | $template = gettemplate('_global_header', true); |
| 255 | 255 | |
| 256 | - if(!empty(classSupernova::$sn_mvc['javascript'])) { |
|
| 257 | - foreach(classSupernova::$sn_mvc['javascript'] as $page_name => $script_list) { |
|
| 258 | - if(empty($page_name) || $page_name == $sn_page_name) { |
|
| 259 | - foreach($script_list as $filename => $content) { |
|
| 256 | + if (!empty(classSupernova::$sn_mvc['javascript'])) { |
|
| 257 | + foreach (classSupernova::$sn_mvc['javascript'] as $page_name => $script_list) { |
|
| 258 | + if (empty($page_name) || $page_name == $sn_page_name) { |
|
| 259 | + foreach ($script_list as $filename => $content) { |
|
| 260 | 260 | $template_result['.']['javascript'][] = array( |
| 261 | 261 | 'FILE' => $filename, |
| 262 | 262 | 'CONTENT' => $content, |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | classSupernova::$sn_mvc['css'][''] = array_merge($standard_css, classSupernova::$sn_mvc['css']['']); |
| 283 | 283 | |
| 284 | 284 | |
| 285 | - foreach(classSupernova::$sn_mvc['css'] as $page_name => $script_list) { |
|
| 286 | - if(empty($page_name) || $page_name == $sn_page_name) { |
|
| 287 | - foreach($script_list as $filename => $content) { |
|
| 285 | + foreach (classSupernova::$sn_mvc['css'] as $page_name => $script_list) { |
|
| 286 | + if (empty($page_name) || $page_name == $sn_page_name) { |
|
| 287 | + foreach ($script_list as $filename => $content) { |
|
| 288 | 288 | $template_result['.']['css'][] = array( |
| 289 | 289 | 'FILE' => $filename, |
| 290 | 290 | 'CONTENT' => $content, |
@@ -331,12 +331,12 @@ discard block |
||
| 331 | 331 | $template->assign_recursive($template_result); |
| 332 | 332 | displayP(parsetemplate($template)); |
| 333 | 333 | |
| 334 | - if(($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) { |
|
| 334 | + if (($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) { |
|
| 335 | 335 | // $AdminPage = $AdminPage ? $user['authlevel'] : 0; |
| 336 | 336 | displayP(parsetemplate(tpl_render_menu())); |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - if($isDisplayTopNav && !$in_admin) { |
|
| 339 | + if ($isDisplayTopNav && !$in_admin) { |
|
| 340 | 340 | displayP(parsetemplate(tpl_render_topnav($user, $planetrow))); |
| 341 | 341 | } |
| 342 | 342 | |
@@ -344,8 +344,8 @@ discard block |
||
| 344 | 344 | |
| 345 | 345 | !is_array($page) ? $page = array($page) : false; |
| 346 | 346 | $result_added = false; |
| 347 | - foreach($page as $page_item) { |
|
| 348 | - if(!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) { |
|
| 347 | + foreach ($page as $page_item) { |
|
| 348 | + if (!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) { |
|
| 349 | 349 | $page_item = gettemplate('_result_message', $page_item); |
| 350 | 350 | $temp = $page_item->files['_result_message']; |
| 351 | 351 | unset($page_item->files['_result_message']); |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | )); |
| 369 | 369 | displayP(parsetemplate($template)); |
| 370 | 370 | |
| 371 | - $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false;; |
|
| 371 | + $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false; ; |
|
| 372 | 372 | |
| 373 | 373 | sn_db_disconnect(); |
| 374 | 374 | |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | * @param string $type |
| 407 | 407 | */ |
| 408 | 408 | function tpl_topnav_event_build(&$template, $FleetList, $type = 'fleet') { |
| 409 | - if(empty($FleetList)) { |
|
| 409 | + if (empty($FleetList)) { |
|
| 410 | 410 | return; |
| 411 | 411 | } |
| 412 | 412 | |
@@ -415,19 +415,19 @@ discard block |
||
| 415 | 415 | $fleet_event_count = 0; |
| 416 | 416 | $fleet_flying_sorter = array(); |
| 417 | 417 | $fleet_flying_events = array(); |
| 418 | - foreach($FleetList->_container as $objFleet) { |
|
| 418 | + foreach ($FleetList->_container as $objFleet) { |
|
| 419 | 419 | $will_return = true; |
| 420 | - if(!$objFleet->isReturning()) { |
|
| 420 | + if (!$objFleet->isReturning()) { |
|
| 421 | 421 | // cut fleets on Hold and Expedition |
| 422 | - if($objFleet->time_arrive_to_target >= SN_TIME_NOW) { |
|
| 422 | + if ($objFleet->time_arrive_to_target >= SN_TIME_NOW) { |
|
| 423 | 423 | $objFleet->mission_type == MT_RELOCATE ? $will_return = false : false; |
| 424 | 424 | tpl_topnav_event_build_helper($objFleet->time_arrive_to_target, EVENT_FLEET_ARRIVE, $lang['sys_event_arrive'], $objFleet->target_coordinates_typed(), !$will_return, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
| 425 | 425 | } |
| 426 | - if($objFleet->time_mission_job_complete) { |
|
| 426 | + if ($objFleet->time_mission_job_complete) { |
|
| 427 | 427 | tpl_topnav_event_build_helper($objFleet->time_mission_job_complete, EVENT_FLEET_STAY, $lang['sys_event_stay'], $objFleet->target_coordinates_typed(), false, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | - if($will_return) { |
|
| 430 | + if ($will_return) { |
|
| 431 | 431 | tpl_topnav_event_build_helper($objFleet->time_return_to_source, EVENT_FLEET_RETURN, $lang['sys_event_return'], $objFleet->launch_coordinates_typed(), true, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count); |
| 432 | 432 | } |
| 433 | 433 | } |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | asort($fleet_flying_sorter); |
| 436 | 436 | |
| 437 | 437 | $fleet_flying_count = $FleetList->count(); |
| 438 | - foreach($fleet_flying_sorter as $fleet_event_id => $fleet_time) { |
|
| 438 | + foreach ($fleet_flying_sorter as $fleet_event_id => $fleet_time) { |
|
| 439 | 439 | $fleet_event = &$fleet_flying_events[$fleet_event_id]; |
| 440 | 440 | $template->assign_block_vars("flying_{$type}s", array( |
| 441 | 441 | 'TIME' => max(0, $fleet_time - SN_TIME_NOW), |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | function sn_tpl_render_topnav(&$user, $planetrow) { |
| 464 | 464 | global $lang, $config, $template_result; |
| 465 | 465 | |
| 466 | - if(!is_array($user)) { |
|
| 466 | + if (!is_array($user)) { |
|
| 467 | 467 | return ''; |
| 468 | 468 | } |
| 469 | 469 | |
@@ -484,8 +484,8 @@ discard block |
||
| 484 | 484 | |
| 485 | 485 | $ThisUsersPlanets = db_planet_list_sorted($user); |
| 486 | 486 | // while ($CurPlanet = db_fetch($ThisUsersPlanets)) |
| 487 | - foreach($ThisUsersPlanets as $CurPlanet) { |
|
| 488 | - if($CurPlanet['destruyed']) { |
|
| 487 | + foreach ($ThisUsersPlanets as $CurPlanet) { |
|
| 488 | + if ($CurPlanet['destruyed']) { |
|
| 489 | 489 | continue; |
| 490 | 490 | } |
| 491 | 491 | |
@@ -509,8 +509,8 @@ discard block |
||
| 509 | 509 | */ |
| 510 | 510 | $fleet_flying_list = array(); |
| 511 | 511 | $fleet_flying_list[0] = FleetList::dbGetFleetListByOwnerId($user['id']); |
| 512 | - foreach($fleet_flying_list[0]->_container as $fleet_id => $objFleet) { |
|
| 513 | - if(empty($fleet_flying_list[$objFleet->mission_type])) { |
|
| 512 | + foreach ($fleet_flying_list[0]->_container as $fleet_id => $objFleet) { |
|
| 513 | + if (empty($fleet_flying_list[$objFleet->mission_type])) { |
|
| 514 | 514 | $fleet_flying_list[$objFleet->mission_type] = new FleetList(); |
| 515 | 515 | } |
| 516 | 516 | $fleet_flying_list[$objFleet->mission_type][$fleet_id] = $objFleet; |
@@ -522,8 +522,8 @@ discard block |
||
| 522 | 522 | que_tpl_parse($template, QUE_RESEARCH, $user, array(), null, !classSupernova::$user_options[PLAYER_OPTION_NAVBAR_RESEARCH_WIDE]); |
| 523 | 523 | que_tpl_parse($template, SUBQUE_FLEET, $user, $planetrow, null, true); |
| 524 | 524 | |
| 525 | - if(!empty(classSupernova::$sn_mvc['navbar_prefix_button']) && is_array(classSupernova::$sn_mvc['navbar_prefix_button'])) { |
|
| 526 | - foreach(classSupernova::$sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) { |
|
| 525 | + if (!empty(classSupernova::$sn_mvc['navbar_prefix_button']) && is_array(classSupernova::$sn_mvc['navbar_prefix_button'])) { |
|
| 526 | + foreach (classSupernova::$sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) { |
|
| 527 | 527 | $template->assign_block_vars('navbar_prefix_button', array( |
| 528 | 528 | 'IMAGE' => $navbar_button_image, |
| 529 | 529 | 'URL_RELATIVE' => $navbar_button_url, |
@@ -537,13 +537,13 @@ discard block |
||
| 537 | 537 | $time_now_parsed = getdate(SN_TIME_NOW); |
| 538 | 538 | $time_local_parsed = getdate(defined('SN_CLIENT_TIME_LOCAL') ? SN_CLIENT_TIME_LOCAL : SN_TIME_NOW); |
| 539 | 539 | |
| 540 | - if($config->game_news_overview) { |
|
| 540 | + if ($config->game_news_overview) { |
|
| 541 | 541 | $user_last_read_safe = intval($user['news_lastread']); |
| 542 | 542 | nws_render($template, "WHERE UNIX_TIMESTAMP(`tsTimeStamp`) >= {$user_last_read_safe}", $config->game_news_overview); |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | $notes_query = db_note_list_by_owner($user['id'], true); |
| 546 | - while($note_row = db_fetch($notes_query)) { |
|
| 546 | + while ($note_row = db_fetch($notes_query)) { |
|
| 547 | 547 | note_assign($template, $note_row); |
| 548 | 548 | } |
| 549 | 549 | |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | 'QUE_ID' => QUE_RESEARCH, |
| 555 | 555 | 'QUE_HTML' => 'topnav', |
| 556 | 556 | |
| 557 | - 'RESEARCH_ONGOING' => (boolean)$user['que'], |
|
| 557 | + 'RESEARCH_ONGOING' => (boolean) $user['que'], |
|
| 558 | 558 | |
| 559 | 559 | 'TIME_TEXT' => sprintf($str_date_format, $time_now_parsed['year'], $lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'], |
| 560 | 560 | $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds'] |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | 'QUE_STRUCTURES' => QUE_STRUCTURES, |
| 632 | 632 | )); |
| 633 | 633 | |
| 634 | - if((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) { |
|
| 634 | + if ((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) { |
|
| 635 | 635 | tpl_set_resource_info($template, $planetrow); |
| 636 | 636 | $template->assign_vars(array( |
| 637 | 637 | 'SN_RENDER_NAVBAR_PLANET' => true, |
@@ -646,12 +646,12 @@ discard block |
||
| 646 | 646 | * @param template|string $template |
| 647 | 647 | */ |
| 648 | 648 | function displayP($template) { |
| 649 | - if(is_object($template)) { |
|
| 650 | - if(empty($template->parsed)) { |
|
| 649 | + if (is_object($template)) { |
|
| 650 | + if (empty($template->parsed)) { |
|
| 651 | 651 | parsetemplate($template); |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - foreach($template->files as $section => $filename) { |
|
| 654 | + foreach ($template->files as $section => $filename) { |
|
| 655 | 655 | $template->display($section); |
| 656 | 656 | } |
| 657 | 657 | } else { |
@@ -666,11 +666,11 @@ discard block |
||
| 666 | 666 | * @return mixed |
| 667 | 667 | */ |
| 668 | 668 | function parsetemplate($template, $array = false) { |
| 669 | - if(is_object($template)) { |
|
| 669 | + if (is_object($template)) { |
|
| 670 | 670 | global $user; |
| 671 | 671 | |
| 672 | - if(!empty($array) && is_array($array)) { |
|
| 673 | - foreach($array as $key => $data) { |
|
| 672 | + if (!empty($array) && is_array($array)) { |
|
| 673 | + foreach ($array as $key => $data) { |
|
| 674 | 674 | $template->assign_var($key, $data); |
| 675 | 675 | } |
| 676 | 676 | } |
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | $template_ex = '.tpl.html'; |
| 713 | 713 | |
| 714 | - if($template === false) { |
|
| 714 | + if ($template === false) { |
|
| 715 | 715 | return sys_file_read(TEMPLATE_DIR . '/' . $files . $template_ex); |
| 716 | 716 | } |
| 717 | 717 | |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | !empty(classSupernova::$sn_mvc['i18n']['']) ? lng_load_i18n(classSupernova::$sn_mvc['i18n']['']) : false; |
| 732 | 732 | $sn_page_name ? lng_load_i18n(classSupernova::$sn_mvc['i18n'][$sn_page_name]) : false; |
| 733 | 733 | |
| 734 | - foreach($files as &$filename) { |
|
| 734 | + foreach ($files as &$filename) { |
|
| 735 | 735 | $filename = $filename . $template_ex; |
| 736 | 736 | } |
| 737 | 737 | |
@@ -756,13 +756,13 @@ discard block |
||
| 756 | 756 | 'LANG' => $language ? $language : '', |
| 757 | 757 | 'referral' => $id_ref ? '&id_ref=' . $id_ref : '', |
| 758 | 758 | |
| 759 | - 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '',// "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
| 759 | + 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '', // "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
| 760 | 760 | 'FILENAME' => basename($_SERVER['PHP_SELF']), |
| 761 | 761 | )); |
| 762 | 762 | |
| 763 | - foreach(lng_get_list() as $lng_id => $lng_data) { |
|
| 764 | - if(isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) { |
|
| 765 | - foreach($lng_data['LANG_VARIANTS'] as $lang_variant) { |
|
| 763 | + foreach (lng_get_list() as $lng_id => $lng_data) { |
|
| 764 | + if (isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) { |
|
| 765 | + foreach ($lng_data['LANG_VARIANTS'] as $lang_variant) { |
|
| 766 | 766 | $lng_data1 = $lng_data; |
| 767 | 767 | $lng_data1 = array_merge($lng_data1, $lang_variant); |
| 768 | 768 | $template->assign_block_vars('language', $lng_data1); |
@@ -785,8 +785,8 @@ discard block |
||
| 785 | 785 | $que = $que['ques'][$que_type][$planet['id_owner']][$planet['id']]; |
| 786 | 786 | |
| 787 | 787 | $que_length = 0; |
| 788 | - if(!empty($que)) { |
|
| 789 | - foreach($que as $que_item) { |
|
| 788 | + if (!empty($que)) { |
|
| 789 | + foreach ($que as $que_item) { |
|
| 790 | 790 | $template->assign_block_vars('que', que_tpl_parse_element($que_item)); |
| 791 | 791 | } |
| 792 | 792 | $que_length = count($que); |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | function tpl_planet_density_info(&$template, &$density_price_chart, $user_dark_matter) { |
| 804 | 804 | global $lang; |
| 805 | 805 | |
| 806 | - foreach($density_price_chart as $density_price_index => &$density_price_data) { |
|
| 806 | + foreach ($density_price_chart as $density_price_index => &$density_price_data) { |
|
| 807 | 807 | $density_cost = $density_price_data; |
| 808 | 808 | $density_number_style = pretty_number($density_cost, true, $user_dark_matter, false, false); |
| 809 | 809 | |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | function tpl_assign_select(&$template, $name, $values) { |
| 828 | 828 | !is_array($values) ? $values = array($values => $values) : false; |
| 829 | 829 | |
| 830 | - foreach($values as $key => $value) { |
|
| 830 | + foreach ($values as $key => $value) { |
|
| 831 | 831 | $template->assign_block_vars($name, array( |
| 832 | 832 | 'KEY' => htmlentities($key, ENT_COMPAT, 'UTF-8'), |
| 833 | 833 | 'VALUE' => htmlentities($value, ENT_COMPAT, 'UTF-8'), |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 10 | 10 | |
| 11 | -if(!sn_module_get_active_count('payment')) { |
|
| 11 | +if (!sn_module_get_active_count('payment')) { |
|
| 12 | 12 | sys_redirect('dark_matter.php'); |
| 13 | 13 | die(); |
| 14 | 14 | } |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | // Таблица скидок |
| 67 | 67 | $prev_discount = 0; |
| 68 | -if(isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) { |
|
| 69 | - foreach(sn_module_payment::$bonus_table as $sum => $discount) { |
|
| 70 | - if($discount && $discount != $prev_discount) { |
|
| 68 | +if (isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) { |
|
| 69 | + foreach (sn_module_payment::$bonus_table as $sum => $discount) { |
|
| 70 | + if ($discount && $discount != $prev_discount) { |
|
| 71 | 71 | $template->assign_block_vars('discount', array( |
| 72 | 72 | 'SUM' => $sum, |
| 73 | 73 | 'DISCOUNT' => $discount * 100, |
@@ -80,19 +80,19 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // Результат платежа |
| 83 | -if($payment_id = sys_get_param_id('payment_id')) { |
|
| 83 | +if ($payment_id = sys_get_param_id('payment_id')) { |
|
| 84 | 84 | $payment = db_payment_get($payment_id); |
| 85 | - if($payment && $payment['payment_user_id'] == $user['id']) { |
|
| 86 | - if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
| 85 | + if ($payment && $payment['payment_user_id'] == $user['id']) { |
|
| 86 | + if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
| 87 | 87 | $template->assign_block_vars('result', array('MESSAGE' => sprintf($lang['pay_msg_mm_purchase_complete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name'], $payment['payment_dark_matter_gained']))); |
| 88 | 88 | } |
| 89 | - if($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
| 89 | + if ($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
| 90 | 90 | $template->assign_block_vars('result', array( |
| 91 | 91 | 'MESSAGE' => sprintf($lang['pay_msg_mm_purchase_incomplete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name']), |
| 92 | 92 | 'STATUS' => 1, |
| 93 | 93 | )); |
| 94 | 94 | } |
| 95 | - if($payment['payment_test']) { |
|
| 95 | + if ($payment['payment_test']) { |
|
| 96 | 96 | $template->assign_block_vars('result', array( |
| 97 | 97 | 'MESSAGE' => sprintf($lang['pay_msg_mm_purchase_test']), |
| 98 | 98 | 'STATUS' => -1, |
@@ -107,28 +107,28 @@ discard block |
||
| 107 | 107 | 'metamatter' => sys_get_param_float('metamatter'), |
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | -if(!$request['metamatter']) { |
|
| 110 | +if (!$request['metamatter']) { |
|
| 111 | 111 | unset($_POST); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $payment_methods_available = array_combine(array_keys(sn_module_payment::$payment_methods), array_fill(0, count(sn_module_payment::$payment_methods), null)); |
| 115 | -array_walk($payment_methods_available, function (&$value, $index) { |
|
| 115 | +array_walk($payment_methods_available, function(&$value, $index) { |
|
| 116 | 116 | $value = !empty(sn_module_payment::$payment_methods[$index]) ? array_combine(array_keys(sn_module_payment::$payment_methods[$index]), array_fill(0, count(sn_module_payment::$payment_methods[$index]), null)) : $value; |
| 117 | 117 | }); |
| 118 | 118 | |
| 119 | 119 | // pdump($payment_methods_available); |
| 120 | 120 | $payment_module_valid = false; |
| 121 | 121 | $payment_module = sys_get_param_str('payment_module'); |
| 122 | -foreach(sn_module::$sn_module_list['payment'] as $module_name => $module) { |
|
| 123 | - if(!is_object($module) || !$module->manifest['active']) { |
|
| 122 | +foreach (sn_module::$sn_module_list['payment'] as $module_name => $module) { |
|
| 123 | + if (!is_object($module) || !$module->manifest['active']) { |
|
| 124 | 124 | continue; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | lng_include($module_name, $module->manifest['root_relative']); |
| 128 | 128 | |
| 129 | - foreach(sn_module_payment::$payment_methods as $payment_type_id => $available_methods) { |
|
| 130 | - foreach($available_methods as $payment_method => $payment_currency) { |
|
| 131 | - if(isset($module->manifest['payment_method'][$payment_method])) { |
|
| 129 | + foreach (sn_module_payment::$payment_methods as $payment_type_id => $available_methods) { |
|
| 130 | + foreach ($available_methods as $payment_method => $payment_currency) { |
|
| 131 | + if (isset($module->manifest['payment_method'][$payment_method])) { |
|
| 132 | 132 | $payment_methods_available[$payment_type_id][$payment_method][$module_name] = $module->manifest['payment_method'][$payment_method]; |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | global $template_result; |
| 141 | 141 | // Доступные платежные методы |
| 142 | -foreach($payment_methods_available as $payment_type_id => $payment_methods) { |
|
| 143 | - if(empty($payment_methods)) { |
|
| 142 | +foreach ($payment_methods_available as $payment_type_id => $payment_methods) { |
|
| 143 | + if (empty($payment_methods)) { |
|
| 144 | 144 | continue; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | 'ID' => $payment_type_id, |
| 149 | 149 | 'NAME' => $lang['pay_methods'][$payment_type_id], |
| 150 | 150 | ); |
| 151 | - foreach($payment_methods as $payment_method_id => $module_list) { |
|
| 152 | - if(empty($module_list)) { |
|
| 151 | + foreach ($payment_methods as $payment_method_id => $module_list) { |
|
| 152 | + if (empty($module_list)) { |
|
| 153 | 153 | continue; |
| 154 | 154 | } |
| 155 | 155 | $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id] = array( |
@@ -160,14 +160,14 @@ discard block |
||
| 160 | 160 | 'NAME_FORCE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['name']), |
| 161 | 161 | 'BUTTON' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['button']), |
| 162 | 162 | ); |
| 163 | - foreach($module_list as $payment_module_name => $payment_module_method_details) { |
|
| 163 | + foreach ($module_list as $payment_module_name => $payment_module_method_details) { |
|
| 164 | 164 | $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id]['.']['module'][] = array( |
| 165 | 165 | 'MODULE' => $payment_module_name, |
| 166 | 166 | ); |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if(empty($template_result['.']['payment'][$payment_type_id]['.'])) { |
|
| 170 | + if (empty($template_result['.']['payment'][$payment_type_id]['.'])) { |
|
| 171 | 171 | unset($template_result['.']['payment'][$payment_type_id]); |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -180,19 +180,19 @@ discard block |
||
| 180 | 180 | $payment_module_valid = $payment_module_valid && (!$payment_method_selected || isset($payment_methods_available[$payment_type_selected][$payment_method_selected][$module_name])); |
| 181 | 181 | |
| 182 | 182 | // If payment_module invalid - making it empty OR if there is only one payment_module - selecting it |
| 183 | -if($payment_module_valid) { |
|
| 183 | +if ($payment_module_valid) { |
|
| 184 | 184 | // $payment_module = $payment_module; // Really - do nothing |
| 185 | -} elseif($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) { |
|
| 185 | +} elseif ($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) { |
|
| 186 | 186 | reset($payment_methods_available[$payment_type_selected][$payment_method_selected]); |
| 187 | 187 | $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]); |
| 188 | -} elseif(count(sn_module::$sn_module_list['payment']) == 1) { |
|
| 188 | +} elseif (count(sn_module::$sn_module_list['payment']) == 1) { |
|
| 189 | 189 | $payment_module = $module_name; |
| 190 | 190 | } else { |
| 191 | 191 | $payment_module = ''; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | -if($payment_type_selected && $payment_method_selected) { |
|
| 195 | - foreach($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) { |
|
| 194 | +if ($payment_type_selected && $payment_method_selected) { |
|
| 195 | + foreach ($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) { |
|
| 196 | 196 | $template->assign_block_vars('payment_module', array( |
| 197 | 197 | 'ID' => $module_name, |
| 198 | 198 | 'NAME' => $lang["module_{$module_name}_name"], |
@@ -201,10 +201,10 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | -foreach($lang['pay_currency_list'] as $key => $value) { |
|
| 204 | +foreach ($lang['pay_currency_list'] as $key => $value) { |
|
| 205 | 205 | $course = get_exchange_rate($key); |
| 206 | 206 | // if(!$course || $key == $config->payment_currency_default) { |
| 207 | - if(!$course) { |
|
| 207 | + if (!$course) { |
|
| 208 | 208 | continue; |
| 209 | 209 | } |
| 210 | 210 | $template->assign_block_vars('exchange', array( |
@@ -219,17 +219,17 @@ discard block |
||
| 219 | 219 | )); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | -if($request['metamatter'] && $payment_module) { |
|
| 222 | +if ($request['metamatter'] && $payment_module) { |
|
| 223 | 223 | try { |
| 224 | 224 | // Any possible errors about generating paylink should be raised in module! |
| 225 | 225 | $pay_link = sn_module::$sn_module[$payment_module]->compile_request($request); |
| 226 | 226 | |
| 227 | 227 | // Поддержка дополнительной информации |
| 228 | - if(is_array($pay_link['RENDER'])) { |
|
| 229 | - foreach($pay_link['RENDER'] as $html_data) { |
|
| 228 | + if (is_array($pay_link['RENDER'])) { |
|
| 229 | + foreach ($pay_link['RENDER'] as $html_data) { |
|
| 230 | 230 | $template->assign_block_vars('render', $html_data); |
| 231 | - if(isset($html_data['VALUE']) && is_array($html_data['VALUE'])) { |
|
| 232 | - foreach($html_data['VALUE'] as $value_id => $value_value) { |
|
| 231 | + if (isset($html_data['VALUE']) && is_array($html_data['VALUE'])) { |
|
| 232 | + foreach ($html_data['VALUE'] as $value_id => $value_value) { |
|
| 233 | 233 | $template->assign_block_vars('render.value', array( |
| 234 | 234 | 'FIELD' => $value_id, |
| 235 | 235 | 'VALUE' => $value_value, |
@@ -240,8 +240,8 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | // Поддержка передачи данных для многошаговых платежных систем |
| 243 | - if(is_array($pay_link['DATA'])) { |
|
| 244 | - foreach($pay_link['DATA'] as $key => $value) { |
|
| 243 | + if (is_array($pay_link['DATA'])) { |
|
| 244 | + foreach ($pay_link['DATA'] as $key => $value) { |
|
| 245 | 245 | $template->assign_block_vars('pay_link_data', array( |
| 246 | 246 | 'FIELD' => $key, |
| 247 | 247 | 'VALUE' => $value, |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if(is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) { |
|
| 252 | + if (is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) { |
|
| 253 | 253 | // TODO Переделать это под assign_vars_recursive и возвращать пустые строки если нет платежного метода - для унификации формы в темплейте |
| 254 | 254 | $template->assign_vars(array( |
| 255 | 255 | 'PAY_LINK_METHOD' => $pay_link['PAY_LINK_METHOD'], |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | } else { |
| 259 | 259 | throw new exception($lang['pay_msg_request_paylink_unsupported'], ERR_ERROR); |
| 260 | 260 | } |
| 261 | - } catch(exception $e) { |
|
| 261 | + } catch (exception $e) { |
|
| 262 | 262 | $template->assign_block_vars('result', $response = array( |
| 263 | 263 | 'STATUS' => $e->getCode(), |
| 264 | 264 | 'MESSAGE' => $e->getMessage(), |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // Прегенерированные пакеты |
| 271 | -foreach($unit_available_amount_list as $unit_amount => $discount) { |
|
| 271 | +foreach ($unit_available_amount_list as $unit_amount => $discount) { |
|
| 272 | 272 | $temp = sn_module_payment::currency_convert($unit_amount, 'MM_', $player_currency); |
| 273 | 273 | $template->assign_block_vars('mm_amount', array( |
| 274 | 274 | 'VALUE' => $unit_amount, |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | 'PLAYER_CURRENCY' => $player_currency, |
| 304 | 304 | 'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10), |
| 305 | 305 | |
| 306 | - 'UNIT_AMOUNT' => (float)$request['metamatter'], |
|
| 306 | + 'UNIT_AMOUNT' => (float) $request['metamatter'], |
|
| 307 | 307 | 'UNIT_AMOUNT_TEXT' => pretty_number($request['metamatter']), |
| 308 | 308 | 'UNIT_AMOUNT_BONUS_PERCENT' => $bonus_percent, |
| 309 | 309 | 'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text, |