@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @var array Which databases support this method? |
| 35 | 35 | */ |
| 36 | - protected $supported_databases = array('mysql','postgresql'); |
|
| 36 | + protected $supported_databases = array('mysql', 'postgresql'); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * The constructor function |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | $query_where = array(); |
| 177 | 177 | $query_params = $search_data['params']; |
| 178 | 178 | |
| 179 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
| 179 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
| 180 | 180 | $modSettings['search_simple_fulltext'] = true; |
| 181 | 181 | |
| 182 | 182 | if ($query_params['id_search']) |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | // if we have bool terms to search, add them in |
| 257 | 257 | if ($query_params['boolean_match']) |
| 258 | 258 | { |
| 259 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
| 259 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
| 260 | 260 | { |
| 261 | 261 | $language_ftx = $smcFunc['db_search_language'](); |
| 262 | 262 | |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
| 271 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
| 272 | 272 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
| 273 | 273 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
| 274 | 274 | SELECT ' . implode(', ', $query_select) . ' |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Class fulltext_search |
@@ -75,8 +76,9 @@ discard block |
||
| 75 | 76 | } |
| 76 | 77 | |
| 77 | 78 | // Maybe parent got support |
| 78 | - if (!$return) |
|
| 79 | - $return = parent::supportsMethod($methodName, $query_params); |
|
| 79 | + if (!$return) { |
|
| 80 | + $return = parent::supportsMethod($methodName, $query_params); |
|
| 81 | + } |
|
| 80 | 82 | |
| 81 | 83 | return $return; |
| 82 | 84 | } |
@@ -92,8 +94,9 @@ discard block |
||
| 92 | 94 | { |
| 93 | 95 | global $smcFunc, $db_type; |
| 94 | 96 | |
| 95 | - if ($db_type == 'postgresql') |
|
| 96 | - return 0; |
|
| 97 | + if ($db_type == 'postgresql') { |
|
| 98 | + return 0; |
|
| 99 | + } |
|
| 97 | 100 | // Try to determine the minimum number of letters for a fulltext search. |
| 98 | 101 | $request = $smcFunc['db_search_query']('max_fulltext_length', ' |
| 99 | 102 | SHOW VARIABLES |
@@ -108,8 +111,9 @@ discard block |
||
| 108 | 111 | $smcFunc['db_free_result']($request); |
| 109 | 112 | } |
| 110 | 113 | // 4 is the MySQL default... |
| 111 | - else |
|
| 112 | - $min_word_length = 4; |
|
| 114 | + else { |
|
| 115 | + $min_word_length = 4; |
|
| 116 | + } |
|
| 113 | 117 | |
| 114 | 118 | return $min_word_length; |
| 115 | 119 | } |
@@ -148,8 +152,7 @@ discard block |
||
| 148 | 152 | $wordsSearch['words'][] = trim($word, "/*- "); |
| 149 | 153 | $wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"'; |
| 150 | 154 | } |
| 151 | - } |
|
| 152 | - elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
| 155 | + } elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
| 153 | 156 | { |
| 154 | 157 | // short words have feelings too |
| 155 | 158 | $wordsSearch['words'][] = trim($word, "/*- "); |
@@ -159,8 +162,9 @@ discard block |
||
| 159 | 162 | |
| 160 | 163 | $fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"'; |
| 161 | 164 | $wordsSearch['indexed_words'][] = $fulltextWord; |
| 162 | - if ($isExcluded) |
|
| 163 | - $wordsExclude[] = $fulltextWord; |
|
| 165 | + if ($isExcluded) { |
|
| 166 | + $wordsExclude[] = $fulltextWord; |
|
| 167 | + } |
|
| 164 | 168 | } |
| 165 | 169 | |
| 166 | 170 | /** |
@@ -176,44 +180,54 @@ discard block |
||
| 176 | 180 | $query_where = array(); |
| 177 | 181 | $query_params = $search_data['params']; |
| 178 | 182 | |
| 179 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
| 180 | - $modSettings['search_simple_fulltext'] = true; |
|
| 183 | + if( $smcFunc['db_title'] == "PostgreSQL") { |
|
| 184 | + $modSettings['search_simple_fulltext'] = true; |
|
| 185 | + } |
|
| 181 | 186 | |
| 182 | - if ($query_params['id_search']) |
|
| 183 | - $query_select['id_search'] = '{int:id_search}'; |
|
| 187 | + if ($query_params['id_search']) { |
|
| 188 | + $query_select['id_search'] = '{int:id_search}'; |
|
| 189 | + } |
|
| 184 | 190 | |
| 185 | 191 | $count = 0; |
| 186 | - if (empty($modSettings['search_simple_fulltext'])) |
|
| 187 | - foreach ($words['words'] as $regularWord) |
|
| 192 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
| 193 | + foreach ($words['words'] as $regularWord) |
|
| 188 | 194 | { |
| 189 | 195 | $query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}'; |
| 196 | + } |
|
| 190 | 197 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
| 191 | 198 | } |
| 192 | 199 | |
| 193 | - if ($query_params['user_query']) |
|
| 194 | - $query_where[] = '{raw:user_query}'; |
|
| 195 | - if ($query_params['board_query']) |
|
| 196 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 200 | + if ($query_params['user_query']) { |
|
| 201 | + $query_where[] = '{raw:user_query}'; |
|
| 202 | + } |
|
| 203 | + if ($query_params['board_query']) { |
|
| 204 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 205 | + } |
|
| 197 | 206 | |
| 198 | - if ($query_params['topic']) |
|
| 199 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 200 | - if ($query_params['min_msg_id']) |
|
| 201 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 202 | - if ($query_params['max_msg_id']) |
|
| 203 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 207 | + if ($query_params['topic']) { |
|
| 208 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 209 | + } |
|
| 210 | + if ($query_params['min_msg_id']) { |
|
| 211 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 212 | + } |
|
| 213 | + if ($query_params['max_msg_id']) { |
|
| 214 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 215 | + } |
|
| 204 | 216 | |
| 205 | 217 | $count = 0; |
| 206 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
| 207 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 218 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
| 219 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 208 | 220 | { |
| 209 | 221 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}'; |
| 222 | + } |
|
| 210 | 223 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
| 211 | 224 | } |
| 212 | 225 | $count = 0; |
| 213 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
| 214 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 226 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
| 227 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 215 | 228 | { |
| 216 | 229 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}'; |
| 230 | + } |
|
| 217 | 231 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
| 218 | 232 | } |
| 219 | 233 | |
@@ -225,12 +239,11 @@ discard block |
||
| 225 | 239 | |
| 226 | 240 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:body_match})'; |
| 227 | 241 | $query_params['language_ftx'] = $language_ftx; |
| 242 | + } else { |
|
| 243 | + $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
| 228 | 244 | } |
| 229 | - else |
|
| 230 | - $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
| 231 | 245 | $query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words'])); |
| 232 | - } |
|
| 233 | - else |
|
| 246 | + } else |
|
| 234 | 247 | { |
| 235 | 248 | $query_params['boolean_match'] = ''; |
| 236 | 249 | |
@@ -246,10 +259,10 @@ discard block |
||
| 246 | 259 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' '; |
| 247 | 260 | $row++; |
| 248 | 261 | } |
| 249 | - } |
|
| 250 | - else |
|
| 251 | - foreach ($words['indexed_words'] as $fulltextWord) |
|
| 262 | + } else { |
|
| 263 | + foreach ($words['indexed_words'] as $fulltextWord) |
|
| 252 | 264 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' '; |
| 265 | + } |
|
| 253 | 266 | |
| 254 | 267 | $query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1); |
| 255 | 268 | |
@@ -262,9 +275,9 @@ discard block |
||
| 262 | 275 | |
| 263 | 276 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:boolean_match})'; |
| 264 | 277 | $query_params['language_ftx'] = $language_ftx; |
| 278 | + } else { |
|
| 279 | + $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
| 265 | 280 | } |
| 266 | - else |
|
| 267 | - $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
| 268 | 281 | } |
| 269 | 282 | } |
| 270 | 283 | |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Standard non full index, non custom index search |
@@ -27,8 +28,9 @@ discard block |
||
| 27 | 28 | $return = false; |
| 28 | 29 | |
| 29 | 30 | // Maybe parent got support |
| 30 | - if (!$return) |
|
| 31 | - $return = parent::supportsMethod($methodName, $query_params); |
|
| 31 | + if (!$return) { |
|
| 32 | + $return = parent::supportsMethod($methodName, $query_params); |
|
| 33 | + } |
|
| 32 | 34 | |
| 33 | 35 | return $return; |
| 34 | 36 | } |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
| 54 | 55 | return; |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | - if (empty($modSettings['search_custom_index_config'])) |
|
| 58 | - return; |
|
| 58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
| 59 | + return; |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | $this->indexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
| 61 | 63 | |
@@ -86,8 +88,9 @@ discard block |
||
| 86 | 88 | } |
| 87 | 89 | |
| 88 | 90 | // Maybe parent got support |
| 89 | - if (!$return) |
|
| 90 | - $return = parent::supportsMethod($methodName, $query_params); |
|
| 91 | + if (!$return) { |
|
| 92 | + $return = parent::supportsMethod($methodName, $query_params); |
|
| 93 | + } |
|
| 91 | 94 | |
| 92 | 95 | return $return; |
| 93 | 96 | } |
@@ -124,21 +127,23 @@ discard block |
||
| 124 | 127 | |
| 125 | 128 | $subwords = text2words($word, $this->min_word_length, true); |
| 126 | 129 | |
| 127 | - if (empty($modSettings['search_force_index'])) |
|
| 128 | - $wordsSearch['words'][] = $word; |
|
| 130 | + if (empty($modSettings['search_force_index'])) { |
|
| 131 | + $wordsSearch['words'][] = $word; |
|
| 132 | + } |
|
| 129 | 133 | |
| 130 | 134 | // Excluded phrases don't benefit from being split into subwords. |
| 131 | - if (count($subwords) > 1 && $isExcluded) |
|
| 132 | - return; |
|
| 133 | - else |
|
| 135 | + if (count($subwords) > 1 && $isExcluded) { |
|
| 136 | + return; |
|
| 137 | + } else |
|
| 134 | 138 | { |
| 135 | 139 | foreach ($subwords as $subword) |
| 136 | 140 | { |
| 137 | 141 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
| 138 | 142 | { |
| 139 | 143 | $wordsSearch['indexed_words'][] = $subword; |
| 140 | - if ($isExcluded) |
|
| 141 | - $wordsExclude[] = $subword; |
|
| 144 | + if ($isExcluded) { |
|
| 145 | + $wordsExclude[] = $subword; |
|
| 146 | + } |
|
| 142 | 147 | } |
| 143 | 148 | } |
| 144 | 149 | } |
@@ -159,8 +164,9 @@ discard block |
||
| 159 | 164 | $query_where = array(); |
| 160 | 165 | $query_params = $search_data['params']; |
| 161 | 166 | |
| 162 | - if ($query_params['id_search']) |
|
| 163 | - $query_select['id_search'] = '{int:id_search}'; |
|
| 167 | + if ($query_params['id_search']) { |
|
| 168 | + $query_select['id_search'] = '{int:id_search}'; |
|
| 169 | + } |
|
| 164 | 170 | |
| 165 | 171 | $count = 0; |
| 166 | 172 | foreach ($words['words'] as $regularWord) |
@@ -169,30 +175,37 @@ discard block |
||
| 169 | 175 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
| 170 | 176 | } |
| 171 | 177 | |
| 172 | - if ($query_params['user_query']) |
|
| 173 | - $query_where[] = '{raw:user_query}'; |
|
| 174 | - if ($query_params['board_query']) |
|
| 175 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 178 | + if ($query_params['user_query']) { |
|
| 179 | + $query_where[] = '{raw:user_query}'; |
|
| 180 | + } |
|
| 181 | + if ($query_params['board_query']) { |
|
| 182 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 183 | + } |
|
| 176 | 184 | |
| 177 | - if ($query_params['topic']) |
|
| 178 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 179 | - if ($query_params['min_msg_id']) |
|
| 180 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 181 | - if ($query_params['max_msg_id']) |
|
| 182 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 185 | + if ($query_params['topic']) { |
|
| 186 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 187 | + } |
|
| 188 | + if ($query_params['min_msg_id']) { |
|
| 189 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 190 | + } |
|
| 191 | + if ($query_params['max_msg_id']) { |
|
| 192 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 193 | + } |
|
| 183 | 194 | |
| 184 | 195 | $count = 0; |
| 185 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
| 186 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 196 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
| 197 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 187 | 198 | { |
| 188 | 199 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
| 200 | + } |
|
| 189 | 201 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
| 190 | 202 | } |
| 191 | 203 | $count = 0; |
| 192 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
| 193 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 204 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
| 205 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 194 | 206 | { |
| 195 | 207 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
| 208 | + } |
|
| 196 | 209 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
| 197 | 210 | } |
| 198 | 211 | |
@@ -205,8 +218,7 @@ discard block |
||
| 205 | 218 | { |
| 206 | 219 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
| 207 | 220 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
| 208 | - } |
|
| 209 | - else |
|
| 221 | + } else |
|
| 210 | 222 | { |
| 211 | 223 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
| 212 | 224 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -242,16 +254,18 @@ discard block |
||
| 242 | 254 | $customIndexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
| 243 | 255 | |
| 244 | 256 | $inserts = array(); |
| 245 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
| 246 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 257 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
| 258 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 259 | + } |
|
| 247 | 260 | |
| 248 | - if (!empty($inserts)) |
|
| 249 | - $smcFunc['db_insert']('ignore', |
|
| 261 | + if (!empty($inserts)) { |
|
| 262 | + $smcFunc['db_insert']('ignore', |
|
| 250 | 263 | '{db_prefix}log_search_words', |
| 251 | 264 | array('id_word' => 'int', 'id_msg' => 'int'), |
| 252 | 265 | $inserts, |
| 253 | 266 | array('id_word', 'id_msg') |
| 254 | 267 | ); |
| 268 | + } |
|
| 255 | 269 | } |
| 256 | 270 | |
| 257 | 271 | /** |
@@ -294,8 +308,9 @@ discard block |
||
| 294 | 308 | if (!empty($inserted_words)) |
| 295 | 309 | { |
| 296 | 310 | $inserts = array(); |
| 297 | - foreach ($inserted_words as $word) |
|
| 298 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 311 | + foreach ($inserted_words as $word) { |
|
| 312 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 313 | + } |
|
| 299 | 314 | $smcFunc['db_insert']('insert', |
| 300 | 315 | '{db_prefix}log_search_words', |
| 301 | 316 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -1229,8 +1229,8 @@ |
||
| 1229 | 1229 | continue; |
| 1230 | 1230 | |
| 1231 | 1231 | $final_saves[$string_key] = array( |
| 1232 | - 'find' => "\n\n?".'>', |
|
| 1233 | - 'replace' => "\n$" . $type . '[\'' . $string_key . '\'] = ' . $string_val['string'] . ';' . "\n\n?".'>', |
|
| 1232 | + 'find' => "\n\n?" . '>', |
|
| 1233 | + 'replace' => "\n$" . $type . '[\'' . $string_key . '\'] = ' . $string_val['string'] . ';' . "\n\n?" . '>', |
|
| 1234 | 1234 | ); |
| 1235 | 1235 | } |
| 1236 | 1236 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * This is the main function for the languages area. |
@@ -150,11 +151,11 @@ discard block |
||
| 150 | 151 | $language_list = new xmlArray(fetch_web_data($url), true); |
| 151 | 152 | |
| 152 | 153 | // Check that the site responded and that the language exists. |
| 153 | - if (!$language_list->exists('languages')) |
|
| 154 | - $context['smf_error'] = 'no_response'; |
|
| 155 | - elseif (!$language_list->exists('languages/language')) |
|
| 156 | - $context['smf_error'] = 'no_files'; |
|
| 157 | - else |
|
| 154 | + if (!$language_list->exists('languages')) { |
|
| 155 | + $context['smf_error'] = 'no_response'; |
|
| 156 | + } elseif (!$language_list->exists('languages/language')) { |
|
| 157 | + $context['smf_error'] = 'no_files'; |
|
| 158 | + } else |
|
| 158 | 159 | { |
| 159 | 160 | $language_list = $language_list->path('languages[0]'); |
| 160 | 161 | $lang_files = $language_list->set('language'); |
@@ -162,8 +163,9 @@ discard block |
||
| 162 | 163 | foreach ($lang_files as $file) |
| 163 | 164 | { |
| 164 | 165 | // Were we searching? |
| 165 | - if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) |
|
| 166 | - continue; |
|
| 166 | + if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) { |
|
| 167 | + continue; |
|
| 168 | + } |
|
| 167 | 169 | |
| 168 | 170 | $smf_languages[] = array( |
| 169 | 171 | 'id' => $file->fetch('id'), |
@@ -174,10 +176,11 @@ discard block |
||
| 174 | 176 | 'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>', |
| 175 | 177 | ); |
| 176 | 178 | } |
| 177 | - if (empty($smf_languages)) |
|
| 178 | - $context['smf_error'] = 'no_files'; |
|
| 179 | - else |
|
| 180 | - return $smf_languages; |
|
| 179 | + if (empty($smf_languages)) { |
|
| 180 | + $context['smf_error'] = 'no_files'; |
|
| 181 | + } else { |
|
| 182 | + return $smf_languages; |
|
| 183 | + } |
|
| 181 | 184 | } |
| 182 | 185 | } |
| 183 | 186 | |
@@ -199,8 +202,9 @@ discard block |
||
| 199 | 202 | require_once($sourcedir . '/Subs-Package.php'); |
| 200 | 203 | |
| 201 | 204 | // Clearly we need to know what to request. |
| 202 | - if (!isset($_GET['did'])) |
|
| 203 | - fatal_lang_error('no_access', false); |
|
| 205 | + if (!isset($_GET['did'])) { |
|
| 206 | + fatal_lang_error('no_access', false); |
|
| 207 | + } |
|
| 204 | 208 | |
| 205 | 209 | // Some lovely context. |
| 206 | 210 | $context['download_id'] = $_GET['did']; |
@@ -220,8 +224,9 @@ discard block |
||
| 220 | 224 | foreach ($_POST['copy_file'] as $file) |
| 221 | 225 | { |
| 222 | 226 | // Check it's not very bad. |
| 223 | - if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) |
|
| 224 | - fatal_error($txt['languages_download_illegal_paths']); |
|
| 227 | + if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) { |
|
| 228 | + fatal_error($txt['languages_download_illegal_paths']); |
|
| 229 | + } |
|
| 225 | 230 | |
| 226 | 231 | $chmod_files[] = $boarddir . '/' . $file; |
| 227 | 232 | $install_files[] = $file; |
@@ -232,8 +237,9 @@ discard block |
||
| 232 | 237 | $files_left = $file_status['files']['notwritable']; |
| 233 | 238 | |
| 234 | 239 | // Something not writable? |
| 235 | - if (!empty($files_left)) |
|
| 236 | - $context['error_message'] = $txt['languages_download_not_chmod']; |
|
| 240 | + if (!empty($files_left)) { |
|
| 241 | + $context['error_message'] = $txt['languages_download_not_chmod']; |
|
| 242 | + } |
|
| 237 | 243 | // Otherwise, go go go! |
| 238 | 244 | elseif (!empty($install_files)) |
| 239 | 245 | { |
@@ -248,11 +254,13 @@ discard block |
||
| 248 | 254 | } |
| 249 | 255 | |
| 250 | 256 | // Open up the old china. |
| 251 | - if (!isset($archive_content)) |
|
| 252 | - $archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
| 257 | + if (!isset($archive_content)) { |
|
| 258 | + $archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
| 259 | + } |
|
| 253 | 260 | |
| 254 | - if (empty($archive_content)) |
|
| 255 | - fatal_error($txt['add_language_error_no_response']); |
|
| 261 | + if (empty($archive_content)) { |
|
| 262 | + fatal_error($txt['add_language_error_no_response']); |
|
| 263 | + } |
|
| 256 | 264 | |
| 257 | 265 | // Now for each of the files, let's do some *stuff* |
| 258 | 266 | $context['files'] = array( |
@@ -267,8 +275,9 @@ discard block |
||
| 267 | 275 | $extension = substr($filename, strrpos($filename, '.') + 1); |
| 268 | 276 | |
| 269 | 277 | // Don't do anything with files we don't understand. |
| 270 | - if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) |
|
| 271 | - continue; |
|
| 278 | + if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) { |
|
| 279 | + continue; |
|
| 280 | + } |
|
| 272 | 281 | |
| 273 | 282 | // Basic data. |
| 274 | 283 | $context_data = array( |
@@ -287,8 +296,9 @@ discard block |
||
| 287 | 296 | // Does the file exist, is it different and can we overwrite? |
| 288 | 297 | if (file_exists($boarddir . '/' . $file['filename'])) |
| 289 | 298 | { |
| 290 | - if (is_writable($boarddir . '/' . $file['filename'])) |
|
| 291 | - $context_data['writable'] = true; |
|
| 299 | + if (is_writable($boarddir . '/' . $file['filename'])) { |
|
| 300 | + $context_data['writable'] = true; |
|
| 301 | + } |
|
| 292 | 302 | |
| 293 | 303 | // Finally, do we actually think the content has changed? |
| 294 | 304 | if ($file['size'] == filesize($boarddir . '/' . $file['filename']) && $file['md5'] == md5_file($boarddir . '/' . $file['filename'])) |
@@ -301,16 +311,17 @@ discard block |
||
| 301 | 311 | { |
| 302 | 312 | $context_data['exists'] = 'same'; |
| 303 | 313 | $context_data['default_copy'] = false; |
| 314 | + } else { |
|
| 315 | + $context_data['exists'] = 'different'; |
|
| 304 | 316 | } |
| 305 | - else |
|
| 306 | - $context_data['exists'] = 'different'; |
|
| 307 | 317 | } |
| 308 | 318 | // No overwrite? |
| 309 | 319 | else |
| 310 | 320 | { |
| 311 | 321 | // Can we at least stick it in the directory... |
| 312 | - if (is_writable($boarddir . '/' . $dirname)) |
|
| 313 | - $context_data['writable'] = true; |
|
| 322 | + if (is_writable($boarddir . '/' . $dirname)) { |
|
| 323 | + $context_data['writable'] = true; |
|
| 324 | + } |
|
| 314 | 325 | } |
| 315 | 326 | |
| 316 | 327 | // I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin... |
@@ -325,8 +336,9 @@ discard block |
||
| 325 | 336 | list ($name, $language) = explode('.', $filename); |
| 326 | 337 | |
| 327 | 338 | // Let's get the new version, I like versions, they tell me that I'm up to date. |
| 328 | - if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) |
|
| 329 | - $context_data['version'] = $match[1]; |
|
| 339 | + if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) { |
|
| 340 | + $context_data['version'] = $match[1]; |
|
| 341 | + } |
|
| 330 | 342 | |
| 331 | 343 | // Now does the old file exist - if so what is it's version? |
| 332 | 344 | if (file_exists($boarddir . '/' . $file['filename'])) |
@@ -342,34 +354,35 @@ discard block |
||
| 342 | 354 | $context_data['cur_version'] = $match[1]; |
| 343 | 355 | |
| 344 | 356 | // How does this compare? |
| 345 | - if ($context_data['cur_version'] == $context_data['version']) |
|
| 346 | - $context_data['version_compare'] = 'same'; |
|
| 347 | - elseif ($context_data['cur_version'] > $context_data['version']) |
|
| 348 | - $context_data['version_compare'] = 'older'; |
|
| 357 | + if ($context_data['cur_version'] == $context_data['version']) { |
|
| 358 | + $context_data['version_compare'] = 'same'; |
|
| 359 | + } elseif ($context_data['cur_version'] > $context_data['version']) { |
|
| 360 | + $context_data['version_compare'] = 'older'; |
|
| 361 | + } |
|
| 349 | 362 | |
| 350 | 363 | // Don't recommend copying if the version is the same. |
| 351 | - if ($context_data['version_compare'] != 'newer') |
|
| 352 | - $context_data['default_copy'] = false; |
|
| 364 | + if ($context_data['version_compare'] != 'newer') { |
|
| 365 | + $context_data['default_copy'] = false; |
|
| 366 | + } |
|
| 353 | 367 | } |
| 354 | 368 | } |
| 355 | 369 | |
| 356 | 370 | // Add the context data to the main set. |
| 357 | 371 | $context['files']['lang'][] = $context_data; |
| 358 | - } |
|
| 359 | - elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
| 372 | + } elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
| 360 | 373 | { |
| 361 | 374 | // Registration agreement is a primary file |
| 362 | 375 | $context['files']['lang'][] = $context_data; |
| 363 | - } |
|
| 364 | - else |
|
| 376 | + } else |
|
| 365 | 377 | { |
| 366 | 378 | // There shouldn't be anything else, but load this into "other" in case we decide to handle it in the future |
| 367 | 379 | $context['files']['other'][] = $context_data; |
| 368 | 380 | } |
| 369 | 381 | |
| 370 | 382 | // Collect together all non-writable areas. |
| 371 | - if (!$context_data['writable']) |
|
| 372 | - $context['make_writable'][] = $context_data['destination']; |
|
| 383 | + if (!$context_data['writable']) { |
|
| 384 | + $context['make_writable'][] = $context_data['destination']; |
|
| 385 | + } |
|
| 373 | 386 | } |
| 374 | 387 | |
| 375 | 388 | // Before we go to far can we make anything writable, eh, eh? |
@@ -384,22 +397,24 @@ discard block |
||
| 384 | 397 | { |
| 385 | 398 | if ($type == 'lang') |
| 386 | 399 | { |
| 387 | - foreach ($data as $k => $file) |
|
| 388 | - if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
| 400 | + foreach ($data as $k => $file) { |
|
| 401 | + if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
| 389 | 402 | $context['files'][$type][$k]['writable'] = true; |
| 390 | - } |
|
| 391 | - else |
|
| 403 | + } |
|
| 404 | + } else |
|
| 392 | 405 | { |
| 393 | - foreach ($data as $theme => $files) |
|
| 394 | - foreach ($files as $k => $file) |
|
| 406 | + foreach ($data as $theme => $files) { |
|
| 407 | + foreach ($files as $k => $file) |
|
| 395 | 408 | if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
| 396 | 409 | $context['files'][$type][$theme][$k]['writable'] = true; |
| 410 | + } |
|
| 397 | 411 | } |
| 398 | 412 | } |
| 399 | 413 | |
| 400 | 414 | // Are we going to need more language stuff? |
| 401 | - if (!empty($context['still_not_writable'])) |
|
| 402 | - loadLanguage('Packages'); |
|
| 415 | + if (!empty($context['still_not_writable'])) { |
|
| 416 | + loadLanguage('Packages'); |
|
| 417 | + } |
|
| 403 | 418 | } |
| 404 | 419 | |
| 405 | 420 | // This is the list for the main files. |
@@ -612,12 +627,13 @@ discard block |
||
| 612 | 627 | highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '");', true); |
| 613 | 628 | |
| 614 | 629 | // Display a warning if we cannot edit the default setting. |
| 615 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 616 | - $listOptions['additional_rows'][] = array( |
|
| 630 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 631 | + $listOptions['additional_rows'][] = array( |
|
| 617 | 632 | 'position' => 'after_title', |
| 618 | 633 | 'value' => $txt['language_settings_writable'], |
| 619 | 634 | 'class' => 'smalltext alert', |
| 620 | 635 | ); |
| 636 | + } |
|
| 621 | 637 | |
| 622 | 638 | require_once($sourcedir . '/Subs-List.php'); |
| 623 | 639 | createList($listOptions); |
@@ -659,10 +675,11 @@ discard block |
||
| 659 | 675 | |
| 660 | 676 | // Put them back. |
| 661 | 677 | $settings['actual_theme_dir'] = $backup_actual_theme_dir; |
| 662 | - if (!empty($backup_base_theme_dir)) |
|
| 663 | - $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
| 664 | - else |
|
| 665 | - unset($settings['base_theme_dir']); |
|
| 678 | + if (!empty($backup_base_theme_dir)) { |
|
| 679 | + $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
| 680 | + } else { |
|
| 681 | + unset($settings['base_theme_dir']); |
|
| 682 | + } |
|
| 666 | 683 | |
| 667 | 684 | // Get the language files and data... |
| 668 | 685 | foreach ($context['languages'] as $lang) |
@@ -691,13 +708,15 @@ discard block |
||
| 691 | 708 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 692 | 709 | { |
| 693 | 710 | // Default? |
| 694 | - if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) |
|
| 695 | - $row['lngfile'] = $language; |
|
| 711 | + if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) { |
|
| 712 | + $row['lngfile'] = $language; |
|
| 713 | + } |
|
| 696 | 714 | |
| 697 | - if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) |
|
| 698 | - $languages['english']['count'] += $row['num_users']; |
|
| 699 | - elseif (isset($languages[$row['lngfile']])) |
|
| 700 | - $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
| 715 | + if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) { |
|
| 716 | + $languages['english']['count'] += $row['num_users']; |
|
| 717 | + } elseif (isset($languages[$row['lngfile']])) { |
|
| 718 | + $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
| 719 | + } |
|
| 701 | 720 | } |
| 702 | 721 | $smcFunc['db_free_result']($request); |
| 703 | 722 | |
@@ -737,13 +756,15 @@ discard block |
||
| 737 | 756 | |
| 738 | 757 | call_integration_hook('integrate_language_settings', array(&$config_vars)); |
| 739 | 758 | |
| 740 | - if ($return_config) |
|
| 741 | - return $config_vars; |
|
| 759 | + if ($return_config) { |
|
| 760 | + return $config_vars; |
|
| 761 | + } |
|
| 742 | 762 | |
| 743 | 763 | // Get our languages. No cache |
| 744 | 764 | getLanguages(false); |
| 745 | - foreach ($context['languages'] as $lang) |
|
| 746 | - $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']); |
|
| 765 | + foreach ($context['languages'] as $lang) { |
|
| 766 | + $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']); |
|
| 767 | + } |
|
| 747 | 768 | |
| 748 | 769 | // Saving settings? |
| 749 | 770 | if (isset($_REQUEST['save'])) |
@@ -753,8 +774,9 @@ discard block |
||
| 753 | 774 | call_integration_hook('integrate_save_language_settings', array(&$config_vars)); |
| 754 | 775 | |
| 755 | 776 | saveSettings($config_vars); |
| 756 | - if (!$settings_not_writable && !$settings_backup_fail) |
|
| 757 | - $_SESSION['adm-save'] = true; |
|
| 777 | + if (!$settings_not_writable && !$settings_backup_fail) { |
|
| 778 | + $_SESSION['adm-save'] = true; |
|
| 779 | + } |
|
| 758 | 780 | redirectexit('action=admin;area=languages;sa=settings'); |
| 759 | 781 | } |
| 760 | 782 | |
@@ -763,10 +785,11 @@ discard block |
||
| 763 | 785 | $context['settings_title'] = $txt['language_settings']; |
| 764 | 786 | $context['save_disabled'] = $settings_not_writable; |
| 765 | 787 | |
| 766 | - if ($settings_not_writable) |
|
| 767 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 768 | - elseif ($settings_backup_fail) |
|
| 769 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 788 | + if ($settings_not_writable) { |
|
| 789 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 790 | + } elseif ($settings_backup_fail) { |
|
| 791 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 792 | + } |
|
| 770 | 793 | |
| 771 | 794 | // Fill the config array. |
| 772 | 795 | prepareServerSettingsContext($config_vars); |
@@ -813,8 +836,9 @@ discard block |
||
| 813 | 836 | 'theme_dir' => $settings['default_theme_dir'], |
| 814 | 837 | ), |
| 815 | 838 | ); |
| 816 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 817 | - $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 839 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 840 | + $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 841 | + } |
|
| 818 | 842 | $smcFunc['db_free_result']($request); |
| 819 | 843 | |
| 820 | 844 | // This will be where we look |
@@ -841,14 +865,16 @@ discard block |
||
| 841 | 865 | // Check we have themes with a path and a name - just in case - and add the path. |
| 842 | 866 | foreach ($themes as $id => $data) |
| 843 | 867 | { |
| 844 | - if (count($data) != 2) |
|
| 845 | - unset($themes[$id]); |
|
| 846 | - elseif (is_dir($data['theme_dir'] . '/languages')) |
|
| 847 | - $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
| 868 | + if (count($data) != 2) { |
|
| 869 | + unset($themes[$id]); |
|
| 870 | + } elseif (is_dir($data['theme_dir'] . '/languages')) { |
|
| 871 | + $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
| 872 | + } |
|
| 848 | 873 | |
| 849 | 874 | // How about image directories? |
| 850 | - if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) |
|
| 851 | - $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
| 875 | + if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) { |
|
| 876 | + $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
| 877 | + } |
|
| 852 | 878 | } |
| 853 | 879 | |
| 854 | 880 | $current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : ''; |
@@ -862,15 +888,17 @@ discard block |
||
| 862 | 888 | while ($entry = $dir->read()) |
| 863 | 889 | { |
| 864 | 890 | // We're only after the files for this language. |
| 865 | - if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) |
|
| 866 | - continue; |
|
| 891 | + if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) { |
|
| 892 | + continue; |
|
| 893 | + } |
|
| 867 | 894 | |
| 868 | - if (!isset($context['possible_files'][$theme])) |
|
| 869 | - $context['possible_files'][$theme] = array( |
|
| 895 | + if (!isset($context['possible_files'][$theme])) { |
|
| 896 | + $context['possible_files'][$theme] = array( |
|
| 870 | 897 | 'id' => $theme, |
| 871 | 898 | 'name' => $themes[$theme]['name'], |
| 872 | 899 | 'files' => array(), |
| 873 | 900 | ); |
| 901 | + } |
|
| 874 | 902 | |
| 875 | 903 | $context['possible_files'][$theme]['files'][] = array( |
| 876 | 904 | 'id' => $matches[1], |
@@ -899,31 +927,36 @@ discard block |
||
| 899 | 927 | { |
| 900 | 928 | $_SESSION['last_backup_for'] = $context['lang_id'] . '$$$'; |
| 901 | 929 | $result = package_create_backup('backup_lang_' . $context['lang_id']); |
| 902 | - if (!$result) |
|
| 903 | - fatal_lang_error('could_not_language_backup', false); |
|
| 930 | + if (!$result) { |
|
| 931 | + fatal_lang_error('could_not_language_backup', false); |
|
| 932 | + } |
|
| 904 | 933 | } |
| 905 | 934 | |
| 906 | 935 | // Second, loop through the array to remove the files. |
| 907 | 936 | foreach ($lang_dirs as $curPath) |
| 908 | 937 | { |
| 909 | - foreach ($context['possible_files'][1]['files'] as $lang) |
|
| 910 | - if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
| 938 | + foreach ($context['possible_files'][1]['files'] as $lang) { |
|
| 939 | + if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
| 911 | 940 | unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'); |
| 941 | + } |
|
| 912 | 942 | |
| 913 | 943 | // Check for the email template. |
| 914 | - if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) |
|
| 915 | - unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
| 944 | + if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) { |
|
| 945 | + unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
| 946 | + } |
|
| 916 | 947 | } |
| 917 | 948 | |
| 918 | 949 | // Third, the agreement file. |
| 919 | - if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) |
|
| 920 | - unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
| 950 | + if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) { |
|
| 951 | + unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
| 952 | + } |
|
| 921 | 953 | |
| 922 | 954 | // Fourth, a related images folder, if it exists... |
| 923 | - if (!empty($images_dirs)) |
|
| 924 | - foreach ($images_dirs as $curPath) |
|
| 955 | + if (!empty($images_dirs)) { |
|
| 956 | + foreach ($images_dirs as $curPath) |
|
| 925 | 957 | if (is_dir($curPath)) |
| 926 | 958 | deltree($curPath); |
| 959 | + } |
|
| 927 | 960 | |
| 928 | 961 | // Members can no longer use this language. |
| 929 | 962 | $smcFunc['db_query']('', ' |
@@ -1010,13 +1043,14 @@ discard block |
||
| 1010 | 1043 | foreach ($_POST['edit'] as $k => $v) |
| 1011 | 1044 | { |
| 1012 | 1045 | // Only try to save if 'edit' was specified and if the string has changed |
| 1013 | - if ($v == 'edit' && isset($_POST['entry'][$k]) && isset($_POST['comp'][$k]) && $_POST['entry'][$k] != $_POST['comp'][$k]) |
|
| 1014 | - $save_strings[$k] = cleanLangString($_POST['entry'][$k], false); |
|
| 1046 | + if ($v == 'edit' && isset($_POST['entry'][$k]) && isset($_POST['comp'][$k]) && $_POST['entry'][$k] != $_POST['comp'][$k]) { |
|
| 1047 | + $save_strings[$k] = cleanLangString($_POST['entry'][$k], false); |
|
| 1048 | + } |
|
| 1015 | 1049 | |
| 1016 | 1050 | // Record any add or remove requests. We'll decide on them later. |
| 1017 | - elseif ($v == 'remove') |
|
| 1018 | - $remove_strings[] = $k; |
|
| 1019 | - elseif ($v == 'add' && isset($_POST['entry'][$k])) |
|
| 1051 | + elseif ($v == 'remove') { |
|
| 1052 | + $remove_strings[] = $k; |
|
| 1053 | + } elseif ($v == 'add' && isset($_POST['entry'][$k])) |
|
| 1020 | 1054 | { |
| 1021 | 1055 | $add_strings[$k] = array( |
| 1022 | 1056 | 'group' => isset($_POST['grp'][$k]) ? $_POST['grp'][$k] : 'txt', |
@@ -1056,8 +1090,9 @@ discard block |
||
| 1056 | 1090 | { |
| 1057 | 1091 | $group = !empty($special_groups[$file_id][$matches[1]]) ? $special_groups[$file_id][$matches[1]] : $matches[1]; |
| 1058 | 1092 | |
| 1059 | - if (isset($allows_add_remove[$file_id]['add']) && in_array($matches[1], $allows_add_remove[$file_id]['add'])) |
|
| 1060 | - $context['can_add_lang_entry'][$group] = true; |
|
| 1093 | + if (isset($allows_add_remove[$file_id]['add']) && in_array($matches[1], $allows_add_remove[$file_id]['add'])) { |
|
| 1094 | + $context['can_add_lang_entry'][$group] = true; |
|
| 1095 | + } |
|
| 1061 | 1096 | |
| 1062 | 1097 | $entries[$matches[2]] = array( |
| 1063 | 1098 | 'type' => $matches[1], |
@@ -1079,8 +1114,9 @@ discard block |
||
| 1079 | 1114 | { |
| 1080 | 1115 | $group = !empty($special_groups[$file_id][$matches[1]]) ? $special_groups[$file_id][$matches[1]] : $matches[1]; |
| 1081 | 1116 | |
| 1082 | - if (isset($allows_add_remove[$file_id]['add']) && in_array($matches[1], $allows_add_remove[$file_id]['add'])) |
|
| 1083 | - $context['can_add_lang_entry'][$group] = true; |
|
| 1117 | + if (isset($allows_add_remove[$file_id]['add']) && in_array($matches[1], $allows_add_remove[$file_id]['add'])) { |
|
| 1118 | + $context['can_add_lang_entry'][$group] = true; |
|
| 1119 | + } |
|
| 1084 | 1120 | |
| 1085 | 1121 | $entries[$matches[2]] = array( |
| 1086 | 1122 | 'type' => $matches[1], |
@@ -1100,8 +1136,9 @@ discard block |
||
| 1100 | 1136 | { |
| 1101 | 1137 | // Ignore some things we set separately. |
| 1102 | 1138 | $ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl'); |
| 1103 | - if (in_array($entryKey, $ignore_files)) |
|
| 1104 | - continue; |
|
| 1139 | + if (in_array($entryKey, $ignore_files)) { |
|
| 1140 | + continue; |
|
| 1141 | + } |
|
| 1105 | 1142 | |
| 1106 | 1143 | // These are arrays that need breaking out. |
| 1107 | 1144 | $arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short'); |
@@ -1134,9 +1171,9 @@ discard block |
||
| 1134 | 1171 | { |
| 1135 | 1172 | $save_cache['entries'][$cur_index] = strtr($save_strings[$entryKey . '-+- ' . $cur_index], array('\'' => '')); |
| 1136 | 1173 | $save_cache['enabled'] = true; |
| 1174 | + } else { |
|
| 1175 | + $save_cache['entries'][$cur_index] = $subValue; |
|
| 1137 | 1176 | } |
| 1138 | - else |
|
| 1139 | - $save_cache['entries'][$cur_index] = $subValue; |
|
| 1140 | 1177 | |
| 1141 | 1178 | $context['file_entries'][$entryValue['group']][] = array( |
| 1142 | 1179 | 'key' => $entryKey . '-+- ' . $cur_index, |
@@ -1159,9 +1196,9 @@ discard block |
||
| 1159 | 1196 | { |
| 1160 | 1197 | $items[] = $k2 . ' => \'' . $v2 . '\''; |
| 1161 | 1198 | $cur_index = $k2; |
| 1199 | + } else { |
|
| 1200 | + $items[] = '\'' . $v2 . '\''; |
|
| 1162 | 1201 | } |
| 1163 | - else |
|
| 1164 | - $items[] = '\'' . $v2 . '\''; |
|
| 1165 | 1202 | |
| 1166 | 1203 | $cur_index++; |
| 1167 | 1204 | } |
@@ -1171,15 +1208,15 @@ discard block |
||
| 1171 | 1208 | 'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');', |
| 1172 | 1209 | ); |
| 1173 | 1210 | } |
| 1174 | - } |
|
| 1175 | - else |
|
| 1211 | + } else |
|
| 1176 | 1212 | { |
| 1177 | 1213 | // Saving? |
| 1178 | 1214 | if (isset($save_strings[$entryKey]) && $save_strings[$entryKey] != $entryValue['entry']) |
| 1179 | 1215 | { |
| 1180 | 1216 | // @todo Fix this properly. |
| 1181 | - if ($save_strings[$entryKey] == '') |
|
| 1182 | - $save_strings[$entryKey] = '\'\''; |
|
| 1217 | + if ($save_strings[$entryKey] == '') { |
|
| 1218 | + $save_strings[$entryKey] = '\'\''; |
|
| 1219 | + } |
|
| 1183 | 1220 | |
| 1184 | 1221 | // Set the new value. |
| 1185 | 1222 | $entryValue['entry'] = $save_strings[$entryKey]; |
@@ -1218,8 +1255,9 @@ discard block |
||
| 1218 | 1255 | { |
| 1219 | 1256 | $type = isset($special_types[$string_val['group']]) ? $special_types[$string_val['group']] : $string_val['group']; |
| 1220 | 1257 | |
| 1221 | - if (!in_array($type, $allows_add_remove[$file_id]['add'])) |
|
| 1222 | - continue; |
|
| 1258 | + if (!in_array($type, $allows_add_remove[$file_id]['add'])) { |
|
| 1259 | + continue; |
|
| 1260 | + } |
|
| 1223 | 1261 | |
| 1224 | 1262 | $final_saves[$string_key] = array( |
| 1225 | 1263 | 'find' => "\n\n?".'>', |
@@ -1234,8 +1272,9 @@ discard block |
||
| 1234 | 1272 | checkSession(); |
| 1235 | 1273 | |
| 1236 | 1274 | $file_contents = implode('', file($current_file)); |
| 1237 | - foreach ($final_saves as $save) |
|
| 1238 | - $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
| 1275 | + foreach ($final_saves as $save) { |
|
| 1276 | + $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
| 1277 | + } |
|
| 1239 | 1278 | |
| 1240 | 1279 | // Save the actual changes. |
| 1241 | 1280 | $fp = fopen($current_file, 'w+'); |
@@ -1293,8 +1332,9 @@ discard block |
||
| 1293 | 1332 | } |
| 1294 | 1333 | |
| 1295 | 1334 | // If we saved, redirect. |
| 1296 | - if ($madeSave) |
|
| 1297 | - redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
| 1335 | + if ($madeSave) { |
|
| 1336 | + redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
| 1337 | + } |
|
| 1298 | 1338 | |
| 1299 | 1339 | createToken('admin-mlang'); |
| 1300 | 1340 | } |
@@ -1326,8 +1366,9 @@ discard block |
||
| 1326 | 1366 | // Toggle the escape. |
| 1327 | 1367 | $is_escape = !$is_escape; |
| 1328 | 1368 | // If we're now escaped don't add this string. |
| 1329 | - if ($is_escape) |
|
| 1330 | - continue; |
|
| 1369 | + if ($is_escape) { |
|
| 1370 | + continue; |
|
| 1371 | + } |
|
| 1331 | 1372 | } |
| 1332 | 1373 | // Special case - parsed string with line break etc? |
| 1333 | 1374 | elseif (($string{$i} == 'n' || $string{$i} == 't') && $in_string == 2 && $is_escape) |
@@ -1344,11 +1385,13 @@ discard block |
||
| 1344 | 1385 | if ($in_string != 2 && ($in_string != 1 || !$is_escape)) |
| 1345 | 1386 | { |
| 1346 | 1387 | // Is it the end of a single quote string? |
| 1347 | - if ($in_string == 1) |
|
| 1348 | - $in_string = 0; |
|
| 1388 | + if ($in_string == 1) { |
|
| 1389 | + $in_string = 0; |
|
| 1390 | + } |
|
| 1349 | 1391 | // Otherwise it's the start! |
| 1350 | - else |
|
| 1351 | - $in_string = 1; |
|
| 1392 | + else { |
|
| 1393 | + $in_string = 1; |
|
| 1394 | + } |
|
| 1352 | 1395 | |
| 1353 | 1396 | // Don't actually include this character! |
| 1354 | 1397 | continue; |
@@ -1361,19 +1404,22 @@ discard block |
||
| 1361 | 1404 | if ($in_string != 1 && ($in_string != 2 || !$is_escape)) |
| 1362 | 1405 | { |
| 1363 | 1406 | // Is it the end of a double quote string? |
| 1364 | - if ($in_string == 2) |
|
| 1365 | - $in_string = 0; |
|
| 1407 | + if ($in_string == 2) { |
|
| 1408 | + $in_string = 0; |
|
| 1409 | + } |
|
| 1366 | 1410 | // Otherwise it's the start! |
| 1367 | - else |
|
| 1368 | - $in_string = 2; |
|
| 1411 | + else { |
|
| 1412 | + $in_string = 2; |
|
| 1413 | + } |
|
| 1369 | 1414 | |
| 1370 | 1415 | // Don't actually include this character! |
| 1371 | 1416 | continue; |
| 1372 | 1417 | } |
| 1373 | 1418 | } |
| 1374 | 1419 | // A join/space outside of a string is simply removed. |
| 1375 | - elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) |
|
| 1376 | - continue; |
|
| 1420 | + elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) { |
|
| 1421 | + continue; |
|
| 1422 | + } |
|
| 1377 | 1423 | // Start of a variable? |
| 1378 | 1424 | elseif ($in_string == 0 && $string{$i} == '$') |
| 1379 | 1425 | { |
@@ -1407,8 +1453,7 @@ discard block |
||
| 1407 | 1453 | |
| 1408 | 1454 | // Unhtml then rehtml the whole thing! |
| 1409 | 1455 | $new_string = $smcFunc['htmlspecialchars'](un_htmlspecialchars($new_string)); |
| 1410 | - } |
|
| 1411 | - else |
|
| 1456 | + } else |
|
| 1412 | 1457 | { |
| 1413 | 1458 | // Keep track of what we're doing... |
| 1414 | 1459 | $in_string = 0; |
@@ -1437,10 +1482,11 @@ discard block |
||
| 1437 | 1482 | preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches); |
| 1438 | 1483 | if (!empty($matches[1])) |
| 1439 | 1484 | { |
| 1440 | - if ($in_string == 1) |
|
| 1441 | - $new_string .= '\' . '; |
|
| 1442 | - elseif ($new_string) |
|
| 1443 | - $new_string .= ' . '; |
|
| 1485 | + if ($in_string == 1) { |
|
| 1486 | + $new_string .= '\' . '; |
|
| 1487 | + } elseif ($new_string) { |
|
| 1488 | + $new_string .= ' . '; |
|
| 1489 | + } |
|
| 1444 | 1490 | |
| 1445 | 1491 | $new_string .= $matches[1]; |
| 1446 | 1492 | $i += strlen($matches[1]) + 3; |
@@ -1453,8 +1499,9 @@ discard block |
||
| 1453 | 1499 | elseif ($string{$i} == '<') |
| 1454 | 1500 | { |
| 1455 | 1501 | // Probably HTML? |
| 1456 | - if ($string{$i + 1} != ' ') |
|
| 1457 | - $in_html = true; |
|
| 1502 | + if ($string{$i + 1} != ' ') { |
|
| 1503 | + $in_html = true; |
|
| 1504 | + } |
|
| 1458 | 1505 | // Assume we need an entity... |
| 1459 | 1506 | else |
| 1460 | 1507 | { |
@@ -1466,8 +1513,9 @@ discard block |
||
| 1466 | 1513 | elseif ($string{$i} == '>') |
| 1467 | 1514 | { |
| 1468 | 1515 | // Will it be HTML? |
| 1469 | - if ($in_html) |
|
| 1470 | - $in_html = false; |
|
| 1516 | + if ($in_html) { |
|
| 1517 | + $in_html = false; |
|
| 1518 | + } |
|
| 1471 | 1519 | // Otherwise we need an entity... |
| 1472 | 1520 | else |
| 1473 | 1521 | { |
@@ -1476,8 +1524,9 @@ discard block |
||
| 1476 | 1524 | } |
| 1477 | 1525 | } |
| 1478 | 1526 | // Is it a slash? If so escape it... |
| 1479 | - if ($string{$i} == '\\') |
|
| 1480 | - $new_string .= '\\'; |
|
| 1527 | + if ($string{$i} == '\\') { |
|
| 1528 | + $new_string .= '\\'; |
|
| 1529 | + } |
|
| 1481 | 1530 | // The infamous double quote? |
| 1482 | 1531 | elseif ($string{$i} == '"') |
| 1483 | 1532 | { |
@@ -1500,10 +1549,11 @@ discard block |
||
| 1500 | 1549 | } |
| 1501 | 1550 | |
| 1502 | 1551 | // If we ended as a string then close it off. |
| 1503 | - if ($in_string == 1) |
|
| 1504 | - $new_string .= '\''; |
|
| 1505 | - elseif ($in_string == 2) |
|
| 1506 | - $new_string .= '"'; |
|
| 1552 | + if ($in_string == 1) { |
|
| 1553 | + $new_string .= '\''; |
|
| 1554 | + } elseif ($in_string == 2) { |
|
| 1555 | + $new_string .= '"'; |
|
| 1556 | + } |
|
| 1507 | 1557 | } |
| 1508 | 1558 | |
| 1509 | 1559 | return $new_string; |
@@ -36,11 +36,12 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // An error? |
| 39 | - if (!empty($context['error_message'])) |
|
| 40 | - echo ' |
|
| 39 | + if (!empty($context['error_message'])) { |
|
| 40 | + echo ' |
|
| 41 | 41 | <div class="errorbox"> |
| 42 | 42 | ', $context['error_message'], ' |
| 43 | 43 | </div>'; |
| 44 | + } |
|
| 44 | 45 | |
| 45 | 46 | // Provide something of an introduction... |
| 46 | 47 | echo ' |
@@ -67,11 +68,12 @@ discard block |
||
| 67 | 68 | // If the files are not writable, we might! |
| 68 | 69 | if (!empty($context['still_not_writable'])) |
| 69 | 70 | { |
| 70 | - if (!empty($context['package_ftp']['error'])) |
|
| 71 | - echo ' |
|
| 71 | + if (!empty($context['package_ftp']['error'])) { |
|
| 72 | + echo ' |
|
| 72 | 73 | <div class="errorbox"> |
| 73 | 74 | ', $context['package_ftp']['error'], ' |
| 74 | 75 | </div>'; |
| 76 | + } |
|
| 75 | 77 | |
| 76 | 78 | echo ' |
| 77 | 79 | <div class="cat_bar"> |
@@ -150,11 +152,12 @@ discard block |
||
| 150 | 152 | </div>'; |
| 151 | 153 | |
| 152 | 154 | // Not writable? Oops, show an error for ya. |
| 153 | - if (!empty($context['lang_file_not_writable_message'])) |
|
| 154 | - echo ' |
|
| 155 | + if (!empty($context['lang_file_not_writable_message'])) { |
|
| 156 | + echo ' |
|
| 155 | 157 | <div class="errorbox"> |
| 156 | 158 | ', $context['lang_file_not_writable_message'], ' |
| 157 | 159 | </div>'; |
| 160 | + } |
|
| 158 | 161 | |
| 159 | 162 | // Show the language entries |
| 160 | 163 | echo ' |
@@ -199,9 +202,10 @@ discard block |
||
| 199 | 202 | <input type="submit" name="save_main" value="', $txt['save'], '"', $context['lang_file_not_writable_message'] || !empty($context['file_entries']) ? ' disabled' : '', ' class="button">'; |
| 200 | 203 | |
| 201 | 204 | // Allow deleting entries. English can't be deleted though. |
| 202 | - if ($context['lang_id'] != 'english') |
|
| 203 | - echo ' |
|
| 205 | + if ($context['lang_id'] != 'english') { |
|
| 206 | + echo ' |
|
| 204 | 207 | <input type="submit" name="delete_main" value="', $txt['delete'], '"', $context['lang_file_not_writable_message'] || !empty($context['file_entries']) ? ' disabled' : '', ' onclick="confirm(\'', $txt['languages_delete_confirm'], '\');" class="button">'; |
| 208 | + } |
|
| 205 | 209 | |
| 206 | 210 | echo ' |
| 207 | 211 | </div><!-- .windowbg --> |
@@ -224,9 +228,10 @@ discard block |
||
| 224 | 228 | echo ' |
| 225 | 229 | <optgroup label="', $theme['name'], '">'; |
| 226 | 230 | |
| 227 | - foreach ($theme['files'] as $file) |
|
| 228 | - echo ' |
|
| 231 | + foreach ($theme['files'] as $file) { |
|
| 232 | + echo ' |
|
| 229 | 233 | <option value="', $id_theme, '+', $file['id'], '"', $file['selected'] ? ' selected' : '', '>', $file['name'], '</option>'; |
| 234 | + } |
|
| 230 | 235 | |
| 231 | 236 | echo ' |
| 232 | 237 | </optgroup>'; |
@@ -241,11 +246,12 @@ discard block |
||
| 241 | 246 | </div><!-- .information -->'; |
| 242 | 247 | |
| 243 | 248 | // Is it not writable? Show an error. |
| 244 | - if (!empty($context['entries_not_writable_message'])) |
|
| 245 | - echo ' |
|
| 249 | + if (!empty($context['entries_not_writable_message'])) { |
|
| 250 | + echo ' |
|
| 246 | 251 | <div class="errorbox"> |
| 247 | 252 | ', $context['entries_not_writable_message'], ' |
| 248 | 253 | </div>'; |
| 254 | + } |
|
| 249 | 255 | |
| 250 | 256 | // Already have some file entries? |
| 251 | 257 | if (!empty($context['file_entries'])) |
@@ -274,8 +280,8 @@ discard block |
||
| 274 | 280 | </dt> |
| 275 | 281 | <dd id="entry_', $entry_num, '">'; |
| 276 | 282 | |
| 277 | - if ($entry['can_remove']) |
|
| 278 | - echo ' |
|
| 283 | + if ($entry['can_remove']) { |
|
| 284 | + echo ' |
|
| 279 | 285 | <span style="margin-right: 1ch; white-space: nowrap"> |
| 280 | 286 | <input id="entry_', $entry_num, '_none" class="entry_toggle" type="radio" name="edit[', $entry['key'], ']" value="" data-target="#entry_', $entry_num, '" checked> |
| 281 | 287 | <label for="entry_', $entry_num, '_none">', $txt['no_change'], '</label> |
@@ -288,10 +294,11 @@ discard block |
||
| 288 | 294 | <input id="entry_', $entry_num, '_remove" class="entry_toggle" type="radio" name="edit[', $entry['key'], ']" value="remove" data-target="#entry_', $entry_num, '"> |
| 289 | 295 | <label for="entry_', $entry_num, '_remove">', $txt['remove'], '</label> |
| 290 | 296 | </span>'; |
| 291 | - else |
|
| 292 | - echo ' |
|
| 297 | + } else { |
|
| 298 | + echo ' |
|
| 293 | 299 | <input id="entry_', $entry_num, '_edit" class="entry_toggle" type="checkbox" name="edit[', $entry['key'], ']" value="edit" data-target="#entry_', $entry_num, '"> |
| 294 | 300 | <label for="entry_', $entry_num, '_edit">', $txt['edit'], '</label>'; |
| 301 | + } |
|
| 295 | 302 | |
| 296 | 303 | echo ' |
| 297 | 304 | </span> |
@@ -351,12 +358,13 @@ discard block |
||
| 351 | 358 | <input type="text" name="smf_add" size="40" value="', !empty($context['smf_search_term']) ? $context['smf_search_term'] : '', '">'; |
| 352 | 359 | |
| 353 | 360 | // Do we have some errors? Too bad. Display a little error box. |
| 354 | - if (!empty($context['smf_error'])) |
|
| 355 | - echo ' |
|
| 361 | + if (!empty($context['smf_error'])) { |
|
| 362 | + echo ' |
|
| 356 | 363 | <div> |
| 357 | 364 | <br> |
| 358 | 365 | <p class="errorbox">', $txt['add_language_error_' . $context['smf_error']], '</p> |
| 359 | 366 | </div>'; |
| 367 | + } |
|
| 360 | 368 | |
| 361 | 369 | echo ' |
| 362 | 370 | </fieldset> |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | { |
| 33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
| 34 | 35 | |
| 35 | - if (empty($topic)) |
|
| 36 | - fatal_lang_error('no_access', false); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + fatal_lang_error('no_access', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | $request = $smcFunc['db_query']('', ' |
| 39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
| 49 | 51 | $smcFunc['db_free_result']($request); |
| 50 | 52 | |
| 51 | 53 | // Can they see it - if not approved? |
| 52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
| 53 | - isAllowedTo('approve_posts'); |
|
| 54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
| 55 | + isAllowedTo('approve_posts'); |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Permission check! |
| 56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
| 59 | 62 | if ($id_member_started == $user_info['id']) |
| 60 | 63 | { |
| 61 | 64 | isAllowedTo('move_own'); |
| 65 | + } else { |
|
| 66 | + isAllowedTo('move_any'); |
|
| 62 | 67 | } |
| 63 | - else |
|
| 64 | - isAllowedTo('move_any'); |
|
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
| 83 | 86 | 'not_redirection' => true, |
| 84 | 87 | ); |
| 85 | 88 | |
| 86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
| 87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
| 90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | - if (!$context['move_any']) |
|
| 90 | - $options['included_boards'] = $boards; |
|
| 93 | + if (!$context['move_any']) { |
|
| 94 | + $options['included_boards'] = $boards; |
|
| 95 | + } |
|
| 91 | 96 | |
| 92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
| 93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
| 138 | 143 | global $txt, $topic, $scripturl, $sourcedir, $context; |
| 139 | 144 | global $board, $language, $user_info, $smcFunc; |
| 140 | 145 | |
| 141 | - if (empty($topic)) |
|
| 142 | - fatal_lang_error('no_access', false); |
|
| 146 | + if (empty($topic)) { |
|
| 147 | + fatal_lang_error('no_access', false); |
|
| 148 | + } |
|
| 143 | 149 | |
| 144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
| 145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
| 146 | - fatal_lang_error('movetopic_no_reason', false); |
|
| 151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
| 152 | + fatal_lang_error('movetopic_no_reason', false); |
|
| 153 | + } |
|
| 147 | 154 | |
| 148 | 155 | moveTopicConcurrence(); |
| 149 | 156 | |
@@ -163,16 +170,18 @@ discard block |
||
| 163 | 170 | $smcFunc['db_free_result']($request); |
| 164 | 171 | |
| 165 | 172 | // Can they see it? |
| 166 | - if (!$context['is_approved']) |
|
| 167 | - isAllowedTo('approve_posts'); |
|
| 173 | + if (!$context['is_approved']) { |
|
| 174 | + isAllowedTo('approve_posts'); |
|
| 175 | + } |
|
| 168 | 176 | |
| 169 | 177 | // Can they move topics on this board? |
| 170 | 178 | if (!allowedTo('move_any')) |
| 171 | 179 | { |
| 172 | - if ($id_member_started == $user_info['id']) |
|
| 173 | - isAllowedTo('move_own'); |
|
| 174 | - else |
|
| 175 | - isAllowedTo('move_any'); |
|
| 180 | + if ($id_member_started == $user_info['id']) { |
|
| 181 | + isAllowedTo('move_own'); |
|
| 182 | + } else { |
|
| 183 | + isAllowedTo('move_any'); |
|
| 184 | + } |
|
| 176 | 185 | } |
| 177 | 186 | |
| 178 | 187 | checkSession(); |
@@ -197,8 +206,9 @@ discard block |
||
| 197 | 206 | 'blank_redirect' => '', |
| 198 | 207 | ) |
| 199 | 208 | ); |
| 200 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 201 | - fatal_lang_error('no_board'); |
|
| 209 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 210 | + fatal_lang_error('no_board'); |
|
| 211 | + } |
|
| 202 | 212 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
| 203 | 213 | $smcFunc['db_free_result']($request); |
| 204 | 214 | |
@@ -210,8 +220,9 @@ discard block |
||
| 210 | 220 | { |
| 211 | 221 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
| 212 | 222 | // Keep checking the length. |
| 213 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
| 214 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 223 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
| 224 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 225 | + } |
|
| 215 | 226 | |
| 216 | 227 | // If it's still valid move onwards and upwards. |
| 217 | 228 | if ($_POST['custom_subject'] != '') |
@@ -221,9 +232,9 @@ discard block |
||
| 221 | 232 | // Get a response prefix, but in the forum's default language. |
| 222 | 233 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 223 | 234 | { |
| 224 | - if ($language === $user_info['language']) |
|
| 225 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 226 | - else |
|
| 235 | + if ($language === $user_info['language']) { |
|
| 236 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 237 | + } else |
|
| 227 | 238 | { |
| 228 | 239 | loadLanguage('index', $language, false); |
| 229 | 240 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -263,8 +274,9 @@ discard block |
||
| 263 | 274 | if (isset($_POST['postRedirect'])) |
| 264 | 275 | { |
| 265 | 276 | // Should be in the boardwide language. |
| 266 | - if ($user_info['language'] != $language) |
|
| 267 | - loadLanguage('index', $language); |
|
| 277 | + if ($user_info['language'] != $language) { |
|
| 278 | + loadLanguage('index', $language); |
|
| 279 | + } |
|
| 268 | 280 | |
| 269 | 281 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
| 270 | 282 | preparsecode($_POST['reason']); |
@@ -328,8 +340,9 @@ discard block |
||
| 328 | 340 | $posters = array(); |
| 329 | 341 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 330 | 342 | { |
| 331 | - if (!isset($posters[$row['id_member']])) |
|
| 332 | - $posters[$row['id_member']] = 0; |
|
| 343 | + if (!isset($posters[$row['id_member']])) { |
|
| 344 | + $posters[$row['id_member']] = 0; |
|
| 345 | + } |
|
| 333 | 346 | |
| 334 | 347 | $posters[$row['id_member']]++; |
| 335 | 348 | } |
@@ -338,11 +351,13 @@ discard block |
||
| 338 | 351 | foreach ($posters as $id_member => $posts) |
| 339 | 352 | { |
| 340 | 353 | // The board we're moving from counted posts, but not to. |
| 341 | - if (empty($pcounter_from)) |
|
| 342 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 354 | + if (empty($pcounter_from)) { |
|
| 355 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 356 | + } |
|
| 343 | 357 | // The reverse: from didn't, to did. |
| 344 | - else |
|
| 345 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 358 | + else { |
|
| 359 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 360 | + } |
|
| 346 | 361 | } |
| 347 | 362 | } |
| 348 | 363 | |
@@ -350,19 +365,21 @@ discard block |
||
| 350 | 365 | moveTopics($topic, $_POST['toboard']); |
| 351 | 366 | |
| 352 | 367 | // Log that they moved this topic. |
| 353 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
| 354 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 368 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
| 369 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 370 | + } |
|
| 355 | 371 | // Notify people that this topic has been moved? |
| 356 | 372 | sendNotifications($topic, 'move'); |
| 357 | 373 | |
| 358 | 374 | call_integration_hook('integrate_movetopic2_end'); |
| 359 | 375 | |
| 360 | 376 | // Why not go back to the original board in case they want to keep moving? |
| 361 | - if (!isset($_REQUEST['goback'])) |
|
| 362 | - redirectexit('board=' . $board . '.0'); |
|
| 363 | - else |
|
| 364 | - redirectexit('topic=' . $topic . '.0'); |
|
| 365 | -} |
|
| 377 | + if (!isset($_REQUEST['goback'])) { |
|
| 378 | + redirectexit('board=' . $board . '.0'); |
|
| 379 | + } else { |
|
| 380 | + redirectexit('topic=' . $topic . '.0'); |
|
| 381 | + } |
|
| 382 | + } |
|
| 366 | 383 | |
| 367 | 384 | /** |
| 368 | 385 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -378,18 +395,21 @@ discard block |
||
| 378 | 395 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
| 379 | 396 | |
| 380 | 397 | // Empty array? |
| 381 | - if (empty($topics)) |
|
| 382 | - return; |
|
| 398 | + if (empty($topics)) { |
|
| 399 | + return; |
|
| 400 | + } |
|
| 383 | 401 | |
| 384 | 402 | // Only a single topic. |
| 385 | - if (is_numeric($topics)) |
|
| 386 | - $topics = array($topics); |
|
| 403 | + if (is_numeric($topics)) { |
|
| 404 | + $topics = array($topics); |
|
| 405 | + } |
|
| 387 | 406 | |
| 388 | 407 | $fromBoards = array(); |
| 389 | 408 | |
| 390 | 409 | // Destination board empty or equal to 0? |
| 391 | - if (empty($toBoard)) |
|
| 392 | - return; |
|
| 410 | + if (empty($toBoard)) { |
|
| 411 | + return; |
|
| 412 | + } |
|
| 393 | 413 | |
| 394 | 414 | // Are we moving to the recycle board? |
| 395 | 415 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -397,8 +417,9 @@ discard block |
||
| 397 | 417 | // Callback for search APIs to do their thing |
| 398 | 418 | require_once($sourcedir . '/Search.php'); |
| 399 | 419 | $searchAPI = findSearchAPI(); |
| 400 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
| 401 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
| 420 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
| 421 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
| 422 | + } |
|
| 402 | 423 | |
| 403 | 424 | // Determine the source boards... |
| 404 | 425 | $request = $smcFunc['db_query']('', ' |
@@ -412,8 +433,9 @@ discard block |
||
| 412 | 433 | ) |
| 413 | 434 | ); |
| 414 | 435 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
| 415 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 416 | - return; |
|
| 436 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 437 | + return; |
|
| 438 | + } |
|
| 417 | 439 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 418 | 440 | { |
| 419 | 441 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -431,10 +453,11 @@ discard block |
||
| 431 | 453 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
| 432 | 454 | |
| 433 | 455 | // Add the topics to the right type. |
| 434 | - if ($row['approved']) |
|
| 435 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 436 | - else |
|
| 437 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 456 | + if ($row['approved']) { |
|
| 457 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 458 | + } else { |
|
| 459 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 460 | + } |
|
| 438 | 461 | } |
| 439 | 462 | $smcFunc['db_free_result']($request); |
| 440 | 463 | |
@@ -560,13 +583,14 @@ discard block |
||
| 560 | 583 | ) |
| 561 | 584 | ); |
| 562 | 585 | $approval_msgs = array(); |
| 563 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 564 | - $approval_msgs[] = $row['id_msg']; |
|
| 586 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 587 | + $approval_msgs[] = $row['id_msg']; |
|
| 588 | + } |
|
| 565 | 589 | $smcFunc['db_free_result']($request); |
| 566 | 590 | |
| 567 | 591 | // Empty the approval queue for these, as we're going to approve them next. |
| 568 | - if (!empty($approval_msgs)) |
|
| 569 | - $smcFunc['db_query']('', ' |
|
| 592 | + if (!empty($approval_msgs)) { |
|
| 593 | + $smcFunc['db_query']('', ' |
|
| 570 | 594 | DELETE FROM {db_prefix}approval_queue |
| 571 | 595 | WHERE id_msg IN ({array_int:message_list}) |
| 572 | 596 | AND id_attach = {int:id_attach}', |
@@ -575,6 +599,7 @@ discard block |
||
| 575 | 599 | 'id_attach' => 0, |
| 576 | 600 | ) |
| 577 | 601 | ); |
| 602 | + } |
|
| 578 | 603 | |
| 579 | 604 | // Get all the current max and mins. |
| 580 | 605 | $request = $smcFunc['db_query']('', ' |
@@ -608,8 +633,8 @@ discard block |
||
| 608 | 633 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 609 | 634 | { |
| 610 | 635 | // If not, update. |
| 611 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
| 612 | - $smcFunc['db_query']('', ' |
|
| 636 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
| 637 | + $smcFunc['db_query']('', ' |
|
| 613 | 638 | UPDATE {db_prefix}topics |
| 614 | 639 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
| 615 | 640 | WHERE id_topic = {int:selected_topic}', |
@@ -619,6 +644,7 @@ discard block |
||
| 619 | 644 | 'selected_topic' => $row['id_topic'], |
| 620 | 645 | ) |
| 621 | 646 | ); |
| 647 | + } |
|
| 622 | 648 | } |
| 623 | 649 | $smcFunc['db_free_result']($request); |
| 624 | 650 | } |
@@ -677,9 +703,10 @@ discard block |
||
| 677 | 703 | } |
| 678 | 704 | |
| 679 | 705 | // Update the cache? |
| 680 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
| 681 | - foreach ($topics as $topic_id) |
|
| 706 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
| 707 | + foreach ($topics as $topic_id) |
|
| 682 | 708 | cache_put_data('topic_board-' . $topic_id, null, 120); |
| 709 | + } |
|
| 683 | 710 | |
| 684 | 711 | require_once($sourcedir . '/Subs-Post.php'); |
| 685 | 712 | |
@@ -703,15 +730,17 @@ discard block |
||
| 703 | 730 | { |
| 704 | 731 | global $board, $topic, $smcFunc, $scripturl; |
| 705 | 732 | |
| 706 | - if (isset($_GET['current_board'])) |
|
| 707 | - $move_from = (int) $_GET['current_board']; |
|
| 733 | + if (isset($_GET['current_board'])) { |
|
| 734 | + $move_from = (int) $_GET['current_board']; |
|
| 735 | + } |
|
| 708 | 736 | |
| 709 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
| 710 | - return true; |
|
| 737 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
| 738 | + return true; |
|
| 739 | + } |
|
| 711 | 740 | |
| 712 | - if ($move_from == $board) |
|
| 713 | - return true; |
|
| 714 | - else |
|
| 741 | + if ($move_from == $board) { |
|
| 742 | + return true; |
|
| 743 | + } else |
|
| 715 | 744 | { |
| 716 | 745 | $request = $smcFunc['db_query']('', ' |
| 717 | 746 | SELECT m.subject, b.name |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * View the forum's error log. |
@@ -30,12 +31,14 @@ discard block |
||
| 30 | 31 | global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc; |
| 31 | 32 | |
| 32 | 33 | // Viewing contents of a file? |
| 33 | - if (isset($_GET['file'])) |
|
| 34 | - return ViewFile(); |
|
| 34 | + if (isset($_GET['file'])) { |
|
| 35 | + return ViewFile(); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Viewing contents of a backtrace? |
| 37 | - if (isset($_GET['backtrace'])) |
|
| 38 | - return ViewBacktrace(); |
|
| 39 | + if (isset($_GET['backtrace'])) { |
|
| 40 | + return ViewBacktrace(); |
|
| 41 | + } |
|
| 39 | 42 | |
| 40 | 43 | // Check for the administrative permission to do this. |
| 41 | 44 | isAllowedTo('admin_forum'); |
@@ -89,8 +92,8 @@ discard block |
||
| 89 | 92 | ); |
| 90 | 93 | |
| 91 | 94 | // Set up the filtering... |
| 92 | - if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) |
|
| 93 | - $filter = array( |
|
| 95 | + if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { |
|
| 96 | + $filter = array( |
|
| 94 | 97 | 'variable' => $_GET['filter'], |
| 95 | 98 | 'value' => array( |
| 96 | 99 | 'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']), |
@@ -98,10 +101,12 @@ discard block |
||
| 98 | 101 | 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], |
| 99 | 102 | 'entity' => $filters[$_GET['filter']]['txt'] |
| 100 | 103 | ); |
| 104 | + } |
|
| 101 | 105 | |
| 102 | 106 | // Deleting, are we? |
| 103 | - if (isset($_POST['delall']) || isset($_POST['delete'])) |
|
| 104 | - deleteErrors(); |
|
| 107 | + if (isset($_POST['delall']) || isset($_POST['delete'])) { |
|
| 108 | + deleteErrors(); |
|
| 109 | + } |
|
| 105 | 110 | |
| 106 | 111 | // Just how many errors are there? |
| 107 | 112 | $result = $smcFunc['db_query']('', ' |
@@ -116,12 +121,14 @@ discard block |
||
| 116 | 121 | $smcFunc['db_free_result']($result); |
| 117 | 122 | |
| 118 | 123 | // If this filter is empty... |
| 119 | - if ($num_errors == 0 && isset($filter)) |
|
| 120 | - redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
| 124 | + if ($num_errors == 0 && isset($filter)) { |
|
| 125 | + redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
| 126 | + } |
|
| 121 | 127 | |
| 122 | 128 | // Clean up start. |
| 123 | - if (!isset($_GET['start']) || $_GET['start'] < 0) |
|
| 124 | - $_GET['start'] = 0; |
|
| 129 | + if (!isset($_GET['start']) || $_GET['start'] < 0) { |
|
| 130 | + $_GET['start'] = 0; |
|
| 131 | + } |
|
| 125 | 132 | |
| 126 | 133 | // Do we want to reverse error listing? |
| 127 | 134 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
@@ -131,9 +138,9 @@ discard block |
||
| 131 | 138 | $context['start'] = $_GET['start']; |
| 132 | 139 | |
| 133 | 140 | // Update the error count |
| 134 | - if (!isset($filter)) |
|
| 135 | - $context['num_errors'] = $num_errors; |
|
| 136 | - else |
|
| 141 | + if (!isset($filter)) { |
|
| 142 | + $context['num_errors'] = $num_errors; |
|
| 143 | + } else |
|
| 137 | 144 | { |
| 138 | 145 | // We want all errors, not just the number of filtered messages... |
| 139 | 146 | $query = $smcFunc['db_query']('', ' |
@@ -165,8 +172,9 @@ discard block |
||
| 165 | 172 | for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++) |
| 166 | 173 | { |
| 167 | 174 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
| 168 | - if ($search_message == $filter['value']['sql']) |
|
| 169 | - $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
| 175 | + if ($search_message == $filter['value']['sql']) { |
|
| 176 | + $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
| 177 | + } |
|
| 170 | 178 | $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br>')); |
| 171 | 179 | |
| 172 | 180 | $context['errors'][$row['id_error']] = array( |
@@ -225,8 +233,9 @@ discard block |
||
| 225 | 233 | 'members' => count($members), |
| 226 | 234 | ) |
| 227 | 235 | ); |
| 228 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 229 | - $members[$row['id_member']] = $row; |
|
| 236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 237 | + $members[$row['id_member']] = $row; |
|
| 238 | + } |
|
| 230 | 239 | $smcFunc['db_free_result']($request); |
| 231 | 240 | |
| 232 | 241 | // This is a guest... |
@@ -258,20 +267,18 @@ discard block |
||
| 258 | 267 | $id = $filter['value']['sql']; |
| 259 | 268 | loadMemberData($id, false, 'minimal'); |
| 260 | 269 | $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; |
| 261 | - } |
|
| 262 | - elseif ($filter['variable'] == 'url') |
|
| 263 | - $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
| 264 | - elseif ($filter['variable'] == 'message') |
|
| 270 | + } elseif ($filter['variable'] == 'url') { |
|
| 271 | + $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
| 272 | + } elseif ($filter['variable'] == 'message') |
|
| 265 | 273 | { |
| 266 | 274 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
| 267 | 275 | $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); |
| 268 | - } |
|
| 269 | - elseif ($filter['variable'] == 'error_type') |
|
| 276 | + } elseif ($filter['variable'] == 'error_type') |
|
| 270 | 277 | { |
| 271 | 278 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
| 279 | + } else { |
|
| 280 | + $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
| 272 | 281 | } |
| 273 | - else |
|
| 274 | - $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
| 275 | 282 | } |
| 276 | 283 | |
| 277 | 284 | $context['error_types'] = array(); |
@@ -312,10 +319,11 @@ discard block |
||
| 312 | 319 | $context['error_types']['all']['label'] .= ' (' . $sum . ')'; |
| 313 | 320 | |
| 314 | 321 | // Finally, work out what is the last tab! |
| 315 | - if (isset($context['error_types'][$sum])) |
|
| 316 | - $context['error_types'][$sum]['is_last'] = true; |
|
| 317 | - else |
|
| 318 | - $context['error_types']['all']['is_last'] = true; |
|
| 322 | + if (isset($context['error_types'][$sum])) { |
|
| 323 | + $context['error_types'][$sum]['is_last'] = true; |
|
| 324 | + } else { |
|
| 325 | + $context['error_types']['all']['is_last'] = true; |
|
| 326 | + } |
|
| 319 | 327 | |
| 320 | 328 | // And this is pretty basic ;). |
| 321 | 329 | $context['page_title'] = $txt['errlog']; |
@@ -341,21 +349,23 @@ discard block |
||
| 341 | 349 | validateToken('admin-el'); |
| 342 | 350 | |
| 343 | 351 | // Delete all or just some? |
| 344 | - if (isset($_POST['delall']) && !isset($filter)) |
|
| 345 | - $smcFunc['db_query']('truncate_table', ' |
|
| 352 | + if (isset($_POST['delall']) && !isset($filter)) { |
|
| 353 | + $smcFunc['db_query']('truncate_table', ' |
|
| 346 | 354 | TRUNCATE {db_prefix}log_errors', |
| 347 | 355 | array( |
| 348 | 356 | ) |
| 349 | 357 | ); |
| 358 | + } |
|
| 350 | 359 | // Deleting all with a filter? |
| 351 | - elseif (isset($_POST['delall']) && isset($filter)) |
|
| 352 | - $smcFunc['db_query']('', ' |
|
| 360 | + elseif (isset($_POST['delall']) && isset($filter)) { |
|
| 361 | + $smcFunc['db_query']('', ' |
|
| 353 | 362 | DELETE FROM {db_prefix}log_errors |
| 354 | 363 | WHERE ' . $filter['variable'] . ' LIKE {string:filter}', |
| 355 | 364 | array( |
| 356 | 365 | 'filter' => $filter['value']['sql'], |
| 357 | 366 | ) |
| 358 | 367 | ); |
| 368 | + } |
|
| 359 | 369 | // Just specific errors? |
| 360 | 370 | elseif (!empty($_POST['delete'])) |
| 361 | 371 | { |
@@ -401,15 +411,17 @@ discard block |
||
| 401 | 411 | $line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0; |
| 402 | 412 | |
| 403 | 413 | // Make sure the file we are looking for is one they are allowed to look at |
| 404 | - if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) |
|
| 405 | - fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
| 414 | + if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) { |
|
| 415 | + fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
| 416 | + } |
|
| 406 | 417 | |
| 407 | 418 | // get the min and max lines |
| 408 | 419 | $min = $line - 20 <= 0 ? 1 : $line - 20; |
| 409 | 420 | $max = $line + 21; // One additional line to make everything work out correctly |
| 410 | 421 | |
| 411 | - if ($max <= 0 || $min >= $max) |
|
| 412 | - fatal_lang_error('error_bad_line'); |
|
| 422 | + if ($max <= 0 || $min >= $max) { |
|
| 423 | + fatal_lang_error('error_bad_line'); |
|
| 424 | + } |
|
| 413 | 425 | |
| 414 | 426 | $file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file))))); |
| 415 | 427 | |
@@ -254,8 +254,8 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | case 'datetime': |
| 256 | 256 | if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
| 257 | - return 'str_to_date('. |
|
| 258 | - sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
|
| 257 | + return 'str_to_date(' . |
|
| 258 | + sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) . |
|
| 259 | 259 | ',\'%Y-%m-%d %h:%i:%s\')'; |
| 260 | 260 | else |
| 261 | 261 | smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | $old_pos = 0; |
| 407 | 407 | $pos = -1; |
| 408 | 408 | // Remove the string escape for better runtime |
| 409 | - $db_string_1 = str_replace('\\\'','',$db_string); |
|
| 409 | + $db_string_1 = str_replace('\\\'', '', $db_string); |
|
| 410 | 410 | while (true) |
| 411 | 411 | { |
| 412 | 412 | $pos = strpos($db_string_1, '\'', $pos + 1); |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | { |
| 788 | 788 | $count = count($insertRows); |
| 789 | 789 | $ai = 0; |
| 790 | - for($i = 0; $i < $count; $i++) |
|
| 790 | + for ($i = 0; $i < $count; $i++) |
|
| 791 | 791 | { |
| 792 | 792 | $old_id = $smcFunc['db_insert_id'](); |
| 793 | 793 | |
@@ -813,13 +813,13 @@ discard block |
||
| 813 | 813 | $count2 = count($indexed_columns); |
| 814 | 814 | for ($x = 0; $x < $count2; $x++) |
| 815 | 815 | { |
| 816 | - $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
|
| 816 | + $where_string += key($indexed_columns[$x]) . ' = ' . $insertRows[$i][$x]; |
|
| 817 | 817 | if (($x + 1) < $count2) |
| 818 | 818 | $where_string += ' AND '; |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | - $request = $smcFunc['db_query']('',' |
|
| 822 | - SELECT `'. $keys[0] . '` FROM ' . $table .' |
|
| 821 | + $request = $smcFunc['db_query']('', ' |
|
| 822 | + SELECT `'. $keys[0] . '` FROM ' . $table . ' |
|
| 823 | 823 | WHERE ' . $where_string . ' LIMIT 1', |
| 824 | 824 | array() |
| 825 | 825 | ); |
@@ -848,7 +848,7 @@ discard block |
||
| 848 | 848 | $return_var = array(); |
| 849 | 849 | $count = count($insertRows); |
| 850 | 850 | $start = smf_db_insert_id($table, $keys[0]); |
| 851 | - for ($i = 0; $i < $count; $i++ ) |
|
| 851 | + for ($i = 0; $i < $count; $i++) |
|
| 852 | 852 | $return_var[] = $start + $i; |
| 853 | 853 | } |
| 854 | 854 | return $return_var; |
@@ -985,7 +985,7 @@ discard block |
||
| 985 | 985 | mysqli_stmt_bind_param($mysql_error_data_prep, 'iissssssis', |
| 986 | 986 | $error_array[0], $error_array[1], $error_array[2], $error_array[3], $error_array[4], $error_array[5], $error_array[6], |
| 987 | 987 | $error_array[7], $error_array[8], $error_array[9]); |
| 988 | - mysqli_stmt_execute ($mysql_error_data_prep); |
|
| 988 | + mysqli_stmt_execute($mysql_error_data_prep); |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | /** |
@@ -999,7 +999,7 @@ discard block |
||
| 999 | 999 | */ |
| 1000 | 1000 | function smf_db_custom_order($field, $array_values, $desc = false) |
| 1001 | 1001 | { |
| 1002 | - $return = 'CASE '. $field . ' '; |
|
| 1002 | + $return = 'CASE ' . $field . ' '; |
|
| 1003 | 1003 | $count = count($array_values); |
| 1004 | 1004 | $then = ($desc ? ' THEN -' : ' THEN '); |
| 1005 | 1005 | |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Maps the implementations in this file (smf_db_function_name) |
@@ -33,8 +34,8 @@ discard block |
||
| 33 | 34 | global $smcFunc; |
| 34 | 35 | |
| 35 | 36 | // Map some database specific functions, only do this once. |
| 36 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
| 37 | - $smcFunc += array( |
|
| 37 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
| 38 | + $smcFunc += array( |
|
| 38 | 39 | 'db_query' => 'smf_db_query', |
| 39 | 40 | 'db_quote' => 'smf_db_quote', |
| 40 | 41 | 'db_fetch_assoc' => 'mysqli_fetch_assoc', |
@@ -64,13 +65,16 @@ discard block |
||
| 64 | 65 | 'db_custom_order' => 'smf_db_custom_order', |
| 65 | 66 | 'db_native_replace' => 'smf_db_native_replace', |
| 66 | 67 | ); |
| 68 | + } |
|
| 67 | 69 | |
| 68 | - if (!empty($db_options['persist'])) |
|
| 69 | - $db_server = 'p:' . $db_server; |
|
| 70 | + if (!empty($db_options['persist'])) { |
|
| 71 | + $db_server = 'p:' . $db_server; |
|
| 72 | + } |
|
| 70 | 73 | |
| 71 | 74 | // We are not going to make it very far without these. |
| 72 | - if (!function_exists('mysqli_init') || !function_exists('mysqli_real_connect')) |
|
| 73 | - display_db_error(); |
|
| 75 | + if (!function_exists('mysqli_init') || !function_exists('mysqli_real_connect')) { |
|
| 76 | + display_db_error(); |
|
| 77 | + } |
|
| 74 | 78 | |
| 75 | 79 | $connection = mysqli_init(); |
| 76 | 80 | |
@@ -80,29 +84,33 @@ discard block |
||
| 80 | 84 | |
| 81 | 85 | if ($connection) |
| 82 | 86 | { |
| 83 | - if (!empty($db_options['port'])) |
|
| 84 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, null, $db_options['port'], null, $flags); |
|
| 85 | - else |
|
| 86 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, null, 0, null, $flags); |
|
| 87 | + if (!empty($db_options['port'])) { |
|
| 88 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, null, $db_options['port'], null, $flags); |
|
| 89 | + } else { |
|
| 90 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, null, 0, null, $flags); |
|
| 91 | + } |
|
| 87 | 92 | } |
| 88 | 93 | |
| 89 | 94 | // Something's wrong, show an error if its fatal (which we assume it is) |
| 90 | 95 | if ($success === false) |
| 91 | 96 | { |
| 92 | - if (!empty($db_options['non_fatal'])) |
|
| 93 | - return null; |
|
| 94 | - else |
|
| 95 | - display_db_error(); |
|
| 97 | + if (!empty($db_options['non_fatal'])) { |
|
| 98 | + return null; |
|
| 99 | + } else { |
|
| 100 | + display_db_error(); |
|
| 101 | + } |
|
| 96 | 102 | } |
| 97 | 103 | |
| 98 | 104 | // Select the database, unless told not to |
| 99 | - if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) |
|
| 100 | - display_db_error(); |
|
| 105 | + if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) { |
|
| 106 | + display_db_error(); |
|
| 107 | + } |
|
| 101 | 108 | |
| 102 | 109 | mysqli_query($connection, 'SET SESSION sql_mode = \'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\''); |
| 103 | 110 | |
| 104 | - if (!empty($db_options['db_mb4'])) |
|
| 105 | - $smcFunc['db_mb4'] = (bool) $db_options['db_mb4']; |
|
| 111 | + if (!empty($db_options['db_mb4'])) { |
|
| 112 | + $smcFunc['db_mb4'] = (bool) $db_options['db_mb4']; |
|
| 113 | + } |
|
| 106 | 114 | |
| 107 | 115 | return $connection; |
| 108 | 116 | } |
@@ -173,34 +181,42 @@ discard block |
||
| 173 | 181 | global $db_callback, $user_info, $db_prefix, $smcFunc; |
| 174 | 182 | |
| 175 | 183 | list ($values, $connection) = $db_callback; |
| 176 | - if (!is_object($connection)) |
|
| 177 | - display_db_error(); |
|
| 184 | + if (!is_object($connection)) { |
|
| 185 | + display_db_error(); |
|
| 186 | + } |
|
| 178 | 187 | |
| 179 | - if ($matches[1] === 'db_prefix') |
|
| 180 | - return $db_prefix; |
|
| 188 | + if ($matches[1] === 'db_prefix') { |
|
| 189 | + return $db_prefix; |
|
| 190 | + } |
|
| 181 | 191 | |
| 182 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
| 183 | - return $user_info[$matches[1]]; |
|
| 192 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
| 193 | + return $user_info[$matches[1]]; |
|
| 194 | + } |
|
| 184 | 195 | |
| 185 | - if ($matches[1] === 'empty') |
|
| 186 | - return '\'\''; |
|
| 196 | + if ($matches[1] === 'empty') { |
|
| 197 | + return '\'\''; |
|
| 198 | + } |
|
| 187 | 199 | |
| 188 | - if (!isset($matches[2])) |
|
| 189 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 200 | + if (!isset($matches[2])) { |
|
| 201 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 202 | + } |
|
| 190 | 203 | |
| 191 | - if ($matches[1] === 'literal') |
|
| 192 | - return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
| 204 | + if ($matches[1] === 'literal') { |
|
| 205 | + return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
| 206 | + } |
|
| 193 | 207 | |
| 194 | - if (!isset($values[$matches[2]])) |
|
| 195 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 208 | + if (!isset($values[$matches[2]])) { |
|
| 209 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 210 | + } |
|
| 196 | 211 | |
| 197 | 212 | $replacement = $values[$matches[2]]; |
| 198 | 213 | |
| 199 | 214 | switch ($matches[1]) |
| 200 | 215 | { |
| 201 | 216 | case 'int': |
| 202 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
| 203 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 217 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
| 218 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 219 | + } |
|
| 204 | 220 | return (string) (int) $replacement; |
| 205 | 221 | break; |
| 206 | 222 | |
@@ -212,65 +228,73 @@ discard block |
||
| 212 | 228 | case 'array_int': |
| 213 | 229 | if (is_array($replacement)) |
| 214 | 230 | { |
| 215 | - if (empty($replacement)) |
|
| 216 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 231 | + if (empty($replacement)) { |
|
| 232 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 233 | + } |
|
| 217 | 234 | |
| 218 | 235 | foreach ($replacement as $key => $value) |
| 219 | 236 | { |
| 220 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
| 221 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 237 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
| 238 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 239 | + } |
|
| 222 | 240 | |
| 223 | 241 | $replacement[$key] = (string) (int) $value; |
| 224 | 242 | } |
| 225 | 243 | |
| 226 | 244 | return implode(', ', $replacement); |
| 245 | + } else { |
|
| 246 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 227 | 247 | } |
| 228 | - else |
|
| 229 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 230 | 248 | |
| 231 | 249 | break; |
| 232 | 250 | |
| 233 | 251 | case 'array_string': |
| 234 | 252 | if (is_array($replacement)) |
| 235 | 253 | { |
| 236 | - if (empty($replacement)) |
|
| 237 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 254 | + if (empty($replacement)) { |
|
| 255 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 256 | + } |
|
| 238 | 257 | |
| 239 | - foreach ($replacement as $key => $value) |
|
| 240 | - $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
| 258 | + foreach ($replacement as $key => $value) { |
|
| 259 | + $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
| 260 | + } |
|
| 241 | 261 | |
| 242 | 262 | return implode(', ', $replacement); |
| 263 | + } else { |
|
| 264 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 243 | 265 | } |
| 244 | - else |
|
| 245 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 246 | 266 | break; |
| 247 | 267 | |
| 248 | 268 | case 'date': |
| 249 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
| 250 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 251 | - else |
|
| 252 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 269 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
| 270 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 271 | + } else { |
|
| 272 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 273 | + } |
|
| 253 | 274 | break; |
| 254 | 275 | |
| 255 | 276 | case 'time': |
| 256 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
| 257 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
| 258 | - else |
|
| 259 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 277 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
| 278 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
| 279 | + } else { |
|
| 280 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 281 | + } |
|
| 260 | 282 | break; |
| 261 | 283 | |
| 262 | 284 | case 'datetime': |
| 263 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
| 264 | - return 'str_to_date('. |
|
| 285 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) { |
|
| 286 | + return 'str_to_date('. |
|
| 265 | 287 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
| 266 | 288 | ',\'%Y-%m-%d %h:%i:%s\')'; |
| 267 | - else |
|
| 268 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 289 | + } else { |
|
| 290 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 291 | + } |
|
| 269 | 292 | break; |
| 270 | 293 | |
| 271 | 294 | case 'float': |
| 272 | - if (!is_numeric($replacement)) |
|
| 273 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 295 | + if (!is_numeric($replacement)) { |
|
| 296 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 297 | + } |
|
| 274 | 298 | return (string) (float) $replacement; |
| 275 | 299 | break; |
| 276 | 300 | |
@@ -284,32 +308,37 @@ discard block |
||
| 284 | 308 | break; |
| 285 | 309 | |
| 286 | 310 | case 'inet': |
| 287 | - if ($replacement == 'null' || $replacement == '') |
|
| 288 | - return 'null'; |
|
| 289 | - if (!isValidIP($replacement)) |
|
| 290 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 311 | + if ($replacement == 'null' || $replacement == '') { |
|
| 312 | + return 'null'; |
|
| 313 | + } |
|
| 314 | + if (!isValidIP($replacement)) { |
|
| 315 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 316 | + } |
|
| 291 | 317 | //we don't use the native support of mysql > 5.6.2 |
| 292 | 318 | return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement))); |
| 293 | 319 | |
| 294 | 320 | case 'array_inet': |
| 295 | 321 | if (is_array($replacement)) |
| 296 | 322 | { |
| 297 | - if (empty($replacement)) |
|
| 298 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 323 | + if (empty($replacement)) { |
|
| 324 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 325 | + } |
|
| 299 | 326 | |
| 300 | 327 | foreach ($replacement as $key => $value) |
| 301 | 328 | { |
| 302 | - if ($replacement == 'null' || $replacement == '') |
|
| 303 | - $replacement[$key] = 'null'; |
|
| 304 | - if (!isValidIP($value)) |
|
| 305 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 329 | + if ($replacement == 'null' || $replacement == '') { |
|
| 330 | + $replacement[$key] = 'null'; |
|
| 331 | + } |
|
| 332 | + if (!isValidIP($value)) { |
|
| 333 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 334 | + } |
|
| 306 | 335 | $replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value))); |
| 307 | 336 | } |
| 308 | 337 | |
| 309 | 338 | return implode(', ', $replacement); |
| 339 | + } else { |
|
| 340 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 310 | 341 | } |
| 311 | - else |
|
| 312 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 313 | 342 | break; |
| 314 | 343 | |
| 315 | 344 | default: |
@@ -380,18 +409,20 @@ discard block |
||
| 380 | 409 | // One more query.... |
| 381 | 410 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
| 382 | 411 | |
| 383 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
| 384 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 412 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
| 413 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 414 | + } |
|
| 385 | 415 | |
| 386 | 416 | // Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By |
| 387 | 417 | if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string)) |
| 388 | 418 | { |
| 389 | 419 | // Add before LIMIT |
| 390 | - if ($pos = strpos($db_string, 'LIMIT ')) |
|
| 391 | - $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 392 | - else |
|
| 393 | - // Append it. |
|
| 420 | + if ($pos = strpos($db_string, 'LIMIT ')) { |
|
| 421 | + $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 422 | + } else { |
|
| 423 | + // Append it. |
|
| 394 | 424 | $db_string .= "\n\t\t\tORDER BY null"; |
| 425 | + } |
|
| 395 | 426 | } |
| 396 | 427 | |
| 397 | 428 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
@@ -417,17 +448,18 @@ discard block |
||
| 417 | 448 | while (true) |
| 418 | 449 | { |
| 419 | 450 | $pos = strpos($db_string_1, '\'', $pos + 1); |
| 420 | - if ($pos === false) |
|
| 421 | - break; |
|
| 451 | + if ($pos === false) { |
|
| 452 | + break; |
|
| 453 | + } |
|
| 422 | 454 | $clean .= substr($db_string_1, $old_pos, $pos - $old_pos); |
| 423 | 455 | |
| 424 | 456 | while (true) |
| 425 | 457 | { |
| 426 | 458 | $pos1 = strpos($db_string_1, '\'', $pos + 1); |
| 427 | 459 | $pos2 = strpos($db_string_1, '\\', $pos + 1); |
| 428 | - if ($pos1 === false) |
|
| 429 | - break; |
|
| 430 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
| 460 | + if ($pos1 === false) { |
|
| 461 | + break; |
|
| 462 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
| 431 | 463 | { |
| 432 | 464 | $pos = $pos1; |
| 433 | 465 | break; |
@@ -443,16 +475,19 @@ discard block |
||
| 443 | 475 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
| 444 | 476 | |
| 445 | 477 | // Comments? We don't use comments in our queries, we leave 'em outside! |
| 446 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
| 447 | - $fail = true; |
|
| 478 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
| 479 | + $fail = true; |
|
| 480 | + } |
|
| 448 | 481 | // Trying to change passwords, slow us down, or something? |
| 449 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
| 450 | - $fail = true; |
|
| 451 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
| 452 | - $fail = true; |
|
| 482 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
| 483 | + $fail = true; |
|
| 484 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
| 485 | + $fail = true; |
|
| 486 | + } |
|
| 453 | 487 | |
| 454 | - if (!empty($fail) && function_exists('log_error')) |
|
| 455 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 488 | + if (!empty($fail) && function_exists('log_error')) { |
|
| 489 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 490 | + } |
|
| 456 | 491 | } |
| 457 | 492 | |
| 458 | 493 | // Debugging. |
@@ -462,8 +497,9 @@ discard block |
||
| 462 | 497 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
| 463 | 498 | |
| 464 | 499 | // Initialize $db_cache if not already initialized. |
| 465 | - if (!isset($db_cache)) |
|
| 466 | - $db_cache = array(); |
|
| 500 | + if (!isset($db_cache)) { |
|
| 501 | + $db_cache = array(); |
|
| 502 | + } |
|
| 467 | 503 | |
| 468 | 504 | if (!empty($_SESSION['debug_redirect'])) |
| 469 | 505 | { |
@@ -479,17 +515,20 @@ discard block |
||
| 479 | 515 | $db_cache[$db_count]['s'] = ($st = microtime(true)) - $time_start; |
| 480 | 516 | } |
| 481 | 517 | |
| 482 | - if (empty($db_unbuffered)) |
|
| 483 | - $ret = @mysqli_query($connection, $db_string); |
|
| 484 | - else |
|
| 485 | - $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 518 | + if (empty($db_unbuffered)) { |
|
| 519 | + $ret = @mysqli_query($connection, $db_string); |
|
| 520 | + } else { |
|
| 521 | + $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 522 | + } |
|
| 486 | 523 | |
| 487 | - if ($ret === false && empty($db_values['db_error_skip'])) |
|
| 488 | - $ret = smf_db_error($db_string, $connection); |
|
| 524 | + if ($ret === false && empty($db_values['db_error_skip'])) { |
|
| 525 | + $ret = smf_db_error($db_string, $connection); |
|
| 526 | + } |
|
| 489 | 527 | |
| 490 | 528 | // Debugging. |
| 491 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 492 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 529 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 530 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 531 | + } |
|
| 493 | 532 | |
| 494 | 533 | return $ret; |
| 495 | 534 | } |
@@ -536,12 +575,13 @@ discard block |
||
| 536 | 575 | // Decide which connection to use |
| 537 | 576 | $connection = $connection === null ? $db_connection : $connection; |
| 538 | 577 | |
| 539 | - if ($type == 'begin') |
|
| 540 | - return @mysqli_query($connection, 'BEGIN'); |
|
| 541 | - elseif ($type == 'rollback') |
|
| 542 | - return @mysqli_query($connection, 'ROLLBACK'); |
|
| 543 | - elseif ($type == 'commit') |
|
| 544 | - return @mysqli_query($connection, 'COMMIT'); |
|
| 578 | + if ($type == 'begin') { |
|
| 579 | + return @mysqli_query($connection, 'BEGIN'); |
|
| 580 | + } elseif ($type == 'rollback') { |
|
| 581 | + return @mysqli_query($connection, 'ROLLBACK'); |
|
| 582 | + } elseif ($type == 'commit') { |
|
| 583 | + return @mysqli_query($connection, 'COMMIT'); |
|
| 584 | + } |
|
| 545 | 585 | |
| 546 | 586 | return false; |
| 547 | 587 | } |
@@ -579,8 +619,9 @@ discard block |
||
| 579 | 619 | // 1213: Deadlock found. |
| 580 | 620 | |
| 581 | 621 | // Log the error. |
| 582 | - if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) |
|
| 583 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 622 | + if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) { |
|
| 623 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 624 | + } |
|
| 584 | 625 | |
| 585 | 626 | // Database error auto fixing ;). |
| 586 | 627 | if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1')) |
@@ -589,8 +630,9 @@ discard block |
||
| 589 | 630 | $old_cache = @$modSettings['cache_enable']; |
| 590 | 631 | $modSettings['cache_enable'] = '1'; |
| 591 | 632 | |
| 592 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
| 593 | - $db_last_error = max(@$db_last_error, $temp); |
|
| 633 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
| 634 | + $db_last_error = max(@$db_last_error, $temp); |
|
| 635 | + } |
|
| 594 | 636 | |
| 595 | 637 | if (@$db_last_error < time() - 3600 * 24 * 3) |
| 596 | 638 | { |
@@ -606,8 +648,9 @@ discard block |
||
| 606 | 648 | foreach ($tables as $table) |
| 607 | 649 | { |
| 608 | 650 | // Now, it's still theoretically possible this could be an injection. So backtick it! |
| 609 | - if (trim($table) != '') |
|
| 610 | - $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 651 | + if (trim($table) != '') { |
|
| 652 | + $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 653 | + } |
|
| 611 | 654 | } |
| 612 | 655 | } |
| 613 | 656 | |
@@ -616,8 +659,9 @@ discard block |
||
| 616 | 659 | // Table crashed. Let's try to fix it. |
| 617 | 660 | elseif ($query_errno == 1016) |
| 618 | 661 | { |
| 619 | - if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) |
|
| 620 | - $fix_tables = array('`' . $match[1] . '`'); |
|
| 662 | + if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) { |
|
| 663 | + $fix_tables = array('`' . $match[1] . '`'); |
|
| 664 | + } |
|
| 621 | 665 | } |
| 622 | 666 | // Indexes crashed. Should be easy to fix! |
| 623 | 667 | elseif ($query_errno == 1034 || $query_errno == 1035) |
@@ -636,13 +680,15 @@ discard block |
||
| 636 | 680 | |
| 637 | 681 | // Make a note of the REPAIR... |
| 638 | 682 | cache_put_data('db_last_error', time(), 600); |
| 639 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
| 640 | - updateSettingsFile(array('db_last_error' => time())); |
|
| 683 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
| 684 | + updateSettingsFile(array('db_last_error' => time())); |
|
| 685 | + } |
|
| 641 | 686 | |
| 642 | 687 | // Attempt to find and repair the broken table. |
| 643 | - foreach ($fix_tables as $table) |
|
| 644 | - $smcFunc['db_query']('', " |
|
| 688 | + foreach ($fix_tables as $table) { |
|
| 689 | + $smcFunc['db_query']('', " |
|
| 645 | 690 | REPAIR TABLE $table", false, false); |
| 691 | + } |
|
| 646 | 692 | |
| 647 | 693 | // And send off an email! |
| 648 | 694 | sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror'); |
@@ -651,11 +697,12 @@ discard block |
||
| 651 | 697 | |
| 652 | 698 | // Try the query again...? |
| 653 | 699 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 654 | - if ($ret !== false) |
|
| 655 | - return $ret; |
|
| 700 | + if ($ret !== false) { |
|
| 701 | + return $ret; |
|
| 702 | + } |
|
| 703 | + } else { |
|
| 704 | + $modSettings['cache_enable'] = $old_cache; |
|
| 656 | 705 | } |
| 657 | - else |
|
| 658 | - $modSettings['cache_enable'] = $old_cache; |
|
| 659 | 706 | |
| 660 | 707 | // Check for the "lost connection" or "deadlock found" errors - and try it just one more time. |
| 661 | 708 | if (in_array($query_errno, array(1205, 1213))) |
@@ -668,24 +715,27 @@ discard block |
||
| 668 | 715 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 669 | 716 | |
| 670 | 717 | $new_errno = mysqli_errno($db_connection); |
| 671 | - if ($ret !== false || in_array($new_errno, array(1205, 1213))) |
|
| 672 | - break; |
|
| 718 | + if ($ret !== false || in_array($new_errno, array(1205, 1213))) { |
|
| 719 | + break; |
|
| 720 | + } |
|
| 673 | 721 | } |
| 674 | 722 | |
| 675 | 723 | // If it failed again, shucks to be you... we're not trying it over and over. |
| 676 | - if ($ret !== false) |
|
| 677 | - return $ret; |
|
| 724 | + if ($ret !== false) { |
|
| 725 | + return $ret; |
|
| 726 | + } |
|
| 678 | 727 | } |
| 679 | 728 | } |
| 680 | 729 | // Are they out of space, perhaps? |
| 681 | 730 | elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false)) |
| 682 | 731 | { |
| 683 | - if (!isset($txt)) |
|
| 684 | - $query_error .= ' - check database storage space.'; |
|
| 685 | - else |
|
| 732 | + if (!isset($txt)) { |
|
| 733 | + $query_error .= ' - check database storage space.'; |
|
| 734 | + } else |
|
| 686 | 735 | { |
| 687 | - if (!isset($txt['mysql_error_space'])) |
|
| 688 | - loadLanguage('Errors'); |
|
| 736 | + if (!isset($txt['mysql_error_space'])) { |
|
| 737 | + loadLanguage('Errors'); |
|
| 738 | + } |
|
| 689 | 739 | |
| 690 | 740 | $query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space']; |
| 691 | 741 | } |
@@ -693,15 +743,17 @@ discard block |
||
| 693 | 743 | } |
| 694 | 744 | |
| 695 | 745 | // Nothing's defined yet... just die with it. |
| 696 | - if (empty($context) || empty($txt)) |
|
| 697 | - die($query_error); |
|
| 746 | + if (empty($context) || empty($txt)) { |
|
| 747 | + die($query_error); |
|
| 748 | + } |
|
| 698 | 749 | |
| 699 | 750 | // Show an error message, if possible. |
| 700 | 751 | $context['error_title'] = $txt['database_error']; |
| 701 | - if (allowedTo('admin_forum')) |
|
| 702 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 703 | - else |
|
| 704 | - $context['error_message'] = $txt['try_again']; |
|
| 752 | + if (allowedTo('admin_forum')) { |
|
| 753 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 754 | + } else { |
|
| 755 | + $context['error_message'] = $txt['try_again']; |
|
| 756 | + } |
|
| 705 | 757 | |
| 706 | 758 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
| 707 | 759 | { |
@@ -733,8 +785,9 @@ discard block |
||
| 733 | 785 | $return_var = null; |
| 734 | 786 | |
| 735 | 787 | // With nothing to insert, simply return. |
| 736 | - if (empty($data)) |
|
| 737 | - return; |
|
| 788 | + if (empty($data)) { |
|
| 789 | + return; |
|
| 790 | + } |
|
| 738 | 791 | |
| 739 | 792 | // Replace the prefix holder with the actual prefix. |
| 740 | 793 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -744,23 +797,26 @@ discard block |
||
| 744 | 797 | if (!empty($keys) && (count($keys) > 0) && $returnmode > 0) |
| 745 | 798 | { |
| 746 | 799 | $with_returning = true; |
| 747 | - if ($returnmode == 2) |
|
| 748 | - $return_var = array(); |
|
| 800 | + if ($returnmode == 2) { |
|
| 801 | + $return_var = array(); |
|
| 802 | + } |
|
| 749 | 803 | } |
| 750 | 804 | |
| 751 | 805 | // Inserting data as a single row can be done as a single array. |
| 752 | - if (!is_array($data[array_rand($data)])) |
|
| 753 | - $data = array($data); |
|
| 806 | + if (!is_array($data[array_rand($data)])) { |
|
| 807 | + $data = array($data); |
|
| 808 | + } |
|
| 754 | 809 | |
| 755 | 810 | // Create the mold for a single row insert. |
| 756 | 811 | $insertData = '('; |
| 757 | 812 | foreach ($columns as $columnName => $type) |
| 758 | 813 | { |
| 759 | 814 | // Are we restricting the length? |
| 760 | - if (strpos($type, 'string-') !== false) |
|
| 761 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 762 | - else |
|
| 763 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 815 | + if (strpos($type, 'string-') !== false) { |
|
| 816 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 817 | + } else { |
|
| 818 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 819 | + } |
|
| 764 | 820 | } |
| 765 | 821 | $insertData = substr($insertData, 0, -2) . ')'; |
| 766 | 822 | |
@@ -769,8 +825,9 @@ discard block |
||
| 769 | 825 | |
| 770 | 826 | // Here's where the variables are injected to the query. |
| 771 | 827 | $insertRows = array(); |
| 772 | - foreach ($data as $dataRow) |
|
| 773 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 828 | + foreach ($data as $dataRow) { |
|
| 829 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 830 | + } |
|
| 774 | 831 | |
| 775 | 832 | // Determine the method of insertion. |
| 776 | 833 | $queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT'); |
@@ -789,8 +846,7 @@ discard block |
||
| 789 | 846 | ), |
| 790 | 847 | $connection |
| 791 | 848 | ); |
| 792 | - } |
|
| 793 | - else //special way for ignore method with returning |
|
| 849 | + } else //special way for ignore method with returning |
|
| 794 | 850 | { |
| 795 | 851 | $count = count($insertRows); |
| 796 | 852 | $ai = 0; |
@@ -810,19 +866,21 @@ discard block |
||
| 810 | 866 | ); |
| 811 | 867 | $new_id = $smcFunc['db_insert_id'](); |
| 812 | 868 | |
| 813 | - if ($last_id != $new_id) //the inserted value was new |
|
| 869 | + if ($last_id != $new_id) { |
|
| 870 | + //the inserted value was new |
|
| 814 | 871 | { |
| 815 | 872 | $ai = $new_id; |
| 816 | 873 | } |
| 817 | - else // the inserted value already exists we need to find the pk |
|
| 874 | + } else // the inserted value already exists we need to find the pk |
|
| 818 | 875 | { |
| 819 | 876 | $where_string = ''; |
| 820 | 877 | $count2 = count($indexed_columns); |
| 821 | 878 | for ($x = 0; $x < $count2; $x++) |
| 822 | 879 | { |
| 823 | 880 | $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
| 824 | - if (($x + 1) < $count2) |
|
| 825 | - $where_string += ' AND '; |
|
| 881 | + if (($x + 1) < $count2) { |
|
| 882 | + $where_string += ' AND '; |
|
| 883 | + } |
|
| 826 | 884 | } |
| 827 | 885 | |
| 828 | 886 | $request = $smcFunc['db_query']('',' |
@@ -838,25 +896,27 @@ discard block |
||
| 838 | 896 | } |
| 839 | 897 | } |
| 840 | 898 | |
| 841 | - if ($returnmode == 1) |
|
| 842 | - $return_var = $ai; |
|
| 843 | - else if ($returnmode == 2) |
|
| 844 | - $return_var[] = $ai; |
|
| 899 | + if ($returnmode == 1) { |
|
| 900 | + $return_var = $ai; |
|
| 901 | + } else if ($returnmode == 2) { |
|
| 902 | + $return_var[] = $ai; |
|
| 903 | + } |
|
| 845 | 904 | } |
| 846 | 905 | } |
| 847 | 906 | |
| 848 | 907 | |
| 849 | 908 | if ($with_returning) |
| 850 | 909 | { |
| 851 | - if ($returnmode == 1 && empty($return_var)) |
|
| 852 | - $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
| 853 | - else if ($returnmode == 2 && empty($return_var)) |
|
| 910 | + if ($returnmode == 1 && empty($return_var)) { |
|
| 911 | + $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
| 912 | + } else if ($returnmode == 2 && empty($return_var)) |
|
| 854 | 913 | { |
| 855 | 914 | $return_var = array(); |
| 856 | 915 | $count = count($insertRows); |
| 857 | 916 | $start = smf_db_insert_id($table, $keys[0]); |
| 858 | - for ($i = 0; $i < $count; $i++ ) |
|
| 859 | - $return_var[] = $start + $i; |
|
| 917 | + for ($i = 0; $i < $count; $i++ ) { |
|
| 918 | + $return_var[] = $start + $i; |
|
| 919 | + } |
|
| 860 | 920 | } |
| 861 | 921 | return $return_var; |
| 862 | 922 | } |
@@ -874,8 +934,9 @@ discard block |
||
| 874 | 934 | */ |
| 875 | 935 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
| 876 | 936 | { |
| 877 | - if (empty($log_message)) |
|
| 878 | - $log_message = $error_message; |
|
| 937 | + if (empty($log_message)) { |
|
| 938 | + $log_message = $error_message; |
|
| 939 | + } |
|
| 879 | 940 | |
| 880 | 941 | foreach (debug_backtrace() as $step) |
| 881 | 942 | { |
@@ -894,12 +955,14 @@ discard block |
||
| 894 | 955 | } |
| 895 | 956 | |
| 896 | 957 | // A special case - we want the file and line numbers for debugging. |
| 897 | - if ($error_type == 'return') |
|
| 898 | - return array($file, $line); |
|
| 958 | + if ($error_type == 'return') { |
|
| 959 | + return array($file, $line); |
|
| 960 | + } |
|
| 899 | 961 | |
| 900 | 962 | // Is always a critical error. |
| 901 | - if (function_exists('log_error')) |
|
| 902 | - log_error($log_message, 'critical', $file, $line); |
|
| 963 | + if (function_exists('log_error')) { |
|
| 964 | + log_error($log_message, 'critical', $file, $line); |
|
| 965 | + } |
|
| 903 | 966 | |
| 904 | 967 | if (function_exists('fatal_error')) |
| 905 | 968 | { |
@@ -907,12 +970,12 @@ discard block |
||
| 907 | 970 | |
| 908 | 971 | // Cannot continue... |
| 909 | 972 | exit; |
| 973 | + } elseif ($error_type) { |
|
| 974 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 975 | + } else { |
|
| 976 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 977 | + } |
|
| 910 | 978 | } |
| 911 | - elseif ($error_type) |
|
| 912 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 913 | - else |
|
| 914 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 915 | -} |
|
| 916 | 979 | |
| 917 | 980 | /** |
| 918 | 981 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -929,10 +992,11 @@ discard block |
||
| 929 | 992 | '\\' => '\\\\', |
| 930 | 993 | ); |
| 931 | 994 | |
| 932 | - if ($translate_human_wildcards) |
|
| 933 | - $replacements += array( |
|
| 995 | + if ($translate_human_wildcards) { |
|
| 996 | + $replacements += array( |
|
| 934 | 997 | '*' => '%', |
| 935 | 998 | ); |
| 999 | + } |
|
| 936 | 1000 | |
| 937 | 1001 | return strtr($string, $replacements); |
| 938 | 1002 | } |
@@ -946,8 +1010,9 @@ discard block |
||
| 946 | 1010 | */ |
| 947 | 1011 | function smf_is_resource($result) |
| 948 | 1012 | { |
| 949 | - if ($result instanceof mysqli_result) |
|
| 950 | - return true; |
|
| 1013 | + if ($result instanceof mysqli_result) { |
|
| 1014 | + return true; |
|
| 1015 | + } |
|
| 951 | 1016 | |
| 952 | 1017 | return false; |
| 953 | 1018 | } |
@@ -976,19 +1041,22 @@ discard block |
||
| 976 | 1041 | static $mysql_error_data_prep; |
| 977 | 1042 | |
| 978 | 1043 | // without database we can't do anything |
| 979 | - if (empty($db_connection)) |
|
| 980 | - return; |
|
| 1044 | + if (empty($db_connection)) { |
|
| 1045 | + return; |
|
| 1046 | + } |
|
| 981 | 1047 | |
| 982 | - if (empty($mysql_error_data_prep)) |
|
| 983 | - $mysql_error_data_prep = mysqli_prepare($db_connection, |
|
| 1048 | + if (empty($mysql_error_data_prep)) { |
|
| 1049 | + $mysql_error_data_prep = mysqli_prepare($db_connection, |
|
| 984 | 1050 | 'INSERT INTO ' . $db_prefix . 'log_errors(id_member, log_time, ip, url, message, session, error_type, file, line, backtrace) |
| 985 | 1051 | VALUES( ?, ?, unhex(?), ?, ?, ?, ?, ?, ?, ?)' |
| 986 | 1052 | ); |
| 1053 | + } |
|
| 987 | 1054 | |
| 988 | - if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) |
|
| 989 | - $error_array[2] = bin2hex(inet_pton($error_array[2])); |
|
| 990 | - else |
|
| 991 | - $error_array[2] = null; |
|
| 1055 | + if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) { |
|
| 1056 | + $error_array[2] = bin2hex(inet_pton($error_array[2])); |
|
| 1057 | + } else { |
|
| 1058 | + $error_array[2] = null; |
|
| 1059 | + } |
|
| 992 | 1060 | mysqli_stmt_bind_param($mysql_error_data_prep, 'iissssssis', |
| 993 | 1061 | $error_array[0], $error_array[1], $error_array[2], $error_array[3], $error_array[4], $error_array[5], $error_array[6], |
| 994 | 1062 | $error_array[7], $error_array[8], $error_array[9]); |
@@ -1010,8 +1078,9 @@ discard block |
||
| 1010 | 1078 | $count = count($array_values); |
| 1011 | 1079 | $then = ($desc ? ' THEN -' : ' THEN '); |
| 1012 | 1080 | |
| 1013 | - for ($i = 0; $i < $count; $i++) |
|
| 1014 | - $return .= 'WHEN ' . (int) $array_values[$i] . $then . $i . ' '; |
|
| 1081 | + for ($i = 0; $i < $count; $i++) { |
|
| 1082 | + $return .= 'WHEN ' . (int) $array_values[$i] . $then . $i . ' '; |
|
| 1083 | + } |
|
| 1015 | 1084 | |
| 1016 | 1085 | $return .= 'END'; |
| 1017 | 1086 | return $return; |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | |
| 20 | 21 | /** |
@@ -44,8 +45,9 @@ discard block |
||
| 44 | 45 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_membergroups') ? 'index' : 'settings'); |
| 45 | 46 | |
| 46 | 47 | // Is it elsewhere? |
| 47 | - if (isset($subActions[$_REQUEST['sa']][2])) |
|
| 48 | - require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
| 48 | + if (isset($subActions[$_REQUEST['sa']][2])) { |
|
| 49 | + require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | // Do the permission check, you might not be allowed her. |
| 51 | 53 | isAllowedTo($subActions[$_REQUEST['sa']][1]); |
@@ -104,19 +106,20 @@ discard block |
||
| 104 | 106 | 'function' => function($rowData) use ($scripturl) |
| 105 | 107 | { |
| 106 | 108 | // Since the moderator group has no explicit members, no link is needed. |
| 107 | - if ($rowData['id_group'] == 3) |
|
| 108 | - $group_name = $rowData['group_name']; |
|
| 109 | - else |
|
| 109 | + if ($rowData['id_group'] == 3) { |
|
| 110 | + $group_name = $rowData['group_name']; |
|
| 111 | + } else |
|
| 110 | 112 | { |
| 111 | 113 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
| 112 | 114 | $group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
| 113 | 115 | } |
| 114 | 116 | |
| 115 | 117 | // Add a help option for moderator and administrator. |
| 116 | - if ($rowData['id_group'] == 1) |
|
| 117 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 118 | - elseif ($rowData['id_group'] == 3) |
|
| 119 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 118 | + if ($rowData['id_group'] == 1) { |
|
| 119 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 120 | + } elseif ($rowData['id_group'] == 3) { |
|
| 121 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 122 | + } |
|
| 120 | 123 | |
| 121 | 124 | return $group_name; |
| 122 | 125 | }, |
@@ -329,12 +332,14 @@ discard block |
||
| 329 | 332 | call_integration_hook('integrate_add_membergroup', array($id_group, $postCountBasedGroup)); |
| 330 | 333 | |
| 331 | 334 | // Update the post groups now, if this is a post group! |
| 332 | - if (isset($_POST['min_posts'])) |
|
| 333 | - updateStats('postgroups'); |
|
| 335 | + if (isset($_POST['min_posts'])) { |
|
| 336 | + updateStats('postgroups'); |
|
| 337 | + } |
|
| 334 | 338 | |
| 335 | 339 | // You cannot set permissions for post groups if they are disabled. |
| 336 | - if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) |
|
| 337 | - $_POST['perm_type'] = ''; |
|
| 340 | + if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) { |
|
| 341 | + $_POST['perm_type'] = ''; |
|
| 342 | + } |
|
| 338 | 343 | |
| 339 | 344 | if ($_POST['perm_type'] == 'predefined') |
| 340 | 345 | { |
@@ -364,8 +369,9 @@ discard block |
||
| 364 | 369 | $smcFunc['db_free_result']($request); |
| 365 | 370 | |
| 366 | 371 | // Protected groups are... well, protected! |
| 367 | - if ($copy_type == 1) |
|
| 368 | - fatal_lang_error('membergroup_does_not_exist'); |
|
| 372 | + if ($copy_type == 1) { |
|
| 373 | + fatal_lang_error('membergroup_does_not_exist'); |
|
| 374 | + } |
|
| 369 | 375 | } |
| 370 | 376 | |
| 371 | 377 | // Don't allow copying of a real priviledged person! |
@@ -383,18 +389,20 @@ discard block |
||
| 383 | 389 | $inserts = array(); |
| 384 | 390 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 385 | 391 | { |
| 386 | - if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) |
|
| 387 | - $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
| 392 | + if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) { |
|
| 393 | + $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
| 394 | + } |
|
| 388 | 395 | } |
| 389 | 396 | $smcFunc['db_free_result']($request); |
| 390 | 397 | |
| 391 | - if (!empty($inserts)) |
|
| 392 | - $smcFunc['db_insert']('insert', |
|
| 398 | + if (!empty($inserts)) { |
|
| 399 | + $smcFunc['db_insert']('insert', |
|
| 393 | 400 | '{db_prefix}permissions', |
| 394 | 401 | array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
| 395 | 402 | $inserts, |
| 396 | 403 | array('id_group', 'permission') |
| 397 | 404 | ); |
| 405 | + } |
|
| 398 | 406 | |
| 399 | 407 | $request = $smcFunc['db_query']('', ' |
| 400 | 408 | SELECT id_profile, permission, add_deny |
@@ -405,17 +413,19 @@ discard block |
||
| 405 | 413 | ) |
| 406 | 414 | ); |
| 407 | 415 | $inserts = array(); |
| 408 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 409 | - $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
| 416 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 417 | + $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
| 418 | + } |
|
| 410 | 419 | $smcFunc['db_free_result']($request); |
| 411 | 420 | |
| 412 | - if (!empty($inserts)) |
|
| 413 | - $smcFunc['db_insert']('insert', |
|
| 421 | + if (!empty($inserts)) { |
|
| 422 | + $smcFunc['db_insert']('insert', |
|
| 414 | 423 | '{db_prefix}board_permissions', |
| 415 | 424 | array('id_group' => 'int', 'id_profile' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
| 416 | 425 | $inserts, |
| 417 | 426 | array('id_group', 'id_profile', 'permission') |
| 418 | 427 | ); |
| 428 | + } |
|
| 419 | 429 | |
| 420 | 430 | // Also get some membergroup information if we're copying and not copying from guests... |
| 421 | 431 | if ($copy_id > 0 && $_POST['perm_type'] == 'copy') |
@@ -468,14 +478,15 @@ discard block |
||
| 468 | 478 | $changed_boards['allow'] = array(); |
| 469 | 479 | $changed_boards['deny'] = array(); |
| 470 | 480 | $changed_boards['ignore'] = array(); |
| 471 | - foreach ($accesses as $group_id => $action) |
|
| 472 | - $changed_boards[$action][] = (int) $group_id; |
|
| 481 | + foreach ($accesses as $group_id => $action) { |
|
| 482 | + $changed_boards[$action][] = (int) $group_id; |
|
| 483 | + } |
|
| 473 | 484 | |
| 474 | 485 | foreach (array('allow', 'deny') as $board_action) |
| 475 | 486 | { |
| 476 | 487 | // Only do this if they have special access requirements. |
| 477 | - if (!empty($changed_boards[$board_action])) |
|
| 478 | - $smcFunc['db_query']('', ' |
|
| 488 | + if (!empty($changed_boards[$board_action])) { |
|
| 489 | + $smcFunc['db_query']('', ' |
|
| 479 | 490 | UPDATE {db_prefix}boards |
| 480 | 491 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
| 481 | 492 | WHERE id_board IN ({array_int:board_list})', |
@@ -487,11 +498,13 @@ discard block |
||
| 487 | 498 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 488 | 499 | ) |
| 489 | 500 | ); |
| 501 | + } |
|
| 490 | 502 | } |
| 491 | 503 | |
| 492 | 504 | // If this is joinable then set it to show group membership in people's profiles. |
| 493 | - if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) |
|
| 494 | - updateSettings(array('show_group_membership' => 1)); |
|
| 505 | + if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) { |
|
| 506 | + updateSettings(array('show_group_membership' => 1)); |
|
| 507 | + } |
|
| 495 | 508 | |
| 496 | 509 | // Rebuild the group cache. |
| 497 | 510 | updateSettings(array( |
@@ -512,8 +525,9 @@ discard block |
||
| 512 | 525 | $context['undefined_group'] = !isset($_REQUEST['postgroup']) && !isset($_REQUEST['generalgroup']); |
| 513 | 526 | $context['allow_protected'] = allowedTo('admin_forum'); |
| 514 | 527 | |
| 515 | - if (!empty($modSettings['deny_boards_access'])) |
|
| 516 | - loadLanguage('ManagePermissions'); |
|
| 528 | + if (!empty($modSettings['deny_boards_access'])) { |
|
| 529 | + loadLanguage('ManagePermissions'); |
|
| 530 | + } |
|
| 517 | 531 | |
| 518 | 532 | $result = $smcFunc['db_query']('', ' |
| 519 | 533 | SELECT id_group, group_name |
@@ -530,11 +544,12 @@ discard block |
||
| 530 | 544 | ) |
| 531 | 545 | ); |
| 532 | 546 | $context['groups'] = array(); |
| 533 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 534 | - $context['groups'][] = array( |
|
| 547 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 548 | + $context['groups'][] = array( |
|
| 535 | 549 | 'id' => $row['id_group'], |
| 536 | 550 | 'name' => $row['group_name'] |
| 537 | 551 | ); |
| 552 | + } |
|
| 538 | 553 | $smcFunc['db_free_result']($result); |
| 539 | 554 | |
| 540 | 555 | $request = $smcFunc['db_query']('', ' |
@@ -551,12 +566,13 @@ discard block |
||
| 551 | 566 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 552 | 567 | { |
| 553 | 568 | // This category hasn't been set up yet.. |
| 554 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 555 | - $context['categories'][$row['id_cat']] = array( |
|
| 569 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 570 | + $context['categories'][$row['id_cat']] = array( |
|
| 556 | 571 | 'id' => $row['id_cat'], |
| 557 | 572 | 'name' => $row['cat_name'], |
| 558 | 573 | 'boards' => array() |
| 559 | 574 | ); |
| 575 | + } |
|
| 560 | 576 | |
| 561 | 577 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 562 | 578 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -603,8 +619,9 @@ discard block |
||
| 603 | 619 | require_once($sourcedir . '/Subs-Membergroups.php'); |
| 604 | 620 | $result = deleteMembergroups((int) $_REQUEST['group']); |
| 605 | 621 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
| 606 | - if ($result === 'group_cannot_delete_sub') |
|
| 607 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 622 | + if ($result === 'group_cannot_delete_sub') { |
|
| 623 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 624 | + } |
|
| 608 | 625 | |
| 609 | 626 | // Go back to the membergroup index. |
| 610 | 627 | redirectexit('action=admin;area=membergroups;'); |
@@ -626,8 +643,9 @@ discard block |
||
| 626 | 643 | |
| 627 | 644 | $_REQUEST['group'] = isset($_REQUEST['group']) && $_REQUEST['group'] > 0 ? (int) $_REQUEST['group'] : 0; |
| 628 | 645 | |
| 629 | - if (!empty($modSettings['deny_boards_access'])) |
|
| 630 | - loadLanguage('ManagePermissions'); |
|
| 646 | + if (!empty($modSettings['deny_boards_access'])) { |
|
| 647 | + loadLanguage('ManagePermissions'); |
|
| 648 | + } |
|
| 631 | 649 | |
| 632 | 650 | // Make sure this group is editable. |
| 633 | 651 | if (!empty($_REQUEST['group'])) |
@@ -649,8 +667,9 @@ discard block |
||
| 649 | 667 | } |
| 650 | 668 | |
| 651 | 669 | // Now, do we have a valid id? |
| 652 | - if (empty($_REQUEST['group'])) |
|
| 653 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 670 | + if (empty($_REQUEST['group'])) { |
|
| 671 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 672 | + } |
|
| 654 | 673 | |
| 655 | 674 | // People who can manage boards are a bit special. |
| 656 | 675 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -681,8 +700,9 @@ discard block |
||
| 681 | 700 | require_once($sourcedir . '/Subs-Membergroups.php'); |
| 682 | 701 | $result = deleteMembergroups($_REQUEST['group']); |
| 683 | 702 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
| 684 | - if ($result === 'group_cannot_delete_sub') |
|
| 685 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 703 | + if ($result === 'group_cannot_delete_sub') { |
|
| 704 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 705 | + } |
|
| 686 | 706 | |
| 687 | 707 | redirectexit('action=admin;area=membergroups;'); |
| 688 | 708 | } |
@@ -759,16 +779,18 @@ discard block |
||
| 759 | 779 | $request = $smcFunc['db_query']('', ' |
| 760 | 780 | SELECT id_board |
| 761 | 781 | FROM {db_prefix}boards'); |
| 762 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 763 | - $accesses[(int) $row['id_board']] = 'allow'; |
|
| 782 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 783 | + $accesses[(int) $row['id_board']] = 'allow'; |
|
| 784 | + } |
|
| 764 | 785 | $smcFunc['db_free_result']($request); |
| 765 | 786 | } |
| 766 | 787 | |
| 767 | 788 | $changed_boards['allow'] = array(); |
| 768 | 789 | $changed_boards['deny'] = array(); |
| 769 | 790 | $changed_boards['ignore'] = array(); |
| 770 | - foreach ($accesses as $group_id => $action) |
|
| 771 | - $changed_boards[$action][] = (int) $group_id; |
|
| 791 | + foreach ($accesses as $group_id => $action) { |
|
| 792 | + $changed_boards[$action][] = (int) $group_id; |
|
| 793 | + } |
|
| 772 | 794 | |
| 773 | 795 | foreach (array('allow', 'deny') as $board_action) |
| 774 | 796 | { |
@@ -784,8 +806,8 @@ discard block |
||
| 784 | 806 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 785 | 807 | ) |
| 786 | 808 | ); |
| 787 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 788 | - $smcFunc['db_query']('', ' |
|
| 809 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 810 | + $smcFunc['db_query']('', ' |
|
| 789 | 811 | UPDATE {db_prefix}boards |
| 790 | 812 | SET {raw:column} = {string:member_group_access} |
| 791 | 813 | WHERE id_board = {int:current_board}', |
@@ -795,11 +817,12 @@ discard block |
||
| 795 | 817 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 796 | 818 | ) |
| 797 | 819 | ); |
| 820 | + } |
|
| 798 | 821 | $smcFunc['db_free_result']($request); |
| 799 | 822 | |
| 800 | 823 | // Add the membergroup to all boards that hadn't been set yet. |
| 801 | - if (!empty($changed_boards[$board_action])) |
|
| 802 | - $smcFunc['db_query']('', ' |
|
| 824 | + if (!empty($changed_boards[$board_action])) { |
|
| 825 | + $smcFunc['db_query']('', ' |
|
| 803 | 826 | UPDATE {db_prefix}boards |
| 804 | 827 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
| 805 | 828 | WHERE id_board IN ({array_int:board_list}) |
@@ -813,6 +836,7 @@ discard block |
||
| 813 | 836 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 814 | 837 | ) |
| 815 | 838 | ); |
| 839 | + } |
|
| 816 | 840 | } |
| 817 | 841 | } |
| 818 | 842 | |
@@ -838,12 +862,14 @@ discard block |
||
| 838 | 862 | ) |
| 839 | 863 | ); |
| 840 | 864 | $updates = array(); |
| 841 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 842 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 865 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 866 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 867 | + } |
|
| 843 | 868 | $smcFunc['db_free_result']($request); |
| 844 | 869 | |
| 845 | - foreach ($updates as $additional_groups => $memberArray) |
|
| 846 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
| 870 | + foreach ($updates as $additional_groups => $memberArray) { |
|
| 871 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
| 872 | + } |
|
| 847 | 873 | |
| 848 | 874 | // Sorry, but post groups can't moderate boards |
| 849 | 875 | $smcFunc['db_query']('', ' |
@@ -853,8 +879,7 @@ discard block |
||
| 853 | 879 | 'current_group' => (int) $_REQUEST['group'], |
| 854 | 880 | ) |
| 855 | 881 | ); |
| 856 | - } |
|
| 857 | - elseif ($_REQUEST['group'] != 3) |
|
| 882 | + } elseif ($_REQUEST['group'] != 3) |
|
| 858 | 883 | { |
| 859 | 884 | // Making it a hidden group? If so remove everyone with it as primary group (Actually, just make them additional). |
| 860 | 885 | if ($_POST['group_hidden'] == 2) |
@@ -869,8 +894,9 @@ discard block |
||
| 869 | 894 | ) |
| 870 | 895 | ); |
| 871 | 896 | $updates = array(); |
| 872 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 873 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 897 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 898 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 899 | + } |
|
| 874 | 900 | $smcFunc['db_free_result']($request); |
| 875 | 901 | |
| 876 | 902 | foreach ($updates as $additional_groups => $memberArray) |
@@ -912,8 +938,9 @@ discard block |
||
| 912 | 938 | $smcFunc['db_free_result']($request); |
| 913 | 939 | |
| 914 | 940 | // Do we need to update the setting? |
| 915 | - if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) |
|
| 916 | - updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
| 941 | + if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) { |
|
| 942 | + updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
| 943 | + } |
|
| 917 | 944 | } |
| 918 | 945 | |
| 919 | 946 | // Do we need to set inherited permissions? |
@@ -946,8 +973,9 @@ discard block |
||
| 946 | 973 | { |
| 947 | 974 | $moderators[$k] = trim($moderators[$k]); |
| 948 | 975 | |
| 949 | - if (strlen($moderators[$k]) == 0) |
|
| 950 | - unset($moderators[$k]); |
|
| 976 | + if (strlen($moderators[$k]) == 0) { |
|
| 977 | + unset($moderators[$k]); |
|
| 978 | + } |
|
| 951 | 979 | } |
| 952 | 980 | |
| 953 | 981 | // Find all the id_member's for the member_name's in the list. |
@@ -963,8 +991,9 @@ discard block |
||
| 963 | 991 | 'count' => count($moderators), |
| 964 | 992 | ) |
| 965 | 993 | ); |
| 966 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 967 | - $group_moderators[] = $row['id_member']; |
|
| 994 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 995 | + $group_moderators[] = $row['id_member']; |
|
| 996 | + } |
|
| 968 | 997 | $smcFunc['db_free_result']($request); |
| 969 | 998 | } |
| 970 | 999 | } |
@@ -972,8 +1001,9 @@ discard block |
||
| 972 | 1001 | if (!empty($_POST['moderator_list'])) |
| 973 | 1002 | { |
| 974 | 1003 | $moderators = array(); |
| 975 | - foreach ($_POST['moderator_list'] as $moderator) |
|
| 976 | - $moderators[] = (int) $moderator; |
|
| 1004 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
| 1005 | + $moderators[] = (int) $moderator; |
|
| 1006 | + } |
|
| 977 | 1007 | |
| 978 | 1008 | if (!empty($moderators)) |
| 979 | 1009 | { |
@@ -987,8 +1017,9 @@ discard block |
||
| 987 | 1017 | 'num_moderators' => count($moderators), |
| 988 | 1018 | ) |
| 989 | 1019 | ); |
| 990 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 991 | - $group_moderators[] = $row['id_member']; |
|
| 1020 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1021 | + $group_moderators[] = $row['id_member']; |
|
| 1022 | + } |
|
| 992 | 1023 | $smcFunc['db_free_result']($request); |
| 993 | 1024 | } |
| 994 | 1025 | } |
@@ -1000,8 +1031,9 @@ discard block |
||
| 1000 | 1031 | if (!empty($group_moderators)) |
| 1001 | 1032 | { |
| 1002 | 1033 | $mod_insert = array(); |
| 1003 | - foreach ($group_moderators as $moderator) |
|
| 1004 | - $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
| 1034 | + foreach ($group_moderators as $moderator) { |
|
| 1035 | + $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
| 1036 | + } |
|
| 1005 | 1037 | |
| 1006 | 1038 | $smcFunc['db_insert']('insert', |
| 1007 | 1039 | '{db_prefix}group_moderators', |
@@ -1035,8 +1067,9 @@ discard block |
||
| 1035 | 1067 | 'current_group' => (int) $_REQUEST['group'], |
| 1036 | 1068 | ) |
| 1037 | 1069 | ); |
| 1038 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1039 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 1070 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1071 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 1072 | + } |
|
| 1040 | 1073 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1041 | 1074 | $smcFunc['db_free_result']($request); |
| 1042 | 1075 | |
@@ -1073,14 +1106,16 @@ discard block |
||
| 1073 | 1106 | ) |
| 1074 | 1107 | ); |
| 1075 | 1108 | $context['group']['moderators'] = array(); |
| 1076 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1077 | - $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
| 1109 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1110 | + $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
| 1111 | + } |
|
| 1078 | 1112 | $smcFunc['db_free_result']($request); |
| 1079 | 1113 | |
| 1080 | 1114 | $context['group']['moderator_list'] = empty($context['group']['moderators']) ? '' : '"' . implode('", "', $context['group']['moderators']) . '"'; |
| 1081 | 1115 | |
| 1082 | - if (!empty($context['group']['moderators'])) |
|
| 1083 | - list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
| 1116 | + if (!empty($context['group']['moderators'])) { |
|
| 1117 | + list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
| 1118 | + } |
|
| 1084 | 1119 | |
| 1085 | 1120 | // Get a list of boards this membergroup is allowed to see. |
| 1086 | 1121 | $context['boards'] = array(); |
@@ -1100,12 +1135,13 @@ discard block |
||
| 1100 | 1135 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1101 | 1136 | { |
| 1102 | 1137 | // This category hasn't been set up yet.. |
| 1103 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 1104 | - $context['categories'][$row['id_cat']] = array( |
|
| 1138 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 1139 | + $context['categories'][$row['id_cat']] = array( |
|
| 1105 | 1140 | 'id' => $row['id_cat'], |
| 1106 | 1141 | 'name' => $row['cat_name'], |
| 1107 | 1142 | 'boards' => array() |
| 1108 | 1143 | ); |
| 1144 | + } |
|
| 1109 | 1145 | |
| 1110 | 1146 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 1111 | 1147 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -1147,14 +1183,16 @@ discard block |
||
| 1147 | 1183 | $ext = pathinfo($settings['default_theme_dir'] . '/images/membericons/' . $value, PATHINFO_EXTENSION); |
| 1148 | 1184 | |
| 1149 | 1185 | // If the extension is not empty, and it is valid |
| 1150 | - if (!empty($ext) && in_array($ext, $imageExts)) |
|
| 1151 | - $context['possible_icons'][] = $value; |
|
| 1186 | + if (!empty($ext) && in_array($ext, $imageExts)) { |
|
| 1187 | + $context['possible_icons'][] = $value; |
|
| 1188 | + } |
|
| 1152 | 1189 | } |
| 1153 | 1190 | } |
| 1154 | 1191 | |
| 1155 | 1192 | // Insert our JS, if we have possible icons. |
| 1156 | - if (!empty($context['possible_icons'])) |
|
| 1157 | - loadJavaScriptFile('icondropdown.js', array('validate' => true, 'minimize' => true), 'smf_icondropdown'); |
|
| 1193 | + if (!empty($context['possible_icons'])) { |
|
| 1194 | + loadJavaScriptFile('icondropdown.js', array('validate' => true, 'minimize' => true), 'smf_icondropdown'); |
|
| 1195 | + } |
|
| 1158 | 1196 | |
| 1159 | 1197 | loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest'); |
| 1160 | 1198 | |
@@ -1176,8 +1214,9 @@ discard block |
||
| 1176 | 1214 | ) |
| 1177 | 1215 | ); |
| 1178 | 1216 | $context['inheritable_groups'] = array(); |
| 1179 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1180 | - $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
| 1217 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1218 | + $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
| 1219 | + } |
|
| 1181 | 1220 | $smcFunc['db_free_result']($request); |
| 1182 | 1221 | |
| 1183 | 1222 | call_integration_hook('integrate_view_membergroup'); |