@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -165,7 +165,7 @@ |
||
165 | 165 | if($query_add) { |
166 | 166 | $query_add = "IN ({$query_add})"; |
167 | 167 | if($message_range == 'unchecked') { |
168 | - $query_add = "NOT {$query_add}"; |
|
168 | + $query_add = "not {$query_add}"; |
|
169 | 169 | } |
170 | 170 | $query_add = " AND `message_id` {$query_add}"; |
171 | 171 | } |
@@ -48,112 +48,112 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | switch ($mode) { |
51 | - case 'write': |
|
52 | - $error_list = array(); |
|
53 | - $template = gettemplate('msg_message_compose', true); |
|
51 | + case 'write': |
|
52 | + $error_list = array(); |
|
53 | + $template = gettemplate('msg_message_compose', true); |
|
54 | 54 | |
55 | - $recipient_name = sys_get_param_str_unsafe('recipient_name'); |
|
56 | - if($recipient_name) { |
|
57 | - $recipient_row = db_user_by_username($recipient_name); |
|
58 | - } |
|
55 | + $recipient_name = sys_get_param_str_unsafe('recipient_name'); |
|
56 | + if($recipient_name) { |
|
57 | + $recipient_row = db_user_by_username($recipient_name); |
|
58 | + } |
|
59 | 59 | |
60 | - if(!$recipient_row) { |
|
61 | - $recipient_id = sys_get_param_id('id'); |
|
62 | - $recipient_row = db_user_by_id($recipient_id); |
|
63 | 60 | if(!$recipient_row) { |
64 | - $recipient_id = 0; |
|
61 | + $recipient_id = sys_get_param_id('id'); |
|
62 | + $recipient_row = db_user_by_id($recipient_id); |
|
63 | + if(!$recipient_row) { |
|
64 | + $recipient_id = 0; |
|
65 | + } |
|
65 | 66 | } |
66 | - } |
|
67 | 67 | |
68 | - if($recipient_row) { |
|
69 | - $recipient_id = $recipient_row['id']; |
|
70 | - $recipient_name = $recipient_row['username']; |
|
71 | - } |
|
68 | + if($recipient_row) { |
|
69 | + $recipient_id = $recipient_row['id']; |
|
70 | + $recipient_name = $recipient_row['username']; |
|
71 | + } |
|
72 | 72 | |
73 | - if($recipient_id == $user['id']) { |
|
74 | - $error_list[] = array('MESSAGE' => $lang['msg_err_self_send'], 'STATUS' => ERR_ERROR); |
|
75 | - } |
|
73 | + if($recipient_id == $user['id']) { |
|
74 | + $error_list[] = array('MESSAGE' => $lang['msg_err_self_send'], 'STATUS' => ERR_ERROR); |
|
75 | + } |
|
76 | 76 | |
77 | - $re = 0; |
|
78 | - $subject = sys_get_param_str('subject'); |
|
79 | - while(strpos($subject, $lang['msg_answer_prefix']) !== false) { |
|
80 | - $subject = substr($subject, strlen($lang['msg_answer_prefix'])); |
|
81 | - $re++; |
|
82 | - } |
|
83 | - $re ? $subject = $lang['msg_answer_prefix'] . $subject : false; |
|
77 | + $re = 0; |
|
78 | + $subject = sys_get_param_str('subject'); |
|
79 | + while(strpos($subject, $lang['msg_answer_prefix']) !== false) { |
|
80 | + $subject = substr($subject, strlen($lang['msg_answer_prefix'])); |
|
81 | + $re++; |
|
82 | + } |
|
83 | + $re ? $subject = $lang['msg_answer_prefix'] . $subject : false; |
|
84 | 84 | |
85 | - if(sys_get_param_str('msg_send')) { |
|
86 | - $subject = $subject ? $subject : $lang['msg_subject_default']; |
|
85 | + if(sys_get_param_str('msg_send')) { |
|
86 | + $subject = $subject ? $subject : $lang['msg_subject_default']; |
|
87 | 87 | |
88 | - if(!$recipient_id) { |
|
89 | - $error_list[] = array('MESSAGE' => $lang['msg_err_player_not_found'], 'STATUS' => ERR_ERROR); |
|
90 | - } |
|
88 | + if(!$recipient_id) { |
|
89 | + $error_list[] = array('MESSAGE' => $lang['msg_err_player_not_found'], 'STATUS' => ERR_ERROR); |
|
90 | + } |
|
91 | 91 | |
92 | - $text = sys_get_param_str('text'); |
|
93 | - if(!$text) { |
|
94 | - $error_list[] = array('MESSAGE' => $lang['msg_err_no_text'], 'STATUS' => ERR_ERROR); |
|
95 | - } |
|
92 | + $text = sys_get_param_str('text'); |
|
93 | + if(!$text) { |
|
94 | + $error_list[] = array('MESSAGE' => $lang['msg_err_no_text'], 'STATUS' => ERR_ERROR); |
|
95 | + } |
|
96 | 96 | |
97 | - if(empty($error_list)) { |
|
98 | - $error_list[] = array('MESSAGE' => $lang['msg_not_message_sent'], 'STATUS' => ERR_NONE); |
|
97 | + if(empty($error_list)) { |
|
98 | + $error_list[] = array('MESSAGE' => $lang['msg_not_message_sent'], 'STATUS' => ERR_NONE); |
|
99 | 99 | |
100 | - $user_safe_name = db_escape($user['username']); |
|
101 | - $recipient_name = db_escape($recipient_name); |
|
102 | - msg_send_simple_message($recipient_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, "{$user_safe_name} [{$user['galaxy']}:{$user['system']}:{$user['planet']}]", $subject, $text, true); |
|
100 | + $user_safe_name = db_escape($user['username']); |
|
101 | + $recipient_name = db_escape($recipient_name); |
|
102 | + msg_send_simple_message($recipient_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, "{$user_safe_name} [{$user['galaxy']}:{$user['system']}:{$user['planet']}]", $subject, $text, true); |
|
103 | 103 | |
104 | - //$recipient_id = 0; |
|
105 | - //$recipient_name = ''; |
|
106 | - //$subject = ''; |
|
107 | - $text = ''; |
|
104 | + //$recipient_id = 0; |
|
105 | + //$recipient_name = ''; |
|
106 | + //$subject = ''; |
|
107 | + $text = ''; |
|
108 | 108 | |
109 | - $msg_sent = true; |
|
110 | - } else { |
|
111 | - $subject = sys_get_param_str_unsafe('subject'); |
|
112 | - $text = sys_get_param_str_unsafe('text'); |
|
109 | + $msg_sent = true; |
|
110 | + } else { |
|
111 | + $subject = sys_get_param_str_unsafe('subject'); |
|
112 | + $text = sys_get_param_str_unsafe('text'); |
|
113 | + } |
|
114 | + $recipient_name = sys_get_param_str_unsafe('recipient_name'); |
|
113 | 115 | } |
114 | - $recipient_name = sys_get_param_str_unsafe('recipient_name'); |
|
115 | - } |
|
116 | 116 | |
117 | - $subject = $subject ? $subject : $lang['msg_subject_default']; |
|
117 | + $subject = $subject ? $subject : $lang['msg_subject_default']; |
|
118 | 118 | |
119 | - $template->assign_vars(array( |
|
120 | - 'RECIPIENT_ID' => $recipient_id, |
|
121 | - 'RECIPIENT_NAME' => htmlspecialchars($recipient_name), |
|
122 | - 'SUBJECT' => htmlspecialchars($subject), |
|
123 | - 'TEXT' => htmlspecialchars($text), |
|
124 | - )); |
|
119 | + $template->assign_vars(array( |
|
120 | + 'RECIPIENT_ID' => $recipient_id, |
|
121 | + 'RECIPIENT_NAME' => htmlspecialchars($recipient_name), |
|
122 | + 'SUBJECT' => htmlspecialchars($subject), |
|
123 | + 'TEXT' => htmlspecialchars($text), |
|
124 | + )); |
|
125 | 125 | |
126 | - foreach($error_list as $error_message) { |
|
127 | - $template->assign_block_vars('result', $error_message); |
|
128 | - } |
|
126 | + foreach($error_list as $error_message) { |
|
127 | + $template->assign_block_vars('result', $error_message); |
|
128 | + } |
|
129 | 129 | |
130 | - $message_query = doquery( |
|
131 | - "SELECT * FROM {{messages}} |
|
130 | + $message_query = doquery( |
|
131 | + "SELECT * FROM {{messages}} |
|
132 | 132 | WHERE |
133 | 133 | `message_type` = '" . MSG_TYPE_PLAYER . "' AND |
134 | 134 | ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}') |
135 | 135 | OR |
136 | 136 | (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;"); |
137 | - while ($message_row = db_fetch($message_query)) { |
|
138 | - $template->assign_block_vars('messages', array( |
|
139 | - 'ID' => $message_row['message_id'], |
|
140 | - 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), |
|
141 | - 'FROM' => htmlspecialchars($message_row['message_from']), |
|
142 | - 'SUBJ' => htmlspecialchars($message_row['message_subject']), |
|
143 | - 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), |
|
144 | - |
|
145 | - 'FROM_ID' => $message_row['message_sender'], |
|
146 | - )); |
|
147 | - } |
|
137 | + while ($message_row = db_fetch($message_query)) { |
|
138 | + $template->assign_block_vars('messages', array( |
|
139 | + 'ID' => $message_row['message_id'], |
|
140 | + 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), |
|
141 | + 'FROM' => htmlspecialchars($message_row['message_from']), |
|
142 | + 'SUBJ' => htmlspecialchars($message_row['message_subject']), |
|
143 | + 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), |
|
144 | + |
|
145 | + 'FROM_ID' => $message_row['message_sender'], |
|
146 | + )); |
|
147 | + } |
|
148 | 148 | |
149 | - break; |
|
149 | + break; |
|
150 | 150 | |
151 | - case 'delete': |
|
152 | - $query_add = ''; |
|
151 | + case 'delete': |
|
152 | + $query_add = ''; |
|
153 | 153 | |
154 | - $message_range = sys_get_param_str('message_range'); |
|
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()); |
@@ -177,65 +177,65 @@ discard block |
||
177 | 177 | case 'all': |
178 | 178 | $query_add = $query_add ? $query_add : true; |
179 | 179 | break; |
180 | - } |
|
180 | + } |
|
181 | 181 | |
182 | 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 | - case 'show': |
|
188 | - if($current_class == MSG_TYPE_OUTBOX) { |
|
189 | - $message_query = db_message_list_outbox_by_user_id($user['id']); |
|
190 | - } else { |
|
191 | - if ($current_class == MSG_TYPE_NEW) { |
|
192 | - $SubUpdateQry = array(); |
|
193 | - foreach($sn_message_class_list as $message_class_id => $message_class) { |
|
194 | - if($message_class_id != MSG_TYPE_OUTBOX) { |
|
195 | - $SubUpdateQry[] = "`{$message_class['name']}` = '0'"; |
|
196 | - $user[$message_class['name']] = 0; |
|
187 | + case 'show': |
|
188 | + if($current_class == MSG_TYPE_OUTBOX) { |
|
189 | + $message_query = db_message_list_outbox_by_user_id($user['id']); |
|
190 | + } else { |
|
191 | + if ($current_class == MSG_TYPE_NEW) { |
|
192 | + $SubUpdateQry = array(); |
|
193 | + foreach($sn_message_class_list as $message_class_id => $message_class) { |
|
194 | + if($message_class_id != MSG_TYPE_OUTBOX) { |
|
195 | + $SubUpdateQry[] = "`{$message_class['name']}` = '0'"; |
|
196 | + $user[$message_class['name']] = 0; |
|
197 | + } |
|
197 | 198 | } |
199 | + $SubUpdateQry = implode(',', $SubUpdateQry); |
|
200 | + } else { |
|
201 | + $SubUpdateQry = "`{$sn_message_class_list[$current_class]['name']}` = '0', `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` = `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` - '{$user[$sn_message_class_list[$current_class]['name']]}'"; |
|
202 | + $SubSelectQry = "AND `message_type` = '{$current_class}'"; |
|
203 | + |
|
204 | + $user[$sn_message_class_list[MSG_TYPE_NEW]['name']] -= $user[$sn_message_class_list[$current_class]['name']]; |
|
205 | + $user[$sn_message_class_list[$current_class]['name']] = 0; |
|
198 | 206 | } |
199 | - $SubUpdateQry = implode(',', $SubUpdateQry); |
|
200 | - } else { |
|
201 | - $SubUpdateQry = "`{$sn_message_class_list[$current_class]['name']}` = '0', `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` = `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` - '{$user[$sn_message_class_list[$current_class]['name']]}'"; |
|
202 | - $SubSelectQry = "AND `message_type` = '{$current_class}'"; |
|
203 | 207 | |
204 | - $user[$sn_message_class_list[MSG_TYPE_NEW]['name']] -= $user[$sn_message_class_list[$current_class]['name']]; |
|
205 | - $user[$sn_message_class_list[$current_class]['name']] = 0; |
|
208 | + db_user_set_by_id($user['id'], $SubUpdateQry); |
|
209 | + $message_query = "SELECT * FROM {{messages}} WHERE `message_owner` = '{$user['id']}' {$SubSelectQry} ORDER BY `message_time` DESC;"; |
|
210 | + $message_query = doquery($message_query); |
|
206 | 211 | } |
207 | 212 | |
208 | - db_user_set_by_id($user['id'], $SubUpdateQry); |
|
209 | - $message_query = "SELECT * FROM {{messages}} WHERE `message_owner` = '{$user['id']}' {$SubSelectQry} ORDER BY `message_time` DESC;"; |
|
210 | - $message_query = doquery($message_query); |
|
211 | - } |
|
212 | - |
|
213 | - if(sys_get_param_int('return')) { |
|
214 | - sys_redirect('messages.php'); |
|
215 | - } |
|
213 | + if(sys_get_param_int('return')) { |
|
214 | + sys_redirect('messages.php'); |
|
215 | + } |
|
216 | 216 | |
217 | - $template = gettemplate('msg_message_list', true); |
|
218 | - while ($message_row = db_fetch($message_query)) { |
|
219 | - $template->assign_block_vars('messages', array( |
|
220 | - 'ID' => $message_row['message_id'], |
|
221 | - 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), |
|
222 | - 'FROM' => htmlspecialchars($message_row['message_from']), |
|
223 | - 'SUBJ' => htmlspecialchars($message_row['message_subject']), |
|
224 | - 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), |
|
225 | - |
|
226 | - 'FROM_ID' => $message_row['message_sender'], |
|
227 | - 'SUBJ_SANITIZED' => htmlspecialchars($message_row['message_subject']), |
|
228 | - 'STYLE' => $current_class == MSG_TYPE_OUTBOX ? $sn_message_class_list[MSG_TYPE_OUTBOX]['name'] : $sn_message_class_list[$message_row['message_type']]['name'], |
|
229 | - )); |
|
230 | - } |
|
217 | + $template = gettemplate('msg_message_list', true); |
|
218 | + while ($message_row = db_fetch($message_query)) { |
|
219 | + $template->assign_block_vars('messages', array( |
|
220 | + 'ID' => $message_row['message_id'], |
|
221 | + 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), |
|
222 | + 'FROM' => htmlspecialchars($message_row['message_from']), |
|
223 | + 'SUBJ' => htmlspecialchars($message_row['message_subject']), |
|
224 | + 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), |
|
225 | + |
|
226 | + 'FROM_ID' => $message_row['message_sender'], |
|
227 | + 'SUBJ_SANITIZED' => htmlspecialchars($message_row['message_subject']), |
|
228 | + 'STYLE' => $current_class == MSG_TYPE_OUTBOX ? $sn_message_class_list[MSG_TYPE_OUTBOX]['name'] : $sn_message_class_list[$message_row['message_type']]['name'], |
|
229 | + )); |
|
230 | + } |
|
231 | 231 | |
232 | - $current_class_text = $lang['msg_class'][$current_class]; |
|
232 | + $current_class_text = $lang['msg_class'][$current_class]; |
|
233 | 233 | |
234 | - $template->assign_vars(array( |
|
235 | - "MESSAGE_CLASS" => $current_class, |
|
236 | - "MESSAGE_CLASS_TEXT" => $current_class_text, |
|
237 | - )); |
|
238 | - break; |
|
234 | + $template->assign_vars(array( |
|
235 | + "MESSAGE_CLASS" => $current_class, |
|
236 | + "MESSAGE_CLASS_TEXT" => $current_class_text, |
|
237 | + )); |
|
238 | + break; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | if(!$template) { |
@@ -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 | sys_redirect('messages.php'); |
215 | 215 | } |
216 | 216 | |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | break; |
239 | 239 | } |
240 | 240 | |
241 | -if(!$template) { |
|
241 | +if (!$template) { |
|
242 | 242 | $template = gettemplate('msg_message_class', true); |
243 | 243 | |
244 | 244 | $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;"); |
245 | - while($message_row = db_fetch($query)) { |
|
245 | + while ($message_row = db_fetch($query)) { |
|
246 | 246 | $messages_total[$message_row['message_type']] = $message_row['message_count']; |
247 | 247 | $messages_total[MSG_TYPE_NEW] += $message_row['message_count']; |
248 | 248 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $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); |
251 | 251 | $messages_total[MSG_TYPE_OUTBOX] = intval($query['message_count']); |
252 | 252 | |
253 | - foreach($sn_message_class_list as $message_class_id => $message_class) { |
|
253 | + foreach ($sn_message_class_list as $message_class_id => $message_class) { |
|
254 | 254 | $template->assign_block_vars('message_class', array( |
255 | 255 | 'ID' => $message_class_id, |
256 | 256 | 'STYLE' => $message_class['name'], |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | !is_array($offset) ? $offset = array($offset) : false; |
39 | 39 | |
40 | 40 | $current_leaf = $this->__get(reset($offset)); |
41 | - while(($leaf_index = next($offset)) !== false) { |
|
42 | - if(!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
41 | + while (($leaf_index = next($offset)) !== false) { |
|
42 | + if (!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
43 | 43 | unset($current_leaf); |
44 | 44 | break; |
45 | 45 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | |
65 | 65 | !is_array($offset) ? $offset = array($offset) : false; |
66 | 66 | |
67 | - if($this->offsetExists($offset)) { |
|
67 | + if ($this->offsetExists($offset)) { |
|
68 | 68 | $result = $this->__get(reset($offset)); |
69 | - while(($leaf_index = next($offset)) !== false) { |
|
69 | + while (($leaf_index = next($offset)) !== false) { |
|
70 | 70 | $result = $result[$leaf_index]; |
71 | 71 | } |
72 | 72 | } |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function offsetSet($offset, $value = null) { |
93 | 93 | // Если нет никакого индекса - значит нечего записывать |
94 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
94 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | 98 | // Если в массиве индекса только один элемент - значит это просто индекс |
99 | - if(is_array($offset) && count($offset) == 1) { |
|
99 | + if (is_array($offset) && count($offset) == 1) { |
|
100 | 100 | // Разворачиваем его в индекс |
101 | 101 | $offset = array(reset($offset) => $value); |
102 | 102 | unset($value); |
@@ -104,16 +104,16 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | // Адресация многомерного массива через массив индексов в $option |
107 | - if(is_array($offset) && isset($value)) { |
|
107 | + if (is_array($offset) && isset($value)) { |
|
108 | 108 | // TODO - а не переделать ли это всё на __isset() ?? |
109 | 109 | // Вытаскиваем корневой элемент |
110 | 110 | $root = $this->__get(reset($offset)); |
111 | 111 | $current_leaf = &$root; |
112 | - while(($leaf_index = next($offset)) !== false) { |
|
112 | + while (($leaf_index = next($offset)) !== false) { |
|
113 | 113 | !is_array($current_leaf[$leaf_index]) ? $current_leaf[$leaf_index] = array() : false; |
114 | 114 | $current_leaf = &$current_leaf[$leaf_index]; |
115 | 115 | } |
116 | - if($current_leaf != $value) { |
|
116 | + if ($current_leaf != $value) { |
|
117 | 117 | $current_leaf = $value; |
118 | 118 | // Сохраняем данные с корня |
119 | 119 | $this->__set(reset($offset), $root); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | // Пакетная запись из массива ключ -> значение |
123 | 123 | !is_array($offset) ? $offset = array($offset => $value) : false; |
124 | 124 | |
125 | - foreach($offset as $key => $value) { |
|
125 | + foreach ($offset as $key => $value) { |
|
126 | 126 | $this->__get($key) !== $value ? $this->__set($key, $value) : false; |
127 | 127 | } |
128 | 128 | } |
@@ -143,18 +143,18 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function offsetUnset($offset) { |
145 | 145 | // Если нет никакого индекса - значит нечего записывать |
146 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
146 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
147 | 147 | return; |
148 | 148 | } |
149 | 149 | |
150 | 150 | !is_array($offset) ? $offset = array($offset) : false; |
151 | 151 | |
152 | - if($this->offsetExists($offset)) { |
|
152 | + if ($this->offsetExists($offset)) { |
|
153 | 153 | // Перематываем массив в конец |
154 | 154 | $key_to_delete = end($offset); |
155 | 155 | $parent_offset = $offset; |
156 | 156 | array_pop($parent_offset); |
157 | - if(!count($parent_offset)) { |
|
157 | + if (!count($parent_offset)) { |
|
158 | 158 | // В массиве был один элемент - мы удаляем в корне. Просто удаляем элемент |
159 | 159 | $this->__unset($key_to_delete); |
160 | 160 | } else { |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | |
31 | 31 | static $need_keys = array('server', 'user', 'pass', 'name', 'prefix'); |
32 | 32 | |
33 | - if($this->connected) { |
|
33 | + if ($this->connected) { |
|
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
37 | - if(empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) { |
|
37 | + if (empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) { |
|
38 | 38 | $debug->error_fatal('There is missconfiguration in your config.php. Check it again'); |
39 | 39 | } |
40 | 40 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | return mysqli_real_escape_string($this->link, $unescaped_string); |
91 | 91 | } |
92 | 92 | function mysql_close_link() { |
93 | - if(is_object($this->link)) { |
|
93 | + if (is_object($this->link)) { |
|
94 | 94 | $this->link->close(); |
95 | 95 | $this->connected = false; |
96 | 96 | unset($this->link); |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | |
143 | 143 | preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches); |
144 | 144 | $include_blocks = $matches[1]; |
145 | - if($include_blocks) |
|
145 | + if ($include_blocks) |
|
146 | 146 | { |
147 | - foreach($include_blocks as &$included_file) |
|
147 | + foreach ($include_blocks as &$included_file) |
|
148 | 148 | { |
149 | 149 | $included_file .= '.tpl.html'; |
150 | 150 | } |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | |
454 | 454 | $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){'; |
455 | 455 | // $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;'; |
456 | - $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
457 | - $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
456 | + $tag_template_php .= '$_' . $tag_args . '_val = &' . $varref . '[$_' . $tag_args . '_i];'; |
|
457 | + $tag_template_php .= '$this->_block_value["' . $tag_args . '"] = &' . $varref . '[$_' . $tag_args . '_i];'; |
|
458 | 458 | |
459 | 459 | return $tag_template_php; |
460 | 460 | } |
@@ -558,10 +558,10 @@ discard block |
||
558 | 558 | break; |
559 | 559 | |
560 | 560 | case 'is': |
561 | - $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1; |
|
561 | + $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1; |
|
562 | 562 | $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); |
563 | 563 | |
564 | - $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); |
|
564 | + $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1)); |
|
565 | 565 | |
566 | 566 | array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens); |
567 | 567 | |
@@ -821,11 +821,11 @@ discard block |
||
821 | 821 | } |
822 | 822 | else if ($include_last_iterator) |
823 | 823 | { |
824 | - return '$_'. $blocks[$blockcount] . '_val'; |
|
824 | + return '$_' . $blocks[$blockcount] . '_val'; |
|
825 | 825 | } |
826 | 826 | else |
827 | 827 | { |
828 | - return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
|
828 | + return '$_' . $blocks[$blockcount - 1] . '_val[\'' . $blocks[$blockcount] . '\']'; |
|
829 | 829 | } |
830 | 830 | } |
831 | 831 | |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | if ($fp = @fopen($filename, 'wb')) |
843 | 843 | { |
844 | 844 | @flock($fp, LOCK_EX); |
845 | - @fwrite ($fp, $data); |
|
845 | + @fwrite($fp, $data); |
|
846 | 846 | @flock($fp, LOCK_UN); |
847 | 847 | @fclose($fp); |
848 | 848 | |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | { |
863 | 863 | global $config; |
864 | 864 | |
865 | - if(!$config->tpl_minifier) |
|
865 | + if (!$config->tpl_minifier) |
|
866 | 866 | { |
867 | 867 | return $html; |
868 | 868 | } |
@@ -874,14 +874,14 @@ discard block |
||
874 | 874 | //$html = preg_replace('/[\r\n\t]+/', ' ', $html); |
875 | 875 | $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags |
876 | 876 | $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space |
877 | - if(!empty($pre[0])) |
|
877 | + if (!empty($pre[0])) |
|
878 | 878 | { |
879 | - foreach($pre[0] as $tag) |
|
879 | + foreach ($pre[0] as $tag) |
|
880 | 880 | { |
881 | 881 | $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside |
882 | 882 | $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one |
883 | 883 | $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one |
884 | - $html = preg_replace('/#pre#/', $tag, $html,1); |
|
884 | + $html = preg_replace('/#pre#/', $tag, $html, 1); |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 |
@@ -468,6 +468,7 @@ discard block |
||
468 | 468 | * Compile IF tags - much of this is from Smarty with |
469 | 469 | * some adaptions for our block level methods |
470 | 470 | * @access private |
471 | + * @param boolean $elseif |
|
471 | 472 | */ |
472 | 473 | function compile_tag_if($tag_args, $elseif) |
473 | 474 | { |
@@ -625,6 +626,7 @@ discard block |
||
625 | 626 | /** |
626 | 627 | * Compile DEFINE tags |
627 | 628 | * @access private |
629 | + * @param boolean $op |
|
628 | 630 | */ |
629 | 631 | function compile_tag_define($tag_args, $op) |
630 | 632 | { |
@@ -703,6 +705,7 @@ discard block |
||
703 | 705 | * parse expression |
704 | 706 | * This is from Smarty |
705 | 707 | * @access private |
708 | + * @param string $is_arg |
|
706 | 709 | */ |
707 | 710 | function _parse_is_expr($is_arg, $tokens) |
708 | 711 | { |
@@ -799,6 +802,8 @@ discard block |
||
799 | 802 | * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
800 | 803 | * NOTE: does not expect a trailing "." on the blockname. |
801 | 804 | * @access private |
805 | + * @param string $blockname |
|
806 | + * @param boolean $include_last_iterator |
|
802 | 807 | */ |
803 | 808 | function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
804 | 809 | { |
@@ -862,6 +867,7 @@ discard block |
||
862 | 867 | /** |
863 | 868 | * Minifies template w/i PHP code by removing extra spaces |
864 | 869 | * @access private |
870 | + * @return string |
|
865 | 871 | */ |
866 | 872 | function minify($html) |
867 | 873 | { |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | - * Load template source from file |
|
59 | - * @access private |
|
60 | - */ |
|
58 | + * Load template source from file |
|
59 | + * @access private |
|
60 | + */ |
|
61 | 61 | function _tpl_load_file($handle, $store_in_db = false) |
62 | 62 | { |
63 | 63 | // Try and open template for read |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | - * Remove any PHP tags that do not belong, these regular expressions are derived from |
|
104 | - * the ones that exist in zend_language_scanner.l |
|
105 | - * @access private |
|
106 | - */ |
|
103 | + * Remove any PHP tags that do not belong, these regular expressions are derived from |
|
104 | + * the ones that exist in zend_language_scanner.l |
|
105 | + * @access private |
|
106 | + */ |
|
107 | 107 | function remove_php_tags(&$code) |
108 | 108 | { |
109 | 109 | // This matches the information gathered from the internal PHP lexer |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
120 | - * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
|
121 | - * @access private |
|
122 | - */ |
|
120 | + * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
|
121 | + * @access private |
|
122 | + */ |
|
123 | 123 | function compile($code, $no_echo = false, $echo_var = '') |
124 | 124 | { |
125 | 125 | global $config; |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
293 | - * Compile variables |
|
294 | - * @access private |
|
295 | - */ |
|
293 | + * Compile variables |
|
294 | + * @access private |
|
295 | + */ |
|
296 | 296 | function compile_var_tags(&$text_blocks) |
297 | 297 | { |
298 | 298 | // including $lang variable |
@@ -359,9 +359,9 @@ discard block |
||
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
362 | - * Compile blocks |
|
363 | - * @access private |
|
364 | - */ |
|
362 | + * Compile blocks |
|
363 | + * @access private |
|
364 | + */ |
|
365 | 365 | function compile_tag_block($tag_args) |
366 | 366 | { |
367 | 367 | $no_nesting = false; |
@@ -447,14 +447,14 @@ discard block |
||
447 | 447 | $tag_template_php .= 'if ($_' . $tag_args . '_count) {'; |
448 | 448 | |
449 | 449 | /** |
450 | - * 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 |
|
451 | - * <code> |
|
452 | - * if (!$offset) |
|
453 | - * { |
|
454 | - * $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){'; |
|
455 | - * } |
|
456 | - * </code> |
|
457 | - */ |
|
450 | + * 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 |
|
451 | + * <code> |
|
452 | + * if (!$offset) |
|
453 | + * { |
|
454 | + * $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){'; |
|
455 | + * } |
|
456 | + * </code> |
|
457 | + */ |
|
458 | 458 | |
459 | 459 | $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){'; |
460 | 460 | // $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;'; |
@@ -465,10 +465,10 @@ discard block |
||
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
468 | - * Compile IF tags - much of this is from Smarty with |
|
469 | - * some adaptions for our block level methods |
|
470 | - * @access private |
|
471 | - */ |
|
468 | + * Compile IF tags - much of this is from Smarty with |
|
469 | + * some adaptions for our block level methods |
|
470 | + * @access private |
|
471 | + */ |
|
472 | 472 | function compile_tag_if($tag_args, $elseif) |
473 | 473 | { |
474 | 474 | // Tokenize args for 'if' tag. |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | } |
624 | 624 | |
625 | 625 | /** |
626 | - * Compile DEFINE tags |
|
627 | - * @access private |
|
628 | - */ |
|
626 | + * Compile DEFINE tags |
|
627 | + * @access private |
|
628 | + */ |
|
629 | 629 | function compile_tag_define($tag_args, $op) |
630 | 630 | { |
631 | 631 | preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match); |
@@ -676,9 +676,9 @@ discard block |
||
676 | 676 | } |
677 | 677 | |
678 | 678 | /** |
679 | - * Compile INCLUDE tag |
|
680 | - * @access private |
|
681 | - */ |
|
679 | + * Compile INCLUDE tag |
|
680 | + * @access private |
|
681 | + */ |
|
682 | 682 | function compile_tag_include($tag_args) |
683 | 683 | { |
684 | 684 | // Process dynamic includes |
@@ -691,19 +691,19 @@ discard block |
||
691 | 691 | } |
692 | 692 | |
693 | 693 | /** |
694 | - * Compile INCLUDE_PHP tag |
|
695 | - * @access private |
|
696 | - */ |
|
694 | + * Compile INCLUDE_PHP tag |
|
695 | + * @access private |
|
696 | + */ |
|
697 | 697 | function compile_tag_include_php($tag_args) |
698 | 698 | { |
699 | 699 | return "\$this->_php_include('$tag_args');"; |
700 | 700 | } |
701 | 701 | |
702 | 702 | /** |
703 | - * parse expression |
|
704 | - * This is from Smarty |
|
705 | - * @access private |
|
706 | - */ |
|
703 | + * parse expression |
|
704 | + * This is from Smarty |
|
705 | + * @access private |
|
706 | + */ |
|
707 | 707 | function _parse_is_expr($is_arg, $tokens) |
708 | 708 | { |
709 | 709 | $expr_end = 0; |
@@ -768,13 +768,13 @@ discard block |
||
768 | 768 | } |
769 | 769 | |
770 | 770 | /** |
771 | - * Generates a reference to the given variable inside the given (possibly nested) |
|
772 | - * block namespace. This is a string of the form: |
|
773 | - * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' |
|
774 | - * It's ready to be inserted into an "echo" line in one of the templates. |
|
775 | - * NOTE: expects a trailing "." on the namespace. |
|
776 | - * @access private |
|
777 | - */ |
|
771 | + * Generates a reference to the given variable inside the given (possibly nested) |
|
772 | + * block namespace. This is a string of the form: |
|
773 | + * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' |
|
774 | + * It's ready to be inserted into an "echo" line in one of the templates. |
|
775 | + * NOTE: expects a trailing "." on the namespace. |
|
776 | + * @access private |
|
777 | + */ |
|
778 | 778 | function generate_block_varref($namespace, $varname, $echo = true, $defop = false) |
779 | 779 | { |
780 | 780 | // Strip the trailing period. |
@@ -792,14 +792,14 @@ discard block |
||
792 | 792 | } |
793 | 793 | |
794 | 794 | /** |
795 | - * Generates a reference to the array of data values for the given |
|
796 | - * (possibly nested) block namespace. This is a string of the form: |
|
797 | - * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] |
|
798 | - * |
|
799 | - * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
|
800 | - * NOTE: does not expect a trailing "." on the blockname. |
|
801 | - * @access private |
|
802 | - */ |
|
795 | + * Generates a reference to the array of data values for the given |
|
796 | + * (possibly nested) block namespace. This is a string of the form: |
|
797 | + * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] |
|
798 | + * |
|
799 | + * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
|
800 | + * NOTE: does not expect a trailing "." on the blockname. |
|
801 | + * @access private |
|
802 | + */ |
|
803 | 803 | function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
804 | 804 | { |
805 | 805 | // Get an array of the blocks involved. |
@@ -835,9 +835,9 @@ discard block |
||
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
838 | - * Write compiled file to cache directory |
|
839 | - * @access private |
|
840 | - */ |
|
838 | + * Write compiled file to cache directory |
|
839 | + * @access private |
|
840 | + */ |
|
841 | 841 | function compile_write($handle, $data) |
842 | 842 | { |
843 | 843 | $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
@@ -860,9 +860,9 @@ discard block |
||
860 | 860 | |
861 | 861 | // Gorlum's minifier BOF |
862 | 862 | /** |
863 | - * Minifies template w/i PHP code by removing extra spaces |
|
864 | - * @access private |
|
865 | - */ |
|
863 | + * Minifies template w/i PHP code by removing extra spaces |
|
864 | + * @access private |
|
865 | + */ |
|
866 | 866 | function minify($html) |
867 | 867 | { |
868 | 868 | global $config; |
@@ -37,8 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @package phpBB3 |
39 | 39 | */ |
40 | -class template_compile |
|
41 | -{ |
|
40 | +class template_compile { |
|
42 | 41 | var $template; |
43 | 42 | |
44 | 43 | // Various storage arrays |
@@ -58,8 +57,7 @@ discard block |
||
58 | 57 | * Load template source from file |
59 | 58 | * @access private |
60 | 59 | */ |
61 | - function _tpl_load_file($handle, $store_in_db = false) |
|
62 | - { |
|
60 | + function _tpl_load_file($handle, $store_in_db = false) { |
|
63 | 61 | // Try and open template for read |
64 | 62 | if (!file_exists($this->template->files[$handle])) |
65 | 63 | { |
@@ -67,8 +65,7 @@ discard block |
||
67 | 65 | { |
68 | 66 | return; |
69 | 67 | trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR); |
70 | - } |
|
71 | - else |
|
68 | + } else |
|
72 | 69 | { |
73 | 70 | $this->template->files[$handle] = $this->template->files_inherit[$handle]; |
74 | 71 | } |
@@ -104,8 +101,7 @@ discard block |
||
104 | 101 | * the ones that exist in zend_language_scanner.l |
105 | 102 | * @access private |
106 | 103 | */ |
107 | - function remove_php_tags(&$code) |
|
108 | - { |
|
104 | + function remove_php_tags(&$code) { |
|
109 | 105 | // This matches the information gathered from the internal PHP lexer |
110 | 106 | $match = array( |
111 | 107 | '#<([\?%])=?.*?\1>#s', |
@@ -120,8 +116,7 @@ discard block |
||
120 | 116 | * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
121 | 117 | * @access private |
122 | 118 | */ |
123 | - function compile($code, $no_echo = false, $echo_var = '') |
|
124 | - { |
|
119 | + function compile($code, $no_echo = false, $echo_var = '') { |
|
125 | 120 | global $config; |
126 | 121 | |
127 | 122 | if ($echo_var) |
@@ -226,15 +221,13 @@ discard block |
||
226 | 221 | $var = substr($temp, 2, -1); |
227 | 222 | //$file = $this->template->_tpldata['DEFINE']['.'][$var]; |
228 | 223 | $temp = "\$this->_tpldata['DEFINE']['.']['$var']"; |
229 | - } |
|
230 | - else |
|
224 | + } else |
|
231 | 225 | { |
232 | 226 | $var = substr($temp, 1, -1); |
233 | 227 | //$file = $this->template->_rootref[$var]; |
234 | 228 | $temp = "\$this->_rootref['$var']"; |
235 | 229 | } |
236 | - } |
|
237 | - else |
|
230 | + } else |
|
238 | 231 | { |
239 | 232 | $file = $temp; |
240 | 233 | } |
@@ -293,8 +286,7 @@ discard block |
||
293 | 286 | * Compile variables |
294 | 287 | * @access private |
295 | 288 | */ |
296 | - function compile_var_tags(&$text_blocks) |
|
297 | - { |
|
289 | + function compile_var_tags(&$text_blocks) { |
|
298 | 290 | // including $lang variable |
299 | 291 | global $lang, $config; |
300 | 292 | |
@@ -362,8 +354,7 @@ discard block |
||
362 | 354 | * Compile blocks |
363 | 355 | * @access private |
364 | 356 | */ |
365 | - function compile_tag_block($tag_args) |
|
366 | - { |
|
357 | + function compile_tag_block($tag_args) { |
|
367 | 358 | $no_nesting = false; |
368 | 359 | |
369 | 360 | // Is the designer wanting to call another loop in a loop? |
@@ -386,8 +377,7 @@ discard block |
||
386 | 377 | if ($match[2] < 0) |
387 | 378 | { |
388 | 379 | $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; |
389 | - } |
|
390 | - else |
|
380 | + } else |
|
391 | 381 | { |
392 | 382 | $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; |
393 | 383 | } |
@@ -395,17 +385,14 @@ discard block |
||
395 | 385 | if (strlen($match[3]) < 1 || $match[3] == -1) |
396 | 386 | { |
397 | 387 | $loop_end = '$_' . $tag_args . '_count'; |
398 | - } |
|
399 | - else if ($match[3] >= 0) |
|
388 | + } else if ($match[3] >= 0) |
|
400 | 389 | { |
401 | 390 | $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')'; |
402 | - } |
|
403 | - else //if ($match[3] < -1) |
|
391 | + } else //if ($match[3] < -1) |
|
404 | 392 | { |
405 | 393 | $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1); |
406 | 394 | } |
407 | - } |
|
408 | - else |
|
395 | + } else |
|
409 | 396 | { |
410 | 397 | $loop_start = 0; |
411 | 398 | $loop_end = '$_' . $tag_args . '_count'; |
@@ -418,8 +405,7 @@ discard block |
||
418 | 405 | { |
419 | 406 | // We need to implode $no_nesting times from the end... |
420 | 407 | $block = array_slice($this->block_names, -$no_nesting); |
421 | - } |
|
422 | - else |
|
408 | + } else |
|
423 | 409 | { |
424 | 410 | $block = $this->block_names; |
425 | 411 | } |
@@ -429,8 +415,7 @@ discard block |
||
429 | 415 | // Block is not nested. |
430 | 416 | $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
431 | 417 | $varref = "\$this->_tpldata['$tag_args']"; |
432 | - } |
|
433 | - else |
|
418 | + } else |
|
434 | 419 | { |
435 | 420 | // This block is nested. |
436 | 421 | // Generate a namespace string for this block. |
@@ -469,8 +454,7 @@ discard block |
||
469 | 454 | * some adaptions for our block level methods |
470 | 455 | * @access private |
471 | 456 | */ |
472 | - function compile_tag_if($tag_args, $elseif) |
|
473 | - { |
|
457 | + function compile_tag_if($tag_args, $elseif) { |
|
474 | 458 | // Tokenize args for 'if' tag. |
475 | 459 | preg_match_all('/(?: |
476 | 460 | "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | |
@@ -578,8 +562,7 @@ discard block |
||
578 | 562 | if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs)) |
579 | 563 | { |
580 | 564 | $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] . '\']'); |
581 | - } |
|
582 | - else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
565 | + } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
583 | 566 | { |
584 | 567 | // Allow checking if loops are set with .loopname |
585 | 568 | // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example |
@@ -595,8 +578,7 @@ discard block |
||
595 | 578 | |
596 | 579 | // Add the block reference for the last child. |
597 | 580 | $varref .= "['" . $block . "']"; |
598 | - } |
|
599 | - else |
|
581 | + } else |
|
600 | 582 | { |
601 | 583 | $varref = '$this->_tpldata'; |
602 | 584 | |
@@ -604,8 +586,7 @@ discard block |
||
604 | 586 | $varref .= "['" . $blocks[0] . "']"; |
605 | 587 | } |
606 | 588 | $token = "sizeof($varref)"; |
607 | - } |
|
608 | - else if (!empty($token)) |
|
589 | + } else if (!empty($token)) |
|
609 | 590 | { |
610 | 591 | $token = '(' . $token . ')'; |
611 | 592 | } |
@@ -626,8 +607,7 @@ discard block |
||
626 | 607 | * Compile DEFINE tags |
627 | 608 | * @access private |
628 | 609 | */ |
629 | - function compile_tag_define($tag_args, $op) |
|
630 | - { |
|
610 | + function compile_tag_define($tag_args, $op) { |
|
631 | 611 | preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match); |
632 | 612 | |
633 | 613 | if (empty($match[2]) || (!isset($match[4]) && $op)) |
@@ -650,8 +630,7 @@ discard block |
||
650 | 630 | |
651 | 631 | // Now replace the php code |
652 | 632 | $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'"; |
653 | - } |
|
654 | - else |
|
633 | + } else |
|
655 | 634 | { |
656 | 635 | preg_match('#true|false|\.#i', $match[4], $type); |
657 | 636 | |
@@ -679,8 +658,7 @@ discard block |
||
679 | 658 | * Compile INCLUDE tag |
680 | 659 | * @access private |
681 | 660 | */ |
682 | - function compile_tag_include($tag_args) |
|
683 | - { |
|
661 | + function compile_tag_include($tag_args) { |
|
684 | 662 | // Process dynamic includes |
685 | 663 | if ($tag_args[0] == '$') |
686 | 664 | { |
@@ -694,8 +672,7 @@ discard block |
||
694 | 672 | * Compile INCLUDE_PHP tag |
695 | 673 | * @access private |
696 | 674 | */ |
697 | - function compile_tag_include_php($tag_args) |
|
698 | - { |
|
675 | + function compile_tag_include_php($tag_args) { |
|
699 | 676 | return "\$this->_php_include('$tag_args');"; |
700 | 677 | } |
701 | 678 | |
@@ -704,8 +681,7 @@ discard block |
||
704 | 681 | * This is from Smarty |
705 | 682 | * @access private |
706 | 683 | */ |
707 | - function _parse_is_expr($is_arg, $tokens) |
|
708 | - { |
|
684 | + function _parse_is_expr($is_arg, $tokens) { |
|
709 | 685 | $expr_end = 0; |
710 | 686 | $negate_expr = false; |
711 | 687 | |
@@ -713,8 +689,7 @@ discard block |
||
713 | 689 | { |
714 | 690 | $negate_expr = true; |
715 | 691 | $expr_type = array_shift($tokens); |
716 | - } |
|
717 | - else |
|
692 | + } else |
|
718 | 693 | { |
719 | 694 | $expr_type = $first_token; |
720 | 695 | } |
@@ -727,8 +702,7 @@ discard block |
||
727 | 702 | $expr_end++; |
728 | 703 | $expr_arg = $tokens[$expr_end++]; |
729 | 704 | $expr = "!(($is_arg / $expr_arg) % $expr_arg)"; |
730 | - } |
|
731 | - else |
|
705 | + } else |
|
732 | 706 | { |
733 | 707 | $expr = "!($is_arg & 1)"; |
734 | 708 | } |
@@ -740,8 +714,7 @@ discard block |
||
740 | 714 | $expr_end++; |
741 | 715 | $expr_arg = $tokens[$expr_end++]; |
742 | 716 | $expr = "(($is_arg / $expr_arg) % $expr_arg)"; |
743 | - } |
|
744 | - else |
|
717 | + } else |
|
745 | 718 | { |
746 | 719 | $expr = "($is_arg & 1)"; |
747 | 720 | } |
@@ -775,8 +748,7 @@ discard block |
||
775 | 748 | * NOTE: expects a trailing "." on the namespace. |
776 | 749 | * @access private |
777 | 750 | */ |
778 | - function generate_block_varref($namespace, $varname, $echo = true, $defop = false) |
|
779 | - { |
|
751 | + function generate_block_varref($namespace, $varname, $echo = true, $defop = false) { |
|
780 | 752 | // Strip the trailing period. |
781 | 753 | $namespace = substr($namespace, 0, -1); |
782 | 754 | |
@@ -800,8 +772,7 @@ discard block |
||
800 | 772 | * NOTE: does not expect a trailing "." on the blockname. |
801 | 773 | * @access private |
802 | 774 | */ |
803 | - function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
|
804 | - { |
|
775 | + function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) { |
|
805 | 776 | // Get an array of the blocks involved. |
806 | 777 | $blocks = explode('.', $blockname); |
807 | 778 | $blockcount = sizeof($blocks) - 1; |
@@ -823,12 +794,10 @@ discard block |
||
823 | 794 | $varref .= '[$_' . $blocks[$blockcount] . '_i]'; |
824 | 795 | } |
825 | 796 | return $varref; |
826 | - } |
|
827 | - else if ($include_last_iterator) |
|
797 | + } else if ($include_last_iterator) |
|
828 | 798 | { |
829 | 799 | return '$_'. $blocks[$blockcount] . '_val'; |
830 | - } |
|
831 | - else |
|
800 | + } else |
|
832 | 801 | { |
833 | 802 | return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
834 | 803 | } |
@@ -838,8 +807,7 @@ discard block |
||
838 | 807 | * Write compiled file to cache directory |
839 | 808 | * @access private |
840 | 809 | */ |
841 | - function compile_write($handle, $data) |
|
842 | - { |
|
810 | + function compile_write($handle, $data) { |
|
843 | 811 | $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
844 | 812 | |
845 | 813 | $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data); |
@@ -863,8 +831,7 @@ discard block |
||
863 | 831 | * Minifies template w/i PHP code by removing extra spaces |
864 | 832 | * @access private |
865 | 833 | */ |
866 | - function minify($html) |
|
867 | - { |
|
834 | + function minify($html) { |
|
868 | 835 | global $config; |
869 | 836 | |
870 | 837 | if(!$config->tpl_minifier) |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | // Инфа об устройстве и браузере - общая для всех |
90 | 90 | sn_db_transaction_start(); |
91 | 91 | $this->device_cypher = $_COOKIE[SN_COOKIE_D]; |
92 | - if($this->device_cypher) { |
|
92 | + if ($this->device_cypher) { |
|
93 | 93 | $cypher_safe = db_escape($this->device_cypher); |
94 | 94 | $device_id = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true); |
95 | - if(!empty($device_id['device_id'])) { |
|
95 | + if (!empty($device_id['device_id'])) { |
|
96 | 96 | $this->device_id = $device_id['device_id']; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - if($this->device_id <= 0) { |
|
100 | + if ($this->device_id <= 0) { |
|
101 | 101 | do { |
102 | 102 | $cypher_safe = db_escape($this->device_cypher = sys_random_string()); |
103 | 103 | $row = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true); |
@@ -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 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | public function db_counter_insert($user_id_unsafe) { |
168 | 168 | global $config, $sys_stop_log_hit, $is_watching; |
169 | 169 | |
170 | - if($sys_stop_log_hit || !$config->game_counter) { |
|
170 | + if ($sys_stop_log_hit || !$config->game_counter) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | // $this->ip_v4_int . ", '{$proxy_safe}', " . $this->page_address_id . ", " . $this->page_url_id . ");"); |
184 | 184 | doquery( |
185 | 185 | "INSERT INTO {{counter}} SET |
186 | - `visit_time` = '" . SN_TIME_SQL. "', |
|
186 | + `visit_time` = '" . SN_TIME_SQL . "', |
|
187 | 187 | `user_id` = {$user_id_safe}, |
188 | 188 | `device_id` = {$this->device_id}, |
189 | 189 | `browser_id` = {$this->browser_id}, |
190 | 190 | `user_ip` = {$this->ip_v4_int}, |
191 | 191 | `user_proxy` = '{$proxy_safe}', |
192 | 192 | `page_url_id` = {$this->page_address_id}" . |
193 | - ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '' ). |
|
193 | + ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '') . |
|
194 | 194 | ";"); |
195 | 195 | |
196 | 196 | $is_watching = false; |
@@ -140,11 +140,13 @@ |
||
140 | 140 | $error_backtrace['locks'] = classSupernova::$locks; |
141 | 141 | $error_backtrace['cSN_data'] = classSupernova::$data; |
142 | 142 | foreach($error_backtrace['cSN_data'] as &$location) { |
143 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
143 | + foreach($location as $location_id => &$location_data) { |
|
144 | + // $location_data = $location_id; |
|
144 | 145 | { |
145 | 146 | $location_data = isset($location_data['username']) ? $location_data['username'] : |
146 | 147 | (isset($location_data['name']) ? $location_data['name'] : $location_id); |
147 | 148 | } |
149 | + } |
|
148 | 150 | } |
149 | 151 | $error_backtrace['cSN_queries'] = classSupernova::$queries; |
150 | 152 | } |
@@ -76,7 +76,7 @@ |
||
76 | 76 | |
77 | 77 | $result = array(); |
78 | 78 | $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++; |
79 | - $result[] = "tID {$transaction_id}"; |
|
79 | + $result[] = "tid {$transaction_id}"; |
|
80 | 80 | foreach($backtrace as $a_trace) { |
81 | 81 | if(in_array($a_trace['function'], $exclude_functions)) { |
82 | 82 | continue; |
@@ -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 = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$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,25 +134,24 @@ discard block |
||
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
137 | + if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
138 | 138 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
139 | 139 | $error_backtrace['locks'] = classSupernova::$locks; |
140 | 140 | $error_backtrace['cSN_data'] = classSupernova::$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 | $error_backtrace['cSN_queries'] = classSupernova::$queries; |
149 | 148 | } |
150 | 149 | |
151 | - if($base_dump) { |
|
152 | - if(!is_array($this->log_array) || empty($this->log_array)) { |
|
150 | + if ($base_dump) { |
|
151 | + if (!is_array($this->log_array) || empty($this->log_array)) { |
|
153 | 152 | $this->log_array = []; |
154 | 153 | } else { |
155 | - foreach($this->log_array as $log) { |
|
154 | + foreach ($this->log_array as $log) { |
|
156 | 155 | $error_backtrace['queries'][] = $log; |
157 | 156 | } |
158 | 157 | } |
@@ -164,17 +163,17 @@ discard block |
||
164 | 163 | // Converting object instances to object names |
165 | 164 | |
166 | 165 | foreach ($error_backtrace['backtrace'] as &$backtrace) { |
167 | - if(is_object($backtrace['object'])) { |
|
166 | + if (is_object($backtrace['object'])) { |
|
168 | 167 | $backtrace['object'] = get_class($backtrace['object']); |
169 | 168 | } |
170 | 169 | |
171 | - if(empty($backtrace['args'])) { |
|
170 | + if (empty($backtrace['args'])) { |
|
172 | 171 | continue; |
173 | 172 | } |
174 | 173 | |
175 | 174 | // Doing same conversion for backtrace params |
176 | - foreach($backtrace['args'] as &$arg) { |
|
177 | - if(is_object($arg)) { |
|
175 | + foreach ($backtrace['args'] as &$arg) { |
|
176 | + if (is_object($arg)) { |
|
178 | 177 | $arg = 'object::' . get_class($arg); |
179 | 178 | } |
180 | 179 | } |
@@ -203,14 +202,14 @@ discard block |
||
203 | 202 | function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
204 | 203 | global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user; |
205 | 204 | |
206 | - if(empty(classSupernova::$db->connected)) { |
|
205 | + if (empty(classSupernova::$db->connected)) { |
|
207 | 206 | // TODO - писать ошибку в файл |
208 | 207 | die('SQL server currently unavailable. Please contact Administration...'); |
209 | 208 | } |
210 | 209 | |
211 | 210 | sn_db_transaction_rollback(); |
212 | 211 | |
213 | - if(classSupernova::$config->debug == 1) { |
|
212 | + if (classSupernova::$config->debug == 1) { |
|
214 | 213 | echo "<h2>{$title}</h2><br><font color=red>" . htmlspecialchars($message) . "</font><br><hr>"; |
215 | 214 | echo "<table>{$this->log}</table>"; |
216 | 215 | } |
@@ -220,7 +219,7 @@ discard block |
||
220 | 219 | $error_text = db_escape($message); |
221 | 220 | $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false); |
222 | 221 | |
223 | - if(!$sys_log_disabled) { |
|
222 | + if (!$sys_log_disabled) { |
|
224 | 223 | $query = "INSERT INTO `{{logs}}` SET |
225 | 224 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "', |
226 | 225 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -238,7 +237,7 @@ discard block |
||
238 | 237 | ob_start(); |
239 | 238 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
240 | 239 | |
241 | - foreach($error_backtrace as $name => $value) { |
|
240 | + foreach ($error_backtrace as $name => $value) { |
|
242 | 241 | print('<hr>'); |
243 | 242 | pdump($value, $name); |
244 | 243 | } |
@@ -250,14 +249,14 @@ discard block |
||
250 | 249 | function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
251 | 250 | global $user, $lang, $sys_log_disabled; |
252 | 251 | |
253 | - if(empty(classSupernova::$db->connected)) { |
|
252 | + if (empty(classSupernova::$db->connected)) { |
|
254 | 253 | // TODO - писать ошибку в файл |
255 | 254 | die('SQL server currently unavailable. Please contact Administration...'); |
256 | 255 | } |
257 | 256 | |
258 | 257 | $error_backtrace = $this->dump($dump, false); |
259 | 258 | |
260 | - if(!$sys_log_disabled) { |
|
259 | + if (!$sys_log_disabled) { |
|
261 | 260 | $query = "INSERT INTO `{{logs}}` SET |
262 | 261 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "', |
263 | 262 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -275,11 +274,11 @@ discard block |
||
275 | 274 | // Dump variables nicer then var_dump() |
276 | 275 | |
277 | 276 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
278 | - if(isset($varname)) { |
|
277 | + if (isset($varname)) { |
|
279 | 278 | $varname .= " = "; |
280 | 279 | } |
281 | 280 | |
282 | - if($level == -1) { |
|
281 | + if ($level == -1) { |
|
283 | 282 | $trans[' '] = '∴'; |
284 | 283 | $trans["\t"] = '⇒'; |
285 | 284 | $trans["\n"] = '¶;'; |
@@ -288,7 +287,7 @@ discard block |
||
288 | 287 | |
289 | 288 | return strtr(htmlspecialchars($value), $trans); |
290 | 289 | } |
291 | - if($level == 0) { |
|
290 | + if ($level == 0) { |
|
292 | 291 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
293 | 292 | $dumper = mt_rand(10, 99) . '|' . $varname; |
294 | 293 | } |
@@ -296,22 +295,22 @@ discard block |
||
296 | 295 | $type = gettype($value); |
297 | 296 | $dumper .= $type; |
298 | 297 | |
299 | - if($type == 'string') { |
|
298 | + if ($type == 'string') { |
|
300 | 299 | $dumper .= '(' . strlen($value) . ')'; |
301 | 300 | $value = dump($value, '', -1); |
302 | - } elseif($type == 'boolean') { |
|
301 | + } elseif ($type == 'boolean') { |
|
303 | 302 | $value = ($value ? 'true' : 'false'); |
304 | - } elseif($type == 'object') { |
|
303 | + } elseif ($type == 'object') { |
|
305 | 304 | $props = get_class_vars(get_class($value)); |
306 | 305 | $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
307 | - foreach($props as $key => $val) { |
|
306 | + foreach ($props as $key => $val) { |
|
308 | 307 | $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
309 | 308 | $dumper .= dump($value->$key, '', $level + 1); |
310 | 309 | } |
311 | 310 | $value = ''; |
312 | - } elseif($type == 'array') { |
|
311 | + } elseif ($type == 'array') { |
|
313 | 312 | $dumper .= '(' . count($value) . ')'; |
314 | - foreach($value as $key => $val) { |
|
313 | + foreach ($value as $key => $val) { |
|
315 | 314 | $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
316 | 315 | $dumper .= dump($val, '', $level + 1); |
317 | 316 | } |
@@ -331,7 +330,7 @@ discard block |
||
331 | 330 | // $backtrace = $backtrace[1]; |
332 | 331 | |
333 | 332 | $caller = ''; |
334 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
333 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
335 | 334 | $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
336 | 335 | (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
337 | 336 | $backtrace[1]['function'] . |
@@ -358,7 +357,7 @@ discard block |
||
358 | 357 | } |
359 | 358 | |
360 | 359 | function pr($prePrint = false) { |
361 | - if($prePrint) { |
|
360 | + if ($prePrint) { |
|
362 | 361 | print("<br>"); |
363 | 362 | } |
364 | 363 | print(mt_rand() . "<br>"); |
@@ -368,7 +367,7 @@ discard block |
||
368 | 367 | global $_PRINT_COUNT_VALUE; |
369 | 368 | $_PRINT_COUNT_VALUE++; |
370 | 369 | |
371 | - if($prePrint) { |
|
370 | + if ($prePrint) { |
|
372 | 371 | print("<br>"); |
373 | 372 | } |
374 | 373 | print($_PRINT_COUNT_VALUE . "<br>"); |
@@ -15,34 +15,34 @@ discard block |
||
15 | 15 | $template = gettemplate('notes', true); |
16 | 16 | |
17 | 17 | $result = array(); |
18 | -if(($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) { |
|
18 | +if (($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) { |
|
19 | 19 | $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => $lang[$result_message]); |
20 | 20 | } |
21 | 21 | |
22 | 22 | $note_id_edit = sys_get_param_id('note_id_edit'); |
23 | -if(sys_get_param('note_delete')) { |
|
23 | +if (sys_get_param('note_delete')) { |
|
24 | 24 | try { |
25 | 25 | $not = ''; |
26 | 26 | $query_where = ''; |
27 | - switch(sys_get_param_str('note_delete_range')) { |
|
27 | + switch (sys_get_param_str('note_delete_range')) { |
|
28 | 28 | case 'all': |
29 | 29 | break; |
30 | 30 | |
31 | 31 | case 'marked_not': |
32 | 32 | $not = 'NOT'; |
33 | 33 | case 'marked': |
34 | - if(!is_array($notes_marked = sys_get_param('note'))) { |
|
34 | + if (!is_array($notes_marked = sys_get_param('note'))) { |
|
35 | 35 | throw new exception('note_err_none_selected', ERR_WARNING); |
36 | 36 | } |
37 | 37 | |
38 | 38 | $notes_marked_filtered = array(); |
39 | - foreach($notes_marked as $note_id => $note_select) { |
|
40 | - if($note_select == 'on' && $note_id = idval($note_id)) { |
|
39 | + foreach ($notes_marked as $note_id => $note_select) { |
|
40 | + if ($note_select == 'on' && $note_id = idval($note_id)) { |
|
41 | 41 | $notes_marked_filtered[] = $note_id; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | - if(empty($notes_marked_filtered)) { |
|
45 | + if (empty($notes_marked_filtered)) { |
|
46 | 46 | throw new exception('note_err_none_selected', ERR_WARNING); |
47 | 47 | } |
48 | 48 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | doquery("DELETE FROM {{notes}} WHERE `owner` = {$user['id']} {$query_where};"); |
60 | 60 | sn_db_transaction_commit(); |
61 | 61 | throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
62 | - } catch(exception $e) { |
|
62 | + } catch (exception $e) { |
|
63 | 63 | $note_id_edit = 0; |
64 | 64 | sn_db_transaction_rollback(); |
65 | 65 | $result[] = array( |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'MESSAGE' => $lang[$e->getMessage()], |
68 | 68 | ); |
69 | 69 | } |
70 | -} elseif(($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
70 | +} elseif (($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
71 | 71 | $note_title == db_escape($lang['note_new_title']) ? $note_title = '' : false; |
72 | 72 | ($note_text = sys_get_param_str('note_text')) == db_escape($lang['note_new_text']) ? $note_text = '' : false; |
73 | 73 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $note_system = max(0, min(sys_get_param_id('note_system'), classSupernova::$config->game_maxSystem)); |
77 | 77 | $note_planet = max(0, min(sys_get_param_id('note_planet'), classSupernova::$config->game_maxPlanet + 1)); |
78 | 78 | |
79 | - if(!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
79 | + if (!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
80 | 80 | throw new exception('note_err_note_empty', ERR_WARNING); |
81 | 81 | } |
82 | 82 | |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0; |
86 | 86 | |
87 | 87 | sn_db_transaction_start(); |
88 | - if($note_id_edit) { |
|
88 | + if ($note_id_edit) { |
|
89 | 89 | $check_note_id = doquery("SELECT `id`, `owner` FROM {{notes}} WHERE `id` = {$note_id_edit} LIMIT 1 FOR UPDATE", true); |
90 | - if(!$check_note_id) { |
|
90 | + if (!$check_note_id) { |
|
91 | 91 | throw new exception('note_err_note_not_found', ERR_ERROR); |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - if($note_id_edit) { |
|
96 | - if($check_note_id['owner'] != $user['id']) { |
|
95 | + if ($note_id_edit) { |
|
96 | + if ($check_note_id['owner'] != $user['id']) { |
|
97 | 97 | throw new exception('note_err_owner_wrong', ERR_ERROR); |
98 | 98 | } |
99 | 99 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | sn_db_transaction_commit(); |
109 | 109 | sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added')); |
110 | 110 | // throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
111 | - } catch(exception $e) { |
|
111 | + } catch (exception $e) { |
|
112 | 112 | $note_id_edit = 0; |
113 | 113 | sn_db_transaction_rollback(); |
114 | 114 | $result[] = array( |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | -if(!$note_id_edit) { |
|
121 | +if (!$note_id_edit) { |
|
122 | 122 | note_assign($template, array( |
123 | 123 | 'id' => 0, |
124 | 124 | 'time' => SN_TIME_NOW, |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | |
132 | 132 | $note_exist = false; |
133 | 133 | $notes_query = doquery("SELECT * FROM {{notes}} WHERE owner={$user['id']} ORDER BY priority DESC, galaxy ASC, system ASC, planet ASC, planet_type ASC, `time` DESC"); |
134 | -while($note_row = db_fetch($notes_query)) { |
|
134 | +while ($note_row = db_fetch($notes_query)) { |
|
135 | 135 | note_assign($template, $note_row); |
136 | 136 | $note_exist = $note_exist || $note_row['id'] == $note_id_edit; |
137 | 137 | } |
138 | 138 | $note_id_edit = $note_exist ? $note_id_edit : 0; |
139 | 139 | |
140 | -foreach($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
140 | +foreach ($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
141 | 141 | $template->assign_block_vars('note_priority', array( |
142 | 142 | 'ID' => $note_priority_id, |
143 | 143 | 'CLASS' => $note_priority_classes[$note_priority_id], |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | )); |
146 | 146 | } |
147 | 147 | |
148 | -foreach($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
148 | +foreach ($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
149 | 149 | $template->assign_block_vars('planet_type', array( |
150 | 150 | 'ID' => $planet_type_id, |
151 | 151 | 'TEXT' => $planet_type_string, |
152 | 152 | )); |
153 | 153 | } |
154 | 154 | |
155 | -foreach($result as $result_data) { |
|
155 | +foreach ($result as $result_data) { |
|
156 | 156 | $template->assign_block_vars('result', $result_data); |
157 | 157 | } |
158 | 158 |
@@ -27,19 +27,19 @@ discard block |
||
27 | 27 | */ |
28 | 28 | function db_set_make_safe_string($set, $delta = false) { |
29 | 29 | $set_safe = array(); |
30 | - foreach($set as $field => $value) { |
|
31 | - if(empty($field)) { |
|
30 | + foreach ($set as $field => $value) { |
|
31 | + if (empty($field)) { |
|
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | 35 | $field = '`' . db_escape($field) . '`'; |
36 | 36 | $new_value = $value; |
37 | - if($value === null) { |
|
37 | + if ($value === null) { |
|
38 | 38 | $new_value = 'NULL'; |
39 | - } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) { |
|
39 | + } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) { |
|
40 | 40 | // non-float |
41 | 41 | $new_value = '"' . db_escape($value) . '"'; |
42 | - } elseif($delta) { |
|
42 | + } elseif ($delta) { |
|
43 | 43 | // float and DELTA-set |
44 | 44 | $new_value = "{$field} + ({$new_value})"; |
45 | 45 | } |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function missile_list_convert_to_fleet(&$missile_db_list, &$fleet_db_list) { |
61 | 61 | // Missile attack |
62 | - foreach($missile_db_list as $irak) { |
|
63 | - if($irak['fleet_end_time'] >= SN_TIME_NOW) { |
|
62 | + foreach ($missile_db_list as $irak) { |
|
63 | + if ($irak['fleet_end_time'] >= SN_TIME_NOW) { |
|
64 | 64 | $irak['fleet_start_type'] = PT_PLANET; |
65 | 65 | $planet_start = DBStaticPlanet::db_planet_by_vector($irak, 'fleet_start_', false, 'name'); |
66 | 66 | $irak['fleet_id'] = -$irak['id']; |