@@ -139,11 +139,13 @@ |
||
139 | 139 | $error_backtrace['locks'] = _SnCacheInternal::$locks; |
140 | 140 | $error_backtrace['cSN_data'] = _SnCacheInternal::$data; |
141 | 141 | foreach($error_backtrace['cSN_data'] as &$location) { |
142 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
142 | + foreach($location as $location_id => &$location_data) { |
|
143 | + // $location_data = $location_id; |
|
143 | 144 | { |
144 | 145 | $location_data = isset($location_data['username']) ? $location_data['username'] : |
145 | 146 | (isset($location_data['name']) ? $location_data['name'] : $location_id); |
146 | 147 | } |
148 | + } |
|
147 | 149 | } |
148 | 150 | } |
149 | 151 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * que esperabas!!! soy newbie!!! D':< |
25 | 25 | */ |
26 | 26 | |
27 | -if(!defined('INSIDE')) { |
|
27 | +if (!defined('INSIDE')) { |
|
28 | 28 | die("attemp hacking"); |
29 | 29 | } |
30 | 30 | |
@@ -37,16 +37,16 @@ discard block |
||
37 | 37 | function log_file($message, $ident_change = 0) { |
38 | 38 | static $ident = 0; |
39 | 39 | |
40 | - if(!defined('SN_DEBUG_LOG')) { |
|
40 | + if (!defined('SN_DEBUG_LOG')) { |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
44 | - if($this->log_file_handler === null) { |
|
44 | + if ($this->log_file_handler === null) { |
|
45 | 45 | $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
46 | 46 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
47 | 47 | } |
48 | 48 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
49 | - if($this->log_file_handler) { |
|
49 | + if ($this->log_file_handler) { |
|
50 | 50 | @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
51 | 51 | } |
52 | 52 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | $result = array(); |
82 | 82 | $transaction_id = SN::db_transaction_check(false) ? SN::$transaction_id : SN::$transaction_id++; |
83 | 83 | $result[] = "tID {$transaction_id}"; |
84 | - foreach($backtrace as $a_trace) { |
|
85 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
84 | + foreach ($backtrace as $a_trace) { |
|
85 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
86 | 86 | continue; |
87 | 87 | } |
88 | 88 | $function = |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | $result[] = "{$function} - '{$file}' Line {$a_trace['line']}"; |
100 | 100 | |
101 | - if(!$long_comment) { |
|
101 | + if (!$long_comment) { |
|
102 | 102 | break; |
103 | 103 | } |
104 | 104 | } |
@@ -107,26 +107,26 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | function dump($dump = false, $force_base = false, $deadlock = false) { |
110 | - if($dump === false) { |
|
110 | + if ($dump === false) { |
|
111 | 111 | return; |
112 | 112 | } |
113 | 113 | |
114 | 114 | $error_backtrace = array(); |
115 | 115 | $base_dump = false; |
116 | 116 | |
117 | - if($force_base === true) { |
|
117 | + if ($force_base === true) { |
|
118 | 118 | $base_dump = true; |
119 | 119 | } |
120 | 120 | |
121 | - if($dump === true) { |
|
121 | + if ($dump === true) { |
|
122 | 122 | $base_dump = true; |
123 | 123 | } else { |
124 | - if(!is_array($dump)) { |
|
124 | + if (!is_array($dump)) { |
|
125 | 125 | $dump = array('var' => $dump); |
126 | 126 | } |
127 | 127 | |
128 | - foreach($dump as $dump_var_name => $dump_var) { |
|
129 | - if($dump_var_name == 'base_dump') { |
|
128 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
129 | + if ($dump_var_name == 'base_dump') { |
|
130 | 130 | $base_dump = $dump_var; |
131 | 131 | } else { |
132 | 132 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -134,24 +134,23 @@ discard block |
||
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - if($deadlock && ($q = db_fetch(SN::$db->mysql_get_innodb_status()))) { |
|
137 | + if ($deadlock && ($q = db_fetch(SN::$db->mysql_get_innodb_status()))) { |
|
138 | 138 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
139 | 139 | $error_backtrace['locks'] = _SnCacheInternal::$locks; |
140 | 140 | $error_backtrace['cSN_data'] = _SnCacheInternal::$data; |
141 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
142 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
141 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
142 | + foreach ($location as $location_id => &$location_data) // $location_data = $location_id; |
|
143 | 143 | { |
144 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
145 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
144 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
146 | 145 | } |
147 | 146 | } |
148 | 147 | } |
149 | 148 | |
150 | - if($base_dump) { |
|
151 | - if(!is_array($this->log_array) || empty($this->log_array)) { |
|
149 | + if ($base_dump) { |
|
150 | + if (!is_array($this->log_array) || empty($this->log_array)) { |
|
152 | 151 | $this->log_array = []; |
153 | 152 | } else { |
154 | - foreach($this->log_array as $log) { |
|
153 | + foreach ($this->log_array as $log) { |
|
155 | 154 | $error_backtrace['queries'][] = $log; |
156 | 155 | } |
157 | 156 | } |
@@ -163,17 +162,17 @@ discard block |
||
163 | 162 | // Converting object instances to object names |
164 | 163 | |
165 | 164 | foreach ($error_backtrace['backtrace'] as &$backtrace) { |
166 | - if(is_object($backtrace['object'])) { |
|
165 | + if (is_object($backtrace['object'])) { |
|
167 | 166 | $backtrace['object'] = get_class($backtrace['object']); |
168 | 167 | } |
169 | 168 | |
170 | - if(empty($backtrace['args'])) { |
|
169 | + if (empty($backtrace['args'])) { |
|
171 | 170 | continue; |
172 | 171 | } |
173 | 172 | |
174 | 173 | // Doing same conversion for backtrace params |
175 | - foreach($backtrace['args'] as &$arg) { |
|
176 | - if(is_object($arg)) { |
|
174 | + foreach ($backtrace['args'] as &$arg) { |
|
175 | + if (is_object($arg)) { |
|
177 | 176 | $arg = 'object::' . get_class($arg); |
178 | 177 | } |
179 | 178 | } |
@@ -202,14 +201,14 @@ discard block |
||
202 | 201 | function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
203 | 202 | global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user; |
204 | 203 | |
205 | - if(empty(SN::$db->connected)) { |
|
204 | + if (empty(SN::$db->connected)) { |
|
206 | 205 | // TODO - писать ошибку в файл |
207 | 206 | die('SQL server currently unavailable. Please contact Administration...'); |
208 | 207 | } |
209 | 208 | |
210 | 209 | sn_db_transaction_rollback(); |
211 | 210 | |
212 | - if(SN::$config->debug == 1) { |
|
211 | + if (SN::$config->debug == 1) { |
|
213 | 212 | echo "<h2>{$title}</h2><br><font color=red>" . htmlspecialchars($message) . "</font><br><hr>"; |
214 | 213 | echo "<table>{$this->log}</table>"; |
215 | 214 | } |
@@ -219,7 +218,7 @@ discard block |
||
219 | 218 | $error_text = db_escape($message); |
220 | 219 | $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false); |
221 | 220 | |
222 | - if(!$sys_log_disabled) { |
|
221 | + if (!$sys_log_disabled) { |
|
223 | 222 | $query = "INSERT INTO `{{logs}}` SET |
224 | 223 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "', |
225 | 224 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -237,7 +236,7 @@ discard block |
||
237 | 236 | ob_start(); |
238 | 237 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
239 | 238 | |
240 | - foreach($error_backtrace as $name => $value) { |
|
239 | + foreach ($error_backtrace as $name => $value) { |
|
241 | 240 | print('<hr>'); |
242 | 241 | pdump($value, $name); |
243 | 242 | } |
@@ -249,14 +248,14 @@ discard block |
||
249 | 248 | function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
250 | 249 | global $user, $lang, $sys_log_disabled; |
251 | 250 | |
252 | - if(empty(SN::$db->connected)) { |
|
251 | + if (empty(SN::$db->connected)) { |
|
253 | 252 | // TODO - писать ошибку в файл |
254 | 253 | die('SQL server currently unavailable. Please contact Administration...'); |
255 | 254 | } |
256 | 255 | |
257 | 256 | $error_backtrace = $this->dump($dump, false); |
258 | 257 | |
259 | - if(!$sys_log_disabled) { |
|
258 | + if (!$sys_log_disabled) { |
|
260 | 259 | $query = "INSERT INTO `{{logs}}` SET |
261 | 260 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "', |
262 | 261 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -274,11 +273,11 @@ discard block |
||
274 | 273 | // Dump variables nicer then var_dump() |
275 | 274 | |
276 | 275 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
277 | - if(isset($varname)) { |
|
276 | + if (isset($varname)) { |
|
278 | 277 | $varname .= " = "; |
279 | 278 | } |
280 | 279 | |
281 | - if($level == -1) { |
|
280 | + if ($level == -1) { |
|
282 | 281 | $trans[' '] = '∴'; |
283 | 282 | $trans["\t"] = '⇒'; |
284 | 283 | $trans["\n"] = '¶;'; |
@@ -287,7 +286,7 @@ discard block |
||
287 | 286 | |
288 | 287 | return strtr(htmlspecialchars($value), $trans); |
289 | 288 | } |
290 | - if($level == 0) { |
|
289 | + if ($level == 0) { |
|
291 | 290 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
292 | 291 | $dumper = mt_rand(10, 99) . '|' . $varname; |
293 | 292 | } |
@@ -295,22 +294,22 @@ discard block |
||
295 | 294 | $type = gettype($value); |
296 | 295 | $dumper .= $type; |
297 | 296 | |
298 | - if($type == 'string') { |
|
297 | + if ($type == 'string') { |
|
299 | 298 | $dumper .= '(' . strlen($value) . ')'; |
300 | 299 | $value = dump($value, '', -1); |
301 | - } elseif($type == 'boolean') { |
|
300 | + } elseif ($type == 'boolean') { |
|
302 | 301 | $value = ($value ? 'true' : 'false'); |
303 | - } elseif($type == 'object') { |
|
302 | + } elseif ($type == 'object') { |
|
304 | 303 | $props = get_class_vars(get_class($value)); |
305 | 304 | $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
306 | - foreach($props as $key => $val) { |
|
305 | + foreach ($props as $key => $val) { |
|
307 | 306 | $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
308 | 307 | $dumper .= dump($value->$key, '', $level + 1); |
309 | 308 | } |
310 | 309 | $value = ''; |
311 | - } elseif($type == 'array') { |
|
310 | + } elseif ($type == 'array') { |
|
312 | 311 | $dumper .= '(' . count($value) . ')'; |
313 | - foreach($value as $key => $val) { |
|
312 | + foreach ($value as $key => $val) { |
|
314 | 313 | $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
315 | 314 | $dumper .= dump($val, '', $level + 1); |
316 | 315 | } |
@@ -330,7 +329,7 @@ discard block |
||
330 | 329 | // $backtrace = $backtrace[1]; |
331 | 330 | |
332 | 331 | $caller = ''; |
333 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
332 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
334 | 333 | $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
335 | 334 | (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
336 | 335 | $backtrace[1]['function'] . |
@@ -357,7 +356,7 @@ discard block |
||
357 | 356 | } |
358 | 357 | |
359 | 358 | function pr($prePrint = false) { |
360 | - if($prePrint) { |
|
359 | + if ($prePrint) { |
|
361 | 360 | print("<br>"); |
362 | 361 | } |
363 | 362 | print(mt_rand() . "<br>"); |
@@ -367,7 +366,7 @@ discard block |
||
367 | 366 | global $_PRINT_COUNT_VALUE; |
368 | 367 | $_PRINT_COUNT_VALUE++; |
369 | 368 | |
370 | - if($prePrint) { |
|
369 | + if ($prePrint) { |
|
371 | 370 | print("<br>"); |
372 | 371 | } |
373 | 372 | print($_PRINT_COUNT_VALUE . "<br>"); |
@@ -80,7 +80,7 @@ |
||
80 | 80 | |
81 | 81 | $result = array(); |
82 | 82 | $transaction_id = SN::db_transaction_check(false) ? SN::$transaction_id : SN::$transaction_id++; |
83 | - $result[] = "tID {$transaction_id}"; |
|
83 | + $result[] = "tid {$transaction_id}"; |
|
84 | 84 | foreach($backtrace as $a_trace) { |
85 | 85 | if(in_array($a_trace['function'], $exclude_functions)) { |
86 | 86 | continue; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | "SELECT `id` AS `ID`, `username` AS `NAME`, `ally_name` AS `ALLY`, `total_points` AS `STAT_POINTS`, |
181 | 181 | `onlinetime` AS `ACTIVITY` |
182 | 182 | FROM `{{users}}` |
183 | - WHERE `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) ." ORDER BY user_as_ally, `". $TypeSort ."` ASC;"); |
|
183 | + WHERE `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) . " ORDER BY user_as_ally, `" . $TypeSort . "` ASC;"); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | return doquery("SELECT u.*, COUNT(r.id) AS referral_count, SUM(r.dark_matter) AS referral_dm FROM {{users}} as u |
196 | 196 | LEFT JOIN {{referrals}} as r on r.id_partner = u.id |
197 | 197 | WHERE" . |
198 | - ($online ? " `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) : ' user_as_ally IS NULL') . |
|
198 | + ($online ? " `onlinetime` >= " . (SN_TIME_NOW - $config->game_users_online_timeout) : ' user_as_ally IS NULL') . |
|
199 | 199 | " GROUP BY u.id |
200 | 200 | ORDER BY user_as_ally, {$sort} ASC"); |
201 | 201 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | !is_array($user_id_list) ? $user_id_list = array($user_id_list) : false; |
212 | 212 | |
213 | 213 | $user_list = array(); |
214 | - foreach($user_id_list as $user_id_unsafe) { |
|
214 | + foreach ($user_id_list as $user_id_unsafe) { |
|
215 | 215 | $user = db_user_by_id($user_id_unsafe); |
216 | 216 | !empty($user) ? $user_list[$user_id_unsafe] = $user : false; |
217 | 217 | } |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | sprintf($lang['buddy_msg_accept_text'], $user['username'])); |
57 | 57 | sn_db_transaction_commit(); |
58 | 58 | throw new exception('buddy_err_accept_none', ERR_NONE); |
59 | - } |
|
60 | - else |
|
59 | + } else |
|
61 | 60 | { |
62 | 61 | throw new exception('buddy_err_accept_internal', ERR_ERROR); |
63 | 62 | } |
@@ -69,9 +68,11 @@ discard block |
||
69 | 68 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
70 | 69 | } |
71 | 70 | |
72 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
71 | + if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
72 | + // Existing friendship |
|
73 | 73 | { |
74 | 74 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
75 | + } |
|
75 | 76 | |
76 | 77 | msg_send_simple_message($ex_friend_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_unfriend_title'], |
77 | 78 | sprintf($lang['buddy_msg_unfriend_text'], $user['username'])); |
@@ -79,17 +80,19 @@ discard block |
||
79 | 80 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
80 | 81 | sn_db_transaction_commit(); |
81 | 82 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
82 | - } |
|
83 | - elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
83 | + } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
84 | + // Player's outcoming request - either denied or waiting |
|
84 | 85 | { |
85 | 86 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
87 | + } |
|
86 | 88 | sn_db_transaction_commit(); |
87 | 89 | throw new exception('buddy_err_delete_own', ERR_NONE); |
88 | - } |
|
89 | - elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
90 | + } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) { |
|
91 | + // Deny incoming request |
|
90 | 92 | { |
91 | 93 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
92 | 94 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
95 | + } |
|
93 | 96 | |
94 | 97 | doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_DENIED . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
95 | 98 | sn_db_transaction_commit(); |
@@ -104,8 +107,7 @@ discard block |
||
104 | 107 | if($new_friend_id = sys_get_param_id('request_user_id')) |
105 | 108 | { |
106 | 109 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
107 | - } |
|
108 | - elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
110 | + } elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
109 | 111 | { |
110 | 112 | $new_friend_row = db_user_by_username($new_friend_name); |
111 | 113 | $new_friend_name = db_escape($new_friend_name); |
@@ -138,8 +140,7 @@ discard block |
||
138 | 140 | sn_db_transaction_commit(); |
139 | 141 | throw new exception('buddy_err_adding_none', ERR_NONE); |
140 | 142 | } |
141 | -} |
|
142 | -catch(exception $e) |
|
143 | +} catch(exception $e) |
|
143 | 144 | { |
144 | 145 | $result[] = array( |
145 | 146 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -18,39 +18,39 @@ discard block |
||
18 | 18 | { |
19 | 19 | sn_db_transaction_start(); |
20 | 20 | |
21 | - if($buddy_id = sys_get_param_id('buddy_id')) |
|
21 | + if ($buddy_id = sys_get_param_id('buddy_id')) |
|
22 | 22 | { |
23 | 23 | $buddy_row = doquery("SELECT BUDDY_SENDER_ID, BUDDY_OWNER_ID, BUDDY_STATUS FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1 FOR UPDATE;", true); |
24 | - if(!is_array($buddy_row)) |
|
24 | + if (!is_array($buddy_row)) |
|
25 | 25 | { |
26 | 26 | throw new exception('buddy_err_not_exist', ERR_ERROR); |
27 | 27 | } |
28 | 28 | |
29 | - switch($mode = sys_get_param_str('mode')) |
|
29 | + switch ($mode = sys_get_param_str('mode')) |
|
30 | 30 | { |
31 | 31 | case 'accept': |
32 | - if($buddy_row['BUDDY_SENDER_ID'] == $user['id']) |
|
32 | + if ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) |
|
33 | 33 | { |
34 | 34 | throw new exception('buddy_err_accept_own', ERR_ERROR); |
35 | 35 | } |
36 | 36 | |
37 | - if($buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
37 | + if ($buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
38 | 38 | { |
39 | 39 | throw new exception('buddy_err_accept_alien', ERR_ERROR); |
40 | 40 | } |
41 | 41 | |
42 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) |
|
42 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) |
|
43 | 43 | { |
44 | 44 | throw new exception('buddy_err_accept_already', ERR_WARNING); |
45 | 45 | } |
46 | 46 | |
47 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) |
|
47 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) |
|
48 | 48 | { |
49 | 49 | throw new exception('buddy_err_accept_denied', ERR_ERROR); |
50 | 50 | } |
51 | 51 | |
52 | 52 | doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_ACTIVE . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
53 | - if(SN::$db->db_affected_rows()) |
|
53 | + if (SN::$db->db_affected_rows()) |
|
54 | 54 | { |
55 | 55 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_accept_title'], |
56 | 56 | sprintf($lang['buddy_msg_accept_text'], $user['username'])); |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | break; |
65 | 65 | |
66 | 66 | case 'delete': |
67 | - if($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
67 | + if ($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
68 | 68 | { |
69 | 69 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
70 | 70 | } |
71 | 71 | |
72 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
72 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
73 | 73 | { |
74 | 74 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
75 | 75 | |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | sn_db_transaction_commit(); |
81 | 81 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
82 | 82 | } |
83 | - elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
83 | + elseif ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
84 | 84 | { |
85 | 85 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
86 | 86 | sn_db_transaction_commit(); |
87 | 87 | throw new exception('buddy_err_delete_own', ERR_NONE); |
88 | 88 | } |
89 | - elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
89 | + elseif ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
90 | 90 | { |
91 | 91 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
92 | 92 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
@@ -101,24 +101,24 @@ discard block |
||
101 | 101 | |
102 | 102 | // New request? |
103 | 103 | // Checking for user ID - in case if it was request from outside buddy system |
104 | - if($new_friend_id = sys_get_param_id('request_user_id')) |
|
104 | + if ($new_friend_id = sys_get_param_id('request_user_id')) |
|
105 | 105 | { |
106 | 106 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
107 | 107 | } |
108 | - elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
108 | + elseif ($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
109 | 109 | { |
110 | 110 | $new_friend_row = db_user_by_username($new_friend_name); |
111 | 111 | $new_friend_name = db_escape($new_friend_name); |
112 | 112 | } |
113 | 113 | |
114 | - if($new_friend_row['id'] == $user['id']) |
|
114 | + if ($new_friend_row['id'] == $user['id']) |
|
115 | 115 | { |
116 | 116 | unset($new_friend_row); |
117 | 117 | throw new exception('buddy_err_adding_self', ERR_ERROR); |
118 | 118 | } |
119 | 119 | |
120 | 120 | // Checking for user name & request text - in case if it was request to adding new request |
121 | - if(isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) |
|
121 | + if (isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) |
|
122 | 122 | { |
123 | 123 | $check_relation = doquery("SELECT `BUDDY_ID` FROM {{buddy}} WHERE |
124 | 124 | (`BUDDY_SENDER_ID` = {$user['id']} AND `BUDDY_OWNER_ID` = {$new_friend_row['id']}) |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | (`BUDDY_SENDER_ID` = {$new_friend_row['id']} AND `BUDDY_OWNER_ID` = {$user['id']}) |
127 | 127 | LIMIT 1 FOR UPDATE;" |
128 | 128 | , true); |
129 | - if(isset($check_relation['BUDDY_ID'])) |
|
129 | + if (isset($check_relation['BUDDY_ID'])) |
|
130 | 130 | { |
131 | 131 | throw new exception('buddy_err_adding_exists', ERR_WARNING); |
132 | 132 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | throw new exception('buddy_err_adding_none', ERR_NONE); |
140 | 140 | } |
141 | 141 | } |
142 | -catch(exception $e) |
|
142 | +catch (exception $e) |
|
143 | 143 | { |
144 | 144 | $result[] = array( |
145 | 145 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | sn_db_transaction_rollback(); |
151 | 151 | |
152 | 152 | $query = db_buddy_list_by_user($user['id']); |
153 | -while($row = db_fetch($query)) |
|
153 | +while ($row = db_fetch($query)) |
|
154 | 154 | { |
155 | 155 | $row['BUDDY_REQUEST'] = HelperString::nl2br($row['BUDDY_REQUEST']); |
156 | 156 |
@@ -18,13 +18,13 @@ discard block |
||
18 | 18 | |
19 | 19 | messageBoxAdminAccessDenied(AUTH_LEVEL_ADMINISTRATOR); |
20 | 20 | |
21 | -$template = gettemplate('admin/adm_payment', true); |
|
21 | +$template = gettemplate('admin/adm_payment', true); |
|
22 | 22 | |
23 | 23 | $payer_list = array( |
24 | 24 | -1 => $lang['adm_pay_filter_all'], |
25 | 25 | ); |
26 | 26 | $query = doquery("SELECT payment_user_id, payment_user_name FROM `{{payment}}` GROUP BY payment_user_id ORDER BY payment_user_name"); |
27 | -while($row = db_fetch($query)) { |
|
27 | +while ($row = db_fetch($query)) { |
|
28 | 28 | $payer_list[$row['payment_user_id']] = '[' . $row['payment_user_id'] . '] ' . $row['payment_user_name']; |
29 | 29 | } |
30 | 30 | tpl_assign_select($template, 'payer', $payer_list); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | '' => $lang['adm_pay_filter_all'], |
34 | 34 | ); |
35 | 35 | $query = doquery("SELECT distinct payment_module_name FROM `{{payment}}` ORDER BY payment_module_name"); |
36 | -while($row = db_fetch($query)) { |
|
36 | +while ($row = db_fetch($query)) { |
|
37 | 37 | $module_list[$row['payment_module_name']] = $row['payment_module_name']; |
38 | 38 | } |
39 | 39 | tpl_assign_select($template, 'module', $module_list); |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | |
70 | 70 | |
71 | 71 | //while($row = db_fetch($query)) { |
72 | -foreach($query as $row) { |
|
72 | +foreach ($query as $row) { |
|
73 | 73 | $row2 = array(); |
74 | - foreach($row as $key => $value) { |
|
74 | + foreach ($row as $key => $value) { |
|
75 | 75 | $row2[strtoupper($key)] = $value; |
76 | 76 | } |
77 | 77 | $template->assign_block_vars('payment', $row2); |
@@ -114,7 +114,7 @@ |
||
114 | 114 | $this->addFirstLast(); |
115 | 115 | } |
116 | 116 | |
117 | - if(!empty($this->result)) { |
|
117 | + if (!empty($this->result)) { |
|
118 | 118 | $template = gettemplate('_paging'); |
119 | 119 | $template->assign_recursive([ |
120 | 120 | 'PAGING_ROOT' => $this->rootUrl, |
@@ -19,7 +19,7 @@ |
||
19 | 19 | } |
20 | 20 | } |
21 | 21 | |
22 | - if(!empty($paramList)) { |
|
22 | + if (!empty($paramList)) { |
|
23 | 23 | $strParams = implode('&', $paramList); |
24 | 24 | } |
25 | 25 |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | ORDER BY `message_time` DESC;"; |
329 | 329 | } |
330 | 330 | |
331 | - if($this->showAll) { |
|
331 | + if ($this->showAll) { |
|
332 | 332 | $message_query = $this->db->selectIterator($message_query); |
333 | 333 | } else { |
334 | 334 | $message_query = new DbSqlPaging($message_query, PAGING_PAGE_SIZE_DEFAULT_MESSAGES, sys_get_param_int(PagingRenderer::KEYWORD)); |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | $this->mode = sys_get_param_str('msg_delete') ? static::MESSAGES_MODE_DELETE : sys_get_param_str('mode'); |
484 | 484 | } |
485 | 485 | |
486 | - if($this->showAll = sys_get_param_str('msg_show_all') ? true : false) { |
|
486 | + if ($this->showAll = sys_get_param_str('msg_show_all') ? true : false) { |
|
487 | 487 | $this->mode = static::MESSAGES_MODE_MESSAGES; |
488 | 488 | } |
489 | 489 |
@@ -46,7 +46,7 @@ |
||
46 | 46 | * @return bool |
47 | 47 | */ |
48 | 48 | public function changeTitle(AllianceTitle $title) { |
49 | - if(!$title instanceof AllianceTitle) { |
|
49 | + if (!$title instanceof AllianceTitle) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | continue; |
46 | 46 | } |
47 | 47 | |
48 | - $result[] = (string)$title; |
|
48 | + $result[] = (string) $title; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return implode(';', $result); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * Updates title names and access rights with current ones |
68 | 68 | */ |
69 | 69 | public function updateTitles() { |
70 | - $this->alliance->titleList = (string)$this; |
|
70 | + $this->alliance->titleList = (string) $this; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function extractTitles() { |