@@ -31,9 +31,10 @@ discard block |
||
| 31 | 31 | <div class="selectbox floatright" id="upper_show">', $txt['who_show1'], ' |
| 32 | 32 | <select name="show_top" onchange="document.forms.whoFilter.show.value = this.value; document.forms.whoFilter.submit();">'; |
| 33 | 33 | |
| 34 | - foreach ($context['show_methods'] as $value => $label) |
|
| 35 | - echo ' |
|
| 34 | + foreach ($context['show_methods'] as $value => $label) { |
|
| 35 | + echo ' |
|
| 36 | 36 | <option value="', $value, '" ', $value == $context['show_by'] ? ' selected' : '', '>', $label, '</option>'; |
| 37 | + } |
|
| 37 | 38 | echo ' |
| 38 | 39 | </select> |
| 39 | 40 | <noscript> |
@@ -71,9 +72,10 @@ discard block |
||
| 71 | 72 | ', $member['is_guest'] ? $member['name'] : '<a href="' . $member['href'] . '" title="' . $txt['profile_of'] . ' ' . $member['name'] . '"' . (empty($member['color']) ? '' : ' style="color: ' . $member['color'] . '"') . '>' . $member['name'] . '</a>', ' |
| 72 | 73 | </span>'; |
| 73 | 74 | |
| 74 | - if (!empty($member['ip'])) |
|
| 75 | - echo ' |
|
| 75 | + if (!empty($member['ip'])) { |
|
| 76 | + echo ' |
|
| 76 | 77 | (<a href="' . $scripturl . '?action=', ($member['is_guest'] ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $member['id']), ';searchip=' . $member['ip'] . '">' . $member['ip'] . '</a>)'; |
| 78 | + } |
|
| 77 | 79 | |
| 78 | 80 | echo ' |
| 79 | 81 | </td> |
@@ -103,9 +105,10 @@ discard block |
||
| 103 | 105 | <div class="selectbox floatright">', $txt['who_show1'], ' |
| 104 | 106 | <select name="show" onchange="document.forms.whoFilter.submit();">'; |
| 105 | 107 | |
| 106 | - foreach ($context['show_methods'] as $value => $label) |
|
| 107 | - echo ' |
|
| 108 | + foreach ($context['show_methods'] as $value => $label) { |
|
| 109 | + echo ' |
|
| 108 | 110 | <option value="', $value, '" ', $value == $context['show_by'] ? ' selected' : '', '>', $label, '</option>'; |
| 111 | + } |
|
| 109 | 112 | echo ' |
| 110 | 113 | </select> |
| 111 | 114 | <noscript> |
@@ -134,17 +137,19 @@ discard block |
||
| 134 | 137 | |
| 135 | 138 | foreach ($context['credits'] as $section) |
| 136 | 139 | { |
| 137 | - if (isset($section['pretext'])) |
|
| 138 | - echo ' |
|
| 140 | + if (isset($section['pretext'])) { |
|
| 141 | + echo ' |
|
| 139 | 142 | <div class="windowbg noup"> |
| 140 | 143 | <p>', $section['pretext'], '</p> |
| 141 | 144 | </div>'; |
| 145 | + } |
|
| 142 | 146 | |
| 143 | - if (isset($section['title'])) |
|
| 144 | - echo ' |
|
| 147 | + if (isset($section['title'])) { |
|
| 148 | + echo ' |
|
| 145 | 149 | <div class="cat_bar"> |
| 146 | 150 | <h3 class="catbg">', $section['title'], '</h3> |
| 147 | 151 | </div>'; |
| 152 | + } |
|
| 148 | 153 | |
| 149 | 154 | echo ' |
| 150 | 155 | <div class="windowbg2 noup"> |
@@ -152,17 +157,18 @@ discard block |
||
| 152 | 157 | |
| 153 | 158 | foreach ($section['groups'] as $group) |
| 154 | 159 | { |
| 155 | - if (isset($group['title'])) |
|
| 156 | - echo ' |
|
| 160 | + if (isset($group['title'])) { |
|
| 161 | + echo ' |
|
| 157 | 162 | <dt> |
| 158 | 163 | <strong>', $group['title'], '</strong> |
| 159 | 164 | </dt> |
| 160 | 165 | <dd>'; |
| 166 | + } |
|
| 161 | 167 | |
| 162 | 168 | // Try to make this read nicely. |
| 163 | - if (count($group['members']) <= 2) |
|
| 164 | - echo implode(' ' . $txt['credits_and'] . ' ', $group['members']); |
|
| 165 | - else |
|
| 169 | + if (count($group['members']) <= 2) { |
|
| 170 | + echo implode(' ' . $txt['credits_and'] . ' ', $group['members']); |
|
| 171 | + } else |
|
| 166 | 172 | { |
| 167 | 173 | $last_peep = array_pop($group['members']); |
| 168 | 174 | echo implode(', ', $group['members']), ' ', $txt['credits_and'], ' ', $last_peep; |
@@ -175,9 +181,10 @@ discard block |
||
| 175 | 181 | echo ' |
| 176 | 182 | </dl>'; |
| 177 | 183 | |
| 178 | - if (isset($section['posttext'])) |
|
| 179 | - echo ' |
|
| 184 | + if (isset($section['posttext'])) { |
|
| 185 | + echo ' |
|
| 180 | 186 | <p class="posttext">', $section['posttext'], '</p>'; |
| 187 | + } |
|
| 181 | 188 | |
| 182 | 189 | echo ' |
| 183 | 190 | </div>'; |
@@ -192,26 +199,29 @@ discard block |
||
| 192 | 199 | </div> |
| 193 | 200 | <div class="windowbg noup">'; |
| 194 | 201 | |
| 195 | - if (!empty($context['credits_software_graphics']['graphics'])) |
|
| 196 | - echo ' |
|
| 202 | + if (!empty($context['credits_software_graphics']['graphics'])) { |
|
| 203 | + echo ' |
|
| 197 | 204 | <dl> |
| 198 | 205 | <dt><strong>', $txt['credits_graphics'], '</strong></dt> |
| 199 | 206 | <dd>', implode('</dd><dd>', $context['credits_software_graphics']['graphics']), '</dd> |
| 200 | 207 | </dl>'; |
| 208 | + } |
|
| 201 | 209 | |
| 202 | - if (!empty($context['credits_software_graphics']['software'])) |
|
| 203 | - echo ' |
|
| 210 | + if (!empty($context['credits_software_graphics']['software'])) { |
|
| 211 | + echo ' |
|
| 204 | 212 | <dl> |
| 205 | 213 | <dt><strong>', $txt['credits_software'], '</strong></dt> |
| 206 | 214 | <dd>', implode('</dd><dd>', $context['credits_software_graphics']['software']), '</dd> |
| 207 | 215 | </dl>'; |
| 216 | + } |
|
| 208 | 217 | |
| 209 | - if (!empty($context['credits_software_graphics']['fonts'])) |
|
| 210 | - echo ' |
|
| 218 | + if (!empty($context['credits_software_graphics']['fonts'])) { |
|
| 219 | + echo ' |
|
| 211 | 220 | <dl> |
| 212 | 221 | <dt><strong>', $txt['credits_fonts'], '</strong></dt> |
| 213 | 222 | <dd>', implode('</dd><dd>', $context['credits_software_graphics']['fonts']), '</dd> |
| 214 | 223 | </dl>'; |
| 224 | + } |
|
| 215 | 225 | echo ' |
| 216 | 226 | </div>'; |
| 217 | 227 | } |
@@ -226,16 +236,18 @@ discard block |
||
| 226 | 236 | <div class="windowbg noup">'; |
| 227 | 237 | |
| 228 | 238 | // Display the credits. |
| 229 | - if (!empty($context['credits_modifications'])) |
|
| 230 | - echo ' |
|
| 239 | + if (!empty($context['credits_modifications'])) { |
|
| 240 | + echo ' |
|
| 231 | 241 | ', implode(' |
| 232 | 242 | <br>', $context['credits_modifications']); |
| 243 | + } |
|
| 233 | 244 | |
| 234 | 245 | // Legacy. |
| 235 | - if (!empty($context['copyrights']['mods'])) |
|
| 236 | - echo (empty($context['credits_modifications']) ? '<br>' : ''), |
|
| 246 | + if (!empty($context['copyrights']['mods'])) { |
|
| 247 | + echo (empty($context['credits_modifications']) ? '<br>' : ''), |
|
| 237 | 248 | implode(' |
| 238 | 249 | <br>', $context['copyrights']['mods']); |
| 250 | + } |
|
| 239 | 251 | |
| 240 | 252 | echo ' |
| 241 | 253 | </div>'; |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | <div class="windowbg2 noup"> |
| 112 | 112 | <dl class="settings">'; |
| 113 | 113 | |
| 114 | - if (!empty($context['table_info'])) |
|
| 115 | - echo ' |
|
| 114 | + if (!empty($context['table_info'])) { |
|
| 115 | + echo ' |
|
| 116 | 116 | <dt> |
| 117 | 117 | <strong>', $txt['search_method_messages_table_space'], ':</strong> |
| 118 | 118 | </dt> |
@@ -125,6 +125,7 @@ discard block |
||
| 125 | 125 | <dd> |
| 126 | 126 | ', $context['table_info']['index_length'], ' |
| 127 | 127 | </dd>'; |
| 128 | + } |
|
| 128 | 129 | echo ' |
| 129 | 130 | </dl> |
| 130 | 131 | ', $context['double_index'] ? '<div class="noticebox"> |
@@ -146,16 +147,17 @@ discard block |
||
| 146 | 147 | <dd> |
| 147 | 148 | |
| 148 | 149 | <span class="smalltext">'; |
| 149 | - if (empty($context['fulltext_index']) && empty($context['cannot_create_fulltext'])) |
|
| 150 | - echo ' |
|
| 150 | + if (empty($context['fulltext_index']) && empty($context['cannot_create_fulltext'])) { |
|
| 151 | + echo ' |
|
| 151 | 152 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_no_index_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=createfulltext;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_method_fulltext_create'], '</a>]'; |
| 152 | - elseif (empty($context['fulltext_index']) && !empty($context['cannot_create_fulltext'])) |
|
| 153 | - echo ' |
|
| 153 | + } elseif (empty($context['fulltext_index']) && !empty($context['cannot_create_fulltext'])) { |
|
| 154 | + echo ' |
|
| 154 | 155 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_fulltext_cannot_create']; |
| 155 | - else |
|
| 156 | - echo ' |
|
| 156 | + } else { |
|
| 157 | + echo ' |
|
| 157 | 158 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_index_already_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=removefulltext;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_method_fulltext_remove'], '</a>]<br> |
| 158 | 159 | <strong>', $txt['search_index_size'], ':</strong> ', $context['table_info']['fulltext_length']; |
| 160 | + } |
|
| 159 | 161 | echo ' |
| 160 | 162 | </span> |
| 161 | 163 | </dd>'; |
@@ -168,25 +170,27 @@ discard block |
||
| 168 | 170 | </dt> |
| 169 | 171 | <dd> |
| 170 | 172 | <span class="smalltext">'; |
| 171 | - if ($context['custom_index']) |
|
| 172 | - echo ' |
|
| 173 | + if ($context['custom_index']) { |
|
| 174 | + echo ' |
|
| 173 | 175 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_index_already_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=removecustom;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_index_custom_remove'], '</a>]<br> |
| 174 | 176 | <strong>', $txt['search_index_size'], ':</strong> ', $context['table_info']['custom_index_length']; |
| 175 | - elseif ($context['partial_custom_index']) |
|
| 176 | - echo ' |
|
| 177 | + } elseif ($context['partial_custom_index']) { |
|
| 178 | + echo ' |
|
| 177 | 179 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_index_partial'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=removecustom;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_index_custom_remove'], '</a>] [<a href="', $scripturl, '?action=admin;area=managesearch;sa=createmsgindex;resume;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_index_custom_resume'], '</a>]<br> |
| 178 | 180 | <strong>', $txt['search_index_size'], ':</strong> ', $context['table_info']['custom_index_length']; |
| 179 | - else |
|
| 180 | - echo ' |
|
| 181 | + } else { |
|
| 182 | + echo ' |
|
| 181 | 183 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_no_index_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=createmsgindex">', $txt['search_index_create_custom'], '</a>]'; |
| 184 | + } |
|
| 182 | 185 | echo ' |
| 183 | 186 | </span> |
| 184 | 187 | </dd>'; |
| 185 | 188 | |
| 186 | 189 | foreach ($context['search_apis'] as $api) |
| 187 | 190 | { |
| 188 | - if (empty($api['label']) || $api['has_template']) |
|
| 189 | - continue; |
|
| 191 | + if (empty($api['label']) || $api['has_template']) { |
|
| 192 | + continue; |
|
| 193 | + } |
|
| 190 | 194 | |
| 191 | 195 | echo ' |
| 192 | 196 | <dt> |
@@ -194,12 +198,13 @@ discard block |
||
| 194 | 198 | ', $api['label'] ,' |
| 195 | 199 | </dt>'; |
| 196 | 200 | |
| 197 | - if ($api['desc']) |
|
| 198 | - echo ' |
|
| 201 | + if ($api['desc']) { |
|
| 202 | + echo ' |
|
| 199 | 203 | <dd> |
| 200 | 204 | <span class="smalltext">', $api['desc'], '</span> |
| 201 | 205 | </dd>'; |
| 202 | 206 | } |
| 207 | + } |
|
| 203 | 208 | |
| 204 | 209 | echo ' |
| 205 | 210 | </dl> |
@@ -44,10 +44,11 @@ discard block |
||
| 44 | 44 | <dt>', $txt['users_online_today'], ':</dt> |
| 45 | 45 | <dd>', $context['online_today'], '</dd>'; |
| 46 | 46 | |
| 47 | - if (!empty($modSettings['hitStats'])) |
|
| 48 | - echo ' |
|
| 47 | + if (!empty($modSettings['hitStats'])) { |
|
| 48 | + echo ' |
|
| 49 | 49 | <dt>', $txt['num_hits'], ':</dt> |
| 50 | 50 | <dd>', $context['num_hits'], '</dd>'; |
| 51 | + } |
|
| 51 | 52 | |
| 52 | 53 | echo ' |
| 53 | 54 | </dl> |
@@ -71,17 +72,19 @@ discard block |
||
| 71 | 72 | <dt>', $txt['gender_stats'], ':</dt> |
| 72 | 73 | <dd>'; |
| 73 | 74 | |
| 74 | - foreach ($context['gender'] as $g => $n) |
|
| 75 | - echo $g, ': ', $n, '<br>'; |
|
| 75 | + foreach ($context['gender'] as $g => $n) { |
|
| 76 | + echo $g, ': ', $n, '<br>'; |
|
| 77 | + } |
|
| 76 | 78 | |
| 77 | 79 | echo ' |
| 78 | 80 | </dd>'; |
| 79 | 81 | } |
| 80 | 82 | |
| 81 | - if (!empty($modSettings['hitStats'])) |
|
| 82 | - echo ' |
|
| 83 | + if (!empty($modSettings['hitStats'])) { |
|
| 84 | + echo ' |
|
| 83 | 85 | <dt>', $txt['average_hits'], ':</dt> |
| 84 | 86 | <dd>', $context['average_hits'], '</dd>'; |
| 87 | + } |
|
| 85 | 88 | |
| 86 | 89 | echo ' |
| 87 | 90 | </dl>'; |
@@ -105,14 +108,15 @@ discard block |
||
| 105 | 108 | </dt> |
| 106 | 109 | <dd class="statsbar">'; |
| 107 | 110 | |
| 108 | - if (!empty($item['percent'])) |
|
| 109 | - echo ' |
|
| 111 | + if (!empty($item['percent'])) { |
|
| 112 | + echo ' |
|
| 110 | 113 | <div class="bar" style="width: ', $item['percent'], '%;"> |
| 111 | 114 | <span class="righttext">', $item['num'], '</span> |
| 112 | 115 | </div>'; |
| 113 | - else |
|
| 114 | - echo ' |
|
| 116 | + } else { |
|
| 117 | + echo ' |
|
| 115 | 118 | <div class="bar empty"><span class="righttext">', $item['num'], '</span></div>'; |
| 119 | + } |
|
| 116 | 120 | |
| 117 | 121 | echo ' |
| 118 | 122 | </dd>'; |
@@ -144,9 +148,10 @@ discard block |
||
| 144 | 148 | <th>', $txt['stats_new_members'], '</th> |
| 145 | 149 | <th>', $txt['most_online'], '</th>'; |
| 146 | 150 | |
| 147 | - if (!empty($modSettings['hitStats'])) |
|
| 148 | - echo ' |
|
| 151 | + if (!empty($modSettings['hitStats'])) { |
|
| 152 | + echo ' |
|
| 149 | 153 | <th>', $txt['page_views'], '</th>'; |
| 154 | + } |
|
| 150 | 155 | |
| 151 | 156 | echo ' |
| 152 | 157 | </tr> |
@@ -165,9 +170,10 @@ discard block |
||
| 165 | 170 | <th>', $year['new_members'], '</th> |
| 166 | 171 | <th>', $year['most_members_online'], '</th>'; |
| 167 | 172 | |
| 168 | - if (!empty($modSettings['hitStats'])) |
|
| 169 | - echo ' |
|
| 173 | + if (!empty($modSettings['hitStats'])) { |
|
| 174 | + echo ' |
|
| 170 | 175 | <th>', $year['hits'], '</th>'; |
| 176 | + } |
|
| 171 | 177 | |
| 172 | 178 | echo ' |
| 173 | 179 | </tr>'; |
@@ -184,9 +190,10 @@ discard block |
||
| 184 | 190 | <th>', $month['new_members'], '</th> |
| 185 | 191 | <th>', $month['most_members_online'], '</th>'; |
| 186 | 192 | |
| 187 | - if (!empty($modSettings['hitStats'])) |
|
| 188 | - echo ' |
|
| 193 | + if (!empty($modSettings['hitStats'])) { |
|
| 194 | + echo ' |
|
| 189 | 195 | <th>', $month['hits'], '</th>'; |
| 196 | + } |
|
| 190 | 197 | |
| 191 | 198 | echo ' |
| 192 | 199 | </tr>'; |
@@ -203,9 +210,10 @@ discard block |
||
| 203 | 210 | <td>', $day['new_members'], '</td> |
| 204 | 211 | <td>', $day['most_members_online'], '</td>'; |
| 205 | 212 | |
| 206 | - if (!empty($modSettings['hitStats'])) |
|
| 207 | - echo ' |
|
| 213 | + if (!empty($modSettings['hitStats'])) { |
|
| 214 | + echo ' |
|
| 208 | 215 | <td>', $day['hits'], '</td>'; |
| 216 | + } |
|
| 209 | 217 | |
| 210 | 218 | echo ' |
| 211 | 219 | </tr>'; |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Don't do anything if SMF is already loaded. |
| 15 | -if (defined('SMF')) |
|
| 15 | +if (defined('SMF')) { |
|
| 16 | 16 | return true; |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | define('SMF', 'SSI'); |
| 19 | 20 | |
@@ -26,21 +27,24 @@ discard block |
||
| 26 | 27 | |
| 27 | 28 | // Remember the current configuration so it can be set back. |
| 28 | 29 | $ssi_magic_quotes_runtime = function_exists('get_magic_quotes_gpc') && get_magic_quotes_runtime(); |
| 29 | -if (function_exists('set_magic_quotes_runtime')) |
|
| 30 | +if (function_exists('set_magic_quotes_runtime')) { |
|
| 30 | 31 | @set_magic_quotes_runtime(0); |
| 32 | +} |
|
| 31 | 33 | $time_start = microtime(); |
| 32 | 34 | |
| 33 | 35 | // Just being safe... |
| 34 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 36 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 35 | 37 | if (isset($GLOBALS[$variable])) |
| 36 | 38 | unset($GLOBALS[$variable]); |
| 39 | +} |
|
| 37 | 40 | |
| 38 | 41 | // Get the forum's settings for database and file paths. |
| 39 | 42 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 40 | 43 | |
| 41 | 44 | // Make absolutely sure the cache directory is defined. |
| 42 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 45 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 43 | 46 | $cachedir = $boarddir . '/cache'; |
| 47 | +} |
|
| 44 | 48 | |
| 45 | 49 | $ssi_error_reporting = error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL); |
| 46 | 50 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -51,12 +55,14 @@ discard block |
||
| 51 | 55 | $ssi_on_error_method = false; |
| 52 | 56 | |
| 53 | 57 | // Don't do john didley if the forum's been shut down completely. |
| 54 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
| 58 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
| 55 | 59 | die($mmessage); |
| 60 | +} |
|
| 56 | 61 | |
| 57 | 62 | // Fix for using the current directory as a path. |
| 58 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
| 63 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
| 59 | 64 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
| 65 | +} |
|
| 60 | 66 | |
| 61 | 67 | // Load the important includes. |
| 62 | 68 | require_once($sourcedir . '/QueryString.php'); |
@@ -81,34 +87,38 @@ discard block |
||
| 81 | 87 | cleanRequest(); |
| 82 | 88 | |
| 83 | 89 | // Seed the random generator? |
| 84 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 90 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 85 | 91 | smf_seed_generator(); |
| 92 | +} |
|
| 86 | 93 | |
| 87 | 94 | // Check on any hacking attempts. |
| 88 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
| 95 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
| 89 | 96 | die('No direct access...'); |
| 90 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
| 97 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
| 91 | 98 | die('No direct access...'); |
| 92 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
| 99 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
| 93 | 100 | die('No direct access...'); |
| 94 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
| 101 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
| 95 | 102 | die('No direct access...'); |
| 96 | -if (isset($_REQUEST['context'])) |
|
| 103 | +} |
|
| 104 | +if (isset($_REQUEST['context'])) { |
|
| 97 | 105 | die('No direct access...'); |
| 106 | +} |
|
| 98 | 107 | |
| 99 | 108 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
| 100 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
| 109 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
| 101 | 110 | ob_start('ob_gzhandler'); |
| 102 | -else |
|
| 111 | +} else { |
|
| 103 | 112 | $modSettings['enableCompressedOutput'] = '0'; |
| 113 | +} |
|
| 104 | 114 | |
| 105 | 115 | // Primarily, this is to fix the URLs... |
| 106 | 116 | ob_start('ob_sessrewrite'); |
| 107 | 117 | |
| 108 | 118 | // Start the session... known to scramble SSI includes in cases... |
| 109 | -if (!headers_sent()) |
|
| 119 | +if (!headers_sent()) { |
|
| 110 | 120 | loadSession(); |
| 111 | -else |
|
| 121 | +} else |
|
| 112 | 122 | { |
| 113 | 123 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
| 114 | 124 | { |
@@ -142,12 +152,14 @@ discard block |
||
| 142 | 152 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
| 143 | 153 | |
| 144 | 154 | // @todo: probably not the best place, but somewhere it should be set... |
| 145 | -if (!headers_sent()) |
|
| 155 | +if (!headers_sent()) { |
|
| 146 | 156 | header('Content-Type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
| 157 | +} |
|
| 147 | 158 | |
| 148 | 159 | // Take care of any banning that needs to be done. |
| 149 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
| 160 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
| 150 | 161 | is_not_banned(); |
| 162 | +} |
|
| 151 | 163 | |
| 152 | 164 | // Do we allow guests in here? |
| 153 | 165 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -162,17 +174,19 @@ discard block |
||
| 162 | 174 | { |
| 163 | 175 | $context['template_layers'] = $ssi_layers; |
| 164 | 176 | template_header(); |
| 165 | -} |
|
| 166 | -else |
|
| 177 | +} else { |
|
| 167 | 178 | setupThemeContext(); |
| 179 | +} |
|
| 168 | 180 | |
| 169 | 181 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
| 170 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
| 182 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
| 171 | 183 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
| 184 | +} |
|
| 172 | 185 | |
| 173 | 186 | // Without visiting the forum this session variable might not be set on submit. |
| 174 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
| 187 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
| 175 | 188 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
| 189 | +} |
|
| 176 | 190 | |
| 177 | 191 | // Have the ability to easily add functions to SSI. |
| 178 | 192 | call_integration_hook('integrate_SSI'); |
@@ -183,15 +197,18 @@ discard block |
||
| 183 | 197 | call_user_func('ssi_' . $_GET['ssi_function']); |
| 184 | 198 | exit; |
| 185 | 199 | } |
| 186 | -if (isset($_GET['ssi_function'])) |
|
| 200 | +if (isset($_GET['ssi_function'])) { |
|
| 187 | 201 | exit; |
| 202 | +} |
|
| 188 | 203 | // You shouldn't just access SSI.php directly by URL!! |
| 189 | -elseif (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
|
| 204 | +elseif (basename($_SERVER['PHP_SELF']) == 'SSI.php') { |
|
| 190 | 205 | die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
| 206 | +} |
|
| 191 | 207 | |
| 192 | 208 | error_reporting($ssi_error_reporting); |
| 193 | -if (function_exists('set_magic_quotes_runtime')) |
|
| 209 | +if (function_exists('set_magic_quotes_runtime')) { |
|
| 194 | 210 | @set_magic_quotes_runtime($ssi_magic_quotes_runtime); |
| 211 | +} |
|
| 195 | 212 | |
| 196 | 213 | return true; |
| 197 | 214 | |
@@ -201,9 +218,10 @@ discard block |
||
| 201 | 218 | */ |
| 202 | 219 | function ssi_shutdown() |
| 203 | 220 | { |
| 204 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
| 205 | - template_footer(); |
|
| 206 | -} |
|
| 221 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
| 222 | + template_footer(); |
|
| 223 | + } |
|
| 224 | + } |
|
| 207 | 225 | |
| 208 | 226 | /** |
| 209 | 227 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -216,15 +234,17 @@ discard block |
||
| 216 | 234 | |
| 217 | 235 | if ($output_method == 'echo') |
| 218 | 236 | { |
| 219 | - if ($context['user']['is_guest']) |
|
| 220 | - echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
| 221 | - else |
|
| 222 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
| 237 | + if ($context['user']['is_guest']) { |
|
| 238 | + echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
| 239 | + } else { |
|
| 240 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
| 241 | + } |
|
| 223 | 242 | } |
| 224 | 243 | // Don't echo... then do what?! |
| 225 | - else |
|
| 226 | - return $context['user']; |
|
| 227 | -} |
|
| 244 | + else { |
|
| 245 | + return $context['user']; |
|
| 246 | + } |
|
| 247 | + } |
|
| 228 | 248 | |
| 229 | 249 | /** |
| 230 | 250 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -235,12 +255,14 @@ discard block |
||
| 235 | 255 | { |
| 236 | 256 | global $context; |
| 237 | 257 | |
| 238 | - if ($output_method == 'echo') |
|
| 239 | - template_menu(); |
|
| 258 | + if ($output_method == 'echo') { |
|
| 259 | + template_menu(); |
|
| 260 | + } |
|
| 240 | 261 | // What else could this do? |
| 241 | - else |
|
| 242 | - return $context['menu_buttons']; |
|
| 243 | -} |
|
| 262 | + else { |
|
| 263 | + return $context['menu_buttons']; |
|
| 264 | + } |
|
| 265 | + } |
|
| 244 | 266 | |
| 245 | 267 | /** |
| 246 | 268 | * Show a logout link. |
@@ -252,20 +274,23 @@ discard block |
||
| 252 | 274 | { |
| 253 | 275 | global $context, $txt, $scripturl; |
| 254 | 276 | |
| 255 | - if ($redirect_to != '') |
|
| 256 | - $_SESSION['logout_url'] = $redirect_to; |
|
| 277 | + if ($redirect_to != '') { |
|
| 278 | + $_SESSION['logout_url'] = $redirect_to; |
|
| 279 | + } |
|
| 257 | 280 | |
| 258 | 281 | // Guests can't log out. |
| 259 | - if ($context['user']['is_guest']) |
|
| 260 | - return false; |
|
| 282 | + if ($context['user']['is_guest']) { |
|
| 283 | + return false; |
|
| 284 | + } |
|
| 261 | 285 | |
| 262 | 286 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
| 263 | 287 | |
| 264 | - if ($output_method == 'echo') |
|
| 265 | - echo $link; |
|
| 266 | - else |
|
| 267 | - return $link; |
|
| 268 | -} |
|
| 288 | + if ($output_method == 'echo') { |
|
| 289 | + echo $link; |
|
| 290 | + } else { |
|
| 291 | + return $link; |
|
| 292 | + } |
|
| 293 | + } |
|
| 269 | 294 | |
| 270 | 295 | /** |
| 271 | 296 | * Recent post list: [board] Subject by Poster Date |
@@ -281,17 +306,17 @@ discard block |
||
| 281 | 306 | global $modSettings, $context; |
| 282 | 307 | |
| 283 | 308 | // Excluding certain boards... |
| 284 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
| 285 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 286 | - else |
|
| 287 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 309 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
| 310 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 311 | + } else { |
|
| 312 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 313 | + } |
|
| 288 | 314 | |
| 289 | 315 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
| 290 | 316 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
| 291 | 317 | { |
| 292 | 318 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
| 293 | - } |
|
| 294 | - elseif ($include_boards != null) |
|
| 319 | + } elseif ($include_boards != null) |
|
| 295 | 320 | { |
| 296 | 321 | $include_boards = array(); |
| 297 | 322 | } |
@@ -328,8 +353,9 @@ discard block |
||
| 328 | 353 | { |
| 329 | 354 | global $modSettings; |
| 330 | 355 | |
| 331 | - if (empty($post_ids)) |
|
| 332 | - return; |
|
| 356 | + if (empty($post_ids)) { |
|
| 357 | + return; |
|
| 358 | + } |
|
| 333 | 359 | |
| 334 | 360 | // Allow the user to request more than one - why not? |
| 335 | 361 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -364,8 +390,9 @@ discard block |
||
| 364 | 390 | global $scripturl, $txt, $user_info; |
| 365 | 391 | global $modSettings, $smcFunc, $context; |
| 366 | 392 | |
| 367 | - if (!empty($modSettings['enable_likes'])) |
|
| 368 | - $context['can_like'] = allowedTo('likes_like'); |
|
| 393 | + if (!empty($modSettings['enable_likes'])) { |
|
| 394 | + $context['can_like'] = allowedTo('likes_like'); |
|
| 395 | + } |
|
| 369 | 396 | |
| 370 | 397 | // Find all the posts. Newer ones will have higher IDs. |
| 371 | 398 | $request = $smcFunc['db_query']('substring', ' |
@@ -431,12 +458,13 @@ discard block |
||
| 431 | 458 | ); |
| 432 | 459 | |
| 433 | 460 | // Get the likes for each message. |
| 434 | - if (!empty($modSettings['enable_likes'])) |
|
| 435 | - $posts[$row['id_msg']]['likes'] = array( |
|
| 461 | + if (!empty($modSettings['enable_likes'])) { |
|
| 462 | + $posts[$row['id_msg']]['likes'] = array( |
|
| 436 | 463 | 'count' => $row['likes'], |
| 437 | 464 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
| 438 | 465 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
| 439 | 466 | ); |
| 467 | + } |
|
| 440 | 468 | } |
| 441 | 469 | $smcFunc['db_free_result']($request); |
| 442 | 470 | |
@@ -444,13 +472,14 @@ discard block |
||
| 444 | 472 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
| 445 | 473 | |
| 446 | 474 | // Just return it. |
| 447 | - if ($output_method != 'echo' || empty($posts)) |
|
| 448 | - return $posts; |
|
| 475 | + if ($output_method != 'echo' || empty($posts)) { |
|
| 476 | + return $posts; |
|
| 477 | + } |
|
| 449 | 478 | |
| 450 | 479 | echo ' |
| 451 | 480 | <table style="border: none" class="ssi_table">'; |
| 452 | - foreach ($posts as $post) |
|
| 453 | - echo ' |
|
| 481 | + foreach ($posts as $post) { |
|
| 482 | + echo ' |
|
| 454 | 483 | <tr> |
| 455 | 484 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 456 | 485 | [', $post['board']['link'], '] |
@@ -464,6 +493,7 @@ discard block |
||
| 464 | 493 | ', $post['time'], ' |
| 465 | 494 | </td> |
| 466 | 495 | </tr>'; |
| 496 | + } |
|
| 467 | 497 | echo ' |
| 468 | 498 | </table>'; |
| 469 | 499 | } |
@@ -481,25 +511,26 @@ discard block |
||
| 481 | 511 | global $settings, $scripturl, $txt, $user_info; |
| 482 | 512 | global $modSettings, $smcFunc, $context; |
| 483 | 513 | |
| 484 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
| 485 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 486 | - else |
|
| 487 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 514 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
| 515 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 516 | + } else { |
|
| 517 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 518 | + } |
|
| 488 | 519 | |
| 489 | 520 | // Only some boards?. |
| 490 | 521 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
| 491 | 522 | { |
| 492 | 523 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
| 493 | - } |
|
| 494 | - elseif ($include_boards != null) |
|
| 524 | + } elseif ($include_boards != null) |
|
| 495 | 525 | { |
| 496 | 526 | $output_method = $include_boards; |
| 497 | 527 | $include_boards = array(); |
| 498 | 528 | } |
| 499 | 529 | |
| 500 | 530 | $icon_sources = array(); |
| 501 | - foreach ($context['stable_icons'] as $icon) |
|
| 502 | - $icon_sources[$icon] = 'images_url'; |
|
| 531 | + foreach ($context['stable_icons'] as $icon) { |
|
| 532 | + $icon_sources[$icon] = 'images_url'; |
|
| 533 | + } |
|
| 503 | 534 | |
| 504 | 535 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
| 505 | 536 | $request = $smcFunc['db_query']('substring', ' |
@@ -524,13 +555,15 @@ discard block |
||
| 524 | 555 | ) |
| 525 | 556 | ); |
| 526 | 557 | $topics = array(); |
| 527 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 528 | - $topics[$row['id_topic']] = $row; |
|
| 558 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 559 | + $topics[$row['id_topic']] = $row; |
|
| 560 | + } |
|
| 529 | 561 | $smcFunc['db_free_result']($request); |
| 530 | 562 | |
| 531 | 563 | // Did we find anything? If not, bail. |
| 532 | - if (empty($topics)) |
|
| 533 | - return array(); |
|
| 564 | + if (empty($topics)) { |
|
| 565 | + return array(); |
|
| 566 | + } |
|
| 534 | 567 | |
| 535 | 568 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
| 536 | 569 | |
@@ -558,19 +591,22 @@ discard block |
||
| 558 | 591 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 559 | 592 | { |
| 560 | 593 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
| 561 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 562 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 594 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 595 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 596 | + } |
|
| 563 | 597 | |
| 564 | 598 | // Censor the subject. |
| 565 | 599 | censorText($row['subject']); |
| 566 | 600 | censorText($row['body']); |
| 567 | 601 | |
| 568 | 602 | // Recycled icon |
| 569 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
| 570 | - $row['icon'] = 'recycled'; |
|
| 603 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
| 604 | + $row['icon'] = 'recycled'; |
|
| 605 | + } |
|
| 571 | 606 | |
| 572 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
| 573 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 607 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
| 608 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 609 | + } |
|
| 574 | 610 | |
| 575 | 611 | // Build the array. |
| 576 | 612 | $posts[] = array( |
@@ -609,13 +645,14 @@ discard block |
||
| 609 | 645 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
| 610 | 646 | |
| 611 | 647 | // Just return it. |
| 612 | - if ($output_method != 'echo' || empty($posts)) |
|
| 613 | - return $posts; |
|
| 648 | + if ($output_method != 'echo' || empty($posts)) { |
|
| 649 | + return $posts; |
|
| 650 | + } |
|
| 614 | 651 | |
| 615 | 652 | echo ' |
| 616 | 653 | <table style="border: none" class="ssi_table">'; |
| 617 | - foreach ($posts as $post) |
|
| 618 | - echo ' |
|
| 654 | + foreach ($posts as $post) { |
|
| 655 | + echo ' |
|
| 619 | 656 | <tr> |
| 620 | 657 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 621 | 658 | [', $post['board']['link'], '] |
@@ -629,6 +666,7 @@ discard block |
||
| 629 | 666 | ', $post['time'], ' |
| 630 | 667 | </td> |
| 631 | 668 | </tr>'; |
| 669 | + } |
|
| 632 | 670 | echo ' |
| 633 | 671 | </table>'; |
| 634 | 672 | } |
@@ -653,27 +691,30 @@ discard block |
||
| 653 | 691 | ) |
| 654 | 692 | ); |
| 655 | 693 | $return = array(); |
| 656 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 657 | - $return[] = array( |
|
| 694 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 695 | + $return[] = array( |
|
| 658 | 696 | 'id' => $row['id_member'], |
| 659 | 697 | 'name' => $row['real_name'], |
| 660 | 698 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
| 661 | 699 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
| 662 | 700 | 'posts' => $row['posts'] |
| 663 | 701 | ); |
| 702 | + } |
|
| 664 | 703 | $smcFunc['db_free_result']($request); |
| 665 | 704 | |
| 666 | 705 | // If mods want to do somthing with this list of members, let them do that now. |
| 667 | 706 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
| 668 | 707 | |
| 669 | 708 | // Just return all the top posters. |
| 670 | - if ($output_method != 'echo') |
|
| 671 | - return $return; |
|
| 709 | + if ($output_method != 'echo') { |
|
| 710 | + return $return; |
|
| 711 | + } |
|
| 672 | 712 | |
| 673 | 713 | // Make a quick array to list the links in. |
| 674 | 714 | $temp_array = array(); |
| 675 | - foreach ($return as $member) |
|
| 676 | - $temp_array[] = $member['link']; |
|
| 715 | + foreach ($return as $member) { |
|
| 716 | + $temp_array[] = $member['link']; |
|
| 717 | + } |
|
| 677 | 718 | |
| 678 | 719 | echo implode(', ', $temp_array); |
| 679 | 720 | } |
@@ -705,8 +746,8 @@ discard block |
||
| 705 | 746 | ) |
| 706 | 747 | ); |
| 707 | 748 | $boards = array(); |
| 708 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 709 | - $boards[] = array( |
|
| 749 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 750 | + $boards[] = array( |
|
| 710 | 751 | 'id' => $row['id_board'], |
| 711 | 752 | 'num_posts' => $row['num_posts'], |
| 712 | 753 | 'num_topics' => $row['num_topics'], |
@@ -715,14 +756,16 @@ discard block |
||
| 715 | 756 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
| 716 | 757 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
| 717 | 758 | ); |
| 759 | + } |
|
| 718 | 760 | $smcFunc['db_free_result']($request); |
| 719 | 761 | |
| 720 | 762 | // If mods want to do somthing with this list of boards, let them do that now. |
| 721 | 763 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
| 722 | 764 | |
| 723 | 765 | // If we shouldn't output or have nothing to output, just jump out. |
| 724 | - if ($output_method != 'echo' || empty($boards)) |
|
| 725 | - return $boards; |
|
| 766 | + if ($output_method != 'echo' || empty($boards)) { |
|
| 767 | + return $boards; |
|
| 768 | + } |
|
| 726 | 769 | |
| 727 | 770 | echo ' |
| 728 | 771 | <table class="ssi_table"> |
@@ -731,13 +774,14 @@ discard block |
||
| 731 | 774 | <th style="text-align: left">', $txt['board_topics'], '</th> |
| 732 | 775 | <th style="text-align: left">', $txt['posts'], '</th> |
| 733 | 776 | </tr>'; |
| 734 | - foreach ($boards as $sBoard) |
|
| 735 | - echo ' |
|
| 777 | + foreach ($boards as $sBoard) { |
|
| 778 | + echo ' |
|
| 736 | 779 | <tr> |
| 737 | 780 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td> |
| 738 | 781 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
| 739 | 782 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
| 740 | 783 | </tr>'; |
| 784 | + } |
|
| 741 | 785 | echo ' |
| 742 | 786 | </table>'; |
| 743 | 787 | } |
@@ -770,12 +814,13 @@ discard block |
||
| 770 | 814 | ) |
| 771 | 815 | ); |
| 772 | 816 | $topic_ids = array(); |
| 773 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 774 | - $topic_ids[] = $row['id_topic']; |
|
| 817 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 818 | + $topic_ids[] = $row['id_topic']; |
|
| 819 | + } |
|
| 775 | 820 | $smcFunc['db_free_result']($request); |
| 821 | + } else { |
|
| 822 | + $topic_ids = array(); |
|
| 776 | 823 | } |
| 777 | - else |
|
| 778 | - $topic_ids = array(); |
|
| 779 | 824 | |
| 780 | 825 | $request = $smcFunc['db_query']('', ' |
| 781 | 826 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -814,8 +859,9 @@ discard block |
||
| 814 | 859 | // If mods want to do somthing with this list of topics, let them do that now. |
| 815 | 860 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
| 816 | 861 | |
| 817 | - if ($output_method != 'echo' || empty($topics)) |
|
| 818 | - return $topics; |
|
| 862 | + if ($output_method != 'echo' || empty($topics)) { |
|
| 863 | + return $topics; |
|
| 864 | + } |
|
| 819 | 865 | |
| 820 | 866 | echo ' |
| 821 | 867 | <table class="ssi_table"> |
@@ -824,8 +870,8 @@ discard block |
||
| 824 | 870 | <th style="text-align: left">', $txt['views'], '</th> |
| 825 | 871 | <th style="text-align: left">', $txt['replies'], '</th> |
| 826 | 872 | </tr>'; |
| 827 | - foreach ($topics as $sTopic) |
|
| 828 | - echo ' |
|
| 873 | + foreach ($topics as $sTopic) { |
|
| 874 | + echo ' |
|
| 829 | 875 | <tr> |
| 830 | 876 | <td style="text-align: left"> |
| 831 | 877 | ', $sTopic['link'], ' |
@@ -833,6 +879,7 @@ discard block |
||
| 833 | 879 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
| 834 | 880 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
| 835 | 881 | </tr>'; |
| 882 | + } |
|
| 836 | 883 | echo ' |
| 837 | 884 | </table>'; |
| 838 | 885 | } |
@@ -868,12 +915,13 @@ discard block |
||
| 868 | 915 | { |
| 869 | 916 | global $txt, $context; |
| 870 | 917 | |
| 871 | - if ($output_method == 'echo') |
|
| 872 | - echo ' |
|
| 918 | + if ($output_method == 'echo') { |
|
| 919 | + echo ' |
|
| 873 | 920 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
| 874 | - else |
|
| 875 | - return $context['common_stats']['latest_member']; |
|
| 876 | -} |
|
| 921 | + } else { |
|
| 922 | + return $context['common_stats']['latest_member']; |
|
| 923 | + } |
|
| 924 | + } |
|
| 877 | 925 | |
| 878 | 926 | /** |
| 879 | 927 | * Fetches a random member. |
@@ -922,8 +970,9 @@ discard block |
||
| 922 | 970 | } |
| 923 | 971 | |
| 924 | 972 | // Just to be sure put the random generator back to something... random. |
| 925 | - if ($random_type != '') |
|
| 926 | - mt_srand(time()); |
|
| 973 | + if ($random_type != '') { |
|
| 974 | + mt_srand(time()); |
|
| 975 | + } |
|
| 927 | 976 | |
| 928 | 977 | return $result; |
| 929 | 978 | } |
@@ -936,8 +985,9 @@ discard block |
||
| 936 | 985 | */ |
| 937 | 986 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
| 938 | 987 | { |
| 939 | - if (empty($member_ids)) |
|
| 940 | - return; |
|
| 988 | + if (empty($member_ids)) { |
|
| 989 | + return; |
|
| 990 | + } |
|
| 941 | 991 | |
| 942 | 992 | // Can have more than one member if you really want... |
| 943 | 993 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -962,8 +1012,9 @@ discard block |
||
| 962 | 1012 | */ |
| 963 | 1013 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
| 964 | 1014 | { |
| 965 | - if ($group_id === null) |
|
| 966 | - return; |
|
| 1015 | + if ($group_id === null) { |
|
| 1016 | + return; |
|
| 1017 | + } |
|
| 967 | 1018 | |
| 968 | 1019 | $query_where = ' |
| 969 | 1020 | id_group = {int:id_group} |
@@ -990,8 +1041,9 @@ discard block |
||
| 990 | 1041 | { |
| 991 | 1042 | global $smcFunc, $memberContext; |
| 992 | 1043 | |
| 993 | - if ($query_where === null) |
|
| 994 | - return; |
|
| 1044 | + if ($query_where === null) { |
|
| 1045 | + return; |
|
| 1046 | + } |
|
| 995 | 1047 | |
| 996 | 1048 | // Fetch the members in question. |
| 997 | 1049 | $request = $smcFunc['db_query']('', ' |
@@ -1004,12 +1056,14 @@ discard block |
||
| 1004 | 1056 | )) |
| 1005 | 1057 | ); |
| 1006 | 1058 | $members = array(); |
| 1007 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1008 | - $members[] = $row['id_member']; |
|
| 1059 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1060 | + $members[] = $row['id_member']; |
|
| 1061 | + } |
|
| 1009 | 1062 | $smcFunc['db_free_result']($request); |
| 1010 | 1063 | |
| 1011 | - if (empty($members)) |
|
| 1012 | - return array(); |
|
| 1064 | + if (empty($members)) { |
|
| 1065 | + return array(); |
|
| 1066 | + } |
|
| 1013 | 1067 | |
| 1014 | 1068 | // If mods want to do somthing with this list of members, let them do that now. |
| 1015 | 1069 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1018,23 +1072,25 @@ discard block |
||
| 1018 | 1072 | loadMemberData($members); |
| 1019 | 1073 | |
| 1020 | 1074 | // Draw the table! |
| 1021 | - if ($output_method == 'echo') |
|
| 1022 | - echo ' |
|
| 1075 | + if ($output_method == 'echo') { |
|
| 1076 | + echo ' |
|
| 1023 | 1077 | <table style="border: none" class="ssi_table">'; |
| 1078 | + } |
|
| 1024 | 1079 | |
| 1025 | 1080 | $query_members = array(); |
| 1026 | 1081 | foreach ($members as $member) |
| 1027 | 1082 | { |
| 1028 | 1083 | // Load their context data. |
| 1029 | - if (!loadMemberContext($member)) |
|
| 1030 | - continue; |
|
| 1084 | + if (!loadMemberContext($member)) { |
|
| 1085 | + continue; |
|
| 1086 | + } |
|
| 1031 | 1087 | |
| 1032 | 1088 | // Store this member's information. |
| 1033 | 1089 | $query_members[$member] = $memberContext[$member]; |
| 1034 | 1090 | |
| 1035 | 1091 | // Only do something if we're echo'ing. |
| 1036 | - if ($output_method == 'echo') |
|
| 1037 | - echo ' |
|
| 1092 | + if ($output_method == 'echo') { |
|
| 1093 | + echo ' |
|
| 1038 | 1094 | <tr> |
| 1039 | 1095 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 1040 | 1096 | ', $query_members[$member]['link'], ' |
@@ -1042,12 +1098,14 @@ discard block |
||
| 1042 | 1098 | <br>', $query_members[$member]['avatar']['image'], ' |
| 1043 | 1099 | </td> |
| 1044 | 1100 | </tr>'; |
| 1101 | + } |
|
| 1045 | 1102 | } |
| 1046 | 1103 | |
| 1047 | 1104 | // End the table if appropriate. |
| 1048 | - if ($output_method == 'echo') |
|
| 1049 | - echo ' |
|
| 1105 | + if ($output_method == 'echo') { |
|
| 1106 | + echo ' |
|
| 1050 | 1107 | </table>'; |
| 1108 | + } |
|
| 1051 | 1109 | |
| 1052 | 1110 | // Send back the data. |
| 1053 | 1111 | return $query_members; |
@@ -1062,8 +1120,9 @@ discard block |
||
| 1062 | 1120 | { |
| 1063 | 1121 | global $txt, $scripturl, $modSettings, $smcFunc; |
| 1064 | 1122 | |
| 1065 | - if (!allowedTo('view_stats')) |
|
| 1066 | - return; |
|
| 1123 | + if (!allowedTo('view_stats')) { |
|
| 1124 | + return; |
|
| 1125 | + } |
|
| 1067 | 1126 | |
| 1068 | 1127 | $totals = array( |
| 1069 | 1128 | 'members' => $modSettings['totalMembers'], |
@@ -1092,8 +1151,9 @@ discard block |
||
| 1092 | 1151 | // If mods want to do somthing with the board stats, let them do that now. |
| 1093 | 1152 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
| 1094 | 1153 | |
| 1095 | - if ($output_method != 'echo') |
|
| 1096 | - return $totals; |
|
| 1154 | + if ($output_method != 'echo') { |
|
| 1155 | + return $totals; |
|
| 1156 | + } |
|
| 1097 | 1157 | |
| 1098 | 1158 | echo ' |
| 1099 | 1159 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1122,8 +1182,8 @@ discard block |
||
| 1122 | 1182 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
| 1123 | 1183 | |
| 1124 | 1184 | // Add some redundancy for backwards compatibility reasons. |
| 1125 | - if ($output_method != 'echo') |
|
| 1126 | - return $return + array( |
|
| 1185 | + if ($output_method != 'echo') { |
|
| 1186 | + return $return + array( |
|
| 1127 | 1187 | 'users' => $return['users_online'], |
| 1128 | 1188 | 'guests' => $return['num_guests'], |
| 1129 | 1189 | 'hidden' => $return['num_users_hidden'], |
@@ -1131,29 +1191,35 @@ discard block |
||
| 1131 | 1191 | 'num_users' => $return['num_users_online'], |
| 1132 | 1192 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
| 1133 | 1193 | ); |
| 1194 | + } |
|
| 1134 | 1195 | |
| 1135 | 1196 | echo ' |
| 1136 | 1197 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
| 1137 | 1198 | |
| 1138 | 1199 | $bracketList = array(); |
| 1139 | - if (!empty($user_info['buddies'])) |
|
| 1140 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 1141 | - if (!empty($return['num_spiders'])) |
|
| 1142 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 1143 | - if (!empty($return['num_users_hidden'])) |
|
| 1144 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
| 1200 | + if (!empty($user_info['buddies'])) { |
|
| 1201 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 1202 | + } |
|
| 1203 | + if (!empty($return['num_spiders'])) { |
|
| 1204 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 1205 | + } |
|
| 1206 | + if (!empty($return['num_users_hidden'])) { |
|
| 1207 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
| 1208 | + } |
|
| 1145 | 1209 | |
| 1146 | - if (!empty($bracketList)) |
|
| 1147 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 1210 | + if (!empty($bracketList)) { |
|
| 1211 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 1212 | + } |
|
| 1148 | 1213 | |
| 1149 | 1214 | echo '<br> |
| 1150 | 1215 | ', implode(', ', $return['list_users_online']); |
| 1151 | 1216 | |
| 1152 | 1217 | // Showing membergroups? |
| 1153 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
| 1154 | - echo '<br> |
|
| 1218 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
| 1219 | + echo '<br> |
|
| 1155 | 1220 | [' . implode('] [', $return['membergroups']) . ']'; |
| 1156 | -} |
|
| 1221 | + } |
|
| 1222 | + } |
|
| 1157 | 1223 | |
| 1158 | 1224 | /** |
| 1159 | 1225 | * Just like whosOnline except it also logs the online presence. |
@@ -1164,11 +1230,12 @@ discard block |
||
| 1164 | 1230 | { |
| 1165 | 1231 | writeLog(); |
| 1166 | 1232 | |
| 1167 | - if ($output_method != 'echo') |
|
| 1168 | - return ssi_whosOnline($output_method); |
|
| 1169 | - else |
|
| 1170 | - ssi_whosOnline($output_method); |
|
| 1171 | -} |
|
| 1233 | + if ($output_method != 'echo') { |
|
| 1234 | + return ssi_whosOnline($output_method); |
|
| 1235 | + } else { |
|
| 1236 | + ssi_whosOnline($output_method); |
|
| 1237 | + } |
|
| 1238 | + } |
|
| 1172 | 1239 | |
| 1173 | 1240 | // Shows a login box. |
| 1174 | 1241 | /** |
@@ -1181,11 +1248,13 @@ discard block |
||
| 1181 | 1248 | { |
| 1182 | 1249 | global $scripturl, $txt, $user_info, $context; |
| 1183 | 1250 | |
| 1184 | - if ($redirect_to != '') |
|
| 1185 | - $_SESSION['login_url'] = $redirect_to; |
|
| 1251 | + if ($redirect_to != '') { |
|
| 1252 | + $_SESSION['login_url'] = $redirect_to; |
|
| 1253 | + } |
|
| 1186 | 1254 | |
| 1187 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
| 1188 | - return $user_info['is_guest']; |
|
| 1255 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
| 1256 | + return $user_info['is_guest']; |
|
| 1257 | + } |
|
| 1189 | 1258 | |
| 1190 | 1259 | // Create a login token |
| 1191 | 1260 | createToken('login'); |
@@ -1237,8 +1306,9 @@ discard block |
||
| 1237 | 1306 | |
| 1238 | 1307 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
| 1239 | 1308 | |
| 1240 | - if (empty($boardsAllowed)) |
|
| 1241 | - return array(); |
|
| 1309 | + if (empty($boardsAllowed)) { |
|
| 1310 | + return array(); |
|
| 1311 | + } |
|
| 1242 | 1312 | |
| 1243 | 1313 | $request = $smcFunc['db_query']('', ' |
| 1244 | 1314 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1271,12 +1341,14 @@ discard block |
||
| 1271 | 1341 | $smcFunc['db_free_result']($request); |
| 1272 | 1342 | |
| 1273 | 1343 | // This user has voted on all the polls. |
| 1274 | - if (empty($row) || !is_array($row)) |
|
| 1275 | - return array(); |
|
| 1344 | + if (empty($row) || !is_array($row)) { |
|
| 1345 | + return array(); |
|
| 1346 | + } |
|
| 1276 | 1347 | |
| 1277 | 1348 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
| 1278 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
| 1279 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
| 1349 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
| 1350 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
| 1351 | + } |
|
| 1280 | 1352 | |
| 1281 | 1353 | $request = $smcFunc['db_query']('', ' |
| 1282 | 1354 | SELECT COUNT(DISTINCT id_member) |
@@ -1340,8 +1412,9 @@ discard block |
||
| 1340 | 1412 | // If mods want to do somthing with this list of polls, let them do that now. |
| 1341 | 1413 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
| 1342 | 1414 | |
| 1343 | - if ($output_method != 'echo') |
|
| 1344 | - return $return; |
|
| 1415 | + if ($output_method != 'echo') { |
|
| 1416 | + return $return; |
|
| 1417 | + } |
|
| 1345 | 1418 | |
| 1346 | 1419 | if ($allow_view_results) |
| 1347 | 1420 | { |
@@ -1350,19 +1423,20 @@ discard block |
||
| 1350 | 1423 | <strong>', $return['question'], '</strong><br> |
| 1351 | 1424 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
| 1352 | 1425 | |
| 1353 | - foreach ($return['options'] as $option) |
|
| 1354 | - echo ' |
|
| 1426 | + foreach ($return['options'] as $option) { |
|
| 1427 | + echo ' |
|
| 1355 | 1428 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
| 1429 | + } |
|
| 1356 | 1430 | |
| 1357 | 1431 | echo ' |
| 1358 | 1432 | <input type="submit" value="', $txt['poll_vote'], '" class="button_submit"> |
| 1359 | 1433 | <input type="hidden" name="poll" value="', $return['id'], '"> |
| 1360 | 1434 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1361 | 1435 | </form>'; |
| 1436 | + } else { |
|
| 1437 | + echo $txt['poll_cannot_see']; |
|
| 1438 | + } |
|
| 1362 | 1439 | } |
| 1363 | - else |
|
| 1364 | - echo $txt['poll_cannot_see']; |
|
| 1365 | -} |
|
| 1366 | 1440 | |
| 1367 | 1441 | /** |
| 1368 | 1442 | * Shows the poll from the specified topic |
@@ -1376,13 +1450,15 @@ discard block |
||
| 1376 | 1450 | |
| 1377 | 1451 | $boardsAllowed = boardsAllowedTo('poll_view'); |
| 1378 | 1452 | |
| 1379 | - if (empty($boardsAllowed)) |
|
| 1380 | - return array(); |
|
| 1453 | + if (empty($boardsAllowed)) { |
|
| 1454 | + return array(); |
|
| 1455 | + } |
|
| 1381 | 1456 | |
| 1382 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
| 1383 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
| 1384 | - else |
|
| 1385 | - $topic = (int) $topic; |
|
| 1457 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
| 1458 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
| 1459 | + } else { |
|
| 1460 | + $topic = (int) $topic; |
|
| 1461 | + } |
|
| 1386 | 1462 | |
| 1387 | 1463 | $request = $smcFunc['db_query']('', ' |
| 1388 | 1464 | SELECT |
@@ -1403,17 +1479,18 @@ discard block |
||
| 1403 | 1479 | ); |
| 1404 | 1480 | |
| 1405 | 1481 | // Either this topic has no poll, or the user cannot view it. |
| 1406 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1407 | - return array(); |
|
| 1482 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1483 | + return array(); |
|
| 1484 | + } |
|
| 1408 | 1485 | |
| 1409 | 1486 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1410 | 1487 | $smcFunc['db_free_result']($request); |
| 1411 | 1488 | |
| 1412 | 1489 | // Check if they can vote. |
| 1413 | 1490 | $already_voted = false; |
| 1414 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
| 1415 | - $allow_vote = false; |
|
| 1416 | - elseif ($user_info['is_guest']) |
|
| 1491 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
| 1492 | + $allow_vote = false; |
|
| 1493 | + } elseif ($user_info['is_guest']) |
|
| 1417 | 1494 | { |
| 1418 | 1495 | // There's a difference between "allowed to vote" and "already voted"... |
| 1419 | 1496 | $allow_vote = $row['guest_vote']; |
@@ -1423,10 +1500,9 @@ discard block |
||
| 1423 | 1500 | { |
| 1424 | 1501 | $already_voted = true; |
| 1425 | 1502 | } |
| 1426 | - } |
|
| 1427 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
| 1428 | - $allow_vote = false; |
|
| 1429 | - else |
|
| 1503 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
| 1504 | + $allow_vote = false; |
|
| 1505 | + } else |
|
| 1430 | 1506 | { |
| 1431 | 1507 | $request = $smcFunc['db_query']('', ' |
| 1432 | 1508 | SELECT id_member |
@@ -1508,8 +1584,9 @@ discard block |
||
| 1508 | 1584 | // If mods want to do somthing with this poll, let them do that now. |
| 1509 | 1585 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
| 1510 | 1586 | |
| 1511 | - if ($output_method != 'echo') |
|
| 1512 | - return $return; |
|
| 1587 | + if ($output_method != 'echo') { |
|
| 1588 | + return $return; |
|
| 1589 | + } |
|
| 1513 | 1590 | |
| 1514 | 1591 | if ($return['allow_vote']) |
| 1515 | 1592 | { |
@@ -1518,17 +1595,17 @@ discard block |
||
| 1518 | 1595 | <strong>', $return['question'], '</strong><br> |
| 1519 | 1596 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
| 1520 | 1597 | |
| 1521 | - foreach ($return['options'] as $option) |
|
| 1522 | - echo ' |
|
| 1598 | + foreach ($return['options'] as $option) { |
|
| 1599 | + echo ' |
|
| 1523 | 1600 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
| 1601 | + } |
|
| 1524 | 1602 | |
| 1525 | 1603 | echo ' |
| 1526 | 1604 | <input type="submit" value="', $txt['poll_vote'], '" class="button_submit"> |
| 1527 | 1605 | <input type="hidden" name="poll" value="', $return['id'], '"> |
| 1528 | 1606 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1529 | 1607 | </form>'; |
| 1530 | - } |
|
| 1531 | - else |
|
| 1608 | + } else |
|
| 1532 | 1609 | { |
| 1533 | 1610 | echo ' |
| 1534 | 1611 | <div class="ssi_poll"> |
@@ -1608,27 +1685,32 @@ discard block |
||
| 1608 | 1685 | 'is_approved' => 1, |
| 1609 | 1686 | ) |
| 1610 | 1687 | ); |
| 1611 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1612 | - die; |
|
| 1688 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1689 | + die; |
|
| 1690 | + } |
|
| 1613 | 1691 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1614 | 1692 | $smcFunc['db_free_result']($request); |
| 1615 | 1693 | |
| 1616 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
| 1617 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1694 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
| 1695 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1696 | + } |
|
| 1618 | 1697 | |
| 1619 | 1698 | // Too many options checked? |
| 1620 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
| 1621 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1699 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
| 1700 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1701 | + } |
|
| 1622 | 1702 | |
| 1623 | 1703 | // It's a guest who has already voted? |
| 1624 | 1704 | if ($user_info['is_guest']) |
| 1625 | 1705 | { |
| 1626 | 1706 | // Guest voting disabled? |
| 1627 | - if (!$row['guest_vote']) |
|
| 1628 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1707 | + if (!$row['guest_vote']) { |
|
| 1708 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1709 | + } |
|
| 1629 | 1710 | // Already voted? |
| 1630 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
| 1631 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1711 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
| 1712 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1713 | + } |
|
| 1632 | 1714 | } |
| 1633 | 1715 | |
| 1634 | 1716 | $sOptions = array(); |
@@ -1682,11 +1764,13 @@ discard block |
||
| 1682 | 1764 | { |
| 1683 | 1765 | global $scripturl, $txt, $context; |
| 1684 | 1766 | |
| 1685 | - if (!allowedTo('search_posts')) |
|
| 1686 | - return; |
|
| 1767 | + if (!allowedTo('search_posts')) { |
|
| 1768 | + return; |
|
| 1769 | + } |
|
| 1687 | 1770 | |
| 1688 | - if ($output_method != 'echo') |
|
| 1689 | - return $scripturl . '?action=search'; |
|
| 1771 | + if ($output_method != 'echo') { |
|
| 1772 | + return $scripturl . '?action=search'; |
|
| 1773 | + } |
|
| 1690 | 1774 | |
| 1691 | 1775 | echo ' |
| 1692 | 1776 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1708,8 +1792,9 @@ discard block |
||
| 1708 | 1792 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
| 1709 | 1793 | call_integration_hook('integrate_ssi_news'); |
| 1710 | 1794 | |
| 1711 | - if ($output_method != 'echo') |
|
| 1712 | - return $context['random_news_line']; |
|
| 1795 | + if ($output_method != 'echo') { |
|
| 1796 | + return $context['random_news_line']; |
|
| 1797 | + } |
|
| 1713 | 1798 | |
| 1714 | 1799 | echo $context['random_news_line']; |
| 1715 | 1800 | } |
@@ -1723,8 +1808,9 @@ discard block |
||
| 1723 | 1808 | { |
| 1724 | 1809 | global $scripturl, $modSettings, $user_info; |
| 1725 | 1810 | |
| 1726 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
| 1727 | - return; |
|
| 1811 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
| 1812 | + return; |
|
| 1813 | + } |
|
| 1728 | 1814 | |
| 1729 | 1815 | $eventOptions = array( |
| 1730 | 1816 | 'include_birthdays' => true, |
@@ -1735,13 +1821,15 @@ discard block |
||
| 1735 | 1821 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1736 | 1822 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1737 | 1823 | |
| 1738 | - if ($output_method != 'echo') |
|
| 1739 | - return $return['calendar_birthdays']; |
|
| 1824 | + if ($output_method != 'echo') { |
|
| 1825 | + return $return['calendar_birthdays']; |
|
| 1826 | + } |
|
| 1740 | 1827 | |
| 1741 | - foreach ($return['calendar_birthdays'] as $member) |
|
| 1742 | - echo ' |
|
| 1828 | + foreach ($return['calendar_birthdays'] as $member) { |
|
| 1829 | + echo ' |
|
| 1743 | 1830 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : ''); |
| 1744 | -} |
|
| 1831 | + } |
|
| 1832 | + } |
|
| 1745 | 1833 | |
| 1746 | 1834 | /** |
| 1747 | 1835 | * Shows today's holidays. |
@@ -1752,8 +1840,9 @@ discard block |
||
| 1752 | 1840 | { |
| 1753 | 1841 | global $modSettings, $user_info; |
| 1754 | 1842 | |
| 1755 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1756 | - return; |
|
| 1843 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1844 | + return; |
|
| 1845 | + } |
|
| 1757 | 1846 | |
| 1758 | 1847 | $eventOptions = array( |
| 1759 | 1848 | 'include_holidays' => true, |
@@ -1764,8 +1853,9 @@ discard block |
||
| 1764 | 1853 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1765 | 1854 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1766 | 1855 | |
| 1767 | - if ($output_method != 'echo') |
|
| 1768 | - return $return['calendar_holidays']; |
|
| 1856 | + if ($output_method != 'echo') { |
|
| 1857 | + return $return['calendar_holidays']; |
|
| 1858 | + } |
|
| 1769 | 1859 | |
| 1770 | 1860 | echo ' |
| 1771 | 1861 | ', implode(', ', $return['calendar_holidays']); |
@@ -1779,8 +1869,9 @@ discard block |
||
| 1779 | 1869 | { |
| 1780 | 1870 | global $modSettings, $user_info; |
| 1781 | 1871 | |
| 1782 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1783 | - return; |
|
| 1872 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1873 | + return; |
|
| 1874 | + } |
|
| 1784 | 1875 | |
| 1785 | 1876 | $eventOptions = array( |
| 1786 | 1877 | 'include_events' => true, |
@@ -1791,14 +1882,16 @@ discard block |
||
| 1791 | 1882 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1792 | 1883 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1793 | 1884 | |
| 1794 | - if ($output_method != 'echo') |
|
| 1795 | - return $return['calendar_events']; |
|
| 1885 | + if ($output_method != 'echo') { |
|
| 1886 | + return $return['calendar_events']; |
|
| 1887 | + } |
|
| 1796 | 1888 | |
| 1797 | 1889 | foreach ($return['calendar_events'] as $event) |
| 1798 | 1890 | { |
| 1799 | - if ($event['can_edit']) |
|
| 1800 | - echo ' |
|
| 1891 | + if ($event['can_edit']) { |
|
| 1892 | + echo ' |
|
| 1801 | 1893 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 1894 | + } |
|
| 1802 | 1895 | echo ' |
| 1803 | 1896 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
| 1804 | 1897 | } |
@@ -1813,8 +1906,9 @@ discard block |
||
| 1813 | 1906 | { |
| 1814 | 1907 | global $modSettings, $txt, $scripturl, $user_info; |
| 1815 | 1908 | |
| 1816 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1817 | - return; |
|
| 1909 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1910 | + return; |
|
| 1911 | + } |
|
| 1818 | 1912 | |
| 1819 | 1913 | $eventOptions = array( |
| 1820 | 1914 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1827,19 +1921,22 @@ discard block |
||
| 1827 | 1921 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1828 | 1922 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1829 | 1923 | |
| 1830 | - if ($output_method != 'echo') |
|
| 1831 | - return $return; |
|
| 1924 | + if ($output_method != 'echo') { |
|
| 1925 | + return $return; |
|
| 1926 | + } |
|
| 1832 | 1927 | |
| 1833 | - if (!empty($return['calendar_holidays'])) |
|
| 1834 | - echo ' |
|
| 1928 | + if (!empty($return['calendar_holidays'])) { |
|
| 1929 | + echo ' |
|
| 1835 | 1930 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
| 1931 | + } |
|
| 1836 | 1932 | if (!empty($return['calendar_birthdays'])) |
| 1837 | 1933 | { |
| 1838 | 1934 | echo ' |
| 1839 | 1935 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
| 1840 | - foreach ($return['calendar_birthdays'] as $member) |
|
| 1841 | - echo ' |
|
| 1936 | + foreach ($return['calendar_birthdays'] as $member) { |
|
| 1937 | + echo ' |
|
| 1842 | 1938 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : ''; |
| 1939 | + } |
|
| 1843 | 1940 | echo ' |
| 1844 | 1941 | <br>'; |
| 1845 | 1942 | } |
@@ -1849,9 +1946,10 @@ discard block |
||
| 1849 | 1946 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
| 1850 | 1947 | foreach ($return['calendar_events'] as $event) |
| 1851 | 1948 | { |
| 1852 | - if ($event['can_edit']) |
|
| 1853 | - echo ' |
|
| 1949 | + if ($event['can_edit']) { |
|
| 1950 | + echo ' |
|
| 1854 | 1951 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 1952 | + } |
|
| 1855 | 1953 | echo ' |
| 1856 | 1954 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
| 1857 | 1955 | } |
@@ -1875,25 +1973,29 @@ discard block |
||
| 1875 | 1973 | loadLanguage('Stats'); |
| 1876 | 1974 | |
| 1877 | 1975 | // Must be integers.... |
| 1878 | - if ($limit === null) |
|
| 1879 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
| 1880 | - else |
|
| 1881 | - $limit = (int) $limit; |
|
| 1882 | - |
|
| 1883 | - if ($start === null) |
|
| 1884 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 1885 | - else |
|
| 1886 | - $start = (int) $start; |
|
| 1887 | - |
|
| 1888 | - if ($board !== null) |
|
| 1889 | - $board = (int) $board; |
|
| 1890 | - elseif (isset($_GET['board'])) |
|
| 1891 | - $board = (int) $_GET['board']; |
|
| 1892 | - |
|
| 1893 | - if ($length === null) |
|
| 1894 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
| 1895 | - else |
|
| 1896 | - $length = (int) $length; |
|
| 1976 | + if ($limit === null) { |
|
| 1977 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
| 1978 | + } else { |
|
| 1979 | + $limit = (int) $limit; |
|
| 1980 | + } |
|
| 1981 | + |
|
| 1982 | + if ($start === null) { |
|
| 1983 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 1984 | + } else { |
|
| 1985 | + $start = (int) $start; |
|
| 1986 | + } |
|
| 1987 | + |
|
| 1988 | + if ($board !== null) { |
|
| 1989 | + $board = (int) $board; |
|
| 1990 | + } elseif (isset($_GET['board'])) { |
|
| 1991 | + $board = (int) $_GET['board']; |
|
| 1992 | + } |
|
| 1993 | + |
|
| 1994 | + if ($length === null) { |
|
| 1995 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
| 1996 | + } else { |
|
| 1997 | + $length = (int) $length; |
|
| 1998 | + } |
|
| 1897 | 1999 | |
| 1898 | 2000 | $limit = max(0, $limit); |
| 1899 | 2001 | $start = max(0, $start); |
@@ -1911,17 +2013,19 @@ discard block |
||
| 1911 | 2013 | ); |
| 1912 | 2014 | if ($smcFunc['db_num_rows']($request) == 0) |
| 1913 | 2015 | { |
| 1914 | - if ($output_method == 'echo') |
|
| 1915 | - die($txt['ssi_no_guests']); |
|
| 1916 | - else |
|
| 1917 | - return array(); |
|
| 2016 | + if ($output_method == 'echo') { |
|
| 2017 | + die($txt['ssi_no_guests']); |
|
| 2018 | + } else { |
|
| 2019 | + return array(); |
|
| 2020 | + } |
|
| 1918 | 2021 | } |
| 1919 | 2022 | list ($board) = $smcFunc['db_fetch_row']($request); |
| 1920 | 2023 | $smcFunc['db_free_result']($request); |
| 1921 | 2024 | |
| 1922 | 2025 | $icon_sources = array(); |
| 1923 | - foreach ($context['stable_icons'] as $icon) |
|
| 1924 | - $icon_sources[$icon] = 'images_url'; |
|
| 2026 | + foreach ($context['stable_icons'] as $icon) { |
|
| 2027 | + $icon_sources[$icon] = 'images_url'; |
|
| 2028 | + } |
|
| 1925 | 2029 | |
| 1926 | 2030 | if (!empty($modSettings['enable_likes'])) |
| 1927 | 2031 | { |
@@ -1945,12 +2049,14 @@ discard block |
||
| 1945 | 2049 | ) |
| 1946 | 2050 | ); |
| 1947 | 2051 | $posts = array(); |
| 1948 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1949 | - $posts[] = $row['id_first_msg']; |
|
| 2052 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2053 | + $posts[] = $row['id_first_msg']; |
|
| 2054 | + } |
|
| 1950 | 2055 | $smcFunc['db_free_result']($request); |
| 1951 | 2056 | |
| 1952 | - if (empty($posts)) |
|
| 1953 | - return array(); |
|
| 2057 | + if (empty($posts)) { |
|
| 2058 | + return array(); |
|
| 2059 | + } |
|
| 1954 | 2060 | |
| 1955 | 2061 | // Find the posts. |
| 1956 | 2062 | $request = $smcFunc['db_query']('', ' |
@@ -1980,24 +2086,28 @@ discard block |
||
| 1980 | 2086 | $last_space = strrpos($row['body'], ' '); |
| 1981 | 2087 | $last_open = strrpos($row['body'], '<'); |
| 1982 | 2088 | $last_close = strrpos($row['body'], '>'); |
| 1983 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
| 1984 | - $cutoff = $last_open; |
|
| 1985 | - elseif (empty($last_close) || $last_close < $last_open) |
|
| 1986 | - $cutoff = $last_space; |
|
| 2089 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
| 2090 | + $cutoff = $last_open; |
|
| 2091 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
| 2092 | + $cutoff = $last_space; |
|
| 2093 | + } |
|
| 1987 | 2094 | |
| 1988 | - if ($cutoff !== false) |
|
| 1989 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
| 2095 | + if ($cutoff !== false) { |
|
| 2096 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
| 2097 | + } |
|
| 1990 | 2098 | $row['body'] .= '...'; |
| 1991 | 2099 | } |
| 1992 | 2100 | |
| 1993 | 2101 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
| 1994 | 2102 | |
| 1995 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
| 1996 | - $row['icon'] = 'recycled'; |
|
| 2103 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
| 2104 | + $row['icon'] = 'recycled'; |
|
| 2105 | + } |
|
| 1997 | 2106 | |
| 1998 | 2107 | // Check that this message icon is there... |
| 1999 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
| 2000 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2108 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
| 2109 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2110 | + } |
|
| 2001 | 2111 | |
| 2002 | 2112 | censorText($row['subject']); |
| 2003 | 2113 | censorText($row['body']); |
@@ -2034,16 +2144,18 @@ discard block |
||
| 2034 | 2144 | } |
| 2035 | 2145 | $smcFunc['db_free_result']($request); |
| 2036 | 2146 | |
| 2037 | - if (empty($return)) |
|
| 2038 | - return $return; |
|
| 2147 | + if (empty($return)) { |
|
| 2148 | + return $return; |
|
| 2149 | + } |
|
| 2039 | 2150 | |
| 2040 | 2151 | $return[count($return) - 1]['is_last'] = true; |
| 2041 | 2152 | |
| 2042 | 2153 | // If mods want to do somthing with this list of posts, let them do that now. |
| 2043 | 2154 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
| 2044 | 2155 | |
| 2045 | - if ($output_method != 'echo') |
|
| 2046 | - return $return; |
|
| 2156 | + if ($output_method != 'echo') { |
|
| 2157 | + return $return; |
|
| 2158 | + } |
|
| 2047 | 2159 | |
| 2048 | 2160 | foreach ($return as $news) |
| 2049 | 2161 | { |
@@ -2095,9 +2207,10 @@ discard block |
||
| 2095 | 2207 | echo ' |
| 2096 | 2208 | </div>'; |
| 2097 | 2209 | |
| 2098 | - if (!$news['is_last']) |
|
| 2099 | - echo ' |
|
| 2210 | + if (!$news['is_last']) { |
|
| 2211 | + echo ' |
|
| 2100 | 2212 | <hr>'; |
| 2213 | + } |
|
| 2101 | 2214 | } |
| 2102 | 2215 | } |
| 2103 | 2216 | |
@@ -2111,8 +2224,9 @@ discard block |
||
| 2111 | 2224 | { |
| 2112 | 2225 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
| 2113 | 2226 | |
| 2114 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 2115 | - return; |
|
| 2227 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 2228 | + return; |
|
| 2229 | + } |
|
| 2116 | 2230 | |
| 2117 | 2231 | // Find all events which are happening in the near future that the member can see. |
| 2118 | 2232 | $request = $smcFunc['db_query']('', ' |
@@ -2137,20 +2251,23 @@ discard block |
||
| 2137 | 2251 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2138 | 2252 | { |
| 2139 | 2253 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
| 2140 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
| 2141 | - continue; |
|
| 2254 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
| 2255 | + continue; |
|
| 2256 | + } |
|
| 2142 | 2257 | |
| 2143 | 2258 | // Censor the title. |
| 2144 | 2259 | censorText($row['title']); |
| 2145 | 2260 | |
| 2146 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
| 2147 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
| 2148 | - else |
|
| 2149 | - $date = $row['start_date']; |
|
| 2261 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
| 2262 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
| 2263 | + } else { |
|
| 2264 | + $date = $row['start_date']; |
|
| 2265 | + } |
|
| 2150 | 2266 | |
| 2151 | 2267 | // If the topic it is attached to is not approved then don't link it. |
| 2152 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
| 2153 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
| 2268 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
| 2269 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
| 2270 | + } |
|
| 2154 | 2271 | |
| 2155 | 2272 | $return[$date][] = array( |
| 2156 | 2273 | 'id' => $row['id_event'], |
@@ -2169,24 +2286,27 @@ discard block |
||
| 2169 | 2286 | } |
| 2170 | 2287 | $smcFunc['db_free_result']($request); |
| 2171 | 2288 | |
| 2172 | - foreach ($return as $mday => $array) |
|
| 2173 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
| 2289 | + foreach ($return as $mday => $array) { |
|
| 2290 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
| 2291 | + } |
|
| 2174 | 2292 | |
| 2175 | 2293 | // If mods want to do somthing with this list of events, let them do that now. |
| 2176 | 2294 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
| 2177 | 2295 | |
| 2178 | - if ($output_method != 'echo' || empty($return)) |
|
| 2179 | - return $return; |
|
| 2296 | + if ($output_method != 'echo' || empty($return)) { |
|
| 2297 | + return $return; |
|
| 2298 | + } |
|
| 2180 | 2299 | |
| 2181 | 2300 | // Well the output method is echo. |
| 2182 | 2301 | echo ' |
| 2183 | 2302 | <span class="event">' . $txt['events'] . '</span> '; |
| 2184 | - foreach ($return as $mday => $array) |
|
| 2185 | - foreach ($array as $event) |
|
| 2303 | + foreach ($return as $mday => $array) { |
|
| 2304 | + foreach ($array as $event) |
|
| 2186 | 2305 | { |
| 2187 | 2306 | if ($event['can_edit']) |
| 2188 | 2307 | echo ' |
| 2189 | 2308 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 2309 | + } |
|
| 2190 | 2310 | |
| 2191 | 2311 | echo ' |
| 2192 | 2312 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2205,8 +2325,9 @@ discard block |
||
| 2205 | 2325 | global $smcFunc; |
| 2206 | 2326 | |
| 2207 | 2327 | // If $id is null, this was most likely called from a query string and should do nothing. |
| 2208 | - if ($id === null) |
|
| 2209 | - return; |
|
| 2328 | + if ($id === null) { |
|
| 2329 | + return; |
|
| 2330 | + } |
|
| 2210 | 2331 | |
| 2211 | 2332 | $request = $smcFunc['db_query']('', ' |
| 2212 | 2333 | SELECT passwd, member_name, is_activated |
@@ -2238,8 +2359,9 @@ discard block |
||
| 2238 | 2359 | $attachments_boards = boardsAllowedTo('view_attachments'); |
| 2239 | 2360 | |
| 2240 | 2361 | // No boards? Adios amigo. |
| 2241 | - if (empty($attachments_boards)) |
|
| 2242 | - return array(); |
|
| 2362 | + if (empty($attachments_boards)) { |
|
| 2363 | + return array(); |
|
| 2364 | + } |
|
| 2243 | 2365 | |
| 2244 | 2366 | // Is it an array? |
| 2245 | 2367 | $attachment_ext = (array) $attachment_ext; |
@@ -2323,8 +2445,9 @@ discard block |
||
| 2323 | 2445 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
| 2324 | 2446 | |
| 2325 | 2447 | // So you just want an array? Here you can have it. |
| 2326 | - if ($output_method == 'array' || empty($attachments)) |
|
| 2327 | - return $attachments; |
|
| 2448 | + if ($output_method == 'array' || empty($attachments)) { |
|
| 2449 | + return $attachments; |
|
| 2450 | + } |
|
| 2328 | 2451 | |
| 2329 | 2452 | // Give them the default. |
| 2330 | 2453 | echo ' |
@@ -2335,14 +2458,15 @@ discard block |
||
| 2335 | 2458 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
| 2336 | 2459 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
| 2337 | 2460 | </tr>'; |
| 2338 | - foreach ($attachments as $attach) |
|
| 2339 | - echo ' |
|
| 2461 | + foreach ($attachments as $attach) { |
|
| 2462 | + echo ' |
|
| 2340 | 2463 | <tr> |
| 2341 | 2464 | <td>', $attach['file']['link'], '</td> |
| 2342 | 2465 | <td>', $attach['member']['link'], '</td> |
| 2343 | 2466 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
| 2344 | 2467 | <td>', $attach['file']['filesize'], '</td> |
| 2345 | 2468 | </tr>'; |
| 2469 | + } |
|
| 2346 | 2470 | echo ' |
| 2347 | 2471 | </table>'; |
| 2348 | 2472 | } |
@@ -41,37 +41,43 @@ discard block |
||
| 41 | 41 | define('TIME_START', microtime(true)); |
| 42 | 42 | |
| 43 | 43 | // Just being safe... |
| 44 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 44 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 45 | 45 | if (isset($GLOBALS[$variable])) |
| 46 | 46 | unset($GLOBALS[$variable]); |
| 47 | +} |
|
| 47 | 48 | |
| 48 | 49 | // Get the forum's settings for database and file paths. |
| 49 | 50 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 50 | 51 | |
| 51 | 52 | // Make absolutely sure the cache directory is defined. |
| 52 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 53 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 53 | 54 | $cachedir = $boarddir . '/cache'; |
| 55 | +} |
|
| 54 | 56 | |
| 55 | 57 | // Don't do john didley if the forum's been shut down competely. |
| 56 | -if ($maintenance == 2) |
|
| 58 | +if ($maintenance == 2) { |
|
| 57 | 59 | die($mmessage); |
| 60 | +} |
|
| 58 | 61 | |
| 59 | 62 | // Fix for using the current directory as a path. |
| 60 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
| 63 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
| 61 | 64 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
| 65 | +} |
|
| 62 | 66 | |
| 63 | 67 | // Have we already turned this off? If so, exist gracefully. |
| 64 | -if (file_exists($cachedir . '/cron.lock')) |
|
| 68 | +if (file_exists($cachedir . '/cron.lock')) { |
|
| 65 | 69 | obExit_cron(); |
| 70 | +} |
|
| 66 | 71 | |
| 67 | 72 | // Before we go any further, if this is not a CLI request, we need to do some checking. |
| 68 | 73 | if (!FROM_CLI) |
| 69 | 74 | { |
| 70 | 75 | // We will clean up $_GET shortly. But we want to this ASAP. |
| 71 | 76 | $ts = isset($_GET['ts']) ? (int) $_GET['ts'] : 0; |
| 72 | - if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) |
|
| 73 | - obExit_cron(); |
|
| 74 | -} |
|
| 77 | + if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) { |
|
| 78 | + obExit_cron(); |
|
| 79 | + } |
|
| 80 | + } |
|
| 75 | 81 | |
| 76 | 82 | // Load the most important includes. In general, a background should be loading its own dependencies. |
| 77 | 83 | require_once($sourcedir . '/Errors.php'); |
@@ -123,8 +129,9 @@ discard block |
||
| 123 | 129 | global $smcFunc; |
| 124 | 130 | |
| 125 | 131 | // Check we haven't run over our time limit. |
| 126 | - if (microtime(true) - TIME_START > MAX_CRON_TIME) |
|
| 127 | - return false; |
|
| 132 | + if (microtime(true) - TIME_START > MAX_CRON_TIME) { |
|
| 133 | + return false; |
|
| 134 | + } |
|
| 128 | 135 | |
| 129 | 136 | // Try to find a task. Specifically, try to find one that hasn't been claimed previously, or failing that, |
| 130 | 137 | // a task that was claimed but failed for whatever reason and failed long enough ago. We should not care |
@@ -159,14 +166,12 @@ discard block |
||
| 159 | 166 | // Update the time and go back. |
| 160 | 167 | $row['claimed_time'] = time(); |
| 161 | 168 | return $row; |
| 162 | - } |
|
| 163 | - else |
|
| 169 | + } else |
|
| 164 | 170 | { |
| 165 | 171 | // Uh oh, we just missed it. Try to claim another one, and let it fall through if there aren't any. |
| 166 | 172 | return fetch_task(); |
| 167 | 173 | } |
| 168 | - } |
|
| 169 | - else |
|
| 174 | + } else |
|
| 170 | 175 | { |
| 171 | 176 | // No dice. Clean up and go home. |
| 172 | 177 | $smcFunc['db_free_result']($request); |
@@ -187,8 +192,9 @@ discard block |
||
| 187 | 192 | if (!empty($task_details['task_file'])) |
| 188 | 193 | { |
| 189 | 194 | $include = strtr(trim($task_details['task_file']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 190 | - if (file_exists($include)) |
|
| 191 | - require_once($include); |
|
| 195 | + if (file_exists($include)) { |
|
| 196 | + require_once($include); |
|
| 197 | + } |
|
| 192 | 198 | } |
| 193 | 199 | |
| 194 | 200 | if (empty($task_details['task_class'])) |
@@ -204,8 +210,7 @@ discard block |
||
| 204 | 210 | $details = empty($task_details['task_data']) ? array() : json_decode($task_details['task_data'], true); |
| 205 | 211 | $bgtask = new $task_details['task_class']($details); |
| 206 | 212 | return $bgtask->execute(); |
| 207 | - } |
|
| 208 | - else |
|
| 213 | + } else |
|
| 209 | 214 | { |
| 210 | 215 | log_error('Invalid background task specified: (class: ' . $task_details['task_class'] . ', ' . (empty($task_details['task_file']) ? ' no file' : ' to load ' . $task_details['task_file']) . ')'); |
| 211 | 216 | return true; // So we clear it from the queue. |
@@ -224,8 +229,9 @@ discard block |
||
| 224 | 229 | $scripturl = $boardurl . '/index.php'; |
| 225 | 230 | |
| 226 | 231 | // These keys shouldn't be set...ever. |
| 227 | - if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
| 228 | - die('Invalid request variable.'); |
|
| 232 | + if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
| 233 | + die('Invalid request variable.'); |
|
| 234 | + } |
|
| 229 | 235 | |
| 230 | 236 | // Save some memory.. (since we don't use these anyway.) |
| 231 | 237 | unset($GLOBALS['HTTP_POST_VARS'], $GLOBALS['HTTP_POST_VARS']); |
@@ -246,26 +252,28 @@ discard block |
||
| 246 | 252 | global $modSettings; |
| 247 | 253 | |
| 248 | 254 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.) |
| 249 | - if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) |
|
| 250 | - return; |
|
| 255 | + if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) { |
|
| 256 | + return; |
|
| 257 | + } |
|
| 251 | 258 | |
| 252 | 259 | $error_type = 'cron'; |
| 253 | 260 | |
| 254 | 261 | log_error($error_level . ': ' . $error_string, $error_type, $file, $line); |
| 255 | 262 | |
| 256 | 263 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
| 257 | - if ($error_level % 255 == E_ERROR) |
|
| 258 | - die('No direct access...'); |
|
| 259 | -} |
|
| 264 | + if ($error_level % 255 == E_ERROR) { |
|
| 265 | + die('No direct access...'); |
|
| 266 | + } |
|
| 267 | + } |
|
| 260 | 268 | |
| 261 | 269 | /** |
| 262 | 270 | * The exit function |
| 263 | 271 | */ |
| 264 | 272 | function obExit_cron() |
| 265 | 273 | { |
| 266 | - if (FROM_CLI) |
|
| 267 | - die(0); |
|
| 268 | - else |
|
| 274 | + if (FROM_CLI) { |
|
| 275 | + die(0); |
|
| 276 | + } else |
|
| 269 | 277 | { |
| 270 | 278 | header('Content-Type: image/gif'); |
| 271 | 279 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
@@ -16,8 +16,9 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | // Start things rolling by getting SMF alive... |
| 18 | 18 | $ssi_guest_access = true; |
| 19 | -if (!file_exists(dirname(__FILE__) . '/SSI.php')) |
|
| 19 | +if (!file_exists(dirname(__FILE__) . '/SSI.php')) { |
|
| 20 | 20 | die('Cannot find SSI.php'); |
| 21 | +} |
|
| 21 | 22 | |
| 22 | 23 | require_once(dirname(__FILE__) . '/SSI.php'); |
| 23 | 24 | require_once($sourcedir . '/ManagePaid.php'); |
@@ -35,20 +36,22 @@ discard block |
||
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | // I assume we're even active? |
| 38 | -if (empty($modSettings['paid_enabled'])) |
|
| 39 | +if (empty($modSettings['paid_enabled'])) { |
|
| 39 | 40 | exit; |
| 41 | +} |
|
| 40 | 42 | |
| 41 | 43 | // If we have some custom people who find out about problems load them here. |
| 42 | 44 | $notify_users = array(); |
| 43 | 45 | if (!empty($modSettings['paid_email_to'])) |
| 44 | 46 | { |
| 45 | - foreach (explode(',', $modSettings['paid_email_to']) as $email) |
|
| 46 | - $notify_users[] = array( |
|
| 47 | + foreach (explode(',', $modSettings['paid_email_to']) as $email) { |
|
| 48 | + $notify_users[] = array( |
|
| 47 | 49 | 'email' => $email, |
| 48 | 50 | 'name' => $txt['who_member'], |
| 49 | 51 | 'id' => 0, |
| 50 | 52 | ); |
| 51 | -} |
|
| 53 | + } |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // We need to see whether we can find the correct payment gateway, |
| 54 | 57 | // we'll going to go through all our gateway scripts and find out |
@@ -65,8 +68,9 @@ discard block |
||
| 65 | 68 | } |
| 66 | 69 | } |
| 67 | 70 | |
| 68 | -if (empty($txnType)) |
|
| 71 | +if (empty($txnType)) { |
|
| 69 | 72 | generateSubscriptionError($txt['paid_unknown_transaction_type']); |
| 73 | +} |
|
| 70 | 74 | |
| 71 | 75 | // Get the subscription and member ID amoungst others... |
| 72 | 76 | @list($subscription_id, $member_id) = $gatewayClass->precheck(); |
@@ -76,8 +80,9 @@ discard block |
||
| 76 | 80 | $member_id = (int) $member_id; |
| 77 | 81 | |
| 78 | 82 | // This would be bad... |
| 79 | -if (empty($member_id)) |
|
| 83 | +if (empty($member_id)) { |
|
| 80 | 84 | generateSubscriptionError($txt['paid_empty_member']); |
| 85 | +} |
|
| 81 | 86 | |
| 82 | 87 | // Verify the member. |
| 83 | 88 | $request = $smcFunc['db_query']('', ' |
@@ -89,8 +94,9 @@ discard block |
||
| 89 | 94 | ) |
| 90 | 95 | ); |
| 91 | 96 | // Didn't find them? |
| 92 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
| 97 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 93 | 98 | generateSubscriptionError(sprintf($txt['paid_could_not_find_member'], $member_id)); |
| 99 | +} |
|
| 94 | 100 | $member_info = $smcFunc['db_fetch_assoc']($request); |
| 95 | 101 | $smcFunc['db_free_result']($request); |
| 96 | 102 | |
@@ -105,8 +111,9 @@ discard block |
||
| 105 | 111 | ); |
| 106 | 112 | |
| 107 | 113 | // Didn't find it? |
| 108 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
| 114 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 109 | 115 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription'], $member_id, $subscription_id)); |
| 116 | +} |
|
| 110 | 117 | |
| 111 | 118 | $subscription_info = $smcFunc['db_fetch_assoc']($request); |
| 112 | 119 | $smcFunc['db_free_result']($request); |
@@ -123,8 +130,9 @@ discard block |
||
| 123 | 130 | 'current_member' => $member_id, |
| 124 | 131 | ) |
| 125 | 132 | ); |
| 126 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
| 133 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 127 | 134 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription_log'], $member_id, $subscription_id)); |
| 135 | +} |
|
| 128 | 136 | $subscription_info += $smcFunc['db_fetch_assoc']($request); |
| 129 | 137 | $smcFunc['db_free_result']($request); |
| 130 | 138 | |
@@ -139,8 +147,7 @@ discard block |
||
| 139 | 147 | removeSubscription($subscription_id, $member_id); |
| 140 | 148 | $subscription_act = time(); |
| 141 | 149 | $status = 0; |
| 142 | - } |
|
| 143 | - else |
|
| 150 | + } else |
|
| 144 | 151 | { |
| 145 | 152 | loadSubscriptions(); |
| 146 | 153 | $subscription_act = $subscription_info['end_time'] - $context['subscriptions'][$subscription_id]['num_length']; |
@@ -188,16 +195,18 @@ discard block |
||
| 188 | 195 | if (!$gatewayClass->isSubscription()) |
| 189 | 196 | { |
| 190 | 197 | $real_details = json_decode($subscription_info['pending_details'], true); |
| 191 | - if (empty($real_details)) |
|
| 192 | - generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
| 198 | + if (empty($real_details)) { |
|
| 199 | + generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
| 200 | + } |
|
| 193 | 201 | |
| 194 | 202 | // Now we just try to find anything pending. |
| 195 | 203 | // We don't really care which it is as security happens later. |
| 196 | 204 | foreach ($real_details as $id => $detail) |
| 197 | 205 | { |
| 198 | 206 | unset($real_details[$id]); |
| 199 | - if ($detail[3] == 'payback' && $subscription_info['payments_pending']) |
|
| 200 | - $subscription_info['payments_pending']--; |
|
| 207 | + if ($detail[3] == 'payback' && $subscription_info['payments_pending']) { |
|
| 208 | + $subscription_info['payments_pending']--; |
|
| 209 | + } |
|
| 201 | 210 | break; |
| 202 | 211 | } |
| 203 | 212 | |
@@ -223,10 +232,11 @@ discard block |
||
| 223 | 232 | // This is a little harder, can we find the right duration? |
| 224 | 233 | foreach ($cost as $duration => $value) |
| 225 | 234 | { |
| 226 | - if ($duration == 'fixed') |
|
| 227 | - continue; |
|
| 228 | - elseif ((float) $value == (float) $total_cost) |
|
| 229 | - $found_duration = strtoupper(substr($duration, 0, 1)); |
|
| 235 | + if ($duration == 'fixed') { |
|
| 236 | + continue; |
|
| 237 | + } elseif ((float) $value == (float) $total_cost) { |
|
| 238 | + $found_duration = strtoupper(substr($duration, 0, 1)); |
|
| 239 | + } |
|
| 230 | 240 | } |
| 231 | 241 | |
| 232 | 242 | // If we have the duration then we're done. |
@@ -235,8 +245,7 @@ discard block |
||
| 235 | 245 | $notify = true; |
| 236 | 246 | addSubscription($subscription_id, $member_id, $found_duration); |
| 237 | 247 | } |
| 238 | - } |
|
| 239 | - else |
|
| 248 | + } else |
|
| 240 | 249 | { |
| 241 | 250 | $actual_cost = $cost['fixed']; |
| 242 | 251 | |
@@ -268,10 +277,10 @@ discard block |
||
| 268 | 277 | // Maybe they're cancelling. Some subscriptions may require actively doing something, but PayPal doesn't, for example. |
| 269 | 278 | elseif ($gatewayClass->isCancellation()) |
| 270 | 279 | { |
| 271 | - if (method_exists($gatewayClass, 'performCancel')) |
|
| 272 | - $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
| 273 | -} |
|
| 274 | -else |
|
| 280 | + if (method_exists($gatewayClass, 'performCancel')) { |
|
| 281 | + $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
| 282 | + } |
|
| 283 | + } else |
|
| 275 | 284 | { |
| 276 | 285 | // Some other "valid" transaction such as: |
| 277 | 286 | // |
@@ -308,8 +317,9 @@ discard block |
||
| 308 | 317 | // Maybe we can try to give them the post data? |
| 309 | 318 | if (!empty($_POST)) |
| 310 | 319 | { |
| 311 | - foreach ($_POST as $key => $val) |
|
| 312 | - $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
| 320 | + foreach ($_POST as $key => $val) { |
|
| 321 | + $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
| 322 | + } |
|
| 313 | 323 | } |
| 314 | 324 | |
| 315 | 325 | // Then just log and die. |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Edit the position and properties of a category. |
@@ -42,8 +43,9 @@ discard block |
||
| 42 | 43 | $cat_order = array(); |
| 43 | 44 | |
| 44 | 45 | // Setting 'move_after' to '0' moves the category to the top. |
| 45 | - if ($catOptions['move_after'] == 0) |
|
| 46 | - $cats[] = $category_id; |
|
| 46 | + if ($catOptions['move_after'] == 0) { |
|
| 47 | + $cats[] = $category_id; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Grab the categories sorted by cat_order. |
| 49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -55,17 +57,19 @@ discard block |
||
| 55 | 57 | ); |
| 56 | 58 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 57 | 59 | { |
| 58 | - if ($row['id_cat'] != $category_id) |
|
| 59 | - $cats[] = $row['id_cat']; |
|
| 60 | - if ($row['id_cat'] == $catOptions['move_after']) |
|
| 61 | - $cats[] = $category_id; |
|
| 60 | + if ($row['id_cat'] != $category_id) { |
|
| 61 | + $cats[] = $row['id_cat']; |
|
| 62 | + } |
|
| 63 | + if ($row['id_cat'] == $catOptions['move_after']) { |
|
| 64 | + $cats[] = $category_id; |
|
| 65 | + } |
|
| 62 | 66 | $cat_order[$row['id_cat']] = $row['cat_order']; |
| 63 | 67 | } |
| 64 | 68 | $smcFunc['db_free_result']($request); |
| 65 | 69 | |
| 66 | 70 | // Set the new order for the categories. |
| 67 | - foreach ($cats as $index => $cat) |
|
| 68 | - if ($index != $cat_order[$cat]) |
|
| 71 | + foreach ($cats as $index => $cat) { |
|
| 72 | + if ($index != $cat_order[$cat]) |
|
| 69 | 73 | $smcFunc['db_query']('', ' |
| 70 | 74 | UPDATE {db_prefix}categories |
| 71 | 75 | SET cat_order = {int:new_order} |
@@ -75,6 +79,7 @@ discard block |
||
| 75 | 79 | 'current_category' => $cat, |
| 76 | 80 | ) |
| 77 | 81 | ); |
| 82 | + } |
|
| 78 | 83 | |
| 79 | 84 | // If the category order changed, so did the board order. |
| 80 | 85 | require_once($sourcedir . '/Subs-Boards.php'); |
@@ -117,8 +122,9 @@ discard block |
||
| 117 | 122 | )) |
| 118 | 123 | ); |
| 119 | 124 | |
| 120 | - if (empty($catOptions['dont_log'])) |
|
| 121 | - logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
| 125 | + if (empty($catOptions['dont_log'])) { |
|
| 126 | + logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
| 127 | + } |
|
| 122 | 128 | } |
| 123 | 129 | } |
| 124 | 130 | |
@@ -135,16 +141,20 @@ discard block |
||
| 135 | 141 | global $smcFunc; |
| 136 | 142 | |
| 137 | 143 | // Check required values. |
| 138 | - if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') |
|
| 139 | - trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
| 144 | + if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') { |
|
| 145 | + trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
| 146 | + } |
|
| 140 | 147 | |
| 141 | 148 | // Set default values. |
| 142 | - if (!isset($catOptions['cat_desc'])) |
|
| 143 | - $catOptions['cat_desc'] = ''; |
|
| 144 | - if (!isset($catOptions['move_after'])) |
|
| 145 | - $catOptions['move_after'] = 0; |
|
| 146 | - if (!isset($catOptions['is_collapsible'])) |
|
| 147 | - $catOptions['is_collapsible'] = true; |
|
| 149 | + if (!isset($catOptions['cat_desc'])) { |
|
| 150 | + $catOptions['cat_desc'] = ''; |
|
| 151 | + } |
|
| 152 | + if (!isset($catOptions['move_after'])) { |
|
| 153 | + $catOptions['move_after'] = 0; |
|
| 154 | + } |
|
| 155 | + if (!isset($catOptions['is_collapsible'])) { |
|
| 156 | + $catOptions['is_collapsible'] = true; |
|
| 157 | + } |
|
| 148 | 158 | // Don't log an edit right after. |
| 149 | 159 | $catOptions['dont_log'] = true; |
| 150 | 160 | |
@@ -212,21 +222,24 @@ discard block |
||
| 212 | 222 | ) |
| 213 | 223 | ); |
| 214 | 224 | $boards_inside = array(); |
| 215 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 216 | - $boards_inside[] = $row['id_board']; |
|
| 225 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 226 | + $boards_inside[] = $row['id_board']; |
|
| 227 | + } |
|
| 217 | 228 | $smcFunc['db_free_result']($request); |
| 218 | 229 | |
| 219 | - if (!empty($boards_inside)) |
|
| 220 | - deleteBoards($boards_inside, null); |
|
| 230 | + if (!empty($boards_inside)) { |
|
| 231 | + deleteBoards($boards_inside, null); |
|
| 232 | + } |
|
| 221 | 233 | } |
| 222 | 234 | |
| 223 | 235 | // Make sure the safe category is really safe. |
| 224 | - elseif (in_array($moveBoardsTo, $categories)) |
|
| 225 | - trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
| 236 | + elseif (in_array($moveBoardsTo, $categories)) { |
|
| 237 | + trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
| 238 | + } |
|
| 226 | 239 | |
| 227 | 240 | // Move the boards inside the categories to a safe category. |
| 228 | - else |
|
| 229 | - $smcFunc['db_query']('', ' |
|
| 241 | + else { |
|
| 242 | + $smcFunc['db_query']('', ' |
|
| 230 | 243 | UPDATE {db_prefix}boards |
| 231 | 244 | SET id_cat = {int:new_parent_cat} |
| 232 | 245 | WHERE id_cat IN ({array_int:category_list})', |
@@ -235,6 +248,7 @@ discard block |
||
| 235 | 248 | 'new_parent_cat' => $moveBoardsTo, |
| 236 | 249 | ) |
| 237 | 250 | ); |
| 251 | + } |
|
| 238 | 252 | |
| 239 | 253 | // Do the deletion of the category itself |
| 240 | 254 | $smcFunc['db_query']('', ' |
@@ -246,8 +260,9 @@ discard block |
||
| 246 | 260 | ); |
| 247 | 261 | |
| 248 | 262 | // Log what we've done. |
| 249 | - foreach ($categories as $category) |
|
| 250 | - logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
| 263 | + foreach ($categories as $category) { |
|
| 264 | + logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
| 265 | + } |
|
| 251 | 266 | |
| 252 | 267 | // Get all boards back into the right order. |
| 253 | 268 | reorderBoards(); |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 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 | * Who's online, and what are they doing? |
@@ -35,8 +36,9 @@ discard block |
||
| 35 | 36 | isAllowedTo('who_view'); |
| 36 | 37 | |
| 37 | 38 | // You can't do anything if this is off. |
| 38 | - if (empty($modSettings['who_enabled'])) |
|
| 39 | - fatal_lang_error('who_off', false); |
|
| 39 | + if (empty($modSettings['who_enabled'])) { |
|
| 40 | + fatal_lang_error('who_off', false); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // Load the 'Who' template. |
| 42 | 44 | loadTemplate('Who'); |
@@ -71,9 +73,9 @@ discard block |
||
| 71 | 73 | $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; |
| 72 | 74 | $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; |
| 73 | 75 | $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; |
| 76 | + } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { |
|
| 77 | + unset($_SESSION['who_online_filter']); |
|
| 74 | 78 | } |
| 75 | - elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') |
|
| 76 | - unset($_SESSION['who_online_filter']); |
|
| 77 | 79 | |
| 78 | 80 | // Does the user prefer a different sort direction? |
| 79 | 81 | if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) |
@@ -97,20 +99,24 @@ discard block |
||
| 97 | 99 | $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down'; |
| 98 | 100 | |
| 99 | 101 | $conditions = array(); |
| 100 | - if (!allowedTo('moderate_forum')) |
|
| 101 | - $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 102 | + if (!allowedTo('moderate_forum')) { |
|
| 103 | + $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 104 | + } |
|
| 102 | 105 | |
| 103 | 106 | // Fallback to top filter? |
| 104 | - if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) |
|
| 105 | - $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 107 | + if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { |
|
| 108 | + $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 109 | + } |
|
| 106 | 110 | // Does the user wish to apply a filter? |
| 107 | - if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) |
|
| 108 | - $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 111 | + if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { |
|
| 112 | + $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 113 | + } |
|
| 109 | 114 | // Perhaps we saved a filter earlier in the session? |
| 110 | - elseif (isset($_SESSION['who_online_filter'])) |
|
| 111 | - $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 112 | - else |
|
| 113 | - $context['show_by'] = 'members'; |
|
| 115 | + elseif (isset($_SESSION['who_online_filter'])) { |
|
| 116 | + $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 117 | + } else { |
|
| 118 | + $context['show_by'] = 'members'; |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | $conditions[] = $show_methods[$context['show_by']]; |
| 116 | 122 | |
@@ -156,8 +162,9 @@ discard block |
||
| 156 | 162 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 157 | 163 | { |
| 158 | 164 | $actions = smf_json_decode($row['url'], true); |
| 159 | - if ($actions === false) |
|
| 160 | - continue; |
|
| 165 | + if ($actions === false) { |
|
| 166 | + continue; |
|
| 167 | + } |
|
| 161 | 168 | |
| 162 | 169 | // Send the information to the template. |
| 163 | 170 | $context['members'][$row['session']] = array( |
@@ -195,8 +202,8 @@ discard block |
||
| 195 | 202 | $spiderContext = array(); |
| 196 | 203 | if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
| 197 | 204 | { |
| 198 | - foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) |
|
| 199 | - $spiderContext[$id] = array( |
|
| 205 | + foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) { |
|
| 206 | + $spiderContext[$id] = array( |
|
| 200 | 207 | 'id' => 0, |
| 201 | 208 | 'name' => $name, |
| 202 | 209 | 'group' => $txt['spiders'], |
@@ -205,6 +212,7 @@ discard block |
||
| 205 | 212 | 'email' => $name, |
| 206 | 213 | 'is_guest' => true |
| 207 | 214 | ); |
| 215 | + } |
|
| 208 | 216 | } |
| 209 | 217 | |
| 210 | 218 | $url_data = determineActions($url_data); |
@@ -219,16 +227,18 @@ discard block |
||
| 219 | 227 | // Put it in the context variables. |
| 220 | 228 | foreach ($context['members'] as $i => $member) |
| 221 | 229 | { |
| 222 | - if ($member['id'] != 0) |
|
| 223 | - $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 230 | + if ($member['id'] != 0) { |
|
| 231 | + $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 232 | + } |
|
| 224 | 233 | |
| 225 | 234 | // Keep the IP that came from the database. |
| 226 | 235 | $memberContext[$member['id']]['ip'] = $member['ip']; |
| 227 | 236 | $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; |
| 228 | - if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) |
|
| 229 | - $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 230 | - else |
|
| 231 | - $context['members'][$i] += $memberContext[$member['id']]; |
|
| 237 | + if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { |
|
| 238 | + $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 239 | + } else { |
|
| 240 | + $context['members'][$i] += $memberContext[$member['id']]; |
|
| 241 | + } |
|
| 232 | 242 | } |
| 233 | 243 | |
| 234 | 244 | // Some people can't send personal messages... |
@@ -263,8 +273,9 @@ discard block |
||
| 263 | 273 | { |
| 264 | 274 | global $txt, $user_info, $modSettings, $smcFunc; |
| 265 | 275 | |
| 266 | - if (!allowedTo('who_view')) |
|
| 267 | - return array(); |
|
| 276 | + if (!allowedTo('who_view')) { |
|
| 277 | + return array(); |
|
| 278 | + } |
|
| 268 | 279 | loadLanguage('Who'); |
| 269 | 280 | |
| 270 | 281 | // Actions that require a specific permission level. |
@@ -292,10 +303,11 @@ discard block |
||
| 292 | 303 | ); |
| 293 | 304 | call_integration_hook('who_allowed', array(&$allowedActions)); |
| 294 | 305 | |
| 295 | - if (!is_array($urls)) |
|
| 296 | - $url_list = array(array($urls, $user_info['id'])); |
|
| 297 | - else |
|
| 298 | - $url_list = $urls; |
|
| 306 | + if (!is_array($urls)) { |
|
| 307 | + $url_list = array(array($urls, $user_info['id'])); |
|
| 308 | + } else { |
|
| 309 | + $url_list = $urls; |
|
| 310 | + } |
|
| 299 | 311 | |
| 300 | 312 | // These are done to later query these in large chunks. (instead of one by one.) |
| 301 | 313 | $topic_ids = array(); |
@@ -307,12 +319,14 @@ discard block |
||
| 307 | 319 | { |
| 308 | 320 | // Get the request parameters.. |
| 309 | 321 | $actions = smf_json_decode($url[0], true); |
| 310 | - if ($actions === false) |
|
| 311 | - continue; |
|
| 322 | + if ($actions === false) { |
|
| 323 | + continue; |
|
| 324 | + } |
|
| 312 | 325 | |
| 313 | 326 | // If it's the admin or moderation center, and there is an area set, use that instead. |
| 314 | - if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) |
|
| 315 | - $actions['action'] = $actions['area']; |
|
| 327 | + if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) { |
|
| 328 | + $actions['action'] = $actions['area']; |
|
| 329 | + } |
|
| 316 | 330 | |
| 317 | 331 | // Check if there was no action or the action is display. |
| 318 | 332 | if (!isset($actions['action']) || $actions['action'] == 'display') |
@@ -332,12 +346,14 @@ discard block |
||
| 332 | 346 | $board_ids[$actions['board']][$k] = $txt['who_board']; |
| 333 | 347 | } |
| 334 | 348 | // It's the board index!! It must be! |
| 335 | - else |
|
| 336 | - $data[$k] = $txt['who_index']; |
|
| 349 | + else { |
|
| 350 | + $data[$k] = $txt['who_index']; |
|
| 351 | + } |
|
| 337 | 352 | } |
| 338 | 353 | // Probably an error or some goon? |
| 339 | - elseif ($actions['action'] == '') |
|
| 340 | - $data[$k] = $txt['who_index']; |
|
| 354 | + elseif ($actions['action'] == '') { |
|
| 355 | + $data[$k] = $txt['who_index']; |
|
| 356 | + } |
|
| 341 | 357 | // Some other normal action...? |
| 342 | 358 | else |
| 343 | 359 | { |
@@ -345,23 +361,25 @@ discard block |
||
| 345 | 361 | if ($actions['action'] == 'profile') |
| 346 | 362 | { |
| 347 | 363 | // Whose? Their own? |
| 348 | - if (empty($actions['u'])) |
|
| 349 | - $actions['u'] = $url[1]; |
|
| 364 | + if (empty($actions['u'])) { |
|
| 365 | + $actions['u'] = $url[1]; |
|
| 366 | + } |
|
| 350 | 367 | |
| 351 | 368 | $data[$k] = $txt['who_hidden']; |
| 352 | 369 | $profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile']; |
| 353 | - } |
|
| 354 | - elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 370 | + } elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 355 | 371 | { |
| 356 | 372 | $data[$k] = $txt['who_hidden']; |
| 357 | 373 | $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post']; |
| 358 | 374 | } |
| 359 | 375 | // A subaction anyone can view... if the language string is there, show it. |
| 360 | - elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) |
|
| 361 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 376 | + elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) { |
|
| 377 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 378 | + } |
|
| 362 | 379 | // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.) |
| 363 | - elseif (isset($txt['whoall_' . $actions['action']])) |
|
| 364 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 380 | + elseif (isset($txt['whoall_' . $actions['action']])) { |
|
| 381 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 382 | + } |
|
| 365 | 383 | // Viewable if and only if they can see the board... |
| 366 | 384 | elseif (isset($txt['whotopic_' . $actions['action']])) |
| 367 | 385 | { |
@@ -370,8 +388,7 @@ discard block |
||
| 370 | 388 | |
| 371 | 389 | $data[$k] = $txt['who_hidden']; |
| 372 | 390 | $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']]; |
| 373 | - } |
|
| 374 | - elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 391 | + } elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 375 | 392 | { |
| 376 | 393 | // Find out what message they are accessing. |
| 377 | 394 | $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0)); |
@@ -394,41 +411,46 @@ discard block |
||
| 394 | 411 | $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject); |
| 395 | 412 | $smcFunc['db_free_result']($result); |
| 396 | 413 | |
| 397 | - if (empty($id_topic)) |
|
| 398 | - $data[$k] = $txt['who_hidden']; |
|
| 414 | + if (empty($id_topic)) { |
|
| 415 | + $data[$k] = $txt['who_hidden']; |
|
| 416 | + } |
|
| 399 | 417 | } |
| 400 | 418 | // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!) |
| 401 | - elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) |
|
| 402 | - $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 419 | + elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) { |
|
| 420 | + $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 421 | + } |
|
| 403 | 422 | // Viewable by permission level. |
| 404 | 423 | elseif (isset($allowedActions[$actions['action']])) |
| 405 | 424 | { |
| 406 | - if (allowedTo($allowedActions[$actions['action']])) |
|
| 407 | - $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 408 | - elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) |
|
| 409 | - $data[$k] = $txt['who_moderate']; |
|
| 410 | - elseif (in_array('admin_forum', $allowedActions[$actions['action']])) |
|
| 411 | - $data[$k] = $txt['who_admin']; |
|
| 412 | - else |
|
| 413 | - $data[$k] = $txt['who_hidden']; |
|
| 425 | + if (allowedTo($allowedActions[$actions['action']])) { |
|
| 426 | + $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 427 | + } elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) { |
|
| 428 | + $data[$k] = $txt['who_moderate']; |
|
| 429 | + } elseif (in_array('admin_forum', $allowedActions[$actions['action']])) { |
|
| 430 | + $data[$k] = $txt['who_admin']; |
|
| 431 | + } else { |
|
| 432 | + $data[$k] = $txt['who_hidden']; |
|
| 433 | + } |
|
| 434 | + } elseif (!empty($actions['action'])) { |
|
| 435 | + $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 436 | + } else { |
|
| 437 | + $data[$k] = $txt['who_unknown']; |
|
| 414 | 438 | } |
| 415 | - elseif (!empty($actions['action'])) |
|
| 416 | - $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 417 | - else |
|
| 418 | - $data[$k] = $txt['who_unknown']; |
|
| 419 | 439 | } |
| 420 | 440 | |
| 421 | 441 | if (isset($actions['error'])) |
| 422 | 442 | { |
| 423 | - if (isset($txt[$actions['error']])) |
|
| 424 | - $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 425 | - elseif ($actions['error'] == 'guest_login') |
|
| 426 | - $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 427 | - else |
|
| 428 | - $error_message = str_replace('"', '"', $actions['error']); |
|
| 429 | - |
|
| 430 | - if (!empty($error_message)) |
|
| 431 | - $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 443 | + if (isset($txt[$actions['error']])) { |
|
| 444 | + $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 445 | + } elseif ($actions['error'] == 'guest_login') { |
|
| 446 | + $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 447 | + } else { |
|
| 448 | + $error_message = str_replace('"', '"', $actions['error']); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + if (!empty($error_message)) { |
|
| 452 | + $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 453 | + } |
|
| 432 | 454 | } |
| 433 | 455 | |
| 434 | 456 | // Maybe the action is integrated into another system? |
@@ -439,12 +461,15 @@ discard block |
||
| 439 | 461 | if (!empty($integrate_action)) |
| 440 | 462 | { |
| 441 | 463 | $data[$k] = $integrate_action; |
| 442 | - if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) |
|
| 443 | - $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 444 | - if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) |
|
| 445 | - $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 446 | - if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) |
|
| 447 | - $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 464 | + if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) { |
|
| 465 | + $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 466 | + } |
|
| 467 | + if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) { |
|
| 468 | + $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 469 | + } |
|
| 470 | + if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) { |
|
| 471 | + $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 472 | + } |
|
| 448 | 473 | break; |
| 449 | 474 | } |
| 450 | 475 | } |
@@ -472,8 +497,9 @@ discard block |
||
| 472 | 497 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 473 | 498 | { |
| 474 | 499 | // Show the topic's subject for each of the actions. |
| 475 | - foreach ($topic_ids[$row['id_topic']] as $k => $session_text) |
|
| 476 | - $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 500 | + foreach ($topic_ids[$row['id_topic']] as $k => $session_text) { |
|
| 501 | + $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 502 | + } |
|
| 477 | 503 | } |
| 478 | 504 | $smcFunc['db_free_result']($result); |
| 479 | 505 | } |
@@ -495,8 +521,9 @@ discard block |
||
| 495 | 521 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 496 | 522 | { |
| 497 | 523 | // Put the board name into the string for each member... |
| 498 | - foreach ($board_ids[$row['id_board']] as $k => $session_text) |
|
| 499 | - $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 524 | + foreach ($board_ids[$row['id_board']] as $k => $session_text) { |
|
| 525 | + $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 526 | + } |
|
| 500 | 527 | } |
| 501 | 528 | $smcFunc['db_free_result']($result); |
| 502 | 529 | } |
@@ -518,23 +545,26 @@ discard block |
||
| 518 | 545 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 519 | 546 | { |
| 520 | 547 | // If they aren't allowed to view this person's profile, skip it. |
| 521 | - if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) |
|
| 522 | - continue; |
|
| 548 | + if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) { |
|
| 549 | + continue; |
|
| 550 | + } |
|
| 523 | 551 | |
| 524 | 552 | // Set their action on each - session/text to sprintf. |
| 525 | - foreach ($profile_ids[$row['id_member']] as $k => $session_text) |
|
| 526 | - $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 553 | + foreach ($profile_ids[$row['id_member']] as $k => $session_text) { |
|
| 554 | + $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 555 | + } |
|
| 527 | 556 | } |
| 528 | 557 | $smcFunc['db_free_result']($result); |
| 529 | 558 | } |
| 530 | 559 | |
| 531 | 560 | call_integration_hook('whos_online_after', array(&$urls, &$data)); |
| 532 | 561 | |
| 533 | - if (!is_array($urls)) |
|
| 534 | - return isset($data[0]) ? $data[0] : false; |
|
| 535 | - else |
|
| 536 | - return $data; |
|
| 537 | -} |
|
| 562 | + if (!is_array($urls)) { |
|
| 563 | + return isset($data[0]) ? $data[0] : false; |
|
| 564 | + } else { |
|
| 565 | + return $data; |
|
| 566 | + } |
|
| 567 | + } |
|
| 538 | 568 | |
| 539 | 569 | /** |
| 540 | 570 | * It prepares credit and copyright information for the credits page or the admin page |
@@ -709,8 +739,8 @@ discard block |
||
| 709 | 739 | ); |
| 710 | 740 | |
| 711 | 741 | // Give the translators some credit for their hard work. |
| 712 | - if (!empty($txt['translation_credits'])) |
|
| 713 | - $context['credits'][] = array( |
|
| 742 | + if (!empty($txt['translation_credits'])) { |
|
| 743 | + $context['credits'][] = array( |
|
| 714 | 744 | 'title' => $txt['credits_groups_translation'], |
| 715 | 745 | 'groups' => array( |
| 716 | 746 | array( |
@@ -719,6 +749,7 @@ discard block |
||
| 719 | 749 | ), |
| 720 | 750 | ), |
| 721 | 751 | ); |
| 752 | + } |
|
| 722 | 753 | |
| 723 | 754 | $context['credits'][] = array( |
| 724 | 755 | 'title' => $txt['credits_special'], |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | loadLanguage('Drafts'); |
| 21 | 22 | |
@@ -33,8 +34,9 @@ discard block |
||
| 33 | 34 | global $context, $user_info, $smcFunc, $modSettings, $board; |
| 34 | 35 | |
| 35 | 36 | // can you be, should you be ... here? |
| 36 | - if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) |
|
| 37 | - return false; |
|
| 37 | + if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | // read in what they sent us, if anything |
| 40 | 42 | $id_draft = (int) $_POST['id_draft']; |
@@ -46,14 +48,16 @@ discard block |
||
| 46 | 48 | $context['draft_saved_on'] = $draft_info['poster_time']; |
| 47 | 49 | |
| 48 | 50 | // since we were called from the autosave function, send something back |
| 49 | - if (!empty($id_draft)) |
|
| 50 | - XmlDraft($id_draft); |
|
| 51 | + if (!empty($id_draft)) { |
|
| 52 | + XmlDraft($id_draft); |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | return true; |
| 53 | 56 | } |
| 54 | 57 | |
| 55 | - if (!isset($_POST['message'])) |
|
| 56 | - $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
| 58 | + if (!isset($_POST['message'])) { |
|
| 59 | + $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
| 60 | + } |
|
| 57 | 61 | |
| 58 | 62 | // prepare any data from the form |
| 59 | 63 | $topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic']; |
@@ -66,8 +70,9 @@ discard block |
||
| 66 | 70 | |
| 67 | 71 | // message and subject still need a bit more work |
| 68 | 72 | preparsecode($draft['body']); |
| 69 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
| 70 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 73 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
| 74 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 75 | + } |
|
| 71 | 76 | |
| 72 | 77 | // Modifying an existing draft, like hitting the save draft button or autosave enabled? |
| 73 | 78 | if (!empty($id_draft) && !empty($draft_info) && $draft_info['id_member'] == $user_info['id']) |
@@ -150,9 +155,9 @@ discard block |
||
| 150 | 155 | { |
| 151 | 156 | $context['draft_saved'] = true; |
| 152 | 157 | $context['id_draft'] = $id_draft; |
| 158 | + } else { |
|
| 159 | + $post_errors[] = 'draft_not_saved'; |
|
| 153 | 160 | } |
| 154 | - else |
|
| 155 | - $post_errors[] = 'draft_not_saved'; |
|
| 156 | 161 | |
| 157 | 162 | // cleanup |
| 158 | 163 | unset($_POST['save_draft']); |
@@ -182,8 +187,9 @@ discard block |
||
| 182 | 187 | global $context, $user_info, $smcFunc, $modSettings; |
| 183 | 188 | |
| 184 | 189 | // PM survey says ... can you stay or must you go |
| 185 | - if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) |
|
| 186 | - return false; |
|
| 190 | + if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) { |
|
| 191 | + return false; |
|
| 192 | + } |
|
| 187 | 193 | |
| 188 | 194 | // read in what you sent us |
| 189 | 195 | $id_pm_draft = (int) $_POST['id_pm_draft']; |
@@ -195,8 +201,9 @@ discard block |
||
| 195 | 201 | $context['draft_saved_on'] = $draft_info['poster_time']; |
| 196 | 202 | |
| 197 | 203 | // Send something back to the javascript caller |
| 198 | - if (!empty($id_draft)) |
|
| 199 | - XmlDraft($id_draft); |
|
| 204 | + if (!empty($id_draft)) { |
|
| 205 | + XmlDraft($id_draft); |
|
| 206 | + } |
|
| 200 | 207 | |
| 201 | 208 | return true; |
| 202 | 209 | } |
@@ -206,9 +213,9 @@ discard block |
||
| 206 | 213 | { |
| 207 | 214 | $recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array(); |
| 208 | 215 | $recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array(); |
| 216 | + } elseif (!empty($draft_info['to_list']) && empty($recipientList)) { |
|
| 217 | + $recipientList = smf_json_decode($draft_info['to_list'], true); |
|
| 209 | 218 | } |
| 210 | - elseif (!empty($draft_info['to_list']) && empty($recipientList)) |
|
| 211 | - $recipientList = smf_json_decode($draft_info['to_list'], true); |
|
| 212 | 219 | |
| 213 | 220 | // prepare the data we got from the form |
| 214 | 221 | $reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to']; |
@@ -217,8 +224,9 @@ discard block |
||
| 217 | 224 | |
| 218 | 225 | // message and subject always need a bit more work |
| 219 | 226 | preparsecode($draft['body']); |
| 220 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
| 221 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 227 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
| 228 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 229 | + } |
|
| 222 | 230 | |
| 223 | 231 | // Modifying an existing PM draft? |
| 224 | 232 | if (!empty($id_pm_draft) && !empty($draft_info) && $draft_info['id_member'] == $user_info['id']) |
@@ -284,9 +292,9 @@ discard block |
||
| 284 | 292 | { |
| 285 | 293 | $context['draft_saved'] = true; |
| 286 | 294 | $context['id_pm_draft'] = $id_pm_draft; |
| 295 | + } else { |
|
| 296 | + $post_errors[] = 'draft_not_saved'; |
|
| 287 | 297 | } |
| 288 | - else |
|
| 289 | - $post_errors[] = 'draft_not_saved'; |
|
| 290 | 298 | } |
| 291 | 299 | |
| 292 | 300 | // if we were called from the autosave function, send something back |
@@ -319,8 +327,9 @@ discard block |
||
| 319 | 327 | $type = (int) $type; |
| 320 | 328 | |
| 321 | 329 | // nothing to read, nothing to do |
| 322 | - if (empty($id_draft)) |
|
| 323 | - return false; |
|
| 330 | + if (empty($id_draft)) { |
|
| 331 | + return false; |
|
| 332 | + } |
|
| 324 | 333 | |
| 325 | 334 | // load in this draft from the DB |
| 326 | 335 | $request = $smcFunc['db_query']('', ' |
@@ -341,8 +350,9 @@ discard block |
||
| 341 | 350 | ); |
| 342 | 351 | |
| 343 | 352 | // no results? |
| 344 | - if (!$smcFunc['db_num_rows']($request)) |
|
| 345 | - return false; |
|
| 353 | + if (!$smcFunc['db_num_rows']($request)) { |
|
| 354 | + return false; |
|
| 355 | + } |
|
| 346 | 356 | |
| 347 | 357 | // load up the data |
| 348 | 358 | $draft_info = $smcFunc['db_fetch_assoc']($request); |
@@ -363,8 +373,7 @@ discard block |
||
| 363 | 373 | $context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
| 364 | 374 | $context['board'] = !empty($draft_info['board_id']) ? $draft_info['id_board'] : ''; |
| 365 | 375 | $context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0; |
| 366 | - } |
|
| 367 | - elseif ($type === 1) |
|
| 376 | + } elseif ($type === 1) |
|
| 368 | 377 | { |
| 369 | 378 | // one of those pm drafts? then set it up like we have an error |
| 370 | 379 | $_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
@@ -400,12 +409,14 @@ discard block |
||
| 400 | 409 | global $user_info, $smcFunc; |
| 401 | 410 | |
| 402 | 411 | // Only a single draft. |
| 403 | - if (is_numeric($id_draft)) |
|
| 404 | - $id_draft = array($id_draft); |
|
| 412 | + if (is_numeric($id_draft)) { |
|
| 413 | + $id_draft = array($id_draft); |
|
| 414 | + } |
|
| 405 | 415 | |
| 406 | 416 | // can't delete nothing |
| 407 | - if (empty($id_draft) || ($check && empty($user_info['id']))) |
|
| 408 | - return false; |
|
| 417 | + if (empty($id_draft) || ($check && empty($user_info['id']))) { |
|
| 418 | + return false; |
|
| 419 | + } |
|
| 409 | 420 | |
| 410 | 421 | $smcFunc['db_query']('', ' |
| 411 | 422 | DELETE FROM {db_prefix}user_drafts |
@@ -434,14 +445,16 @@ discard block |
||
| 434 | 445 | global $smcFunc, $scripturl, $context, $txt, $modSettings; |
| 435 | 446 | |
| 436 | 447 | // Permissions |
| 437 | - if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) |
|
| 438 | - return false; |
|
| 448 | + if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) { |
|
| 449 | + return false; |
|
| 450 | + } |
|
| 439 | 451 | |
| 440 | 452 | $context['drafts'] = array(); |
| 441 | 453 | |
| 442 | 454 | // has a specific draft has been selected? Load it up if there is not a message already in the editor |
| 443 | - if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) |
|
| 444 | - ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
| 455 | + if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) { |
|
| 456 | + ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
| 457 | + } |
|
| 445 | 458 | |
| 446 | 459 | // load the drafts this user has available |
| 447 | 460 | $request = $smcFunc['db_query']('', ' |
@@ -464,23 +477,26 @@ discard block |
||
| 464 | 477 | // add them to the draft array for display |
| 465 | 478 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 466 | 479 | { |
| 467 | - if (empty($row['subject'])) |
|
| 468 | - $row['subject'] = $txt['no_subject']; |
|
| 480 | + if (empty($row['subject'])) { |
|
| 481 | + $row['subject'] = $txt['no_subject']; |
|
| 482 | + } |
|
| 469 | 483 | |
| 470 | 484 | // Post drafts |
| 471 | - if ($draft_type === 0) |
|
| 472 | - $context['drafts'][] = array( |
|
| 485 | + if ($draft_type === 0) { |
|
| 486 | + $context['drafts'][] = array( |
|
| 473 | 487 | 'subject' => censorText(shorten_subject(stripslashes($row['subject']), 24)), |
| 474 | 488 | 'poster_time' => timeformat($row['poster_time']), |
| 475 | 489 | 'link' => '<a href="' . $scripturl . '?action=post;board=' . $row['id_board'] . ';' . (!empty($row['id_topic']) ? 'topic='. $row['id_topic'] .'.0;' : '') . 'id_draft=' . $row['id_draft'] . '">' . $row['subject'] . '</a>', |
| 476 | 490 | ); |
| 491 | + } |
|
| 477 | 492 | // PM drafts |
| 478 | - elseif ($draft_type === 1) |
|
| 479 | - $context['drafts'][] = array( |
|
| 493 | + elseif ($draft_type === 1) { |
|
| 494 | + $context['drafts'][] = array( |
|
| 480 | 495 | 'subject' => censorText(shorten_subject(stripslashes($row['subject']), 24)), |
| 481 | 496 | 'poster_time' => timeformat($row['poster_time']), |
| 482 | 497 | 'link' => '<a href="' . $scripturl . '?action=pm;sa=send;id_draft=' . $row['id_draft'] . '">' . (!empty($row['subject']) ? $row['subject'] : $txt['drafts_none']) . '</a>', |
| 483 | 498 | ); |
| 499 | + } |
|
| 484 | 500 | } |
| 485 | 501 | $smcFunc['db_free_result']($request); |
| 486 | 502 | } |
@@ -544,8 +560,9 @@ discard block |
||
| 544 | 560 | } |
| 545 | 561 | |
| 546 | 562 | // Default to 10. |
| 547 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 548 | - $_REQUEST['viewscount'] = 10; |
|
| 563 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 564 | + $_REQUEST['viewscount'] = 10; |
|
| 565 | + } |
|
| 549 | 566 | |
| 550 | 567 | // Get the count of applicable drafts on the boards they can (still) see ... |
| 551 | 568 | // @todo .. should we just let them see their drafts even if they have lost board access ? |
@@ -610,12 +627,14 @@ discard block |
||
| 610 | 627 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 611 | 628 | { |
| 612 | 629 | // Censor.... |
| 613 | - if (empty($row['body'])) |
|
| 614 | - $row['body'] = ''; |
|
| 630 | + if (empty($row['body'])) { |
|
| 631 | + $row['body'] = ''; |
|
| 632 | + } |
|
| 615 | 633 | |
| 616 | 634 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
| 617 | - if (empty($row['subject'])) |
|
| 618 | - $row['subject'] = $txt['no_subject']; |
|
| 635 | + if (empty($row['subject'])) { |
|
| 636 | + $row['subject'] = $txt['no_subject']; |
|
| 637 | + } |
|
| 619 | 638 | |
| 620 | 639 | censorText($row['body']); |
| 621 | 640 | censorText($row['subject']); |
@@ -647,8 +666,9 @@ discard block |
||
| 647 | 666 | $smcFunc['db_free_result']($request); |
| 648 | 667 | |
| 649 | 668 | // If the drafts were retrieved in reverse order, get them right again. |
| 650 | - if ($reverse) |
|
| 651 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 669 | + if ($reverse) { |
|
| 670 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 671 | + } |
|
| 652 | 672 | |
| 653 | 673 | // Menu tab |
| 654 | 674 | $context[$context['profile_menu_name']]['tab_data'] = array( |
@@ -706,8 +726,9 @@ discard block |
||
| 706 | 726 | } |
| 707 | 727 | |
| 708 | 728 | // Default to 10. |
| 709 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 710 | - $_REQUEST['viewscount'] = 10; |
|
| 729 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 730 | + $_REQUEST['viewscount'] = 10; |
|
| 731 | + } |
|
| 711 | 732 | |
| 712 | 733 | // Get the count of applicable drafts |
| 713 | 734 | $request = $smcFunc['db_query']('', ' |
@@ -766,12 +787,14 @@ discard block |
||
| 766 | 787 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 767 | 788 | { |
| 768 | 789 | // Censor.... |
| 769 | - if (empty($row['body'])) |
|
| 770 | - $row['body'] = ''; |
|
| 790 | + if (empty($row['body'])) { |
|
| 791 | + $row['body'] = ''; |
|
| 792 | + } |
|
| 771 | 793 | |
| 772 | 794 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
| 773 | - if (empty($row['subject'])) |
|
| 774 | - $row['subject'] = $txt['no_subject']; |
|
| 795 | + if (empty($row['subject'])) { |
|
| 796 | + $row['subject'] = $txt['no_subject']; |
|
| 797 | + } |
|
| 775 | 798 | |
| 776 | 799 | censorText($row['body']); |
| 777 | 800 | censorText($row['subject']); |
@@ -826,8 +849,9 @@ discard block |
||
| 826 | 849 | $smcFunc['db_free_result']($request); |
| 827 | 850 | |
| 828 | 851 | // if the drafts were retrieved in reverse order, then put them in the right order again. |
| 829 | - if ($reverse) |
|
| 830 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 852 | + if ($reverse) { |
|
| 853 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 854 | + } |
|
| 831 | 855 | |
| 832 | 856 | // off to the template we go |
| 833 | 857 | $context['page_title'] = $txt['drafts']; |