Completed
Push — work-fleets ( d64c53...5442ac )
by SuperNova.WS
05:10
created
includes/includes/flt_flying_fleet_handler2.php 1 patch
Spacing   +7 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,15 +19,11 @@  discard block
 block discarded – undo
19 19
 // ------------------------------------------------------------------
20 20
 function flt_flyingFleetsSort($a, $b) {
21 21
   // Сравниваем время флотов - кто раньше, тот и первый обрабатывается
22
-  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 :
23
-    // Если время - одинаковое, сравниваем события флотов
22
+  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов
24 23
     // Если события - одинаковые, то флоты равны
25
-    ($a['fleet_event'] == $b['fleet_event'] ? 0 :
26
-      // Если события разные - первыми считаем прибывающие флоты
27
-      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 :
28
-        // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
29
-        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 :
30
-          // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
24
+    ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты
25
+      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
26
+        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
31 27
           // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска
32 28
           (
33 29
           0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий
@@ -45,13 +41,13 @@  discard block
 block discarded – undo
45 41
     $handler = fopen('event.log', 'a+');
46 42
   }
47 43
 
48
-  fwrite($handler, date(FMT_DATE_TIME_SQL, time()) . ' ' . $msg . "\r\n");
44
+  fwrite($handler, date(FMT_DATE_TIME_SQL, time()).' '.$msg."\r\n");
49 45
 }
50 46
 
51 47
 // ------------------------------------------------------------------
52 48
 function flt_flying_fleet_handler($skip_fleet_update = false) {
53 49
   if (true) {
54
-    if(!defined('IN_AJAX')) {
50
+    if (!defined('IN_AJAX')) {
55 51
       print('<div style="color: red; font-size: 300%">Fleet handler is disabled</div>');
56 52
       pdump('Fleet handler is disabled');
57 53
     }
@@ -177,7 +173,7 @@  discard block
 block discarded – undo
177 173
     MT_EXPLORE   => 'flt_mission_explore',
178 174
   );
179 175
   foreach ($missions_used as $mission_id => $cork) {
180
-    require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX);
176
+    require_once(SN_ROOT_PHYSICAL."includes/includes/{$mission_files[$mission_id]}".DOT_PHP_EX);
181 177
   }
182 178
 
183 179
 //log_file('Обработка миссий');
Please login to merge, or discard this patch.
includes/classes/DBStaticUser.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
       static::buildSelect()
50 50
         ->fields('id')
51 51
         ->where(array(
52
-          "`user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER . " FOR UPDATE;"
52
+          "`user_as_ally` IS NULL AND `user_bot` = ".USER_BOT_PLAYER." FOR UPDATE;"
53 53
         ))
54 54
     );
55 55
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
   public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) {
62 62
     static::$dbStatic->execute(
63 63
       static::buildSelectLock()
64
-        ->where(array("`id` = " . idval($user['id']) .
65
-          (isset($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '')))
64
+        ->where(array("`id` = ".idval($user['id']).
65
+          (isset($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : '')))
66 66
     );
67 67
 
68 68
 //    doquery("SELECT 1 FROM {{users}} WHERE `id` = " . idval($user['id']) .
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
   }
73 73
 
74 74
   public static function db_user_count($online = false) {
75
-    $result = doquery('SELECT COUNT(id) AS user_count FROM `{{users}}` WHERE user_as_ally IS NULL' . ($online ? ' AND onlinetime > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : ''), true);
75
+    $result = doquery('SELECT COUNT(id) AS user_count FROM `{{users}}` WHERE user_as_ally IS NULL'.($online ? ' AND onlinetime > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : ''), true);
76 76
 
77 77
     return isset($result['user_count']) ? $result['user_count'] : 0;
78 78
   }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     return doquery("SELECT u.*, COUNT(r.id) AS referral_count, SUM(r.dark_matter) AS referral_dm FROM {{users}} as u
113 113
     LEFT JOIN {{referrals}} as r on r.id_partner = u.id
114 114
     WHERE" .
115
-      ($online ? " `onlinetime` >= " . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : ' user_as_ally IS NULL') .
115
+      ($online ? " `onlinetime` >= ".(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : ' user_as_ally IS NULL').
116 116
       " GROUP BY u.id
117 117
     ORDER BY user_as_ally, {$sort} ASC");
118 118
   }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
   }
169 169
 
170 170
   public static function db_user_list_set_mass_mail(&$owners_list, $set) {
171
-    return classSupernova::db_upd_record_list(LOC_USER, !empty($owners_list) ? '`id` IN (' . implode(',', $owners_list) . ');' : '', $set);
171
+    return classSupernova::db_upd_record_list(LOC_USER, !empty($owners_list) ? '`id` IN ('.implode(',', $owners_list).');' : '', $set);
172 172
   }
173 173
 
174 174
   public static function db_user_list_set_by_ally_and_rank($ally_id, $ally_rank_id, $set) {
Please login to merge, or discard this patch.
includes/classes/classSupernova.php 1 patch
Spacing   +18 added lines, -20 removed lines patch added patch discarded remove patch
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
   public static function cache_clear($location_type, $hard = true) {
237 237
     if ($hard && !empty(static::$data[$location_type])) {
238 238
       // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях
239
-      array_walk(static::$data[$location_type], function (&$item) { $item = null; });
239
+      array_walk(static::$data[$location_type], function(&$item) { $item = null; });
240 240
     }
241 241
     static::$locator[$location_type] = array();
242 242
     static::$queries[$location_type] = array();
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 
355 355
     if (!empty($error_msg)) {
356 356
       // TODO - Убрать позже
357
-      print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>');
357
+      print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>');
358 358
       $backtrace = debug_backtrace();
359 359
       array_shift($backtrace);
360 360
       pdump($backtrace);
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
   public static function db_transaction_start($level = '') {
368 368
     static::db_transaction_check(null);
369 369
 
370
-    $level ? doquery('SET TRANSACTION ISOLATION LEVEL ' . $level) : false;
370
+    $level ? doquery('SET TRANSACTION ISOLATION LEVEL '.$level) : false;
371 371
 
372 372
     static::$transaction_id++;
373 373
     doquery('START TRANSACTION');
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
   public static function db_lock_tables($tables) {
428 428
     $tables = is_array($tables) ? $tables : array($tables => '');
429 429
     foreach ($tables as $table_name => $condition) {
430
-      self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : ''));
430
+      self::$db->doquery("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : ''));
431 431
     }
432 432
   }
433 433
 
@@ -503,8 +503,8 @@  discard block
 block discarded – undo
503 503
           $query = static::db_query(
504 504
             "SELECT
505 505
               distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id
506
-            FROM {{{$location_info[P_TABLE_NAME]}}}" .
507
-            ($filter ? ' WHERE ' . $filter : '') .
506
+            FROM {{{$location_info[P_TABLE_NAME]}}}".
507
+            ($filter ? ' WHERE '.$filter : '').
508 508
             ($fetch ? ' LIMIT 1' : ''), false, true);
509 509
 
510 510
           while ($row = db_fetch($query)) {
@@ -517,13 +517,13 @@  discard block
 block discarded – undo
517 517
           if ($indexes_str = implode(',', $parent_id_list)) {
518 518
             $parent_id_field = static::$location_info[$owner_location_type][P_ID];
519 519
             static::db_get_record_list($owner_location_type,
520
-              $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
520
+              $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
521 521
           }
522 522
         }
523 523
       }
524 524
 
525 525
       $query = static::db_query(
526
-        "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" .
526
+        "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}".
527 527
         (($filter = trim($filter)) ? " WHERE {$filter}" : '')
528 528
       );
529 529
       while ($row = db_fetch($query)) {
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
     $condition = trim($condition);
590 590
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
591 591
 
592
-    if ($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) {
592
+    if ($result = static::db_query("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) {
593 593
 
594 594
       if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
595 595
         // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
       // TODO переписать
752 752
       $user = static::dbFetchOne(
753 753
         DBStaticUser::buildSelect()
754
-          ->where(array("`username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'"))
754
+          ->where(array("`username` ".($like ? 'LIKE' : '=')." '{$username_safe}'"))
755 755
       );
756 756
 
757 757
 //      $user = static::db_query(
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
 
845 845
     $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id];
846 846
     if (!isset($query_cache)) {
847
-      $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . static::db_unit_time_restrictions());
847
+      $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".static::db_unit_time_restrictions());
848 848
       if (is_array($got_data)) {
849 849
         foreach ($got_data as $unit_id => $unit_data) {
850 850
           $query_cache[$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
     if ($que_type == QUE_RESEARCH || $planet_id === null) {
906 906
       $query[] = "`que_planet_id` IS NULL";
907 907
     } elseif ($planet_id) {
908
-      $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")";
908
+      $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")";
909 909
     }
910 910
     if ($que_type) {
911 911
       $query[] = "`que_type` = {$que_type}";
@@ -1026,13 +1026,13 @@  discard block
 block discarded – undo
1026 1026
         $condition = "`{$field_name}` = ";
1027 1027
         $value = '';
1028 1028
         if ($field_data['delta']) {
1029
-          $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta'];
1029
+          $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta'];
1030 1030
         } elseif ($field_data['set']) {
1031 1031
           $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']);
1032 1032
         }
1033 1033
 
1034 1034
         if ($value) {
1035
-          $fields[] = $condition . $value;
1035
+          $fields[] = $condition.$value;
1036 1036
         }
1037 1037
       }
1038 1038
       $conditions[P_FIELDS_STR] = implode(',', $fields);
@@ -1046,9 +1046,7 @@  discard block
 block discarded – undo
1046 1046
           // Простое условие - $field_id = $field_value
1047 1047
           if (is_string($field_id)) {
1048 1048
             $field_value =
1049
-              $field_value === null ? 'NULL' :
1050
-                (is_string($field_value) ? "'" . db_escape($field_value) . "'" :
1051
-                  (is_bool($field_value) ? intval($field_value) : $field_value));
1049
+              $field_value === null ? 'NULL' : (is_string($field_value) ? "'".db_escape($field_value)."'" : (is_bool($field_value) ? intval($field_value) : $field_value));
1052 1050
             $the_conditions[] = "`{$field_id}` = {$field_value}";
1053 1051
           } else {
1054 1052
             die('Неподдерживаемый тип условия');
@@ -1075,7 +1073,7 @@  discard block
 block discarded – undo
1075 1073
         die('Неподдерживаемая операция в classSupernova::db_changeset_condition_compile');
1076 1074
     }
1077 1075
 
1078
-    $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR] . ' ' . $conditions[P_FIELDS_STR] . (' WHERE ' . $conditions[P_WHERE_STR]);
1076
+    $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR].' '.$conditions[P_FIELDS_STR].(' WHERE '.$conditions[P_WHERE_STR]);
1079 1077
   }
1080 1078
 
1081 1079
   public static function db_changeset_apply($db_changeset, $flush_delayed = false) {
@@ -1173,7 +1171,7 @@  discard block
 block discarded – undo
1173 1171
     ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false;
1174 1172
     if (@get_magic_quotes_gpc()) {
1175 1173
       $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
1176
-      array_walk_recursive($gpcr, function (&$value, $key) {
1174
+      array_walk_recursive($gpcr, function(&$value, $key) {
1177 1175
         $value = stripslashes($value);
1178 1176
       });
1179 1177
     }
@@ -1187,7 +1185,7 @@  discard block
 block discarded – undo
1187 1185
   public static function init_3_load_config_file() {
1188 1186
     $dbsettings = array();
1189 1187
 
1190
-    require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
1188
+    require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX);
1191 1189
     self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix'];
1192 1190
     self::$db_name = $dbsettings['name'];
1193 1191
     self::$sn_secret_word = $dbsettings['secretword'];
Please login to merge, or discard this patch.
includes/classes/DbSqlStatement.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -260,28 +260,28 @@  discard block
 block discarded – undo
260 260
     $result = '';
261 261
     $result .= $this->stringEscape($this->operation);
262 262
 
263
-    $result .= ' ' . $this->selectFieldsToString($this->fields);
263
+    $result .= ' '.$this->selectFieldsToString($this->fields);
264 264
 
265 265
     $result .= ' FROM';
266
-    $result .= ' `{{' . $this->stringEscape($this->table) . '}}`';
267
-    $result .= !empty($this->alias) ? ' AS `' . $this->stringEscape($this->alias) . '`' : '';
266
+    $result .= ' `{{'.$this->stringEscape($this->table).'}}`';
267
+    $result .= !empty($this->alias) ? ' AS `'.$this->stringEscape($this->alias).'`' : '';
268 268
 
269 269
     // TODO - fields should be escaped !!
270
-    $result .= !empty($this->where) ? ' WHERE ' . implode(' AND ', $this->where) : '';
270
+    $result .= !empty($this->where) ? ' WHERE '.implode(' AND ', $this->where) : '';
271 271
 
272 272
     // TODO - fields should be escaped !!
273
-    $result .= !empty($this->group) ? ' GROUP BY ' . implode(',', $this->group) : '';
273
+    $result .= !empty($this->group) ? ' GROUP BY '.implode(',', $this->group) : '';
274 274
 
275 275
     // TODO - fields should be escaped !!
276
-    $result .= !empty($this->order) ? ' ORDER BY ' . implode(',', $this->order) : '';
276
+    $result .= !empty($this->order) ? ' ORDER BY '.implode(',', $this->order) : '';
277 277
 
278 278
     // TODO - fields should be escaped !!
279
-    $result .= !empty($this->having) ? ' HAVING ' . implode(' AND ', $this->having) : '';
279
+    $result .= !empty($this->having) ? ' HAVING '.implode(' AND ', $this->having) : '';
280 280
 
281 281
     // TODO - fields should be escaped !!
282 282
     $limit = $this->fetchOne ? 1 : $this->limit;
283 283
     $result .= !empty($limit)
284
-      ? ' LIMIT ' . $limit . (!empty($this->offset) ? ' OFFSET ' . $this->offset : '')
284
+      ? ' LIMIT '.$limit.(!empty($this->offset) ? ' OFFSET '.$this->offset : '')
285 285
       : '';
286 286
 
287 287
     $result .=
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
    */
328 328
   protected function processField($fieldName) {
329 329
     if (is_bool($fieldName)) {
330
-      $result = (string)intval($fieldName);
330
+      $result = (string) intval($fieldName);
331 331
     } elseif (is_null($fieldName)) {
332 332
       $result = 'NULL';
333 333
     } elseif ($fieldName === '*') {
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
    * @return string
346 346
    */
347 347
   protected function processFieldDefault($fieldName) {
348
-    $result = (string)$fieldName;
348
+    $result = (string) $fieldName;
349 349
     if (
350 350
       $result != ''
351 351
       &&
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
       !is_numeric($fieldName)
357 357
     ) {
358 358
       // Other should be formatted
359
-      $result = '`' . $this->stringEscape($result) . '`';
359
+      $result = '`'.$this->stringEscape($result).'`';
360 360
     }
361 361
 
362 362
     return $result;
Please login to merge, or discard this patch.