Completed
Push — work-fleets ( 8f8df9...1920ae )
by SuperNova.WS
06:30
created
includes/classes/DBStaticNote.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
    * @param $note_id_edit
37 37
    */
38 38
   public static function db_note_update_by_id($note_priority, $note_title, $note_text, $note_galaxy, $note_system, $note_planet, $note_planet_type, $note_sticky, $note_id_edit) {
39
-    classSupernova::$db->doUpdate("UPDATE {{notes}} SET `time` = " . SN_TIME_NOW . ", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}',
39
+    classSupernova::$db->doUpdate("UPDATE {{notes}} SET `time` = ".SN_TIME_NOW.", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}',
40 40
         `galaxy` = {$note_galaxy}, `system` = {$note_system}, `planet` = {$note_planet}, `planet_type` = {$note_planet_type}, `sticky` = {$note_sticky}
41 41
         WHERE `id` = {$note_id_edit} LIMIT 1;");
42 42
   }
Please login to merge, or discard this patch.
includes/classes/UBE/UBEDebris.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
    */
28 28
   public function debris_add_resource($resource_id, $resource_amount) {
29 29
     // В обломках может быть только металл или кристалл
30
-    if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) {
30
+    if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) {
31 31
       return;
32 32
     }
33 33
     $this->debris[$resource_id] += $resource_amount;
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
    * @param bool  $is_simulator
39 39
    */
40 40
   public function add_wrecks(array $wreckage, $is_simulator) {
41
-    foreach($wreckage as $resource_id => $resource_amount) {
41
+    foreach ($wreckage as $resource_id => $resource_amount) {
42 42
       $this->debris_add_resource($resource_id, floor($resource_amount *
43 43
         ($is_simulator
44 44
           ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
    * @param bool  $is_simulator
55 55
    */
56 56
   public function add_cargo_drop(array $dropped_resources, $is_simulator) {
57
-    foreach($dropped_resources as $resource_id => $resource_amount) {
57
+    foreach ($dropped_resources as $resource_id => $resource_amount) {
58 58
       $this->debris_add_resource($resource_id, floor($resource_amount *
59 59
         ($is_simulator
60 60
           ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
    * @param $moon_debris_left_part
94 94
    */
95 95
   public function debris_adjust_proportional($moon_debris_left_part) {
96
-    foreach($this->debris as $resource_id => &$resource_amount) {
96
+    foreach ($this->debris as $resource_id => &$resource_amount) {
97 97
       $resource_amount = floor($resource_amount * $moon_debris_left_part);
98 98
     }
99 99
   }
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
    */
115 115
   public function report_generate_array() {
116 116
     return array(
117
-      'ube_report_debris_metal'          => (float)$this->debris_get_resource(RES_METAL),
118
-      'ube_report_debris_crystal'        => (float)$this->debris_get_resource(RES_CRYSTAL),
119
-      'ube_report_debris_total_in_metal' => (float)$this->debris_in_metal(),
117
+      'ube_report_debris_metal'          => (float) $this->debris_get_resource(RES_METAL),
118
+      'ube_report_debris_crystal'        => (float) $this->debris_get_resource(RES_CRYSTAL),
119
+      'ube_report_debris_total_in_metal' => (float) $this->debris_in_metal(),
120 120
     );
121 121
   }
122 122
 
Please login to merge, or discard this patch.
includes/classes/UBE/UBEMoonCalculator.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     $debris_for_moon = $debris->debris_total();
72 72
 
73
-    if(!$debris_for_moon) {
73
+    if (!$debris_for_moon) {
74 74
       return;
75 75
     }
76 76
 
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
     $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure
79 79
     $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0;
80 80
     $this->create_chance = $moon_chance;
81
-    if($moon_chance) {
82
-      if($is_simulator || mt_rand(1, 100) <= $moon_chance) {
81
+    if ($moon_chance) {
82
+      if ($is_simulator || mt_rand(1, 100) <= $moon_chance) {
83 83
         $this->status = UBE_MOON_CREATE_SUCCESS;
84 84
         $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999));
85 85
 
86
-        if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) {
86
+        if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) {
87 87
           $debris->_reset();
88 88
         } else {
89 89
           $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
    */
103 103
   protected function moon_destroy_try($reapers) {
104 104
     // TODO: $is_simulator
105
-    if($reapers <= 0) {
105
+    if ($reapers <= 0) {
106 106
       return;
107 107
     }
108 108
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
    * @version 2016-02-25 23:42:45 41a4.68
121 121
    */
122 122
   public function calculate_moon(UBE $ube) {
123
-    if(UBE_MOON_EXISTS == $this->status) {
124
-      if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) {
123
+    if (UBE_MOON_EXISTS == $this->status) {
124
+      if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) {
125 125
         $reapers = $ube->fleet_list->ube_calculate_attack_reapers();
126 126
         $this->moon_destroy_try($reapers);
127 127
       }
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
    */
136 136
   public function report_generate_array() {
137 137
     return array(
138
-      'ube_report_moon'                    => (int)$this->status,
139
-      'ube_report_moon_chance'             => (int)$this->create_chance,
140
-      'ube_report_moon_size'               => (float)$this->moon_diameter,
141
-      'ube_report_moon_reapers'            => (int)$this->reapers_status,
142
-      'ube_report_moon_destroy_chance'     => (int)$this->destroy_chance,
143
-      'ube_report_moon_reapers_die_chance' => (int)$this->reaper_die_chance,
138
+      'ube_report_moon'                    => (int) $this->status,
139
+      'ube_report_moon_chance'             => (int) $this->create_chance,
140
+      'ube_report_moon_size'               => (float) $this->moon_diameter,
141
+      'ube_report_moon_reapers'            => (int) $this->reapers_status,
142
+      'ube_report_moon_destroy_chance'     => (int) $this->destroy_chance,
143
+      'ube_report_moon_reapers_die_chance' => (int) $this->reaper_die_chance,
144 144
     );
145 145
   }
146 146
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
    * @param $planet_id
172 172
    */
173 173
   public function db_apply_result($planet_info, $destination_user_id) {
174
-    if($this->status == UBE_MOON_CREATE_SUCCESS) {
174
+    if ($this->status == UBE_MOON_CREATE_SUCCESS) {
175 175
       $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false);
176 176
       $this->moon_name = $moon_row['name'];
177 177
       unset($moon_row);
178
-    } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) {
178
+    } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) {
179 179
       DBStaticPlanet::db_planet_delete_by_id($planet_info[PLANET_ID]);
180 180
     }
181 181
   }
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
     $classLocale = classLocale::$lang;
185 185
 
186 186
     $text_defender = '';
187
-    if($this->status == UBE_MOON_CREATE_SUCCESS) {
187
+    if ($this->status == UBE_MOON_CREATE_SUCCESS) {
188 188
       $text_defender .= "{$classLocale['ube_report_moon_created']} {$this->moon_diameter} {$classLocale['sys_kilometers_short']}<br /><br />";
189
-    } elseif($this->status == UBE_MOON_CREATE_FAILED) {
189
+    } elseif ($this->status == UBE_MOON_CREATE_FAILED) {
190 190
       $text_defender .= "{$classLocale['ube_report_moon_chance']} {$this->create_chance}%<br /><br />";
191 191
     }
192 192
 
193
-    if($ube->mission_type_id == MT_DESTROY) {
194
-      if($this->reapers_status == UBE_MOON_REAPERS_NONE) {
193
+    if ($ube->mission_type_id == MT_DESTROY) {
194
+      if ($this->reapers_status == UBE_MOON_REAPERS_NONE) {
195 195
         $text_defender .= classLocale::$lang['ube_report_moon_reapers_none'];
196 196
       } else {
197 197
         $text_defender .= "{$classLocale['ube_report_moon_reapers_wave']}. {$classLocale['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. ";
198
-        $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure'] . "<br />";
198
+        $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure']."<br />";
199 199
 
200 200
         $text_defender .= "{$classLocale['ube_report_moon_reapers_outcome']} {$this->reaper_die_chance}%. ";
201 201
         $text_defender .= classLocale::$lang[$this->reapers_status == UBE_MOON_REAPERS_RETURNED ? 'ube_report_moon_reapers_survive' : 'ube_report_moon_reapers_died'];
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
    * @version 2016-02-25 23:42:45 41a4.68
221 221
    */
222 222
   public function ubeInitLoadStatis($destination_planet) {
223
-    if($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) {
223
+    if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) {
224 224
       $this->status = UBE_MOON_EXISTS;
225 225
       $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter'];
226 226
       $this->reapers_status = UBE_MOON_REAPERS_NONE;
Please login to merge, or discard this patch.
announce.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 $allow_anonymous = true;
12
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
12
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
13 13
 
14 14
 nws_mark_read($user);
15 15
 $template = gettemplate('announce', true);
@@ -23,42 +23,42 @@  discard block
 block discarded – undo
23 23
 $mode = sys_get_param_str('mode');
24 24
 
25 25
 $announce = array();
26
-if($user['authlevel'] >= 3) {
27
-  if(!empty($text)) {
26
+if ($user['authlevel'] >= 3) {
27
+  if (!empty($text)) {
28 28
     $announce_time = strtotime($announce_time, SN_TIME_NOW);
29 29
     $announce_time = $announce_time ? $announce_time : SN_TIME_NOW;
30 30
 
31
-    if($mode == 'edit') {
31
+    if ($mode == 'edit') {
32 32
       DBStaticNews::db_news_update_set($announce_time, $text, $detail_url, $announce_id);
33 33
       DBStaticSurvey::db_survey_delete_by_id($announce_id);
34 34
     } else {
35 35
       DBStaticNews::db_news_insert_set($announce_time, $text_unsafe, $detail_url_unsafe, $user['id'], $user['username']);
36 36
       $announce_id = classSupernova::$db->db_insert_id();
37 37
     }
38
-    if(($survey_question = sys_get_param_str('survey_question')) && ($survey_answers = sys_get_param('survey_answers'))) {
38
+    if (($survey_question = sys_get_param_str('survey_question')) && ($survey_answers = sys_get_param('survey_answers'))) {
39 39
       $survey_answers = explode("\r\n", $survey_answers);
40 40
       $survey_until = strtotime($survey_until = sys_get_param_str('survey_until'), SN_TIME_NOW);
41 41
       $survey_until = date(FMT_DATE_TIME_SQL, $survey_until ? $survey_until : SN_TIME_NOW + PERIOD_DAY * 1);
42 42
       $survey_question_unsafe = sys_get_param_str_unsafe('survey_question');
43 43
       DBStaticSurvey::db_survey_insert($announce_id, $survey_question_unsafe, $survey_until);
44 44
       $survey_id = classSupernova::$db->db_insert_id();
45
-      foreach($survey_answers as $survey_answer) {
45
+      foreach ($survey_answers as $survey_answer) {
46 46
         $survey_answer_unsafe = trim($survey_answer);
47
-        if(empty($survey_answer_unsafe)) {
47
+        if (empty($survey_answer_unsafe)) {
48 48
           continue;
49 49
         }
50 50
         DBStaticSurveyAnswer::db_survey_answer_insert($survey_id, $survey_answer_unsafe);
51 51
       }
52 52
     }
53 53
 
54
-    if($announce_time <= SN_TIME_NOW) {
55
-      if($announce_time > classSupernova::$config->var_news_last && $announce_time == SN_TIME_NOW) {
54
+    if ($announce_time <= SN_TIME_NOW) {
55
+      if ($announce_time > classSupernova::$config->var_news_last && $announce_time == SN_TIME_NOW) {
56 56
         classSupernova::$config->db_saveItem('var_news_last', $announce_time);
57 57
       }
58 58
 
59
-      if(sys_get_param_int('news_mass_mail')) {
59
+      if (sys_get_param_int('news_mass_mail')) {
60 60
         $lang_news_more = classLocale::$lang['news_more'];
61
-        $text = sys_get_param('text') . ($detail_url ? " <a href=\"{$detail_url}\"><span class=\"positive\">{$lang_news_more}</span></a>" : '');
61
+        $text = sys_get_param('text').($detail_url ? " <a href=\"{$detail_url}\"><span class=\"positive\">{$lang_news_more}</span></a>" : '');
62 62
         DBStaticMessages::msgSendFromAdmin('*', classLocale::$lang['news_title'], $text);
63 63
       }
64 64
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
   }
69 69
 
70 70
   $survey_answers = '';
71
-  switch($mode) {
71
+  switch ($mode) {
72 72
     case 'del':
73 73
       DBStaticNews::db_news_delete_by_id($announce_id);
74 74
       $mode = '';
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
       $template->assign_var('ID', $announce_id);
80 80
     case 'copy':
81 81
       $announce = DBStaticNews::db_news_with_survey_select_by_id($announce_id);
82
-      if($announce['survey_id']) {
82
+      if ($announce['survey_id']) {
83 83
         $query = DBStaticSurveyAnswer::db_survey_answer_text_select_by_news($announce);
84
-        while($row = db_fetch($query)) {
84
+        while ($row = db_fetch($query)) {
85 85
           $survey_answers[] = $row['survey_answer_text'];
86 86
         }
87 87
         $survey_answers = implode("\r\n", $survey_answers);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     break;
90 90
   }
91 91
 } else {
92
-  $annQuery = 'WHERE UNIX_TIMESTAMP(`tsTimeStamp`) <= ' . SN_TIME_NOW;
92
+  $annQuery = 'WHERE UNIX_TIMESTAMP(`tsTimeStamp`) <= '.SN_TIME_NOW;
93 93
 }
94 94
 
95 95
 nws_render($template, $annQuery, 20);
Please login to merge, or discard this patch.
notes.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 use Vector\Vector;
12 12
 
13
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
13
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
14 14
 lng_include('notes');
15 15
 
16 16
 global $user;
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
 $template = gettemplate('notes', true);
19 19
 
20 20
 $result = array();
21
-if(($result_message = sys_get_param_str('MESSAGE')) && isset(classLocale::$lang[$result_message])) {
21
+if (($result_message = sys_get_param_str('MESSAGE')) && isset(classLocale::$lang[$result_message])) {
22 22
   $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => classLocale::$lang[$result_message]);
23 23
 }
24 24
 
25 25
 $note_id_edit = sys_get_param_id('note_id_edit');
26 26
 $note_title_unsafe = sys_get_param_str_unsafe('note_title');
27 27
 $note_text_unsafe = sys_get_param_str_unsafe('note_text');
28
-if(sys_get_param('note_delete')) {
28
+if (sys_get_param('note_delete')) {
29 29
   try {
30 30
     DBStaticNote::processDelete($user, $note_id_edit);
31
-  } catch(Exception $e) {
31
+  } catch (Exception $e) {
32 32
     $note_id_edit = 0;
33 33
     sn_db_transaction_rollback();
34 34
     $result[] = array(
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
       'MESSAGE' => classLocale::$lang[$e->getMessage()],
37 37
     );
38 38
   }
39
-} elseif(($note_title_unsafe = sys_get_param_str_unsafe('note_title')) || ($note_text_unsafe = sys_get_param_str('note_text'))) {
39
+} elseif (($note_title_unsafe = sys_get_param_str_unsafe('note_title')) || ($note_text_unsafe = sys_get_param_str('note_text'))) {
40 40
   $note_title_unsafe == classLocale::$lang['note_new_title'] ? $note_title_unsafe = '' : false;
41 41
   $note_text_unsafe == classLocale::$lang['note_new_text'] ? $note_text_unsafe = '' : false;
42 42
   try {
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     $note_system = max(0, min(sys_get_param_id('note_system'), Vector::$knownSystems));
45 45
     $note_planet = max(0, min(sys_get_param_id('note_planet'), Vector::$knownPlanets + 1));
46 46
 
47
-    if(!$note_text_unsafe && !$note_title_unsafe && !$note_galaxy && !$note_system && !$note_planet) {
47
+    if (!$note_text_unsafe && !$note_title_unsafe && !$note_galaxy && !$note_system && !$note_planet) {
48 48
       throw new Exception('note_err_note_empty', ERR_WARNING);
49 49
     }
50 50
 
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
     $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0;
54 54
 
55 55
     sn_db_transaction_start();
56
-    if($note_id_edit) {
56
+    if ($note_id_edit) {
57 57
       $check_note_id = DBStaticNote::db_note_get_id_and_owner($note_id_edit);
58
-      if(!$check_note_id) {
58
+      if (!$check_note_id) {
59 59
         throw new Exception('note_err_note_not_found', ERR_ERROR);
60 60
       }
61 61
     }
62 62
 
63
-    if($note_id_edit) {
64
-      if($check_note_id['owner'] != $user['id']) {
63
+    if ($note_id_edit) {
64
+      if ($check_note_id['owner'] != $user['id']) {
65 65
         throw new Exception('note_err_owner_wrong', ERR_ERROR);
66 66
       }
67 67
 
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
     }
72 72
 
73 73
     sn_db_transaction_commit();
74
-    sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added'));
74
+    sys_redirect('notes.php?STATUS='.ERR_NONE.'&MESSAGE='.($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added'));
75 75
 //    throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE);
76
-  } catch(Exception $e) {
76
+  } catch (Exception $e) {
77 77
     $note_id_edit = 0;
78 78
     sn_db_transaction_rollback();
79 79
     $result[] = array(
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
   }
84 84
 }
85 85
 
86
-if(!$note_id_edit) {
86
+if (!$note_id_edit) {
87 87
   note_assign($template, array(
88 88
     'id'          => 0,
89 89
     'time'        => SN_TIME_NOW,
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
 
97 97
 $note_exist = false;
98 98
 $notes_query = DBStaticNote::db_note_list_by_owner($user['id']);
99
-while($note_row = db_fetch($notes_query)) {
99
+while ($note_row = db_fetch($notes_query)) {
100 100
   note_assign($template, $note_row);
101 101
   $note_exist = $note_exist || $note_row['id'] == $note_id_edit;
102 102
 }
103 103
 $note_id_edit = $note_exist ? $note_id_edit : 0;
104 104
 
105
-foreach($note_priority_classes as $note_priority_id => $note_priority_class) {
105
+foreach ($note_priority_classes as $note_priority_id => $note_priority_class) {
106 106
   $template->assign_block_vars('note_priority', array(
107 107
     'ID'    => $note_priority_id,
108 108
     'CLASS' => $note_priority_classes[$note_priority_id],
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
   ));
111 111
 }
112 112
 
113
-foreach(classLocale::$lang['sys_planet_type'] as $planet_type_id => $planet_type_string) {
113
+foreach (classLocale::$lang['sys_planet_type'] as $planet_type_id => $planet_type_string) {
114 114
   $template->assign_block_vars('planet_type', array(
115 115
     'ID'   => $planet_type_id,
116 116
     'TEXT' => $planet_type_string,
117 117
   ));
118 118
 }
119 119
 
120
-foreach($result as $result_data) {
120
+foreach ($result as $result_data) {
121 121
   $template->assign_block_vars('result', $result_data);
122 122
 }
123 123
 
Please login to merge, or discard this patch.