@@ -7,7 +7,7 @@ |
||
7 | 7 | /** |
8 | 8 | * @param UBE $ube |
9 | 9 | * |
10 | - * @return bool|string |
|
10 | + * @return false|string |
|
11 | 11 | * |
12 | 12 | * @version 2016-02-25 23:42:45 41a4.68 |
13 | 13 | */ |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function sn_ube_report_save($ube) { |
15 | 15 | // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем |
16 | - if($ube->get_cypher()) { |
|
16 | + if ($ube->get_cypher()) { |
|
17 | 17 | return false; |
18 | 18 | } |
19 | 19 | |
20 | 20 | // Генерируем уникальный секретный ключ и проверяем наличие в базе |
21 | 21 | do { |
22 | 22 | $ube->report_cypher = sys_random_string(32); |
23 | - } while(classSupernova::$db->doSelectFetch("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE")); |
|
23 | + } while (classSupernova::$db->doSelectFetch("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE")); |
|
24 | 24 | |
25 | 25 | // Инициализация таблицы для пакетной вставки информации |
26 | 26 | $sql_perform = array( |
@@ -106,21 +106,21 @@ discard block |
||
106 | 106 | |
107 | 107 | // Сохраняем общую информацию о бое |
108 | 108 | classSupernova::$db->doInsertSet(TABLE_UBE_REPORT, array( |
109 | - 'ube_report_cypher' => (string)$ube->report_cypher, |
|
110 | - 'ube_report_time_combat' => (string)date(FMT_DATE_TIME_SQL, $ube->combat_timestamp), |
|
111 | - 'ube_report_time_spent' => (float)$ube->time_spent, |
|
112 | - 'ube_report_combat_admin' => (int)$ube->is_admin_in_combat, |
|
113 | - 'ube_report_mission_type' => (int)$ube->mission_type_id, |
|
114 | - 'ube_report_combat_result' => (int)$ube->combat_result, |
|
115 | - 'ube_report_combat_sfr' => (int)$ube->is_small_fleet_recce, |
|
116 | - 'ube_report_planet_id' => (int)$ube->ube_planet_info[PLANET_ID], |
|
117 | - 'ube_report_planet_name' => (string)$ube->ube_planet_info[PLANET_NAME], |
|
118 | - 'ube_report_planet_size' => (int)$ube->ube_planet_info[PLANET_SIZE], |
|
119 | - 'ube_report_planet_galaxy' => (int)$ube->ube_planet_info[PLANET_GALAXY], |
|
120 | - 'ube_report_planet_system' => (int)$ube->ube_planet_info[PLANET_SYSTEM], |
|
121 | - 'ube_report_planet_planet' => (int)$ube->ube_planet_info[PLANET_PLANET], |
|
122 | - 'ube_report_planet_planet_type' => (int)$ube->ube_planet_info[PLANET_TYPE], |
|
123 | - 'ube_report_capture_result' => (int)$ube->capture_result, |
|
109 | + 'ube_report_cypher' => (string) $ube->report_cypher, |
|
110 | + 'ube_report_time_combat' => (string) date(FMT_DATE_TIME_SQL, $ube->combat_timestamp), |
|
111 | + 'ube_report_time_spent' => (float) $ube->time_spent, |
|
112 | + 'ube_report_combat_admin' => (int) $ube->is_admin_in_combat, |
|
113 | + 'ube_report_mission_type' => (int) $ube->mission_type_id, |
|
114 | + 'ube_report_combat_result' => (int) $ube->combat_result, |
|
115 | + 'ube_report_combat_sfr' => (int) $ube->is_small_fleet_recce, |
|
116 | + 'ube_report_planet_id' => (int) $ube->ube_planet_info[PLANET_ID], |
|
117 | + 'ube_report_planet_name' => (string) $ube->ube_planet_info[PLANET_NAME], |
|
118 | + 'ube_report_planet_size' => (int) $ube->ube_planet_info[PLANET_SIZE], |
|
119 | + 'ube_report_planet_galaxy' => (int) $ube->ube_planet_info[PLANET_GALAXY], |
|
120 | + 'ube_report_planet_system' => (int) $ube->ube_planet_info[PLANET_SYSTEM], |
|
121 | + 'ube_report_planet_planet' => (int) $ube->ube_planet_info[PLANET_PLANET], |
|
122 | + 'ube_report_planet_planet_type' => (int) $ube->ube_planet_info[PLANET_TYPE], |
|
123 | + 'ube_report_capture_result' => (int) $ube->capture_result, |
|
124 | 124 | ) |
125 | 125 | + $ube->debris->report_generate_array() |
126 | 126 | + $ube->moon_calculator->report_generate_array() |
@@ -129,22 +129,22 @@ discard block |
||
129 | 129 | |
130 | 130 | // Сохраняем общую информацию по игрокам |
131 | 131 | $player_sides = $ube->players->get_player_sides(); |
132 | - foreach($player_sides as $player_id => $player_side) { |
|
132 | + foreach ($player_sides as $player_id => $player_side) { |
|
133 | 133 | $sql_perform['ube_report_player'][] = array( |
134 | 134 | $ube_report_id, |
135 | 135 | $player_id, |
136 | 136 | |
137 | - "'" . db_escape($ube->players[$player_id]->name) . "'", |
|
137 | + "'".db_escape($ube->players[$player_id]->name)."'", |
|
138 | 138 | $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0, |
139 | 139 | |
140 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
141 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
142 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
140 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
141 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
142 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
143 | 143 | ); |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Всякая информация по флотам |
147 | - foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
147 | + foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
148 | 148 | // Сохраняем общую информацию по флотам |
149 | 149 | $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id); |
150 | 150 | |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | $ube->rounds->sql_generate_unit_array($sql_perform['ube_report_unit'], $ube_report_id, $ube->fleet_list); |
160 | 160 | |
161 | 161 | // Пакетная вставка данных |
162 | - foreach($sql_perform as $table_name => $table_data) { |
|
163 | - if(count($table_data) < 2) { |
|
162 | + foreach ($sql_perform as $table_name => $table_data) { |
|
163 | + if (count($table_data) < 2) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | - foreach($table_data as &$record_data) { |
|
167 | - $record_data = '(' . implode(',', $record_data) . ')'; |
|
166 | + foreach ($table_data as &$record_data) { |
|
167 | + $record_data = '('.implode(',', $record_data).')'; |
|
168 | 168 | } |
169 | 169 | $fields = $table_data[0]; |
170 | 170 | unset($table_data[0]); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $report_cypher = db_escape($report_cypher); |
187 | 187 | |
188 | 188 | $report_row = classSupernova::$db->doSelectFetch("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1"); |
189 | - if(!$report_row) { |
|
189 | + if (!$report_row) { |
|
190 | 190 | return UBE_REPORT_NOT_FOUND; |
191 | 191 | } |
192 | 192 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param $template_result |
203 | 203 | */ |
204 | 204 | public function sn_ube_report_generate(UBE $ube, &$template_result) { |
205 | - if(!is_object($ube)) { |
|
205 | + if (!is_object($ube)) { |
|
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
@@ -217,15 +217,15 @@ discard block |
||
217 | 217 | |
218 | 218 | // Координаты, тип и название планеты - если есть |
219 | 219 | //R $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER]; |
220 | - if(isset($ube->ube_planet_info)) { |
|
220 | + if (isset($ube->ube_planet_info)) { |
|
221 | 221 | $template_result += $ube->ube_planet_info; |
222 | 222 | $template_result[PLANET_NAME] = str_replace(' ', ' ', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8')); |
223 | 223 | } |
224 | 224 | |
225 | 225 | // Обломки |
226 | 226 | $debris = array(); |
227 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
228 | - if($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
227 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
228 | + if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
229 | 229 | $debris[] = array( |
230 | 230 | 'NAME' => classLocale::$lang['tech'][$resource_id], |
231 | 231 | 'AMOUNT' => pretty_number($resource_amount), |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | // Pretty Safe |
3 | 3 | // TODO: Add ally_tag to usertable |
4 | 4 | |
5 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
5 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
6 | 6 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
@@ -11,22 +11,22 @@ discard block |
||
11 | 11 | $ally_name_unsafe = sys_get_param_str_unsafe('name'); |
12 | 12 | $ally_name = db_escape($ally_name_unsafe); |
13 | 13 | |
14 | -if($ally_tag) { |
|
15 | - if(!$ally_name_unsafe || !$ally_tag_unsafe) { |
|
14 | +if ($ally_tag) { |
|
15 | + if (!$ally_name_unsafe || !$ally_tag_unsafe) { |
|
16 | 16 | message(classLocale::$lang['have_not_name'], classLocale::$lang['make_alliance']); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $query = DBStaticAlly::db_ally_get_by_name_or_tag($ally_tag, $ally_name); |
20 | - if($query) { |
|
20 | + if ($query) { |
|
21 | 21 | message(str_replace('%s', $query['ally_tag'] == $ally_tag_unsafe ? $ally_tag_unsafe : $ally_name_unsafe, classLocale::$lang['always_exist']), classLocale::$lang['make_alliance']); |
22 | 22 | } |
23 | 23 | |
24 | 24 | DBStaticAlly::db_ally_insert($ally_name_unsafe, $ally_tag_unsafe, $user['id']); |
25 | 25 | $ally_id = classSupernova::$db->db_insert_id(); |
26 | - DBStaticUser::db_user_set_by_id($user['id'], "`ally_tag` = '{$ally_tag}', `ally_id`= {$ally_id}, `ally_name`='{$ally_name}', `ally_register_time`= " . SN_TIME_NOW . ""); |
|
26 | + DBStaticUser::db_user_set_by_id($user['id'], "`ally_tag` = '{$ally_tag}', `ally_id`= {$ally_id}, `ally_name`='{$ally_name}', `ally_register_time`= ".SN_TIME_NOW.""); |
|
27 | 27 | |
28 | 28 | $ally_user = classSupernova::$gc->cacheOperator->db_ins_record(LOC_USER, array( |
29 | - 'username' => "[" . $ally_tag_unsafe . "]", |
|
29 | + 'username' => "[".$ally_tag_unsafe."]", |
|
30 | 30 | 'register_time' => SN_TIME_NOW, |
31 | 31 | 'user_as_ally' => $ally_id, |
32 | 32 | )); |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | // Инфа об устройстве и браузере - общая для всех |
88 | 88 | sn_db_transaction_start(); |
89 | 89 | $this->device_cypher = $_COOKIE[SN_COOKIE_D]; |
90 | - if($this->device_cypher) { |
|
90 | + if ($this->device_cypher) { |
|
91 | 91 | $cypher_safe = db_escape($this->device_cypher); |
92 | 92 | $device_id = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE"); |
93 | - if(!empty($device_id['device_id'])) { |
|
93 | + if (!empty($device_id['device_id'])) { |
|
94 | 94 | $this->device_id = $device_id['device_id']; |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - if($this->device_id <= 0) { |
|
98 | + if ($this->device_id <= 0) { |
|
99 | 99 | do { |
100 | 100 | $cypher_safe = db_escape($this->device_cypher = sys_random_string()); |
101 | 101 | $row = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE"); |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string'); |
119 | 119 | sn_db_transaction_commit(); |
120 | 120 | |
121 | - if($this->write_full_url) { |
|
121 | + if ($this->write_full_url) { |
|
122 | 122 | sn_db_transaction_start(); |
123 | 123 | $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE)); |
124 | - if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
124 | + if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
125 | 125 | $this->page_url = '/simulator.php'; |
126 | 126 | } |
127 | 127 | $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string'); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function db_security_entry_insert($user_id_unsafe) { |
146 | 146 | // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL'; |
147 | - if(empty($user_id_unsafe)) { |
|
147 | + if (empty($user_id_unsafe)) { |
|
148 | 148 | // self::flog('Нет ИД пользователя'); |
149 | 149 | return true; |
150 | 150 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | public function db_counter_insert($user_id_unsafe) { |
167 | 167 | global $sys_stop_log_hit; |
168 | 168 | |
169 | - if($sys_stop_log_hit || !classSupernova::$config->game_counter) { |
|
169 | + if ($sys_stop_log_hit || !classSupernova::$config->game_counter) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | ->setIdField($entity->getIdFieldName()) |
19 | 19 | ->field('*') |
20 | 20 | ->from($entity->getTableName()) |
21 | - ->where($entity->getIdFieldName() . ' = "' . $entity->dbId . '"'); |
|
21 | + ->where($entity->getIdFieldName().' = "'.$entity->dbId.'"'); |
|
22 | 22 | |
23 | 23 | return $stmt->selectRow(); |
24 | 24 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | public function load_db_settings($configFile = '') { |
94 | 94 | $dbsettings = array(); |
95 | 95 | |
96 | - empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false; |
|
96 | + empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false; |
|
97 | 97 | |
98 | 98 | require $configFile; |
99 | 99 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | if (empty($this->dbsettings)) { |
116 | - $this->load_db_settings(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
116 | + $this->load_db_settings(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $sql = $query; |
166 | 166 | if (strpos($sql, '{{') !== false) { |
167 | 167 | foreach ($this->table_list as $tableName) { |
168 | - $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql); |
|
168 | + $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | |
239 | 239 | $queryResult = null; |
240 | 240 | try { |
241 | - $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace)); |
|
241 | + $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace)); |
|
242 | 242 | if (!$queryResult) { |
243 | 243 | throw new Exception(); |
244 | 244 | } |
245 | 245 | } catch (Exception $e) { |
246 | - classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error'); |
|
246 | + classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error'); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | return $queryResult; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $safeFieldsAndValues = implode(',', $this->safeFieldsAndValues($fieldsAndValues)); |
313 | 313 | // $command = $replace == DB_INSERT_REPLACE ? 'REPLACE' : 'INSERT'; |
314 | 314 | // $command .= $replace == DB_INSERT_IGNORE ? ' IGNORE' : ''; |
315 | - switch($replace) { |
|
315 | + switch ($replace) { |
|
316 | 316 | case DB_INSERT_IGNORE: |
317 | 317 | $command = 'INSERT IGNORE'; |
318 | 318 | break; |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | |
464 | 464 | |
465 | 465 | protected function castAsDbValue($value) { |
466 | - switch(gettype($value)) { |
|
466 | + switch (gettype($value)) { |
|
467 | 467 | case TYPE_INTEGER: |
468 | 468 | case TYPE_DOUBLE: |
469 | 469 | // do nothing |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | case TYPE_EMPTY: |
487 | 487 | // No-type defaults to string |
488 | 488 | default: |
489 | - $value = "'" . $this->db_escape((string)$value) . "'"; |
|
489 | + $value = "'".$this->db_escape((string) $value)."'"; |
|
490 | 490 | break; |
491 | 491 | } |
492 | 492 | |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | if (is_int($fieldName)) { |
515 | 515 | $result[$fieldName] = $fieldValue; |
516 | 516 | } else { |
517 | - $result[$fieldName] = "`{$fieldName}` = " . $this->castAsDbValue($fieldValue); |
|
517 | + $result[$fieldName] = "`{$fieldName}` = ".$this->castAsDbValue($fieldValue); |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | } |
546 | 546 | |
547 | 547 | foreach ($fields as $key => $value) { |
548 | - $result[$key] = "`" . $this->db_escape($value) . "`"; |
|
548 | + $result[$key] = "`".$this->db_escape($value)."`"; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | return $result; |
@@ -601,10 +601,10 @@ discard block |
||
601 | 601 | $this->isWatching = true; |
602 | 602 | $msg = "\$query = \"{$query}\"\n\r"; |
603 | 603 | if (!empty($_POST)) { |
604 | - $msg .= "\n\r" . dump($_POST, '$_POST'); |
|
604 | + $msg .= "\n\r".dump($_POST, '$_POST'); |
|
605 | 605 | } |
606 | 606 | if (!empty($_GET)) { |
607 | - $msg .= "\n\r" . dump($_GET, '$_GET'); |
|
607 | + $msg .= "\n\r".dump($_GET, '$_GET'); |
|
608 | 608 | } |
609 | 609 | classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
610 | 610 | $this->isWatching = false; |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | |
620 | 620 | global $user, $dm_change_legit, $mm_change_legit; |
621 | 621 | |
622 | - switch(true) { |
|
622 | + switch (true) { |
|
623 | 623 | case stripos($query, 'RUNCATE TABL') != false: |
624 | 624 | case stripos($query, 'ROP TABL') != false: |
625 | 625 | case stripos($query, 'ENAME TABL') != false: |
@@ -630,37 +630,37 @@ discard block |
||
630 | 630 | case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit: |
631 | 631 | case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit: |
632 | 632 | case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0: |
633 | - $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n"; |
|
633 | + $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n"; |
|
634 | 634 | $report .= ">Database Inforamation\n"; |
635 | - $report .= "\tID - " . $user['id'] . "\n"; |
|
636 | - $report .= "\tUser - " . $user['username'] . "\n"; |
|
637 | - $report .= "\tAuth level - " . $user['authlevel'] . "\n"; |
|
638 | - $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n"; |
|
639 | - $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n"; |
|
640 | - $report .= "\tUser IP - " . $user['user_lastip'] . "\n"; |
|
641 | - $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n"; |
|
642 | - $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
643 | - $report .= "\tCurrent Page - " . $user['current_page'] . "\n"; |
|
644 | - $report .= "\tRegister Time - " . $user['register_time'] . "\n"; |
|
635 | + $report .= "\tID - ".$user['id']."\n"; |
|
636 | + $report .= "\tUser - ".$user['username']."\n"; |
|
637 | + $report .= "\tAuth level - ".$user['authlevel']."\n"; |
|
638 | + $report .= "\tAdmin Notes - ".$user['adminNotes']."\n"; |
|
639 | + $report .= "\tCurrent Planet - ".$user['current_planet']."\n"; |
|
640 | + $report .= "\tUser IP - ".$user['user_lastip']."\n"; |
|
641 | + $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n"; |
|
642 | + $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
643 | + $report .= "\tCurrent Page - ".$user['current_page']."\n"; |
|
644 | + $report .= "\tRegister Time - ".$user['register_time']."\n"; |
|
645 | 645 | $report .= "\n"; |
646 | 646 | |
647 | 647 | $report .= ">Query Information\n"; |
648 | - $report .= "\tQuery - " . $query . "\n"; |
|
648 | + $report .= "\tQuery - ".$query."\n"; |
|
649 | 649 | $report .= "\n"; |
650 | 650 | |
651 | 651 | $report .= ">\$_SERVER Information\n"; |
652 | - $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n"; |
|
653 | - $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n"; |
|
654 | - $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
655 | - $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n"; |
|
656 | - $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n"; |
|
657 | - $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n"; |
|
658 | - $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n"; |
|
659 | - $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n"; |
|
652 | + $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n"; |
|
653 | + $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n"; |
|
654 | + $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
655 | + $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n"; |
|
656 | + $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n"; |
|
657 | + $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n"; |
|
658 | + $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n"; |
|
659 | + $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n"; |
|
660 | 660 | |
661 | 661 | $report .= "\n--------------------------------------------------------------------------------------------------\n"; |
662 | 662 | |
663 | - $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a'); |
|
663 | + $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a'); |
|
664 | 664 | fwrite($fp, $report); |
665 | 665 | fclose($fp); |
666 | 666 | |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | $prefix_length = strlen($this->db_prefix); |
682 | 682 | |
683 | 683 | $tl = array(); |
684 | - while($row = $this->db_fetch($query)) { |
|
684 | + while ($row = $this->db_fetch($query)) { |
|
685 | 685 | foreach ($row as $table_name) { |
686 | 686 | if (strpos($table_name, $this->db_prefix) === 0) { |
687 | 687 | $table_name = substr($table_name, $prefix_length); |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | if (is_bool($query)) { |
813 | 813 | throw new Exception('Result of SHOW STATUS command is boolean - which should never happen. Connection to DB is lost?'); |
814 | 814 | } |
815 | - while($row = db_fetch($query)) { |
|
815 | + while ($row = db_fetch($query)) { |
|
816 | 816 | $result[$row['Variable_name']] = $row['Value']; |
817 | 817 | } |
818 | 818 |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | /** |
163 | 163 | * @param string $query |
164 | 164 | * |
165 | - * @return mixed|string |
|
165 | + * @return string |
|
166 | 166 | */ |
167 | 167 | public function replaceTablePlaceholders($query) { |
168 | 168 | $sql = $query; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
179 | - * @param $query |
|
179 | + * @param string $query |
|
180 | 180 | */ |
181 | 181 | protected function logQuery($query) { |
182 | 182 | if (!classSupernova::$config->debug) { |
@@ -306,10 +306,16 @@ discard block |
||
306 | 306 | } |
307 | 307 | |
308 | 308 | |
309 | + /** |
|
310 | + * @param string $query |
|
311 | + */ |
|
309 | 312 | public function doInsertComplex($query) { |
310 | 313 | return $this->doExecute($query); |
311 | 314 | } |
312 | 315 | |
316 | + /** |
|
317 | + * @param integer $replace |
|
318 | + */ |
|
313 | 319 | protected function doSet($table, $fieldsAndValues, $replace = DB_INSERT_PLAIN) { |
314 | 320 | $tableSafe = $this->db_escape($table); |
315 | 321 | $safeFieldsAndValues = implode(',', $this->safeFieldsEqualValues($fieldsAndValues)); |
@@ -342,6 +348,9 @@ discard block |
||
342 | 348 | return $this->doSet($table, $fieldsAndValues, $replace); |
343 | 349 | } |
344 | 350 | |
351 | + /** |
|
352 | + * @param string $table |
|
353 | + */ |
|
345 | 354 | public function doReplaceSet($table, $fieldsAndValues) { |
346 | 355 | return $this->doSet($table, $fieldsAndValues, DB_INSERT_REPLACE); |
347 | 356 | } |
@@ -376,7 +385,7 @@ discard block |
||
376 | 385 | * Values should be passed as-is |
377 | 386 | * |
378 | 387 | * @param string $table |
379 | - * @param array $fields |
|
388 | + * @param string[] $fields |
|
380 | 389 | * @param string[] $values |
381 | 390 | * |
382 | 391 | * @return array|bool|mysqli_result|null |
@@ -411,7 +420,7 @@ discard block |
||
411 | 420 | * Self-contained - means no params used |
412 | 421 | * Such queries usually used to make large amount of in-base calculations |
413 | 422 | * |
414 | - * @param $query |
|
423 | + * @param string $query |
|
415 | 424 | * |
416 | 425 | * @return array|bool|mysqli_result|null |
417 | 426 | */ |
@@ -419,6 +428,9 @@ discard block |
||
419 | 428 | return $this->doExecute($query); |
420 | 429 | } |
421 | 430 | |
431 | + /** |
|
432 | + * @param boolean $isOneRecord |
|
433 | + */ |
|
422 | 434 | protected function doUpdateWhere($table, $fieldsAndValues, $where = array(), $isOneRecord = DB_RECORDS_ALL) { |
423 | 435 | $tableSafe = $this->db_escape($table); |
424 | 436 | $safeFieldsEqualValues = implode(',', $this->safeFieldsEqualValues($fieldsAndValues)); |
@@ -430,10 +442,16 @@ discard block |
||
430 | 442 | return $this->doExecute($query); |
431 | 443 | } |
432 | 444 | |
445 | + /** |
|
446 | + * @param string $table |
|
447 | + */ |
|
433 | 448 | public function doUpdateRowWhere($table, $fieldsAndValues, $where) { |
434 | 449 | return $this->doUpdateWhere($table, $fieldsAndValues, $where, DB_RECORD_ONE); |
435 | 450 | } |
436 | 451 | |
452 | + /** |
|
453 | + * @param string $table |
|
454 | + */ |
|
437 | 455 | public function doUpdateTable($table, $fieldsAndValues, $where = array()) { |
438 | 456 | return $this->doUpdateWhere($table, $fieldsAndValues, $where, DB_RECORDS_ALL); |
439 | 457 | } |
@@ -504,7 +522,7 @@ discard block |
||
504 | 522 | * |
505 | 523 | * Usually used for mallformed $where conditions |
506 | 524 | * |
507 | - * @param $table |
|
525 | + * @param string $table |
|
508 | 526 | * @param $where |
509 | 527 | * |
510 | 528 | * @return array|bool|mysqli_result|null |
@@ -642,6 +660,10 @@ discard block |
||
642 | 660 | } |
643 | 661 | |
644 | 662 | // TODO Заменить это на новый логгер |
663 | + |
|
664 | + /** |
|
665 | + * @param string $query |
|
666 | + */ |
|
645 | 667 | protected function security_watch_user_queries($query) { |
646 | 668 | global $user; |
647 | 669 | |
@@ -665,6 +687,9 @@ discard block |
||
665 | 687 | } |
666 | 688 | |
667 | 689 | |
690 | + /** |
|
691 | + * @param string $query |
|
692 | + */ |
|
668 | 693 | public function security_query_check_bad_words($query) { |
669 | 694 | if ($this->skipQueryCheck) { |
670 | 695 | return; |
@@ -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 |