@@ -27,7 +27,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -70,7 +70,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -9,7 +9,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -10,7 +10,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -467,6 +467,12 @@ |
||
467 | 467 | {$StartRec}, 25;"); |
468 | 468 | } |
469 | 469 | |
470 | + /** |
|
471 | + * @param integer $message_type |
|
472 | + * @param string $from_unsafe |
|
473 | + * @param string $subject_unsafe |
|
474 | + * @param string $text_unsafe |
|
475 | + */ |
|
470 | 476 | public static function db_message_insert_all($message_type, $from_unsafe, $subject_unsafe, $text_unsafe) { |
471 | 477 | $message_type_safe = intval($message_type); |
472 | 478 | $from_safe = db_escape($from_unsafe); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | sys_user_options_unpack($owner_row); |
114 | 114 | |
115 | 115 | if ($force || !$message_class['switchable'] || $owner_row["opt_{$message_class_name}"]) { |
116 | - $insert_values[] = "('" . idval($owner) . "', '{$sender}', '{$timestamp}', '{$message_type}', '" . db_escape($from_unsafe) . "', '" . db_escape($subject_unsafe) . "', '" . db_escape($text_unsafe) . "')"; |
|
116 | + $insert_values[] = "('".idval($owner)."', '{$sender}', '{$timestamp}', '{$message_type}', '".db_escape($from_unsafe)."', '".db_escape($subject_unsafe)."', '".db_escape($text_unsafe)."')"; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // TODO - allow sending HTML email only from admin |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | array(), |
154 | 154 | array( |
155 | 155 | // TODO DANGER |
156 | - '`id` IN (' . implode(',', $owners) . ')', |
|
156 | + '`id` IN ('.implode(',', $owners).')', |
|
157 | 157 | ) |
158 | 158 | ); |
159 | 159 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $sendList = array(); |
173 | 173 | $list = ''; |
174 | 174 | $query = DBStaticUser::db_user_list( |
175 | - "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
|
175 | + "ally_id = '{$ally_id}'".($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
|
176 | 176 | false, 'id, username'); |
177 | 177 | foreach ($query as $u) { |
178 | 178 | $sendList[] = $u['id']; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $subject_unsafe = substr($subject_unsafe, strlen(classLocale::$lang['msg_answer_prefix'])); |
262 | 262 | $re++; |
263 | 263 | } |
264 | - $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'] . $subject_unsafe : false; |
|
264 | + $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'].$subject_unsafe : false; |
|
265 | 265 | |
266 | 266 | $subject_unsafe = $subject_unsafe ? $subject_unsafe : classLocale::$lang['msg_subject_default']; |
267 | 267 | |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | return classSupernova::$db->doSelect( |
438 | 438 | "SELECT * FROM {{messages}} |
439 | 439 | WHERE |
440 | - `message_type` = '" . MSG_TYPE_PLAYER . "' AND |
|
440 | + `message_type` = '" . MSG_TYPE_PLAYER."' AND |
|
441 | 441 | ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}') |
442 | 442 | OR |
443 | 443 | (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;"); |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | FROM |
482 | 482 | {{messages}} AS m |
483 | 483 | LEFT JOIN {{users}} AS u ON u.id = m.message_owner " . |
484 | - ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '') . |
|
484 | + ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : ''). |
|
485 | 485 | "ORDER BY |
486 | 486 | `message_id` DESC |
487 | 487 | LIMIT |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $subject_safe = db_escape($subject_unsafe); |
495 | 495 | $text_safe = db_escape($text_unsafe); |
496 | 496 | |
497 | - return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
|
497 | + return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '. |
|
498 | 498 | "SELECT `id`, 0, unix_timestamp(now()), {$message_type_safe}, '{$from_safe}', '{$subject_safe}', '{$text_safe}' FROM {{users}}"); |
499 | 499 | } |
500 | 500 | |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | * @return array|bool|mysqli_result|null |
505 | 505 | */ |
506 | 506 | public static function db_message_count_by_type($int_type_selected) { |
507 | - $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : '')); |
|
507 | + $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`'.($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : '')); |
|
508 | 508 | |
509 | 509 | return $page_max; |
510 | 510 | } |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | */ |
540 | 540 | public static function db_message_list_delete_by_date($delete_date, $int_type_selected) { |
541 | 541 | $where = array(); |
542 | - if($int_type_selected >= 0) { |
|
542 | + if ($int_type_selected >= 0) { |
|
543 | 543 | $where['message_type'] = $int_type_selected; |
544 | 544 | } |
545 | 545 | classSupernova::$db->doDeleteDanger( |
@@ -169,6 +169,11 @@ discard block |
||
169 | 169 | */ |
170 | 170 | // OK v4 |
171 | 171 | // TODO - вынести в отдельный класс |
172 | +/** |
|
173 | + * @param string $db_id_field_name |
|
174 | + * @param string $db_table_name |
|
175 | + * @param string $db_value_field_name |
|
176 | + */ |
|
172 | 177 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
173 | 178 | $current_value_safe = db_escape($current_value_unsafe); |
174 | 179 | $value_id = classSupernova::$db->doSelectFetch("SELECT `{$db_id_field_name}` FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE"); |
@@ -487,8 +492,8 @@ discard block |
||
487 | 492 | |
488 | 493 | |
489 | 494 | /** |
490 | - * @param $user_id |
|
491 | - * @param $change_type |
|
495 | + * @param integer $user_id |
|
496 | + * @param integer $change_type |
|
492 | 497 | * @param $dark_matter |
493 | 498 | * @param $comment_unsafe |
494 | 499 | * @param $rowUserNameUnsafe |
@@ -509,7 +514,7 @@ discard block |
||
509 | 514 | /** |
510 | 515 | * @param $user_id_safe |
511 | 516 | * |
512 | - * @return array|bool|mysqli_result|null |
|
517 | + * @return integer |
|
513 | 518 | */ |
514 | 519 | function db_referral_get_by_id($user_id_safe) { |
515 | 520 | $old_referral = classSupernova::$db->doSelectFetch("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;"); |
@@ -540,9 +545,9 @@ discard block |
||
540 | 545 | |
541 | 546 | // Quests *********************************************************************************************************** |
542 | 547 | /** |
543 | - * @param $query_add_select |
|
548 | + * @param string $query_add_select |
|
544 | 549 | * @param $query_add_from |
545 | - * @param $query_add_where |
|
550 | + * @param string $query_add_where |
|
546 | 551 | * |
547 | 552 | * @return array|bool|mysqli_result|null |
548 | 553 | */ |
@@ -586,11 +591,11 @@ discard block |
||
586 | 591 | } |
587 | 592 | |
588 | 593 | /** |
589 | - * @param $quest_name_unsafe |
|
590 | - * @param $quest_type |
|
591 | - * @param $quest_description_unsafe |
|
594 | + * @param string $quest_name_unsafe |
|
595 | + * @param integer $quest_type |
|
596 | + * @param string $quest_description_unsafe |
|
592 | 597 | * @param $quest_conditions |
593 | - * @param $quest_rewards |
|
598 | + * @param string $quest_rewards |
|
594 | 599 | * @param $quest_id |
595 | 600 | */ |
596 | 601 | function db_quest_update($quest_name_unsafe, $quest_type, $quest_description_unsafe, $quest_conditions, $quest_rewards, $quest_id) { |
@@ -674,7 +679,7 @@ discard block |
||
674 | 679 | |
675 | 680 | /** |
676 | 681 | * @param $payment_id |
677 | - * @param $payment_status |
|
682 | + * @param integer $payment_status |
|
678 | 683 | * @param $comment_unsafe |
679 | 684 | */ |
680 | 685 | function db_payment_update($payment_id, $payment_status, $comment_unsafe) { |
@@ -4,11 +4,11 @@ discard block |
||
4 | 4 | |
5 | 5 | function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) { |
6 | 6 | return classSupernova::$db->doSelect( |
7 | - "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') . |
|
7 | + "SELECT p.*, u.username".($table_parent_columns ? ', p1.name AS parent_name' : ''). |
|
8 | 8 | " FROM {{planets}} AS p |
9 | 9 | LEFT JOIN {{users}} AS u ON u.id = p.id_owner" . |
10 | - ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : '') . |
|
11 | - " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
|
10 | + ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : ''). |
|
11 | + " WHERE ".($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function db_planet_list_search($searchtext) { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | ORDER BY |
107 | 107 | sp.`{$Rank}_rank`, subject.{$source['id']} |
108 | 108 | LIMIT |
109 | - " . $start . ",100;"; |
|
109 | + ".$start.",100;"; |
|
110 | 110 | } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
111 | 111 | $query_str = |
112 | 112 | "SELECT |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | ORDER BY |
120 | 120 | subject.{$Rank} DESC, subject.{$source['id']} |
121 | 121 | LIMIT |
122 | - " . $start . ",100;"; |
|
122 | + ".$start.",100;"; |
|
123 | 123 | } |
124 | 124 | } else { |
125 | 125 | // TODO |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | ORDER BY |
137 | 137 | sp.`{$Rank}_rank`, subject.id |
138 | 138 | LIMIT |
139 | - " . $start . ",100;"; |
|
139 | + ".$start.",100;"; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | return classSupernova::$db->doSelect($query_str); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | |
146 | 146 | function db_stat_list_update_ally_stats() { |
147 | - return ; |
|
147 | + return; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | function db_stat_list_delete_ally_player() { |
@@ -394,9 +394,9 @@ discard block |
||
394 | 394 | */ |
395 | 395 | function db_payment_list_get($flt_payer, $flt_status, $flt_test, $flt_module) { |
396 | 396 | $extra_conditions = |
397 | - ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : '') . |
|
398 | - ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : '') . |
|
399 | - ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : '') . |
|
397 | + ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : ''). |
|
398 | + ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : ''). |
|
399 | + ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : ''). |
|
400 | 400 | ($flt_module ? "AND payment_module_name = '{$flt_module}' " : ''); |
401 | 401 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{payment}}` WHERE 1 {$extra_conditions} ORDER BY payment_id DESC;"); |
402 | 402 | |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | // Log Online ************************************************************************************************************* |
426 | 426 | function db_log_online_insert() { |
427 | 427 | classSupernova::$db->doInsertSet(TABLE_LOG_USERS_ONLINE, array( |
428 | - 'online_count' => (int)classSupernova::$config->var_online_user_count, |
|
428 | + 'online_count' => (int) classSupernova::$config->var_online_user_count, |
|
429 | 429 | ), DB_INSERT_IGNORE); |
430 | 430 | } |
431 | 431 | |
@@ -450,9 +450,9 @@ discard block |
||
450 | 450 | function db_log_delete_update_and_stat_calc() { |
451 | 451 | classSupernova::$db->doDeleteSimple( |
452 | 452 | 'DELETE FROM `{{logs}}` WHERE `log_code` IN (' |
453 | - . LOG_INFO_DB_CHANGE . ', ' |
|
454 | - . LOG_INFO_MAINTENANCE . ', ' |
|
455 | - . LOG_INFO_STAT_PROCESS . |
|
453 | + . LOG_INFO_DB_CHANGE.', ' |
|
454 | + . LOG_INFO_MAINTENANCE.', ' |
|
455 | + . LOG_INFO_STAT_PROCESS. |
|
456 | 456 | ')' |
457 | 457 | ); |
458 | 458 | } |
@@ -521,10 +521,10 @@ discard block |
||
521 | 521 | function db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment_unsafe, $rowUserNameUnsafe, $page_url_unsafe) { |
522 | 522 | return classSupernova::$db->doInsertSet(TABLE_LOG_DARK_MATTER, array( |
523 | 523 | 'log_dark_matter_username' => $rowUserNameUnsafe, |
524 | - 'log_dark_matter_reason' => (int)$change_type, |
|
525 | - 'log_dark_matter_amount' => (float)$dark_matter, |
|
526 | - 'log_dark_matter_comment' => (string)$comment_unsafe, |
|
527 | - 'log_dark_matter_page' => (string)$page_url_unsafe, |
|
524 | + 'log_dark_matter_reason' => (int) $change_type, |
|
525 | + 'log_dark_matter_amount' => (float) $dark_matter, |
|
526 | + 'log_dark_matter_comment' => (string) $comment_unsafe, |
|
527 | + 'log_dark_matter_page' => (string) $page_url_unsafe, |
|
528 | 528 | 'log_dark_matter_sender' => $user_id, |
529 | 529 | )); |
530 | 530 | } |
@@ -693,9 +693,9 @@ discard block |
||
693 | 693 | function db_ube_report_get_best_battles() { |
694 | 694 | $query = classSupernova::$db->doSelect("SELECT * |
695 | 695 | FROM `{{ube_report}}` |
696 | - WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS . " DAY)) |
|
696 | + WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS." DAY)) |
|
697 | 697 | ORDER BY `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC |
698 | - LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW . ";"); |
|
698 | + LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW.";"); |
|
699 | 699 | |
700 | 700 | return $query; |
701 | 701 | } |
@@ -1,23 +1,23 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
4 | 4 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
7 | -if(!$user_can_send_mails) { |
|
7 | +if (!$user_can_send_mails) { |
|
8 | 8 | message(classLocale::$lang['Denied_access'], classLocale::$lang['Send_circular_mail']); |
9 | 9 | } |
10 | 10 | |
11 | 11 | $POST_text = sys_get_param_str('text'); |
12 | 12 | $internalAliSendTextUnsafe = sys_get_param_str_unsafe('text'); |
13 | -if($internalAliSendTextUnsafe) { |
|
14 | - message(classLocale::$lang['members_who_recived_message'] . DBStaticMessages::msg_ali_send($internalAliSendTextUnsafe, classLocale::$lang['ali_adm_msg_subject'], sys_get_param_int('r')), classLocale::$lang['Circular_sended'], "alliance.php", ''); |
|
13 | +if ($internalAliSendTextUnsafe) { |
|
14 | + message(classLocale::$lang['members_who_recived_message'].DBStaticMessages::msg_ali_send($internalAliSendTextUnsafe, classLocale::$lang['ali_adm_msg_subject'], sys_get_param_int('r')), classLocale::$lang['Circular_sended'], "alliance.php", ''); |
|
15 | 15 | } |
16 | 16 | |
17 | -$r_list = "<option value=\"-1\">" . classLocale::$lang['All_players'] . "</option>"; |
|
18 | -if($ranks) { |
|
19 | - foreach($ranks as $id => $array) { |
|
20 | - $r_list .= "<option value=\"" . $id . "\">" . $array['name'] . "</option>"; |
|
17 | +$r_list = "<option value=\"-1\">".classLocale::$lang['All_players']."</option>"; |
|
18 | +if ($ranks) { |
|
19 | + foreach ($ranks as $id => $array) { |
|
20 | + $r_list .= "<option value=\"".$id."\">".$array['name']."</option>"; |
|
21 | 21 | } |
22 | 22 | } |
23 | 23 |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param db_mysql|null $db |
87 | 87 | */ |
88 | 88 | public static function setDb($db = null) { |
89 | - if(empty($db) || !($db instanceof db_mysql)) { |
|
89 | + if (empty($db) || !($db instanceof db_mysql)) { |
|
90 | 90 | $db = null; |
91 | 91 | } |
92 | 92 | static::$db = !empty($db) || !class_exists('classSupernova', false) ? $db : classSupernova::$db; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | public function dbLoad($dbId, $lockSkip = false) { |
150 | 150 | $dbId = idval($dbId); |
151 | 151 | if ($dbId <= 0) { |
152 | - classSupernova::$debug->error(get_called_class() . '::' . __METHOD__ . ' $dbId not positive = ' . $dbId); |
|
152 | + classSupernova::$debug->error(get_called_class().'::'.__METHOD__.' $dbId not positive = '.$dbId); |
|
153 | 153 | |
154 | 154 | return; |
155 | 155 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $this->dbGetLockById($this->_dbId); |
162 | 162 | } |
163 | 163 | |
164 | - $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId . " LIMIT 1 FOR UPDATE;"); |
|
164 | + $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{".static::$_table."}}` WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId." LIMIT 1 FOR UPDATE;"); |
|
165 | 165 | if (empty($db_row)) { |
166 | 166 | return; |
167 | 167 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if ($this->isNew()) { |
194 | 194 | // No DB_ID - new unit |
195 | 195 | if ($this->isEmpty()) { |
196 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave'); |
|
196 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - object is empty on '.get_called_class().'::dbSave'); |
|
197 | 197 | } |
198 | 198 | $this->dbInsert(); |
199 | 199 | } else { |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $this->dbDelete(); |
203 | 203 | } else { |
204 | 204 | if (!sn_db_transaction_check(false)) { |
205 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate'); |
|
205 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - transaction should always be started on '.get_called_class().'::dbUpdate'); |
|
206 | 206 | } |
207 | 207 | $this->dbUpdate(); |
208 | 208 | } |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | // TODO - protected |
231 | 231 | public function dbInsert() { |
232 | 232 | if (!$this->isNew()) { |
233 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert'); |
|
233 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - record db_id is not empty on '.get_called_class().'::dbInsert'); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | $fieldSet = $this->dbMakeFieldSet(false); |
237 | 237 | |
238 | 238 | if (!static::$db->doInsertSet(static::$_table, $fieldSet)) { |
239 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert'); |
|
239 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - error saving record '.get_called_class().'::dbInsert'); |
|
240 | 240 | } |
241 | 241 | $this->_dbId = static::$db->db_insert_id(); |
242 | 242 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | public function dbUpdate() { |
251 | 251 | // TODO - Update |
252 | 252 | if ($this->isNew()) { |
253 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate'); |
|
253 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbUpdate'); |
|
254 | 254 | } |
255 | 255 | $this->db_field_update($this->dbMakeFieldUpdate()); |
256 | 256 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | // TODO - protected |
262 | 262 | public function dbDelete() { |
263 | 263 | if ($this->isNew()) { |
264 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete'); |
|
264 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbDelete'); |
|
265 | 265 | } |
266 | 266 | classSupernova::$gc->db->doDeleteRowWhere(static::$_table, array(static::$_dbIdFieldName => $this->_dbId)); |
267 | 267 | $this->_dbId = 0; |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | } |
448 | 448 | } |
449 | 449 | |
450 | - if(empty($set)) { |
|
450 | + if (empty($set)) { |
|
451 | 451 | $theResult = true; |
452 | 452 | } else { |
453 | 453 | $theResult = classSupernova::$db->doUpdateRowAdjust( |
@@ -118,6 +118,9 @@ |
||
118 | 118 | return classSupernova::$gc->cacheOperator->db_ins_record(LOC_UNIT, $set); |
119 | 119 | } |
120 | 120 | |
121 | + /** |
|
122 | + * @param integer $unit_location_type |
|
123 | + */ |
|
121 | 124 | public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id = 0, $unit_snid = 0) { |
122 | 125 | $where = array('unit_location_type' => $unit_location_type); |
123 | 126 | ($unit_location_id = idval($unit_location_id)) ? $where['unit_location_id'] = $unit_location_id : false; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | if (classSupernova::$gc->snCache->isUnitLocatorNotSet($location_type, $location_id)) { |
27 | - $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions()); |
|
27 | + $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions()); |
|
28 | 28 | if (!empty($got_data) && is_array($got_data)) { |
29 | 29 | foreach ($got_data as $unit_id => $unit_data) { |
30 | 30 | classSupernova::$gc->snCache->setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data); |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | |
60 | 60 | public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) { |
61 | 61 | $query = classSupernova::$db->doSelect( |
62 | - "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} " . |
|
63 | - ($unit_type ? "AND `unit_type` = {$unit_type} " : '') . |
|
64 | - ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') . |
|
62 | + "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} ". |
|
63 | + ($unit_type ? "AND `unit_type` = {$unit_type} " : ''). |
|
64 | + ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : ''). |
|
65 | 65 | 'GROUP BY `unit_snid`' |
66 | 66 | ); |
67 | 67 | $result = array(); |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | WHERE |
82 | 82 | f.fleet_owner = {$user_id} AND |
83 | 83 | (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id}) |
84 | - AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() . |
|
85 | - " LIMIT 1" . |
|
84 | + AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions(). |
|
85 | + " LIMIT 1". |
|
86 | 86 | ($for_update ? ' FOR UPDATE' : '')); |
87 | 87 | } |
88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public static function db_unit_list_laboratories($user_id) { |
91 | 91 | return classSupernova::$db->doSelect("SELECT DISTINCT unit_location_id AS `id` |
92 | 92 | FROM {{unit}} |
93 | - WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");"); |
|
93 | + WHERE unit_player_id = {$user_id} AND unit_location_type = ".LOC_PLANET." AND unit_level > 0 AND unit_snid IN (".STRUC_LABORATORY.", ".STRUC_LABORATORY_NANO.");"); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | return classSupernova::$db->doSelect( |
137 | 137 | "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount |
138 | 138 | FROM `{{unit}}` |
139 | - WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() . |
|
139 | + WHERE unit_level > 0 AND " . self::db_unit_time_restrictions(). |
|
140 | 140 | " GROUP BY unit_player_id, unit_type, unit_snid, unit_level" |
141 | 141 | ); |
142 | 142 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | ), |
165 | 165 | array( |
166 | 166 | 'unit_time_finish IS NOT NULL', |
167 | - "unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ")", |
|
167 | + "unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.")", |
|
168 | 168 | ) |
169 | 169 | ); |
170 | 170 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
205 | 205 | if (!empty($temp['unit_id'])) { |
206 | - $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
|
206 | + $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
|
207 | 207 | LOC_UNIT, |
208 | 208 | $temp['unit_id'], |
209 | 209 | array(), |
@@ -214,15 +214,15 @@ discard block |
||
214 | 214 | } else { |
215 | 215 | $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id; |
216 | 216 | $unitType = get_unit_param($unit_id, P_UNIT_TYPE); |
217 | - $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record( |
|
217 | + $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record( |
|
218 | 218 | LOC_UNIT, |
219 | 219 | array( |
220 | 220 | 'unit_player_id' => $user['id'], |
221 | - 'unit_location_type' => (int)$unit_location, |
|
221 | + 'unit_location_type' => (int) $unit_location, |
|
222 | 222 | 'unit_location_id' => $locationIdRendered, |
223 | - 'unit_type' => (int)$unitType, |
|
224 | - 'unit_snid' => (int)$unit_id, |
|
225 | - 'unit_level' => (float)$unit_value, |
|
223 | + 'unit_type' => (int) $unitType, |
|
224 | + 'unit_snid' => (int) $unit_id, |
|
225 | + 'unit_level' => (float) $unit_value, |
|
226 | 226 | ) |
227 | 227 | ); |
228 | 228 | } |