@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Class browser_detector |
@@ -55,20 +56,25 @@ discard block |
||
| 55 | 56 | $this->_browsers['needs_size_fix'] = false; |
| 56 | 57 | |
| 57 | 58 | // One at a time, one at a time, and in this order too |
| 58 | - if ($this->isOpera()) |
|
| 59 | - $this->setupOpera(); |
|
| 59 | + if ($this->isOpera()) { |
|
| 60 | + $this->setupOpera(); |
|
| 61 | + } |
|
| 60 | 62 | // Meh... |
| 61 | - elseif ($this->isEdge()) |
|
| 62 | - $this->setupEdge(); |
|
| 63 | + elseif ($this->isEdge()) { |
|
| 64 | + $this->setupEdge(); |
|
| 65 | + } |
|
| 63 | 66 | // Them webkits need to be set up too |
| 64 | - elseif ($this->isWebkit()) |
|
| 65 | - $this->setupWebkit(); |
|
| 67 | + elseif ($this->isWebkit()) { |
|
| 68 | + $this->setupWebkit(); |
|
| 69 | + } |
|
| 66 | 70 | // We may have work to do on Firefox... |
| 67 | - elseif ($this->isFirefox()) |
|
| 68 | - $this->setupFirefox(); |
|
| 71 | + elseif ($this->isFirefox()) { |
|
| 72 | + $this->setupFirefox(); |
|
| 73 | + } |
|
| 69 | 74 | // Old friend, old frenemy |
| 70 | - elseif ($this->isIe()) |
|
| 71 | - $this->setupIe(); |
|
| 75 | + elseif ($this->isIe()) { |
|
| 76 | + $this->setupIe(); |
|
| 77 | + } |
|
| 72 | 78 | |
| 73 | 79 | // Just a few mobile checks |
| 74 | 80 | $this->isOperaMini(); |
@@ -84,11 +90,12 @@ discard block |
||
| 84 | 90 | $this->_browsers['possibly_robot'] = !empty($user_info['possibly_robot']); |
| 85 | 91 | |
| 86 | 92 | // Robots shouldn't be logging in or registering. So, they aren't a bot. Better to be wrong than sorry (or people won't be able to log in!), anyway. |
| 87 | - if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) |
|
| 88 | - $this->_browsers['possibly_robot'] = false; |
|
| 93 | + if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) { |
|
| 94 | + $this->_browsers['possibly_robot'] = false; |
|
| 95 | + } |
|
| 96 | + } else { |
|
| 97 | + $this->_browsers['possibly_robot'] = false; |
|
| 89 | 98 | } |
| 90 | - else |
|
| 91 | - $this->_browsers['possibly_robot'] = false; |
|
| 92 | 99 | |
| 93 | 100 | // Fill out the historical array as needed to support old mods that don't use isBrowser |
| 94 | 101 | $this->fillInformation(); |
@@ -106,8 +113,9 @@ discard block |
||
| 106 | 113 | */ |
| 107 | 114 | function isOpera() |
| 108 | 115 | { |
| 109 | - if (!isset($this->_browsers['is_opera'])) |
|
| 110 | - $this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false; |
|
| 116 | + if (!isset($this->_browsers['is_opera'])) { |
|
| 117 | + $this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false; |
|
| 118 | + } |
|
| 111 | 119 | return $this->_browsers['is_opera']; |
| 112 | 120 | } |
| 113 | 121 | |
@@ -118,8 +126,9 @@ discard block |
||
| 118 | 126 | function isIe() |
| 119 | 127 | { |
| 120 | 128 | // I'm IE, Yes I'm the real IE; All you other IEs are just imitating. |
| 121 | - if (!isset($this->_browsers['is_ie'])) |
|
| 122 | - $this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1; |
|
| 129 | + if (!isset($this->_browsers['is_ie'])) { |
|
| 130 | + $this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1; |
|
| 131 | + } |
|
| 123 | 132 | return $this->_browsers['is_ie']; |
| 124 | 133 | } |
| 125 | 134 | |
@@ -131,8 +140,9 @@ discard block |
||
| 131 | 140 | { |
| 132 | 141 | // IE11 is a bit different than earlier versions |
| 133 | 142 | // The isGecko() part is to ensure we get this right... |
| 134 | - if (!isset($this->_browsers['is_ie11'])) |
|
| 135 | - $this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko(); |
|
| 143 | + if (!isset($this->_browsers['is_ie11'])) { |
|
| 144 | + $this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko(); |
|
| 145 | + } |
|
| 136 | 146 | return $this->_browsers['is_ie11']; |
| 137 | 147 | } |
| 138 | 148 | |
@@ -142,8 +152,9 @@ discard block |
||
| 142 | 152 | */ |
| 143 | 153 | function isEdge() |
| 144 | 154 | { |
| 145 | - if (!isset($this->_browsers['is_edge'])) |
|
| 146 | - $this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false; |
|
| 155 | + if (!isset($this->_browsers['is_edge'])) { |
|
| 156 | + $this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false; |
|
| 157 | + } |
|
| 147 | 158 | return $this->_browsers['is_edge']; |
| 148 | 159 | } |
| 149 | 160 | |
@@ -153,8 +164,9 @@ discard block |
||
| 153 | 164 | */ |
| 154 | 165 | function isWebkit() |
| 155 | 166 | { |
| 156 | - if (!isset($this->_browsers['is_webkit'])) |
|
| 157 | - $this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false; |
|
| 167 | + if (!isset($this->_browsers['is_webkit'])) { |
|
| 168 | + $this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false; |
|
| 169 | + } |
|
| 158 | 170 | return $this->_browsers['is_webkit']; |
| 159 | 171 | } |
| 160 | 172 | |
@@ -164,8 +176,9 @@ discard block |
||
| 164 | 176 | */ |
| 165 | 177 | function isFirefox() |
| 166 | 178 | { |
| 167 | - if (!isset($this->_browsers['is_firefox'])) |
|
| 168 | - $this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko(); |
|
| 179 | + if (!isset($this->_browsers['is_firefox'])) { |
|
| 180 | + $this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko(); |
|
| 181 | + } |
|
| 169 | 182 | return $this->_browsers['is_firefox']; |
| 170 | 183 | } |
| 171 | 184 | |
@@ -175,8 +188,9 @@ discard block |
||
| 175 | 188 | */ |
| 176 | 189 | function isWebTv() |
| 177 | 190 | { |
| 178 | - if (!isset($this->_browsers['is_web_tv'])) |
|
| 179 | - $this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false; |
|
| 191 | + if (!isset($this->_browsers['is_web_tv'])) { |
|
| 192 | + $this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false; |
|
| 193 | + } |
|
| 180 | 194 | return $this->_browsers['is_web_tv']; |
| 181 | 195 | } |
| 182 | 196 | |
@@ -186,8 +200,9 @@ discard block |
||
| 186 | 200 | */ |
| 187 | 201 | function isKonqueror() |
| 188 | 202 | { |
| 189 | - if (!isset($this->_browsers['is_konqueror'])) |
|
| 190 | - $this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false; |
|
| 203 | + if (!isset($this->_browsers['is_konqueror'])) { |
|
| 204 | + $this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false; |
|
| 205 | + } |
|
| 191 | 206 | return $this->_browsers['is_konqueror']; |
| 192 | 207 | } |
| 193 | 208 | |
@@ -197,8 +212,9 @@ discard block |
||
| 197 | 212 | */ |
| 198 | 213 | function isGecko() |
| 199 | 214 | { |
| 200 | - if (!isset($this->_browsers['is_gecko'])) |
|
| 201 | - $this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror(); |
|
| 215 | + if (!isset($this->_browsers['is_gecko'])) { |
|
| 216 | + $this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror(); |
|
| 217 | + } |
|
| 202 | 218 | return $this->_browsers['is_gecko']; |
| 203 | 219 | } |
| 204 | 220 | |
@@ -208,10 +224,12 @@ discard block |
||
| 208 | 224 | */ |
| 209 | 225 | function isOperaMini() |
| 210 | 226 | { |
| 211 | - if (!isset($this->_browsers['is_opera_mini'])) |
|
| 212 | - $this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false); |
|
| 213 | - if ($this->_browsers['is_opera_mini']) |
|
| 214 | - $this->_is_mobile = true; |
|
| 227 | + if (!isset($this->_browsers['is_opera_mini'])) { |
|
| 228 | + $this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false); |
|
| 229 | + } |
|
| 230 | + if ($this->_browsers['is_opera_mini']) { |
|
| 231 | + $this->_is_mobile = true; |
|
| 232 | + } |
|
| 215 | 233 | return $this->_browsers['is_opera_mini']; |
| 216 | 234 | } |
| 217 | 235 | |
@@ -221,10 +239,12 @@ discard block |
||
| 221 | 239 | */ |
| 222 | 240 | function isOperaMobi() |
| 223 | 241 | { |
| 224 | - if (!isset($this->_browsers['is_opera_mobi'])) |
|
| 225 | - $this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false; |
|
| 226 | - if ($this->_browsers['is_opera_mobi']) |
|
| 227 | - $this->_is_mobile = true; |
|
| 242 | + if (!isset($this->_browsers['is_opera_mobi'])) { |
|
| 243 | + $this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false; |
|
| 244 | + } |
|
| 245 | + if ($this->_browsers['is_opera_mobi']) { |
|
| 246 | + $this->_is_mobile = true; |
|
| 247 | + } |
|
| 228 | 248 | return $this->_browsers['is_opera_mini']; |
| 229 | 249 | } |
| 230 | 250 | |
@@ -244,8 +264,9 @@ discard block |
||
| 244 | 264 | ); |
| 245 | 265 | |
| 246 | 266 | // blackberry, playbook, iphone, nokia, android and ipods set a mobile flag |
| 247 | - if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) |
|
| 248 | - $this->_is_mobile = true; |
|
| 267 | + if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) { |
|
| 268 | + $this->_is_mobile = true; |
|
| 269 | + } |
|
| 249 | 270 | |
| 250 | 271 | // @todo what to do with the blaPad? ... for now leave it detected as Safari ... |
| 251 | 272 | $this->_browsers['is_safari'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false && !$this->_browsers['is_chrome'] && !$this->_browsers['is_iphone']; |
@@ -254,15 +275,17 @@ discard block |
||
| 254 | 275 | // if Chrome, get the major version |
| 255 | 276 | if ($this->_browsers['is_chrome']) |
| 256 | 277 | { |
| 257 | - if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
| 258 | - $this->_browsers['is_chrome' . (int) $match[1]] = true; |
|
| 278 | + if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
| 279 | + $this->_browsers['is_chrome' . (int) $match[1]] = true; |
|
| 280 | + } |
|
| 259 | 281 | } |
| 260 | 282 | |
| 261 | 283 | // or if Safari get its major version |
| 262 | 284 | if ($this->_browsers['is_safari']) |
| 263 | 285 | { |
| 264 | - if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
| 265 | - $this->_browsers['is_safari' . (int) trim($match[1])] = true; |
|
| 286 | + if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
| 287 | + $this->_browsers['is_safari' . (int) trim($match[1])] = true; |
|
| 288 | + } |
|
| 266 | 289 | } |
| 267 | 290 | } |
| 268 | 291 | |
@@ -291,8 +314,9 @@ discard block |
||
| 291 | 314 | $this->_browsers['is_ie' . ((int) $trident_match[1] + 4)] = true; |
| 292 | 315 | |
| 293 | 316 | // If trident is set, see the (if any) msie tag in the user agent matches ... if not its in some compatibility view |
| 294 | - if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) |
|
| 295 | - $this->_browsers['is_ie_compat_view'] = true; |
|
| 317 | + if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) { |
|
| 318 | + $this->_browsers['is_ie_compat_view'] = true; |
|
| 319 | + } |
|
| 296 | 320 | } |
| 297 | 321 | |
| 298 | 322 | // Detect true IE6 and IE7 and not IE in compat mode. |
@@ -326,8 +350,9 @@ discard block |
||
| 326 | 350 | */ |
| 327 | 351 | private function setupFirefox() |
| 328 | 352 | { |
| 329 | - if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
| 330 | - $this->_browsers['is_firefox' . (int) $match[1]] = true; |
|
| 353 | + if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
| 354 | + $this->_browsers['is_firefox' . (int) $match[1]] = true; |
|
| 355 | + } |
|
| 331 | 356 | } |
| 332 | 357 | |
| 333 | 358 | /** |
@@ -338,11 +363,13 @@ discard block |
||
| 338 | 363 | private function setupOpera() |
| 339 | 364 | { |
| 340 | 365 | // Opera 10+ uses the version tag at the end of the string |
| 341 | - if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) |
|
| 342 | - $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
| 366 | + if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) { |
|
| 367 | + $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
| 368 | + } |
|
| 343 | 369 | // Opera pre 10 is supposed to uses the Opera tag alone, as do some spoofers |
| 344 | - elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) |
|
| 345 | - $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
| 370 | + elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) { |
|
| 371 | + $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
| 372 | + } |
|
| 346 | 373 | |
| 347 | 374 | // Needs size fix? |
| 348 | 375 | $this->_browsers['needs_size_fix'] = !empty($this->_browsers['is_opera6']); |
@@ -353,8 +380,9 @@ discard block |
||
| 353 | 380 | */ |
| 354 | 381 | private function setupEdge() |
| 355 | 382 | { |
| 356 | - if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
| 357 | - $this->_browsers['is_edge' . (int) $match[1]] = true; |
|
| 383 | + if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
| 384 | + $this->_browsers['is_edge' . (int) $match[1]] = true; |
|
| 385 | + } |
|
| 358 | 386 | } |
| 359 | 387 | |
| 360 | 388 | /** |
@@ -367,9 +395,9 @@ discard block |
||
| 367 | 395 | { |
| 368 | 396 | global $context; |
| 369 | 397 | |
| 370 | - if ($this->_is_mobile) |
|
| 371 | - $context['browser_body_id'] = 'mobile'; |
|
| 372 | - else |
|
| 398 | + if ($this->_is_mobile) { |
|
| 399 | + $context['browser_body_id'] = 'mobile'; |
|
| 400 | + } else |
|
| 373 | 401 | { |
| 374 | 402 | // add in any specific detection conversions here if you want a special body id e.g. 'is_opera9' => 'opera9' |
| 375 | 403 | $browser_priority = array( |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Entrance point for the registration center, it checks permissions and forwards |
@@ -31,8 +32,9 @@ discard block |
||
| 31 | 32 | global $context, $txt; |
| 32 | 33 | |
| 33 | 34 | // Old templates might still request this. |
| 34 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') |
|
| 35 | - redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
| 35 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') { |
|
| 36 | + redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | $subActions = array( |
| 38 | 40 | 'register' => array('AdminRegister', 'moderate_forum'), |
@@ -99,9 +101,10 @@ discard block |
||
| 99 | 101 | checkSession(); |
| 100 | 102 | validateToken('admin-regc'); |
| 101 | 103 | |
| 102 | - foreach ($_POST as $key => $value) |
|
| 103 | - if (!is_array($_POST[$key])) |
|
| 104 | + foreach ($_POST as $key => $value) { |
|
| 105 | + if (!is_array($_POST[$key])) |
|
| 104 | 106 | $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
| 107 | + } |
|
| 105 | 108 | |
| 106 | 109 | $regOptions = array( |
| 107 | 110 | 'interface' => 'admin', |
@@ -161,12 +164,13 @@ discard block |
||
| 161 | 164 | ) |
| 162 | 165 | ); |
| 163 | 166 | $context['member_groups'] = array(0 => $txt['admin_register_group_none']); |
| 164 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 165 | - $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
| 167 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 168 | + $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
| 169 | + } |
|
| 166 | 170 | $smcFunc['db_free_result']($request); |
| 171 | + } else { |
|
| 172 | + $context['member_groups'] = array(); |
|
| 167 | 173 | } |
| 168 | - else |
|
| 169 | - $context['member_groups'] = array(); |
|
| 170 | 174 | |
| 171 | 175 | // Basic stuff. |
| 172 | 176 | $context['sub_template'] = 'admin_register'; |
@@ -207,8 +211,9 @@ discard block |
||
| 207 | 211 | { |
| 208 | 212 | $context['editable_agreements']['.' . $lang['filename']] = $lang['name']; |
| 209 | 213 | // Are we editing this? |
| 210 | - if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) |
|
| 211 | - $context['current_agreement'] = '.' . $lang['filename']; |
|
| 214 | + if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) { |
|
| 215 | + $context['current_agreement'] = '.' . $lang['filename']; |
|
| 216 | + } |
|
| 212 | 217 | } |
| 213 | 218 | } |
| 214 | 219 | |
@@ -223,10 +228,11 @@ discard block |
||
| 223 | 228 | |
| 224 | 229 | updateSettings(array('requireAgreement' => !empty($_POST['requireAgreement']))); |
| 225 | 230 | |
| 226 | - if ($bytes == strlen($to_write)) |
|
| 227 | - $context['saved_successful'] = true; |
|
| 228 | - else |
|
| 229 | - $context['could_not_save'] = true; |
|
| 231 | + if ($bytes == strlen($to_write)) { |
|
| 232 | + $context['saved_successful'] = true; |
|
| 233 | + } else { |
|
| 234 | + $context['could_not_save'] = true; |
|
| 235 | + } |
|
| 230 | 236 | } |
| 231 | 237 | |
| 232 | 238 | $context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? $smcFunc['htmlspecialchars'](file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : ''; |
@@ -310,8 +316,9 @@ discard block |
||
| 310 | 316 | |
| 311 | 317 | call_integration_hook('integrate_modify_registration_settings', array(&$config_vars)); |
| 312 | 318 | |
| 313 | - if ($return_config) |
|
| 314 | - return $config_vars; |
|
| 319 | + if ($return_config) { |
|
| 320 | + return $config_vars; |
|
| 321 | + } |
|
| 315 | 322 | |
| 316 | 323 | // Setup the template |
| 317 | 324 | $context['sub_template'] = 'show_settings'; |
@@ -322,8 +329,9 @@ discard block |
||
| 322 | 329 | checkSession(); |
| 323 | 330 | |
| 324 | 331 | // Are there some contacts missing? |
| 325 | - if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) |
|
| 326 | - fatal_lang_error('admin_setting_coppa_require_contact'); |
|
| 332 | + if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) { |
|
| 333 | + fatal_lang_error('admin_setting_coppa_require_contact'); |
|
| 334 | + } |
|
| 327 | 335 | |
| 328 | 336 | // Post needs to take into account line breaks. |
| 329 | 337 | $_POST['coppaPost'] = str_replace("\n", '<br>', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main dispatcher; doesn't do anything, just delegates. |
@@ -92,18 +93,19 @@ discard block |
||
| 92 | 93 | checkSession('get'); |
| 93 | 94 | validateToken('admin-bm-' . (int) $_REQUEST['src_board'], 'request'); |
| 94 | 95 | |
| 95 | - if ($_REQUEST['move_to'] === 'top') |
|
| 96 | - $boardOptions = array( |
|
| 96 | + if ($_REQUEST['move_to'] === 'top') { |
|
| 97 | + $boardOptions = array( |
|
| 97 | 98 | 'move_to' => $_REQUEST['move_to'], |
| 98 | 99 | 'target_category' => (int) $_REQUEST['target_cat'], |
| 99 | 100 | 'move_first_child' => true, |
| 100 | 101 | ); |
| 101 | - else |
|
| 102 | - $boardOptions = array( |
|
| 102 | + } else { |
|
| 103 | + $boardOptions = array( |
|
| 103 | 104 | 'move_to' => $_REQUEST['move_to'], |
| 104 | 105 | 'target_board' => (int) $_REQUEST['target_board'], |
| 105 | 106 | 'move_first_child' => true, |
| 106 | 107 | ); |
| 108 | + } |
|
| 107 | 109 | modifyBoard((int) $_REQUEST['src_board'], $boardOptions); |
| 108 | 110 | } |
| 109 | 111 | |
@@ -148,15 +150,16 @@ discard block |
||
| 148 | 150 | $security = $context['session_var'] . '=' . $context['session_id'] . ';' . $context['admin-bm-' . $context['move_board'] . '_token_var'] . '=' . $context['admin-bm-' . $context['move_board'] . '_token']; |
| 149 | 151 | foreach ($boardList[$catid] as $boardid) |
| 150 | 152 | { |
| 151 | - if (!isset($context['categories'][$catid]['move_link'])) |
|
| 152 | - $context['categories'][$catid]['move_link'] = array( |
|
| 153 | + if (!isset($context['categories'][$catid]['move_link'])) { |
|
| 154 | + $context['categories'][$catid]['move_link'] = array( |
|
| 153 | 155 | 'child_level' => 0, |
| 154 | 156 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
| 155 | 157 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security, |
| 156 | 158 | ); |
| 159 | + } |
|
| 157 | 160 | |
| 158 | - if (!$context['categories'][$catid]['boards'][$boardid]['move']) |
|
| 159 | - $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
| 161 | + if (!$context['categories'][$catid]['boards'][$boardid]['move']) { |
|
| 162 | + $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
| 160 | 163 | array( |
| 161 | 164 | 'child_level' => $boards[$boardid]['level'], |
| 162 | 165 | 'label' => $txt['mboards_order_after'] . '\'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
@@ -170,34 +173,39 @@ discard block |
||
| 170 | 173 | 'class' => 'here', |
| 171 | 174 | ), |
| 172 | 175 | ); |
| 176 | + } |
|
| 173 | 177 | |
| 174 | 178 | $difference = $boards[$boardid]['level'] - $prev_child_level; |
| 175 | - if ($difference == 1) |
|
| 176 | - array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
| 177 | - elseif ($difference < 0) |
|
| 179 | + if ($difference == 1) { |
|
| 180 | + array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
| 181 | + } elseif ($difference < 0) |
|
| 178 | 182 | { |
| 179 | - if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
| 180 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
| 181 | - for ($i = 0; $i < -$difference; $i++) |
|
| 182 | - if (($temp = array_pop($stack)) != null) |
|
| 183 | + if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
| 184 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
| 185 | + } |
|
| 186 | + for ($i = 0; $i < -$difference; $i++) { |
|
| 187 | + if (($temp = array_pop($stack)) != null) |
|
| 183 | 188 | array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp); |
| 189 | + } |
|
| 184 | 190 | } |
| 185 | 191 | |
| 186 | 192 | $prev_board = $boardid; |
| 187 | 193 | $prev_child_level = $boards[$boardid]['level']; |
| 188 | 194 | |
| 189 | 195 | } |
| 190 | - if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
| 191 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
| 192 | - elseif (!empty($stack)) |
|
| 193 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
| 196 | + if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
| 197 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
| 198 | + } elseif (!empty($stack)) { |
|
| 199 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
| 200 | + } |
|
| 194 | 201 | |
| 195 | - if (empty($boardList[$catid])) |
|
| 196 | - $context['categories'][$catid]['move_link'] = array( |
|
| 202 | + if (empty($boardList[$catid])) { |
|
| 203 | + $context['categories'][$catid]['move_link'] = array( |
|
| 197 | 204 | 'child_level' => 0, |
| 198 | 205 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'', |
| 199 | 206 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
| 200 | 207 | ); |
| 208 | + } |
|
| 201 | 209 | } |
| 202 | 210 | } |
| 203 | 211 | |
@@ -253,9 +261,9 @@ discard block |
||
| 253 | 261 | ); |
| 254 | 262 | } |
| 255 | 263 | // Category doesn't exist, man... sorry. |
| 256 | - elseif (!isset($cat_tree[$_REQUEST['cat']])) |
|
| 257 | - redirectexit('action=admin;area=manageboards'); |
|
| 258 | - else |
|
| 264 | + elseif (!isset($cat_tree[$_REQUEST['cat']])) { |
|
| 265 | + redirectexit('action=admin;area=manageboards'); |
|
| 266 | + } else |
|
| 259 | 267 | { |
| 260 | 268 | $context['category'] = array( |
| 261 | 269 | 'id' => $_REQUEST['cat'], |
@@ -267,30 +275,31 @@ discard block |
||
| 267 | 275 | 'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children']) |
| 268 | 276 | ); |
| 269 | 277 | |
| 270 | - foreach ($boardList[$_REQUEST['cat']] as $child_board) |
|
| 271 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
| 278 | + foreach ($boardList[$_REQUEST['cat']] as $child_board) { |
|
| 279 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
| 280 | + } |
|
| 272 | 281 | } |
| 273 | 282 | |
| 274 | 283 | $prevCat = 0; |
| 275 | 284 | foreach ($cat_tree as $catid => $tree) |
| 276 | 285 | { |
| 277 | - if ($catid == $_REQUEST['cat'] && $prevCat > 0) |
|
| 278 | - $context['category_order'][$prevCat]['selected'] = true; |
|
| 279 | - elseif ($catid != $_REQUEST['cat']) |
|
| 280 | - $context['category_order'][$catid] = array( |
|
| 286 | + if ($catid == $_REQUEST['cat'] && $prevCat > 0) { |
|
| 287 | + $context['category_order'][$prevCat]['selected'] = true; |
|
| 288 | + } elseif ($catid != $_REQUEST['cat']) { |
|
| 289 | + $context['category_order'][$catid] = array( |
|
| 281 | 290 | 'id' => $catid, |
| 282 | 291 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
| 283 | 292 | 'selected' => false, |
| 284 | 293 | 'true_name' => $tree['node']['name'] |
| 285 | 294 | ); |
| 295 | + } |
|
| 286 | 296 | $prevCat = $catid; |
| 287 | 297 | } |
| 288 | 298 | if (!isset($_REQUEST['delete'])) |
| 289 | 299 | { |
| 290 | 300 | $context['sub_template'] = 'modify_category'; |
| 291 | 301 | $context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit']; |
| 292 | - } |
|
| 293 | - else |
|
| 302 | + } else |
|
| 294 | 303 | { |
| 295 | 304 | $context['sub_template'] = 'confirm_category_delete'; |
| 296 | 305 | $context['page_title'] = $txt['mboards_delete_cat']; |
@@ -327,8 +336,9 @@ discard block |
||
| 327 | 336 | { |
| 328 | 337 | $catOptions = array(); |
| 329 | 338 | |
| 330 | - if (isset($_POST['cat_order'])) |
|
| 331 | - $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
| 339 | + if (isset($_POST['cat_order'])) { |
|
| 340 | + $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
| 341 | + } |
|
| 332 | 342 | |
| 333 | 343 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
| 334 | 344 | $catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']); |
@@ -336,10 +346,11 @@ discard block |
||
| 336 | 346 | |
| 337 | 347 | $catOptions['is_collapsible'] = isset($_POST['collapse']); |
| 338 | 348 | |
| 339 | - if (isset($_POST['add'])) |
|
| 340 | - createCategory($catOptions); |
|
| 341 | - else |
|
| 342 | - modifyCategory($_POST['cat'], $catOptions); |
|
| 349 | + if (isset($_POST['add'])) { |
|
| 350 | + createCategory($catOptions); |
|
| 351 | + } else { |
|
| 352 | + modifyCategory($_POST['cat'], $catOptions); |
|
| 353 | + } |
|
| 343 | 354 | } |
| 344 | 355 | // If they want to delete - first give them confirmation. |
| 345 | 356 | elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) |
@@ -353,13 +364,14 @@ discard block |
||
| 353 | 364 | // First off - check if we are moving all the current boards first - before we start deleting! |
| 354 | 365 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
| 355 | 366 | { |
| 356 | - if (empty($_POST['cat_to'])) |
|
| 357 | - fatal_lang_error('mboards_delete_error'); |
|
| 367 | + if (empty($_POST['cat_to'])) { |
|
| 368 | + fatal_lang_error('mboards_delete_error'); |
|
| 369 | + } |
|
| 358 | 370 | |
| 359 | 371 | deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); |
| 372 | + } else { |
|
| 373 | + deleteCategories(array($_POST['cat'])); |
|
| 360 | 374 | } |
| 361 | - else |
|
| 362 | - deleteCategories(array($_POST['cat'])); |
|
| 363 | 375 | } |
| 364 | 376 | |
| 365 | 377 | redirectexit('action=admin;area=manageboards'); |
@@ -404,8 +416,9 @@ discard block |
||
| 404 | 416 | if ($_REQUEST['sa'] == 'newboard') |
| 405 | 417 | { |
| 406 | 418 | // Category doesn't exist, man... sorry. |
| 407 | - if (empty($_REQUEST['cat'])) |
|
| 408 | - redirectexit('action=admin;area=manageboards'); |
|
| 419 | + if (empty($_REQUEST['cat'])) { |
|
| 420 | + redirectexit('action=admin;area=manageboards'); |
|
| 421 | + } |
|
| 409 | 422 | |
| 410 | 423 | // Some things that need to be setup for a new board. |
| 411 | 424 | $curBoard = array( |
@@ -429,8 +442,7 @@ discard block |
||
| 429 | 442 | 'category' => (int) $_REQUEST['cat'], |
| 430 | 443 | 'no_children' => true, |
| 431 | 444 | ); |
| 432 | - } |
|
| 433 | - else |
|
| 445 | + } else |
|
| 434 | 446 | { |
| 435 | 447 | // Just some easy shortcuts. |
| 436 | 448 | $curBoard = &$boards[$_REQUEST['boardid']]; |
@@ -478,8 +490,9 @@ discard block |
||
| 478 | 490 | ); |
| 479 | 491 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 480 | 492 | { |
| 481 | - if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) |
|
| 482 | - $curBoard['member_groups'][] = $row['id_group']; |
|
| 493 | + if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) { |
|
| 494 | + $curBoard['member_groups'][] = $row['id_group']; |
|
| 495 | + } |
|
| 483 | 496 | |
| 484 | 497 | $context['groups'][(int) $row['id_group']] = array( |
| 485 | 498 | 'id' => $row['id_group'], |
@@ -492,8 +505,9 @@ discard block |
||
| 492 | 505 | $smcFunc['db_free_result']($request); |
| 493 | 506 | |
| 494 | 507 | // Category doesn't exist, man... sorry. |
| 495 | - if (!isset($boardList[$curBoard['category']])) |
|
| 496 | - redirectexit('action=admin;area=manageboards'); |
|
| 508 | + if (!isset($boardList[$curBoard['category']])) { |
|
| 509 | + redirectexit('action=admin;area=manageboards'); |
|
| 510 | + } |
|
| 497 | 511 | |
| 498 | 512 | foreach ($boardList[$curBoard['category']] as $boardid) |
| 499 | 513 | { |
@@ -507,8 +521,7 @@ discard block |
||
| 507 | 521 | 'is_child' => false, |
| 508 | 522 | 'selected' => true |
| 509 | 523 | ); |
| 510 | - } |
|
| 511 | - else |
|
| 524 | + } else |
|
| 512 | 525 | { |
| 513 | 526 | $context['board_order'][] = array( |
| 514 | 527 | 'id' => $boardid, |
@@ -525,19 +538,21 @@ discard block |
||
| 525 | 538 | $context['can_move_children'] = false; |
| 526 | 539 | $context['children'] = $boards[$_REQUEST['boardid']]['tree']['children']; |
| 527 | 540 | |
| 528 | - foreach ($context['board_order'] as $lBoard) |
|
| 529 | - if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
| 541 | + foreach ($context['board_order'] as $lBoard) { |
|
| 542 | + if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
| 530 | 543 | $context['can_move_children'] = true; |
| 544 | + } |
|
| 531 | 545 | } |
| 532 | 546 | |
| 533 | 547 | // Get other available categories. |
| 534 | 548 | $context['categories'] = array(); |
| 535 | - foreach ($cat_tree as $catID => $tree) |
|
| 536 | - $context['categories'][] = array( |
|
| 549 | + foreach ($cat_tree as $catID => $tree) { |
|
| 550 | + $context['categories'][] = array( |
|
| 537 | 551 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
| 538 | 552 | 'name' => $tree['node']['name'], |
| 539 | 553 | 'selected' => $catID == $curBoard['category'] |
| 540 | 554 | ); |
| 555 | + } |
|
| 541 | 556 | |
| 542 | 557 | $request = $smcFunc['db_query']('', ' |
| 543 | 558 | SELECT mem.id_member, mem.real_name |
@@ -549,14 +564,16 @@ discard block |
||
| 549 | 564 | ) |
| 550 | 565 | ); |
| 551 | 566 | $context['board']['moderators'] = array(); |
| 552 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 553 | - $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
| 567 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 568 | + $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
| 569 | + } |
|
| 554 | 570 | $smcFunc['db_free_result']($request); |
| 555 | 571 | |
| 556 | 572 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
| 557 | 573 | |
| 558 | - if (!empty($context['board']['moderators'])) |
|
| 559 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
| 574 | + if (!empty($context['board']['moderators'])) { |
|
| 575 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
| 576 | + } |
|
| 560 | 577 | |
| 561 | 578 | // Get all the groups assigned as moderators |
| 562 | 579 | $request = $smcFunc['db_query']('', ' |
@@ -568,14 +585,16 @@ discard block |
||
| 568 | 585 | ) |
| 569 | 586 | ); |
| 570 | 587 | $context['board']['moderator_groups'] = array(); |
| 571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 572 | - $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
| 588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 589 | + $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
| 590 | + } |
|
| 573 | 591 | $smcFunc['db_free_result']($request); |
| 574 | 592 | |
| 575 | 593 | $context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '"' . implode('", &qout;', $context['board']['moderator_groups']) . '"'; |
| 576 | 594 | |
| 577 | - if (!empty($context['board']['moderator_groups'])) |
|
| 578 | - list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
| 595 | + if (!empty($context['board']['moderator_groups'])) { |
|
| 596 | + list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
| 597 | + } |
|
| 579 | 598 | |
| 580 | 599 | // Get all the themes... |
| 581 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +606,9 @@ discard block |
||
| 587 | 606 | ) |
| 588 | 607 | ); |
| 589 | 608 | $context['themes'] = array(); |
| 590 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 591 | - $context['themes'][] = $row; |
|
| 609 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 610 | + $context['themes'][] = $row; |
|
| 611 | + } |
|
| 592 | 612 | $smcFunc['db_free_result']($request); |
| 593 | 613 | |
| 594 | 614 | if (!isset($_REQUEST['delete'])) |
@@ -596,8 +616,7 @@ discard block |
||
| 596 | 616 | $context['sub_template'] = 'modify_board'; |
| 597 | 617 | $context['page_title'] = $txt['boardsEdit']; |
| 598 | 618 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 599 | - } |
|
| 600 | - else |
|
| 619 | + } else |
|
| 601 | 620 | { |
| 602 | 621 | $context['sub_template'] = 'confirm_board_delete'; |
| 603 | 622 | $context['page_title'] = $txt['mboards_delete_board']; |
@@ -641,8 +660,9 @@ discard block |
||
| 641 | 660 | // Change the boardorder of this board? |
| 642 | 661 | elseif (!empty($_POST['placement']) && !empty($_POST['board_order'])) |
| 643 | 662 | { |
| 644 | - if (!in_array($_POST['placement'], array('before', 'after', 'child'))) |
|
| 645 | - fatal_lang_error('mangled_post', false); |
|
| 663 | + if (!in_array($_POST['placement'], array('before', 'after', 'child'))) { |
|
| 664 | + fatal_lang_error('mangled_post', false); |
|
| 665 | + } |
|
| 646 | 666 | |
| 647 | 667 | $boardOptions['move_to'] = $_POST['placement']; |
| 648 | 668 | $boardOptions['target_board'] = (int) $_POST['board_order']; |
@@ -655,13 +675,14 @@ discard block |
||
| 655 | 675 | $boardOptions['access_groups'] = array(); |
| 656 | 676 | $boardOptions['deny_groups'] = array(); |
| 657 | 677 | |
| 658 | - if (!empty($_POST['groups'])) |
|
| 659 | - foreach ($_POST['groups'] as $group => $action) |
|
| 678 | + if (!empty($_POST['groups'])) { |
|
| 679 | + foreach ($_POST['groups'] as $group => $action) |
|
| 660 | 680 | { |
| 661 | 681 | if ($action == 'allow') |
| 662 | 682 | $boardOptions['access_groups'][] = (int) $group; |
| 663 | - elseif ($action == 'deny') |
|
| 664 | - $boardOptions['deny_groups'][] = (int) $group; |
|
| 683 | + } elseif ($action == 'deny') { |
|
| 684 | + $boardOptions['deny_groups'][] = (int) $group; |
|
| 685 | + } |
|
| 665 | 686 | } |
| 666 | 687 | |
| 667 | 688 | // People with manage-boards are special. |
@@ -673,8 +694,9 @@ discard block |
||
| 673 | 694 | // Secondly, make sure those with super cow powers (like apt-get, or in this case manage boards) are upgraded. |
| 674 | 695 | $boardOptions['access_groups'] = array_unique(array_merge($boardOptions['access_groups'], $board_managers)); |
| 675 | 696 | |
| 676 | - if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
|
| 677 | - fatal_lang_error('too_many_groups', false); |
|
| 697 | + if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) { |
|
| 698 | + fatal_lang_error('too_many_groups', false); |
|
| 699 | + } |
|
| 678 | 700 | |
| 679 | 701 | // Do not allow HTML tags. Parse the string. |
| 680 | 702 | $boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']); |
@@ -685,8 +707,9 @@ discard block |
||
| 685 | 707 | if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list'])) |
| 686 | 708 | { |
| 687 | 709 | $moderators = array(); |
| 688 | - foreach ($_POST['moderator_list'] as $moderator) |
|
| 689 | - $moderators[(int) $moderator] = (int) $moderator; |
|
| 710 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
| 711 | + $moderators[(int) $moderator] = (int) $moderator; |
|
| 712 | + } |
|
| 690 | 713 | $boardOptions['moderators'] = $moderators; |
| 691 | 714 | } |
| 692 | 715 | |
@@ -695,8 +718,9 @@ discard block |
||
| 695 | 718 | if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list'])) |
| 696 | 719 | { |
| 697 | 720 | $moderator_groups = array(); |
| 698 | - foreach ($_POST['moderator_group_list'] as $moderator_group) |
|
| 699 | - $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
| 721 | + foreach ($_POST['moderator_group_list'] as $moderator_group) { |
|
| 722 | + $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
| 723 | + } |
|
| 700 | 724 | $boardOptions['moderator_groups'] = $moderator_groups; |
| 701 | 725 | } |
| 702 | 726 | |
@@ -722,56 +746,62 @@ discard block |
||
| 722 | 746 | $smcFunc['db_free_result']($request); |
| 723 | 747 | |
| 724 | 748 | // 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. |
| 725 | - if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) |
|
| 726 | - unset($boardOptions['redirect']); |
|
| 749 | + if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) { |
|
| 750 | + unset($boardOptions['redirect']); |
|
| 751 | + } |
|
| 727 | 752 | // Reset the redirection count when switching on/off. |
| 728 | - elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) |
|
| 729 | - $boardOptions['num_posts'] = 0; |
|
| 753 | + elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) { |
|
| 754 | + $boardOptions['num_posts'] = 0; |
|
| 755 | + } |
|
| 730 | 756 | // Resetting the count? |
| 731 | - elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) |
|
| 732 | - $boardOptions['num_posts'] = 0; |
|
| 757 | + elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) { |
|
| 758 | + $boardOptions['num_posts'] = 0; |
|
| 759 | + } |
|
| 733 | 760 | } |
| 734 | 761 | |
| 735 | 762 | // Create a new board... |
| 736 | 763 | if (isset($_POST['add'])) |
| 737 | 764 | { |
| 738 | 765 | // New boards by default go to the bottom of the category. |
| 739 | - if (empty($_POST['new_cat'])) |
|
| 740 | - $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
| 741 | - if (!isset($boardOptions['move_to'])) |
|
| 742 | - $boardOptions['move_to'] = 'bottom'; |
|
| 766 | + if (empty($_POST['new_cat'])) { |
|
| 767 | + $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
| 768 | + } |
|
| 769 | + if (!isset($boardOptions['move_to'])) { |
|
| 770 | + $boardOptions['move_to'] = 'bottom'; |
|
| 771 | + } |
|
| 743 | 772 | |
| 744 | 773 | createBoard($boardOptions); |
| 745 | 774 | } |
| 746 | 775 | |
| 747 | 776 | // ...or update an existing board. |
| 748 | - else |
|
| 749 | - modifyBoard($_POST['boardid'], $boardOptions); |
|
| 750 | - } |
|
| 751 | - elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
| 777 | + else { |
|
| 778 | + modifyBoard($_POST['boardid'], $boardOptions); |
|
| 779 | + } |
|
| 780 | + } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
| 752 | 781 | { |
| 753 | 782 | EditBoard(); |
| 754 | 783 | return; |
| 755 | - } |
|
| 756 | - elseif (isset($_POST['delete'])) |
|
| 784 | + } elseif (isset($_POST['delete'])) |
|
| 757 | 785 | { |
| 758 | 786 | // First off - check if we are moving all the current child boards first - before we start deleting! |
| 759 | 787 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
| 760 | 788 | { |
| 761 | - if (empty($_POST['board_to'])) |
|
| 762 | - fatal_lang_error('mboards_delete_board_error'); |
|
| 789 | + if (empty($_POST['board_to'])) { |
|
| 790 | + fatal_lang_error('mboards_delete_board_error'); |
|
| 791 | + } |
|
| 763 | 792 | |
| 764 | 793 | deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']); |
| 794 | + } else { |
|
| 795 | + deleteBoards(array($_POST['boardid']), 0); |
|
| 765 | 796 | } |
| 766 | - else |
|
| 767 | - deleteBoards(array($_POST['boardid']), 0); |
|
| 768 | 797 | } |
| 769 | 798 | |
| 770 | - if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') |
|
| 771 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 772 | - else |
|
| 773 | - redirectexit('action=admin;area=manageboards'); |
|
| 774 | -} |
|
| 799 | + if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') { |
|
| 800 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 801 | + } else { |
|
| 802 | + redirectexit('action=admin;area=manageboards'); |
|
| 803 | + } |
|
| 804 | + } |
|
| 775 | 805 | |
| 776 | 806 | /** |
| 777 | 807 | * Used to retrieve data for modifying a board category |
@@ -808,8 +838,9 @@ discard block |
||
| 808 | 838 | $smcFunc['db_free_result']($request); |
| 809 | 839 | |
| 810 | 840 | // This would probably never happen, but just to be sure. |
| 811 | - if ($cat .= $allowed_sa[1]) |
|
| 812 | - die(str_replace(',', ' to', $cat)); |
|
| 841 | + if ($cat .= $allowed_sa[1]) { |
|
| 842 | + die(str_replace(',', ' to', $cat)); |
|
| 843 | + } |
|
| 813 | 844 | |
| 814 | 845 | redirectexit(); |
| 815 | 846 | } |
@@ -835,8 +866,9 @@ discard block |
||
| 835 | 866 | 'empty_string' => '', |
| 836 | 867 | ) |
| 837 | 868 | ); |
| 838 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 839 | - $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
| 869 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 870 | + $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
| 871 | + } |
|
| 840 | 872 | $smcFunc['db_free_result']($request); |
| 841 | 873 | |
| 842 | 874 | require_once($sourcedir . '/Subs-Boards.php'); |
@@ -860,8 +892,9 @@ discard block |
||
| 860 | 892 | |
| 861 | 893 | call_integration_hook('integrate_modify_board_settings', array(&$config_vars)); |
| 862 | 894 | |
| 863 | - if ($return_config) |
|
| 864 | - return $config_vars; |
|
| 895 | + if ($return_config) { |
|
| 896 | + return $config_vars; |
|
| 897 | + } |
|
| 865 | 898 | |
| 866 | 899 | // Needed for the settings template. |
| 867 | 900 | require_once($sourcedir . '/ManageServer.php'); |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Converts the given UTF-8 string into lowercase. |
@@ -569,8 +570,8 @@ discard block |
||
| 569 | 570 | ); |
| 570 | 571 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 571 | 572 | { |
| 572 | - if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
| 573 | - $smcFunc['db_query']('', ' |
|
| 573 | + if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
| 574 | + $smcFunc['db_query']('', ' |
|
| 574 | 575 | UPDATE {db_prefix}log_actions |
| 575 | 576 | SET extra = {string:extra} |
| 576 | 577 | WHERE id_action = {int:current_action}', |
@@ -579,6 +580,7 @@ discard block |
||
| 579 | 580 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 580 | 581 | ) |
| 581 | 582 | ); |
| 583 | + } |
|
| 582 | 584 | } |
| 583 | 585 | $smcFunc['db_free_result']($request); |
| 584 | 586 | |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | $supported = class_exists('memcached'); |
| 36 | 37 | |
| 37 | - if ($test) |
|
| 38 | - return $supported; |
|
| 38 | + if ($test) { |
|
| 39 | + return $supported; |
|
| 40 | + } |
|
| 39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
| 40 | 42 | } |
| 41 | 43 | |
@@ -54,9 +56,9 @@ discard block |
||
| 54 | 56 | $currentServers = $this->memcached->getServerList(); |
| 55 | 57 | foreach ($servers as $server) |
| 56 | 58 | { |
| 57 | - if (strpos($server,'/') !== false) |
|
| 58 | - $tempServer = array($server, 0); |
|
| 59 | - else |
|
| 59 | + if (strpos($server,'/') !== false) { |
|
| 60 | + $tempServer = array($server, 0); |
|
| 61 | + } else |
|
| 60 | 62 | { |
| 61 | 63 | $server = explode(':', $server); |
| 62 | 64 | $tempServer = array($server[0], isset($server[1]) ? $server[1] : 11211); |
@@ -74,8 +76,9 @@ discard block |
||
| 74 | 76 | } |
| 75 | 77 | |
| 76 | 78 | // Found it? |
| 77 | - if (empty($foundServer)) |
|
| 78 | - $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
| 79 | + if (empty($foundServer)) { |
|
| 80 | + $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
| 81 | + } |
|
| 79 | 82 | } |
| 80 | 83 | |
| 81 | 84 | // Best guess is this worked. |
@@ -92,8 +95,9 @@ discard block |
||
| 92 | 95 | $value = $this->memcached->get($key); |
| 93 | 96 | |
| 94 | 97 | // $value should return either data or false (from failure, key not found or empty array). |
| 95 | - if ($value === false) |
|
| 96 | - return null; |
|
| 98 | + if ($value === false) { |
|
| 99 | + return null; |
|
| 100 | + } |
|
| 97 | 101 | return $value; |
| 98 | 102 | } |
| 99 | 103 | |
@@ -136,8 +140,9 @@ discard block |
||
| 136 | 140 | $config_vars[] = $txt['cache_memcache_settings']; |
| 137 | 141 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
| 138 | 142 | |
| 139 | - if (!isset($context['settings_post_javascript'])) |
|
| 140 | - $context['settings_post_javascript'] = ''; |
|
| 143 | + if (!isset($context['settings_post_javascript'])) { |
|
| 144 | + $context['settings_post_javascript'] = ''; |
|
| 145 | + } |
|
| 141 | 146 | |
| 142 | 147 | $context['settings_post_javascript'] .= ' |
| 143 | 148 | $("#cache_accelerator").change(function (e) { |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Display some useful/interesting board statistics. |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | |
| 31 | 32 | isAllowedTo('view_stats'); |
| 32 | 33 | // Page disabled - redirect them out |
| 33 | - if (empty($modSettings['trackStats'])) |
|
| 34 | - fatal_lang_error('feature_disabled', true); |
|
| 34 | + if (empty($modSettings['trackStats'])) { |
|
| 35 | + fatal_lang_error('feature_disabled', true); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | if (!empty($_REQUEST['expand'])) |
| 37 | 39 | { |
@@ -39,31 +41,34 @@ discard block |
||
| 39 | 41 | |
| 40 | 42 | $month = (int) substr($_REQUEST['expand'], 4); |
| 41 | 43 | $year = (int) substr($_REQUEST['expand'], 0, 4); |
| 42 | - if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) |
|
| 43 | - $_SESSION['expanded_stats'][$year][] = $month; |
|
| 44 | - } |
|
| 45 | - elseif (!empty($_REQUEST['collapse'])) |
|
| 44 | + if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) { |
|
| 45 | + $_SESSION['expanded_stats'][$year][] = $month; |
|
| 46 | + } |
|
| 47 | + } elseif (!empty($_REQUEST['collapse'])) |
|
| 46 | 48 | { |
| 47 | 49 | $context['robot_no_index'] = true; |
| 48 | 50 | |
| 49 | 51 | $month = (int) substr($_REQUEST['collapse'], 4); |
| 50 | 52 | $year = (int) substr($_REQUEST['collapse'], 0, 4); |
| 51 | - if (!empty($_SESSION['expanded_stats'][$year])) |
|
| 52 | - $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
| 53 | + if (!empty($_SESSION['expanded_stats'][$year])) { |
|
| 54 | + $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
| 55 | + } |
|
| 53 | 56 | } |
| 54 | 57 | |
| 55 | 58 | // Handle the XMLHttpRequest. |
| 56 | 59 | if (isset($_REQUEST['xml'])) |
| 57 | 60 | { |
| 58 | 61 | // Collapsing stats only needs adjustments of the session variables. |
| 59 | - if (!empty($_REQUEST['collapse'])) |
|
| 60 | - obExit(false); |
|
| 62 | + if (!empty($_REQUEST['collapse'])) { |
|
| 63 | + obExit(false); |
|
| 64 | + } |
|
| 61 | 65 | |
| 62 | 66 | $context['sub_template'] = 'stats'; |
| 63 | 67 | $context['yearly'] = array(); |
| 64 | 68 | |
| 65 | - if (empty($month) || empty($year)) |
|
| 66 | - return; |
|
| 69 | + if (empty($month) || empty($year)) { |
|
| 70 | + return; |
|
| 71 | + } |
|
| 67 | 72 | |
| 68 | 73 | getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month)); |
| 69 | 74 | $context['yearly'][$year]['months'][$month]['date'] = array( |
@@ -220,8 +225,9 @@ discard block |
||
| 220 | 225 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
| 221 | 226 | ); |
| 222 | 227 | |
| 223 | - if ($max_num_posts < $row_members['posts']) |
|
| 224 | - $max_num_posts = $row_members['posts']; |
|
| 228 | + if ($max_num_posts < $row_members['posts']) { |
|
| 229 | + $max_num_posts = $row_members['posts']; |
|
| 230 | + } |
|
| 225 | 231 | } |
| 226 | 232 | $smcFunc['db_free_result']($members_result); |
| 227 | 233 | |
@@ -257,8 +263,9 @@ discard block |
||
| 257 | 263 | 'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['name'] . '</a>' |
| 258 | 264 | ); |
| 259 | 265 | |
| 260 | - if ($max_num_posts < $row_board['num_posts']) |
|
| 261 | - $max_num_posts = $row_board['num_posts']; |
|
| 266 | + if ($max_num_posts < $row_board['num_posts']) { |
|
| 267 | + $max_num_posts = $row_board['num_posts']; |
|
| 268 | + } |
|
| 262 | 269 | } |
| 263 | 270 | $smcFunc['db_free_result']($boards_result); |
| 264 | 271 | |
@@ -284,12 +291,13 @@ discard block |
||
| 284 | 291 | ) |
| 285 | 292 | ); |
| 286 | 293 | $topic_ids = array(); |
| 287 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 288 | - $topic_ids[] = $row['id_topic']; |
|
| 294 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 295 | + $topic_ids[] = $row['id_topic']; |
|
| 296 | + } |
|
| 289 | 297 | $smcFunc['db_free_result']($request); |
| 298 | + } else { |
|
| 299 | + $topic_ids = array(); |
|
| 290 | 300 | } |
| 291 | - else |
|
| 292 | - $topic_ids = array(); |
|
| 293 | 301 | |
| 294 | 302 | // Topic replies top 10. |
| 295 | 303 | $topic_reply_result = $smcFunc['db_query']('', ' |
@@ -329,8 +337,9 @@ discard block |
||
| 329 | 337 | 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_reply['id_topic'] . '.0">' . $row_topic_reply['subject'] . '</a>' |
| 330 | 338 | ); |
| 331 | 339 | |
| 332 | - if ($max_num_replies < $row_topic_reply['num_replies']) |
|
| 333 | - $max_num_replies = $row_topic_reply['num_replies']; |
|
| 340 | + if ($max_num_replies < $row_topic_reply['num_replies']) { |
|
| 341 | + $max_num_replies = $row_topic_reply['num_replies']; |
|
| 342 | + } |
|
| 334 | 343 | } |
| 335 | 344 | $smcFunc['db_free_result']($topic_reply_result); |
| 336 | 345 | |
@@ -354,12 +363,13 @@ discard block |
||
| 354 | 363 | ) |
| 355 | 364 | ); |
| 356 | 365 | $topic_ids = array(); |
| 357 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 358 | - $topic_ids[] = $row['id_topic']; |
|
| 366 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 367 | + $topic_ids[] = $row['id_topic']; |
|
| 368 | + } |
|
| 359 | 369 | $smcFunc['db_free_result']($request); |
| 370 | + } else { |
|
| 371 | + $topic_ids = array(); |
|
| 360 | 372 | } |
| 361 | - else |
|
| 362 | - $topic_ids = array(); |
|
| 363 | 373 | |
| 364 | 374 | // Topic views top 10. |
| 365 | 375 | $topic_view_result = $smcFunc['db_query']('', ' |
@@ -399,8 +409,9 @@ discard block |
||
| 399 | 409 | 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . $row_topic_views['subject'] . '</a>' |
| 400 | 410 | ); |
| 401 | 411 | |
| 402 | - if ($max_num < $row_topic_views['num_views']) |
|
| 403 | - $max_num = $row_topic_views['num_views']; |
|
| 412 | + if ($max_num < $row_topic_views['num_views']) { |
|
| 413 | + $max_num = $row_topic_views['num_views']; |
|
| 414 | + } |
|
| 404 | 415 | } |
| 405 | 416 | $smcFunc['db_free_result']($topic_view_result); |
| 406 | 417 | |
@@ -425,15 +436,17 @@ discard block |
||
| 425 | 436 | ) |
| 426 | 437 | ); |
| 427 | 438 | $members = array(); |
| 428 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 429 | - $members[$row['id_member_started']] = $row['hits']; |
|
| 439 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 440 | + $members[$row['id_member_started']] = $row['hits']; |
|
| 441 | + } |
|
| 430 | 442 | $smcFunc['db_free_result']($request); |
| 431 | 443 | |
| 432 | 444 | cache_put_data('stats_top_starters', $members, 360); |
| 433 | 445 | } |
| 434 | 446 | |
| 435 | - if (empty($members)) |
|
| 436 | - $members = array(0 => 0); |
|
| 447 | + if (empty($members)) { |
|
| 448 | + $members = array(0 => 0); |
|
| 449 | + } |
|
| 437 | 450 | |
| 438 | 451 | // Topic poster top 10. |
| 439 | 452 | $members_result = $smcFunc['db_query']('', ' |
@@ -458,8 +471,9 @@ discard block |
||
| 458 | 471 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
| 459 | 472 | ); |
| 460 | 473 | |
| 461 | - if ($max_num < $members[$row_members['id_member']]) |
|
| 462 | - $max_num = $members[$row_members['id_member']]; |
|
| 474 | + if ($max_num < $members[$row_members['id_member']]) { |
|
| 475 | + $max_num = $members[$row_members['id_member']]; |
|
| 476 | + } |
|
| 463 | 477 | } |
| 464 | 478 | ksort($context['stats_blocks']['starters']); |
| 465 | 479 | $smcFunc['db_free_result']($members_result); |
@@ -488,8 +502,9 @@ discard block |
||
| 488 | 502 | while ($row_members = $smcFunc['db_fetch_assoc']($members_result)) |
| 489 | 503 | { |
| 490 | 504 | $temp2[] = (int) $row_members['id_member']; |
| 491 | - if (count($context['stats_blocks']['time_online']) >= 10) |
|
| 492 | - continue; |
|
| 505 | + if (count($context['stats_blocks']['time_online']) >= 10) { |
|
| 506 | + continue; |
|
| 507 | + } |
|
| 493 | 508 | |
| 494 | 509 | // Figure out the days, hours and minutes. |
| 495 | 510 | $timeDays = floor($row_members['total_time_logged_in'] / 86400); |
@@ -497,10 +512,12 @@ discard block |
||
| 497 | 512 | |
| 498 | 513 | // Figure out which things to show... (days, hours, minutes, etc.) |
| 499 | 514 | $timelogged = ''; |
| 500 | - if ($timeDays > 0) |
|
| 501 | - $timelogged .= $timeDays . $txt['totalTimeLogged5']; |
|
| 502 | - if ($timeHours > 0) |
|
| 503 | - $timelogged .= $timeHours . $txt['totalTimeLogged6']; |
|
| 515 | + if ($timeDays > 0) { |
|
| 516 | + $timelogged .= $timeDays . $txt['totalTimeLogged5']; |
|
| 517 | + } |
|
| 518 | + if ($timeHours > 0) { |
|
| 519 | + $timelogged .= $timeHours . $txt['totalTimeLogged6']; |
|
| 520 | + } |
|
| 504 | 521 | $timelogged .= floor(($row_members['total_time_logged_in'] % 3600) / 60) . $txt['totalTimeLogged7']; |
| 505 | 522 | |
| 506 | 523 | $context['stats_blocks']['time_online'][] = array( |
@@ -512,17 +529,20 @@ discard block |
||
| 512 | 529 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
| 513 | 530 | ); |
| 514 | 531 | |
| 515 | - if ($max_time_online < $row_members['total_time_logged_in']) |
|
| 516 | - $max_time_online = $row_members['total_time_logged_in']; |
|
| 532 | + if ($max_time_online < $row_members['total_time_logged_in']) { |
|
| 533 | + $max_time_online = $row_members['total_time_logged_in']; |
|
| 534 | + } |
|
| 517 | 535 | } |
| 518 | 536 | $smcFunc['db_free_result']($members_result); |
| 519 | 537 | |
| 520 | - foreach ($context['stats_blocks']['time_online'] as $i => $member) |
|
| 521 | - $context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online); |
|
| 538 | + foreach ($context['stats_blocks']['time_online'] as $i => $member) { |
|
| 539 | + $context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online); |
|
| 540 | + } |
|
| 522 | 541 | |
| 523 | 542 | // Cache the ones we found for a bit, just so we don't have to look again. |
| 524 | - if ($temp !== $temp2) |
|
| 525 | - cache_put_data('stats_total_time_members', $temp2, 480); |
|
| 543 | + if ($temp !== $temp2) { |
|
| 544 | + cache_put_data('stats_total_time_members', $temp2, 480); |
|
| 545 | + } |
|
| 526 | 546 | |
| 527 | 547 | // Likes. |
| 528 | 548 | if (!empty($modSettings['enable_likes'])) |
@@ -558,13 +578,15 @@ discard block |
||
| 558 | 578 | 'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>' |
| 559 | 579 | ); |
| 560 | 580 | |
| 561 | - if ($max_liked_message < $row_liked_message['likes']) |
|
| 562 | - $max_liked_message = $row_liked_message['likes']; |
|
| 581 | + if ($max_liked_message < $row_liked_message['likes']) { |
|
| 582 | + $max_liked_message = $row_liked_message['likes']; |
|
| 583 | + } |
|
| 563 | 584 | } |
| 564 | 585 | $smcFunc['db_free_result']($liked_messages); |
| 565 | 586 | |
| 566 | - foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) |
|
| 567 | - $context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message); |
|
| 587 | + foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) { |
|
| 588 | + $context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message); |
|
| 589 | + } |
|
| 568 | 590 | |
| 569 | 591 | // Liked users top 10. |
| 570 | 592 | $context['stats_blocks']['liked_users'] = array(); |
@@ -595,14 +617,16 @@ discard block |
||
| 595 | 617 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_liked_users['liked_user'] . '">' . $row_liked_users['real_name'] . '</a>', |
| 596 | 618 | ); |
| 597 | 619 | |
| 598 | - if ($max_liked_users < $row_liked_users['count']) |
|
| 599 | - $max_liked_users = $row_liked_users['count']; |
|
| 620 | + if ($max_liked_users < $row_liked_users['count']) { |
|
| 621 | + $max_liked_users = $row_liked_users['count']; |
|
| 622 | + } |
|
| 600 | 623 | } |
| 601 | 624 | |
| 602 | 625 | $smcFunc['db_free_result']($liked_users); |
| 603 | 626 | |
| 604 | - foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) |
|
| 605 | - $context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users); |
|
| 627 | + foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) { |
|
| 628 | + $context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users); |
|
| 629 | + } |
|
| 606 | 630 | } |
| 607 | 631 | |
| 608 | 632 | // Activity by month. |
@@ -620,8 +644,8 @@ discard block |
||
| 620 | 644 | $ID_MONTH = $row_months['stats_year'] . sprintf('%02d', $row_months['stats_month']); |
| 621 | 645 | $expanded = !empty($_SESSION['expanded_stats'][$row_months['stats_year']]) && in_array($row_months['stats_month'], $_SESSION['expanded_stats'][$row_months['stats_year']]); |
| 622 | 646 | |
| 623 | - if (!isset($context['yearly'][$row_months['stats_year']])) |
|
| 624 | - $context['yearly'][$row_months['stats_year']] = array( |
|
| 647 | + if (!isset($context['yearly'][$row_months['stats_year']])) { |
|
| 648 | + $context['yearly'][$row_months['stats_year']] = array( |
|
| 625 | 649 | 'year' => $row_months['stats_year'], |
| 626 | 650 | 'new_topics' => 0, |
| 627 | 651 | 'new_posts' => 0, |
@@ -633,6 +657,7 @@ discard block |
||
| 633 | 657 | 'expanded' => false, |
| 634 | 658 | 'current_year' => $row_months['stats_year'] == date('Y'), |
| 635 | 659 | ); |
| 660 | + } |
|
| 636 | 661 | |
| 637 | 662 | $context['yearly'][$row_months['stats_year']]['months'][(int) $row_months['stats_month']] = array( |
| 638 | 663 | 'id' => $ID_MONTH, |
@@ -678,26 +703,30 @@ discard block |
||
| 678 | 703 | $context['yearly'][$year]['hits'] = comma_format($data['hits']); |
| 679 | 704 | |
| 680 | 705 | // Keep a list of collapsed years. |
| 681 | - if (!$data['expanded'] && !$data['current_year']) |
|
| 682 | - $context['collapsed_years'][] = $year; |
|
| 706 | + if (!$data['expanded'] && !$data['current_year']) { |
|
| 707 | + $context['collapsed_years'][] = $year; |
|
| 708 | + } |
|
| 683 | 709 | } |
| 684 | 710 | |
| 685 | - if (empty($_SESSION['expanded_stats'])) |
|
| 686 | - return; |
|
| 711 | + if (empty($_SESSION['expanded_stats'])) { |
|
| 712 | + return; |
|
| 713 | + } |
|
| 687 | 714 | |
| 688 | 715 | $condition_text = array(); |
| 689 | 716 | $condition_params = array(); |
| 690 | - foreach ($_SESSION['expanded_stats'] as $year => $months) |
|
| 691 | - if (!empty($months)) |
|
| 717 | + foreach ($_SESSION['expanded_stats'] as $year => $months) { |
|
| 718 | + if (!empty($months)) |
|
| 692 | 719 | { |
| 693 | 720 | $condition_text[] = 'YEAR(date) = {int:year_' . $year . '} AND MONTH(date) IN ({array_int:months_' . $year . '})'; |
| 721 | + } |
|
| 694 | 722 | $condition_params['year_' . $year] = $year; |
| 695 | 723 | $condition_params['months_' . $year] = $months; |
| 696 | 724 | } |
| 697 | 725 | |
| 698 | 726 | // No daily stats to even look at? |
| 699 | - if (empty($condition_text)) |
|
| 700 | - return; |
|
| 727 | + if (empty($condition_text)) { |
|
| 728 | + return; |
|
| 729 | + } |
|
| 701 | 730 | |
| 702 | 731 | getDailyStats(implode(' OR ', $condition_text), $condition_params); |
| 703 | 732 | |
@@ -723,8 +752,8 @@ discard block |
||
| 723 | 752 | ORDER BY stats_day ASC', |
| 724 | 753 | $condition_parameters |
| 725 | 754 | ); |
| 726 | - while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) |
|
| 727 | - $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array( |
|
| 755 | + while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) { |
|
| 756 | + $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array( |
|
| 728 | 757 | 'day' => sprintf('%02d', $row_days['stats_day']), |
| 729 | 758 | 'month' => sprintf('%02d', $row_days['stats_month']), |
| 730 | 759 | 'year' => $row_days['stats_year'], |
@@ -734,6 +763,7 @@ discard block |
||
| 734 | 763 | 'most_members_online' => comma_format($row_days['most_on']), |
| 735 | 764 | 'hits' => comma_format($row_days['hits']) |
| 736 | 765 | ); |
| 766 | + } |
|
| 737 | 767 | $smcFunc['db_free_result']($days_result); |
| 738 | 768 | } |
| 739 | 769 | |
@@ -752,16 +782,19 @@ discard block |
||
| 752 | 782 | global $modSettings, $user_info, $forum_version, $sourcedir; |
| 753 | 783 | |
| 754 | 784 | // First, is it disabled? |
| 755 | - if (empty($modSettings['allow_sm_stats'])) |
|
| 756 | - die(); |
|
| 785 | + if (empty($modSettings['allow_sm_stats'])) { |
|
| 786 | + die(); |
|
| 787 | + } |
|
| 757 | 788 | |
| 758 | 789 | // Are we saying who we are, and are we right? (OR an admin) |
| 759 | - if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['allow_sm_stats'])) |
|
| 760 | - die(); |
|
| 790 | + if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['allow_sm_stats'])) { |
|
| 791 | + die(); |
|
| 792 | + } |
|
| 761 | 793 | |
| 762 | 794 | // Verify the referer... |
| 763 | - if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) |
|
| 764 | - die(); |
|
| 795 | + if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) { |
|
| 796 | + die(); |
|
| 797 | + } |
|
| 765 | 798 | |
| 766 | 799 | // Get some server versions. |
| 767 | 800 | require_once($sourcedir . '/Subs-Admin.php'); |
@@ -787,16 +820,17 @@ discard block |
||
| 787 | 820 | ); |
| 788 | 821 | |
| 789 | 822 | // Encode all the data, for security. |
| 790 | - foreach ($stats_to_send as $k => $v) |
|
| 791 | - $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v); |
|
| 823 | + foreach ($stats_to_send as $k => $v) { |
|
| 824 | + $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v); |
|
| 825 | + } |
|
| 792 | 826 | |
| 793 | 827 | // Turn this into the query string! |
| 794 | 828 | $stats_to_send = implode('&', $stats_to_send); |
| 795 | 829 | |
| 796 | 830 | // If we're an admin, just plonk them out. |
| 797 | - if ($user_info['is_admin']) |
|
| 798 | - echo $stats_to_send; |
|
| 799 | - else |
|
| 831 | + if ($user_info['is_admin']) { |
|
| 832 | + echo $stats_to_send; |
|
| 833 | + } else |
|
| 800 | 834 | { |
| 801 | 835 | // Connect to the collection script. |
| 802 | 836 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
| 98 | 99 | { |
| 99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
| 100 | 101 | |
| 101 | - foreach ($_POST['censortext'] as $c) |
|
| 102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 103 | - } |
|
| 104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 102 | + foreach ($_POST['censortext'] as $c) { |
|
| 103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 104 | + } |
|
| 105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 105 | 106 | { |
| 106 | 107 | if (is_array($_POST['censor_vulgar'])) |
| 107 | 108 | { |
| 108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
| 109 | 110 | { |
| 110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
| 111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
| 112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 113 | + } |
|
| 112 | 114 | } |
| 113 | 115 | |
| 114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
| 115 | 117 | $censored_proper = $_POST['censor_proper']; |
| 116 | - } |
|
| 117 | - else |
|
| 118 | + } else |
|
| 118 | 119 | { |
| 119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
| 120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
| 151 | 152 | $context['censored_words'] = array(); |
| 152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
| 153 | 154 | { |
| 154 | - if (empty($censor_vulgar[$i])) |
|
| 155 | - continue; |
|
| 155 | + if (empty($censor_vulgar[$i])) { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | // Skip it, it's either spaces or stars only. |
| 158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
| 159 | - continue; |
|
| 160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 160 | 163 | |
| 161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
| 162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
| 187 | 190 | |
| 188 | 191 | // Make an inline conditional a little shorter... |
| 189 | 192 | $can_spell_check = false; |
| 190 | - if (function_exists('pspell_new')) |
|
| 191 | - $can_spell_check = true; |
|
| 192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
| 193 | - $can_spell_check = true; |
|
| 193 | + if (function_exists('pspell_new')) { |
|
| 194 | + $can_spell_check = true; |
|
| 195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
| 196 | + $can_spell_check = true; |
|
| 197 | + } |
|
| 194 | 198 | |
| 195 | 199 | // All the settings... |
| 196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
| 221 | 225 | |
| 222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
| 223 | 227 | |
| 224 | - if ($return_config) |
|
| 225 | - return $config_vars; |
|
| 228 | + if ($return_config) { |
|
| 229 | + return $config_vars; |
|
| 230 | + } |
|
| 226 | 231 | |
| 227 | 232 | // We'll want this for our easy save. |
| 228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
| 242 | 247 | db_extend('packages'); |
| 243 | 248 | |
| 244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 245 | - foreach ($colData as $column) |
|
| 246 | - if ($column['name'] == 'body') |
|
| 250 | + foreach ($colData as $column) { |
|
| 251 | + if ($column['name'] == 'body') |
|
| 247 | 252 | $body_type = $column['type']; |
| 253 | + } |
|
| 248 | 254 | |
| 249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
| 250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
| 256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 257 | + } |
|
| 251 | 258 | } |
| 252 | 259 | |
| 253 | 260 | // If we're changing the post preview length let's check its valid |
| 254 | - if (!empty($_POST['preview_characters'])) |
|
| 255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 261 | + if (!empty($_POST['preview_characters'])) { |
|
| 262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 263 | + } |
|
| 256 | 264 | |
| 257 | 265 | call_integration_hook('integrate_save_post_settings'); |
| 258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
| 313 | 321 | |
| 314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
| 315 | 323 | |
| 316 | - if ($return_config) |
|
| 317 | - return $config_vars; |
|
| 324 | + if ($return_config) { |
|
| 325 | + return $config_vars; |
|
| 326 | + } |
|
| 318 | 327 | |
| 319 | 328 | // Get the settings template ready. |
| 320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
| 367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
| 368 | 377 | ); |
| 369 | 378 | |
| 370 | - if ($return_config) |
|
| 371 | - return $config_vars; |
|
| 379 | + if ($return_config) { |
|
| 380 | + return $config_vars; |
|
| 381 | + } |
|
| 372 | 382 | |
| 373 | 383 | // Get the settings template ready. |
| 374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Log an error, if the error logging is enabled. |
@@ -36,8 +37,9 @@ discard block |
||
| 36 | 37 | static $tried_hook = false; |
| 37 | 38 | |
| 38 | 39 | // Check if error logging is actually on. |
| 39 | - if (empty($modSettings['enableErrorLogging'])) |
|
| 40 | - return $error_message; |
|
| 40 | + if (empty($modSettings['enableErrorLogging'])) { |
|
| 41 | + return $error_message; |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | 44 | // Basically, htmlspecialchars it minus &. (for entities!) |
| 43 | 45 | $error_message = strtr($error_message, array('<' => '<', '>' => '>', '"' => '"')); |
@@ -45,22 +47,26 @@ discard block |
||
| 45 | 47 | |
| 46 | 48 | // Add a file and line to the error message? |
| 47 | 49 | // Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line |
| 48 | - if ($file == null) |
|
| 49 | - $file = ''; |
|
| 50 | - else |
|
| 51 | - // Window style slashes don't play well, lets convert them to the unix style. |
|
| 50 | + if ($file == null) { |
|
| 51 | + $file = ''; |
|
| 52 | + } else { |
|
| 53 | + // Window style slashes don't play well, lets convert them to the unix style. |
|
| 52 | 54 | $file = str_replace('\\', '/', $file); |
| 55 | + } |
|
| 53 | 56 | |
| 54 | - if ($line == null) |
|
| 55 | - $line = 0; |
|
| 56 | - else |
|
| 57 | - $line = (int) $line; |
|
| 57 | + if ($line == null) { |
|
| 58 | + $line = 0; |
|
| 59 | + } else { |
|
| 60 | + $line = (int) $line; |
|
| 61 | + } |
|
| 58 | 62 | |
| 59 | 63 | // Just in case there's no id_member or IP set yet. |
| 60 | - if (empty($user_info['id'])) |
|
| 61 | - $user_info['id'] = 0; |
|
| 62 | - if (empty($user_info['ip'])) |
|
| 63 | - $user_info['ip'] = ''; |
|
| 64 | + if (empty($user_info['id'])) { |
|
| 65 | + $user_info['id'] = 0; |
|
| 66 | + } |
|
| 67 | + if (empty($user_info['ip'])) { |
|
| 68 | + $user_info['ip'] = ''; |
|
| 69 | + } |
|
| 64 | 70 | |
| 65 | 71 | // Find the best query string we can... |
| 66 | 72 | $query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING']; |
@@ -69,8 +75,9 @@ discard block |
||
| 69 | 75 | $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
| 70 | 76 | |
| 71 | 77 | // Just so we know what board error messages are from. |
| 72 | - if (isset($_POST['board']) && !isset($_GET['board'])) |
|
| 73 | - $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
| 78 | + if (isset($_POST['board']) && !isset($_GET['board'])) { |
|
| 79 | + $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
| 80 | + } |
|
| 74 | 81 | |
| 75 | 82 | // What types of categories do we have? |
| 76 | 83 | $known_error_types = array( |
@@ -132,12 +139,14 @@ discard block |
||
| 132 | 139 | global $txt; |
| 133 | 140 | |
| 134 | 141 | // Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all |
| 135 | - if (!empty($status)) |
|
| 136 | - send_http_status($status); |
|
| 142 | + if (!empty($status)) { |
|
| 143 | + send_http_status($status); |
|
| 144 | + } |
|
| 137 | 145 | |
| 138 | 146 | // We don't have $txt yet, but that's okay... |
| 139 | - if (empty($txt)) |
|
| 140 | - die($error); |
|
| 147 | + if (empty($txt)) { |
|
| 148 | + die($error); |
|
| 149 | + } |
|
| 141 | 150 | |
| 142 | 151 | log_error_online($error, false); |
| 143 | 152 | setup_fatal_error_context($log ? log_error($error, $log) : $error); |
@@ -164,8 +173,9 @@ discard block |
||
| 164 | 173 | static $fatal_error_called = false; |
| 165 | 174 | |
| 166 | 175 | // Send the status header - set this to 0 or false if you don't want to send one at all |
| 167 | - if (!empty($status)) |
|
| 168 | - send_http_status($status); |
|
| 176 | + if (!empty($status)) { |
|
| 177 | + send_http_status($status); |
|
| 178 | + } |
|
| 169 | 179 | |
| 170 | 180 | // Try to load a theme if we don't have one. |
| 171 | 181 | if (empty($context['theme_loaded']) && empty($fatal_error_called)) |
@@ -175,8 +185,9 @@ discard block |
||
| 175 | 185 | } |
| 176 | 186 | |
| 177 | 187 | // If we have no theme stuff we can't have the language file... |
| 178 | - if (empty($context['theme_loaded'])) |
|
| 179 | - die($error); |
|
| 188 | + if (empty($context['theme_loaded'])) { |
|
| 189 | + die($error); |
|
| 190 | + } |
|
| 180 | 191 | |
| 181 | 192 | $reload_lang_file = true; |
| 182 | 193 | // Log the error in the forum's language, but don't waste the time if we aren't logging |
@@ -212,8 +223,9 @@ discard block |
||
| 212 | 223 | global $settings, $modSettings, $db_show_debug; |
| 213 | 224 | |
| 214 | 225 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.) |
| 215 | - if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) |
|
| 216 | - return; |
|
| 226 | + if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) { |
|
| 227 | + return; |
|
| 228 | + } |
|
| 217 | 229 | |
| 218 | 230 | if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename'])) |
| 219 | 231 | { |
@@ -221,19 +233,22 @@ discard block |
||
| 221 | 233 | $count = count($array); |
| 222 | 234 | for ($i = 0; $i < $count; $i++) |
| 223 | 235 | { |
| 224 | - if ($array[$i]['function'] != 'loadSubTemplate') |
|
| 225 | - continue; |
|
| 236 | + if ($array[$i]['function'] != 'loadSubTemplate') { |
|
| 237 | + continue; |
|
| 238 | + } |
|
| 226 | 239 | |
| 227 | 240 | // This is a bug in PHP, with eval, it seems! |
| 228 | - if (empty($array[$i]['args'])) |
|
| 229 | - $i++; |
|
| 241 | + if (empty($array[$i]['args'])) { |
|
| 242 | + $i++; |
|
| 243 | + } |
|
| 230 | 244 | break; |
| 231 | 245 | } |
| 232 | 246 | |
| 233 | - if (isset($array[$i]) && !empty($array[$i]['args'])) |
|
| 234 | - $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
| 235 | - else |
|
| 236 | - $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
| 247 | + if (isset($array[$i]) && !empty($array[$i]['args'])) { |
|
| 248 | + $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
| 249 | + } else { |
|
| 250 | + $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
| 251 | + } |
|
| 237 | 252 | } |
| 238 | 253 | |
| 239 | 254 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -242,8 +257,9 @@ discard block |
||
| 242 | 257 | if ($error_level % 255 != E_ERROR) |
| 243 | 258 | { |
| 244 | 259 | $temporary = ob_get_contents(); |
| 245 | - if (substr($temporary, -2) == '="') |
|
| 246 | - echo '"'; |
|
| 260 | + if (substr($temporary, -2) == '="') { |
|
| 261 | + echo '"'; |
|
| 262 | + } |
|
| 247 | 263 | } |
| 248 | 264 | |
| 249 | 265 | // Debugging! This should look like a PHP error message. |
@@ -259,23 +275,27 @@ discard block |
||
| 259 | 275 | call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); |
| 260 | 276 | |
| 261 | 277 | // Dying on these errors only causes MORE problems (blank pages!) |
| 262 | - if ($file == 'Unknown') |
|
| 263 | - return; |
|
| 278 | + if ($file == 'Unknown') { |
|
| 279 | + return; |
|
| 280 | + } |
|
| 264 | 281 | |
| 265 | 282 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
| 266 | - if ($error_level % 255 == E_ERROR) |
|
| 267 | - obExit(false); |
|
| 268 | - else |
|
| 269 | - return; |
|
| 283 | + if ($error_level % 255 == E_ERROR) { |
|
| 284 | + obExit(false); |
|
| 285 | + } else { |
|
| 286 | + return; |
|
| 287 | + } |
|
| 270 | 288 | |
| 271 | 289 | // If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die. Violently so. |
| 272 | - if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) |
|
| 273 | - fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
| 290 | + if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) { |
|
| 291 | + fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
| 292 | + } |
|
| 274 | 293 | |
| 275 | 294 | // We should NEVER get to this point. Any fatal error MUST quit, or very bad things can happen. |
| 276 | - if ($error_level % 255 == E_ERROR) |
|
| 277 | - die('No direct access...'); |
|
| 278 | -} |
|
| 295 | + if ($error_level % 255 == E_ERROR) { |
|
| 296 | + die('No direct access...'); |
|
| 297 | + } |
|
| 298 | + } |
|
| 279 | 299 | |
| 280 | 300 | /** |
| 281 | 301 | * It is called by {@link fatal_error()} and {@link fatal_lang_error()}. |
@@ -291,24 +311,28 @@ discard block |
||
| 291 | 311 | |
| 292 | 312 | // Attempt to prevent a recursive loop. |
| 293 | 313 | ++$level; |
| 294 | - if ($level > 1) |
|
| 295 | - return false; |
|
| 314 | + if ($level > 1) { |
|
| 315 | + return false; |
|
| 316 | + } |
|
| 296 | 317 | |
| 297 | 318 | // Maybe they came from dlattach or similar? |
| 298 | - if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) |
|
| 299 | - loadTheme(); |
|
| 319 | + if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) { |
|
| 320 | + loadTheme(); |
|
| 321 | + } |
|
| 300 | 322 | |
| 301 | 323 | // Don't bother indexing errors mate... |
| 302 | 324 | $context['robot_no_index'] = true; |
| 303 | 325 | |
| 304 | - if (!isset($context['error_title'])) |
|
| 305 | - $context['error_title'] = $txt['error_occured']; |
|
| 326 | + if (!isset($context['error_title'])) { |
|
| 327 | + $context['error_title'] = $txt['error_occured']; |
|
| 328 | + } |
|
| 306 | 329 | $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message; |
| 307 | 330 | |
| 308 | 331 | $context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : ''; |
| 309 | 332 | |
| 310 | - if (empty($context['page_title'])) |
|
| 311 | - $context['page_title'] = $context['error_title']; |
|
| 333 | + if (empty($context['page_title'])) { |
|
| 334 | + $context['page_title'] = $context['error_title']; |
|
| 335 | + } |
|
| 312 | 336 | |
| 313 | 337 | loadTemplate('Errors'); |
| 314 | 338 | $context['sub_template'] = 'fatal_error'; |
@@ -316,23 +340,26 @@ discard block |
||
| 316 | 340 | // If this is SSI, what do they want us to do? |
| 317 | 341 | if (SMF == 'SSI') |
| 318 | 342 | { |
| 319 | - if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) |
|
| 320 | - $ssi_on_error_method(); |
|
| 321 | - elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
| 322 | - loadSubTemplate('fatal_error'); |
|
| 343 | + if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) { |
|
| 344 | + $ssi_on_error_method(); |
|
| 345 | + } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
| 346 | + loadSubTemplate('fatal_error'); |
|
| 347 | + } |
|
| 323 | 348 | |
| 324 | 349 | // No layers? |
| 325 | - if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
| 326 | - exit; |
|
| 350 | + if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
| 351 | + exit; |
|
| 352 | + } |
|
| 327 | 353 | } |
| 328 | 354 | // Alternatively from the cron call? |
| 329 | 355 | elseif (SMF == 'BACKGROUND') |
| 330 | 356 | { |
| 331 | 357 | // We can't rely on even having language files available. |
| 332 | - if (defined('FROM_CLI') && FROM_CLI) |
|
| 333 | - echo 'cron error: ', $context['error_message']; |
|
| 334 | - else |
|
| 335 | - echo 'An error occurred. More information may be available in your logs.'; |
|
| 358 | + if (defined('FROM_CLI') && FROM_CLI) { |
|
| 359 | + echo 'cron error: ', $context['error_message']; |
|
| 360 | + } else { |
|
| 361 | + echo 'An error occurred. More information may be available in your logs.'; |
|
| 362 | + } |
|
| 336 | 363 | exit; |
| 337 | 364 | } |
| 338 | 365 | |
@@ -360,8 +387,8 @@ discard block |
||
| 360 | 387 | |
| 361 | 388 | set_fatal_error_headers(); |
| 362 | 389 | |
| 363 | - if (!empty($maintenance)) |
|
| 364 | - echo '<!DOCTYPE html> |
|
| 390 | + if (!empty($maintenance)) { |
|
| 391 | + echo '<!DOCTYPE html> |
|
| 365 | 392 | <html> |
| 366 | 393 | <head> |
| 367 | 394 | <meta name="robots" content="noindex"> |
@@ -372,6 +399,7 @@ discard block |
||
| 372 | 399 | ', $mmessage, ' |
| 373 | 400 | </body> |
| 374 | 401 | </html>'; |
| 402 | + } |
|
| 375 | 403 | |
| 376 | 404 | die(); |
| 377 | 405 | } |
@@ -393,15 +421,17 @@ discard block |
||
| 393 | 421 | // For our purposes, we're gonna want this on if at all possible. |
| 394 | 422 | $modSettings['cache_enable'] = '1'; |
| 395 | 423 | |
| 396 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
| 397 | - $db_last_error = max($db_last_error, $temp); |
|
| 424 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
| 425 | + $db_last_error = max($db_last_error, $temp); |
|
| 426 | + } |
|
| 398 | 427 | |
| 399 | 428 | if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) |
| 400 | 429 | { |
| 401 | 430 | // Avoid writing to the Settings.php file if at all possible; use shared memory instead. |
| 402 | 431 | cache_put_data('db_last_error', time(), 600); |
| 403 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
| 404 | - logLastDatabaseError(); |
|
| 432 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
| 433 | + logLastDatabaseError(); |
|
| 434 | + } |
|
| 405 | 435 | |
| 406 | 436 | // Language files aren't loaded yet :(. |
| 407 | 437 | $db_error = @$smcFunc['db_error']($db_connection); |
@@ -482,12 +512,14 @@ discard block |
||
| 482 | 512 | global $smcFunc, $user_info, $modSettings; |
| 483 | 513 | |
| 484 | 514 | // Don't bother if Who's Online is disabled. |
| 485 | - if (empty($modSettings['who_enabled'])) |
|
| 486 | - return; |
|
| 515 | + if (empty($modSettings['who_enabled'])) { |
|
| 516 | + return; |
|
| 517 | + } |
|
| 487 | 518 | |
| 488 | 519 | // Maybe they came from SSI or similar where sessions are not recorded? |
| 489 | - if (SMF == 'SSI' || SMF == 'BACKGROUND') |
|
| 490 | - return; |
|
| 520 | + if (SMF == 'SSI' || SMF == 'BACKGROUND') { |
|
| 521 | + return; |
|
| 522 | + } |
|
| 491 | 523 | |
| 492 | 524 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
| 493 | 525 | |
@@ -506,8 +538,9 @@ discard block |
||
| 506 | 538 | $url = smf_json_decode($url, true); |
| 507 | 539 | $url['error'] = $error; |
| 508 | 540 | |
| 509 | - if (!empty($sprintf)) |
|
| 510 | - $url['error_params'] = $sprintf; |
|
| 541 | + if (!empty($sprintf)) { |
|
| 542 | + $url['error_params'] = $sprintf; |
|
| 543 | + } |
|
| 511 | 544 | |
| 512 | 545 | $smcFunc['db_query']('', ' |
| 513 | 546 | UPDATE {db_prefix}log_online |
@@ -538,10 +571,11 @@ discard block |
||
| 538 | 571 | |
| 539 | 572 | $protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; |
| 540 | 573 | |
| 541 | - if (!isset($statuses[$code])) |
|
| 542 | - header($protocol . ' 500 Internal Server Error'); |
|
| 543 | - else |
|
| 544 | - header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
| 545 | -} |
|
| 574 | + if (!isset($statuses[$code])) { |
|
| 575 | + header($protocol . ' 500 Internal Server Error'); |
|
| 576 | + } else { |
|
| 577 | + header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
| 578 | + } |
|
| 579 | + } |
|
| 546 | 580 | |
| 547 | 581 | ?> |
| 548 | 582 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -23,14 +24,15 @@ discard block |
||
| 23 | 24 | { |
| 24 | 25 | global $smcFunc; |
| 25 | 26 | |
| 26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') |
|
| 27 | - $smcFunc += array( |
|
| 27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') { |
|
| 28 | + $smcFunc += array( |
|
| 28 | 29 | 'db_search_query' => 'smf_db_query', |
| 29 | 30 | 'db_search_support' => 'smf_db_search_support', |
| 30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
| 31 | 32 | 'db_support_ignore' => true, |
| 32 | 33 | ); |
| 33 | -} |
|
| 34 | + } |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | /** |
| 36 | 38 | * This function will tell you whether this database type supports this search type. |
@@ -54,12 +56,13 @@ discard block |
||
| 54 | 56 | { |
| 55 | 57 | global $smcFunc; |
| 56 | 58 | |
| 57 | - if ($size == 'small') |
|
| 58 | - $size = 'smallint(5)'; |
|
| 59 | - elseif ($size == 'medium') |
|
| 60 | - $size = 'mediumint(8)'; |
|
| 61 | - else |
|
| 62 | - $size = 'int(10)'; |
|
| 59 | + if ($size == 'small') { |
|
| 60 | + $size = 'smallint(5)'; |
|
| 61 | + } elseif ($size == 'medium') { |
|
| 62 | + $size = 'mediumint(8)'; |
|
| 63 | + } else { |
|
| 64 | + $size = 'int(10)'; |
|
| 65 | + } |
|
| 63 | 66 | |
| 64 | 67 | $smcFunc['db_query']('', ' |
| 65 | 68 | CREATE TABLE {db_prefix}log_search_words ( |