@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
3 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
4 | 4 | |
5 | 5 | $template = gettemplate('viewreport', true); |
6 | 6 | $template->assign_var('PAGE_HINT', classLocale::$lang['cr_view_hint']); |
@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | define('IN_ADMIN', true); |
4 | 4 | |
5 | -require('../includes/init.' . substr(strrchr(__FILE__, '.'), 1)); |
|
5 | +require('../includes/init.'.substr(strrchr(__FILE__, '.'), 1)); |
|
6 | 6 | |
7 | -if($user['authlevel'] < 3) |
|
7 | +if ($user['authlevel'] < 3) |
|
8 | 8 | { |
9 | 9 | message(classLocale::$lang['sys_noalloaw'], classLocale::$lang['sys_noaccess']); |
10 | 10 | die(); |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | // [#] info_best_battles 1b0 |
21 | 21 | $best_reports = array(); |
22 | 22 | |
23 | -if(defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
23 | +if (defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
24 | 24 | $query = db_ube_report_get_best_battles(); |
25 | - while($row = db_fetch($query)) { |
|
25 | + while ($row = db_fetch($query)) { |
|
26 | 26 | $best_reports[] = $row['ube_report_id']; |
27 | 27 | } |
28 | 28 | } |
29 | -$best_reports = !empty($best_reports) ? ' AND ube_report_id NOT IN (' . implode(',', $best_reports) . ')' : ''; |
|
29 | +$best_reports = !empty($best_reports) ? ' AND ube_report_id NOT IN ('.implode(',', $best_reports).')' : ''; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | $ques = array( |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | // Удаляем юниты без планет |
91 | 91 | 'DELETE un FROM {{unit}} AS un |
92 | 92 | LEFT JOIN {{planets}} AS pl ON pl.id = un.unit_location_id |
93 | - WHERE unit_location_type = ' . LOC_PLANET . ' AND pl.id IS NULL;', |
|
93 | + WHERE unit_location_type = ' . LOC_PLANET.' AND pl.id IS NULL;', |
|
94 | 94 | // Удаляем пустые юниты с 0 уровнем (кроме Капитана) |
95 | - 'DELETE FROM {{unit}} WHERE unit_location_type = ' . LOC_PLANET . ' AND unit_level = 0 AND unit_type <> ' . UNIT_CAPTAIN, |
|
95 | + 'DELETE FROM {{unit}} WHERE unit_location_type = '.LOC_PLANET.' AND unit_level = 0 AND unit_type <> '.UNIT_CAPTAIN, |
|
96 | 96 | // Удаляем очереди на ничьих планетах |
97 | 97 | 'DELETE q FROM {{que}} AS q |
98 | 98 | LEFT JOIN {{planets}} AS p ON p.id = q.que_planet_id |
99 | 99 | WHERE |
100 | - que_type IN (' . QUE_STRUCTURES . ', ' . QUE_HANGAR . ', ' . SUBQUE_FLEET . ', ' . SUBQUE_DEFENSE . ') |
|
100 | + que_type IN (' . QUE_STRUCTURES.', '.QUE_HANGAR.', '.SUBQUE_FLEET.', '.SUBQUE_DEFENSE.') |
|
101 | 101 | AND |
102 | 102 | (p.id_owner = 0 OR p.id_owner IS NULL);', |
103 | 103 | |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | // Удаляются сообщения, старше 4 недель, кроме личных и Альянсовских |
113 | 113 | 'DELETE FROM {{messages}} WHERE |
114 | 114 | UNIX_TIMESTAMP() - message_time > 4*7 * 24 * 60 * 60 AND |
115 | - message_type NOT IN (' . MSG_TYPE_PLAYER . ', ' . MSG_TYPE_ALLIANCE . ');', |
|
115 | + message_type NOT IN (' . MSG_TYPE_PLAYER.', '.MSG_TYPE_ALLIANCE.');', |
|
116 | 116 | // Удаляются сообщения у пользователей, которые неактивны больше 4 недель - кроме личных и Альянсовских |
117 | 117 | 'DELETE m FROM `{{users}}` AS u |
118 | 118 | JOIN {{messages}} AS m ON m.message_owner = u.id |
119 | 119 | WHERE |
120 | - message_type NOT IN (' . MSG_TYPE_PLAYER . ', ' . MSG_TYPE_ALLIANCE . ') AND |
|
120 | + message_type NOT IN (' . MSG_TYPE_PLAYER.', '.MSG_TYPE_ALLIANCE.') AND |
|
121 | 121 | authlevel = 0 AND user_as_ally IS NULL AND /* Не админы, Не Альянсы */ |
122 | 122 | UNIX_TIMESTAMP() - onlinetime > 4*7 *86400;', |
123 | 123 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | (log_dark_matter_timestamp, log_dark_matter_username, log_dark_matter_reason, log_dark_matter_amount, |
138 | 138 | log_dark_matter_comment, log_dark_matter_page, log_dark_matter_sender) |
139 | 139 | SELECT |
140 | - '{$pack_until}', IF(u.username IS NULL, ldm.log_dark_matter_username, u.username), " . RPG_CUMULATIVE . ", sum(ldm.log_dark_matter_amount), |
|
140 | + '{$pack_until}', IF(u.username IS NULL, ldm.log_dark_matter_username, u.username), ".RPG_CUMULATIVE.", sum(ldm.log_dark_matter_amount), |
|
141 | 141 | 'Баланс на {$pack_until}', 'admin/ajax_maintenance.php', ldm.log_dark_matter_sender |
142 | 142 | FROM |
143 | 143 | {{log_dark_matter}} AS ldm |
@@ -155,22 +155,22 @@ discard block |
||
155 | 155 | "REPLACE INTO `{{log_users_online}}` |
156 | 156 | (online_timestamp, online_count, online_aggregated) |
157 | 157 | SELECT |
158 | - FROM_UNIXTIME((UNIX_TIMESTAMP(online_timestamp) DIV " . PERIOD_MINUTE_10 . ") * (" . PERIOD_MINUTE_10 . ")), ceil(avg(online_count)), " . LOG_ONLIINE_AGGREGATE_PERIOD_MINUTE_10 . " |
|
158 | + FROM_UNIXTIME((UNIX_TIMESTAMP(online_timestamp) DIV " . PERIOD_MINUTE_10.") * (".PERIOD_MINUTE_10.")), ceil(avg(online_count)), ".LOG_ONLIINE_AGGREGATE_PERIOD_MINUTE_10." |
|
159 | 159 | FROM |
160 | 160 | `{{log_users_online}}` |
161 | 161 | WHERE |
162 | - online_timestamp < '{$pack_until}' AND online_aggregated = " . LOG_ONLIINE_AGGREGATE_NONE . " |
|
162 | + online_timestamp < '{$pack_until}' AND online_aggregated = ".LOG_ONLIINE_AGGREGATE_NONE." |
|
163 | 163 | GROUP BY |
164 | - (UNIX_TIMESTAMP(online_timestamp) DIV " . PERIOD_MINUTE_10 . ") * (" . PERIOD_MINUTE_10 . ");", |
|
164 | + (UNIX_TIMESTAMP(online_timestamp) DIV " . PERIOD_MINUTE_10.") * (".PERIOD_MINUTE_10.");", |
|
165 | 165 | |
166 | - "DELETE FROM {{log_users_online}} WHERE online_timestamp < '{$pack_until}' AND online_aggregated = " . LOG_ONLIINE_AGGREGATE_NONE, |
|
166 | + "DELETE FROM {{log_users_online}} WHERE online_timestamp < '{$pack_until}' AND online_aggregated = ".LOG_ONLIINE_AGGREGATE_NONE, |
|
167 | 167 | ), |
168 | 168 | |
169 | 169 | // Удаляем старые записи из логов |
170 | 170 | "DELETE FROM `{{logs}}` WHERE log_timestamp < '{$pack_until}';", |
171 | 171 | // Удаляем записи о маинтенансе, апдейте и пересчете статистики более чем недельной давности - они нам уже не нужны |
172 | 172 | 'DELETE FROM `{{logs}}` WHERE |
173 | - `log_code` IN (' . LOG_INFO_DB_CHANGE . ', ' . LOG_INFO_MAINTENANCE . ', ' . LOG_INFO_STAT_START . ', ' . LOG_INFO_STAT_PROCESS . ', ' . LOG_INFO_STAT_FINISH . ') |
|
173 | + `log_code` IN (' . LOG_INFO_DB_CHANGE.', '.LOG_INFO_MAINTENANCE.', '.LOG_INFO_STAT_START.', '.LOG_INFO_STAT_PROCESS.', '.LOG_INFO_STAT_FINISH.') |
|
174 | 174 | AND `log_timestamp` < DATE_SUB(NOW(),INTERVAL 7 DAY);', |
175 | 175 | |
176 | 176 | |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | $old_server_status == GAME_DISABLE_NONE ? classSupernova::$config->db_saveItem('game_disable', GAME_DISABLE_MAINTENANCE) : false; |
190 | 190 | sn_db_transaction_commit(); |
191 | 191 | |
192 | -foreach($ques as $que_transaction) { |
|
192 | +foreach ($ques as $que_transaction) { |
|
193 | 193 | sn_db_transaction_start(); |
194 | 194 | |
195 | 195 | !is_array($que_transaction) ? $que_transaction = array($que_transaction) : false; |
196 | - foreach($que_transaction as $que) { |
|
196 | + foreach ($que_transaction as $que) { |
|
197 | 197 | set_time_limit(120); |
198 | - if(is_callable($que)) { |
|
198 | + if (is_callable($que)) { |
|
199 | 199 | $QryResult = call_user_func($que); |
200 | 200 | } else { |
201 | 201 | $QryResult = doquery($que); |
@@ -206,12 +206,12 @@ discard block |
||
206 | 206 | //$que = str_replace('}}', '', $que); |
207 | 207 | |
208 | 208 | $msg .= |
209 | - '<li>' . htmlspecialchars($que) . |
|
210 | - ' --- <span style="' . ($QryResult ? 'ok">OK' : 'error">FAILED!') . '</span> ' . |
|
211 | - classSupernova::$db->db_affected_rows() . ' ' . classLocale::$lang['adm_records'] . |
|
209 | + '<li>'.htmlspecialchars($que). |
|
210 | + ' --- <span style="'.($QryResult ? 'ok">OK' : 'error">FAILED!').'</span> '. |
|
211 | + classSupernova::$db->db_affected_rows().' '.classLocale::$lang['adm_records']. |
|
212 | 212 | "</li>"; |
213 | 213 | |
214 | - classSupernova::$debug->warning($que . ' --- ' . ($QryResult ? 'OK' : 'FAILED!') . ' ' . classSupernova::$db->db_affected_rows() . ' ' . classLocale::$lang['adm_records'], 'System maintenance', LOG_INFO_MAINTENANCE); |
|
214 | + classSupernova::$debug->warning($que.' --- '.($QryResult ? 'OK' : 'FAILED!').' '.classSupernova::$db->db_affected_rows().' '.classLocale::$lang['adm_records'], 'System maintenance', LOG_INFO_MAINTENANCE); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | sn_db_transaction_commit(); |
@@ -239,5 +239,5 @@ discard block |
||
239 | 239 | |
240 | 240 | $adm_stat_title = classLocale::$lang['adm_stat_title']; |
241 | 241 | $result = $result ? "<li>{$adm_stat_title} - {$result}</li>" : ''; |
242 | -$result = '<div align="left"><ul>' . $msg . $result . '</ul></div>'; |
|
243 | -echo json_encode($result . ' ' . $totaltime); |
|
242 | +$result = '<div align="left"><ul>'.$msg.$result.'</ul></div>'; |
|
243 | +echo json_encode($result.' '.$totaltime); |
@@ -12,24 +12,24 @@ discard block |
||
12 | 12 | global $template_result, $user; |
13 | 13 | |
14 | 14 | // Напоминание для Администрации, что игра отключена |
15 | -if($template_result[F_GAME_DISABLE]) { |
|
15 | +if ($template_result[F_GAME_DISABLE]) { |
|
16 | 16 | echo '<div class="global_admin_warning">', $template_result[F_GAME_DISABLE_REASON], '</div>'; |
17 | 17 | } |
18 | 18 | unset($disable_reason); |
19 | 19 | |
20 | 20 | |
21 | -if(defined('IN_ADMIN') && IN_ADMIN === true) { |
|
21 | +if (defined('IN_ADMIN') && IN_ADMIN === true) { |
|
22 | 22 | lng_include('admin'); |
23 | -} elseif($sys_user_logged_in) { |
|
23 | +} elseif ($sys_user_logged_in) { |
|
24 | 24 | sys_user_vacation($user); |
25 | 25 | |
26 | 26 | $planet_id = SetSelectedPlanet($user); |
27 | 27 | |
28 | 28 | // TODO НЕ НУЖНО АЛЬЯНС КАЖДЫЙ РАЗ ОБНОВЛЯТЬ!!! |
29 | - if($user['ally_id']) { |
|
29 | + if ($user['ally_id']) { |
|
30 | 30 | sn_db_transaction_start(); |
31 | 31 | sn_ali_fill_user_ally($user); |
32 | - if(!$user['ally']['player']['id']) { |
|
32 | + if (!$user['ally']['player']['id']) { |
|
33 | 33 | // sn_sys_logout(false, true); |
34 | 34 | // core_auth::logout(false); |
35 | 35 | classSupernova::$auth->logout(false); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | // TODO UNCOMMENT |
39 | 39 | que_process($user['ally']['player']); |
40 | - DBStaticUser::db_user_set_by_id($user['ally']['player']['id'], '`onlinetime` = ' . SN_TIME_NOW); |
|
40 | + DBStaticUser::db_user_set_by_id($user['ally']['player']['id'], '`onlinetime` = '.SN_TIME_NOW); |
|
41 | 41 | sn_db_transaction_commit(); |
42 | 42 | } |
43 | 43 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | sn_db_transaction_commit(); |
49 | 49 | |
50 | 50 | $planetrow = $global_data['planet']; |
51 | - if(!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
51 | + if (!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
52 | 52 | // sn_sys_logout(false, true); |
53 | 53 | // core_auth::logout(false); |
54 | 54 | classSupernova::$auth->logout(false); |
@@ -3,22 +3,22 @@ discard block |
||
3 | 3 | define('INSIDE', true); |
4 | 4 | define('INSTALL', false); |
5 | 5 | define('IN_ADMIN', true); |
6 | -require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
6 | +require('../common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
7 | 7 | |
8 | -if($user['authlevel'] < 3) { |
|
8 | +if ($user['authlevel'] < 3) { |
|
9 | 9 | AdminMessage(classLocale::$lang['adm_err_denied']); |
10 | 10 | } |
11 | 11 | |
12 | 12 | lng_include('admin'); |
13 | 13 | |
14 | 14 | $user_id = sys_get_param_id('uid'); |
15 | -if(!($user_row = DBStaticUser::db_user_by_id($user_id))) { |
|
15 | +if (!($user_row = DBStaticUser::db_user_by_id($user_id))) { |
|
16 | 16 | AdminMessage(sprintf(classLocale::$lang['adm_dm_user_none'], $user_id)); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $template = gettemplate('admin/admin_user', true); |
20 | 20 | |
21 | -if(!empty($user_row['user_last_browser_id'])) { |
|
21 | +if (!empty($user_row['user_last_browser_id'])) { |
|
22 | 22 | $user_row['browser_user_agent'] = db_browser_agent_get_by_id($user_row['user_last_browser_id']); |
23 | 23 | } |
24 | 24 | |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | 'raidsloose', |
55 | 55 | 'raidswin', |
56 | 56 | 'total_rank', |
57 | - 'total_points', ), |
|
57 | + 'total_points',), |
|
58 | 58 | ); |
59 | -foreach($formats as $callable => $field_list) { |
|
60 | - foreach($field_list as $field_name) { |
|
59 | +foreach ($formats as $callable => $field_list) { |
|
60 | + foreach ($field_list as $field_name) { |
|
61 | 61 | $user_row[$field_name] = call_user_func($callable, $user_row[$field_name]); |
62 | 62 | } |
63 | 63 | } |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | $announce_list = db_news_list_get_by_query($template, $query_where, $query_limit); |
12 | 12 | |
13 | 13 | $users = array(); |
14 | - while($announce = db_fetch($announce_list)) { |
|
15 | - if($announce['user_id'] && !isset($users[$announce['user_id']])) { |
|
14 | + while ($announce = db_fetch($announce_list)) { |
|
15 | + if ($announce['user_id'] && !isset($users[$announce['user_id']])) { |
|
16 | 16 | $users[$announce['user_id']] = DBStaticUser::db_user_by_id($announce['user_id']); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $survey_vote = array('survey_vote_id' => 1); |
20 | 20 | $survey_complete = strtotime($announce['survey_until']) < SN_TIME_NOW; |
21 | 21 | |
22 | - if($announce['survey_id'] && !empty($user['id'])) { |
|
22 | + if ($announce['survey_id'] && !empty($user['id'])) { |
|
23 | 23 | $survey_vote = !$survey_complete ? db_survey_get_vote($announce, $user) : array(); |
24 | 24 | } |
25 | 25 | |
@@ -31,8 +31,7 @@ discard block |
||
31 | 31 | 'ANNOUNCE' => cht_message_parse($announce['strAnnounce'], false, intval($announce['authlevel'])), |
32 | 32 | 'DETAIL_URL' => $announce['detail_url'], |
33 | 33 | 'USER_NAME' => |
34 | - isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : |
|
35 | - js_safe_string($announce['user_name']), |
|
34 | + isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : js_safe_string($announce['user_name']), |
|
36 | 35 | 'NEW' => $announce['unix_time'] + classSupernova::$config->game_news_actual >= SN_TIME_NOW, |
37 | 36 | 'FUTURE' => $announce['unix_time'] > SN_TIME_NOW, |
38 | 37 | 'SURVEY_ID' => $announce['survey_id'], |
@@ -42,25 +41,25 @@ discard block |
||
42 | 41 | 'SURVEY_UNTIL' => $announce['survey_until'], |
43 | 42 | )); |
44 | 43 | |
45 | - foreach($announce_exploded as $announce_paragraph) { |
|
44 | + foreach ($announce_exploded as $announce_paragraph) { |
|
46 | 45 | $template->assign_block_vars('announces.paragraph', array( |
47 | 46 | 'TEXT' => $announce_paragraph, |
48 | 47 | )); |
49 | 48 | } |
50 | 49 | |
51 | - if($announce['survey_id']) { |
|
50 | + if ($announce['survey_id']) { |
|
52 | 51 | $survey_query = db_survey_get_answer_texts($announce); |
53 | 52 | $survey_vote_result = array(); |
54 | 53 | $total_votes = 0; |
55 | - while($row = db_fetch($survey_query)) { |
|
54 | + while ($row = db_fetch($survey_query)) { |
|
56 | 55 | $survey_vote_result[] = $row; |
57 | 56 | $total_votes += $row['VOTES']; |
58 | 57 | } |
59 | 58 | |
60 | - if(empty($survey_vote) && !$survey_complete) { |
|
59 | + if (empty($survey_vote) && !$survey_complete) { |
|
61 | 60 | // Can vote |
62 | 61 | $survey_query = db_survey_answers_get_list_by_parent($announce); |
63 | - while($row = db_fetch($survey_query)) { |
|
62 | + while ($row = db_fetch($survey_query)) { |
|
64 | 63 | $template->assign_block_vars('announces.survey_answers', array( |
65 | 64 | 'ID' => $row['survey_answer_id'], |
66 | 65 | 'TEXT' => $row['survey_answer_text'], |
@@ -68,7 +67,7 @@ discard block |
||
68 | 67 | } |
69 | 68 | } else { |
70 | 69 | // Show result |
71 | - foreach($survey_vote_result as &$vote_result) { |
|
70 | + foreach ($survey_vote_result as &$vote_result) { |
|
72 | 71 | $vote_percent = $total_votes ? $vote_result['VOTES'] / $total_votes * 100 : 0; |
73 | 72 | $vote_result['PERCENT'] = $vote_percent; |
74 | 73 | $vote_result['PERCENT_TEXT'] = round($vote_percent, 1); |
@@ -85,8 +84,8 @@ discard block |
||
85 | 84 | } |
86 | 85 | |
87 | 86 | function nws_mark_read(&$user) { |
88 | - if(isset($user['id'])) { |
|
89 | - DBStaticUser::db_user_set_by_id($user['id'], '`news_lastread` = ' . SN_TIME_NOW); |
|
87 | + if (isset($user['id'])) { |
|
88 | + DBStaticUser::db_user_set_by_id($user['id'], '`news_lastread` = '.SN_TIME_NOW); |
|
90 | 89 | $user['news_lastread'] = SN_TIME_NOW; |
91 | 90 | } |
92 | 91 | |
@@ -94,17 +93,17 @@ discard block |
||
94 | 93 | } |
95 | 94 | |
96 | 95 | function survey_vote(&$user) { |
97 | - if(empty($user['id'])) { |
|
96 | + if (empty($user['id'])) { |
|
98 | 97 | return true; |
99 | 98 | } |
100 | 99 | |
101 | 100 | sn_db_transaction_start(); |
102 | 101 | $survey_id = sys_get_param_id('survey_id'); |
103 | 102 | $is_voted = db_survey_vote_get($user, $survey_id); |
104 | - if(empty($is_voted)) { |
|
103 | + if (empty($is_voted)) { |
|
105 | 104 | $survey_vote_id = sys_get_param_id('survey_vote'); |
106 | 105 | $is_answer_exists = db_survey_answer_get($survey_id, $survey_vote_id); |
107 | - if(!empty($is_answer_exists)) { |
|
106 | + if (!empty($is_answer_exists)) { |
|
108 | 107 | $user_name_safe = db_escape($user['username']); |
109 | 108 | db_survey_vote_insert($user, $survey_id, $survey_vote_id, $user_name_safe); |
110 | 109 | } |
@@ -2,31 +2,31 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
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 | |
9 | 9 | // Changing rank for single user |
10 | 10 | $id_user = sys_get_param_id('id_user'); |
11 | -if(isset($_GET['id_rank'])) { |
|
11 | +if (isset($_GET['id_rank'])) { |
|
12 | 12 | $id_rank = sys_get_param_int('id_rank'); |
13 | 13 | } |
14 | -if($id_user && isset($id_rank) && $user_admin) { |
|
14 | +if ($id_user && isset($id_rank) && $user_admin) { |
|
15 | 15 | DBStaticUser::db_user_set_by_id($id_user, "`ally_rank_id` = {$id_rank}"); |
16 | 16 | } |
17 | 17 | |
18 | 18 | $id_kick = sys_get_param_id('kick'); |
19 | 19 | |
20 | -if($id_kick && $user_can_kick) { |
|
20 | +if ($id_kick && $user_can_kick) { |
|
21 | 21 | $u = DBStaticUser::db_user_by_id($id_kick, true); |
22 | - if($u['ally_id'] == $ally['id'] && $u['id'] != $ally['ally_owner']) { |
|
22 | + if ($u['ally_id'] == $ally['id'] && $u['id'] != $ally['ally_owner']) { |
|
23 | 23 | DBStaticUser::db_user_set_by_id($id_kick, '`ally_id`= null, `ally_name` = null, `ally_tag` = null, ally_register_time = 0, ally_rank_id = 0'); |
24 | 24 | db_ally_update_member_decrease($ally); |
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
28 | 28 | $sort2 = sys_get_param_int('sort2'); |
29 | -if($sort2) { |
|
29 | +if ($sort2) { |
|
30 | 30 | $sort2s = "DESC"; |
31 | 31 | $sort2 = 0; |
32 | 32 | } else { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | $sort1 = sys_get_param_int('sort1'); |
38 | -if($sort1 > 5 || $sort1 < 0) { |
|
38 | +if ($sort1 > 5 || $sort1 < 0) { |
|
39 | 39 | $sort1 = 0; |
40 | 40 | } |
41 | 41 | $sort1s = array( |
@@ -49,28 +49,28 @@ discard block |
||
49 | 49 | |
50 | 50 | $template = gettemplate('ali_members', true); |
51 | 51 | |
52 | -$userList = DBStaticUser::db_user_list("`ally_id`= {$user['ally_id']} ORDER BY " . sprintf($sort1s[$sort1], $sort2s), false, |
|
52 | +$userList = DBStaticUser::db_user_list("`ally_id`= {$user['ally_id']} ORDER BY ".sprintf($sort1s[$sort1], $sort2s), false, |
|
53 | 53 | 'id, username, galaxy, system, planet, onlinetime, ally_rank_id, ally_register_time, total_points'); |
54 | 54 | |
55 | 55 | // while ($userRow = db_fetch($userList)) |
56 | -foreach($userList as $userRow) { |
|
56 | +foreach ($userList as $userRow) { |
|
57 | 57 | $i++; |
58 | - if(!isset($ranks[$userRow['ally_rank_id']])) { |
|
58 | + if (!isset($ranks[$userRow['ally_rank_id']])) { |
|
59 | 59 | $userRow['ally_rank_id'] = 0; |
60 | 60 | } |
61 | 61 | |
62 | - if($ally['ally_owner'] == $userRow['id']) { |
|
62 | + if ($ally['ally_owner'] == $userRow['id']) { |
|
63 | 63 | $ally_range = ($ally['ally_owner_range']) ? $ally['ally_owner_range'] : classLocale::$lang['Founder']; |
64 | 64 | } else { |
65 | - if($user_admin) { |
|
66 | - $ally_range = '<select onchange="window.location=\'alliance.php?mode=admin&edit=members&id_user=' . $userRow['id'] . '&id_rank=\' + this.value">'; |
|
65 | + if ($user_admin) { |
|
66 | + $ally_range = '<select onchange="window.location=\'alliance.php?mode=admin&edit=members&id_user='.$userRow['id'].'&id_rank=\' + this.value">'; |
|
67 | 67 | |
68 | - foreach($ranks as $rankID => $rankArray) { |
|
69 | - $ally_range .= '<option value="' . $rankID . '"'; |
|
70 | - if($rankID == $userRow['ally_rank_id']) { |
|
68 | + foreach ($ranks as $rankID => $rankArray) { |
|
69 | + $ally_range .= '<option value="'.$rankID.'"'; |
|
70 | + if ($rankID == $userRow['ally_rank_id']) { |
|
71 | 71 | $ally_range .= " selected"; |
72 | 72 | } |
73 | - $ally_range .= '>' . $rankArray['name']; |
|
73 | + $ally_range .= '>'.$rankArray['name']; |
|
74 | 74 | $ally_range .= '</option>'; |
75 | 75 | } |
76 | 76 | $ally_range .= '</select>'; |
@@ -80,20 +80,20 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | $last_active = time() - $userRow["onlinetime"]; |
83 | - if($user_admin) { |
|
84 | - if($last_active < 60) { |
|
83 | + if ($user_admin) { |
|
84 | + if ($last_active < 60) { |
|
85 | 85 | $tmp = "lime>{$classLocale['On']}"; |
86 | - } elseif($last_active < 60 * 60) { |
|
86 | + } elseif ($last_active < 60 * 60) { |
|
87 | 87 | $last_active = round($last_active / 60); |
88 | 88 | $tmp = "lime>{$last_active} {$classLocale['sys_min_short']}"; |
89 | - } elseif($last_active < 60 * 60 * 24) { |
|
89 | + } elseif ($last_active < 60 * 60 * 24) { |
|
90 | 90 | $last_active = round($last_active / (60 * 60)); |
91 | 91 | $tmp = "green>{$last_active} {$classLocale['sys_hrs_short']}"; |
92 | 92 | } else { |
93 | 93 | $last_active = round($last_active / (60 * 60 * 24)); |
94 | - if($last_active < 7) { |
|
94 | + if ($last_active < 7) { |
|
95 | 95 | $tmp = "yellow"; |
96 | - } elseif($last_active < 30) { |
|
96 | + } elseif ($last_active < 30) { |
|
97 | 97 | $tmp = "orange"; |
98 | 98 | } else { |
99 | 99 | $tmp = "red"; |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | $tmp .= ">{$last_active} {$classLocale['sys_day_short']}"; |
102 | 102 | } |
103 | 103 | } else { |
104 | - if($user_onlinestatus) { |
|
105 | - if($last_active < 60 * 5) { |
|
104 | + if ($user_onlinestatus) { |
|
105 | + if ($last_active < 60 * 5) { |
|
106 | 106 | $tmp = "lime>{$classLocale['On']}"; |
107 | - } elseif($last_active < 60 * 15) { |
|
107 | + } elseif ($last_active < 60 * 15) { |
|
108 | 108 | $tmp = "yellow>{$classLocale['ali_lessThen15min']}"; |
109 | 109 | } else { |
110 | 110 | $tmp = "red>{$classLocale['Off']}"; |
@@ -124,21 +124,21 @@ discard block |
||
124 | 124 | 'SYSTEM' => $userRow['system'], |
125 | 125 | 'PLANET' => $userRow['planet'], |
126 | 126 | 'POINTS' => pretty_number($userRow['total_points']), |
127 | - 'ONLINE' => '<font color=' . $tmp . '</font>', |
|
127 | + 'ONLINE' => '<font color='.$tmp.'</font>', |
|
128 | 128 | 'RANK' => $ally_range, |
129 | 129 | 'REGISTER_TIME' => date(FMT_DATE_TIME, $userRow['ally_register_time']), |
130 | 130 | 'SHOW_KICK' => $user['id'] != $userRow['id'] && $ally['ally_owner'] != $userRow['id'], |
131 | 131 | )); |
132 | 132 | } |
133 | 133 | |
134 | -if($i != $ally['ally_members']) { |
|
134 | +if ($i != $ally['ally_members']) { |
|
135 | 135 | db_ally_update_member_set($i, $ally); |
136 | 136 | } |
137 | 137 | |
138 | 138 | $template->assign_vars(array( |
139 | - 'mode' => $mode . ($edit ? "&edit=" . $edit : ''), |
|
139 | + 'mode' => $mode.($edit ? "&edit=".$edit : ''), |
|
140 | 140 | 'ADMIN_MODE' => $user_can_kick, |
141 | - 'dpath' => SN_ROOT_VIRTUAL . $dpath, |
|
141 | + 'dpath' => SN_ROOT_VIRTUAL.$dpath, |
|
142 | 142 | 'onlineMessage' => $user_admin ? classLocale::$lang['ali_sys_lastActive'] : classLocale::$lang['Online'], |
143 | 143 | 'memberCount' => count($userList), |
144 | 144 | 'memberslist' => $page_list, |
@@ -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,21 +11,21 @@ discard block |
||
11 | 11 | $ally_name_raw = sys_get_param_str_unsafe('name'); |
12 | 12 | $ally_name = db_escape($ally_name_raw); |
13 | 13 | |
14 | -if($ally_tag) { |
|
15 | - if(!$ally_name_raw || !$ally_tag_raw) { |
|
14 | +if ($ally_tag) { |
|
15 | + if (!$ally_name_raw || !$ally_tag_raw) { |
|
16 | 16 | message(classLocale::$lang['have_not_name'], classLocale::$lang['make_alliance']); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $query = 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_raw ? $ally_tag_raw : $ally_name_raw, classLocale::$lang['always_exist']), classLocale::$lang['make_alliance']); |
22 | 22 | } |
23 | 23 | |
24 | 24 | db_ally_insert($ally_name, $ally_tag, $user); |
25 | 25 | $ally_id = 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 | - $ally_user = classSupernova::db_ins_record(LOC_USER, "`username` = '[{$ally_tag}]', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_id}"); |
|
28 | + $ally_user = classSupernova::db_ins_record(LOC_USER, "`username` = '[{$ally_tag}]', `register_time` = ".SN_TIME_NOW.", `user_as_ally` = {$ally_id}"); |
|
29 | 29 | // $ally_user_id = db_insert_id(); |
30 | 30 | $ally_user_id = is_array($ally_user) ? $ally_user['id'] : 'NULL'; |
31 | 31 | db_ally_update_ally_user($ally_user_id, $ally_id); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
4 | 4 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
@@ -10,16 +10,16 @@ discard block |
||
10 | 10 | |
11 | 11 | $d = sys_get_param_id('d'); |
12 | 12 | |
13 | -if($d) { |
|
13 | +if ($d) { |
|
14 | 14 | db_ally_request_deny($d); |
15 | 15 | } |
16 | 16 | |
17 | 17 | $id_user = sys_get_param_id('id_user'); |
18 | 18 | |
19 | -if($id_user) { |
|
19 | +if ($id_user) { |
|
20 | 20 | $ally_name_safe = db_escape($ally['ally_name']); |
21 | 21 | $ally_tag_safe = db_escape($ally['ally_tag']); |
22 | - DBStaticUser::db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = " . SN_TIME_NOW . ", `ally_rank_id` = 0"); |
|
22 | + DBStaticUser::db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = ".SN_TIME_NOW.", `ally_rank_id` = 0"); |
|
23 | 23 | db_ally_update_member_increase($ally); |
24 | 24 | db_ally_request_delete_by_user_id($id_user); |
25 | 25 | } |
@@ -542,7 +542,8 @@ discard block |
||
542 | 542 | $location_info = &static::$location_info[$location_type]; |
543 | 543 | $id_field = $location_info[P_ID]; |
544 | 544 | $table_name = $location_info[P_TABLE_NAME]; |
545 | - if ($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
545 | + if ($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) { |
|
546 | + // TODO Как-то вернуть может быть LIMIT 1 ? |
|
546 | 547 | { |
547 | 548 | if (static::$db->db_affected_rows()) { |
548 | 549 | // Обновляем данные только если ряд был затронут |
@@ -550,6 +551,7 @@ discard block |
||
550 | 551 | |
551 | 552 | // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее |
552 | 553 | static::$data[$location_type][$record_id] = null; |
554 | + } |
|
553 | 555 | // Вытаскиваем обновленную запись |
554 | 556 | static::db_get_record_by_id($location_type, $record_id); |
555 | 557 | static::cache_clear($location_type, false); // Мягкий сброс - только $queries |
@@ -589,9 +591,11 @@ discard block |
||
589 | 591 | $set = trim($set); |
590 | 592 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
591 | 593 | if ($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
592 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
594 | + if (static::$db->db_affected_rows()) { |
|
595 | + // Обновляем данные только если ряд был затронут |
|
593 | 596 | { |
594 | 597 | $record_id = db_insert_id(); |
598 | + } |
|
595 | 599 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
596 | 600 | $result = static::db_get_record_by_id($location_type, $record_id); |
597 | 601 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * <p>null - транзакция НЕ должна быть запущена</p> |
324 | 324 | * <p>true - транзакция должна быть запущена - для совместимости с $for_update</p> |
325 | 325 | * <p>false - всё равно - для совместимости с $for_update</p> |
326 | - * @return bool Текущий статус транзакции |
|
326 | + * @return null|boolean Текущий статус транзакции |
|
327 | 327 | */ |
328 | 328 | public static function db_transaction_check($status = null) { |
329 | 329 | $error_msg = false; |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | /** |
400 | 400 | * Блокирует указанные таблицу/список таблиц |
401 | 401 | * |
402 | - * @param string|array $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов |
|
402 | + * @param string $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов |
|
403 | 403 | * <p>string - название таблицы для блокировки</p> |
404 | 404 | * <p>array - массив, где ключ - имя таблицы, а значение - условия блокировки элементов</p> |
405 | 405 | */ |
@@ -574,6 +574,9 @@ discard block |
||
574 | 574 | return $result; |
575 | 575 | } |
576 | 576 | |
577 | + /** |
|
578 | + * @param integer $location_type |
|
579 | + */ |
|
577 | 580 | public static function db_ins_field_set($location_type, $field_set, $serialize = false) { |
578 | 581 | // TODO multiinsert |
579 | 582 | !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set, $serialize) : false; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | if (!empty($error_msg)) { |
230 | 230 | // TODO - Убрать позже |
231 | - print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>'); |
|
231 | + print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>'); |
|
232 | 232 | $backtrace = debug_backtrace(); |
233 | 233 | array_shift($backtrace); |
234 | 234 | pdump($backtrace); |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | public static function db_transaction_start($level = '') { |
242 | 242 | static::db_transaction_check(null); |
243 | 243 | |
244 | - $level ? doquery('SET TRANSACTION ISOLATION LEVEL ' . $level) : false; |
|
244 | + $level ? doquery('SET TRANSACTION ISOLATION LEVEL '.$level) : false; |
|
245 | 245 | |
246 | 246 | static::$transaction_id++; |
247 | 247 | doquery('START TRANSACTION'); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | public static function db_lock_tables($tables) { |
306 | 306 | $tables = is_array($tables) ? $tables : array($tables => ''); |
307 | 307 | foreach ($tables as $table_name => $condition) { |
308 | - self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
308 | + self::$db->doquery("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | $query = static::db_query( |
366 | 366 | "SELECT |
367 | 367 | distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
368 | - FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
369 | - ($filter ? ' WHERE ' . $filter : '') . |
|
368 | + FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
369 | + ($filter ? ' WHERE '.$filter : ''). |
|
370 | 370 | ($fetch ? ' LIMIT 1' : ''), false, true); |
371 | 371 | |
372 | 372 | while ($row = db_fetch($query)) { |
@@ -379,13 +379,13 @@ discard block |
||
379 | 379 | if ($indexes_str = implode(',', $parent_id_list)) { |
380 | 380 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
381 | 381 | static::db_get_record_list($owner_location_type, |
382 | - $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
382 | + $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
387 | 387 | $query = static::db_query( |
388 | - "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
388 | + "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
389 | 389 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
390 | 390 | ); |
391 | 391 | while ($row = db_fetch($query)) { |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $condition = trim($condition); |
457 | 457 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
458 | 458 | |
459 | - if ($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
459 | + if ($result = static::db_query("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) { |
|
460 | 460 | |
461 | 461 | if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
462 | 462 | // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет |
615 | 615 | |
616 | 616 | $user = static::db_query( |
617 | - "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'" |
|
617 | + "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'" |
|
618 | 618 | , true); |
619 | 619 | SnCache::cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы |
620 | 620 | } |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | } |
672 | 672 | |
673 | 673 | if (SnCache::isUnitLocatorNotSet($location_type, $location_id)) { |
674 | - $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()); |
|
674 | + $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()); |
|
675 | 675 | if (!empty($got_data) && is_array($got_data)) { |
676 | 676 | foreach ($got_data as $unit_id => $unit_data) { |
677 | 677 | SnCache::setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data); |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | if ($que_type == QUE_RESEARCH || $planet_id === null) { |
731 | 731 | $query[] = "`que_planet_id` IS NULL"; |
732 | 732 | } elseif ($planet_id) { |
733 | - $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
733 | + $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")"; |
|
734 | 734 | } |
735 | 735 | if ($que_type) { |
736 | 736 | $query[] = "`que_type` = {$que_type}"; |
@@ -844,13 +844,13 @@ discard block |
||
844 | 844 | $condition = "`{$field_name}` = "; |
845 | 845 | $value = ''; |
846 | 846 | if ($field_data['delta']) { |
847 | - $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
|
847 | + $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta']; |
|
848 | 848 | } elseif ($field_data['set']) { |
849 | 849 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
850 | 850 | } |
851 | 851 | |
852 | 852 | if ($value) { |
853 | - $fields[] = $condition . $value; |
|
853 | + $fields[] = $condition.$value; |
|
854 | 854 | } |
855 | 855 | } |
856 | 856 | $conditions[P_FIELDS_STR] = implode(',', $fields); |
@@ -864,9 +864,7 @@ discard block |
||
864 | 864 | // Простое условие - $field_id = $field_value |
865 | 865 | if (is_string($field_id)) { |
866 | 866 | $field_value = |
867 | - $field_value === null ? 'NULL' : |
|
868 | - (is_string($field_value) ? "'" . db_escape($field_value) . "'" : |
|
869 | - (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
867 | + $field_value === null ? 'NULL' : (is_string($field_value) ? "'".db_escape($field_value)."'" : (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
870 | 868 | $the_conditions[] = "`{$field_id}` = {$field_value}"; |
871 | 869 | } else { |
872 | 870 | die('Неподдерживаемый тип условия'); |
@@ -893,7 +891,7 @@ discard block |
||
893 | 891 | die('Неподдерживаемая операция в classSupernova::db_changeset_condition_compile'); |
894 | 892 | } |
895 | 893 | |
896 | - $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR] . ' ' . $conditions[P_FIELDS_STR] . (' WHERE ' . $conditions[P_WHERE_STR]); |
|
894 | + $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR].' '.$conditions[P_FIELDS_STR].(' WHERE '.$conditions[P_WHERE_STR]); |
|
897 | 895 | } |
898 | 896 | |
899 | 897 | public static function db_changeset_apply($db_changeset, $flush_delayed = false) { |
@@ -981,7 +979,7 @@ discard block |
||
981 | 979 | ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false; |
982 | 980 | if (@get_magic_quotes_gpc()) { |
983 | 981 | $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); |
984 | - array_walk_recursive($gpcr, function (&$value, $key) { |
|
982 | + array_walk_recursive($gpcr, function(&$value, $key) { |
|
985 | 983 | $value = stripslashes($value); |
986 | 984 | }); |
987 | 985 | } |
@@ -998,39 +996,39 @@ discard block |
||
998 | 996 | 'buddyClass' => 'Buddy\BuddyModel', |
999 | 997 | )); |
1000 | 998 | |
1001 | - $container->db = function ($c) {}; |
|
999 | + $container->db = function($c) {}; |
|
1002 | 1000 | |
1003 | - $container->db = function ($c) { |
|
1001 | + $container->db = function($c) { |
|
1004 | 1002 | $db = new db_mysql(); |
1005 | 1003 | $db->sn_db_connect(); |
1006 | 1004 | |
1007 | 1005 | return $db; |
1008 | 1006 | }; |
1009 | 1007 | |
1010 | - $container->debug = function ($c) { |
|
1008 | + $container->debug = function($c) { |
|
1011 | 1009 | return new debug(); |
1012 | 1010 | }; |
1013 | 1011 | |
1014 | - $container->cache = function ($c) { |
|
1012 | + $container->cache = function($c) { |
|
1015 | 1013 | return new classCache(classSupernova::$cache_prefix); |
1016 | 1014 | }; |
1017 | 1015 | |
1018 | - $container->config = function ($c) { |
|
1016 | + $container->config = function($c) { |
|
1019 | 1017 | return new classConfig(classSupernova::$cache_prefix); |
1020 | 1018 | }; |
1021 | 1019 | |
1022 | - $container->dbRowOperator = function ($c) { |
|
1020 | + $container->dbRowOperator = function($c) { |
|
1023 | 1021 | return new DbRowSimple($c); |
1024 | 1022 | }; |
1025 | 1023 | |
1026 | - $container->buddy = $container->factory(function ($c) { |
|
1024 | + $container->buddy = $container->factory(function($c) { |
|
1027 | 1025 | return new $c->buddyClass($c); |
1028 | 1026 | }); |
1029 | 1027 | // $container->buddy = $container->factory(function ($c) { |
1030 | 1028 | // return new Buddy\Buddy($c); |
1031 | 1029 | // }); |
1032 | 1030 | |
1033 | - $container->query = $container->factory(function (Pimple\GlobalContainer $c) { |
|
1031 | + $container->query = $container->factory(function(Pimple\GlobalContainer $c) { |
|
1034 | 1032 | return new DbQueryConstructor($c->db); |
1035 | 1033 | }); |
1036 | 1034 | |
@@ -1045,7 +1043,7 @@ discard block |
||
1045 | 1043 | public static function init_3_load_config_file() { |
1046 | 1044 | $dbsettings = array(); |
1047 | 1045 | |
1048 | - require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
1046 | + require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
1049 | 1047 | self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix']; |
1050 | 1048 | self::$db_name = $dbsettings['name']; |
1051 | 1049 | self::$sn_secret_word = $dbsettings['secretword']; |