@@ -1,52 +1,52 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function dump($value,$varname = "",$level=0,$dumper = "") |
|
3 | +function dump($value, $varname = "", $level = 0, $dumper = "") |
|
4 | 4 | { |
5 | 5 | if ($varname) $varname .= " = "; |
6 | 6 | |
7 | - if ($level==-1) |
|
7 | + if ($level == -1) |
|
8 | 8 | { |
9 | - $trans[' ']='∴'; |
|
10 | - $trans["\t"]='⇒'; |
|
11 | - $trans["\n"]='¶;'; |
|
12 | - $trans["\r"]='⇐'; |
|
13 | - $trans["\0"]='⊕'; |
|
14 | - return strtr(htmlspecialchars($value),$trans); |
|
9 | + $trans[' '] = '∴'; |
|
10 | + $trans["\t"] = '⇒'; |
|
11 | + $trans["\n"] = '¶;'; |
|
12 | + $trans["\r"] = '⇐'; |
|
13 | + $trans["\0"] = '⊕'; |
|
14 | + return strtr(htmlspecialchars($value), $trans); |
|
15 | 15 | } |
16 | - if ($level==0) $dumper = '<pre>' . $varname; |
|
16 | + if ($level == 0) $dumper = '<pre>' . $varname; |
|
17 | 17 | |
18 | 18 | $type = gettype($value); |
19 | 19 | $dumper .= $type; |
20 | 20 | |
21 | - if ($type=='string') |
|
21 | + if ($type == 'string') |
|
22 | 22 | { |
23 | - $dumper .= '('.strlen($value).')'; |
|
24 | - $value = dump($value,"",-1); |
|
23 | + $dumper .= '(' . strlen($value) . ')'; |
|
24 | + $value = dump($value, "", -1); |
|
25 | 25 | } |
26 | - elseif ($type=='boolean') $value= ($value?'true':'false'); |
|
27 | - elseif ($type=='object') |
|
26 | + elseif ($type == 'boolean') $value = ($value ? 'true' : 'false'); |
|
27 | + elseif ($type == 'object') |
|
28 | 28 | { |
29 | - $props= get_class_vars(get_class($value)); |
|
30 | - $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
|
31 | - foreach($props as $key=>$val) |
|
29 | + $props = get_class_vars(get_class($value)); |
|
30 | + $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
|
31 | + foreach ($props as $key=>$val) |
|
32 | 32 | { |
33 | - $dumper .= "\n".str_repeat("\t",$level+1).$key.' => '; |
|
34 | - $dumper .= dump($value->$key,"",$level+1); |
|
33 | + $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
|
34 | + $dumper .= dump($value->$key, "", $level + 1); |
|
35 | 35 | } |
36 | - $value= ''; |
|
36 | + $value = ''; |
|
37 | 37 | } |
38 | - elseif ($type=='array') |
|
38 | + elseif ($type == 'array') |
|
39 | 39 | { |
40 | - $dumper .= '('.count($value).')'; |
|
41 | - foreach($value as $key=>$val) |
|
40 | + $dumper .= '(' . count($value) . ')'; |
|
41 | + foreach ($value as $key=>$val) |
|
42 | 42 | { |
43 | - $dumper .= "\n".str_repeat("\t",$level+1).dump($key,"",-1).' => '; |
|
44 | - $dumper .= dump($val,"",$level+1); |
|
43 | + $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, "", -1) . ' => '; |
|
44 | + $dumper .= dump($val, "", $level + 1); |
|
45 | 45 | } |
46 | - $value= ''; |
|
46 | + $value = ''; |
|
47 | 47 | } |
48 | 48 | $dumper .= " <b>$value</b>"; |
49 | - if ($level==0) $dumper .= '</pre>'; |
|
49 | + if ($level == 0) $dumper .= '</pre>'; |
|
50 | 50 | return $dumper; |
51 | 51 | } |
52 | 52 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $output_buffer .= $string; |
68 | 68 | } |
69 | 69 | |
70 | -if(substr(getcwd(), -4) != 'docs') |
|
70 | +if (substr(getcwd(), -4) != 'docs') |
|
71 | 71 | { |
72 | 72 | $path_prefix = 'docs/'; |
73 | 73 | } |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | |
81 | 81 | $filename = 'changelog'; |
82 | 82 | |
83 | -$input = file_get_contents($path_prefix . $filename . '.txt'); |
|
83 | +$input = file_get_contents($path_prefix . $filename . '.txt'); |
|
84 | 84 | //$input = iconv('CP1251', 'UTF-8', $input); |
85 | 85 | |
86 | 86 | $input = preg_replace("/\r\n\d\d\d\d\-\d\d\-\d\d\ \d\d\:\d\d/", "[D] $0", $input); |
87 | 87 | |
88 | -while(strpos($input, "\r\n\r\n") !== false) |
|
88 | +while (strpos($input, "\r\n\r\n") !== false) |
|
89 | 89 | { |
90 | 90 | $input = str_replace("\r\n\r\n", "\r\n", $input); |
91 | 91 | } |
92 | -while(strpos($input, "~~~") !== false) |
|
92 | +while (strpos($input, "~~~") !== false) |
|
93 | 93 | { |
94 | 94 | $input = str_replace("~~~", "~~", $input); |
95 | 95 | } |
96 | 96 | $input = str_replace("\r\n~~", "~~", $input); |
97 | 97 | |
98 | -while(strpos($input, "===") !== false) |
|
98 | +while (strpos($input, "===") !== false) |
|
99 | 99 | { |
100 | 100 | $input = str_replace("===", "==", $input); |
101 | 101 | } |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | $prev_chapter_is_header = false; |
107 | 107 | $output = array(); |
108 | 108 | $buffer = array(); |
109 | -foreach($input as &$chapter) |
|
109 | +foreach ($input as &$chapter) |
|
110 | 110 | { |
111 | 111 | $chapter = preg_split("/(\r\n[\[])/", $chapter, -1, PREG_SPLIT_NO_EMPTY); // , PREG_SPLIT_DELIM_CAPTURE |
112 | 112 | |
113 | - if(count($chapter) == 1 && !$prev_chapter_is_header) |
|
113 | + if (count($chapter) == 1 && !$prev_chapter_is_header) |
|
114 | 114 | { |
115 | - if(!empty($chapter)) |
|
115 | + if (!empty($chapter)) |
|
116 | 116 | { |
117 | 117 | $output[] = $buffer; |
118 | 118 | $buffer = array(); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | else |
124 | 124 | { |
125 | 125 | $prev_chapter_is_header = false; |
126 | - foreach($chapter as &$note) |
|
126 | + foreach ($chapter as &$note) |
|
127 | 127 | { |
128 | 128 | $note = explode("\r\n", $note); |
129 | 129 | $new_note = true; |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | |
132 | 132 | $note_out = array(); |
133 | 133 | |
134 | - foreach($note as &$line) |
|
134 | + foreach ($note as &$line) |
|
135 | 135 | { |
136 | - if(!$line) |
|
136 | + if (!$line) |
|
137 | 137 | { |
138 | 138 | continue; |
139 | 139 | } |
140 | - if($new_note) |
|
140 | + if ($new_note) |
|
141 | 141 | { |
142 | 142 | // 78 - 3 = 75 |
143 | 143 | $note_out['style'] = $line[0]; |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | $buf_str .= $line; |
148 | - if(mb_strlen($line, 'utf-8') < ($new_note ? 75 : 79)) |
|
148 | + if (mb_strlen($line, 'utf-8') < ($new_note ? 75 : 79)) |
|
149 | 149 | { |
150 | - if(!isset($note_out['name'])) |
|
150 | + if (!isset($note_out['name'])) |
|
151 | 151 | { |
152 | 152 | $note_out['name'] = $buf_str; |
153 | 153 | } |
@@ -201,31 +201,31 @@ discard block |
||
201 | 201 | 'D' => 'date', |
202 | 202 | ); |
203 | 203 | |
204 | -foreach($output as $chapter) |
|
204 | +foreach ($output as $chapter) |
|
205 | 205 | { |
206 | - if(!$chapter) |
|
206 | + if (!$chapter) |
|
207 | 207 | { |
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | |
211 | 211 | buf_print("<h1>{$chapter['name']}</h1>\r\n"); |
212 | - foreach($chapter['content'] as $block) |
|
212 | + foreach ($chapter['content'] as $block) |
|
213 | 213 | { |
214 | 214 | buf_print("<div class=\"{$styles[$block['style']]}\">" . ($block['style'] != 'D' ? "[{$block['style']}] " : '')); |
215 | 215 | buf_print(preg_replace("/\s{2,10}/", " ", $block['name']) . '<br />'); |
216 | - if(isset($block['lines'])) |
|
216 | + if (isset($block['lines'])) |
|
217 | 217 | { |
218 | 218 | $last_spaces = ''; |
219 | 219 | $depth = array(); |
220 | - foreach($block['lines'] as $line) |
|
220 | + foreach ($block['lines'] as $line) |
|
221 | 221 | { |
222 | - if(preg_match("/^(\s+)(\d*|\s)\.*\s*(.*)/", $line, $matches)) |
|
222 | + if (preg_match("/^(\s+)(\d*|\s)\.*\s*(.*)/", $line, $matches)) |
|
223 | 223 | { |
224 | 224 | //$line = strlen($matches[1]) . '/' . $matches[2] . '/' . $matches[3]; |
225 | 225 | $line = $matches[3]; |
226 | - if(strlen($matches[1]) > strlen($last_spaces)) |
|
226 | + if (strlen($matches[1]) > strlen($last_spaces)) |
|
227 | 227 | { |
228 | - if($matches[2]) |
|
228 | + if ($matches[2]) |
|
229 | 229 | { |
230 | 230 | buf_print("<ol>\r\n"); |
231 | 231 | } |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | $last_spaces = $matches[1]; |
238 | 238 | $depth[] = $matches[2]; |
239 | 239 | } |
240 | - elseif(strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
|
240 | + elseif (strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
|
241 | 241 | { |
242 | - if(array_pop($depth)) |
|
242 | + if (array_pop($depth)) |
|
243 | 243 | { |
244 | 244 | buf_print("</ol>\r\n"); |
245 | 245 | } |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | $last_spaces = $matches[1]; |
251 | 251 | buf_print('<li>'); |
252 | 252 | } |
253 | - elseif(strlen($last_spaces) == strlen($matches[1])) |
|
253 | + elseif (strlen($last_spaces) == strlen($matches[1])) |
|
254 | 254 | { |
255 | - if($matches[2] == '' && $depth[count($depth) - 1] != '') |
|
255 | + if ($matches[2] == '' && $depth[count($depth) - 1] != '') |
|
256 | 256 | { |
257 | 257 | buf_print("</ol>\r\n"); |
258 | 258 | buf_print("<ul>\r\n"); |
259 | 259 | } |
260 | - elseif($matches[2] != '' && $depth[count($depth) - 1] == '') |
|
260 | + elseif ($matches[2] != '' && $depth[count($depth) - 1] == '') |
|
261 | 261 | { |
262 | 262 | buf_print("</ul>\r\n"); |
263 | 263 | buf_print("<ol>\r\n"); |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | $line = preg_replace("/\s{2,10}/", " ", $line); |
270 | 270 | buf_print($line . "<br />\r\n"); |
271 | 271 | } |
272 | - while(count($depth)) |
|
272 | + while (count($depth)) |
|
273 | 273 | { |
274 | - if(array_pop($depth)) |
|
274 | + if (array_pop($depth)) |
|
275 | 275 | { |
276 | 276 | buf_print("</ol>\r\n"); |
277 | 277 | } |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | buf_print("</body>\r\n</html>\r\n"); |
288 | 288 | |
289 | 289 | $html = file_get_contents($path_prefix . 'html/' . $filename . '.html'); |
290 | -if($html != $output_buffer) |
|
290 | +if ($html != $output_buffer) |
|
291 | 291 | { |
292 | 292 | file_put_contents($path_prefix . 'html/' . $filename . '.html', $output_buffer); |
293 | - if(!$path_prefix) |
|
293 | + if (!$path_prefix) |
|
294 | 294 | { |
295 | 295 | print($output_buffer); |
296 | 296 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
13 | 13 | |
14 | -if(HIDE_BUILDING_RECORDS) |
|
14 | +if (HIDE_BUILDING_RECORDS) |
|
15 | 15 | { |
16 | 16 | return; |
17 | 17 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | $user_name_cache = array(); |
36 | 36 | |
37 | -foreach($show_groups as $unit_group_id => $mode) |
|
37 | +foreach ($show_groups as $unit_group_id => $mode) |
|
38 | 38 | { |
39 | 39 | $template->assign_block_vars('records', array( |
40 | 40 | 'UNIT' => $lang['tech'][$unit_group_id], |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | )); |
44 | 44 | $unit_group = get_unit_param('techtree', $unit_group_id); // TODO - REWRITE!!!! |
45 | 45 | |
46 | - foreach($unit_group as $unit_id) |
|
46 | + foreach ($unit_group as $unit_id) |
|
47 | 47 | { |
48 | 48 | $unit_name = &$lang['tech'][$unit_id]; |
49 | - if($unit_name) |
|
49 | + if ($unit_name) |
|
50 | 50 | { |
51 | 51 | // TODO - ISUNITSTACKABLE! |
52 | 52 | $data_row = $unit_group_id == UNIT_SHIPS || $unit_group_id == UNIT_DEFENCE ? db_unit_records_sum($unit_id, $user_skip_list_unit) : db_unit_records_plain($unit_id, $user_skip_list_unit); |
53 | 53 | |
54 | - if($data_row) |
|
54 | + if ($data_row) |
|
55 | 55 | { |
56 | 56 | $template->assign_block_vars('records', array( |
57 | 57 | 'UNIT' => $unit_name, |
@@ -951,7 +951,7 @@ |
||
951 | 951 | REGISTER_ERROR_USERNAME_WRONG => 'Wrong player name', |
952 | 952 | REGISTER_ERROR_ACCOUNT_NAME_EXISTS => 'Account name already registered', |
953 | 953 | REGISTER_ERROR_PASSWORD_INSECURE => 'Insecure or wrong password. Password should be at least ' . PASSWORD_LENGTH_MIN . ' characters long and cannot start or end with spaces', |
954 | - REGISTER_ERROR_USERNAME_SHORT => 'Слишком короткое имя. Имя должно состоять минимум из ' . LOGIN_LENGTH_MIN. ' символов', |
|
954 | + REGISTER_ERROR_USERNAME_SHORT => 'Слишком короткое имя. Имя должно состоять минимум из ' . LOGIN_LENGTH_MIN . ' символов', |
|
955 | 955 | REGISTER_ERROR_PASSWORD_DIFFERENT => 'Password does not match confirmation password', |
956 | 956 | REGISTER_ERROR_EMAIL_EMPTY => 'Е-Мейл не может быть пустым', |
957 | 957 | REGISTER_ERROR_EMAIL_WRONG => 'Введенный Е-Мейл не является адресом электронной почты', |
@@ -961,7 +961,7 @@ |
||
961 | 961 | REGISTER_ERROR_USERNAME_WRONG => 'Некорректное имя игрока', |
962 | 962 | REGISTER_ERROR_ACCOUNT_NAME_EXISTS => 'Имя учётной записи уже занято. Попробуйте войти с этим именем и вашим паролем или воспользоваться сбросом пароля', |
963 | 963 | REGISTER_ERROR_PASSWORD_INSECURE => 'Неправильный пароль. Пароль должен состоять минимум из ' . PASSWORD_LENGTH_MIN . ' символов', |
964 | - REGISTER_ERROR_USERNAME_SHORT => 'Слишком короткое имя. Имя должно состоять минимум из ' . LOGIN_LENGTH_MIN. ' символов', |
|
964 | + REGISTER_ERROR_USERNAME_SHORT => 'Слишком короткое имя. Имя должно состоять минимум из ' . LOGIN_LENGTH_MIN . ' символов', |
|
965 | 965 | REGISTER_ERROR_PASSWORD_DIFFERENT => 'Пароль и проверочный пароль не совпадают. Проверьте правильность ввода', |
966 | 966 | REGISTER_ERROR_EMAIL_EMPTY => 'Е-Мейл не может быть пустым', |
967 | 967 | REGISTER_ERROR_EMAIL_WRONG => 'Введенный Е-Мейл не является допустимым адресом электронной почты. Проверьте написание Е-Мейла или используйте другой адрес почтового ящика', |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
4 | 4 | |
5 | -if(sn_module_get_active_count('payment') && !defined('SN_GOOGLE')) { |
|
5 | +if (sn_module_get_active_count('payment') && !defined('SN_GOOGLE')) { |
|
6 | 6 | sys_redirect('metamatter.php'); |
7 | 7 | } |
8 | 8 |
@@ -24,11 +24,11 @@ |
||
24 | 24 | |
25 | 25 | // require_once('includes/includes/scheduler_process.php'); |
26 | 26 | |
27 | -if(($result = scheduler_process()) && !defined('IN_ADMIN')) { |
|
27 | +if (($result = scheduler_process()) && !defined('IN_ADMIN')) { |
|
28 | 28 | $result = htmlspecialchars($result, ENT_QUOTES, 'UTF-8'); |
29 | 29 | print(json_encode($result)); |
30 | 30 | } |
31 | 31 | |
32 | -if(!defined('IN_ADMIN')) { |
|
32 | +if (!defined('IN_ADMIN')) { |
|
33 | 33 | die(); |
34 | 34 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $mode = sys_get_param_str('msg_delete') ? 'delete' : sys_get_param_str('mode'); |
44 | 44 | $current_class = sys_get_param_int('message_class'); |
45 | -if(!isset($sn_message_class_list[$current_class])) { |
|
45 | +if (!isset($sn_message_class_list[$current_class])) { |
|
46 | 46 | $current_class = 0; |
47 | 47 | $mode = ''; |
48 | 48 | } |
@@ -53,48 +53,48 @@ discard block |
||
53 | 53 | $template = gettemplate('msg_message_compose', true); |
54 | 54 | |
55 | 55 | $recipient_name = sys_get_param_str_unsafe('recipient_name'); |
56 | - if($recipient_name) { |
|
56 | + if ($recipient_name) { |
|
57 | 57 | $recipient_row = db_user_by_username($recipient_name); |
58 | 58 | } |
59 | 59 | |
60 | - if(!$recipient_row) { |
|
60 | + if (!$recipient_row) { |
|
61 | 61 | $recipient_id = sys_get_param_id('id'); |
62 | 62 | $recipient_row = db_user_by_id($recipient_id); |
63 | - if(!$recipient_row) { |
|
63 | + if (!$recipient_row) { |
|
64 | 64 | $recipient_id = 0; |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - if($recipient_row) { |
|
68 | + if ($recipient_row) { |
|
69 | 69 | $recipient_id = $recipient_row['id']; |
70 | 70 | $recipient_name = $recipient_row['username']; |
71 | 71 | } |
72 | 72 | |
73 | - if($recipient_id == $user['id']) { |
|
73 | + if ($recipient_id == $user['id']) { |
|
74 | 74 | $error_list[] = array('MESSAGE' => $lang['msg_err_self_send'], 'STATUS' => ERR_ERROR); |
75 | 75 | } |
76 | 76 | |
77 | 77 | $re = 0; |
78 | 78 | $subject = sys_get_param_str('subject'); |
79 | - while(strpos($subject, $lang['msg_answer_prefix']) !== false) { |
|
79 | + while (strpos($subject, $lang['msg_answer_prefix']) !== false) { |
|
80 | 80 | $subject = substr($subject, strlen($lang['msg_answer_prefix'])); |
81 | 81 | $re++; |
82 | 82 | } |
83 | 83 | $re ? $subject = $lang['msg_answer_prefix'] . $subject : false; |
84 | 84 | |
85 | - if(sys_get_param_str('msg_send')) { |
|
85 | + if (sys_get_param_str('msg_send')) { |
|
86 | 86 | $subject = $subject ? $subject : $lang['msg_subject_default']; |
87 | 87 | |
88 | - if(!$recipient_id) { |
|
88 | + if (!$recipient_id) { |
|
89 | 89 | $error_list[] = array('MESSAGE' => $lang['msg_err_player_not_found'], 'STATUS' => ERR_ERROR); |
90 | 90 | } |
91 | 91 | |
92 | 92 | $text = sys_get_param_str('text'); |
93 | - if(!$text) { |
|
93 | + if (!$text) { |
|
94 | 94 | $error_list[] = array('MESSAGE' => $lang['msg_err_no_text'], 'STATUS' => ERR_ERROR); |
95 | 95 | } |
96 | 96 | |
97 | - if(empty($error_list)) { |
|
97 | + if (empty($error_list)) { |
|
98 | 98 | $error_list[] = array('MESSAGE' => $lang['msg_not_message_sent'], 'STATUS' => ERR_NONE); |
99 | 99 | |
100 | 100 | $user_safe_name = db_escape($user['username']); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | //$recipient_id = 0; |
105 | 105 | //$recipient_name = ''; |
106 | 106 | //$subject = ''; |
107 | - $text = ''; |
|
107 | + $text = ''; |
|
108 | 108 | |
109 | 109 | $msg_sent = true; |
110 | 110 | } else { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | 'TEXT' => htmlspecialchars($text), |
124 | 124 | )); |
125 | 125 | |
126 | - foreach($error_list as $error_message) { |
|
126 | + foreach ($error_list as $error_message) { |
|
127 | 127 | $template->assign_block_vars('result', $error_message); |
128 | 128 | } |
129 | 129 | |
@@ -153,25 +153,25 @@ discard block |
||
153 | 153 | |
154 | 154 | $message_range = sys_get_param_str('message_range'); |
155 | 155 | |
156 | - switch($message_range) { |
|
156 | + switch ($message_range) { |
|
157 | 157 | case 'unchecked': |
158 | 158 | case 'checked': |
159 | 159 | $marked_message_list = sys_get_param('mark', array()); |
160 | - if($message_range == 'checked' && empty($marked_message_list)) { |
|
160 | + if ($message_range == 'checked' && empty($marked_message_list)) { |
|
161 | 161 | break; |
162 | 162 | } |
163 | 163 | |
164 | 164 | $query_add = implode(',', $marked_message_list); |
165 | - if($query_add) { |
|
165 | + if ($query_add) { |
|
166 | 166 | $query_add = "IN ({$query_add})"; |
167 | - if($message_range == 'unchecked') { |
|
167 | + if ($message_range == 'unchecked') { |
|
168 | 168 | $query_add = "NOT {$query_add}"; |
169 | 169 | } |
170 | 170 | $query_add = " AND `message_id` {$query_add}"; |
171 | 171 | } |
172 | 172 | |
173 | 173 | case 'class': |
174 | - if($current_class != MSG_TYPE_OUTBOX && $current_class != MSG_TYPE_NEW) { |
|
174 | + if ($current_class != MSG_TYPE_OUTBOX && $current_class != MSG_TYPE_NEW) { |
|
175 | 175 | $query_add .= " AND `message_type` = {$current_class}"; |
176 | 176 | } |
177 | 177 | case 'all': |
@@ -179,19 +179,19 @@ discard block |
||
179 | 179 | break; |
180 | 180 | } |
181 | 181 | |
182 | - if($query_add) { |
|
182 | + if ($query_add) { |
|
183 | 183 | $query_add = $query_add === true ? '' : $query_add; |
184 | 184 | doquery("DELETE FROM `{{messages}}` WHERE `message_owner` = '{$user['id']}'{$query_add};"); |
185 | 185 | } |
186 | 186 | |
187 | 187 | case 'show': |
188 | - if($current_class == MSG_TYPE_OUTBOX) { |
|
188 | + if ($current_class == MSG_TYPE_OUTBOX) { |
|
189 | 189 | $message_query = db_message_list_outbox_by_user_id($user['id']); |
190 | 190 | } else { |
191 | 191 | if ($current_class == MSG_TYPE_NEW) { |
192 | 192 | $SubUpdateQry = array(); |
193 | - foreach($sn_message_class_list as $message_class_id => $message_class) { |
|
194 | - if($message_class_id != MSG_TYPE_OUTBOX) { |
|
193 | + foreach ($sn_message_class_list as $message_class_id => $message_class) { |
|
194 | + if ($message_class_id != MSG_TYPE_OUTBOX) { |
|
195 | 195 | $SubUpdateQry[] = "`{$message_class['name']}` = '0'"; |
196 | 196 | $user[$message_class['name']] = 0; |
197 | 197 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $message_query = doquery($message_query); |
211 | 211 | } |
212 | 212 | |
213 | - if(sys_get_param_int('return')) { |
|
213 | + if (sys_get_param_int('return')) { |
|
214 | 214 | header('Location: messages.php'); |
215 | 215 | die(); |
216 | 216 | } |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | break; |
240 | 240 | } |
241 | 241 | |
242 | -if(!$template) { |
|
242 | +if (!$template) { |
|
243 | 243 | $template = gettemplate('msg_message_class', true); |
244 | 244 | |
245 | 245 | $query = doquery("SELECT message_owner, message_type, COUNT(message_owner) AS message_count FROM {{messages}} WHERE `message_owner` = {$user['id']} GROUP BY message_owner, message_type ORDER BY message_owner ASC, message_type;"); |
246 | - while($message_row = db_fetch($query)) { |
|
246 | + while ($message_row = db_fetch($query)) { |
|
247 | 247 | $messages_total[$message_row['message_type']] = $message_row['message_count']; |
248 | 248 | $messages_total[MSG_TYPE_NEW] += $message_row['message_count']; |
249 | 249 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $query = doquery("SELECT COUNT(message_sender) AS message_count FROM {{messages}} WHERE `message_sender` = '{$user['id']}' AND message_type = 1 GROUP BY message_sender;", '', true); |
252 | 252 | $messages_total[MSG_TYPE_OUTBOX] = intval($query['message_count']); |
253 | 253 | |
254 | - foreach($sn_message_class_list as $message_class_id => $message_class) { |
|
254 | + foreach ($sn_message_class_list as $message_class_id => $message_class) { |
|
255 | 255 | $template->assign_block_vars('message_class', array( |
256 | 256 | 'ID' => $message_class_id, |
257 | 257 | 'STYLE' => $message_class['name'], |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @copyright 2008-2015 Gorlum for Project "SuperNova.WS" |
6 | 6 | */ |
7 | 7 | |
8 | -if(!defined('INSIDE')) { |
|
8 | +if (!defined('INSIDE')) { |
|
9 | 9 | die(); |
10 | 10 | } |
11 | 11 | |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | function db_change_units_perform($query, $tablename, $object_id) { |
15 | 15 | $query = implode(',', $query); |
16 | - if($query && $object_id) { |
|
16 | + if ($query && $object_id) { |
|
17 | 17 | return classSupernova::db_upd_record_by_id($tablename == 'users' ? LOC_USER : LOC_PLANET, $object_id, $query); |
18 | 18 | // return doquery("UPDATE {{{$tablename}}} SET {$query} WHERE `id` = '{$object_id}' LIMIT 1;"); |
19 | 19 | } |
@@ -30,15 +30,15 @@ discard block |
||
30 | 30 | |
31 | 31 | $group = sn_get_groups('resources_loot'); |
32 | 32 | |
33 | - foreach($unit_list as $unit_id => $unit_amount) { |
|
34 | - if(!in_array($unit_id, $group)) { |
|
33 | + foreach ($unit_list as $unit_id => $unit_amount) { |
|
34 | + if (!in_array($unit_id, $group)) { |
|
35 | 35 | // TODO - remove later |
36 | 36 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_units() вызван для не-ресурсов!</h1>'); |
37 | 37 | pdump(debug_backtrace()); |
38 | 38 | die('db_change_units() вызван для не-ресурсов!'); |
39 | 39 | } |
40 | 40 | |
41 | - if(!$unit_amount) { |
|
41 | + if (!$unit_amount) { |
|
42 | 42 | continue; |
43 | 43 | } |
44 | 44 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $unit_location = sys_get_unit_location($user, $planet, $unit_id); |
48 | 48 | |
49 | 49 | // Changing value in object |
50 | - switch($unit_location) { |
|
50 | + switch ($unit_location) { |
|
51 | 51 | case LOC_USER: |
52 | 52 | $user[$unit_db_name] += $unit_amount; |
53 | 53 | break; |
@@ -69,23 +69,23 @@ discard block |
||
69 | 69 | $field_set = ''; |
70 | 70 | $value_set = ''; |
71 | 71 | |
72 | - switch($type) { |
|
72 | + switch ($type) { |
|
73 | 73 | case 'delete': |
74 | 74 | $query = 'DELETE FROM'; |
75 | 75 | break; |
76 | 76 | |
77 | 77 | case 'insert': |
78 | 78 | $query = 'INSERT INTO'; |
79 | - if(isset($options['__multi'])) { |
|
79 | + if (isset($options['__multi'])) { |
|
80 | 80 | // Here we generate mass-insert set |
81 | 81 | break; |
82 | 82 | } |
83 | 83 | case 'update': |
84 | - if(!$query) { |
|
84 | + if (!$query) { |
|
85 | 85 | $query = 'UPDATE'; |
86 | 86 | } |
87 | 87 | |
88 | - foreach($values as $field => &$value) { |
|
88 | + foreach ($values as $field => &$value) { |
|
89 | 89 | $value_type = gettype($value); |
90 | 90 | if ($value_type == 'string') { |
91 | 91 | $value = "'" . db_escape($value) . "'"; |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | $field_set['__IS_SAFE'] = true; |
114 | 114 | } |
115 | 115 | function sn_db_field_set_make_safe($field_set, $serialize = false) { |
116 | - if(!is_array($field_set)) { |
|
116 | + if (!is_array($field_set)) { |
|
117 | 117 | die('$field_set is not an array!'); |
118 | 118 | } |
119 | 119 | |
120 | 120 | $result = array(); |
121 | - foreach($field_set as $field => $value) { |
|
121 | + foreach ($field_set as $field => $value) { |
|
122 | 122 | $field = db_escape(trim($field)); |
123 | 123 | switch (true) { |
124 | 124 | case is_int($value): |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function geometry_progression_sum($n, $b1, $q) { |
4 | - return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
|
4 | + return $q != 1 ? ($b1 * (pow($q, $n) - 1) / ($q - 1)) : ($n * $b1); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | function sn_floor($value) |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return float|int |
45 | 45 | */ |
46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | - if($cut_extreme) { |
|
46 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | + if ($cut_extreme) { |
|
48 | 48 | $range_start--; |
49 | 49 | $range_end++; |
50 | 50 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | $args = func_get_args(); |
62 | 62 | |
63 | - switch(func_num_args()) |
|
63 | + switch (func_num_args()) |
|
64 | 64 | { |
65 | 65 | case 0: |
66 | 66 | // trigger_error('median() requires at least one parameter',E_USER_WARNING); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | // fallthrough |
73 | 73 | |
74 | 74 | default: |
75 | - if(!is_array($args)) |
|
75 | + if (!is_array($args)) |
|
76 | 76 | { |
77 | 77 | // trigger_error('median() requires a list of numbers to operate on or an array of numbers', E_USER_NOTICE); |
78 | 78 | return false; |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | $n = count($args); |
84 | 84 | $h = intval($n / 2); |
85 | 85 | |
86 | - if($n % 2 == 0) |
|
86 | + if ($n % 2 == 0) |
|
87 | 87 | { |
88 | - $median = ($args[$h] + $args[$h-1]) / 2; |
|
88 | + $median = ($args[$h] + $args[$h - 1]) / 2; |
|
89 | 89 | } |
90 | 90 | else |
91 | 91 | { |
@@ -103,47 +103,47 @@ discard block |
||
103 | 103 | } |
104 | 104 | function linear_calc(&$linear, $from = 0, $debug = false) |
105 | 105 | { |
106 | - for($i = $from; $i < count($linear); $i++) |
|
106 | + for ($i = $from; $i < count($linear); $i++) |
|
107 | 107 | { |
108 | 108 | $eq = &$linear[$i]; |
109 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
109 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
110 | 110 | { |
111 | 111 | $eq[$j] /= $eq[$from]; |
112 | 112 | } |
113 | 113 | } |
114 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
114 | + if ($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
115 | 115 | |
116 | - for($i = $from + 1; $i < count($linear); $i++) |
|
116 | + for ($i = $from + 1; $i < count($linear); $i++) |
|
117 | 117 | { |
118 | 118 | $eq = &$linear[$i]; |
119 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
119 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
120 | 120 | { |
121 | 121 | $eq[$j] -= $linear[$from][$j]; |
122 | 122 | } |
123 | 123 | } |
124 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
124 | + if ($debug) pdump($linear, 'Подставили х' . $from); |
|
125 | 125 | |
126 | - if($from < count($linear) - 1) |
|
126 | + if ($from < count($linear) - 1) |
|
127 | 127 | { |
128 | 128 | linear_calc($linear, $from + 1, $debug); |
129 | 129 | } |
130 | 130 | |
131 | - if($from) |
|
131 | + if ($from) |
|
132 | 132 | { |
133 | - for($i = 0; $i < $from; $i++) |
|
133 | + for ($i = 0; $i < $from; $i++) |
|
134 | 134 | { |
135 | 135 | $eq = &$linear[$i]; |
136 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
136 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
137 | 137 | { |
138 | 138 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
139 | 139 | } |
140 | 140 | } |
141 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
141 | + if ($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
145 | - if($debug) pdump($linear, 'Результат' . $from); |
|
146 | - foreach($linear as $index => &$eq) |
|
145 | + if ($debug) pdump($linear, 'Результат' . $from); |
|
146 | + foreach ($linear as $index => &$eq) |
|
147 | 147 | { |
148 | 148 | pdump($eq[count($linear)], 'x' . $index); |
149 | 149 | } |