@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $owners = array(); |
115 | 115 | } else { |
116 | 116 | $insert_values = array(); |
117 | - $insert_template = "('%u'," . str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')"); |
|
117 | + $insert_template = "('%u',".str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')"); |
|
118 | 118 | |
119 | 119 | foreach ($owners as $owner) { |
120 | 120 | if ($user['id'] != $owner) { |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $sendList = array(); |
156 | 156 | $list = ''; |
157 | 157 | $query = DBStaticUser::db_user_list( |
158 | - "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
|
158 | + "ally_id = '{$ally_id}'".($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
|
159 | 159 | false, 'id, username'); |
160 | 160 | foreach ($query as $u) { |
161 | 161 | $sendList[] = $u['id']; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $subject_unsafe = substr($subject_unsafe, strlen(classLocale::$lang['msg_answer_prefix'])); |
254 | 254 | $re++; |
255 | 255 | } |
256 | - $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'] . $subject_unsafe : false; |
|
256 | + $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'].$subject_unsafe : false; |
|
257 | 257 | |
258 | 258 | $subject_unsafe = $subject_unsafe ? $subject_unsafe : classLocale::$lang['msg_subject_default']; |
259 | 259 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | return classSupernova::$db->doSelect( |
422 | 422 | "SELECT * FROM {{messages}} |
423 | 423 | WHERE |
424 | - `message_type` = '" . MSG_TYPE_PLAYER . "' AND |
|
424 | + `message_type` = '" . MSG_TYPE_PLAYER."' AND |
|
425 | 425 | ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}') |
426 | 426 | OR |
427 | 427 | (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;"); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | FROM |
466 | 466 | {{messages}} AS m |
467 | 467 | LEFT JOIN {{users}} AS u ON u.id = m.message_owner " . |
468 | - ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '') . |
|
468 | + ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : ''). |
|
469 | 469 | "ORDER BY |
470 | 470 | `message_id` DESC |
471 | 471 | LIMIT |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | } |
474 | 474 | |
475 | 475 | public static function db_message_insert_all($message_type, $from, $subject, $text) { |
476 | - return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
|
476 | + return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '. |
|
477 | 477 | "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}"); |
478 | 478 | } |
479 | 479 | |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | * @return array|bool|mysqli_result|null |
484 | 484 | */ |
485 | 485 | public static function db_message_count_by_type($int_type_selected) { |
486 | - $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : '')); |
|
486 | + $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`'.($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : '')); |
|
487 | 487 | |
488 | 488 | return $page_max; |
489 | 489 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | */ |
508 | 508 | public static function db_message_list_delete_by_date($delete_date, $int_type_selected) { |
509 | 509 | $where[] = "message_time <= UNIX_TIMESTAMP('{$delete_date}')"; |
510 | - if($int_type_selected >= 0) { |
|
510 | + if ($int_type_selected >= 0) { |
|
511 | 511 | $where['message_type'] = $int_type_selected; |
512 | 512 | } |
513 | 513 | classSupernova::$db->doDeleteDeprecated(TABLE_MESSAGES, $where); |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | |
10 | 10 | $possible_cores = array(); |
11 | 11 | $probability = 0; |
12 | - foreach($density_list as $possible_core_id => $core_data) { |
|
13 | - if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
12 | + foreach ($density_list as $possible_core_id => $core_data) { |
|
13 | + if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
14 | 14 | continue; |
15 | 15 | } |
16 | 16 | |
17 | - if( |
|
17 | + if ( |
|
18 | 18 | // Core type exists |
19 | 19 | in_array($possible_core_id, $position_data['core_types']) |
20 | 20 | // Limit core type with planet sector count |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | |
36 | 36 | $random = mt_rand(1, $probability); |
37 | 37 | $selected_core = null; |
38 | - foreach($possible_cores as $core_type => $core_info) { |
|
39 | - if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
38 | + foreach ($possible_cores as $core_type => $core_info) { |
|
39 | + if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
40 | 40 | $selected_core = $core_info; |
41 | 41 | break; |
42 | 42 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | function uni_create_planet($Galaxy, $System, $Position, $PlanetOwnerID, $planet_name_unsafe = '', $HomeWorld = false, $options = array()) { |
60 | 60 | $Position = intval($Position); |
61 | 61 | |
62 | - if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
62 | + if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | |
69 | 69 | $planet_generator = sn_get_groups('planet_generator'); |
70 | 70 | |
71 | - if($HomeWorld) { |
|
71 | + if ($HomeWorld) { |
|
72 | 72 | $position_data = $planet_generator[0]; |
73 | 73 | } else { |
74 | 74 | $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position]; |
75 | - if($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
75 | + if ($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
76 | 76 | // Корректируем температуру для планеты-странника |
77 | 77 | $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START); |
78 | 78 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | $planet_images = sn_get_groups('planet_images'); |
82 | 82 | $planet_image = $position_data['planet_images'][mt_rand(0, count($position_data['planet_images']) - 1)]; |
83 | - $planet_image .= 'planet' . $planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)]; |
|
83 | + $planet_image .= 'planet'.$planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)]; |
|
84 | 84 | |
85 | 85 | $t_max = sn_rand_gauss_range($position_data['t_max_min'], $position_data['t_max_max'], true, 1.3, true); |
86 | 86 | $t_min = $t_max - sn_rand_gauss_range($position_data['t_delta_min'], $position_data['t_delta_max'], true, 1.3, true); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $core_info = uni_create_planet_get_density($position_data, $user_row, $planet_sectors); |
93 | 93 | |
94 | - $planet_name_unsafe = $user_row['username'] . ' ' . ($planet_name_unsafe ? $planet_name_unsafe : classLocale::$lang['sys_colo_defaultname']); |
|
94 | + $planet_name_unsafe = $user_row['username'].' '.($planet_name_unsafe ? $planet_name_unsafe : classLocale::$lang['sys_colo_defaultname']); |
|
95 | 95 | |
96 | 96 | $planet['name'] = trim(strip_tags($planet_name_unsafe)); |
97 | 97 | $planet['id_owner'] = $PlanetOwnerID; |
@@ -163,15 +163,15 @@ discard block |
||
163 | 163 | $moon_name = ''; |
164 | 164 | $moon_row = array(); |
165 | 165 | $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id'); |
166 | - if(!$moon['id']) { |
|
166 | + if (!$moon['id']) { |
|
167 | 167 | $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`'); |
168 | 168 | |
169 | - if($moon_planet['id']) { |
|
169 | + if ($moon_planet['id']) { |
|
170 | 170 | $base_storage_size = BASE_STORAGE_SIZE; |
171 | 171 | |
172 | - if(!$moon_chance) { |
|
172 | + if (!$moon_chance) { |
|
173 | 173 | $size = mt_rand(1100, 8999); |
174 | - } elseif($moon_chance <= 100) { |
|
174 | + } elseif ($moon_chance <= 100) { |
|
175 | 175 | $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999); |
176 | 176 | } else { |
177 | 177 | $size = $moon_chance; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | $field_max = ceil($size / 1000); |
188 | 188 | |
189 | - if(isset($options['image']) && $options['image']) { |
|
189 | + if (isset($options['image']) && $options['image']) { |
|
190 | 190 | $moon_image = $options['image']; |
191 | 191 | } else { |
192 | 192 | $moon_image = 'mond'; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | 'deuterium_max' => $base_storage_size, |
220 | 220 | )); |
221 | 221 | |
222 | - if($update_debris) { |
|
222 | + if ($update_debris) { |
|
223 | 223 | $debris_spent = $moon_chance * 1000000; |
224 | 224 | $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100)); |
225 | 225 | $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent); |
@@ -254,28 +254,28 @@ discard block |
||
254 | 254 | $planet_row['id'] = $user['current_planet']; |
255 | 255 | |
256 | 256 | // Пытаемся переключить на новую планету |
257 | - if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
257 | + if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
258 | 258 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
259 | 259 | } else { |
260 | 260 | $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']); |
261 | 261 | } |
262 | 262 | |
263 | 263 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
264 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
264 | + if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
265 | 265 | { |
266 | 266 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
267 | 267 | // Если текущей планеты не существует - выставляем Столицу |
268 | - if(!isset($planet_row['id'])) { |
|
268 | + if (!isset($planet_row['id'])) { |
|
269 | 269 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
270 | 270 | // Если и столицы не существует - значит что-то очень не так с записью пользователя |
271 | - if(!isset($planet_row['id'])) { |
|
271 | + if (!isset($planet_row['id'])) { |
|
272 | 272 | classSupernova::$debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502); |
273 | 273 | } |
274 | 274 | } |
275 | 275 | } |
276 | 276 | |
277 | 277 | // Если производилось переключение планеты - делаем запись в юзере |
278 | - if($user['current_planet'] != $planet_row['id']) { |
|
278 | + if ($user['current_planet'] != $planet_row['id']) { |
|
279 | 279 | DBStaticUser::db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'"); |
280 | 280 | $user['current_planet'] = $planet_row['id']; |
281 | 281 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | // ---------------------------------------------------------------------------------------------------------------- |
294 | 294 | function uni_render_coordinates($from, $prefix = '') { |
295 | - return "[{$from[$prefix . 'galaxy']}:{$from[$prefix . 'system']}:{$from[$prefix . 'planet']}]"; |
|
295 | + return "[{$from[$prefix.'galaxy']}:{$from[$prefix.'system']}:{$from[$prefix.'planet']}]"; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | function uni_render_planet($from) { |
@@ -300,17 +300,17 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) { |
303 | - if(!$from['id']) { |
|
303 | + if (!$from['id']) { |
|
304 | 304 | $result = classLocale::$lang['sys_planet_expedition']; |
305 | 305 | } else { |
306 | 306 | $from_planet_id = $include_id ? ( |
307 | - 'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} ' |
|
307 | + 'ID {'.($from['id'] ? $from['id'] : ($from[$prefix.'planet_id'] ? $from[$prefix.'planet_id'] : 0)).'} ' |
|
308 | 308 | ) : ''; |
309 | 309 | |
310 | - $from_planet_type = $from['planet_type'] ? $from['planet_type'] : ($from[$prefix . 'type'] ? $from[$prefix . 'type'] : 0); |
|
311 | - $from_planet_type = ($from_planet_type ? ' ' . classLocale::$lang['sys_planet_type_sh'][$from_planet_type] : ''); |
|
310 | + $from_planet_type = $from['planet_type'] ? $from['planet_type'] : ($from[$prefix.'type'] ? $from[$prefix.'type'] : 0); |
|
311 | + $from_planet_type = ($from_planet_type ? ' '.classLocale::$lang['sys_planet_type_sh'][$from_planet_type] : ''); |
|
312 | 312 | |
313 | - $result = $from_planet_id . uni_render_coordinates($from, $prefix) . $from_planet_type . ($from['name'] ? ' ' . $from['name'] : ''); |
|
313 | + $result = $from_planet_id.uni_render_coordinates($from, $prefix).$from_planet_type.($from['name'] ? ' '.$from['name'] : ''); |
|
314 | 314 | $result = $html_safe ? str_replace(' ', ' ', htmlentities($result, ENT_COMPAT, 'UTF-8')) : $result; |
315 | 315 | } |
316 | 316 | |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | } |
319 | 319 | |
320 | 320 | function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') { |
321 | - return $page . (strpos($page, '?') === false ? '?' : '&') . "galaxy={$from[$prefix . 'galaxy']}&system={$from[$prefix . 'system']}&planet={$from[$prefix . 'planet']}"; |
|
321 | + return $page.(strpos($page, '?') === false ? '?' : '&')."galaxy={$from[$prefix.'galaxy']}&system={$from[$prefix.'system']}&planet={$from[$prefix.'planet']}"; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') { |
325 | - return '<a href="' . uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}") . '"' . ($fleet_type ? " {$fleet_type}" : '') . '>' . uni_render_coordinates($from, $prefix) . '</a>'; |
|
325 | + return '<a href="'.uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}").'"'.($fleet_type ? " {$fleet_type}" : '').'>'.uni_render_coordinates($from, $prefix).'</a>'; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | function uni_get_time_to_jump($moon_row) { |
@@ -350,30 +350,30 @@ discard block |
||
350 | 350 | $coordinates["{$prefix}planet"] = intval($coordinates["{$prefix}planet"]); |
351 | 351 | |
352 | 352 | return |
353 | - isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies&& |
|
354 | - isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems&& |
|
353 | + isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies && |
|
354 | + isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems && |
|
355 | 355 | isset($coordinates["{$prefix}planet"]) && $coordinates["{$prefix}planet"] > 0 && $coordinates["{$prefix}planet"] <= Vector::$knownPlanets; |
356 | 356 | } |
357 | 357 | |
358 | 358 | function uni_planet_teleport_check($user, $planetrow, $new_coordinates = null) { |
359 | 359 | try { |
360 | - if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
360 | + if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
361 | 361 | throw new exception(classLocale::$lang['ov_teleport_err_cooldown'], ERR_ERROR); |
362 | 362 | } |
363 | 363 | |
364 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) { |
|
364 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) { |
|
365 | 365 | throw new exception(classLocale::$lang['ov_teleport_err_no_dark_matter'], ERR_ERROR); |
366 | 366 | } |
367 | 367 | |
368 | 368 | // TODO: Replace quick-check with using gathered flying fleet data |
369 | - if(FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
369 | + if (FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
370 | 370 | throw new exception(classLocale::$lang['ov_teleport_err_fleet'], ERR_ERROR); |
371 | 371 | } |
372 | 372 | |
373 | - if(is_array($new_coordinates)) { |
|
373 | + if (is_array($new_coordinates)) { |
|
374 | 374 | $new_coordinates['planet_type'] = PT_PLANET; |
375 | 375 | $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id'); |
376 | - if($incoming['id']) { |
|
376 | + if ($incoming['id']) { |
|
377 | 377 | throw new exception(classLocale::$lang['ov_teleport_err_destination_busy'], ERR_ERROR); |
378 | 378 | } |
379 | 379 | } |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | 'result' => ERR_NONE, |
383 | 383 | 'message' => '', |
384 | 384 | ); |
385 | - } catch(exception $e) { |
|
385 | + } catch (exception $e) { |
|
386 | 386 | $response = array( |
387 | 387 | 'result' => $e->getCode(), |
388 | 388 | 'message' => $e->getMessage(), |
@@ -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 |