Completed
Push — work-fleets ( 79b501...f5fbda )
by SuperNova.WS
05:22
created
includes/classes/core_classes.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
     !is_array($offset) ? $offset = array($offset) : false;
39 39
 
40 40
     $current_leaf = $this->__get(reset($offset));
41
-    while(($leaf_index = next($offset)) !== false) {
42
-      if(!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) {
41
+    while (($leaf_index = next($offset)) !== false) {
42
+      if (!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) {
43 43
         unset($current_leaf);
44 44
         break;
45 45
       }
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 
65 65
     !is_array($offset) ? $offset = array($offset) : false;
66 66
 
67
-    if($this->offsetExists($offset)) {
67
+    if ($this->offsetExists($offset)) {
68 68
       $result = $this->__get(reset($offset));
69
-      while(($leaf_index = next($offset)) !== false) {
69
+      while (($leaf_index = next($offset)) !== false) {
70 70
         $result = $result[$leaf_index];
71 71
       }
72 72
     }
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
    */
92 92
   public function offsetSet($offset, $value = null) {
93 93
     // Если нет никакого индекса - значит нечего записывать
94
-    if(!isset($offset) || (is_array($offset) && empty($offset))) {
94
+    if (!isset($offset) || (is_array($offset) && empty($offset))) {
95 95
       return;
96 96
     }
97 97
 
98 98
     // Если в массиве индекса только один элемент - значит это просто индекс
99
-    if(is_array($offset) && count($offset) == 1) {
99
+    if (is_array($offset) && count($offset) == 1) {
100 100
       // Разворачиваем его в индекс
101 101
       $offset = array(reset($offset) => $value);
102 102
       unset($value);
@@ -104,20 +104,20 @@  discard block
 block discarded – undo
104 104
     }
105 105
 
106 106
     // Адресация многомерного массива через массив индексов в $option
107
-    if(is_array($offset) && isset($value)) {
107
+    if (is_array($offset) && isset($value)) {
108 108
       // TODO - а не переделать ли это всё на __isset() ??
109 109
 //pdump($offset, '$offset');
110 110
 //pdump($value, '$value');
111 111
       // Вытаскиваем корневой элемент
112 112
       $root = $this->__get(reset($offset));
113 113
       $current_leaf = &$root;
114
-      while(($leaf_index = next($offset)) !== false) {
114
+      while (($leaf_index = next($offset)) !== false) {
115 115
         !is_array($current_leaf[$leaf_index]) ? $current_leaf[$leaf_index] = array() : false;
116 116
         $current_leaf = &$current_leaf[$leaf_index];
117 117
       }
118 118
 //pdump($current_leaf, '$current_leaf');
119 119
 //pdump($value, '$value');
120
-      if($current_leaf != $value) {
120
+      if ($current_leaf != $value) {
121 121
         $current_leaf = $value;
122 122
 //pdump(reset($offset), 'reset($offset)');
123 123
 //pdump($root, '$root');
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
       // Пакетная запись из массива ключ -> значение
129 129
       !is_array($offset) ? $offset = array($offset => $value) : false;
130 130
 
131
-      foreach($offset as $key => $value) {
131
+      foreach ($offset as $key => $value) {
132 132
         $this->__get($key) !== $value ? $this->__set($key, $value) : false;
133 133
       }
134 134
     }
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
    */
150 150
   public function offsetUnset($offset) {
151 151
     // Если нет никакого индекса - значит нечего записывать
152
-    if(!isset($offset) || (is_array($offset) && empty($offset))) {
152
+    if (!isset($offset) || (is_array($offset) && empty($offset))) {
153 153
       return;
154 154
     }
155 155
 
156 156
     !is_array($offset) ? $offset = array($offset) : false;
157 157
 
158
-    if($this->offsetExists($offset)) {
158
+    if ($this->offsetExists($offset)) {
159 159
 //pdump($offset);
160 160
       // Перематываем массив в конец
161 161
       $key_to_delete = end($offset);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 //pdump($key_to_delete, '$key_to_delete');
164 164
       $parent_offset = $offset;
165 165
       array_pop($parent_offset);
166
-      if(!count($parent_offset)) {
166
+      if (!count($parent_offset)) {
167 167
         // В массиве был один элемент - мы удаляем в корне. Просто удаляем элемент
168 168
         $this->__unset($key_to_delete);
169 169
       } else {
Please login to merge, or discard this patch.
includes/classes/Account.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
     $this->reset();
79 79
     $this->db = is_object($db) ? $db : classSupernova::$db;
80 80
 
81
-    foreach($this->table_check as $table_name) {
82
-      if(empty($this->db->table_list[$table_name])) {
81
+    foreach ($this->table_check as $table_name) {
82
+      if (empty($this->db->table_list[$table_name])) {
83 83
         die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br />
84 84
               В противном случае - сообщите Администрации сервера об ошибке.<br/>
85 85
               Не хватает таблицы для работы системы авторизации: ' . $table_name);
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
    */
104 104
   // OK v4.6
105 105
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
106
-    if(!$this->password_check($old_password_unsafe)) {
106
+    if (!$this->password_check($old_password_unsafe)) {
107 107
       return false;
108 108
     }
109 109
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
   // OK v4.5
125 125
   public function assign_from_db_row($row) {
126 126
     $this->reset();
127
-    if(empty($row) || !is_array($row)) {
127
+    if (empty($row) || !is_array($row)) {
128 128
       return false;
129 129
     }
130 130
     $this->account_id = $row['account_id'];
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
         `account_email` = LOWER('{$email_safe}'),
238 238
         `account_language` = '{$language_safe}'"
239 239
     );
240
-    if(!$result) {
240
+    if (!$result) {
241 241
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
242 242
     }
243 243
 
244
-    if(!($account_id = $this->db->db_insert_id())) {
244
+    if (!($account_id = $this->db->db_insert_id())) {
245 245
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
246 246
     }
247 247
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
       WHERE `account_id` = '{$account_id_safe}'"
272 272
     ) ? true : false;
273 273
 
274
-    if($result) {
274
+    if ($result) {
275 275
       $result = $this->db_get_by_id($this->account_id);
276 276
     }
277 277
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
   public function metamatter_change($change_type, $metamatter, $comment = false, $already_changed = false) {
352 352
     global $debug, $mm_change_legit, $config;
353 353
 
354
-    if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
354
+    if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
355 355
       $debug->error('Ошибка при попытке манипуляции с ММ');
356 356
       return false;
357 357
     }
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 
361 361
     $mm_change_legit = true;
362 362
     // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER);
363
-    if($already_changed) {
363
+    if ($already_changed) {
364 364
       $metamatter_total_delta = 0;
365 365
       $result = -1;
366 366
     } else {
@@ -373,13 +373,13 @@  discard block
 block discarded – undo
373 373
           ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$config->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') .
374 374
         " WHERE `account_id` = {$account_id_safe}"
375 375
       );
376
-      if(!$result) {
376
+      if (!$result) {
377 377
         $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
378 378
       }
379 379
       $result = classSupernova::$db->db_affected_rows();
380 380
     }
381 381
 
382
-    if(empty(core_auth::$user['id'])) {
382
+    if (empty(core_auth::$user['id'])) {
383 383
       $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id);
384 384
       reset($user_list);
385 385
       $user_id_unsafe = key($user_list);
@@ -388,30 +388,30 @@  discard block
 block discarded – undo
388 388
     }
389 389
     $user_id_safe = $this->db->db_escape($user_id_unsafe);
390 390
 
391
-    if(!$result) {
391
+    if (!$result) {
392 392
       $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
393 393
     }
394 394
 
395
-    if(!$already_changed) {
395
+    if (!$already_changed) {
396 396
       $this->account_metamatter += $metamatter;
397 397
       $this->account_metamatter_total += $metamatter_total_delta;
398 398
     }
399 399
 
400
-    if(is_array($comment)) {
400
+    if (is_array($comment)) {
401 401
       $comment = call_user_func_array('sprintf', $comment);
402 402
     }
403 403
 
404 404
     $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe);
405 405
 
406
-    if($metamatter > 0 && !empty($user_id_safe)) {
406
+    if ($metamatter > 0 && !empty($user_id_safe)) {
407 407
       $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", '', true);
408
-      if($old_referral['id']) {
408
+      if ($old_referral['id']) {
409 409
         $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM;
410 410
         doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter_from_metamatter}' WHERE `id` = {$user_id_safe} LIMIT 1;");
411 411
         $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1;", '', true);
412 412
 
413 413
         $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0);
414
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
414
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
415 415
           rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}");
416 416
         }
417 417
       }
Please login to merge, or discard this patch.
Doc Comments   +21 added lines patch added patch discarded remove patch
@@ -171,6 +171,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
includes/classes/PlayerToAccountTranslate.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
   protected static $is_init = false;
20 20
 
21 21
   protected static function init() {
22
-    if(!empty(static::$db)) {
22
+    if (!empty(static::$db)) {
23 23
       return;
24 24
     }
25 25
     static::$db = classSupernova::$db;
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
     $provider_id_safe = intval($provider_id_unsafe);
67 67
     !is_array($account_list) ? $account_list = array($account_list) : false;
68 68
 
69
-    foreach($account_list as $provider_account_id_unsafe) {
69
+    foreach ($account_list as $provider_account_id_unsafe) {
70 70
       $provider_account_id_safe = intval($provider_account_id_unsafe);
71 71
 
72 72
       // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером
73 73
       $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE");
74
-      while($row = static::$db->db_fetch($query)) {
74
+      while ($row = static::$db->db_fetch($query)) {
75 75
         $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true;
76 76
       }
77 77
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
       "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " .
92 92
       ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') .
93 93
       "ORDER BY `timestamp` FOR UPDATE");
94
-    while($row = static::$db->db_fetch($query)) {
94
+    while ($row = static::$db->db_fetch($query)) {
95 95
       $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row;
96 96
     }
97 97
 
Please login to merge, or discard this patch.
includes/classes/auth_abstract.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
    */
36 36
   // OK 4.9
37 37
   public function __construct($filename = __FILE__) {
38
-    if($this->provider_id == ACCOUNT_PROVIDER_NONE) {
38
+    if ($this->provider_id == ACCOUNT_PROVIDER_NONE) {
39 39
       die('У всех провайдеров должен быть $provider_id!');
40 40
     }
41 41
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
   // OK 4.6
134 134
   public function player_name_suggest() {
135 135
     $name = '';
136
-    if(is_object($this->account) && !empty($this->account->account_email)) {
136
+    if (is_object($this->account) && !empty($this->account->account_email)) {
137 137
       list($name) = explode('@', $this->account->account_email);
138 138
     }
139 139
 
Please login to merge, or discard this patch.
includes/classes/skin.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
    * Инициализация харнилища скинов
153 153
    */
154 154
   protected static function init() {
155
-    if(static::$is_init) {
155
+    if (static::$is_init) {
156 156
       return;
157 157
     }
158 158
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
     // Загружены ли уже данные по текущему скину?
167 167
 //pdump(static::$skin_list[$ini_path], 'static');
168
-    if(empty(static::$skin_list[$skin_path])) {
168
+    if (empty(static::$skin_list[$skin_path])) {
169 169
       // Прогружаем текущий скин
170 170
       static::$skin_list[$skin_path] = new skin($skin_path);
171 171
       static::$active = static::$skin_list[$skin_path];
@@ -201,22 +201,22 @@  discard block
 block discarded – undo
201 201
 
202 202
     $this->is_ini_present = false;
203 203
     // Проверка на корректность и существование пути
204
-    if(is_file($this->root_physical_absolute . 'skin.ini')) {
204
+    if (is_file($this->root_physical_absolute . 'skin.ini')) {
205 205
       // Пытаемся распарсить файл
206 206
 
207 207
       // По секциям? images и config? Что бы не копировать конфигурацию? Или просто unset(__inherit) а затем заново записать
208 208
       $this->config = parse_ini_file($this->root_physical_absolute . 'skin.ini');
209
-      if(!empty($this->config)) {
209
+      if (!empty($this->config)) {
210 210
 
211 211
         $this->is_ini_present = true;
212 212
 
213
-        if(!empty($this->config['_inherit'])) {
213
+        if (!empty($this->config['_inherit'])) {
214 214
           // Если скин наследует себя...
215
-          if($this->config['_inherit'] == $skin_path) {
215
+          if ($this->config['_inherit'] == $skin_path) {
216 216
             // TODO - определять более сложные случаи циклических ссылок в _inherit
217 217
             die('">circular skin inheritance!');
218 218
           }
219
-          if(empty(static::$skin_list[$this->config['_inherit']])) {
219
+          if (empty(static::$skin_list[$this->config['_inherit']])) {
220 220
             static::$skin_list[$this->config['_inherit']] = new skin($this->config['_inherit']);
221 221
           }
222 222
           $this->parent = static::$skin_list[$this->config['_inherit']];
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
     }
233 233
 
234 234
     // Пытаемся скомпилировать _no_image заранее
235
-    if(!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) {
235
+    if (!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) {
236 236
       $this->container[SKIN_IMAGE_MISSED_FIELD] = $this->compile_try_path(SKIN_IMAGE_MISSED_FIELD, $this->config[SKIN_IMAGE_MISSED_FIELD]);
237 237
     }
238 238
 
239 239
     // Если нет заглушки
240
-    if(empty($this->container[SKIN_IMAGE_MISSED_FIELD])) {
240
+    if (empty($this->container[SKIN_IMAGE_MISSED_FIELD])) {
241 241
       $this->container[SKIN_IMAGE_MISSED_FIELD] = empty($this->parent)
242 242
         // Если нет парента - берем хардкод
243 243
         ? $this->container[SKIN_IMAGE_MISSED_FIELD] = SN_ROOT_VIRTUAL . SKIN_IMAGE_MISSED_FILE_PATH
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
     $image_tag = $this->image_tag_parse($image_tag, $template);
268 268
 
269 269
     // Проверяем наличие ключа RIT в хранилища. В нём не может быть несуществующих файлов по построению
270
-    if(!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) {
270
+    if (!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) {
271 271
       return $this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]];
272 272
     }
273 273
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
     // Нет - image ID не является путём к файлу. Пора обратиться к предкам за помощью...
286 286
     // Пытаемся вытащить путь из родителя и применить к нему свои параметры
287 287
     // Тащим по ID изображения, а не по ТЭГУ - мало ли что там делает с путём родитель и как преобразовывает его в строку?
288
-    if(empty($this->container[$image_id]) && !empty($this->parent)) {
288
+    if (empty($this->container[$image_id]) && !empty($this->parent)) {
289 289
       $this->container[$image_id] = $this->parent->compile_image($image_id, $template);
290 290
 
291 291
       // Если у родителя нет картинки - он вернет пустую строку. Тогда нам надо использовать заглушку - свою или родительскую
@@ -306,18 +306,18 @@  discard block
 block discarded – undo
306 306
   protected function image_tag_parse($image_tag, $template) {
307 307
     $image_tag_ptl_resolved = $image_tag;
308 308
     // Есть переменные из темплейта ?
309
-    if(strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) {
309
+    if (strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) {
310 310
       // Что бы лишний раз не запускать регексп
311 311
       // TODO - многоуровневые вложения ?! Надо ли и где их можно применить
312 312
       preg_match_all('#(\[.+?\])#', $image_tag_ptl_resolved, $matches);
313
-      foreach($matches[0] as &$match) {
313
+      foreach ($matches[0] as &$match) {
314 314
         $var_name = str_replace(array('[', ']'), '', $match);
315
-        if(strpos($var_name, '.') !== false) {
315
+        if (strpos($var_name, '.') !== false) {
316 316
           // Вложенная переменная темплейта - на текущем уровне
317 317
           // TODO Вложенная переменная из корня через "!"
318 318
           list($block_name, $block_var) = explode('.', $var_name);
319 319
           isset($template->_block_value[$block_name][$block_var]) ? $image_tag_ptl_resolved = str_replace($match, $template->_block_value[$block_name][$block_var], $image_tag_ptl_resolved) : false;
320
-        } elseif(strpos($var_name, '$') !== false) {
320
+        } elseif (strpos($var_name, '$') !== false) {
321 321
           // Корневой DEFINE
322 322
           $define_name = substr($var_name, 1);
323 323
           isset($template->_tpldata['DEFINE']['.'][$define_name]) ? $image_tag_ptl_resolved = str_replace($match, $template->_tpldata['DEFINE']['.'][$define_name], $image_tag_ptl_resolved) : false;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
       }
329 329
     }
330 330
 
331
-    if(strpos($image_tag_ptl_resolved, '|') !== false) {
331
+    if (strpos($image_tag_ptl_resolved, '|') !== false) {
332 332
       $params = explode('|', $image_tag_ptl_resolved);
333 333
       $image_id = $params[0];
334 334
       unset($params[0]);
@@ -392,11 +392,11 @@  discard block
 block discarded – undo
392 392
     $image_string = $this->container[$image_tag];
393 393
 
394 394
     // Нет параметров - просто возвращаем значение по $image_name из контейнера
395
-    if(!empty($params) && is_array($params)) {
395
+    if (!empty($params) && is_array($params)) {
396 396
       // Здесь автоматически произойдёт упорядочивание параметров
397 397
 
398 398
       // Параметр 'html' - выводить изображение в виде HTML-тэга
399
-      if(in_array('html', $params)) {
399
+      if (in_array('html', $params)) {
400 400
         $image_tag = $image_tag . '|html';
401 401
         $image_string = '<img src="' . $image_string . '" />';
402 402
         $this->container[$image_tag] = $image_string;
Please login to merge, or discard this patch.
includes/update_old.php 4 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
     upd_do_query("UPDATE `{{planets}}` SET `crystal` = 0 WHERE `crystal` < 0;");
333 333
     upd_do_query("UPDATE `{{planets}}` SET `deuterium` = 0 WHERE `deuterium` < 0;");
334 334
     upd_alter_table('planets', array(
335
-       "DROP COLUMN `b_building`",
336
-       "DROP COLUMN `b_building_id`"
335
+        "DROP COLUMN `b_building`",
336
+        "DROP COLUMN `b_building_id`"
337 337
     ), $update_tables['planets']['b_building']);
338 338
 
339 339
     upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('noobprotection', 'noobprotectionmulti', 'noobprotectiontime', 'chat_admin_msgFormat');");
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
       upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;");
588 588
 
589 589
       upd_alter_table('users', array(
590
-         "ADD CONSTRAINT `FK_users_ally_id` FOREIGN KEY (`ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
591
-         "ADD CONSTRAINT `FK_users_ally_name` FOREIGN KEY (`ally_name`) REFERENCES `{$config->db_prefix}alliance` (`ally_name`) ON DELETE SET NULL ON UPDATE CASCADE",
590
+          "ADD CONSTRAINT `FK_users_ally_id` FOREIGN KEY (`ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
591
+          "ADD CONSTRAINT `FK_users_ally_name` FOREIGN KEY (`ally_name`) REFERENCES `{$config->db_prefix}alliance` (`ally_name`) ON DELETE SET NULL ON UPDATE CASCADE",
592 592
       ), !$update_foreigns['users']['FK_users_ally_id']);
593 593
     }
594 594
 
@@ -1155,46 +1155,46 @@  discard block
 block discarded – undo
1155 1155
       upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true);
1156 1156
 
1157 1157
       upd_alter_table('statpoints', array(
1158
-       "MODIFY COLUMN `stat_date` int(11) NOT NULL DEFAULT '0' FIRST",
1159
-       "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
1160
-       "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL",
1161
-       "MODIFY COLUMN `stat_type` TINYINT UNSIGNED DEFAULT 0",
1162
-       "MODIFY COLUMN `stat_code` TINYINT UNSIGNED NOT NULL DEFAULT '0'",
1163
-
1164
-       "MODIFY COLUMN `tech_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1165
-       "MODIFY COLUMN `tech_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1166
-       "MODIFY COLUMN `tech_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1167
-       "MODIFY COLUMN `tech_count` DECIMAL(65,0) UNSIGNED UNSIGNED NOT NULL DEFAULT '0'",
1168
-
1169
-       "MODIFY COLUMN `build_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1170
-       "MODIFY COLUMN `build_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1171
-       "MODIFY COLUMN `build_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1172
-       "MODIFY COLUMN `build_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1173
-
1174
-       "MODIFY COLUMN `defs_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1175
-       "MODIFY COLUMN `defs_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1176
-       "MODIFY COLUMN `defs_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1177
-       "MODIFY COLUMN `defs_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1178
-
1179
-       "MODIFY COLUMN `fleet_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1180
-       "MODIFY COLUMN `fleet_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1181
-       "MODIFY COLUMN `fleet_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1182
-       "MODIFY COLUMN `fleet_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1183
-
1184
-       "MODIFY COLUMN `res_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Rank by resources' AFTER `fleet_count`",
1185
-       "MODIFY COLUMN `res_old_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Old rank by resources'AFTER `res_rank`",
1186
-       "MODIFY COLUMN `res_points` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource stat points' AFTER `res_old_rank`",
1187
-       "MODIFY COLUMN `res_count` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource count' AFTER `res_points`",
1188
-
1189
-       "MODIFY COLUMN `total_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1190
-       "MODIFY COLUMN `total_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1191
-       "MODIFY COLUMN `total_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1192
-       "MODIFY COLUMN `total_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1193
-
1194
-       "ADD KEY `I_stats_id_ally` (`id_ally`)",
1195
-
1196
-       "ADD CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1197
-       "ADD CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1158
+        "MODIFY COLUMN `stat_date` int(11) NOT NULL DEFAULT '0' FIRST",
1159
+        "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
1160
+        "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL",
1161
+        "MODIFY COLUMN `stat_type` TINYINT UNSIGNED DEFAULT 0",
1162
+        "MODIFY COLUMN `stat_code` TINYINT UNSIGNED NOT NULL DEFAULT '0'",
1163
+
1164
+        "MODIFY COLUMN `tech_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1165
+        "MODIFY COLUMN `tech_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1166
+        "MODIFY COLUMN `tech_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1167
+        "MODIFY COLUMN `tech_count` DECIMAL(65,0) UNSIGNED UNSIGNED NOT NULL DEFAULT '0'",
1168
+
1169
+        "MODIFY COLUMN `build_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1170
+        "MODIFY COLUMN `build_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1171
+        "MODIFY COLUMN `build_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1172
+        "MODIFY COLUMN `build_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1173
+
1174
+        "MODIFY COLUMN `defs_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1175
+        "MODIFY COLUMN `defs_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1176
+        "MODIFY COLUMN `defs_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1177
+        "MODIFY COLUMN `defs_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1178
+
1179
+        "MODIFY COLUMN `fleet_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1180
+        "MODIFY COLUMN `fleet_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1181
+        "MODIFY COLUMN `fleet_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1182
+        "MODIFY COLUMN `fleet_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1183
+
1184
+        "MODIFY COLUMN `res_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Rank by resources' AFTER `fleet_count`",
1185
+        "MODIFY COLUMN `res_old_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Old rank by resources'AFTER `res_rank`",
1186
+        "MODIFY COLUMN `res_points` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource stat points' AFTER `res_old_rank`",
1187
+        "MODIFY COLUMN `res_count` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource count' AFTER `res_points`",
1188
+
1189
+        "MODIFY COLUMN `total_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1190
+        "MODIFY COLUMN `total_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1191
+        "MODIFY COLUMN `total_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1192
+        "MODIFY COLUMN `total_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1193
+
1194
+        "ADD KEY `I_stats_id_ally` (`id_ally`)",
1195
+
1196
+        "ADD CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1197
+        "ADD CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1198 1198
       ), true);
1199 1199
     }
1200 1200
 
Please login to merge, or discard this patch.
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('IN_UPDATE') || IN_UPDATE !== true)
3
+if (!defined('IN_UPDATE') || IN_UPDATE !== true)
4 4
 {
5 5
   die('Hack attempt');
6 6
 }
7 7
 
8
-switch($new_version)
8
+switch ($new_version)
9 9
 {
10 10
   case 0:
11 11
   case 1:
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     );
35 35
     upd_drop_table('lunas');
36 36
 
37
-    if($update_tables['galaxy'])
37
+    if ($update_tables['galaxy'])
38 38
     {
39 39
       upd_do_query(
40 40
         'UPDATE `{{planets}}`
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     );
86 86
     upd_add_more_time();
87 87
 
88
-    if($update_tables['users']['rpg_points'])
88
+    if ($update_tables['users']['rpg_points'])
89 89
     {
90 90
       upd_do_query(
91 91
         "UPDATE {{users}} AS u
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
     upd_drop_table('update');
148 148
 
149
-    upd_check_key('fleet_speed', $config->fleet_speed/2500, $config->fleet_speed >= 2500);
149
+    upd_check_key('fleet_speed', $config->fleet_speed / 2500, $config->fleet_speed >= 2500);
150 150
     upd_check_key('game_counter', 0);
151 151
     upd_check_key('game_default_language', 'ru');
152 152
     upd_check_key('game_default_skin', 'skins/EpicBlue/');
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     upd_check_key('game_news_actual', 259200);
156 156
     upd_check_key('game_noob_factor', 5, !isset($config->game_noob_factor));
157 157
     upd_check_key('game_noob_points', 5000, !isset($config->game_noob_points));
158
-    upd_check_key('game_speed', $config->game_speed/2500, $config->game_speed >= 2500);
158
+    upd_check_key('game_speed', $config->game_speed / 2500, $config->game_speed >= 2500);
159 159
     upd_check_key('int_format_date', 'd.m.Y');
160 160
     upd_check_key('int_format_time', 'H:i:s', true);
161 161
     upd_check_key('int_banner_background', 'design/images/banner.png', true);
@@ -179,22 +179,22 @@  discard block
 block discarded – undo
179 179
     upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']);
180 180
     upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']);
181 181
 
182
-    if($update_tables['planets']['b_building'])
182
+    if ($update_tables['planets']['b_building'])
183 183
     {
184 184
       $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;');
185 185
       $const_que_structures = QUE_STRUCTURES;
186
-      while($planet_data = db_fetch($planet_query))
186
+      while ($planet_data = db_fetch($planet_query))
187 187
       {
188 188
         $old_que = explode(';', $planet_data['b_building_id']);
189
-        foreach($old_que as $old_que_item_string)
189
+        foreach ($old_que as $old_que_item_string)
190 190
         {
191
-          if(!$old_que_item_string)
191
+          if (!$old_que_item_string)
192 192
           {
193 193
             continue;
194 194
           }
195 195
 
196 196
           $old_que_item = explode(',', $old_que_item_string);
197
-          if($old_que_item[4] == 'build')
197
+          if ($old_que_item[4] == 'build')
198 198
           {
199 199
             $old_que_item[4] = BUILD_CREATE;
200 200
           }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
231 231
     );
232 232
 
233
-    if($update_tables['users']['urlaubs_until'])
233
+    if ($update_tables['users']['urlaubs_until'])
234 234
     {
235 235
       upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']);
236 236
       upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;');
@@ -281,10 +281,10 @@  discard block
 block discarded – undo
281 281
     ), !$update_tables['logs']['log_timestamp']);
282 282
     upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;');
283 283
 
284
-    if($update_tables['errors'])
284
+    if ($update_tables['errors'])
285 285
     {
286 286
       upd_do_query('INSERT INTO `{{logs}}` (`log_code`, `log_sender`, `log_title`, `log_text`, `log_page`, `log_time`) SELECT 500, `error_sender`, `error_type`, `error_text`, `error_page`, `error_time` FROM `{{errors}}`;');
287
-      if($update_tables['errors_backup'])
287
+      if ($update_tables['errors_backup'])
288 288
       {
289 289
         upd_drop_table('errors_backup');
290 290
       }
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 
351 351
     upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci');
352 352
 
353
-    if(!$update_tables['shortcut'])
353
+    if (!$update_tables['shortcut'])
354 354
     {
355 355
       upd_create_table('shortcut',
356 356
         "(
@@ -375,12 +375,12 @@  discard block
 block discarded – undo
375 375
       $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON);
376 376
 
377 377
       $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';");
378
-      while($user_data = db_fetch($query))
378
+      while ($user_data = db_fetch($query))
379 379
       {
380 380
         $shortcuts = explode("\r\n", $user_data['fleet_shortcut']);
381
-        foreach($shortcuts as $shortcut)
381
+        foreach ($shortcuts as $shortcut)
382 382
         {
383
-          if(!$shortcut)
383
+          if (!$shortcut)
384 384
           {
385 385
             continue;
386 386
           }
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
           $shortcut[3] = intval($shortcut[3]);
393 393
           $shortcut[4] = intval($shortcut[4]);
394 394
 
395
-          if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types))
395
+          if ($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types))
396 396
           {
397 397
             upd_do_query("INSERT INTO {$config->db_prefix}shortcut (shortcut_user_id, shortcut_galaxy, shortcut_system, shortcut_planet, shortcut_planet_type, shortcut_text) VALUES ({$user_data['id']}, {$shortcut[1]}, {$shortcut[2]}, {$shortcut[3]}, {$shortcut[4]}, '{$shortcut[0]}');", true);
398 398
           }
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 
547 547
     upd_check_key('quest_total', 0, !isset($config->quest_total));
548 548
 
549
-    for($i = 0; $i < 25; $i++)
549
+    for ($i = 0; $i < 25; $i++)
550 550
     {
551 551
       upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]);
552 552
       upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]);
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
       "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist"
576 576
     ), !$update_tables['users']['msg_admin']);
577 577
 
578
-    if(!$update_foreigns['users']['FK_users_ally_id'])
578
+    if (!$update_foreigns['users']['FK_users_ally_id'])
579 579
     {
580 580
       upd_alter_table('users', array(
581 581
         'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL',
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
     ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED');
599 599
 
600 600
     $illegal_moon_query = upd_do_query("SELECT id FROM `{{planets}}` WHERE `id_owner` <> 0 AND `planet_type` = 3 AND `parent_planet` <> 0 AND `parent_planet` NOT IN (SELECT `id` FROM {{planets}} WHERE `planet_type` = 1);");
601
-    while($illegal_moon_row = db_fetch($illegal_moon_query))
601
+    while ($illegal_moon_row = db_fetch($illegal_moon_query))
602 602
     {
603 603
       upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true);
604 604
     }
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
     upd_log_version_update();
614 614
 
615 615
     upd_check_key('game_email_pm', 0, !isset($config->game_email_pm));
616
-    upd_check_key('player_vacation_time', 2*24*60*60, !isset($config->player_vacation_time));
617
-    upd_check_key('player_delete_time', 45*24*60*60, !isset($config->player_delete_time));
616
+    upd_check_key('player_vacation_time', 2 * 24 * 60 * 60, !isset($config->player_vacation_time));
617
+    upd_check_key('player_delete_time', 45 * 24 * 60 * 60, !isset($config->player_delete_time));
618 618
 
619 619
     upd_create_table('log_dark_matter',
620 620
       "(
@@ -636,18 +636,18 @@  discard block
 block discarded – undo
636 636
     upd_do_query('COMMIT;', true);
637 637
 
638 638
     $records = 1;
639
-    while($records)
639
+    while ($records)
640 640
     {
641 641
       upd_do_query('START TRANSACTION;', true);
642 642
       $query = upd_do_query("SELECT * FROM {{logs}} WHERE log_code = 102 order by log_id LIMIT 1000;");
643 643
       $records = db_num_rows($query);
644
-      while($row = db_fetch($query))
644
+      while ($row = db_fetch($query))
645 645
       {
646 646
         $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches);
647 647
 
648 648
         $reason = RPG_NONE;
649 649
         $comment = $matches[3];
650
-        switch($matches[3])
650
+        switch ($matches[3])
651 651
         {
652 652
           case 'Level Up For Structure Building':
653 653
             $reason = RPG_STRUCTURE;
@@ -664,21 +664,21 @@  discard block
 block discarded – undo
664 664
           break;
665 665
 
666 666
           default:
667
-            if(preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2))
667
+            if (preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2))
668 668
             {
669 669
               $reason = RPG_MARKET;
670 670
             }
671
-            elseif(preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2))
671
+            elseif (preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2))
672 672
             {
673 673
               $reason = RPG_MERCENARY;
674 674
               $comment = "Spent for mercenary {$matches2[1]} GUID {$matches2[2]}";
675 675
             }
676
-            elseif(preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2))
676
+            elseif (preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2))
677 677
             {
678 678
               $reason = RPG_REFERRAL;
679 679
               $comment = "Incoming from referral ID {$matches[1]}";
680 680
             }
681
-            elseif(preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2))
681
+            elseif (preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2))
682 682
             {
683 683
               $reason = RPG_ADMIN;
684 684
               $comment = $matches2[1];
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
           break;
687 687
         }
688 688
 
689
-        if($matches[2])
689
+        if ($matches[2])
690 690
         {
691 691
           $row['log_username'] = db_escape($row['log_username']);
692 692
           $row['log_page'] = db_escape($row['log_page']);
@@ -706,14 +706,14 @@  discard block
 block discarded – undo
706 706
       upd_do_query('COMMIT;', true);
707 707
     }
708 708
 
709
-    foreach($update_tables as $table_name => $cork)
709
+    foreach ($update_tables as $table_name => $cork)
710 710
     {
711 711
       $row = db_fetch(upd_do_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$config->db_prefix}{$table_name}';", true));
712
-      if($row['ENGINE'] != 'InnoDB')
712
+      if ($row['ENGINE'] != 'InnoDB')
713 713
       {
714 714
         upd_alter_table($table_name, 'ENGINE=InnoDB', true);
715 715
       }
716
-      if($row['TABLE_COLLATION'] != 'utf8_general_ci')
716
+      if ($row['TABLE_COLLATION'] != 'utf8_general_ci')
717 717
       {
718 718
         upd_alter_table($table_name, 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci', true);
719 719
       }
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
       "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0",
735 735
     ), !$update_tables['planets']['PLANET_GOVERNOR_ID']);
736 736
 
737
-    if($update_tables['users']['rpg_geologue'])
737
+    if ($update_tables['users']['rpg_geologue'])
738 738
     {
739 739
       doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;");
740 740
 
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
       ), $update_tables['users']['rpg_geologue']);
749 749
     }
750 750
 
751
-    if($update_tables['users']['rpg_bunker'])
751
+    if ($update_tables['users']['rpg_bunker'])
752 752
     {
753 753
       doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;");
754 754
 
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
     ), !isset($update_tables['alliance']['total_rank']));
800 800
     doquery("UPDATE {{alliance}} AS a JOIN {{statpoints}} AS sp ON sp.id_owner = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;");
801 801
 
802
-    if(!isset($update_tables['users']['ally_tag']))
802
+    if (!isset($update_tables['users']['ally_tag']))
803 803
     {
804 804
       upd_alter_table('users', array(
805 805
         "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`",
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
       "ADD COLUMN `player_artifact_list` TEXT",
816 816
     ), !isset($update_tables['users']['player_artifact_list']));
817 817
 
818
-    if(!isset($update_tables['users']['player_rpg_tech_xp']))
818
+    if (!isset($update_tables['users']['player_rpg_tech_xp']))
819 819
     {
820 820
       upd_check_key('eco_scale_storage', 1, !isset($config->eco_scale_storage));
821 821
 
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
       "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
847 847
     ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED');
848 848
 
849
-    if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED')
849
+    if (strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED')
850 850
     {
851 851
       upd_alter_table('alliance_diplomacy', array(
852 852
         "DROP FOREIGN KEY `FK_diplomacy_ally_id`",
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
       ), true);
863 863
     }
864 864
 
865
-    if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED')
865
+    if (strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED')
866 866
     {
867 867
       upd_alter_table('alliance_negotiation', array(
868 868
         "DROP FOREIGN KEY `FK_negotiation_ally_id`",
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
       ), true);
880 880
     }
881 881
 
882
-    if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED')
882
+    if (strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED')
883 883
     {
884 884
       upd_do_query('DELETE FROM {{alliance_requests}} WHERE id_user NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true);
885 885
 
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
       ), true);
895 895
     }
896 896
 
897
-    if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED')
897
+    if (strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED')
898 898
     {
899 899
       upd_do_query('DELETE FROM {{annonce}} WHERE user NOT IN (SELECT username FROM {{users}});', true);
900 900
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
       ), true);
909 909
     }
910 910
 
911
-    if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED')
911
+    if (strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED')
912 912
     {
913 913
       upd_alter_table('bashing', array(
914 914
         "DROP FOREIGN KEY `FK_bashing_user_id`",
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
       ), true);
925 925
     }
926 926
 
927
-    if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED')
927
+    if (strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED')
928 928
     {
929 929
       upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR owner NOT IN (SELECT id FROM {{users}});', true);
930 930
 
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
       "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'",
964 964
     ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)');
965 965
 
966
-    if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED')
966
+    if (strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED')
967 967
     {
968 968
       upd_do_query('DELETE FROM {{iraks}} WHERE owner NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true);
969 969
 
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
       ), true);
989 989
     }
990 990
 
991
-    if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED')
991
+    if (strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED')
992 992
     {
993 993
       upd_do_query('DELETE FROM {{notes}} WHERE owner NOT IN (SELECT id FROM {{users}});', true);
994 994
 
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
       "DROP COLUMN `b_hangar_plus`",
1115 1115
     ), isset($update_tables['planets']['b_hangar_plus']));
1116 1116
 
1117
-    if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED')
1117
+    if (strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED')
1118 1118
     {
1119 1119
       upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true);
1120 1120
 
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
       "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED",
1135 1135
     ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED');
1136 1136
 
1137
-    if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED')
1137
+    if (strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED')
1138 1138
     {
1139 1139
       upd_do_query('DELETE FROM {{shortcut}} WHERE shortcut_user_id NOT IN (SELECT id FROM {{users}}) OR shortcut_planet_id NOT IN (SELECT id FROM {{planets}});', true);
1140 1140
 
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
       ), true);
1151 1151
     }
1152 1152
 
1153
-    if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED')
1153
+    if (strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED')
1154 1154
     {
1155 1155
       upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true);
1156 1156
 
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
       "DROP COLUMN `settings_allylogo`",
1306 1306
     ), isset($update_tables['users']['settings_allylogo']));
1307 1307
 
1308
-    if(!isset($update_tables['powerup']))
1308
+    if (!isset($update_tables['powerup']))
1309 1309
     {
1310 1310
       upd_do_query("DROP TABLE IF EXISTS {$config->db_prefix}mercenaries;");
1311 1311
 
@@ -1336,13 +1336,13 @@  discard block
 block discarded – undo
1336 1336
 
1337 1337
       $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;";
1338 1338
       $user_list = upd_do_query("SELECT * FROM {{users}};");
1339
-      while($user_row = db_fetch($user_list))
1339
+      while ($user_row = db_fetch($user_list))
1340 1340
       {
1341 1341
         $update_query_str = '';
1342
-        foreach(sn_get_groups('mercenaries') as $mercenary_id)
1342
+        foreach (sn_get_groups('mercenaries') as $mercenary_id)
1343 1343
         {
1344 1344
           $mercenary_data_name = get_unit_param($mercenary_id, P_NAME);
1345
-          if($mercenary_level = $user_row[$mercenary_data_name])
1345
+          if ($mercenary_level = $user_row[$mercenary_data_name])
1346 1346
           {
1347 1347
             $update_query_str = ", `{$mercenary_data_name}` = 0";
1348 1348
             upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;");
@@ -1350,14 +1350,14 @@  discard block
 block discarded – undo
1350 1350
           }
1351 1351
         }
1352 1352
 
1353
-        if($update_query_str)
1353
+        if ($update_query_str)
1354 1354
         {
1355 1355
           upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id']));
1356 1356
         }
1357 1357
       }
1358 1358
     }
1359 1359
 
1360
-    if(!isset($update_tables['universe']))
1360
+    if (!isset($update_tables['universe']))
1361 1361
     {
1362 1362
       upd_create_table('universe',
1363 1363
         "(
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 
1382 1382
     // ------------------------------------------------------------------------
1383 1383
     // Modifying tables
1384
-    if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED')
1384
+    if (strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED')
1385 1385
     {
1386 1386
       upd_alter_table('users', array(
1387 1387
         "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL",
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
     // ------------------------------------------------------------------------
1404 1404
     // Creating players for allies
1405 1405
     $ally_row_list = doquery("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;");
1406
-    while($ally_row = db_fetch($ally_row_list))
1406
+    while ($ally_row = db_fetch($ally_row_list))
1407 1407
     {
1408 1408
       $ally_user_name = db_escape("[{$ally_row['ally_tag']}]");
1409 1409
       doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};");
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
     // ------------------------------------------------------------------------
1419 1419
     // Creating planets for allies
1420 1420
     $ally_user_list = doquery("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;");
1421
-    while($ally_user_row = db_fetch($ally_user_list))
1421
+    while ($ally_user_row = db_fetch($ally_user_list))
1422 1422
     {
1423 1423
       $ally_planet_name = db_escape($ally_user_row['username']);
1424 1424
       doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};");
@@ -1450,10 +1450,10 @@  discard block
 block discarded – undo
1450 1450
     // Adding db field
1451 1451
     upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']);
1452 1452
     // Converting old data to new one and dropping old fields
1453
-    if($update_tables['users']['b_tech_planet'])
1453
+    if ($update_tables['users']['b_tech_planet'])
1454 1454
     {
1455 1455
       $query = doquery("SELECT * FROM {{planets}} WHERE `b_tech_id` <> 0;");
1456
-      while($planet_row = db_fetch($query))
1456
+      while ($planet_row = db_fetch($query))
1457 1457
       {
1458 1458
         $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH;
1459 1459
         doquery("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;");
@@ -1467,7 +1467,7 @@  discard block
 block discarded – undo
1467 1467
       upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']);
1468 1468
     }
1469 1469
 
1470
-    if(!$update_tables['powerup']['powerup_category'])
1470
+    if (!$update_tables['powerup']['powerup_category'])
1471 1471
     {
1472 1472
       upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']);
1473 1473
 
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
     upd_check_key('ali_bonus_brackets', 10, !isset($config->ali_bonus_brackets));
1490 1490
     upd_check_key('ali_bonus_brackets_divisor', 50, !isset($config->ali_bonus_brackets_divisor));
1491 1491
 
1492
-    if(!$config->db_loadItem('rpg_flt_explore'))
1492
+    if (!$config->db_loadItem('rpg_flt_explore'))
1493 1493
     {
1494 1494
       $inflation_rate = 1000;
1495 1495
 
@@ -1507,20 +1507,20 @@  discard block
 block discarded – undo
1507 1507
       doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};");
1508 1508
 
1509 1509
       $query = doquery("SELECT * FROM {{quest}}");
1510
-      while($row = db_fetch($query))
1510
+      while ($row = db_fetch($query))
1511 1511
       {
1512 1512
         $query_add = '';
1513 1513
         $quest_reward_list = explode(';', $row['quest_rewards']);
1514
-        foreach($quest_reward_list as &$quest_reward)
1514
+        foreach ($quest_reward_list as &$quest_reward)
1515 1515
         {
1516 1516
           list($reward_resource, $reward_amount) = explode(',', $quest_reward);
1517
-          if($reward_resource == RES_DARK_MATTER)
1517
+          if ($reward_resource == RES_DARK_MATTER)
1518 1518
           {
1519 1519
             $quest_reward = "{$reward_resource}," . $reward_amount * 1000;
1520 1520
           }
1521 1521
         }
1522 1522
         $new_rewards = implode(';', $quest_reward_list);
1523
-        if($new_rewards != $row['quest_rewards'])
1523
+        if ($new_rewards != $row['quest_rewards'])
1524 1524
         {
1525 1525
           doquery("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;");
1526 1526
         }
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
     upd_check_key('user_birthday_range', 30, !isset($config->user_birthday_range));
1552 1552
     upd_check_key('user_birthday_celebrate', 0, !isset($config->user_birthday_celebrate));
1553 1553
 
1554
-    if(!isset($update_tables['payment']))
1554
+    if (!isset($update_tables['payment']))
1555 1555
     {
1556 1556
       upd_alter_table('users', array(
1557 1557
         "ADD KEY `I_user_id_name` (`id`, `username`)",
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
     ), !$update_tables['iraks']['fleet_start_type']);
1604 1604
 
1605 1605
 
1606
-    if(!$update_tables['payment']['payment_status'])
1606
+    if (!$update_tables['payment']['payment_status'])
1607 1607
     {
1608 1608
       upd_alter_table('payment', array(
1609 1609
         "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`",
@@ -1688,7 +1688,7 @@  discard block
 block discarded – undo
1688 1688
       "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)",
1689 1689
     ), !$update_indexes['notes']['I_owner_priority_time']);
1690 1690
 
1691
-    if(!$update_tables['buddy']['BUDDY_ID'])
1691
+    if (!$update_tables['buddy']['BUDDY_ID'])
1692 1692
     {
1693 1693
       upd_alter_table('buddy', array(
1694 1694
         "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy table row ID'",
@@ -1710,10 +1710,10 @@  discard block
 block discarded – undo
1710 1710
 
1711 1711
       $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;");
1712 1712
       $found = $lost = array();
1713
-      while($row = db_fetch($query))
1713
+      while ($row = db_fetch($query))
1714 1714
       {
1715 1715
         $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']);
1716
-        if(!isset($found[$index]))
1716
+        if (!isset($found[$index]))
1717 1717
         {
1718 1718
           $found[$index] = $row['BUDDY_ID'];
1719 1719
         }
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
         }
1724 1724
       }
1725 1725
       $lost = implode(',', $lost);
1726
-      if($lost)
1726
+      if ($lost)
1727 1727
       {
1728 1728
         upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})");
1729 1729
       }
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 
1746 1746
     upd_do_query("UPDATE {{users}} SET `ally_name` = null, `ally_tag` = null, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` IS NULL");
1747 1747
 
1748
-    if(!$update_tables['ube_report'])
1748
+    if (!$update_tables['ube_report'])
1749 1749
     {
1750 1750
       upd_create_table('ube_report',
1751 1751
         "(
@@ -1787,7 +1787,7 @@  discard block
 block discarded – undo
1787 1787
       );
1788 1788
     }
1789 1789
 
1790
-    if(!$update_tables['ube_report_player'])
1790
+    if (!$update_tables['ube_report_player'])
1791 1791
     {
1792 1792
       upd_create_table('ube_report_player',
1793 1793
         "(
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
       );
1810 1810
     }
1811 1811
 
1812
-    if(!$update_tables['ube_report_fleet'])
1812
+    if (!$update_tables['ube_report_fleet'])
1813 1813
     {
1814 1814
       upd_create_table('ube_report_fleet',
1815 1815
         "(
@@ -1840,7 +1840,7 @@  discard block
 block discarded – undo
1840 1840
       );
1841 1841
     }
1842 1842
 
1843
-    if(!$update_tables['ube_report_unit'])
1843
+    if (!$update_tables['ube_report_unit'])
1844 1844
     {
1845 1845
       // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках
1846 1846
       // Может сохранять имена удаленных кораблей долго?
@@ -1878,7 +1878,7 @@  discard block
 block discarded – undo
1878 1878
       );
1879 1879
     }
1880 1880
 
1881
-    if(!$update_tables['ube_report_outcome_fleet'])
1881
+    if (!$update_tables['ube_report_outcome_fleet'])
1882 1882
     {
1883 1883
       upd_create_table('ube_report_outcome_fleet',
1884 1884
         "(
@@ -1908,7 +1908,7 @@  discard block
 block discarded – undo
1908 1908
       );
1909 1909
     }
1910 1910
 
1911
-    if(!$update_tables['ube_report_outcome_unit'])
1911
+    if (!$update_tables['ube_report_outcome_unit'])
1912 1912
     {
1913 1913
       upd_create_table('ube_report_outcome_unit',
1914 1914
         "(
@@ -1930,7 +1930,7 @@  discard block
 block discarded – undo
1930 1930
       );
1931 1931
     }
1932 1932
 
1933
-    if(!$update_tables['unit'])
1933
+    if (!$update_tables['unit'])
1934 1934
     {
1935 1935
       upd_create_table('unit',
1936 1936
         "(
@@ -1950,7 +1950,7 @@  discard block
 block discarded – undo
1950 1950
       );
1951 1951
     }
1952 1952
 
1953
-    if(!$update_tables['captain'])
1953
+    if (!$update_tables['captain'])
1954 1954
     {
1955 1955
       upd_create_table('captain',
1956 1956
         "(
@@ -1971,7 +1971,7 @@  discard block
 block discarded – undo
1971 1971
       );
1972 1972
     }
1973 1973
 
1974
-    if(!$update_tables['fleets']['fleet_start_planet_id'])
1974
+    if (!$update_tables['fleets']['fleet_start_planet_id'])
1975 1975
     {
1976 1976
       upd_alter_table('fleets', array(
1977 1977
         "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`",
@@ -1994,7 +1994,7 @@  discard block
 block discarded – undo
1994 1994
 
1995 1995
     upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']);
1996 1996
 
1997
-    if(!$update_tables['chat_player'])
1997
+    if (!$update_tables['chat_player'])
1998 1998
     {
1999 1999
       upd_create_table('chat_player',
2000 2000
         "(
@@ -2057,7 +2057,7 @@  discard block
 block discarded – undo
2057 2057
       "DROP FOREIGN KEY `FK_payment_user`",
2058 2058
     ), $update_foreigns['payment']['FK_payment_user']);
2059 2059
 
2060
-    if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;')
2060
+    if ($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;')
2061 2061
     {
2062 2062
       upd_alter_table('chat', array(
2063 2063
         "DROP FOREIGN KEY `FK_chat_message_sender_user_id`",
@@ -2091,7 +2091,7 @@  discard block
 block discarded – undo
2091 2091
       "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)",
2092 2092
     ), !$update_indexes['ube_report']['I_ube_report_time_combat']);
2093 2093
 
2094
-    if(!$update_tables['unit']['unit_time_start'])
2094
+    if (!$update_tables['unit']['unit_time_start'])
2095 2095
     {
2096 2096
       upd_alter_table('unit', array(
2097 2097
         "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'",
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
       );
2109 2109
     }
2110 2110
 
2111
-    if(!$update_tables['que'])
2111
+    if (!$update_tables['que'])
2112 2112
     {
2113 2113
       upd_create_table('que',
2114 2114
         "(
@@ -2141,15 +2141,15 @@  discard block
 block discarded – undo
2141 2141
     }
2142 2142
 
2143 2143
     // Конвертирум очередь исследований
2144
-    if($update_tables['users']['que'])
2144
+    if ($update_tables['users']['que'])
2145 2145
     {
2146 2146
       $que_lines = array();
2147 2147
       $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`");
2148
-      while($que_row = db_fetch($que_query))
2148
+      while ($que_row = db_fetch($que_query))
2149 2149
       {
2150 2150
         $que_data = explode(',', $que_row['que']);
2151 2151
 
2152
-        if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech')))
2152
+        if (!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech')))
2153 2153
         {
2154 2154
           continue;
2155 2155
         }
@@ -2157,14 +2157,14 @@  discard block
 block discarded – undo
2157 2157
         $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0;
2158 2158
         // Если планета пустая - ставим главку
2159 2159
         $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet'];
2160
-        if($que_data[QI_PLANET_ID])
2160
+        if ($que_data[QI_PLANET_ID])
2161 2161
         {
2162 2162
           $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2163
-          if(!$que_planet_check['id'])
2163
+          if (!$que_planet_check['id'])
2164 2164
           {
2165 2165
             $que_data[QI_PLANET_ID] = $que_row['id_planet'];
2166 2166
             $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2167
-            if(!$que_planet_check['id'])
2167
+            if (!$que_planet_check['id'])
2168 2168
             {
2169 2169
               $que_data[QI_PLANET_ID] = 'NULL';
2170 2170
             }
@@ -2181,9 +2181,9 @@  discard block
 block discarded – undo
2181 2181
         $price_increase = pow($unit_factor, $unit_level);
2182 2182
         $unit_level++;
2183 2183
         $unit_cost = array();
2184
-        foreach($unit_info[P_COST] as $resource_id => $resource_amount)
2184
+        foreach ($unit_info[P_COST] as $resource_id => $resource_amount)
2185 2185
         {
2186
-          if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase))
2186
+          if ($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase))
2187 2187
           {
2188 2188
             continue;
2189 2189
           }
@@ -2195,7 +2195,7 @@  discard block
 block discarded – undo
2195 2195
           BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')";
2196 2196
       }
2197 2197
 
2198
-      if(!empty($que_lines))
2198
+      if (!empty($que_lines))
2199 2199
       {
2200 2200
         upd_do_query('INSERT INTO `{{que}}` (`que_player_id`,`que_planet_id_origin`,`que_type`,`que_time_left`,`que_unit_id`,`que_unit_amount`,`que_unit_mode`,`que_unit_level`,`que_unit_time`,`que_unit_price`) VALUES ' . implode(',', $que_lines));
2201 2201
       }
@@ -2210,7 +2210,7 @@  discard block
 block discarded – undo
2210 2210
 
2211 2211
 
2212 2212
     // Ковертируем технологии в таблицы
2213
-    if($update_tables['users']['graviton_tech'])
2213
+    if ($update_tables['users']['graviton_tech'])
2214 2214
     {
2215 2215
       upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES);
2216 2216
 
@@ -2218,18 +2218,18 @@  discard block
 block discarded – undo
2218 2218
       $user_query = upd_do_query("SELECT * FROM {{users}}");
2219 2219
       upd_add_more_time(300);
2220 2220
       $sn_group_tech = sn_get_groups('tech');
2221
-      while($user_row = db_fetch($user_query))
2221
+      while ($user_row = db_fetch($user_query))
2222 2222
       {
2223
-        foreach($sn_group_tech as $tech_id)
2223
+        foreach ($sn_group_tech as $tech_id)
2224 2224
         {
2225
-          if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)]))
2225
+          if ($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)]))
2226 2226
           {
2227 2227
             $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})";
2228 2228
           }
2229 2229
         }
2230 2230
       }
2231 2231
 
2232
-      if(!empty($que_lines))
2232
+      if (!empty($que_lines))
2233 2233
       {
2234 2234
         upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES " . implode(',', $que_lines));
2235 2235
       }
@@ -2239,30 +2239,30 @@  discard block
 block discarded – undo
2239 2239
       ), $update_tables['users']['graviton_tech']);
2240 2240
     }
2241 2241
 
2242
-    if(!$update_indexes['unit']['I_unit_record_search'])
2242
+    if (!$update_indexes['unit']['I_unit_record_search'])
2243 2243
     {
2244 2244
       upd_alter_table('unit', array(
2245 2245
         "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)",
2246 2246
       ), !$update_indexes['unit']['I_unit_record_search']);
2247 2247
 
2248
-      foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id)
2248
+      foreach (sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id)
2249 2249
       {
2250 2250
         $planet_units[get_unit_param($unit_id, P_NAME)] = 1;
2251 2251
       }
2252 2252
       $drop_index = array();
2253 2253
       $create_index = &$drop_index; // array();
2254
-      foreach($planet_units as $unit_name => $unit_create)
2254
+      foreach ($planet_units as $unit_name => $unit_create)
2255 2255
       {
2256
-        if($update_indexes['planets']['I_' . $unit_name])
2256
+        if ($update_indexes['planets']['I_' . $unit_name])
2257 2257
         {
2258 2258
           $drop_index[] = "DROP KEY I_{$unit_name}";
2259 2259
         }
2260
-        if($update_indexes['planets']['i_' . $unit_name])
2260
+        if ($update_indexes['planets']['i_' . $unit_name])
2261 2261
         {
2262 2262
           $drop_index[] = "DROP KEY i_{$unit_name}";
2263 2263
         }
2264 2264
 
2265
-        if($unit_create)
2265
+        if ($unit_create)
2266 2266
         {
2267 2267
           $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)";
2268 2268
         }
@@ -2274,7 +2274,7 @@  discard block
 block discarded – undo
2274 2274
       "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`",
2275 2275
     ), !$update_tables['users']['user_time_utc_offset']);
2276 2276
 
2277
-    if(!$update_foreigns['alliance']['FK_alliance_owner'])
2277
+    if (!$update_foreigns['alliance']['FK_alliance_owner'])
2278 2278
     {
2279 2279
       upd_do_query("UPDATE {{alliance}} SET ally_owner = null WHERE ally_owner not in (select id from {{users}})");
2280 2280
 
@@ -2295,7 +2295,7 @@  discard block
 block discarded – undo
2295 2295
 
2296 2296
     upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !$config->chat_highlight_developer);
2297 2297
 
2298
-    if(!$update_tables['player_name_history'])
2298
+    if (!$update_tables['player_name_history'])
2299 2299
     {
2300 2300
       upd_check_key('game_user_changename_cost', 100000, !$config->game_user_changename_cost);
2301 2301
       upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY);
@@ -2325,7 +2325,7 @@  discard block
 block discarded – undo
2325 2325
       "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'",
2326 2326
     ), !$update_tables['planets']['density_index']);
2327 2327
 
2328
-    if($update_tables['users']['player_artifact_list'])
2328
+    if ($update_tables['users']['player_artifact_list'])
2329 2329
     {
2330 2330
       upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']);
2331 2331
 
@@ -2336,17 +2336,17 @@  discard block
 block discarded – undo
2336 2336
       $db_changeset = array();
2337 2337
 
2338 2338
       $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE");
2339
-      while($row = db_fetch($query))
2339
+      while ($row = db_fetch($query))
2340 2340
       {
2341 2341
         $artifact_list = explode(';', $row['player_artifact_list']);
2342
-        if(!$row['player_artifact_list'] || empty($artifact_list))
2342
+        if (!$row['player_artifact_list'] || empty($artifact_list))
2343 2343
         {
2344 2344
           continue;
2345 2345
         }
2346
-        foreach($artifact_list as $key => &$value)
2346
+        foreach ($artifact_list as $key => &$value)
2347 2347
         {
2348 2348
           $value = explode(',', $value);
2349
-          if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]]))
2349
+          if (!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]]))
2350 2350
           {
2351 2351
             unset($artifact_list[$key]);
2352 2352
             continue;
@@ -2378,14 +2378,14 @@  discard block
 block discarded – undo
2378 2378
       "DROP COLUMN `colonisation_tech`",
2379 2379
     ), $update_tables['users']['spy_tech']);
2380 2380
 
2381
-    upd_check_key('payment_currency_exchange_dm_', 2500,             !$config->payment_currency_exchange_dm_ || $config->payment_currency_exchange_dm_ == 1000);
2381
+    upd_check_key('payment_currency_exchange_dm_', 2500, !$config->payment_currency_exchange_dm_ || $config->payment_currency_exchange_dm_ == 1000);
2382 2382
     upd_check_key('payment_currency_exchange_eur', 0.09259259259259, !$config->payment_currency_exchange_eur);
2383
-    upd_check_key('payment_currency_exchange_rub', 4.0,              !$config->payment_currency_exchange_rub);
2384
-    upd_check_key('payment_currency_exchange_usd', 0.125,            !$config->payment_currency_exchange_usd);
2385
-    upd_check_key('payment_currency_exchange_wme', 0.0952380952381,  !$config->payment_currency_exchange_usd);
2386
-    upd_check_key('payment_currency_exchange_wmr', 4.1,              !$config->payment_currency_exchange_wmr);
2387
-    upd_check_key('payment_currency_exchange_wmu', 1.05,             !$config->payment_currency_exchange_wmu);
2388
-    upd_check_key('payment_currency_exchange_wmz', 0.126582278481,   !$config->payment_currency_exchange_wmz);
2383
+    upd_check_key('payment_currency_exchange_rub', 4.0, !$config->payment_currency_exchange_rub);
2384
+    upd_check_key('payment_currency_exchange_usd', 0.125, !$config->payment_currency_exchange_usd);
2385
+    upd_check_key('payment_currency_exchange_wme', 0.0952380952381, !$config->payment_currency_exchange_usd);
2386
+    upd_check_key('payment_currency_exchange_wmr', 4.1, !$config->payment_currency_exchange_wmr);
2387
+    upd_check_key('payment_currency_exchange_wmu', 1.05, !$config->payment_currency_exchange_wmu);
2388
+    upd_check_key('payment_currency_exchange_wmz', 0.126582278481, !$config->payment_currency_exchange_wmz);
2389 2389
 
2390 2390
     upd_do_query('COMMIT;', true);
2391 2391
     $new_version = 37;
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -197,8 +197,7 @@  discard block
 block discarded – undo
197 197
           if($old_que_item[4] == 'build')
198 198
           {
199 199
             $old_que_item[4] = BUILD_CREATE;
200
-          }
201
-          else
200
+          } else
202 201
           {
203 202
             $old_que_item[4] = BUILD_DESTROY;
204 203
           }
@@ -667,18 +666,15 @@  discard block
 block discarded – undo
667 666
             if(preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2))
668 667
             {
669 668
               $reason = RPG_MARKET;
670
-            }
671
-            elseif(preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2))
669
+            } elseif(preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2))
672 670
             {
673 671
               $reason = RPG_MERCENARY;
674 672
               $comment = "Spent for mercenary {$matches2[1]} GUID {$matches2[2]}";
675
-            }
676
-            elseif(preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2))
673
+            } elseif(preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2))
677 674
             {
678 675
               $reason = RPG_REFERRAL;
679 676
               $comment = "Incoming from referral ID {$matches[1]}";
680
-            }
681
-            elseif(preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2))
677
+            } elseif(preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2))
682 678
             {
683 679
               $reason = RPG_ADMIN;
684 680
               $comment = $matches2[1];
@@ -1716,8 +1712,7 @@  discard block
 block discarded – undo
1716 1712
         if(!isset($found[$index]))
1717 1713
         {
1718 1714
           $found[$index] = $row['BUDDY_ID'];
1719
-        }
1720
-        else
1715
+        } else
1721 1716
         {
1722 1717
           $lost[] = $row['BUDDY_ID'];
1723 1718
         }
@@ -2169,8 +2164,7 @@  discard block
 block discarded – undo
2169 2164
               $que_data[QI_PLANET_ID] = 'NULL';
2170 2165
             }
2171 2166
           }
2172
-        }
2173
-        else
2167
+        } else
2174 2168
         {
2175 2169
           $que_data[QI_PLANET_ID] = 'NULL';
2176 2170
         }
Please login to merge, or discard this patch.
Switch Indentation   +1564 added lines, -1564 removed lines patch added patch discarded remove patch
@@ -7,48 +7,48 @@  discard block
 block discarded – undo
7 7
 
8 8
 switch($new_version)
9 9
 {
10
-  case 0:
11
-  case 1:
12
-  case 2:
13
-  case 3:
14
-  case 4:
15
-  case 5:
16
-  case 6:
17
-  case 7:
18
-  case 8:
19
-  case 9:
20
-    upd_log_version_update();
21
-
22
-    upd_alter_table('planets', "ADD `debris_metal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_metal']);
23
-    upd_alter_table('planets', "ADD `debris_crystal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_crystal']);
24
-
25
-    upd_alter_table('planets', array(
26
-      "ADD `parent_planet` bigint(11) unsigned DEFAULT '0'",
27
-      "ADD KEY `i_parent_planet` (`parent_planet`)"
28
-    ), !$update_tables['planets']['parent_planet']);
29
-    upd_do_query(
30
-      "UPDATE `{{planets}}` AS lu
10
+    case 0:
11
+    case 1:
12
+    case 2:
13
+    case 3:
14
+    case 4:
15
+    case 5:
16
+    case 6:
17
+    case 7:
18
+    case 8:
19
+    case 9:
20
+      upd_log_version_update();
21
+
22
+      upd_alter_table('planets', "ADD `debris_metal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_metal']);
23
+      upd_alter_table('planets', "ADD `debris_crystal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_crystal']);
24
+
25
+      upd_alter_table('planets', array(
26
+        "ADD `parent_planet` bigint(11) unsigned DEFAULT '0'",
27
+        "ADD KEY `i_parent_planet` (`parent_planet`)"
28
+      ), !$update_tables['planets']['parent_planet']);
29
+      upd_do_query(
30
+        "UPDATE `{{planets}}` AS lu
31 31
         LEFT JOIN `{{planets}}` AS pl
32 32
           ON pl.galaxy=lu.galaxy AND pl.system=lu.system AND pl.planet=lu.planet AND pl.planet_type=1
33 33
       SET lu.parent_planet=pl.id WHERE lu.planet_type=3;"
34
-    );
35
-    upd_drop_table('lunas');
34
+      );
35
+      upd_drop_table('lunas');
36 36
 
37
-    if($update_tables['galaxy'])
38
-    {
39
-      upd_do_query(
40
-        'UPDATE `{{planets}}`
37
+      if($update_tables['galaxy'])
38
+      {
39
+        upd_do_query(
40
+          'UPDATE `{{planets}}`
41 41
           LEFT JOIN `{{galaxy}}` ON {{galaxy}}.id_planet = {{planets}}.id
42 42
         SET
43 43
           {{planets}}.debris_metal = {{galaxy}}.metal,
44 44
           {{planets}}.debris_crystal = {{galaxy}}.crystal
45 45
         WHERE {{galaxy}}.metal>0 OR {{galaxy}}.crystal>0;'
46
-      );
47
-    }
48
-    upd_drop_table('galaxy');
46
+        );
47
+      }
48
+      upd_drop_table('galaxy');
49 49
 
50
-    upd_create_table('counter',
51
-      "(
50
+      upd_create_table('counter',
51
+        "(
52 52
         `id` bigint(11) NOT NULL AUTO_INCREMENT,
53 53
         `time` int(11) NOT NULL DEFAULT '0',
54 54
         `page` varchar(255) CHARACTER SET utf8 DEFAULT '0',
@@ -58,63 +58,63 @@  discard block
 block discarded – undo
58 58
         KEY `i_user_id` (`user_id`),
59 59
         KEY `i_ip` (`ip`)
60 60
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
61
-    );
62
-    upd_alter_table('counter', "ADD `url` varchar(255) CHARACTER SET utf8 DEFAULT ''", !$update_tables['counter']['url']);
61
+      );
62
+      upd_alter_table('counter', "ADD `url` varchar(255) CHARACTER SET utf8 DEFAULT ''", !$update_tables['counter']['url']);
63 63
 
64
-    upd_alter_table('fleets', array(
65
-      "ADD KEY `fleet_mess` (`fleet_mess`)",
66
-      "ADD KEY `fleet_group` (`fleet_group`)"
67
-    ), !$update_indexes['fleets']['fleet_mess']);
64
+      upd_alter_table('fleets', array(
65
+        "ADD KEY `fleet_mess` (`fleet_mess`)",
66
+        "ADD KEY `fleet_group` (`fleet_group`)"
67
+      ), !$update_indexes['fleets']['fleet_mess']);
68 68
 
69
-    upd_alter_table('referrals', "ADD `dark_matter` bigint(11) NOT NULL DEFAULT '0' COMMENT 'How much player have aquired Dark Matter'", !$update_tables['referrals']['dark_matter']);
70
-    upd_alter_table('referrals', "ADD KEY `id_partner` (`id_partner`)", !$update_indexes['referrals']['id_partner']);
69
+      upd_alter_table('referrals', "ADD `dark_matter` bigint(11) NOT NULL DEFAULT '0' COMMENT 'How much player have aquired Dark Matter'", !$update_tables['referrals']['dark_matter']);
70
+      upd_alter_table('referrals', "ADD KEY `id_partner` (`id_partner`)", !$update_indexes['referrals']['id_partner']);
71 71
 
72
-    upd_check_key('rpg_bonus_divisor', 10);
72
+      upd_check_key('rpg_bonus_divisor', 10);
73 73
 
74
-    upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('BannerURL', 'banner_source_post', 'BannerOverviewFrame',
74
+      upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('BannerURL', 'banner_source_post', 'BannerOverviewFrame',
75 75
       'close_reason', 'dbVersion', 'ForumUserBarFrame', 'OverviewBanner', 'OverviewClickBanner', 'OverviewExternChat',
76 76
       'OverviewExternChatCmd', 'OverviewNewsText', 'UserbarURL', 'userbar_source');");
77 77
 
78
-    $dm_change_legit = true;
78
+      $dm_change_legit = true;
79 79
 
80
-    upd_do_query(
81
-      "UPDATE {{referrals}} AS r
80
+      upd_do_query(
81
+        "UPDATE {{referrals}} AS r
82 82
         LEFT JOIN {{users}} AS u
83 83
           ON u.id = r.id
84 84
       SET r.dark_matter = u.lvl_minier + u.lvl_raid;"
85
-    );
86
-    upd_add_more_time();
85
+      );
86
+      upd_add_more_time();
87 87
 
88
-    if($update_tables['users']['rpg_points'])
89
-    {
90
-      upd_do_query(
91
-        "UPDATE {{users}} AS u
88
+      if($update_tables['users']['rpg_points'])
89
+      {
90
+        upd_do_query(
91
+          "UPDATE {{users}} AS u
92 92
           RIGHT JOIN {{referrals}} AS r
93 93
             ON r.id_partner = u.id AND r.dark_matter >= {$config->rpg_bonus_divisor}
94 94
         SET u.rpg_points = u.rpg_points + FLOOR(r.dark_matter/{$config->rpg_bonus_divisor});"
95
-      );
96
-    }
95
+        );
96
+      }
97 97
 
98
-    $dm_change_legit = false;
99
-  upd_do_query('COMMIT;', true);
100
-  $new_version = 10;
101
-
102
-  case 10:
103
-  case 11:
104
-  case 12:
105
-  case 13:
106
-  case 14:
107
-  case 15:
108
-  case 16:
109
-  case 17:
110
-  case 18:
111
-  case 19:
112
-  case 20:
113
-  case 21:
114
-    upd_log_version_update();
115
-
116
-    upd_create_table('alliance_requests',
117
-      "(
98
+      $dm_change_legit = false;
99
+    upd_do_query('COMMIT;', true);
100
+    $new_version = 10;
101
+
102
+    case 10:
103
+    case 11:
104
+    case 12:
105
+    case 13:
106
+    case 14:
107
+    case 15:
108
+    case 16:
109
+    case 17:
110
+    case 18:
111
+    case 19:
112
+    case 20:
113
+    case 21:
114
+      upd_log_version_update();
115
+
116
+      upd_create_table('alliance_requests',
117
+        "(
118 118
         `id_user` int(11) NOT NULL,
119 119
         `id_ally` int(11) NOT NULL DEFAULT '0',
120 120
         `request_text` text,
@@ -122,103 +122,103 @@  discard block
 block discarded – undo
122 122
         `request_denied` tinyint(1) unsigned NOT NULL DEFAULT '0',
123 123
         PRIMARY KEY (`id_user`,`id_ally`)
124 124
       ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"
125
-    );
126
-
127
-    upd_alter_table('announce', "ADD `detail_url` varchar(250) NOT NULL DEFAULT '' COMMENT 'Link to more details about update'", !$update_tables['announce']['detail_url']);
128
-
129
-    upd_alter_table('counter', array("MODIFY `ip` VARCHAR(250) COMMENT 'User last IP'", "ADD `proxy` VARCHAR(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)'"), !$update_tables['counter']['proxy']);
130
-
131
-    upd_alter_table('statpoints', array(
132
-      "ADD `res_rank` INT(11) DEFAULT 0 COMMENT 'Rank by resources'",
133
-      "ADD `res_old_rank` INT(11) DEFAULT 0 COMMENT 'Old rank by resources'",
134
-      "ADD `res_points` BIGINT(20) DEFAULT 0 COMMENT 'Resource stat points'",
135
-      "ADD `res_count` BIGINT(20) DEFAULT 0 COMMENT 'Old rank by resources'"
136
-    ), !$update_tables['statpoints']['res_rank']);
137
-
138
-    upd_alter_table('planets', "ADD `supercargo` bigint(11) NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count'", !$update_tables['planets']['supercargo']);
139
-
140
-    upd_alter_table('users', "DROP COLUMN `current_luna`", $update_tables['users']['current_luna']);
141
-    upd_alter_table('users', array("DROP COLUMN `aktywnosc`", "DROP COLUMN `time_aktyw`", "DROP COLUMN `kiler`",
142
-      "DROP COLUMN `kod_aktywujacy`", "DROP COLUMN `ataker`", "DROP COLUMN `atakin`"), $update_tables['users']['ataker']);
143
-    upd_alter_table('users', "ADD `options` TEXT COMMENT 'Packed user options'", !$update_tables['users']['options']);
144
-    upd_alter_table('users', "ADD `news_lastread` int(11) NOT NULL DEFAULT '0' COMMENT 'News last read date'", !$update_tables['users']['news_lastread']);
145
-    upd_alter_table('users', array("MODIFY `user_lastip` VARCHAR(250) COMMENT 'User last IP'", "ADD `user_proxy` VARCHAR(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)'"), !$update_tables['users']['user_proxy']);
146
-
147
-    upd_drop_table('update');
148
-
149
-    upd_check_key('fleet_speed', $config->fleet_speed/2500, $config->fleet_speed >= 2500);
150
-    upd_check_key('game_counter', 0);
151
-    upd_check_key('game_default_language', 'ru');
152
-    upd_check_key('game_default_skin', 'skins/EpicBlue/');
153
-    upd_check_key('game_default_template', 'OpenGame');
154
-    upd_check_key('game_news_overview', 3);
155
-    upd_check_key('game_news_actual', 259200);
156
-    upd_check_key('game_noob_factor', 5, !isset($config->game_noob_factor));
157
-    upd_check_key('game_noob_points', 5000, !isset($config->game_noob_points));
158
-    upd_check_key('game_speed', $config->game_speed/2500, $config->game_speed >= 2500);
159
-    upd_check_key('int_format_date', 'd.m.Y');
160
-    upd_check_key('int_format_time', 'H:i:s', true);
161
-    upd_check_key('int_banner_background', 'design/images/banner.png', true);
162
-    upd_check_key('int_userbar_background', 'design/images/userbar.png', true);
163
-    upd_check_key('player_max_colonies', $config->player_max_planets ? ($config->player_max_planets - 1) : 9);
164
-    upd_check_key('url_forum', $config->forum_url, !isset($config->url_forum));
165
-    upd_check_key('url_rules', $config->rules_url, !isset($config->url_rules));
166
-    upd_check_key('url_dark_matter', '', !isset($config->url_dark_matter));
167
-
168
-    upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN (
125
+      );
126
+
127
+      upd_alter_table('announce', "ADD `detail_url` varchar(250) NOT NULL DEFAULT '' COMMENT 'Link to more details about update'", !$update_tables['announce']['detail_url']);
128
+
129
+      upd_alter_table('counter', array("MODIFY `ip` VARCHAR(250) COMMENT 'User last IP'", "ADD `proxy` VARCHAR(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)'"), !$update_tables['counter']['proxy']);
130
+
131
+      upd_alter_table('statpoints', array(
132
+        "ADD `res_rank` INT(11) DEFAULT 0 COMMENT 'Rank by resources'",
133
+        "ADD `res_old_rank` INT(11) DEFAULT 0 COMMENT 'Old rank by resources'",
134
+        "ADD `res_points` BIGINT(20) DEFAULT 0 COMMENT 'Resource stat points'",
135
+        "ADD `res_count` BIGINT(20) DEFAULT 0 COMMENT 'Old rank by resources'"
136
+      ), !$update_tables['statpoints']['res_rank']);
137
+
138
+      upd_alter_table('planets', "ADD `supercargo` bigint(11) NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count'", !$update_tables['planets']['supercargo']);
139
+
140
+      upd_alter_table('users', "DROP COLUMN `current_luna`", $update_tables['users']['current_luna']);
141
+      upd_alter_table('users', array("DROP COLUMN `aktywnosc`", "DROP COLUMN `time_aktyw`", "DROP COLUMN `kiler`",
142
+        "DROP COLUMN `kod_aktywujacy`", "DROP COLUMN `ataker`", "DROP COLUMN `atakin`"), $update_tables['users']['ataker']);
143
+      upd_alter_table('users', "ADD `options` TEXT COMMENT 'Packed user options'", !$update_tables['users']['options']);
144
+      upd_alter_table('users', "ADD `news_lastread` int(11) NOT NULL DEFAULT '0' COMMENT 'News last read date'", !$update_tables['users']['news_lastread']);
145
+      upd_alter_table('users', array("MODIFY `user_lastip` VARCHAR(250) COMMENT 'User last IP'", "ADD `user_proxy` VARCHAR(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)'"), !$update_tables['users']['user_proxy']);
146
+
147
+      upd_drop_table('update');
148
+
149
+      upd_check_key('fleet_speed', $config->fleet_speed/2500, $config->fleet_speed >= 2500);
150
+      upd_check_key('game_counter', 0);
151
+      upd_check_key('game_default_language', 'ru');
152
+      upd_check_key('game_default_skin', 'skins/EpicBlue/');
153
+      upd_check_key('game_default_template', 'OpenGame');
154
+      upd_check_key('game_news_overview', 3);
155
+      upd_check_key('game_news_actual', 259200);
156
+      upd_check_key('game_noob_factor', 5, !isset($config->game_noob_factor));
157
+      upd_check_key('game_noob_points', 5000, !isset($config->game_noob_points));
158
+      upd_check_key('game_speed', $config->game_speed/2500, $config->game_speed >= 2500);
159
+      upd_check_key('int_format_date', 'd.m.Y');
160
+      upd_check_key('int_format_time', 'H:i:s', true);
161
+      upd_check_key('int_banner_background', 'design/images/banner.png', true);
162
+      upd_check_key('int_userbar_background', 'design/images/userbar.png', true);
163
+      upd_check_key('player_max_colonies', $config->player_max_planets ? ($config->player_max_planets - 1) : 9);
164
+      upd_check_key('url_forum', $config->forum_url, !isset($config->url_forum));
165
+      upd_check_key('url_rules', $config->rules_url, !isset($config->url_rules));
166
+      upd_check_key('url_dark_matter', '', !isset($config->url_dark_matter));
167
+
168
+      upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN (
169 169
       'game_date_withTime', 'player_max_planets', 'OverviewNewsFrame', 'forum_url', 'rules_url'
170 170
     );");
171 171
 
172
-  upd_do_query('COMMIT;', true);
173
-  $new_version = 22;
172
+    upd_do_query('COMMIT;', true);
173
+    $new_version = 22;
174 174
 
175
-  case 22:
176
-    upd_log_version_update();
175
+    case 22:
176
+      upd_log_version_update();
177 177
 
178
-    upd_alter_table('planets', "ADD `governor` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Planet governor'", !$update_tables['planets']['governor']);
179
-    upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']);
180
-    upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']);
178
+      upd_alter_table('planets', "ADD `governor` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Planet governor'", !$update_tables['planets']['governor']);
179
+      upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']);
180
+      upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']);
181 181
 
182
-    if($update_tables['planets']['b_building'])
183
-    {
184
-      $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;');
185
-      $const_que_structures = QUE_STRUCTURES;
186
-      while($planet_data = db_fetch($planet_query))
182
+      if($update_tables['planets']['b_building'])
187 183
       {
188
-        $old_que = explode(';', $planet_data['b_building_id']);
189
-        foreach($old_que as $old_que_item_string)
184
+        $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;');
185
+        $const_que_structures = QUE_STRUCTURES;
186
+        while($planet_data = db_fetch($planet_query))
190 187
         {
191
-          if(!$old_que_item_string)
188
+          $old_que = explode(';', $planet_data['b_building_id']);
189
+          foreach($old_que as $old_que_item_string)
192 190
           {
193
-            continue;
194
-          }
191
+            if(!$old_que_item_string)
192
+            {
193
+              continue;
194
+            }
195 195
 
196
-          $old_que_item = explode(',', $old_que_item_string);
197
-          if($old_que_item[4] == 'build')
198
-          {
199
-            $old_que_item[4] = BUILD_CREATE;
200
-          }
201
-          else
202
-          {
203
-            $old_que_item[4] = BUILD_DESTROY;
204
-          }
196
+            $old_que_item = explode(',', $old_que_item_string);
197
+            if($old_que_item[4] == 'build')
198
+            {
199
+              $old_que_item[4] = BUILD_CREATE;
200
+            }
201
+            else
202
+            {
203
+              $old_que_item[4] = BUILD_DESTROY;
204
+            }
205 205
 
206
-          $old_que_item[3] = $old_que_item[3] > $planet_data['last_update'] ? $old_que_item[3] - $planet_data['last_update'] : 1;
207
-          $planet_data['que'] = "{$old_que_item[0]},1,{$old_que_item[3]},{$old_que_item[4]},{$const_que_structures};{$planet_data['que']}";
206
+            $old_que_item[3] = $old_que_item[3] > $planet_data['last_update'] ? $old_que_item[3] - $planet_data['last_update'] : 1;
207
+            $planet_data['que'] = "{$old_que_item[0]},1,{$old_que_item[3]},{$old_que_item[4]},{$const_que_structures};{$planet_data['que']}";
208
+          }
209
+          upd_do_query("UPDATE {{planets}} SET `que` = '{$planet_data['que']}', `b_building` = '0', `b_building_id` = '0' WHERE `id` = '{$planet_data['id']}' LIMIT 1;", true);
208 210
         }
209
-        upd_do_query("UPDATE {{planets}} SET `que` = '{$planet_data['que']}', `b_building` = '0', `b_building_id` = '0' WHERE `id` = '{$planet_data['id']}' LIMIT 1;", true);
210 211
       }
211
-    }
212 212
 
213
-  upd_do_query('COMMIT;', true);
214
-  $new_version = 23;
213
+    upd_do_query('COMMIT;', true);
214
+    $new_version = 23;
215 215
 
216
-  case 23:
217
-  case 24:
218
-    upd_log_version_update();
216
+    case 23:
217
+    case 24:
218
+      upd_log_version_update();
219 219
 
220
-    upd_create_table('confirmations',
221
-      "(
220
+      upd_create_table('confirmations',
221
+        "(
222 222
         `id` bigint(11) NOT NULL AUTO_INCREMENT,
223 223
         `id_user` bigint(11) NOT NULL DEFAULT 0,
224 224
         `type` SMALLINT NOT NULL DEFAULT 0,
@@ -228,130 +228,130 @@  discard block
 block discarded – undo
228 228
         PRIMARY KEY (`id`),
229 229
         KEY `i_code_email` (`code`, `email`)
230 230
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
231
-    );
231
+      );
232 232
 
233
-    if($update_tables['users']['urlaubs_until'])
234
-    {
235
-      upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']);
236
-      upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;');
237
-      upd_alter_table('users', 'DROP COLUMN `urlaubs_until`, DROP COLUMN `urlaubs_modus`, DROP COLUMN `urlaubs_modus_time`', $update_tables['users']['urlaubs_until']);
238
-    }
233
+      if($update_tables['users']['urlaubs_until'])
234
+      {
235
+        upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']);
236
+        upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;');
237
+        upd_alter_table('users', 'DROP COLUMN `urlaubs_until`, DROP COLUMN `urlaubs_modus`, DROP COLUMN `urlaubs_modus_time`', $update_tables['users']['urlaubs_until']);
238
+      }
239 239
 
240
-    upd_check_key('user_vacation_disable', $config->urlaubs_modus_erz, !isset($config->user_vacation_disable));
241
-    upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('urlaubs_modus_erz');");
240
+      upd_check_key('user_vacation_disable', $config->urlaubs_modus_erz, !isset($config->user_vacation_disable));
241
+      upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('urlaubs_modus_erz');");
242 242
 
243
-  upd_do_query('COMMIT;', true);
244
-  $new_version = 25;
245
-
246
-  case 25:
247
-    upd_log_version_update();
248
-
249
-    upd_alter_table('rw', array(
250
-      "DROP COLUMN `a_zestrzelona`",
251
-      "DROP INDEX `rid`",
252
-      "ADD COLUMN `report_id` bigint(11) NOT NULL AUTO_INCREMENT FIRST",
253
-      "ADD PRIMARY KEY (`report_id`)",
254
-      "ADD INDEX `i_rid` (`rid`)"
255
-    ), !$update_tables['rw']['report_id']);
256
-
257
-    upd_add_more_time();
258
-    upd_create_table('logs_backup', "AS (SELECT * FROM {$config->db_prefix}logs);");
259
-
260
-    upd_alter_table('logs', array(
261
-      "MODIFY COLUMN `log_id` INT(1)",
262
-      "DROP PRIMARY KEY"
263
-    ), !$update_tables['logs']['log_timestamp']);
264
-
265
-    upd_alter_table('logs', array(
266
-      "DROP COLUMN `log_id`",
267
-      "ADD COLUMN `log_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp' FIRST",
268
-      "ADD COLUMN `log_username` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'Username' AFTER `log_timestamp`",
269
-      "MODIFY COLUMN `log_title` VARCHAR(64) NOT NULL DEFAULT 'Log entry' COMMENT 'Short description' AFTER `log_username`",
270
-      "MODIFY COLUMN `log_page` VARCHAR(512) NOT NULL DEFAULT '' COMMENT 'Page that makes entry to log' AFTER `log_text`",
271
-      "CHANGE COLUMN `log_type` `log_code` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `log_page`",
272
-      "MODIFY COLUMN `log_sender` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ID which make log record' AFTER `log_code`",
273
-      "MODIFY COLUMN `log_time` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Machine-readable timestamp' AFTER `log_sender`",
274
-      "ADD COLUMN `log_dump` TEXT NOT NULL DEFAULT '' COMMENT 'Machine-readable dump of variables' AFTER `log_time`",
275
-      "ADD INDEX `i_log_username` (`log_username`)",
276
-      "ADD INDEX `i_log_time` (`log_time`)",
277
-      "ADD INDEX `i_log_sender` (`log_sender`)",
278
-      "ADD INDEX `i_log_code` (`log_code`)",
279
-      "ADD INDEX `i_log_page` (`log_page`)",
280
-      "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"
281
-    ), !$update_tables['logs']['log_timestamp']);
282
-    upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;');
283
-
284
-    if($update_tables['errors'])
285
-    {
286
-      upd_do_query('INSERT INTO `{{logs}}` (`log_code`, `log_sender`, `log_title`, `log_text`, `log_page`, `log_time`) SELECT 500, `error_sender`, `error_type`, `error_text`, `error_page`, `error_time` FROM `{{errors}}`;');
287
-      if($update_tables['errors_backup'])
243
+    upd_do_query('COMMIT;', true);
244
+    $new_version = 25;
245
+
246
+    case 25:
247
+      upd_log_version_update();
248
+
249
+      upd_alter_table('rw', array(
250
+        "DROP COLUMN `a_zestrzelona`",
251
+        "DROP INDEX `rid`",
252
+        "ADD COLUMN `report_id` bigint(11) NOT NULL AUTO_INCREMENT FIRST",
253
+        "ADD PRIMARY KEY (`report_id`)",
254
+        "ADD INDEX `i_rid` (`rid`)"
255
+      ), !$update_tables['rw']['report_id']);
256
+
257
+      upd_add_more_time();
258
+      upd_create_table('logs_backup', "AS (SELECT * FROM {$config->db_prefix}logs);");
259
+
260
+      upd_alter_table('logs', array(
261
+        "MODIFY COLUMN `log_id` INT(1)",
262
+        "DROP PRIMARY KEY"
263
+      ), !$update_tables['logs']['log_timestamp']);
264
+
265
+      upd_alter_table('logs', array(
266
+        "DROP COLUMN `log_id`",
267
+        "ADD COLUMN `log_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp' FIRST",
268
+        "ADD COLUMN `log_username` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'Username' AFTER `log_timestamp`",
269
+        "MODIFY COLUMN `log_title` VARCHAR(64) NOT NULL DEFAULT 'Log entry' COMMENT 'Short description' AFTER `log_username`",
270
+        "MODIFY COLUMN `log_page` VARCHAR(512) NOT NULL DEFAULT '' COMMENT 'Page that makes entry to log' AFTER `log_text`",
271
+        "CHANGE COLUMN `log_type` `log_code` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `log_page`",
272
+        "MODIFY COLUMN `log_sender` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ID which make log record' AFTER `log_code`",
273
+        "MODIFY COLUMN `log_time` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Machine-readable timestamp' AFTER `log_sender`",
274
+        "ADD COLUMN `log_dump` TEXT NOT NULL DEFAULT '' COMMENT 'Machine-readable dump of variables' AFTER `log_time`",
275
+        "ADD INDEX `i_log_username` (`log_username`)",
276
+        "ADD INDEX `i_log_time` (`log_time`)",
277
+        "ADD INDEX `i_log_sender` (`log_sender`)",
278
+        "ADD INDEX `i_log_code` (`log_code`)",
279
+        "ADD INDEX `i_log_page` (`log_page`)",
280
+        "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"
281
+      ), !$update_tables['logs']['log_timestamp']);
282
+      upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;');
283
+
284
+      if($update_tables['errors'])
288 285
       {
289
-        upd_drop_table('errors_backup');
290
-      }
291
-//      __db_query("ALTER TABLE {$config->db_prefix}errors RENAME TO {$config->db_prefix}errors_backup;");
292
-//      classSupernova::$db->__db_query("ALTER TABLE {$config->db_prefix}errors RENAME TO {$config->db_prefix}errors_backup;");
293
-      upd_alter_table('errors', ' RENAME TO {$config->db_prefix}errors_backup');
286
+        upd_do_query('INSERT INTO `{{logs}}` (`log_code`, `log_sender`, `log_title`, `log_text`, `log_page`, `log_time`) SELECT 500, `error_sender`, `error_type`, `error_text`, `error_page`, `error_time` FROM `{{errors}}`;');
287
+        if($update_tables['errors_backup'])
288
+        {
289
+          upd_drop_table('errors_backup');
290
+        }
291
+  //      __db_query("ALTER TABLE {$config->db_prefix}errors RENAME TO {$config->db_prefix}errors_backup;");
292
+  //      classSupernova::$db->__db_query("ALTER TABLE {$config->db_prefix}errors RENAME TO {$config->db_prefix}errors_backup;");
293
+        upd_alter_table('errors', ' RENAME TO {$config->db_prefix}errors_backup');
294 294
 
295
-      upd_drop_table('errors');
296
-    }
295
+        upd_drop_table('errors');
296
+      }
297 297
 
298
-    upd_alter_table('logs', 'ORDER BY log_time');
298
+      upd_alter_table('logs', 'ORDER BY log_time');
299 299
 
300
-    upd_alter_table('logs', array("ADD COLUMN `log_id` SERIAL", "ADD PRIMARY KEY (`log_id`)"), !$update_tables['logs']['log_id']);
300
+      upd_alter_table('logs', array("ADD COLUMN `log_id` SERIAL", "ADD PRIMARY KEY (`log_id`)"), !$update_tables['logs']['log_id']);
301 301
 
302
-    upd_do_query('UPDATE `{{logs}}` SET `log_timestamp` = FROM_UNIXTIME(`log_time`);');
303
-    upd_do_query('UPDATE `{{logs}}` AS l LEFT JOIN `{{users}}` AS u ON u.id = l.log_sender SET l.log_username = u.username WHERE l.log_username IS NOT NULL;');
302
+      upd_do_query('UPDATE `{{logs}}` SET `log_timestamp` = FROM_UNIXTIME(`log_time`);');
303
+      upd_do_query('UPDATE `{{logs}}` AS l LEFT JOIN `{{users}}` AS u ON u.id = l.log_sender SET l.log_username = u.username WHERE l.log_username IS NOT NULL;');
304 304
 
305
-    upd_do_query("UPDATE `{{logs}}` SET `log_code` = 190 WHERE `log_code` = 100 AND `log_title` = 'Stat update';");
306
-    upd_do_query("UPDATE `{{logs}}` SET `log_code` = 191 WHERE `log_code` = 101 AND `log_title` = 'Stat update';");
307
-    upd_do_query("UPDATE `{{logs}}` SET `log_code` = 192 WHERE `log_code` = 102 AND `log_title` = 'Stat update';");
308
-    $sys_log_disabled = false;
305
+      upd_do_query("UPDATE `{{logs}}` SET `log_code` = 190 WHERE `log_code` = 100 AND `log_title` = 'Stat update';");
306
+      upd_do_query("UPDATE `{{logs}}` SET `log_code` = 191 WHERE `log_code` = 101 AND `log_title` = 'Stat update';");
307
+      upd_do_query("UPDATE `{{logs}}` SET `log_code` = 192 WHERE `log_code` = 102 AND `log_title` = 'Stat update';");
308
+      $sys_log_disabled = false;
309 309
 
310
-    upd_do_query('COMMIT;', true);
311
-    $new_version = 26;
310
+      upd_do_query('COMMIT;', true);
311
+      $new_version = 26;
312 312
 
313
-  case 26:
314
-    upd_log_version_update();
313
+    case 26:
314
+      upd_log_version_update();
315 315
 
316
-    $sys_log_disabled = false;
316
+      $sys_log_disabled = false;
317 317
 
318
-    upd_alter_table('planets', "ADD INDEX `i_parent_planet` (`parent_planet`)", !$update_indexes['planets']['i_parent_planet']);
319
-    upd_alter_table('messages', "DROP INDEX `owner`", $update_indexes['messages']['owner']);
320
-    upd_alter_table('messages', "DROP INDEX `owner_type`", $update_indexes['messages']['owner_type']);
321
-    upd_alter_table('messages', "DROP INDEX `sender_type`", $update_indexes['messages']['sender_type']);
318
+      upd_alter_table('planets', "ADD INDEX `i_parent_planet` (`parent_planet`)", !$update_indexes['planets']['i_parent_planet']);
319
+      upd_alter_table('messages', "DROP INDEX `owner`", $update_indexes['messages']['owner']);
320
+      upd_alter_table('messages', "DROP INDEX `owner_type`", $update_indexes['messages']['owner_type']);
321
+      upd_alter_table('messages', "DROP INDEX `sender_type`", $update_indexes['messages']['sender_type']);
322 322
 
323
-    upd_alter_table('messages', array(
324
-      "ADD INDEX `i_owner_time` (`message_owner`, `message_time`)",
325
-      "ADD INDEX `i_sender_time` (`message_sender`, `message_time`)",
326
-      "ADD INDEX `i_time` (`message_time`)"
327
-    ), !$update_indexes['messages']['i_owner_time']);
323
+      upd_alter_table('messages', array(
324
+        "ADD INDEX `i_owner_time` (`message_owner`, `message_time`)",
325
+        "ADD INDEX `i_sender_time` (`message_sender`, `message_time`)",
326
+        "ADD INDEX `i_time` (`message_time`)"
327
+      ), !$update_indexes['messages']['i_owner_time']);
328 328
 
329
-    upd_drop_table('fleet_log');
329
+      upd_drop_table('fleet_log');
330 330
 
331
-    upd_do_query("UPDATE `{{planets}}` SET `metal` = 0 WHERE `metal` < 0;");
332
-    upd_do_query("UPDATE `{{planets}}` SET `crystal` = 0 WHERE `crystal` < 0;");
333
-    upd_do_query("UPDATE `{{planets}}` SET `deuterium` = 0 WHERE `deuterium` < 0;");
334
-    upd_alter_table('planets', array(
335
-       "DROP COLUMN `b_building`",
336
-       "DROP COLUMN `b_building_id`"
337
-    ), $update_tables['planets']['b_building']);
331
+      upd_do_query("UPDATE `{{planets}}` SET `metal` = 0 WHERE `metal` < 0;");
332
+      upd_do_query("UPDATE `{{planets}}` SET `crystal` = 0 WHERE `crystal` < 0;");
333
+      upd_do_query("UPDATE `{{planets}}` SET `deuterium` = 0 WHERE `deuterium` < 0;");
334
+      upd_alter_table('planets', array(
335
+         "DROP COLUMN `b_building`",
336
+         "DROP COLUMN `b_building_id`"
337
+      ), $update_tables['planets']['b_building']);
338 338
 
339
-    upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('noobprotection', 'noobprotectionmulti', 'noobprotectiontime', 'chat_admin_msgFormat');");
339
+      upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('noobprotection', 'noobprotectionmulti', 'noobprotectiontime', 'chat_admin_msgFormat');");
340 340
 
341
-    upd_do_query("DELETE FROM `{{logs}}` WHERE `log_code` = 501;");
342
-    upd_do_query("DELETE FROM `{{logs}}` WHERE `log_title` IN ('Canceling Hangar Que', 'Building Planet Defense');");
341
+      upd_do_query("DELETE FROM `{{logs}}` WHERE `log_code` = 501;");
342
+      upd_do_query("DELETE FROM `{{logs}}` WHERE `log_title` IN ('Canceling Hangar Que', 'Building Planet Defense');");
343 343
 
344
-    upd_check_key('chat_admin_highlight', '<font color=purple>$1</font>', !isset($config->chat_admin_highlight));
344
+      upd_check_key('chat_admin_highlight', '<font color=purple>$1</font>', !isset($config->chat_admin_highlight));
345 345
 
346
-    upd_check_key('int_banner_URL', 'banner.php?type=banner', $config->int_banner_URL == '/banner.php?type=banner');
347
-    upd_check_key('int_userbar_URL', 'banner.php?type=userbar', $config->int_userbar_URL == '/banner.php?type=userbar');
346
+      upd_check_key('int_banner_URL', 'banner.php?type=banner', $config->int_banner_URL == '/banner.php?type=banner');
347
+      upd_check_key('int_userbar_URL', 'banner.php?type=userbar', $config->int_userbar_URL == '/banner.php?type=userbar');
348 348
 
349
-    upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci');
349
+      upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci');
350 350
 
351
-    if(!$update_tables['shortcut'])
352
-    {
353
-      upd_create_table('shortcut',
354
-        "(
351
+      if(!$update_tables['shortcut'])
352
+      {
353
+        upd_create_table('shortcut',
354
+          "(
355 355
           `shortcut_id` SERIAL,
356 356
           `shortcut_user_id` BIGINT(11) UNSIGNED NOT NULL DEFAULT 0,
357 357
           `shortcut_planet_id` bigint(11) NOT NULL DEFAULT 0,
@@ -368,75 +368,75 @@  discard block
 block discarded – undo
368 368
           CONSTRAINT `FK_shortcut_user_id` FOREIGN KEY (`shortcut_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
369 369
 
370 370
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
371
-      );
371
+        );
372 372
 
373
-      $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON);
373
+        $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON);
374 374
 
375
-      $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';");
376
-      while($user_data = db_fetch($query))
377
-      {
378
-        $shortcuts = explode("\r\n", $user_data['fleet_shortcut']);
379
-        foreach($shortcuts as $shortcut)
375
+        $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';");
376
+        while($user_data = db_fetch($query))
380 377
         {
381
-          if(!$shortcut)
378
+          $shortcuts = explode("\r\n", $user_data['fleet_shortcut']);
379
+          foreach($shortcuts as $shortcut)
382 380
           {
383
-            continue;
384
-          }
381
+            if(!$shortcut)
382
+            {
383
+              continue;
384
+            }
385 385
 
386
-          $shortcut = explode(',', $shortcut);
387
-          $shortcut[0] = db_escape($shortcut[0]);
388
-          $shortcut[1] = intval($shortcut[1]);
389
-          $shortcut[2] = intval($shortcut[2]);
390
-          $shortcut[3] = intval($shortcut[3]);
391
-          $shortcut[4] = intval($shortcut[4]);
386
+            $shortcut = explode(',', $shortcut);
387
+            $shortcut[0] = db_escape($shortcut[0]);
388
+            $shortcut[1] = intval($shortcut[1]);
389
+            $shortcut[2] = intval($shortcut[2]);
390
+            $shortcut[3] = intval($shortcut[3]);
391
+            $shortcut[4] = intval($shortcut[4]);
392 392
 
393
-          if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types))
394
-          {
395
-            upd_do_query("INSERT INTO {$config->db_prefix}shortcut (shortcut_user_id, shortcut_galaxy, shortcut_system, shortcut_planet, shortcut_planet_type, shortcut_text) VALUES ({$user_data['id']}, {$shortcut[1]}, {$shortcut[2]}, {$shortcut[3]}, {$shortcut[4]}, '{$shortcut[0]}');", true);
393
+            if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types))
394
+            {
395
+              upd_do_query("INSERT INTO {$config->db_prefix}shortcut (shortcut_user_id, shortcut_galaxy, shortcut_system, shortcut_planet, shortcut_planet_type, shortcut_text) VALUES ({$user_data['id']}, {$shortcut[1]}, {$shortcut[2]}, {$shortcut[3]}, {$shortcut[4]}, '{$shortcut[0]}');", true);
396
+            }
396 397
           }
397 398
         }
398
-      }
399 399
 
400
-      upd_alter_table('users', 'DROP COLUMN `fleet_shortcut`');
401
-    };
400
+        upd_alter_table('users', 'DROP COLUMN `fleet_shortcut`');
401
+      };
402 402
 
403
-    upd_check_key('url_faq', '', !isset($config->url_faq));
403
+      upd_check_key('url_faq', '', !isset($config->url_faq));
404 404
 
405
-    upd_do_query('COMMIT;', true);
406
-    $new_version = 27;
407
-
408
-  case 27:
409
-    upd_log_version_update();
410
-
411
-    upd_check_key('chat_highlight_moderator', '<font color=green>$1</font>', !isset($config->chat_highlight_moderator));
412
-    upd_check_key('chat_highlight_operator', '<font color=red>$1</font>', !isset($config->chat_highlight_operator));
413
-    upd_check_key('chat_highlight_admin', $config->chat_admin_highlight ? $config->chat_admin_highlight : '<font color=puple>$1</font>', !isset($config->chat_highlight_admin));
414
-
415
-    upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('chat_admin_highlight');");
416
-
417
-    upd_alter_table('banned', array(
418
-      "CHANGE COLUMN id ban_id bigint(20) unsigned NOT NULL AUTO_INCREMENT",
419
-      "CHANGE COLUMN `who` `ban_user_name` VARCHAR(64) NOT NULL DEFAULT ''",
420
-      "CHANGE COLUMN `theme` `ban_reason` VARCHAR(128) NOT NULL DEFAULT ''",
421
-      "CHANGE COLUMN `time` `ban_time` int(11) NOT NULL DEFAULT 0",
422
-      "CHANGE COLUMN `longer` `ban_until` int(11) NOT NULL DEFAULT 0",
423
-      "CHANGE COLUMN `author` `ban_issuer_name` VARCHAR(64) NOT NULL DEFAULT ''",
424
-      "CHANGE COLUMN `email` `ban_issuer_email` VARCHAR(64) NOT NULL DEFAULT ''",
425
-      "DROP COLUMN who2",
426
-      "ADD PRIMARY KEY (`ban_id`)"/*,
405
+      upd_do_query('COMMIT;', true);
406
+      $new_version = 27;
407
+
408
+    case 27:
409
+      upd_log_version_update();
410
+
411
+      upd_check_key('chat_highlight_moderator', '<font color=green>$1</font>', !isset($config->chat_highlight_moderator));
412
+      upd_check_key('chat_highlight_operator', '<font color=red>$1</font>', !isset($config->chat_highlight_operator));
413
+      upd_check_key('chat_highlight_admin', $config->chat_admin_highlight ? $config->chat_admin_highlight : '<font color=puple>$1</font>', !isset($config->chat_highlight_admin));
414
+
415
+      upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('chat_admin_highlight');");
416
+
417
+      upd_alter_table('banned', array(
418
+        "CHANGE COLUMN id ban_id bigint(20) unsigned NOT NULL AUTO_INCREMENT",
419
+        "CHANGE COLUMN `who` `ban_user_name` VARCHAR(64) NOT NULL DEFAULT ''",
420
+        "CHANGE COLUMN `theme` `ban_reason` VARCHAR(128) NOT NULL DEFAULT ''",
421
+        "CHANGE COLUMN `time` `ban_time` int(11) NOT NULL DEFAULT 0",
422
+        "CHANGE COLUMN `longer` `ban_until` int(11) NOT NULL DEFAULT 0",
423
+        "CHANGE COLUMN `author` `ban_issuer_name` VARCHAR(64) NOT NULL DEFAULT ''",
424
+        "CHANGE COLUMN `email` `ban_issuer_email` VARCHAR(64) NOT NULL DEFAULT ''",
425
+        "DROP COLUMN who2",
426
+        "ADD PRIMARY KEY (`ban_id`)"/*,
427 427
       "RENAME TO {$config->db_prefix}ban"*/
428
-    ), !$update_tables['banned']['ban_id']);
429
-
430
-    upd_alter_table('alliance', array(
431
-      "MODIFY COLUMN `id` SERIAL",
432
-      "ADD CONSTRAINT UNIQUE KEY `i_ally_name` (`ally_name`)",
433
-      "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci",
434
-      "ENGINE=InnoDB"
435
-    ), !$update_indexes['alliance']['i_ally_name']);
436
-
437
-    $upd_relation_types = "'neutral', 'war', 'peace', 'confederation', 'federation', 'union', 'master', 'slave'";
438
-    upd_create_table('alliance_diplomacy',
439
-      "(
428
+      ), !$update_tables['banned']['ban_id']);
429
+
430
+      upd_alter_table('alliance', array(
431
+        "MODIFY COLUMN `id` SERIAL",
432
+        "ADD CONSTRAINT UNIQUE KEY `i_ally_name` (`ally_name`)",
433
+        "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci",
434
+        "ENGINE=InnoDB"
435
+      ), !$update_indexes['alliance']['i_ally_name']);
436
+
437
+      $upd_relation_types = "'neutral', 'war', 'peace', 'confederation', 'federation', 'union', 'master', 'slave'";
438
+      upd_create_table('alliance_diplomacy',
439
+        "(
440 440
         `alliance_diplomacy_id` SERIAL,
441 441
         `alliance_diplomacy_ally_id` bigint(11) UNSIGNED DEFAULT NULL,
442 442
         `alliance_diplomacy_contr_ally_id` bigint(11) UNSIGNED DEFAULT NULL,
@@ -453,10 +453,10 @@  discard block
 block discarded – undo
453 453
         ,CONSTRAINT `FK_diplomacy_contr_ally_id`   FOREIGN KEY (`alliance_diplomacy_contr_ally_id`)   REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
454 454
         ,CONSTRAINT `FK_diplomacy_contr_ally_name` FOREIGN KEY (`alliance_diplomacy_contr_ally_name`) REFERENCES `{$config->db_prefix}alliance` (`ally_name`) ON DELETE CASCADE ON UPDATE CASCADE
455 455
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;"
456
-    );
456
+      );
457 457
 
458
-    upd_create_table('alliance_negotiation',
459
-      "(
458
+      upd_create_table('alliance_negotiation',
459
+        "(
460 460
         `alliance_negotiation_id` SERIAL,
461 461
         `alliance_negotiation_ally_id` bigint(11) UNSIGNED DEFAULT NULL,
462 462
         `alliance_negotiation_ally_name` varchar(32) DEFAULT '',
@@ -477,13 +477,13 @@  discard block
 block discarded – undo
477 477
         ,CONSTRAINT `FK_negotiation_contr_ally_id`   FOREIGN KEY (`alliance_negotiation_contr_ally_id`)   REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
478 478
         ,CONSTRAINT `FK_negotiation_contr_ally_name` FOREIGN KEY (`alliance_negotiation_contr_ally_name`) REFERENCES `{$config->db_prefix}alliance` (`ally_name`) ON DELETE CASCADE ON UPDATE CASCADE
479 479
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;"
480
-    );
480
+      );
481 481
 
482
-    upd_alter_table('users', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true);
483
-    upd_alter_table('planets', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true);
482
+      upd_alter_table('users', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true);
483
+      upd_alter_table('planets', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true);
484 484
 
485
-    upd_create_table('bashing',
486
-      "(
485
+      upd_create_table('bashing',
486
+        "(
487 487
         `bashing_id` SERIAL,
488 488
         `bashing_user_id` bigint(11) UNSIGNED DEFAULT NULL,
489 489
         `bashing_planet_id` bigint(11) UNSIGNED DEFAULT NULL,
@@ -497,23 +497,23 @@  discard block
 block discarded – undo
497 497
         CONSTRAINT  `FK_bashing_user_id`   FOREIGN KEY (`bashing_user_id`)   REFERENCES `{$config->db_prefix}users`   (`id`) ON DELETE CASCADE ON UPDATE CASCADE
498 498
         ,CONSTRAINT `FK_bashing_planet_id` FOREIGN KEY (`bashing_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
499 499
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;"
500
-    );
500
+      );
501 501
 
502
-    upd_check_key('fleet_bashing_war_delay', 12 * 60 * 60, !isset($config->fleet_bashing_war_delay));
503
-    upd_check_key('fleet_bashing_scope', 24 * 60 * 60, !isset($config->fleet_bashing_scope));
504
-    upd_check_key('fleet_bashing_interval', 30 * 60, !isset($config->fleet_bashing_interval));
505
-    upd_check_key('fleet_bashing_waves', 3, !isset($config->fleet_bashing_waves));
506
-    upd_check_key('fleet_bashing_attacks', 3, !isset($config->fleet_bashing_attacks));
502
+      upd_check_key('fleet_bashing_war_delay', 12 * 60 * 60, !isset($config->fleet_bashing_war_delay));
503
+      upd_check_key('fleet_bashing_scope', 24 * 60 * 60, !isset($config->fleet_bashing_scope));
504
+      upd_check_key('fleet_bashing_interval', 30 * 60, !isset($config->fleet_bashing_interval));
505
+      upd_check_key('fleet_bashing_waves', 3, !isset($config->fleet_bashing_waves));
506
+      upd_check_key('fleet_bashing_attacks', 3, !isset($config->fleet_bashing_attacks));
507 507
 
508
-  upd_do_query('COMMIT;', true);
509
-  $new_version = 28;
508
+    upd_do_query('COMMIT;', true);
509
+    $new_version = 28;
510 510
 
511
-  case 28:
512
-  case 28.1:
513
-    upd_log_version_update();
511
+    case 28:
512
+    case 28.1:
513
+      upd_log_version_update();
514 514
 
515
-    upd_create_table('quest',
516
-      "(
515
+      upd_create_table('quest',
516
+        "(
517 517
         `quest_id` SERIAL,
518 518
         `quest_name` VARCHAR(255) DEFAULT NULL,
519 519
         `quest_description` TEXT,
@@ -525,10 +525,10 @@  discard block
 block discarded – undo
525 525
         PRIMARY KEY (`quest_id`)
526 526
         ,KEY (`quest_type`, `quest_order`)
527 527
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;"
528
-    );
528
+      );
529 529
 
530
-    upd_create_table('quest_status',
531
-      "(
530
+      upd_create_table('quest_status',
531
+        "(
532 532
         `quest_status_id` SERIAL,
533 533
         `quest_status_quest_id` bigint(20) UNSIGNED DEFAULT NULL,
534 534
         `quest_status_user_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
@@ -540,82 +540,82 @@  discard block
 block discarded – undo
540 540
         ,CONSTRAINT `FK_quest_status_quest_id` FOREIGN KEY (`quest_status_quest_id`) REFERENCES `{$config->db_prefix}quest` (`quest_id`) ON DELETE CASCADE ON UPDATE CASCADE
541 541
         ,CONSTRAINT `FK_quest_status_user_id`  FOREIGN KEY (`quest_status_user_id`)  REFERENCES `{$config->db_prefix}users` (`id`)       ON DELETE CASCADE ON UPDATE CASCADE
542 542
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;"
543
-    );
544
-
545
-    upd_check_key('quest_total', 0, !isset($config->quest_total));
546
-
547
-    for($i = 0; $i < 25; $i++)
548
-    {
549
-      upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]);
550
-      upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]);
551
-      upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]);
552
-    }
553
-
554
-    upd_alter_table('alliance', array('DROP INDEX `id`',), $update_indexes['alliance']['id']);
555
-    upd_alter_table('alliance', array('DROP INDEX `ally_name`',), $update_indexes['alliance']['ally_name']);
556
-    upd_alter_table('alliance', array('ADD UNIQUE INDEX `i_ally_tag` (`ally_tag`)',), !$update_indexes['alliance']['i_ally_tag']);
557
-    upd_alter_table('alliance', array('MODIFY COLUMN `ranklist` TEXT',), true);
543
+      );
558 544
 
559
-    upd_alter_table('users', array('DROP INDEX `id`',), $update_indexes['users']['id']);
560
-    upd_alter_table('users', "CHANGE COLUMN `rpg_points` `dark_matter` int(11) DEFAULT 0", $update_tables['users']['rpg_points']);
545
+      upd_check_key('quest_total', 0, !isset($config->quest_total));
561 546
 
562
-    upd_alter_table('users', array(
563
-      'DROP COLUMN `ally_request`',
564
-      'DROP COLUMN `ally_request_text`',
565
-    ), $update_tables['users']['ally_request_text']);
547
+      for($i = 0; $i < 25; $i++)
548
+      {
549
+        upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]);
550
+        upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]);
551
+        upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]);
552
+      }
566 553
 
567
-    upd_alter_table('users', array(
568
-      'ADD INDEX `i_ally_id` (`ally_id`)',
569
-      'ADD INDEX `i_ally_name` (`ally_name`)',
570
-    ), !$update_indexes['users']['i_ally_id']);
554
+      upd_alter_table('alliance', array('DROP INDEX `id`',), $update_indexes['alliance']['id']);
555
+      upd_alter_table('alliance', array('DROP INDEX `ally_name`',), $update_indexes['alliance']['ally_name']);
556
+      upd_alter_table('alliance', array('ADD UNIQUE INDEX `i_ally_tag` (`ally_tag`)',), !$update_indexes['alliance']['i_ally_tag']);
557
+      upd_alter_table('alliance', array('MODIFY COLUMN `ranklist` TEXT',), true);
571 558
 
572
-    upd_alter_table('users', array(
573
-      "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist"
574
-    ), !$update_tables['users']['msg_admin']);
559
+      upd_alter_table('users', array('DROP INDEX `id`',), $update_indexes['users']['id']);
560
+      upd_alter_table('users', "CHANGE COLUMN `rpg_points` `dark_matter` int(11) DEFAULT 0", $update_tables['users']['rpg_points']);
575 561
 
576
-    if(!$update_foreigns['users']['FK_users_ally_id'])
577
-    {
578 562
       upd_alter_table('users', array(
579
-        'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL',
580
-        'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL',
581
-      ), strtoupper($update_tables['users']['ally_id']['Type']) != 'BIGINT(20) UNSIGNED');
563
+        'DROP COLUMN `ally_request`',
564
+        'DROP COLUMN `ally_request_text`',
565
+      ), $update_tables['users']['ally_request_text']);
582 566
 
583
-      upd_do_query('DELETE FROM {{alliance}} WHERE id not in (select ally_id from {{users}} group by ally_id);');
584
-      upd_do_query("UPDATE {{users}} SET `ally_id` = null, ally_name = null, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` NOT IN (SELECT id FROM {{alliance}});");
585
-      upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;");
567
+      upd_alter_table('users', array(
568
+        'ADD INDEX `i_ally_id` (`ally_id`)',
569
+        'ADD INDEX `i_ally_name` (`ally_name`)',
570
+      ), !$update_indexes['users']['i_ally_id']);
586 571
 
587 572
       upd_alter_table('users', array(
588
-         "ADD CONSTRAINT `FK_users_ally_id` FOREIGN KEY (`ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
589
-         "ADD CONSTRAINT `FK_users_ally_name` FOREIGN KEY (`ally_name`) REFERENCES `{$config->db_prefix}alliance` (`ally_name`) ON DELETE SET NULL ON UPDATE CASCADE",
590
-      ), !$update_foreigns['users']['FK_users_ally_id']);
591
-    }
573
+        "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist"
574
+      ), !$update_tables['users']['msg_admin']);
592 575
 
593
-    upd_alter_table('planets', array(
594
-      "MODIFY COLUMN `debris_metal` BIGINT(20) UNSIGNED DEFAULT 0",
595
-      "MODIFY COLUMN `debris_crystal` BIGINT(20) UNSIGNED DEFAULT 0",
596
-    ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED');
576
+      if(!$update_foreigns['users']['FK_users_ally_id'])
577
+      {
578
+        upd_alter_table('users', array(
579
+          'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL',
580
+          'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL',
581
+        ), strtoupper($update_tables['users']['ally_id']['Type']) != 'BIGINT(20) UNSIGNED');
582
+
583
+        upd_do_query('DELETE FROM {{alliance}} WHERE id not in (select ally_id from {{users}} group by ally_id);');
584
+        upd_do_query("UPDATE {{users}} SET `ally_id` = null, ally_name = null, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` NOT IN (SELECT id FROM {{alliance}});");
585
+        upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;");
586
+
587
+        upd_alter_table('users', array(
588
+           "ADD CONSTRAINT `FK_users_ally_id` FOREIGN KEY (`ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
589
+           "ADD CONSTRAINT `FK_users_ally_name` FOREIGN KEY (`ally_name`) REFERENCES `{$config->db_prefix}alliance` (`ally_name`) ON DELETE SET NULL ON UPDATE CASCADE",
590
+        ), !$update_foreigns['users']['FK_users_ally_id']);
591
+      }
597 592
 
598
-    $illegal_moon_query = upd_do_query("SELECT id FROM `{{planets}}` WHERE `id_owner` <> 0 AND `planet_type` = 3 AND `parent_planet` <> 0 AND `parent_planet` NOT IN (SELECT `id` FROM {{planets}} WHERE `planet_type` = 1);");
599
-    while($illegal_moon_row = db_fetch($illegal_moon_query))
600
-    {
601
-      upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true);
602
-    }
593
+      upd_alter_table('planets', array(
594
+        "MODIFY COLUMN `debris_metal` BIGINT(20) UNSIGNED DEFAULT 0",
595
+        "MODIFY COLUMN `debris_crystal` BIGINT(20) UNSIGNED DEFAULT 0",
596
+      ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED');
603 597
 
604
-    upd_check_key('allow_buffing', isset($config->fleet_buffing_check) ? !$config->fleet_buffing_check : 0, !isset($config->allow_buffing));
605
-    upd_check_key('ally_help_weak', 0, !isset($config->ally_help_weak));
598
+      $illegal_moon_query = upd_do_query("SELECT id FROM `{{planets}}` WHERE `id_owner` <> 0 AND `planet_type` = 3 AND `parent_planet` <> 0 AND `parent_planet` NOT IN (SELECT `id` FROM {{planets}} WHERE `planet_type` = 1);");
599
+      while($illegal_moon_row = db_fetch($illegal_moon_query))
600
+      {
601
+        upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true);
602
+      }
606 603
 
607
-  upd_do_query('COMMIT;', true);
608
-  $new_version = 29;
604
+      upd_check_key('allow_buffing', isset($config->fleet_buffing_check) ? !$config->fleet_buffing_check : 0, !isset($config->allow_buffing));
605
+      upd_check_key('ally_help_weak', 0, !isset($config->ally_help_weak));
606
+
607
+    upd_do_query('COMMIT;', true);
608
+    $new_version = 29;
609 609
 
610
-  case 29:
611
-    upd_log_version_update();
610
+    case 29:
611
+      upd_log_version_update();
612 612
 
613
-    upd_check_key('game_email_pm', 0, !isset($config->game_email_pm));
614
-    upd_check_key('player_vacation_time', 2*24*60*60, !isset($config->player_vacation_time));
615
-    upd_check_key('player_delete_time', 45*24*60*60, !isset($config->player_delete_time));
613
+      upd_check_key('game_email_pm', 0, !isset($config->game_email_pm));
614
+      upd_check_key('player_vacation_time', 2*24*60*60, !isset($config->player_vacation_time));
615
+      upd_check_key('player_delete_time', 45*24*60*60, !isset($config->player_delete_time));
616 616
 
617
-    upd_create_table('log_dark_matter',
618
-      "(
617
+      upd_create_table('log_dark_matter',
618
+        "(
619 619
         `log_dark_matter_id` SERIAL,
620 620
         `log_dark_matter_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp',
621 621
         `log_dark_matter_username` varchar(64) NOT NULL DEFAULT '' COMMENT 'Username',
@@ -630,23 +630,23 @@  discard block
 block discarded – undo
630 630
         KEY `i_log_dark_matter_reason_sender_id` (`log_dark_matter_reason`, `log_dark_matter_sender`, `log_dark_matter_id`),
631 631
         KEY `i_log_dark_matter_amount` (`log_dark_matter_amount`)
632 632
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;"
633
-    );
634
-    upd_do_query('COMMIT;', true);
633
+      );
634
+      upd_do_query('COMMIT;', true);
635 635
 
636
-    $records = 1;
637
-    while($records)
638
-    {
639
-      upd_do_query('START TRANSACTION;', true);
640
-      $query = upd_do_query("SELECT * FROM {{logs}} WHERE log_code = 102 order by log_id LIMIT 1000;");
641
-      $records = db_num_rows($query);
642
-      while($row = db_fetch($query))
636
+      $records = 1;
637
+      while($records)
643 638
       {
644
-        $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches);
645
-
646
-        $reason = RPG_NONE;
647
-        $comment = $matches[3];
648
-        switch($matches[3])
639
+        upd_do_query('START TRANSACTION;', true);
640
+        $query = upd_do_query("SELECT * FROM {{logs}} WHERE log_code = 102 order by log_id LIMIT 1000;");
641
+        $records = db_num_rows($query);
642
+        while($row = db_fetch($query))
649 643
         {
644
+          $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches);
645
+
646
+          $reason = RPG_NONE;
647
+          $comment = $matches[3];
648
+          switch($matches[3])
649
+          {
650 650
           case 'Level Up For Structure Building':
651 651
             $reason = RPG_STRUCTURE;
652 652
           break;
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
               $comment = $matches2[1];
683 683
             }
684 684
           break;
685
-        }
685
+          }
686 686
 
687 687
         if($matches[2])
688 688
         {
@@ -720,595 +720,595 @@  discard block
 block discarded – undo
720 720
   upd_do_query('COMMIT;', true);
721 721
   $new_version = 30;
722 722
 
723
-  case 30:
724
-    upd_log_version_update();
723
+    case 30:
724
+      upd_log_version_update();
725 725
 
726
-    upd_alter_table('users', array(
727
-      "ADD `player_que` TEXT"
728
-    ), !$update_tables['users']['player_que']);
726
+      upd_alter_table('users', array(
727
+        "ADD `player_que` TEXT"
728
+      ), !$update_tables['users']['player_que']);
729 729
 
730
-    upd_alter_table('planets', array(
731
-      "CHANGE COLUMN `governor` `PLANET_GOVERNOR_ID` SMALLINT(5) NOT NULL DEFAULT 0",
732
-      "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0",
733
-    ), !$update_tables['planets']['PLANET_GOVERNOR_ID']);
730
+      upd_alter_table('planets', array(
731
+        "CHANGE COLUMN `governor` `PLANET_GOVERNOR_ID` SMALLINT(5) NOT NULL DEFAULT 0",
732
+        "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0",
733
+      ), !$update_tables['planets']['PLANET_GOVERNOR_ID']);
734 734
 
735
-    if($update_tables['users']['rpg_geologue'])
736
-    {
737
-      doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;");
735
+      if($update_tables['users']['rpg_geologue'])
736
+      {
737
+        doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;");
738
+
739
+        upd_alter_table('users', array(
740
+          "DROP COLUMN `rpg_geologue`",
741
+          "DROP COLUMN `rpg_ingenieur`",
742
+          "DROP COLUMN `rpg_constructeur`",
743
+          "DROP COLUMN `rpg_technocrate`",
744
+          "DROP COLUMN `rpg_scientifique`",
745
+          "DROP COLUMN `rpg_defenseur`",
746
+        ), $update_tables['users']['rpg_geologue']);
747
+      }
738 748
 
739
-      upd_alter_table('users', array(
740
-        "DROP COLUMN `rpg_geologue`",
741
-        "DROP COLUMN `rpg_ingenieur`",
742
-        "DROP COLUMN `rpg_constructeur`",
743
-        "DROP COLUMN `rpg_technocrate`",
744
-        "DROP COLUMN `rpg_scientifique`",
745
-        "DROP COLUMN `rpg_defenseur`",
746
-      ), $update_tables['users']['rpg_geologue']);
747
-    }
749
+      if($update_tables['users']['rpg_bunker'])
750
+      {
751
+        doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;");
748 752
 
749
-    if($update_tables['users']['rpg_bunker'])
750
-    {
751
-      doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;");
753
+        upd_alter_table('users', array(
754
+          "DROP COLUMN `rpg_bunker`",
755
+        ), $update_tables['users']['rpg_bunker']);
756
+      }
752 757
 
753 758
       upd_alter_table('users', array(
754
-        "DROP COLUMN `rpg_bunker`",
755
-      ), $update_tables['users']['rpg_bunker']);
756
-    }
759
+        "DROP COLUMN `p_infligees`",
760
+        "MODIFY COLUMN `dark_matter` BIGINT(20) DEFAULT '0' AFTER `lvl_raid`",
761
+      ), $update_tables['users']['p_infligees']);
757 762
 
758
-    upd_alter_table('users', array(
759
-      "DROP COLUMN `p_infligees`",
760
-      "MODIFY COLUMN `dark_matter` BIGINT(20) DEFAULT '0' AFTER `lvl_raid`",
761
-    ), $update_tables['users']['p_infligees']);
762
-
763
-    upd_alter_table('users', array(
764
-      "ADD COLUMN `mrc_academic` SMALLINT(3) DEFAULT 0",
765
-    ), !$update_tables['users']['mrc_academic']);
766
-
767
-    upd_alter_table('users', array(
768
-      "DROP COLUMN `db_deaktjava`",
769
-      "DROP COLUMN `kolorminus`",
770
-      "DROP COLUMN `kolorplus`",
771
-      "DROP COLUMN `kolorpoziom`",
772
-      "DROP COLUMN `deleteme`",
773
-
774
-      "MODIFY COLUMN `xpraid` BIGINT(20) UNSIGNED DEFAULT '0'",
775
-      "MODIFY COLUMN `xpminier` BIGINT(20) UNSIGNED DEFAULT '0'",
776
-      "MODIFY COLUMN `raids` BIGINT(20) UNSIGNED DEFAULT '0'",
777
-      "MODIFY COLUMN `raidsloose` BIGINT(20) UNSIGNED DEFAULT '0'",
778
-      "MODIFY COLUMN `raidswin` BIGINT(20) UNSIGNED DEFAULT '0'",
779
-
780
-      "MODIFY COLUMN `register_time` INT(10) UNSIGNED DEFAULT '0'",
781
-      "MODIFY COLUMN `onlinetime` INT(10) UNSIGNED DEFAULT '0'",
782
-      "MODIFY COLUMN `news_lastread` INT(10) UNSIGNED DEFAULT '0'",
783
-      "MODIFY COLUMN `deltime` INT(10) UNSIGNED DEFAULT '0'",
784
-      "MODIFY COLUMN `banaday` INT(10) UNSIGNED DEFAULT '0'",
785
-      "MODIFY COLUMN `vacation` INT(10) UNSIGNED DEFAULT '0'",
786
-    ), strtoupper($update_tables['users']['xpraid']['Type']) != 'BIGINT(20) UNSIGNED');
787
-
788
-    upd_alter_table('users', array(
789
-      "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0",
790
-      "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0",
791
-    ), !isset($update_tables['users']['total_rank']));
792
-    doquery("UPDATE {{users}} AS u JOIN {{statpoints}} AS sp ON sp.id_owner = u.id AND sp.stat_code = 1 AND sp.stat_type = 1 SET u.total_rank = sp.total_rank, u.total_points = sp.total_points;");
793
-
794
-    upd_alter_table('alliance', array(
795
-      "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0",
796
-      "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0",
797
-    ), !isset($update_tables['alliance']['total_rank']));
798
-    doquery("UPDATE {{alliance}} AS a JOIN {{statpoints}} AS sp ON sp.id_owner = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;");
799
-
800
-    if(!isset($update_tables['users']['ally_tag']))
801
-    {
802 763
       upd_alter_table('users', array(
803
-        "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`",
804
-      ), !isset($update_tables['users']['ally_tag']));
805
-      doquery("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON a.id = u.ally_id SET u.ally_tag = a.ally_tag, u.ally_name = a.ally_name;");
806
-      doquery("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON a.id = u.ally_id SET u.ally_id = NULL, u.ally_tag = NULL, u.ally_name = NULL, u.ally_register_time = 0, ally_rank_id = 0 WHERE a.id is NULL;");
764
+        "ADD COLUMN `mrc_academic` SMALLINT(3) DEFAULT 0",
765
+      ), !$update_tables['users']['mrc_academic']);
766
+
807 767
       upd_alter_table('users', array(
808
-        "ADD CONSTRAINT `FK_users_ally_tag` FOREIGN KEY (`ally_tag`) REFERENCES `{$config->db_prefix}alliance` (`ally_tag`) ON DELETE SET NULL ON UPDATE CASCADE",
809
-      ), !$update_foreigns['users']['FK_users_ally_tag']);
810
-    }
768
+        "DROP COLUMN `db_deaktjava`",
769
+        "DROP COLUMN `kolorminus`",
770
+        "DROP COLUMN `kolorplus`",
771
+        "DROP COLUMN `kolorpoziom`",
772
+        "DROP COLUMN `deleteme`",
773
+
774
+        "MODIFY COLUMN `xpraid` BIGINT(20) UNSIGNED DEFAULT '0'",
775
+        "MODIFY COLUMN `xpminier` BIGINT(20) UNSIGNED DEFAULT '0'",
776
+        "MODIFY COLUMN `raids` BIGINT(20) UNSIGNED DEFAULT '0'",
777
+        "MODIFY COLUMN `raidsloose` BIGINT(20) UNSIGNED DEFAULT '0'",
778
+        "MODIFY COLUMN `raidswin` BIGINT(20) UNSIGNED DEFAULT '0'",
779
+
780
+        "MODIFY COLUMN `register_time` INT(10) UNSIGNED DEFAULT '0'",
781
+        "MODIFY COLUMN `onlinetime` INT(10) UNSIGNED DEFAULT '0'",
782
+        "MODIFY COLUMN `news_lastread` INT(10) UNSIGNED DEFAULT '0'",
783
+        "MODIFY COLUMN `deltime` INT(10) UNSIGNED DEFAULT '0'",
784
+        "MODIFY COLUMN `banaday` INT(10) UNSIGNED DEFAULT '0'",
785
+        "MODIFY COLUMN `vacation` INT(10) UNSIGNED DEFAULT '0'",
786
+      ), strtoupper($update_tables['users']['xpraid']['Type']) != 'BIGINT(20) UNSIGNED');
811 787
 
812
-    upd_alter_table('users', array(
813
-      "ADD COLUMN `player_artifact_list` TEXT",
814
-    ), !isset($update_tables['users']['player_artifact_list']));
788
+      upd_alter_table('users', array(
789
+        "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0",
790
+        "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0",
791
+      ), !isset($update_tables['users']['total_rank']));
792
+      doquery("UPDATE {{users}} AS u JOIN {{statpoints}} AS sp ON sp.id_owner = u.id AND sp.stat_code = 1 AND sp.stat_type = 1 SET u.total_rank = sp.total_rank, u.total_points = sp.total_points;");
815 793
 
816
-    if(!isset($update_tables['users']['player_rpg_tech_xp']))
817
-    {
818
-      upd_check_key('eco_scale_storage', 1, !isset($config->eco_scale_storage));
794
+      upd_alter_table('alliance', array(
795
+        "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0",
796
+        "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0",
797
+      ), !isset($update_tables['alliance']['total_rank']));
798
+      doquery("UPDATE {{alliance}} AS a JOIN {{statpoints}} AS sp ON sp.id_owner = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;");
799
+
800
+      if(!isset($update_tables['users']['ally_tag']))
801
+      {
802
+        upd_alter_table('users', array(
803
+          "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`",
804
+        ), !isset($update_tables['users']['ally_tag']));
805
+        doquery("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON a.id = u.ally_id SET u.ally_tag = a.ally_tag, u.ally_name = a.ally_name;");
806
+        doquery("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON a.id = u.ally_id SET u.ally_id = NULL, u.ally_tag = NULL, u.ally_name = NULL, u.ally_register_time = 0, ally_rank_id = 0 WHERE a.id is NULL;");
807
+        upd_alter_table('users', array(
808
+          "ADD CONSTRAINT `FK_users_ally_tag` FOREIGN KEY (`ally_tag`) REFERENCES `{$config->db_prefix}alliance` (`ally_tag`) ON DELETE SET NULL ON UPDATE CASCADE",
809
+        ), !$update_foreigns['users']['FK_users_ally_tag']);
810
+      }
819 811
 
820 812
       upd_alter_table('users', array(
821
-        "ADD COLUMN `player_rpg_tech_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
822
-        "ADD COLUMN `player_rpg_tech_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
823
-      ), !isset($update_tables['users']['player_rpg_tech_xp']));
813
+        "ADD COLUMN `player_artifact_list` TEXT",
814
+      ), !isset($update_tables['users']['player_artifact_list']));
824 815
 
825
-      doquery("UPDATE {{users}} AS u LEFT JOIN {{statpoints}} AS s ON s.id_owner = u.id AND s.stat_type = 1 AND s.stat_code = 1 SET u.player_rpg_tech_xp = s.tech_points;");
826
-    }
816
+      if(!isset($update_tables['users']['player_rpg_tech_xp']))
817
+      {
818
+        upd_check_key('eco_scale_storage', 1, !isset($config->eco_scale_storage));
827 819
 
828
-    upd_alter_table('planets', array(
829
-      "ADD COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `big_ship_cargo`",
830
-    ), !isset($update_tables['planets']['planet_cargo_hyper']));
820
+        upd_alter_table('users', array(
821
+          "ADD COLUMN `player_rpg_tech_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
822
+          "ADD COLUMN `player_rpg_tech_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
823
+        ), !isset($update_tables['users']['player_rpg_tech_xp']));
831 824
 
832
-  upd_do_query('COMMIT;', true);
833
-  $new_version = 31;
825
+        doquery("UPDATE {{users}} AS u LEFT JOIN {{statpoints}} AS s ON s.id_owner = u.id AND s.stat_type = 1 AND s.stat_code = 1 SET u.player_rpg_tech_xp = s.tech_points;");
826
+      }
834 827
 
835
-  case 31:
836
-    upd_log_version_update();
828
+      upd_alter_table('planets', array(
829
+        "ADD COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `big_ship_cargo`",
830
+      ), !isset($update_tables['planets']['planet_cargo_hyper']));
837 831
 
838
-    upd_alter_table('aks', array(
839
-      "MODIFY COLUMN `planet_type` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0",
840
-    ), strtoupper($update_tables['aks']['planet_type']['Type']) != 'TINYINT(1) UNSIGNED');
832
+    upd_do_query('COMMIT;', true);
833
+    $new_version = 31;
841 834
 
842
-    upd_alter_table('alliance', array(
843
-      "MODIFY COLUMN `ally_request_notallow` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0",
844
-      "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
845
-    ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED');
835
+    case 31:
836
+      upd_log_version_update();
846 837
 
847
-    if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED')
848
-    {
849
-      upd_alter_table('alliance_diplomacy', array(
850
-        "DROP FOREIGN KEY `FK_diplomacy_ally_id`",
851
-        "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`"
852
-      ), true);
853
-
854
-      upd_alter_table('alliance_diplomacy', array(
855
-        "MODIFY COLUMN `alliance_diplomacy_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL",
856
-        "MODIFY COLUMN `alliance_diplomacy_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL",
857
-
858
-        "ADD CONSTRAINT `FK_diplomacy_ally_id`       FOREIGN KEY (`alliance_diplomacy_ally_id`)       REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
859
-        "ADD CONSTRAINT `FK_diplomacy_contr_ally_id` FOREIGN KEY (`alliance_diplomacy_contr_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
860
-      ), true);
861
-    }
838
+      upd_alter_table('aks', array(
839
+        "MODIFY COLUMN `planet_type` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0",
840
+      ), strtoupper($update_tables['aks']['planet_type']['Type']) != 'TINYINT(1) UNSIGNED');
862 841
 
863
-    if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED')
864
-    {
865
-      upd_alter_table('alliance_negotiation', array(
866
-        "DROP FOREIGN KEY `FK_negotiation_ally_id`",
867
-        "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`"
868
-      ), true);
869
-
870
-      upd_alter_table('alliance_negotiation', array(
871
-        "MODIFY COLUMN `alliance_negotiation_status` TINYINT(1) NOT NULL DEFAULT 0",
872
-        "MODIFY COLUMN `alliance_negotiation_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL",
873
-        "MODIFY COLUMN `alliance_negotiation_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL",
874
-
875
-        "ADD CONSTRAINT `FK_negotiation_ally_id`       FOREIGN KEY (`alliance_negotiation_ally_id`)       REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
876
-        "ADD CONSTRAINT `FK_negotiation_contr_ally_id` FOREIGN KEY (`alliance_negotiation_contr_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
877
-      ), true);
878
-    }
842
+      upd_alter_table('alliance', array(
843
+        "MODIFY COLUMN `ally_request_notallow` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0",
844
+        "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
845
+      ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED');
879 846
 
880
-    if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED')
881
-    {
882
-      upd_do_query('DELETE FROM {{alliance_requests}} WHERE id_user NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true);
847
+      if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED')
848
+      {
849
+        upd_alter_table('alliance_diplomacy', array(
850
+          "DROP FOREIGN KEY `FK_diplomacy_ally_id`",
851
+          "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`"
852
+        ), true);
853
+
854
+        upd_alter_table('alliance_diplomacy', array(
855
+          "MODIFY COLUMN `alliance_diplomacy_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL",
856
+          "MODIFY COLUMN `alliance_diplomacy_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL",
857
+
858
+          "ADD CONSTRAINT `FK_diplomacy_ally_id`       FOREIGN KEY (`alliance_diplomacy_ally_id`)       REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
859
+          "ADD CONSTRAINT `FK_diplomacy_contr_ally_id` FOREIGN KEY (`alliance_diplomacy_contr_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
860
+        ), true);
861
+      }
883 862
 
884
-      upd_alter_table('alliance_requests', array(
885
-        "MODIFY COLUMN `id_user` BIGINT(20) UNSIGNED DEFAULT NULL",
886
-        "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL",
863
+      if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED')
864
+      {
865
+        upd_alter_table('alliance_negotiation', array(
866
+          "DROP FOREIGN KEY `FK_negotiation_ally_id`",
867
+          "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`"
868
+        ), true);
869
+
870
+        upd_alter_table('alliance_negotiation', array(
871
+          "MODIFY COLUMN `alliance_negotiation_status` TINYINT(1) NOT NULL DEFAULT 0",
872
+          "MODIFY COLUMN `alliance_negotiation_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL",
873
+          "MODIFY COLUMN `alliance_negotiation_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL",
874
+
875
+          "ADD CONSTRAINT `FK_negotiation_ally_id`       FOREIGN KEY (`alliance_negotiation_ally_id`)       REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
876
+          "ADD CONSTRAINT `FK_negotiation_contr_ally_id` FOREIGN KEY (`alliance_negotiation_contr_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
877
+        ), true);
878
+      }
887 879
 
888
-        "ADD KEY `I_alliance_requests_id_ally` (`id_ally`, `id_user`)",
880
+      if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED')
881
+      {
882
+        upd_do_query('DELETE FROM {{alliance_requests}} WHERE id_user NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true);
889 883
 
890
-        "ADD CONSTRAINT `FK_alliance_request_user_id` FOREIGN KEY (`id_user`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
891
-        "ADD CONSTRAINT `FK_alliance_request_ally_id` FOREIGN KEY (`id_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
892
-      ), true);
893
-    }
884
+        upd_alter_table('alliance_requests', array(
885
+          "MODIFY COLUMN `id_user` BIGINT(20) UNSIGNED DEFAULT NULL",
886
+          "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL",
894 887
 
895
-    if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED')
896
-    {
897
-      upd_do_query('DELETE FROM {{annonce}} WHERE user NOT IN (SELECT username FROM {{users}});', true);
888
+          "ADD KEY `I_alliance_requests_id_ally` (`id_ally`, `id_user`)",
898 889
 
899
-      upd_alter_table('annonce', array(
900
-        "MODIFY COLUMN `id` SERIAL",
901
-        "MODIFY COLUMN `user` VARCHAR(64) DEFAULT NULL",
890
+          "ADD CONSTRAINT `FK_alliance_request_user_id` FOREIGN KEY (`id_user`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
891
+          "ADD CONSTRAINT `FK_alliance_request_ally_id` FOREIGN KEY (`id_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
892
+        ), true);
893
+      }
902 894
 
903
-        "ADD KEY `I_annonce_user` (`user`, `id`)",
895
+      if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED')
896
+      {
897
+        upd_do_query('DELETE FROM {{annonce}} WHERE user NOT IN (SELECT username FROM {{users}});', true);
904 898
 
905
-        "ADD CONSTRAINT `FK_annonce_user` FOREIGN KEY (`user`) REFERENCES `{$config->db_prefix}users` (`username`) ON DELETE CASCADE ON UPDATE CASCADE",
906
-      ), true);
907
-    }
899
+        upd_alter_table('annonce', array(
900
+          "MODIFY COLUMN `id` SERIAL",
901
+          "MODIFY COLUMN `user` VARCHAR(64) DEFAULT NULL",
908 902
 
909
-    if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED')
910
-    {
911
-      upd_alter_table('bashing', array(
912
-        "DROP FOREIGN KEY `FK_bashing_user_id`",
913
-        "DROP FOREIGN KEY `FK_bashing_planet_id`",
914
-      ), true);
915
-
916
-      upd_alter_table('bashing', array(
917
-        "MODIFY COLUMN `bashing_user_id` BIGINT(20) UNSIGNED DEFAULT NULL",
918
-        "MODIFY COLUMN `bashing_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL",
919
-
920
-        "ADD CONSTRAINT `FK_bashing_user_id`   FOREIGN KEY (`bashing_user_id`)   REFERENCES `{$config->db_prefix}users`   (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
921
-        "ADD CONSTRAINT `FK_bashing_planet_id` FOREIGN KEY (`bashing_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
922
-      ), true);
923
-    }
903
+          "ADD KEY `I_annonce_user` (`user`, `id`)",
924 904
 
925
-    if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED')
926
-    {
927
-      upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR owner NOT IN (SELECT id FROM {{users}});', true);
905
+          "ADD CONSTRAINT `FK_annonce_user` FOREIGN KEY (`user`) REFERENCES `{$config->db_prefix}users` (`username`) ON DELETE CASCADE ON UPDATE CASCADE",
906
+        ), true);
907
+      }
928 908
 
929
-      upd_alter_table('buddy', array(
930
-        "MODIFY COLUMN `id` SERIAL",
931
-        "MODIFY COLUMN `sender` BIGINT(20) UNSIGNED DEFAULT NULL",
932
-        "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL",
933
-        "MODIFY COLUMN `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0",
909
+      if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED')
910
+      {
911
+        upd_alter_table('bashing', array(
912
+          "DROP FOREIGN KEY `FK_bashing_user_id`",
913
+          "DROP FOREIGN KEY `FK_bashing_planet_id`",
914
+        ), true);
915
+
916
+        upd_alter_table('bashing', array(
917
+          "MODIFY COLUMN `bashing_user_id` BIGINT(20) UNSIGNED DEFAULT NULL",
918
+          "MODIFY COLUMN `bashing_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL",
919
+
920
+          "ADD CONSTRAINT `FK_bashing_user_id`   FOREIGN KEY (`bashing_user_id`)   REFERENCES `{$config->db_prefix}users`   (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
921
+          "ADD CONSTRAINT `FK_bashing_planet_id` FOREIGN KEY (`bashing_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
922
+        ), true);
923
+      }
934 924
 
935
-        "ADD KEY `I_buddy_sender` (`sender`)",
936
-        "ADD KEY `I_buddy_owner` (`owner`)",
925
+      if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED')
926
+      {
927
+        upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR owner NOT IN (SELECT id FROM {{users}});', true);
937 928
 
938
-        "ADD CONSTRAINT `FK_buddy_sender_id` FOREIGN KEY (`sender`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
939
-        "ADD CONSTRAINT `FK_buddy_owner_id`  FOREIGN KEY (`owner`)  REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
940
-      ), true);
941
-    }
929
+        upd_alter_table('buddy', array(
930
+          "MODIFY COLUMN `id` SERIAL",
931
+          "MODIFY COLUMN `sender` BIGINT(20) UNSIGNED DEFAULT NULL",
932
+          "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL",
933
+          "MODIFY COLUMN `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0",
942 934
 
943
-    upd_alter_table('chat', array(
944
-      "MODIFY COLUMN `messageid` SERIAL",
945
-    ), strtoupper($update_tables['chat']['messageid']['Type']) != 'BIGINT(20) UNSIGNED');
935
+          "ADD KEY `I_buddy_sender` (`sender`)",
936
+          "ADD KEY `I_buddy_owner` (`owner`)",
946 937
 
947
-    upd_alter_table('counter', array(
948
-      "CHANGE COLUMN `id` `counter_id` SERIAL",
938
+          "ADD CONSTRAINT `FK_buddy_sender_id` FOREIGN KEY (`sender`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
939
+          "ADD CONSTRAINT `FK_buddy_owner_id`  FOREIGN KEY (`owner`)  REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
940
+        ), true);
941
+      }
949 942
 
950
-      "MODIFY COLUMN `user_id` BIGINT(20) UNSIGNED DEFAULT 0",
943
+      upd_alter_table('chat', array(
944
+        "MODIFY COLUMN `messageid` SERIAL",
945
+      ), strtoupper($update_tables['chat']['messageid']['Type']) != 'BIGINT(20) UNSIGNED');
951 946
 
952
-      "ADD COLUMN `user_name` VARCHAR(64) DEFAULT '' AFTER `user_id`",
947
+      upd_alter_table('counter', array(
948
+        "CHANGE COLUMN `id` `counter_id` SERIAL",
953 949
 
954
-      "ADD KEY `I_counter_user_name` (`user_name`)",
955
-    ), strtoupper($update_tables['counter']['counter_id']['Type']) != 'BIGINT(20) UNSIGNED');
950
+        "MODIFY COLUMN `user_id` BIGINT(20) UNSIGNED DEFAULT 0",
956 951
 
957
-    upd_alter_table('fleets', array(
958
-      "MODIFY COLUMN `fleet_id` SERIAL",
959
-      "MODIFY COLUMN `fleet_resource_metal` DECIMAL(65,0) DEFAULT '0'",
960
-      "MODIFY COLUMN `fleet_resource_crystal` DECIMAL(65,0) DEFAULT '0'",
961
-      "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'",
962
-    ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)');
952
+        "ADD COLUMN `user_name` VARCHAR(64) DEFAULT '' AFTER `user_id`",
963 953
 
964
-    if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED')
965
-    {
966
-      upd_do_query('DELETE FROM {{iraks}} WHERE owner NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true);
954
+        "ADD KEY `I_counter_user_name` (`user_name`)",
955
+      ), strtoupper($update_tables['counter']['counter_id']['Type']) != 'BIGINT(20) UNSIGNED');
967 956
 
968
-      upd_alter_table('iraks', array(
969
-        "CHANGE COLUMN `zeit` `fleet_end_time` INT(11) UNSIGNED NOT NULL DEFAULT 0",
970
-        "CHANGE COLUMN `zielid` `fleet_target_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
971
-        "CHANGE COLUMN `owner` `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
972
-        "CHANGE COLUMN `anzahl` `fleet_amount` BIGINT(20) UNSIGNED DEFAULT 0",
973
-        "CHANGE COLUMN `galaxy_angreifer` `fleet_start_galaxy` INT(2) UNSIGNED DEFAULT 0",
974
-        "CHANGE COLUMN `system_angreifer` `fleet_start_system` INT(4) UNSIGNED DEFAULT 0",
975
-        "CHANGE COLUMN `planet_angreifer` `fleet_start_planet` INT(2) UNSIGNED DEFAULT 0",
976
-
977
-        "CHANGE COLUMN `galaxy` `fleet_end_galaxy` INT(2) UNSIGNED DEFAULT 0",
978
-        "CHANGE COLUMN `system` `fleet_end_system` INT(4) UNSIGNED DEFAULT 0",
979
-        "CHANGE COLUMN `planet` `fleet_end_planet` INT(2) UNSIGNED DEFAULT 0",
980
-
981
-        "ADD KEY `I_iraks_fleet_owner` (`fleet_owner`)",
982
-        "ADD KEY `I_iraks_fleet_target_owner` (`fleet_target_owner`)",
983
-
984
-        "ADD CONSTRAINT `FK_iraks_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
985
-        "ADD CONSTRAINT `FK_iraks_fleet_target_owner` FOREIGN KEY (`fleet_target_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
986
-      ), true);
987
-    }
957
+      upd_alter_table('fleets', array(
958
+        "MODIFY COLUMN `fleet_id` SERIAL",
959
+        "MODIFY COLUMN `fleet_resource_metal` DECIMAL(65,0) DEFAULT '0'",
960
+        "MODIFY COLUMN `fleet_resource_crystal` DECIMAL(65,0) DEFAULT '0'",
961
+        "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'",
962
+      ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)');
988 963
 
989
-    if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED')
990
-    {
991
-      upd_do_query('DELETE FROM {{notes}} WHERE owner NOT IN (SELECT id FROM {{users}});', true);
964
+      if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED')
965
+      {
966
+        upd_do_query('DELETE FROM {{iraks}} WHERE owner NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true);
967
+
968
+        upd_alter_table('iraks', array(
969
+          "CHANGE COLUMN `zeit` `fleet_end_time` INT(11) UNSIGNED NOT NULL DEFAULT 0",
970
+          "CHANGE COLUMN `zielid` `fleet_target_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
971
+          "CHANGE COLUMN `owner` `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
972
+          "CHANGE COLUMN `anzahl` `fleet_amount` BIGINT(20) UNSIGNED DEFAULT 0",
973
+          "CHANGE COLUMN `galaxy_angreifer` `fleet_start_galaxy` INT(2) UNSIGNED DEFAULT 0",
974
+          "CHANGE COLUMN `system_angreifer` `fleet_start_system` INT(4) UNSIGNED DEFAULT 0",
975
+          "CHANGE COLUMN `planet_angreifer` `fleet_start_planet` INT(2) UNSIGNED DEFAULT 0",
976
+
977
+          "CHANGE COLUMN `galaxy` `fleet_end_galaxy` INT(2) UNSIGNED DEFAULT 0",
978
+          "CHANGE COLUMN `system` `fleet_end_system` INT(4) UNSIGNED DEFAULT 0",
979
+          "CHANGE COLUMN `planet` `fleet_end_planet` INT(2) UNSIGNED DEFAULT 0",
980
+
981
+          "ADD KEY `I_iraks_fleet_owner` (`fleet_owner`)",
982
+          "ADD KEY `I_iraks_fleet_target_owner` (`fleet_target_owner`)",
983
+
984
+          "ADD CONSTRAINT `FK_iraks_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
985
+          "ADD CONSTRAINT `FK_iraks_fleet_target_owner` FOREIGN KEY (`fleet_target_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
986
+        ), true);
987
+      }
992 988
 
993
-      upd_alter_table('notes', array(
994
-        "MODIFY COLUMN id SERIAL",
995
-        "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL",
989
+      if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED')
990
+      {
991
+        upd_do_query('DELETE FROM {{notes}} WHERE owner NOT IN (SELECT id FROM {{users}});', true);
996 992
 
997
-        "ADD KEY `I_notes_owner` (`owner`)",
993
+        upd_alter_table('notes', array(
994
+          "MODIFY COLUMN id SERIAL",
995
+          "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL",
998 996
 
999
-        "ADD CONSTRAINT `FK_notes_owner` FOREIGN KEY (`owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1000
-      ), true);
1001
-    }
997
+          "ADD KEY `I_notes_owner` (`owner`)",
1002 998
 
1003
-    upd_alter_table('planets', array(
1004
-      "MODIFY COLUMN `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT",
1005
-      "MODIFY COLUMN `name` VARCHAR(64) DEFAULT 'Planet' NOT NULL",
1006
-      "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
1007
-      "MODIFY COLUMN `galaxy` SMALLINT NOT NULL DEFAULT '0'",
1008
-      "MODIFY COLUMN `system` SMALLINT NOT NULL DEFAULT '0'",
1009
-      "MODIFY COLUMN `planet` SMALLINT NOT NULL DEFAULT '0'",
1010
-      "MODIFY COLUMN `planet_type` TINYINT NOT NULL DEFAULT '1'",
1011
-
1012
-      "MODIFY COLUMN `metal` DECIMAL(65,5) NOT NULL DEFAULT '0'",
1013
-      "MODIFY COLUMN `crystal` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `metal`",
1014
-      "MODIFY COLUMN `deuterium` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `crystal`",
1015
-      "MODIFY COLUMN `energy_max` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `deuterium`",
1016
-      "MODIFY COLUMN `energy_used` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `energy_max`",
1017
-
1018
-      "MODIFY COLUMN `metal_mine` SMALLINT NOT NULL DEFAULT '0'",
1019
-      "MODIFY COLUMN `crystal_mine` SMALLINT NOT NULL DEFAULT '0'",
1020
-      "MODIFY COLUMN `deuterium_sintetizer` SMALLINT NOT NULL DEFAULT '0'",
1021
-      "MODIFY COLUMN `solar_plant` SMALLINT NOT NULL DEFAULT '0'",
1022
-      "MODIFY COLUMN `fusion_plant` SMALLINT NOT NULL DEFAULT '0'",
1023
-      "MODIFY COLUMN `robot_factory` SMALLINT NOT NULL DEFAULT '0'",
1024
-      "MODIFY COLUMN `nano_factory` SMALLINT NOT NULL DEFAULT '0'",
1025
-      "MODIFY COLUMN `hangar` SMALLINT NOT NULL DEFAULT '0'",
1026
-      "MODIFY COLUMN `metal_store` SMALLINT NOT NULL DEFAULT '0'",
1027
-      "MODIFY COLUMN `crystal_store` SMALLINT NOT NULL DEFAULT '0'",
1028
-      "MODIFY COLUMN `deuterium_store` SMALLINT NOT NULL DEFAULT '0'",
1029
-      "MODIFY COLUMN `laboratory` SMALLINT NOT NULL DEFAULT '0'",
1030
-      "MODIFY COLUMN `nano` SMALLINT DEFAULT '0' AFTER `laboratory`",
1031
-      "MODIFY COLUMN `terraformer` SMALLINT NOT NULL DEFAULT '0'",
1032
-      "MODIFY COLUMN `ally_deposit` SMALLINT NOT NULL DEFAULT '0'",
1033
-      "MODIFY COLUMN `silo` SMALLINT NOT NULL DEFAULT '0'",
1034
-      "MODIFY COLUMN `mondbasis` SMALLINT NOT NULL DEFAULT '0' AFTER `silo`",
1035
-      "MODIFY COLUMN `phalanx` SMALLINT NOT NULL DEFAULT '0' AFTER `mondbasis`",
1036
-      "MODIFY COLUMN `sprungtor` SMALLINT NOT NULL DEFAULT '0' AFTER `phalanx`",
1037
-      "MODIFY COLUMN `last_jump_time` int(11) NOT NULL DEFAULT '0' AFTER `sprungtor`",
1038
-
1039
-      "MODIFY COLUMN `small_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1040
-      "MODIFY COLUMN `big_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1041
-      "MODIFY COLUMN `supercargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count' AFTER `big_ship_cargo`",
1042
-      "MODIFY COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `supercargo`",
1043
-      "MODIFY COLUMN `recycler` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `planet_cargo_hyper`",
1044
-      "MODIFY COLUMN `colonizer` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `recycler`",
1045
-      "MODIFY COLUMN `spy_sonde` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `colonizer`",
1046
-      "MODIFY COLUMN `solar_satelit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `spy_sonde`",
1047
-
1048
-      "MODIFY COLUMN `light_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1049
-      "MODIFY COLUMN `heavy_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1050
-      "MODIFY COLUMN `crusher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1051
-      "MODIFY COLUMN `battle_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1052
-      "MODIFY COLUMN `bomber_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1053
-      "MODIFY COLUMN `battleship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `bomber_ship`",
1054
-      "MODIFY COLUMN `destructor` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1055
-      "MODIFY COLUMN `dearth_star` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1056
-      "MODIFY COLUMN `supernova` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1057
-
1058
-      "MODIFY COLUMN `misil_launcher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1059
-      "MODIFY COLUMN `small_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1060
-      "MODIFY COLUMN `big_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1061
-      "MODIFY COLUMN `gauss_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1062
-      "MODIFY COLUMN `ionic_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1063
-      "MODIFY COLUMN `buster_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1064
-
1065
-      "MODIFY COLUMN `small_protection_shield` tinyint(1) NOT NULL DEFAULT '0'",
1066
-      "MODIFY COLUMN `big_protection_shield` tinyint(1) NOT NULL DEFAULT '0'",
1067
-      "MODIFY COLUMN `planet_protector` tinyint(1) NOT NULL DEFAULT '0'",
1068
-
1069
-      "MODIFY COLUMN `interceptor_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1070
-      "MODIFY COLUMN `interplanetary_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1071
-
1072
-      "MODIFY COLUMN `metal_perhour` INT NOT NULL DEFAULT '0' AFTER `interplanetary_misil`",
1073
-      "MODIFY COLUMN `crystal_perhour` INT NOT NULL DEFAULT '0' AFTER `metal_perhour`",
1074
-      "MODIFY COLUMN `deuterium_perhour` INT NOT NULL DEFAULT '0' AFTER `crystal_perhour`",
1075
-
1076
-      "MODIFY COLUMN `metal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'",
1077
-      "MODIFY COLUMN `crystal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'",
1078
-      "MODIFY COLUMN `deuterium_sintetizer_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'",
1079
-      "MODIFY COLUMN `solar_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'",
1080
-      "MODIFY COLUMN `fusion_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'",
1081
-      "MODIFY COLUMN `solar_satelit_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'",
1082
-
1083
-      "MODIFY COLUMN `que` TEXT COMMENT 'Planet que' AFTER `solar_satelit_porcent`",
1084
-//      "MODIFY COLUMN `b_tech` INT(11) NOT NULL DEFAULT 0 AFTER `que`",
1085
-//      "MODIFY COLUMN `b_tech_id` SMALLINT NOT NULL DEFAULT 0 AFTER `b_tech`",
1086
-      "MODIFY COLUMN `b_hangar` INT(11) NOT NULL DEFAULT '0' AFTER `que`",
1087
-      "MODIFY COLUMN `b_hangar_id` TEXT AFTER `b_hangar`",
1088
-      "MODIFY COLUMN `last_update` INT(11) DEFAULT NULL AFTER `b_hangar_id`",
1089
-
1090
-      "MODIFY COLUMN `image` varchar(64) NOT NULL DEFAULT 'normaltempplanet01' AFTER `last_update`",
1091
-      "MODIFY COLUMN `points` bigint(20) DEFAULT '0' AFTER `image`",
1092
-      "MODIFY COLUMN `ranks` bigint(20) DEFAULT '0' AFTER `points`",
1093
-      "MODIFY COLUMN `id_level` TINYINT NOT NULL DEFAULT '0' AFTER `ranks`",
1094
-      "MODIFY COLUMN `destruyed` int(11) NOT NULL DEFAULT '0' AFTER `id_level`",
1095
-      "MODIFY COLUMN `diameter` int(11) NOT NULL DEFAULT '12800' AFTER `destruyed`",
1096
-      "MODIFY COLUMN `field_max` SMALLINT UNSIGNED NOT NULL DEFAULT '163' AFTER `diameter`",
1097
-      "MODIFY COLUMN `field_current` SMALLINT UNSIGNED NOT NULL DEFAULT '0' AFTER `field_max`",
1098
-      "MODIFY COLUMN `temp_min` SMALLINT NOT NULL DEFAULT '0' AFTER `field_current`",
1099
-      "MODIFY COLUMN `temp_max` SMALLINT NOT NULL DEFAULT '40' AFTER `temp_min`",
1100
-
1101
-      "MODIFY COLUMN `metal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `temp_max`",
1102
-      "MODIFY COLUMN `crystal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `metal_max`",
1103
-      "MODIFY COLUMN `deuterium_max` DECIMAL(65,0) DEFAULT '100000' AFTER `crystal_max`",
1104
-
1105
-      "MODIFY COLUMN `debris_metal` bigint(20) unsigned DEFAULT '0'",
1106
-      "MODIFY COLUMN `debris_crystal` bigint(20) unsigned DEFAULT '0'",
1107
-      "MODIFY COLUMN `PLANET_GOVERNOR_ID` SMALLINT NOT NULL DEFAULT '0'",
1108
-      "MODIFY COLUMN `PLANET_GOVERNOR_LEVEL` SMALLINT NOT NULL DEFAULT '0'",
1109
-
1110
-      "MODIFY COLUMN `parent_planet` BIGINT(20) unsigned DEFAULT '0'",
1111
-
1112
-      "DROP COLUMN `b_hangar_plus`",
1113
-    ), isset($update_tables['planets']['b_hangar_plus']));
1114
-
1115
-    if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED')
1116
-    {
1117
-      upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true);
999
+          "ADD CONSTRAINT `FK_notes_owner` FOREIGN KEY (`owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1000
+        ), true);
1001
+      }
1118 1002
 
1119
-      upd_alter_table('referrals', array(
1120
-        "MODIFY COLUMN `id` BIGINT(20) UNSIGNED DEFAULT NULL",
1121
-        "MODIFY COLUMN `id_partner` BIGINT(20) UNSIGNED DEFAULT NULL",
1122
-        "MODIFY COLUMN `dark_matter` DECIMAL(65,0) NOT NULL DEFAULT '0'",
1003
+      upd_alter_table('planets', array(
1004
+        "MODIFY COLUMN `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT",
1005
+        "MODIFY COLUMN `name` VARCHAR(64) DEFAULT 'Planet' NOT NULL",
1006
+        "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
1007
+        "MODIFY COLUMN `galaxy` SMALLINT NOT NULL DEFAULT '0'",
1008
+        "MODIFY COLUMN `system` SMALLINT NOT NULL DEFAULT '0'",
1009
+        "MODIFY COLUMN `planet` SMALLINT NOT NULL DEFAULT '0'",
1010
+        "MODIFY COLUMN `planet_type` TINYINT NOT NULL DEFAULT '1'",
1011
+
1012
+        "MODIFY COLUMN `metal` DECIMAL(65,5) NOT NULL DEFAULT '0'",
1013
+        "MODIFY COLUMN `crystal` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `metal`",
1014
+        "MODIFY COLUMN `deuterium` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `crystal`",
1015
+        "MODIFY COLUMN `energy_max` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `deuterium`",
1016
+        "MODIFY COLUMN `energy_used` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `energy_max`",
1017
+
1018
+        "MODIFY COLUMN `metal_mine` SMALLINT NOT NULL DEFAULT '0'",
1019
+        "MODIFY COLUMN `crystal_mine` SMALLINT NOT NULL DEFAULT '0'",
1020
+        "MODIFY COLUMN `deuterium_sintetizer` SMALLINT NOT NULL DEFAULT '0'",
1021
+        "MODIFY COLUMN `solar_plant` SMALLINT NOT NULL DEFAULT '0'",
1022
+        "MODIFY COLUMN `fusion_plant` SMALLINT NOT NULL DEFAULT '0'",
1023
+        "MODIFY COLUMN `robot_factory` SMALLINT NOT NULL DEFAULT '0'",
1024
+        "MODIFY COLUMN `nano_factory` SMALLINT NOT NULL DEFAULT '0'",
1025
+        "MODIFY COLUMN `hangar` SMALLINT NOT NULL DEFAULT '0'",
1026
+        "MODIFY COLUMN `metal_store` SMALLINT NOT NULL DEFAULT '0'",
1027
+        "MODIFY COLUMN `crystal_store` SMALLINT NOT NULL DEFAULT '0'",
1028
+        "MODIFY COLUMN `deuterium_store` SMALLINT NOT NULL DEFAULT '0'",
1029
+        "MODIFY COLUMN `laboratory` SMALLINT NOT NULL DEFAULT '0'",
1030
+        "MODIFY COLUMN `nano` SMALLINT DEFAULT '0' AFTER `laboratory`",
1031
+        "MODIFY COLUMN `terraformer` SMALLINT NOT NULL DEFAULT '0'",
1032
+        "MODIFY COLUMN `ally_deposit` SMALLINT NOT NULL DEFAULT '0'",
1033
+        "MODIFY COLUMN `silo` SMALLINT NOT NULL DEFAULT '0'",
1034
+        "MODIFY COLUMN `mondbasis` SMALLINT NOT NULL DEFAULT '0' AFTER `silo`",
1035
+        "MODIFY COLUMN `phalanx` SMALLINT NOT NULL DEFAULT '0' AFTER `mondbasis`",
1036
+        "MODIFY COLUMN `sprungtor` SMALLINT NOT NULL DEFAULT '0' AFTER `phalanx`",
1037
+        "MODIFY COLUMN `last_jump_time` int(11) NOT NULL DEFAULT '0' AFTER `sprungtor`",
1038
+
1039
+        "MODIFY COLUMN `small_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1040
+        "MODIFY COLUMN `big_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1041
+        "MODIFY COLUMN `supercargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count' AFTER `big_ship_cargo`",
1042
+        "MODIFY COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `supercargo`",
1043
+        "MODIFY COLUMN `recycler` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `planet_cargo_hyper`",
1044
+        "MODIFY COLUMN `colonizer` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `recycler`",
1045
+        "MODIFY COLUMN `spy_sonde` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `colonizer`",
1046
+        "MODIFY COLUMN `solar_satelit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `spy_sonde`",
1047
+
1048
+        "MODIFY COLUMN `light_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1049
+        "MODIFY COLUMN `heavy_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1050
+        "MODIFY COLUMN `crusher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1051
+        "MODIFY COLUMN `battle_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1052
+        "MODIFY COLUMN `bomber_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1053
+        "MODIFY COLUMN `battleship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `bomber_ship`",
1054
+        "MODIFY COLUMN `destructor` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1055
+        "MODIFY COLUMN `dearth_star` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1056
+        "MODIFY COLUMN `supernova` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1057
+
1058
+        "MODIFY COLUMN `misil_launcher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1059
+        "MODIFY COLUMN `small_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1060
+        "MODIFY COLUMN `big_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1061
+        "MODIFY COLUMN `gauss_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1062
+        "MODIFY COLUMN `ionic_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1063
+        "MODIFY COLUMN `buster_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1064
+
1065
+        "MODIFY COLUMN `small_protection_shield` tinyint(1) NOT NULL DEFAULT '0'",
1066
+        "MODIFY COLUMN `big_protection_shield` tinyint(1) NOT NULL DEFAULT '0'",
1067
+        "MODIFY COLUMN `planet_protector` tinyint(1) NOT NULL DEFAULT '0'",
1068
+
1069
+        "MODIFY COLUMN `interceptor_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1070
+        "MODIFY COLUMN `interplanetary_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'",
1071
+
1072
+        "MODIFY COLUMN `metal_perhour` INT NOT NULL DEFAULT '0' AFTER `interplanetary_misil`",
1073
+        "MODIFY COLUMN `crystal_perhour` INT NOT NULL DEFAULT '0' AFTER `metal_perhour`",
1074
+        "MODIFY COLUMN `deuterium_perhour` INT NOT NULL DEFAULT '0' AFTER `crystal_perhour`",
1075
+
1076
+        "MODIFY COLUMN `metal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'",
1077
+        "MODIFY COLUMN `crystal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'",
1078
+        "MODIFY COLUMN `deuterium_sintetizer_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'",
1079
+        "MODIFY COLUMN `solar_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'",
1080
+        "MODIFY COLUMN `fusion_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'",
1081
+        "MODIFY COLUMN `solar_satelit_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'",
1082
+
1083
+        "MODIFY COLUMN `que` TEXT COMMENT 'Planet que' AFTER `solar_satelit_porcent`",
1084
+  //      "MODIFY COLUMN `b_tech` INT(11) NOT NULL DEFAULT 0 AFTER `que`",
1085
+  //      "MODIFY COLUMN `b_tech_id` SMALLINT NOT NULL DEFAULT 0 AFTER `b_tech`",
1086
+        "MODIFY COLUMN `b_hangar` INT(11) NOT NULL DEFAULT '0' AFTER `que`",
1087
+        "MODIFY COLUMN `b_hangar_id` TEXT AFTER `b_hangar`",
1088
+        "MODIFY COLUMN `last_update` INT(11) DEFAULT NULL AFTER `b_hangar_id`",
1089
+
1090
+        "MODIFY COLUMN `image` varchar(64) NOT NULL DEFAULT 'normaltempplanet01' AFTER `last_update`",
1091
+        "MODIFY COLUMN `points` bigint(20) DEFAULT '0' AFTER `image`",
1092
+        "MODIFY COLUMN `ranks` bigint(20) DEFAULT '0' AFTER `points`",
1093
+        "MODIFY COLUMN `id_level` TINYINT NOT NULL DEFAULT '0' AFTER `ranks`",
1094
+        "MODIFY COLUMN `destruyed` int(11) NOT NULL DEFAULT '0' AFTER `id_level`",
1095
+        "MODIFY COLUMN `diameter` int(11) NOT NULL DEFAULT '12800' AFTER `destruyed`",
1096
+        "MODIFY COLUMN `field_max` SMALLINT UNSIGNED NOT NULL DEFAULT '163' AFTER `diameter`",
1097
+        "MODIFY COLUMN `field_current` SMALLINT UNSIGNED NOT NULL DEFAULT '0' AFTER `field_max`",
1098
+        "MODIFY COLUMN `temp_min` SMALLINT NOT NULL DEFAULT '0' AFTER `field_current`",
1099
+        "MODIFY COLUMN `temp_max` SMALLINT NOT NULL DEFAULT '40' AFTER `temp_min`",
1100
+
1101
+        "MODIFY COLUMN `metal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `temp_max`",
1102
+        "MODIFY COLUMN `crystal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `metal_max`",
1103
+        "MODIFY COLUMN `deuterium_max` DECIMAL(65,0) DEFAULT '100000' AFTER `crystal_max`",
1104
+
1105
+        "MODIFY COLUMN `debris_metal` bigint(20) unsigned DEFAULT '0'",
1106
+        "MODIFY COLUMN `debris_crystal` bigint(20) unsigned DEFAULT '0'",
1107
+        "MODIFY COLUMN `PLANET_GOVERNOR_ID` SMALLINT NOT NULL DEFAULT '0'",
1108
+        "MODIFY COLUMN `PLANET_GOVERNOR_LEVEL` SMALLINT NOT NULL DEFAULT '0'",
1109
+
1110
+        "MODIFY COLUMN `parent_planet` BIGINT(20) unsigned DEFAULT '0'",
1111
+
1112
+        "DROP COLUMN `b_hangar_plus`",
1113
+      ), isset($update_tables['planets']['b_hangar_plus']));
1114
+
1115
+      if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED')
1116
+      {
1117
+        upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true);
1123 1118
 
1124
-        "ADD CONSTRAINT `FK_referrals_id` FOREIGN KEY (`id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1125
-        "ADD CONSTRAINT `FK_referrals_id_partner` FOREIGN KEY (`id_partner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1126
-      ), true);
1127
-    }
1119
+        upd_alter_table('referrals', array(
1120
+          "MODIFY COLUMN `id` BIGINT(20) UNSIGNED DEFAULT NULL",
1121
+          "MODIFY COLUMN `id_partner` BIGINT(20) UNSIGNED DEFAULT NULL",
1122
+          "MODIFY COLUMN `dark_matter` DECIMAL(65,0) NOT NULL DEFAULT '0'",
1128 1123
 
1129
-    upd_alter_table('rw', array(
1130
-      "MODIFY COLUMN `report_id` SERIAL",
1131
-      "MODIFY COLUMN `id_owner1` BIGINT(20) UNSIGNED",
1132
-      "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED",
1133
-    ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED');
1124
+          "ADD CONSTRAINT `FK_referrals_id` FOREIGN KEY (`id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1125
+          "ADD CONSTRAINT `FK_referrals_id_partner` FOREIGN KEY (`id_partner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1126
+        ), true);
1127
+      }
1134 1128
 
1135
-    if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED')
1136
-    {
1137
-      upd_do_query('DELETE FROM {{shortcut}} WHERE shortcut_user_id NOT IN (SELECT id FROM {{users}}) OR shortcut_planet_id NOT IN (SELECT id FROM {{planets}});', true);
1138
-
1139
-      upd_alter_table('shortcut', array(
1140
-        "MODIFY COLUMN `shortcut_id` SERIAL",
1141
-        "MODIFY COLUMN `shortcut_user_id` BIGINT(20) UNSIGNED DEFAULT NULL",
1142
-        "MODIFY COLUMN `shortcut_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL",
1143
-        "MODIFY COLUMN `shortcut_galaxy` TINYINT UNSIGNED DEFAULT 0",
1144
-        "MODIFY COLUMN `shortcut_system` SMALLINT UNSIGNED DEFAULT 0",
1145
-        "MODIFY COLUMN `shortcut_planet` TINYINT UNSIGNED DEFAULT 0",
1146
-
1147
-        "ADD CONSTRAINT `FK_shortcut_planet_id` FOREIGN KEY (`shortcut_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1148
-      ), true);
1149
-    }
1129
+      upd_alter_table('rw', array(
1130
+        "MODIFY COLUMN `report_id` SERIAL",
1131
+        "MODIFY COLUMN `id_owner1` BIGINT(20) UNSIGNED",
1132
+        "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED",
1133
+      ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED');
1150 1134
 
1151
-    if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED')
1152
-    {
1153
-      upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true);
1135
+      if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED')
1136
+      {
1137
+        upd_do_query('DELETE FROM {{shortcut}} WHERE shortcut_user_id NOT IN (SELECT id FROM {{users}}) OR shortcut_planet_id NOT IN (SELECT id FROM {{planets}});', true);
1138
+
1139
+        upd_alter_table('shortcut', array(
1140
+          "MODIFY COLUMN `shortcut_id` SERIAL",
1141
+          "MODIFY COLUMN `shortcut_user_id` BIGINT(20) UNSIGNED DEFAULT NULL",
1142
+          "MODIFY COLUMN `shortcut_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL",
1143
+          "MODIFY COLUMN `shortcut_galaxy` TINYINT UNSIGNED DEFAULT 0",
1144
+          "MODIFY COLUMN `shortcut_system` SMALLINT UNSIGNED DEFAULT 0",
1145
+          "MODIFY COLUMN `shortcut_planet` TINYINT UNSIGNED DEFAULT 0",
1146
+
1147
+          "ADD CONSTRAINT `FK_shortcut_planet_id` FOREIGN KEY (`shortcut_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1148
+        ), true);
1149
+      }
1154 1150
 
1155
-      upd_alter_table('statpoints', array(
1156
-       "MODIFY COLUMN `stat_date` int(11) NOT NULL DEFAULT '0' FIRST",
1157
-       "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
1158
-       "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL",
1159
-       "MODIFY COLUMN `stat_type` TINYINT UNSIGNED DEFAULT 0",
1160
-       "MODIFY COLUMN `stat_code` TINYINT UNSIGNED NOT NULL DEFAULT '0'",
1161
-
1162
-       "MODIFY COLUMN `tech_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1163
-       "MODIFY COLUMN `tech_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1164
-       "MODIFY COLUMN `tech_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1165
-       "MODIFY COLUMN `tech_count` DECIMAL(65,0) UNSIGNED UNSIGNED NOT NULL DEFAULT '0'",
1166
-
1167
-       "MODIFY COLUMN `build_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1168
-       "MODIFY COLUMN `build_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1169
-       "MODIFY COLUMN `build_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1170
-       "MODIFY COLUMN `build_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1171
-
1172
-       "MODIFY COLUMN `defs_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1173
-       "MODIFY COLUMN `defs_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1174
-       "MODIFY COLUMN `defs_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1175
-       "MODIFY COLUMN `defs_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1176
-
1177
-       "MODIFY COLUMN `fleet_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1178
-       "MODIFY COLUMN `fleet_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1179
-       "MODIFY COLUMN `fleet_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1180
-       "MODIFY COLUMN `fleet_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1181
-
1182
-       "MODIFY COLUMN `res_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Rank by resources' AFTER `fleet_count`",
1183
-       "MODIFY COLUMN `res_old_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Old rank by resources'AFTER `res_rank`",
1184
-       "MODIFY COLUMN `res_points` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource stat points' AFTER `res_old_rank`",
1185
-       "MODIFY COLUMN `res_count` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource count' AFTER `res_points`",
1186
-
1187
-       "MODIFY COLUMN `total_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1188
-       "MODIFY COLUMN `total_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1189
-       "MODIFY COLUMN `total_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1190
-       "MODIFY COLUMN `total_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1191
-
1192
-       "ADD KEY `I_stats_id_ally` (`id_ally`)",
1193
-
1194
-       "ADD CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1195
-       "ADD CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1196
-      ), true);
1197
-    }
1151
+      if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED')
1152
+      {
1153
+        upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true);
1154
+
1155
+        upd_alter_table('statpoints', array(
1156
+         "MODIFY COLUMN `stat_date` int(11) NOT NULL DEFAULT '0' FIRST",
1157
+         "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
1158
+         "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL",
1159
+         "MODIFY COLUMN `stat_type` TINYINT UNSIGNED DEFAULT 0",
1160
+         "MODIFY COLUMN `stat_code` TINYINT UNSIGNED NOT NULL DEFAULT '0'",
1161
+
1162
+         "MODIFY COLUMN `tech_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1163
+         "MODIFY COLUMN `tech_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1164
+         "MODIFY COLUMN `tech_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1165
+         "MODIFY COLUMN `tech_count` DECIMAL(65,0) UNSIGNED UNSIGNED NOT NULL DEFAULT '0'",
1166
+
1167
+         "MODIFY COLUMN `build_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1168
+         "MODIFY COLUMN `build_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1169
+         "MODIFY COLUMN `build_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1170
+         "MODIFY COLUMN `build_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1171
+
1172
+         "MODIFY COLUMN `defs_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1173
+         "MODIFY COLUMN `defs_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1174
+         "MODIFY COLUMN `defs_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1175
+         "MODIFY COLUMN `defs_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1176
+
1177
+         "MODIFY COLUMN `fleet_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1178
+         "MODIFY COLUMN `fleet_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1179
+         "MODIFY COLUMN `fleet_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1180
+         "MODIFY COLUMN `fleet_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1181
+
1182
+         "MODIFY COLUMN `res_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Rank by resources' AFTER `fleet_count`",
1183
+         "MODIFY COLUMN `res_old_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Old rank by resources'AFTER `res_rank`",
1184
+         "MODIFY COLUMN `res_points` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource stat points' AFTER `res_old_rank`",
1185
+         "MODIFY COLUMN `res_count` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource count' AFTER `res_points`",
1186
+
1187
+         "MODIFY COLUMN `total_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1188
+         "MODIFY COLUMN `total_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'",
1189
+         "MODIFY COLUMN `total_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1190
+         "MODIFY COLUMN `total_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'",
1191
+
1192
+         "ADD KEY `I_stats_id_ally` (`id_ally`)",
1193
+
1194
+         "ADD CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1195
+         "ADD CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1196
+        ), true);
1197
+      }
1198 1198
 
1199
-    upd_alter_table('users', array(
1200
-      "MODIFY COLUMN `authlevel` tinyint unsigned NOT NULL DEFAULT '0' AFTER `username`",
1201
-      "MODIFY COLUMN `vacation` int(11) unsigned DEFAULT '0' AFTER `authlevel`",
1202
-      "MODIFY COLUMN `banaday` int(11) unsigned DEFAULT '0' AFTER `vacation`",
1203
-      "MODIFY COLUMN `dark_matter` bigint(20) DEFAULT '0' AFTER `banaday`",
1204
-      "MODIFY COLUMN `spy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1205
-      "MODIFY COLUMN `computer_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1206
-      "MODIFY COLUMN `military_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1207
-      "MODIFY COLUMN `defence_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1208
-      "MODIFY COLUMN `shield_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1209
-      "MODIFY COLUMN `energy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1210
-      "MODIFY COLUMN `hyperspace_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1211
-      "MODIFY COLUMN `combustion_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1212
-      "MODIFY COLUMN `impulse_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1213
-      "MODIFY COLUMN `hyperspace_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1214
-      "MODIFY COLUMN `laser_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1215
-      "MODIFY COLUMN `ionic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1216
-      "MODIFY COLUMN `buster_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1217
-      "MODIFY COLUMN `intergalactic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1218
-      "MODIFY COLUMN `expedition_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1219
-      "MODIFY COLUMN `colonisation_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1220
-      "MODIFY COLUMN `graviton_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1221
-      "MODIFY COLUMN `player_artifact_list` text AFTER `graviton_tech`",
1222
-      "MODIFY COLUMN `ally_id` bigint(20) unsigned DEFAULT NULL AFTER `player_artifact_list`",
1223
-      "MODIFY COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`",
1224
-      "MODIFY COLUMN `ally_name` varchar(32) DEFAULT NULL AFTER `ally_tag`",
1225
-      "MODIFY COLUMN `ally_register_time` int(11) NOT NULL DEFAULT '0' AFTER `ally_name`",
1226
-      "MODIFY COLUMN `ally_rank_id` int(11) NOT NULL DEFAULT '0' AFTER `ally_register_time`",
1227
-      "MODIFY COLUMN `player_que` text AFTER `ally_rank_id`",
1228
-      "MODIFY COLUMN `lvl_minier` bigint(20) unsigned NOT NULL DEFAULT '1'",
1229
-      "MODIFY COLUMN `xpminier` bigint(20) unsigned DEFAULT '0' AFTER `lvl_minier`",
1230
-      "MODIFY COLUMN `player_rpg_tech_xp` bigint(20) unsigned NOT NULL DEFAULT '0'",
1231
-      "MODIFY COLUMN `player_rpg_tech_level` bigint(20) unsigned NOT NULL DEFAULT '0'",
1232
-      "MODIFY COLUMN `lvl_raid` bigint(20) unsigned NOT NULL DEFAULT '1' AFTER `player_rpg_tech_level`",
1233
-      "MODIFY COLUMN `xpraid` bigint(20) unsigned DEFAULT '0'",
1234
-      "MODIFY COLUMN `raids` bigint(20) unsigned DEFAULT '0'",
1235
-      "MODIFY COLUMN `raidsloose` bigint(20) unsigned DEFAULT '0'",
1236
-      "MODIFY COLUMN `raidswin` bigint(20) unsigned DEFAULT '0'",
1237
-      "MODIFY COLUMN `new_message` int(11) NOT NULL DEFAULT '0' AFTER `raidswin`",
1238
-      "MODIFY COLUMN `mnl_alliance` int(11) NOT NULL DEFAULT '0'",
1239
-      "MODIFY COLUMN `mnl_joueur` int(11) NOT NULL DEFAULT '0'",
1240
-      "MODIFY COLUMN `mnl_attaque` int(11) NOT NULL DEFAULT '0'",
1241
-      "MODIFY COLUMN `mnl_spy` int(11) NOT NULL DEFAULT '0'",
1242
-      "MODIFY COLUMN `mnl_exploit` int(11) NOT NULL DEFAULT '0'",
1243
-      "MODIFY COLUMN `mnl_transport` int(11) NOT NULL DEFAULT '0'",
1244
-      "MODIFY COLUMN `mnl_expedition` int(11) NOT NULL DEFAULT '0'",
1245
-      "MODIFY COLUMN `mnl_buildlist` int(11) NOT NULL DEFAULT '0'",
1246
-      "MODIFY COLUMN `msg_admin` bigint(11) unsigned DEFAULT '0'",
1247
-//      "MODIFY COLUMN `b_tech_planet` int(11) NOT NULL DEFAULT '0' AFTER `msg_admin`",
1248
-      "MODIFY COLUMN `deltime` int(10) unsigned DEFAULT '0'",
1249
-      "MODIFY COLUMN `news_lastread` int(10) unsigned DEFAULT '0'",
1250
-      "MODIFY COLUMN `total_rank` int(10) unsigned NOT NULL DEFAULT '0'",
1251
-      "MODIFY COLUMN `total_points` bigint(20) unsigned NOT NULL DEFAULT '0'",
1252
-      "MODIFY COLUMN `password` varchar(64) NOT NULL DEFAULT '' AFTER `total_points`",
1253
-      "MODIFY COLUMN `email` varchar(64) NOT NULL DEFAULT '' AFTER `password`",
1254
-      "MODIFY COLUMN `email_2` varchar(64) NOT NULL DEFAULT '' AFTER `email`",
1255
-      "MODIFY COLUMN `lang` varchar(8) NOT NULL DEFAULT 'ru' AFTER `email_2`",
1256
-      "MODIFY COLUMN `sex` char(1) DEFAULT NULL AFTER `lang`",
1257
-      "MODIFY COLUMN `avatar` varchar(255) NOT NULL DEFAULT '' AFTER `sex`",
1258
-      "MODIFY COLUMN `sign` mediumtext AFTER `avatar`",
1259
-      "MODIFY COLUMN `id_planet` int(11) NOT NULL DEFAULT '0' AFTER `sign`",
1260
-      "MODIFY COLUMN `galaxy` int(11) NOT NULL DEFAULT '0' AFTER `id_planet`",
1261
-      "MODIFY COLUMN `system` int(11) NOT NULL DEFAULT '0' AFTER `galaxy`",
1262
-      "MODIFY COLUMN `planet` int(11) NOT NULL DEFAULT '0' AFTER `system`",
1263
-      "MODIFY COLUMN `current_planet` int(11) NOT NULL DEFAULT '0' AFTER `planet`",
1264
-      "MODIFY COLUMN `user_agent` mediumtext NOT NULL AFTER `current_planet`",
1265
-      "MODIFY COLUMN `user_lastip` varchar(250) DEFAULT NULL COMMENT 'User last IP' AFTER `user_agent`",
1266
-      "MODIFY COLUMN `user_proxy` varchar(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)' AFTER `user_lastip`",
1267
-      "MODIFY COLUMN `register_time` int(10) unsigned DEFAULT '0' AFTER `user_proxy`",
1268
-      "MODIFY COLUMN `onlinetime` int(10) unsigned DEFAULT '0' AFTER `register_time`",
1269
-      "MODIFY COLUMN `dpath` varchar(255) NOT NULL DEFAULT '' AFTER `onlinetime`",
1270
-      "MODIFY COLUMN `design` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `dpath`",
1271
-      "MODIFY COLUMN `noipcheck` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `design`",
1272
-      "MODIFY COLUMN `options` mediumtext COMMENT 'Packed user options' AFTER `noipcheck`",
1273
-      "MODIFY COLUMN `planet_sort` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `options`",
1274
-      "MODIFY COLUMN `planet_sort_order` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `planet_sort`",
1275
-      "MODIFY COLUMN `spio_anz` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `planet_sort_order`",
1276
-      "MODIFY COLUMN `settings_tooltiptime` tinyint(1) unsigned NOT NULL DEFAULT '5' AFTER `spio_anz`",
1277
-      "MODIFY COLUMN `settings_fleetactions` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_tooltiptime`",
1278
-      "MODIFY COLUMN `settings_esp` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_allylogo`",
1279
-      "MODIFY COLUMN `settings_wri` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_esp`",
1280
-      "MODIFY COLUMN `settings_bud` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_wri`",
1281
-      "MODIFY COLUMN `settings_mis` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_bud`",
1282
-      "MODIFY COLUMN `settings_rep` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_mis`",
1283
-    ), strtoupper($update_tables['users']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED');
1199
+      upd_alter_table('users', array(
1200
+        "MODIFY COLUMN `authlevel` tinyint unsigned NOT NULL DEFAULT '0' AFTER `username`",
1201
+        "MODIFY COLUMN `vacation` int(11) unsigned DEFAULT '0' AFTER `authlevel`",
1202
+        "MODIFY COLUMN `banaday` int(11) unsigned DEFAULT '0' AFTER `vacation`",
1203
+        "MODIFY COLUMN `dark_matter` bigint(20) DEFAULT '0' AFTER `banaday`",
1204
+        "MODIFY COLUMN `spy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1205
+        "MODIFY COLUMN `computer_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1206
+        "MODIFY COLUMN `military_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1207
+        "MODIFY COLUMN `defence_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1208
+        "MODIFY COLUMN `shield_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1209
+        "MODIFY COLUMN `energy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1210
+        "MODIFY COLUMN `hyperspace_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1211
+        "MODIFY COLUMN `combustion_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1212
+        "MODIFY COLUMN `impulse_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1213
+        "MODIFY COLUMN `hyperspace_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1214
+        "MODIFY COLUMN `laser_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1215
+        "MODIFY COLUMN `ionic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1216
+        "MODIFY COLUMN `buster_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1217
+        "MODIFY COLUMN `intergalactic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1218
+        "MODIFY COLUMN `expedition_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1219
+        "MODIFY COLUMN `colonisation_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1220
+        "MODIFY COLUMN `graviton_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'",
1221
+        "MODIFY COLUMN `player_artifact_list` text AFTER `graviton_tech`",
1222
+        "MODIFY COLUMN `ally_id` bigint(20) unsigned DEFAULT NULL AFTER `player_artifact_list`",
1223
+        "MODIFY COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`",
1224
+        "MODIFY COLUMN `ally_name` varchar(32) DEFAULT NULL AFTER `ally_tag`",
1225
+        "MODIFY COLUMN `ally_register_time` int(11) NOT NULL DEFAULT '0' AFTER `ally_name`",
1226
+        "MODIFY COLUMN `ally_rank_id` int(11) NOT NULL DEFAULT '0' AFTER `ally_register_time`",
1227
+        "MODIFY COLUMN `player_que` text AFTER `ally_rank_id`",
1228
+        "MODIFY COLUMN `lvl_minier` bigint(20) unsigned NOT NULL DEFAULT '1'",
1229
+        "MODIFY COLUMN `xpminier` bigint(20) unsigned DEFAULT '0' AFTER `lvl_minier`",
1230
+        "MODIFY COLUMN `player_rpg_tech_xp` bigint(20) unsigned NOT NULL DEFAULT '0'",
1231
+        "MODIFY COLUMN `player_rpg_tech_level` bigint(20) unsigned NOT NULL DEFAULT '0'",
1232
+        "MODIFY COLUMN `lvl_raid` bigint(20) unsigned NOT NULL DEFAULT '1' AFTER `player_rpg_tech_level`",
1233
+        "MODIFY COLUMN `xpraid` bigint(20) unsigned DEFAULT '0'",
1234
+        "MODIFY COLUMN `raids` bigint(20) unsigned DEFAULT '0'",
1235
+        "MODIFY COLUMN `raidsloose` bigint(20) unsigned DEFAULT '0'",
1236
+        "MODIFY COLUMN `raidswin` bigint(20) unsigned DEFAULT '0'",
1237
+        "MODIFY COLUMN `new_message` int(11) NOT NULL DEFAULT '0' AFTER `raidswin`",
1238
+        "MODIFY COLUMN `mnl_alliance` int(11) NOT NULL DEFAULT '0'",
1239
+        "MODIFY COLUMN `mnl_joueur` int(11) NOT NULL DEFAULT '0'",
1240
+        "MODIFY COLUMN `mnl_attaque` int(11) NOT NULL DEFAULT '0'",
1241
+        "MODIFY COLUMN `mnl_spy` int(11) NOT NULL DEFAULT '0'",
1242
+        "MODIFY COLUMN `mnl_exploit` int(11) NOT NULL DEFAULT '0'",
1243
+        "MODIFY COLUMN `mnl_transport` int(11) NOT NULL DEFAULT '0'",
1244
+        "MODIFY COLUMN `mnl_expedition` int(11) NOT NULL DEFAULT '0'",
1245
+        "MODIFY COLUMN `mnl_buildlist` int(11) NOT NULL DEFAULT '0'",
1246
+        "MODIFY COLUMN `msg_admin` bigint(11) unsigned DEFAULT '0'",
1247
+  //      "MODIFY COLUMN `b_tech_planet` int(11) NOT NULL DEFAULT '0' AFTER `msg_admin`",
1248
+        "MODIFY COLUMN `deltime` int(10) unsigned DEFAULT '0'",
1249
+        "MODIFY COLUMN `news_lastread` int(10) unsigned DEFAULT '0'",
1250
+        "MODIFY COLUMN `total_rank` int(10) unsigned NOT NULL DEFAULT '0'",
1251
+        "MODIFY COLUMN `total_points` bigint(20) unsigned NOT NULL DEFAULT '0'",
1252
+        "MODIFY COLUMN `password` varchar(64) NOT NULL DEFAULT '' AFTER `total_points`",
1253
+        "MODIFY COLUMN `email` varchar(64) NOT NULL DEFAULT '' AFTER `password`",
1254
+        "MODIFY COLUMN `email_2` varchar(64) NOT NULL DEFAULT '' AFTER `email`",
1255
+        "MODIFY COLUMN `lang` varchar(8) NOT NULL DEFAULT 'ru' AFTER `email_2`",
1256
+        "MODIFY COLUMN `sex` char(1) DEFAULT NULL AFTER `lang`",
1257
+        "MODIFY COLUMN `avatar` varchar(255) NOT NULL DEFAULT '' AFTER `sex`",
1258
+        "MODIFY COLUMN `sign` mediumtext AFTER `avatar`",
1259
+        "MODIFY COLUMN `id_planet` int(11) NOT NULL DEFAULT '0' AFTER `sign`",
1260
+        "MODIFY COLUMN `galaxy` int(11) NOT NULL DEFAULT '0' AFTER `id_planet`",
1261
+        "MODIFY COLUMN `system` int(11) NOT NULL DEFAULT '0' AFTER `galaxy`",
1262
+        "MODIFY COLUMN `planet` int(11) NOT NULL DEFAULT '0' AFTER `system`",
1263
+        "MODIFY COLUMN `current_planet` int(11) NOT NULL DEFAULT '0' AFTER `planet`",
1264
+        "MODIFY COLUMN `user_agent` mediumtext NOT NULL AFTER `current_planet`",
1265
+        "MODIFY COLUMN `user_lastip` varchar(250) DEFAULT NULL COMMENT 'User last IP' AFTER `user_agent`",
1266
+        "MODIFY COLUMN `user_proxy` varchar(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)' AFTER `user_lastip`",
1267
+        "MODIFY COLUMN `register_time` int(10) unsigned DEFAULT '0' AFTER `user_proxy`",
1268
+        "MODIFY COLUMN `onlinetime` int(10) unsigned DEFAULT '0' AFTER `register_time`",
1269
+        "MODIFY COLUMN `dpath` varchar(255) NOT NULL DEFAULT '' AFTER `onlinetime`",
1270
+        "MODIFY COLUMN `design` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `dpath`",
1271
+        "MODIFY COLUMN `noipcheck` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `design`",
1272
+        "MODIFY COLUMN `options` mediumtext COMMENT 'Packed user options' AFTER `noipcheck`",
1273
+        "MODIFY COLUMN `planet_sort` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `options`",
1274
+        "MODIFY COLUMN `planet_sort_order` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `planet_sort`",
1275
+        "MODIFY COLUMN `spio_anz` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `planet_sort_order`",
1276
+        "MODIFY COLUMN `settings_tooltiptime` tinyint(1) unsigned NOT NULL DEFAULT '5' AFTER `spio_anz`",
1277
+        "MODIFY COLUMN `settings_fleetactions` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_tooltiptime`",
1278
+        "MODIFY COLUMN `settings_esp` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_allylogo`",
1279
+        "MODIFY COLUMN `settings_wri` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_esp`",
1280
+        "MODIFY COLUMN `settings_bud` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_wri`",
1281
+        "MODIFY COLUMN `settings_mis` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_bud`",
1282
+        "MODIFY COLUMN `settings_rep` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_mis`",
1283
+      ), strtoupper($update_tables['users']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED');
1284 1284
 
1285
-    upd_do_query('COMMIT;', true);
1286
-    $new_version = 32;
1285
+      upd_do_query('COMMIT;', true);
1286
+      $new_version = 32;
1287 1287
 
1288
-  case 32:
1289
-    upd_log_version_update();
1288
+    case 32:
1289
+      upd_log_version_update();
1290 1290
 
1291
-    upd_check_key('avatar_max_width', 128, !isset($config->avatar_max_width));
1292
-    upd_check_key('avatar_max_height', 128, !isset($config->avatar_max_height));
1291
+      upd_check_key('avatar_max_width', 128, !isset($config->avatar_max_width));
1292
+      upd_check_key('avatar_max_height', 128, !isset($config->avatar_max_height));
1293 1293
 
1294
-    upd_alter_table('users', array(
1295
-      "MODIFY COLUMN `avatar` tinyint(1) unsigned NOT NULL DEFAULT '0'",
1296
-    ), strtoupper($update_tables['users']['avatar']['Type']) != 'TINYINT(1) UNSIGNED');
1294
+      upd_alter_table('users', array(
1295
+        "MODIFY COLUMN `avatar` tinyint(1) unsigned NOT NULL DEFAULT '0'",
1296
+      ), strtoupper($update_tables['users']['avatar']['Type']) != 'TINYINT(1) UNSIGNED');
1297 1297
 
1298
-    upd_alter_table('alliance', array(
1299
-      "MODIFY COLUMN `ally_image` tinyint(1) unsigned NOT NULL DEFAULT '0'",
1300
-    ), strtoupper($update_tables['alliance']['ally_image']['Type']) != 'TINYINT(1) UNSIGNED');
1298
+      upd_alter_table('alliance', array(
1299
+        "MODIFY COLUMN `ally_image` tinyint(1) unsigned NOT NULL DEFAULT '0'",
1300
+      ), strtoupper($update_tables['alliance']['ally_image']['Type']) != 'TINYINT(1) UNSIGNED');
1301 1301
 
1302
-    upd_alter_table('users', array(
1303
-      "DROP COLUMN `settings_allylogo`",
1304
-    ), isset($update_tables['users']['settings_allylogo']));
1302
+      upd_alter_table('users', array(
1303
+        "DROP COLUMN `settings_allylogo`",
1304
+      ), isset($update_tables['users']['settings_allylogo']));
1305 1305
 
1306
-    if(!isset($update_tables['powerup']))
1307
-    {
1308
-      upd_do_query("DROP TABLE IF EXISTS {$config->db_prefix}mercenaries;");
1306
+      if(!isset($update_tables['powerup']))
1307
+      {
1308
+        upd_do_query("DROP TABLE IF EXISTS {$config->db_prefix}mercenaries;");
1309 1309
 
1310
-      upd_create_table('powerup',
1311
-        "(
1310
+        upd_create_table('powerup',
1311
+          "(
1312 1312
           `powerup_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
1313 1313
           `powerup_user_id` bigint(20) UNSIGNED NULL DEFAULT NULL,
1314 1314
           `powerup_planet_id` bigint(20) UNSIGNED NULL DEFAULT NULL,
@@ -1327,38 +1327,38 @@  discard block
 block discarded – undo
1327 1327
           CONSTRAINT `FK_powerup_user_id` FOREIGN KEY (`powerup_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
1328 1328
           CONSTRAINT `FK_powerup_planet_id` FOREIGN KEY (`powerup_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1329 1329
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
1330
-      );
1330
+        );
1331 1331
 
1332
-      upd_check_key('empire_mercenary_temporary', 0, !isset($config->empire_mercenary_temporary));
1333
-      upd_check_key('empire_mercenary_base_period', PERIOD_MONTH, !isset($config->empire_mercenary_base_period));
1332
+        upd_check_key('empire_mercenary_temporary', 0, !isset($config->empire_mercenary_temporary));
1333
+        upd_check_key('empire_mercenary_base_period', PERIOD_MONTH, !isset($config->empire_mercenary_base_period));
1334 1334
 
1335
-      $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;";
1336
-      $user_list = upd_do_query("SELECT * FROM {{users}};");
1337
-      while($user_row = db_fetch($user_list))
1338
-      {
1339
-        $update_query_str = '';
1340
-        foreach(sn_get_groups('mercenaries') as $mercenary_id)
1335
+        $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;";
1336
+        $user_list = upd_do_query("SELECT * FROM {{users}};");
1337
+        while($user_row = db_fetch($user_list))
1341 1338
         {
1342
-          $mercenary_data_name = get_unit_param($mercenary_id, P_NAME);
1343
-          if($mercenary_level = $user_row[$mercenary_data_name])
1339
+          $update_query_str = '';
1340
+          foreach(sn_get_groups('mercenaries') as $mercenary_id)
1344 1341
           {
1345
-            $update_query_str = ", `{$mercenary_data_name}` = 0";
1346
-            upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;");
1347
-            upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};");
1342
+            $mercenary_data_name = get_unit_param($mercenary_id, P_NAME);
1343
+            if($mercenary_level = $user_row[$mercenary_data_name])
1344
+            {
1345
+              $update_query_str = ", `{$mercenary_data_name}` = 0";
1346
+              upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;");
1347
+              upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};");
1348
+            }
1348 1349
           }
1349
-        }
1350 1350
 
1351
-        if($update_query_str)
1352
-        {
1353
-          upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id']));
1351
+          if($update_query_str)
1352
+          {
1353
+            upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id']));
1354
+          }
1354 1355
         }
1355 1356
       }
1356
-    }
1357 1357
 
1358
-    if(!isset($update_tables['universe']))
1359
-    {
1360
-      upd_create_table('universe',
1361
-        "(
1358
+      if(!isset($update_tables['universe']))
1359
+      {
1360
+        upd_create_table('universe',
1361
+          "(
1362 1362
           `universe_galaxy` SMALLINT UNSIGNED NOT NULL DEFAULT '0',
1363 1363
           `universe_system` SMALLINT UNSIGNED NOT NULL DEFAULT '0',
1364 1364
           `universe_name` varchar(32) NOT NULL DEFAULT '',
@@ -1366,197 +1366,197 @@  discard block
 block discarded – undo
1366 1366
 
1367 1367
           PRIMARY KEY (`universe_galaxy`, `universe_system`)
1368 1368
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
1369
-      );
1370
-
1371
-      upd_check_key('uni_price_galaxy', 10000, !isset($config->uni_price_galaxy));
1372
-      upd_check_key('uni_price_system', 1000, !isset($config->uni_price_system));
1373
-    }
1369
+        );
1374 1370
 
1375
-    // ========================================================================
1376
-    // Ally player
1377
-    // Adding config variable
1378
-    upd_check_key('ali_bonus_members', 10, !isset($config->ali_bonus_members));
1371
+        upd_check_key('uni_price_galaxy', 10000, !isset($config->uni_price_galaxy));
1372
+        upd_check_key('uni_price_system', 1000, !isset($config->uni_price_system));
1373
+      }
1379 1374
 
1380
-    // ------------------------------------------------------------------------
1381
-    // Modifying tables
1382
-    if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED')
1383
-    {
1384
-      upd_alter_table('users', array(
1385
-        "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL",
1375
+      // ========================================================================
1376
+      // Ally player
1377
+      // Adding config variable
1378
+      upd_check_key('ali_bonus_members', 10, !isset($config->ali_bonus_members));
1386 1379
 
1387
-        "ADD KEY `I_user_user_as_ally` (`user_as_ally`)",
1380
+      // ------------------------------------------------------------------------
1381
+      // Modifying tables
1382
+      if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED')
1383
+      {
1384
+        upd_alter_table('users', array(
1385
+          "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL",
1388 1386
 
1389
-        "ADD CONSTRAINT `FK_user_user_as_ally` FOREIGN KEY (`user_as_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1390
-      ), true);
1387
+          "ADD KEY `I_user_user_as_ally` (`user_as_ally`)",
1391 1388
 
1392
-      upd_alter_table('alliance', array(
1393
-        "ADD COLUMN ally_user_id BIGINT(20) UNSIGNED DEFAULT NULL",
1389
+          "ADD CONSTRAINT `FK_user_user_as_ally` FOREIGN KEY (`user_as_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1390
+        ), true);
1394 1391
 
1395
-        "ADD KEY `I_ally_user_id` (`ally_user_id`)",
1392
+        upd_alter_table('alliance', array(
1393
+          "ADD COLUMN ally_user_id BIGINT(20) UNSIGNED DEFAULT NULL",
1396 1394
 
1397
-        "ADD CONSTRAINT `FK_ally_ally_user_id` FOREIGN KEY (`ally_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1398
-      ), true);
1399
-    }
1395
+          "ADD KEY `I_ally_user_id` (`ally_user_id`)",
1400 1396
 
1401
-    // ------------------------------------------------------------------------
1402
-    // Creating players for allies
1403
-    $ally_row_list = doquery("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;");
1404
-    while($ally_row = db_fetch($ally_row_list))
1405
-    {
1406
-      $ally_user_name = db_escape("[{$ally_row['ally_tag']}]");
1407
-      doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};");
1408
-      $ally_user_id = db_insert_id();
1409
-      doquery("UPDATE {{alliance}} SET ally_user_id = {$ally_user_id} WHERE id = {$ally_row['id']} LIMIT 1;");
1410
-    }
1411
-    // Renaming old ally players TODO: Remove on release
1412
-    upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.user_as_ally = a.id SET u.username = CONCAT('[', a.ally_tag, ']') WHERE u.user_as_ally IS NOT NULL AND u.username = '';");
1413
-    // Setting last online time to old ally players TODO: Remove on release
1414
-    upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;");
1415
-
1416
-    // ------------------------------------------------------------------------
1417
-    // Creating planets for allies
1418
-    $ally_user_list = doquery("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;");
1419
-    while($ally_user_row = db_fetch($ally_user_list))
1420
-    {
1421
-      $ally_planet_name = db_escape($ally_user_row['username']);
1422
-      doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};");
1423
-      $ally_planet_id = db_insert_id();
1424
-      doquery("UPDATE {{users}} SET `id_planet` = {$ally_planet_id} WHERE `id` = {$ally_user_row['id']} LIMIT 1;");
1425
-    }
1397
+          "ADD CONSTRAINT `FK_ally_ally_user_id` FOREIGN KEY (`ally_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1398
+        ), true);
1399
+      }
1426 1400
 
1427
-    upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;");
1428
-
1429
-    upd_alter_table('users', array(
1430
-      "DROP COLUMN `rpg_amiral`",
1431
-      "DROP COLUMN `mrc_academic`",
1432
-      "DROP COLUMN `rpg_espion`",
1433
-      "DROP COLUMN `rpg_commandant`",
1434
-      "DROP COLUMN `rpg_stockeur`",
1435
-      "DROP COLUMN `rpg_destructeur`",
1436
-      "DROP COLUMN `rpg_general`",
1437
-      "DROP COLUMN `rpg_raideur`",
1438
-      "DROP COLUMN `rpg_empereur`",
1439
-
1440
-      "ADD COLUMN `metal` decimal(65,5) NOT NULL DEFAULT '0.00000'",
1441
-      "ADD COLUMN `crystal` decimal(65,5) NOT NULL DEFAULT '0.00000'",
1442
-      "ADD COLUMN `deuterium` decimal(65,5) NOT NULL DEFAULT '0.00000'",
1443
-    ), $update_tables['users']['rpg_amiral']);
1444
-
1445
-
1446
-    // ========================================================================
1447
-    // User que
1448
-    // Adding db field
1449
-    upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']);
1450
-    // Converting old data to new one and dropping old fields
1451
-    if($update_tables['users']['b_tech_planet'])
1452
-    {
1453
-      $query = doquery("SELECT * FROM {{planets}} WHERE `b_tech_id` <> 0;");
1454
-      while($planet_row = db_fetch($query))
1401
+      // ------------------------------------------------------------------------
1402
+      // Creating players for allies
1403
+      $ally_row_list = doquery("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;");
1404
+      while($ally_row = db_fetch($ally_row_list))
1405
+      {
1406
+        $ally_user_name = db_escape("[{$ally_row['ally_tag']}]");
1407
+        doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};");
1408
+        $ally_user_id = db_insert_id();
1409
+        doquery("UPDATE {{alliance}} SET ally_user_id = {$ally_user_id} WHERE id = {$ally_row['id']} LIMIT 1;");
1410
+      }
1411
+      // Renaming old ally players TODO: Remove on release
1412
+      upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.user_as_ally = a.id SET u.username = CONCAT('[', a.ally_tag, ']') WHERE u.user_as_ally IS NOT NULL AND u.username = '';");
1413
+      // Setting last online time to old ally players TODO: Remove on release
1414
+      upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;");
1415
+
1416
+      // ------------------------------------------------------------------------
1417
+      // Creating planets for allies
1418
+      $ally_user_list = doquery("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;");
1419
+      while($ally_user_row = db_fetch($ally_user_list))
1455 1420
       {
1456
-        $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH;
1457
-        doquery("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;");
1421
+        $ally_planet_name = db_escape($ally_user_row['username']);
1422
+        doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};");
1423
+        $ally_planet_id = db_insert_id();
1424
+        doquery("UPDATE {{users}} SET `id_planet` = {$ally_planet_id} WHERE `id` = {$ally_user_row['id']} LIMIT 1;");
1458 1425
       }
1459 1426
 
1460
-      upd_alter_table('planets', array(
1461
-        "DROP COLUMN `b_tech`",
1462
-        "DROP COLUMN `b_tech_id`",
1463
-      ), $update_tables['planets']['b_tech']);
1427
+      upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;");
1464 1428
 
1465
-      upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']);
1466
-    }
1429
+      upd_alter_table('users', array(
1430
+        "DROP COLUMN `rpg_amiral`",
1431
+        "DROP COLUMN `mrc_academic`",
1432
+        "DROP COLUMN `rpg_espion`",
1433
+        "DROP COLUMN `rpg_commandant`",
1434
+        "DROP COLUMN `rpg_stockeur`",
1435
+        "DROP COLUMN `rpg_destructeur`",
1436
+        "DROP COLUMN `rpg_general`",
1437
+        "DROP COLUMN `rpg_raideur`",
1438
+        "DROP COLUMN `rpg_empereur`",
1439
+
1440
+        "ADD COLUMN `metal` decimal(65,5) NOT NULL DEFAULT '0.00000'",
1441
+        "ADD COLUMN `crystal` decimal(65,5) NOT NULL DEFAULT '0.00000'",
1442
+        "ADD COLUMN `deuterium` decimal(65,5) NOT NULL DEFAULT '0.00000'",
1443
+      ), $update_tables['users']['rpg_amiral']);
1444
+
1445
+
1446
+      // ========================================================================
1447
+      // User que
1448
+      // Adding db field
1449
+      upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']);
1450
+      // Converting old data to new one and dropping old fields
1451
+      if($update_tables['users']['b_tech_planet'])
1452
+      {
1453
+        $query = doquery("SELECT * FROM {{planets}} WHERE `b_tech_id` <> 0;");
1454
+        while($planet_row = db_fetch($query))
1455
+        {
1456
+          $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH;
1457
+          doquery("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;");
1458
+        }
1467 1459
 
1468
-    if(!$update_tables['powerup']['powerup_category'])
1469
-    {
1470
-      upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']);
1460
+        upd_alter_table('planets', array(
1461
+          "DROP COLUMN `b_tech`",
1462
+          "DROP COLUMN `b_tech_id`",
1463
+        ), $update_tables['planets']['b_tech']);
1471 1464
 
1472
-      doquery("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY);
1473
-    }
1465
+        upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']);
1466
+      }
1467
+
1468
+      if(!$update_tables['powerup']['powerup_category'])
1469
+      {
1470
+        upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']);
1471
+
1472
+        doquery("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY);
1473
+      }
1474 1474
 
1475
-    upd_check_key('rpg_cost_info', 10000, !isset($config->rpg_cost_info));
1476
-    upd_check_key('tpl_minifier', 0, !isset($config->tpl_minifier));
1475
+      upd_check_key('rpg_cost_info', 10000, !isset($config->rpg_cost_info));
1476
+      upd_check_key('tpl_minifier', 0, !isset($config->tpl_minifier));
1477 1477
 
1478
-    upd_check_key('server_updater_check_auto', 0, !isset($config->server_updater_check_auto));
1479
-    upd_check_key('server_updater_check_period', PERIOD_DAY, !isset($config->server_updater_check_period));
1480
-    upd_check_key('server_updater_check_last', 0, !isset($config->server_updater_check_last));
1481
-    upd_check_key('server_updater_check_result', SNC_VER_NEVER, !isset($config->server_updater_check_result));
1482
-    upd_check_key('server_updater_key', '', !isset($config->server_updater_key));
1483
-    upd_check_key('server_updater_id', 0, !isset($config->server_updater_id));
1478
+      upd_check_key('server_updater_check_auto', 0, !isset($config->server_updater_check_auto));
1479
+      upd_check_key('server_updater_check_period', PERIOD_DAY, !isset($config->server_updater_check_period));
1480
+      upd_check_key('server_updater_check_last', 0, !isset($config->server_updater_check_last));
1481
+      upd_check_key('server_updater_check_result', SNC_VER_NEVER, !isset($config->server_updater_check_result));
1482
+      upd_check_key('server_updater_key', '', !isset($config->server_updater_key));
1483
+      upd_check_key('server_updater_id', 0, !isset($config->server_updater_id));
1484 1484
 
1485
-    upd_check_key('ali_bonus_algorithm', 0, !isset($config->ali_bonus_algorithm));
1486
-    upd_check_key('ali_bonus_divisor', 10000000, !isset($config->ali_bonus_divisor));
1487
-    upd_check_key('ali_bonus_brackets', 10, !isset($config->ali_bonus_brackets));
1488
-    upd_check_key('ali_bonus_brackets_divisor', 50, !isset($config->ali_bonus_brackets_divisor));
1485
+      upd_check_key('ali_bonus_algorithm', 0, !isset($config->ali_bonus_algorithm));
1486
+      upd_check_key('ali_bonus_divisor', 10000000, !isset($config->ali_bonus_divisor));
1487
+      upd_check_key('ali_bonus_brackets', 10, !isset($config->ali_bonus_brackets));
1488
+      upd_check_key('ali_bonus_brackets_divisor', 50, !isset($config->ali_bonus_brackets_divisor));
1489 1489
 
1490
-    if(!$config->db_loadItem('rpg_flt_explore'))
1491
-    {
1492
-      $inflation_rate = 1000;
1490
+      if(!$config->db_loadItem('rpg_flt_explore'))
1491
+      {
1492
+        $inflation_rate = 1000;
1493 1493
 
1494
-      $config->db_saveItem('rpg_cost_banker', $config->rpg_cost_banker * $inflation_rate);
1495
-      $config->db_saveItem('rpg_cost_exchange', $config->rpg_cost_exchange * $inflation_rate);
1496
-      $config->db_saveItem('rpg_cost_pawnshop', $config->rpg_cost_pawnshop * $inflation_rate);
1497
-      $config->db_saveItem('rpg_cost_scraper', $config->rpg_cost_scraper * $inflation_rate);
1498
-      $config->db_saveItem('rpg_cost_stockman', $config->rpg_cost_stockman * $inflation_rate);
1499
-      $config->db_saveItem('rpg_cost_trader', $config->rpg_cost_trader * $inflation_rate);
1494
+        $config->db_saveItem('rpg_cost_banker', $config->rpg_cost_banker * $inflation_rate);
1495
+        $config->db_saveItem('rpg_cost_exchange', $config->rpg_cost_exchange * $inflation_rate);
1496
+        $config->db_saveItem('rpg_cost_pawnshop', $config->rpg_cost_pawnshop * $inflation_rate);
1497
+        $config->db_saveItem('rpg_cost_scraper', $config->rpg_cost_scraper * $inflation_rate);
1498
+        $config->db_saveItem('rpg_cost_stockman', $config->rpg_cost_stockman * $inflation_rate);
1499
+        $config->db_saveItem('rpg_cost_trader', $config->rpg_cost_trader * $inflation_rate);
1500 1500
 
1501
-      $config->db_saveItem('rpg_exchange_darkMatter', $config->rpg_exchange_darkMatter / $inflation_rate * 4);
1501
+        $config->db_saveItem('rpg_exchange_darkMatter', $config->rpg_exchange_darkMatter / $inflation_rate * 4);
1502 1502
 
1503
-      $config->db_saveItem('rpg_flt_explore', $inflation_rate);
1503
+        $config->db_saveItem('rpg_flt_explore', $inflation_rate);
1504 1504
 
1505
-      doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};");
1505
+        doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};");
1506 1506
 
1507
-      $query = doquery("SELECT * FROM {{quest}}");
1508
-      while($row = db_fetch($query))
1509
-      {
1510
-        $query_add = '';
1511
-        $quest_reward_list = explode(';', $row['quest_rewards']);
1512
-        foreach($quest_reward_list as &$quest_reward)
1507
+        $query = doquery("SELECT * FROM {{quest}}");
1508
+        while($row = db_fetch($query))
1513 1509
         {
1514
-          list($reward_resource, $reward_amount) = explode(',', $quest_reward);
1515
-          if($reward_resource == RES_DARK_MATTER)
1510
+          $query_add = '';
1511
+          $quest_reward_list = explode(';', $row['quest_rewards']);
1512
+          foreach($quest_reward_list as &$quest_reward)
1516 1513
           {
1517
-            $quest_reward = "{$reward_resource}," . $reward_amount * 1000;
1514
+            list($reward_resource, $reward_amount) = explode(',', $quest_reward);
1515
+            if($reward_resource == RES_DARK_MATTER)
1516
+            {
1517
+              $quest_reward = "{$reward_resource}," . $reward_amount * 1000;
1518
+            }
1519
+          }
1520
+          $new_rewards = implode(';', $quest_reward_list);
1521
+          if($new_rewards != $row['quest_rewards'])
1522
+          {
1523
+            doquery("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;");
1518 1524
           }
1519
-        }
1520
-        $new_rewards = implode(';', $quest_reward_list);
1521
-        if($new_rewards != $row['quest_rewards'])
1522
-        {
1523
-          doquery("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;");
1524 1525
         }
1525 1526
       }
1526
-    }
1527 1527
 
1528
-    upd_check_key('rpg_bonus_minimum', 10000, !isset($config->rpg_bonus_minimum));
1529
-    upd_check_key('rpg_bonus_divisor',
1530
-      !isset($config->rpg_bonus_divisor) ? 10 : ($config->rpg_bonus_divisor >= 1000 ? floor($config->rpg_bonus_divisor / 1000) : $config->rpg_bonus_divisor),
1531
-      !isset($config->rpg_bonus_divisor) || $config->rpg_bonus_divisor >= 1000);
1528
+      upd_check_key('rpg_bonus_minimum', 10000, !isset($config->rpg_bonus_minimum));
1529
+      upd_check_key('rpg_bonus_divisor',
1530
+        !isset($config->rpg_bonus_divisor) ? 10 : ($config->rpg_bonus_divisor >= 1000 ? floor($config->rpg_bonus_divisor / 1000) : $config->rpg_bonus_divisor),
1531
+        !isset($config->rpg_bonus_divisor) || $config->rpg_bonus_divisor >= 1000);
1532 1532
 
1533
-    upd_check_key('var_news_last', 0, !isset($config->var_news_last));
1533
+      upd_check_key('var_news_last', 0, !isset($config->var_news_last));
1534 1534
 
1535
-    upd_do_query('COMMIT;', true);
1536
-    $new_version = 33;
1535
+      upd_do_query('COMMIT;', true);
1536
+      $new_version = 33;
1537 1537
 
1538
-  case 33:
1539
-    upd_log_version_update();
1538
+    case 33:
1539
+      upd_log_version_update();
1540 1540
 
1541
-    upd_alter_table('users', array(
1542
-      "ADD `user_birthday` DATE DEFAULT NULL COMMENT 'User birthday'",
1543
-      "ADD `user_birthday_celebrated` DATE DEFAULT NULL COMMENT 'Last time where user got birthday gift'",
1541
+      upd_alter_table('users', array(
1542
+        "ADD `user_birthday` DATE DEFAULT NULL COMMENT 'User birthday'",
1543
+        "ADD `user_birthday_celebrated` DATE DEFAULT NULL COMMENT 'Last time where user got birthday gift'",
1544 1544
 
1545
-      "ADD KEY `I_user_birthday` (`user_birthday`, `user_birthday_celebrated`)",
1546
-    ), !$update_tables['users']['user_birthday']);
1545
+        "ADD KEY `I_user_birthday` (`user_birthday`, `user_birthday_celebrated`)",
1546
+      ), !$update_tables['users']['user_birthday']);
1547 1547
 
1548
-    upd_check_key('user_birthday_gift', 0, !isset($config->user_birthday_gift));
1549
-    upd_check_key('user_birthday_range', 30, !isset($config->user_birthday_range));
1550
-    upd_check_key('user_birthday_celebrate', 0, !isset($config->user_birthday_celebrate));
1548
+      upd_check_key('user_birthday_gift', 0, !isset($config->user_birthday_gift));
1549
+      upd_check_key('user_birthday_range', 30, !isset($config->user_birthday_range));
1550
+      upd_check_key('user_birthday_celebrate', 0, !isset($config->user_birthday_celebrate));
1551 1551
 
1552
-    if(!isset($update_tables['payment']))
1553
-    {
1554
-      upd_alter_table('users', array(
1555
-        "ADD KEY `I_user_id_name` (`id`, `username`)",
1556
-      ), !$update_indexes['users']['I_user_id_name']);
1552
+      if(!isset($update_tables['payment']))
1553
+      {
1554
+        upd_alter_table('users', array(
1555
+          "ADD KEY `I_user_id_name` (`id`, `username`)",
1556
+        ), !$update_indexes['users']['I_user_id_name']);
1557 1557
 
1558
-      upd_create_table('payment',
1559
-        "(
1558
+        upd_create_table('payment',
1559
+          "(
1560 1560
           `payment_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Internal payment ID',
1561 1561
           `payment_user_id` BIGINT(20) UNSIGNED DEFAULT NULL,
1562 1562
           `payment_user_name` VARCHAR(64) DEFAULT NULL,
@@ -1576,177 +1576,177 @@  discard block
 block discarded – undo
1576 1576
 
1577 1577
           CONSTRAINT `FK_payment_user` FOREIGN KEY (`payment_user_id`, `payment_user_name`) REFERENCES `{$config->db_prefix}users` (`id`, `username`) ON UPDATE CASCADE ON DELETE NO ACTION
1578 1578
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
1579
-      );
1579
+        );
1580 1580
 
1581
-      upd_check_key('payment_currency_default', 'UAH', !isset($config->payment_currency_default));
1582
-    }
1583
-    upd_check_key('payment_lot_size', 1000, !isset($config->payment_lot_size));
1584
-    upd_check_key('payment_lot_price', 1, !isset($config->payment_lot_price));
1581
+        upd_check_key('payment_currency_default', 'UAH', !isset($config->payment_currency_default));
1582
+      }
1583
+      upd_check_key('payment_lot_size', 1000, !isset($config->payment_lot_size));
1584
+      upd_check_key('payment_lot_price', 1, !isset($config->payment_lot_price));
1585 1585
 
1586
-    // Updating category for Mercenaries
1587
-    upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;");
1586
+      // Updating category for Mercenaries
1587
+      upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;");
1588 1588
 
1589
-    // Convert Destructor to Death Star schematic
1590
-    upd_do_query("UPDATE {{powerup}}
1589
+      // Convert Destructor to Death Star schematic
1590
+      upd_do_query("UPDATE {{powerup}}
1591 1591
       SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_DEATH_STAR . "
1592 1592
       WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 612;");
1593
-    // Convert Assasin to SuperNova schematic
1594
-    upd_do_query("UPDATE {{powerup}}
1593
+      // Convert Assasin to SuperNova schematic
1594
+      upd_do_query("UPDATE {{powerup}}
1595 1595
       SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_SUPERNOVA . "
1596 1596
       WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 614;");
1597 1597
 
1598
-    upd_alter_table('iraks', array(
1599
-      "ADD `fleet_start_type` SMALLINT NOT NULL DEFAULT 1",
1600
-      "ADD `fleet_end_type` SMALLINT NOT NULL DEFAULT 1",
1601
-    ), !$update_tables['iraks']['fleet_start_type']);
1602
-
1603
-
1604
-    if(!$update_tables['payment']['payment_status'])
1605
-    {
1606
-      upd_alter_table('payment', array(
1607
-        "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`",
1598
+      upd_alter_table('iraks', array(
1599
+        "ADD `fleet_start_type` SMALLINT NOT NULL DEFAULT 1",
1600
+        "ADD `fleet_end_type` SMALLINT NOT NULL DEFAULT 1",
1601
+      ), !$update_tables['iraks']['fleet_start_type']);
1608 1602
 
1609
-        "CHANGE COLUMN `payment_dm` `payment_dark_matter_paid` DECIMAL(65,0) DEFAULT 0 COMMENT 'Real DM paid for'",
1610
-        "ADD COLUMN `payment_dark_matter_gained` DECIMAL(65,0) DEFAULT 0 COMMENT 'DM gained by player (with bonuses)' AFTER `payment_dark_matter_paid`",
1611 1603
 
1612
-        "CHANGE COLUMN `payment_internal_id` `payment_external_id` VARCHAR(255) DEFAULT '' COMMENT 'External payment ID in payment system'",
1613
-        "CHANGE COLUMN `payment_internal_date` `payment_external_date` DATETIME COMMENT 'External payment timestamp in payment system'",
1614
-        "ADD COLUMN `payment_external_lots` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Payment system lot amount'",
1615
-        "ADD COLUMN `payment_external_amount` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Money incoming from payment system'",
1616
-        "ADD COLUMN `payment_external_currency` VARCHAR(3) NOT NULL DEFAULT '' COMMENT 'Payment system currency'",
1617
-      ), !$update_tables['payment']['payment_status']);
1618
-    }
1604
+      if(!$update_tables['payment']['payment_status'])
1605
+      {
1606
+        upd_alter_table('payment', array(
1607
+          "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`",
1608
+
1609
+          "CHANGE COLUMN `payment_dm` `payment_dark_matter_paid` DECIMAL(65,0) DEFAULT 0 COMMENT 'Real DM paid for'",
1610
+          "ADD COLUMN `payment_dark_matter_gained` DECIMAL(65,0) DEFAULT 0 COMMENT 'DM gained by player (with bonuses)' AFTER `payment_dark_matter_paid`",
1611
+
1612
+          "CHANGE COLUMN `payment_internal_id` `payment_external_id` VARCHAR(255) DEFAULT '' COMMENT 'External payment ID in payment system'",
1613
+          "CHANGE COLUMN `payment_internal_date` `payment_external_date` DATETIME COMMENT 'External payment timestamp in payment system'",
1614
+          "ADD COLUMN `payment_external_lots` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Payment system lot amount'",
1615
+          "ADD COLUMN `payment_external_amount` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Money incoming from payment system'",
1616
+          "ADD COLUMN `payment_external_currency` VARCHAR(3) NOT NULL DEFAULT '' COMMENT 'Payment system currency'",
1617
+        ), !$update_tables['payment']['payment_status']);
1618
+      }
1619 1619
 
1620
-    upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";");
1620
+      upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";");
1621 1621
 
1622
-    upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset($config->server_start_date));
1623
-    upd_check_key('server_que_length_structures', 5, !isset($config->server_que_length_structures));
1624
-    upd_check_key('server_que_length_hangar', 5, !isset($config->server_que_length_hangar));
1622
+      upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset($config->server_start_date));
1623
+      upd_check_key('server_que_length_structures', 5, !isset($config->server_que_length_structures));
1624
+      upd_check_key('server_que_length_hangar', 5, !isset($config->server_que_length_hangar));
1625 1625
 
1626
-    upd_check_key('chat_highlight_moderator', '<span class="nick_moderator">$1</span>', $config->chat_highlight_admin == '<font color=green>$1</font>');
1627
-    upd_check_key('chat_highlight_operator', '<span class="nick_operator">$1</span>', $config->chat_highlight_admin == '<font color=red>$1</font>');
1628
-    upd_check_key('chat_highlight_admin', '<span class="nick_admin">$1</span>', $config->chat_highlight_admin == '<font color=purple>$1</font>');
1626
+      upd_check_key('chat_highlight_moderator', '<span class="nick_moderator">$1</span>', $config->chat_highlight_admin == '<font color=green>$1</font>');
1627
+      upd_check_key('chat_highlight_operator', '<span class="nick_operator">$1</span>', $config->chat_highlight_admin == '<font color=red>$1</font>');
1628
+      upd_check_key('chat_highlight_admin', '<span class="nick_admin">$1</span>', $config->chat_highlight_admin == '<font color=purple>$1</font>');
1629 1629
 
1630
-    upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset($config->chat_highlight_premium));
1630
+      upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset($config->chat_highlight_premium));
1631 1631
 
1632
-    upd_do_query("UPDATE {{planets}} SET `PLANET_GOVERNOR_LEVEL` = CEILING(`PLANET_GOVERNOR_LEVEL`/2) WHERE PLANET_GOVERNOR_ID = " . MRC_ENGINEER . " AND `PLANET_GOVERNOR_LEVEL` > 8;");
1632
+      upd_do_query("UPDATE {{planets}} SET `PLANET_GOVERNOR_LEVEL` = CEILING(`PLANET_GOVERNOR_LEVEL`/2) WHERE PLANET_GOVERNOR_ID = " . MRC_ENGINEER . " AND `PLANET_GOVERNOR_LEVEL` > 8;");
1633 1633
 
1634 1634
 
1635
-    upd_do_query('COMMIT;', true);
1636
-    $new_version = 34;
1635
+      upd_do_query('COMMIT;', true);
1636
+      $new_version = 34;
1637 1637
 
1638
-  case 34:
1639
-    upd_log_version_update();
1638
+    case 34:
1639
+      upd_log_version_update();
1640 1640
 
1641
-    upd_alter_table('planets', array(
1642
-      "ADD COLUMN `planet_teleport_next` INT(11) NOT NULL DEFAULT 0 COMMENT 'Next teleport time'",
1643
-    ), !$update_tables['planets']['planet_teleport_next']);
1641
+      upd_alter_table('planets', array(
1642
+        "ADD COLUMN `planet_teleport_next` INT(11) NOT NULL DEFAULT 0 COMMENT 'Next teleport time'",
1643
+      ), !$update_tables['planets']['planet_teleport_next']);
1644 1644
 
1645
-    upd_check_key('planet_teleport_cost', 50000, !isset($config->planet_teleport_cost));
1646
-    upd_check_key('planet_teleport_timeout', PERIOD_DAY * 1, !isset($config->planet_teleport_timeout));
1645
+      upd_check_key('planet_teleport_cost', 50000, !isset($config->planet_teleport_cost));
1646
+      upd_check_key('planet_teleport_timeout', PERIOD_DAY * 1, !isset($config->planet_teleport_timeout));
1647 1647
 
1648
-    upd_check_key('planet_capital_cost', 25000, !isset($config->planet_capital_cost));
1648
+      upd_check_key('planet_capital_cost', 25000, !isset($config->planet_capital_cost));
1649 1649
 
1650
-    upd_alter_table('users', array(
1651
-      "ADD COLUMN `player_race` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player\'s race'",
1652
-    ), !$update_tables['users']['player_race']);
1650
+      upd_alter_table('users', array(
1651
+        "ADD COLUMN `player_race` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player\'s race'",
1652
+      ), !$update_tables['users']['player_race']);
1653 1653
 
1654
-    upd_alter_table('chat', array(
1655
-      "MODIFY COLUMN `user` TEXT COMMENT 'Chat message user name'",
1656
-    ), strtoupper($update_tables['chat']['user']['Type']) != 'TEXT');
1654
+      upd_alter_table('chat', array(
1655
+        "MODIFY COLUMN `user` TEXT COMMENT 'Chat message user name'",
1656
+      ), strtoupper($update_tables['chat']['user']['Type']) != 'TEXT');
1657 1657
 
1658
-    upd_alter_table('planets', array(
1659
-      "ADD `ship_sattelite_sloth` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Terran Sloth'",
1660
-      "ADD `ship_bomber_envy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Lunar Envy'",
1661
-      "ADD `ship_recycler_gluttony` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Mercurian Gluttony'",
1662
-      "ADD `ship_fighter_wrath` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Venerian Wrath'",
1663
-      "ADD `ship_battleship_pride` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Martian Pride'",
1664
-      "ADD `ship_cargo_greed` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Republican Greed'",
1665
-    ), !$update_tables['planets']['ship_sattelite_sloth']);
1658
+      upd_alter_table('planets', array(
1659
+        "ADD `ship_sattelite_sloth` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Terran Sloth'",
1660
+        "ADD `ship_bomber_envy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Lunar Envy'",
1661
+        "ADD `ship_recycler_gluttony` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Mercurian Gluttony'",
1662
+        "ADD `ship_fighter_wrath` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Venerian Wrath'",
1663
+        "ADD `ship_battleship_pride` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Martian Pride'",
1664
+        "ADD `ship_cargo_greed` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Republican Greed'",
1665
+      ), !$update_tables['planets']['ship_sattelite_sloth']);
1666 1666
 
1667
-    upd_alter_table('planets', array(
1668
-      "ADD `ship_sattelite_sloth_porcent` TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' COMMENT 'Terran Sloth production'",
1669
-      "ADD KEY `I_ship_sattelite_sloth` (`ship_sattelite_sloth`, `id_level`)",
1670
-      "ADD KEY `I_ship_bomber_envy` (`ship_bomber_envy`, `id_level`)",
1671
-      "ADD KEY `I_ship_recycler_gluttony` (`ship_recycler_gluttony`, `id_level`)",
1672
-      "ADD KEY `I_ship_fighter_wrath` (`ship_fighter_wrath`, `id_level`)",
1673
-      "ADD KEY `I_ship_battleship_pride` (`ship_battleship_pride`, `id_level`)",
1674
-      "ADD KEY `I_ship_cargo_greed` (`ship_cargo_greed`, `id_level`)",
1675
-    ), !$update_tables['planets']['ship_sattelite_sloth_porcent']);
1667
+      upd_alter_table('planets', array(
1668
+        "ADD `ship_sattelite_sloth_porcent` TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' COMMENT 'Terran Sloth production'",
1669
+        "ADD KEY `I_ship_sattelite_sloth` (`ship_sattelite_sloth`, `id_level`)",
1670
+        "ADD KEY `I_ship_bomber_envy` (`ship_bomber_envy`, `id_level`)",
1671
+        "ADD KEY `I_ship_recycler_gluttony` (`ship_recycler_gluttony`, `id_level`)",
1672
+        "ADD KEY `I_ship_fighter_wrath` (`ship_fighter_wrath`, `id_level`)",
1673
+        "ADD KEY `I_ship_battleship_pride` (`ship_battleship_pride`, `id_level`)",
1674
+        "ADD KEY `I_ship_cargo_greed` (`ship_cargo_greed`, `id_level`)",
1675
+      ), !$update_tables['planets']['ship_sattelite_sloth_porcent']);
1676 1676
 
1677
-    upd_check_key('stats_hide_admins', 1, !isset($config->stats_hide_admins));
1678
-    upd_check_key('stats_hide_player_list', '', !isset($config->stats_hide_player_list));
1677
+      upd_check_key('stats_hide_admins', 1, !isset($config->stats_hide_admins));
1678
+      upd_check_key('stats_hide_player_list', '', !isset($config->stats_hide_player_list));
1679 1679
 
1680
-    upd_check_key('adv_seo_meta_description', '', !isset($config->adv_seo_meta_description));
1681
-    upd_check_key('adv_seo_meta_keywords', '', !isset($config->adv_seo_meta_keywords));
1680
+      upd_check_key('adv_seo_meta_description', '', !isset($config->adv_seo_meta_description));
1681
+      upd_check_key('adv_seo_meta_keywords', '', !isset($config->adv_seo_meta_keywords));
1682 1682
 
1683
-    upd_check_key('stats_hide_pm_link', '0', !isset($config->stats_hide_pm_link));
1683
+      upd_check_key('stats_hide_pm_link', '0', !isset($config->stats_hide_pm_link));
1684 1684
 
1685
-    upd_alter_table('notes', array(
1686
-      "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)",
1687
-    ), !$update_indexes['notes']['I_owner_priority_time']);
1685
+      upd_alter_table('notes', array(
1686
+        "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)",
1687
+      ), !$update_indexes['notes']['I_owner_priority_time']);
1688 1688
 
1689
-    if(!$update_tables['buddy']['BUDDY_ID'])
1690
-    {
1691
-      upd_alter_table('buddy', array(
1692
-        "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy table row ID'",
1693
-        "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy request status'",
1694
-        "CHANGE COLUMN `text` `BUDDY_REQUEST` TINYTEXT DEFAULT '' COMMENT 'Buddy request text'", // 255 chars
1695
-
1696
-        "DROP INDEX `id`",
1697
-
1698
-        "DROP FOREIGN KEY `FK_buddy_sender_id`",
1699
-        "DROP FOREIGN KEY `FK_buddy_owner_id`",
1700
-        "DROP INDEX `I_buddy_sender`",
1701
-        "DROP INDEX `I_buddy_owner`",
1702
-      ), !$update_tables['buddy']['BUDDY_ID']);
1703
-
1704
-      upd_alter_table('buddy', array(
1705
-        "CHANGE COLUMN `sender` `BUDDY_SENDER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request sender ID'",
1706
-        "CHANGE COLUMN `owner` `BUDDY_OWNER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request recipient ID'",
1707
-      ), !$update_tables['buddy']['BUDDY_SENDER']);
1708
-
1709
-      $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;");
1710
-      $found = $lost = array();
1711
-      while($row = db_fetch($query))
1689
+      if(!$update_tables['buddy']['BUDDY_ID'])
1712 1690
       {
1713
-        $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']);
1714
-        if(!isset($found[$index]))
1691
+        upd_alter_table('buddy', array(
1692
+          "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy table row ID'",
1693
+          "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy request status'",
1694
+          "CHANGE COLUMN `text` `BUDDY_REQUEST` TINYTEXT DEFAULT '' COMMENT 'Buddy request text'", // 255 chars
1695
+
1696
+          "DROP INDEX `id`",
1697
+
1698
+          "DROP FOREIGN KEY `FK_buddy_sender_id`",
1699
+          "DROP FOREIGN KEY `FK_buddy_owner_id`",
1700
+          "DROP INDEX `I_buddy_sender`",
1701
+          "DROP INDEX `I_buddy_owner`",
1702
+        ), !$update_tables['buddy']['BUDDY_ID']);
1703
+
1704
+        upd_alter_table('buddy', array(
1705
+          "CHANGE COLUMN `sender` `BUDDY_SENDER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request sender ID'",
1706
+          "CHANGE COLUMN `owner` `BUDDY_OWNER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request recipient ID'",
1707
+        ), !$update_tables['buddy']['BUDDY_SENDER']);
1708
+
1709
+        $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;");
1710
+        $found = $lost = array();
1711
+        while($row = db_fetch($query))
1715 1712
         {
1716
-          $found[$index] = $row['BUDDY_ID'];
1713
+          $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']);
1714
+          if(!isset($found[$index]))
1715
+          {
1716
+            $found[$index] = $row['BUDDY_ID'];
1717
+          }
1718
+          else
1719
+          {
1720
+            $lost[] = $row['BUDDY_ID'];
1721
+          }
1717 1722
         }
1718
-        else
1723
+        $lost = implode(',', $lost);
1724
+        if($lost)
1719 1725
         {
1720
-          $lost[] = $row['BUDDY_ID'];
1726
+          upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})");
1721 1727
         }
1722
-      }
1723
-      $lost = implode(',', $lost);
1724
-      if($lost)
1725
-      {
1726
-        upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})");
1727
-      }
1728 1728
 
1729
-      upd_alter_table('buddy', array(
1730
-          "ADD KEY `I_BUDDY_SENDER_ID` (`BUDDY_SENDER_ID`, `BUDDY_OWNER_ID`)",
1731
-          "ADD KEY `I_BUDDY_OWNER_ID` (`BUDDY_OWNER_ID`, `BUDDY_SENDER_ID`)",
1729
+        upd_alter_table('buddy', array(
1730
+            "ADD KEY `I_BUDDY_SENDER_ID` (`BUDDY_SENDER_ID`, `BUDDY_OWNER_ID`)",
1731
+            "ADD KEY `I_BUDDY_OWNER_ID` (`BUDDY_OWNER_ID`, `BUDDY_SENDER_ID`)",
1732 1732
 
1733
-          "ADD CONSTRAINT `FK_BUDDY_SENDER_ID` FOREIGN KEY (`BUDDY_SENDER_ID`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1734
-          "ADD CONSTRAINT `FK_BUDDY_OWNER_ID` FOREIGN KEY (`BUDDY_OWNER_ID`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1735
-      ), !$update_indexes['buddy']['I_BUDDY_SENDER_ID']);
1736
-    }
1733
+            "ADD CONSTRAINT `FK_BUDDY_SENDER_ID` FOREIGN KEY (`BUDDY_SENDER_ID`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1734
+            "ADD CONSTRAINT `FK_BUDDY_OWNER_ID` FOREIGN KEY (`BUDDY_OWNER_ID`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
1735
+        ), !$update_indexes['buddy']['I_BUDDY_SENDER_ID']);
1736
+      }
1737 1737
 
1738
-    upd_do_query('COMMIT;', true);
1739
-    $new_version = 35;
1738
+      upd_do_query('COMMIT;', true);
1739
+      $new_version = 35;
1740 1740
 
1741
-  case 35:
1742
-    upd_log_version_update();
1741
+    case 35:
1742
+      upd_log_version_update();
1743 1743
 
1744
-    upd_do_query("UPDATE {{users}} SET `ally_name` = null, `ally_tag` = null, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` IS NULL");
1744
+      upd_do_query("UPDATE {{users}} SET `ally_name` = null, `ally_tag` = null, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` IS NULL");
1745 1745
 
1746
-    if(!$update_tables['ube_report'])
1747
-    {
1748
-      upd_create_table('ube_report',
1749
-        "(
1746
+      if(!$update_tables['ube_report'])
1747
+      {
1748
+        upd_create_table('ube_report',
1749
+          "(
1750 1750
           `ube_report_id` SERIAL COMMENT 'Report ID',
1751 1751
 
1752 1752
           `ube_report_cypher` CHAR(32) NOT NULL DEFAULT '' COMMENT '16 char secret report ID',
@@ -1782,13 +1782,13 @@  discard block
 block discarded – undo
1782 1782
           PRIMARY KEY (`ube_report_id`),
1783 1783
           KEY `I_ube_report_cypher` (`ube_report_cypher`)
1784 1784
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
1785
-      );
1786
-    }
1785
+        );
1786
+      }
1787 1787
 
1788
-    if(!$update_tables['ube_report_player'])
1789
-    {
1790
-      upd_create_table('ube_report_player',
1791
-        "(
1788
+      if(!$update_tables['ube_report_player'])
1789
+      {
1790
+        upd_create_table('ube_report_player',
1791
+          "(
1792 1792
           `ube_report_player_id` SERIAL COMMENT 'Record ID',
1793 1793
           `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID',
1794 1794
           `ube_report_player_player_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Player ID',
@@ -1804,13 +1804,13 @@  discard block
 block discarded – undo
1804 1804
           KEY `I_ube_report_player_player_id` (`ube_report_player_player_id`),
1805 1805
           CONSTRAINT `FK_ube_report_player_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{$config->db_prefix}ube_report` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE
1806 1806
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
1807
-      );
1808
-    }
1807
+        );
1808
+      }
1809 1809
 
1810
-    if(!$update_tables['ube_report_fleet'])
1811
-    {
1812
-      upd_create_table('ube_report_fleet',
1813
-        "(
1810
+      if(!$update_tables['ube_report_fleet'])
1811
+      {
1812
+        upd_create_table('ube_report_fleet',
1813
+          "(
1814 1814
           `ube_report_fleet_id` SERIAL COMMENT 'Record DB ID',
1815 1815
 
1816 1816
           `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID',
@@ -1835,17 +1835,17 @@  discard block
 block discarded – undo
1835 1835
           PRIMARY KEY (`ube_report_fleet_id`),
1836 1836
           CONSTRAINT `FK_ube_report_fleet_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{$config->db_prefix}ube_report` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE
1837 1837
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
1838
-      );
1839
-    }
1838
+        );
1839
+      }
1840 1840
 
1841
-    if(!$update_tables['ube_report_unit'])
1842
-    {
1843
-      // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках
1844
-      // Может сохранять имена удаленных кораблей долго?
1841
+      if(!$update_tables['ube_report_unit'])
1842
+      {
1843
+        // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках
1844
+        // Может сохранять имена удаленных кораблей долго?
1845 1845
 
1846
-      // round SIGNED!!! -1 например - для ауткома
1847
-      upd_create_table('ube_report_unit',
1848
-        "(
1846
+        // round SIGNED!!! -1 например - для ауткома
1847
+        upd_create_table('ube_report_unit',
1848
+          "(
1849 1849
           `ube_report_unit_id` SERIAL COMMENT 'Record DB ID',
1850 1850
 
1851 1851
           `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID',
@@ -1873,13 +1873,13 @@  discard block
 block discarded – undo
1873 1873
           KEY `I_ube_report_unit_order` (`ube_report_unit_sort_order`),
1874 1874
           CONSTRAINT `FK_ube_report_unit_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{$config->db_prefix}ube_report` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE
1875 1875
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
1876
-      );
1877
-    }
1876
+        );
1877
+      }
1878 1878
 
1879
-    if(!$update_tables['ube_report_outcome_fleet'])
1880
-    {
1881
-      upd_create_table('ube_report_outcome_fleet',
1882
-        "(
1879
+      if(!$update_tables['ube_report_outcome_fleet'])
1880
+      {
1881
+        upd_create_table('ube_report_outcome_fleet',
1882
+          "(
1883 1883
           `ube_report_outcome_fleet_id` SERIAL COMMENT 'Record DB ID',
1884 1884
 
1885 1885
           `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID',
@@ -1903,13 +1903,13 @@  discard block
 block discarded – undo
1903 1903
           KEY `I_ube_report_outcome_fleet_report_fleet` (`ube_report_id`, `ube_report_outcome_fleet_fleet_id`),
1904 1904
           CONSTRAINT `FK_ube_report_outcome_fleet_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{$config->db_prefix}ube_report` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE
1905 1905
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
1906
-      );
1907
-    }
1906
+        );
1907
+      }
1908 1908
 
1909
-    if(!$update_tables['ube_report_outcome_unit'])
1910
-    {
1911
-      upd_create_table('ube_report_outcome_unit',
1912
-        "(
1909
+      if(!$update_tables['ube_report_outcome_unit'])
1910
+      {
1911
+        upd_create_table('ube_report_outcome_unit',
1912
+          "(
1913 1913
           `ube_report_outcome_unit_id` SERIAL COMMENT 'Record DB ID',
1914 1914
 
1915 1915
           `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID',
@@ -1925,13 +1925,13 @@  discard block
 block discarded – undo
1925 1925
           KEY `I_ube_report_outcome_unit_report_order` (`ube_report_id`, `ube_report_outcome_unit_sort_order`),
1926 1926
           CONSTRAINT `FK_ube_report_outcome_unit_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{$config->db_prefix}ube_report` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE
1927 1927
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
1928
-      );
1929
-    }
1928
+        );
1929
+      }
1930 1930
 
1931
-    if(!$update_tables['unit'])
1932
-    {
1933
-      upd_create_table('unit',
1934
-        "(
1931
+      if(!$update_tables['unit'])
1932
+      {
1933
+        upd_create_table('unit',
1934
+          "(
1935 1935
           `unit_id` SERIAL COMMENT 'Record ID',
1936 1936
 
1937 1937
           `unit_player_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Unit owner',
@@ -1945,13 +1945,13 @@  discard block
 block discarded – undo
1945 1945
           KEY `I_unit_player_location_snid` (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_snid`),
1946 1946
           CONSTRAINT `FK_unit_player_id` FOREIGN KEY (`unit_player_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
1947 1947
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
1948
-      );
1949
-    }
1948
+        );
1949
+      }
1950 1950
 
1951
-    if(!$update_tables['captain'])
1952
-    {
1953
-      upd_create_table('captain',
1954
-        "(
1951
+      if(!$update_tables['captain'])
1952
+      {
1953
+        upd_create_table('captain',
1954
+          "(
1955 1955
           `captain_id` SERIAL COMMENT 'Record ID',
1956 1956
           `captain_unit_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Link to `unit` record',
1957 1957
 
@@ -1966,36 +1966,36 @@  discard block
 block discarded – undo
1966 1966
           KEY `I_captain_unit_id` (`captain_unit_id`),
1967 1967
           CONSTRAINT `FK_captain_unit_id` FOREIGN KEY (`captain_unit_id`) REFERENCES `{$config->db_prefix}unit` (`unit_id`) ON UPDATE CASCADE ON DELETE CASCADE
1968 1968
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
1969
-      );
1970
-    }
1969
+        );
1970
+      }
1971 1971
 
1972
-    if(!$update_tables['fleets']['fleet_start_planet_id'])
1973
-    {
1974
-      upd_alter_table('fleets', array(
1975
-        "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`",
1976
-        "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`",
1972
+      if(!$update_tables['fleets']['fleet_start_planet_id'])
1973
+      {
1974
+        upd_alter_table('fleets', array(
1975
+          "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`",
1976
+          "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`",
1977 1977
 
1978
-        "ADD KEY `I_fleet_start_planet_id` (`fleet_start_planet_id`)",
1979
-        "ADD KEY `I_fleet_end_planet_id` (`fleet_end_planet_id`)",
1978
+          "ADD KEY `I_fleet_start_planet_id` (`fleet_start_planet_id`)",
1979
+          "ADD KEY `I_fleet_end_planet_id` (`fleet_end_planet_id`)",
1980 1980
 
1981
-        "ADD CONSTRAINT `FK_fleet_planet_start` FOREIGN KEY (`fleet_start_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
1982
-        "ADD CONSTRAINT `FK_fleet_planet_end` FOREIGN KEY (`fleet_end_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
1983
-      ), !$update_tables['fleets']['fleet_start_planet_id']);
1981
+          "ADD CONSTRAINT `FK_fleet_planet_start` FOREIGN KEY (`fleet_start_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
1982
+          "ADD CONSTRAINT `FK_fleet_planet_end` FOREIGN KEY (`fleet_end_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
1983
+        ), !$update_tables['fleets']['fleet_start_planet_id']);
1984 1984
 
1985
-      upd_do_query("
1985
+        upd_do_query("
1986 1986
         UPDATE {{fleets}} AS f
1987 1987
          LEFT JOIN {{planets}} AS p_s ON p_s.galaxy = f.fleet_start_galaxy AND p_s.system = f.fleet_start_system AND p_s.planet = f.fleet_start_planet AND p_s.planet_type = f.fleet_start_type
1988 1988
          LEFT JOIN {{planets}} AS p_e ON p_e.galaxy = f.fleet_end_galaxy AND p_e.system = f.fleet_end_system AND p_e.planet = f.fleet_end_planet AND p_e.planet_type = f.fleet_end_type
1989 1989
         SET f.fleet_start_planet_id = p_s.id, f.fleet_end_planet_id = p_e.id
1990 1990
       ");
1991
-    }
1991
+      }
1992 1992
 
1993
-    upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']);
1993
+      upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']);
1994 1994
 
1995
-    if(!$update_tables['chat_player'])
1996
-    {
1997
-      upd_create_table('chat_player',
1998
-        "(
1995
+      if(!$update_tables['chat_player'])
1996
+      {
1997
+        upd_create_table('chat_player',
1998
+          "(
1999 1999
           `chat_player_id` SERIAL COMMENT 'Record ID',
2000 2000
 
2001 2001
           `chat_player_player_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Chat player record owner',
@@ -2011,105 +2011,105 @@  discard block
 block discarded – undo
2011 2011
           CONSTRAINT `FK_chat_player_id` FOREIGN KEY (`chat_player_player_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
2012 2012
 
2013 2013
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
2014
-      );
2015
-    }
2016
-
2017
-    upd_alter_table('chat', array(
2018
-      "ADD `chat_message_sender_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message sender ID' AFTER `messageid`",
2019
-      "ADD `chat_message_recipient_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message recipient ID' AFTER `user`",
2014
+        );
2015
+      }
2020 2016
 
2021
-      "ADD KEY `I_chat_message_sender_id` (`chat_message_sender_id`)",
2022
-      "ADD KEY `I_chat_message_recipient_id` (`chat_message_recipient_id`)",
2017
+      upd_alter_table('chat', array(
2018
+        "ADD `chat_message_sender_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message sender ID' AFTER `messageid`",
2019
+        "ADD `chat_message_recipient_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message recipient ID' AFTER `user`",
2023 2020
 
2024
-      "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
2025
-      "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
2026
-    ), !$update_tables['chat']['chat_message_sender_id']);
2021
+        "ADD KEY `I_chat_message_sender_id` (`chat_message_sender_id`)",
2022
+        "ADD KEY `I_chat_message_recipient_id` (`chat_message_recipient_id`)",
2027 2023
 
2028
-    upd_alter_table('chat', array(
2029
-      "ADD `chat_message_sender_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_sender_id`",
2030
-      "ADD `chat_message_recipient_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_recipient_id`",
2031
-    ), !$update_tables['chat']['chat_message_sender_name']);
2024
+        "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
2025
+        "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
2026
+      ), !$update_tables['chat']['chat_message_sender_id']);
2032 2027
 
2033
-    upd_alter_table('users', array(
2034
-      "MODIFY COLUMN `banaday` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ban status'",
2035
-    ), strtoupper($update_tables['users']['banaday']['Null']) == 'YES');
2028
+      upd_alter_table('chat', array(
2029
+        "ADD `chat_message_sender_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_sender_id`",
2030
+        "ADD `chat_message_recipient_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_recipient_id`",
2031
+      ), !$update_tables['chat']['chat_message_sender_name']);
2036 2032
 
2037
-    upd_alter_table('banned', array(
2038
-      "ADD `ban_user_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banned user ID' AFTER `ban_id`",
2039
-      "ADD `ban_issuer_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banner ID' AFTER `ban_until`",
2033
+      upd_alter_table('users', array(
2034
+        "MODIFY COLUMN `banaday` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ban status'",
2035
+      ), strtoupper($update_tables['users']['banaday']['Null']) == 'YES');
2040 2036
 
2041
-      "ADD KEY `I_ban_user_id` (`ban_user_id`)",
2042
-      "ADD KEY `I_ban_issuer_id` (`ban_issuer_id`)",
2037
+      upd_alter_table('banned', array(
2038
+        "ADD `ban_user_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banned user ID' AFTER `ban_id`",
2039
+        "ADD `ban_issuer_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banner ID' AFTER `ban_until`",
2043 2040
 
2044
-      "ADD CONSTRAINT `FK_ban_user_id` FOREIGN KEY (`ban_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
2045
-      "ADD CONSTRAINT `FK_ban_issuer_id` FOREIGN KEY (`ban_issuer_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
2046
-    ), !$update_tables['banned']['ban_user_id']);
2041
+        "ADD KEY `I_ban_user_id` (`ban_user_id`)",
2042
+        "ADD KEY `I_ban_issuer_id` (`ban_issuer_id`)",
2047 2043
 
2048
-    upd_do_query('COMMIT;', true);
2049
-    $new_version = 36;
2044
+        "ADD CONSTRAINT `FK_ban_user_id` FOREIGN KEY (`ban_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
2045
+        "ADD CONSTRAINT `FK_ban_issuer_id` FOREIGN KEY (`ban_issuer_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
2046
+      ), !$update_tables['banned']['ban_user_id']);
2050 2047
 
2051
-  case 36:
2052
-    upd_log_version_update();
2048
+      upd_do_query('COMMIT;', true);
2049
+      $new_version = 36;
2053 2050
 
2054
-    upd_alter_table('payment', array(
2055
-      "DROP FOREIGN KEY `FK_payment_user`",
2056
-    ), $update_foreigns['payment']['FK_payment_user']);
2051
+    case 36:
2052
+      upd_log_version_update();
2057 2053
 
2058
-    if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;')
2059
-    {
2060
-      upd_alter_table('chat', array(
2061
-        "DROP FOREIGN KEY `FK_chat_message_sender_user_id`",
2062
-        "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`",
2063
-      ), true);
2054
+      upd_alter_table('payment', array(
2055
+        "DROP FOREIGN KEY `FK_payment_user`",
2056
+      ), $update_foreigns['payment']['FK_payment_user']);
2064 2057
 
2065
-      upd_alter_table('chat', array(
2066
-        "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
2067
-        "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
2068
-      ), true);
2069
-    }
2058
+      if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;')
2059
+      {
2060
+        upd_alter_table('chat', array(
2061
+          "DROP FOREIGN KEY `FK_chat_message_sender_user_id`",
2062
+          "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`",
2063
+        ), true);
2064
+
2065
+        upd_alter_table('chat', array(
2066
+          "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
2067
+          "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
2068
+        ), true);
2069
+      }
2070 2070
 
2071
-    upd_alter_table('users', array(
2072
-      "ADD `user_time_diff` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `onlinetime`",
2073
-      "ADD `user_time_diff_forced` TINYINT(1) DEFAULT 0 COMMENT 'User time difference forced with time zone selection flag' AFTER `user_time_diff`",
2074
-    ), !$update_tables['users']['user_time_diff']);
2071
+      upd_alter_table('users', array(
2072
+        "ADD `user_time_diff` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `onlinetime`",
2073
+        "ADD `user_time_diff_forced` TINYINT(1) DEFAULT 0 COMMENT 'User time difference forced with time zone selection flag' AFTER `user_time_diff`",
2074
+      ), !$update_tables['users']['user_time_diff']);
2075 2075
 
2076
-    upd_alter_table('planets', array(
2077
-      "ADD `ship_orbital_heavy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'HOPe - Heavy Orbital Platform'",
2078
-    ), !$update_tables['planets']['ship_orbital_heavy']);
2076
+      upd_alter_table('planets', array(
2077
+        "ADD `ship_orbital_heavy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'HOPe - Heavy Orbital Platform'",
2078
+      ), !$update_tables['planets']['ship_orbital_heavy']);
2079 2079
 
2080
-    upd_check_key('chat_refresh_rate', 5, !isset($config->chat_refresh_rate));
2080
+      upd_check_key('chat_refresh_rate', 5, !isset($config->chat_refresh_rate));
2081 2081
 
2082
-    upd_alter_table('chat_player', array(
2083
-      "ADD `chat_player_refresh_last`  INT(11) NOT NULL DEFAULT 0 COMMENT 'Player last refresh time'",
2082
+      upd_alter_table('chat_player', array(
2083
+        "ADD `chat_player_refresh_last`  INT(11) NOT NULL DEFAULT 0 COMMENT 'Player last refresh time'",
2084 2084
 
2085
-      "ADD KEY `I_chat_player_refresh_last` (`chat_player_refresh_last`)",
2086
-    ), !$update_tables['chat_player']['chat_player_refresh_last']);
2085
+        "ADD KEY `I_chat_player_refresh_last` (`chat_player_refresh_last`)",
2086
+      ), !$update_tables['chat_player']['chat_player_refresh_last']);
2087 2087
 
2088
-    upd_alter_table('ube_report', array(
2089
-      "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)",
2090
-    ), !$update_indexes['ube_report']['I_ube_report_time_combat']);
2088
+      upd_alter_table('ube_report', array(
2089
+        "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)",
2090
+      ), !$update_indexes['ube_report']['I_ube_report_time_combat']);
2091 2091
 
2092
-    if(!$update_tables['unit']['unit_time_start'])
2093
-    {
2094
-      upd_alter_table('unit', array(
2095
-        "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'",
2096
-        "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'",
2097
-      ), !$update_tables['unit']['unit_time_start']);
2092
+      if(!$update_tables['unit']['unit_time_start'])
2093
+      {
2094
+        upd_alter_table('unit', array(
2095
+          "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'",
2096
+          "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'",
2097
+        ), !$update_tables['unit']['unit_time_start']);
2098 2098
 
2099
-      upd_do_query(
2100
-        "INSERT INTO {{unit}}
2099
+        upd_do_query(
2100
+          "INSERT INTO {{unit}}
2101 2101
           (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level, unit_time_start, unit_time_finish)
2102 2102
         SELECT
2103 2103
           `powerup_user_id`, " . LOC_USER . ", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level`
2104 2104
           , IF(`powerup_time_start`, FROM_UNIXTIME(`powerup_time_start`), NULL), IF(`powerup_time_finish`, FROM_UNIXTIME(`powerup_time_finish`), NULL)
2105 2105
         FROM {{powerup}}"
2106
-      );
2107
-    }
2106
+        );
2107
+      }
2108 2108
 
2109
-    if(!$update_tables['que'])
2110
-    {
2111
-      upd_create_table('que',
2112
-        "(
2109
+      if(!$update_tables['que'])
2110
+      {
2111
+        upd_create_table('que',
2112
+          "(
2113 2113
           `que_id` SERIAL COMMENT 'Internal que id',
2114 2114
 
2115 2115
           `que_player_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Que owner ID',
@@ -2135,175 +2135,175 @@  discard block
 block discarded – undo
2135 2135
           CONSTRAINT `FK_que_planet_id` FOREIGN KEY (`que_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,
2136 2136
           CONSTRAINT `FK_que_planet_id_origin` FOREIGN KEY (`que_planet_id_origin`) REFERENCES `{$config->db_prefix}planets` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
2137 2137
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
2138
-      );
2139
-    }
2138
+        );
2139
+      }
2140 2140
 
2141
-    // Конвертирум очередь исследований
2142
-    if($update_tables['users']['que'])
2143
-    {
2144
-      $que_lines = array();
2145
-      $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`");
2146
-      while($que_row = db_fetch($que_query))
2141
+      // Конвертирум очередь исследований
2142
+      if($update_tables['users']['que'])
2147 2143
       {
2148
-        $que_data = explode(',', $que_row['que']);
2149
-
2150
-        if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech')))
2144
+        $que_lines = array();
2145
+        $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`");
2146
+        while($que_row = db_fetch($que_query))
2151 2147
         {
2152
-          continue;
2153
-        }
2148
+          $que_data = explode(',', $que_row['que']);
2154 2149
 
2155
-        $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0;
2156
-        // Если планета пустая - ставим главку
2157
-        $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet'];
2158
-        if($que_data[QI_PLANET_ID])
2159
-        {
2160
-          $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2161
-          if(!$que_planet_check['id'])
2150
+          if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech')))
2151
+          {
2152
+            continue;
2153
+          }
2154
+
2155
+          $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0;
2156
+          // Если планета пустая - ставим главку
2157
+          $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet'];
2158
+          if($que_data[QI_PLANET_ID])
2162 2159
           {
2163
-            $que_data[QI_PLANET_ID] = $que_row['id_planet'];
2164 2160
             $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2165 2161
             if(!$que_planet_check['id'])
2166 2162
             {
2167
-              $que_data[QI_PLANET_ID] = 'NULL';
2163
+              $que_data[QI_PLANET_ID] = $que_row['id_planet'];
2164
+              $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2165
+              if(!$que_planet_check['id'])
2166
+              {
2167
+                $que_data[QI_PLANET_ID] = 'NULL';
2168
+              }
2168 2169
             }
2169 2170
           }
2170
-        }
2171
-        else
2172
-        {
2173
-          $que_data[QI_PLANET_ID] = 'NULL';
2174
-        }
2171
+          else
2172
+          {
2173
+            $que_data[QI_PLANET_ID] = 'NULL';
2174
+          }
2175 2175
 
2176
-        $unit_info = get_unit_param($que_data[QI_UNIT_ID]);
2177
-        $unit_level = $que_row[$unit_info[P_NAME]];
2178
-        $unit_factor = $unit_info[P_COST][P_FACTOR] ? $unit_info[P_COST][P_FACTOR] : 1;
2179
-        $price_increase = pow($unit_factor, $unit_level);
2180
-        $unit_level++;
2181
-        $unit_cost = array();
2182
-        foreach($unit_info[P_COST] as $resource_id => $resource_amount)
2183
-        {
2184
-          if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase))
2176
+          $unit_info = get_unit_param($que_data[QI_UNIT_ID]);
2177
+          $unit_level = $que_row[$unit_info[P_NAME]];
2178
+          $unit_factor = $unit_info[P_COST][P_FACTOR] ? $unit_info[P_COST][P_FACTOR] : 1;
2179
+          $price_increase = pow($unit_factor, $unit_level);
2180
+          $unit_level++;
2181
+          $unit_cost = array();
2182
+          foreach($unit_info[P_COST] as $resource_id => $resource_amount)
2185 2183
           {
2186
-            continue;
2184
+            if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase))
2185
+            {
2186
+              continue;
2187
+            }
2188
+            $unit_cost[] = $resource_id . ',' . floor($resource_cost);
2187 2189
           }
2188
-          $unit_cost[] = $resource_id . ',' . floor($resource_cost);
2190
+          $unit_cost = implode(';', $unit_cost);
2191
+
2192
+          $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," .
2193
+            BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')";
2189 2194
         }
2190
-        $unit_cost = implode(';', $unit_cost);
2191 2195
 
2192
-        $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," .
2193
-          BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')";
2194
-      }
2196
+        if(!empty($que_lines))
2197
+        {
2198
+          upd_do_query('INSERT INTO `{{que}}` (`que_player_id`,`que_planet_id_origin`,`que_type`,`que_time_left`,`que_unit_id`,`que_unit_amount`,`que_unit_mode`,`que_unit_level`,`que_unit_time`,`que_unit_price`) VALUES ' . implode(',', $que_lines));
2199
+        }
2195 2200
 
2196
-      if(!empty($que_lines))
2197
-      {
2198
-        upd_do_query('INSERT INTO `{{que}}` (`que_player_id`,`que_planet_id_origin`,`que_type`,`que_time_left`,`que_unit_id`,`que_unit_amount`,`que_unit_mode`,`que_unit_level`,`que_unit_time`,`que_unit_price`) VALUES ' . implode(',', $que_lines));
2201
+        upd_alter_table('users', array(
2202
+          "DROP COLUMN `que`",
2203
+        ), $update_tables['users']['que']);
2199 2204
       }
2200 2205
 
2201
-      upd_alter_table('users', array(
2202
-        "DROP COLUMN `que`",
2203
-      ), $update_tables['users']['que']);
2204
-    }
2205
-
2206
-
2207
-    upd_check_key('server_que_length_research', 1, !isset($config->server_que_length_research));
2208 2206
 
2207
+      upd_check_key('server_que_length_research', 1, !isset($config->server_que_length_research));
2209 2208
 
2210
-    // Ковертируем технологии в таблицы
2211
-    if($update_tables['users']['graviton_tech'])
2212
-    {
2213
-      upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES);
2214 2209
 
2215
-      $que_lines = array();
2216
-      $user_query = upd_do_query("SELECT * FROM {{users}}");
2217
-      upd_add_more_time(300);
2218
-      $sn_group_tech = sn_get_groups('tech');
2219
-      while($user_row = db_fetch($user_query))
2210
+      // Ковертируем технологии в таблицы
2211
+      if($update_tables['users']['graviton_tech'])
2220 2212
       {
2221
-        foreach($sn_group_tech as $tech_id)
2213
+        upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES);
2214
+
2215
+        $que_lines = array();
2216
+        $user_query = upd_do_query("SELECT * FROM {{users}}");
2217
+        upd_add_more_time(300);
2218
+        $sn_group_tech = sn_get_groups('tech');
2219
+        while($user_row = db_fetch($user_query))
2222 2220
         {
2223
-          if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)]))
2221
+          foreach($sn_group_tech as $tech_id)
2224 2222
           {
2225
-            $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})";
2223
+            if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)]))
2224
+            {
2225
+              $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})";
2226
+            }
2226 2227
           }
2227 2228
         }
2228
-      }
2229
-
2230
-      if(!empty($que_lines))
2231
-      {
2232
-        upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES " . implode(',', $que_lines));
2233
-      }
2234
-
2235
-      upd_alter_table('users', array(
2236
-        "DROP COLUMN `graviton_tech`",
2237
-      ), $update_tables['users']['graviton_tech']);
2238
-    }
2239 2229
 
2240
-    if(!$update_indexes['unit']['I_unit_record_search'])
2241
-    {
2242
-      upd_alter_table('unit', array(
2243
-        "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)",
2244
-      ), !$update_indexes['unit']['I_unit_record_search']);
2230
+        if(!empty($que_lines))
2231
+        {
2232
+          upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES " . implode(',', $que_lines));
2233
+        }
2245 2234
 
2246
-      foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id)
2247
-      {
2248
-        $planet_units[get_unit_param($unit_id, P_NAME)] = 1;
2235
+        upd_alter_table('users', array(
2236
+          "DROP COLUMN `graviton_tech`",
2237
+        ), $update_tables['users']['graviton_tech']);
2249 2238
       }
2250
-      $drop_index = array();
2251
-      $create_index = &$drop_index; // array();
2252
-      foreach($planet_units as $unit_name => $unit_create)
2239
+
2240
+      if(!$update_indexes['unit']['I_unit_record_search'])
2253 2241
       {
2254
-        if($update_indexes['planets']['I_' . $unit_name])
2242
+        upd_alter_table('unit', array(
2243
+          "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)",
2244
+        ), !$update_indexes['unit']['I_unit_record_search']);
2245
+
2246
+        foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id)
2255 2247
         {
2256
-          $drop_index[] = "DROP KEY I_{$unit_name}";
2248
+          $planet_units[get_unit_param($unit_id, P_NAME)] = 1;
2257 2249
         }
2258
-        if($update_indexes['planets']['i_' . $unit_name])
2250
+        $drop_index = array();
2251
+        $create_index = &$drop_index; // array();
2252
+        foreach($planet_units as $unit_name => $unit_create)
2259 2253
         {
2260
-          $drop_index[] = "DROP KEY i_{$unit_name}";
2261
-        }
2254
+          if($update_indexes['planets']['I_' . $unit_name])
2255
+          {
2256
+            $drop_index[] = "DROP KEY I_{$unit_name}";
2257
+          }
2258
+          if($update_indexes['planets']['i_' . $unit_name])
2259
+          {
2260
+            $drop_index[] = "DROP KEY i_{$unit_name}";
2261
+          }
2262 2262
 
2263
-        if($unit_create)
2264
-        {
2265
-          $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)";
2263
+          if($unit_create)
2264
+          {
2265
+            $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)";
2266
+          }
2266 2267
         }
2268
+        upd_alter_table('planets', $drop_index, true);
2267 2269
       }
2268
-      upd_alter_table('planets', $drop_index, true);
2269
-    }
2270 2270
 
2271
-    upd_alter_table('users', array(
2272
-      "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`",
2273
-    ), !$update_tables['users']['user_time_utc_offset']);
2271
+      upd_alter_table('users', array(
2272
+        "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`",
2273
+      ), !$update_tables['users']['user_time_utc_offset']);
2274 2274
 
2275
-    if(!$update_foreigns['alliance']['FK_alliance_owner'])
2276
-    {
2277
-      upd_do_query("UPDATE {{alliance}} SET ally_owner = null WHERE ally_owner not in (select id from {{users}})");
2275
+      if(!$update_foreigns['alliance']['FK_alliance_owner'])
2276
+      {
2277
+        upd_do_query("UPDATE {{alliance}} SET ally_owner = null WHERE ally_owner not in (select id from {{users}})");
2278 2278
 
2279
-      upd_alter_table('alliance', array(
2280
-        "ADD CONSTRAINT `FK_alliance_owner` FOREIGN KEY (`ally_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
2281
-      ), !$update_foreigns['alliance']['FK_alliance_owner']);
2279
+        upd_alter_table('alliance', array(
2280
+          "ADD CONSTRAINT `FK_alliance_owner` FOREIGN KEY (`ally_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE",
2281
+        ), !$update_foreigns['alliance']['FK_alliance_owner']);
2282 2282
 
2283
-      upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id not in (select id from {{alliance}}) OR alliance_negotiation_contr_ally_id not in (select id from {{alliance}})");
2283
+        upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id not in (select id from {{alliance}}) OR alliance_negotiation_contr_ally_id not in (select id from {{alliance}})");
2284 2284
 
2285
-      upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id = alliance_negotiation_contr_ally_id");
2286
-      upd_do_query("DELETE FROM {{alliance_diplomacy}} WHERE alliance_diplomacy_ally_id = alliance_diplomacy_contr_ally_id");
2287
-    }
2285
+        upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id = alliance_negotiation_contr_ally_id");
2286
+        upd_do_query("DELETE FROM {{alliance_diplomacy}} WHERE alliance_diplomacy_ally_id = alliance_diplomacy_contr_ally_id");
2287
+      }
2288 2288
 
2289
-    upd_alter_table('fleets', array(
2290
-      'MODIFY COLUMN `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL',
2291
-      "ADD CONSTRAINT `FK_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
2292
-    ), strtoupper($update_tables['fleets']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED');
2289
+      upd_alter_table('fleets', array(
2290
+        'MODIFY COLUMN `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL',
2291
+        "ADD CONSTRAINT `FK_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE",
2292
+      ), strtoupper($update_tables['fleets']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED');
2293 2293
 
2294
-    upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !$config->chat_highlight_developer);
2294
+      upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !$config->chat_highlight_developer);
2295 2295
 
2296
-    if(!$update_tables['player_name_history'])
2297
-    {
2298
-      upd_check_key('game_user_changename_cost', 100000, !$config->game_user_changename_cost);
2299
-      upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY);
2296
+      if(!$update_tables['player_name_history'])
2297
+      {
2298
+        upd_check_key('game_user_changename_cost', 100000, !$config->game_user_changename_cost);
2299
+        upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY);
2300 2300
 
2301
-      upd_alter_table('users', array(
2302
-        "CHANGE COLUMN `username` `username` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'Player name'",
2303
-      ));
2301
+        upd_alter_table('users', array(
2302
+          "CHANGE COLUMN `username` `username` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'Player name'",
2303
+        ));
2304 2304
 
2305
-      upd_create_table('player_name_history',
2306
-        "(
2305
+        upd_create_table('player_name_history',
2306
+          "(
2307 2307
           `player_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Player ID',
2308 2308
           `player_name` VARCHAR(32) NOT NULL COMMENT 'Historical player name',
2309 2309
           `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When player changed name',
@@ -2313,79 +2313,79 @@  discard block
 block discarded – undo
2313 2313
 
2314 2314
           CONSTRAINT `FK_player_name_history_id` FOREIGN KEY (`player_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
2315 2315
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
2316
-      );
2316
+        );
2317 2317
 
2318
-      upd_do_query("REPLACE INTO {{player_name_history}} (`player_id`, `player_name`) SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NULL;");
2319
-    }
2318
+        upd_do_query("REPLACE INTO {{player_name_history}} (`player_id`, `player_name`) SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NULL;");
2319
+      }
2320 2320
 
2321
-    upd_alter_table('planets', array(
2322
-      "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'",
2323
-      "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'",
2324
-    ), !$update_tables['planets']['density_index']);
2321
+      upd_alter_table('planets', array(
2322
+        "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'",
2323
+        "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'",
2324
+      ), !$update_tables['planets']['density_index']);
2325 2325
 
2326
-    if($update_tables['users']['player_artifact_list'])
2327
-    {
2328
-      upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']);
2326
+      if($update_tables['users']['player_artifact_list'])
2327
+      {
2328
+        upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']);
2329 2329
 
2330
-      upd_alter_table('unit', "ADD KEY `I_unit_player_location_snid` (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_snid`)", !$update_indexes['unit']['I_unit_player_location_snid']);
2331
-      upd_alter_table('unit', "DROP KEY `I_unit_player_id_temporary`", $update_indexes['unit']['I_unit_player_id_temporary']);
2330
+        upd_alter_table('unit', "ADD KEY `I_unit_player_location_snid` (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_snid`)", !$update_indexes['unit']['I_unit_player_location_snid']);
2331
+        upd_alter_table('unit', "DROP KEY `I_unit_player_id_temporary`", $update_indexes['unit']['I_unit_player_id_temporary']);
2332 2332
 
2333
-      $sn_data_artifacts = sn_get_groups('artifacts');
2334
-      $db_changeset = array();
2333
+        $sn_data_artifacts = sn_get_groups('artifacts');
2334
+        $db_changeset = array();
2335 2335
 
2336
-      $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE");
2337
-      while($row = db_fetch($query))
2338
-      {
2339
-        $artifact_list = explode(';', $row['player_artifact_list']);
2340
-        if(!$row['player_artifact_list'] || empty($artifact_list))
2341
-        {
2342
-          continue;
2343
-        }
2344
-        foreach($artifact_list as $key => &$value)
2336
+        $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE");
2337
+        while($row = db_fetch($query))
2345 2338
         {
2346
-          $value = explode(',', $value);
2347
-          if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]]))
2339
+          $artifact_list = explode(';', $row['player_artifact_list']);
2340
+          if(!$row['player_artifact_list'] || empty($artifact_list))
2348 2341
           {
2349
-            unset($artifact_list[$key]);
2350 2342
             continue;
2351 2343
           }
2352
-          $db_changeset['unit'][] = upd_db_unit_changeset_prepare($value[0], $value[1], $row);
2344
+          foreach($artifact_list as $key => &$value)
2345
+          {
2346
+            $value = explode(',', $value);
2347
+            if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]]))
2348
+            {
2349
+              unset($artifact_list[$key]);
2350
+              continue;
2351
+            }
2352
+            $db_changeset['unit'][] = upd_db_unit_changeset_prepare($value[0], $value[1], $row);
2353
+          }
2353 2354
         }
2354
-      }
2355
-      upd_db_changeset_apply($db_changeset);
2355
+        upd_db_changeset_apply($db_changeset);
2356 2356
 
2357
-      upd_alter_table('users', "DROP COLUMN `player_artifact_list`", $update_tables['users']['player_artifact_list']);
2358
-    }
2357
+        upd_alter_table('users', "DROP COLUMN `player_artifact_list`", $update_tables['users']['player_artifact_list']);
2358
+      }
2359 2359
 
2360
-    upd_alter_table('users', array(
2361
-      "DROP COLUMN `spy_tech`",
2362
-      "DROP COLUMN `computer_tech`",
2363
-      "DROP COLUMN `military_tech`",
2364
-      "DROP COLUMN `defence_tech`",
2365
-      "DROP COLUMN `shield_tech`",
2366
-      "DROP COLUMN `energy_tech`",
2367
-      "DROP COLUMN `hyperspace_tech`",
2368
-      "DROP COLUMN `combustion_tech`",
2369
-      "DROP COLUMN `impulse_motor_tech`",
2370
-      "DROP COLUMN `hyperspace_motor_tech`",
2371
-      "DROP COLUMN `laser_tech`",
2372
-      "DROP COLUMN `ionic_tech`",
2373
-      "DROP COLUMN `buster_tech`",
2374
-      "DROP COLUMN `intergalactic_tech`",
2375
-      "DROP COLUMN `expedition_tech`",
2376
-      "DROP COLUMN `colonisation_tech`",
2377
-    ), $update_tables['users']['spy_tech']);
2378
-
2379
-    upd_check_key('payment_currency_exchange_dm_', 2500,             !$config->payment_currency_exchange_dm_ || $config->payment_currency_exchange_dm_ == 1000);
2380
-    upd_check_key('payment_currency_exchange_eur', 0.09259259259259, !$config->payment_currency_exchange_eur);
2381
-    upd_check_key('payment_currency_exchange_rub', 4.0,              !$config->payment_currency_exchange_rub);
2382
-    upd_check_key('payment_currency_exchange_usd', 0.125,            !$config->payment_currency_exchange_usd);
2383
-    upd_check_key('payment_currency_exchange_wme', 0.0952380952381,  !$config->payment_currency_exchange_usd);
2384
-    upd_check_key('payment_currency_exchange_wmr', 4.1,              !$config->payment_currency_exchange_wmr);
2385
-    upd_check_key('payment_currency_exchange_wmu', 1.05,             !$config->payment_currency_exchange_wmu);
2386
-    upd_check_key('payment_currency_exchange_wmz', 0.126582278481,   !$config->payment_currency_exchange_wmz);
2360
+      upd_alter_table('users', array(
2361
+        "DROP COLUMN `spy_tech`",
2362
+        "DROP COLUMN `computer_tech`",
2363
+        "DROP COLUMN `military_tech`",
2364
+        "DROP COLUMN `defence_tech`",
2365
+        "DROP COLUMN `shield_tech`",
2366
+        "DROP COLUMN `energy_tech`",
2367
+        "DROP COLUMN `hyperspace_tech`",
2368
+        "DROP COLUMN `combustion_tech`",
2369
+        "DROP COLUMN `impulse_motor_tech`",
2370
+        "DROP COLUMN `hyperspace_motor_tech`",
2371
+        "DROP COLUMN `laser_tech`",
2372
+        "DROP COLUMN `ionic_tech`",
2373
+        "DROP COLUMN `buster_tech`",
2374
+        "DROP COLUMN `intergalactic_tech`",
2375
+        "DROP COLUMN `expedition_tech`",
2376
+        "DROP COLUMN `colonisation_tech`",
2377
+      ), $update_tables['users']['spy_tech']);
2378
+
2379
+      upd_check_key('payment_currency_exchange_dm_', 2500,             !$config->payment_currency_exchange_dm_ || $config->payment_currency_exchange_dm_ == 1000);
2380
+      upd_check_key('payment_currency_exchange_eur', 0.09259259259259, !$config->payment_currency_exchange_eur);
2381
+      upd_check_key('payment_currency_exchange_rub', 4.0,              !$config->payment_currency_exchange_rub);
2382
+      upd_check_key('payment_currency_exchange_usd', 0.125,            !$config->payment_currency_exchange_usd);
2383
+      upd_check_key('payment_currency_exchange_wme', 0.0952380952381,  !$config->payment_currency_exchange_usd);
2384
+      upd_check_key('payment_currency_exchange_wmr', 4.1,              !$config->payment_currency_exchange_wmr);
2385
+      upd_check_key('payment_currency_exchange_wmu', 1.05,             !$config->payment_currency_exchange_wmu);
2386
+      upd_check_key('payment_currency_exchange_wmz', 0.126582278481,   !$config->payment_currency_exchange_wmz);
2387 2387
 
2388
-    upd_do_query('COMMIT;', true);
2389
-    $new_version = 37;
2388
+      upd_do_query('COMMIT;', true);
2389
+      $new_version = 37;
2390 2390
 
2391 2391
 }
Please login to merge, or discard this patch.
includes/pages/imperator.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 //    $same_user = false;
54 54
 //  }
55 55
 
56
-  if(!$user_data) {
56
+  if (!$user_data) {
57 57
     message($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10);
58 58
     die();
59 59
   }
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
   $stat_array = array();
65 65
   $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;");
66 66
   $stat_count = classSupernova::$db->db_affected_rows();
67
-  while($row = db_fetch($query)) {
68
-    foreach($stat_fields as $field_db_name => $field_template_name) {
67
+  while ($row = db_fetch($query)) {
68
+    foreach ($stat_fields as $field_db_name => $field_template_name) {
69 69
       // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS
70 70
       $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name];
71 71
     }
72 72
   }
73 73
 
74 74
   $stat_array_date = $stat_array['STAT_DATE'];
75
-  foreach($stat_array_date['DATA'] as $key => $value) {
75
+  foreach ($stat_array_date['DATA'] as $key => $value) {
76 76
     $template->assign_block_vars('stat_date', array(
77 77
       'ID' => $key,
78 78
       'VALUE' => $value,
@@ -85,17 +85,17 @@  discard block
 block discarded – undo
85 85
 
86 86
   unset($stat_array['STAT_DATE']);
87 87
   $template_data = array();
88
-  foreach($stat_array as $stat_type => &$stat_type_data) {
88
+  foreach ($stat_array as $stat_type => &$stat_type_data) {
89 89
     $reverse_min_max = strpos($stat_type, '_RANK') !== false;
90 90
     $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']);
91 91
     $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']);
92 92
     $stat_type_data['AVG'] = average($stat_type_data['DATA']);
93
-    foreach($stat_type_data['DATA'] as $key => $value) {
93
+    foreach ($stat_type_data['DATA'] as $key => $value) {
94 94
       // $stat_type_data['PERCENT'][$key] = $stat_type_data['MAX'] - $value ? ($stat_type_data['MAX'] - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $value) : 100;
95 95
       $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100;
96 96
       $template_data[$stat_type][$key]['ID'] = $key;
97 97
       $template_data[$stat_type][$key]['VALUE'] = $value;
98
-      $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN']  - $value : $value - $stat_type_data['MAX']);
98
+      $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']);
99 99
       $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key];
100 100
 
101 101
 //$template_data[$stat_type][$key]['PERCENT'] = $key ? $stat_type_data['PERCENT'][$key] : 50; // TODO DEBUG
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
   }
104 104
   // pdump($stat_array['RES_POINTS']);
105 105
 
106
-  foreach($template_data as $stat_type => $stat_type_data) {
106
+  foreach ($template_data as $stat_type => $stat_type_data) {
107 107
     $template->assign_block_vars('stat', array(
108 108
       'TYPE' => $stat_type,
109 109
       'TEXT' => $lang['imp_stat_types'][$stat_type],
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
       'MAX' => $stat_array[$stat_type]['MAX'],
112 112
       'AVG' => $stat_array[$stat_type]['AVG'],
113 113
     ));
114
-    foreach($stat_type_data as $stat_entry) {
114
+    foreach ($stat_type_data as $stat_entry) {
115 115
       $template->assign_block_vars('stat.entry', $stat_entry);
116 116
     }
117 117
   }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
   // pdump($template_data);
121 121
 
122
-  if($same_user) {
122
+  if ($same_user) {
123 123
     rpg_level_up($user, RPG_STRUCTURE);
124 124
     rpg_level_up($user, RPG_RAID);
125 125
     rpg_level_up($user, RPG_TECH);
@@ -153,29 +153,29 @@  discard block
 block discarded – undo
153 153
     'builder_xp'           => pretty_number($user_data['xpminier']),
154 154
     'builder_lvl'          => pretty_number($user_data['lvl_minier']),
155 155
     'builder_lvl_st'       => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'])),
156
-    'builder_lvl_up'       => pretty_number(rpg_get_miner_xp($user_data['lvl_minier']+1)),
156
+    'builder_lvl_up'       => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'] + 1)),
157 157
     'raid_xp'              => pretty_number($user_data['xpraid']),
158 158
     'raid_lvl'             => pretty_number($user_data['lvl_raid']),
159
-    'raid_lvl_up'          => pretty_number(rpg_get_raider_xp($user_data['lvl_raid']+1)),
159
+    'raid_lvl_up'          => pretty_number(rpg_get_raider_xp($user_data['lvl_raid'] + 1)),
160 160
     'raids'                => pretty_number($user_data['raids']),
161 161
     'raidswin'             => pretty_number($user_data['raidswin']),
162 162
     'raidsloose'           => pretty_number($user_data['raidsloose']),
163 163
     'tech_xp'              => pretty_number($user_data['player_rpg_tech_xp']),
164 164
     'tech_lvl'             => pretty_number($user_data['player_rpg_tech_level']),
165 165
     'tech_lvl_st'          => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'])),
166
-    'tech_lvl_up'          => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)),
166
+    'tech_lvl_up'          => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)),
167 167
 
168 168
     'explore_xp'           => pretty_number($user_data['player_rpg_explore_xp']),
169 169
     'explore_lvl'          => pretty_number($user_data['player_rpg_explore_level']),
170 170
     'explore_lvl_st'       => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'])),
171
-    'explore_lvl_up'       => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)),
172
-
173
-    'build_points'         => pretty_number( $StatRecord['build_points'] ),
174
-    'tech_points'          => pretty_number( $StatRecord['tech_points'] ),
175
-    'fleet_points'         => pretty_number( $StatRecord['fleet_points'] ),
176
-    'defs_points'          => pretty_number( $StatRecord['defs_points'] ),
177
-    'res_points'           => pretty_number( $StatRecord['res_points'] ),
178
-    'total_points'         => pretty_number( $StatRecord['total_points'] ),
171
+    'explore_lvl_up'       => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)),
172
+
173
+    'build_points'         => pretty_number($StatRecord['build_points']),
174
+    'tech_points'          => pretty_number($StatRecord['tech_points']),
175
+    'fleet_points'         => pretty_number($StatRecord['fleet_points']),
176
+    'defs_points'          => pretty_number($StatRecord['defs_points']),
177
+    'res_points'           => pretty_number($StatRecord['res_points']),
178
+    'total_points'         => pretty_number($StatRecord['total_points']),
179 179
     'user_rank'            => $StatRecord['total_rank'],
180 180
     'RANK_DIFF'            => $StatRecord['total_old_rank'] - $StatRecord['total_rank'],
181 181
 
Please login to merge, or discard this patch.
includes/pages/techtree.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
   global $lang, $user, $planetrow;
15 15
 
16 16
   $tech_tree = array();
17
-  foreach(get_unit_param('techtree') as $unit_group_id => $unit_list)
17
+  foreach (get_unit_param('techtree') as $unit_group_id => $unit_list)
18 18
   {
19 19
     $tech_tree[] = array(
20 20
       'NAME' => $lang['tech'][$unit_group_id],
21 21
       'GROUP_ID' => $unit_group_id,
22 22
     );
23 23
 
24
-    foreach($unit_list as $unit_id)
24
+    foreach ($unit_list as $unit_id)
25 25
     {
26 26
       $sn_data_unit = get_unit_param($unit_id);
27 27
       $level_basic = $sn_data_unit[P_STACKABLE] ? 0 : mrc_get_level($user, $planetrow, $unit_id, false, true);
Please login to merge, or discard this patch.
includes/debug.class.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -140,11 +140,13 @@
 block discarded – undo
140 140
       $error_backtrace['locks'] = classSupernova::$locks;
141 141
       $error_backtrace['cSN_data'] = classSupernova::$data;
142 142
       foreach($error_backtrace['cSN_data'] as &$location) {
143
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
143
+        foreach($location as $location_id => &$location_data) {
144
+          //          $location_data = $location_id;
144 145
         {
145 146
           $location_data = isset($location_data['username']) ? $location_data['username'] :
146 147
             (isset($location_data['name']) ? $location_data['name'] : $location_id);
147 148
         }
149
+        }
148 150
       }
149 151
       $error_backtrace['cSN_queries'] = classSupernova::$queries;
150 152
     }
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Some helpers to sweeten dev's life
4
- */
3
+   * Some helpers to sweeten dev's life
4
+   */
5 5
 
6 6
 /*
7 7
  * debug.class.php ::  Clase Debug, maneja reporte de eventos
Please login to merge, or discard this patch.
Spacing   +37 added lines, -38 removed lines patch added patch discarded remove patch
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
   function log_file($message, $ident_change = 0) {
51 51
     static $ident = 0;
52 52
 
53
-    if(!defined('SN_DEBUG_LOG')) {
53
+    if (!defined('SN_DEBUG_LOG')) {
54 54
       return;
55 55
     }
56 56
 
57
-    if($this->log_file_handler === null) {
57
+    if ($this->log_file_handler === null) {
58 58
       $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
59 59
       @fwrite($this->log_file_handler, "\r\n\r\n");
60 60
     }
61 61
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
62
-    if($this->log_file_handler) {
62
+    if ($this->log_file_handler) {
63 63
       @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
64 64
     }
65 65
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
     $result = array();
91 91
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
92 92
     $result[] = "tID {$transaction_id}";
93
-    foreach($backtrace as $a_trace) {
94
-      if(in_array($a_trace['function'], $exclude_functions)) {
93
+    foreach ($backtrace as $a_trace) {
94
+      if (in_array($a_trace['function'], $exclude_functions)) {
95 95
         continue;
96 96
       }
97 97
       $function =
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
       // $result[] = "{$function} ({$a_trace['line']})'{$file}'";
109 109
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
110 110
 
111
-      if(!$long_comment) {
111
+      if (!$long_comment) {
112 112
         break;
113 113
       }
114 114
     }
@@ -120,26 +120,26 @@  discard block
 block discarded – undo
120 120
   }
121 121
 
122 122
   function dump($dump = false, $force_base = false, $deadlock = false) {
123
-    if($dump === false) {
123
+    if ($dump === false) {
124 124
       return;
125 125
     }
126 126
 
127 127
     $error_backtrace = array();
128 128
     $base_dump = false;
129 129
 
130
-    if($force_base === true) {
130
+    if ($force_base === true) {
131 131
       $base_dump = true;
132 132
     }
133 133
 
134
-    if($dump === true) {
134
+    if ($dump === true) {
135 135
       $base_dump = true;
136 136
     } else {
137
-      if(!is_array($dump)) {
137
+      if (!is_array($dump)) {
138 138
         $dump = array('var' => $dump);
139 139
       }
140 140
 
141
-      foreach($dump as $dump_var_name => $dump_var) {
142
-        if($dump_var_name == 'base_dump') {
141
+      foreach ($dump as $dump_var_name => $dump_var) {
142
+        if ($dump_var_name == 'base_dump') {
143 143
           $base_dump = $dump_var;
144 144
         } else {
145 145
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -148,26 +148,25 @@  discard block
 block discarded – undo
148 148
     }
149 149
 
150 150
 //    if($deadlock && ($q = db_fetch(classSupernova::$db->__db_query('SHOW ENGINE INNODB STATUS')))) {
151
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
151
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
152 152
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
153 153
       $error_backtrace['locks'] = classSupernova::$locks;
154 154
       $error_backtrace['cSN_data'] = classSupernova::$data;
155
-      foreach($error_backtrace['cSN_data'] as &$location) {
156
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
155
+      foreach ($error_backtrace['cSN_data'] as &$location) {
156
+        foreach ($location as $location_id => &$location_data) //          $location_data = $location_id;
157 157
         {
158
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
159
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
158
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
160 159
         }
161 160
       }
162 161
       $error_backtrace['cSN_queries'] = classSupernova::$queries;
163 162
     }
164 163
 
165
-    if($base_dump) {
166
-      if(is_array($this->log_array) && count($this->log_array) > 0) {
164
+    if ($base_dump) {
165
+      if (is_array($this->log_array) && count($this->log_array) > 0) {
167 166
 //        ;
168 167
 //      }
169 168
 //      {
170
-        foreach($this->log_array as $log) {
169
+        foreach ($this->log_array as $log) {
171 170
           $error_backtrace['queries'][] = $log;
172 171
         }
173 172
       }
@@ -198,14 +197,14 @@  discard block
 block discarded – undo
198 197
   function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
199 198
     global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user;
200 199
 
201
-    if(empty(classSupernova::$db->connected)) {
200
+    if (empty(classSupernova::$db->connected)) {
202 201
       // TODO - писать ошибку в файл
203 202
       die('SQL server currently unavailable. Please contact Administration...');
204 203
     }
205 204
 
206 205
     sn_db_transaction_rollback();
207 206
 
208
-    if($config->debug == 1) {
207
+    if ($config->debug == 1) {
209 208
       echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>";
210 209
       echo "<table>{$this->log}</table>";
211 210
     }
@@ -215,7 +214,7 @@  discard block
 block discarded – undo
215 214
     $error_text = db_escape($message);
216 215
     $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false);
217 216
 
218
-    if(!$sys_log_disabled) {
217
+    if (!$sys_log_disabled) {
219 218
       $query = "INSERT INTO `{{logs}}` SET
220 219
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($user['id']) . "',
221 220
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -233,7 +232,7 @@  discard block
 block discarded – undo
233 232
       ob_start();
234 233
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
235 234
 
236
-      foreach($error_backtrace as $name => $value) {
235
+      foreach ($error_backtrace as $name => $value) {
237 236
         print(__DEBUG_LINE);
238 237
         pdump($value, $name);
239 238
       }
@@ -245,14 +244,14 @@  discard block
 block discarded – undo
245 244
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
246 245
     global $user, $lang, $sys_log_disabled;
247 246
 
248
-    if(empty(classSupernova::$db->connected)) {
247
+    if (empty(classSupernova::$db->connected)) {
249 248
       // TODO - писать ошибку в файл
250 249
       die('SQL server currently unavailable. Please contact Administration...');
251 250
     }
252 251
 
253 252
     $error_backtrace = $this->dump($dump, false);
254 253
 
255
-    if(!$sys_log_disabled) {
254
+    if (!$sys_log_disabled) {
256 255
       $query = "INSERT INTO `{{logs}}` SET
257 256
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($user['id']) . "',
258 257
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -270,11 +269,11 @@  discard block
 block discarded – undo
270 269
 // Dump variables nicer then var_dump()
271 270
 
272 271
 function dump($value, $varname = null, $level = 0, $dumper = '') {
273
-  if(isset($varname)) {
272
+  if (isset($varname)) {
274 273
     $varname .= " = ";
275 274
   }
276 275
 
277
-  if($level == -1) {
276
+  if ($level == -1) {
278 277
     $trans[' '] = '&there4;';
279 278
     $trans["\t"] = '&rArr;';
280 279
     $trans["\n"] = '&para;;';
@@ -283,7 +282,7 @@  discard block
 block discarded – undo
283 282
 
284 283
     return strtr(htmlspecialchars($value), $trans);
285 284
   }
286
-  if($level == 0) {
285
+  if ($level == 0) {
287 286
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
288 287
     $dumper = mt_rand(10, 99) . '|' . $varname;
289 288
   }
@@ -291,22 +290,22 @@  discard block
 block discarded – undo
291 290
   $type = gettype($value);
292 291
   $dumper .= $type;
293 292
 
294
-  if($type == 'string') {
293
+  if ($type == 'string') {
295 294
     $dumper .= '(' . strlen($value) . ')';
296 295
     $value = dump($value, '', -1);
297
-  } elseif($type == 'boolean') {
296
+  } elseif ($type == 'boolean') {
298 297
     $value = ($value ? 'true' : 'false');
299
-  } elseif($type == 'object') {
298
+  } elseif ($type == 'object') {
300 299
     $props = get_class_vars(get_class($value));
301 300
     $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
302
-    foreach($props as $key => $val) {
301
+    foreach ($props as $key => $val) {
303 302
       $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
304 303
       $dumper .= dump($value->$key, '', $level + 1);
305 304
     }
306 305
     $value = '';
307
-  } elseif($type == 'array') {
306
+  } elseif ($type == 'array') {
308 307
     $dumper .= '(' . count($value) . ')';
309
-    foreach($value as $key => $val) {
308
+    foreach ($value as $key => $val) {
310 309
       $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
311 310
       $dumper .= dump($val, '', $level + 1);
312 311
     }
@@ -326,7 +325,7 @@  discard block
 block discarded – undo
326 325
 //  $backtrace = $backtrace[1];
327 326
 
328 327
   $caller = '';
329
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
328
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
330 329
     $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
331 330
       (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
332 331
       $backtrace[1]['function'] .
@@ -353,7 +352,7 @@  discard block
 block discarded – undo
353 352
 }
354 353
 
355 354
 function pr($prePrint = false) {
356
-  if($prePrint) {
355
+  if ($prePrint) {
357 356
     print(__DEBUG_CRLF);
358 357
   }
359 358
   print(mt_rand() . __DEBUG_CRLF);
@@ -363,7 +362,7 @@  discard block
 block discarded – undo
363 362
   global $_PRINT_COUNT_VALUE;
364 363
   $_PRINT_COUNT_VALUE++;
365 364
 
366
-  if($prePrint) {
365
+  if ($prePrint) {
367 366
     print(__DEBUG_CRLF);
368 367
   }
369 368
   print($_PRINT_COUNT_VALUE . __DEBUG_CRLF);
Please login to merge, or discard this patch.