@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | </thead> |
| 149 | 149 | <tbody>'; |
| 150 | 150 | |
| 151 | - foreach ($context['membergroups'] as $membergroup) |
|
| 152 | - echo ' |
|
| 151 | + foreach ($context['membergroups'] as $membergroup) { |
|
| 152 | + echo ' |
|
| 153 | 153 | <tr class="windowbg"> |
| 154 | 154 | <td>', $membergroup['name'], '</td> |
| 155 | 155 | <td class="centercol"> |
@@ -159,6 +159,7 @@ discard block |
||
| 159 | 159 | ', $membergroup['can_be_additional'] ? '<input type="checkbox" name="membergroups[2][]" value="' . $membergroup['id'] . '" checked>' : '', ' |
| 160 | 160 | </td> |
| 161 | 161 | </tr>'; |
| 162 | + } |
|
| 162 | 163 | |
| 163 | 164 | echo ' |
| 164 | 165 | <tr class="windowbg"> |
@@ -185,8 +186,8 @@ discard block |
||
| 185 | 186 | </thead> |
| 186 | 187 | <tbody>'; |
| 187 | 188 | |
| 188 | - foreach ($context['postgroups'] as $postgroup) |
|
| 189 | - echo ' |
|
| 189 | + foreach ($context['postgroups'] as $postgroup) { |
|
| 190 | + echo ' |
|
| 190 | 191 | <tr class="windowbg"> |
| 191 | 192 | <td> |
| 192 | 193 | ', $postgroup['name'], ' |
@@ -195,6 +196,7 @@ discard block |
||
| 195 | 196 | <input type="checkbox" name="postgroups[]" value="', $postgroup['id'], '" checked> |
| 196 | 197 | </td> |
| 197 | 198 | </tr>'; |
| 199 | + } |
|
| 198 | 200 | |
| 199 | 201 | echo ' |
| 200 | 202 | <tr class="windowbg"> |
@@ -144,11 +144,12 @@ discard block |
||
| 144 | 144 | <div class="question">', $txt['poll_question'], ': <strong>', $context['poll']['question'], '</strong>'; |
| 145 | 145 | |
| 146 | 146 | $options = 1; |
| 147 | - foreach ($context['poll']['options'] as $option) |
|
| 148 | - echo ' |
|
| 147 | + foreach ($context['poll']['options'] as $option) { |
|
| 148 | + echo ' |
|
| 149 | 149 | <div class="', $option['voted_this'] ? 'voted' : '', '">', $txt['option'], ' ', $options++, ': <strong>', $option['option'], '</strong> |
| 150 | 150 | ', $context['allow_poll_view'] ? $txt['votes'] . ': ' . $option['votes'] . '' : '', ' |
| 151 | 151 | </div>'; |
| 152 | + } |
|
| 152 | 153 | |
| 153 | 154 | echo ' |
| 154 | 155 | </div>'; |
@@ -170,9 +171,10 @@ discard block |
||
| 170 | 171 | echo ' |
| 171 | 172 | <hr>'; |
| 172 | 173 | |
| 173 | - foreach ($context['printattach'][$post['id_msg']] as $attach) |
|
| 174 | - echo ' |
|
| 174 | + foreach ($context['printattach'][$post['id_msg']] as $attach) { |
|
| 175 | + echo ' |
|
| 175 | 176 | <img width="' . $attach['width'] . '" height="' . $attach['height'] . '" src="', $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attach['id_attach'] . '" alt="">'; |
| 177 | + } |
|
| 176 | 178 | } |
| 177 | 179 | |
| 178 | 180 | echo ' |
@@ -207,12 +209,13 @@ discard block |
||
| 207 | 209 | <div class="print_options">'; |
| 208 | 210 | |
| 209 | 211 | // Which option is set, text or text&images |
| 210 | - if (isset($_REQUEST['images'])) |
|
| 211 | - echo ' |
|
| 212 | + if (isset($_REQUEST['images'])) { |
|
| 213 | + echo ' |
|
| 212 | 214 | <a href="', $url_text, '">', $txt['print_page_text'], '</a> | <strong><a href="', $url_images, '">', $txt['print_page_images'], '</a></strong>'; |
| 213 | - else |
|
| 214 | - echo ' |
|
| 215 | + } else { |
|
| 216 | + echo ' |
|
| 215 | 217 | <strong><a href="', $url_text, '">', $txt['print_page_text'], '</a></strong> | <a href="', $url_images, '">', $txt['print_page_images'], '</a>'; |
| 218 | + } |
|
| 216 | 219 | |
| 217 | 220 | echo ' |
| 218 | 221 | </div><!-- .print_options -->'; |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | <div class="windowbg"> |
| 32 | 32 | <ul id="likes">'; |
| 33 | 33 | |
| 34 | - foreach ($context['likers'] as $liker => $like_details) |
|
| 35 | - echo ' |
|
| 34 | + foreach ($context['likers'] as $liker => $like_details) { |
|
| 35 | + echo ' |
|
| 36 | 36 | <li> |
| 37 | 37 | ', $like_details['profile']['avatar']['image'], ' |
| 38 | 38 | <span> |
@@ -41,6 +41,7 @@ discard block |
||
| 41 | 41 | </span> |
| 42 | 42 | <span class="floatright">', $like_details['time'], '</span> |
| 43 | 43 | </li>'; |
| 44 | + } |
|
| 44 | 45 | |
| 45 | 46 | echo ' |
| 46 | 47 | </ul> |
@@ -61,11 +62,12 @@ discard block |
||
| 61 | 62 | echo ' |
| 62 | 63 | <ul class="floatleft">'; |
| 63 | 64 | |
| 64 | - if (!empty($context['data']['can_like'])) |
|
| 65 | - echo ' |
|
| 65 | + if (!empty($context['data']['can_like'])) { |
|
| 66 | + echo ' |
|
| 66 | 67 | <li class="like_button" id="', $context['data']['type'], '_', $context['data']['id_content'], '_likes"', '> |
| 67 | 68 | <a href="', $scripturl, '?action=likes;ltype=', $context['data']['type'], ';sa=like;like=', $context['data']['id_content'], ';', $context['session_var'], '=', $context['session_id'], '" class="', $context['data']['type'], '_like"><span class="generic_icons ', $context['data']['already_liked'] ? 'unlike' : 'like', '"></span> ', $context['data']['already_liked'] ? $txt['unlike'] : $txt['like'], '</a> |
| 68 | 69 | </li>'; |
| 70 | + } |
|
| 69 | 71 | |
| 70 | 72 | if (!empty($context['data']['count'])) |
| 71 | 73 | { |
@@ -20,13 +20,12 @@ discard block |
||
| 20 | 20 | // We completed some tasks? |
| 21 | 21 | if (!empty($context['tasks_were_run'])) |
| 22 | 22 | { |
| 23 | - if (empty($context['scheduled_errors'])) |
|
| 24 | - echo ' |
|
| 23 | + if (empty($context['scheduled_errors'])) { |
|
| 24 | + echo ' |
|
| 25 | 25 | <div class="infobox"> |
| 26 | 26 | ', $txt['scheduled_tasks_were_run'], ' |
| 27 | 27 | </div>'; |
| 28 | - |
|
| 29 | - else |
|
| 28 | + } else |
|
| 30 | 29 | { |
| 31 | 30 | echo ' |
| 32 | 31 | <div class="errorbox" id="errors"> |
@@ -35,14 +34,15 @@ discard block |
||
| 35 | 34 | <strong id="error_serious">', $txt['scheduled_tasks_were_run_errors'], '</strong> |
| 36 | 35 | </dt>'; |
| 37 | 36 | |
| 38 | - foreach ($context['scheduled_errors'] as $task => $errors) |
|
| 39 | - echo ' |
|
| 37 | + foreach ($context['scheduled_errors'] as $task => $errors) { |
|
| 38 | + echo ' |
|
| 40 | 39 | <dd class="error"> |
| 41 | 40 | <strong>', isset($txt['scheduled_task_' . $task]) ? $txt['scheduled_task_' . $task] : $task, '</strong> |
| 42 | 41 | <ul> |
| 43 | 42 | <li>', implode('</li><li>', $errors), '</li> |
| 44 | 43 | </ul> |
| 45 | 44 | </dd>'; |
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | echo ' |
| 48 | 48 | </dl> |
@@ -29,9 +29,10 @@ discard block |
||
| 29 | 29 | // Go through each type of report they can run. |
| 30 | 30 | foreach ($context['report_types'] as $type) |
| 31 | 31 | { |
| 32 | - if (isset($type['description'])) |
|
| 33 | - echo ' |
|
| 32 | + if (isset($type['description'])) { |
|
| 33 | + echo ' |
|
| 34 | 34 | <dt>', $type['description'], '</dt>'; |
| 35 | + } |
|
| 35 | 36 | |
| 36 | 37 | echo ' |
| 37 | 38 | <dd> |
@@ -62,8 +63,9 @@ discard block |
||
| 62 | 63 | </div> |
| 63 | 64 | <div id="report_buttons">'; |
| 64 | 65 | |
| 65 | - if (!empty($context['report_buttons'])) |
|
| 66 | - template_button_strip($context['report_buttons'], 'right'); |
|
| 66 | + if (!empty($context['report_buttons'])) { |
|
| 67 | + template_button_strip($context['report_buttons'], 'right'); |
|
| 68 | + } |
|
| 67 | 69 | |
| 68 | 70 | echo ' |
| 69 | 71 | </div>'; |
@@ -74,25 +76,27 @@ discard block |
||
| 74 | 76 | echo ' |
| 75 | 77 | <table class="table_grid report_results">'; |
| 76 | 78 | |
| 77 | - if (!empty($table['title'])) |
|
| 78 | - echo ' |
|
| 79 | + if (!empty($table['title'])) { |
|
| 80 | + echo ' |
|
| 79 | 81 | <thead> |
| 80 | 82 | <tr class="title_bar"> |
| 81 | 83 | <th scope="col" colspan="', $table['column_count'], '">', $table['title'], '</th> |
| 82 | 84 | </tr> |
| 83 | 85 | </thead> |
| 84 | 86 | <tbody>'; |
| 87 | + } |
|
| 85 | 88 | |
| 86 | 89 | // Now do each row! |
| 87 | 90 | $row_number = 0; |
| 88 | 91 | foreach ($table['data'] as $row) |
| 89 | 92 | { |
| 90 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
| 91 | - echo ' |
|
| 93 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
| 94 | + echo ' |
|
| 92 | 95 | <tr class="windowbg table_caption">'; |
| 93 | - else |
|
| 94 | - echo ' |
|
| 96 | + } else { |
|
| 97 | + echo ' |
|
| 95 | 98 | <tr class="', !empty($row[0]['separator']) ? 'title_bar' : 'windowbg', '">'; |
| 99 | + } |
|
| 96 | 100 | |
| 97 | 101 | // Now do each column. |
| 98 | 102 | $column_number = 0; |
@@ -110,16 +114,17 @@ discard block |
||
| 110 | 114 | } |
| 111 | 115 | |
| 112 | 116 | // Shaded? |
| 113 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
| 114 | - echo ' |
|
| 117 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
| 118 | + echo ' |
|
| 115 | 119 | <td class="table_caption ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
| 116 | 120 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
| 117 | 121 | </td>'; |
| 118 | - else |
|
| 119 | - echo ' |
|
| 122 | + } else { |
|
| 123 | + echo ' |
|
| 120 | 124 | <td class="smalltext centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
| 121 | 125 | ', $data['v'], ' |
| 122 | 126 | </td>'; |
| 127 | + } |
|
| 123 | 128 | |
| 124 | 129 | $column_number++; |
| 125 | 130 | } |
@@ -168,24 +173,26 @@ discard block |
||
| 168 | 173 | <div style="overflow: visible;', $table['max_width'] != 'auto' ? ' width: ' . $table['max_width'] . 'px;' : '', '"> |
| 169 | 174 | <table class="bordercolor">'; |
| 170 | 175 | |
| 171 | - if (!empty($table['title'])) |
|
| 172 | - echo ' |
|
| 176 | + if (!empty($table['title'])) { |
|
| 177 | + echo ' |
|
| 173 | 178 | <tr class="title_bar"> |
| 174 | 179 | <td colspan="', $table['column_count'], '"> |
| 175 | 180 | ', $table['title'], ' |
| 176 | 181 | </td> |
| 177 | 182 | </tr>'; |
| 183 | + } |
|
| 178 | 184 | |
| 179 | 185 | // Now do each row! |
| 180 | 186 | $row_number = 0; |
| 181 | 187 | foreach ($table['data'] as $row) |
| 182 | 188 | { |
| 183 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
| 184 | - echo ' |
|
| 189 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
| 190 | + echo ' |
|
| 185 | 191 | <tr class="titlebg">'; |
| 186 | - else |
|
| 187 | - echo ' |
|
| 192 | + } else { |
|
| 193 | + echo ' |
|
| 188 | 194 | <tr class="windowbg">'; |
| 195 | + } |
|
| 189 | 196 | |
| 190 | 197 | // Now do each column!! |
| 191 | 198 | $column_number = 0; |
@@ -202,16 +209,17 @@ discard block |
||
| 202 | 209 | } |
| 203 | 210 | |
| 204 | 211 | // Shaded? |
| 205 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
| 206 | - echo ' |
|
| 212 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
| 213 | + echo ' |
|
| 207 | 214 | <td class="titlebg ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
| 208 | 215 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
| 209 | 216 | </td>'; |
| 210 | - else |
|
| 211 | - echo ' |
|
| 217 | + } else { |
|
| 218 | + echo ' |
|
| 212 | 219 | <td class="centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
| 213 | 220 | ', $data['v'], ' |
| 214 | 221 | </td>'; |
| 222 | + } |
|
| 215 | 223 | |
| 216 | 224 | $column_number++; |
| 217 | 225 | } |
@@ -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 | * Main entry point for the admin search settings screen. |
@@ -107,11 +108,13 @@ discard block |
||
| 107 | 108 | // Perhaps the search method wants to add some settings? |
| 108 | 109 | require_once($sourcedir . '/Search.php'); |
| 109 | 110 | $searchAPI = findSearchAPI(); |
| 110 | - if (is_callable(array($searchAPI, 'searchSettings'))) |
|
| 111 | - call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
| 111 | + if (is_callable(array($searchAPI, 'searchSettings'))) { |
|
| 112 | + call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
| 113 | + } |
|
| 112 | 114 | |
| 113 | - if ($return_config) |
|
| 114 | - return $config_vars; |
|
| 115 | + if ($return_config) { |
|
| 116 | + return $config_vars; |
|
| 117 | + } |
|
| 115 | 118 | |
| 116 | 119 | $context['page_title'] = $txt['search_settings_title']; |
| 117 | 120 | $context['sub_template'] = 'show_settings'; |
@@ -126,8 +129,9 @@ discard block |
||
| 126 | 129 | |
| 127 | 130 | call_integration_hook('integrate_save_search_settings'); |
| 128 | 131 | |
| 129 | - if (empty($_POST['search_results_per_page'])) |
|
| 130 | - $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 132 | + if (empty($_POST['search_results_per_page'])) { |
|
| 133 | + $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 134 | + } |
|
| 131 | 135 | saveDBSettings($config_vars); |
| 132 | 136 | $_SESSION['adm-save'] = true; |
| 133 | 137 | redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']); |
@@ -177,17 +181,20 @@ discard block |
||
| 177 | 181 | call_integration_hook('integrate_save_search_weights'); |
| 178 | 182 | |
| 179 | 183 | $changes = array(); |
| 180 | - foreach ($factors as $factor) |
|
| 181 | - $changes[$factor] = (int) $_POST[$factor]; |
|
| 184 | + foreach ($factors as $factor) { |
|
| 185 | + $changes[$factor] = (int) $_POST[$factor]; |
|
| 186 | + } |
|
| 182 | 187 | updateSettings($changes); |
| 183 | 188 | } |
| 184 | 189 | |
| 185 | 190 | $context['relative_weights'] = array('total' => 0); |
| 186 | - foreach ($factors as $factor) |
|
| 187 | - $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
| 191 | + foreach ($factors as $factor) { |
|
| 192 | + $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
| 193 | + } |
|
| 188 | 194 | |
| 189 | - foreach ($factors as $factor) |
|
| 190 | - $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
| 195 | + foreach ($factors as $factor) { |
|
| 196 | + $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
| 197 | + } |
|
| 191 | 198 | |
| 192 | 199 | createToken('admin-msw'); |
| 193 | 200 | } |
@@ -215,8 +222,9 @@ discard block |
||
| 215 | 222 | $context['search_apis'] = loadSearchAPIs(); |
| 216 | 223 | |
| 217 | 224 | // Detect whether a fulltext index is set. |
| 218 | - if ($context['supports_fulltext']) |
|
| 219 | - detectFulltextIndex(); |
|
| 225 | + if ($context['supports_fulltext']) { |
|
| 226 | + detectFulltextIndex(); |
|
| 227 | + } |
|
| 220 | 228 | |
| 221 | 229 | if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'createfulltext') |
| 222 | 230 | { |
@@ -240,8 +248,7 @@ discard block |
||
| 240 | 248 | 'language' => $language_ftx |
| 241 | 249 | ) |
| 242 | 250 | ); |
| 243 | - } |
|
| 244 | - else |
|
| 251 | + } else |
|
| 245 | 252 | { |
| 246 | 253 | // Make sure it's gone before creating it. |
| 247 | 254 | $smcFunc['db_query']('', ' |
@@ -259,8 +266,7 @@ discard block |
||
| 259 | 266 | ) |
| 260 | 267 | ); |
| 261 | 268 | } |
| 262 | - } |
|
| 263 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
| 269 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
| 264 | 270 | { |
| 265 | 271 | checkSession('get'); |
| 266 | 272 | validateToken('admin-msm', 'get'); |
@@ -277,12 +283,12 @@ discard block |
||
| 277 | 283 | $context['fulltext_index'] = array(); |
| 278 | 284 | |
| 279 | 285 | // Go back to the default search method. |
| 280 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') |
|
| 281 | - updateSettings(array( |
|
| 286 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') { |
|
| 287 | + updateSettings(array( |
|
| 282 | 288 | 'search_index' => '', |
| 283 | 289 | )); |
| 284 | - } |
|
| 285 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
| 290 | + } |
|
| 291 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
| 286 | 292 | { |
| 287 | 293 | checkSession('get'); |
| 288 | 294 | validateToken('admin-msm', 'get'); |
@@ -304,12 +310,12 @@ discard block |
||
| 304 | 310 | )); |
| 305 | 311 | |
| 306 | 312 | // Go back to the default search method. |
| 307 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
| 308 | - updateSettings(array( |
|
| 313 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
| 314 | + updateSettings(array( |
|
| 309 | 315 | 'search_index' => '', |
| 310 | 316 | )); |
| 311 | - } |
|
| 312 | - elseif (isset($_POST['save'])) |
|
| 317 | + } |
|
| 318 | + } elseif (isset($_POST['save'])) |
|
| 313 | 319 | { |
| 314 | 320 | checkSession(); |
| 315 | 321 | validateToken('admin-msmpost'); |
@@ -331,8 +337,8 @@ discard block |
||
| 331 | 337 | // Get some info about the messages table, to show its size and index size. |
| 332 | 338 | if ($db_type == 'mysql') |
| 333 | 339 | { |
| 334 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
| 335 | - $request = $smcFunc['db_query']('', ' |
|
| 340 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
| 341 | + $request = $smcFunc['db_query']('', ' |
|
| 336 | 342 | SHOW TABLE STATUS |
| 337 | 343 | FROM {string:database_name} |
| 338 | 344 | LIKE {string:table_name}', |
@@ -341,14 +347,15 @@ discard block |
||
| 341 | 347 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
| 342 | 348 | ) |
| 343 | 349 | ); |
| 344 | - else |
|
| 345 | - $request = $smcFunc['db_query']('', ' |
|
| 350 | + } else { |
|
| 351 | + $request = $smcFunc['db_query']('', ' |
|
| 346 | 352 | SHOW TABLE STATUS |
| 347 | 353 | LIKE {string:table_name}', |
| 348 | 354 | array( |
| 349 | 355 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
| 350 | 356 | ) |
| 351 | 357 | ); |
| 358 | + } |
|
| 352 | 359 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
| 353 | 360 | { |
| 354 | 361 | // Only do this if the user has permission to execute this query. |
@@ -360,8 +367,8 @@ discard block |
||
| 360 | 367 | } |
| 361 | 368 | |
| 362 | 369 | // Now check the custom index table, if it exists at all. |
| 363 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
| 364 | - $request = $smcFunc['db_query']('', ' |
|
| 370 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
| 371 | + $request = $smcFunc['db_query']('', ' |
|
| 365 | 372 | SHOW TABLE STATUS |
| 366 | 373 | FROM {string:database_name} |
| 367 | 374 | LIKE {string:table_name}', |
@@ -370,14 +377,15 @@ discard block |
||
| 370 | 377 | 'table_name' => str_replace('_', '\_', $match[2]) . 'log_search_words', |
| 371 | 378 | ) |
| 372 | 379 | ); |
| 373 | - else |
|
| 374 | - $request = $smcFunc['db_query']('', ' |
|
| 380 | + } else { |
|
| 381 | + $request = $smcFunc['db_query']('', ' |
|
| 375 | 382 | SHOW TABLE STATUS |
| 376 | 383 | LIKE {string:table_name}', |
| 377 | 384 | array( |
| 378 | 385 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'log_search_words', |
| 379 | 386 | ) |
| 380 | 387 | ); |
| 388 | + } |
|
| 381 | 389 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
| 382 | 390 | { |
| 383 | 391 | // Only do this if the user has permission to execute this query. |
@@ -386,8 +394,7 @@ discard block |
||
| 386 | 394 | $context['table_info']['custom_index_length'] = $row['Data_length'] + $row['Index_length']; |
| 387 | 395 | $smcFunc['db_free_result']($request); |
| 388 | 396 | } |
| 389 | - } |
|
| 390 | - elseif ($db_type == 'postgresql') |
|
| 397 | + } elseif ($db_type == 'postgresql') |
|
| 391 | 398 | { |
| 392 | 399 | // In order to report the sizes correctly we need to perform vacuum (optimize) on the tables we will be using. |
| 393 | 400 | //db_extend(); |
@@ -429,38 +436,38 @@ discard block |
||
| 429 | 436 | $context['table_info']['data_length'] = (int) $row['table_size']; |
| 430 | 437 | $context['table_info']['index_length'] = (int) $row['index_size']; |
| 431 | 438 | $context['table_info']['fulltext_length'] = (int) $row['index_size']; |
| 432 | - } |
|
| 433 | - elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
| 439 | + } elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
| 434 | 440 | { |
| 435 | 441 | $context['table_info']['index_length'] = (int) $row['index_size']; |
| 436 | 442 | $context['table_info']['custom_index_length'] = (int) $row['index_size']; |
| 437 | 443 | } |
| 438 | 444 | } |
| 439 | 445 | $smcFunc['db_free_result']($request); |
| 440 | - } |
|
| 441 | - else |
|
| 442 | - // Didn't work for some reason... |
|
| 446 | + } else { |
|
| 447 | + // Didn't work for some reason... |
|
| 443 | 448 | $context['table_info'] = array( |
| 444 | 449 | 'data_length' => $txt['not_applicable'], |
| 445 | 450 | 'index_length' => $txt['not_applicable'], |
| 446 | 451 | 'fulltext_length' => $txt['not_applicable'], |
| 447 | 452 | 'custom_index_length' => $txt['not_applicable'], |
| 448 | 453 | ); |
| 449 | - } |
|
| 450 | - else |
|
| 451 | - $context['table_info'] = array( |
|
| 454 | + } |
|
| 455 | + } else { |
|
| 456 | + $context['table_info'] = array( |
|
| 452 | 457 | 'data_length' => $txt['not_applicable'], |
| 453 | 458 | 'index_length' => $txt['not_applicable'], |
| 454 | 459 | 'fulltext_length' => $txt['not_applicable'], |
| 455 | 460 | 'custom_index_length' => $txt['not_applicable'], |
| 456 | 461 | ); |
| 462 | + } |
|
| 457 | 463 | |
| 458 | 464 | // Format the data and index length in kilobytes. |
| 459 | 465 | foreach ($context['table_info'] as $type => $size) |
| 460 | 466 | { |
| 461 | 467 | // If it's not numeric then just break. This database engine doesn't support size. |
| 462 | - if (!is_numeric($size)) |
|
| 463 | - break; |
|
| 468 | + if (!is_numeric($size)) { |
|
| 469 | + break; |
|
| 470 | + } |
|
| 464 | 471 | |
| 465 | 472 | $context['table_info'][$type] = comma_format($context['table_info'][$type] / 1024) . ' ' . $txt['search_method_kilobytes']; |
| 466 | 473 | } |
@@ -489,8 +496,9 @@ discard block |
||
| 489 | 496 | |
| 490 | 497 | // Scotty, we need more time... |
| 491 | 498 | @set_time_limit(600); |
| 492 | - if (function_exists('apache_reset_timeout')) |
|
| 493 | - @apache_reset_timeout(); |
|
| 499 | + if (function_exists('apache_reset_timeout')) { |
|
| 500 | + @apache_reset_timeout(); |
|
| 501 | + } |
|
| 494 | 502 | |
| 495 | 503 | $context[$context['admin_menu_name']]['current_subsection'] = 'method'; |
| 496 | 504 | $context['page_title'] = $txt['search_index_custom']; |
@@ -520,8 +528,7 @@ discard block |
||
| 520 | 528 | $context['start'] = (int) $context['index_settings']['resume_at']; |
| 521 | 529 | unset($context['index_settings']['resume_at']); |
| 522 | 530 | $context['step'] = 1; |
| 523 | - } |
|
| 524 | - else |
|
| 531 | + } else |
|
| 525 | 532 | { |
| 526 | 533 | $context['index_settings'] = array( |
| 527 | 534 | 'bytes_per_word' => isset($_REQUEST['bytes_per_word']) && isset($index_properties[$_REQUEST['bytes_per_word']]) ? (int) $_REQUEST['bytes_per_word'] : 2, |
@@ -530,12 +537,14 @@ discard block |
||
| 530 | 537 | $context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0; |
| 531 | 538 | |
| 532 | 539 | // admin timeouts are painful when building these long indexes - but only if we actually have such things enabled |
| 533 | - if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) |
|
| 534 | - $_SESSION['admin_time'] = time(); |
|
| 540 | + if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) { |
|
| 541 | + $_SESSION['admin_time'] = time(); |
|
| 542 | + } |
|
| 535 | 543 | } |
| 536 | 544 | |
| 537 | - if ($context['step'] !== 0) |
|
| 538 | - checkSession('request'); |
|
| 545 | + if ($context['step'] !== 0) { |
|
| 546 | + checkSession('request'); |
|
| 547 | + } |
|
| 539 | 548 | |
| 540 | 549 | // Step 0: let the user determine how they like their index. |
| 541 | 550 | if ($context['step'] === 0) |
@@ -564,12 +573,14 @@ discard block |
||
| 564 | 573 | $smcFunc['db_create_word_search']($index_properties[$context['index_settings']['bytes_per_word']]['column_definition']); |
| 565 | 574 | |
| 566 | 575 | // Temporarily switch back to not using a search index. |
| 567 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
| 568 | - updateSettings(array('search_index' => '')); |
|
| 576 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
| 577 | + updateSettings(array('search_index' => '')); |
|
| 578 | + } |
|
| 569 | 579 | |
| 570 | 580 | // Don't let simultanious processes be updating the search index. |
| 571 | - if (!empty($modSettings['search_custom_index_config'])) |
|
| 572 | - updateSettings(array('search_custom_index_config' => '')); |
|
| 581 | + if (!empty($modSettings['search_custom_index_config'])) { |
|
| 582 | + updateSettings(array('search_custom_index_config' => '')); |
|
| 583 | + } |
|
| 573 | 584 | } |
| 574 | 585 | |
| 575 | 586 | $num_messages = array( |
@@ -585,16 +596,16 @@ discard block |
||
| 585 | 596 | 'starting_id' => $context['start'], |
| 586 | 597 | ) |
| 587 | 598 | ); |
| 588 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 589 | - $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
| 599 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 600 | + $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
| 601 | + } |
|
| 590 | 602 | |
| 591 | 603 | if (empty($num_messages['todo'])) |
| 592 | 604 | { |
| 593 | 605 | $context['step'] = 2; |
| 594 | 606 | $context['percentage'] = 80; |
| 595 | 607 | $context['start'] = 0; |
| 596 | - } |
|
| 597 | - else |
|
| 608 | + } else |
|
| 598 | 609 | { |
| 599 | 610 | // Number of seconds before the next step. |
| 600 | 611 | $stop = time() + 3; |
@@ -635,21 +646,22 @@ discard block |
||
| 635 | 646 | |
| 636 | 647 | $context['start'] += $forced_break ? $number_processed : $messages_per_batch; |
| 637 | 648 | |
| 638 | - if (!empty($inserts)) |
|
| 639 | - $smcFunc['db_insert']('ignore', |
|
| 649 | + if (!empty($inserts)) { |
|
| 650 | + $smcFunc['db_insert']('ignore', |
|
| 640 | 651 | '{db_prefix}log_search_words', |
| 641 | 652 | array('id_word' => 'int', 'id_msg' => 'int'), |
| 642 | 653 | $inserts, |
| 643 | 654 | array('id_word', 'id_msg') |
| 644 | 655 | ); |
| 656 | + } |
|
| 645 | 657 | if ($num_messages['todo'] === 0) |
| 646 | 658 | { |
| 647 | 659 | $context['step'] = 2; |
| 648 | 660 | $context['start'] = 0; |
| 649 | 661 | break; |
| 662 | + } else { |
|
| 663 | + updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
| 650 | 664 | } |
| 651 | - else |
|
| 652 | - updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
| 653 | 665 | } |
| 654 | 666 | |
| 655 | 667 | // Since there are still two steps to go, 80% is the maximum here. |
@@ -660,9 +672,9 @@ discard block |
||
| 660 | 672 | // Step 2: removing the words that occur too often and are of no use. |
| 661 | 673 | elseif ($context['step'] === 2) |
| 662 | 674 | { |
| 663 | - if ($context['index_settings']['bytes_per_word'] < 4) |
|
| 664 | - $context['step'] = 3; |
|
| 665 | - else |
|
| 675 | + if ($context['index_settings']['bytes_per_word'] < 4) { |
|
| 676 | + $context['step'] = 3; |
|
| 677 | + } else |
|
| 666 | 678 | { |
| 667 | 679 | $stop_words = $context['start'] === 0 || empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']); |
| 668 | 680 | $stop = time() + 3; |
@@ -683,20 +695,22 @@ discard block |
||
| 683 | 695 | 'minimum_messages' => $max_messages, |
| 684 | 696 | ) |
| 685 | 697 | ); |
| 686 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 687 | - $stop_words[] = $row['id_word']; |
|
| 698 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 699 | + $stop_words[] = $row['id_word']; |
|
| 700 | + } |
|
| 688 | 701 | $smcFunc['db_free_result']($request); |
| 689 | 702 | |
| 690 | 703 | updateSettings(array('search_stopwords' => implode(',', $stop_words))); |
| 691 | 704 | |
| 692 | - if (!empty($stop_words)) |
|
| 693 | - $smcFunc['db_query']('', ' |
|
| 705 | + if (!empty($stop_words)) { |
|
| 706 | + $smcFunc['db_query']('', ' |
|
| 694 | 707 | DELETE FROM {db_prefix}log_search_words |
| 695 | 708 | WHERE id_word in ({array_int:stop_words})', |
| 696 | 709 | array( |
| 697 | 710 | 'stop_words' => $stop_words, |
| 698 | 711 | ) |
| 699 | 712 | ); |
| 713 | + } |
|
| 700 | 714 | |
| 701 | 715 | $context['start'] += $index_properties[$context['index_settings']['bytes_per_word']]['step_size']; |
| 702 | 716 | if ($context['start'] > $index_properties[$context['index_settings']['bytes_per_word']]['max_size']) |
@@ -757,8 +771,9 @@ discard block |
||
| 757 | 771 | $searchAPI = new $search_class_name(); |
| 758 | 772 | |
| 759 | 773 | // No Support? NEXT! |
| 760 | - if (!$searchAPI->is_supported) |
|
| 761 | - continue; |
|
| 774 | + if (!$searchAPI->is_supported) { |
|
| 775 | + continue; |
|
| 776 | + } |
|
| 762 | 777 | |
| 763 | 778 | $apis[$index_name] = array( |
| 764 | 779 | 'filename' => $file, |
@@ -805,10 +820,10 @@ discard block |
||
| 805 | 820 | 'messages_ftx' => $db_prefix . 'messages_ftx', |
| 806 | 821 | ) |
| 807 | 822 | ); |
| 808 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 809 | - $context['fulltext_index'][] = $row['indexname']; |
|
| 810 | - } |
|
| 811 | - else |
|
| 823 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 824 | + $context['fulltext_index'][] = $row['indexname']; |
|
| 825 | + } |
|
| 826 | + } else |
|
| 812 | 827 | { |
| 813 | 828 | $request = $smcFunc['db_query']('', ' |
| 814 | 829 | SHOW INDEX |
@@ -819,17 +834,19 @@ discard block |
||
| 819 | 834 | $context['fulltext_index'] = array(); |
| 820 | 835 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 821 | 836 | { |
| 822 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 823 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 837 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 838 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 824 | 839 | $context['fulltext_index'][] = $row['Key_name']; |
| 840 | + } |
|
| 825 | 841 | $smcFunc['db_free_result']($request); |
| 826 | 842 | |
| 827 | - if (is_array($context['fulltext_index'])) |
|
| 828 | - $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
| 843 | + if (is_array($context['fulltext_index'])) { |
|
| 844 | + $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
| 845 | + } |
|
| 829 | 846 | } |
| 830 | 847 | |
| 831 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
| 832 | - $request = $smcFunc['db_query']('', ' |
|
| 848 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
| 849 | + $request = $smcFunc['db_query']('', ' |
|
| 833 | 850 | SHOW TABLE STATUS |
| 834 | 851 | FROM {string:database_name} |
| 835 | 852 | LIKE {string:table_name}', |
@@ -838,20 +855,22 @@ discard block |
||
| 838 | 855 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
| 839 | 856 | ) |
| 840 | 857 | ); |
| 841 | - else |
|
| 842 | - $request = $smcFunc['db_query']('', ' |
|
| 858 | + } else { |
|
| 859 | + $request = $smcFunc['db_query']('', ' |
|
| 843 | 860 | SHOW TABLE STATUS |
| 844 | 861 | LIKE {string:table_name}', |
| 845 | 862 | array( |
| 846 | 863 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
| 847 | 864 | ) |
| 848 | 865 | ); |
| 866 | + } |
|
| 849 | 867 | |
| 850 | 868 | if ($request !== false) |
| 851 | 869 | { |
| 852 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 853 | - if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>='))) |
|
| 870 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 871 | + if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>='))) |
|
| 854 | 872 | $context['cannot_create_fulltext'] = true; |
| 873 | + } |
|
| 855 | 874 | $smcFunc['db_free_result']($request); |
| 856 | 875 | } |
| 857 | 876 | } |
@@ -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 | * Get a list of versions that are currently installed on the server. |
@@ -45,8 +46,7 @@ discard block |
||
| 45 | 46 | $temp2 = $temp->getVersion(); |
| 46 | 47 | $im_version = $temp2['versionString']; |
| 47 | 48 | $extension_version = 'Imagick ' . phpversion('Imagick'); |
| 48 | - } |
|
| 49 | - else |
|
| 49 | + } else |
|
| 50 | 50 | { |
| 51 | 51 | $im_version = MagickGetVersionString(); |
| 52 | 52 | $extension_version = 'MagickWand ' . phpversion('MagickWand'); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | if (in_array('db_server', $checkFor)) |
| 62 | 62 | { |
| 63 | 63 | db_extend(); |
| 64 | - if (!isset($db_connection) || $db_connection === false) |
|
| 65 | - trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | - else |
|
| 64 | + if (!isset($db_connection) || $db_connection === false) { |
|
| 65 | + trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | + } else |
|
| 67 | 67 | { |
| 68 | 68 | $versions['db_engine'] = array('title' => sprintf($txt['support_versions_db_engine'], $smcFunc['db_title']), 'version' => ''); |
| 69 | 69 | $versions['db_engine']['version'] = $smcFunc['db_get_vendor'](); |
@@ -75,24 +75,31 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | // If we're using memcache we need the server info. |
| 77 | 77 | $memcache_version = '???'; |
| 78 | - if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) |
|
| 79 | - $memcache_version = $cacheAPI->getVersion(); |
|
| 78 | + if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) { |
|
| 79 | + $memcache_version = $cacheAPI->getVersion(); |
|
| 80 | + } |
|
| 80 | 81 | |
| 81 | 82 | // Check to see if we have any accelerators installed... |
| 82 | - if (in_array('phpa', $checkFor) && isset($_PHPA)) |
|
| 83 | - $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 84 | - if (in_array('apc', $checkFor) && extension_loaded('apc')) |
|
| 85 | - $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 86 | - if (in_array('memcache', $checkFor) && function_exists('memcache_set')) |
|
| 87 | - $versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version); |
|
| 88 | - if (in_array('xcache', $checkFor) && function_exists('xcache_set')) |
|
| 89 | - $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 83 | + if (in_array('phpa', $checkFor) && isset($_PHPA)) { |
|
| 84 | + $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 85 | + } |
|
| 86 | + if (in_array('apc', $checkFor) && extension_loaded('apc')) { |
|
| 87 | + $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 88 | + } |
|
| 89 | + if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { |
|
| 90 | + $versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version); |
|
| 91 | + } |
|
| 92 | + if (in_array('xcache', $checkFor) && function_exists('xcache_set')) { |
|
| 93 | + $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 94 | + } |
|
| 90 | 95 | |
| 91 | - if (in_array('php', $checkFor)) |
|
| 92 | - $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 96 | + if (in_array('php', $checkFor)) { |
|
| 97 | + $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 98 | + } |
|
| 93 | 99 | |
| 94 | - if (in_array('server', $checkFor)) |
|
| 95 | - $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 100 | + if (in_array('server', $checkFor)) { |
|
| 101 | + $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 102 | + } |
|
| 96 | 103 | |
| 97 | 104 | return $versions; |
| 98 | 105 | } |
@@ -132,11 +139,13 @@ discard block |
||
| 132 | 139 | fclose($fp); |
| 133 | 140 | |
| 134 | 141 | // The comment looks rougly like... that. |
| 135 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 136 | - $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 142 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 143 | + $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 144 | + } |
|
| 137 | 145 | // Not found! This is bad. |
| 138 | - else |
|
| 139 | - $version_info['file_versions']['SSI.php'] = '??'; |
|
| 146 | + else { |
|
| 147 | + $version_info['file_versions']['SSI.php'] = '??'; |
|
| 148 | + } |
|
| 140 | 149 | } |
| 141 | 150 | |
| 142 | 151 | // Do the paid subscriptions handler? |
@@ -147,11 +156,13 @@ discard block |
||
| 147 | 156 | fclose($fp); |
| 148 | 157 | |
| 149 | 158 | // Found it? |
| 150 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 151 | - $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 159 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 160 | + $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 161 | + } |
|
| 152 | 162 | // If we haven't how do we all get paid? |
| 153 | - else |
|
| 154 | - $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 163 | + else { |
|
| 164 | + $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 165 | + } |
|
| 155 | 166 | } |
| 156 | 167 | |
| 157 | 168 | // Load all the files in the Sources directory, except this file and the redirect. |
@@ -166,11 +177,13 @@ discard block |
||
| 166 | 177 | fclose($fp); |
| 167 | 178 | |
| 168 | 179 | // Look for the version comment in the file header. |
| 169 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 170 | - $version_info['file_versions'][$entry] = $match[1]; |
|
| 180 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 181 | + $version_info['file_versions'][$entry] = $match[1]; |
|
| 182 | + } |
|
| 171 | 183 | // It wasn't found, but the file was... show a '??'. |
| 172 | - else |
|
| 173 | - $version_info['file_versions'][$entry] = '??'; |
|
| 184 | + else { |
|
| 185 | + $version_info['file_versions'][$entry] = '??'; |
|
| 186 | + } |
|
| 174 | 187 | } |
| 175 | 188 | } |
| 176 | 189 | $sources_dir->close(); |
@@ -189,11 +202,13 @@ discard block |
||
| 189 | 202 | fclose($fp); |
| 190 | 203 | |
| 191 | 204 | // Look for the version comment in the file header. |
| 192 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 193 | - $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 205 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 206 | + $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 207 | + } |
|
| 194 | 208 | // It wasn't found, but the file was... show a '??'. |
| 195 | - else |
|
| 196 | - $version_info['tasks_versions'][$entry] = '??'; |
|
| 209 | + else { |
|
| 210 | + $version_info['tasks_versions'][$entry] = '??'; |
|
| 211 | + } |
|
| 197 | 212 | } |
| 198 | 213 | } |
| 199 | 214 | $tasks_dir->close(); |
@@ -201,8 +216,9 @@ discard block |
||
| 201 | 216 | |
| 202 | 217 | // Load all the files in the default template directory - and the current theme if applicable. |
| 203 | 218 | $directories = array('default_template_versions' => $settings['default_theme_dir']); |
| 204 | - if ($settings['theme_id'] != 1) |
|
| 205 | - $directories += array('template_versions' => $settings['theme_dir']); |
|
| 219 | + if ($settings['theme_id'] != 1) { |
|
| 220 | + $directories += array('template_versions' => $settings['theme_dir']); |
|
| 221 | + } |
|
| 206 | 222 | |
| 207 | 223 | foreach ($directories as $type => $dirname) |
| 208 | 224 | { |
@@ -217,11 +233,13 @@ discard block |
||
| 217 | 233 | fclose($fp); |
| 218 | 234 | |
| 219 | 235 | // Look for the version comment in the file header. |
| 220 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 221 | - $version_info[$type][$entry] = $match[1]; |
|
| 236 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 237 | + $version_info[$type][$entry] = $match[1]; |
|
| 238 | + } |
|
| 222 | 239 | // It wasn't found, but the file was... show a '??'. |
| 223 | - else |
|
| 224 | - $version_info[$type][$entry] = '??'; |
|
| 240 | + else { |
|
| 241 | + $version_info[$type][$entry] = '??'; |
|
| 242 | + } |
|
| 225 | 243 | } |
| 226 | 244 | } |
| 227 | 245 | $this_dir->close(); |
@@ -242,11 +260,13 @@ discard block |
||
| 242 | 260 | list ($name, $language) = explode('.', $entry); |
| 243 | 261 | |
| 244 | 262 | // Look for the version comment in the file header. |
| 245 | - if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) |
|
| 246 | - $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 263 | + if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) { |
|
| 264 | + $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 265 | + } |
|
| 247 | 266 | // It wasn't found, but the file was... show a '??'. |
| 248 | - else |
|
| 249 | - $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 267 | + else { |
|
| 268 | + $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 269 | + } |
|
| 250 | 270 | } |
| 251 | 271 | } |
| 252 | 272 | $this_dir->close(); |
@@ -261,8 +281,9 @@ discard block |
||
| 261 | 281 | ksort($version_info['tasks_versions']); |
| 262 | 282 | |
| 263 | 283 | // For languages sort each language too. |
| 264 | - foreach ($version_info['default_language_versions'] as $language => $dummy) |
|
| 265 | - ksort($version_info['default_language_versions'][$language]); |
|
| 284 | + foreach ($version_info['default_language_versions'] as $language => $dummy) { |
|
| 285 | + ksort($version_info['default_language_versions'][$language]); |
|
| 286 | + } |
|
| 266 | 287 | } |
| 267 | 288 | return $version_info; |
| 268 | 289 | } |
@@ -304,27 +325,31 @@ discard block |
||
| 304 | 325 | $settingsArray = trim(file_get_contents($boarddir . '/Settings.php')); |
| 305 | 326 | |
| 306 | 327 | // Break it up based on \r or \n, and then clean out extra characters. |
| 307 | - if (strpos($settingsArray, "\n") !== false) |
|
| 308 | - $settingsArray = explode("\n", $settingsArray); |
|
| 309 | - elseif (strpos($settingsArray, "\r") !== false) |
|
| 310 | - $settingsArray = explode("\r", $settingsArray); |
|
| 311 | - else |
|
| 312 | - return; |
|
| 328 | + if (strpos($settingsArray, "\n") !== false) { |
|
| 329 | + $settingsArray = explode("\n", $settingsArray); |
|
| 330 | + } elseif (strpos($settingsArray, "\r") !== false) { |
|
| 331 | + $settingsArray = explode("\r", $settingsArray); |
|
| 332 | + } else { |
|
| 333 | + return; |
|
| 334 | + } |
|
| 313 | 335 | |
| 314 | 336 | // Presumably, the file has to have stuff in it for this function to be called :P. |
| 315 | - if (count($settingsArray) < 10) |
|
| 316 | - return; |
|
| 337 | + if (count($settingsArray) < 10) { |
|
| 338 | + return; |
|
| 339 | + } |
|
| 317 | 340 | |
| 318 | 341 | // remove any /r's that made there way in here |
| 319 | - foreach ($settingsArray as $k => $dummy) |
|
| 320 | - $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 342 | + foreach ($settingsArray as $k => $dummy) { |
|
| 343 | + $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 344 | + } |
|
| 321 | 345 | |
| 322 | 346 | // go line by line and see whats changing |
| 323 | 347 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 324 | 348 | { |
| 325 | 349 | // Don't trim or bother with it if it's not a variable. |
| 326 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 327 | - continue; |
|
| 350 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 351 | + continue; |
|
| 352 | + } |
|
| 328 | 353 | |
| 329 | 354 | $settingsArray[$i] = trim($settingsArray[$i]) . "\n"; |
| 330 | 355 | |
@@ -336,8 +361,7 @@ discard block |
||
| 336 | 361 | { |
| 337 | 362 | updateDbLastError($val); |
| 338 | 363 | unset($config_vars[$var]); |
| 339 | - } |
|
| 340 | - elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 364 | + } elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 341 | 365 | { |
| 342 | 366 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 343 | 367 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n"; |
@@ -348,34 +372,39 @@ discard block |
||
| 348 | 372 | } |
| 349 | 373 | |
| 350 | 374 | // End of the file ... maybe |
| 351 | - if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') |
|
| 352 | - $end = $i; |
|
| 375 | + if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') { |
|
| 376 | + $end = $i; |
|
| 377 | + } |
|
| 353 | 378 | } |
| 354 | 379 | |
| 355 | 380 | // This should never happen, but apparently it is happening. |
| 356 | - if (empty($end) || $end < 10) |
|
| 357 | - $end = count($settingsArray) - 1; |
|
| 381 | + if (empty($end) || $end < 10) { |
|
| 382 | + $end = count($settingsArray) - 1; |
|
| 383 | + } |
|
| 358 | 384 | |
| 359 | 385 | // Still more variables to go? Then lets add them at the end. |
| 360 | 386 | if (!empty($config_vars)) |
| 361 | 387 | { |
| 362 | - if (trim($settingsArray[$end]) == '?' . '>') |
|
| 363 | - $settingsArray[$end++] = ''; |
|
| 364 | - else |
|
| 365 | - $end++; |
|
| 388 | + if (trim($settingsArray[$end]) == '?' . '>') { |
|
| 389 | + $settingsArray[$end++] = ''; |
|
| 390 | + } else { |
|
| 391 | + $end++; |
|
| 392 | + } |
|
| 366 | 393 | |
| 367 | 394 | // Add in any newly defined vars that were passed |
| 368 | - foreach ($config_vars as $var => $val) |
|
| 369 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 395 | + foreach ($config_vars as $var => $val) { |
|
| 396 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 397 | + } |
|
| 370 | 398 | |
| 371 | 399 | $settingsArray[$end] = '?' . '>'; |
| 400 | + } else { |
|
| 401 | + $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 372 | 402 | } |
| 373 | - else |
|
| 374 | - $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 375 | 403 | |
| 376 | 404 | // Sanity error checking: the file needs to be at least 12 lines. |
| 377 | - if (count($settingsArray) < 12) |
|
| 378 | - return; |
|
| 405 | + if (count($settingsArray) < 12) { |
|
| 406 | + return; |
|
| 407 | + } |
|
| 379 | 408 | |
| 380 | 409 | // Try to avoid a few pitfalls: |
| 381 | 410 | // - like a possible race condition, |
@@ -383,8 +412,9 @@ discard block |
||
| 383 | 412 | // |
| 384 | 413 | // Check before you act: if cache is enabled, we can do a simple write test |
| 385 | 414 | // to validate that we even write things on this filesystem. |
| 386 | - if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 387 | - $cachedir = $boarddir . '/cache'; |
|
| 415 | + if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 416 | + $cachedir = $boarddir . '/cache'; |
|
| 417 | + } |
|
| 388 | 418 | |
| 389 | 419 | $test_fp = @fopen($cachedir . '/settings_update.tmp', "w+"); |
| 390 | 420 | if ($test_fp) |
@@ -419,16 +449,18 @@ discard block |
||
| 419 | 449 | // Well this is not good at all, lets see if we can save this |
| 420 | 450 | $context['settings_message'] = 'settings_error'; |
| 421 | 451 | |
| 422 | - if (file_exists($boarddir . '/Settings_bak.php')) |
|
| 423 | - @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 452 | + if (file_exists($boarddir . '/Settings_bak.php')) { |
|
| 453 | + @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 454 | + } |
|
| 424 | 455 | } |
| 425 | 456 | } |
| 426 | 457 | |
| 427 | 458 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 428 | 459 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 429 | - if (function_exists('opcache_invalidate')) |
|
| 430 | - opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 431 | -} |
|
| 460 | + if (function_exists('opcache_invalidate')) { |
|
| 461 | + opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 462 | + } |
|
| 463 | + } |
|
| 432 | 464 | |
| 433 | 465 | /** |
| 434 | 466 | * Saves the time of the last db error for the error log |
@@ -454,8 +486,9 @@ discard block |
||
| 454 | 486 | global $options, $context, $smcFunc, $settings, $user_info; |
| 455 | 487 | |
| 456 | 488 | // This must exist! |
| 457 | - if (!isset($context['admin_preferences'])) |
|
| 458 | - return false; |
|
| 489 | + if (!isset($context['admin_preferences'])) { |
|
| 490 | + return false; |
|
| 491 | + } |
|
| 459 | 492 | |
| 460 | 493 | // This is what we'll be saving. |
| 461 | 494 | $options['admin_preferences'] = $smcFunc['json_encode']($context['admin_preferences']); |
@@ -519,8 +552,9 @@ discard block |
||
| 519 | 552 | $emails_sent = array(); |
| 520 | 553 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 521 | 554 | { |
| 522 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 523 | - continue; |
|
| 555 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 556 | + continue; |
|
| 557 | + } |
|
| 524 | 558 | |
| 525 | 559 | // Stick their particulars in the replacement data. |
| 526 | 560 | $replacements['IDMEMBER'] = $row['id_member']; |
@@ -539,11 +573,12 @@ discard block |
||
| 539 | 573 | $smcFunc['db_free_result']($request); |
| 540 | 574 | |
| 541 | 575 | // Any additional users we must email this to? |
| 542 | - if (!empty($additional_recipients)) |
|
| 543 | - foreach ($additional_recipients as $recipient) |
|
| 576 | + if (!empty($additional_recipients)) { |
|
| 577 | + foreach ($additional_recipients as $recipient) |
|
| 544 | 578 | { |
| 545 | 579 | if (in_array($recipient['email'], $emails_sent)) |
| 546 | 580 | continue; |
| 581 | + } |
|
| 547 | 582 | |
| 548 | 583 | $replacements['IDMEMBER'] = $recipient['id']; |
| 549 | 584 | $replacements['REALNAME'] = $recipient['name']; |
@@ -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 | * The news dispatcher; doesn't do anything, just delegates. |
@@ -67,8 +68,9 @@ discard block |
||
| 67 | 68 | ); |
| 68 | 69 | |
| 69 | 70 | // Force the right area... |
| 70 | - if (substr($_REQUEST['sa'], 0, 7) == 'mailing') |
|
| 71 | - $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
| 71 | + if (substr($_REQUEST['sa'], 0, 7) == 'mailing') { |
|
| 72 | + $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
| 73 | + } |
|
| 72 | 74 | |
| 73 | 75 | call_helper($subActions[$_REQUEST['sa']][0]); |
| 74 | 76 | } |
@@ -99,9 +101,10 @@ discard block |
||
| 99 | 101 | $temp_news = explode("\n", $modSettings['news']); |
| 100 | 102 | |
| 101 | 103 | // Remove the items that were selected. |
| 102 | - foreach ($temp_news as $i => $news) |
|
| 103 | - if (in_array($i, $_POST['remove'])) |
|
| 104 | + foreach ($temp_news as $i => $news) { |
|
| 105 | + if (in_array($i, $_POST['remove'])) |
|
| 104 | 106 | unset($temp_news[$i]); |
| 107 | + } |
|
| 105 | 108 | |
| 106 | 109 | // Update the database. |
| 107 | 110 | updateSettings(array('news' => implode("\n", $temp_news))); |
@@ -117,9 +120,9 @@ discard block |
||
| 117 | 120 | |
| 118 | 121 | foreach ($_POST['news'] as $i => $news) |
| 119 | 122 | { |
| 120 | - if (trim($news) == '') |
|
| 121 | - unset($_POST['news'][$i]); |
|
| 122 | - else |
|
| 123 | + if (trim($news) == '') { |
|
| 124 | + unset($_POST['news'][$i]); |
|
| 125 | + } else |
|
| 123 | 126 | { |
| 124 | 127 | $_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES); |
| 125 | 128 | preparsecode($_POST['news'][$i]); |
@@ -155,12 +158,13 @@ discard block |
||
| 155 | 158 | 'data' => array( |
| 156 | 159 | 'function' => function($news) |
| 157 | 160 | { |
| 158 | - if (is_numeric($news['id'])) |
|
| 159 | - return ' |
|
| 161 | + if (is_numeric($news['id'])) { |
|
| 162 | + return ' |
|
| 160 | 163 | <textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
| 161 | 164 | <div class="floatleft" id="preview_' . $news['id'] . '"></div>'; |
| 162 | - else |
|
| 163 | - return $news['unparsed']; |
|
| 165 | + } else { |
|
| 166 | + return $news['unparsed']; |
|
| 167 | + } |
|
| 164 | 168 | }, |
| 165 | 169 | 'class' => 'half_table', |
| 166 | 170 | ), |
@@ -186,10 +190,11 @@ discard block |
||
| 186 | 190 | 'data' => array( |
| 187 | 191 | 'function' => function($news) |
| 188 | 192 | { |
| 189 | - if (is_numeric($news['id'])) |
|
| 190 | - return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
| 191 | - else |
|
| 192 | - return ''; |
|
| 193 | + if (is_numeric($news['id'])) { |
|
| 194 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
| 195 | + } else { |
|
| 196 | + return ''; |
|
| 197 | + } |
|
| 193 | 198 | }, |
| 194 | 199 | 'class' => 'centercol icon', |
| 195 | 200 | ), |
@@ -283,12 +288,13 @@ discard block |
||
| 283 | 288 | |
| 284 | 289 | $admin_current_news = array(); |
| 285 | 290 | // Ready the current news. |
| 286 | - foreach (explode("\n", $modSettings['news']) as $id => $line) |
|
| 287 | - $admin_current_news[$id] = array( |
|
| 291 | + foreach (explode("\n", $modSettings['news']) as $id => $line) { |
|
| 292 | + $admin_current_news[$id] = array( |
|
| 288 | 293 | 'id' => $id, |
| 289 | 294 | 'unparsed' => un_preparsecode($line), |
| 290 | 295 | 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)), |
| 291 | 296 | ); |
| 297 | + } |
|
| 292 | 298 | |
| 293 | 299 | $admin_current_news['last'] = array( |
| 294 | 300 | 'id' => 'last', |
@@ -355,10 +361,11 @@ discard block |
||
| 355 | 361 | 'member_count' => 0, |
| 356 | 362 | ); |
| 357 | 363 | |
| 358 | - if ($row['min_posts'] == -1) |
|
| 359 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
| 360 | - else |
|
| 361 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
| 364 | + if ($row['min_posts'] == -1) { |
|
| 365 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
| 366 | + } else { |
|
| 367 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
| 368 | + } |
|
| 362 | 369 | } |
| 363 | 370 | $smcFunc['db_free_result']($request); |
| 364 | 371 | |
@@ -374,8 +381,9 @@ discard block |
||
| 374 | 381 | 'post_group_list' => $postGroups, |
| 375 | 382 | ) |
| 376 | 383 | ); |
| 377 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 378 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 384 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 385 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 386 | + } |
|
| 379 | 387 | $smcFunc['db_free_result']($query); |
| 380 | 388 | } |
| 381 | 389 | |
@@ -391,8 +399,9 @@ discard block |
||
| 391 | 399 | 'normal_group_list' => $normalGroups, |
| 392 | 400 | ) |
| 393 | 401 | ); |
| 394 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 395 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 402 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 403 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 404 | + } |
|
| 396 | 405 | $smcFunc['db_free_result']($query); |
| 397 | 406 | |
| 398 | 407 | // Also do those who have it as an additional membergroup - this ones more yucky... |
@@ -409,8 +418,9 @@ discard block |
||
| 409 | 418 | 'blank_string' => '', |
| 410 | 419 | ) |
| 411 | 420 | ); |
| 412 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 413 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 421 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 422 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 423 | + } |
|
| 414 | 424 | $smcFunc['db_free_result']($query); |
| 415 | 425 | } |
| 416 | 426 | |
@@ -461,10 +471,11 @@ discard block |
||
| 461 | 471 | { |
| 462 | 472 | $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : ''; |
| 463 | 473 | |
| 464 | - if (empty($context[$key]) && empty($_REQUEST['xml'])) |
|
| 465 | - $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
| 466 | - elseif (!empty($_REQUEST['xml'])) |
|
| 467 | - continue; |
|
| 474 | + if (empty($context[$key]) && empty($_REQUEST['xml'])) { |
|
| 475 | + $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
| 476 | + } elseif (!empty($_REQUEST['xml'])) { |
|
| 477 | + continue; |
|
| 478 | + } |
|
| 468 | 479 | |
| 469 | 480 | preparsecode($context[$key]); |
| 470 | 481 | if ($html) |
@@ -543,10 +554,12 @@ discard block |
||
| 543 | 554 | |
| 544 | 555 | // Start by finding any members! |
| 545 | 556 | $toClean = array(); |
| 546 | - if (!empty($_POST['members'])) |
|
| 547 | - $toClean[] = 'members'; |
|
| 548 | - if (!empty($_POST['exclude_members'])) |
|
| 549 | - $toClean[] = 'exclude_members'; |
|
| 557 | + if (!empty($_POST['members'])) { |
|
| 558 | + $toClean[] = 'members'; |
|
| 559 | + } |
|
| 560 | + if (!empty($_POST['exclude_members'])) { |
|
| 561 | + $toClean[] = 'exclude_members'; |
|
| 562 | + } |
|
| 550 | 563 | if (!empty($toClean)) |
| 551 | 564 | { |
| 552 | 565 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -558,11 +571,13 @@ discard block |
||
| 558 | 571 | preg_match_all('~"([^"]+)"~', $_POST[$type], $matches); |
| 559 | 572 | $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type])))); |
| 560 | 573 | |
| 561 | - foreach ($_POST[$type] as $index => $member) |
|
| 562 | - if (strlen(trim($member)) > 0) |
|
| 574 | + foreach ($_POST[$type] as $index => $member) { |
|
| 575 | + if (strlen(trim($member)) > 0) |
|
| 563 | 576 | $_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member))); |
| 564 | - else |
|
| 565 | - unset($_POST[$type][$index]); |
|
| 577 | + } |
|
| 578 | + else { |
|
| 579 | + unset($_POST[$type][$index]); |
|
| 580 | + } |
|
| 566 | 581 | |
| 567 | 582 | // Find the members |
| 568 | 583 | $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type]))); |
@@ -572,16 +587,18 @@ discard block |
||
| 572 | 587 | if (isset($_POST['member_list']) && is_array($_POST['member_list'])) |
| 573 | 588 | { |
| 574 | 589 | $members = array(); |
| 575 | - foreach ($_POST['member_list'] as $member_id) |
|
| 576 | - $members[] = (int) $member_id; |
|
| 590 | + foreach ($_POST['member_list'] as $member_id) { |
|
| 591 | + $members[] = (int) $member_id; |
|
| 592 | + } |
|
| 577 | 593 | $_POST['members'] = implode(',', $members); |
| 578 | 594 | } |
| 579 | 595 | |
| 580 | 596 | if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) |
| 581 | 597 | { |
| 582 | 598 | $members = array(); |
| 583 | - foreach ($_POST['exclude_member_list'] as $member_id) |
|
| 584 | - $members[] = (int) $member_id; |
|
| 599 | + foreach ($_POST['exclude_member_list'] as $member_id) { |
|
| 600 | + $members[] = (int) $member_id; |
|
| 601 | + } |
|
| 585 | 602 | $_POST['exclude_members'] = implode(',', $members); |
| 586 | 603 | } |
| 587 | 604 | |
@@ -605,8 +622,9 @@ discard block |
||
| 605 | 622 | 'current_time' => time(), |
| 606 | 623 | ) |
| 607 | 624 | ); |
| 608 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 609 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 625 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 626 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 627 | + } |
|
| 610 | 628 | $smcFunc['db_free_result']($request); |
| 611 | 629 | |
| 612 | 630 | $request = $smcFunc['db_query']('', ' |
@@ -641,8 +659,9 @@ discard block |
||
| 641 | 659 | WHERE email_address IN(' . implode(', ', $condition_array) . ')', |
| 642 | 660 | $condition_array_params |
| 643 | 661 | ); |
| 644 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 645 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 662 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 663 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 664 | + } |
|
| 646 | 665 | $smcFunc['db_free_result']($request); |
| 647 | 666 | } |
| 648 | 667 | |
@@ -660,10 +679,11 @@ discard block |
||
| 660 | 679 | ); |
| 661 | 680 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 662 | 681 | { |
| 663 | - if (in_array(3, $context['recipients'])) |
|
| 664 | - $context['recipients']['exclude_members'][] = $row['identifier']; |
|
| 665 | - else |
|
| 666 | - $context['recipients']['members'][] = $row['identifier']; |
|
| 682 | + if (in_array(3, $context['recipients'])) { |
|
| 683 | + $context['recipients']['exclude_members'][] = $row['identifier']; |
|
| 684 | + } else { |
|
| 685 | + $context['recipients']['members'][] = $row['identifier']; |
|
| 686 | + } |
|
| 667 | 687 | } |
| 668 | 688 | $smcFunc['db_free_result']($request); |
| 669 | 689 | } |
@@ -710,8 +730,9 @@ discard block |
||
| 710 | 730 | $num_at_once = 1000; |
| 711 | 731 | |
| 712 | 732 | // If by PM's I suggest we half the above number. |
| 713 | - if (!empty($_POST['send_pm'])) |
|
| 714 | - $num_at_once /= 2; |
|
| 733 | + if (!empty($_POST['send_pm'])) { |
|
| 734 | + $num_at_once /= 2; |
|
| 735 | + } |
|
| 715 | 736 | |
| 716 | 737 | checkSession(); |
| 717 | 738 | |
@@ -734,8 +755,7 @@ discard block |
||
| 734 | 755 | ); |
| 735 | 756 | list ($context['total_members']) = $smcFunc['db_fetch_row']($request); |
| 736 | 757 | $smcFunc['db_free_result']($request); |
| 737 | - } |
|
| 738 | - else |
|
| 758 | + } else |
|
| 739 | 759 | { |
| 740 | 760 | $context['total_members'] = (int) $_REQUEST['total_members']; |
| 741 | 761 | } |
@@ -753,32 +773,35 @@ discard block |
||
| 753 | 773 | if (!empty($_POST['exclude_members'])) |
| 754 | 774 | { |
| 755 | 775 | $members = explode(',', $_POST['exclude_members']); |
| 756 | - foreach ($members as $member) |
|
| 757 | - if ($member >= $context['start']) |
|
| 776 | + foreach ($members as $member) { |
|
| 777 | + if ($member >= $context['start']) |
|
| 758 | 778 | $context['recipients']['exclude_members'][] = (int) $member; |
| 779 | + } |
|
| 759 | 780 | } |
| 760 | 781 | |
| 761 | 782 | // What about members we *must* do? |
| 762 | 783 | if (!empty($_POST['members'])) |
| 763 | 784 | { |
| 764 | 785 | $members = explode(',', $_POST['members']); |
| 765 | - foreach ($members as $member) |
|
| 766 | - if ($member >= $context['start']) |
|
| 786 | + foreach ($members as $member) { |
|
| 787 | + if ($member >= $context['start']) |
|
| 767 | 788 | $context['recipients']['members'][] = (int) $member; |
| 789 | + } |
|
| 768 | 790 | } |
| 769 | 791 | // Cleaning groups is simple - although deal with both checkbox and commas. |
| 770 | 792 | if (isset($_POST['groups'])) |
| 771 | 793 | { |
| 772 | 794 | if (is_array($_POST['groups'])) |
| 773 | 795 | { |
| 774 | - foreach ($_POST['groups'] as $group => $dummy) |
|
| 775 | - $context['recipients']['groups'][] = (int) $group; |
|
| 776 | - } |
|
| 777 | - else |
|
| 796 | + foreach ($_POST['groups'] as $group => $dummy) { |
|
| 797 | + $context['recipients']['groups'][] = (int) $group; |
|
| 798 | + } |
|
| 799 | + } else |
|
| 778 | 800 | { |
| 779 | 801 | $groups = explode(',', $_POST['groups']); |
| 780 | - foreach ($groups as $group) |
|
| 781 | - $context['recipients']['groups'][] = (int) $group; |
|
| 802 | + foreach ($groups as $group) { |
|
| 803 | + $context['recipients']['groups'][] = (int) $group; |
|
| 804 | + } |
|
| 782 | 805 | } |
| 783 | 806 | } |
| 784 | 807 | // Same for excluded groups |
@@ -786,15 +809,17 @@ discard block |
||
| 786 | 809 | { |
| 787 | 810 | if (is_array($_POST['exclude_groups'])) |
| 788 | 811 | { |
| 789 | - foreach ($_POST['exclude_groups'] as $group => $dummy) |
|
| 790 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 812 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
| 813 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 814 | + } |
|
| 791 | 815 | } |
| 792 | 816 | // Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected |
| 793 | 817 | elseif ($_POST['exclude_groups'] != '') |
| 794 | 818 | { |
| 795 | 819 | $groups = explode(',', $_POST['exclude_groups']); |
| 796 | - foreach ($groups as $group) |
|
| 797 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 820 | + foreach ($groups as $group) { |
|
| 821 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 822 | + } |
|
| 798 | 823 | } |
| 799 | 824 | } |
| 800 | 825 | // Finally - emails! |
@@ -804,14 +829,16 @@ discard block |
||
| 804 | 829 | foreach ($addressed as $curmem) |
| 805 | 830 | { |
| 806 | 831 | $curmem = trim($curmem); |
| 807 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
| 808 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
| 832 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
| 833 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
| 834 | + } |
|
| 809 | 835 | } |
| 810 | 836 | } |
| 811 | 837 | |
| 812 | 838 | // If we're only cleaning drop out here. |
| 813 | - if ($clean_only) |
|
| 814 | - return; |
|
| 839 | + if ($clean_only) { |
|
| 840 | + return; |
|
| 841 | + } |
|
| 815 | 842 | |
| 816 | 843 | require_once($sourcedir . '/Subs-Post.php'); |
| 817 | 844 | |
@@ -827,16 +854,18 @@ discard block |
||
| 827 | 854 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
| 828 | 855 | { |
| 829 | 856 | // Prepare the message for HTML. |
| 830 | - if (!empty($_POST['parse_html'])) |
|
| 831 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
| 857 | + if (!empty($_POST['parse_html'])) { |
|
| 858 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
| 859 | + } |
|
| 832 | 860 | |
| 833 | 861 | // This is here to prevent spam filters from tagging this as spam. |
| 834 | 862 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
| 835 | 863 | { |
| 836 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
| 837 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
| 838 | - else |
|
| 839 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
| 864 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
| 865 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
| 866 | + } else { |
|
| 867 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
| 868 | + } |
|
| 840 | 869 | } |
| 841 | 870 | } |
| 842 | 871 | |
@@ -890,15 +919,17 @@ discard block |
||
| 890 | 919 | foreach ($context['recipients']['emails'] as $k => $email) |
| 891 | 920 | { |
| 892 | 921 | // Done as many as we can? |
| 893 | - if ($i >= $num_at_once) |
|
| 894 | - break; |
|
| 922 | + if ($i >= $num_at_once) { |
|
| 923 | + break; |
|
| 924 | + } |
|
| 895 | 925 | |
| 896 | 926 | // Don't sent it twice! |
| 897 | 927 | unset($context['recipients']['emails'][$k]); |
| 898 | 928 | |
| 899 | 929 | // Dammit - can't PM emails! |
| 900 | - if ($context['send_pm']) |
|
| 901 | - continue; |
|
| 930 | + if ($context['send_pm']) { |
|
| 931 | + continue; |
|
| 932 | + } |
|
| 902 | 933 | |
| 903 | 934 | $to_member = array( |
| 904 | 935 | $email, |
@@ -932,8 +963,9 @@ discard block |
||
| 932 | 963 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
| 933 | 964 | } |
| 934 | 965 | } |
| 935 | - if (!empty($queryBuild)) |
|
| 936 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
| 966 | + if (!empty($queryBuild)) { |
|
| 967 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
| 968 | + } |
|
| 937 | 969 | } |
| 938 | 970 | if (!empty($context['recipients']['members'])) |
| 939 | 971 | { |
@@ -952,8 +984,9 @@ discard block |
||
| 952 | 984 | } |
| 953 | 985 | |
| 954 | 986 | // Anything to exclude? |
| 955 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
| 956 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
| 987 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
| 988 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
| 989 | + } |
|
| 957 | 990 | if (!empty($context['recipients']['exclude_members'])) |
| 958 | 991 | { |
| 959 | 992 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -989,21 +1022,24 @@ discard block |
||
| 989 | 1022 | foreach ($rows as $row) |
| 990 | 1023 | { |
| 991 | 1024 | // Force them to have it? |
| 992 | - if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) |
|
| 993 | - continue; |
|
| 1025 | + if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) { |
|
| 1026 | + continue; |
|
| 1027 | + } |
|
| 994 | 1028 | |
| 995 | 1029 | // What groups are we looking at here? |
| 996 | - if (empty($row['additional_groups'])) |
|
| 997 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
| 998 | - else |
|
| 999 | - $groups = array_merge( |
|
| 1030 | + if (empty($row['additional_groups'])) { |
|
| 1031 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
| 1032 | + } else { |
|
| 1033 | + $groups = array_merge( |
|
| 1000 | 1034 | array($row['id_group'], $row['id_post_group']), |
| 1001 | 1035 | explode(',', $row['additional_groups']) |
| 1002 | 1036 | ); |
| 1037 | + } |
|
| 1003 | 1038 | |
| 1004 | 1039 | // Excluded groups? |
| 1005 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
| 1006 | - continue; |
|
| 1040 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
| 1041 | + continue; |
|
| 1042 | + } |
|
| 1007 | 1043 | |
| 1008 | 1044 | // We might need this |
| 1009 | 1045 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1026,10 +1062,11 @@ discard block |
||
| 1026 | 1062 | ), $_POST['subject']); |
| 1027 | 1063 | |
| 1028 | 1064 | // Send the actual email - or a PM! |
| 1029 | - if (!$context['send_pm']) |
|
| 1030 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
| 1031 | - else |
|
| 1032 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
| 1065 | + if (!$context['send_pm']) { |
|
| 1066 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
| 1067 | + } else { |
|
| 1068 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
| 1069 | + } |
|
| 1033 | 1070 | } |
| 1034 | 1071 | } |
| 1035 | 1072 | |
@@ -1079,8 +1116,9 @@ discard block |
||
| 1079 | 1116 | |
| 1080 | 1117 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
| 1081 | 1118 | |
| 1082 | - if ($return_config) |
|
| 1083 | - return $config_vars; |
|
| 1119 | + if ($return_config) { |
|
| 1120 | + return $config_vars; |
|
| 1121 | + } |
|
| 1084 | 1122 | |
| 1085 | 1123 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
| 1086 | 1124 | $context['sub_template'] = 'show_settings'; |
@@ -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('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * PostgreSQL Cache API class |
@@ -49,8 +50,9 @@ discard block |
||
| 49 | 50 | |
| 50 | 51 | $result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache')); |
| 51 | 52 | |
| 52 | - if (pg_affected_rows($result) === 0) |
|
| 53 | - pg_query($db_connection, 'CREATE UNLOGGED TABLE ' . $db_prefix . 'cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
| 53 | + if (pg_affected_rows($result) === 0) { |
|
| 54 | + pg_query($db_connection, 'CREATE UNLOGGED TABLE ' . $db_prefix . 'cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
| 55 | + } |
|
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | /** |
@@ -60,14 +62,16 @@ discard block |
||
| 60 | 62 | { |
| 61 | 63 | global $smcFunc, $db_connection; |
| 62 | 64 | |
| 63 | - if ($smcFunc['db_title'] !== 'PostgreSQL') |
|
| 64 | - return false; |
|
| 65 | + if ($smcFunc['db_title'] !== 'PostgreSQL') { |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 65 | 68 | |
| 66 | 69 | $result = pg_query($db_connection, 'SHOW server_version_num'); |
| 67 | 70 | $res = pg_fetch_assoc($result); |
| 68 | 71 | |
| 69 | - if ($res['server_version_num'] < 90500) |
|
| 70 | - return false; |
|
| 72 | + if ($res['server_version_num'] < 90500) { |
|
| 73 | + return false; |
|
| 74 | + } |
|
| 71 | 75 | |
| 72 | 76 | return $test ? true : parent::isSupported(); |
| 73 | 77 | } |
@@ -81,13 +85,15 @@ discard block |
||
| 81 | 85 | |
| 82 | 86 | $ttl = time() - $ttl; |
| 83 | 87 | |
| 84 | - if (empty($this->pg_get_data_prep)) |
|
| 85 | - $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
| 88 | + if (empty($this->pg_get_data_prep)) { |
|
| 89 | + $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
| 90 | + } |
|
| 86 | 91 | |
| 87 | 92 | $result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl)); |
| 88 | 93 | |
| 89 | - if (pg_affected_rows($result) === 0) |
|
| 90 | - return null; |
|
| 94 | + if (pg_affected_rows($result) === 0) { |
|
| 95 | + return null; |
|
| 96 | + } |
|
| 91 | 97 | |
| 92 | 98 | $res = pg_fetch_assoc($result); |
| 93 | 99 | |
@@ -101,23 +107,26 @@ discard block |
||
| 101 | 107 | { |
| 102 | 108 | global $db_prefix, $db_connection; |
| 103 | 109 | |
| 104 | - if (!isset($value)) |
|
| 105 | - $value = ''; |
|
| 110 | + if (!isset($value)) { |
|
| 111 | + $value = ''; |
|
| 112 | + } |
|
| 106 | 113 | |
| 107 | 114 | $ttl = time() + $ttl; |
| 108 | 115 | |
| 109 | - if (empty($this->pg_put_data_prep)) |
|
| 110 | - $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
| 116 | + if (empty($this->pg_put_data_prep)) { |
|
| 117 | + $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
| 111 | 118 | 'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3) |
| 112 | 119 | ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl' |
| 113 | 120 | ); |
| 121 | + } |
|
| 114 | 122 | |
| 115 | 123 | $result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl)); |
| 116 | 124 | |
| 117 | - if (pg_affected_rows($result) > 0) |
|
| 118 | - return true; |
|
| 119 | - else |
|
| 120 | - return false; |
|
| 125 | + if (pg_affected_rows($result) > 0) { |
|
| 126 | + return true; |
|
| 127 | + } else { |
|
| 128 | + return false; |
|
| 129 | + } |
|
| 121 | 130 | } |
| 122 | 131 | |
| 123 | 132 | /** |