@@ -64,6 +64,10 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | */ |
| 66 | 66 | // DEPRECATED |
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * @param boolean $for_update |
|
| 70 | + */ |
|
| 67 | 71 | public static function dbGetFleetList($where_safe = '', $for_update = DB_SELECT_FOR_UPDATE) { |
| 68 | 72 | $fleetList = new static(); |
| 69 | 73 | $fleetList->dbLoadWhere($where_safe, $for_update); |
@@ -246,6 +250,7 @@ discard block |
||
| 246 | 250 | * LIST - Get missile attack list by condition |
| 247 | 251 | * |
| 248 | 252 | * @param string $where |
| 253 | + * @param boolean $for_update |
|
| 249 | 254 | */ |
| 250 | 255 | public function dbMergeMissileList($where, $for_update = DB_SELECT_FOR_UPDATE) { |
| 251 | 256 | $query = classSupernova::$db->doSelect( |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | (!empty($where_safe) ? " WHERE {$where_safe}" : '') . |
| 38 | 38 | " FOR UPDATE;" |
| 39 | 39 | ); |
| 40 | - while($row = db_fetch($query)) { |
|
| 40 | + while ($row = db_fetch($query)) { |
|
| 41 | 41 | /** |
| 42 | 42 | * @var Fleet $fleet |
| 43 | 43 | */ |
| 44 | 44 | $fleet = $this->_createElement(); |
| 45 | 45 | $fleet->dbRowParse($row); |
| 46 | 46 | |
| 47 | - if(isset($this[$fleet->dbId])) { |
|
| 47 | + if (isset($this[$fleet->dbId])) { |
|
| 48 | 48 | // Нужно ли ???? |
| 49 | 49 | classSupernova::$debug->error('Fleet list already set'); |
| 50 | 50 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @return static |
| 171 | 171 | */ |
| 172 | 172 | public static function dbGetFleetListAndMissileByCoordinates($coordinates, $for_phalanx = false) { |
| 173 | - if(empty($coordinates) || !is_array($coordinates)) { |
|
| 173 | + if (empty($coordinates) || !is_array($coordinates)) { |
|
| 174 | 174 | return array(); |
| 175 | 175 | } |
| 176 | 176 | |
@@ -199,8 +199,8 @@ discard block |
||
| 199 | 199 | * @var Fleet[] $array_of_Fleet |
| 200 | 200 | */ |
| 201 | 201 | $array_of_Fleet = array(); |
| 202 | - if(!empty($fleet_db_list) && $fleet_db_list->count()) { |
|
| 203 | - foreach($fleet_db_list->_container as $fleet_id => $objFleet) { |
|
| 202 | + if (!empty($fleet_db_list) && $fleet_db_list->count()) { |
|
| 203 | + foreach ($fleet_db_list->_container as $fleet_id => $objFleet) { |
|
| 204 | 204 | $array_of_Fleet[$fleet_id] = $objFleet; |
| 205 | 205 | } |
| 206 | 206 | $planet_fleets = flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | "SELECT * FROM `{{iraks}}`" . |
| 250 | 250 | (!empty($where) ? " WHERE {$where}" : '') . |
| 251 | 251 | " FOR UPDATE;"); |
| 252 | - while($missile_db_row = db_fetch($query)) { |
|
| 252 | + while ($missile_db_row = db_fetch($query)) { |
|
| 253 | 253 | /** |
| 254 | 254 | * @var Fleet $objFleet |
| 255 | 255 | */ |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | public static function dbGetFleetListAndMissileINCOMING($owner_id) { |
| 273 | 273 | $owner_id_safe = idval($owner_id); |
| 274 | - if(empty($owner_id_safe)) { |
|
| 274 | + if (empty($owner_id_safe)) { |
|
| 275 | 275 | return array(); |
| 276 | 276 | } |
| 277 | 277 | |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | */ |
| 306 | 306 | public static function fleet_count_flying($player_id, $mission_id = 0) { |
| 307 | 307 | $player_id_safe = idval($player_id); |
| 308 | - if(!empty($player_id_safe)) { |
|
| 308 | + if (!empty($player_id_safe)) { |
|
| 309 | 309 | $mission_id_safe = intval($mission_id); |
| 310 | 310 | $result = static::db_fleet_count( |
| 311 | 311 | "`fleet_owner` = {$player_id_safe}" . |
@@ -820,7 +820,7 @@ discard block |
||
| 820 | 820 | |
| 821 | 821 | |
| 822 | 822 | /** |
| 823 | - * @return int |
|
| 823 | + * @return boolean |
|
| 824 | 824 | */ |
| 825 | 825 | protected function checkExpeditionsMax() { |
| 826 | 826 | return get_player_max_expeditons($this->fleet->dbOwnerRow) > 0; |
@@ -920,6 +920,10 @@ discard block |
||
| 920 | 920 | $this->checkMissionExact($missionType); |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | + /** |
|
| 924 | + * @param integer $missionType |
|
| 925 | + * @param boolean $result |
|
| 926 | + */ |
|
| 923 | 927 | protected function checkMissionResultAndUnset($missionType, $result, $forceMission = false) { |
| 924 | 928 | $this->unsetMission($missionType, $result, $forceMission); |
| 925 | 929 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | 'checkSpeedPercentOld' => FLIGHT_FLEET_SPEED_WRONG, |
| 17 | 17 | 'checkTargetInUniverse' => FLIGHT_VECTOR_BEYOND_UNIVERSE, |
| 18 | 18 | 'checkTargetNotSource' => FLIGHT_VECTOR_SAME_SOURCE, |
| 19 | - 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, // tODO |
|
| 19 | + 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, // tODO |
|
| 20 | 20 | 'checkTargetNoVacation' => FLIGHT_PLAYER_VACATION, |
| 21 | 21 | 'checkFleetNotEmpty' => FLIGHT_SHIPS_NO_SHIPS, |
| 22 | 22 | // 'checkUnitsPositive' => FLIGHT_SHIPS_NEGATIVE, // Unused - 'cause it's not allowed to put negative units into Unit class |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | $this->checkMissionRestrictions($action); |
| 159 | 159 | } else { |
| 160 | 160 | // No - then just performing action |
| 161 | - if($exception) { |
|
| 161 | + if ($exception) { |
|
| 162 | 162 | throw new ExceptionFleetInvalid($action, $action); |
| 163 | 163 | } else { |
| 164 | 164 | return $action; |
@@ -16,10 +16,10 @@ discard block |
||
| 16 | 16 | $RecyclerCapacity = 0; |
| 17 | 17 | $OtherFleetCapacity = 0; |
| 18 | 18 | |
| 19 | - foreach($objFleet->shipsIterator() as $unit_id => $unit) { |
|
| 20 | - if(in_array($unit_id, classSupernova::$gc->groupFleet)) { |
|
| 19 | + foreach ($objFleet->shipsIterator() as $unit_id => $unit) { |
|
| 20 | + if (in_array($unit_id, classSupernova::$gc->groupFleet)) { |
|
| 21 | 21 | $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit->count; |
| 22 | - if(in_array($unit_id, classSupernova::$gc->groupRecyclers)) { |
|
| 22 | + if (in_array($unit_id, classSupernova::$gc->groupRecyclers)) { |
|
| 23 | 23 | $RecyclerCapacity += $capacity; |
| 24 | 24 | } else { |
| 25 | 25 | $OtherFleetCapacity += $capacity; |
@@ -28,33 +28,33 @@ discard block |
||
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $fleet_resources_amount = $objFleet->resourcesGetTotal(); |
| 31 | - if($fleet_resources_amount > $OtherFleetCapacity) { |
|
| 31 | + if ($fleet_resources_amount > $OtherFleetCapacity) { |
|
| 32 | 32 | // Если во флоте есть другие корабли И количество ресурсов больше, чем их ёмкость трюмов - значит часть этих ресурсов лежит в трюмах переработчиков |
| 33 | 33 | // Уменьшаем ёмкость переработчиков на указанную величину |
| 34 | 34 | $RecyclerCapacity -= ($fleet_resources_amount - $OtherFleetCapacity); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $resources_recycled = array(); |
| 38 | - if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) { |
|
| 38 | + if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) { |
|
| 39 | 39 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
| 40 | 40 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
| 41 | 41 | } else { |
| 42 | - if(($destination_planet["debris_metal"] > $RecyclerCapacity / 2) && |
|
| 42 | + if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) && |
|
| 43 | 43 | ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2) |
| 44 | 44 | ) { |
| 45 | 45 | $resources_recycled[RES_METAL] = $RecyclerCapacity / 2; |
| 46 | 46 | $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity / 2; |
| 47 | 47 | } else { |
| 48 | - if($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) { |
|
| 48 | + if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) { |
|
| 49 | 49 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
| 50 | - if($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) { |
|
| 50 | + if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) { |
|
| 51 | 51 | $resources_recycled[RES_METAL] = $RecyclerCapacity - $resources_recycled[RES_CRYSTAL]; |
| 52 | 52 | } else { |
| 53 | 53 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
| 54 | 54 | } |
| 55 | 55 | } else { |
| 56 | 56 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
| 57 | - if($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) { |
|
| 57 | + if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) { |
|
| 58 | 58 | $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity - $resources_recycled[RES_METAL]; |
| 59 | 59 | } else { |
| 60 | 60 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
@@ -979,7 +979,7 @@ discard block |
||
| 979 | 979 | /** |
| 980 | 980 | * Set current resource list from array of units |
| 981 | 981 | * |
| 982 | - * @param array $resource_list |
|
| 982 | + * @param integer[] $resource_list |
|
| 983 | 983 | */ |
| 984 | 984 | public function resourcesSet($resource_list) { |
| 985 | 985 | if (!empty($this->propertiesAdjusted['resource_list'])) { |
@@ -1027,7 +1027,7 @@ discard block |
||
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | 1029 | /** |
| 1030 | - * @param array $rate |
|
| 1030 | + * @param integer[] $rate |
|
| 1031 | 1031 | * |
| 1032 | 1032 | * @return float |
| 1033 | 1033 | */ |
@@ -1058,8 +1058,6 @@ discard block |
||
| 1058 | 1058 | * Restores fleet or resources to planet |
| 1059 | 1059 | * |
| 1060 | 1060 | * @param bool $start |
| 1061 | - * @param bool $only_resources |
|
| 1062 | - * @param int $result |
|
| 1063 | 1061 | */ |
| 1064 | 1062 | public function resourcesUnload($start = true) { |
| 1065 | 1063 | sn_db_transaction_check(true); |
@@ -1,6 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | use DBStatic\DBStaticFleetACS; |
| 3 | -use DBStatic\DBStaticNote; |
|
| 4 | 3 | use DBStatic\DBStaticPlanet; |
| 5 | 4 | use DBStatic\DBStaticUnit; |
| 6 | 5 | use DBStatic\DBStaticUser; |
@@ -1325,14 +1325,14 @@ |
||
| 1325 | 1325 | if (FLIGHT_ALLOWED == $validateResult[$missionType]) { |
| 1326 | 1326 | $this->allowed_missions[$missionType] = $mission; |
| 1327 | 1327 | } else { |
| 1328 | - if($missionType == $this->mission_type) { |
|
| 1328 | + if ($missionType == $this->mission_type) { |
|
| 1329 | 1329 | } |
| 1330 | 1330 | unset($this->allowed_missions[$missionType]); |
| 1331 | 1331 | } |
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | - if(empty($this->allowed_missions)) { |
|
| 1335 | - if($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) { |
|
| 1334 | + if (empty($this->allowed_missions)) { |
|
| 1335 | + if ($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) { |
|
| 1336 | 1336 | throw new ExceptionFleetInvalid($validateResult[$this->mission_type], $validateResult[$this->mission_type]); |
| 1337 | 1337 | } else { |
| 1338 | 1338 | throw new ExceptionFleetInvalid(FLIGHT_MISSION_IMPOSSIBLE, FLIGHT_MISSION_IMPOSSIBLE); |
@@ -52,82 +52,82 @@ |
||
| 52 | 52 | $gc = $this; |
| 53 | 53 | |
| 54 | 54 | // Default db |
| 55 | - $gc->db = function ($c) { |
|
| 55 | + $gc->db = function($c) { |
|
| 56 | 56 | classSupernova::$db = $db = new \db_mysql($c); |
| 57 | 57 | |
| 58 | 58 | return $db; |
| 59 | 59 | }; |
| 60 | 60 | |
| 61 | - $gc->debug = function ($c) { |
|
| 61 | + $gc->debug = function($c) { |
|
| 62 | 62 | return new \debug(); |
| 63 | 63 | }; |
| 64 | 64 | |
| 65 | - $gc->types = function ($c) { |
|
| 65 | + $gc->types = function($c) { |
|
| 66 | 66 | return new \Common\Types(); |
| 67 | 67 | }; |
| 68 | 68 | |
| 69 | - $gc->cache = function ($c) { |
|
| 69 | + $gc->cache = function($c) { |
|
| 70 | 70 | return new \classCache(classSupernova::$cache_prefix); |
| 71 | 71 | }; |
| 72 | 72 | |
| 73 | - $gc->config = function ($c) { |
|
| 73 | + $gc->config = function($c) { |
|
| 74 | 74 | return new \classConfig(classSupernova::$cache_prefix); |
| 75 | 75 | }; |
| 76 | 76 | |
| 77 | - $gc->localePlayer = function (GlobalContainer $c) { |
|
| 77 | + $gc->localePlayer = function(GlobalContainer $c) { |
|
| 78 | 78 | return new \classLocale($c->config->server_locale_log_usage); |
| 79 | 79 | }; |
| 80 | 80 | |
| 81 | - $gc->dbGlobalRowOperator = function (GlobalContainer $c) { |
|
| 81 | + $gc->dbGlobalRowOperator = function(GlobalContainer $c) { |
|
| 82 | 82 | return new \DbRowDirectOperator($c->db); |
| 83 | 83 | }; |
| 84 | 84 | |
| 85 | - $gc->query = $gc->factory(function (GlobalContainer $c) { |
|
| 85 | + $gc->query = $gc->factory(function(GlobalContainer $c) { |
|
| 86 | 86 | return new \DbQueryConstructor($c->db); |
| 87 | 87 | }); |
| 88 | 88 | |
| 89 | - $gc->cacheOperator = function (GlobalContainer $gc) { |
|
| 89 | + $gc->cacheOperator = function(GlobalContainer $gc) { |
|
| 90 | 90 | return new \SnDbCachedOperator($gc); |
| 91 | 91 | }; |
| 92 | 92 | |
| 93 | 93 | $gc->snCacheClass = 'SnCache'; |
| 94 | - $gc->snCache = function (GlobalContainer $gc) { |
|
| 94 | + $gc->snCache = function(GlobalContainer $gc) { |
|
| 95 | 95 | return $gc->db->snCache; |
| 96 | 96 | }; |
| 97 | 97 | |
| 98 | 98 | $gc->buddyClass = 'Buddy\BuddyModel'; |
| 99 | - $gc->buddyModel = function (GlobalContainer $c) { |
|
| 99 | + $gc->buddyModel = function(GlobalContainer $c) { |
|
| 100 | 100 | return new $c->buddyClass($c); |
| 101 | 101 | }; |
| 102 | 102 | |
| 103 | - $gc->unitModel = function (GlobalContainer $c) { |
|
| 103 | + $gc->unitModel = function(GlobalContainer $c) { |
|
| 104 | 104 | return new \V2Unit\V2UnitModel($c); |
| 105 | 105 | }; |
| 106 | - $gc->unitList = $this->factory(function (GlobalContainer $c) { |
|
| 106 | + $gc->unitList = $this->factory(function(GlobalContainer $c) { |
|
| 107 | 107 | return new \V2Unit\V2UnitList($c); |
| 108 | 108 | }); |
| 109 | 109 | |
| 110 | - $gc->fleetModel = function (GlobalContainer $c) { |
|
| 110 | + $gc->fleetModel = function(GlobalContainer $c) { |
|
| 111 | 111 | return new V2FleetModel($c); |
| 112 | 112 | }; |
| 113 | 113 | |
| 114 | - $gc->planetRenderer = function (GlobalContainer $c) { |
|
| 114 | + $gc->planetRenderer = function(GlobalContainer $c) { |
|
| 115 | 115 | return new PlanetRenderer($c); |
| 116 | 116 | }; |
| 117 | 117 | |
| 118 | - $gc->fleetRenderer = function (GlobalContainer $c) { |
|
| 118 | + $gc->fleetRenderer = function(GlobalContainer $c) { |
|
| 119 | 119 | return new \FleetRenderer($c); |
| 120 | 120 | }; |
| 121 | 121 | |
| 122 | - $gc->groupFleet = function (GlobalContainer $c) { |
|
| 122 | + $gc->groupFleet = function(GlobalContainer $c) { |
|
| 123 | 123 | return sn_get_groups('fleet'); |
| 124 | 124 | }; |
| 125 | 125 | |
| 126 | - $gc->groupFleetAndMissiles = function (GlobalContainer $c) { |
|
| 126 | + $gc->groupFleetAndMissiles = function(GlobalContainer $c) { |
|
| 127 | 127 | return sn_get_groups(array('fleet', GROUP_STR_MISSILES)); |
| 128 | 128 | }; |
| 129 | 129 | |
| 130 | - $gc->groupRecyclers = function (GlobalContainer $c) { |
|
| 130 | + $gc->groupRecyclers = function(GlobalContainer $c) { |
|
| 131 | 131 | return sn_get_groups('flt_recyclers'); |
| 132 | 132 | }; |
| 133 | 133 | |
@@ -171,6 +171,10 @@ discard block |
||
| 171 | 171 | * @return bool |
| 172 | 172 | */ |
| 173 | 173 | // OK v4.5 |
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * @param string $account_name_unsafe |
|
| 177 | + */ |
|
| 174 | 178 | public function db_get_by_name($account_name_unsafe) { |
| 175 | 179 | $this->reset(); |
| 176 | 180 | |
@@ -207,6 +211,11 @@ discard block |
||
| 207 | 211 | * |
| 208 | 212 | */ |
| 209 | 213 | // OK v4.5 |
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * @param string $account_name_unsafe |
|
| 217 | + * @param string $email_unsafe |
|
| 218 | + */ |
|
| 210 | 219 | public function db_get_by_name_or_email($account_name_unsafe, $email_unsafe) { |
| 211 | 220 | $this->reset(); |
| 212 | 221 | |
@@ -223,6 +232,13 @@ discard block |
||
| 223 | 232 | * @throws Exception |
| 224 | 233 | */ |
| 225 | 234 | // OK v4.5 |
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * @param string $account_name_unsafe |
|
| 238 | + * @param string $password_raw |
|
| 239 | + * @param string $email_unsafe |
|
| 240 | + * @param string $language_unsafe |
|
| 241 | + */ |
|
| 226 | 242 | public function db_create($account_name_unsafe, $password_raw, $email_unsafe, $language_unsafe = null, $salt_unsafe = null) { |
| 227 | 243 | $this->reset(); |
| 228 | 244 | |
@@ -317,6 +333,11 @@ discard block |
||
| 317 | 333 | * @return int|string |
| 318 | 334 | */ |
| 319 | 335 | // OK 4.8 |
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * @param integer $change_type |
|
| 339 | + * @param double $metamatter |
|
| 340 | + */ |
|
| 320 | 341 | protected function db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe) { |
| 321 | 342 | $provider_id_safe = intval(core_auth::$main_provider->provider_id); |
| 322 | 343 | //$account_id_safe = $this->db->db_escape($this->account_id); |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | $this->reset(); |
| 80 | 80 | $this->db = is_object($db) ? $db : classSupernova::$db; |
| 81 | 81 | |
| 82 | - foreach($this->table_check as $table_name) { |
|
| 83 | - if(empty($this->db->table_list[$table_name])) { |
|
| 82 | + foreach ($this->table_check as $table_name) { |
|
| 83 | + if (empty($this->db->table_list[$table_name])) { |
|
| 84 | 84 | die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br /> |
| 85 | 85 | В противном случае - сообщите Администрации сервера об ошибке.<br/> |
| 86 | 86 | Не хватает таблицы для работы системы авторизации: ' . $table_name); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | // OK v4.6 |
| 106 | 106 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
| 107 | - if(!$this->password_check($old_password_unsafe)) { |
|
| 107 | + if (!$this->password_check($old_password_unsafe)) { |
|
| 108 | 108 | return false; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | // OK v4.5 |
| 126 | 126 | public function assign_from_db_row($row) { |
| 127 | 127 | $this->reset(); |
| 128 | - if(empty($row) || !is_array($row)) { |
|
| 128 | + if (empty($row) || !is_array($row)) { |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | $this->account_id = $row['account_id']; |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | `account_email` = LOWER('{$email_safe}'), |
| 243 | 243 | `account_language` = '{$language_safe}'" |
| 244 | 244 | ); |
| 245 | - if(!$result) { |
|
| 245 | + if (!$result) { |
|
| 246 | 246 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if(!($account_id = $this->db->db_insert_id())) { |
|
| 249 | + if (!($account_id = $this->db->db_insert_id())) { |
|
| 250 | 250 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | WHERE `account_id` = '{$account_id_safe}'" |
| 277 | 277 | ) ? true : false; |
| 278 | 278 | |
| 279 | - if($result) { |
|
| 279 | + if ($result) { |
|
| 280 | 280 | $result = $this->db_get_by_id($this->account_id); |
| 281 | 281 | } |
| 282 | 282 | |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | public function metamatter_change($change_type, $metamatter, $comment = '', $already_changed = false) { |
| 364 | 364 | global $debug, $mm_change_legit; |
| 365 | 365 | |
| 366 | - if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
| 366 | + if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
| 367 | 367 | $debug->error('Ошибка при попытке манипуляции с ММ'); |
| 368 | 368 | |
| 369 | 369 | return false; |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | $mm_change_legit = true; |
| 375 | 375 | // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER); |
| 376 | - if($already_changed) { |
|
| 376 | + if ($already_changed) { |
|
| 377 | 377 | $metamatter_total_delta = 0; |
| 378 | 378 | $result = -1; |
| 379 | 379 | } else { |
@@ -387,13 +387,13 @@ discard block |
||
| 387 | 387 | ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') . |
| 388 | 388 | " WHERE `account_id` = {$account_id_safe}" |
| 389 | 389 | ); |
| 390 | - if(!$result) { |
|
| 390 | + if (!$result) { |
|
| 391 | 391 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
| 392 | 392 | } |
| 393 | 393 | $result = classSupernova::$db->db_affected_rows(); |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - if(empty(core_auth::$user['id'])) { |
|
| 396 | + if (empty(core_auth::$user['id'])) { |
|
| 397 | 397 | $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id); |
| 398 | 398 | reset($user_list); |
| 399 | 399 | $user_id_unsafe = key($user_list); |
@@ -402,30 +402,30 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | $user_id_safe = $this->db->db_escape($user_id_unsafe); |
| 404 | 404 | |
| 405 | - if(!$result) { |
|
| 405 | + if (!$result) { |
|
| 406 | 406 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - if(!$already_changed) { |
|
| 409 | + if (!$already_changed) { |
|
| 410 | 410 | $this->account_metamatter += $metamatter; |
| 411 | 411 | $this->account_metamatter_total += $metamatter_total_delta; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - if(is_array($comment)) { |
|
| 414 | + if (is_array($comment)) { |
|
| 415 | 415 | $comment = call_user_func_array('sprintf', $comment); |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe); |
| 419 | 419 | |
| 420 | - if($metamatter > 0 && !empty($user_id_safe)) { |
|
| 420 | + if ($metamatter > 0 && !empty($user_id_safe)) { |
|
| 421 | 421 | $old_referral = db_referral_get_by_id($user_id_safe); |
| 422 | - if($old_referral['id']) { |
|
| 422 | + if ($old_referral['id']) { |
|
| 423 | 423 | $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM; |
| 424 | 424 | db_referral_update_dm($user_id_safe, $dark_matter_from_metamatter); |
| 425 | 425 | $new_referral = db_referral_get_by_id($user_id_safe); |
| 426 | 426 | |
| 427 | 427 | $partner_bonus = floor($new_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) : 0); |
| 428 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
| 428 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
| 429 | 429 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}"); |
| 430 | 430 | } |
| 431 | 431 | } |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | /** |
| 91 | 91 | * @param KeyedContainer $cEntity |
| 92 | 92 | */ |
| 93 | - protected function onSaveUnchanged($cEntity){ |
|
| 93 | + protected function onSaveUnchanged($cEntity) { |
|
| 94 | 94 | // TODO - or just save nothing ????? |
| 95 | 95 | // throw new \Exception('EntityModel isNotEmpty, have dbId and not CHANGED! It can\'t be!'); |
| 96 | 96 | // Do nothing |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | /** |
| 91 | 91 | * @param KeyedContainer $cEntity |
| 92 | 92 | */ |
| 93 | - protected function onSaveUnchanged($cEntity){ |
|
| 93 | + protected function onSaveUnchanged($cEntity) { |
|
| 94 | 94 | // TODO - or just save nothing ????? |
| 95 | 95 | // throw new \Exception('EntityModel isNotEmpty, have dbId and not CHANGED! It can\'t be!'); |
| 96 | 96 | // Do nothing |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | /** |
| 165 | 165 | * @param string $query |
| 166 | 166 | * |
| 167 | - * @return mixed|string |
|
| 167 | + * @return string |
|
| 168 | 168 | */ |
| 169 | 169 | public function replaceTablePlaceholders($query) { |
| 170 | 170 | $sql = $query; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
| 181 | - * @param $query |
|
| 181 | + * @param string $query |
|
| 182 | 182 | */ |
| 183 | 183 | protected function logQuery($query) { |
| 184 | 184 | if (!classSupernova::$config->debug) { |
@@ -290,6 +290,7 @@ discard block |
||
| 290 | 290 | * @param array $fields |
| 291 | 291 | * @param array $where |
| 292 | 292 | * @param bool $isOneRecord |
| 293 | + * @param boolean $forUpdate |
|
| 293 | 294 | * |
| 294 | 295 | * @return array|bool|mysqli_result|null |
| 295 | 296 | * |
@@ -332,6 +333,10 @@ discard block |
||
| 332 | 333 | |
| 333 | 334 | // |
| 334 | 335 | // INSERT/REPLACE ---------------------------------------------------------------------------------------------------- |
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * @param string $query |
|
| 339 | + */ |
|
| 335 | 340 | public function doInsertComplex($query) { |
| 336 | 341 | return $this->doSql($query); |
| 337 | 342 | } |
@@ -408,7 +413,7 @@ discard block |
||
| 408 | 413 | * Self-contained - means no params used |
| 409 | 414 | * Such queries usually used to make large amount of in-base calculations |
| 410 | 415 | * |
| 411 | - * @param $query |
|
| 416 | + * @param string $query |
|
| 412 | 417 | * |
| 413 | 418 | * @return array|bool|mysqli_result|null |
| 414 | 419 | */ |
@@ -425,13 +430,16 @@ discard block |
||
| 425 | 430 | } |
| 426 | 431 | |
| 427 | 432 | /** |
| 428 | - * @param $DbQuery DbQuery |
|
| 433 | + * @param DbQuery $DbQuery DbQuery |
|
| 429 | 434 | */ |
| 430 | 435 | public function doUpdateDbQueryAdjust($DbQuery) { |
| 431 | 436 | return $this->doUpdateDbQuery($DbQuery); |
| 432 | 437 | } |
| 433 | 438 | |
| 434 | 439 | |
| 440 | + /** |
|
| 441 | + * @param boolean $isOneRecord |
|
| 442 | + */ |
|
| 435 | 443 | protected function doUpdateWhere($table, $fieldsSet, $fieldsAdjust = array(), $where = array(), $isOneRecord = DB_RECORDS_ALL, $whereDanger = array()) { |
| 436 | 444 | $query = DbQuery::build($this) |
| 437 | 445 | ->setTable($table) |
@@ -450,6 +458,9 @@ discard block |
||
| 450 | 458 | return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORD_ONE); |
| 451 | 459 | } |
| 452 | 460 | |
| 461 | + /** |
|
| 462 | + * @param string $table |
|
| 463 | + */ |
|
| 453 | 464 | public function doUpdateTableSet($table, $fieldsAndValues, $where = array()) { |
| 454 | 465 | return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORDS_ALL); |
| 455 | 466 | } |
@@ -559,6 +570,10 @@ discard block |
||
| 559 | 570 | // |
| 560 | 571 | // OTHER FUNCTIONS ---------------------------------------------------------------------------------------------------------- |
| 561 | 572 | // TODO Заменить это на новый логгер |
| 573 | + |
|
| 574 | + /** |
|
| 575 | + * @param string $query |
|
| 576 | + */ |
|
| 562 | 577 | protected function security_watch_user_queries($query) { |
| 563 | 578 | global $user; |
| 564 | 579 | |
@@ -582,6 +597,9 @@ discard block |
||
| 582 | 597 | } |
| 583 | 598 | |
| 584 | 599 | |
| 600 | + /** |
|
| 601 | + * @param string $query |
|
| 602 | + */ |
|
| 585 | 603 | public function security_query_check_bad_words($query) { |
| 586 | 604 | if ($this->skipQueryCheck) { |
| 587 | 605 | return; |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | |
| 590 | 590 | global $user, $dm_change_legit, $mm_change_legit; |
| 591 | 591 | |
| 592 | - switch(true) { |
|
| 592 | + switch (true) { |
|
| 593 | 593 | case stripos($query, 'RUNCATE TABL') != false: |
| 594 | 594 | case stripos($query, 'ROP TABL') != false: |
| 595 | 595 | case stripos($query, 'ENAME TABL') != false: |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | $prefix_length = strlen($this->db_prefix); |
| 652 | 652 | |
| 653 | 653 | $tl = array(); |
| 654 | - while($row = $this->db_fetch($query)) { |
|
| 654 | + while ($row = $this->db_fetch($query)) { |
|
| 655 | 655 | foreach ($row as $table_name) { |
| 656 | 656 | if (strpos($table_name, $this->db_prefix) === 0) { |
| 657 | 657 | $table_name = substr($table_name, $prefix_length); |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | if (is_bool($query)) { |
| 786 | 786 | throw new Exception('Result of SHOW STATUS command is boolean - which should never happen. Connection to DB is lost?'); |
| 787 | 787 | } |
| 788 | - while($row = db_fetch($query)) { |
|
| 788 | + while ($row = db_fetch($query)) { |
|
| 789 | 789 | $result[$row['Variable_name']] = $row['Value']; |
| 790 | 790 | } |
| 791 | 791 | |
@@ -20,17 +20,17 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | $sensorLevel = mrc_get_level($user, $planetrow, STRUC_MOON_PHALANX); |
| 22 | 22 | if (!intval($sensorLevel)) { |
| 23 | - message (classLocale::$lang['phalanx_nosensoravailable'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 23 | + message(classLocale::$lang['phalanx_nosensoravailable'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | if ($planetrow['planet_type'] != PT_MOON) { |
| 27 | - message (classLocale::$lang['phalanx_onlyformoons'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 27 | + message(classLocale::$lang['phalanx_onlyformoons'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $scan_galaxy = sys_get_param_int('galaxy'); |
| 31 | 31 | $scan_system = sys_get_param_int('system'); |
| 32 | 32 | $scan_planet = sys_get_param_int('planet'); |
| 33 | -$scan_planet_type = 1; // sys_get_param_int('planettype'); |
|
| 33 | +$scan_planet_type = 1; // sys_get_param_int('planettype'); |
|
| 34 | 34 | $id = sys_get_param_id('id'); |
| 35 | 35 | |
| 36 | 36 | $source_galaxy = $planetrow['galaxy']; |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | $sensorRange = GetPhalanxRange($sensorLevel); |
| 41 | 41 | |
| 42 | 42 | $system_distance = abs($source_system - $scan_system); |
| 43 | -if($system_distance > $sensorRange || $scan_galaxy != $source_galaxy) |
|
| 43 | +if ($system_distance > $sensorRange || $scan_galaxy != $source_galaxy) |
|
| 44 | 44 | { |
| 45 | - message (classLocale::$lang['phalanx_rangeerror'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 45 | + message(classLocale::$lang['phalanx_rangeerror'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $cost = $sensorLevel * 1000; |
@@ -53,20 +53,20 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | $planet_scanned = DBStaticPlanet::db_planet_by_gspt($scan_galaxy, $scan_system, $scan_planet, $scan_planet_type); |
| 56 | -if(!$planet_scanned['id']) |
|
| 56 | +if (!$planet_scanned['id']) |
|
| 57 | 57 | { |
| 58 | 58 | message(classLocale::$lang['phalanx_planet_not_exists'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | -if($planet_scanned['destruyed']) |
|
| 61 | +if ($planet_scanned['destruyed']) |
|
| 62 | 62 | { |
| 63 | - message (classLocale::$lang['phalanx_planet_destroyed'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 63 | + message(classLocale::$lang['phalanx_planet_destroyed'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | DBStaticPlanet::db_planet_update_adjust_by_id( |
| 67 | 67 | $user['current_planet'], |
| 68 | 68 | array( |
| 69 | - 'deuterium' => - $cost, |
|
| 69 | + 'deuterium' => -$cost, |
|
| 70 | 70 | ) |
| 71 | 71 | ); |
| 72 | 72 | |