@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | // If there are no parent boards we can see, avoid showing an empty category (unless its collapsed). |
| 38 | 38 | if (empty($category['boards']) && !$category['is_collapsed']) |
| 39 | - continue; |
|
| 39 | + { |
|
| 40 | + continue; |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // @todo - Invent nifty class name for boardindex header bars. |
| 42 | 44 | echo ' |
@@ -45,8 +47,10 @@ discard block |
||
| 45 | 47 | |
| 46 | 48 | // If this category even can collapse, show a link to collapse it. |
| 47 | 49 | if ($category['can_collapse']) |
| 48 | - echo ' |
|
| 50 | + { |
|
| 51 | + echo ' |
|
| 49 | 52 | <a class="chevricon i-chevron-', $category['is_collapsed'] ? 'down' : 'up', '" href="', $category['collapse_href'], '" title="', $category['is_collapsed'] ? $txt['show'] : $txt['hide'], '"></a>'; |
| 53 | + } |
|
| 50 | 54 | |
| 51 | 55 | // The "category link" is only a link for logged in members. Guests just get the name. |
| 52 | 56 | echo ' |
@@ -56,7 +60,9 @@ discard block |
||
| 56 | 60 | |
| 57 | 61 | // Assuming the category hasn't been collapsed... |
| 58 | 62 | if (!$category['is_collapsed']) |
| 59 | - template_list_boards($category['boards'], 'category_' . $category['id'] . '_boards'); |
|
| 63 | + { |
|
| 64 | + template_list_boards($category['boards'], 'category_' . $category['id'] . '_boards'); |
|
| 65 | + } |
|
| 60 | 66 | |
| 61 | 67 | echo ' |
| 62 | 68 | </section>'; |
@@ -99,12 +105,16 @@ discard block |
||
| 99 | 105 | |
| 100 | 106 | // Show the mark all as read button? |
| 101 | 107 | if ($settings['show_mark_read'] && !$context['user']['is_guest'] && !empty($context['categories'])) |
| 102 | - echo ' |
|
| 108 | + { |
|
| 109 | + echo ' |
|
| 103 | 110 | ', template_button_strip($context['mark_read_button'], 'right'); |
| 111 | + } |
|
| 104 | 112 | |
| 105 | 113 | if ($context['user']['is_logged']) |
| 106 | - echo ' |
|
| 114 | + { |
|
| 115 | + echo ' |
|
| 107 | 116 | <p title="', $txt['new_posts'], '"><i class="icon i-board-new"></i>', $txt['new_posts'], '</p>'; |
| 117 | + } |
|
| 108 | 118 | |
| 109 | 119 | echo ' |
| 110 | 120 | <p title="', $txt['old_posts'], '"><i class="icon i-board-off"></i>', $txt['old_posts'], '</p> |
@@ -252,8 +262,10 @@ discard block |
||
| 252 | 262 | |
| 253 | 263 | // Holidays like "Christmas", "Hanukkah", and "We Love [Unknown] Day" :P. |
| 254 | 264 | if (!empty($context['calendar_holidays'])) |
| 255 | - echo ' |
|
| 265 | + { |
|
| 266 | + echo ' |
|
| 256 | 267 | <p class="inline holiday">', $txt['calendar_prompt'], ' ', implode(', ', $context['calendar_holidays']), '</p>'; |
| 268 | + } |
|
| 257 | 269 | |
| 258 | 270 | // People's birthdays. Like mine. And yours, I guess. Kidding. |
| 259 | 271 | if (!empty($context['calendar_birthdays'])) |
@@ -264,8 +276,10 @@ discard block |
||
| 264 | 276 | |
| 265 | 277 | // Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) |
| 266 | 278 | foreach ($context['calendar_birthdays'] as $member) |
| 267 | - echo ' |
|
| 279 | + { |
|
| 280 | + echo ' |
|
| 268 | 281 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong>' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', '; |
| 282 | + } |
|
| 269 | 283 | |
| 270 | 284 | echo ' |
| 271 | 285 | </p>'; |
@@ -281,8 +295,10 @@ discard block |
||
| 281 | 295 | // Each event in calendar_events should have: |
| 282 | 296 | // title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. |
| 283 | 297 | foreach ($context['calendar_events'] as $event) |
| 284 | - echo ' |
|
| 298 | + { |
|
| 299 | + echo ' |
|
| 285 | 300 | ', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '" class="icon i-modify"></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br />' : ', '; |
| 301 | + } |
|
| 286 | 302 | |
| 287 | 303 | echo ' |
| 288 | 304 | </p>'; |
@@ -328,16 +344,24 @@ discard block |
||
| 328 | 344 | // Handle hidden users and buddies. |
| 329 | 345 | $bracketList = array(); |
| 330 | 346 | if ($context['show_buddies']) |
| 331 | - $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 347 | + { |
|
| 348 | + $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 349 | + } |
|
| 332 | 350 | |
| 333 | 351 | if (!empty($context['num_spiders'])) |
| 334 | - $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 352 | + { |
|
| 353 | + $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 354 | + } |
|
| 335 | 355 | |
| 336 | 356 | if (!empty($context['num_users_hidden'])) |
| 337 | - $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_users_hidden'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
| 357 | + { |
|
| 358 | + $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_users_hidden'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
| 359 | + } |
|
| 338 | 360 | |
| 339 | 361 | if (!empty($bracketList)) |
| 340 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 362 | + { |
|
| 363 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 364 | + } |
|
| 341 | 365 | |
| 342 | 366 | echo $context['show_who'] ? '</a>' : '', ' |
| 343 | 367 | </h3>'; |
@@ -350,8 +374,10 @@ discard block |
||
| 350 | 374 | |
| 351 | 375 | // Showing membergroups? |
| 352 | 376 | if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) |
| 353 | - echo ' |
|
| 377 | + { |
|
| 378 | + echo ' |
|
| 354 | 379 | <p class="inline membergroups">[' . implode(', ', $context['membergroups']) . ']</p>'; |
| 380 | + } |
|
| 355 | 381 | } |
| 356 | 382 | echo ' |
| 357 | 383 | </li>'; |
@@ -97,7 +97,9 @@ discard block |
||
| 97 | 97 | $cache = Cache::instance(); |
| 98 | 98 | |
| 99 | 99 | if (empty($changeArray) || !is_array($changeArray)) |
| 100 | - return; |
|
| 100 | + { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 101 | 103 | |
| 102 | 104 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
| 103 | 105 | if ($update) |
@@ -128,10 +130,14 @@ discard block |
||
| 128 | 130 | { |
| 129 | 131 | // Don't bother if it's already like that ;). |
| 130 | 132 | if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
| 131 | - continue; |
|
| 133 | + { |
|
| 134 | + continue; |
|
| 135 | + } |
|
| 132 | 136 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
| 133 | 137 | elseif (!isset($modSettings[$variable]) && empty($value)) |
| 134 | - continue; |
|
| 138 | + { |
|
| 139 | + continue; |
|
| 140 | + } |
|
| 135 | 141 | |
| 136 | 142 | $replaceArray[] = array($variable, $value); |
| 137 | 143 | |
@@ -139,7 +145,9 @@ discard block |
||
| 139 | 145 | } |
| 140 | 146 | |
| 141 | 147 | if (empty($replaceArray)) |
| 142 | - return; |
|
| 148 | + { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 143 | 151 | |
| 144 | 152 | $db->insert('replace', |
| 145 | 153 | '{db_prefix}settings', |
@@ -164,10 +172,14 @@ discard block |
||
| 164 | 172 | $db = database(); |
| 165 | 173 | |
| 166 | 174 | if (empty($toRemove)) |
| 167 | - return; |
|
| 175 | + { |
|
| 176 | + return; |
|
| 177 | + } |
|
| 168 | 178 | |
| 169 | 179 | if (!is_array($toRemove)) |
| 170 | - $toRemove = array($toRemove); |
|
| 180 | + { |
|
| 181 | + $toRemove = array($toRemove); |
|
| 182 | + } |
|
| 171 | 183 | |
| 172 | 184 | // Remove the setting from the db |
| 173 | 185 | $db->query('', ' |
@@ -180,8 +192,10 @@ discard block |
||
| 180 | 192 | |
| 181 | 193 | // Remove it from $modSettings now so it does not persist |
| 182 | 194 | foreach ($toRemove as $setting) |
| 183 | - if (isset($modSettings[$setting])) |
|
| 195 | + { |
|
| 196 | + if (isset($modSettings[$setting])) |
|
| 184 | 197 | unset($modSettings[$setting]); |
| 198 | + } |
|
| 185 | 199 | |
| 186 | 200 | // Kill the cache - it needs redoing now, but we won't bother ourselves with that here. |
| 187 | 201 | Cache::instance()->remove('modSettings'); |
@@ -228,13 +242,18 @@ discard block |
||
| 228 | 242 | |
| 229 | 243 | // Make sure $start is a proper variable - not less than 0. |
| 230 | 244 | if ($start_invalid) |
| 231 | - $start = 0; |
|
| 245 | + { |
|
| 246 | + $start = 0; |
|
| 247 | + } |
|
| 232 | 248 | // Not greater than the upper bound. |
| 233 | 249 | elseif ($start >= $max_value) |
| 234 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 250 | + { |
|
| 251 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 252 | + } |
|
| 235 | 253 | // And it has to be a multiple of $num_per_page! |
| 236 | - else |
|
| 237 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 254 | + else { |
|
| 255 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 256 | + } |
|
| 238 | 257 | |
| 239 | 258 | $context['current_page'] = $start / $num_per_page; |
| 240 | 259 | |
@@ -249,12 +268,16 @@ discard block |
||
| 249 | 268 | // Show all the pages. |
| 250 | 269 | $display_page = 1; |
| 251 | 270 | for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
| 252 | - $pageindex .= $start == $counter && !$start_invalid && empty($show['all_selected']) ? sprintf($settings['page_index_template']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 271 | + { |
|
| 272 | + $pageindex .= $start == $counter && !$start_invalid && empty($show['all_selected']) ? sprintf($settings['page_index_template']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 273 | + } |
|
| 253 | 274 | |
| 254 | 275 | // Show the right arrow. |
| 255 | 276 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
| 256 | 277 | if ($start != $counter - $max_value && !$start_invalid && $show['prev_next'] && empty($show['all_selected'])) |
| 257 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, str_replace('{next_txt}', $txt['next'], $settings['page_index_template']['next_page'])); |
|
| 278 | + { |
|
| 279 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, str_replace('{next_txt}', $txt['next'], $settings['page_index_template']['next_page'])); |
|
| 280 | + } |
|
| 258 | 281 | } |
| 259 | 282 | else |
| 260 | 283 | { |
@@ -263,61 +286,84 @@ discard block |
||
| 263 | 286 | |
| 264 | 287 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
| 265 | 288 | if (!empty($start) && $show['prev_next']) |
| 266 | - $pageindex = sprintf($base_link, $start - $num_per_page, str_replace('{prev_txt}', $txt['prev'], $settings['page_index_template']['previous_page'])); |
|
| 267 | - else |
|
| 268 | - $pageindex = ''; |
|
| 289 | + { |
|
| 290 | + $pageindex = sprintf($base_link, $start - $num_per_page, str_replace('{prev_txt}', $txt['prev'], $settings['page_index_template']['previous_page'])); |
|
| 291 | + } |
|
| 292 | + else { |
|
| 293 | + $pageindex = ''; |
|
| 294 | + } |
|
| 269 | 295 | |
| 270 | 296 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
| 271 | 297 | if ($start > $num_per_page * $PageContiguous) |
| 272 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
| 298 | + { |
|
| 299 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
| 300 | + } |
|
| 273 | 301 | |
| 274 | 302 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
| 275 | 303 | if ($start > $num_per_page * ($PageContiguous + 1)) |
| 276 | - $pageindex .= str_replace('{custom}', 'data-baseurl="' . htmlspecialchars(JavaScriptEscape(($flexible_start ? $base_url : strtr($base_url, array('%' => '%%')) . ';start=%1$d')), ENT_COMPAT, 'UTF-8') . '" data-perpage="' . $num_per_page . '" data-firstpage="' . $num_per_page . '" data-lastpage="' . ($start - $num_per_page * $PageContiguous) . '"', $settings['page_index_template']['expand_pages']); |
|
| 304 | + { |
|
| 305 | + $pageindex .= str_replace('{custom}', 'data-baseurl="' . htmlspecialchars(JavaScriptEscape(($flexible_start ? $base_url : strtr($base_url, array('%' => '%%')) . ';start=%1$d')), ENT_COMPAT, 'UTF-8') . '" data-perpage="' . $num_per_page . '" data-firstpage="' . $num_per_page . '" data-lastpage="' . ($start - $num_per_page * $PageContiguous) . '"', $settings['page_index_template']['expand_pages']); |
|
| 306 | + } |
|
| 277 | 307 | |
| 278 | 308 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
| 279 | 309 | for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
| 280 | - if ($start >= $num_per_page * $nCont) |
|
| 310 | + { |
|
| 311 | + if ($start >= $num_per_page * $nCont) |
|
| 281 | 312 | { |
| 282 | 313 | $tmpStart = $start - $num_per_page * $nCont; |
| 314 | + } |
|
| 283 | 315 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 284 | 316 | } |
| 285 | 317 | |
| 286 | 318 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
| 287 | 319 | if (!$start_invalid && empty($show['all_selected'])) |
| 288 | - $pageindex .= sprintf($settings['page_index_template']['current_page'], ($start / $num_per_page + 1)); |
|
| 289 | - else |
|
| 290 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 320 | + { |
|
| 321 | + $pageindex .= sprintf($settings['page_index_template']['current_page'], ($start / $num_per_page + 1)); |
|
| 322 | + } |
|
| 323 | + else { |
|
| 324 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 325 | + } |
|
| 291 | 326 | |
| 292 | 327 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
| 293 | 328 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
| 294 | 329 | for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
| 295 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 330 | + { |
|
| 331 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 296 | 332 | { |
| 297 | 333 | $tmpStart = $start + $num_per_page * $nCont; |
| 334 | + } |
|
| 298 | 335 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 299 | 336 | } |
| 300 | 337 | |
| 301 | 338 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
| 302 | 339 | if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
| 303 | - $pageindex .= str_replace('{custom}', 'data-baseurl="' . htmlspecialchars(JavaScriptEscape(($flexible_start ? $base_url : strtr($base_url, array('%' => '%%')) . ';start=%1$d')), ENT_COMPAT, 'UTF-8') . '" data-perpage="' . $num_per_page . '" data-firstpage="' . ($start + $num_per_page * ($PageContiguous + 1)) . '" data-lastpage="' . $tmpMaxPages . '"', $settings['page_index_template']['expand_pages']); |
|
| 340 | + { |
|
| 341 | + $pageindex .= str_replace('{custom}', 'data-baseurl="' . htmlspecialchars(JavaScriptEscape(($flexible_start ? $base_url : strtr($base_url, array('%' => '%%')) . ';start=%1$d')), ENT_COMPAT, 'UTF-8') . '" data-perpage="' . $num_per_page . '" data-firstpage="' . ($start + $num_per_page * ($PageContiguous + 1)) . '" data-lastpage="' . $tmpMaxPages . '"', $settings['page_index_template']['expand_pages']); |
|
| 342 | + } |
|
| 304 | 343 | |
| 305 | 344 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
| 306 | 345 | if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
| 307 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 346 | + { |
|
| 347 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 348 | + } |
|
| 308 | 349 | |
| 309 | 350 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
| 310 | 351 | if ($start != $tmpMaxPages && $show['prev_next'] && empty($show['all_selected'])) |
| 311 | - $pageindex .= sprintf($base_link, $start + $num_per_page, str_replace('{next_txt}', $txt['next'], $settings['page_index_template']['next_page'])); |
|
| 352 | + { |
|
| 353 | + $pageindex .= sprintf($base_link, $start + $num_per_page, str_replace('{next_txt}', $txt['next'], $settings['page_index_template']['next_page'])); |
|
| 354 | + } |
|
| 312 | 355 | } |
| 313 | 356 | |
| 314 | 357 | // The "all" button |
| 315 | 358 | if ($show['all']) |
| 316 | 359 | { |
| 317 | 360 | if (!empty($show['all_selected'])) |
| 318 | - $pageindex .= sprintf($settings['page_index_template']['current_page'], $txt['all']); |
|
| 319 | - else |
|
| 320 | - $pageindex .= sprintf(str_replace('%1$d', '%1$s', $base_link), '0;all', str_replace('{all_txt}', $txt['all'], $settings['page_index_template']['all'])); |
|
| 361 | + { |
|
| 362 | + $pageindex .= sprintf($settings['page_index_template']['current_page'], $txt['all']); |
|
| 363 | + } |
|
| 364 | + else { |
|
| 365 | + $pageindex .= sprintf(str_replace('%1$d', '%1$s', $base_link), '0;all', str_replace('{all_txt}', $txt['all'], $settings['page_index_template']['all'])); |
|
| 366 | + } |
|
| 321 | 367 | } |
| 322 | 368 | |
| 323 | 369 | return $pageindex; |
@@ -347,7 +393,9 @@ discard block |
||
| 347 | 393 | { |
| 348 | 394 | // Not set for whatever reason? |
| 349 | 395 | if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
| 350 | - return $number; |
|
| 396 | + { |
|
| 397 | + return $number; |
|
| 398 | + } |
|
| 351 | 399 | |
| 352 | 400 | // Cache these each load... |
| 353 | 401 | $thousands_separator = $matches[1]; |
@@ -436,16 +484,23 @@ discard block |
||
| 436 | 484 | |
| 437 | 485 | // Offset the time. |
| 438 | 486 | if (!$offset_type) |
| 439 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 487 | + { |
|
| 488 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 489 | + } |
|
| 440 | 490 | // Just the forum offset? |
| 441 | 491 | elseif ($offset_type === 'forum') |
| 442 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 443 | - else |
|
| 444 | - $time = $log_time; |
|
| 492 | + { |
|
| 493 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 494 | + } |
|
| 495 | + else { |
|
| 496 | + $time = $log_time; |
|
| 497 | + } |
|
| 445 | 498 | |
| 446 | 499 | // We can't have a negative date (on Windows, at least.) |
| 447 | 500 | if ($log_time < 0) |
| 448 | - $log_time = 0; |
|
| 501 | + { |
|
| 502 | + $log_time = 0; |
|
| 503 | + } |
|
| 449 | 504 | |
| 450 | 505 | // Today and Yesterday? |
| 451 | 506 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -463,16 +518,21 @@ discard block |
||
| 463 | 518 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
| 464 | 519 | $today_fmt = $h . ':%M' . $s . ' %p'; |
| 465 | 520 | } |
| 466 | - else |
|
| 467 | - $today_fmt = '%H:%M' . $s; |
|
| 521 | + else { |
|
| 522 | + $today_fmt = '%H:%M' . $s; |
|
| 523 | + } |
|
| 468 | 524 | |
| 469 | 525 | // Same day of the year, same year.... Today! |
| 470 | 526 | if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
| 471 | - return sprintf($txt['today'], standardTime($log_time, $today_fmt, $offset_type)); |
|
| 527 | + { |
|
| 528 | + return sprintf($txt['today'], standardTime($log_time, $today_fmt, $offset_type)); |
|
| 529 | + } |
|
| 472 | 530 | |
| 473 | 531 | // Day-of-year is one less and same year, or it's the first of the year and that's the last of the year... |
| 474 | 532 | if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) |
| 475 | - return sprintf($txt['yesterday'], standardTime($log_time, $today_fmt, $offset_type)); |
|
| 533 | + { |
|
| 534 | + return sprintf($txt['yesterday'], standardTime($log_time, $today_fmt, $offset_type)); |
|
| 535 | + } |
|
| 476 | 536 | } |
| 477 | 537 | |
| 478 | 538 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
@@ -480,28 +540,40 @@ discard block |
||
| 480 | 540 | if (setlocale(LC_TIME, $txt['lang_locale'])) |
| 481 | 541 | { |
| 482 | 542 | if (!isset($non_twelve_hour)) |
| 483 | - $non_twelve_hour = trim(Util::strftime('%p')) === ''; |
|
| 543 | + { |
|
| 544 | + $non_twelve_hour = trim(Util::strftime('%p')) === ''; |
|
| 545 | + } |
|
| 484 | 546 | if ($non_twelve_hour && strpos($str, '%p') !== false) |
| 485 | - $str = str_replace('%p', (Util::strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 547 | + { |
|
| 548 | + $str = str_replace('%p', (Util::strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 549 | + } |
|
| 486 | 550 | |
| 487 | 551 | foreach (array('%a', '%A', '%b', '%B') as $token) |
| 488 | - if (strpos($str, $token) !== false) |
|
| 552 | + { |
|
| 553 | + if (strpos($str, $token) !== false) |
|
| 489 | 554 | $str = str_replace($token, !empty($txt['lang_capitalize_dates']) ? Util::ucwords(Util::strftime($token, $time)) : Util::strftime($token, $time), $str); |
| 555 | + } |
|
| 490 | 556 | } |
| 491 | 557 | else |
| 492 | 558 | { |
| 493 | 559 | // Do-it-yourself time localization. Fun. |
| 494 | 560 | foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
| 495 | - if (strpos($str, $token) !== false) |
|
| 561 | + { |
|
| 562 | + if (strpos($str, $token) !== false) |
|
| 496 | 563 | $str = str_replace($token, $txt[$text_label][(int) Util::strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
| 564 | + } |
|
| 497 | 565 | |
| 498 | 566 | if (strpos($str, '%p') !== false) |
| 499 | - $str = str_replace('%p', (Util::strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 567 | + { |
|
| 568 | + $str = str_replace('%p', (Util::strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 569 | + } |
|
| 500 | 570 | } |
| 501 | 571 | |
| 502 | 572 | // Windows doesn't support %e; on some versions, Util::strftime fails altogether if used, so let's prevent that. |
| 503 | 573 | if ($support_e && strpos($str, '%e') !== false) |
| 504 | - $str = str_replace('%e', ltrim(Util::strftime('%d', $time), '0'), $str); |
|
| 574 | + { |
|
| 575 | + $str = str_replace('%e', ltrim(Util::strftime('%d', $time), '0'), $str); |
|
| 576 | + } |
|
| 505 | 577 | |
| 506 | 578 | // Format any other characters.. |
| 507 | 579 | return Util::strftime($str, $time); |
@@ -519,7 +591,9 @@ discard block |
||
| 519 | 591 | global $txt, $context; |
| 520 | 592 | |
| 521 | 593 | if (empty($timestamp)) |
| 522 | - return ''; |
|
| 594 | + { |
|
| 595 | + return ''; |
|
| 596 | + } |
|
| 523 | 597 | |
| 524 | 598 | $forumtime = forum_time(false, $timestamp); |
| 525 | 599 | $timestamp = forum_time(true, $timestamp); |
@@ -547,9 +621,13 @@ discard block |
||
| 547 | 621 | global $user_info, $modSettings; |
| 548 | 622 | |
| 549 | 623 | if ($timestamp === null) |
| 550 | - $timestamp = time(); |
|
| 624 | + { |
|
| 625 | + $timestamp = time(); |
|
| 626 | + } |
|
| 551 | 627 | elseif ($timestamp == 0) |
| 552 | - return 0; |
|
| 628 | + { |
|
| 629 | + return 0; |
|
| 630 | + } |
|
| 553 | 631 | |
| 554 | 632 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
| 555 | 633 | } |
@@ -568,7 +646,9 @@ discard block |
||
| 568 | 646 | function un_htmlspecialchars($string) |
| 569 | 647 | { |
| 570 | 648 | if (empty($string)) |
| 571 | - return $string; |
|
| 649 | + { |
|
| 650 | + return $string; |
|
| 651 | + } |
|
| 572 | 652 | |
| 573 | 653 | $string = htmlspecialchars_decode($string, ENT_QUOTES); |
| 574 | 654 | $string = str_replace(' ', ' ', $string); |
@@ -609,7 +689,9 @@ discard block |
||
| 609 | 689 | $array[$j] = $temp; |
| 610 | 690 | |
| 611 | 691 | for ($i = 1; $p[$i] == 0; $i++) |
| 612 | - $p[$i] = $i; |
|
| 692 | + { |
|
| 693 | + $p[$i] = $i; |
|
| 694 | + } |
|
| 613 | 695 | |
| 614 | 696 | $orders[] = $array; |
| 615 | 697 | } |
@@ -691,7 +773,9 @@ discard block |
||
| 691 | 773 | { |
| 692 | 774 | // Don't waste cycles |
| 693 | 775 | if ($message === '') |
| 694 | - return ''; |
|
| 776 | + { |
|
| 777 | + return ''; |
|
| 778 | + } |
|
| 695 | 779 | |
| 696 | 780 | $parser = \BBC\ParserWrapper::instance(); |
| 697 | 781 | |
@@ -779,29 +863,40 @@ discard block |
||
| 779 | 863 | |
| 780 | 864 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
| 781 | 865 | if (!empty($context['flush_mail'])) |
| 782 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 866 | + { |
|
| 867 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 783 | 868 | AddMailQueue(true); |
| 869 | + } |
|
| 784 | 870 | |
| 785 | 871 | Notifications::instance()->send(); |
| 786 | 872 | |
| 787 | 873 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
| 788 | 874 | |
| 789 | 875 | if ($add) |
| 790 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 876 | + { |
|
| 877 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 878 | + } |
|
| 791 | 879 | |
| 792 | 880 | // Put the session ID in. |
| 793 | 881 | if (empty($_COOKIE) && defined('SID') && SID != '') |
| 794 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 882 | + { |
|
| 883 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 884 | + } |
|
| 795 | 885 | // Keep that debug in their for template debugging! |
| 796 | 886 | elseif (isset($_GET['debug'])) |
| 797 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 887 | + { |
|
| 888 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 889 | + } |
|
| 798 | 890 | |
| 799 | 891 | if (!empty($modSettings['queryless_urls']) && detectServer()->supportRewrite()) |
| 800 | 892 | { |
| 801 | 893 | if (defined('SID') && SID != '') |
| 802 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', 'redirectexit_callback', $setLocation); |
|
| 803 | - else |
|
| 804 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', 'redirectexit_callback', $setLocation); |
|
| 894 | + { |
|
| 895 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', 'redirectexit_callback', $setLocation); |
|
| 896 | + } |
|
| 897 | + else { |
|
| 898 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', 'redirectexit_callback', $setLocation); |
|
| 899 | + } |
|
| 805 | 900 | } |
| 806 | 901 | |
| 807 | 902 | // Maybe integrations want to change where we are heading? |
@@ -809,9 +904,12 @@ discard block |
||
| 809 | 904 | |
| 810 | 905 | // We send a Refresh header only in special cases because Location looks better. (and is quicker...) |
| 811 | 906 | if ($refresh) |
| 812 | - header('Refresh: 0; URL=' . strtr($setLocation, array(' ' => '%20'))); |
|
| 813 | - else |
|
| 814 | - header('Location: ' . str_replace(' ', '%20', $setLocation)); |
|
| 907 | + { |
|
| 908 | + header('Refresh: 0; URL=' . strtr($setLocation, array(' ' => '%20'))); |
|
| 909 | + } |
|
| 910 | + else { |
|
| 911 | + header('Location: ' . str_replace(' ', '%20', $setLocation)); |
|
| 912 | + } |
|
| 815 | 913 | |
| 816 | 914 | // Debugging. |
| 817 | 915 | if ($db_show_debug === true) |
@@ -837,10 +935,13 @@ discard block |
||
| 837 | 935 | global $scripturl; |
| 838 | 936 | |
| 839 | 937 | if (defined('SID') && SID != '') |
| 840 | - return $scripturl . '/' . strtr($matches[1], '&;=', '//,') . '.html?' . SID . (isset($matches[2]) ? $matches[2] : ''); |
|
| 841 | - else |
|
| 842 | - return $scripturl . '/' . strtr($matches[1], '&;=', '//,') . '.html' . (isset($matches[2]) ? $matches[2] : ''); |
|
| 843 | -} |
|
| 938 | + { |
|
| 939 | + return $scripturl . '/' . strtr($matches[1], '&;=', '//,') . '.html?' . SID . (isset($matches[2]) ? $matches[2] : ''); |
|
| 940 | + } |
|
| 941 | + else { |
|
| 942 | + return $scripturl . '/' . strtr($matches[1], '&;=', '//,') . '.html' . (isset($matches[2]) ? $matches[2] : ''); |
|
| 943 | + } |
|
| 944 | + } |
|
| 844 | 945 | |
| 845 | 946 | /** |
| 846 | 947 | * Ends execution. |
@@ -868,10 +969,14 @@ discard block |
||
| 868 | 969 | // Attempt to prevent a recursive loop. |
| 869 | 970 | ++$level; |
| 870 | 971 | if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
| 871 | - exit; |
|
| 972 | + { |
|
| 973 | + exit; |
|
| 974 | + } |
|
| 872 | 975 | |
| 873 | 976 | if ($from_fatal_error) |
| 874 | - $has_fatal_error = true; |
|
| 977 | + { |
|
| 978 | + $has_fatal_error = true; |
|
| 979 | + } |
|
| 875 | 980 | |
| 876 | 981 | // Clear out the stat cache. |
| 877 | 982 | trackStats(); |
@@ -880,19 +985,25 @@ discard block |
||
| 880 | 985 | |
| 881 | 986 | // If we have mail to send, send it. |
| 882 | 987 | if (!empty($context['flush_mail'])) |
| 883 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 988 | + { |
|
| 989 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 884 | 990 | AddMailQueue(true); |
| 991 | + } |
|
| 885 | 992 | |
| 886 | 993 | $do_header = $header === null ? !$header_done : $header; |
| 887 | 994 | if ($do_footer === null) |
| 888 | - $do_footer = $do_header; |
|
| 995 | + { |
|
| 996 | + $do_footer = $do_header; |
|
| 997 | + } |
|
| 889 | 998 | |
| 890 | 999 | // Has the template/header been done yet? |
| 891 | 1000 | if ($do_header) |
| 892 | 1001 | { |
| 893 | 1002 | // Was the page title set last minute? Also update the HTML safe one. |
| 894 | 1003 | if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
| 895 | - $context['page_title_html_safe'] = Util::htmlspecialchars(un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 1004 | + { |
|
| 1005 | + $context['page_title_html_safe'] = Util::htmlspecialchars(un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 1006 | + } |
|
| 896 | 1007 | |
| 897 | 1008 | // Start up the session URL fixer. |
| 898 | 1009 | ob_start('ob_sessrewrite'); |
@@ -940,8 +1051,10 @@ discard block |
||
| 940 | 1051 | |
| 941 | 1052 | // Don't exit if we're coming from index.php; that will pass through normally. |
| 942 | 1053 | if (!$from_index) |
| 943 | - exit; |
|
| 944 | -} |
|
| 1054 | + { |
|
| 1055 | + exit; |
|
| 1056 | + } |
|
| 1057 | + } |
|
| 945 | 1058 | |
| 946 | 1059 | function setOldUrl($index = 'old_url') |
| 947 | 1060 | { |
@@ -978,19 +1091,28 @@ discard block |
||
| 978 | 1091 | { |
| 979 | 1092 | // Set topic class depending on locked status and number of replies. |
| 980 | 1093 | if ($topic_context['is_very_hot']) |
| 981 | - $topic_context['class'] = 'veryhot'; |
|
| 1094 | + { |
|
| 1095 | + $topic_context['class'] = 'veryhot'; |
|
| 1096 | + } |
|
| 982 | 1097 | elseif ($topic_context['is_hot']) |
| 983 | - $topic_context['class'] = 'hot'; |
|
| 984 | - else |
|
| 985 | - $topic_context['class'] = 'normal'; |
|
| 1098 | + { |
|
| 1099 | + $topic_context['class'] = 'hot'; |
|
| 1100 | + } |
|
| 1101 | + else { |
|
| 1102 | + $topic_context['class'] = 'normal'; |
|
| 1103 | + } |
|
| 986 | 1104 | |
| 987 | 1105 | $topic_context['class'] .= !empty($topic_context['is_poll']) ? '_poll' : '_post'; |
| 988 | 1106 | |
| 989 | 1107 | if ($topic_context['is_locked']) |
| 990 | - $topic_context['class'] .= '_locked'; |
|
| 1108 | + { |
|
| 1109 | + $topic_context['class'] .= '_locked'; |
|
| 1110 | + } |
|
| 991 | 1111 | |
| 992 | 1112 | if ($topic_context['is_sticky']) |
| 993 | - $topic_context['class'] .= '_sticky'; |
|
| 1113 | + { |
|
| 1114 | + $topic_context['class'] .= '_sticky'; |
|
| 1115 | + } |
|
| 994 | 1116 | |
| 995 | 1117 | // This is so old themes will still work. |
| 996 | 1118 | // @deprecated since 1.0 do not rely on it |
@@ -1180,16 +1302,24 @@ discard block |
||
| 1180 | 1302 | $ip_array = array(); |
| 1181 | 1303 | |
| 1182 | 1304 | if (count($ip_parts) != 8) |
| 1183 | - return array(); |
|
| 1305 | + { |
|
| 1306 | + return array(); |
|
| 1307 | + } |
|
| 1184 | 1308 | |
| 1185 | 1309 | for ($i = 0; $i < 8; $i++) |
| 1186 | 1310 | { |
| 1187 | 1311 | if ($ip_parts[$i] == '*') |
| 1188 | - $ip_array[$i] = array('low' => '0', 'high' => hexdec('ffff')); |
|
| 1312 | + { |
|
| 1313 | + $ip_array[$i] = array('low' => '0', 'high' => hexdec('ffff')); |
|
| 1314 | + } |
|
| 1189 | 1315 | elseif (preg_match('/^([0-9A-Fa-f]{1,4})\-([0-9A-Fa-f]{1,4})$/', $ip_parts[$i], $range) == 1) |
| 1190 | - $ip_array[$i] = array('low' => hexdec($range[1]), 'high' => hexdec($range[2])); |
|
| 1316 | + { |
|
| 1317 | + $ip_array[$i] = array('low' => hexdec($range[1]), 'high' => hexdec($range[2])); |
|
| 1318 | + } |
|
| 1191 | 1319 | elseif (is_numeric(hexdec($ip_parts[$i]))) |
| 1192 | - $ip_array[$i] = array('low' => hexdec($ip_parts[$i]), 'high' => hexdec($ip_parts[$i])); |
|
| 1320 | + { |
|
| 1321 | + $ip_array[$i] = array('low' => hexdec($ip_parts[$i]), 'high' => hexdec($ip_parts[$i])); |
|
| 1322 | + } |
|
| 1193 | 1323 | } |
| 1194 | 1324 | |
| 1195 | 1325 | return $ip_array; |
@@ -1197,22 +1327,32 @@ discard block |
||
| 1197 | 1327 | |
| 1198 | 1328 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
| 1199 | 1329 | if ($fullip == 'unknown') |
| 1200 | - $fullip = '255.255.255.255'; |
|
| 1330 | + { |
|
| 1331 | + $fullip = '255.255.255.255'; |
|
| 1332 | + } |
|
| 1201 | 1333 | |
| 1202 | 1334 | $ip_parts = explode('.', $fullip); |
| 1203 | 1335 | $ip_array = array(); |
| 1204 | 1336 | |
| 1205 | 1337 | if (count($ip_parts) != 4) |
| 1206 | - return array(); |
|
| 1338 | + { |
|
| 1339 | + return array(); |
|
| 1340 | + } |
|
| 1207 | 1341 | |
| 1208 | 1342 | for ($i = 0; $i < 4; $i++) |
| 1209 | 1343 | { |
| 1210 | 1344 | if ($ip_parts[$i] == '*') |
| 1211 | - $ip_array[$i] = array('low' => '0', 'high' => '255'); |
|
| 1345 | + { |
|
| 1346 | + $ip_array[$i] = array('low' => '0', 'high' => '255'); |
|
| 1347 | + } |
|
| 1212 | 1348 | elseif (preg_match('/^(\d{1,3})\-(\d{1,3})$/', $ip_parts[$i], $range) == 1) |
| 1213 | - $ip_array[$i] = array('low' => $range[1], 'high' => $range[2]); |
|
| 1349 | + { |
|
| 1350 | + $ip_array[$i] = array('low' => $range[1], 'high' => $range[2]); |
|
| 1351 | + } |
|
| 1214 | 1352 | elseif (is_numeric($ip_parts[$i])) |
| 1215 | - $ip_array[$i] = array('low' => $ip_parts[$i], 'high' => $ip_parts[$i]); |
|
| 1353 | + { |
|
| 1354 | + $ip_array[$i] = array('low' => $ip_parts[$i], 'high' => $ip_parts[$i]); |
|
| 1355 | + } |
|
| 1216 | 1356 | } |
| 1217 | 1357 | |
| 1218 | 1358 | // Makes it simpler to work with. |
@@ -1239,7 +1379,9 @@ discard block |
||
| 1239 | 1379 | |
| 1240 | 1380 | $host = ''; |
| 1241 | 1381 | if ($cache->getVar($host, 'hostlookup-' . $ip, 600) || empty($ip)) |
| 1242 | - return $host; |
|
| 1382 | + { |
|
| 1383 | + return $host; |
|
| 1384 | + } |
|
| 1243 | 1385 | |
| 1244 | 1386 | $t = microtime(true); |
| 1245 | 1387 | |
@@ -1294,11 +1436,15 @@ discard block |
||
| 1294 | 1436 | |
| 1295 | 1437 | // This is the last try :/. |
| 1296 | 1438 | if (!isset($host) || $host === false) |
| 1297 | - $host = @gethostbyaddr($ip); |
|
| 1439 | + { |
|
| 1440 | + $host = @gethostbyaddr($ip); |
|
| 1441 | + } |
|
| 1298 | 1442 | |
| 1299 | 1443 | // It took a long time, so let's cache it! |
| 1300 | 1444 | if (microtime(true) - $t > 0.5) |
| 1301 | - $cache->put('hostlookup-' . $ip, $host, 600); |
|
| 1445 | + { |
|
| 1446 | + $cache->put('hostlookup-' . $ip, $host, 600); |
|
| 1447 | + } |
|
| 1302 | 1448 | |
| 1303 | 1449 | return $host; |
| 1304 | 1450 | } |
@@ -1338,7 +1484,9 @@ discard block |
||
| 1338 | 1484 | |
| 1339 | 1485 | // Create an integer representation |
| 1340 | 1486 | for ($i = 0; $i < $max_chars; $i++) |
| 1341 | - $total += $possible_chars[ord($encrypted[$i])] * pow(63, $i); |
|
| 1487 | + { |
|
| 1488 | + $total += $possible_chars[ord($encrypted[$i])] * pow(63, $i); |
|
| 1489 | + } |
|
| 1342 | 1490 | |
| 1343 | 1491 | // Return the value |
| 1344 | 1492 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
@@ -1351,8 +1499,10 @@ discard block |
||
| 1351 | 1499 | // Trim characters before and after and add slashes for database insertion. |
| 1352 | 1500 | $returned_words = array(); |
| 1353 | 1501 | foreach ($words as $word) |
| 1354 | - if (($word = trim($word, '-_\'')) !== '') |
|
| 1502 | + { |
|
| 1503 | + if (($word = trim($word, '-_\'')) !== '') |
|
| 1355 | 1504 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
| 1505 | + } |
|
| 1356 | 1506 | |
| 1357 | 1507 | // Filter out all words that occur more than once. |
| 1358 | 1508 | return array_unique($returned_words); |
@@ -1378,15 +1528,22 @@ discard block |
||
| 1378 | 1528 | |
| 1379 | 1529 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
| 1380 | 1530 | if (function_exists('template_create_button') && !$force_use) |
| 1381 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 1531 | + { |
|
| 1532 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 1533 | + } |
|
| 1382 | 1534 | |
| 1383 | 1535 | if (!$settings['use_image_buttons']) |
| 1384 | - return $txt[$alt]; |
|
| 1536 | + { |
|
| 1537 | + return $txt[$alt]; |
|
| 1538 | + } |
|
| 1385 | 1539 | elseif (!empty($settings['use_buttons'])) |
| 1386 | - return '<img src="' . $settings['images_url'] . '/buttons/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . ' />' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 1387 | - else |
|
| 1388 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . ' />'; |
|
| 1389 | -} |
|
| 1540 | + { |
|
| 1541 | + return '<img src="' . $settings['images_url'] . '/buttons/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . ' />' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 1542 | + } |
|
| 1543 | + else { |
|
| 1544 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . ' />'; |
|
| 1545 | + } |
|
| 1546 | + } |
|
| 1390 | 1547 | |
| 1391 | 1548 | /** |
| 1392 | 1549 | * Sets up all of the top menu buttons |
@@ -1413,8 +1570,10 @@ discard block |
||
| 1413 | 1570 | |
| 1414 | 1571 | // Change the seed. |
| 1415 | 1572 | if (mt_rand(1, 250) == 69 || empty($modSettings['rand_seed'])) |
| 1416 | - updateSettings(array('rand_seed' => mt_rand())); |
|
| 1417 | -} |
|
| 1573 | + { |
|
| 1574 | + updateSettings(array('rand_seed' => mt_rand())); |
|
| 1575 | + } |
|
| 1576 | + } |
|
| 1418 | 1577 | |
| 1419 | 1578 | /** |
| 1420 | 1579 | * Process functions of an integration hook. |
@@ -1500,35 +1659,50 @@ discard block |
||
| 1500 | 1659 | function replaceEntities__callback($matches) |
| 1501 | 1660 | { |
| 1502 | 1661 | if (!isset($matches[2])) |
| 1503 | - return ''; |
|
| 1662 | + { |
|
| 1663 | + return ''; |
|
| 1664 | + } |
|
| 1504 | 1665 | |
| 1505 | 1666 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 1506 | 1667 | |
| 1507 | 1668 | // remove left to right / right to left overrides |
| 1508 | 1669 | if ($num === 0x202D || $num === 0x202E) |
| 1509 | - return ''; |
|
| 1670 | + { |
|
| 1671 | + return ''; |
|
| 1672 | + } |
|
| 1510 | 1673 | |
| 1511 | 1674 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
| 1512 | 1675 | if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
| 1513 | - return '&#' . $num . ';'; |
|
| 1676 | + { |
|
| 1677 | + return '&#' . $num . ';'; |
|
| 1678 | + } |
|
| 1514 | 1679 | |
| 1515 | 1680 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
| 1516 | 1681 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
| 1517 | 1682 | if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
| 1518 | - return ''; |
|
| 1683 | + { |
|
| 1684 | + return ''; |
|
| 1685 | + } |
|
| 1519 | 1686 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 1520 | 1687 | elseif ($num < 0x80) |
| 1521 | - return chr($num); |
|
| 1688 | + { |
|
| 1689 | + return chr($num); |
|
| 1690 | + } |
|
| 1522 | 1691 | // <0x800 (2048) |
| 1523 | 1692 | elseif ($num < 0x800) |
| 1524 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 1693 | + { |
|
| 1694 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 1695 | + } |
|
| 1525 | 1696 | // < 0x10000 (65536) |
| 1526 | 1697 | elseif ($num < 0x10000) |
| 1527 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 1698 | + { |
|
| 1699 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 1700 | + } |
|
| 1528 | 1701 | // <= 0x10FFFF (1114111) |
| 1529 | - else |
|
| 1530 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 1531 | -} |
|
| 1702 | + else { |
|
| 1703 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 1704 | + } |
|
| 1705 | + } |
|
| 1532 | 1706 | |
| 1533 | 1707 | /** |
| 1534 | 1708 | * Converts html entities to utf8 equivalents |
@@ -1546,27 +1720,38 @@ discard block |
||
| 1546 | 1720 | function fixchar__callback($matches) |
| 1547 | 1721 | { |
| 1548 | 1722 | if (!isset($matches[1])) |
| 1549 | - return ''; |
|
| 1723 | + { |
|
| 1724 | + return ''; |
|
| 1725 | + } |
|
| 1550 | 1726 | |
| 1551 | 1727 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
| 1552 | 1728 | |
| 1553 | 1729 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
| 1554 | 1730 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
| 1555 | 1731 | if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
| 1556 | - return ''; |
|
| 1732 | + { |
|
| 1733 | + return ''; |
|
| 1734 | + } |
|
| 1557 | 1735 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 1558 | 1736 | elseif ($num < 0x80) |
| 1559 | - return chr($num); |
|
| 1737 | + { |
|
| 1738 | + return chr($num); |
|
| 1739 | + } |
|
| 1560 | 1740 | // <0x800 (2048) |
| 1561 | 1741 | elseif ($num < 0x800) |
| 1562 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 1742 | + { |
|
| 1743 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 1744 | + } |
|
| 1563 | 1745 | // < 0x10000 (65536) |
| 1564 | 1746 | elseif ($num < 0x10000) |
| 1565 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 1747 | + { |
|
| 1748 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 1749 | + } |
|
| 1566 | 1750 | // <= 0x10FFFF (1114111) |
| 1567 | - else |
|
| 1568 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 1569 | -} |
|
| 1751 | + else { |
|
| 1752 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 1753 | + } |
|
| 1754 | + } |
|
| 1570 | 1755 | |
| 1571 | 1756 | /** |
| 1572 | 1757 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -1583,16 +1768,21 @@ discard block |
||
| 1583 | 1768 | function entity_fix__callback($matches) |
| 1584 | 1769 | { |
| 1585 | 1770 | if (!isset($matches[2])) |
| 1586 | - return ''; |
|
| 1771 | + { |
|
| 1772 | + return ''; |
|
| 1773 | + } |
|
| 1587 | 1774 | |
| 1588 | 1775 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 1589 | 1776 | |
| 1590 | 1777 | // We don't allow control characters, characters out of range, byte markers, etc |
| 1591 | 1778 | if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
| 1592 | - return ''; |
|
| 1593 | - else |
|
| 1594 | - return '&#' . $num . ';'; |
|
| 1595 | -} |
|
| 1779 | + { |
|
| 1780 | + return ''; |
|
| 1781 | + } |
|
| 1782 | + else { |
|
| 1783 | + return '&#' . $num . ';'; |
|
| 1784 | + } |
|
| 1785 | + } |
|
| 1596 | 1786 | |
| 1597 | 1787 | /** |
| 1598 | 1788 | * Retrieve additional search engines, if there are any, as an array. |
@@ -1608,7 +1798,9 @@ discard block |
||
| 1608 | 1798 | { |
| 1609 | 1799 | $search_engines = Util::unserialize($modSettings['additional_search_engines']); |
| 1610 | 1800 | foreach ($search_engines as $engine) |
| 1611 | - $engines[strtolower(preg_replace('~[^A-Za-z0-9 ]~', '', $engine['name']))] = $engine; |
|
| 1801 | + { |
|
| 1802 | + $engines[strtolower(preg_replace('~[^A-Za-z0-9 ]~', '', $engine['name']))] = $engine; |
|
| 1803 | + } |
|
| 1612 | 1804 | } |
| 1613 | 1805 | |
| 1614 | 1806 | return $engines; |
@@ -1634,11 +1826,15 @@ discard block |
||
| 1634 | 1826 | |
| 1635 | 1827 | // Start from the beginning... |
| 1636 | 1828 | if ($reset) |
| 1637 | - return $db->data_seek($messages_request, 0); |
|
| 1829 | + { |
|
| 1830 | + return $db->data_seek($messages_request, 0); |
|
| 1831 | + } |
|
| 1638 | 1832 | |
| 1639 | 1833 | // If the query has already returned false, get out of here |
| 1640 | 1834 | if (empty($messages_request)) |
| 1641 | - return false; |
|
| 1835 | + { |
|
| 1836 | + return false; |
|
| 1837 | + } |
|
| 1642 | 1838 | |
| 1643 | 1839 | // Attempt to get the next message. |
| 1644 | 1840 | $message = $db->fetch_assoc($messages_request); |
@@ -1671,22 +1867,32 @@ discard block |
||
| 1671 | 1867 | { |
| 1672 | 1868 | // Search for key names or values |
| 1673 | 1869 | if ($assoc) |
| 1674 | - $position = array_search($key, array_keys($input), $strict); |
|
| 1675 | - else |
|
| 1676 | - $position = array_search($key, $input, $strict); |
|
| 1870 | + { |
|
| 1871 | + $position = array_search($key, array_keys($input), $strict); |
|
| 1872 | + } |
|
| 1873 | + else { |
|
| 1874 | + $position = array_search($key, $input, $strict); |
|
| 1875 | + } |
|
| 1677 | 1876 | |
| 1678 | 1877 | // If the key is not found, just insert it at the end |
| 1679 | 1878 | if ($position === false) |
| 1680 | - return array_merge($input, $insert); |
|
| 1879 | + { |
|
| 1880 | + return array_merge($input, $insert); |
|
| 1881 | + } |
|
| 1681 | 1882 | |
| 1682 | 1883 | if ($where === 'after') |
| 1683 | - $position++; |
|
| 1884 | + { |
|
| 1885 | + $position++; |
|
| 1886 | + } |
|
| 1684 | 1887 | |
| 1685 | 1888 | // Insert as first |
| 1686 | 1889 | if ($position === 0) |
| 1687 | - $input = array_merge($insert, $input); |
|
| 1688 | - else |
|
| 1689 | - $input = array_merge(array_slice($input, 0, $position), $insert, array_slice($input, $position)); |
|
| 1890 | + { |
|
| 1891 | + $input = array_merge($insert, $input); |
|
| 1892 | + } |
|
| 1893 | + else { |
|
| 1894 | + $input = array_merge(array_slice($input, 0, $position), $insert, array_slice($input, $position)); |
|
| 1895 | + } |
|
| 1690 | 1896 | |
| 1691 | 1897 | return $input; |
| 1692 | 1898 | } |
@@ -1706,9 +1912,12 @@ discard block |
||
| 1706 | 1912 | global $modSettings; |
| 1707 | 1913 | |
| 1708 | 1914 | if (!isset($modSettings['scheduleTaskImmediate'])) |
| 1709 | - $scheduleTaskImmediate = array(); |
|
| 1710 | - else |
|
| 1711 | - $scheduleTaskImmediate = Util::unserialize($modSettings['scheduleTaskImmediate']); |
|
| 1915 | + { |
|
| 1916 | + $scheduleTaskImmediate = array(); |
|
| 1917 | + } |
|
| 1918 | + else { |
|
| 1919 | + $scheduleTaskImmediate = Util::unserialize($modSettings['scheduleTaskImmediate']); |
|
| 1920 | + } |
|
| 1712 | 1921 | |
| 1713 | 1922 | // If it has not been scheduled, the do so now |
| 1714 | 1923 | if (!isset($scheduleTaskImmediate[$task])) |
@@ -1739,9 +1948,12 @@ discard block |
||
| 1739 | 1948 | |
| 1740 | 1949 | // Not on, bail |
| 1741 | 1950 | if (!isset($modSettings['scheduleTaskImmediate'])) |
| 1742 | - return; |
|
| 1743 | - else |
|
| 1744 | - $scheduleTaskImmediate = Util::unserialize($modSettings['scheduleTaskImmediate']); |
|
| 1951 | + { |
|
| 1952 | + return; |
|
| 1953 | + } |
|
| 1954 | + else { |
|
| 1955 | + $scheduleTaskImmediate = Util::unserialize($modSettings['scheduleTaskImmediate']); |
|
| 1956 | + } |
|
| 1745 | 1957 | |
| 1746 | 1958 | // Clear / remove the task if it was set |
| 1747 | 1959 | if (isset($scheduleTaskImmediate[$task])) |
@@ -1845,10 +2057,13 @@ discard block |
||
| 1845 | 2057 | $time = trim(file_get_contents(BOARDDIR . '/db_last_error.txt')); |
| 1846 | 2058 | |
| 1847 | 2059 | if (preg_match('~^\d{10}$~', $time) === 1) |
| 1848 | - return $time; |
|
| 1849 | - else |
|
| 1850 | - return 0; |
|
| 1851 | -} |
|
| 2060 | + { |
|
| 2061 | + return $time; |
|
| 2062 | + } |
|
| 2063 | + else { |
|
| 2064 | + return 0; |
|
| 2065 | + } |
|
| 2066 | + } |
|
| 1852 | 2067 | |
| 1853 | 2068 | /** |
| 1854 | 2069 | * This function has the only task to retrieve the correct prefix to be used |
@@ -1867,7 +2082,9 @@ discard block |
||
| 1867 | 2082 | if ($response_prefix === null && (!$cache->getVar($response_prefix, 'response_prefix') || !$response_prefix)) |
| 1868 | 2083 | { |
| 1869 | 2084 | if ($language === $user_info['language']) |
| 1870 | - $response_prefix = $txt['response_prefix']; |
|
| 2085 | + { |
|
| 2086 | + $response_prefix = $txt['response_prefix']; |
|
| 2087 | + } |
|
| 1871 | 2088 | else |
| 1872 | 2089 | { |
| 1873 | 2090 | loadLanguage('index', $language, false); |
@@ -1895,10 +2112,13 @@ discard block |
||
| 1895 | 2112 | { |
| 1896 | 2113 | $value = trim($value); |
| 1897 | 2114 | if (filter_var($value, FILTER_VALIDATE_EMAIL) && Util::strlen($value) < 255) |
| 1898 | - return $value; |
|
| 1899 | - else |
|
| 1900 | - return false; |
|
| 1901 | -} |
|
| 2115 | + { |
|
| 2116 | + return $value; |
|
| 2117 | + } |
|
| 2118 | + else { |
|
| 2119 | + return false; |
|
| 2120 | + } |
|
| 2121 | + } |
|
| 1902 | 2122 | |
| 1903 | 2123 | /** |
| 1904 | 2124 | * Adds a protocol (http/s, ftp/mailto) to the beginning of an url if missing |
@@ -2042,7 +2262,9 @@ discard block |
||
| 2042 | 2262 | |
| 2043 | 2263 | // Don't know any browser! |
| 2044 | 2264 | if (empty($context['browser'])) |
| 2045 | - detectBrowser(); |
|
| 2265 | + { |
|
| 2266 | + detectBrowser(); |
|
| 2267 | + } |
|
| 2046 | 2268 | |
| 2047 | 2269 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
| 2048 | 2270 | } |
@@ -2114,7 +2336,9 @@ discard block |
||
| 2114 | 2336 | foreach ($button_strip as $key => $value) |
| 2115 | 2337 | { |
| 2116 | 2338 | if (!isset($value['test']) || !empty($context[$value['test']])) |
| 2117 | - return true; |
|
| 2339 | + { |
|
| 2340 | + return true; |
|
| 2341 | + } |
|
| 2118 | 2342 | } |
| 2119 | 2343 | |
| 2120 | 2344 | return false; |
@@ -1918,7 +1918,7 @@ |
||
| 1918 | 1918 | } |
| 1919 | 1919 | else |
| 1920 | 1920 | { |
| 1921 | - $pattern = '~^(' . implode('|', array_map(function ($val) {return preg_quote($val, '~');}, $protocols)) . ')~i'; |
|
| 1921 | + $pattern = '~^(' . implode('|', array_map(function($val) {return preg_quote($val, '~'); }, $protocols)) . ')~i'; |
|
| 1922 | 1922 | } |
| 1923 | 1923 | |
| 1924 | 1924 | $found = false; |
@@ -25,7 +25,8 @@ discard block |
||
| 25 | 25 | # requirements (there can be none), but merely suggestions. |
| 26 | 26 | # |
| 27 | 27 | |
| 28 | -class PasswordHash { |
|
| 28 | +class PasswordHash |
|
| 29 | +{ |
|
| 29 | 30 | var $itoa64; |
| 30 | 31 | var $iteration_count_log2; |
| 31 | 32 | var $portable_hashes; |
@@ -36,7 +37,9 @@ discard block |
||
| 36 | 37 | $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
| 37 | 38 | |
| 38 | 39 | if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31) |
| 39 | - $iteration_count_log2 = 8; |
|
| 40 | + { |
|
| 41 | + $iteration_count_log2 = 8; |
|
| 42 | + } |
|
| 40 | 43 | $this->iteration_count_log2 = $iteration_count_log2; |
| 41 | 44 | |
| 42 | 45 | $this->portable_hashes = $portable_hashes; |
@@ -49,25 +52,30 @@ discard block |
||
| 49 | 52 | $output = ''; |
| 50 | 53 | |
| 51 | 54 | // PHP >= 7 |
| 52 | - if (is_callable('random_bytes')) { |
|
| 55 | + if (is_callable('random_bytes')) |
|
| 56 | + { |
|
| 53 | 57 | $output = random_bytes($count); |
| 54 | 58 | } |
| 55 | 59 | // *nix |
| 56 | 60 | elseif (@is_readable('/dev/urandom') && |
| 57 | - ($fh = @fopen('/dev/urandom', 'rb'))) { |
|
| 61 | + ($fh = @fopen('/dev/urandom', 'rb'))) |
|
| 62 | + { |
|
| 58 | 63 | $output = fread($fh, $count); |
| 59 | 64 | fclose($fh); |
| 60 | 65 | } |
| 61 | 66 | // This is much to slow on windows php < 5.3.4 |
| 62 | 67 | elseif (function_exists('openssl_random_pseudo_bytes') && |
| 63 | - (substr(PHP_OS, 0, 3) !== 'WIN' || version_compare(PHP_VERSION, '5.3.4', '>='))) { |
|
| 68 | + (substr(PHP_OS, 0, 3) !== 'WIN' || version_compare(PHP_VERSION, '5.3.4', '>='))) |
|
| 69 | + { |
|
| 64 | 70 | $output = openssl_random_pseudo_bytes($count); |
| 65 | 71 | } |
| 66 | 72 | |
| 67 | 73 | // Do it ourselves then |
| 68 | - if (strlen($output) < $count) { |
|
| 74 | + if (strlen($output) < $count) |
|
| 75 | + { |
|
| 69 | 76 | $output = ''; |
| 70 | - for ($i = 0; $i < $count; $i += 16) { |
|
| 77 | + for ($i = 0; $i < $count; $i += 16) |
|
| 78 | + { |
|
| 71 | 79 | $this->random_state = |
| 72 | 80 | md5(microtime() . $this->random_state); |
| 73 | 81 | $output .= |
@@ -83,19 +91,28 @@ discard block |
||
| 83 | 91 | { |
| 84 | 92 | $output = ''; |
| 85 | 93 | $i = 0; |
| 86 | - do { |
|
| 94 | + do |
|
| 95 | + { |
|
| 87 | 96 | $value = ord($input[$i++]); |
| 88 | 97 | $output .= $this->itoa64[$value & 0x3f]; |
| 89 | 98 | if ($i < $count) |
| 90 | - $value |= ord($input[$i]) << 8; |
|
| 99 | + { |
|
| 100 | + $value |= ord($input[$i]) << 8; |
|
| 101 | + } |
|
| 91 | 102 | $output .= $this->itoa64[($value >> 6) & 0x3f]; |
| 92 | 103 | if ($i++ >= $count) |
| 93 | - break; |
|
| 104 | + { |
|
| 105 | + break; |
|
| 106 | + } |
|
| 94 | 107 | if ($i < $count) |
| 95 | - $value |= ord($input[$i]) << 16; |
|
| 108 | + { |
|
| 109 | + $value |= ord($input[$i]) << 16; |
|
| 110 | + } |
|
| 96 | 111 | $output .= $this->itoa64[($value >> 12) & 0x3f]; |
| 97 | 112 | if ($i++ >= $count) |
| 98 | - break; |
|
| 113 | + { |
|
| 114 | + break; |
|
| 115 | + } |
|
| 99 | 116 | $output .= $this->itoa64[($value >> 18) & 0x3f]; |
| 100 | 117 | } while ($i < $count); |
| 101 | 118 | |
@@ -116,22 +133,30 @@ discard block |
||
| 116 | 133 | { |
| 117 | 134 | $output = '*0'; |
| 118 | 135 | if (substr($setting, 0, 2) == $output) |
| 119 | - $output = '*1'; |
|
| 136 | + { |
|
| 137 | + $output = '*1'; |
|
| 138 | + } |
|
| 120 | 139 | |
| 121 | 140 | $id = substr($setting, 0, 3); |
| 122 | 141 | # We use "$P$", phpBB3 uses "$H$" for the same thing |
| 123 | 142 | if ($id != '$P$' && $id != '$H$') |
| 124 | - return $output; |
|
| 143 | + { |
|
| 144 | + return $output; |
|
| 145 | + } |
|
| 125 | 146 | |
| 126 | 147 | $count_log2 = strpos($this->itoa64, $setting[3]); |
| 127 | 148 | if ($count_log2 < 7 || $count_log2 > 30) |
| 128 | - return $output; |
|
| 149 | + { |
|
| 150 | + return $output; |
|
| 151 | + } |
|
| 129 | 152 | |
| 130 | 153 | $count = 1 << $count_log2; |
| 131 | 154 | |
| 132 | 155 | $salt = substr($setting, 4, 8); |
| 133 | 156 | if (strlen($salt) != 8) |
| 134 | - return $output; |
|
| 157 | + { |
|
| 158 | + return $output; |
|
| 159 | + } |
|
| 135 | 160 | |
| 136 | 161 | # We're kind of forced to use MD5 here since it's the only |
| 137 | 162 | # cryptographic primitive available in all versions of PHP |
@@ -139,14 +164,19 @@ discard block |
||
| 139 | 164 | # in PHP would result in much worse performance and |
| 140 | 165 | # consequently in lower iteration counts and hashes that are |
| 141 | 166 | # quicker to crack (by non-PHP code). |
| 142 | - if (PHP_VERSION >= '5') { |
|
| 167 | + if (PHP_VERSION >= '5') |
|
| 168 | + { |
|
| 143 | 169 | $hash = md5($salt . $password, TRUE); |
| 144 | - do { |
|
| 170 | + do |
|
| 171 | + { |
|
| 145 | 172 | $hash = md5($hash . $password, TRUE); |
| 146 | 173 | } while (--$count); |
| 147 | - } else { |
|
| 174 | + } |
|
| 175 | + else |
|
| 176 | + { |
|
| 148 | 177 | $hash = pack('H*', md5($salt . $password)); |
| 149 | - do { |
|
| 178 | + do |
|
| 179 | + { |
|
| 150 | 180 | $hash = pack('H*', md5($hash . $password)); |
| 151 | 181 | } while (--$count); |
| 152 | 182 | } |
@@ -193,11 +223,13 @@ discard block |
||
| 193 | 223 | $output .= '$'; |
| 194 | 224 | |
| 195 | 225 | $i = 0; |
| 196 | - do { |
|
| 226 | + do |
|
| 227 | + { |
|
| 197 | 228 | $c1 = ord($input[$i++]); |
| 198 | 229 | $output .= $itoa64[$c1 >> 2]; |
| 199 | 230 | $c1 = ($c1 & 0x03) << 4; |
| 200 | - if ($i >= 16) { |
|
| 231 | + if ($i >= 16) |
|
| 232 | + { |
|
| 201 | 233 | $output .= $itoa64[$c1]; |
| 202 | 234 | break; |
| 203 | 235 | } |
@@ -219,34 +251,48 @@ discard block |
||
| 219 | 251 | public function HashPassword($password) |
| 220 | 252 | { |
| 221 | 253 | if ( strlen( $password ) > 4096 ) |
| 222 | - return '*'; |
|
| 254 | + { |
|
| 255 | + return '*'; |
|
| 256 | + } |
|
| 223 | 257 | |
| 224 | 258 | $random = ''; |
| 225 | 259 | |
| 226 | - if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) { |
|
| 260 | + if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) |
|
| 261 | + { |
|
| 227 | 262 | $random = $this->get_random_bytes(16); |
| 228 | 263 | $hash = |
| 229 | 264 | crypt($password, $this->gensalt_blowfish($random)); |
| 230 | 265 | if (strlen($hash) == 60) |
| 231 | - return $hash; |
|
| 266 | + { |
|
| 267 | + return $hash; |
|
| 268 | + } |
|
| 232 | 269 | } |
| 233 | 270 | |
| 234 | - if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) { |
|
| 271 | + if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) |
|
| 272 | + { |
|
| 235 | 273 | if (strlen($random) < 3) |
| 236 | - $random = $this->get_random_bytes(3); |
|
| 274 | + { |
|
| 275 | + $random = $this->get_random_bytes(3); |
|
| 276 | + } |
|
| 237 | 277 | $hash = |
| 238 | 278 | crypt($password, $this->gensalt_extended($random)); |
| 239 | 279 | if (strlen($hash) == 20) |
| 240 | - return $hash; |
|
| 280 | + { |
|
| 281 | + return $hash; |
|
| 282 | + } |
|
| 241 | 283 | } |
| 242 | 284 | |
| 243 | 285 | if (strlen($random) < 6) |
| 244 | - $random = $this->get_random_bytes(6); |
|
| 286 | + { |
|
| 287 | + $random = $this->get_random_bytes(6); |
|
| 288 | + } |
|
| 245 | 289 | $hash = |
| 246 | 290 | $this->crypt_private($password, |
| 247 | 291 | $this->gensalt_private($random)); |
| 248 | 292 | if (strlen($hash) == 34) |
| 249 | - return $hash; |
|
| 293 | + { |
|
| 294 | + return $hash; |
|
| 295 | + } |
|
| 250 | 296 | |
| 251 | 297 | # Returning '*' on error is safe here, but would _not_ be safe |
| 252 | 298 | # in a crypt(3)-like function used _both_ for generating new |
@@ -257,11 +303,15 @@ discard block |
||
| 257 | 303 | public function CheckPassword($password, $stored_hash) |
| 258 | 304 | { |
| 259 | 305 | if ( strlen( $password ) > 4096 ) |
| 260 | - return false; |
|
| 306 | + { |
|
| 307 | + return false; |
|
| 308 | + } |
|
| 261 | 309 | |
| 262 | 310 | $hash = $this->crypt_private($password, $stored_hash); |
| 263 | 311 | if ($hash[0] == '*') |
| 264 | - $hash = crypt($password, $stored_hash); |
|
| 312 | + { |
|
| 313 | + $hash = crypt($password, $stored_hash); |
|
| 314 | + } |
|
| 265 | 315 | |
| 266 | 316 | return $this->_hash_equals($hash, $stored_hash); |
| 267 | 317 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | $this->portable_hashes = $portable_hashes; |
| 43 | 43 | |
| 44 | - $this->random_state = microtime() . uniqid(rand(), TRUE); |
|
| 44 | + $this->random_state = microtime() . uniqid(rand(), true); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | private function get_random_bytes($count) |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | # consequently in lower iteration counts and hashes that are |
| 141 | 141 | # quicker to crack (by non-PHP code). |
| 142 | 142 | if (PHP_VERSION >= '5') { |
| 143 | - $hash = md5($salt . $password, TRUE); |
|
| 143 | + $hash = md5($salt . $password, true); |
|
| 144 | 144 | do { |
| 145 | - $hash = md5($hash . $password, TRUE); |
|
| 145 | + $hash = md5($hash . $password, true); |
|
| 146 | 146 | } while (--$count); |
| 147 | 147 | } else { |
| 148 | 148 | $hash = pack('H*', md5($salt . $password)); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | var $portable_hashes; |
| 32 | 32 | var $random_state; |
| 33 | 33 | |
| 34 | - public function __construct( $iteration_count_log2, $portable_hashes ) |
|
| 34 | + public function __construct($iteration_count_log2, $portable_hashes) |
|
| 35 | 35 | { |
| 36 | 36 | $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
| 37 | 37 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | public function HashPassword($password) |
| 220 | 220 | { |
| 221 | - if ( strlen( $password ) > 4096 ) |
|
| 221 | + if (strlen($password) > 4096) |
|
| 222 | 222 | return '*'; |
| 223 | 223 | |
| 224 | 224 | $random = ''; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | public function CheckPassword($password, $stored_hash) |
| 258 | 258 | { |
| 259 | - if ( strlen( $password ) > 4096 ) |
|
| 259 | + if (strlen($password) > 4096) |
|
| 260 | 260 | return false; |
| 261 | 261 | |
| 262 | 262 | $hash = $this->crypt_private($password, $stored_hash); |
@@ -154,7 +154,9 @@ discard block |
||
| 154 | 154 | $validator->text_replacements(array('paid_email_to' => $txt['paid_email_to'])); |
| 155 | 155 | |
| 156 | 156 | if ($validator->validate($this->_req->post)) |
| 157 | - $this->_req->post->paid_email_to = $validator->validation_data('paid_email_to'); |
|
| 157 | + { |
|
| 158 | + $this->_req->post->paid_email_to = $validator->validation_data('paid_email_to'); |
|
| 159 | + } |
|
| 158 | 160 | else |
| 159 | 161 | { |
| 160 | 162 | // That's not an email, lets set it back in the form to be fixed and let them know its wrong |
@@ -162,7 +164,9 @@ discard block |
||
| 162 | 164 | $context['error_type'] = 'minor'; |
| 163 | 165 | $context['settings_message'] = array(); |
| 164 | 166 | foreach ($validator->validation_errors() as $id => $error) |
| 165 | - $context['settings_message'][] = $error; |
|
| 167 | + { |
|
| 168 | + $context['settings_message'][] = $error; |
|
| 169 | + } |
|
| 166 | 170 | } |
| 167 | 171 | } |
| 168 | 172 | |
@@ -201,7 +205,9 @@ discard block |
||
| 201 | 205 | // If the currency is set to something different then we need to set it to other for this to work and set it back shortly. |
| 202 | 206 | $modSettings['paid_currency'] = !empty($modSettings['paid_currency_code']) ? $modSettings['paid_currency_code'] : ''; |
| 203 | 207 | if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp'))) |
| 204 | - $modSettings['paid_currency'] = 'other'; |
|
| 208 | + { |
|
| 209 | + $modSettings['paid_currency'] = 'other'; |
|
| 210 | + } |
|
| 205 | 211 | |
| 206 | 212 | // These are all the default settings. |
| 207 | 213 | $config_vars = array( |
@@ -257,7 +263,9 @@ discard block |
||
| 257 | 263 | |
| 258 | 264 | // Not made the settings yet? |
| 259 | 265 | if (empty($modSettings['paid_currency_symbol'])) |
| 260 | - throw new Elk_Exception('paid_not_set_currency', false, array($scripturl . '?action=admin;area=paidsubscribe;sa=settings')); |
|
| 266 | + { |
|
| 267 | + throw new Elk_Exception('paid_not_set_currency', false, array($scripturl . '?action=admin;area=paidsubscribe;sa=settings')); |
|
| 268 | + } |
|
| 261 | 269 | |
| 262 | 270 | // Some basic stuff. |
| 263 | 271 | $context['page_title'] = $txt['paid_subs_view']; |
@@ -460,7 +468,9 @@ discard block |
||
| 460 | 468 | |
| 461 | 469 | // There needs to be something. |
| 462 | 470 | if (empty($this->_req->post->span_value) || empty($this->_req->post->cost)) |
| 463 | - throw new Elk_Exception('paid_no_cost_value'); |
|
| 471 | + { |
|
| 472 | + throw new Elk_Exception('paid_no_cost_value'); |
|
| 473 | + } |
|
| 464 | 474 | } |
| 465 | 475 | // Flexible is harder but more fun ;) |
| 466 | 476 | else |
@@ -475,7 +485,9 @@ discard block |
||
| 475 | 485 | ); |
| 476 | 486 | |
| 477 | 487 | if (empty($this->_req->post->cost_day) && empty($this->_req->post->cost_week) && empty($this->_req->post->cost_month) && empty($this->_req->post->cost_year)) |
| 478 | - throw new Elk_Exception('paid_all_freq_blank'); |
|
| 488 | + { |
|
| 489 | + throw new Elk_Exception('paid_all_freq_blank'); |
|
| 490 | + } |
|
| 479 | 491 | } |
| 480 | 492 | |
| 481 | 493 | $cost = serialize($cost); |
@@ -485,7 +497,9 @@ discard block |
||
| 485 | 497 | if (!empty($this->_req->post->addgroup)) |
| 486 | 498 | { |
| 487 | 499 | foreach ($this->_req->post->addgroup as $id => $dummy) |
| 488 | - $addGroups[] = (int) $id; |
|
| 500 | + { |
|
| 501 | + $addGroups[] = (int) $id; |
|
| 502 | + } |
|
| 489 | 503 | } |
| 490 | 504 | $addGroups = implode(',', $addGroups); |
| 491 | 505 | |
@@ -813,16 +827,22 @@ discard block |
||
| 813 | 827 | |
| 814 | 828 | // If we haven't been passed the subscription ID get it. |
| 815 | 829 | if ($context['log_id'] && !$context['sub_id']) |
| 816 | - $context['sub_id'] = validateSubscriptionID($context['log_id']); |
|
| 830 | + { |
|
| 831 | + $context['sub_id'] = validateSubscriptionID($context['log_id']); |
|
| 832 | + } |
|
| 817 | 833 | |
| 818 | 834 | if (!isset($context['subscriptions'][$context['sub_id']])) |
| 819 | - throw new Elk_Exception('no_access', false); |
|
| 835 | + { |
|
| 836 | + throw new Elk_Exception('no_access', false); |
|
| 837 | + } |
|
| 820 | 838 | |
| 821 | 839 | $context['current_subscription'] = $context['subscriptions'][$context['sub_id']]; |
| 822 | 840 | |
| 823 | 841 | // Searching? |
| 824 | 842 | if (isset($this->_req->post->ssearch)) |
| 825 | - return $this->action_viewsub(); |
|
| 843 | + { |
|
| 844 | + return $this->action_viewsub(); |
|
| 845 | + } |
|
| 826 | 846 | // Saving? |
| 827 | 847 | elseif (isset($this->_req->post->save_sub)) |
| 828 | 848 | { |
@@ -843,14 +863,20 @@ discard block |
||
| 843 | 863 | $member = getMemberByName($this->_req->post->name); |
| 844 | 864 | |
| 845 | 865 | if (empty($member)) |
| 846 | - throw new Elk_Exception('error_member_not_found'); |
|
| 866 | + { |
|
| 867 | + throw new Elk_Exception('error_member_not_found'); |
|
| 868 | + } |
|
| 847 | 869 | |
| 848 | 870 | if (alreadySubscribed($context['sub_id'], $member['id_member'])) |
| 849 | - throw new Elk_Exception('member_already_subscribed'); |
|
| 871 | + { |
|
| 872 | + throw new Elk_Exception('member_already_subscribed'); |
|
| 873 | + } |
|
| 850 | 874 | |
| 851 | 875 | // Actually put the subscription in place. |
| 852 | 876 | if ($status == 1) |
| 853 | - addSubscription($context['sub_id'], $member['id_member'], 0, $starttime, $endtime); |
|
| 877 | + { |
|
| 878 | + addSubscription($context['sub_id'], $member['id_member'], 0, $starttime, $endtime); |
|
| 879 | + } |
|
| 854 | 880 | else |
| 855 | 881 | { |
| 856 | 882 | $details = array( |
@@ -872,10 +898,14 @@ discard block |
||
| 872 | 898 | |
| 873 | 899 | // Pick the right permission stuff depending on what the status is changing from/to. |
| 874 | 900 | if ($subscription_status['old_status'] == 1 && $status != 1) |
| 875 | - removeSubscription($context['sub_id'], $subscription_status['id_member']); |
|
| 901 | + { |
|
| 902 | + removeSubscription($context['sub_id'], $subscription_status['id_member']); |
|
| 903 | + } |
|
| 876 | 904 | |
| 877 | 905 | elseif ($status == 1 && $subscription_status['old_status'] != 1) |
| 878 | - addSubscription($context['sub_id'], $subscription_status['id_member'], 0, $starttime, $endtime); |
|
| 906 | + { |
|
| 907 | + addSubscription($context['sub_id'], $subscription_status['id_member'], 0, $starttime, $endtime); |
|
| 908 | + } |
|
| 879 | 909 | |
| 880 | 910 | else |
| 881 | 911 | { |
@@ -902,12 +932,16 @@ discard block |
||
| 902 | 932 | { |
| 903 | 933 | $toDelete = array(); |
| 904 | 934 | foreach ($this->_req->post->delsub as $id => $dummy) |
| 905 | - $toDelete[] = (int) $id; |
|
| 935 | + { |
|
| 936 | + $toDelete[] = (int) $id; |
|
| 937 | + } |
|
| 906 | 938 | |
| 907 | 939 | $deletes = prepareDeleteSubscriptions($toDelete); |
| 908 | 940 | |
| 909 | 941 | foreach ($deletes as $id_subscribe => $id_member) |
| 910 | - removeSubscription($id_subscribe, $id_member, isset($this->_req->post->delete)); |
|
| 942 | + { |
|
| 943 | + removeSubscription($id_subscribe, $id_member, isset($this->_req->post->delete)); |
|
| 944 | + } |
|
| 911 | 945 | } |
| 912 | 946 | redirectexit('action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id']); |
| 913 | 947 | } |
@@ -946,15 +980,18 @@ discard block |
||
| 946 | 980 | $result = getBasicMemberData((int) $this->_req->query->uid); |
| 947 | 981 | $context['sub']['username'] = $result['real_name']; |
| 948 | 982 | } |
| 949 | - else |
|
| 950 | - $context['sub']['username'] = ''; |
|
| 983 | + else { |
|
| 984 | + $context['sub']['username'] = ''; |
|
| 985 | + } |
|
| 951 | 986 | } |
| 952 | 987 | // Otherwise load the existing info. |
| 953 | 988 | else |
| 954 | 989 | { |
| 955 | 990 | $row = getPendingSubscriptions($context['log_id']); |
| 956 | 991 | if (empty($row)) |
| 957 | - throw new Elk_Exception('no_access', false); |
|
| 992 | + { |
|
| 993 | + throw new Elk_Exception('no_access', false); |
|
| 994 | + } |
|
| 958 | 995 | |
| 959 | 996 | // Any pending payments? |
| 960 | 997 | $context['pending_payments'] = array(); |
@@ -974,9 +1011,11 @@ discard block |
||
| 974 | 1011 | foreach ($costs as $duration => $cost) |
| 975 | 1012 | { |
| 976 | 1013 | if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) |
| 977 | - $context['pending_payments'][$id] = array( |
|
| 1014 | + { |
|
| 1015 | + $context['pending_payments'][$id] = array( |
|
| 978 | 1016 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $cost . '/' . $txt[$duration]), |
| 979 | 1017 | ); |
| 1018 | + } |
|
| 980 | 1019 | } |
| 981 | 1020 | } |
| 982 | 1021 | elseif ($costs['fixed'] == $pending[1]) |
@@ -998,7 +1037,9 @@ discard block |
||
| 998 | 1037 | { |
| 999 | 1038 | // Flexible? |
| 1000 | 1039 | if (isset($this->_req->query->accept)) |
| 1001 | - addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] === 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
| 1040 | + { |
|
| 1041 | + addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] === 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
| 1042 | + } |
|
| 1002 | 1043 | unset($pending_details[$id]); |
| 1003 | 1044 | |
| 1004 | 1045 | $new_details = serialize($pending_details); |
@@ -270,13 +270,13 @@ discard block |
||
| 270 | 270 | 'items_per_page' => 20, |
| 271 | 271 | 'base_href' => $scripturl . '?action=admin;area=paidsubscribe;sa=view', |
| 272 | 272 | 'get_items' => array( |
| 273 | - 'function' => function () { |
|
| 273 | + 'function' => function() { |
|
| 274 | 274 | global $context; |
| 275 | 275 | return $context['subscriptions']; |
| 276 | 276 | }, |
| 277 | 277 | ), |
| 278 | 278 | 'get_count' => array( |
| 279 | - 'function' => function () { |
|
| 279 | + 'function' => function() { |
|
| 280 | 280 | global $context; |
| 281 | 281 | return count($context['subscriptions']); |
| 282 | 282 | }, |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | 'style' => 'width: 30%;', |
| 290 | 290 | ), |
| 291 | 291 | 'data' => array( |
| 292 | - 'function' => function ($rowData) { |
|
| 292 | + 'function' => function($rowData) { |
|
| 293 | 293 | global $scripturl; |
| 294 | 294 | |
| 295 | 295 | return sprintf('<a href="%1$s?action=admin;area=paidsubscribe;sa=viewsub;sid=%2$s">%3$s</a>', $scripturl, $rowData['id'], $rowData['name']); |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | 'value' => $txt['paid_cost'], |
| 302 | 302 | ), |
| 303 | 303 | 'data' => array( |
| 304 | - 'function' => function ($rowData) { |
|
| 304 | + 'function' => function($rowData) { |
|
| 305 | 305 | global $txt; |
| 306 | 306 | |
| 307 | 307 | return $rowData['flexible'] ? '<em>' . $txt['flexible'] . '</em>' : $rowData['cost'] . ' / ' . $rowData['length']; |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | 'value' => $txt['paid_is_active'], |
| 339 | 339 | ), |
| 340 | 340 | 'data' => array( |
| 341 | - 'function' => function ($rowData) { |
|
| 341 | + 'function' => function($rowData) { |
|
| 342 | 342 | global $txt; |
| 343 | 343 | |
| 344 | 344 | return '<span class="' . ($rowData['active'] ? 'success' : 'alert') . '">' . ($rowData['active'] ? $txt['yes'] : $txt['no']) . '</span>'; |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | 'value' => $txt['subscribers'], |
| 351 | 351 | ), |
| 352 | 352 | 'data' => array( |
| 353 | - 'function' => function ($rowData) { |
|
| 353 | + 'function' => function($rowData) { |
|
| 354 | 354 | global $scripturl, $txt; |
| 355 | 355 | |
| 356 | 356 | return '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=viewsub;sid=' . $rowData['id'] . '"><i class="icon i-view" title="' . $txt['view'] . '"></i></a>'; |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | 'value' => $txt['modify'], |
| 364 | 364 | ), |
| 365 | 365 | 'data' => array( |
| 366 | - 'function' => function ($rowData) { |
|
| 366 | + 'function' => function($rowData) { |
|
| 367 | 367 | global $txt, $scripturl; |
| 368 | 368 | |
| 369 | 369 | return '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modify;sid=' . $rowData['id'] . '"><i class="icon i-modify" title="' . $txt['modify'] . '"></i></a>'; |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | 'value' => $txt['remove'] |
| 377 | 377 | ), |
| 378 | 378 | 'data' => array( |
| 379 | - 'function' => function ($rowData) { |
|
| 379 | + 'function' => function($rowData) { |
|
| 380 | 380 | global $txt, $scripturl; |
| 381 | 381 | |
| 382 | 382 | return '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modify;delete;sid=' . $rowData['id'] . '"><i class="icon i-delete" title="' . $txt['delete'] . '"></i></a>'; |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | 'style' => 'width: 20%;', |
| 637 | 637 | ), |
| 638 | 638 | 'data' => array( |
| 639 | - 'function' => function ($rowData) { |
|
| 639 | + 'function' => function($rowData) { |
|
| 640 | 640 | global $txt, $scripturl; |
| 641 | 641 | |
| 642 | 642 | return $rowData['id_member'] == 0 ? $txt['guest'] : '<a href="' . $scripturl . '?action=profile;u=' . $rowData['id_member'] . '">' . $rowData['name'] . '</a>'; |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | 'value' => $txt['edit_subscriber'], |
| 709 | 709 | ), |
| 710 | 710 | 'data' => array( |
| 711 | - 'function' => function ($rowData) { |
|
| 711 | + 'function' => function($rowData) { |
|
| 712 | 712 | global $txt, $scripturl; |
| 713 | 713 | |
| 714 | 714 | return '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $rowData['id'] . '">' . $txt['modify'] . '</a>'; |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | 'class' => 'centertext', |
| 723 | 723 | ), |
| 724 | 724 | 'data' => array( |
| 725 | - 'function' => function ($rowData) { |
|
| 725 | + 'function' => function($rowData) { |
|
| 726 | 726 | return '<input type="checkbox" name="delsub[' . $rowData['id'] . ']" class="input_check" />'; |
| 727 | 727 | }, |
| 728 | 728 | 'class' => 'centertext', |
@@ -168,7 +168,9 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | // Prevent absurd boundaries here - make it a day tops. |
| 170 | 170 | if (isset($this->_req->post->lastActive)) |
| 171 | - $this->_req->post->lastActive = min((int) $this->_req->post->lastActive, 1440); |
|
| 171 | + { |
|
| 172 | + $this->_req->post->lastActive = min((int) $this->_req->post->lastActive, 1440); |
|
| 173 | + } |
|
| 172 | 174 | |
| 173 | 175 | call_integration_hook('integrate_save_basic_settings'); |
| 174 | 176 | |
@@ -420,7 +422,9 @@ discard block |
||
| 420 | 422 | |
| 421 | 423 | // Something like enableModule('mentions', array('post', 'display'); |
| 422 | 424 | foreach ($modules as $key => $val) |
| 423 | - $function($key, $val); |
|
| 425 | + { |
|
| 426 | + $function($key, $val); |
|
| 427 | + } |
|
| 424 | 428 | } |
| 425 | 429 | } |
| 426 | 430 | |
@@ -499,7 +503,9 @@ discard block |
||
| 499 | 503 | |
| 500 | 504 | // Temporarily make each setting a modSetting! |
| 501 | 505 | foreach ($context['signature_settings'] as $key => $value) |
| 502 | - $modSettings['signature_' . $key] = $value; |
|
| 506 | + { |
|
| 507 | + $modSettings['signature_' . $key] = $value; |
|
| 508 | + } |
|
| 503 | 509 | |
| 504 | 510 | // Make sure we check the right tags! |
| 505 | 511 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -514,17 +520,25 @@ discard block |
||
| 514 | 520 | $bbcTags = $codes->getTags(); |
| 515 | 521 | |
| 516 | 522 | if (!isset($this->_req->post->signature_bbc_enabledTags)) |
| 517 | - $this->_req->post->signature_bbc_enabledTags = array(); |
|
| 523 | + { |
|
| 524 | + $this->_req->post->signature_bbc_enabledTags = array(); |
|
| 525 | + } |
|
| 518 | 526 | elseif (!is_array($this->_req->post->signature_bbc_enabledTags)) |
| 519 | - $this->_req->post->signature_bbc_enabledTags = array($this->_req->post->signature_bbc_enabledTags); |
|
| 527 | + { |
|
| 528 | + $this->_req->post->signature_bbc_enabledTags = array($this->_req->post->signature_bbc_enabledTags); |
|
| 529 | + } |
|
| 520 | 530 | |
| 521 | 531 | $sig_limits = array(); |
| 522 | 532 | foreach ($context['signature_settings'] as $key => $value) |
| 523 | 533 | { |
| 524 | 534 | if ($key == 'allow_smileys') |
| 525 | - continue; |
|
| 535 | + { |
|
| 536 | + continue; |
|
| 537 | + } |
|
| 526 | 538 | elseif ($key == 'max_smileys' && empty($this->_req->post->signature_allow_smileys)) |
| 527 | - $sig_limits[] = -1; |
|
| 539 | + { |
|
| 540 | + $sig_limits[] = -1; |
|
| 541 | + } |
|
| 528 | 542 | else |
| 529 | 543 | { |
| 530 | 544 | $current_key = $this->_req->getPost('signature_' . $key, 'intval'); |
@@ -606,7 +620,9 @@ discard block |
||
| 606 | 620 | foreach ($this->_req->post->reg as $value) |
| 607 | 621 | { |
| 608 | 622 | if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
| 609 | - $reg_fields[] = $value; |
|
| 623 | + { |
|
| 624 | + $reg_fields[] = $value; |
|
| 625 | + } |
|
| 610 | 626 | } |
| 611 | 627 | } |
| 612 | 628 | |
@@ -614,7 +630,9 @@ discard block |
||
| 614 | 630 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
| 615 | 631 | |
| 616 | 632 | if (!empty($changes)) |
| 617 | - updateSettings($changes); |
|
| 633 | + { |
|
| 634 | + updateSettings($changes); |
|
| 635 | + } |
|
| 618 | 636 | } |
| 619 | 637 | |
| 620 | 638 | createToken('admin-scp'); |
@@ -874,7 +892,9 @@ discard block |
||
| 874 | 892 | loadLanguage('Errors'); |
| 875 | 893 | |
| 876 | 894 | if (isset($txt['custom_option_' . $this->_req->query->msg])) |
| 877 | - $context['custom_option__error'] = $txt['custom_option_' . $this->_req->query->msg]; |
|
| 895 | + { |
|
| 896 | + $context['custom_option__error'] = $txt['custom_option_' . $this->_req->query->msg]; |
|
| 897 | + } |
|
| 878 | 898 | } |
| 879 | 899 | |
| 880 | 900 | // Load the profile language for section names. |
@@ -928,9 +948,12 @@ discard block |
||
| 928 | 948 | |
| 929 | 949 | // Enable and disable custom fields as required. |
| 930 | 950 | $enabled = array(0); |
| 931 | - if(isset($this->_req->post->cust) && is_array($this->_req->post->cust)) { |
|
| 951 | + if(isset($this->_req->post->cust) && is_array($this->_req->post->cust)) |
|
| 952 | + { |
|
| 932 | 953 | foreach ($this->_req->post->cust as $id) |
| 933 | - $enabled[] = (int) $id; |
|
| 954 | + { |
|
| 955 | + $enabled[] = (int) $id; |
|
| 956 | + } |
|
| 934 | 957 | } |
| 935 | 958 | |
| 936 | 959 | updateRenamedProfileStatus($enabled); |
@@ -943,11 +966,15 @@ discard block |
||
| 943 | 966 | |
| 944 | 967 | // Everyone needs a name - even the (bracket) unknown... |
| 945 | 968 | if (trim($this->_req->post->field_name) == '') |
| 946 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $this->_req->query->fid . ';msg=need_name'); |
|
| 969 | + { |
|
| 970 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $this->_req->query->fid . ';msg=need_name'); |
|
| 971 | + } |
|
| 947 | 972 | |
| 948 | 973 | // Regex you say? Do a very basic test to see if the pattern is valid |
| 949 | 974 | if (!empty($this->_req->post->regex) && @preg_match($this->_req->post->regex, 'dummy') === false) |
| 950 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $this->_req->query->fid . ';msg=regex_error'); |
|
| 975 | + { |
|
| 976 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $this->_req->query->fid . ';msg=regex_error'); |
|
| 977 | + } |
|
| 951 | 978 | |
| 952 | 979 | $this->_req->post->field_name = $this->_req->getPost('field_name', 'Util::htmlspecialchars'); |
| 953 | 980 | $this->_req->post->field_desc = $this->_req->getPost('field_desc', 'Util::htmlspecialchars'); |
@@ -968,7 +995,9 @@ discard block |
||
| 968 | 995 | // Some masking stuff... |
| 969 | 996 | $mask = $this->_req->getPost('mask', 'strval', ''); |
| 970 | 997 | if ($mask == 'regex' && isset($this->_req->post->regex)) |
| 971 | - $mask .= $this->_req->post->regex; |
|
| 998 | + { |
|
| 999 | + $mask .= $this->_req->post->regex; |
|
| 1000 | + } |
|
| 972 | 1001 | |
| 973 | 1002 | $field_length = $this->_req->getPost('max_length', 'intval', 255); |
| 974 | 1003 | $enclose = $this->_req->getPost('enclose', 'strval', ''); |
@@ -998,7 +1027,9 @@ discard block |
||
| 998 | 1027 | |
| 999 | 1028 | // Nada, zip, etc... |
| 1000 | 1029 | if (trim($v) == '') |
| 1001 | - continue; |
|
| 1030 | + { |
|
| 1031 | + continue; |
|
| 1032 | + } |
|
| 1002 | 1033 | |
| 1003 | 1034 | // Otherwise, save it boy. |
| 1004 | 1035 | $field_options .= $v . ','; |
@@ -1014,7 +1045,9 @@ discard block |
||
| 1014 | 1045 | } |
| 1015 | 1046 | |
| 1016 | 1047 | if (isset($_POST['default_select']) && $_POST['default_select'] == 'no_default') |
| 1017 | - $default = 'no_default'; |
|
| 1048 | + { |
|
| 1049 | + $default = 'no_default'; |
|
| 1050 | + } |
|
| 1018 | 1051 | |
| 1019 | 1052 | $field_options = substr($field_options, 0, -1); |
| 1020 | 1053 | } |
@@ -1035,15 +1068,20 @@ discard block |
||
| 1035 | 1068 | |
| 1036 | 1069 | // If there is nothing to the name, then let's start our own - for foreign languages etc. |
| 1037 | 1070 | if (isset($matches[1])) |
| 1038 | - $colname = $initial_colname = 'cust_' . strtolower($matches[1]); |
|
| 1039 | - else |
|
| 1040 | - $colname = $initial_colname = 'cust_' . mt_rand(1, 999999); |
|
| 1071 | + { |
|
| 1072 | + $colname = $initial_colname = 'cust_' . strtolower($matches[1]); |
|
| 1073 | + } |
|
| 1074 | + else { |
|
| 1075 | + $colname = $initial_colname = 'cust_' . mt_rand(1, 999999); |
|
| 1076 | + } |
|
| 1041 | 1077 | |
| 1042 | 1078 | $unique = ensureUniqueProfileField($colname, $initial_colname); |
| 1043 | 1079 | |
| 1044 | 1080 | // Still not a unique column name? Leave it up to the user, then. |
| 1045 | 1081 | if (!$unique) |
| 1046 | - throw new Elk_Exception('custom_option_not_unique'); |
|
| 1082 | + { |
|
| 1083 | + throw new Elk_Exception('custom_option_not_unique'); |
|
| 1084 | + } |
|
| 1047 | 1085 | |
| 1048 | 1086 | // And create a new field |
| 1049 | 1087 | $new_field = array( |
@@ -1091,7 +1129,9 @@ discard block |
||
| 1091 | 1129 | foreach ($context['field']['options'] as $k => $option) |
| 1092 | 1130 | { |
| 1093 | 1131 | if (trim($option) == '') |
| 1094 | - continue; |
|
| 1132 | + { |
|
| 1133 | + continue; |
|
| 1134 | + } |
|
| 1095 | 1135 | |
| 1096 | 1136 | // Still exists? |
| 1097 | 1137 | if (in_array($option, $newOptions)) |
@@ -1106,7 +1146,9 @@ discard block |
||
| 1106 | 1146 | { |
| 1107 | 1147 | // Just been renamed? |
| 1108 | 1148 | if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
| 1109 | - updateRenamedProfileField($k, $newOptions, $context['field']['colname'], $option); |
|
| 1149 | + { |
|
| 1150 | + updateRenamedProfileField($k, $newOptions, $context['field']['colname'], $option); |
|
| 1151 | + } |
|
| 1110 | 1152 | } |
| 1111 | 1153 | } |
| 1112 | 1154 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1139,7 +1181,9 @@ discard block |
||
| 1139 | 1181 | |
| 1140 | 1182 | // Just clean up any old selects - these are a pain! |
| 1141 | 1183 | if (($this->_req->post->field_type == 'select' || $this->_req->post->field_type == 'radio') && !empty($newOptions)) |
| 1142 | - deleteOldProfileFieldSelects($newOptions, $context['field']['colname']); |
|
| 1184 | + { |
|
| 1185 | + deleteOldProfileFieldSelects($newOptions, $context['field']['colname']); |
|
| 1186 | + } |
|
| 1143 | 1187 | } |
| 1144 | 1188 | } |
| 1145 | 1189 | // Deleting? |
@@ -1197,7 +1241,9 @@ discard block |
||
| 1197 | 1241 | foreach ($context['pm_limits'] as $group_id => $group) |
| 1198 | 1242 | { |
| 1199 | 1243 | if (isset($this->_req->post->group[$group_id]) && $this->_req->post->group[$group_id] != $group['max_messages']) |
| 1200 | - updateMembergroupProperties(array('current_group' => $group_id, 'max_messages' => $this->_req->post->group[$group_id])); |
|
| 1244 | + { |
|
| 1245 | + updateMembergroupProperties(array('current_group' => $group_id, 'max_messages' => $this->_req->post->group[$group_id])); |
|
| 1246 | + } |
|
| 1201 | 1247 | } |
| 1202 | 1248 | |
| 1203 | 1249 | call_integration_hook('integrate_save_pmsettings_settings'); |
@@ -1260,12 +1306,16 @@ discard block |
||
| 1260 | 1306 | // Get all the time zones. |
| 1261 | 1307 | $all_zones = timezone_identifiers_list(); |
| 1262 | 1308 | if ($all_zones === false) |
| 1263 | - unset($config_vars['default_timezone']); |
|
| 1309 | + { |
|
| 1310 | + unset($config_vars['default_timezone']); |
|
| 1311 | + } |
|
| 1264 | 1312 | else |
| 1265 | 1313 | { |
| 1266 | 1314 | // Make sure we set the value to the same as the printed value. |
| 1267 | 1315 | foreach ($all_zones as $zone) |
| 1268 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 1316 | + { |
|
| 1317 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 1318 | + } |
|
| 1269 | 1319 | } |
| 1270 | 1320 | |
| 1271 | 1321 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
@@ -1565,7 +1615,9 @@ discard block |
||
| 1565 | 1615 | |
| 1566 | 1616 | // Have we exhausted all the time we allowed? |
| 1567 | 1617 | if (time() - array_sum(explode(' ', $sig_start)) < 3) |
| 1568 | - return; |
|
| 1618 | + { |
|
| 1619 | + return; |
|
| 1620 | + } |
|
| 1569 | 1621 | |
| 1570 | 1622 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $applied_sigs . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1571 | 1623 | $context['page_title'] = $txt['not_done_title']; |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | 'class' => 'centertext', |
| 658 | 658 | ), |
| 659 | 659 | 'data' => array( |
| 660 | - 'function' => function ($rowData) { |
|
| 660 | + 'function' => function($rowData) { |
|
| 661 | 661 | $isChecked = $rowData['disabled'] ? '' : ' checked="checked"'; |
| 662 | 662 | $onClickHandler = $rowData['can_show_register'] ? sprintf('onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
| 663 | 663 | return sprintf('<input type="checkbox" name="active[]" id="active_%1$s" value="%1$s" class="input_check" %2$s %3$s />', $rowData['id'], $isChecked, $onClickHandler); |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | 'class' => 'centertext', |
| 673 | 673 | ), |
| 674 | 674 | 'data' => array( |
| 675 | - 'function' => function ($rowData) { |
|
| 675 | + 'function' => function($rowData) { |
|
| 676 | 676 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked="checked"' : ''; |
| 677 | 677 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled="disabled"'; |
| 678 | 678 | return sprintf('<input type="checkbox" name="reg[]" id="reg_%1$s" value="%1$s" class="input_check" %2$s %3$s />', $rowData['id'], $isChecked, $isDisabled); |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | 'value' => $txt['custom_profile_fieldname'], |
| 735 | 735 | ), |
| 736 | 736 | 'data' => array( |
| 737 | - 'function' => function ($rowData) { |
|
| 737 | + 'function' => function($rowData) { |
|
| 738 | 738 | global $scripturl; |
| 739 | 739 | |
| 740 | 740 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | 'value' => $txt['custom_profile_fieldtype'], |
| 752 | 752 | ), |
| 753 | 753 | 'data' => array( |
| 754 | - 'function' => function ($rowData) { |
|
| 754 | + 'function' => function($rowData) { |
|
| 755 | 755 | global $txt; |
| 756 | 756 | |
| 757 | 757 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | 'class' => 'centertext', |
| 771 | 771 | ), |
| 772 | 772 | 'data' => array( |
| 773 | - 'function' => function ($rowData) { |
|
| 773 | + 'function' => function($rowData) { |
|
| 774 | 774 | $isChecked = $rowData['active'] ? ' checked="checked"' : ''; |
| 775 | 775 | return sprintf('<input type="checkbox" name="cust[]" id="cust_%1$s" value="%1$s" class="input_check"%2$s />', $rowData['id_field'], $isChecked); |
| 776 | 776 | }, |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | 'value' => $txt['custom_profile_placement'], |
| 788 | 788 | ), |
| 789 | 789 | 'data' => array( |
| 790 | - 'function' => function ($rowData) { |
|
| 790 | + 'function' => function($rowData) { |
|
| 791 | 791 | global $txt; |
| 792 | 792 | $placement = 'custom_profile_placement_'; |
| 793 | 793 | |
@@ -939,7 +939,7 @@ discard block |
||
| 939 | 939 | |
| 940 | 940 | // Enable and disable custom fields as required. |
| 941 | 941 | $enabled = array(0); |
| 942 | - if(isset($this->_req->post->cust) && is_array($this->_req->post->cust)) { |
|
| 942 | + if (isset($this->_req->post->cust) && is_array($this->_req->post->cust)) { |
|
| 943 | 943 | foreach ($this->_req->post->cust as $id) |
| 944 | 944 | $enabled[] = (int) $id; |
| 945 | 945 | } |
@@ -147,18 +147,21 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | // Top is special, its the top! |
| 149 | 149 | if ($this->_req->query->move_to === 'top') |
| 150 | - $boardOptions = array( |
|
| 150 | + { |
|
| 151 | + $boardOptions = array( |
|
| 151 | 152 | 'move_to' => $this->_req->query->move_to, |
| 152 | 153 | 'target_category' => (int) $this->_req->query->target_cat, |
| 153 | 154 | 'move_first_child' => true, |
| 154 | 155 | ); |
| 156 | + } |
|
| 155 | 157 | // Moving it after another board |
| 156 | - else |
|
| 157 | - $boardOptions = array( |
|
| 158 | + else { |
|
| 159 | + $boardOptions = array( |
|
| 158 | 160 | 'move_to' => $this->_req->query->move_to, |
| 159 | 161 | 'target_board' => (int) $this->_req->query->target_board, |
| 160 | 162 | 'move_first_child' => true, |
| 161 | 163 | ); |
| 164 | + } |
|
| 162 | 165 | |
| 163 | 166 | // Use modifyBoard to perform the action |
| 164 | 167 | modifyBoard((int) $this->_req->query->src_board, $boardOptions); |
@@ -210,14 +213,17 @@ discard block |
||
| 210 | 213 | foreach ($boardList[$catid] as $boardid) |
| 211 | 214 | { |
| 212 | 215 | if (!isset($context['categories'][$catid]['move_link'])) |
| 213 | - $context['categories'][$catid]['move_link'] = array( |
|
| 216 | + { |
|
| 217 | + $context['categories'][$catid]['move_link'] = array( |
|
| 214 | 218 | 'child_level' => 0, |
| 215 | 219 | 'label' => $txt['mboards_order_before'] . ' \'' . htmlspecialchars($boards[$boardid]['name'], ENT_COMPAT, 'UTF-8') . '\'', |
| 216 | 220 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security, |
| 217 | 221 | ); |
| 222 | + } |
|
| 218 | 223 | |
| 219 | 224 | if (!$context['categories'][$catid]['boards'][$boardid]['move']) |
| 220 | - $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
| 225 | + { |
|
| 226 | + $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
| 221 | 227 | array( |
| 222 | 228 | 'child_level' => $boards[$boardid]['level'], |
| 223 | 229 | 'label' => $txt['mboards_order_after'] . '\'' . htmlspecialchars($boards[$boardid]['name'], ENT_COMPAT, 'UTF-8') . '\'', |
@@ -229,18 +235,25 @@ discard block |
||
| 229 | 235 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=child;' . $security, |
| 230 | 236 | ), |
| 231 | 237 | ); |
| 238 | + } |
|
| 232 | 239 | |
| 233 | 240 | $difference = $boards[$boardid]['level'] - $prev_child_level; |
| 234 | 241 | if ($difference == 1) |
| 235 | - array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
| 242 | + { |
|
| 243 | + array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
| 244 | + } |
|
| 236 | 245 | elseif ($difference < 0) |
| 237 | 246 | { |
| 238 | 247 | if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
| 239 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
| 248 | + { |
|
| 249 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
| 250 | + } |
|
| 240 | 251 | |
| 241 | 252 | for ($i = 0; $i < -$difference; $i++) |
| 242 | - if (($temp = array_pop($stack)) !== null) |
|
| 253 | + { |
|
| 254 | + if (($temp = array_pop($stack)) !== null) |
|
| 243 | 255 | array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp); |
| 256 | + } |
|
| 244 | 257 | } |
| 245 | 258 | |
| 246 | 259 | $prev_board = $boardid; |
@@ -249,16 +262,22 @@ discard block |
||
| 249 | 262 | } |
| 250 | 263 | |
| 251 | 264 | if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
| 252 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
| 265 | + { |
|
| 266 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
| 267 | + } |
|
| 253 | 268 | elseif (!empty($stack)) |
| 254 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
| 269 | + { |
|
| 270 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
| 271 | + } |
|
| 255 | 272 | |
| 256 | 273 | if (empty($boardList[$catid])) |
| 257 | - $context['categories'][$catid]['move_link'] = array( |
|
| 274 | + { |
|
| 275 | + $context['categories'][$catid]['move_link'] = array( |
|
| 258 | 276 | 'child_level' => 0, |
| 259 | 277 | 'label' => $txt['mboards_order_before'] . ' \'' . htmlspecialchars($tree['node']['name'], ENT_COMPAT, 'UTF-8') . '\'', |
| 260 | 278 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
| 261 | 279 | ); |
| 280 | + } |
|
| 262 | 281 | } |
| 263 | 282 | } |
| 264 | 283 | |
@@ -317,7 +336,9 @@ discard block |
||
| 317 | 336 | } |
| 318 | 337 | // Category doesn't exist, man... sorry. |
| 319 | 338 | elseif (!isset($cat_tree[$this->cat])) |
| 320 | - redirectexit('action=admin;area=manageboards'); |
|
| 339 | + { |
|
| 340 | + redirectexit('action=admin;area=manageboards'); |
|
| 341 | + } |
|
| 321 | 342 | else |
| 322 | 343 | { |
| 323 | 344 | $context['category'] = array( |
@@ -330,21 +351,27 @@ discard block |
||
| 330 | 351 | ); |
| 331 | 352 | |
| 332 | 353 | foreach ($boardList[$this->cat] as $child_board) |
| 333 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
| 354 | + { |
|
| 355 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
| 356 | + } |
|
| 334 | 357 | } |
| 335 | 358 | |
| 336 | 359 | $prevCat = 0; |
| 337 | 360 | foreach ($cat_tree as $catid => $tree) |
| 338 | 361 | { |
| 339 | 362 | if ($catid == $this->cat && $prevCat > 0) |
| 340 | - $context['category_order'][$prevCat]['selected'] = true; |
|
| 363 | + { |
|
| 364 | + $context['category_order'][$prevCat]['selected'] = true; |
|
| 365 | + } |
|
| 341 | 366 | elseif ($catid != $this->cat) |
| 342 | - $context['category_order'][$catid] = array( |
|
| 367 | + { |
|
| 368 | + $context['category_order'][$catid] = array( |
|
| 343 | 369 | 'id' => $catid, |
| 344 | 370 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
| 345 | 371 | 'selected' => false, |
| 346 | 372 | 'true_name' => $tree['node']['name'] |
| 347 | 373 | ); |
| 374 | + } |
|
| 348 | 375 | |
| 349 | 376 | $prevCat = $catid; |
| 350 | 377 | } |
@@ -393,7 +420,9 @@ discard block |
||
| 393 | 420 | $catOptions = array(); |
| 394 | 421 | |
| 395 | 422 | if (isset($this->_req->post->cat_order)) |
| 396 | - $catOptions['move_after'] = (int) $this->_req->post->cat_order; |
|
| 423 | + { |
|
| 424 | + $catOptions['move_after'] = (int) $this->_req->post->cat_order; |
|
| 425 | + } |
|
| 397 | 426 | |
| 398 | 427 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
| 399 | 428 | $catOptions['cat_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&$1', $this->_req->post->cat_name); |
@@ -401,9 +430,12 @@ discard block |
||
| 401 | 430 | $catOptions['is_collapsible'] = isset($this->_req->post->collapse); |
| 402 | 431 | |
| 403 | 432 | if (isset($this->_req->post->add)) |
| 404 | - createCategory($catOptions); |
|
| 405 | - else |
|
| 406 | - modifyCategory($this->cat, $catOptions); |
|
| 433 | + { |
|
| 434 | + createCategory($catOptions); |
|
| 435 | + } |
|
| 436 | + else { |
|
| 437 | + modifyCategory($this->cat, $catOptions); |
|
| 438 | + } |
|
| 407 | 439 | } |
| 408 | 440 | // If they want to delete - first give them confirmation. |
| 409 | 441 | elseif (isset($this->_req->post->delete) && !isset($this->_req->post->confirmation) && !isset($this->_req->post->empty)) |
@@ -418,12 +450,15 @@ discard block |
||
| 418 | 450 | if (isset($this->_req->post->delete_action) && $this->_req->post->delete_action == 1) |
| 419 | 451 | { |
| 420 | 452 | if (empty($this->_req->post->cat_to)) |
| 421 | - throw new Elk_Exception('mboards_delete_error'); |
|
| 453 | + { |
|
| 454 | + throw new Elk_Exception('mboards_delete_error'); |
|
| 455 | + } |
|
| 422 | 456 | |
| 423 | 457 | deleteCategories(array($this->cat), (int) $this->_req->post->cat_to); |
| 424 | 458 | } |
| 425 | - else |
|
| 426 | - deleteCategories(array($this->cat)); |
|
| 459 | + else { |
|
| 460 | + deleteCategories(array($this->cat)); |
|
| 461 | + } |
|
| 427 | 462 | } |
| 428 | 463 | |
| 429 | 464 | redirectexit('action=admin;area=manageboards'); |
@@ -470,7 +505,9 @@ discard block |
||
| 470 | 505 | |
| 471 | 506 | // Category doesn't exist, man... sorry. |
| 472 | 507 | if (empty($this->cat)) |
| 473 | - redirectexit('action=admin;area=manageboards'); |
|
| 508 | + { |
|
| 509 | + redirectexit('action=admin;area=manageboards'); |
|
| 510 | + } |
|
| 474 | 511 | |
| 475 | 512 | // Some things that need to be setup for a new board. |
| 476 | 513 | $curBoard = array( |
@@ -534,7 +571,9 @@ discard block |
||
| 534 | 571 | |
| 535 | 572 | // Category doesn't exist, man... sorry. |
| 536 | 573 | if (!isset($boardList[$curBoard['category']])) |
| 537 | - redirectexit('action=admin;area=manageboards'); |
|
| 574 | + { |
|
| 575 | + redirectexit('action=admin;area=manageboards'); |
|
| 576 | + } |
|
| 538 | 577 | |
| 539 | 578 | foreach ($boardList[$curBoard['category']] as $boardid) |
| 540 | 579 | { |
@@ -566,24 +605,30 @@ discard block |
||
| 566 | 605 | $context['can_move_children'] = false; |
| 567 | 606 | $context['children'] = $boards[$this->boardid]['tree']['children']; |
| 568 | 607 | foreach ($context['board_order'] as $board) |
| 569 | - if ($board['is_child'] === false && $board['selected'] === false) |
|
| 608 | + { |
|
| 609 | + if ($board['is_child'] === false && $board['selected'] === false) |
|
| 570 | 610 | $context['can_move_children'] = true; |
| 611 | + } |
|
| 571 | 612 | } |
| 572 | 613 | |
| 573 | 614 | // Get other available categories. |
| 574 | 615 | $context['categories'] = array(); |
| 575 | 616 | foreach ($cat_tree as $catID => $tree) |
| 576 | - $context['categories'][] = array( |
|
| 617 | + { |
|
| 618 | + $context['categories'][] = array( |
|
| 577 | 619 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
| 578 | 620 | 'name' => $tree['node']['name'], |
| 579 | 621 | 'selected' => $catID == $curBoard['category'] |
| 580 | 622 | ); |
| 623 | + } |
|
| 581 | 624 | |
| 582 | 625 | $context['board']['moderators'] = getBoardModerators($this->boardid); |
| 583 | 626 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
| 584 | 627 | |
| 585 | 628 | if (!empty($context['board']['moderators'])) |
| 586 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
| 629 | + { |
|
| 630 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
| 631 | + } |
|
| 587 | 632 | |
| 588 | 633 | $context['themes'] = getAllThemes(); |
| 589 | 634 | |
@@ -646,7 +691,9 @@ discard block |
||
| 646 | 691 | elseif (!empty($this->_req->post->placement) && !empty($this->_req->post->board_order)) |
| 647 | 692 | { |
| 648 | 693 | if (!in_array($this->_req->post->placement, array('before', 'after', 'child'))) |
| 649 | - throw new Elk_Exception('mangled_post', false); |
|
| 694 | + { |
|
| 695 | + throw new Elk_Exception('mangled_post', false); |
|
| 696 | + } |
|
| 650 | 697 | |
| 651 | 698 | $boardOptions['move_to'] = $this->_req->post->placement; |
| 652 | 699 | $boardOptions['target_board'] = (int) $this->_req->post->board_order; |
@@ -664,14 +711,20 @@ discard block |
||
| 664 | 711 | foreach ($this->_req->post->groups as $group => $action) |
| 665 | 712 | { |
| 666 | 713 | if ($action == 'allow') |
| 667 | - $boardOptions['access_groups'][] = (int) $group; |
|
| 714 | + { |
|
| 715 | + $boardOptions['access_groups'][] = (int) $group; |
|
| 716 | + } |
|
| 668 | 717 | elseif ($action == 'deny') |
| 669 | - $boardOptions['deny_groups'][] = (int) $group; |
|
| 718 | + { |
|
| 719 | + $boardOptions['deny_groups'][] = (int) $group; |
|
| 720 | + } |
|
| 670 | 721 | } |
| 671 | 722 | } |
| 672 | 723 | |
| 673 | 724 | if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
| 674 | - throw new Elk_Exception('too_many_groups', false); |
|
| 725 | + { |
|
| 726 | + throw new Elk_Exception('too_many_groups', false); |
|
| 727 | + } |
|
| 675 | 728 | |
| 676 | 729 | // Change '1 & 2' to '1 & 2', but not '&' to '&amp;'... |
| 677 | 730 | $boardOptions['board_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&$1', $this->_req->post->board_name); |
@@ -685,7 +738,9 @@ discard block |
||
| 685 | 738 | { |
| 686 | 739 | $moderators = array(); |
| 687 | 740 | foreach ($this->_req->post->moderator_list as $moderator) |
| 688 | - $moderators[(int) $moderator] = (int) $moderator; |
|
| 741 | + { |
|
| 742 | + $moderators[(int) $moderator] = (int) $moderator; |
|
| 743 | + } |
|
| 689 | 744 | |
| 690 | 745 | $boardOptions['moderators'] = $moderators; |
| 691 | 746 | } |
@@ -704,13 +759,19 @@ discard block |
||
| 704 | 759 | |
| 705 | 760 | // If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board. |
| 706 | 761 | if ($boardOptions['redirect'] && empty($properties['oldRedirect']) && $properties['numPosts']) |
| 707 | - unset($boardOptions['redirect']); |
|
| 762 | + { |
|
| 763 | + unset($boardOptions['redirect']); |
|
| 764 | + } |
|
| 708 | 765 | // Reset the redirection count when switching on/off. |
| 709 | 766 | elseif (empty($boardOptions['redirect']) != empty($properties['oldRedirect'])) |
| 710 | - $boardOptions['num_posts'] = 0; |
|
| 767 | + { |
|
| 768 | + $boardOptions['num_posts'] = 0; |
|
| 769 | + } |
|
| 711 | 770 | // Resetting the count? |
| 712 | 771 | elseif ($boardOptions['redirect'] && !empty($this->_req->post->reset_redirect)) |
| 713 | - $boardOptions['num_posts'] = 0; |
|
| 772 | + { |
|
| 773 | + $boardOptions['num_posts'] = 0; |
|
| 774 | + } |
|
| 714 | 775 | } |
| 715 | 776 | |
| 716 | 777 | call_integration_hook('integrate_save_board', array($board_id, &$boardOptions)); |
@@ -720,22 +781,29 @@ discard block |
||
| 720 | 781 | { |
| 721 | 782 | // New boards by default go to the bottom of the category. |
| 722 | 783 | if (empty($this->_req->post->new_cat)) |
| 723 | - $boardOptions['target_category'] = (int) $this->_req->post->cur_cat; |
|
| 784 | + { |
|
| 785 | + $boardOptions['target_category'] = (int) $this->_req->post->cur_cat; |
|
| 786 | + } |
|
| 724 | 787 | if (!isset($boardOptions['move_to'])) |
| 725 | - $boardOptions['move_to'] = 'bottom'; |
|
| 788 | + { |
|
| 789 | + $boardOptions['move_to'] = 'bottom'; |
|
| 790 | + } |
|
| 726 | 791 | |
| 727 | 792 | createBoard($boardOptions); |
| 728 | 793 | } |
| 729 | 794 | // ...or update an existing board. |
| 730 | - else |
|
| 731 | - modifyBoard($board_id, $boardOptions); |
|
| 795 | + else { |
|
| 796 | + modifyBoard($board_id, $boardOptions); |
|
| 797 | + } |
|
| 732 | 798 | } |
| 733 | 799 | elseif (isset($this->_req->post->delete) && !isset($this->_req->post->confirmation) && !isset($this->_req->post->no_children)) |
| 734 | 800 | { |
| 735 | - if ($posts) { |
|
| 801 | + if ($posts) |
|
| 802 | + { |
|
| 736 | 803 | throw new Elk_Exception('mboards_delete_board_has_posts'); |
| 737 | 804 | } |
| 738 | - else { |
|
| 805 | + else |
|
| 806 | + { |
|
| 739 | 807 | $this->action_board(); |
| 740 | 808 | } |
| 741 | 809 | return; |
@@ -743,25 +811,32 @@ discard block |
||
| 743 | 811 | elseif (isset($this->_req->post->delete)) |
| 744 | 812 | { |
| 745 | 813 | // First, check if our board still has posts or topics. |
| 746 | - if ($posts) { |
|
| 814 | + if ($posts) |
|
| 815 | + { |
|
| 747 | 816 | throw new Elk_Exception('mboards_delete_board_has_posts'); |
| 748 | 817 | } |
| 749 | 818 | else if (isset($this->_req->post->delete_action) && $this->_req->post->delete_action == 1) |
| 750 | 819 | { |
| 751 | 820 | // Check if we are moving all the current sub-boards first - before we start deleting! |
| 752 | 821 | if (empty($this->_req->post->board_to)) |
| 753 | - throw new Elk_Exception('mboards_delete_board_error'); |
|
| 822 | + { |
|
| 823 | + throw new Elk_Exception('mboards_delete_board_error'); |
|
| 824 | + } |
|
| 754 | 825 | |
| 755 | 826 | deleteBoards(array($board_id), (int) $this->_req->post->board_to); |
| 756 | 827 | } |
| 757 | - else |
|
| 758 | - deleteBoards(array($board_id), 0); |
|
| 828 | + else { |
|
| 829 | + deleteBoards(array($board_id), 0); |
|
| 830 | + } |
|
| 759 | 831 | } |
| 760 | 832 | |
| 761 | 833 | if (isset($this->_req->query->rid) && $this->_req->query->rid == 'permissions') |
| 762 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 763 | - else |
|
| 764 | - redirectexit('action=admin;area=manageboards'); |
|
| 834 | + { |
|
| 835 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 836 | + } |
|
| 837 | + else { |
|
| 838 | + redirectexit('action=admin;area=manageboards'); |
|
| 839 | + } |
|
| 765 | 840 | } |
| 766 | 841 | |
| 767 | 842 | /** |
@@ -826,7 +901,9 @@ discard block |
||
| 826 | 901 | $boards = getBoardList(array('override_permissions' => true, 'not_redirection' => true), true); |
| 827 | 902 | $recycle_boards = array(''); |
| 828 | 903 | foreach ($boards as $board) |
| 829 | - $recycle_boards[$board['id_board']] = $board['cat_name'] . ' - ' . $board['board_name']; |
|
| 904 | + { |
|
| 905 | + $recycle_boards[$board['id_board']] = $board['cat_name'] . ' - ' . $board['board_name']; |
|
| 906 | + } |
|
| 830 | 907 | |
| 831 | 908 | // Here and the board settings... |
| 832 | 909 | $config_vars = array( |
@@ -242,14 +242,19 @@ discard block |
||
| 242 | 242 | $this->_req->post->holiday = $this->_req->getPost('holiday', 'intval', 0); |
| 243 | 243 | |
| 244 | 244 | if (isset($this->_req->post->delete)) |
| 245 | - removeHolidays($this->_req->post->holiday); |
|
| 245 | + { |
|
| 246 | + removeHolidays($this->_req->post->holiday); |
|
| 247 | + } |
|
| 246 | 248 | else |
| 247 | 249 | { |
| 248 | 250 | $date = Util::strftime($this->_req->post->year <= 4 ? '0004-%m-%d' : '%Y-%m-%d', mktime(0, 0, 0, $this->_req->post->month, $this->_req->post->day, $this->_req->post->year)); |
| 249 | 251 | if (isset($this->_req->post->edit)) |
| 250 | - editHoliday($this->_req->post->holiday, $date, $this->_req->post->title); |
|
| 251 | - else |
|
| 252 | - insertHoliday($date, $this->_req->post->title); |
|
| 252 | + { |
|
| 253 | + editHoliday($this->_req->post->holiday, $date, $this->_req->post->title); |
|
| 254 | + } |
|
| 255 | + else { |
|
| 256 | + insertHoliday($date, $this->_req->post->title); |
|
| 257 | + } |
|
| 253 | 258 | } |
| 254 | 259 | |
| 255 | 260 | redirectexit('action=admin;area=managecalendar;sa=holidays'); |
@@ -267,8 +272,9 @@ discard block |
||
| 267 | 272 | ); |
| 268 | 273 | } |
| 269 | 274 | // If it's not new load the data. |
| 270 | - else |
|
| 271 | - $context['holiday'] = getHoliday($this->_req->query->holiday); |
|
| 275 | + else { |
|
| 276 | + $context['holiday'] = getHoliday($this->_req->query->holiday); |
|
| 277 | + } |
|
| 272 | 278 | |
| 273 | 279 | // Last day for the drop down? |
| 274 | 280 | $context['holiday']['last_day'] = (int) Util::strftime('%d', mktime(0, 0, 0, $context['holiday']['month'] == 12 ? 1 : $context['holiday']['month'] + 1, 0, $context['holiday']['month'] == 12 ? $context['holiday']['year'] + 1 : $context['holiday']['year'])); |
@@ -337,7 +343,9 @@ discard block |
||
| 337 | 343 | $boards_list = getBoardList(array('override_permissions' => true, 'not_redirection' => true), true); |
| 338 | 344 | $boards = array(''); |
| 339 | 345 | foreach ($boards_list as $board) |
| 340 | - $boards[$board['id_board']] = $board['cat_name'] . ' - ' . $board['board_name']; |
|
| 346 | + { |
|
| 347 | + $boards[$board['id_board']] = $board['cat_name'] . ' - ' . $board['board_name']; |
|
| 348 | + } |
|
| 341 | 349 | |
| 342 | 350 | // Look, all the calendar settings - of which there are many! |
| 343 | 351 | $config_vars = array( |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | 'settings' => array( |
| 43 | 43 | 'cal_enabled' => 1, |
| 44 | 44 | ), |
| 45 | - 'setting_callback' => function ($value) { |
|
| 45 | + 'setting_callback' => function($value) { |
|
| 46 | 46 | if ($value) |
| 47 | 47 | { |
| 48 | 48 | enableModules('calendar', array('admin', 'post', 'boardindex', 'display')); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | 'value' => $txt['date'], |
| 165 | 165 | ), |
| 166 | 166 | 'data' => array( |
| 167 | - 'function' => function ($rowData) { |
|
| 167 | + 'function' => function($rowData) { |
|
| 168 | 168 | global $txt; |
| 169 | 169 | |
| 170 | 170 | // Recurring every year or just a single year? |
@@ -113,7 +113,9 @@ discard block |
||
| 113 | 113 | $context['package_download_broken'] = !is_writable(BOARDDIR . '/packages') || !is_writable(BOARDDIR . '/packages/installed.list'); |
| 114 | 114 | |
| 115 | 115 | if ($context['package_download_broken']) |
| 116 | - $this->ftp_connect(); |
|
| 116 | + { |
|
| 117 | + $this->ftp_connect(); |
|
| 118 | + } |
|
| 117 | 119 | } |
| 118 | 120 | |
| 119 | 121 | /** |
@@ -130,11 +132,14 @@ discard block |
||
| 130 | 132 | |
| 131 | 133 | // Browsing the packages from a server |
| 132 | 134 | if (isset($this->_req->query->server)) |
| 133 | - list($name, $url, $server) = $this->_package_server(); |
|
| 135 | + { |
|
| 136 | + list($name, $url, $server) = $this->_package_server(); |
|
| 137 | + } |
|
| 134 | 138 | |
| 135 | 139 | // Minimum required parameter did not exist so dump out. |
| 136 | - else |
|
| 137 | - throw new Elk_Exception('couldnt_connect', false); |
|
| 140 | + else { |
|
| 141 | + throw new Elk_Exception('couldnt_connect', false); |
|
| 142 | + } |
|
| 138 | 143 | |
| 139 | 144 | // Might take some time. |
| 140 | 145 | detectServer()->setTimeLimit(60); |
@@ -159,11 +164,15 @@ discard block |
||
| 159 | 164 | // Look through the list of installed mods and get version information for the compare |
| 160 | 165 | $installed_adds = array(); |
| 161 | 166 | foreach ($instadds as $installed_add) |
| 162 | - $installed_adds[$installed_add['package_id']] = $installed_add['version']; |
|
| 167 | + { |
|
| 168 | + $installed_adds[$installed_add['package_id']] = $installed_add['version']; |
|
| 169 | + } |
|
| 163 | 170 | |
| 164 | 171 | $the_version = strtr(FORUM_VERSION, array('ElkArte ' => '')); |
| 165 | 172 | if (!empty($_SESSION['version_emulate'])) |
| 166 | - $the_version = $_SESSION['version_emulate']; |
|
| 173 | + { |
|
| 174 | + $the_version = $_SESSION['version_emulate']; |
|
| 175 | + } |
|
| 167 | 176 | |
| 168 | 177 | // Parse the json file, each section contains a category of addons |
| 169 | 178 | $packageNum = 0; |
@@ -352,12 +361,15 @@ discard block |
||
| 352 | 361 | // not always accurate, especially when dealing with repos. So for now just put in in no conflict mode |
| 353 | 362 | // and do the save. |
| 354 | 363 | if ($this->_req->getQuery('area') === 'packageservers' && $this->_req->getQuery('sa') === 'download') |
| 355 | - $this->_req->query->auto = true; |
|
| 364 | + { |
|
| 365 | + $this->_req->query->auto = true; |
|
| 366 | + } |
|
| 356 | 367 | |
| 357 | 368 | return str_replace($invalid, '_', $newname) . $matches[6]; |
| 358 | 369 | } |
| 359 | - else |
|
| 360 | - return basename($name); |
|
| 370 | + else { |
|
| 371 | + return basename($name); |
|
| 372 | + } |
|
| 361 | 373 | } |
| 362 | 374 | |
| 363 | 375 | /** |
@@ -384,13 +396,18 @@ discard block |
||
| 384 | 396 | |
| 385 | 397 | // Security is good... |
| 386 | 398 | if (isset($this->_req->query->server)) |
| 387 | - checkSession('get'); |
|
| 388 | - else |
|
| 389 | - checkSession(); |
|
| 399 | + { |
|
| 400 | + checkSession('get'); |
|
| 401 | + } |
|
| 402 | + else { |
|
| 403 | + checkSession(); |
|
| 404 | + } |
|
| 390 | 405 | |
| 391 | 406 | // To download something, we need either a valid server or url. |
| 392 | 407 | if (empty($this->_req->query->server) && (!empty($this->_req->query->get) && !empty($this->_req->post->package))) |
| 393 | - throw new Elk_Exception('package_get_error_is_zero', false); |
|
| 408 | + { |
|
| 409 | + throw new Elk_Exception('package_get_error_is_zero', false); |
|
| 410 | + } |
|
| 394 | 411 | |
| 395 | 412 | // Start off with nothing |
| 396 | 413 | $server = ''; |
@@ -418,8 +435,9 @@ discard block |
||
| 418 | 435 | $url = isset($path_url['dirname']) ? $path_url['dirname'] . '/' : ''; |
| 419 | 436 | } |
| 420 | 437 | // Not found or some monkey business |
| 421 | - else |
|
| 422 | - throw new Elk_Exception('package_cant_download', false); |
|
| 438 | + else { |
|
| 439 | + throw new Elk_Exception('package_cant_download', false); |
|
| 440 | + } |
|
| 423 | 441 | } |
| 424 | 442 | // Entered a url and optional filename |
| 425 | 443 | elseif (isset($this->_req->post->byurl) && !empty($this->_req->post->filename)) |
@@ -443,13 +461,16 @@ discard block |
||
| 443 | 461 | $ext = substr($package_name, strrpos(substr($package_name, 0, -3), '.')); |
| 444 | 462 | $package_name = substr($package_name, 0, strrpos(substr($package_name, 0, -3), '.')) . '_'; |
| 445 | 463 | } |
| 446 | - else |
|
| 447 | - $ext = ''; |
|
| 464 | + else { |
|
| 465 | + $ext = ''; |
|
| 466 | + } |
|
| 448 | 467 | |
| 449 | 468 | // Find the first available free name |
| 450 | 469 | $i = 1; |
| 451 | 470 | while (file_exists(BOARDDIR . '/packages/' . $package_name . $i . $ext)) |
| 452 | - $i++; |
|
| 471 | + { |
|
| 472 | + $i++; |
|
| 473 | + } |
|
| 453 | 474 | |
| 454 | 475 | $package_name = $package_name . $i . $ext; |
| 455 | 476 | } |
@@ -458,7 +479,9 @@ discard block |
||
| 458 | 479 | $packageInfo = getPackageInfo($url . $package_id); |
| 459 | 480 | |
| 460 | 481 | if (!is_array($packageInfo)) |
| 461 | - throw new Elk_Exception($packageInfo); |
|
| 482 | + { |
|
| 483 | + throw new Elk_Exception($packageInfo); |
|
| 484 | + } |
|
| 462 | 485 | |
| 463 | 486 | // Save the package to disk, use FTP if necessary |
| 464 | 487 | create_chmod_control( |
@@ -473,7 +496,9 @@ discard block |
||
| 473 | 496 | |
| 474 | 497 | // Done! Did we get this package automatically? |
| 475 | 498 | if (preg_match('~^http://[\w_\-]+\.elkarte\.net/~', $package_id) == 1 && strpos($package_id, 'dlattach') === false && isset($this->_req->query->auto)) |
| 476 | - redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
| 499 | + { |
|
| 500 | + redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
| 501 | + } |
|
| 477 | 502 | |
| 478 | 503 | // You just downloaded a addon from SERVER_NAME_GOES_HERE. |
| 479 | 504 | $context['package_server'] = $server; |
@@ -482,16 +507,25 @@ discard block |
||
| 482 | 507 | $context['package'] = getPackageInfo($package_name); |
| 483 | 508 | |
| 484 | 509 | if (!is_array($context['package'])) |
| 485 | - throw new Elk_Exception('package_cant_download', false); |
|
| 510 | + { |
|
| 511 | + throw new Elk_Exception('package_cant_download', false); |
|
| 512 | + } |
|
| 486 | 513 | |
| 487 | 514 | if ($context['package']['type'] === 'modification' || $context['package']['type'] === 'addon') |
| 488 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['install_mod'] . '</a>'; |
|
| 515 | + { |
|
| 516 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['install_mod'] . '</a>'; |
|
| 517 | + } |
|
| 489 | 518 | elseif ($context['package']['type'] === 'avatar') |
| 490 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['use_avatars'] . '</a>'; |
|
| 519 | + { |
|
| 520 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['use_avatars'] . '</a>'; |
|
| 521 | + } |
|
| 491 | 522 | elseif ($context['package']['type'] === 'language') |
| 492 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['add_languages'] . '</a>'; |
|
| 493 | - else |
|
| 494 | - $context['package']['install']['link'] = ''; |
|
| 523 | + { |
|
| 524 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['add_languages'] . '</a>'; |
|
| 525 | + } |
|
| 526 | + else { |
|
| 527 | + $context['package']['install']['link'] = ''; |
|
| 528 | + } |
|
| 495 | 529 | |
| 496 | 530 | $context['package']['list_files']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=list;package=' . $context['package']['filename'] . '">' . $txt['list_files'] . '</a>'; |
| 497 | 531 | |
@@ -519,7 +553,9 @@ discard block |
||
| 519 | 553 | if (isset($this->_req->query->server)) |
| 520 | 554 | { |
| 521 | 555 | if ($this->_req->query->server == '') |
| 522 | - redirectexit('action=admin;area=packageservers'); |
|
| 556 | + { |
|
| 557 | + redirectexit('action=admin;area=packageservers'); |
|
| 558 | + } |
|
| 523 | 559 | |
| 524 | 560 | $server = $this->_req->getQuery('server', 'intval'); |
| 525 | 561 | |
@@ -530,7 +566,9 @@ discard block |
||
| 530 | 566 | |
| 531 | 567 | // If server does not exist then dump out. |
| 532 | 568 | if (empty($url)) |
| 533 | - throw new Elk_Exception('couldnt_connect', false); |
|
| 569 | + { |
|
| 570 | + throw new Elk_Exception('couldnt_connect', false); |
|
| 571 | + } |
|
| 534 | 572 | } |
| 535 | 573 | |
| 536 | 574 | return array($name, $url, $server); |
@@ -551,15 +589,21 @@ discard block |
||
| 551 | 589 | // @todo Use FTP if the packages directory is not writable. |
| 552 | 590 | // Check the file was even sent! |
| 553 | 591 | if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '') |
| 554 | - throw new Elk_Exception('package_upload_error_nofile'); |
|
| 592 | + { |
|
| 593 | + throw new Elk_Exception('package_upload_error_nofile'); |
|
| 594 | + } |
|
| 555 | 595 | elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name']))) |
| 556 | - throw new Elk_Exception('package_upload_error_failed'); |
|
| 596 | + { |
|
| 597 | + throw new Elk_Exception('package_upload_error_failed'); |
|
| 598 | + } |
|
| 557 | 599 | |
| 558 | 600 | // Make sure it has a sane filename. |
| 559 | 601 | $_FILES['package']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['package']['name']); |
| 560 | 602 | |
| 561 | 603 | if (strtolower(substr($_FILES['package']['name'], -4)) !== '.zip' && strtolower(substr($_FILES['package']['name'], -4)) !== '.tgz' && strtolower(substr($_FILES['package']['name'], -7)) !== '.tar.gz') |
| 562 | - throw new Elk_Exception('package_upload_error_supports', false, array('zip, tgz, tar.gz')); |
|
| 604 | + { |
|
| 605 | + throw new Elk_Exception('package_upload_error_supports', false, array('zip, tgz, tar.gz')); |
|
| 606 | + } |
|
| 563 | 607 | |
| 564 | 608 | // We only need the filename... |
| 565 | 609 | $packageName = basename($_FILES['package']['name']); |
@@ -569,7 +613,9 @@ discard block |
||
| 569 | 613 | |
| 570 | 614 | // @todo Maybe just roll it like we do for downloads? |
| 571 | 615 | if (file_exists($destination)) |
| 572 | - throw new Elk_Exception('package_upload_error_exists'); |
|
| 616 | + { |
|
| 617 | + throw new Elk_Exception('package_upload_error_exists'); |
|
| 618 | + } |
|
| 573 | 619 | |
| 574 | 620 | // Now move the file. |
| 575 | 621 | move_uploaded_file($_FILES['package']['tmp_name'], $destination); |
@@ -601,12 +647,16 @@ discard block |
||
| 601 | 647 | { |
| 602 | 648 | // No need to check these |
| 603 | 649 | if ($package->getFilename() == $packageName) |
| 604 | - continue; |
|
| 650 | + { |
|
| 651 | + continue; |
|
| 652 | + } |
|
| 605 | 653 | |
| 606 | 654 | // Read package info for the archive we found |
| 607 | 655 | $packageInfo = getPackageInfo($package->getFilename()); |
| 608 | 656 | if (!is_array($packageInfo)) |
| 609 | - continue; |
|
| 657 | + { |
|
| 658 | + continue; |
|
| 659 | + } |
|
| 610 | 660 | |
| 611 | 661 | // If it was already uploaded under another name don't upload it again. |
| 612 | 662 | if ($packageInfo['id'] == $context['package']['id'] && compareVersions($packageInfo['version'], $context['package']['version']) == 0) |
@@ -624,13 +674,20 @@ discard block |
||
| 624 | 674 | } |
| 625 | 675 | |
| 626 | 676 | if ($context['package']['type'] === 'modification' || $context['package']['type'] === 'addon') |
| 627 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['install_mod'] . '</a>'; |
|
| 677 | + { |
|
| 678 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['install_mod'] . '</a>'; |
|
| 679 | + } |
|
| 628 | 680 | elseif ($context['package']['type'] === 'avatar') |
| 629 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['use_avatars'] . '</a>'; |
|
| 681 | + { |
|
| 682 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['use_avatars'] . '</a>'; |
|
| 683 | + } |
|
| 630 | 684 | elseif ($context['package']['type'] === 'language') |
| 631 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['add_languages'] . '</a>'; |
|
| 632 | - else |
|
| 633 | - $context['package']['install']['link'] = ''; |
|
| 685 | + { |
|
| 686 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['add_languages'] . '</a>'; |
|
| 687 | + } |
|
| 688 | + else { |
|
| 689 | + $context['package']['install']['link'] = ''; |
|
| 690 | + } |
|
| 634 | 691 | |
| 635 | 692 | $context['package']['list_files']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=list;package=' . $context['package']['filename'] . '">' . $txt['list_files'] . '</a>'; |
| 636 | 693 | |
@@ -654,7 +711,9 @@ discard block |
||
| 654 | 711 | |
| 655 | 712 | // If they put a slash on the end, get rid of it. |
| 656 | 713 | if (substr($this->_req->post->serverurl, -1) === '/') |
| 657 | - $this->_req->post->serverurl = substr($this->_req->post->serverurl, 0, -1); |
|
| 714 | + { |
|
| 715 | + $this->_req->post->serverurl = substr($this->_req->post->serverurl, 0, -1); |
|
| 716 | + } |
|
| 658 | 717 | |
| 659 | 718 | // Are they both nice and clean? |
| 660 | 719 | $servername = trim(Util::htmlspecialchars($this->_req->post->servername)); |
@@ -712,7 +771,9 @@ discard block |
||
| 712 | 771 | |
| 713 | 772 | // Give FTP a chance... |
| 714 | 773 | if ($context['package_download_broken']) |
| 715 | - $this->ftp_connect(); |
|
| 774 | + { |
|
| 775 | + $this->ftp_connect(); |
|
| 776 | + } |
|
| 716 | 777 | } |
| 717 | 778 | |
| 718 | 779 | /** |
@@ -769,15 +830,21 @@ discard block |
||
| 769 | 830 | } |
| 770 | 831 | // ...or we failed |
| 771 | 832 | elseif ($ftp->error !== false && !isset($ftp_error)) |
| 772 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 833 | + { |
|
| 834 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 835 | + } |
|
| 773 | 836 | |
| 774 | 837 | list ($username, $detect_path, $found_path) = $ftp->detect_path(BOARDDIR); |
| 775 | 838 | |
| 776 | 839 | if ($found_path || !isset($this->_req->post->ftp_path)) |
| 777 | - $this->_req->post->ftp_path = $detect_path; |
|
| 840 | + { |
|
| 841 | + $this->_req->post->ftp_path = $detect_path; |
|
| 842 | + } |
|
| 778 | 843 | |
| 779 | 844 | if (!isset($this->_req->post->ftp_username)) |
| 780 | - $this->_req->post->ftp_username = $username; |
|
| 845 | + { |
|
| 846 | + $this->_req->post->ftp_username = $username; |
|
| 847 | + } |
|
| 781 | 848 | |
| 782 | 849 | // Fill the boxes for a FTP connection with data from the previous attempt too, if any |
| 783 | 850 | $context['package_ftp'] = array( |
@@ -82,7 +82,9 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | // Now - finally - call the right place! |
| 84 | 84 | if (isset($admin_include_data['file'])) |
| 85 | - require_once($admin_include_data['file']); |
|
| 85 | + { |
|
| 86 | + require_once($admin_include_data['file']); |
|
| 87 | + } |
|
| 86 | 88 | |
| 87 | 89 | callMenu($admin_include_data); |
| 88 | 90 | } |
@@ -612,16 +614,20 @@ discard block |
||
| 612 | 614 | ); |
| 613 | 615 | |
| 614 | 616 | if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') |
| 615 | - $context['linktree'][] = array( |
|
| 617 | + { |
|
| 618 | + $context['linktree'][] = array( |
|
| 616 | 619 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 617 | 620 | 'name' => $admin_include_data['label'], |
| 618 | 621 | ); |
| 622 | + } |
|
| 619 | 623 | |
| 620 | 624 | if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) |
| 621 | - $context['linktree'][] = array( |
|
| 625 | + { |
|
| 626 | + $context['linktree'][] = array( |
|
| 622 | 627 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 623 | 628 | 'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0], |
| 624 | 629 | ); |
| 630 | + } |
|
| 625 | 631 | } |
| 626 | 632 | |
| 627 | 633 | /** |
@@ -779,9 +785,12 @@ discard block |
||
| 779 | 785 | |
| 780 | 786 | // You did remember to enter something to search for, otherwise its easy |
| 781 | 787 | if ($context['search_term'] === '') |
| 782 | - $context['search_results'] = array(); |
|
| 783 | - else |
|
| 784 | - $action->dispatch($subAction); |
|
| 788 | + { |
|
| 789 | + $context['search_results'] = array(); |
|
| 790 | + } |
|
| 791 | + else { |
|
| 792 | + $action->dispatch($subAction); |
|
| 793 | + } |
|
| 785 | 794 | } |
| 786 | 795 | |
| 787 | 796 | /** |
@@ -925,7 +934,9 @@ discard block |
||
| 925 | 934 | |
| 926 | 935 | // Encode the search data. |
| 927 | 936 | foreach ($postVars as $k => $v) |
| 928 | - $postVars[$k] = urlencode($v); |
|
| 937 | + { |
|
| 938 | + $postVars[$k] = urlencode($v); |
|
| 939 | + } |
|
| 929 | 940 | |
| 930 | 941 | // This is what we will send. |
| 931 | 942 | $postVars = implode('+', $postVars); |
@@ -938,7 +949,9 @@ discard block |
||
| 938 | 949 | |
| 939 | 950 | // If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded? |
| 940 | 951 | if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) !== 1) |
| 941 | - throw new Elk_Exception('cannot_connect_doc_site'); |
|
| 952 | + { |
|
| 953 | + throw new Elk_Exception('cannot_connect_doc_site'); |
|
| 954 | + } |
|
| 942 | 955 | |
| 943 | 956 | $search_results = !empty($matches[1]) ? $matches[1] : ''; |
| 944 | 957 | |