@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | function db_news_insert_set($announce_time, $text, $detail_url, $user) { |
13 | 13 | doquery("INSERT INTO {{announce}} |
14 | 14 | SET `tsTimeStamp` = FROM_UNIXTIME({$announce_time}), `strAnnounce`='{$text}', detail_url = '{$detail_url}', |
15 | - `user_id` = {$user['id']}, `user_name` = '" . db_escape($user['username']) . "'"); |
|
15 | + `user_id` = {$user['id']}, `user_name` = '".db_escape($user['username'])."'"); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | function db_survey_insert($announce_id, $survey_question, $survey_until) { |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | LEFT JOIN {{survey}} AS s ON s.survey_announce_id = a.idAnnounce |
94 | 94 | LEFT JOIN {{users}} AS u ON u.id = a.user_id |
95 | 95 | {$query_where} |
96 | - ORDER BY `tsTimeStamp` DESC, idAnnounce" . |
|
96 | + ORDER BY `tsTimeStamp` DESC, idAnnounce". |
|
97 | 97 | ($query_limit ? " LIMIT {$query_limit}" : '')); |
98 | 98 | |
99 | 99 | $template->assign_var('NEWS_COUNT', db_num_rows($announce_list)); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param $note_id_edit |
37 | 37 | */ |
38 | 38 | public static function db_note_update_by_id($note_priority, $note_title, $note_text, $note_galaxy, $note_system, $note_planet, $note_planet_type, $note_sticky, $note_id_edit) { |
39 | - doquery("UPDATE {{notes}} SET `time` = " . SN_TIME_NOW . ", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}', |
|
39 | + doquery("UPDATE {{notes}} SET `time` = ".SN_TIME_NOW.", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}', |
|
40 | 40 | `galaxy` = {$note_galaxy}, `system` = {$note_system}, `planet` = {$note_planet}, `planet_type` = {$note_planet_type}, `sticky` = {$note_sticky} |
41 | 41 | WHERE `id` = {$note_id_edit} LIMIT 1;"); |
42 | 42 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param $note_sticky |
54 | 54 | */ |
55 | 55 | public static function db_note_insert($user, $note_priority, $note_title, $note_text, $note_galaxy, $note_system, $note_planet, $note_planet_type, $note_sticky) { |
56 | - doquery("INSERT INTO {{notes}} SET `owner` = {$user['id']}, `time` = " . SN_TIME_NOW . ", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}', |
|
56 | + doquery("INSERT INTO {{notes}} SET `owner` = {$user['id']}, `time` = ".SN_TIME_NOW.", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}', |
|
57 | 57 | `galaxy` = {$note_galaxy}, `system` = {$note_system}, `planet` = {$note_planet}, `planet_type` = {$note_planet_type}, `sticky` = {$note_sticky};"); |
58 | 58 | } |
59 | 59 |
@@ -19,15 +19,11 @@ discard block |
||
19 | 19 | // ------------------------------------------------------------------ |
20 | 20 | function flt_flyingFleetsSort($a, $b) { |
21 | 21 | // Сравниваем время флотов - кто раньше, тот и первый обрабатывается |
22 | - return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : |
|
23 | - // Если время - одинаковое, сравниваем события флотов |
|
22 | + return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов |
|
24 | 23 | // Если события - одинаковые, то флоты равны |
25 | - ($a['fleet_event'] == $b['fleet_event'] ? 0 : |
|
26 | - // Если события разные - первыми считаем прибывающие флоты |
|
27 | - ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : |
|
28 | - // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
29 | - ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : |
|
30 | - // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
24 | + ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты |
|
25 | + ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
26 | + ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
31 | 27 | // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска |
32 | 28 | ( |
33 | 29 | 0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий |
@@ -45,13 +41,13 @@ discard block |
||
45 | 41 | $handler = fopen('event.log', 'a+'); |
46 | 42 | } |
47 | 43 | |
48 | - fwrite($handler, date(FMT_DATE_TIME_SQL, time()) . ' ' . $msg . "\r\n"); |
|
44 | + fwrite($handler, date(FMT_DATE_TIME_SQL, time()).' '.$msg."\r\n"); |
|
49 | 45 | } |
50 | 46 | |
51 | 47 | // ------------------------------------------------------------------ |
52 | 48 | function flt_flying_fleet_handler($skip_fleet_update = false) { |
53 | 49 | if (true) { |
54 | - if(!defined('IN_AJAX')) { |
|
50 | + if (!defined('IN_AJAX')) { |
|
55 | 51 | print('<div style="color: red; font-size: 300%">Fleet handler is disabled</div>'); |
56 | 52 | pdump('Fleet handler is disabled'); |
57 | 53 | } |
@@ -177,7 +173,7 @@ discard block |
||
177 | 173 | MT_EXPLORE => 'flt_mission_explore', |
178 | 174 | ); |
179 | 175 | foreach ($missions_used as $mission_id => $cork) { |
180 | - require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX); |
|
176 | + require_once(SN_ROOT_PHYSICAL."includes/includes/{$mission_files[$mission_id]}".DOT_PHP_EX); |
|
181 | 177 | } |
182 | 178 | |
183 | 179 | //log_file('Обработка миссий'); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | public static function cache_clear($location_type, $hard = true) { |
237 | 237 | if ($hard && !empty(static::$data[$location_type])) { |
238 | 238 | // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях |
239 | - array_walk(static::$data[$location_type], function (&$item) { $item = null; }); |
|
239 | + array_walk(static::$data[$location_type], function(&$item) { $item = null; }); |
|
240 | 240 | } |
241 | 241 | static::$locator[$location_type] = array(); |
242 | 242 | static::$queries[$location_type] = array(); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | |
355 | 355 | if (!empty($error_msg)) { |
356 | 356 | // TODO - Убрать позже |
357 | - print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>'); |
|
357 | + print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>'); |
|
358 | 358 | $backtrace = debug_backtrace(); |
359 | 359 | array_shift($backtrace); |
360 | 360 | pdump($backtrace); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | public static function db_transaction_start($level = '') { |
368 | 368 | static::db_transaction_check(null); |
369 | 369 | |
370 | - $level ? doquery('SET TRANSACTION ISOLATION LEVEL ' . $level) : false; |
|
370 | + $level ? doquery('SET TRANSACTION ISOLATION LEVEL '.$level) : false; |
|
371 | 371 | |
372 | 372 | static::$transaction_id++; |
373 | 373 | doquery('START TRANSACTION'); |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | public static function db_lock_tables($tables) { |
428 | 428 | $tables = is_array($tables) ? $tables : array($tables => ''); |
429 | 429 | foreach ($tables as $table_name => $condition) { |
430 | - self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
430 | + self::$db->doquery("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | $query = static::db_query( |
504 | 504 | "SELECT |
505 | 505 | distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
506 | - FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
507 | - ($filter ? ' WHERE ' . $filter : '') . |
|
506 | + FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
507 | + ($filter ? ' WHERE '.$filter : ''). |
|
508 | 508 | ($fetch ? ' LIMIT 1' : ''), false, true); |
509 | 509 | |
510 | 510 | while ($row = db_fetch($query)) { |
@@ -517,13 +517,13 @@ discard block |
||
517 | 517 | if ($indexes_str = implode(',', $parent_id_list)) { |
518 | 518 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
519 | 519 | static::db_get_record_list($owner_location_type, |
520 | - $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
520 | + $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
525 | 525 | $query = static::db_query( |
526 | - "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
526 | + "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
527 | 527 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
528 | 528 | ); |
529 | 529 | while ($row = db_fetch($query)) { |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | $condition = trim($condition); |
590 | 590 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
591 | 591 | |
592 | - if ($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
592 | + if ($result = static::db_query("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) { |
|
593 | 593 | |
594 | 594 | if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
595 | 595 | // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | // TODO переписать |
752 | 752 | $user = static::dbFetchOne( |
753 | 753 | DBStaticUser::buildSelect() |
754 | - ->where(array("`username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'")) |
|
754 | + ->where(array("`username` ".($like ? 'LIKE' : '=')." '{$username_safe}'")) |
|
755 | 755 | ); |
756 | 756 | |
757 | 757 | // $user = static::db_query( |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | |
845 | 845 | $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id]; |
846 | 846 | if (!isset($query_cache)) { |
847 | - $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . static::db_unit_time_restrictions()); |
|
847 | + $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".static::db_unit_time_restrictions()); |
|
848 | 848 | if (is_array($got_data)) { |
849 | 849 | foreach ($got_data as $unit_id => $unit_data) { |
850 | 850 | $query_cache[$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id]; |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | if ($que_type == QUE_RESEARCH || $planet_id === null) { |
906 | 906 | $query[] = "`que_planet_id` IS NULL"; |
907 | 907 | } elseif ($planet_id) { |
908 | - $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
908 | + $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")"; |
|
909 | 909 | } |
910 | 910 | if ($que_type) { |
911 | 911 | $query[] = "`que_type` = {$que_type}"; |
@@ -1026,13 +1026,13 @@ discard block |
||
1026 | 1026 | $condition = "`{$field_name}` = "; |
1027 | 1027 | $value = ''; |
1028 | 1028 | if ($field_data['delta']) { |
1029 | - $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
|
1029 | + $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta']; |
|
1030 | 1030 | } elseif ($field_data['set']) { |
1031 | 1031 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | if ($value) { |
1035 | - $fields[] = $condition . $value; |
|
1035 | + $fields[] = $condition.$value; |
|
1036 | 1036 | } |
1037 | 1037 | } |
1038 | 1038 | $conditions[P_FIELDS_STR] = implode(',', $fields); |
@@ -1046,9 +1046,7 @@ discard block |
||
1046 | 1046 | // Простое условие - $field_id = $field_value |
1047 | 1047 | if (is_string($field_id)) { |
1048 | 1048 | $field_value = |
1049 | - $field_value === null ? 'NULL' : |
|
1050 | - (is_string($field_value) ? "'" . db_escape($field_value) . "'" : |
|
1051 | - (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
1049 | + $field_value === null ? 'NULL' : (is_string($field_value) ? "'".db_escape($field_value)."'" : (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
1052 | 1050 | $the_conditions[] = "`{$field_id}` = {$field_value}"; |
1053 | 1051 | } else { |
1054 | 1052 | die('Неподдерживаемый тип условия'); |
@@ -1075,7 +1073,7 @@ discard block |
||
1075 | 1073 | die('Неподдерживаемая операция в classSupernova::db_changeset_condition_compile'); |
1076 | 1074 | } |
1077 | 1075 | |
1078 | - $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR] . ' ' . $conditions[P_FIELDS_STR] . (' WHERE ' . $conditions[P_WHERE_STR]); |
|
1076 | + $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR].' '.$conditions[P_FIELDS_STR].(' WHERE '.$conditions[P_WHERE_STR]); |
|
1079 | 1077 | } |
1080 | 1078 | |
1081 | 1079 | public static function db_changeset_apply($db_changeset, $flush_delayed = false) { |
@@ -1173,7 +1171,7 @@ discard block |
||
1173 | 1171 | ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false; |
1174 | 1172 | if (@get_magic_quotes_gpc()) { |
1175 | 1173 | $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); |
1176 | - array_walk_recursive($gpcr, function (&$value, $key) { |
|
1174 | + array_walk_recursive($gpcr, function(&$value, $key) { |
|
1177 | 1175 | $value = stripslashes($value); |
1178 | 1176 | }); |
1179 | 1177 | } |
@@ -1187,7 +1185,7 @@ discard block |
||
1187 | 1185 | public static function init_3_load_config_file() { |
1188 | 1186 | $dbsettings = array(); |
1189 | 1187 | |
1190 | - require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
1188 | + require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
1191 | 1189 | self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix']; |
1192 | 1190 | self::$db_name = $dbsettings['name']; |
1193 | 1191 | self::$sn_secret_word = $dbsettings['secretword']; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | define('INSTALL', false); |
11 | 11 | define('IN_ADMIN', true); |
12 | 12 | |
13 | -require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
13 | +require('../common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
14 | 14 | |
15 | 15 | if ($user['authlevel'] < 3) { |
16 | 16 | AdminMessage(classLocale::$lang['adm_err_denied']); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | foreach ($value as $interval_data) { |
112 | 112 | print("<tr>"); |
113 | 113 | print("<td>{$user_id}</td><td>{$user_record['username']}</td><td>{$interval_data[0]}</td><td>{$interval_data[1]}</td><td>{$interval_data[2]}</td>"); |
114 | - print("<td>" . date(FMT_DATE_TIME_SQL, $user_record['onlinetime']) . "</td>"); |
|
114 | + print("<td>".date(FMT_DATE_TIME_SQL, $user_record['onlinetime'])."</td>"); |
|
115 | 115 | print("</tr>"); |
116 | 116 | } |
117 | 117 | } |
@@ -45,8 +45,8 @@ |
||
45 | 45 | */ |
46 | 46 | protected function quoteStringAsFieldByRef(&$string) { |
47 | 47 | $string = $this->stringEscape($string); |
48 | - if ((string)$string && '*' != $string) { |
|
49 | - $string = '`' . $string . '`'; |
|
48 | + if ((string) $string && '*' != $string) { |
|
49 | + $string = '`'.$string.'`'; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | |
22 | 22 | public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) { |
23 | 23 | $query = doquery( |
24 | - "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} " . |
|
25 | - ($unit_type ? "AND `unit_type` = {$unit_type} " : '') . |
|
26 | - ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') . |
|
24 | + "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} ". |
|
25 | + ($unit_type ? "AND `unit_type` = {$unit_type} " : ''). |
|
26 | + ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : ''). |
|
27 | 27 | 'GROUP BY `unit_snid`' |
28 | 28 | ); |
29 | 29 | $result = array(); |
30 | - while($row = db_fetch($query)) { |
|
30 | + while ($row = db_fetch($query)) { |
|
31 | 31 | $result[$row['unit_snid']] = $row; |
32 | 32 | } |
33 | 33 | |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | WHERE |
44 | 44 | f.fleet_owner = {$user_id} AND |
45 | 45 | (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id}) |
46 | - AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() . |
|
47 | - " LIMIT 1" . |
|
46 | + AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions(). |
|
47 | + " LIMIT 1". |
|
48 | 48 | ($for_update ? ' FOR UPDATE' : '') |
49 | 49 | , true); |
50 | 50 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public static function db_unit_list_laboratories($user_id) { |
54 | 54 | return doquery("SELECT DISTINCT unit_location_id AS `id` |
55 | 55 | FROM {{unit}} |
56 | - 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 . ");"); |
|
56 | + 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.");"); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | public static function db_unit_set_by_id($unit_id, $set) { |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | |
72 | 72 | public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id = 0, $unit_snid = 0) { |
73 | 73 | return classSupernova::db_del_record_list(LOC_UNIT, |
74 | - "`unit_location_type` = {$unit_location_type}" . |
|
75 | - ($unit_location_id = idval($unit_location_id) ? " AND `unit_location_id` = {$unit_location_id}" : '') . |
|
76 | - ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') . |
|
74 | + "`unit_location_type` = {$unit_location_type}". |
|
75 | + ($unit_location_id = idval($unit_location_id) ? " AND `unit_location_id` = {$unit_location_id}" : ''). |
|
76 | + ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : ''). |
|
77 | 77 | ($unit_snid = idval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : '')); |
78 | 78 | } |
79 | 79 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | return doquery( |
82 | 82 | "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount |
83 | 83 | FROM `{{unit}}` |
84 | - WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() . |
|
84 | + WHERE unit_level > 0 AND " . self::db_unit_time_restrictions(). |
|
85 | 85 | " GROUP BY unit_player_id, unit_type, unit_snid, unit_level" |
86 | 86 | ); |
87 | 87 | } |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | |
94 | 94 | |
95 | 95 | public static function db_unit_list_admin_delete_mercenaries_finished() { |
96 | - return doquery("DELETE FROM {{unit}} WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ") AND unit_type = " . UNIT_MERCENARIES); |
|
96 | + return doquery("DELETE FROM {{unit}} WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.") AND unit_type = ".UNIT_MERCENARIES); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | public static function db_unit_list_admin_set_mercenaries_expire_time($default_length) { |
100 | 100 | return doquery( |
101 | 101 | "UPDATE {{unit}} |
102 | 102 | SET |
103 | - unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW . "), |
|
104 | - unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length) . ") |
|
103 | + unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW."), |
|
104 | + unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length).") |
|
105 | 105 | WHERE unit_type = " . UNIT_MERCENARIES |
106 | 106 | ); |
107 | 107 | } |
@@ -398,31 +398,31 @@ discard block |
||
398 | 398 | |
399 | 399 | return doquery( |
400 | 400 | // Блокировка самого флота |
401 | - "SELECT 1 FROM {{fleets}} AS f " . |
|
401 | + "SELECT 1 FROM {{fleets}} AS f ". |
|
402 | 402 | |
403 | 403 | // Блокировка всех юнитов, принадлежащих этому флоту |
404 | - "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " . |
|
404 | + "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ". |
|
405 | 405 | |
406 | 406 | // Блокировка всех прилетающих и улетающих флотов, если нужно |
407 | 407 | // TODO - lock fleets by COORDINATES |
408 | - ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '') . |
|
408 | + ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : ''). |
|
409 | 409 | // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination |
410 | - ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') . |
|
410 | + ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = ".static::$locationType." AND ufd.unit_location_id = fd.fleet_id " : ''). |
|
411 | 411 | |
412 | - ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') . |
|
412 | + ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : ''). |
|
413 | 413 | // Блокировка всех юнитов, принадлежащих владельцу планеты-цели |
414 | - ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') . |
|
414 | + ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : ''). |
|
415 | 415 | // Блокировка планеты-цели |
416 | - ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') . |
|
416 | + ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : ''). |
|
417 | 417 | // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели |
418 | 418 | // ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') . |
419 | 419 | |
420 | 420 | |
421 | - ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') . |
|
421 | + ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : ''). |
|
422 | 422 | // Блокировка всех юнитов, принадлежащих владельцу флота |
423 | - ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') . |
|
423 | + ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : ''). |
|
424 | 424 | // Блокировка планеты отправления |
425 | - ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') . |
|
425 | + ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : ''). |
|
426 | 426 | // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота |
427 | 427 | // ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') . |
428 | 428 | |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | public function dbGetLockById($dbId) { |
440 | 440 | doquery( |
441 | 441 | // Блокировка самого флота |
442 | - "SELECT 1 FROM {{fleets}} AS FLEET0 " . |
|
442 | + "SELECT 1 FROM {{fleets}} AS FLEET0 ". |
|
443 | 443 | // Lock fleet owner |
444 | - "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " . |
|
444 | + "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ". |
|
445 | 445 | // Блокировка всех юнитов, принадлежащих этому флоту |
446 | - "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " . |
|
446 | + "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ". |
|
447 | 447 | |
448 | 448 | // Без предварительной выборки неизвестно - куда летит этот флот. |
449 | 449 | // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота. |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | FLEET1.fleet_end_planet = FLEET0.fleet_end_planet |
460 | 460 | " . |
461 | 461 | // Блокировка всех юнитов, принадлежащих этим флотам |
462 | - "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " . |
|
462 | + "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ". |
|
463 | 463 | // Lock fleet owner |
464 | - "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " . |
|
464 | + "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ". |
|
465 | 465 | |
466 | 466 | "LEFT JOIN {{fleets}} AS FLEET2 ON |
467 | 467 | FLEET2.fleet_mess = 1 AND FLEET0.fleet_mess = 0 AND |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | " . |
472 | 472 | // Блокировка всех юнитов, принадлежащих этим флотам |
473 | 473 | "LEFT JOIN {{unit}} as UNIT2 ON |
474 | - UNIT2.unit_location_type = " . LOC_FLEET . " AND |
|
474 | + UNIT2.unit_location_type = " . LOC_FLEET." AND |
|
475 | 475 | UNIT2.unit_location_id = FLEET2.fleet_id |
476 | 476 | " . |
477 | 477 | // Lock fleet owner |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | " . |
489 | 489 | // Блокировка всех юнитов, принадлежащих этим флотам |
490 | 490 | "LEFT JOIN {{unit}} as UNIT3 ON |
491 | - UNIT3.unit_location_type = " . LOC_FLEET . " AND |
|
491 | + UNIT3.unit_location_type = " . LOC_FLEET." AND |
|
492 | 492 | UNIT3.unit_location_id = FLEET3.fleet_id |
493 | 493 | " . |
494 | 494 | // Lock fleet owner |
495 | - "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " . |
|
495 | + "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ". |
|
496 | 496 | |
497 | 497 | "LEFT JOIN {{fleets}} AS FLEET4 ON |
498 | 498 | FLEET4.fleet_mess = 1 AND FLEET0.fleet_mess = 1 AND |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | " . |
503 | 503 | // Блокировка всех юнитов, принадлежащих этим флотам |
504 | 504 | "LEFT JOIN {{unit}} as UNIT4 ON |
505 | - UNIT4.unit_location_type = " . LOC_FLEET . " AND |
|
505 | + UNIT4.unit_location_type = " . LOC_FLEET." AND |
|
506 | 506 | UNIT4.unit_location_id = FLEET4.fleet_id |
507 | 507 | " . |
508 | 508 | // Lock fleet owner |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | " . |
525 | 525 | // Блокировка всех юнитов, принадлежащих этой планете |
526 | 526 | "LEFT JOIN {{unit}} as UNIT5 ON |
527 | - UNIT5.unit_location_type = " . LOC_PLANET . " AND |
|
527 | + UNIT5.unit_location_type = " . LOC_PLANET." AND |
|
528 | 528 | UNIT5.unit_location_id = PLANETS5.id |
529 | 529 | " . |
530 | 530 | |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | " . |
543 | 543 | // Блокировка всех юнитов, принадлежащих этой планете |
544 | 544 | "LEFT JOIN {{unit}} as UNIT6 ON |
545 | - UNIT6.unit_location_type = " . LOC_PLANET . " AND |
|
545 | + UNIT6.unit_location_type = " . LOC_PLANET." AND |
|
546 | 546 | UNIT6.unit_location_id = PLANETS6.id |
547 | 547 | " . |
548 | 548 | "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE" |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | } elseif ($this->isResource($unit_id)) { |
662 | 662 | $this->resource_list[$unit_id] = $unit_count; |
663 | 663 | } else { |
664 | - throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR); |
|
664 | + throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), ERR_ERROR); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | } |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | */ |
987 | 987 | public function resourcesSet($resource_list) { |
988 | 988 | if (!empty($this->propertiesAdjusted['resource_list'])) { |
989 | - throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR); |
|
989 | + throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR); |
|
990 | 990 | } |
991 | 991 | $this->resourcesAdjust($resource_list, true); |
992 | 992 | } |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | // Check for negative unit value |
1021 | 1021 | if ($this->resource_list[$resource_id] < 0) { |
1022 | 1022 | // TODO |
1023 | - throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR); |
|
1023 | + throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR); |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | } |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | |
1194 | 1194 | protected function printErrorIfNoShips() { |
1195 | 1195 | if ($this->unitList->unitsCount() <= 0) { |
1196 | - message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5); |
|
1196 | + message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5); |
|
1197 | 1197 | } |
1198 | 1198 | } |
1199 | 1199 | |
@@ -1540,7 +1540,7 @@ discard block |
||
1540 | 1540 | } catch (Exception $e) { |
1541 | 1541 | |
1542 | 1542 | // TODO - MESSAGE BOX |
1543 | - if($e instanceof ExceptionFleetInvalid) { |
|
1543 | + if ($e instanceof ExceptionFleetInvalid) { |
|
1544 | 1544 | sn_db_transaction_rollback(); |
1545 | 1545 | pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]); |
1546 | 1546 | } else { |
@@ -1629,7 +1629,7 @@ discard block |
||
1629 | 1629 | $validator->validate(); |
1630 | 1630 | } catch (Exception $e) { |
1631 | 1631 | // TODO - MESSAGE BOX |
1632 | - if($e instanceof ExceptionFleetInvalid) { |
|
1632 | + if ($e instanceof ExceptionFleetInvalid) { |
|
1633 | 1633 | sn_db_transaction_rollback(); |
1634 | 1634 | pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]); |
1635 | 1635 | } else { |
@@ -1690,7 +1690,7 @@ discard block |
||
1690 | 1690 | |
1691 | 1691 | |
1692 | 1692 | if (!empty($this->captain['unit_id'])) { |
1693 | - DBStaticUnit::db_unit_set_by_id($this->captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$this->_dbId}"); |
|
1693 | + DBStaticUnit::db_unit_set_by_id($this->captain['unit_id'], "`unit_location_type` = ".LOC_FLEET.", `unit_location_id` = {$this->_dbId}"); |
|
1694 | 1694 | } |
1695 | 1695 | |
1696 | 1696 | // return $this->fleet->acs['ankunft'] - $this->fleet->time_launch >= $this->fleet->travelData['duration']; |
@@ -1702,7 +1702,7 @@ discard block |
||
1702 | 1702 | $template_result['.']['fleets'][] = $this->renderFleet(SN_TIME_NOW, $timeMissionJob); |
1703 | 1703 | |
1704 | 1704 | $template_result += array( |
1705 | - 'mission' => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''), |
|
1705 | + 'mission' => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''), |
|
1706 | 1706 | 'dist' => pretty_number($this->travelData['distance']), |
1707 | 1707 | 'speed' => pretty_number($this->travelData['fleet_speed']), |
1708 | 1708 | 'deute_need' => pretty_number($this->travelData['consumption']), |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | |
36 | 36 | $this->container = array(); |
37 | 37 | |
38 | - if(classSupernova::$cache->_MODE != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
38 | + if (classSupernova::$cache->_MODE != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
39 | 39 | $this->cache = classSupernova::$cache; |
40 | 40 | classSupernova::log_file('locale.__constructor: Cache is present'); |
41 | 41 | //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug! |
42 | 42 | } |
43 | 43 | |
44 | - if($enable_stat_usage && empty($this->stat_usage)) { |
|
44 | + if ($enable_stat_usage && empty($this->stat_usage)) { |
|
45 | 45 | $this->enable_stat_usage = $enable_stat_usage; |
46 | 46 | $this->usage_stat_load(); |
47 | 47 | // TODO shutdown function |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | unset($fallback[$this->active]); |
68 | 68 | |
69 | 69 | // Проходим по оставшимся локалям |
70 | - foreach($fallback as $try_language) { |
|
70 | + foreach ($fallback as $try_language) { |
|
71 | 71 | // Если нет такой строки - пытаемся вытащить из кэша |
72 | - if(!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
73 | - $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset); |
|
72 | + if (!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
73 | + $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix.$try_language.'_'.$offset); |
|
74 | 74 | // Записываем результат работы кэша |
75 | 75 | $locale_cache_statistic['queries']++; |
76 | 76 | isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['hits']++ : $locale_cache_statistic['misses']++; |
77 | -!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix . $try_language . '_' . $offset : false; |
|
77 | +!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix.$try_language.'_'.$offset : false; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Если мы как-то где-то нашли строку... |
81 | - if(isset($this->container[$try_language][$offset])) { |
|
81 | + if (isset($this->container[$try_language][$offset])) { |
|
82 | 82 | // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер |
83 | 83 | $this[$offset] = $this->container[$try_language][$offset]; |
84 | 84 | $locale_cache_statistic['fallbacks']++; |
@@ -94,16 +94,16 @@ discard block |
||
94 | 94 | $this->container[$this->active][] = $value; |
95 | 95 | } else { |
96 | 96 | $this->container[$this->active][$offset] = $value; |
97 | - if($this->cache) { |
|
98 | - $this->cache->__set($this->cache_prefix_lang . $offset, $value); |
|
97 | + if ($this->cache) { |
|
98 | + $this->cache->__set($this->cache_prefix_lang.$offset, $value); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | 102 | public function offsetExists($offset) { |
103 | 103 | // Шорткат если у нас уже есть строка в памяти PHP |
104 | - if(!isset($this->container[$this->active][$offset])) { |
|
104 | + if (!isset($this->container[$this->active][$offset])) { |
|
105 | 105 | // pdump($this->cache_prefix_lang . $offset); |
106 | - if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
106 | + if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang.$offset))) { |
|
107 | 107 | // pdump($this->cache_prefix_lang . $offset); |
108 | 108 | // Если нету такой строки - делаем фоллбэк |
109 | 109 | $this->locale_string_fallback($offset); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | public function offsetGet($offset) { |
121 | 121 | $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null; |
122 | - if($this->enable_stat_usage) { |
|
122 | + if ($this->enable_stat_usage) { |
|
123 | 123 | $this->usage_stat_log($offset, $value); |
124 | 124 | } |
125 | 125 | return $value; |
@@ -136,26 +136,26 @@ discard block |
||
136 | 136 | public function usage_stat_load() { |
137 | 137 | global $sn_cache; |
138 | 138 | |
139 | - $this->stat_usage = $sn_cache->lng_stat_usage = array(); // TODO for debug |
|
140 | - if(empty($this->stat_usage)) { |
|
139 | + $this->stat_usage = $sn_cache->lng_stat_usage = array(); // TODO for debug |
|
140 | + if (empty($this->stat_usage)) { |
|
141 | 141 | $query = doquery("SELECT * FROM {{lng_usage_stat}}"); |
142 | - while($row = db_fetch($query)) { |
|
143 | - $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty']; |
|
142 | + while ($row = db_fetch($query)) { |
|
143 | + $this->stat_usage[$row['lang_code'].':'.$row['string_id'].':'.$row['file'].':'.$row['line']] = $row['is_empty']; |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | } |
147 | 147 | public function usage_stat_save() { |
148 | - if(!empty($this->stat_usage_new)) { |
|
148 | + if (!empty($this->stat_usage_new)) { |
|
149 | 149 | global $sn_cache; |
150 | 150 | $sn_cache->lng_stat_usage = $this->stat_usage; |
151 | 151 | doquery("SELECT 1 FROM {{lng_usage_stat}} LIMIT 1"); |
152 | - foreach($this->stat_usage_new as &$value) { |
|
153 | - foreach($value as &$value2) { |
|
154 | - $value2 = '"' . db_escape($value2) . '"'; |
|
152 | + foreach ($this->stat_usage_new as &$value) { |
|
153 | + foreach ($value as &$value2) { |
|
154 | + $value2 = '"'.db_escape($value2).'"'; |
|
155 | 155 | } |
156 | - $value = '(' . implode(',', $value) .')'; |
|
156 | + $value = '('.implode(',', $value).')'; |
|
157 | 157 | } |
158 | - doquery("REPLACE INTO {{lng_usage_stat}} (lang_code,string_id,`file`,line,is_empty,locale) VALUES " . implode(',', $this->stat_usage_new)); |
|
158 | + doquery("REPLACE INTO {{lng_usage_stat}} (lang_code,string_id,`file`,line,is_empty,locale) VALUES ".implode(',', $this->stat_usage_new)); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | public function usage_stat_log(&$offset, &$value) { |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | |
166 | 166 | $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1)); |
167 | 167 | |
168 | - $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line']; |
|
169 | - if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
168 | + $string_id = $this->active.':'.$offset.':'.$file.':'.$trace[1]['line']; |
|
169 | + if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
170 | 170 | $this->stat_usage[$string_id] = empty($value); |
171 | 171 | $this->stat_usage_new[] = array( |
172 | 172 | 'lang_code' => $this->active, |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | 'file' => $file, |
175 | 175 | 'line' => $trace[1]['line'], |
176 | 176 | 'is_empty' => intval(empty($value)), |
177 | - 'locale' => '' . $value, |
|
177 | + 'locale' => ''.$value, |
|
178 | 178 | ); |
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | 182 | |
183 | 183 | protected function lng_try_filepath($path, $file_path_relative) { |
184 | - $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
|
184 | + $file_path = SN_ROOT_PHYSICAL.($path && file_exists(SN_ROOT_PHYSICAL.$path.$file_path_relative) ? $path : '').$file_path_relative; |
|
185 | 185 | return file_exists($file_path) ? $file_path : false; |
186 | 186 | } |
187 | 187 | |
@@ -203,14 +203,14 @@ discard block |
||
203 | 203 | |
204 | 204 | classSupernova::log_file("locale.include: Loading data from domain '{$filename}'", 1); |
205 | 205 | |
206 | - $cache_file_key = $this->cache_prefix_lang . '__' . $filename; |
|
206 | + $cache_file_key = $this->cache_prefix_lang.'__'.$filename; |
|
207 | 207 | |
208 | 208 | // Подключен ли внешний кэш? |
209 | - if($this->cache) { |
|
209 | + if ($this->cache) { |
|
210 | 210 | // Загружен ли уже данный файл? |
211 | 211 | $cache_file_status = $this->cache->__get($cache_file_key); |
212 | - classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is " . ($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0); |
|
213 | - if($cache_file_status) { |
|
212 | + classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is ".($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0); |
|
213 | + if ($cache_file_status) { |
|
214 | 214 | // Если да - повторять загрузку нет смысла |
215 | 215 | return null; |
216 | 216 | } |
@@ -224,47 +224,47 @@ discard block |
||
224 | 224 | $this->make_fallback($language); |
225 | 225 | |
226 | 226 | $file_path = ''; |
227 | - foreach($this->fallback as $lang_try) { |
|
228 | - if(!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
227 | + foreach ($this->fallback as $lang_try) { |
|
228 | + if (!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
229 | 229 | continue; |
230 | 230 | } |
231 | 231 | |
232 | - if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
232 | + if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
233 | 233 | break; |
234 | 234 | } |
235 | 235 | |
236 | - if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
236 | + if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
237 | 237 | break; |
238 | 238 | } |
239 | 239 | |
240 | 240 | $file_path = ''; |
241 | 241 | } |
242 | 242 | |
243 | - if($file_path) { |
|
243 | + if ($file_path) { |
|
244 | 244 | $a_lang_array = array(); |
245 | 245 | include($file_path); |
246 | 246 | |
247 | - if(!empty($a_lang_array)) { |
|
247 | + if (!empty($a_lang_array)) { |
|
248 | 248 | $this->merge($a_lang_array); |
249 | 249 | |
250 | 250 | // Загрузка данных из файла в кэш |
251 | - if($this->cache) { |
|
251 | + if ($this->cache) { |
|
252 | 252 | classSupernova::log_file("Locale: loading '{$filename}' into cache"); |
253 | - foreach($a_lang_array as $key => $value) { |
|
254 | - $value_cache_key = $this->cache_prefix_lang . $key; |
|
255 | - if($this->cache->__isset($value_cache_key)) { |
|
256 | - if(is_array($value)) { |
|
253 | + foreach ($a_lang_array as $key => $value) { |
|
254 | + $value_cache_key = $this->cache_prefix_lang.$key; |
|
255 | + if ($this->cache->__isset($value_cache_key)) { |
|
256 | + if (is_array($value)) { |
|
257 | 257 | $alt_value = $this->cache->__get($value_cache_key); |
258 | 258 | $value = array_replace_recursive($alt_value, $value); |
259 | 259 | // pdump($alt_value, $alt_value); |
260 | 260 | } |
261 | 261 | } |
262 | - $this->cache->__set($this->cache_prefix_lang . $key, $value); |
|
262 | + $this->cache->__set($this->cache_prefix_lang.$key, $value); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
267 | - if($this->cache) { |
|
267 | + if ($this->cache) { |
|
268 | 268 | $this->cache->__set($cache_file_key, true); |
269 | 269 | } |
270 | 270 | |
@@ -277,14 +277,14 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | public function lng_load_i18n($i18n) { |
280 | - if(!isset($i18n)) { |
|
280 | + if (!isset($i18n)) { |
|
281 | 281 | return; |
282 | 282 | } |
283 | 283 | |
284 | - foreach($i18n as $i18n_data) { |
|
285 | - if(is_string($i18n_data)) { |
|
284 | + foreach ($i18n as $i18n_data) { |
|
285 | + if (is_string($i18n_data)) { |
|
286 | 286 | $this->lng_include($i18n_data); |
287 | - } elseif(is_array($i18n_data)) { |
|
287 | + } elseif (is_array($i18n_data)) { |
|
288 | 288 | $this->lng_include($i18n_data['file'], $i18n_data['path']); |
289 | 289 | } |
290 | 290 | } |
@@ -302,27 +302,27 @@ discard block |
||
302 | 302 | |
303 | 303 | classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'"); |
304 | 304 | |
305 | - if($language_new == $this->active) { |
|
305 | + if ($language_new == $this->active) { |
|
306 | 306 | classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1); |
307 | 307 | return false; |
308 | 308 | } |
309 | 309 | |
310 | 310 | $this->active = $language = $language_new; |
311 | - $this->cache_prefix_lang = $this->cache_prefix . $this->active . '_'; |
|
311 | + $this->cache_prefix_lang = $this->cache_prefix.$this->active.'_'; |
|
312 | 312 | |
313 | 313 | $this['LANG_INFO'] = $this->lng_get_info($this->active); |
314 | 314 | $this->make_fallback($this->active); |
315 | 315 | |
316 | - if($this->cache) { |
|
317 | - $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT'); |
|
318 | - classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is " . ($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0); |
|
319 | - if($cache_lang_init_status) { |
|
316 | + if ($this->cache) { |
|
317 | + $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang.'__INIT'); |
|
318 | + classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is ".($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0); |
|
319 | + if ($cache_lang_init_status) { |
|
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | |
323 | 323 | // Чистим текущие локализации из кэша. Достаточно почистить только флаги инициализации языкового кэша и загрузки файлов - они начинаются с '__' |
324 | 324 | classSupernova::log_file("locale.switch: Cache - invalidating data"); |
325 | - $this->cache->unset_by_prefix($this->cache_prefix_lang . '__'); |
|
325 | + $this->cache->unset_by_prefix($this->cache_prefix_lang.'__'); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | $this->lng_include('system'); |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | // Loading global language files |
333 | 333 | $this->lng_load_i18n(classSupernova::$sn_mvc['i18n']['']); |
334 | 334 | |
335 | - if($this->cache) { |
|
336 | - classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT'); |
|
337 | - $this->cache->__set($this->cache_prefix_lang . '__INIT', true); |
|
335 | + if ($this->cache) { |
|
336 | + classSupernova::log_file("locale.switch: Cache - setting flag ".$this->cache_prefix_lang.'__INIT'); |
|
337 | + $this->cache->__set($this->cache_prefix_lang.'__INIT', true); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | classSupernova::log_file("locale.switch: Complete - EXIT"); |
@@ -344,9 +344,9 @@ discard block |
||
344 | 344 | |
345 | 345 | |
346 | 346 | public function lng_get_info($entry) { |
347 | - $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php'; |
|
347 | + $file_name = SN_ROOT_PHYSICAL.'language/'.$entry.'/language.mo.php'; |
|
348 | 348 | $lang_info = array(); |
349 | - if(file_exists($file_name)) { |
|
349 | + if (file_exists($file_name)) { |
|
350 | 350 | include($file_name); |
351 | 351 | } |
352 | 352 | |
@@ -354,15 +354,15 @@ discard block |
||
354 | 354 | } |
355 | 355 | |
356 | 356 | public function lng_get_list() { |
357 | - if(empty($this->lang_list)) { |
|
357 | + if (empty($this->lang_list)) { |
|
358 | 358 | $this->lang_list = array(); |
359 | 359 | |
360 | - $path = SN_ROOT_PHYSICAL . 'language/'; |
|
360 | + $path = SN_ROOT_PHYSICAL.'language/'; |
|
361 | 361 | $dir = dir($path); |
362 | - while(false !== ($entry = $dir->read())) { |
|
363 | - if(is_dir($path . $entry) && $entry[0] != '.') { |
|
362 | + while (false !== ($entry = $dir->read())) { |
|
363 | + if (is_dir($path.$entry) && $entry[0] != '.') { |
|
364 | 364 | $lang_info = $this->lng_get_info($entry); |
365 | - if($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
365 | + if ($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
366 | 366 | $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info; |
367 | 367 | } |
368 | 368 | } |