@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | define('INSTALL', false); |
13 | 13 | define('IN_ADMIN', true); |
14 | 14 | |
15 | -require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
15 | +require('../common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
16 | 16 | |
17 | 17 | if ($user['authlevel'] < 3) { |
18 | 18 | AdminMessage(classLocale::$lang['adm_err_denied']); |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | print("<td>Last online</td>"); |
102 | 102 | print("</tr>"); |
103 | 103 | foreach ($session_list as $user_id => $value) { |
104 | - $user_record = classSupernova::$db->doSelect("SELECT * FROM `{{users}}` WHERE `id` = " . idval($user_id)); |
|
104 | + $user_record = classSupernova::$db->doSelect("SELECT * FROM `{{users}}` WHERE `id` = ".idval($user_id)); |
|
105 | 105 | foreach ($value as $interval_data) { |
106 | 106 | print("<tr>"); |
107 | 107 | 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>"); |
108 | - print("<td>" . date(FMT_DATE_TIME_SQL, $user_record['onlinetime']) . "</td>"); |
|
108 | + print("<td>".date(FMT_DATE_TIME_SQL, $user_record['onlinetime'])."</td>"); |
|
109 | 109 | print("</tr>"); |
110 | 110 | } |
111 | 111 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | // classSupernova::$db->sn_db_connect(); |
16 | 16 | if (!(strpos($query, '{{') === false)) { |
17 | 17 | foreach ($update_tables as $tableName => $cork) { |
18 | - $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); |
|
18 | + $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix.$tableName, $query); |
|
19 | 19 | } |
20 | 20 | } |
21 | - !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for ' . $query . ': ' . classSupernova::$db->db_error()) : false; |
|
21 | + !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for '.$query.': '.classSupernova::$db->db_error()) : false; |
|
22 | 22 | |
23 | 23 | return $result; |
24 | 24 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | global $update_tables, $update_indexes, $update_indexes_full, $update_foreigns; |
86 | 86 | |
87 | 87 | $tableName = $prefixed ? str_replace(classSupernova::$config->db_prefix, '', $prefix_table_name) : $prefix_table_name; |
88 | - $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix . $prefix_table_name; |
|
88 | + $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix.$prefix_table_name; |
|
89 | 89 | |
90 | 90 | upd_unset_table_info($tableName); |
91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1; |
101 | 101 | } |
102 | 102 | |
103 | - $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
103 | + $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '".db_escape(classSupernova::$db_name)."' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
104 | 104 | while ($r1 = db_fetch($q1)) { |
105 | 105 | $table_referenced = str_replace(classSupernova::$config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); |
106 | 106 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}{$table_name}` {$declaration}"); |
161 | 161 | $error = classSupernova::$db->db_error(); |
162 | 162 | if ($error) { |
163 | - die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); |
|
163 | + die("Creating error for table `{$table_name}`: {$error}<br />".dump($declaration)); |
|
164 | 164 | } |
165 | 165 | upd_do_query('set foreign_key_checks = 1;', true); |
166 | 166 | upd_load_table_info($table_name, false); |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | |
8 | 8 | function que_get_unit_que($unit_id) { |
9 | 9 | $que_type = false; |
10 | - foreach(sn_get_groups('ques') as $que_id => $que_data) { |
|
11 | - if(in_array($unit_id, $que_data['unit_list'])) { |
|
10 | + foreach (sn_get_groups('ques') as $que_id => $que_data) { |
|
11 | + if (in_array($unit_id, $que_data['unit_list'])) { |
|
12 | 12 | $que_type = $que_id; |
13 | 13 | break; |
14 | 14 | } |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | |
20 | 20 | |
21 | 21 | function que_get_max_que_length($user, $planet, $que_id, $que_data = null) { |
22 | - if(empty($que_data)) { |
|
22 | + if (empty($que_data)) { |
|
23 | 23 | $que_data = sn_get_groups('ques'); |
24 | 24 | $que_data = $que_data[$que_id]; |
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | 28 | $que_length = 1; |
29 | - switch($que_id) { |
|
29 | + switch ($que_id) { |
|
30 | 30 | case QUE_RESEARCH: |
31 | 31 | $que_length = classSupernova::$config->server_que_length_research + mrc_get_level($user, null, UNIT_PREMIUM); // TODO - вынести в модуль |
32 | 32 | break; |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | function eco_que_str2arr($que_str) { |
42 | 42 | $que_arr = explode(';', $que_str); |
43 | - foreach($que_arr as $que_index => &$que_item) { |
|
44 | - if($que_item) { |
|
43 | + foreach ($que_arr as $que_index => &$que_item) { |
|
44 | + if ($que_item) { |
|
45 | 45 | $que_item = explode(',', $que_item); |
46 | 46 | } else { |
47 | 47 | unset($que_arr[$que_index]); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | function eco_que_arr2str($que_arr) { |
55 | - foreach($que_arr as &$que_item) { |
|
55 | + foreach ($que_arr as &$que_item) { |
|
56 | 56 | $que_item = implode(',', $que_item); |
57 | 57 | } |
58 | 58 | |
@@ -64,28 +64,28 @@ discard block |
||
64 | 64 | $classLocale = classLocale::$lang; |
65 | 65 | |
66 | 66 | $is_autoconvert = false; |
67 | - if($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
67 | + if ($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
68 | 68 | $build_mode = BUILD_CREATE; |
69 | 69 | $is_autoconvert = true; |
70 | 70 | } |
71 | 71 | |
72 | 72 | $unit_amount_qued = 0; |
73 | 73 | try { |
74 | - if(!$user['id']) { |
|
74 | + if (!$user['id']) { |
|
75 | 75 | throw new exception('{Нет идентификатора пользователя - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
76 | 76 | } |
77 | 77 | |
78 | 78 | $unit_id = sys_get_param_int('unit_id'); |
79 | - if(!$unit_id) { |
|
79 | + if (!$unit_id) { |
|
80 | 80 | throw new exception('{Нет идентификатора юнита - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
81 | 81 | } |
82 | 82 | |
83 | 83 | $que_id = que_get_unit_que($unit_id); |
84 | - if(!$que_id) { |
|
84 | + if (!$que_id) { |
|
85 | 85 | throw new exception('{Неправильный тип очереди - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
86 | 86 | } |
87 | 87 | |
88 | - if($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
88 | + if ($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
89 | 89 | throw new exception('{Уничтожать можно только здания на планете}', ERR_ERROR); // TODO EXCEPTION |
90 | 90 | } |
91 | 91 | |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | $que_data = $que_data[$que_id]; |
94 | 94 | |
95 | 95 | // TODO Переделать под подочереди |
96 | - if($que_id == QUE_STRUCTURES) { |
|
96 | + if ($que_id == QUE_STRUCTURES) { |
|
97 | 97 | $sn_groups_build_allow = sn_get_groups('build_allow'); |
98 | 98 | $que_data['unit_list'] = $sn_groups_build_allow[$planet['planet_type']]; |
99 | 99 | |
100 | - if(!isset($que_data['unit_list'][$unit_id])) { |
|
101 | - throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION |
|
100 | + if (!isset($que_data['unit_list'][$unit_id])) { |
|
101 | + throw new exception('{Это здание нельзя строить на '.($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | // TODO Разделить очереди для Верфи и Обороны |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | // Это нужно, что бы заблокировать пользователя и работу с очередями |
109 | 109 | $user = DBStaticUser::db_user_by_id($user['id']); |
110 | 110 | // Это нужно, что бы заблокировать планету от списания ресурсов |
111 | - if(isset($planet['id']) && $planet['id']) { |
|
111 | + if (isset($planet['id']) && $planet['id']) { |
|
112 | 112 | $planet = DBStaticPlanet::db_planet_by_id($planet['id'], true); |
113 | 113 | } else { |
114 | 114 | $planet['id'] = 0; |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | $in_que = &$que['in_que'][$que_id][$user['id']][$planet_id]; |
121 | 121 | $que_max_length = que_get_max_que_length($user, $planet, $que_id, $que_data); |
122 | 122 | // TODO Добавить вызовы функций проверок текущей и максимальной длин очередей |
123 | - if(count($in_que) >= $que_max_length) { |
|
123 | + if (count($in_que) >= $que_max_length) { |
|
124 | 124 | throw new exception('{Все слоты очереди заняты}', ERR_ERROR); // TODO EXCEPTION |
125 | 125 | } |
126 | 126 | |
127 | 127 | // TODO Отдельно посмотреть на уничтожение зданий - что бы можно было уничтожать их без планов |
128 | - switch(eco_can_build_unit($user, $planet, $unit_id)) { |
|
128 | + switch (eco_can_build_unit($user, $planet, $unit_id)) { |
|
129 | 129 | case BUILD_ALLOWED: |
130 | 130 | break; |
131 | 131 | case BUILD_UNIT_BUSY: |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading |
134 | 134 | // case BUILD_REQUIRE_NOT_MEET: |
135 | 135 | default: |
136 | - if($build_mode == BUILD_CREATE) { |
|
136 | + if ($build_mode == BUILD_CREATE) { |
|
137 | 137 | throw new exception('{Требования не удовлетворены}', ERR_ERROR); |
138 | 138 | } |
139 | 139 | break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet |
@@ -143,33 +143,33 @@ discard block |
||
143 | 143 | $unit_amount_qued = $unit_amount; |
144 | 144 | $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0; |
145 | 145 | $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued; |
146 | - if($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
147 | - if($unit_level >= $unit_max) { |
|
146 | + if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
147 | + if ($unit_level >= $unit_max) { |
|
148 | 148 | throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
149 | 149 | } |
150 | 150 | $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level)); |
151 | 151 | } |
152 | 152 | |
153 | - if($unit_amount < 1) { |
|
153 | + if ($unit_amount < 1) { |
|
154 | 154 | throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
155 | 155 | } |
156 | 156 | |
157 | 157 | // TODO Переделать eco_unit_busy для всех типов зданий |
158 | - if(get_unit_param($unit_id, P_STACKABLE)) { |
|
158 | + if (get_unit_param($unit_id, P_STACKABLE)) { |
|
159 | 159 | // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь |
160 | - if(in_array($unit_id, $group_missile = sn_get_groups(GROUP_STR_MISSILES))) { |
|
160 | + if (in_array($unit_id, $group_missile = sn_get_groups(GROUP_STR_MISSILES))) { |
|
161 | 161 | // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита |
162 | 162 | $used_silo = 0; |
163 | - foreach($group_missile as $missile_id) { |
|
163 | + foreach ($group_missile as $missile_id) { |
|
164 | 164 | $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0; |
165 | 165 | $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE); |
166 | 166 | } |
167 | 167 | $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo; |
168 | - if($free_silo <= 0) { |
|
168 | + if ($free_silo <= 0) { |
|
169 | 169 | throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
170 | 170 | } |
171 | 171 | $unit_size = get_unit_param($unit_id, P_UNIT_SIZE); |
172 | - if($free_silo < $unit_size) { |
|
172 | + if ($free_silo < $unit_size) { |
|
173 | 173 | throw new exception("{В ракетной шахте нет места для {$classLocale['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION |
174 | 174 | } |
175 | 175 | $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size))); |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | $unit_level = $new_unit_level = 0; |
178 | 178 | } else { |
179 | 179 | $unit_amount = 1; |
180 | - if($que_id == QUE_STRUCTURES) { |
|
180 | + if ($que_id == QUE_STRUCTURES) { |
|
181 | 181 | $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0; |
182 | - if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) { |
|
182 | + if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) { |
|
183 | 183 | throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION |
184 | 184 | } |
185 | 185 | } |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | |
192 | 192 | $exchange = array(); |
193 | 193 | $market_get_autoconvert_cost = market_get_autoconvert_cost(); |
194 | - if($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
194 | + if ($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
195 | 195 | $dark_matter = mrc_get_level($user, null, RES_DARK_MATTER); |
196 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
197 | - throw new exception("{Нет хватает " . ($market_get_autoconvert_cost - $dark_matter) . "ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION |
|
196 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
197 | + throw new exception("{Нет хватает ".($market_get_autoconvert_cost - $dark_matter)."ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | !get_unit_param($unit_id, P_STACKABLE) ? $unit_amount = 1 : false; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $resource_exchange_rates = array(); |
204 | 204 | $resource_diff = array(); |
205 | 205 | $all_positive = true; |
206 | - foreach($resources_loot as $resource_id) { |
|
206 | + foreach ($resources_loot as $resource_id) { |
|
207 | 207 | $resource_db_name = pname_resource_name($resource_id); |
208 | 208 | $resource_got[$resource_id] = floor(mrc_get_level($user, $planet, $resource_id)); |
209 | 209 | $resource_exchange_rates[$resource_id] = classSupernova::$config->__get("rpg_exchange_{$resource_db_name}"); |
@@ -211,15 +211,15 @@ discard block |
||
211 | 211 | $all_positive = $all_positive && ($resource_diff[$resource_id] > 0); |
212 | 212 | } |
213 | 213 | // Нужна автоконвертация |
214 | - if($all_positive) { |
|
214 | + if ($all_positive) { |
|
215 | 215 | $is_autoconvert = false; |
216 | 216 | } else { |
217 | - foreach($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
218 | - if($resource_diff_amount >= 0) { |
|
217 | + foreach ($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
218 | + if ($resource_diff_amount >= 0) { |
|
219 | 219 | continue; |
220 | 220 | } |
221 | - foreach($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
222 | - if($resource_got_amount <= 0) { |
|
221 | + foreach ($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
222 | + if ($resource_got_amount <= 0) { |
|
223 | 223 | continue; |
224 | 224 | } |
225 | 225 | $current_exchange = $resource_exchange_rates[$resource_got_id] / $resource_exchange_rates[$resource_diff_id]; |
@@ -235,14 +235,14 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | $is_autoconvert_ok = true; |
238 | - foreach($resource_diff as $resource_diff_amount2) { |
|
239 | - if($resource_diff_amount2 < 0) { |
|
238 | + foreach ($resource_diff as $resource_diff_amount2) { |
|
239 | + if ($resource_diff_amount2 < 0) { |
|
240 | 240 | $is_autoconvert_ok = false; |
241 | 241 | break; |
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
245 | - if($is_autoconvert_ok) { |
|
245 | + if ($is_autoconvert_ok) { |
|
246 | 246 | $build_data['RESULT'][$build_mode] = BUILD_ALLOWED; |
247 | 247 | $build_data['CAN'][$build_mode] = $unit_amount; |
248 | 248 | } else { |
@@ -251,19 +251,19 @@ discard block |
||
251 | 251 | } |
252 | 252 | } |
253 | 253 | $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount); |
254 | - if($unit_amount <= 0) { |
|
254 | + if ($unit_amount <= 0) { |
|
255 | 255 | throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION |
256 | 256 | } |
257 | 257 | |
258 | - if($new_unit_level < 0) { |
|
258 | + if ($new_unit_level < 0) { |
|
259 | 259 | throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION |
260 | 260 | } |
261 | 261 | |
262 | - if($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
262 | + if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
263 | 263 | throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION |
264 | 264 | } |
265 | 265 | |
266 | - if($is_autoconvert) { |
|
266 | + if ($is_autoconvert) { |
|
267 | 267 | ksort($exchange); |
268 | 268 | ksort($resource_got); |
269 | 269 | db_change_resources( |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | $unit_amount_qued = 0; |
285 | - while($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
285 | + while ($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
286 | 286 | $place = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW); |
287 | 287 | que_add_unit($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode); |
288 | 288 | $unit_amount -= $place; |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | |
293 | 293 | sn_db_transaction_commit(); |
294 | 294 | |
295 | - if($redirect) { |
|
296 | - sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id')); |
|
295 | + if ($redirect) { |
|
296 | + sys_redirect("{$_SERVER['PHP_SELF']}?mode=".sys_get_param_str('mode')."&ally_id=".sys_get_param_id('ally_id')); |
|
297 | 297 | die(); |
298 | 298 | } |
299 | 299 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | 'STATUS' => ERR_NONE, |
302 | 302 | 'MESSAGE' => '{Строительство начато}', |
303 | 303 | ); |
304 | - } catch(Exception $e) { |
|
304 | + } catch (Exception $e) { |
|
305 | 305 | sn_db_transaction_rollback(); |
306 | 306 | $operation_result = array( |
307 | 307 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -309,8 +309,8 @@ discard block |
||
309 | 309 | ); |
310 | 310 | } |
311 | 311 | |
312 | - if(!empty($operation_result['MESSAGE'])) { |
|
313 | - $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . classLocale::$lang['tech'][$unit_id] . ']'; |
|
312 | + if (!empty($operation_result['MESSAGE'])) { |
|
313 | + $operation_result['MESSAGE'] .= ' '.($unit_amount_qued ? $unit_amount_qued : $unit_amount).'x['.classLocale::$lang['tech'][$unit_id].']'; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | return $operation_result; |
@@ -320,11 +320,11 @@ discard block |
||
320 | 320 | function que_recalculate($old_que) { |
321 | 321 | $new_que = array(); |
322 | 322 | |
323 | - if(!is_array($old_que['items'])) { |
|
323 | + if (!is_array($old_que['items'])) { |
|
324 | 324 | return $new_que; |
325 | 325 | } |
326 | - foreach($old_que['items'] as $row) { |
|
327 | - if(!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
326 | + foreach ($old_que['items'] as $row) { |
|
327 | + if (!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
328 | 328 | continue; |
329 | 329 | } |
330 | 330 | |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | |
336 | 336 | $last_id = count($new_que['items']) - 1; |
337 | 337 | |
338 | - if($row['que_planet_id']) { |
|
338 | + if ($row['que_planet_id']) { |
|
339 | 339 | $new_que['planets'][$row['que_planet_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
340 | - } elseif($row['que_type'] == QUE_RESEARCH) { |
|
340 | + } elseif ($row['que_type'] == QUE_RESEARCH) { |
|
341 | 341 | $new_que['players'][$row['que_player_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
342 | 342 | } |
343 | 343 | $new_que['ques'][$row['que_type']][$row['que_player_id']][intval($row['que_planet_id'])][] = &$new_que['items'][$last_id]; |
@@ -375,14 +375,14 @@ discard block |
||
375 | 375 | $que_type = que_get_unit_que($unit_id); |
376 | 376 | $planet_id_origin = $planet['id'] ? $planet['id'] : 'NULL'; |
377 | 377 | $planet_id = $que_type == QUE_RESEARCH ? 'NULL' : $planet_id_origin; |
378 | - if(is_numeric($planet_id)) { |
|
378 | + if (is_numeric($planet_id)) { |
|
379 | 379 | DBStaticPlanet::db_planet_update_set_by_id( |
380 | 380 | $planet_id, |
381 | 381 | array( |
382 | 382 | 'que_processed' => SN_TIME_NOW, |
383 | 383 | ) |
384 | 384 | ); |
385 | - } elseif(is_numeric($user['id'])) { |
|
385 | + } elseif (is_numeric($user['id'])) { |
|
386 | 386 | DBStaticUser::db_user_set_by_id( |
387 | 387 | $user['id'], |
388 | 388 | array( |
@@ -417,17 +417,17 @@ discard block |
||
417 | 417 | $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0; |
418 | 418 | $global_que = que_get($user['id'], $planet['id'], $que_type, true); |
419 | 419 | |
420 | - if(!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
420 | + if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
421 | 421 | $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]); |
422 | 422 | |
423 | - foreach($que as $que_item) { |
|
423 | + foreach ($que as $que_item) { |
|
424 | 424 | DBStaticQue::db_que_delete_by_id($que_item['que_id']); |
425 | 425 | |
426 | - if($que_item['que_planet_id_origin']) { |
|
426 | + if ($que_item['que_planet_id_origin']) { |
|
427 | 427 | $planet['id'] = $que_item['que_planet_id_origin']; |
428 | 428 | } |
429 | 429 | |
430 | - if(!isset($planets_locked[$planet['id']])) { |
|
430 | + if (!isset($planets_locked[$planet['id']])) { |
|
431 | 431 | $planets_locked[$planet['id']] = $planet['id'] ? DBStaticPlanet::db_planet_by_id($planet['id'], true) : $planet; |
432 | 432 | } |
433 | 433 | |
@@ -443,19 +443,19 @@ discard block |
||
443 | 443 | ) |
444 | 444 | ); |
445 | 445 | |
446 | - if(!$clear) { |
|
446 | + if (!$clear) { |
|
447 | 447 | break; |
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | - if(is_numeric($planet['id'])) { |
|
451 | + if (is_numeric($planet['id'])) { |
|
452 | 452 | DBStaticPlanet::db_planet_update_set_by_id( |
453 | 453 | $planet['id'], |
454 | 454 | array( |
455 | 455 | 'que_processed' => SN_TIME_SQL, |
456 | 456 | ) |
457 | 457 | ); |
458 | - } elseif(is_numeric($user['id'])) { |
|
458 | + } elseif (is_numeric($user['id'])) { |
|
459 | 459 | DBStaticUser::db_user_set_by_id( |
460 | 460 | $user['id'], |
461 | 461 | array( |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | } else { |
469 | 469 | sn_db_transaction_rollback(); |
470 | 470 | } |
471 | - header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}" . "&ally_id=" . sys_get_param_id('ally_id')); |
|
471 | + header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}"."&ally_id=".sys_get_param_id('ally_id')); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | |
@@ -507,21 +507,21 @@ discard block |
||
507 | 507 | // TODO: Переделать для $que_type === false |
508 | 508 | $planet['id'] = $planet['id'] ? $planet['id'] : 0; |
509 | 509 | |
510 | - if(!is_array($que)) { |
|
510 | + if (!is_array($que)) { |
|
511 | 511 | $que = que_get($user['id'], $planet['id'], $que_type); |
512 | 512 | } |
513 | 513 | |
514 | - if(is_array($que) && isset($que['items'])) { |
|
514 | + if (is_array($que) && isset($que['items'])) { |
|
515 | 515 | $que = $que['ques'][$que_type][$user['id']][$planet['id']]; |
516 | 516 | } |
517 | 517 | |
518 | - if($que) { |
|
519 | - foreach($que as $que_element) { |
|
518 | + if ($que) { |
|
519 | + foreach ($que as $que_element) { |
|
520 | 520 | $template->assign_block_vars('que', que_tpl_parse_element($que_element, $short_names)); |
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
524 | - if($que_type == QUE_RESEARCH) { |
|
524 | + if ($que_type == QUE_RESEARCH) { |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | $user = DBStaticUser::db_user_by_id($user['id'], true); |
546 | 546 | |
547 | 547 | $time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']); |
548 | - if($planet === null && !$time_left[$user['id']][0]) { |
|
548 | + if ($planet === null && !$time_left[$user['id']][0]) { |
|
549 | 549 | return $que; |
550 | 550 | } |
551 | 551 | |
@@ -553,12 +553,12 @@ discard block |
||
553 | 553 | $que_type_id = $planet === null ? QUE_RESEARCH : false; |
554 | 554 | $planet = intval(is_array($planet) ? $planet['id'] : $planet); // В $planet у нас теперь только её ID или шаблон null/0/false |
555 | 555 | $que = que_get($user['id'], $planet, $que_type_id, true); |
556 | - if(empty($que['items'])) { |
|
556 | + if (empty($que['items'])) { |
|
557 | 557 | return $que; |
558 | 558 | } |
559 | 559 | |
560 | 560 | $planet_list = array(); |
561 | - if($planet !== null) { |
|
561 | + if ($planet !== null) { |
|
562 | 562 | // Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них |
563 | 563 | // TODO - от них не надо ничего, кроме ID и que_processed |
564 | 564 | $planet_row = DBStaticPlanet::db_planet_list_by_user_or_planet($user['id'], $planet); |
@@ -567,20 +567,20 @@ discard block |
||
567 | 567 | } |
568 | 568 | |
569 | 569 | // Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты |
570 | - if(array_sum($time_left[$user['id']]) == 0) { |
|
570 | + if (array_sum($time_left[$user['id']]) == 0) { |
|
571 | 571 | return $que; |
572 | 572 | } |
573 | 573 | |
574 | 574 | $unit_changes = array(); |
575 | - foreach($que['items'] as &$que_item) { |
|
575 | + foreach ($que['items'] as &$que_item) { |
|
576 | 576 | $que_player_id = &$que_item['que_player_id']; |
577 | 577 | $que_planet_id = intval($que_item['que_planet_id']); |
578 | 578 | |
579 | 579 | $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']]; |
580 | - if(!isset($que_time_left)) { |
|
580 | + if (!isset($que_time_left)) { |
|
581 | 581 | $que_time_left = $time_left[$que_player_id][$que_planet_id]; |
582 | 582 | } |
583 | - if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
583 | + if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
584 | 584 | continue; |
585 | 585 | } |
586 | 586 | // Дальше мы идем, если только осталось время в очереди И юниты к постройке |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля |
594 | 594 | |
595 | 595 | // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит |
596 | - if($que_time_left >= $que_item['que_time_left']) { |
|
596 | + if ($que_time_left >= $que_item['que_time_left']) { |
|
597 | 597 | // Увеличиваем количество отстроенных юнитов |
598 | 598 | $unit_processed++; |
599 | 599 | // Вычитаем из времени очереди потраченное на постройку время |
@@ -606,12 +606,12 @@ discard block |
||
606 | 606 | $que_item['que_unit_amount'] -= $unit_processed; |
607 | 607 | |
608 | 608 | // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита |
609 | - if($que_item['que_unit_amount'] > 0) { |
|
609 | + if ($que_item['que_unit_amount'] > 0) { |
|
610 | 610 | $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left; |
611 | 611 | $que_time_left = 0; |
612 | 612 | } |
613 | 613 | |
614 | - if($que_item['que_unit_amount'] <= 0) { |
|
614 | + if ($que_item['que_unit_amount'] <= 0) { |
|
615 | 615 | DBStaticQue::db_que_delete_by_id($que_item['que_id']); |
616 | 616 | } else { |
617 | 617 | classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
@@ -626,15 +626,15 @@ discard block |
||
626 | 626 | ); |
627 | 627 | } |
628 | 628 | |
629 | - if($unit_processed) { |
|
629 | + if ($unit_processed) { |
|
630 | 630 | $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1); |
631 | 631 | $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta; |
632 | 632 | } |
633 | 633 | } |
634 | 634 | |
635 | - foreach($time_left as $player_id => $planet_data) { |
|
636 | - foreach($planet_data as $planet_id => $time_on_planet) { |
|
637 | - if($planet_id) { |
|
635 | + foreach ($time_left as $player_id => $planet_data) { |
|
636 | + foreach ($planet_data as $planet_id => $time_on_planet) { |
|
637 | + if ($planet_id) { |
|
638 | 638 | // update planet |
639 | 639 | classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
640 | 640 | LOC_PLANET, |
@@ -656,8 +656,8 @@ discard block |
||
656 | 656 | ); |
657 | 657 | } |
658 | 658 | |
659 | - if(is_array($unit_changes[$player_id][$planet_id])) { |
|
660 | - foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
659 | + if (is_array($unit_changes[$player_id][$planet_id])) { |
|
660 | + foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
661 | 661 | DBStaticUnit::dbUpdateOrInsertUnit($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null); |
662 | 662 | } |
663 | 663 | } |
@@ -667,38 +667,38 @@ discard block |
||
667 | 667 | $que = que_recalculate($que); |
668 | 668 | |
669 | 669 | // TODO: Re-enable quests for Alliances |
670 | - if(!empty($unit_changes) && !$user['user_as_ally']) { |
|
670 | + if (!empty($unit_changes) && !$user['user_as_ally']) { |
|
671 | 671 | $quest_list = qst_get_quests($user['id']); |
672 | 672 | $quest_triggers = qst_active_triggers($quest_list); |
673 | 673 | $quest_rewards = array(); |
674 | 674 | |
675 | 675 | |
676 | 676 | $xp_incoming = array(); |
677 | - foreach($unit_changes as $user_id => $planet_changes) { |
|
678 | - foreach($planet_changes as $planet_id => $changes) { |
|
677 | + foreach ($unit_changes as $user_id => $planet_changes) { |
|
678 | + foreach ($planet_changes as $planet_id => $changes) { |
|
679 | 679 | $planet_this = $planet_id ? classSupernova::$gc->cacheOperator->db_get_record_by_id(LOC_PLANET, $planet_id) : array(); |
680 | - foreach($changes as $unit_id => $unit_value) { |
|
680 | + foreach ($changes as $unit_id => $unit_value) { |
|
681 | 681 | $que_id = que_get_unit_que($unit_id); |
682 | 682 | $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value; |
683 | - if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
683 | + if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
684 | 684 | $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1); |
685 | 685 | $build_data = $build_data[BUILD_CREATE]; |
686 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
686 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
687 | 687 | $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена |
688 | 688 | } |
689 | 689 | } |
690 | 690 | |
691 | - if(is_array($quest_triggers)) { |
|
691 | + if (is_array($quest_triggers)) { |
|
692 | 692 | // TODO: Check mutiply condition quests |
693 | 693 | $quest_trigger_list = array_keys($quest_triggers, $unit_id); |
694 | - if(is_array($quest_trigger_list)) { |
|
695 | - foreach($quest_trigger_list as $quest_id) { |
|
694 | + if (is_array($quest_trigger_list)) { |
|
695 | + foreach ($quest_trigger_list as $quest_id) { |
|
696 | 696 | $quest_unit_level = $unit_level_new; |
697 | - if(get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) { |
|
697 | + if (get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) { |
|
698 | 698 | $quest_unit_level = DBStaticUnit::db_unit_count_by_user_and_type_and_snid($user_id, 0, $unit_id); |
699 | 699 | $quest_unit_level = $quest_unit_level[$unit_id]['qty']; |
700 | 700 | } |
701 | - if($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) { |
|
701 | + if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) { |
|
702 | 702 | $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list']; |
703 | 703 | $quest_list[$quest_id]['quest_status_status'] = QUEST_STATUS_COMPLETE; |
704 | 704 | } |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч |
712 | 712 | qst_reward($user, $quest_rewards, $quest_list); |
713 | 713 | |
714 | - foreach($xp_incoming as $que_id => $xp) { |
|
714 | + foreach ($xp_incoming as $que_id => $xp) { |
|
715 | 715 | rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000); |
716 | 716 | } |
717 | 717 | } |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | // Инфа об устройстве и браузере - общая для всех |
88 | 88 | sn_db_transaction_start(); |
89 | 89 | $this->device_cypher = $_COOKIE[SN_COOKIE_D]; |
90 | - if($this->device_cypher) { |
|
90 | + if ($this->device_cypher) { |
|
91 | 91 | $cypher_safe = db_escape($this->device_cypher); |
92 | 92 | $device_id = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE"); |
93 | - if(!empty($device_id['device_id'])) { |
|
93 | + if (!empty($device_id['device_id'])) { |
|
94 | 94 | $this->device_id = $device_id['device_id']; |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - if($this->device_id <= 0) { |
|
98 | + if ($this->device_id <= 0) { |
|
99 | 99 | do { |
100 | 100 | $cypher_safe = db_escape($this->device_cypher = sys_random_string()); |
101 | 101 | $row = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE"); |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string'); |
119 | 119 | sn_db_transaction_commit(); |
120 | 120 | |
121 | - if($this->write_full_url) { |
|
121 | + if ($this->write_full_url) { |
|
122 | 122 | sn_db_transaction_start(); |
123 | 123 | $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE)); |
124 | - if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
124 | + if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
125 | 125 | $this->page_url = '/simulator.php'; |
126 | 126 | } |
127 | 127 | $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string'); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function db_security_entry_insert($user_id_unsafe) { |
146 | 146 | // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL'; |
147 | - if(empty($user_id_unsafe)) { |
|
147 | + if (empty($user_id_unsafe)) { |
|
148 | 148 | // self::flog('Нет ИД пользователя'); |
149 | 149 | return true; |
150 | 150 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | public function db_counter_insert($user_id_unsafe) { |
167 | 167 | global $sys_stop_log_hit; |
168 | 168 | |
169 | - if($sys_stop_log_hit || !classSupernova::$config->game_counter) { |
|
169 | + if ($sys_stop_log_hit || !classSupernova::$config->game_counter) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'template_data' => trim(@file_get_contents($this->template->files[$handle])), |
92 | 92 | ); |
93 | 93 | |
94 | - $sql = 'INSERT INTO ' . STYLES_TEMPLATE_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); |
|
94 | + $sql = 'INSERT INTO '.STYLES_TEMPLATE_DATA_TABLE.' '.$db->sql_build_array('INSERT', $sql_ary); |
|
95 | 95 | $db->sql_query($sql); |
96 | 96 | } |
97 | 97 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | |
139 | 139 | preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches); |
140 | 140 | $include_blocks = $matches[1]; |
141 | - if($include_blocks) |
|
141 | + if ($include_blocks) |
|
142 | 142 | { |
143 | - foreach($include_blocks as &$included_file) |
|
143 | + foreach ($include_blocks as &$included_file) |
|
144 | 144 | { |
145 | 145 | $included_file .= '.tpl.html'; |
146 | 146 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | { |
170 | 170 | case 'BEGIN': |
171 | 171 | $this->block_else_level[] = false; |
172 | - $compile_blocks[] = '<?php ' . $this->compile_tag_block($block_val[2]) . ' ?>'; |
|
172 | + $compile_blocks[] = '<?php '.$this->compile_tag_block($block_val[2]).' ?>'; |
|
173 | 173 | break; |
174 | 174 | |
175 | 175 | case 'BEGINELSE': |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | |
180 | 180 | case 'END': |
181 | 181 | array_pop($this->block_names); |
182 | - $compile_blocks[] = '<?php ' . ((array_pop($this->block_else_level)) ? '}' : '}}') . ' ?>'; |
|
182 | + $compile_blocks[] = '<?php '.((array_pop($this->block_else_level)) ? '}' : '}}').' ?>'; |
|
183 | 183 | break; |
184 | 184 | |
185 | 185 | case 'IF': |
186 | - $compile_blocks[] = '<?php ' . $this->compile_tag_if($block_val[2], false) . ' ?>'; |
|
186 | + $compile_blocks[] = '<?php '.$this->compile_tag_if($block_val[2], false).' ?>'; |
|
187 | 187 | break; |
188 | 188 | |
189 | 189 | case 'ELSE': |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | break; |
192 | 192 | |
193 | 193 | case 'ELSEIF': |
194 | - $compile_blocks[] = '<?php ' . $this->compile_tag_if($block_val[2], true) . ' ?>'; |
|
194 | + $compile_blocks[] = '<?php '.$this->compile_tag_if($block_val[2], true).' ?>'; |
|
195 | 195 | break; |
196 | 196 | |
197 | 197 | case 'ENDIF': |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | break; |
200 | 200 | |
201 | 201 | case 'DEFINE': |
202 | - $compile_blocks[] = '<?php ' . $this->compile_tag_define($block_val[2], true) . ' ?>'; |
|
202 | + $compile_blocks[] = '<?php '.$this->compile_tag_define($block_val[2], true).' ?>'; |
|
203 | 203 | break; |
204 | 204 | |
205 | 205 | case 'UNDEFINE': |
206 | - $compile_blocks[] = '<?php ' . $this->compile_tag_define($block_val[2], false) . ' ?>'; |
|
206 | + $compile_blocks[] = '<?php '.$this->compile_tag_define($block_val[2], false).' ?>'; |
|
207 | 207 | break; |
208 | 208 | |
209 | 209 | case 'INCLUDE': |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $file = $temp; |
235 | 235 | } |
236 | 236 | |
237 | - $compile_blocks[] = '<?php ' . $this->compile_tag_include($temp) . ' ?>'; |
|
237 | + $compile_blocks[] = '<?php '.$this->compile_tag_include($temp).' ?>'; |
|
238 | 238 | |
239 | 239 | // No point in checking variable includes |
240 | 240 | if ($file) |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | break; |
245 | 245 | |
246 | 246 | case 'INCLUDEPHP': |
247 | - $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php ' . $this->compile_tag_include_php(array_shift($includephp_blocks)) . ' ?>' : ''; |
|
247 | + $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php '.$this->compile_tag_include_php(array_shift($includephp_blocks)).' ?>' : ''; |
|
248 | 248 | break; |
249 | 249 | |
250 | 250 | case 'PHP': |
251 | - $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php ' . array_shift($php_blocks) . ' ?>' : ''; |
|
251 | + $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php '.array_shift($php_blocks).' ?>' : ''; |
|
252 | 252 | break; |
253 | 253 | |
254 | 254 | default: |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | for ($i = 0, $size = sizeof($text_blocks); $i < $size; $i++) |
264 | 264 | { |
265 | 265 | $trim_check_text = trim($text_blocks[$i]); |
266 | - $template_php .= (!$no_echo) ? (($trim_check_text != '') ? $text_blocks[$i] : '') . ((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '') : (($trim_check_text != '') ? $text_blocks[$i] : '') . ((isset($compile_blocks[$i])) ? $compile_blocks[$i] : ''); |
|
266 | + $template_php .= (!$no_echo) ? (($trim_check_text != '') ? $text_blocks[$i] : '').((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '') : (($trim_check_text != '') ? $text_blocks[$i] : '').((isset($compile_blocks[$i])) ? $compile_blocks[$i] : ''); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | // Remove unused opening/closing tags |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | // we'll strip out such occurences, minimising such switching |
279 | 279 | if ($no_echo) |
280 | 280 | { |
281 | - return "\$$echo_var .= '" . $template_php . "'"; |
|
281 | + return "\$$echo_var .= '".$template_php."'"; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return $template_php; |
@@ -373,30 +373,30 @@ discard block |
||
373 | 373 | |
374 | 374 | if ($match[2] < 0) |
375 | 375 | { |
376 | - $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; |
|
376 | + $loop_start = '($_'.$tag_args.'_count '.$match[2].' < 0 ? 0 : $_'.$tag_args.'_count '.$match[2].')'; |
|
377 | 377 | } |
378 | 378 | else |
379 | 379 | { |
380 | - $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; |
|
380 | + $loop_start = '($_'.$tag_args.'_count < '.$match[2].' ? $_'.$tag_args.'_count : '.$match[2].')'; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | if (strlen($match[3]) < 1 || $match[3] == -1) |
384 | 384 | { |
385 | - $loop_end = '$_' . $tag_args . '_count'; |
|
385 | + $loop_end = '$_'.$tag_args.'_count'; |
|
386 | 386 | } |
387 | 387 | else if ($match[3] >= 0) |
388 | 388 | { |
389 | - $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')'; |
|
389 | + $loop_end = '('.($match[3] + 1).' > $_'.$tag_args.'_count ? $_'.$tag_args.'_count : '.($match[3] + 1).')'; |
|
390 | 390 | } |
391 | 391 | else //if ($match[3] < -1) |
392 | 392 | { |
393 | - $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1); |
|
393 | + $loop_end = '$_'.$tag_args.'_count'.($match[3] + 1); |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | else |
397 | 397 | { |
398 | 398 | $loop_start = 0; |
399 | - $loop_end = '$_' . $tag_args . '_count'; |
|
399 | + $loop_end = '$_'.$tag_args.'_count'; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | $tag_template_php = ''; |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | if (sizeof($block) < 2) |
416 | 416 | { |
417 | 417 | // Block is not nested. |
418 | - $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
|
418 | + $tag_template_php = '$_'.$tag_args."_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
|
419 | 419 | $varref = "\$this->_tpldata['$tag_args']"; |
420 | 420 | } |
421 | 421 | else |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | $varref = $this->generate_block_data_ref($namespace, false); |
430 | 430 | |
431 | 431 | // Create the for loop code to iterate over this block. |
432 | - $tag_template_php = '$_' . $tag_args . '_count = (isset(' . $varref . ')) ? sizeof(' . $varref . ') : 0;'; |
|
432 | + $tag_template_php = '$_'.$tag_args.'_count = (isset('.$varref.')) ? sizeof('.$varref.') : 0;'; |
|
433 | 433 | } |
434 | 434 | |
435 | - $tag_template_php .= 'if ($_' . $tag_args . '_count) {'; |
|
435 | + $tag_template_php .= 'if ($_'.$tag_args.'_count) {'; |
|
436 | 436 | |
437 | 437 | /** |
438 | 438 | * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory |
@@ -444,10 +444,10 @@ discard block |
||
444 | 444 | * </code> |
445 | 445 | */ |
446 | 446 | |
447 | - $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){'; |
|
447 | + $tag_template_php .= 'for ($_'.$tag_args.'_i = '.$loop_start.'; $_'.$tag_args.'_i < '.$loop_end.'; ++$_'.$tag_args.'_i){'; |
|
448 | 448 | // $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;'; |
449 | - $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
450 | - $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
449 | + $tag_template_php .= '$_'.$tag_args.'_val = &'.$varref.'[$_'.$tag_args.'_i];'; |
|
450 | + $tag_template_php .= '$this->_block_value["'.$tag_args.'"] = &'.$varref.'[$_'.$tag_args.'_i];'; |
|
451 | 451 | |
452 | 452 | return $tag_template_php; |
453 | 453 | } |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | break; |
552 | 552 | |
553 | 553 | case 'is': |
554 | - $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1; |
|
554 | + $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1; |
|
555 | 555 | $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); |
556 | 556 | |
557 | - $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); |
|
557 | + $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1)); |
|
558 | 558 | |
559 | 559 | array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens); |
560 | 560 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | default: |
566 | 566 | if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs)) |
567 | 567 | { |
568 | - $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']'); |
|
568 | + $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]).'[\''.$varrefs[3].'\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$varrefs[3].'\']' : '$this->_rootref[\''.$varrefs[3].'\']'); |
|
569 | 569 | } |
570 | 570 | else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
571 | 571 | { |
@@ -582,20 +582,20 @@ discard block |
||
582 | 582 | $varref = $this->generate_block_data_ref($namespace, true); |
583 | 583 | |
584 | 584 | // Add the block reference for the last child. |
585 | - $varref .= "['" . $block . "']"; |
|
585 | + $varref .= "['".$block."']"; |
|
586 | 586 | } |
587 | 587 | else |
588 | 588 | { |
589 | 589 | $varref = '$this->_tpldata'; |
590 | 590 | |
591 | 591 | // Add the block reference for the last child. |
592 | - $varref .= "['" . $blocks[0] . "']"; |
|
592 | + $varref .= "['".$blocks[0]."']"; |
|
593 | 593 | } |
594 | 594 | $token = "sizeof($varref)"; |
595 | 595 | } |
596 | 596 | else if (!empty($token)) |
597 | 597 | { |
598 | - $token = '(' . $token . ')'; |
|
598 | + $token = '('.$token.')'; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | break; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | { |
608 | 608 | $tokens = array('false'); |
609 | 609 | } |
610 | - return (($elseif) ? '} else if (' : 'if (') . (implode(' ', $tokens) . ') { '); |
|
610 | + return (($elseif) ? '} else if (' : 'if (').(implode(' ', $tokens).') { '); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | |
626 | 626 | if (!$op) |
627 | 627 | { |
628 | - return 'unset(' . (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ');'; |
|
628 | + return 'unset('.(($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true).'[\''.$match[2].'\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$match[2].'\']').');'; |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | // Are we a string? |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | $match[4] = $this->compile($match[4]); |
638 | 638 | |
639 | 639 | // Now replace the php code |
640 | - $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'"; |
|
640 | + $match[4] = "'".str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4])."'"; |
|
641 | 641 | } |
642 | 642 | else |
643 | 643 | { |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | } |
661 | 661 | } |
662 | 662 | |
663 | - return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ' = ' . $match[4] . ';'; |
|
663 | + return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true).'[\''.$match[2].'\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$match[2].'\']').' = '.$match[4].';'; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -801,24 +801,24 @@ discard block |
||
801 | 801 | // Build up the string with everything but the last child. |
802 | 802 | for ($i = 0; $i < $blockcount; $i++) |
803 | 803 | { |
804 | - $varref .= "['" . $blocks[$i] . "'][\$_" . $blocks[$i] . '_i]'; |
|
804 | + $varref .= "['".$blocks[$i]."'][\$_".$blocks[$i].'_i]'; |
|
805 | 805 | } |
806 | 806 | // Add the block reference for the last child. |
807 | - $varref .= "['" . $blocks[$blockcount] . "']"; |
|
807 | + $varref .= "['".$blocks[$blockcount]."']"; |
|
808 | 808 | // Add the iterator for the last child if requried. |
809 | 809 | if ($include_last_iterator) |
810 | 810 | { |
811 | - $varref .= '[$_' . $blocks[$blockcount] . '_i]'; |
|
811 | + $varref .= '[$_'.$blocks[$blockcount].'_i]'; |
|
812 | 812 | } |
813 | 813 | return $varref; |
814 | 814 | } |
815 | 815 | else if ($include_last_iterator) |
816 | 816 | { |
817 | - return '$_'. $blocks[$blockcount] . '_val'; |
|
817 | + return '$_'.$blocks[$blockcount].'_val'; |
|
818 | 818 | } |
819 | 819 | else |
820 | 820 | { |
821 | - return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
|
821 | + return '$_'.$blocks[$blockcount - 1].'_val[\''.$blocks[$blockcount].'\']'; |
|
822 | 822 | } |
823 | 823 | } |
824 | 824 | |
@@ -828,14 +828,14 @@ discard block |
||
828 | 828 | */ |
829 | 829 | function compile_write($handle, $data) |
830 | 830 | { |
831 | - $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
|
831 | + $filename = $this->template->cachepath.str_replace('/', '.', $this->template->filename[$handle]).DOT_PHP_EX; |
|
832 | 832 | |
833 | - $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data); |
|
833 | + $data = "<?php if (!defined('INSIDE')) exit;".((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>'.$data); |
|
834 | 834 | |
835 | 835 | if ($fp = @fopen($filename, 'wb')) |
836 | 836 | { |
837 | 837 | @flock($fp, LOCK_EX); |
838 | - @fwrite ($fp, $data); |
|
838 | + @fwrite($fp, $data); |
|
839 | 839 | @flock($fp, LOCK_UN); |
840 | 840 | @fclose($fp); |
841 | 841 | |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | */ |
853 | 853 | private function minify($html) |
854 | 854 | { |
855 | - if(!classSupernova::$config->tpl_minifier) |
|
855 | + if (!classSupernova::$config->tpl_minifier) |
|
856 | 856 | { |
857 | 857 | return $html; |
858 | 858 | } |
@@ -862,14 +862,14 @@ discard block |
||
862 | 862 | $html = preg_replace('/(<script[^>]*?>.*?<\/script>)/si', '#pre#', $html); |
863 | 863 | $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags |
864 | 864 | $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space |
865 | - if(!empty($pre[0])) |
|
865 | + if (!empty($pre[0])) |
|
866 | 866 | { |
867 | - foreach($pre[0] as $tag) |
|
867 | + foreach ($pre[0] as $tag) |
|
868 | 868 | { |
869 | 869 | $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside |
870 | 870 | $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one |
871 | 871 | $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one |
872 | - $html = preg_replace('/#pre#/', $tag, $html,1); |
|
872 | + $html = preg_replace('/#pre#/', $tag, $html, 1); |
|
873 | 873 | } |
874 | 874 | } |
875 | 875 |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * @version 41a6.16 |
24 | 24 | */ |
25 | 25 | protected function db_load_player_by_id($player_id) { |
26 | - if(isset($this[$player_id])) { |
|
26 | + if (isset($this[$player_id])) { |
|
27 | 27 | return; |
28 | 28 | } |
29 | 29 |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | { |
62 | 62 | global $phpbb_root_path, $user; |
63 | 63 | |
64 | - if (file_exists($phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template')) |
|
64 | + if (file_exists($phpbb_root_path.'styles/'.$user->theme['template_path'].'/template')) |
|
65 | 65 | { |
66 | - $this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'; |
|
67 | - $this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_'; |
|
66 | + $this->root = $phpbb_root_path.'styles/'.$user->theme['template_path'].'/template'; |
|
67 | + $this->cachepath = $phpbb_root_path.'cache/tpl_'.str_replace('_', '-', $user->theme['template_path']).'_'; |
|
68 | 68 | |
69 | 69 | if ($this->orig_tpl_storedb === null) |
70 | 70 | { |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | |
82 | 82 | if ($user->theme['template_inherits_id']) |
83 | 83 | { |
84 | - $this->inherit_root = $phpbb_root_path . 'styles/' . $user->theme['template_inherit_path'] . '/template'; |
|
84 | + $this->inherit_root = $phpbb_root_path.'styles/'.$user->theme['template_inherit_path'].'/template'; |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | else |
88 | 88 | { |
89 | - trigger_error('Template path could not be found: styles/' . $user->theme['template_path'] . '/template', E_USER_ERROR); |
|
89 | + trigger_error('Template path could not be found: styles/'.$user->theme['template_path'].'/template', E_USER_ERROR); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | $this->_rootref = &$this->_tpldata['.'][0]; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | $this->root = $template_path; |
112 | - $this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_'; |
|
112 | + $this->cachepath = $phpbb_root_path.'cache/ctpl_'.str_replace('_', '-', $template_name).'_'; |
|
113 | 113 | |
114 | 114 | if ($fallback_template_path !== false) |
115 | 115 | { |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | $this->filename[$handle] = $filename; |
157 | - $this->files[$handle] = $this->root . '/' . $filename; |
|
157 | + $this->files[$handle] = $this->root.'/'.$filename; |
|
158 | 158 | |
159 | 159 | if ($this->inherit_root) |
160 | 160 | { |
161 | - $this->files_inherit[$handle] = $this->inherit_root . '/' . $filename; |
|
161 | + $this->files_inherit[$handle] = $this->inherit_root.'/'.$filename; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } |
236 | 236 | else |
237 | 237 | { |
238 | - eval(' ?>' . $this->compiled_code[$handle] . '<?php '); |
|
238 | + eval(' ?>'.$this->compiled_code[$handle].'<?php '); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | return true; |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | //$user->theme['template_storedb'] = $this->orig_tpl_storedb; |
281 | 281 | //$user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id; |
282 | 282 | |
283 | - $filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . DOT_PHP_EX; |
|
283 | + $filename = $this->cachepath.str_replace('/', '.', $this->filename[$handle]).DOT_PHP_EX; |
|
284 | 284 | //$this->files_template[$handle] = (isset($user->theme['template_id'])) ? $user->theme['template_id'] : 0; |
285 | 285 | |
286 | 286 | $recompile = false; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | if (!class_exists('template_compile')) |
311 | 311 | { |
312 | - include($phpbb_root_path . 'includes/functions_template' . DOT_PHP_EX); |
|
312 | + include($phpbb_root_path.'includes/functions_template'.DOT_PHP_EX); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Inheritance - we point to another template file for this one. Equality is also used for store_db |
@@ -348,10 +348,10 @@ discard block |
||
348 | 348 | foreach ($ids as $id) |
349 | 349 | { |
350 | 350 | $sql = 'SELECT * |
351 | - FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' |
|
352 | - WHERE template_id = ' . $id . " |
|
353 | - AND (template_filename = '" . $db->sql_escape($this->filename[$handle]) . "' |
|
354 | - OR template_included " . $db->sql_like_expression($db->any_char . $this->filename[$handle] . ':' . $db->any_char) . ')'; |
|
351 | + FROM ' . STYLES_TEMPLATE_DATA_TABLE.' |
|
352 | + WHERE template_id = ' . $id." |
|
353 | + AND (template_filename = '" . $db->sql_escape($this->filename[$handle])."' |
|
354 | + OR template_included " . $db->sql_like_expression($db->any_char.$this->filename[$handle].':'.$db->any_char).')'; |
|
355 | 355 | |
356 | 356 | $result = $db->sql_query($sql); |
357 | 357 | while ($row = $db->sql_fetchrow($result)) |
@@ -365,14 +365,14 @@ discard block |
||
365 | 365 | { |
366 | 366 | foreach ($rows as $row) |
367 | 367 | { |
368 | - $file = $this->root . '/' . $row['template_filename']; |
|
368 | + $file = $this->root.'/'.$row['template_filename']; |
|
369 | 369 | $force_reload = false; |
370 | 370 | if ($row['template_id'] != $user->theme['template_id']) |
371 | 371 | { |
372 | 372 | // make sure that we are not overlooking a file not in the db yet |
373 | 373 | if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($file)) |
374 | 374 | { |
375 | - $file = $this->inherit_root . '/' . $row['template_filename']; |
|
375 | + $file = $this->inherit_root.'/'.$row['template_filename']; |
|
376 | 376 | $this->files[$row['template_filename']] = $file; |
377 | 377 | $this->files_inherit[$row['template_filename']] = $file; |
378 | 378 | $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id']; |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | else |
415 | 415 | { |
416 | 416 | // Only bother compiling if it doesn't already exist |
417 | - if (!file_exists($this->cachepath . str_replace('/', '.', $row['template_filename']) . DOT_PHP_EX)) |
|
417 | + if (!file_exists($this->cachepath.str_replace('/', '.', $row['template_filename']).DOT_PHP_EX)) |
|
418 | 418 | { |
419 | 419 | $this->filename[$row['template_filename']] = $row['template_filename']; |
420 | 420 | $compile->compile_write($row['template_filename'], $compile->compile(trim($row['template_data']))); |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | } |
426 | 426 | else |
427 | 427 | { |
428 | - $file = $this->root . '/' . $row['template_filename']; |
|
428 | + $file = $this->root.'/'.$row['template_filename']; |
|
429 | 429 | |
430 | 430 | if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($file)) |
431 | 431 | { |
432 | - $file = $this->inherit_root . '/' . $row['template_filename']; |
|
432 | + $file = $this->inherit_root.'/'.$row['template_filename']; |
|
433 | 433 | $this->files[$row['template_filename']] = $file; |
434 | 434 | $this->files_inherit[$row['template_filename']] = $file; |
435 | 435 | $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id']; |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | // Re-position template blocks |
623 | 623 | for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--) |
624 | 624 | { |
625 | - $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i-1]; |
|
625 | + $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i - 1]; |
|
626 | 626 | $this->_tpldata[$blockname][$i]['S_ROW_COUNT'] = $i; |
627 | 627 | } |
628 | 628 | |
@@ -656,10 +656,10 @@ discard block |
||
656 | 656 | { |
657 | 657 | $handle = $filename; |
658 | 658 | $this->filename[$handle] = $filename; |
659 | - $this->files[$handle] = $this->root . '/' . $filename; |
|
659 | + $this->files[$handle] = $this->root.'/'.$filename; |
|
660 | 660 | if ($this->inherit_root) |
661 | 661 | { |
662 | - $this->files_inherit[$handle] = $this->inherit_root . '/' . $filename; |
|
662 | + $this->files_inherit[$handle] = $this->inherit_root.'/'.$filename; |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | $filename = $this->_tpl_load($handle); |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | include($filename); |
674 | 674 | return; |
675 | 675 | } |
676 | - eval(' ?>' . $this->compiled_code[$handle] . '<?php '); |
|
676 | + eval(' ?>'.$this->compiled_code[$handle].'<?php '); |
|
677 | 677 | } |
678 | 678 | } |
679 | 679 | |
@@ -685,12 +685,12 @@ discard block |
||
685 | 685 | { |
686 | 686 | global $phpbb_root_path; |
687 | 687 | |
688 | - $file = $phpbb_root_path . $filename; |
|
688 | + $file = $phpbb_root_path.$filename; |
|
689 | 689 | |
690 | 690 | if (!file_exists($file)) |
691 | 691 | { |
692 | 692 | // trigger_error cannot be used here, as the output already started |
693 | - echo 'template->_php_include(): File ' . htmlspecialchars($file) . ' does not exist or is empty'; |
|
693 | + echo 'template->_php_include(): File '.htmlspecialchars($file).' does not exist or is empty'; |
|
694 | 694 | return; |
695 | 695 | } |
696 | 696 | include($file); |
@@ -702,13 +702,13 @@ discard block |
||
702 | 702 | */ |
703 | 703 | function assign_recursive($values, $name = '') |
704 | 704 | { |
705 | - if(isset($values['.'])) |
|
705 | + if (isset($values['.'])) |
|
706 | 706 | { |
707 | 707 | $values_extra = $values['.']; |
708 | 708 | unset($values['.']); |
709 | 709 | } |
710 | 710 | |
711 | - if(!$name) |
|
711 | + if (!$name) |
|
712 | 712 | { |
713 | 713 | $this->assign_vars($values); |
714 | 714 | } |
@@ -717,12 +717,12 @@ discard block |
||
717 | 717 | $this->assign_block_vars($name, $values); |
718 | 718 | } |
719 | 719 | |
720 | - if(isset($values_extra)) |
|
720 | + if (isset($values_extra)) |
|
721 | 721 | { |
722 | - foreach($values_extra as $sub_array_name => $sub_array) |
|
722 | + foreach ($values_extra as $sub_array_name => $sub_array) |
|
723 | 723 | { |
724 | - $new_name = $name . ($name ? '.' : '') . $sub_array_name; |
|
725 | - foreach($sub_array as $sub_element) |
|
724 | + $new_name = $name.($name ? '.' : '').$sub_array_name; |
|
725 | + foreach ($sub_array as $sub_element) |
|
726 | 726 | { |
727 | 727 | $this->assign_recursive($sub_element, $new_name); |
728 | 728 | } |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | $this->prepare(); |
94 | 94 | |
95 | 95 | $this->manifest['active'] = false; |
96 | - if(!empty($this->config) && is_array($this->config['db'])) { |
|
96 | + if (!empty($this->config) && is_array($this->config['db'])) { |
|
97 | 97 | // БД, отличная от стандартной |
98 | 98 | $this->db = new db_mysql(); |
99 | 99 | |
100 | 100 | $this->db->sn_db_connect($this->config['db']); |
101 | - if($this->manifest['active'] = $this->db->connected) { |
|
101 | + if ($this->manifest['active'] = $this->db->connected) { |
|
102 | 102 | $this->provider_id = ACCOUNT_PROVIDER_CENTRAL; |
103 | 103 | |
104 | 104 | $this->domain = $this->config['domain']; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | // Fallback to local DB |
115 | - if(!$this->manifest['active']) { |
|
115 | + if (!$this->manifest['active']) { |
|
116 | 116 | $this->db = classSupernova::$db; |
117 | 117 | |
118 | 118 | $this->provider_id = ACCOUNT_PROVIDER_LOCAL; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $this->manifest['active'] = true; |
126 | 126 | } |
127 | 127 | |
128 | - $this->cookie_name_impersonate = $this->cookie_name . AUTH_COOKIE_IMPERSONATE_SUFFIX; |
|
128 | + $this->cookie_name_impersonate = $this->cookie_name.AUTH_COOKIE_IMPERSONATE_SUFFIX; |
|
129 | 129 | |
130 | 130 | $this->account = new Account($this->db); |
131 | 131 | $this->confirmation = new Confirmation($this->db); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | // OK v4.5 |
167 | 167 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
168 | 168 | $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe); |
169 | - if($result) { |
|
169 | + if ($result) { |
|
170 | 170 | $this->cookie_set(); |
171 | 171 | } |
172 | 172 | |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | */ |
195 | 195 | // OK v4.6 |
196 | 196 | protected function password_reset_send_code() { |
197 | - if(!$this->is_password_reset) { |
|
197 | + if (!$this->is_password_reset) { |
|
198 | 198 | return $this->account_login_status; |
199 | 199 | } |
200 | 200 | |
201 | 201 | // Проверяем поддержку сброса пароля |
202 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
202 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
203 | 203 | return $this->account_login_status; |
204 | 204 | } |
205 | 205 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | unset($this->account); |
210 | 210 | $this->account = new Account($this->db); |
211 | 211 | |
212 | - if(!$this->account->db_get_by_email($email_unsafe)) { |
|
212 | + if (!$this->account->db_get_by_email($email_unsafe)) { |
|
213 | 213 | throw new Exception(PASSWORD_RESTORE_ERROR_EMAIL_NOT_EXISTS, ERR_ERROR); |
214 | 214 | // return $this->account_login_status; |
215 | 215 | } |
@@ -219,14 +219,14 @@ discard block |
||
219 | 219 | |
220 | 220 | // TODO - Проверять уровень доступа аккаунта! |
221 | 221 | // Аккаунты с АУТЛЕВЕЛ больше 0 - НЕ СБРАСЫВАЮТ ПАРОЛИ! |
222 | - foreach($user_list as $user_id => $user_data) { |
|
223 | - if($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
222 | + foreach ($user_list as $user_id => $user_data) { |
|
223 | + if ($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
224 | 224 | throw new Exception(PASSWORD_RESTORE_ERROR_ADMIN_ACCOUNT, ERR_ERROR); |
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | 228 | $confirmation = $this->confirmation->db_confirmation_get_latest_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5 |
229 | - if(isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
229 | + if (isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
230 | 230 | throw new Exception(PASSWORD_RESTORE_ERROR_TOO_OFTEN, ERR_ERROR); |
231 | 231 | } |
232 | 232 | |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | |
240 | 240 | @$result = mymail($email_unsafe, |
241 | 241 | sprintf(classLocale::$lang['log_lost_email_title'], classSupernova::$config->game_name), |
242 | - sprintf(classLocale::$lang['log_lost_email_code'], SN_ROOT_VIRTUAL . 'login.php', $confirm_code_unsafe, date(FMT_DATE_TIME, SN_TIME_NOW + AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE), classSupernova::$config->game_name) |
|
242 | + sprintf(classLocale::$lang['log_lost_email_code'], SN_ROOT_VIRTUAL.'login.php', $confirm_code_unsafe, date(FMT_DATE_TIME, SN_TIME_NOW + AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE), classSupernova::$config->game_name) |
|
243 | 243 | ); |
244 | 244 | |
245 | 245 | $result = $result ? PASSWORD_RESTORE_SUCCESS_CODE_SENT : PASSWORD_RESTORE_ERROR_SENDING; |
246 | - } catch(Exception $e) { |
|
246 | + } catch (Exception $e) { |
|
247 | 247 | sn_db_transaction_rollback(); |
248 | 248 | $result = $e->getMessage(); |
249 | 249 | } |
@@ -256,46 +256,46 @@ discard block |
||
256 | 256 | * @return int|string |
257 | 257 | */ |
258 | 258 | protected function password_reset_confirm() { |
259 | - if(!$this->is_password_reset_confirm) { |
|
259 | + if (!$this->is_password_reset_confirm) { |
|
260 | 260 | return $this->account_login_status; |
261 | 261 | } |
262 | 262 | |
263 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
263 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
264 | 264 | return $this->account_login_status; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Проверяем поддержку сброса пароля |
268 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
268 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
269 | 269 | return $this->account_login_status; |
270 | 270 | } |
271 | 271 | |
272 | 272 | try { |
273 | 273 | $code_unsafe = sys_get_param_str_unsafe('password_reset_code'); |
274 | - if(empty($code_unsafe)) { |
|
274 | + if (empty($code_unsafe)) { |
|
275 | 275 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_EMPTY, ERR_ERROR); |
276 | 276 | } |
277 | 277 | |
278 | 278 | sn_db_transaction_start(); |
279 | 279 | $confirmation = $this->confirmation->db_confirmation_get_by_type_and_code(CONFIRM_PASSWORD_RESET, $code_unsafe); // OK 4.5 |
280 | 280 | |
281 | - if(empty($confirmation)) { |
|
281 | + if (empty($confirmation)) { |
|
282 | 282 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_WRONG, ERR_ERROR); |
283 | 283 | } |
284 | 284 | |
285 | - if(SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
285 | + if (SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
286 | 286 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_TOO_OLD, ERR_ERROR); |
287 | 287 | } |
288 | 288 | |
289 | 289 | unset($this->account); |
290 | 290 | $this->account = new Account($this->db); |
291 | 291 | |
292 | - if(!$this->account->db_get_by_email($confirmation['email'])) { |
|
292 | + if (!$this->account->db_get_by_email($confirmation['email'])) { |
|
293 | 293 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_OK_BUT_NO_ACCOUNT_FOR_EMAIL, ERR_ERROR); |
294 | 294 | } |
295 | 295 | |
296 | 296 | $new_password_unsafe = $this->make_random_password(); |
297 | 297 | $salt_unsafe = $this->password_salt_generate(); |
298 | - if(!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
298 | + if (!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
299 | 299 | // Ошибка смены пароля |
300 | 300 | throw new Exception(AUTH_ERROR_INTERNAL_PASSWORD_CHANGE_ON_RESTORE, ERR_ERROR); |
301 | 301 | } |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | $this->cookie_set(); |
306 | 306 | $this->login_cookie(); |
307 | 307 | |
308 | - if($this->account_login_status == LOGIN_SUCCESS) { |
|
308 | + if ($this->account_login_status == LOGIN_SUCCESS) { |
|
309 | 309 | // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!! |
310 | 310 | $message_header = sprintf(classLocale::$lang['log_lost_email_title'], classSupernova::$config->game_name); |
311 | 311 | $message = sprintf(classLocale::$lang['log_lost_email_pass'], classSupernova::$config->game_name, $this->account->account_name, $new_password_unsafe); |
312 | 312 | @$operation_result = mymail($confirmation['email'], $message_header, htmlspecialchars($message)); |
313 | 313 | |
314 | 314 | $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5 |
315 | - if(!empty($users_translated)) { |
|
315 | + if (!empty($users_translated)) { |
|
316 | 316 | // Отправляем в лички письмо о сбросе пароля |
317 | 317 | |
318 | 318 | // ПО ОПРЕДЕЛЕНИЮ в $users_translated только |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | // - игроки, привязанные только к этим аккаунтам |
322 | 322 | // Значит им всем сразу скопом можно отправлять сообщения |
323 | 323 | $message = sprintf(classLocale::$lang['sys_password_reset_message_body'], $new_password_unsafe); |
324 | - $message = sys_bbcodeParse($message) . '<br><br>'; |
|
324 | + $message = sys_bbcodeParse($message).'<br><br>'; |
|
325 | 325 | |
326 | - foreach($users_translated as $user_id => $providers_list) { |
|
326 | + foreach ($users_translated as $user_id => $providers_list) { |
|
327 | 327 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, classLocale::$lang['sys_administration'], classLocale::$lang['sys_login_register_message_title'], $message); |
328 | 328 | } |
329 | 329 | } else { |
@@ -375,10 +375,10 @@ discard block |
||
375 | 375 | // OK v4.5 |
376 | 376 | protected function register() { |
377 | 377 | // TODO РЕГИСТРАЦИЯ ВСЕГДА ДОЛЖНА ЛОГИНИТЬ ПОЛЬЗОВАТЕЛЯ! |
378 | - $this->flog('Регистрация: начинаем. Провайдер ' . $this->provider_id); |
|
378 | + $this->flog('Регистрация: начинаем. Провайдер '.$this->provider_id); |
|
379 | 379 | |
380 | 380 | try { |
381 | - if(!$this->is_register) { |
|
381 | + if (!$this->is_register) { |
|
382 | 382 | $this->flog('Регистрация: не выставлен флаг регистрации - пропускаем'); |
383 | 383 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
384 | 384 | } |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | sn_db_transaction_start(); |
389 | 389 | |
390 | 390 | $this->account->db_get_by_name_or_email($this->input_login_unsafe, $this->input_email_unsafe); |
391 | - if($this->account->is_exists) { |
|
392 | - if($this->account->account_email == $this->input_email_unsafe) { |
|
391 | + if ($this->account->is_exists) { |
|
392 | + if ($this->account->account_email == $this->input_email_unsafe) { |
|
393 | 393 | throw new Exception(REGISTER_ERROR_EMAIL_EXISTS, ERR_ERROR); |
394 | 394 | } else { |
395 | 395 | throw new Exception(REGISTER_ERROR_ACCOUNT_NAME_EXISTS, ERR_ERROR); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | // А вот это пока не нужно. Трансляцией аккаунтов в юзеров и созданием новых юзеров для новозашедших аккаунтов занимается Auth |
412 | 412 | // $this->register_account(); |
413 | 413 | sn_db_transaction_commit(); |
414 | - } catch(Exception $e) { |
|
414 | + } catch (Exception $e) { |
|
415 | 415 | sn_db_transaction_rollback(); |
416 | 416 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
417 | 417 | } |
@@ -427,19 +427,19 @@ discard block |
||
427 | 427 | */ |
428 | 428 | // OK v4.5 |
429 | 429 | protected function login_cookie() { |
430 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
430 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
431 | 431 | return $this->account_login_status; |
432 | 432 | } |
433 | 433 | |
434 | 434 | // Пытаемся войти по куке |
435 | - if(!empty($_COOKIE[$this->cookie_name])) { |
|
436 | - if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
435 | + if (!empty($_COOKIE[$this->cookie_name])) { |
|
436 | + if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
437 | 437 | list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]); |
438 | 438 | } else { |
439 | 439 | list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]); |
440 | 440 | } |
441 | 441 | |
442 | - if( |
|
442 | + if ( |
|
443 | 443 | $this->account->db_get_by_id($account_id_unsafe) |
444 | 444 | && ($this->password_encode_for_cookie($this->account->account_password) == $cookie_password_hash_salted) |
445 | 445 | ) { |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | - if($this->account_login_status != LOGIN_SUCCESS) { |
|
451 | + if ($this->account_login_status != LOGIN_SUCCESS) { |
|
452 | 452 | // Невалидная кука - чистим |
453 | 453 | $this->cookie_clear(); |
454 | 454 | } |
@@ -466,29 +466,29 @@ discard block |
||
466 | 466 | protected function login_username() { |
467 | 467 | // TODO - Логин по старым именам |
468 | 468 | try { |
469 | - if(!$this->is_login) { |
|
469 | + if (!$this->is_login) { |
|
470 | 470 | $this->flog('Логин: не выставлен флаг входа в игру - это не логин'); |
471 | 471 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
472 | 472 | } |
473 | 473 | |
474 | 474 | // TODO Пустое имя аккаунта |
475 | - if(!$this->input_login_unsafe) { |
|
475 | + if (!$this->input_login_unsafe) { |
|
476 | 476 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
477 | 477 | } |
478 | 478 | |
479 | 479 | $this->login_validate_input(); |
480 | 480 | |
481 | - if(!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
481 | + if (!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
482 | 482 | throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR); |
483 | 483 | } |
484 | 484 | |
485 | - if(!$this->account->password_check($this->input_login_password_raw)) { |
|
485 | + if (!$this->account->password_check($this->input_login_password_raw)) { |
|
486 | 486 | throw new Exception(LOGIN_ERROR_PASSWORD, ERR_ERROR); |
487 | 487 | } |
488 | 488 | |
489 | 489 | $this->cookie_set(); |
490 | 490 | $this->account_login_status = LOGIN_SUCCESS; |
491 | - } catch(Exception $e) { |
|
491 | + } catch (Exception $e) { |
|
492 | 492 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
493 | 493 | } |
494 | 494 | |
@@ -510,18 +510,18 @@ discard block |
||
510 | 510 | protected function cookie_set($account_to_impersonate = null) { |
511 | 511 | $this_account = is_object($account_to_impersonate) ? $account_to_impersonate : $this->account; |
512 | 512 | |
513 | - if(!is_object($this_account) || !$this_account->is_exists) { |
|
513 | + if (!is_object($this_account) || !$this_account->is_exists) { |
|
514 | 514 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
515 | 515 | } |
516 | 516 | |
517 | - if(is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
517 | + if (is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
518 | 518 | sn_setcookie($this->cookie_name_impersonate, $_COOKIE[$this->cookie_name], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
519 | 519 | } |
520 | 520 | |
521 | 521 | $expire_time = $this->remember_me ? SN_TIME_NOW + PERIOD_YEAR : 0; |
522 | 522 | |
523 | 523 | $password_encoded = $this->password_encode_for_cookie($this_account->account_password); |
524 | - $cookie = $this_account->account_id . AUTH_COOKIE_DELIMETER . $password_encoded . AUTH_COOKIE_DELIMETER . $this->remember_me; |
|
524 | + $cookie = $this_account->account_id.AUTH_COOKIE_DELIMETER.$password_encoded.AUTH_COOKIE_DELIMETER.$this->remember_me; |
|
525 | 525 | $this->flog("cookie_set() - Устанавливаем куку {$cookie}"); |
526 | 526 | return sn_setcookie($this->cookie_name, $cookie, $expire_time, $this->sn_root_path, $this->domain); |
527 | 527 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | // OK v4.1 |
533 | 533 | protected function cookie_clear() { |
534 | 534 | // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё |
535 | - if(!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
535 | + if (!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
536 | 536 | sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
537 | 537 | sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $this->domain); |
538 | 538 | } else { |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | protected function login_validate_input() { |
552 | 552 | // Проверяем, что бы в начале и конце не было пустых символов |
553 | 553 | // TODO - при копировании Эксель -> Опера - в конце образуются пустые места. Это не должно быть проблемой! Вынести проверку пароля в регистрацию! |
554 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
554 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
555 | 555 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
556 | 556 | } |
557 | - if(!$this->input_login_password_raw) { |
|
557 | + if (!$this->input_login_password_raw) { |
|
558 | 558 | throw new Exception(LOGIN_ERROR_PASSWORD_EMPTY, ERR_ERROR); |
559 | 559 | } |
560 | 560 | } |
@@ -570,37 +570,37 @@ discard block |
||
570 | 570 | $this->login_validate_input(); |
571 | 571 | |
572 | 572 | // Если нет имени пользователя - NO GO! |
573 | - if(!$this->input_login_unsafe) { |
|
573 | + if (!$this->input_login_unsafe) { |
|
574 | 574 | throw new Exception(LOGIN_ERROR_USERNAME_EMPTY, ERR_ERROR); |
575 | 575 | } |
576 | 576 | // Если логин имеет запрещенные символы - NO GO! |
577 | - if(strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
577 | + if (strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
578 | 578 | throw new Exception(LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
579 | 579 | } |
580 | 580 | // Если логин меньше минимальной длины - NO GO! |
581 | - if(strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
581 | + if (strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
582 | 582 | throw new Exception(REGISTER_ERROR_USERNAME_SHORT, ERR_ERROR); |
583 | 583 | } |
584 | 584 | // Если пароль меньше минимальной длины - NO GO! |
585 | - if(strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
585 | + if (strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
586 | 586 | throw new Exception(REGISTER_ERROR_PASSWORD_INSECURE, ERR_ERROR); |
587 | 587 | } |
588 | 588 | // Если пароль имеет пробельные символы в начале или конце - NO GO! |
589 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
589 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
590 | 590 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
591 | 591 | } |
592 | 592 | // Если пароль не совпадает с подтверждением - NO GO! То, что у пароля нет пробельных символов в начале/конце - мы уже проверили выше |
593 | 593 | //Если они есть у повтора - значит пароль и повтор не совпадут |
594 | - if($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
594 | + if ($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
595 | 595 | throw new Exception(REGISTER_ERROR_PASSWORD_DIFFERENT, ERR_ERROR); |
596 | 596 | } |
597 | 597 | // Если нет емейла - NO GO! |
598 | 598 | // TODO - регистрация без емейла |
599 | - if(!$this->input_email_unsafe) { |
|
599 | + if (!$this->input_email_unsafe) { |
|
600 | 600 | throw new Exception(REGISTER_ERROR_EMAIL_EMPTY, ERR_ERROR); |
601 | 601 | } |
602 | 602 | // Если емейл не является емейлом - NO GO! |
603 | - if(!is_email($this->input_email_unsafe)) { |
|
603 | + if (!is_email($this->input_email_unsafe)) { |
|
604 | 604 | throw new Exception(REGISTER_ERROR_EMAIL_WRONG, ERR_ERROR); |
605 | 605 | } |
606 | 606 | } |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | |
610 | 610 | // OK v4 |
611 | 611 | protected function password_encode_for_cookie($password) { |
612 | - return md5("{$password}--" . $this->secret_word); |
|
612 | + return md5("{$password}--".$this->secret_word); |
|
613 | 613 | } |
614 | 614 | // OK v4 |
615 | 615 | protected function password_encode($password, $salt) { |
@@ -629,22 +629,22 @@ discard block |
||
629 | 629 | return core_auth::make_random_password(); |
630 | 630 | } |
631 | 631 | protected function flog($message, $die = false) { |
632 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
632 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
633 | 633 | return; |
634 | 634 | } |
635 | 635 | list($called, $caller) = debug_backtrace(false); |
636 | 636 | |
637 | 637 | $caller_name = |
638 | - ((get_called_class()) ? get_called_class() : (!empty($caller['class']) ? $caller['class'] : '')) . |
|
639 | - (!empty($caller['type']) ? $caller['type'] : '') . |
|
640 | - (!empty($caller['function']) ? $caller['function'] : '') . |
|
641 | - (!empty($called['line']) ? ':' . $called['line'] : ''); |
|
638 | + ((get_called_class()) ? get_called_class() : (!empty($caller['class']) ? $caller['class'] : '')). |
|
639 | + (!empty($caller['type']) ? $caller['type'] : ''). |
|
640 | + (!empty($caller['function']) ? $caller['function'] : ''). |
|
641 | + (!empty($called['line']) ? ':'.$called['line'] : ''); |
|
642 | 642 | |
643 | 643 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
644 | 644 | |
645 | 645 | classSupernova::log_file("$message - $caller_name"); |
646 | - if($die) { |
|
647 | - $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
646 | + if ($die) { |
|
647 | + $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | UBE_PLAYER_IS_DEFENDER => array(), |
56 | 56 | ); |
57 | 57 | |
58 | - foreach($this->_container as $player_id => $UBEPlayer) { |
|
58 | + foreach ($this->_container as $player_id => $UBEPlayer) { |
|
59 | 59 | $result[$UBEPlayer->getSide() ? UBE_PLAYER_IS_ATTACKER : UBE_PLAYER_IS_DEFENDER][$player_id] = $UBEPlayer->getDbRow(); |
60 | 60 | } |
61 | 61 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function get_first_player_on_side($side) { |
72 | 72 | $result = null; |
73 | - foreach($this->_container as $player_id => $UBEPlayer) { |
|
74 | - if($UBEPlayer->getSide() == $side) { |
|
73 | + foreach ($this->_container as $player_id => $UBEPlayer) { |
|
74 | + if ($UBEPlayer->getSide() == $side) { |
|
75 | 75 | $result = $UBEPlayer; |
76 | 76 | break; |
77 | 77 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function get_player_sides() { |
90 | 90 | $result = array(); |
91 | - foreach($this->_container as $player_id => $UBEPlayer) { |
|
91 | + foreach ($this->_container as $player_id => $UBEPlayer) { |
|
92 | 92 | $result[$player_id] = $UBEPlayer->getSide() ? UBE_PLAYER_IS_ATTACKER : UBE_PLAYER_IS_DEFENDER; |
93 | 93 | } |
94 | 94 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | public function ubeLoadPlayersAndSetSideFromFleetIdList(array $added_fleets, UBEFleetList $fleetList, $side = UBE_PLAYER_IS_DEFENDER) { |
99 | - foreach($added_fleets as $fleet_id) { |
|
99 | + foreach ($added_fleets as $fleet_id) { |
|
100 | 100 | $this->db_load_player_by_id($fleetList[$fleet_id]->owner_id, $side); |
101 | 101 | } |
102 | 102 | } |