@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Class 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 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * 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 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Dispatches to the right function based on the given subaction. |
@@ -176,8 +177,9 @@ discard block |
||
| 176 | 177 | // If it's inherited, just add it as a child. |
| 177 | 178 | if ($row['id_parent'] != -2) |
| 178 | 179 | { |
| 179 | - if (isset($context['groups'][$row['id_parent']])) |
|
| 180 | - $context['groups'][$row['id_parent']]['children'][$row['id_group']] = $row['group_name']; |
|
| 180 | + if (isset($context['groups'][$row['id_parent']])) { |
|
| 181 | + $context['groups'][$row['id_parent']]['children'][$row['id_group']] = $row['group_name']; |
|
| 182 | + } |
|
| 181 | 183 | continue; |
| 182 | 184 | } |
| 183 | 185 | |
@@ -202,10 +204,11 @@ discard block |
||
| 202 | 204 | 'access' => false, |
| 203 | 205 | ); |
| 204 | 206 | |
| 205 | - if ($row['min_posts'] == -1) |
|
| 206 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
| 207 | - else |
|
| 208 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
| 207 | + if ($row['min_posts'] == -1) { |
|
| 208 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
| 209 | + } else { |
|
| 210 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
| 211 | + } |
|
| 209 | 212 | } |
| 210 | 213 | $smcFunc['db_free_result']($query); |
| 211 | 214 | |
@@ -221,8 +224,9 @@ discard block |
||
| 221 | 224 | 'post_group_list' => $postGroups, |
| 222 | 225 | ) |
| 223 | 226 | ); |
| 224 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 225 | - $context['groups'][$row['id_group']]['num_members'] += $row['num_members']; |
|
| 227 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 228 | + $context['groups'][$row['id_group']]['num_members'] += $row['num_members']; |
|
| 229 | + } |
|
| 226 | 230 | $smcFunc['db_free_result']($query); |
| 227 | 231 | } |
| 228 | 232 | |
@@ -238,8 +242,9 @@ discard block |
||
| 238 | 242 | 'normal_group_list' => $normalGroups, |
| 239 | 243 | ) |
| 240 | 244 | ); |
| 241 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 242 | - $context['groups'][$row['id_group']]['num_members'] += $row['num_members']; |
|
| 245 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 246 | + $context['groups'][$row['id_group']]['num_members'] += $row['num_members']; |
|
| 247 | + } |
|
| 243 | 248 | $smcFunc['db_free_result']($query); |
| 244 | 249 | |
| 245 | 250 | // This one is slower, but it's okay... careful not to count twice! |
@@ -256,15 +261,17 @@ discard block |
||
| 256 | 261 | 'blank_string' => '', |
| 257 | 262 | ) |
| 258 | 263 | ); |
| 259 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 260 | - $context['groups'][$row['id_group']]['num_members'] += $row['num_members']; |
|
| 264 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 265 | + $context['groups'][$row['id_group']]['num_members'] += $row['num_members']; |
|
| 266 | + } |
|
| 261 | 267 | $smcFunc['db_free_result']($query); |
| 262 | 268 | } |
| 263 | 269 | |
| 264 | 270 | foreach ($context['groups'] as $id => $data) |
| 265 | 271 | { |
| 266 | - if ($data['href'] != '') |
|
| 267 | - $context['groups'][$id]['link'] = '<a href="' . $data['href'] . '">' . $data['num_members'] . '</a>'; |
|
| 272 | + if ($data['href'] != '') { |
|
| 273 | + $context['groups'][$id]['link'] = '<a href="' . $data['href'] . '">' . $data['num_members'] . '</a>'; |
|
| 274 | + } |
|
| 268 | 275 | } |
| 269 | 276 | |
| 270 | 277 | if (empty($_REQUEST['pid'])) |
@@ -278,9 +285,10 @@ discard block |
||
| 278 | 285 | 'hidden_permissions' => !empty($context['hidden_permissions']) ? $context['hidden_permissions'] : array(), |
| 279 | 286 | ) |
| 280 | 287 | ); |
| 281 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 282 | - if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) |
|
| 288 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 289 | + if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) |
|
| 283 | 290 | $context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] = $row['num_permissions']; |
| 291 | + } |
|
| 284 | 292 | $smcFunc['db_free_result']($request); |
| 285 | 293 | |
| 286 | 294 | // Get the "default" profile permissions too. |
@@ -297,17 +305,18 @@ discard block |
||
| 297 | 305 | ); |
| 298 | 306 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 299 | 307 | { |
| 300 | - if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) |
|
| 301 | - $context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions']; |
|
| 308 | + if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) { |
|
| 309 | + $context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions']; |
|
| 310 | + } |
|
| 302 | 311 | } |
| 303 | 312 | $smcFunc['db_free_result']($request); |
| 304 | - } |
|
| 305 | - else |
|
| 313 | + } else |
|
| 306 | 314 | { |
| 307 | 315 | $_REQUEST['pid'] = (int) $_REQUEST['pid']; |
| 308 | 316 | |
| 309 | - if (!isset($context['profiles'][$_REQUEST['pid']])) |
|
| 310 | - fatal_lang_error('no_access', false); |
|
| 317 | + if (!isset($context['profiles'][$_REQUEST['pid']])) { |
|
| 318 | + fatal_lang_error('no_access', false); |
|
| 319 | + } |
|
| 311 | 320 | |
| 312 | 321 | // Change the selected tab to better reflect that this really is a board profile. |
| 313 | 322 | $context[$context['admin_menu_name']]['current_subsection'] = 'profiles'; |
@@ -323,8 +332,9 @@ discard block |
||
| 323 | 332 | ); |
| 324 | 333 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 325 | 334 | { |
| 326 | - if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) |
|
| 327 | - $context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions']; |
|
| 335 | + if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) { |
|
| 336 | + $context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions']; |
|
| 337 | + } |
|
| 328 | 338 | } |
| 329 | 339 | $smcFunc['db_free_result']($request); |
| 330 | 340 | |
@@ -366,8 +376,8 @@ discard block |
||
| 366 | 376 | |
| 367 | 377 | if (!empty($changes)) |
| 368 | 378 | { |
| 369 | - foreach ($changes as $profile => $boards) |
|
| 370 | - $smcFunc['db_query']('', ' |
|
| 379 | + foreach ($changes as $profile => $boards) { |
|
| 380 | + $smcFunc['db_query']('', ' |
|
| 371 | 381 | UPDATE {db_prefix}boards |
| 372 | 382 | SET id_profile = {int:current_profile} |
| 373 | 383 | WHERE id_board IN ({array_int:board_list})', |
@@ -376,6 +386,7 @@ discard block |
||
| 376 | 386 | 'current_profile' => $profile, |
| 377 | 387 | ) |
| 378 | 388 | ); |
| 389 | + } |
|
| 379 | 390 | } |
| 380 | 391 | |
| 381 | 392 | $context['edit_all'] = false; |
@@ -400,8 +411,9 @@ discard block |
||
| 400 | 411 | ); |
| 401 | 412 | foreach ($boardList[$catid] as $boardid) |
| 402 | 413 | { |
| 403 | - if (!isset($context['profiles'][$boards[$boardid]['profile']])) |
|
| 404 | - $boards[$boardid]['profile'] = 1; |
|
| 414 | + if (!isset($context['profiles'][$boards[$boardid]['profile']])) { |
|
| 415 | + $boards[$boardid]['profile'] = 1; |
|
| 416 | + } |
|
| 405 | 417 | |
| 406 | 418 | $context['categories'][$catid]['boards'][$boardid] = array( |
| 407 | 419 | 'id' => &$boards[$boardid]['id'], |
@@ -433,64 +445,74 @@ discard block |
||
| 433 | 445 | loadIllegalGuestPermissions(); |
| 434 | 446 | |
| 435 | 447 | // Make sure only one of the quick options was selected. |
| 436 | - if ((!empty($_POST['predefined']) && ((isset($_POST['copy_from']) && $_POST['copy_from'] != 'empty') || !empty($_POST['permissions']))) || (!empty($_POST['copy_from']) && $_POST['copy_from'] != 'empty' && !empty($_POST['permissions']))) |
|
| 437 | - fatal_lang_error('permissions_only_one_option', false); |
|
| 448 | + if ((!empty($_POST['predefined']) && ((isset($_POST['copy_from']) && $_POST['copy_from'] != 'empty') || !empty($_POST['permissions']))) || (!empty($_POST['copy_from']) && $_POST['copy_from'] != 'empty' && !empty($_POST['permissions']))) { |
|
| 449 | + fatal_lang_error('permissions_only_one_option', false); |
|
| 450 | + } |
|
| 438 | 451 | |
| 439 | - if (empty($_POST['group']) || !is_array($_POST['group'])) |
|
| 440 | - $_POST['group'] = array(); |
|
| 452 | + if (empty($_POST['group']) || !is_array($_POST['group'])) { |
|
| 453 | + $_POST['group'] = array(); |
|
| 454 | + } |
|
| 441 | 455 | |
| 442 | 456 | // Only accept numeric values for selected membergroups. |
| 443 | - foreach ($_POST['group'] as $id => $group_id) |
|
| 444 | - $_POST['group'][$id] = (int) $group_id; |
|
| 457 | + foreach ($_POST['group'] as $id => $group_id) { |
|
| 458 | + $_POST['group'][$id] = (int) $group_id; |
|
| 459 | + } |
|
| 445 | 460 | $_POST['group'] = array_unique($_POST['group']); |
| 446 | 461 | |
| 447 | - if (empty($_REQUEST['pid'])) |
|
| 448 | - $_REQUEST['pid'] = 0; |
|
| 449 | - else |
|
| 450 | - $_REQUEST['pid'] = (int) $_REQUEST['pid']; |
|
| 462 | + if (empty($_REQUEST['pid'])) { |
|
| 463 | + $_REQUEST['pid'] = 0; |
|
| 464 | + } else { |
|
| 465 | + $_REQUEST['pid'] = (int) $_REQUEST['pid']; |
|
| 466 | + } |
|
| 451 | 467 | |
| 452 | 468 | // Fix up the old global to the new default! |
| 453 | 469 | $bid = max(1, $_REQUEST['pid']); |
| 454 | 470 | |
| 455 | 471 | // No modifying the predefined profiles. |
| 456 | - if ($_REQUEST['pid'] > 1 && $_REQUEST['pid'] < 5) |
|
| 457 | - fatal_lang_error('no_access', false); |
|
| 472 | + if ($_REQUEST['pid'] > 1 && $_REQUEST['pid'] < 5) { |
|
| 473 | + fatal_lang_error('no_access', false); |
|
| 474 | + } |
|
| 458 | 475 | |
| 459 | 476 | // Clear out any cached authority. |
| 460 | 477 | updateSettings(array('settings_updated' => time())); |
| 461 | 478 | |
| 462 | 479 | // No groups where selected. |
| 463 | - if (empty($_POST['group'])) |
|
| 464 | - redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
| 480 | + if (empty($_POST['group'])) { |
|
| 481 | + redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
| 482 | + } |
|
| 465 | 483 | |
| 466 | 484 | // Set a predefined permission profile. |
| 467 | 485 | if (!empty($_POST['predefined'])) |
| 468 | 486 | { |
| 469 | 487 | // Make sure it's a predefined permission set we expect. |
| 470 | - if (!in_array($_POST['predefined'], array('restrict', 'standard', 'moderator', 'maintenance'))) |
|
| 471 | - redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
| 488 | + if (!in_array($_POST['predefined'], array('restrict', 'standard', 'moderator', 'maintenance'))) { |
|
| 489 | + redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
| 490 | + } |
|
| 472 | 491 | |
| 473 | 492 | foreach ($_POST['group'] as $group_id) |
| 474 | 493 | { |
| 475 | - if (!empty($_REQUEST['pid'])) |
|
| 476 | - setPermissionLevel($_POST['predefined'], $group_id, $_REQUEST['pid']); |
|
| 477 | - else |
|
| 478 | - setPermissionLevel($_POST['predefined'], $group_id); |
|
| 494 | + if (!empty($_REQUEST['pid'])) { |
|
| 495 | + setPermissionLevel($_POST['predefined'], $group_id, $_REQUEST['pid']); |
|
| 496 | + } else { |
|
| 497 | + setPermissionLevel($_POST['predefined'], $group_id); |
|
| 498 | + } |
|
| 479 | 499 | } |
| 480 | 500 | } |
| 481 | 501 | // Set a permission profile based on the permissions of a selected group. |
| 482 | 502 | elseif ($_POST['copy_from'] != 'empty') |
| 483 | 503 | { |
| 484 | 504 | // Just checking the input. |
| 485 | - if (!is_numeric($_POST['copy_from'])) |
|
| 486 | - redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
| 505 | + if (!is_numeric($_POST['copy_from'])) { |
|
| 506 | + redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
| 507 | + } |
|
| 487 | 508 | |
| 488 | 509 | // Make sure the group we're copying to is never included. |
| 489 | 510 | $_POST['group'] = array_diff($_POST['group'], array($_POST['copy_from'])); |
| 490 | 511 | |
| 491 | 512 | // No groups left? Too bad. |
| 492 | - if (empty($_POST['group'])) |
|
| 493 | - redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
| 513 | + if (empty($_POST['group'])) { |
|
| 514 | + redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
| 515 | + } |
|
| 494 | 516 | |
| 495 | 517 | if (empty($_REQUEST['pid'])) |
| 496 | 518 | { |
@@ -504,22 +526,26 @@ discard block |
||
| 504 | 526 | ) |
| 505 | 527 | ); |
| 506 | 528 | $target_perm = array(); |
| 507 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 508 | - $target_perm[$row['permission']] = $row['add_deny']; |
|
| 529 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 530 | + $target_perm[$row['permission']] = $row['add_deny']; |
|
| 531 | + } |
|
| 509 | 532 | $smcFunc['db_free_result']($request); |
| 510 | 533 | |
| 511 | 534 | $inserts = array(); |
| 512 | - foreach ($_POST['group'] as $group_id) |
|
| 513 | - foreach ($target_perm as $perm => $add_deny) |
|
| 535 | + foreach ($_POST['group'] as $group_id) { |
|
| 536 | + foreach ($target_perm as $perm => $add_deny) |
|
| 514 | 537 | { |
| 515 | 538 | // No dodgy permissions please! |
| 516 | 539 | if (!empty($context['illegal_permissions']) && in_array($perm, $context['illegal_permissions'])) |
| 517 | 540 | continue; |
| 518 | - if ($group_id == -1 && in_array($perm, $context['non_guest_permissions'])) |
|
| 519 | - continue; |
|
| 541 | + } |
|
| 542 | + if ($group_id == -1 && in_array($perm, $context['non_guest_permissions'])) { |
|
| 543 | + continue; |
|
| 544 | + } |
|
| 520 | 545 | |
| 521 | - if ($group_id != 1 && $group_id != 3) |
|
| 522 | - $inserts[] = array($perm, $group_id, $add_deny); |
|
| 546 | + if ($group_id != 1 && $group_id != 3) { |
|
| 547 | + $inserts[] = array($perm, $group_id, $add_deny); |
|
| 548 | + } |
|
| 523 | 549 | } |
| 524 | 550 | |
| 525 | 551 | // Delete the previous permissions... |
@@ -559,17 +585,19 @@ discard block |
||
| 559 | 585 | ) |
| 560 | 586 | ); |
| 561 | 587 | $target_perm = array(); |
| 562 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 563 | - $target_perm[$row['permission']] = $row['add_deny']; |
|
| 588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 589 | + $target_perm[$row['permission']] = $row['add_deny']; |
|
| 590 | + } |
|
| 564 | 591 | $smcFunc['db_free_result']($request); |
| 565 | 592 | |
| 566 | 593 | $inserts = array(); |
| 567 | - foreach ($_POST['group'] as $group_id) |
|
| 568 | - foreach ($target_perm as $perm => $add_deny) |
|
| 594 | + foreach ($_POST['group'] as $group_id) { |
|
| 595 | + foreach ($target_perm as $perm => $add_deny) |
|
| 569 | 596 | { |
| 570 | 597 | // Are these for guests? |
| 571 | 598 | if ($group_id == -1 && in_array($perm, $context['non_guest_permissions'])) |
| 572 | 599 | continue; |
| 600 | + } |
|
| 573 | 601 | |
| 574 | 602 | $inserts[] = array($perm, $group_id, $bid, $add_deny); |
| 575 | 603 | } |
@@ -607,13 +635,14 @@ discard block |
||
| 607 | 635 | list ($permissionType, $permission) = explode('/', $_POST['permissions']); |
| 608 | 636 | |
| 609 | 637 | // Check whether our input is within expected range. |
| 610 | - if (!in_array($_POST['add_remove'], array('add', 'clear', 'deny')) || !in_array($permissionType, array('membergroup', 'board'))) |
|
| 611 | - redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
| 638 | + if (!in_array($_POST['add_remove'], array('add', 'clear', 'deny')) || !in_array($permissionType, array('membergroup', 'board'))) { |
|
| 639 | + redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
| 640 | + } |
|
| 612 | 641 | |
| 613 | 642 | if ($_POST['add_remove'] == 'clear') |
| 614 | 643 | { |
| 615 | - if ($permissionType == 'membergroup') |
|
| 616 | - $smcFunc['db_query']('', ' |
|
| 644 | + if ($permissionType == 'membergroup') { |
|
| 645 | + $smcFunc['db_query']('', ' |
|
| 617 | 646 | DELETE FROM {db_prefix}permissions |
| 618 | 647 | WHERE id_group IN ({array_int:current_group_list}) |
| 619 | 648 | AND permission = {string:current_permission} |
@@ -624,8 +653,8 @@ discard block |
||
| 624 | 653 | 'illegal_permissions' => !empty($context['illegal_permissions']) ? $context['illegal_permissions'] : array(), |
| 625 | 654 | ) |
| 626 | 655 | ); |
| 627 | - else |
|
| 628 | - $smcFunc['db_query']('', ' |
|
| 656 | + } else { |
|
| 657 | + $smcFunc['db_query']('', ' |
|
| 629 | 658 | DELETE FROM {db_prefix}board_permissions |
| 630 | 659 | WHERE id_group IN ({array_int:current_group_list}) |
| 631 | 660 | AND id_profile = {int:current_profile} |
@@ -636,6 +665,7 @@ discard block |
||
| 636 | 665 | 'current_permission' => $permission, |
| 637 | 666 | ) |
| 638 | 667 | ); |
| 668 | + } |
|
| 639 | 669 | } |
| 640 | 670 | // Add a permission (either 'set' or 'deny'). |
| 641 | 671 | else |
@@ -644,32 +674,36 @@ discard block |
||
| 644 | 674 | $permChange = array(); |
| 645 | 675 | foreach ($_POST['group'] as $groupID) |
| 646 | 676 | { |
| 647 | - if ($groupID == -1 && in_array($permission, $context['non_guest_permissions'])) |
|
| 648 | - continue; |
|
| 677 | + if ($groupID == -1 && in_array($permission, $context['non_guest_permissions'])) { |
|
| 678 | + continue; |
|
| 679 | + } |
|
| 649 | 680 | |
| 650 | - if ($permissionType == 'membergroup' && $groupID != 1 && $groupID != 3 && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions']))) |
|
| 651 | - $permChange[] = array($permission, $groupID, $add_deny); |
|
| 652 | - elseif ($permissionType != 'membergroup') |
|
| 653 | - $permChange[] = array($permission, $groupID, $bid, $add_deny); |
|
| 681 | + if ($permissionType == 'membergroup' && $groupID != 1 && $groupID != 3 && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions']))) { |
|
| 682 | + $permChange[] = array($permission, $groupID, $add_deny); |
|
| 683 | + } elseif ($permissionType != 'membergroup') { |
|
| 684 | + $permChange[] = array($permission, $groupID, $bid, $add_deny); |
|
| 685 | + } |
|
| 654 | 686 | } |
| 655 | 687 | |
| 656 | 688 | if (!empty($permChange)) |
| 657 | 689 | { |
| 658 | - if ($permissionType == 'membergroup') |
|
| 659 | - $smcFunc['db_insert']('replace', |
|
| 690 | + if ($permissionType == 'membergroup') { |
|
| 691 | + $smcFunc['db_insert']('replace', |
|
| 660 | 692 | '{db_prefix}permissions', |
| 661 | 693 | array('permission' => 'string', 'id_group' => 'int', 'add_deny' => 'int'), |
| 662 | 694 | $permChange, |
| 663 | 695 | array('permission', 'id_group') |
| 664 | 696 | ); |
| 697 | + } |
|
| 665 | 698 | // Board permissions go into the other table. |
| 666 | - else |
|
| 667 | - $smcFunc['db_insert']('replace', |
|
| 699 | + else { |
|
| 700 | + $smcFunc['db_insert']('replace', |
|
| 668 | 701 | '{db_prefix}board_permissions', |
| 669 | 702 | array('permission' => 'string', 'id_group' => 'int', 'id_profile' => 'int', 'add_deny' => 'int'), |
| 670 | 703 | $permChange, |
| 671 | 704 | array('permission', 'id_group', 'id_profile') |
| 672 | 705 | ); |
| 706 | + } |
|
| 673 | 707 | } |
| 674 | 708 | } |
| 675 | 709 | |
@@ -687,14 +721,16 @@ discard block |
||
| 687 | 721 | { |
| 688 | 722 | global $context, $txt, $smcFunc, $modSettings; |
| 689 | 723 | |
| 690 | - if (!isset($_GET['group'])) |
|
| 691 | - fatal_lang_error('no_access', false); |
|
| 724 | + if (!isset($_GET['group'])) { |
|
| 725 | + fatal_lang_error('no_access', false); |
|
| 726 | + } |
|
| 692 | 727 | |
| 693 | 728 | $context['group']['id'] = (int) $_GET['group']; |
| 694 | 729 | |
| 695 | 730 | // It's not likely you'd end up here with this setting disabled. |
| 696 | - if ($_GET['group'] == 1) |
|
| 697 | - redirectexit('action=admin;area=permissions'); |
|
| 731 | + if ($_GET['group'] == 1) { |
|
| 732 | + redirectexit('action=admin;area=permissions'); |
|
| 733 | + } |
|
| 698 | 734 | |
| 699 | 735 | loadAllPermissions(); |
| 700 | 736 | loadPermissionProfiles(); |
@@ -715,13 +751,14 @@ discard block |
||
| 715 | 751 | $smcFunc['db_free_result']($result); |
| 716 | 752 | |
| 717 | 753 | // Cannot edit an inherited group! |
| 718 | - if ($parent != -2) |
|
| 719 | - fatal_lang_error('cannot_edit_permissions_inherited'); |
|
| 754 | + if ($parent != -2) { |
|
| 755 | + fatal_lang_error('cannot_edit_permissions_inherited'); |
|
| 756 | + } |
|
| 757 | + } elseif ($context['group']['id'] == -1) { |
|
| 758 | + $context['group']['name'] = $txt['membergroups_guests']; |
|
| 759 | + } else { |
|
| 760 | + $context['group']['name'] = $txt['membergroups_members']; |
|
| 720 | 761 | } |
| 721 | - elseif ($context['group']['id'] == -1) |
|
| 722 | - $context['group']['name'] = $txt['membergroups_guests']; |
|
| 723 | - else |
|
| 724 | - $context['group']['name'] = $txt['membergroups_members']; |
|
| 725 | 762 | |
| 726 | 763 | $context['profile']['id'] = empty($_GET['pid']) ? 0 : (int) $_GET['pid']; |
| 727 | 764 | |
@@ -767,8 +804,9 @@ discard block |
||
| 767 | 804 | 'current_group' => $_GET['group'], |
| 768 | 805 | ) |
| 769 | 806 | ); |
| 770 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 771 | - $permissions['membergroup'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission']; |
|
| 807 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 808 | + $permissions['membergroup'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission']; |
|
| 809 | + } |
|
| 772 | 810 | $smcFunc['db_free_result']($result); |
| 773 | 811 | } |
| 774 | 812 | |
@@ -783,8 +821,9 @@ discard block |
||
| 783 | 821 | 'current_profile' => $context['permission_type'] == 'membergroup' ? 1 : $context['profile']['id'], |
| 784 | 822 | ) |
| 785 | 823 | ); |
| 786 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 787 | - $permissions['board'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission']; |
|
| 824 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 825 | + $permissions['board'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission']; |
|
| 826 | + } |
|
| 788 | 827 | $smcFunc['db_free_result']($result); |
| 789 | 828 | |
| 790 | 829 | // Loop through each permission and set whether it's checked. |
@@ -803,9 +842,9 @@ discard block |
||
| 803 | 842 | { |
| 804 | 843 | $curPerm['any']['select'] = in_array($perm['id'] . '_any', $permissions[$permissionType]['allowed']) ? 'on' : (in_array($perm['id'] . '_any', $permissions[$permissionType]['denied']) ? 'deny' : 'off'); |
| 805 | 844 | $curPerm['own']['select'] = in_array($perm['id'] . '_own', $permissions[$permissionType]['allowed']) ? 'on' : (in_array($perm['id'] . '_own', $permissions[$permissionType]['denied']) ? 'deny' : 'off'); |
| 845 | + } else { |
|
| 846 | + $curPerm['select'] = in_array($perm['id'], $permissions[$permissionType]['denied']) ? 'deny' : (in_array($perm['id'], $permissions[$permissionType]['allowed']) ? 'on' : 'off'); |
|
| 806 | 847 | } |
| 807 | - else |
|
| 808 | - $curPerm['select'] = in_array($perm['id'], $permissions[$permissionType]['denied']) ? 'deny' : (in_array($perm['id'], $permissions[$permissionType]['allowed']) ? 'on' : 'off'); |
|
| 809 | 848 | |
| 810 | 849 | // Keep the last value if it's hidden. |
| 811 | 850 | if ($perm['hidden'] || $permissionArray['hidden']) |
@@ -822,13 +861,13 @@ discard block |
||
| 822 | 861 | $perm['any']['id'], |
| 823 | 862 | $curPerm['any']['select'] == 'deny' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $curPerm['any']['select'], |
| 824 | 863 | ); |
| 825 | - } |
|
| 826 | - else |
|
| 827 | - $context['hidden_perms'][] = array( |
|
| 864 | + } else { |
|
| 865 | + $context['hidden_perms'][] = array( |
|
| 828 | 866 | $permissionType, |
| 829 | 867 | $perm['id'], |
| 830 | 868 | $curPerm['select'] == 'deny' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $curPerm['select'], |
| 831 | 869 | ); |
| 870 | + } |
|
| 832 | 871 | } |
| 833 | 872 | } |
| 834 | 873 | } |
@@ -856,13 +895,14 @@ discard block |
||
| 856 | 895 | $_GET['pid'] = (int) $_GET['pid']; |
| 857 | 896 | |
| 858 | 897 | // Cannot modify predefined profiles. |
| 859 | - if ($_GET['pid'] > 1 && $_GET['pid'] < 5) |
|
| 860 | - fatal_lang_error('no_access', false); |
|
| 898 | + if ($_GET['pid'] > 1 && $_GET['pid'] < 5) { |
|
| 899 | + fatal_lang_error('no_access', false); |
|
| 900 | + } |
|
| 861 | 901 | |
| 862 | 902 | // Verify this isn't inherited. |
| 863 | - if ($_GET['group'] == -1 || $_GET['group'] == 0) |
|
| 864 | - $parent = -2; |
|
| 865 | - else |
|
| 903 | + if ($_GET['group'] == -1 || $_GET['group'] == 0) { |
|
| 904 | + $parent = -2; |
|
| 905 | + } else |
|
| 866 | 906 | { |
| 867 | 907 | $result = $smcFunc['db_query']('', ' |
| 868 | 908 | SELECT id_parent |
@@ -877,8 +917,9 @@ discard block |
||
| 877 | 917 | $smcFunc['db_free_result']($result); |
| 878 | 918 | } |
| 879 | 919 | |
| 880 | - if ($parent != -2) |
|
| 881 | - fatal_lang_error('cannot_edit_permissions_inherited'); |
|
| 920 | + if ($parent != -2) { |
|
| 921 | + fatal_lang_error('cannot_edit_permissions_inherited'); |
|
| 922 | + } |
|
| 882 | 923 | |
| 883 | 924 | $givePerms = array('membergroup' => array(), 'board' => array()); |
| 884 | 925 | |
@@ -896,12 +937,13 @@ discard block |
||
| 896 | 937 | { |
| 897 | 938 | if (is_array($perm_array)) |
| 898 | 939 | { |
| 899 | - foreach ($perm_array as $permission => $value) |
|
| 900 | - if ($value == 'on' || $value == 'deny') |
|
| 940 | + foreach ($perm_array as $permission => $value) { |
|
| 941 | + if ($value == 'on' || $value == 'deny') |
|
| 901 | 942 | { |
| 902 | 943 | // Don't allow people to escalate themselves! |
| 903 | 944 | if (!empty($context['illegal_permissions']) && in_array($permission, $context['illegal_permissions'])) |
| 904 | 945 | continue; |
| 946 | + } |
|
| 905 | 947 | |
| 906 | 948 | $givePerms[$perm_type][] = array($_GET['group'], $permission, $value == 'deny' ? 0 : 1); |
| 907 | 949 | } |
@@ -946,8 +988,9 @@ discard block |
||
| 946 | 988 | ); |
| 947 | 989 | if (!empty($givePerms['board'])) |
| 948 | 990 | { |
| 949 | - foreach ($givePerms['board'] as $k => $v) |
|
| 950 | - $givePerms['board'][$k][] = $profileid; |
|
| 991 | + foreach ($givePerms['board'] as $k => $v) { |
|
| 992 | + $givePerms['board'][$k][] = $profileid; |
|
| 993 | + } |
|
| 951 | 994 | $smcFunc['db_insert']('replace', |
| 952 | 995 | '{db_prefix}board_permissions', |
| 953 | 996 | array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int', 'id_profile' => 'int'), |
@@ -988,8 +1031,9 @@ discard block |
||
| 988 | 1031 | |
| 989 | 1032 | call_integration_hook('integrate_modify_permission_settings', array(&$config_vars)); |
| 990 | 1033 | |
| 991 | - if ($return_config) |
|
| 992 | - return $config_vars; |
|
| 1034 | + if ($return_config) { |
|
| 1035 | + return $config_vars; |
|
| 1036 | + } |
|
| 993 | 1037 | |
| 994 | 1038 | $context['page_title'] = $txt['permission_settings_title']; |
| 995 | 1039 | $context['sub_template'] = 'show_settings'; |
@@ -1040,8 +1084,9 @@ discard block |
||
| 1040 | 1084 | 'min_posts' => -1, |
| 1041 | 1085 | ) |
| 1042 | 1086 | ); |
| 1043 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1044 | - $post_groups[] = $row['id_group']; |
|
| 1087 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1088 | + $post_groups[] = $row['id_group']; |
|
| 1089 | + } |
|
| 1045 | 1090 | $smcFunc['db_free_result']($request); |
| 1046 | 1091 | |
| 1047 | 1092 | // Remove'em. |
@@ -1250,16 +1295,19 @@ discard block |
||
| 1250 | 1295 | // Make sure we're not granting someone too many permissions! |
| 1251 | 1296 | foreach ($groupLevels['global'][$level] as $k => $permission) |
| 1252 | 1297 | { |
| 1253 | - if (!empty($context['illegal_permissions']) && in_array($permission, $context['illegal_permissions'])) |
|
| 1254 | - unset($groupLevels['global'][$level][$k]); |
|
| 1298 | + if (!empty($context['illegal_permissions']) && in_array($permission, $context['illegal_permissions'])) { |
|
| 1299 | + unset($groupLevels['global'][$level][$k]); |
|
| 1300 | + } |
|
| 1255 | 1301 | |
| 1256 | - if ($group == -1 && in_array($permission, $context['non_guest_permissions'])) |
|
| 1257 | - unset($groupLevels['global'][$level][$k]); |
|
| 1302 | + if ($group == -1 && in_array($permission, $context['non_guest_permissions'])) { |
|
| 1303 | + unset($groupLevels['global'][$level][$k]); |
|
| 1304 | + } |
|
| 1258 | 1305 | } |
| 1259 | - if ($group == -1) |
|
| 1260 | - foreach ($groupLevels['board'][$level] as $k => $permission) |
|
| 1306 | + if ($group == -1) { |
|
| 1307 | + foreach ($groupLevels['board'][$level] as $k => $permission) |
|
| 1261 | 1308 | if (in_array($permission, $context['non_guest_permissions'])) |
| 1262 | 1309 | unset($groupLevels['board'][$level][$k]); |
| 1310 | + } |
|
| 1263 | 1311 | |
| 1264 | 1312 | // Reset all cached permissions. |
| 1265 | 1313 | updateSettings(array('settings_updated' => time())); |
@@ -1269,8 +1317,9 @@ discard block |
||
| 1269 | 1317 | { |
| 1270 | 1318 | $group = (int) $group; |
| 1271 | 1319 | |
| 1272 | - if (empty($groupLevels['global'][$level])) |
|
| 1273 | - return; |
|
| 1320 | + if (empty($groupLevels['global'][$level])) { |
|
| 1321 | + return; |
|
| 1322 | + } |
|
| 1274 | 1323 | |
| 1275 | 1324 | $smcFunc['db_query']('', ' |
| 1276 | 1325 | DELETE FROM {db_prefix}permissions |
@@ -1292,8 +1341,9 @@ discard block |
||
| 1292 | 1341 | ); |
| 1293 | 1342 | |
| 1294 | 1343 | $groupInserts = array(); |
| 1295 | - foreach ($groupLevels['global'][$level] as $permission) |
|
| 1296 | - $groupInserts[] = array($group, $permission); |
|
| 1344 | + foreach ($groupLevels['global'][$level] as $permission) { |
|
| 1345 | + $groupInserts[] = array($group, $permission); |
|
| 1346 | + } |
|
| 1297 | 1347 | |
| 1298 | 1348 | $smcFunc['db_insert']('insert', |
| 1299 | 1349 | '{db_prefix}permissions', |
@@ -1303,8 +1353,9 @@ discard block |
||
| 1303 | 1353 | ); |
| 1304 | 1354 | |
| 1305 | 1355 | $boardInserts = array(); |
| 1306 | - foreach ($groupLevels['board'][$level] as $permission) |
|
| 1307 | - $boardInserts[] = array(1, $group, $permission); |
|
| 1356 | + foreach ($groupLevels['board'][$level] as $permission) { |
|
| 1357 | + $boardInserts[] = array(1, $group, $permission); |
|
| 1358 | + } |
|
| 1308 | 1359 | |
| 1309 | 1360 | $smcFunc['db_insert']('insert', |
| 1310 | 1361 | '{db_prefix}board_permissions', |
@@ -1335,8 +1386,9 @@ discard block |
||
| 1335 | 1386 | if (!empty($groupLevels['board'][$level])) |
| 1336 | 1387 | { |
| 1337 | 1388 | $boardInserts = array(); |
| 1338 | - foreach ($groupLevels['board'][$level] as $permission) |
|
| 1339 | - $boardInserts[] = array($profile, $group, $permission); |
|
| 1389 | + foreach ($groupLevels['board'][$level] as $permission) { |
|
| 1390 | + $boardInserts[] = array($profile, $group, $permission); |
|
| 1391 | + } |
|
| 1340 | 1392 | |
| 1341 | 1393 | $smcFunc['db_insert']('insert', |
| 1342 | 1394 | '{db_prefix}board_permissions', |
@@ -1359,8 +1411,9 @@ discard block |
||
| 1359 | 1411 | ) |
| 1360 | 1412 | ); |
| 1361 | 1413 | |
| 1362 | - if (empty($boardLevels[$level])) |
|
| 1363 | - return; |
|
| 1414 | + if (empty($boardLevels[$level])) { |
|
| 1415 | + return; |
|
| 1416 | + } |
|
| 1364 | 1417 | |
| 1365 | 1418 | // Get all the groups... |
| 1366 | 1419 | $query = $smcFunc['db_query']('', ' |
@@ -1378,8 +1431,9 @@ discard block |
||
| 1378 | 1431 | $group = $row[0]; |
| 1379 | 1432 | |
| 1380 | 1433 | $boardInserts = array(); |
| 1381 | - foreach ($boardLevels[$level] as $permission) |
|
| 1382 | - $boardInserts[] = array($profile, $group, $permission); |
|
| 1434 | + foreach ($boardLevels[$level] as $permission) { |
|
| 1435 | + $boardInserts[] = array($profile, $group, $permission); |
|
| 1436 | + } |
|
| 1383 | 1437 | |
| 1384 | 1438 | $smcFunc['db_insert']('insert', |
| 1385 | 1439 | '{db_prefix}board_permissions', |
@@ -1392,8 +1446,9 @@ discard block |
||
| 1392 | 1446 | |
| 1393 | 1447 | // Add permissions for ungrouped members. |
| 1394 | 1448 | $boardInserts = array(); |
| 1395 | - foreach ($boardLevels[$level] as $permission) |
|
| 1396 | - $boardInserts[] = array($profile, 0, $permission); |
|
| 1449 | + foreach ($boardLevels[$level] as $permission) { |
|
| 1450 | + $boardInserts[] = array($profile, 0, $permission); |
|
| 1451 | + } |
|
| 1397 | 1452 | |
| 1398 | 1453 | $smcFunc['db_insert']('insert', |
| 1399 | 1454 | '{db_prefix}board_permissions', |
@@ -1403,9 +1458,10 @@ discard block |
||
| 1403 | 1458 | ); |
| 1404 | 1459 | } |
| 1405 | 1460 | // $profile and $group are both null! |
| 1406 | - else |
|
| 1407 | - fatal_lang_error('no_access', false); |
|
| 1408 | -} |
|
| 1461 | + else { |
|
| 1462 | + fatal_lang_error('no_access', false); |
|
| 1463 | + } |
|
| 1464 | + } |
|
| 1409 | 1465 | |
| 1410 | 1466 | /** |
| 1411 | 1467 | * Load permissions into $context['permissions']. |
@@ -1606,15 +1662,17 @@ discard block |
||
| 1606 | 1662 | foreach ($permissionList as $permission => $permissionArray) |
| 1607 | 1663 | { |
| 1608 | 1664 | // If this is a guest permission we don't do it if it's the guest group. |
| 1609 | - if (isset($context['group']['id']) && $context['group']['id'] == -1 && in_array($permission, $context['non_guest_permissions'])) |
|
| 1610 | - continue; |
|
| 1665 | + if (isset($context['group']['id']) && $context['group']['id'] == -1 && in_array($permission, $context['non_guest_permissions'])) { |
|
| 1666 | + continue; |
|
| 1667 | + } |
|
| 1611 | 1668 | |
| 1612 | 1669 | // What groups will this permission be in? |
| 1613 | 1670 | $own_group = $permissionArray[1]; |
| 1614 | 1671 | |
| 1615 | 1672 | // First, Do these groups actually exist - if not add them. |
| 1616 | - if (!isset($permissionGroups[$permissionType][$own_group])) |
|
| 1617 | - $permissionGroups[$permissionType][$own_group] = true; |
|
| 1673 | + if (!isset($permissionGroups[$permissionType][$own_group])) { |
|
| 1674 | + $permissionGroups[$permissionType][$own_group] = true; |
|
| 1675 | + } |
|
| 1618 | 1676 | |
| 1619 | 1677 | // What column should this be located into? |
| 1620 | 1678 | $position = !in_array($own_group, $leftPermissionGroups) ? 1 : 0; |
@@ -1622,8 +1680,8 @@ discard block |
||
| 1622 | 1680 | // If the groups have not yet been created be sure to create them. |
| 1623 | 1681 | $bothGroups = array('own' => $own_group); |
| 1624 | 1682 | |
| 1625 | - foreach ($bothGroups as $group) |
|
| 1626 | - if (!isset($context['permissions'][$permissionType]['columns'][$position][$group])) |
|
| 1683 | + foreach ($bothGroups as $group) { |
|
| 1684 | + if (!isset($context['permissions'][$permissionType]['columns'][$position][$group])) |
|
| 1627 | 1685 | $context['permissions'][$permissionType]['columns'][$position][$group] = array( |
| 1628 | 1686 | 'type' => $permissionType, |
| 1629 | 1687 | 'id' => $group, |
@@ -1633,6 +1691,7 @@ discard block |
||
| 1633 | 1691 | 'hidden' => false, |
| 1634 | 1692 | 'permissions' => array() |
| 1635 | 1693 | ); |
| 1694 | + } |
|
| 1636 | 1695 | |
| 1637 | 1696 | $context['permissions'][$permissionType]['columns'][$position][$own_group]['permissions'][$permission] = array( |
| 1638 | 1697 | 'id' => $permission, |
@@ -1657,27 +1716,30 @@ discard block |
||
| 1657 | 1716 | { |
| 1658 | 1717 | $context['hidden_permissions'][] = $permission . '_own'; |
| 1659 | 1718 | $context['hidden_permissions'][] = $permission . '_any'; |
| 1719 | + } else { |
|
| 1720 | + $context['hidden_permissions'][] = $permission; |
|
| 1660 | 1721 | } |
| 1661 | - else |
|
| 1662 | - $context['hidden_permissions'][] = $permission; |
|
| 1663 | 1722 | } |
| 1664 | 1723 | } |
| 1665 | 1724 | ksort($context['permissions'][$permissionType]['columns']); |
| 1666 | 1725 | |
| 1667 | 1726 | // Check we don't leave any empty groups - and mark hidden ones as such. |
| 1668 | - foreach ($context['permissions'][$permissionType]['columns'] as $column => $groups) |
|
| 1669 | - foreach ($groups as $id => $group) |
|
| 1727 | + foreach ($context['permissions'][$permissionType]['columns'] as $column => $groups) { |
|
| 1728 | + foreach ($groups as $id => $group) |
|
| 1670 | 1729 | { |
| 1671 | 1730 | if (empty($group['permissions'])) |
| 1672 | 1731 | unset($context['permissions'][$permissionType]['columns'][$column][$id]); |
| 1732 | + } |
|
| 1673 | 1733 | else |
| 1674 | 1734 | { |
| 1675 | 1735 | $foundNonHidden = false; |
| 1676 | - foreach ($group['permissions'] as $permission) |
|
| 1677 | - if (empty($permission['hidden'])) |
|
| 1736 | + foreach ($group['permissions'] as $permission) { |
|
| 1737 | + if (empty($permission['hidden'])) |
|
| 1678 | 1738 | $foundNonHidden = true; |
| 1679 | - if (!$foundNonHidden) |
|
| 1680 | - $context['permissions'][$permissionType]['columns'][$column][$id]['hidden'] = true; |
|
| 1739 | + } |
|
| 1740 | + if (!$foundNonHidden) { |
|
| 1741 | + $context['permissions'][$permissionType]['columns'][$column][$id]['hidden'] = true; |
|
| 1742 | + } |
|
| 1681 | 1743 | } |
| 1682 | 1744 | } |
| 1683 | 1745 | } |
@@ -1704,12 +1766,13 @@ discard block |
||
| 1704 | 1766 | $context['can_change_permissions'] = allowedTo('manage_permissions'); |
| 1705 | 1767 | |
| 1706 | 1768 | // Nothing to initialize here. |
| 1707 | - if (!$context['can_change_permissions']) |
|
| 1708 | - return; |
|
| 1769 | + if (!$context['can_change_permissions']) { |
|
| 1770 | + return; |
|
| 1771 | + } |
|
| 1709 | 1772 | |
| 1710 | 1773 | // Load the permission settings for guests |
| 1711 | - foreach ($permissions as $permission) |
|
| 1712 | - $context[$permission] = array( |
|
| 1774 | + foreach ($permissions as $permission) { |
|
| 1775 | + $context[$permission] = array( |
|
| 1713 | 1776 | -1 => array( |
| 1714 | 1777 | 'id' => -1, |
| 1715 | 1778 | 'name' => $txt['membergroups_guests'], |
@@ -1723,6 +1786,7 @@ discard block |
||
| 1723 | 1786 | 'status' => 'off', |
| 1724 | 1787 | ), |
| 1725 | 1788 | ); |
| 1789 | + } |
|
| 1726 | 1790 | |
| 1727 | 1791 | $request = $smcFunc['db_query']('', ' |
| 1728 | 1792 | SELECT id_group, CASE WHEN add_deny = {int:denied} THEN {string:deny} ELSE {string:on} END AS status, permission |
@@ -1736,8 +1800,9 @@ discard block |
||
| 1736 | 1800 | 'on' => 'on', |
| 1737 | 1801 | ) |
| 1738 | 1802 | ); |
| 1739 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1740 | - $context[$row['permission']][$row['id_group']]['status'] = $row['status']; |
|
| 1803 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1804 | + $context[$row['permission']][$row['id_group']]['status'] = $row['status']; |
|
| 1805 | + } |
|
| 1741 | 1806 | $smcFunc['db_free_result']($request); |
| 1742 | 1807 | |
| 1743 | 1808 | $request = $smcFunc['db_query']('', ' |
@@ -1758,14 +1823,15 @@ discard block |
||
| 1758 | 1823 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1759 | 1824 | { |
| 1760 | 1825 | // Initialize each permission as being 'off' until proven otherwise. |
| 1761 | - foreach ($permissions as $permission) |
|
| 1762 | - if (!isset($context[$permission][$row['id_group']])) |
|
| 1826 | + foreach ($permissions as $permission) { |
|
| 1827 | + if (!isset($context[$permission][$row['id_group']])) |
|
| 1763 | 1828 | $context[$permission][$row['id_group']] = array( |
| 1764 | 1829 | 'id' => $row['id_group'], |
| 1765 | 1830 | 'name' => $row['group_name'], |
| 1766 | 1831 | 'is_postgroup' => $row['min_posts'] != -1, |
| 1767 | 1832 | 'status' => 'off', |
| 1768 | 1833 | ); |
| 1834 | + } |
|
| 1769 | 1835 | |
| 1770 | 1836 | $context[$row['permission']][$row['id_group']]['status'] = empty($row['status']) ? 'deny' : ($row['status'] == 1 ? 'on' : 'off'); |
| 1771 | 1837 | } |
@@ -1779,8 +1845,9 @@ discard block |
||
| 1779 | 1845 | { |
| 1780 | 1846 | foreach ($permissions as $permission) |
| 1781 | 1847 | { |
| 1782 | - if (isset($context[$permission][$group])) |
|
| 1783 | - unset($context[$permission][$group]); |
|
| 1848 | + if (isset($context[$permission][$group])) { |
|
| 1849 | + unset($context[$permission][$group]); |
|
| 1850 | + } |
|
| 1784 | 1851 | } |
| 1785 | 1852 | } |
| 1786 | 1853 | |
@@ -1788,8 +1855,9 @@ discard block |
||
| 1788 | 1855 | $non_guest_perms = array_intersect(str_replace(array('_any', '_own'), '', $permissions), $context['non_guest_permissions']); |
| 1789 | 1856 | foreach ($non_guest_perms as $permission) |
| 1790 | 1857 | { |
| 1791 | - if (isset($context[$permission][-1])) |
|
| 1792 | - unset($context[$permission][-1]); |
|
| 1858 | + if (isset($context[$permission][-1])) { |
|
| 1859 | + unset($context[$permission][-1]); |
|
| 1860 | + } |
|
| 1793 | 1861 | } |
| 1794 | 1862 | |
| 1795 | 1863 | // Create the token for the separate inline permission verification. |
@@ -1824,8 +1892,9 @@ discard block |
||
| 1824 | 1892 | global $context, $smcFunc; |
| 1825 | 1893 | |
| 1826 | 1894 | // No permissions? Not a great deal to do here. |
| 1827 | - if (!allowedTo('manage_permissions')) |
|
| 1828 | - return; |
|
| 1895 | + if (!allowedTo('manage_permissions')) { |
|
| 1896 | + return; |
|
| 1897 | + } |
|
| 1829 | 1898 | |
| 1830 | 1899 | // Almighty session check, verify our ways. |
| 1831 | 1900 | checkSession(); |
@@ -1837,13 +1906,15 @@ discard block |
||
| 1837 | 1906 | $insertRows = array(); |
| 1838 | 1907 | foreach ($permissions as $permission) |
| 1839 | 1908 | { |
| 1840 | - if (!isset($_POST[$permission])) |
|
| 1841 | - continue; |
|
| 1909 | + if (!isset($_POST[$permission])) { |
|
| 1910 | + continue; |
|
| 1911 | + } |
|
| 1842 | 1912 | |
| 1843 | 1913 | foreach ($_POST[$permission] as $id_group => $value) |
| 1844 | 1914 | { |
| 1845 | - if (in_array($value, array('on', 'deny')) && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions']))) |
|
| 1846 | - $insertRows[] = array((int) $id_group, $permission, $value == 'on' ? 1 : 0); |
|
| 1915 | + if (in_array($value, array('on', 'deny')) && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions']))) { |
|
| 1916 | + $insertRows[] = array((int) $id_group, $permission, $value == 'on' ? 1 : 0); |
|
| 1917 | + } |
|
| 1847 | 1918 | } |
| 1848 | 1919 | } |
| 1849 | 1920 | |
@@ -1859,13 +1930,14 @@ discard block |
||
| 1859 | 1930 | ); |
| 1860 | 1931 | |
| 1861 | 1932 | // ...and replace them with new ones. |
| 1862 | - if (!empty($insertRows)) |
|
| 1863 | - $smcFunc['db_insert']('insert', |
|
| 1933 | + if (!empty($insertRows)) { |
|
| 1934 | + $smcFunc['db_insert']('insert', |
|
| 1864 | 1935 | '{db_prefix}permissions', |
| 1865 | 1936 | array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
| 1866 | 1937 | $insertRows, |
| 1867 | 1938 | array('id_group', 'permission') |
| 1868 | 1939 | ); |
| 1940 | + } |
|
| 1869 | 1941 | |
| 1870 | 1942 | // Do a full child update. |
| 1871 | 1943 | updateChildPermissions(array(), -1); |
@@ -1892,10 +1964,11 @@ discard block |
||
| 1892 | 1964 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1893 | 1965 | { |
| 1894 | 1966 | // Format the label nicely. |
| 1895 | - if (isset($txt['permissions_profile_' . $row['profile_name']])) |
|
| 1896 | - $name = $txt['permissions_profile_' . $row['profile_name']]; |
|
| 1897 | - else |
|
| 1898 | - $name = $row['profile_name']; |
|
| 1967 | + if (isset($txt['permissions_profile_' . $row['profile_name']])) { |
|
| 1968 | + $name = $txt['permissions_profile_' . $row['profile_name']]; |
|
| 1969 | + } else { |
|
| 1970 | + $name = $row['profile_name']; |
|
| 1971 | + } |
|
| 1899 | 1972 | |
| 1900 | 1973 | $context['profiles'][$row['id_profile']] = array( |
| 1901 | 1974 | 'id' => $row['id_profile'], |
@@ -1950,17 +2023,19 @@ discard block |
||
| 1950 | 2023 | ) |
| 1951 | 2024 | ); |
| 1952 | 2025 | $inserts = array(); |
| 1953 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1954 | - $inserts[] = array($profile_id, $row['id_group'], $row['permission'], $row['add_deny']); |
|
| 2026 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2027 | + $inserts[] = array($profile_id, $row['id_group'], $row['permission'], $row['add_deny']); |
|
| 2028 | + } |
|
| 1955 | 2029 | $smcFunc['db_free_result']($request); |
| 1956 | 2030 | |
| 1957 | - if (!empty($inserts)) |
|
| 1958 | - $smcFunc['db_insert']('insert', |
|
| 2031 | + if (!empty($inserts)) { |
|
| 2032 | + $smcFunc['db_insert']('insert', |
|
| 1959 | 2033 | '{db_prefix}board_permissions', |
| 1960 | 2034 | array('id_profile' => 'int', 'id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
| 1961 | 2035 | $inserts, |
| 1962 | 2036 | array('id_profile', 'id_group', 'permission') |
| 1963 | 2037 | ); |
| 2038 | + } |
|
| 1964 | 2039 | } |
| 1965 | 2040 | // Renaming? |
| 1966 | 2041 | elseif (isset($_POST['rename'])) |
@@ -1969,16 +2044,16 @@ discard block |
||
| 1969 | 2044 | validateToken('admin-mpp'); |
| 1970 | 2045 | |
| 1971 | 2046 | // Just showing the boxes? |
| 1972 | - if (!isset($_POST['rename_profile'])) |
|
| 1973 | - $context['show_rename_boxes'] = true; |
|
| 1974 | - else |
|
| 2047 | + if (!isset($_POST['rename_profile'])) { |
|
| 2048 | + $context['show_rename_boxes'] = true; |
|
| 2049 | + } else |
|
| 1975 | 2050 | { |
| 1976 | 2051 | foreach ($_POST['rename_profile'] as $id => $value) |
| 1977 | 2052 | { |
| 1978 | 2053 | $value = $smcFunc['htmlspecialchars']($value); |
| 1979 | 2054 | |
| 1980 | - if (trim($value) != '' && $id > 4) |
|
| 1981 | - $smcFunc['db_query']('', ' |
|
| 2055 | + if (trim($value) != '' && $id > 4) { |
|
| 2056 | + $smcFunc['db_query']('', ' |
|
| 1982 | 2057 | UPDATE {db_prefix}permission_profiles |
| 1983 | 2058 | SET profile_name = {string:profile_name} |
| 1984 | 2059 | WHERE id_profile = {int:current_profile}', |
@@ -1987,6 +2062,7 @@ discard block |
||
| 1987 | 2062 | 'profile_name' => $value, |
| 1988 | 2063 | ) |
| 1989 | 2064 | ); |
| 2065 | + } |
|
| 1990 | 2066 | } |
| 1991 | 2067 | } |
| 1992 | 2068 | } |
@@ -1997,9 +2073,10 @@ discard block |
||
| 1997 | 2073 | validateToken('admin-mpp'); |
| 1998 | 2074 | |
| 1999 | 2075 | $profiles = array(); |
| 2000 | - foreach ($_POST['delete_profile'] as $profile) |
|
| 2001 | - if ($profile > 4) |
|
| 2076 | + foreach ($_POST['delete_profile'] as $profile) { |
|
| 2077 | + if ($profile > 4) |
|
| 2002 | 2078 | $profiles[] = (int) $profile; |
| 2079 | + } |
|
| 2003 | 2080 | |
| 2004 | 2081 | // Verify it's not in use... |
| 2005 | 2082 | $request = $smcFunc['db_query']('', ' |
@@ -2011,8 +2088,9 @@ discard block |
||
| 2011 | 2088 | 'profile_list' => $profiles, |
| 2012 | 2089 | ) |
| 2013 | 2090 | ); |
| 2014 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 2015 | - fatal_lang_error('no_access', false); |
|
| 2091 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 2092 | + fatal_lang_error('no_access', false); |
|
| 2093 | + } |
|
| 2016 | 2094 | $smcFunc['db_free_result']($request); |
| 2017 | 2095 | |
| 2018 | 2096 | // Oh well, delete. |
@@ -2036,10 +2114,11 @@ discard block |
||
| 2036 | 2114 | array( |
| 2037 | 2115 | ) |
| 2038 | 2116 | ); |
| 2039 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2040 | - if (isset($context['profiles'][$row['id_profile']])) |
|
| 2117 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2118 | + if (isset($context['profiles'][$row['id_profile']])) |
|
| 2041 | 2119 | { |
| 2042 | 2120 | $context['profiles'][$row['id_profile']]['in_use'] = true; |
| 2121 | + } |
|
| 2043 | 2122 | $context['profiles'][$row['id_profile']]['boards'] = $row['board_count']; |
| 2044 | 2123 | $context['profiles'][$row['id_profile']]['boards_text'] = $row['board_count'] > 1 ? sprintf($txt['permissions_profile_used_by_many'], $row['board_count']) : $txt['permissions_profile_used_by_' . ($row['board_count'] ? 'one' : 'none')]; |
| 2045 | 2124 | } |
@@ -2051,8 +2130,9 @@ discard block |
||
| 2051 | 2130 | { |
| 2052 | 2131 | // Can't delete special ones. |
| 2053 | 2132 | $context['profiles'][$id]['can_edit'] = isset($txt['permissions_profile_' . $profile['unformatted_name']]) ? false : true; |
| 2054 | - if ($context['profiles'][$id]['can_edit']) |
|
| 2055 | - $context['can_edit_something'] = true; |
|
| 2133 | + if ($context['profiles'][$id]['can_edit']) { |
|
| 2134 | + $context['can_edit_something'] = true; |
|
| 2135 | + } |
|
| 2056 | 2136 | |
| 2057 | 2137 | // You can only delete it if you can edit it AND it's not in use. |
| 2058 | 2138 | $context['profiles'][$id]['can_delete'] = $context['profiles'][$id]['can_edit'] && empty($profile['in_use']) ? true : false; |
@@ -2073,8 +2153,9 @@ discard block |
||
| 2073 | 2153 | global $smcFunc; |
| 2074 | 2154 | |
| 2075 | 2155 | // All the parent groups to sort out. |
| 2076 | - if (!is_array($parents)) |
|
| 2077 | - $parents = array($parents); |
|
| 2156 | + if (!is_array($parents)) { |
|
| 2157 | + $parents = array($parents); |
|
| 2158 | + } |
|
| 2078 | 2159 | |
| 2079 | 2160 | // Find all the children of this group. |
| 2080 | 2161 | $request = $smcFunc['db_query']('', ' |
@@ -2101,8 +2182,9 @@ discard block |
||
| 2101 | 2182 | $parents = array_unique($parents); |
| 2102 | 2183 | |
| 2103 | 2184 | // Not a sausage, or a child? |
| 2104 | - if (empty($children)) |
|
| 2105 | - return false; |
|
| 2185 | + if (empty($children)) { |
|
| 2186 | + return false; |
|
| 2187 | + } |
|
| 2106 | 2188 | |
| 2107 | 2189 | // First off, are we doing general permissions? |
| 2108 | 2190 | if ($profile < 1 || $profile === null) |
@@ -2117,9 +2199,10 @@ discard block |
||
| 2117 | 2199 | ) |
| 2118 | 2200 | ); |
| 2119 | 2201 | $permissions = array(); |
| 2120 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2121 | - foreach ($children[$row['id_group']] as $child) |
|
| 2202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2203 | + foreach ($children[$row['id_group']] as $child) |
|
| 2122 | 2204 | $permissions[] = array($child, $row['permission'], $row['add_deny']); |
| 2205 | + } |
|
| 2123 | 2206 | $smcFunc['db_free_result']($request); |
| 2124 | 2207 | |
| 2125 | 2208 | $smcFunc['db_query']('', ' |
@@ -2159,9 +2242,10 @@ discard block |
||
| 2159 | 2242 | ) |
| 2160 | 2243 | ); |
| 2161 | 2244 | $permissions = array(); |
| 2162 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2163 | - foreach ($children[$row['id_group']] as $child) |
|
| 2245 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2246 | + foreach ($children[$row['id_group']] as $child) |
|
| 2164 | 2247 | $permissions[] = array($child, $row['id_profile'], $row['permission'], $row['add_deny']); |
| 2248 | + } |
|
| 2165 | 2249 | $smcFunc['db_free_result']($request); |
| 2166 | 2250 | |
| 2167 | 2251 | $smcFunc['db_query']('', ' |
@@ -2195,12 +2279,15 @@ discard block |
||
| 2195 | 2279 | global $context; |
| 2196 | 2280 | |
| 2197 | 2281 | $context['illegal_permissions'] = array(); |
| 2198 | - if (!allowedTo('admin_forum')) |
|
| 2199 | - $context['illegal_permissions'][] = 'admin_forum'; |
|
| 2200 | - if (!allowedTo('manage_membergroups')) |
|
| 2201 | - $context['illegal_permissions'][] = 'manage_membergroups'; |
|
| 2202 | - if (!allowedTo('manage_permissions')) |
|
| 2203 | - $context['illegal_permissions'][] = 'manage_permissions'; |
|
| 2282 | + if (!allowedTo('admin_forum')) { |
|
| 2283 | + $context['illegal_permissions'][] = 'admin_forum'; |
|
| 2284 | + } |
|
| 2285 | + if (!allowedTo('manage_membergroups')) { |
|
| 2286 | + $context['illegal_permissions'][] = 'manage_membergroups'; |
|
| 2287 | + } |
|
| 2288 | + if (!allowedTo('manage_permissions')) { |
|
| 2289 | + $context['illegal_permissions'][] = 'manage_permissions'; |
|
| 2290 | + } |
|
| 2204 | 2291 | |
| 2205 | 2292 | call_integration_hook('integrate_load_illegal_permissions'); |
| 2206 | 2293 | } |
@@ -2349,16 +2436,17 @@ discard block |
||
| 2349 | 2436 | 'attachment' => 'disallow', |
| 2350 | 2437 | 'children' => array(), |
| 2351 | 2438 | ); |
| 2439 | + } elseif (isset($context['profile_groups'][$row['id_parent']])) { |
|
| 2440 | + $context['profile_groups'][$row['id_parent']]['children'][] = $row['group_name']; |
|
| 2352 | 2441 | } |
| 2353 | - elseif (isset($context['profile_groups'][$row['id_parent']])) |
|
| 2354 | - $context['profile_groups'][$row['id_parent']]['children'][] = $row['group_name']; |
|
| 2355 | 2442 | } |
| 2356 | 2443 | $smcFunc['db_free_result']($request); |
| 2357 | 2444 | |
| 2358 | 2445 | // What are the permissions we are querying? |
| 2359 | 2446 | $all_permissions = array(); |
| 2360 | - foreach ($mappings as $perm_set) |
|
| 2361 | - $all_permissions = array_merge($all_permissions, $perm_set); |
|
| 2447 | + foreach ($mappings as $perm_set) { |
|
| 2448 | + $all_permissions = array_merge($all_permissions, $perm_set); |
|
| 2449 | + } |
|
| 2362 | 2450 | |
| 2363 | 2451 | // If we're saving the changes then do just that - save them. |
| 2364 | 2452 | if (!empty($_POST['save_changes']) && ($context['current_profile'] == 1 || $context['current_profile'] > 4)) |
@@ -2373,8 +2461,7 @@ discard block |
||
| 2373 | 2461 | { |
| 2374 | 2462 | // Turning it on. This seems easy enough. |
| 2375 | 2463 | updateSettings(array('postmod_active' => 1)); |
| 2376 | - } |
|
| 2377 | - else |
|
| 2464 | + } else |
|
| 2378 | 2465 | { |
| 2379 | 2466 | // Turning it off. Not so straightforward. We have to turn off warnings to moderation level, and make everything approved. |
| 2380 | 2467 | updateSettings(array( |
@@ -2385,8 +2472,7 @@ discard block |
||
| 2385 | 2472 | require_once($sourcedir . '/PostModeration.php'); |
| 2386 | 2473 | approveAllData(); |
| 2387 | 2474 | } |
| 2388 | - } |
|
| 2389 | - elseif ($modSettings['postmod_active']) |
|
| 2475 | + } elseif ($modSettings['postmod_active']) |
|
| 2390 | 2476 | { |
| 2391 | 2477 | // We're not saving a new setting - and if it's still enabled we have more work to do. |
| 2392 | 2478 | |
@@ -2416,21 +2502,22 @@ discard block |
||
| 2416 | 2502 | // Give them both sets for fun. |
| 2417 | 2503 | $new_permissions[] = array($context['current_profile'], $group['id'], $data[0], 1); |
| 2418 | 2504 | $new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1); |
| 2505 | + } elseif ($_POST[$index][$group['id']] == 'moderate') { |
|
| 2506 | + $new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1); |
|
| 2419 | 2507 | } |
| 2420 | - elseif ($_POST[$index][$group['id']] == 'moderate') |
|
| 2421 | - $new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1); |
|
| 2422 | 2508 | } |
| 2423 | 2509 | } |
| 2424 | 2510 | } |
| 2425 | 2511 | |
| 2426 | 2512 | // Insert new permissions. |
| 2427 | - if (!empty($new_permissions)) |
|
| 2428 | - $smcFunc['db_insert']('', |
|
| 2513 | + if (!empty($new_permissions)) { |
|
| 2514 | + $smcFunc['db_insert']('', |
|
| 2429 | 2515 | '{db_prefix}board_permissions', |
| 2430 | 2516 | array('id_profile' => 'int', 'id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
| 2431 | 2517 | $new_permissions, |
| 2432 | 2518 | array('id_profile', 'id_group', 'permission') |
| 2433 | 2519 | ); |
| 2520 | + } |
|
| 2434 | 2521 | } |
| 2435 | 2522 | } |
| 2436 | 2523 | |
@@ -2459,11 +2546,13 @@ discard block |
||
| 2459 | 2546 | if ($row['add_deny']) |
| 2460 | 2547 | { |
| 2461 | 2548 | // Full allowance? |
| 2462 | - if ($index == 0) |
|
| 2463 | - $context['profile_groups'][$row['id_group']][$key] = 'allow'; |
|
| 2549 | + if ($index == 0) { |
|
| 2550 | + $context['profile_groups'][$row['id_group']][$key] = 'allow'; |
|
| 2551 | + } |
|
| 2464 | 2552 | // Otherwise only bother with moderate if not on allow. |
| 2465 | - elseif ($context['profile_groups'][$row['id_group']][$key] != 'allow') |
|
| 2466 | - $context['profile_groups'][$row['id_group']][$key] = 'moderate'; |
|
| 2553 | + elseif ($context['profile_groups'][$row['id_group']][$key] != 'allow') { |
|
| 2554 | + $context['profile_groups'][$row['id_group']][$key] = 'moderate'; |
|
| 2555 | + } |
|
| 2467 | 2556 | } |
| 2468 | 2557 | } |
| 2469 | 2558 | } |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Interface cache_api_interface |
@@ -183,8 +184,9 @@ discard block |
||
| 183 | 184 | { |
| 184 | 185 | global $cache_enable; |
| 185 | 186 | |
| 186 | - if ($test) |
|
| 187 | - return true; |
|
| 187 | + if ($test) { |
|
| 188 | + return true; |
|
| 189 | + } |
|
| 188 | 190 | return !empty($cache_enable); |
| 189 | 191 | } |
| 190 | 192 | |
@@ -203,10 +205,11 @@ discard block |
||
| 203 | 205 | global $boardurl, $cachedir; |
| 204 | 206 | |
| 205 | 207 | // Set the default if no prefix was specified. |
| 206 | - if (empty($prefix)) |
|
| 207 | - $this->prefix = md5($boardurl . filemtime($cachedir . '/' . 'index.php')) . '-SMF-'; |
|
| 208 | - else |
|
| 209 | - $this->prefix = $prefix; |
|
| 208 | + if (empty($prefix)) { |
|
| 209 | + $this->prefix = md5($boardurl . filemtime($cachedir . '/' . 'index.php')) . '-SMF-'; |
|
| 210 | + } else { |
|
| 211 | + $this->prefix = $prefix; |
|
| 212 | + } |
|
| 210 | 213 | |
| 211 | 214 | return true; |
| 212 | 215 | } |
@@ -269,8 +272,9 @@ discard block |
||
| 269 | 272 | |
| 270 | 273 | // Invalidate cache, to be sure! |
| 271 | 274 | // ... as long as index.php can be modified, anyway. |
| 272 | - if (is_writable($cachedir . '/' . 'index.php')) |
|
| 273 | - @touch($cachedir . '/' . 'index.php'); |
|
| 275 | + if (is_writable($cachedir . '/' . 'index.php')) { |
|
| 276 | + @touch($cachedir . '/' . 'index.php'); |
|
| 277 | + } |
|
| 274 | 278 | |
| 275 | 279 | return true; |
| 276 | 280 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
| 56 | 57 | |
| 57 | 58 | $context['name'] = $board_info['name']; |
| 58 | 59 | $context['description'] = $board_info['description']; |
| 59 | - if (!empty($board_info['description'])) |
|
| 60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
| 60 | + if (!empty($board_info['description'])) { |
|
| 61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | // How many topics do we have in total? |
| 63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
| 73 | 75 | $session_name = session_name(); |
| 74 | 76 | foreach ($_GET as $k => $v) |
| 75 | 77 | { |
| 76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
| 77 | - $context['robot_no_index'] = true; |
|
| 78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
| 79 | + $context['robot_no_index'] = true; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | } |
| 80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 81 | - $context['robot_no_index'] = true; |
|
| 83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 84 | + $context['robot_no_index'] = true; |
|
| 85 | + } |
|
| 82 | 86 | |
| 83 | 87 | // If we can view unapproved messages and there are some build up a list. |
| 84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
| 89 | 93 | } |
| 90 | 94 | |
| 91 | 95 | // We only know these. |
| 92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
| 93 | - $_REQUEST['sort'] = 'last_post'; |
|
| 96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
| 97 | + $_REQUEST['sort'] = 'last_post'; |
|
| 98 | + } |
|
| 94 | 99 | |
| 95 | 100 | // Make sure the starting place makes sense and construct the page index. |
| 96 | - if (isset($_REQUEST['sort'])) |
|
| 97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 98 | - else |
|
| 99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 101 | + if (isset($_REQUEST['sort'])) { |
|
| 102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 103 | + } else { |
|
| 104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 105 | + } |
|
| 100 | 106 | $context['start'] = &$_REQUEST['start']; |
| 101 | 107 | |
| 102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
| 132 | 138 | $context['link_moderators'] = array(); |
| 133 | 139 | if (!empty($board_info['moderators'])) |
| 134 | 140 | { |
| 135 | - foreach ($board_info['moderators'] as $mod) |
|
| 136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 141 | + foreach ($board_info['moderators'] as $mod) { |
|
| 142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 143 | + } |
|
| 137 | 144 | } |
| 138 | 145 | if (!empty($board_info['moderator_groups'])) |
| 139 | 146 | { |
| 140 | 147 | // By default just tack the moderator groups onto the end of the members |
| 141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 150 | + } |
|
| 143 | 151 | } |
| 144 | 152 | |
| 145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
| 191 | 199 | ); |
| 192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 193 | 201 | { |
| 194 | - if (empty($row['id_member'])) |
|
| 195 | - continue; |
|
| 202 | + if (empty($row['id_member'])) { |
|
| 203 | + continue; |
|
| 204 | + } |
|
| 196 | 205 | |
| 197 | - if (!empty($row['online_color'])) |
|
| 198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 199 | - else |
|
| 200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 206 | + if (!empty($row['online_color'])) { |
|
| 207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 208 | + } else { |
|
| 209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 210 | + } |
|
| 201 | 211 | |
| 202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 203 | - if ($is_buddy) |
|
| 204 | - $link = '<strong>' . $link . '</strong>'; |
|
| 213 | + if ($is_buddy) { |
|
| 214 | + $link = '<strong>' . $link . '</strong>'; |
|
| 215 | + } |
|
| 205 | 216 | |
| 206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 219 | + } |
|
| 208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
| 209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
| 217 | 229 | 'hidden' => empty($row['show_online']), |
| 218 | 230 | ); |
| 219 | 231 | |
| 220 | - if (empty($row['show_online'])) |
|
| 221 | - $context['view_num_hidden']++; |
|
| 232 | + if (empty($row['show_online'])) { |
|
| 233 | + $context['view_num_hidden']++; |
|
| 234 | + } |
|
| 222 | 235 | } |
| 223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
| 224 | 237 | $smcFunc['db_free_result']($request); |
@@ -257,8 +270,9 @@ discard block |
||
| 257 | 270 | $context['sort_direction'] = $ascending ? 'up' : 'down'; |
| 258 | 271 | $txt['starter'] = $txt['started_by']; |
| 259 | 272 | |
| 260 | - foreach ($sort_methods as $key => $val) |
|
| 261 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 273 | + foreach ($sort_methods as $key => $val) { |
|
| 274 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 275 | + } |
|
| 262 | 276 | |
| 263 | 277 | // Calculate the fastest way to get the topics. |
| 264 | 278 | $start = (int) $_REQUEST['start']; |
@@ -268,14 +282,15 @@ discard block |
||
| 268 | 282 | $fake_ascending = true; |
| 269 | 283 | $maxindex = $board_info['total_topics'] < $start + $maxindex + 1 ? $board_info['total_topics'] - $start : $maxindex; |
| 270 | 284 | $start = $board_info['total_topics'] < $start + $maxindex + 1 ? 0 : $board_info['total_topics'] - $start - $maxindex; |
| 285 | + } else { |
|
| 286 | + $fake_ascending = false; |
|
| 271 | 287 | } |
| 272 | - else |
|
| 273 | - $fake_ascending = false; |
|
| 274 | 288 | |
| 275 | 289 | // Setup the default topic icons... |
| 276 | 290 | $context['icon_sources'] = array(); |
| 277 | - foreach ($context['stable_icons'] as $icon) |
|
| 278 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 291 | + foreach ($context['stable_icons'] as $icon) { |
|
| 292 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 293 | + } |
|
| 279 | 294 | |
| 280 | 295 | $topic_ids = array(); |
| 281 | 296 | $context['topics'] = array(); |
@@ -306,8 +321,9 @@ discard block |
||
| 306 | 321 | ) |
| 307 | 322 | ); |
| 308 | 323 | $topic_ids = array(); |
| 309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 310 | - $topic_ids[] = $row['id_topic']; |
|
| 324 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 325 | + $topic_ids[] = $row['id_topic']; |
|
| 326 | + } |
|
| 311 | 327 | } |
| 312 | 328 | |
| 313 | 329 | // Grab the appropriate topic information... |
@@ -363,11 +379,13 @@ discard block |
||
| 363 | 379 | // Begin 'printing' the message index for current board. |
| 364 | 380 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 365 | 381 | { |
| 366 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 367 | - continue; |
|
| 382 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 383 | + continue; |
|
| 384 | + } |
|
| 368 | 385 | |
| 369 | - if (!$pre_query) |
|
| 370 | - $topic_ids[] = $row['id_topic']; |
|
| 386 | + if (!$pre_query) { |
|
| 387 | + $topic_ids[] = $row['id_topic']; |
|
| 388 | + } |
|
| 371 | 389 | |
| 372 | 390 | // Reference the main color class. |
| 373 | 391 | $colorClass = 'windowbg'; |
@@ -377,8 +395,9 @@ discard block |
||
| 377 | 395 | { |
| 378 | 396 | // Limit them to $modSettings['preview_characters'] characters |
| 379 | 397 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 380 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
| 381 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 398 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
| 399 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 400 | + } |
|
| 382 | 401 | |
| 383 | 402 | // Censor the subject and message preview. |
| 384 | 403 | censorText($row['first_subject']); |
@@ -389,27 +408,27 @@ discard block |
||
| 389 | 408 | { |
| 390 | 409 | $row['last_subject'] = $row['first_subject']; |
| 391 | 410 | $row['last_body'] = $row['first_body']; |
| 392 | - } |
|
| 393 | - else |
|
| 411 | + } else |
|
| 394 | 412 | { |
| 395 | 413 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 396 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
| 397 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 414 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
| 415 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 416 | + } |
|
| 398 | 417 | |
| 399 | 418 | censorText($row['last_subject']); |
| 400 | 419 | censorText($row['last_body']); |
| 401 | 420 | } |
| 402 | - } |
|
| 403 | - else |
|
| 421 | + } else |
|
| 404 | 422 | { |
| 405 | 423 | $row['first_body'] = ''; |
| 406 | 424 | $row['last_body'] = ''; |
| 407 | 425 | censorText($row['first_subject']); |
| 408 | 426 | |
| 409 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 410 | - $row['last_subject'] = $row['first_subject']; |
|
| 411 | - else |
|
| 412 | - censorText($row['last_subject']); |
|
| 427 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 428 | + $row['last_subject'] = $row['first_subject']; |
|
| 429 | + } else { |
|
| 430 | + censorText($row['last_subject']); |
|
| 431 | + } |
|
| 413 | 432 | } |
| 414 | 433 | |
| 415 | 434 | // Decide how many pages the topic should have. |
@@ -420,42 +439,50 @@ discard block |
||
| 420 | 439 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
| 421 | 440 | |
| 422 | 441 | // If we can use all, show all. |
| 423 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
| 424 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 442 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
| 443 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 444 | + } |
|
| 445 | + } else { |
|
| 446 | + $pages = ''; |
|
| 425 | 447 | } |
| 426 | - else |
|
| 427 | - $pages = ''; |
|
| 428 | 448 | |
| 429 | 449 | // We need to check the topic icons exist... |
| 430 | 450 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 431 | 451 | { |
| 432 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 433 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 434 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 435 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 436 | - } |
|
| 437 | - else |
|
| 452 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 453 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 454 | + } |
|
| 455 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 456 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 457 | + } |
|
| 458 | + } else |
|
| 438 | 459 | { |
| 439 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 440 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 441 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 442 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 460 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 461 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 462 | + } |
|
| 463 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 464 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 465 | + } |
|
| 443 | 466 | } |
| 444 | 467 | |
| 445 | - if (!empty($board_info['recycle'])) |
|
| 446 | - $row['first_icon'] = 'recycled'; |
|
| 468 | + if (!empty($board_info['recycle'])) { |
|
| 469 | + $row['first_icon'] = 'recycled'; |
|
| 470 | + } |
|
| 447 | 471 | |
| 448 | 472 | // Is this topic pending approval, or does it have any posts pending approval? |
| 449 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
| 450 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 473 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
| 474 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 475 | + } |
|
| 451 | 476 | |
| 452 | 477 | // Sticky topics should get a different color, too. |
| 453 | - if ($row['is_sticky']) |
|
| 454 | - $colorClass .= ' sticky'; |
|
| 478 | + if ($row['is_sticky']) { |
|
| 479 | + $colorClass .= ' sticky'; |
|
| 480 | + } |
|
| 455 | 481 | |
| 456 | 482 | // Locked topics get special treatment as well. |
| 457 | - if ($row['locked']) |
|
| 458 | - $colorClass .= ' locked'; |
|
| 483 | + if ($row['locked']) { |
|
| 484 | + $colorClass .= ' locked'; |
|
| 485 | + } |
|
| 459 | 486 | |
| 460 | 487 | // 'Print' the topic info. |
| 461 | 488 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -536,8 +563,9 @@ discard block |
||
| 536 | 563 | $smcFunc['db_free_result']($result); |
| 537 | 564 | |
| 538 | 565 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
| 539 | - if ($fake_ascending) |
|
| 540 | - $context['topics'] = array_reverse($context['topics'], true); |
|
| 566 | + if ($fake_ascending) { |
|
| 567 | + $context['topics'] = array_reverse($context['topics'], true); |
|
| 568 | + } |
|
| 541 | 569 | |
| 542 | 570 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) |
| 543 | 571 | { |
@@ -554,8 +582,9 @@ discard block |
||
| 554 | 582 | 'limit' => count($topic_ids), |
| 555 | 583 | ) |
| 556 | 584 | ); |
| 557 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 558 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 585 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 586 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 587 | + } |
|
| 559 | 588 | $smcFunc['db_free_result']($result); |
| 560 | 589 | } |
| 561 | 590 | } |
@@ -580,9 +609,9 @@ discard block |
||
| 580 | 609 | // Can we restore topics? |
| 581 | 610 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
| 582 | 611 | |
| 583 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
| 584 | - $context['can_move_any'] = true; |
|
| 585 | - else |
|
| 612 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
| 613 | + $context['can_move_any'] = true; |
|
| 614 | + } else |
|
| 586 | 615 | { |
| 587 | 616 | // We'll use this in a minute |
| 588 | 617 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -609,11 +638,13 @@ discard block |
||
| 609 | 638 | } |
| 610 | 639 | |
| 611 | 640 | // Can we use quick moderation checkboxes? |
| 612 | - if ($options['display_quick_mod'] == 1) |
|
| 613 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 641 | + if ($options['display_quick_mod'] == 1) { |
|
| 642 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 643 | + } |
|
| 614 | 644 | // Or the icons? |
| 615 | - else |
|
| 616 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 645 | + else { |
|
| 646 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 647 | + } |
|
| 617 | 648 | } |
| 618 | 649 | |
| 619 | 650 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -647,13 +678,15 @@ discard block |
||
| 647 | 678 | ); |
| 648 | 679 | |
| 649 | 680 | // We've seen all these boards now! |
| 650 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
| 651 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 681 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
| 682 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 652 | 683 | unset($_SESSION['topicseen_cache'][$k]); |
| 684 | + } |
|
| 653 | 685 | } |
| 654 | 686 | |
| 655 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
| 656 | - unset($_SESSION['topicseen_cache'][$board]); |
|
| 687 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 688 | + unset($_SESSION['topicseen_cache'][$board]); |
|
| 689 | + } |
|
| 657 | 690 | |
| 658 | 691 | $request = $smcFunc['db_query']('', ' |
| 659 | 692 | SELECT id_topic, id_board, sent |
@@ -674,8 +707,9 @@ discard block |
||
| 674 | 707 | $context['is_marked_notify'] = true; |
| 675 | 708 | $board_sent = $row['sent']; |
| 676 | 709 | } |
| 677 | - if (!empty($row['id_topic'])) |
|
| 678 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 710 | + if (!empty($row['id_topic'])) { |
|
| 711 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 712 | + } |
|
| 679 | 713 | } |
| 680 | 714 | $smcFunc['db_free_result']($request); |
| 681 | 715 | |
@@ -699,8 +733,7 @@ discard block |
||
| 699 | 733 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
| 700 | 734 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
| 701 | 735 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
| 702 | - } |
|
| 703 | - else |
|
| 736 | + } else |
|
| 704 | 737 | { |
| 705 | 738 | $context['is_marked_notify'] = false; |
| 706 | 739 | $context['board_notification_mode'] = 1; |
@@ -713,23 +746,27 @@ discard block |
||
| 713 | 746 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 714 | 747 | |
| 715 | 748 | // Don't want to show this forever... |
| 716 | - if ($context['becomesUnapproved']) |
|
| 717 | - unset($_SESSION['becomesUnapproved']); |
|
| 749 | + if ($context['becomesUnapproved']) { |
|
| 750 | + unset($_SESSION['becomesUnapproved']); |
|
| 751 | + } |
|
| 718 | 752 | |
| 719 | 753 | // Build the message index button array. |
| 720 | 754 | $context['normal_buttons'] = array(); |
| 721 | 755 | |
| 722 | - if ($context['can_post_new']) |
|
| 723 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 756 | + if ($context['can_post_new']) { |
|
| 757 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 758 | + } |
|
| 724 | 759 | |
| 725 | - if ($context['can_post_poll']) |
|
| 726 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 760 | + if ($context['can_post_poll']) { |
|
| 761 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 762 | + } |
|
| 727 | 763 | |
| 728 | - if (!$context['user']['is_logged']) |
|
| 729 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 764 | + if (!$context['user']['is_logged']) { |
|
| 765 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 766 | + } |
|
| 730 | 767 | |
| 731 | - if ($context['can_mark_notify']) |
|
| 732 | - $context['normal_buttons']['notify'] = array( |
|
| 768 | + if ($context['can_mark_notify']) { |
|
| 769 | + $context['normal_buttons']['notify'] = array( |
|
| 733 | 770 | 'lang' => true, |
| 734 | 771 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
| 735 | 772 | 'sub_buttons' => array( |
@@ -747,6 +784,7 @@ discard block |
||
| 747 | 784 | ), |
| 748 | 785 | ), |
| 749 | 786 | ); |
| 787 | + } |
|
| 750 | 788 | |
| 751 | 789 | // Javascript for inline editing. |
| 752 | 790 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -768,18 +806,21 @@ discard block |
||
| 768 | 806 | checkSession('request'); |
| 769 | 807 | |
| 770 | 808 | // Lets go straight to the restore area. |
| 771 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
| 772 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 809 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
| 810 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 811 | + } |
|
| 773 | 812 | |
| 774 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 775 | - $_SESSION['topicseen_cache'] = array(); |
|
| 813 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 814 | + $_SESSION['topicseen_cache'] = array(); |
|
| 815 | + } |
|
| 776 | 816 | |
| 777 | 817 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
| 778 | 818 | require_once($sourcedir . '/Subs-Post.php'); |
| 779 | 819 | |
| 780 | 820 | // Remember the last board they moved things to. |
| 781 | - if (isset($_REQUEST['move_to'])) |
|
| 782 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 821 | + if (isset($_REQUEST['move_to'])) { |
|
| 822 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 823 | + } |
|
| 783 | 824 | |
| 784 | 825 | // Only a few possible actions. |
| 785 | 826 | $possibleActions = array(); |
@@ -799,8 +840,7 @@ discard block |
||
| 799 | 840 | ); |
| 800 | 841 | |
| 801 | 842 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
| 802 | - } |
|
| 803 | - else |
|
| 843 | + } else |
|
| 804 | 844 | { |
| 805 | 845 | /** |
| 806 | 846 | * @todo Ugly. There's no getting around this, is there? |
@@ -818,8 +858,7 @@ discard block |
||
| 818 | 858 | if (!empty($board)) |
| 819 | 859 | { |
| 820 | 860 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
| 821 | - } |
|
| 822 | - else |
|
| 861 | + } else |
|
| 823 | 862 | { |
| 824 | 863 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
| 825 | 864 | } |
@@ -830,55 +869,67 @@ discard block |
||
| 830 | 869 | } |
| 831 | 870 | } |
| 832 | 871 | |
| 833 | - if (!$user_info['is_guest']) |
|
| 834 | - $possibleActions[] = 'markread'; |
|
| 835 | - if (!empty($boards_can['make_sticky'])) |
|
| 836 | - $possibleActions[] = 'sticky'; |
|
| 837 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
| 838 | - $possibleActions[] = 'move'; |
|
| 839 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
| 840 | - $possibleActions[] = 'remove'; |
|
| 841 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
| 842 | - $possibleActions[] = 'lock'; |
|
| 843 | - if (!empty($boards_can['merge_any'])) |
|
| 844 | - $possibleActions[] = 'merge'; |
|
| 845 | - if (!empty($boards_can['approve_posts'])) |
|
| 846 | - $possibleActions[] = 'approve'; |
|
| 872 | + if (!$user_info['is_guest']) { |
|
| 873 | + $possibleActions[] = 'markread'; |
|
| 874 | + } |
|
| 875 | + if (!empty($boards_can['make_sticky'])) { |
|
| 876 | + $possibleActions[] = 'sticky'; |
|
| 877 | + } |
|
| 878 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
| 879 | + $possibleActions[] = 'move'; |
|
| 880 | + } |
|
| 881 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
| 882 | + $possibleActions[] = 'remove'; |
|
| 883 | + } |
|
| 884 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
| 885 | + $possibleActions[] = 'lock'; |
|
| 886 | + } |
|
| 887 | + if (!empty($boards_can['merge_any'])) { |
|
| 888 | + $possibleActions[] = 'merge'; |
|
| 889 | + } |
|
| 890 | + if (!empty($boards_can['approve_posts'])) { |
|
| 891 | + $possibleActions[] = 'approve'; |
|
| 892 | + } |
|
| 847 | 893 | |
| 848 | 894 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
| 849 | 895 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
| 850 | 896 | if (!empty($_REQUEST['topics'])) |
| 851 | 897 | { |
| 852 | 898 | // If the action isn't valid, just quit now. |
| 853 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
| 854 | - redirectexit($redirect_url); |
|
| 899 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
| 900 | + redirectexit($redirect_url); |
|
| 901 | + } |
|
| 855 | 902 | |
| 856 | 903 | // Merge requires all topics as one parameter and can be done at once. |
| 857 | 904 | if ($_REQUEST['qaction'] == 'merge') |
| 858 | 905 | { |
| 859 | 906 | // Merge requires at least two topics. |
| 860 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
| 861 | - redirectexit($redirect_url); |
|
| 907 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
| 908 | + redirectexit($redirect_url); |
|
| 909 | + } |
|
| 862 | 910 | |
| 863 | 911 | require_once($sourcedir . '/SplitTopics.php'); |
| 864 | 912 | return MergeExecute($_REQUEST['topics']); |
| 865 | 913 | } |
| 866 | 914 | |
| 867 | 915 | // Just convert to the other method, to make it easier. |
| 868 | - foreach ($_REQUEST['topics'] as $topic) |
|
| 869 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 916 | + foreach ($_REQUEST['topics'] as $topic) { |
|
| 917 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 918 | + } |
|
| 870 | 919 | } |
| 871 | 920 | |
| 872 | 921 | // Weird... how'd you get here? |
| 873 | - if (empty($_REQUEST['actions'])) |
|
| 874 | - redirectexit($redirect_url); |
|
| 922 | + if (empty($_REQUEST['actions'])) { |
|
| 923 | + redirectexit($redirect_url); |
|
| 924 | + } |
|
| 875 | 925 | |
| 876 | 926 | // Validate each action. |
| 877 | 927 | $temp = array(); |
| 878 | 928 | foreach ($_REQUEST['actions'] as $topic => $action) |
| 879 | 929 | { |
| 880 | - if (in_array($action, $possibleActions)) |
|
| 881 | - $temp[(int) $topic] = $action; |
|
| 930 | + if (in_array($action, $possibleActions)) { |
|
| 931 | + $temp[(int) $topic] = $action; |
|
| 932 | + } |
|
| 882 | 933 | } |
| 883 | 934 | $_REQUEST['actions'] = $temp; |
| 884 | 935 | |
@@ -899,27 +950,31 @@ discard block |
||
| 899 | 950 | { |
| 900 | 951 | if (!empty($board)) |
| 901 | 952 | { |
| 902 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
| 903 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 904 | - } |
|
| 905 | - else |
|
| 953 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
| 954 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 955 | + } |
|
| 956 | + } else |
|
| 906 | 957 | { |
| 907 | 958 | // Don't allow them to act on unapproved posts they can't see... |
| 908 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
| 909 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 959 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
| 960 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 961 | + } |
|
| 910 | 962 | // Goodness, this is fun. We need to validate the action. |
| 911 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
| 912 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 913 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
| 914 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 915 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
| 916 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 963 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
| 964 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 965 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
| 966 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 967 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
| 968 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 969 | + } |
|
| 917 | 970 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
| 918 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
| 919 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 971 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
| 972 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 973 | + } |
|
| 920 | 974 | // If the topic is approved then you need permission to approve the posts within. |
| 921 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
| 922 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 975 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
| 976 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 977 | + } |
|
| 923 | 978 | } |
| 924 | 979 | } |
| 925 | 980 | $smcFunc['db_free_result']($request); |
@@ -937,11 +992,11 @@ discard block |
||
| 937 | 992 | { |
| 938 | 993 | $topic = (int) $topic; |
| 939 | 994 | |
| 940 | - if ($action == 'markread') |
|
| 941 | - $markCache[] = $topic; |
|
| 942 | - elseif ($action == 'sticky') |
|
| 943 | - $stickyCache[] = $topic; |
|
| 944 | - elseif ($action == 'move') |
|
| 995 | + if ($action == 'markread') { |
|
| 996 | + $markCache[] = $topic; |
|
| 997 | + } elseif ($action == 'sticky') { |
|
| 998 | + $stickyCache[] = $topic; |
|
| 999 | + } elseif ($action == 'move') |
|
| 945 | 1000 | { |
| 946 | 1001 | require_once($sourcedir . '/MoveTopic.php'); |
| 947 | 1002 | moveTopicConcurrence(); |
@@ -949,23 +1004,25 @@ discard block |
||
| 949 | 1004 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
| 950 | 1005 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
| 951 | 1006 | |
| 952 | - if (empty($moveCache[1][$topic])) |
|
| 953 | - continue; |
|
| 1007 | + if (empty($moveCache[1][$topic])) { |
|
| 1008 | + continue; |
|
| 1009 | + } |
|
| 954 | 1010 | |
| 955 | 1011 | $moveCache[0][] = $topic; |
| 1012 | + } elseif ($action == 'remove') { |
|
| 1013 | + $removeCache[] = $topic; |
|
| 1014 | + } elseif ($action == 'lock') { |
|
| 1015 | + $lockCache[] = $topic; |
|
| 1016 | + } elseif ($action == 'approve') { |
|
| 1017 | + $approveCache[] = $topic; |
|
| 956 | 1018 | } |
| 957 | - elseif ($action == 'remove') |
|
| 958 | - $removeCache[] = $topic; |
|
| 959 | - elseif ($action == 'lock') |
|
| 960 | - $lockCache[] = $topic; |
|
| 961 | - elseif ($action == 'approve') |
|
| 962 | - $approveCache[] = $topic; |
|
| 963 | 1019 | } |
| 964 | 1020 | |
| 965 | - if (empty($board)) |
|
| 966 | - $affectedBoards = array(); |
|
| 967 | - else |
|
| 968 | - $affectedBoards = array($board => array(0, 0)); |
|
| 1021 | + if (empty($board)) { |
|
| 1022 | + $affectedBoards = array(); |
|
| 1023 | + } else { |
|
| 1024 | + $affectedBoards = array($board => array(0, 0)); |
|
| 1025 | + } |
|
| 969 | 1026 | |
| 970 | 1027 | // Do all the stickies... |
| 971 | 1028 | if (!empty($stickyCache)) |
@@ -1025,14 +1082,16 @@ discard block |
||
| 1025 | 1082 | { |
| 1026 | 1083 | $to = $moveCache[1][$row['id_topic']]; |
| 1027 | 1084 | |
| 1028 | - if (empty($to)) |
|
| 1029 | - continue; |
|
| 1085 | + if (empty($to)) { |
|
| 1086 | + continue; |
|
| 1087 | + } |
|
| 1030 | 1088 | |
| 1031 | 1089 | // Does this topic's board count the posts or not? |
| 1032 | 1090 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
| 1033 | 1091 | |
| 1034 | - if (!isset($moveTos[$to])) |
|
| 1035 | - $moveTos[$to] = array(); |
|
| 1092 | + if (!isset($moveTos[$to])) { |
|
| 1093 | + $moveTos[$to] = array(); |
|
| 1094 | + } |
|
| 1036 | 1095 | |
| 1037 | 1096 | $moveTos[$to][] = $row['id_topic']; |
| 1038 | 1097 | |
@@ -1046,8 +1105,9 @@ discard block |
||
| 1046 | 1105 | require_once($sourcedir . '/MoveTopic.php'); |
| 1047 | 1106 | |
| 1048 | 1107 | // Do the actual moves... |
| 1049 | - foreach ($moveTos as $to => $topics) |
|
| 1050 | - moveTopics($topics, $to); |
|
| 1108 | + foreach ($moveTos as $to => $topics) { |
|
| 1109 | + moveTopics($topics, $to); |
|
| 1110 | + } |
|
| 1051 | 1111 | |
| 1052 | 1112 | // Does the post counts need to be updated? |
| 1053 | 1113 | if (!empty($moveTos)) |
@@ -1096,20 +1156,23 @@ discard block |
||
| 1096 | 1156 | |
| 1097 | 1157 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1098 | 1158 | { |
| 1099 | - if (!isset($members[$row['id_member']])) |
|
| 1100 | - $members[$row['id_member']] = 0; |
|
| 1159 | + if (!isset($members[$row['id_member']])) { |
|
| 1160 | + $members[$row['id_member']] = 0; |
|
| 1161 | + } |
|
| 1101 | 1162 | |
| 1102 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
| 1103 | - $members[$row['id_member']] += 1; |
|
| 1104 | - else |
|
| 1105 | - $members[$row['id_member']] -= 1; |
|
| 1163 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
| 1164 | + $members[$row['id_member']] += 1; |
|
| 1165 | + } else { |
|
| 1166 | + $members[$row['id_member']] -= 1; |
|
| 1167 | + } |
|
| 1106 | 1168 | } |
| 1107 | 1169 | |
| 1108 | 1170 | $smcFunc['db_free_result']($request); |
| 1109 | 1171 | |
| 1110 | 1172 | // And now update them member's post counts |
| 1111 | - foreach ($members as $id_member => $post_adj) |
|
| 1112 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1173 | + foreach ($members as $id_member => $post_adj) { |
|
| 1174 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1175 | + } |
|
| 1113 | 1176 | |
| 1114 | 1177 | } |
| 1115 | 1178 | } |
@@ -1189,8 +1252,9 @@ discard block |
||
| 1189 | 1252 | approveTopics($approveCache); |
| 1190 | 1253 | |
| 1191 | 1254 | // Time for some logging! |
| 1192 | - foreach ($approveCache as $topic) |
|
| 1193 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1255 | + foreach ($approveCache as $topic) { |
|
| 1256 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1257 | + } |
|
| 1194 | 1258 | } |
| 1195 | 1259 | } |
| 1196 | 1260 | |
@@ -1225,8 +1289,7 @@ discard block |
||
| 1225 | 1289 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
| 1226 | 1290 | } |
| 1227 | 1291 | $smcFunc['db_free_result']($result); |
| 1228 | - } |
|
| 1229 | - else |
|
| 1292 | + } else |
|
| 1230 | 1293 | { |
| 1231 | 1294 | $result = $smcFunc['db_query']('', ' |
| 1232 | 1295 | SELECT id_topic, locked, id_board |
@@ -1276,13 +1339,15 @@ discard block |
||
| 1276 | 1339 | ) |
| 1277 | 1340 | ); |
| 1278 | 1341 | $logged_topics = array(); |
| 1279 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1280 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1342 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1343 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1344 | + } |
|
| 1281 | 1345 | $smcFunc['db_free_result']($request); |
| 1282 | 1346 | |
| 1283 | 1347 | $markArray = array(); |
| 1284 | - foreach ($markCache as $topic) |
|
| 1285 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1348 | + foreach ($markCache as $topic) { |
|
| 1349 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1350 | + } |
|
| 1286 | 1351 | |
| 1287 | 1352 | $smcFunc['db_insert']('replace', |
| 1288 | 1353 | '{db_prefix}log_topics', |
@@ -1295,8 +1360,9 @@ discard block |
||
| 1295 | 1360 | foreach ($moveCache as $topic) |
| 1296 | 1361 | { |
| 1297 | 1362 | // Didn't actually move anything! |
| 1298 | - if (!isset($topic[0])) |
|
| 1299 | - break; |
|
| 1363 | + if (!isset($topic[0])) { |
|
| 1364 | + break; |
|
| 1365 | + } |
|
| 1300 | 1366 | |
| 1301 | 1367 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
| 1302 | 1368 | sendNotifications($topic[0], 'move'); |
@@ -1318,8 +1384,9 @@ discard block |
||
| 1318 | 1384 | 'calendar_updated' => time(), |
| 1319 | 1385 | )); |
| 1320 | 1386 | |
| 1321 | - if (!empty($affectedBoards)) |
|
| 1322 | - updateLastMessages(array_keys($affectedBoards)); |
|
| 1387 | + if (!empty($affectedBoards)) { |
|
| 1388 | + updateLastMessages(array_keys($affectedBoards)); |
|
| 1389 | + } |
|
| 1323 | 1390 | |
| 1324 | 1391 | redirectexit($redirect_url); |
| 1325 | 1392 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Main dispatcher, the maintenance access point. |
@@ -96,14 +97,16 @@ discard block |
||
| 96 | 97 | call_integration_hook('integrate_manage_maintenance', array(&$subActions)); |
| 97 | 98 | |
| 98 | 99 | // Yep, sub-action time! |
| 99 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 100 | - $subAction = $_REQUEST['sa']; |
|
| 101 | - else |
|
| 102 | - $subAction = 'routine'; |
|
| 100 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 101 | + $subAction = $_REQUEST['sa']; |
|
| 102 | + } else { |
|
| 103 | + $subAction = 'routine'; |
|
| 104 | + } |
|
| 103 | 105 | |
| 104 | 106 | // Doing something special? |
| 105 | - if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) |
|
| 106 | - $activity = $_REQUEST['activity']; |
|
| 107 | + if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) { |
|
| 108 | + $activity = $_REQUEST['activity']; |
|
| 109 | + } |
|
| 107 | 110 | |
| 108 | 111 | // Set a few things. |
| 109 | 112 | $context['page_title'] = $txt['maintain_title']; |
@@ -114,12 +117,14 @@ discard block |
||
| 114 | 117 | call_helper($subActions[$subAction]['function']); |
| 115 | 118 | |
| 116 | 119 | // Any special activity? |
| 117 | - if (isset($activity)) |
|
| 118 | - call_helper($subActions[$subAction]['activities'][$activity]); |
|
| 120 | + if (isset($activity)) { |
|
| 121 | + call_helper($subActions[$subAction]['activities'][$activity]); |
|
| 122 | + } |
|
| 119 | 123 | |
| 120 | 124 | //converted to UTF-8? show a small maintenance info |
| 121 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
| 122 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
| 125 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
| 126 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
| 127 | + } |
|
| 123 | 128 | |
| 124 | 129 | // Create a maintenance token. Kinda hard to do it any other way. |
| 125 | 130 | createToken('admin-maint'); |
@@ -141,19 +146,22 @@ discard block |
||
| 141 | 146 | db_extend('packages'); |
| 142 | 147 | |
| 143 | 148 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 144 | - foreach ($colData as $column) |
|
| 145 | - if ($column['name'] == 'body') |
|
| 149 | + foreach ($colData as $column) { |
|
| 150 | + if ($column['name'] == 'body') |
|
| 146 | 151 | $body_type = $column['type']; |
| 152 | + } |
|
| 147 | 153 | |
| 148 | 154 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
| 149 | 155 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
| 150 | 156 | } |
| 151 | 157 | |
| 152 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
| 153 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
| 154 | - if (isset($_GET['done']) && $_GET['done'] == 'convertentities') |
|
| 155 | - $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
| 156 | -} |
|
| 158 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
| 159 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
| 160 | + } |
|
| 161 | + if (isset($_GET['done']) && $_GET['done'] == 'convertentities') { |
|
| 162 | + $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
| 163 | + } |
|
| 164 | + } |
|
| 157 | 165 | |
| 158 | 166 | /** |
| 159 | 167 | * Supporting function for the routine maintenance area. |
@@ -162,9 +170,10 @@ discard block |
||
| 162 | 170 | { |
| 163 | 171 | global $context, $txt; |
| 164 | 172 | |
| 165 | - if (isset($_GET['done']) && $_GET['done'] == 'recount') |
|
| 166 | - $context['maintenance_finished'] = $txt['maintain_recount']; |
|
| 167 | -} |
|
| 173 | + if (isset($_GET['done']) && $_GET['done'] == 'recount') { |
|
| 174 | + $context['maintenance_finished'] = $txt['maintain_recount']; |
|
| 175 | + } |
|
| 176 | + } |
|
| 168 | 177 | |
| 169 | 178 | /** |
| 170 | 179 | * Supporting function for the members maintenance area. |
@@ -195,8 +204,9 @@ discard block |
||
| 195 | 204 | } |
| 196 | 205 | $smcFunc['db_free_result']($result); |
| 197 | 206 | |
| 198 | - if (isset($_GET['done']) && $_GET['done'] == 'recountposts') |
|
| 199 | - $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
| 207 | + if (isset($_GET['done']) && $_GET['done'] == 'recountposts') { |
|
| 208 | + $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
| 209 | + } |
|
| 200 | 210 | |
| 201 | 211 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 202 | 212 | } |
@@ -222,11 +232,12 @@ discard block |
||
| 222 | 232 | $context['categories'] = array(); |
| 223 | 233 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 224 | 234 | { |
| 225 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 226 | - $context['categories'][$row['id_cat']] = array( |
|
| 235 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 236 | + $context['categories'][$row['id_cat']] = array( |
|
| 227 | 237 | 'name' => $row['cat_name'], |
| 228 | 238 | 'boards' => array() |
| 229 | 239 | ); |
| 240 | + } |
|
| 230 | 241 | |
| 231 | 242 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
| 232 | 243 | 'id' => $row['id_board'], |
@@ -239,11 +250,12 @@ discard block |
||
| 239 | 250 | require_once($sourcedir . '/Subs-Boards.php'); |
| 240 | 251 | sortCategories($context['categories']); |
| 241 | 252 | |
| 242 | - if (isset($_GET['done']) && $_GET['done'] == 'purgeold') |
|
| 243 | - $context['maintenance_finished'] = $txt['maintain_old']; |
|
| 244 | - elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') |
|
| 245 | - $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
| 246 | -} |
|
| 253 | + if (isset($_GET['done']) && $_GET['done'] == 'purgeold') { |
|
| 254 | + $context['maintenance_finished'] = $txt['maintain_old']; |
|
| 255 | + } elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') { |
|
| 256 | + $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
| 257 | + } |
|
| 258 | + } |
|
| 247 | 259 | |
| 248 | 260 | /** |
| 249 | 261 | * Find and fix all errors on the forum. |
@@ -351,15 +363,17 @@ discard block |
||
| 351 | 363 | // Show me your badge! |
| 352 | 364 | isAllowedTo('admin_forum'); |
| 353 | 365 | |
| 354 | - if ($db_type != 'mysql') |
|
| 355 | - return; |
|
| 366 | + if ($db_type != 'mysql') { |
|
| 367 | + return; |
|
| 368 | + } |
|
| 356 | 369 | |
| 357 | 370 | db_extend('packages'); |
| 358 | 371 | |
| 359 | 372 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 360 | - foreach ($colData as $column) |
|
| 361 | - if ($column['name'] == 'body') |
|
| 373 | + foreach ($colData as $column) { |
|
| 374 | + if ($column['name'] == 'body') |
|
| 362 | 375 | $body_type = $column['type']; |
| 376 | + } |
|
| 363 | 377 | |
| 364 | 378 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
| 365 | 379 | |
@@ -369,33 +383,36 @@ discard block |
||
| 369 | 383 | validateToken('admin-maint'); |
| 370 | 384 | |
| 371 | 385 | // Make it longer so we can do their limit. |
| 372 | - if ($body_type == 'text') |
|
| 373 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
| 386 | + if ($body_type == 'text') { |
|
| 387 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
| 388 | + } |
|
| 374 | 389 | // Shorten the column so we can have a bit (literally per record) less space occupied |
| 375 | - else |
|
| 376 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
| 390 | + else { |
|
| 391 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
| 392 | + } |
|
| 377 | 393 | |
| 378 | 394 | // 3rd party integrations may be interested in knowning about this. |
| 379 | 395 | call_integration_hook('integrate_convert_msgbody', array($body_type)); |
| 380 | 396 | |
| 381 | 397 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 382 | - foreach ($colData as $column) |
|
| 383 | - if ($column['name'] == 'body') |
|
| 398 | + foreach ($colData as $column) { |
|
| 399 | + if ($column['name'] == 'body') |
|
| 384 | 400 | $body_type = $column['type']; |
| 401 | + } |
|
| 385 | 402 | |
| 386 | 403 | $context['maintenance_finished'] = $txt[$context['convert_to'] . '_title']; |
| 387 | 404 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
| 388 | 405 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
| 389 | 406 | |
| 390 | 407 | return; |
| 391 | - } |
|
| 392 | - elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
| 408 | + } elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
| 393 | 409 | { |
| 394 | 410 | checkSession(); |
| 395 | - if (empty($_REQUEST['start'])) |
|
| 396 | - validateToken('admin-maint'); |
|
| 397 | - else |
|
| 398 | - validateToken('admin-convertMsg'); |
|
| 411 | + if (empty($_REQUEST['start'])) { |
|
| 412 | + validateToken('admin-maint'); |
|
| 413 | + } else { |
|
| 414 | + validateToken('admin-convertMsg'); |
|
| 415 | + } |
|
| 399 | 416 | |
| 400 | 417 | $context['page_title'] = $txt['not_done_title']; |
| 401 | 418 | $context['continue_post_data'] = ''; |
@@ -427,8 +444,9 @@ discard block |
||
| 427 | 444 | 'increment' => $increment - 1, |
| 428 | 445 | ) |
| 429 | 446 | ); |
| 430 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 431 | - $id_msg_exceeding[] = $row['id_msg']; |
|
| 447 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 448 | + $id_msg_exceeding[] = $row['id_msg']; |
|
| 449 | + } |
|
| 432 | 450 | $smcFunc['db_free_result']($request); |
| 433 | 451 | |
| 434 | 452 | $_REQUEST['start'] += $increment; |
@@ -457,9 +475,9 @@ discard block |
||
| 457 | 475 | { |
| 458 | 476 | $query_msg = array_slice($id_msg_exceeding, 0, 100); |
| 459 | 477 | $context['exceeding_messages_morethan'] = sprintf($txt['exceeding_messages_morethan'], count($id_msg_exceeding)); |
| 478 | + } else { |
|
| 479 | + $query_msg = $id_msg_exceeding; |
|
| 460 | 480 | } |
| 461 | - else |
|
| 462 | - $query_msg = $id_msg_exceeding; |
|
| 463 | 481 | |
| 464 | 482 | $context['exceeding_messages'] = array(); |
| 465 | 483 | $request = $smcFunc['db_query']('', ' |
@@ -470,8 +488,9 @@ discard block |
||
| 470 | 488 | 'messages' => $query_msg, |
| 471 | 489 | ) |
| 472 | 490 | ); |
| 473 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 474 | - $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 491 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 492 | + $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 493 | + } |
|
| 475 | 494 | $smcFunc['db_free_result']($request); |
| 476 | 495 | } |
| 477 | 496 | } |
@@ -495,8 +514,9 @@ discard block |
||
| 495 | 514 | isAllowedTo('admin_forum'); |
| 496 | 515 | |
| 497 | 516 | // Check to see if UTF-8 is currently the default character set. |
| 498 | - if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') |
|
| 499 | - fatal_lang_error('entity_convert_only_utf8'); |
|
| 517 | + if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') { |
|
| 518 | + fatal_lang_error('entity_convert_only_utf8'); |
|
| 519 | + } |
|
| 500 | 520 | |
| 501 | 521 | // Some starting values. |
| 502 | 522 | $context['table'] = empty($_REQUEST['table']) ? 0 : (int) $_REQUEST['table']; |
@@ -558,8 +578,9 @@ discard block |
||
| 558 | 578 | // Make sure we keep stuff unique! |
| 559 | 579 | $primary_keys = array(); |
| 560 | 580 | |
| 561 | - if (function_exists('apache_reset_timeout')) |
|
| 562 | - @apache_reset_timeout(); |
|
| 581 | + if (function_exists('apache_reset_timeout')) { |
|
| 582 | + @apache_reset_timeout(); |
|
| 583 | + } |
|
| 563 | 584 | |
| 564 | 585 | // Get a list of text columns. |
| 565 | 586 | $columns = array(); |
@@ -570,9 +591,10 @@ discard block |
||
| 570 | 591 | 'cur_table' => $cur_table, |
| 571 | 592 | ) |
| 572 | 593 | ); |
| 573 | - while ($column_info = $smcFunc['db_fetch_assoc']($request)) |
|
| 574 | - if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
| 594 | + while ($column_info = $smcFunc['db_fetch_assoc']($request)) { |
|
| 595 | + if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
| 575 | 596 | $columns[] = strtolower($column_info['Field']); |
| 597 | + } |
|
| 576 | 598 | |
| 577 | 599 | // Get the column with the (first) primary key. |
| 578 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -586,8 +608,9 @@ discard block |
||
| 586 | 608 | { |
| 587 | 609 | if ($row['Key_name'] === 'PRIMARY') |
| 588 | 610 | { |
| 589 | - if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) |
|
| 590 | - $primary_key = $row['Column_name']; |
|
| 611 | + if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) { |
|
| 612 | + $primary_key = $row['Column_name']; |
|
| 613 | + } |
|
| 591 | 614 | |
| 592 | 615 | $primary_keys[] = $row['Column_name']; |
| 593 | 616 | } |
@@ -596,8 +619,9 @@ discard block |
||
| 596 | 619 | |
| 597 | 620 | // No primary key, no glory. |
| 598 | 621 | // Same for columns. Just to be sure we've work to do! |
| 599 | - if (empty($primary_key) || empty($columns)) |
|
| 600 | - continue; |
|
| 622 | + if (empty($primary_key) || empty($columns)) { |
|
| 623 | + continue; |
|
| 624 | + } |
|
| 601 | 625 | |
| 602 | 626 | // Get the maximum value for the primary key. |
| 603 | 627 | $request = $smcFunc['db_query']('', ' |
@@ -611,8 +635,9 @@ discard block |
||
| 611 | 635 | list($max_value) = $smcFunc['db_fetch_row']($request); |
| 612 | 636 | $smcFunc['db_free_result']($request); |
| 613 | 637 | |
| 614 | - if (empty($max_value)) |
|
| 615 | - continue; |
|
| 638 | + if (empty($max_value)) { |
|
| 639 | + continue; |
|
| 640 | + } |
|
| 616 | 641 | |
| 617 | 642 | while ($context['start'] <= $max_value) |
| 618 | 643 | { |
@@ -636,10 +661,11 @@ discard block |
||
| 636 | 661 | { |
| 637 | 662 | $insertion_variables = array(); |
| 638 | 663 | $changes = array(); |
| 639 | - foreach ($row as $column_name => $column_value) |
|
| 640 | - if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
| 664 | + foreach ($row as $column_name => $column_value) { |
|
| 665 | + if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
| 641 | 666 | { |
| 642 | 667 | $changes[] = $column_name . ' = {string:changes_' . $column_name . '}'; |
| 668 | + } |
|
| 643 | 669 | $insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~', 'fixchar__callback', $column_value); |
| 644 | 670 | } |
| 645 | 671 | |
@@ -651,8 +677,8 @@ discard block |
||
| 651 | 677 | } |
| 652 | 678 | |
| 653 | 679 | // Update the row. |
| 654 | - if (!empty($changes)) |
|
| 655 | - $smcFunc['db_query']('', ' |
|
| 680 | + if (!empty($changes)) { |
|
| 681 | + $smcFunc['db_query']('', ' |
|
| 656 | 682 | UPDATE {db_prefix}' . $cur_table . ' |
| 657 | 683 | SET |
| 658 | 684 | ' . implode(', |
@@ -660,6 +686,7 @@ discard block |
||
| 660 | 686 | WHERE ' . implode(' AND ', $where), |
| 661 | 687 | $insertion_variables |
| 662 | 688 | ); |
| 689 | + } |
|
| 663 | 690 | } |
| 664 | 691 | $smcFunc['db_free_result']($request); |
| 665 | 692 | $context['start'] += 500; |
@@ -704,10 +731,11 @@ discard block |
||
| 704 | 731 | |
| 705 | 732 | checkSession('request'); |
| 706 | 733 | |
| 707 | - if (!isset($_SESSION['optimized_tables'])) |
|
| 708 | - validateToken('admin-maint'); |
|
| 709 | - else |
|
| 710 | - validateToken('admin-optimize', 'post', false); |
|
| 734 | + if (!isset($_SESSION['optimized_tables'])) { |
|
| 735 | + validateToken('admin-maint'); |
|
| 736 | + } else { |
|
| 737 | + validateToken('admin-optimize', 'post', false); |
|
| 738 | + } |
|
| 711 | 739 | |
| 712 | 740 | ignore_user_abort(true); |
| 713 | 741 | db_extend(); |
@@ -723,13 +751,15 @@ discard block |
||
| 723 | 751 | // Get a list of tables, as well as how many there are. |
| 724 | 752 | $temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%'); |
| 725 | 753 | $tables = array(); |
| 726 | - foreach ($temp_tables as $table) |
|
| 727 | - $tables[] = array('table_name' => $table); |
|
| 754 | + foreach ($temp_tables as $table) { |
|
| 755 | + $tables[] = array('table_name' => $table); |
|
| 756 | + } |
|
| 728 | 757 | |
| 729 | 758 | // If there aren't any tables then I believe that would mean the world has exploded... |
| 730 | 759 | $context['num_tables'] = count($tables); |
| 731 | - if ($context['num_tables'] == 0) |
|
| 732 | - fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
| 760 | + if ($context['num_tables'] == 0) { |
|
| 761 | + fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
| 762 | + } |
|
| 733 | 763 | |
| 734 | 764 | $_REQUEST['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 735 | 765 | |
@@ -740,8 +770,9 @@ discard block |
||
| 740 | 770 | $_SESSION['optimized_tables'] = !empty($_SESSION['optimized_tables']) ? $_SESSION['optimized_tables'] : array(); |
| 741 | 771 | for ($key = $_REQUEST['start']; $context['num_tables'] - 1; $key++) |
| 742 | 772 | { |
| 743 | - if (empty($tables[$key])) |
|
| 744 | - break; |
|
| 773 | + if (empty($tables[$key])) { |
|
| 774 | + break; |
|
| 775 | + } |
|
| 745 | 776 | |
| 746 | 777 | // Continue? |
| 747 | 778 | if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 10) |
@@ -755,8 +786,9 @@ discard block |
||
| 755 | 786 | createToken('admin-optimize'); |
| 756 | 787 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-optimize_token_var'] . '" value="' . $context['admin-optimize_token'] . '">'; |
| 757 | 788 | |
| 758 | - if (function_exists('apache_reset_timeout')) |
|
| 759 | - apache_reset_timeout(); |
|
| 789 | + if (function_exists('apache_reset_timeout')) { |
|
| 790 | + apache_reset_timeout(); |
|
| 791 | + } |
|
| 760 | 792 | |
| 761 | 793 | return; |
| 762 | 794 | } |
@@ -764,11 +796,12 @@ discard block |
||
| 764 | 796 | // Optimize the table! We use backticks here because it might be a custom table. |
| 765 | 797 | $data_freed = $smcFunc['db_optimize_table']($tables[$key]['table_name']); |
| 766 | 798 | |
| 767 | - if ($data_freed > 0) |
|
| 768 | - $_SESSION['optimized_tables'][] = array( |
|
| 799 | + if ($data_freed > 0) { |
|
| 800 | + $_SESSION['optimized_tables'][] = array( |
|
| 769 | 801 | 'name' => $tables[$key]['table_name'], |
| 770 | 802 | 'data_freed' => $data_freed, |
| 771 | 803 | ); |
| 804 | + } |
|
| 772 | 805 | } |
| 773 | 806 | |
| 774 | 807 | // Number of tables, etc... |
@@ -803,10 +836,11 @@ discard block |
||
| 803 | 836 | checkSession('request'); |
| 804 | 837 | |
| 805 | 838 | // validate the request or the loop |
| 806 | - if (!isset($_REQUEST['step'])) |
|
| 807 | - validateToken('admin-maint'); |
|
| 808 | - else |
|
| 809 | - validateToken('admin-boardrecount'); |
|
| 839 | + if (!isset($_REQUEST['step'])) { |
|
| 840 | + validateToken('admin-maint'); |
|
| 841 | + } else { |
|
| 842 | + validateToken('admin-boardrecount'); |
|
| 843 | + } |
|
| 810 | 844 | |
| 811 | 845 | $context['page_title'] = $txt['not_done_title']; |
| 812 | 846 | $context['continue_post_data'] = ''; |
@@ -827,8 +861,9 @@ discard block |
||
| 827 | 861 | $smcFunc['db_free_result']($request); |
| 828 | 862 | |
| 829 | 863 | $increment = min(max(50, ceil($max_topics / 4)), 2000); |
| 830 | - if (empty($_REQUEST['start'])) |
|
| 831 | - $_REQUEST['start'] = 0; |
|
| 864 | + if (empty($_REQUEST['start'])) { |
|
| 865 | + $_REQUEST['start'] = 0; |
|
| 866 | + } |
|
| 832 | 867 | |
| 833 | 868 | $total_steps = 8; |
| 834 | 869 | |
@@ -855,8 +890,8 @@ discard block |
||
| 855 | 890 | 'max_id' => $_REQUEST['start'] + $increment, |
| 856 | 891 | ) |
| 857 | 892 | ); |
| 858 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 859 | - $smcFunc['db_query']('', ' |
|
| 893 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 894 | + $smcFunc['db_query']('', ' |
|
| 860 | 895 | UPDATE {db_prefix}topics |
| 861 | 896 | SET num_replies = {int:num_replies} |
| 862 | 897 | WHERE id_topic = {int:id_topic}', |
@@ -865,6 +900,7 @@ discard block |
||
| 865 | 900 | 'id_topic' => $row['id_topic'], |
| 866 | 901 | ) |
| 867 | 902 | ); |
| 903 | + } |
|
| 868 | 904 | $smcFunc['db_free_result']($request); |
| 869 | 905 | |
| 870 | 906 | // Recount unapproved messages |
@@ -883,8 +919,8 @@ discard block |
||
| 883 | 919 | 'max_id' => $_REQUEST['start'] + $increment, |
| 884 | 920 | ) |
| 885 | 921 | ); |
| 886 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 887 | - $smcFunc['db_query']('', ' |
|
| 922 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 923 | + $smcFunc['db_query']('', ' |
|
| 888 | 924 | UPDATE {db_prefix}topics |
| 889 | 925 | SET unapproved_posts = {int:unapproved_posts} |
| 890 | 926 | WHERE id_topic = {int:id_topic}', |
@@ -893,6 +929,7 @@ discard block |
||
| 893 | 929 | 'id_topic' => $row['id_topic'], |
| 894 | 930 | ) |
| 895 | 931 | ); |
| 932 | + } |
|
| 896 | 933 | $smcFunc['db_free_result']($request); |
| 897 | 934 | |
| 898 | 935 | $_REQUEST['start'] += $increment; |
@@ -915,8 +952,8 @@ discard block |
||
| 915 | 952 | // Update the post count of each board. |
| 916 | 953 | if ($_REQUEST['step'] <= 1) |
| 917 | 954 | { |
| 918 | - if (empty($_REQUEST['start'])) |
|
| 919 | - $smcFunc['db_query']('', ' |
|
| 955 | + if (empty($_REQUEST['start'])) { |
|
| 956 | + $smcFunc['db_query']('', ' |
|
| 920 | 957 | UPDATE {db_prefix}boards |
| 921 | 958 | SET num_posts = {int:num_posts} |
| 922 | 959 | WHERE redirect = {string:redirect}', |
@@ -925,6 +962,7 @@ discard block |
||
| 925 | 962 | 'redirect' => '', |
| 926 | 963 | ) |
| 927 | 964 | ); |
| 965 | + } |
|
| 928 | 966 | |
| 929 | 967 | while ($_REQUEST['start'] < $max_topics) |
| 930 | 968 | { |
@@ -941,8 +979,8 @@ discard block |
||
| 941 | 979 | 'is_approved' => 1, |
| 942 | 980 | ) |
| 943 | 981 | ); |
| 944 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 945 | - $smcFunc['db_query']('', ' |
|
| 982 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 983 | + $smcFunc['db_query']('', ' |
|
| 946 | 984 | UPDATE {db_prefix}boards |
| 947 | 985 | SET num_posts = num_posts + {int:real_num_posts} |
| 948 | 986 | WHERE id_board = {int:id_board}', |
@@ -951,6 +989,7 @@ discard block |
||
| 951 | 989 | 'real_num_posts' => $row['real_num_posts'], |
| 952 | 990 | ) |
| 953 | 991 | ); |
| 992 | + } |
|
| 954 | 993 | $smcFunc['db_free_result']($request); |
| 955 | 994 | |
| 956 | 995 | $_REQUEST['start'] += $increment; |
@@ -973,14 +1012,15 @@ discard block |
||
| 973 | 1012 | // Update the topic count of each board. |
| 974 | 1013 | if ($_REQUEST['step'] <= 2) |
| 975 | 1014 | { |
| 976 | - if (empty($_REQUEST['start'])) |
|
| 977 | - $smcFunc['db_query']('', ' |
|
| 1015 | + if (empty($_REQUEST['start'])) { |
|
| 1016 | + $smcFunc['db_query']('', ' |
|
| 978 | 1017 | UPDATE {db_prefix}boards |
| 979 | 1018 | SET num_topics = {int:num_topics}', |
| 980 | 1019 | array( |
| 981 | 1020 | 'num_topics' => 0, |
| 982 | 1021 | ) |
| 983 | 1022 | ); |
| 1023 | + } |
|
| 984 | 1024 | |
| 985 | 1025 | while ($_REQUEST['start'] < $max_topics) |
| 986 | 1026 | { |
@@ -997,8 +1037,8 @@ discard block |
||
| 997 | 1037 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
| 998 | 1038 | ) |
| 999 | 1039 | ); |
| 1000 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1001 | - $smcFunc['db_query']('', ' |
|
| 1040 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1041 | + $smcFunc['db_query']('', ' |
|
| 1002 | 1042 | UPDATE {db_prefix}boards |
| 1003 | 1043 | SET num_topics = num_topics + {int:real_num_topics} |
| 1004 | 1044 | WHERE id_board = {int:id_board}', |
@@ -1007,6 +1047,7 @@ discard block |
||
| 1007 | 1047 | 'real_num_topics' => $row['real_num_topics'], |
| 1008 | 1048 | ) |
| 1009 | 1049 | ); |
| 1050 | + } |
|
| 1010 | 1051 | $smcFunc['db_free_result']($request); |
| 1011 | 1052 | |
| 1012 | 1053 | $_REQUEST['start'] += $increment; |
@@ -1029,14 +1070,15 @@ discard block |
||
| 1029 | 1070 | // Update the unapproved post count of each board. |
| 1030 | 1071 | if ($_REQUEST['step'] <= 3) |
| 1031 | 1072 | { |
| 1032 | - if (empty($_REQUEST['start'])) |
|
| 1033 | - $smcFunc['db_query']('', ' |
|
| 1073 | + if (empty($_REQUEST['start'])) { |
|
| 1074 | + $smcFunc['db_query']('', ' |
|
| 1034 | 1075 | UPDATE {db_prefix}boards |
| 1035 | 1076 | SET unapproved_posts = {int:unapproved_posts}', |
| 1036 | 1077 | array( |
| 1037 | 1078 | 'unapproved_posts' => 0, |
| 1038 | 1079 | ) |
| 1039 | 1080 | ); |
| 1081 | + } |
|
| 1040 | 1082 | |
| 1041 | 1083 | while ($_REQUEST['start'] < $max_topics) |
| 1042 | 1084 | { |
@@ -1053,8 +1095,8 @@ discard block |
||
| 1053 | 1095 | 'is_approved' => 0, |
| 1054 | 1096 | ) |
| 1055 | 1097 | ); |
| 1056 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1057 | - $smcFunc['db_query']('', ' |
|
| 1098 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1099 | + $smcFunc['db_query']('', ' |
|
| 1058 | 1100 | UPDATE {db_prefix}boards |
| 1059 | 1101 | SET unapproved_posts = unapproved_posts + {int:unapproved_posts} |
| 1060 | 1102 | WHERE id_board = {int:id_board}', |
@@ -1063,6 +1105,7 @@ discard block |
||
| 1063 | 1105 | 'unapproved_posts' => $row['real_unapproved_posts'], |
| 1064 | 1106 | ) |
| 1065 | 1107 | ); |
| 1108 | + } |
|
| 1066 | 1109 | $smcFunc['db_free_result']($request); |
| 1067 | 1110 | |
| 1068 | 1111 | $_REQUEST['start'] += $increment; |
@@ -1085,14 +1128,15 @@ discard block |
||
| 1085 | 1128 | // Update the unapproved topic count of each board. |
| 1086 | 1129 | if ($_REQUEST['step'] <= 4) |
| 1087 | 1130 | { |
| 1088 | - if (empty($_REQUEST['start'])) |
|
| 1089 | - $smcFunc['db_query']('', ' |
|
| 1131 | + if (empty($_REQUEST['start'])) { |
|
| 1132 | + $smcFunc['db_query']('', ' |
|
| 1090 | 1133 | UPDATE {db_prefix}boards |
| 1091 | 1134 | SET unapproved_topics = {int:unapproved_topics}', |
| 1092 | 1135 | array( |
| 1093 | 1136 | 'unapproved_topics' => 0, |
| 1094 | 1137 | ) |
| 1095 | 1138 | ); |
| 1139 | + } |
|
| 1096 | 1140 | |
| 1097 | 1141 | while ($_REQUEST['start'] < $max_topics) |
| 1098 | 1142 | { |
@@ -1109,8 +1153,8 @@ discard block |
||
| 1109 | 1153 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
| 1110 | 1154 | ) |
| 1111 | 1155 | ); |
| 1112 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1113 | - $smcFunc['db_query']('', ' |
|
| 1156 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1157 | + $smcFunc['db_query']('', ' |
|
| 1114 | 1158 | UPDATE {db_prefix}boards |
| 1115 | 1159 | SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics} |
| 1116 | 1160 | WHERE id_board = {int:id_board}', |
@@ -1119,6 +1163,7 @@ discard block |
||
| 1119 | 1163 | 'real_unapproved_topics' => $row['real_unapproved_topics'], |
| 1120 | 1164 | ) |
| 1121 | 1165 | ); |
| 1166 | + } |
|
| 1122 | 1167 | $smcFunc['db_free_result']($request); |
| 1123 | 1168 | |
| 1124 | 1169 | $_REQUEST['start'] += $increment; |
@@ -1152,8 +1197,9 @@ discard block |
||
| 1152 | 1197 | 'is_not_deleted' => 0, |
| 1153 | 1198 | ) |
| 1154 | 1199 | ); |
| 1155 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1156 | - updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
| 1200 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1201 | + updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
| 1202 | + } |
|
| 1157 | 1203 | $smcFunc['db_free_result']($request); |
| 1158 | 1204 | |
| 1159 | 1205 | $request = $smcFunc['db_query']('', ' |
@@ -1168,8 +1214,9 @@ discard block |
||
| 1168 | 1214 | 'is_not_read' => 0, |
| 1169 | 1215 | ) |
| 1170 | 1216 | ); |
| 1171 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1172 | - updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
| 1217 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1218 | + updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
| 1219 | + } |
|
| 1173 | 1220 | $smcFunc['db_free_result']($request); |
| 1174 | 1221 | |
| 1175 | 1222 | if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3) |
@@ -1201,12 +1248,13 @@ discard block |
||
| 1201 | 1248 | ) |
| 1202 | 1249 | ); |
| 1203 | 1250 | $boards = array(); |
| 1204 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1205 | - $boards[$row['id_board']][] = $row['id_msg']; |
|
| 1251 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1252 | + $boards[$row['id_board']][] = $row['id_msg']; |
|
| 1253 | + } |
|
| 1206 | 1254 | $smcFunc['db_free_result']($request); |
| 1207 | 1255 | |
| 1208 | - foreach ($boards as $board_id => $messages) |
|
| 1209 | - $smcFunc['db_query']('', ' |
|
| 1256 | + foreach ($boards as $board_id => $messages) { |
|
| 1257 | + $smcFunc['db_query']('', ' |
|
| 1210 | 1258 | UPDATE {db_prefix}messages |
| 1211 | 1259 | SET id_board = {int:id_board} |
| 1212 | 1260 | WHERE id_msg IN ({array_int:id_msg_array})', |
@@ -1215,6 +1263,7 @@ discard block |
||
| 1215 | 1263 | 'id_board' => $board_id, |
| 1216 | 1264 | ) |
| 1217 | 1265 | ); |
| 1266 | + } |
|
| 1218 | 1267 | |
| 1219 | 1268 | $_REQUEST['start'] += $increment; |
| 1220 | 1269 | |
@@ -1244,8 +1293,9 @@ discard block |
||
| 1244 | 1293 | ) |
| 1245 | 1294 | ); |
| 1246 | 1295 | $realBoardCounts = array(); |
| 1247 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1248 | - $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
| 1296 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1297 | + $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
| 1298 | + } |
|
| 1249 | 1299 | $smcFunc['db_free_result']($request); |
| 1250 | 1300 | |
| 1251 | 1301 | $request = $smcFunc['db_query']('', ' |
@@ -1265,18 +1315,20 @@ discard block |
||
| 1265 | 1315 | krsort($resort_me); |
| 1266 | 1316 | |
| 1267 | 1317 | $lastModifiedMsg = array(); |
| 1268 | - foreach ($resort_me as $rows) |
|
| 1269 | - foreach ($rows as $row) |
|
| 1318 | + foreach ($resort_me as $rows) { |
|
| 1319 | + foreach ($rows as $row) |
|
| 1270 | 1320 | { |
| 1271 | 1321 | // The latest message is the latest of the current board and its children. |
| 1272 | 1322 | if (isset($lastModifiedMsg[$row['id_board']])) |
| 1273 | 1323 | $curLastModifiedMsg = max($row['local_last_msg'], $lastModifiedMsg[$row['id_board']]); |
| 1274 | - else |
|
| 1275 | - $curLastModifiedMsg = $row['local_last_msg']; |
|
| 1324 | + } |
|
| 1325 | + else { |
|
| 1326 | + $curLastModifiedMsg = $row['local_last_msg']; |
|
| 1327 | + } |
|
| 1276 | 1328 | |
| 1277 | 1329 | // If what is and what should be the latest message differ, an update is necessary. |
| 1278 | - if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) |
|
| 1279 | - $smcFunc['db_query']('', ' |
|
| 1330 | + if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) { |
|
| 1331 | + $smcFunc['db_query']('', ' |
|
| 1280 | 1332 | UPDATE {db_prefix}boards |
| 1281 | 1333 | SET id_last_msg = {int:id_last_msg}, id_msg_updated = {int:id_msg_updated} |
| 1282 | 1334 | WHERE id_board = {int:id_board}', |
@@ -1286,12 +1338,14 @@ discard block |
||
| 1286 | 1338 | 'id_board' => $row['id_board'], |
| 1287 | 1339 | ) |
| 1288 | 1340 | ); |
| 1341 | + } |
|
| 1289 | 1342 | |
| 1290 | 1343 | // Parent boards inherit the latest modified message of their children. |
| 1291 | - if (isset($lastModifiedMsg[$row['id_parent']])) |
|
| 1292 | - $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
| 1293 | - else |
|
| 1294 | - $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
| 1344 | + if (isset($lastModifiedMsg[$row['id_parent']])) { |
|
| 1345 | + $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
| 1346 | + } else { |
|
| 1347 | + $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
| 1348 | + } |
|
| 1295 | 1349 | } |
| 1296 | 1350 | |
| 1297 | 1351 | // Update all the basic statistics. |
@@ -1363,8 +1417,9 @@ discard block |
||
| 1363 | 1417 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1364 | 1418 | $members = findMembers($_POST['to']); |
| 1365 | 1419 | |
| 1366 | - if (empty($members)) |
|
| 1367 | - fatal_lang_error('reattribute_cannot_find_member'); |
|
| 1420 | + if (empty($members)) { |
|
| 1421 | + fatal_lang_error('reattribute_cannot_find_member'); |
|
| 1422 | + } |
|
| 1368 | 1423 | |
| 1369 | 1424 | $memID = array_shift($members); |
| 1370 | 1425 | $memID = $memID['id']; |
@@ -1394,8 +1449,9 @@ discard block |
||
| 1394 | 1449 | validateToken('admin-maint'); |
| 1395 | 1450 | |
| 1396 | 1451 | $groups = array(); |
| 1397 | - foreach ($_POST['groups'] as $id => $dummy) |
|
| 1398 | - $groups[] = (int) $id; |
|
| 1452 | + foreach ($_POST['groups'] as $id => $dummy) { |
|
| 1453 | + $groups[] = (int) $id; |
|
| 1454 | + } |
|
| 1399 | 1455 | $time_limit = (time() - ($_POST['maxdays'] * 24 * 3600)); |
| 1400 | 1456 | $where_vars = array( |
| 1401 | 1457 | 'time_limit' => $time_limit, |
@@ -1404,9 +1460,9 @@ discard block |
||
| 1404 | 1460 | { |
| 1405 | 1461 | $where = 'mem.date_registered < {int:time_limit} AND mem.is_activated = {int:is_activated}'; |
| 1406 | 1462 | $where_vars['is_activated'] = 0; |
| 1463 | + } else { |
|
| 1464 | + $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
| 1407 | 1465 | } |
| 1408 | - else |
|
| 1409 | - $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
| 1410 | 1466 | |
| 1411 | 1467 | // Need to get *all* groups then work out which (if any) we avoid. |
| 1412 | 1468 | $request = $smcFunc['db_query']('', ' |
@@ -1425,8 +1481,7 @@ discard block |
||
| 1425 | 1481 | { |
| 1426 | 1482 | $where .= ' AND mem.id_post_group != {int:id_post_group_' . $row['id_group'] . '}'; |
| 1427 | 1483 | $where_vars['id_post_group_' . $row['id_group']] = $row['id_group']; |
| 1428 | - } |
|
| 1429 | - else |
|
| 1484 | + } else |
|
| 1430 | 1485 | { |
| 1431 | 1486 | $where .= ' AND mem.id_group != {int:id_group_' . $row['id_group'] . '} AND FIND_IN_SET({int:id_group_' . $row['id_group'] . '}, mem.additional_groups) = 0'; |
| 1432 | 1487 | $where_vars['id_group_' . $row['id_group']] = $row['id_group']; |
@@ -1453,8 +1508,9 @@ discard block |
||
| 1453 | 1508 | $members = array(); |
| 1454 | 1509 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1455 | 1510 | { |
| 1456 | - if (!$row['is_mod'] || !in_array(3, $groups)) |
|
| 1457 | - $members[] = $row['id_member']; |
|
| 1511 | + if (!$row['is_mod'] || !in_array(3, $groups)) { |
|
| 1512 | + $members[] = $row['id_member']; |
|
| 1513 | + } |
|
| 1458 | 1514 | } |
| 1459 | 1515 | $smcFunc['db_free_result']($request); |
| 1460 | 1516 | |
@@ -1501,8 +1557,9 @@ discard block |
||
| 1501 | 1557 | ) |
| 1502 | 1558 | ); |
| 1503 | 1559 | |
| 1504 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1505 | - $drafts[] = (int) $row[0]; |
|
| 1560 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1561 | + $drafts[] = (int) $row[0]; |
|
| 1562 | + } |
|
| 1506 | 1563 | $smcFunc['db_free_result']($request); |
| 1507 | 1564 | |
| 1508 | 1565 | // If we have old drafts, remove them |
@@ -1545,8 +1602,9 @@ discard block |
||
| 1545 | 1602 | $sticky = isset($_POST['move_type_sticky']) || isset($_GET['sticky']); |
| 1546 | 1603 | |
| 1547 | 1604 | // No boards then this is your stop. |
| 1548 | - if (empty($id_board_from) || empty($id_board_to)) |
|
| 1549 | - return; |
|
| 1605 | + if (empty($id_board_from) || empty($id_board_to)) { |
|
| 1606 | + return; |
|
| 1607 | + } |
|
| 1550 | 1608 | |
| 1551 | 1609 | // The big WHERE clause |
| 1552 | 1610 | $conditions = 'WHERE t.id_board = {int:id_board_from} |
@@ -1594,18 +1652,20 @@ discard block |
||
| 1594 | 1652 | ); |
| 1595 | 1653 | list ($total_topics) = $smcFunc['db_fetch_row']($request); |
| 1596 | 1654 | $smcFunc['db_free_result']($request); |
| 1655 | + } else { |
|
| 1656 | + $total_topics = (int) $_REQUEST['totaltopics']; |
|
| 1597 | 1657 | } |
| 1598 | - else |
|
| 1599 | - $total_topics = (int) $_REQUEST['totaltopics']; |
|
| 1600 | 1658 | |
| 1601 | 1659 | // Seems like we need this here. |
| 1602 | 1660 | $context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';max_days=' . $max_days; |
| 1603 | 1661 | |
| 1604 | - if ($locked) |
|
| 1605 | - $context['continue_get_data'] .= ';locked'; |
|
| 1662 | + if ($locked) { |
|
| 1663 | + $context['continue_get_data'] .= ';locked'; |
|
| 1664 | + } |
|
| 1606 | 1665 | |
| 1607 | - if ($sticky) |
|
| 1608 | - $context['continue_get_data'] .= ';sticky'; |
|
| 1666 | + if ($sticky) { |
|
| 1667 | + $context['continue_get_data'] .= ';sticky'; |
|
| 1668 | + } |
|
| 1609 | 1669 | |
| 1610 | 1670 | $context['continue_get_data'] .= ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1611 | 1671 | |
@@ -1626,8 +1686,9 @@ discard block |
||
| 1626 | 1686 | |
| 1627 | 1687 | // Get the ids. |
| 1628 | 1688 | $topics = array(); |
| 1629 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1630 | - $topics[] = $row['id_topic']; |
|
| 1689 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1690 | + $topics[] = $row['id_topic']; |
|
| 1691 | + } |
|
| 1631 | 1692 | |
| 1632 | 1693 | // Just return if we don't have any topics left to move. |
| 1633 | 1694 | if (empty($topics)) |
@@ -1718,9 +1779,9 @@ discard block |
||
| 1718 | 1779 | // save it so we don't do this again for this task |
| 1719 | 1780 | list ($_SESSION['total_members']) = $smcFunc['db_fetch_row']($request); |
| 1720 | 1781 | $smcFunc['db_free_result']($request); |
| 1782 | + } else { |
|
| 1783 | + validateToken('admin-recountposts'); |
|
| 1721 | 1784 | } |
| 1722 | - else |
|
| 1723 | - validateToken('admin-recountposts'); |
|
| 1724 | 1785 | |
| 1725 | 1786 | // Lets get a group of members and determine their post count (from the boards that have post count enabled of course). |
| 1726 | 1787 | $request = $smcFunc['db_query']('', ' |
@@ -1766,8 +1827,9 @@ discard block |
||
| 1766 | 1827 | createToken('admin-recountposts'); |
| 1767 | 1828 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-recountposts_token_var'] . '" value="' . $context['admin-recountposts_token'] . '">'; |
| 1768 | 1829 | |
| 1769 | - if (function_exists('apache_reset_timeout')) |
|
| 1770 | - apache_reset_timeout(); |
|
| 1830 | + if (function_exists('apache_reset_timeout')) { |
|
| 1831 | + apache_reset_timeout(); |
|
| 1832 | + } |
|
| 1771 | 1833 | return; |
| 1772 | 1834 | } |
| 1773 | 1835 | |
@@ -1853,10 +1915,9 @@ discard block |
||
| 1853 | 1915 | checkSession('request'); |
| 1854 | 1916 | validateToken('admin-hook', 'request'); |
| 1855 | 1917 | |
| 1856 | - if ($_REQUEST['do'] == 'remove') |
|
| 1857 | - remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
| 1858 | - |
|
| 1859 | - else |
|
| 1918 | + if ($_REQUEST['do'] == 'remove') { |
|
| 1919 | + remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
| 1920 | + } else |
|
| 1860 | 1921 | { |
| 1861 | 1922 | $function_remove = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '' : '!'); |
| 1862 | 1923 | $function_add = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '!' : ''); |
@@ -1906,11 +1967,11 @@ discard block |
||
| 1906 | 1967 | // Show a nice icon to indicate this is an instance. |
| 1907 | 1968 | $instance = (!empty($data['instance']) ? '<span class="generic_icons news" title="' . $txt['hooks_field_function_method'] . '"></span> ' : ''); |
| 1908 | 1969 | |
| 1909 | - if (!empty($data['included_file'])) |
|
| 1910 | - return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
| 1911 | - |
|
| 1912 | - else |
|
| 1913 | - return $instance . $data['real_function']; |
|
| 1970 | + if (!empty($data['included_file'])) { |
|
| 1971 | + return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
| 1972 | + } else { |
|
| 1973 | + return $instance . $data['real_function']; |
|
| 1974 | + } |
|
| 1914 | 1975 | }, |
| 1915 | 1976 | ), |
| 1916 | 1977 | 'sort' => array( |
@@ -1975,11 +2036,12 @@ discard block |
||
| 1975 | 2036 | 'data' => array( |
| 1976 | 2037 | 'function' => function($data) use ($txt, $scripturl, $context) |
| 1977 | 2038 | { |
| 1978 | - if (!$data['hook_exists']) |
|
| 1979 | - return ' |
|
| 2039 | + if (!$data['hook_exists']) { |
|
| 2040 | + return ' |
|
| 1980 | 2041 | <a href="' . $scripturl . '?action=admin;area=maintain;sa=hooks;do=remove;hook=' . $data['hook_name'] . ';function=' . urlencode($data['function_name']) . $context['filter_url'] . ';' . $context['admin-hook_token_var'] . '=' . $context['admin-hook_token'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['quickmod_confirm'] . '" class="you_sure"> |
| 1981 | 2042 | <span class="generic_icons delete" title="' . $txt['hooks_button_remove'] . '"></span> |
| 1982 | 2043 | </a>'; |
| 2044 | + } |
|
| 1983 | 2045 | }, |
| 1984 | 2046 | 'class' => 'centertext', |
| 1985 | 2047 | ), |
@@ -2014,10 +2076,11 @@ discard block |
||
| 2014 | 2076 | { |
| 2015 | 2077 | if ($file != '.' && $file != '..') |
| 2016 | 2078 | { |
| 2017 | - if (is_dir($dir_path . '/' . $file)) |
|
| 2018 | - $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
| 2019 | - else |
|
| 2020 | - $files[] = array('dir' => $dir_path, 'name' => $file); |
|
| 2079 | + if (is_dir($dir_path . '/' . $file)) { |
|
| 2080 | + $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
| 2081 | + } else { |
|
| 2082 | + $files[] = array('dir' => $dir_path, 'name' => $file); |
|
| 2083 | + } |
|
| 2021 | 2084 | } |
| 2022 | 2085 | } |
| 2023 | 2086 | } |
@@ -2066,16 +2129,16 @@ discard block |
||
| 2066 | 2129 | // I need to know if there is at least one function called in this file. |
| 2067 | 2130 | $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
| 2068 | 2131 | unset($temp_hooks[$hook][$rawFunc]); |
| 2069 | - } |
|
| 2070 | - elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
| 2132 | + } elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
| 2071 | 2133 | { |
| 2072 | 2134 | $hook_status[$hook][$hookParsedData['pureFunc']] = $hookParsedData; |
| 2073 | 2135 | $hook_status[$hook][$hookParsedData['pureFunc']]['exists'] = true; |
| 2074 | 2136 | $hook_status[$hook][$hookParsedData['pureFunc']]['in_file'] = (!empty($file['name']) ? $file['name'] : (!empty($hookParsedData['hookFile']) ? $hookParsedData['hookFile'] : '')); |
| 2075 | 2137 | |
| 2076 | 2138 | // Does the hook has its own file? |
| 2077 | - if (!empty($hookParsedData['hookFile'])) |
|
| 2078 | - $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
| 2139 | + if (!empty($hookParsedData['hookFile'])) { |
|
| 2140 | + $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
| 2141 | + } |
|
| 2079 | 2142 | |
| 2080 | 2143 | // I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too) |
| 2081 | 2144 | $temp_data['function'][$file['name']][$hookParsedData['pureFunc']] = $hookParsedData['enabled']; |
@@ -2102,15 +2165,17 @@ discard block |
||
| 2102 | 2165 | $sort = array(); |
| 2103 | 2166 | $hooks_filters = array(); |
| 2104 | 2167 | |
| 2105 | - foreach ($hooks as $hook => $functions) |
|
| 2106 | - $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
| 2168 | + foreach ($hooks as $hook => $functions) { |
|
| 2169 | + $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
| 2170 | + } |
|
| 2107 | 2171 | |
| 2108 | - if (!empty($hooks_filters)) |
|
| 2109 | - $context['insert_after_template'] .= ' |
|
| 2172 | + if (!empty($hooks_filters)) { |
|
| 2173 | + $context['insert_after_template'] .= ' |
|
| 2110 | 2174 | <script> |
| 2111 | 2175 | var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\'); |
| 2112 | 2176 | hook_name_header.innerHTML += ' . JavaScriptEscape('<select style="margin-left:15px;" onchange="window.location=(\'' . $scripturl . '?action=admin;area=maintain;sa=hooks\' + (this.value ? \';filter=\' + this.value : \'\'));"><option value="">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>') . '; |
| 2113 | 2177 | </script>'; |
| 2178 | + } |
|
| 2114 | 2179 | |
| 2115 | 2180 | $temp_data = array(); |
| 2116 | 2181 | $id = 0; |
@@ -2152,10 +2217,11 @@ discard block |
||
| 2152 | 2217 | |
| 2153 | 2218 | foreach ($temp_data as $data) |
| 2154 | 2219 | { |
| 2155 | - if (++$counter < $start) |
|
| 2156 | - continue; |
|
| 2157 | - elseif ($counter == $start + $per_page) |
|
| 2158 | - break; |
|
| 2220 | + if (++$counter < $start) { |
|
| 2221 | + continue; |
|
| 2222 | + } elseif ($counter == $start + $per_page) { |
|
| 2223 | + break; |
|
| 2224 | + } |
|
| 2159 | 2225 | |
| 2160 | 2226 | $hooks_data[] = $data; |
| 2161 | 2227 | } |
@@ -2177,13 +2243,15 @@ discard block |
||
| 2177 | 2243 | $hooks_count = 0; |
| 2178 | 2244 | |
| 2179 | 2245 | $context['filter'] = false; |
| 2180 | - if (isset($_GET['filter'])) |
|
| 2181 | - $context['filter'] = $_GET['filter']; |
|
| 2246 | + if (isset($_GET['filter'])) { |
|
| 2247 | + $context['filter'] = $_GET['filter']; |
|
| 2248 | + } |
|
| 2182 | 2249 | |
| 2183 | 2250 | foreach ($hooks as $hook => $functions) |
| 2184 | 2251 | { |
| 2185 | - if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) |
|
| 2186 | - $hooks_count += count($functions); |
|
| 2252 | + if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) { |
|
| 2253 | + $hooks_count += count($functions); |
|
| 2254 | + } |
|
| 2187 | 2255 | } |
| 2188 | 2256 | |
| 2189 | 2257 | return $hooks_count; |
@@ -2204,8 +2272,9 @@ discard block |
||
| 2204 | 2272 | $integration_hooks = array(); |
| 2205 | 2273 | foreach ($modSettings as $key => $value) |
| 2206 | 2274 | { |
| 2207 | - if (!empty($value) && substr($key, 0, 10) === 'integrate_') |
|
| 2208 | - $integration_hooks[$key] = explode(',', $value); |
|
| 2275 | + if (!empty($value) && substr($key, 0, 10) === 'integrate_') { |
|
| 2276 | + $integration_hooks[$key] = explode(',', $value); |
|
| 2277 | + } |
|
| 2209 | 2278 | } |
| 2210 | 2279 | } |
| 2211 | 2280 | |
@@ -2236,8 +2305,9 @@ discard block |
||
| 2236 | 2305 | ); |
| 2237 | 2306 | |
| 2238 | 2307 | // Meh... |
| 2239 | - if (empty($rawData)) |
|
| 2240 | - return $hookData; |
|
| 2308 | + if (empty($rawData)) { |
|
| 2309 | + return $hookData; |
|
| 2310 | + } |
|
| 2241 | 2311 | |
| 2242 | 2312 | // For convenience purposes only! |
| 2243 | 2313 | $modFunc = $rawData; |
@@ -2248,11 +2318,11 @@ discard block |
||
| 2248 | 2318 | list ($hookData['hookFile'], $modFunc) = explode('|', $modFunc); |
| 2249 | 2319 | |
| 2250 | 2320 | // Does the file exists? who knows! |
| 2251 | - if (empty($settings['theme_dir'])) |
|
| 2252 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 2253 | - |
|
| 2254 | - else |
|
| 2255 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 2321 | + if (empty($settings['theme_dir'])) { |
|
| 2322 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 2323 | + } else { |
|
| 2324 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 2325 | + } |
|
| 2256 | 2326 | |
| 2257 | 2327 | $hookData['fileExists'] = file_exists($hookData['absPath']); |
| 2258 | 2328 | $hookData['hookFile'] = basename($hookData['hookFile']); |
@@ -2277,11 +2347,10 @@ discard block |
||
| 2277 | 2347 | { |
| 2278 | 2348 | list ($hookData['class'], $hookData['method']) = explode('::', $modFunc); |
| 2279 | 2349 | $hookData['pureFunc'] = $hookData['method']; |
| 2350 | + } else { |
|
| 2351 | + $hookData['pureFunc'] = $modFunc; |
|
| 2280 | 2352 | } |
| 2281 | 2353 | |
| 2282 | - else |
|
| 2283 | - $hookData['pureFunc'] = $modFunc; |
|
| 2284 | - |
|
| 2285 | 2354 | return $hookData; |
| 2286 | 2355 | } |
| 2287 | 2356 | |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Ban center. The main entrance point for all ban center functions. |
@@ -120,10 +121,11 @@ discard block |
||
| 120 | 121 | } |
| 121 | 122 | |
| 122 | 123 | // Create a date string so we don't overload them with date info. |
| 123 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 124 | - $context['ban_time_format'] = $user_info['time_format']; |
|
| 125 | - else |
|
| 126 | - $context['ban_time_format'] = $matches[0]; |
|
| 124 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 125 | + $context['ban_time_format'] = $user_info['time_format']; |
|
| 126 | + } else { |
|
| 127 | + $context['ban_time_format'] = $matches[0]; |
|
| 128 | + } |
|
| 127 | 129 | |
| 128 | 130 | $listOptions = array( |
| 129 | 131 | 'id' => 'ban_list', |
@@ -201,16 +203,19 @@ discard block |
||
| 201 | 203 | 'function' => function($rowData) use ($txt) |
| 202 | 204 | { |
| 203 | 205 | // This ban never expires...whahaha. |
| 204 | - if ($rowData['expire_time'] === null) |
|
| 205 | - return $txt['never']; |
|
| 206 | + if ($rowData['expire_time'] === null) { |
|
| 207 | + return $txt['never']; |
|
| 208 | + } |
|
| 206 | 209 | |
| 207 | 210 | // This ban has already expired. |
| 208 | - elseif ($rowData['expire_time'] < time()) |
|
| 209 | - return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
| 211 | + elseif ($rowData['expire_time'] < time()) { |
|
| 212 | + return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
| 213 | + } |
|
| 210 | 214 | |
| 211 | 215 | // Still need to wait a few days for this ban to expire. |
| 212 | - else |
|
| 213 | - return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
| 216 | + else { |
|
| 217 | + return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
| 218 | + } |
|
| 214 | 219 | }, |
| 215 | 220 | ), |
| 216 | 221 | 'sort' => array( |
@@ -309,8 +314,9 @@ discard block |
||
| 309 | 314 | ) |
| 310 | 315 | ); |
| 311 | 316 | $bans = array(); |
| 312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 313 | - $bans[] = $row; |
|
| 317 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 318 | + $bans[] = $row; |
|
| 319 | + } |
|
| 314 | 320 | |
| 315 | 321 | $smcFunc['db_free_result']($request); |
| 316 | 322 | |
@@ -352,8 +358,9 @@ discard block |
||
| 352 | 358 | { |
| 353 | 359 | global $txt, $modSettings, $context, $scripturl, $smcFunc, $sourcedir; |
| 354 | 360 | |
| 355 | - if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) |
|
| 356 | - BanEdit2(); |
|
| 361 | + if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) { |
|
| 362 | + BanEdit2(); |
|
| 363 | + } |
|
| 357 | 364 | |
| 358 | 365 | $ban_group_id = isset($context['ban']['id']) ? $context['ban']['id'] : (isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0); |
| 359 | 366 | |
@@ -364,10 +371,10 @@ discard block |
||
| 364 | 371 | |
| 365 | 372 | if (!empty($context['ban_errors'])) |
| 366 | 373 | { |
| 367 | - foreach ($context['ban_errors'] as $error) |
|
| 368 | - $context['error_messages'][$error] = $txt[$error]; |
|
| 369 | - } |
|
| 370 | - else |
|
| 374 | + foreach ($context['ban_errors'] as $error) { |
|
| 375 | + $context['error_messages'][$error] = $txt[$error]; |
|
| 376 | + } |
|
| 377 | + } else |
|
| 371 | 378 | { |
| 372 | 379 | // If we're editing an existing ban, get it from the database. |
| 373 | 380 | if (!empty($ban_group_id)) |
@@ -403,12 +410,13 @@ discard block |
||
| 403 | 410 | 'data' => array( |
| 404 | 411 | 'function' => function($ban_item) use ($txt) |
| 405 | 412 | { |
| 406 | - if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) |
|
| 407 | - return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
| 408 | - elseif ($ban_item['type'] == 'user') |
|
| 409 | - return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
| 410 | - else |
|
| 411 | - return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
| 413 | + if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) { |
|
| 414 | + return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
| 415 | + } elseif ($ban_item['type'] == 'user') { |
|
| 416 | + return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
| 417 | + } else { |
|
| 418 | + return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
| 419 | + } |
|
| 412 | 420 | }, |
| 413 | 421 | 'style' => 'text-align: left;', |
| 414 | 422 | ), |
@@ -546,8 +554,9 @@ discard block |
||
| 546 | 554 | $context['ban']['from_user'] = true; |
| 547 | 555 | |
| 548 | 556 | // Would be nice if we could also ban the hostname. |
| 549 | - if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) |
|
| 550 | - $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
| 557 | + if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) { |
|
| 558 | + $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
| 559 | + } |
|
| 551 | 560 | |
| 552 | 561 | $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
| 553 | 562 | } |
@@ -615,8 +624,9 @@ discard block |
||
| 615 | 624 | 'items_per_page' => $items_per_page, |
| 616 | 625 | ) |
| 617 | 626 | ); |
| 618 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 619 | - fatal_lang_error('ban_not_found', false); |
|
| 627 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 628 | + fatal_lang_error('ban_not_found', false); |
|
| 629 | + } |
|
| 620 | 630 | |
| 621 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 622 | 632 | { |
@@ -653,18 +663,15 @@ discard block |
||
| 653 | 663 | { |
| 654 | 664 | $ban_items[$row['id_ban']]['type'] = 'ip'; |
| 655 | 665 | $ban_items[$row['id_ban']]['ip'] = range2ip($row['ip_low'], $row['ip_high']); |
| 656 | - } |
|
| 657 | - elseif (!empty($row['hostname'])) |
|
| 666 | + } elseif (!empty($row['hostname'])) |
|
| 658 | 667 | { |
| 659 | 668 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
| 660 | 669 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
| 661 | - } |
|
| 662 | - elseif (!empty($row['email_address'])) |
|
| 670 | + } elseif (!empty($row['email_address'])) |
|
| 663 | 671 | { |
| 664 | 672 | $ban_items[$row['id_ban']]['type'] = 'email'; |
| 665 | 673 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
| 666 | - } |
|
| 667 | - elseif (!empty($row['id_member'])) |
|
| 674 | + } elseif (!empty($row['id_member'])) |
|
| 668 | 675 | { |
| 669 | 676 | $ban_items[$row['id_ban']]['type'] = 'user'; |
| 670 | 677 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -730,9 +737,10 @@ discard block |
||
| 730 | 737 | $search_list += array('ips_in_messages' => 'banLoadAdditionalIPsMember', 'ips_in_errors' => 'banLoadAdditionalIPsError'); |
| 731 | 738 | |
| 732 | 739 | $return = array(); |
| 733 | - foreach ($search_list as $key => $callable) |
|
| 734 | - if (is_callable($callable)) |
|
| 740 | + foreach ($search_list as $key => $callable) { |
|
| 741 | + if (is_callable($callable)) |
|
| 735 | 742 | $return[$key] = call_user_func($callable, $member_id); |
| 743 | + } |
|
| 736 | 744 | |
| 737 | 745 | return $return; |
| 738 | 746 | } |
@@ -757,8 +765,9 @@ discard block |
||
| 757 | 765 | 'current_user' => $member_id, |
| 758 | 766 | ) |
| 759 | 767 | ); |
| 760 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 761 | - $message_ips[] = inet_dtop($row['poster_ip']); |
|
| 768 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 769 | + $message_ips[] = inet_dtop($row['poster_ip']); |
|
| 770 | + } |
|
| 762 | 771 | $smcFunc['db_free_result']($request); |
| 763 | 772 | |
| 764 | 773 | return $message_ips; |
@@ -783,8 +792,9 @@ discard block |
||
| 783 | 792 | 'current_user' => $member_id, |
| 784 | 793 | ) |
| 785 | 794 | ); |
| 786 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 787 | - $error_ips[] = inet_dtop($row['ip']); |
|
| 795 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 796 | + $error_ips[] = inet_dtop($row['ip']); |
|
| 797 | + } |
|
| 788 | 798 | $smcFunc['db_free_result']($request); |
| 789 | 799 | |
| 790 | 800 | return $error_ips; |
@@ -825,11 +835,13 @@ discard block |
||
| 825 | 835 | $ban_info['cannot']['login'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_login']) ? 0 : 1; |
| 826 | 836 | |
| 827 | 837 | // Adding a new ban group |
| 828 | - if (empty($_REQUEST['bg'])) |
|
| 829 | - $ban_group_id = insertBanGroup($ban_info); |
|
| 838 | + if (empty($_REQUEST['bg'])) { |
|
| 839 | + $ban_group_id = insertBanGroup($ban_info); |
|
| 840 | + } |
|
| 830 | 841 | // Editing an existing ban group |
| 831 | - else |
|
| 832 | - $ban_group_id = updateBanGroup($ban_info); |
|
| 842 | + else { |
|
| 843 | + $ban_group_id = updateBanGroup($ban_info); |
|
| 844 | + } |
|
| 833 | 845 | |
| 834 | 846 | if (is_numeric($ban_group_id)) |
| 835 | 847 | { |
@@ -840,9 +852,10 @@ discard block |
||
| 840 | 852 | $context['ban'] = $ban_info; |
| 841 | 853 | } |
| 842 | 854 | |
| 843 | - if (isset($_POST['ban_suggestions'])) |
|
| 844 | - // @TODO: is $_REQUEST['bi'] ever set? |
|
| 855 | + if (isset($_POST['ban_suggestions'])) { |
|
| 856 | + // @TODO: is $_REQUEST['bi'] ever set? |
|
| 845 | 857 | $saved_triggers = saveTriggers($_POST['ban_suggestions'], $ban_info['id'], isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : 0, isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0); |
| 858 | + } |
|
| 846 | 859 | |
| 847 | 860 | // Something went wrong somewhere... Oh well, let's go back. |
| 848 | 861 | if (!empty($context['ban_errors'])) |
@@ -852,8 +865,9 @@ discard block |
||
| 852 | 865 | $context['ban_suggestions'] = array_merge($context['ban_suggestions'], getMemberData((int) $_REQUEST['u'])); |
| 853 | 866 | |
| 854 | 867 | // Not strictly necessary, but it's nice |
| 855 | - if (!empty($context['ban_suggestions']['member']['id'])) |
|
| 856 | - $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
| 868 | + if (!empty($context['ban_suggestions']['member']['id'])) { |
|
| 869 | + $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
| 870 | + } |
|
| 857 | 871 | return BanEdit(); |
| 858 | 872 | } |
| 859 | 873 | $context['ban_suggestions']['saved_triggers'] = !empty($saved_triggers) ? $saved_triggers : array(); |
@@ -900,10 +914,11 @@ discard block |
||
| 900 | 914 | |
| 901 | 915 | foreach ($suggestions as $key => $value) |
| 902 | 916 | { |
| 903 | - if (is_array($value)) |
|
| 904 | - $triggers[$key] = $value; |
|
| 905 | - else |
|
| 906 | - $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
| 917 | + if (is_array($value)) { |
|
| 918 | + $triggers[$key] = $value; |
|
| 919 | + } else { |
|
| 920 | + $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
| 921 | + } |
|
| 907 | 922 | } |
| 908 | 923 | |
| 909 | 924 | $ban_triggers = validateTriggers($triggers); |
@@ -911,16 +926,18 @@ discard block |
||
| 911 | 926 | // Time to save! |
| 912 | 927 | if (!empty($ban_triggers['ban_triggers']) && empty($context['ban_errors'])) |
| 913 | 928 | { |
| 914 | - if (empty($ban_id)) |
|
| 915 | - addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
| 916 | - else |
|
| 917 | - updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
| 929 | + if (empty($ban_id)) { |
|
| 930 | + addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
| 931 | + } else { |
|
| 932 | + updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
| 933 | + } |
|
| 934 | + } |
|
| 935 | + if (!empty($context['ban_errors'])) { |
|
| 936 | + return $triggers; |
|
| 937 | + } else { |
|
| 938 | + return false; |
|
| 939 | + } |
|
| 918 | 940 | } |
| 919 | - if (!empty($context['ban_errors'])) |
|
| 920 | - return $triggers; |
|
| 921 | - else |
|
| 922 | - return false; |
|
| 923 | -} |
|
| 924 | 941 | |
| 925 | 942 | /** |
| 926 | 943 | * This function removes a bunch of triggers based on ids |
@@ -934,14 +951,17 @@ discard block |
||
| 934 | 951 | { |
| 935 | 952 | global $smcFunc, $scripturl; |
| 936 | 953 | |
| 937 | - if ($group_id !== false) |
|
| 938 | - $group_id = (int) $group_id; |
|
| 954 | + if ($group_id !== false) { |
|
| 955 | + $group_id = (int) $group_id; |
|
| 956 | + } |
|
| 939 | 957 | |
| 940 | - if (empty($group_id) && empty($items_ids)) |
|
| 941 | - return false; |
|
| 958 | + if (empty($group_id) && empty($items_ids)) { |
|
| 959 | + return false; |
|
| 960 | + } |
|
| 942 | 961 | |
| 943 | - if (!is_array($items_ids)) |
|
| 944 | - $items_ids = array($items_ids); |
|
| 962 | + if (!is_array($items_ids)) { |
|
| 963 | + $items_ids = array($items_ids); |
|
| 964 | + } |
|
| 945 | 965 | |
| 946 | 966 | $log_info = array(); |
| 947 | 967 | $ban_items = array(); |
@@ -979,8 +999,7 @@ discard block |
||
| 979 | 999 | 'bantype' => ($is_range ? 'ip_range' : 'main_ip'), |
| 980 | 1000 | 'value' => $ban_items[$row['id_ban']]['ip'], |
| 981 | 1001 | ); |
| 982 | - } |
|
| 983 | - elseif (!empty($row['hostname'])) |
|
| 1002 | + } elseif (!empty($row['hostname'])) |
|
| 984 | 1003 | { |
| 985 | 1004 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
| 986 | 1005 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
@@ -988,8 +1007,7 @@ discard block |
||
| 988 | 1007 | 'bantype' => 'hostname', |
| 989 | 1008 | 'value' => $row['hostname'], |
| 990 | 1009 | ); |
| 991 | - } |
|
| 992 | - elseif (!empty($row['email_address'])) |
|
| 1010 | + } elseif (!empty($row['email_address'])) |
|
| 993 | 1011 | { |
| 994 | 1012 | $ban_items[$row['id_ban']]['type'] = 'email'; |
| 995 | 1013 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
@@ -997,8 +1015,7 @@ discard block |
||
| 997 | 1015 | 'bantype' => 'email', |
| 998 | 1016 | 'value' => $ban_items[$row['id_ban']]['email'], |
| 999 | 1017 | ); |
| 1000 | - } |
|
| 1001 | - elseif (!empty($row['id_member'])) |
|
| 1018 | + } elseif (!empty($row['id_member'])) |
|
| 1002 | 1019 | { |
| 1003 | 1020 | $ban_items[$row['id_ban']]['type'] = 'user'; |
| 1004 | 1021 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -1031,8 +1048,7 @@ discard block |
||
| 1031 | 1048 | 'ban_group' => $group_id, |
| 1032 | 1049 | ) |
| 1033 | 1050 | ); |
| 1034 | - } |
|
| 1035 | - elseif (!empty($items_ids)) |
|
| 1051 | + } elseif (!empty($items_ids)) |
|
| 1036 | 1052 | { |
| 1037 | 1053 | $smcFunc['db_query']('', ' |
| 1038 | 1054 | DELETE FROM {db_prefix}ban_items |
@@ -1057,13 +1073,15 @@ discard block |
||
| 1057 | 1073 | { |
| 1058 | 1074 | global $smcFunc; |
| 1059 | 1075 | |
| 1060 | - if (!is_array($group_ids)) |
|
| 1061 | - $group_ids = array($group_ids); |
|
| 1076 | + if (!is_array($group_ids)) { |
|
| 1077 | + $group_ids = array($group_ids); |
|
| 1078 | + } |
|
| 1062 | 1079 | |
| 1063 | 1080 | $group_ids = array_unique($group_ids); |
| 1064 | 1081 | |
| 1065 | - if (empty($group_ids)) |
|
| 1066 | - return false; |
|
| 1082 | + if (empty($group_ids)) { |
|
| 1083 | + return false; |
|
| 1084 | + } |
|
| 1067 | 1085 | |
| 1068 | 1086 | $smcFunc['db_query']('', ' |
| 1069 | 1087 | DELETE FROM {db_prefix}ban_groups |
@@ -1087,21 +1105,23 @@ discard block |
||
| 1087 | 1105 | { |
| 1088 | 1106 | global $smcFunc; |
| 1089 | 1107 | |
| 1090 | - if (empty($ids)) |
|
| 1091 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1108 | + if (empty($ids)) { |
|
| 1109 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1092 | 1110 | TRUNCATE {db_prefix}log_banned', |
| 1093 | 1111 | array( |
| 1094 | 1112 | ) |
| 1095 | 1113 | ); |
| 1096 | - else |
|
| 1114 | + } else |
|
| 1097 | 1115 | { |
| 1098 | - if (!is_array($ids)) |
|
| 1099 | - $ids = array($ids); |
|
| 1116 | + if (!is_array($ids)) { |
|
| 1117 | + $ids = array($ids); |
|
| 1118 | + } |
|
| 1100 | 1119 | |
| 1101 | 1120 | $ids = array_unique($ids); |
| 1102 | 1121 | |
| 1103 | - if (empty($ids)) |
|
| 1104 | - return false; |
|
| 1122 | + if (empty($ids)) { |
|
| 1123 | + return false; |
|
| 1124 | + } |
|
| 1105 | 1125 | |
| 1106 | 1126 | $smcFunc['db_query']('', ' |
| 1107 | 1127 | DELETE FROM {db_prefix}log_banned |
@@ -1127,8 +1147,9 @@ discard block |
||
| 1127 | 1147 | { |
| 1128 | 1148 | global $context, $smcFunc; |
| 1129 | 1149 | |
| 1130 | - if (empty($triggers)) |
|
| 1131 | - $context['ban_erros'][] = 'ban_empty_triggers'; |
|
| 1150 | + if (empty($triggers)) { |
|
| 1151 | + $context['ban_erros'][] = 'ban_empty_triggers'; |
|
| 1152 | + } |
|
| 1132 | 1153 | |
| 1133 | 1154 | $ban_triggers = array(); |
| 1134 | 1155 | $log_info = array(); |
@@ -1137,39 +1158,39 @@ discard block |
||
| 1137 | 1158 | { |
| 1138 | 1159 | if (!empty($value)) |
| 1139 | 1160 | { |
| 1140 | - if ($key == 'member') |
|
| 1141 | - continue; |
|
| 1161 | + if ($key == 'member') { |
|
| 1162 | + continue; |
|
| 1163 | + } |
|
| 1142 | 1164 | |
| 1143 | 1165 | if ($key == 'main_ip') |
| 1144 | 1166 | { |
| 1145 | 1167 | $value = trim($value); |
| 1146 | 1168 | $ip_parts = ip2range($value); |
| 1147 | - if (!checkExistingTriggerIP($ip_parts, $value)) |
|
| 1148 | - $context['ban_erros'][] = 'invalid_ip'; |
|
| 1149 | - else |
|
| 1169 | + if (!checkExistingTriggerIP($ip_parts, $value)) { |
|
| 1170 | + $context['ban_erros'][] = 'invalid_ip'; |
|
| 1171 | + } else |
|
| 1150 | 1172 | { |
| 1151 | 1173 | $ban_triggers['main_ip'] = array( |
| 1152 | 1174 | 'ip_low' => $ip_parts['low'], |
| 1153 | 1175 | 'ip_high' => $ip_parts['high'] |
| 1154 | 1176 | ); |
| 1155 | 1177 | } |
| 1156 | - } |
|
| 1157 | - elseif ($key == 'hostname') |
|
| 1178 | + } elseif ($key == 'hostname') |
|
| 1158 | 1179 | { |
| 1159 | - if (preg_match('/[^\w.\-*]/', $value) == 1) |
|
| 1160 | - $context['ban_erros'][] = 'invalid_hostname'; |
|
| 1161 | - else |
|
| 1180 | + if (preg_match('/[^\w.\-*]/', $value) == 1) { |
|
| 1181 | + $context['ban_erros'][] = 'invalid_hostname'; |
|
| 1182 | + } else |
|
| 1162 | 1183 | { |
| 1163 | 1184 | // Replace the * wildcard by a MySQL wildcard %. |
| 1164 | 1185 | $value = substr(str_replace('*', '%', $value), 0, 255); |
| 1165 | 1186 | |
| 1166 | 1187 | $ban_triggers['hostname']['hostname'] = $value; |
| 1167 | 1188 | } |
| 1168 | - } |
|
| 1169 | - elseif ($key == 'email') |
|
| 1189 | + } elseif ($key == 'email') |
|
| 1170 | 1190 | { |
| 1171 | - if (preg_match('/[^\w.\-\+*@]/', $value) == 1) |
|
| 1172 | - $context['ban_erros'][] = 'invalid_email'; |
|
| 1191 | + if (preg_match('/[^\w.\-\+*@]/', $value) == 1) { |
|
| 1192 | + $context['ban_erros'][] = 'invalid_email'; |
|
| 1193 | + } |
|
| 1173 | 1194 | |
| 1174 | 1195 | // Check the user is not banning an admin. |
| 1175 | 1196 | $request = $smcFunc['db_query']('', ' |
@@ -1183,15 +1204,15 @@ discard block |
||
| 1183 | 1204 | 'email' => $value, |
| 1184 | 1205 | ) |
| 1185 | 1206 | ); |
| 1186 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1187 | - $context['ban_erros'][] = 'no_ban_admin'; |
|
| 1207 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1208 | + $context['ban_erros'][] = 'no_ban_admin'; |
|
| 1209 | + } |
|
| 1188 | 1210 | $smcFunc['db_free_result']($request); |
| 1189 | 1211 | |
| 1190 | 1212 | $value = substr(strtolower(str_replace('*', '%', $value)), 0, 255); |
| 1191 | 1213 | |
| 1192 | 1214 | $ban_triggers['email']['email_address'] = $value; |
| 1193 | - } |
|
| 1194 | - elseif ($key == 'user') |
|
| 1215 | + } elseif ($key == 'user') |
|
| 1195 | 1216 | { |
| 1196 | 1217 | $user = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $smcFunc['htmlspecialchars']($value, ENT_QUOTES)); |
| 1197 | 1218 | |
@@ -1205,8 +1226,9 @@ discard block |
||
| 1205 | 1226 | 'username' => $user, |
| 1206 | 1227 | ) |
| 1207 | 1228 | ); |
| 1208 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1209 | - $context['ban_erros'][] = 'invalid_username'; |
|
| 1229 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1230 | + $context['ban_erros'][] = 'invalid_username'; |
|
| 1231 | + } |
|
| 1210 | 1232 | list ($value, $isAdmin) = $smcFunc['db_fetch_row']($request); |
| 1211 | 1233 | $smcFunc['db_free_result']($request); |
| 1212 | 1234 | |
@@ -1214,25 +1236,25 @@ discard block |
||
| 1214 | 1236 | { |
| 1215 | 1237 | unset($value); |
| 1216 | 1238 | $context['ban_erros'][] = 'no_ban_admin'; |
| 1239 | + } else { |
|
| 1240 | + $ban_triggers['user']['id_member'] = $value; |
|
| 1217 | 1241 | } |
| 1218 | - else |
|
| 1219 | - $ban_triggers['user']['id_member'] = $value; |
|
| 1220 | - } |
|
| 1221 | - elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
| 1242 | + } elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
| 1222 | 1243 | { |
| 1223 | 1244 | // Special case, those two are arrays themselves |
| 1224 | 1245 | $values = array_unique($value); |
| 1225 | 1246 | // Don't add the main IP again. |
| 1226 | - if (isset($triggers['main_ip'])) |
|
| 1227 | - $values = array_diff($values, array($triggers['main_ip'])); |
|
| 1247 | + if (isset($triggers['main_ip'])) { |
|
| 1248 | + $values = array_diff($values, array($triggers['main_ip'])); |
|
| 1249 | + } |
|
| 1228 | 1250 | unset($value); |
| 1229 | 1251 | foreach ($values as $val) |
| 1230 | 1252 | { |
| 1231 | 1253 | $val = trim($val); |
| 1232 | 1254 | $ip_parts = ip2range($val); |
| 1233 | - if (!checkExistingTriggerIP($ip_parts, $val)) |
|
| 1234 | - $context['ban_erros'][] = 'invalid_ip'; |
|
| 1235 | - else |
|
| 1255 | + if (!checkExistingTriggerIP($ip_parts, $val)) { |
|
| 1256 | + $context['ban_erros'][] = 'invalid_ip'; |
|
| 1257 | + } else |
|
| 1236 | 1258 | { |
| 1237 | 1259 | $ban_triggers[$key][] = array( |
| 1238 | 1260 | 'ip_low' => $ip_parts['low'], |
@@ -1245,15 +1267,16 @@ discard block |
||
| 1245 | 1267 | ); |
| 1246 | 1268 | } |
| 1247 | 1269 | } |
| 1270 | + } else { |
|
| 1271 | + $context['ban_erros'][] = 'no_bantype_selected'; |
|
| 1248 | 1272 | } |
| 1249 | - else |
|
| 1250 | - $context['ban_erros'][] = 'no_bantype_selected'; |
|
| 1251 | 1273 | |
| 1252 | - if (isset($value) && !is_array($value)) |
|
| 1253 | - $log_info[] = array( |
|
| 1274 | + if (isset($value) && !is_array($value)) { |
|
| 1275 | + $log_info[] = array( |
|
| 1254 | 1276 | 'value' => $value, |
| 1255 | 1277 | 'bantype' => $key, |
| 1256 | 1278 | ); |
| 1279 | + } |
|
| 1257 | 1280 | } |
| 1258 | 1281 | } |
| 1259 | 1282 | return array('ban_triggers' => $ban_triggers, 'log_info' => $log_info); |
@@ -1273,8 +1296,9 @@ discard block |
||
| 1273 | 1296 | { |
| 1274 | 1297 | global $smcFunc, $context; |
| 1275 | 1298 | |
| 1276 | - if (empty($group_id)) |
|
| 1277 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1299 | + if (empty($group_id)) { |
|
| 1300 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1301 | + } |
|
| 1278 | 1302 | |
| 1279 | 1303 | // Preset all values that are required. |
| 1280 | 1304 | $values = array( |
@@ -1299,18 +1323,21 @@ discard block |
||
| 1299 | 1323 | foreach ($triggers as $key => $trigger) |
| 1300 | 1324 | { |
| 1301 | 1325 | // Exceptions, exceptions, exceptions...always exceptions... :P |
| 1302 | - if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
| 1303 | - foreach ($trigger as $real_trigger) |
|
| 1326 | + if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) { |
|
| 1327 | + foreach ($trigger as $real_trigger) |
|
| 1304 | 1328 | $insertTriggers[] = array_merge($values, $real_trigger); |
| 1305 | - else |
|
| 1306 | - $insertTriggers[] = array_merge($values, $trigger); |
|
| 1329 | + } else { |
|
| 1330 | + $insertTriggers[] = array_merge($values, $trigger); |
|
| 1331 | + } |
|
| 1307 | 1332 | } |
| 1308 | 1333 | |
| 1309 | - if (empty($insertTriggers)) |
|
| 1310 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1334 | + if (empty($insertTriggers)) { |
|
| 1335 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1336 | + } |
|
| 1311 | 1337 | |
| 1312 | - if (!empty($context['ban_errors'])) |
|
| 1313 | - return false; |
|
| 1338 | + if (!empty($context['ban_errors'])) { |
|
| 1339 | + return false; |
|
| 1340 | + } |
|
| 1314 | 1341 | |
| 1315 | 1342 | $smcFunc['db_insert']('', |
| 1316 | 1343 | '{db_prefix}ban_items', |
@@ -1338,15 +1365,19 @@ discard block |
||
| 1338 | 1365 | { |
| 1339 | 1366 | global $smcFunc, $context; |
| 1340 | 1367 | |
| 1341 | - if (empty($ban_item)) |
|
| 1342 | - $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
| 1343 | - if (empty($group_id)) |
|
| 1344 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1345 | - if (empty($trigger)) |
|
| 1346 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1368 | + if (empty($ban_item)) { |
|
| 1369 | + $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
| 1370 | + } |
|
| 1371 | + if (empty($group_id)) { |
|
| 1372 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1373 | + } |
|
| 1374 | + if (empty($trigger)) { |
|
| 1375 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1376 | + } |
|
| 1347 | 1377 | |
| 1348 | - if (!empty($context['ban_errors'])) |
|
| 1349 | - return; |
|
| 1378 | + if (!empty($context['ban_errors'])) { |
|
| 1379 | + return; |
|
| 1380 | + } |
|
| 1350 | 1381 | |
| 1351 | 1382 | // Preset all values that are required. |
| 1352 | 1383 | $values = array( |
@@ -1387,8 +1418,9 @@ discard block |
||
| 1387 | 1418 | */ |
| 1388 | 1419 | function logTriggersUpdates($logs, $new = true, $removal = false) |
| 1389 | 1420 | { |
| 1390 | - if (empty($logs)) |
|
| 1391 | - return; |
|
| 1421 | + if (empty($logs)) { |
|
| 1422 | + return; |
|
| 1423 | + } |
|
| 1392 | 1424 | |
| 1393 | 1425 | $log_name_map = array( |
| 1394 | 1426 | 'main_ip' => 'ip_range', |
@@ -1399,14 +1431,15 @@ discard block |
||
| 1399 | 1431 | ); |
| 1400 | 1432 | |
| 1401 | 1433 | // Log the addion of the ban entries into the moderation log. |
| 1402 | - foreach ($logs as $log) |
|
| 1403 | - logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
| 1434 | + foreach ($logs as $log) { |
|
| 1435 | + logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
| 1404 | 1436 | $log_name_map[$log['bantype']] => $log['value'], |
| 1405 | 1437 | 'new' => empty($new) ? 0 : 1, |
| 1406 | 1438 | 'remove' => empty($removal) ? 0 : 1, |
| 1407 | 1439 | 'type' => $log['bantype'], |
| 1408 | 1440 | )); |
| 1409 | -} |
|
| 1441 | + } |
|
| 1442 | + } |
|
| 1410 | 1443 | |
| 1411 | 1444 | /** |
| 1412 | 1445 | * Updates an existing ban group |
@@ -1420,12 +1453,15 @@ discard block |
||
| 1420 | 1453 | { |
| 1421 | 1454 | global $smcFunc, $context; |
| 1422 | 1455 | |
| 1423 | - if (empty($ban_info['name'])) |
|
| 1424 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1425 | - if (empty($ban_info['id'])) |
|
| 1426 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1427 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
| 1428 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1456 | + if (empty($ban_info['name'])) { |
|
| 1457 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1458 | + } |
|
| 1459 | + if (empty($ban_info['id'])) { |
|
| 1460 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1461 | + } |
|
| 1462 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
| 1463 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1464 | + } |
|
| 1429 | 1465 | |
| 1430 | 1466 | if (!empty($ban_info['id'])) |
| 1431 | 1467 | { |
@@ -1440,8 +1476,9 @@ discard block |
||
| 1440 | 1476 | ) |
| 1441 | 1477 | ); |
| 1442 | 1478 | |
| 1443 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1444 | - $context['ban_errors'][] = 'ban_not_found'; |
|
| 1479 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1480 | + $context['ban_errors'][] = 'ban_not_found'; |
|
| 1481 | + } |
|
| 1445 | 1482 | $smcFunc['db_free_result']($request); |
| 1446 | 1483 | } |
| 1447 | 1484 | |
@@ -1459,13 +1496,15 @@ discard block |
||
| 1459 | 1496 | 'new_ban_name' => $ban_info['name'], |
| 1460 | 1497 | ) |
| 1461 | 1498 | ); |
| 1462 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1463 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1499 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1500 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1501 | + } |
|
| 1464 | 1502 | $smcFunc['db_free_result']($request); |
| 1465 | 1503 | } |
| 1466 | 1504 | |
| 1467 | - if (!empty($context['ban_errors'])) |
|
| 1468 | - return $ban_info['id']; |
|
| 1505 | + if (!empty($context['ban_errors'])) { |
|
| 1506 | + return $ban_info['id']; |
|
| 1507 | + } |
|
| 1469 | 1508 | |
| 1470 | 1509 | $smcFunc['db_query']('', ' |
| 1471 | 1510 | UPDATE {db_prefix}ban_groups |
@@ -1509,10 +1548,12 @@ discard block |
||
| 1509 | 1548 | { |
| 1510 | 1549 | global $smcFunc, $context; |
| 1511 | 1550 | |
| 1512 | - if (empty($ban_info['name'])) |
|
| 1513 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1514 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
| 1515 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1551 | + if (empty($ban_info['name'])) { |
|
| 1552 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1553 | + } |
|
| 1554 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
| 1555 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1556 | + } |
|
| 1516 | 1557 | |
| 1517 | 1558 | if (!empty($ban_info['name'])) |
| 1518 | 1559 | { |
@@ -1527,13 +1568,15 @@ discard block |
||
| 1527 | 1568 | ) |
| 1528 | 1569 | ); |
| 1529 | 1570 | |
| 1530 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 1531 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1571 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 1572 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1573 | + } |
|
| 1532 | 1574 | $smcFunc['db_free_result']($request); |
| 1533 | 1575 | } |
| 1534 | 1576 | |
| 1535 | - if (!empty($context['ban_errors'])) |
|
| 1536 | - return; |
|
| 1577 | + if (!empty($context['ban_errors'])) { |
|
| 1578 | + return; |
|
| 1579 | + } |
|
| 1537 | 1580 | |
| 1538 | 1581 | // Yes yes, we're ready to add now. |
| 1539 | 1582 | $ban_info['id'] = $smcFunc['db_insert']('', |
@@ -1550,8 +1593,9 @@ discard block |
||
| 1550 | 1593 | 1 |
| 1551 | 1594 | ); |
| 1552 | 1595 | |
| 1553 | - if (empty($ban_info['id'])) |
|
| 1554 | - $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
| 1596 | + if (empty($ban_info['id'])) { |
|
| 1597 | + $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
| 1598 | + } |
|
| 1555 | 1599 | |
| 1556 | 1600 | return $ban_info['id']; |
| 1557 | 1601 | } |
@@ -1576,24 +1620,24 @@ discard block |
||
| 1576 | 1620 | $ban_group = isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0; |
| 1577 | 1621 | $ban_id = isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0; |
| 1578 | 1622 | |
| 1579 | - if (empty($ban_group)) |
|
| 1580 | - fatal_lang_error('ban_not_found', false); |
|
| 1623 | + if (empty($ban_group)) { |
|
| 1624 | + fatal_lang_error('ban_not_found', false); |
|
| 1625 | + } |
|
| 1581 | 1626 | |
| 1582 | 1627 | if (isset($_POST['add_new_trigger']) && !empty($_POST['ban_suggestions'])) |
| 1583 | 1628 | { |
| 1584 | 1629 | saveTriggers($_POST['ban_suggestions'], $ban_group, 0, $ban_id); |
| 1585 | 1630 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
| 1586 | - } |
|
| 1587 | - elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
| 1631 | + } elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
| 1588 | 1632 | { |
| 1589 | 1633 | // The first replaces the old one, the others are added new (simplification, otherwise it would require another query and some work...) |
| 1590 | 1634 | saveTriggers(array_shift($_POST['ban_suggestions']), $ban_group, 0, $ban_id); |
| 1591 | - if (!empty($_POST['ban_suggestions'])) |
|
| 1592 | - saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
| 1635 | + if (!empty($_POST['ban_suggestions'])) { |
|
| 1636 | + saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
| 1637 | + } |
|
| 1593 | 1638 | |
| 1594 | 1639 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
| 1595 | - } |
|
| 1596 | - elseif (isset($_POST['edit_trigger'])) |
|
| 1640 | + } elseif (isset($_POST['edit_trigger'])) |
|
| 1597 | 1641 | { |
| 1598 | 1642 | removeBanTriggers($ban_id); |
| 1599 | 1643 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
@@ -1624,8 +1668,7 @@ discard block |
||
| 1624 | 1668 | ), |
| 1625 | 1669 | 'is_new' => true, |
| 1626 | 1670 | ); |
| 1627 | - } |
|
| 1628 | - else |
|
| 1671 | + } else |
|
| 1629 | 1672 | { |
| 1630 | 1673 | $request = $smcFunc['db_query']('', ' |
| 1631 | 1674 | SELECT |
@@ -1642,8 +1685,9 @@ discard block |
||
| 1642 | 1685 | 'ban_group' => $ban_group, |
| 1643 | 1686 | ) |
| 1644 | 1687 | ); |
| 1645 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1646 | - fatal_lang_error('ban_not_found', false); |
|
| 1688 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1689 | + fatal_lang_error('ban_not_found', false); |
|
| 1690 | + } |
|
| 1647 | 1691 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1648 | 1692 | $smcFunc['db_free_result']($request); |
| 1649 | 1693 | |
@@ -1692,8 +1736,9 @@ discard block |
||
| 1692 | 1736 | removeBanTriggers($_POST['remove']); |
| 1693 | 1737 | |
| 1694 | 1738 | // Rehabilitate some members. |
| 1695 | - if ($_REQUEST['entity'] == 'member') |
|
| 1696 | - updateBanMembers(); |
|
| 1739 | + if ($_REQUEST['entity'] == 'member') { |
|
| 1740 | + updateBanMembers(); |
|
| 1741 | + } |
|
| 1697 | 1742 | |
| 1698 | 1743 | // Make sure the ban cache is refreshed. |
| 1699 | 1744 | updateSettings(array('banLastUpdated' => time())); |
@@ -1806,8 +1851,7 @@ discard block |
||
| 1806 | 1851 | 'default' => 'bi.ip_low, bi.ip_high, bi.ip_low', |
| 1807 | 1852 | 'reverse' => 'bi.ip_low DESC, bi.ip_high DESC', |
| 1808 | 1853 | ); |
| 1809 | - } |
|
| 1810 | - elseif ($context['selected_entity'] === 'hostname') |
|
| 1854 | + } elseif ($context['selected_entity'] === 'hostname') |
|
| 1811 | 1855 | { |
| 1812 | 1856 | $listOptions['columns']['banned_entity']['data'] = array( |
| 1813 | 1857 | 'function' => function($rowData) use ($smcFunc) |
@@ -1819,8 +1863,7 @@ discard block |
||
| 1819 | 1863 | 'default' => 'bi.hostname', |
| 1820 | 1864 | 'reverse' => 'bi.hostname DESC', |
| 1821 | 1865 | ); |
| 1822 | - } |
|
| 1823 | - elseif ($context['selected_entity'] === 'email') |
|
| 1866 | + } elseif ($context['selected_entity'] === 'email') |
|
| 1824 | 1867 | { |
| 1825 | 1868 | $listOptions['columns']['banned_entity']['data'] = array( |
| 1826 | 1869 | 'function' => function($rowData) use ($smcFunc) |
@@ -1832,8 +1875,7 @@ discard block |
||
| 1832 | 1875 | 'default' => 'bi.email_address', |
| 1833 | 1876 | 'reverse' => 'bi.email_address DESC', |
| 1834 | 1877 | ); |
| 1835 | - } |
|
| 1836 | - elseif ($context['selected_entity'] === 'member') |
|
| 1878 | + } elseif ($context['selected_entity'] === 'member') |
|
| 1837 | 1879 | { |
| 1838 | 1880 | $listOptions['columns']['banned_entity']['data'] = array( |
| 1839 | 1881 | 'sprintf' => array( |
@@ -1897,8 +1939,9 @@ discard block |
||
| 1897 | 1939 | ) |
| 1898 | 1940 | ); |
| 1899 | 1941 | $ban_triggers = array(); |
| 1900 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1901 | - $ban_triggers[] = $row; |
|
| 1942 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1943 | + $ban_triggers[] = $row; |
|
| 1944 | + } |
|
| 1902 | 1945 | $smcFunc['db_free_result']($request); |
| 1903 | 1946 | |
| 1904 | 1947 | return $ban_triggers; |
@@ -1954,8 +1997,9 @@ discard block |
||
| 1954 | 1997 | validateToken('admin-bl'); |
| 1955 | 1998 | |
| 1956 | 1999 | // 'Delete all entries' button was pressed. |
| 1957 | - if (!empty($_POST['removeAll'])) |
|
| 1958 | - removeBanLogs(); |
|
| 2000 | + if (!empty($_POST['removeAll'])) { |
|
| 2001 | + removeBanLogs(); |
|
| 2002 | + } |
|
| 1959 | 2003 | // 'Delete selection' button was pressed. |
| 1960 | 2004 | else |
| 1961 | 2005 | { |
@@ -2164,12 +2208,15 @@ discard block |
||
| 2164 | 2208 | $low = inet_dtop($low); |
| 2165 | 2209 | $high = inet_dtop($high); |
| 2166 | 2210 | |
| 2167 | - if ($low == '255.255.255.255') return 'unknown'; |
|
| 2168 | - if ($low == $high) |
|
| 2169 | - return $low; |
|
| 2170 | - else |
|
| 2171 | - return $low . '-' . $high; |
|
| 2172 | -} |
|
| 2211 | + if ($low == '255.255.255.255') { |
|
| 2212 | + return 'unknown'; |
|
| 2213 | + } |
|
| 2214 | + if ($low == $high) { |
|
| 2215 | + return $low; |
|
| 2216 | + } else { |
|
| 2217 | + return $low . '-' . $high; |
|
| 2218 | + } |
|
| 2219 | + } |
|
| 2173 | 2220 | |
| 2174 | 2221 | /** |
| 2175 | 2222 | * Checks whether a given IP range already exists in the trigger list. |
@@ -2245,15 +2292,17 @@ discard block |
||
| 2245 | 2292 | $memberEmailWild = array(); |
| 2246 | 2293 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2247 | 2294 | { |
| 2248 | - if ($row['id_member']) |
|
| 2249 | - $memberIDs[$row['id_member']] = $row['id_member']; |
|
| 2295 | + if ($row['id_member']) { |
|
| 2296 | + $memberIDs[$row['id_member']] = $row['id_member']; |
|
| 2297 | + } |
|
| 2250 | 2298 | if ($row['email_address']) |
| 2251 | 2299 | { |
| 2252 | 2300 | // Does it have a wildcard - if so we can't do a IN on it. |
| 2253 | - if (strpos($row['email_address'], '%') !== false) |
|
| 2254 | - $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
| 2255 | - else |
|
| 2256 | - $memberEmails[$row['email_address']] = $row['email_address']; |
|
| 2301 | + if (strpos($row['email_address'], '%') !== false) { |
|
| 2302 | + $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
| 2303 | + } else { |
|
| 2304 | + $memberEmails[$row['email_address']] = $row['email_address']; |
|
| 2305 | + } |
|
| 2257 | 2306 | } |
| 2258 | 2307 | } |
| 2259 | 2308 | $smcFunc['db_free_result']($request); |
@@ -2304,14 +2353,15 @@ discard block |
||
| 2304 | 2353 | } |
| 2305 | 2354 | |
| 2306 | 2355 | // We welcome our new members in the realm of the banned. |
| 2307 | - if (!empty($newMembers)) |
|
| 2308 | - $smcFunc['db_query']('', ' |
|
| 2356 | + if (!empty($newMembers)) { |
|
| 2357 | + $smcFunc['db_query']('', ' |
|
| 2309 | 2358 | DELETE FROM {db_prefix}log_online |
| 2310 | 2359 | WHERE id_member IN ({array_int:new_banned_members})', |
| 2311 | 2360 | array( |
| 2312 | 2361 | 'new_banned_members' => $newMembers, |
| 2313 | 2362 | ) |
| 2314 | 2363 | ); |
| 2364 | + } |
|
| 2315 | 2365 | |
| 2316 | 2366 | // Find members that are wrongfully marked as banned. |
| 2317 | 2367 | $request = $smcFunc['db_query']('', ' |
@@ -2338,9 +2388,10 @@ discard block |
||
| 2338 | 2388 | } |
| 2339 | 2389 | $smcFunc['db_free_result']($request); |
| 2340 | 2390 | |
| 2341 | - if (!empty($updates)) |
|
| 2342 | - foreach ($updates as $newStatus => $members) |
|
| 2391 | + if (!empty($updates)) { |
|
| 2392 | + foreach ($updates as $newStatus => $members) |
|
| 2343 | 2393 | updateMemberData($members, array('is_activated' => $newStatus)); |
| 2394 | + } |
|
| 2344 | 2395 | |
| 2345 | 2396 | // Update the latest member and our total members as banning may change them. |
| 2346 | 2397 | updateStats('member'); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * This is the main function for the languages area. |
@@ -153,11 +154,11 @@ discard block |
||
| 153 | 154 | $language_list = new xmlArray(fetch_web_data($url), true); |
| 154 | 155 | |
| 155 | 156 | // Check that the site responded and that the language exists. |
| 156 | - if (!$language_list->exists('languages')) |
|
| 157 | - $context['smf_error'] = 'no_response'; |
|
| 158 | - elseif (!$language_list->exists('languages/language')) |
|
| 159 | - $context['smf_error'] = 'no_files'; |
|
| 160 | - else |
|
| 157 | + if (!$language_list->exists('languages')) { |
|
| 158 | + $context['smf_error'] = 'no_response'; |
|
| 159 | + } elseif (!$language_list->exists('languages/language')) { |
|
| 160 | + $context['smf_error'] = 'no_files'; |
|
| 161 | + } else |
|
| 161 | 162 | { |
| 162 | 163 | $language_list = $language_list->path('languages[0]'); |
| 163 | 164 | $lang_files = $language_list->set('language'); |
@@ -165,8 +166,9 @@ discard block |
||
| 165 | 166 | foreach ($lang_files as $file) |
| 166 | 167 | { |
| 167 | 168 | // Were we searching? |
| 168 | - if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) |
|
| 169 | - continue; |
|
| 169 | + if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) { |
|
| 170 | + continue; |
|
| 171 | + } |
|
| 170 | 172 | |
| 171 | 173 | $smf_languages[] = array( |
| 172 | 174 | 'id' => $file->fetch('id'), |
@@ -177,10 +179,11 @@ discard block |
||
| 177 | 179 | 'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>', |
| 178 | 180 | ); |
| 179 | 181 | } |
| 180 | - if (empty($smf_languages)) |
|
| 181 | - $context['smf_error'] = 'no_files'; |
|
| 182 | - else |
|
| 183 | - return $smf_languages; |
|
| 182 | + if (empty($smf_languages)) { |
|
| 183 | + $context['smf_error'] = 'no_files'; |
|
| 184 | + } else { |
|
| 185 | + return $smf_languages; |
|
| 186 | + } |
|
| 184 | 187 | } |
| 185 | 188 | } |
| 186 | 189 | |
@@ -202,8 +205,9 @@ discard block |
||
| 202 | 205 | require_once($sourcedir . '/Subs-Package.php'); |
| 203 | 206 | |
| 204 | 207 | // Clearly we need to know what to request. |
| 205 | - if (!isset($_GET['did'])) |
|
| 206 | - fatal_lang_error('no_access', false); |
|
| 208 | + if (!isset($_GET['did'])) { |
|
| 209 | + fatal_lang_error('no_access', false); |
|
| 210 | + } |
|
| 207 | 211 | |
| 208 | 212 | // Some lovely context. |
| 209 | 213 | $context['download_id'] = $_GET['did']; |
@@ -223,8 +227,9 @@ discard block |
||
| 223 | 227 | foreach ($_POST['copy_file'] as $file) |
| 224 | 228 | { |
| 225 | 229 | // Check it's not very bad. |
| 226 | - if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) |
|
| 227 | - fatal_error($txt['languages_download_illegal_paths']); |
|
| 230 | + if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) { |
|
| 231 | + fatal_error($txt['languages_download_illegal_paths']); |
|
| 232 | + } |
|
| 228 | 233 | |
| 229 | 234 | $chmod_files[] = $boarddir . '/' . $file; |
| 230 | 235 | $install_files[] = $file; |
@@ -235,8 +240,9 @@ discard block |
||
| 235 | 240 | $files_left = $file_status['files']['notwritable']; |
| 236 | 241 | |
| 237 | 242 | // Something not writable? |
| 238 | - if (!empty($files_left)) |
|
| 239 | - $context['error_message'] = $txt['languages_download_not_chmod']; |
|
| 243 | + if (!empty($files_left)) { |
|
| 244 | + $context['error_message'] = $txt['languages_download_not_chmod']; |
|
| 245 | + } |
|
| 240 | 246 | // Otherwise, go go go! |
| 241 | 247 | elseif (!empty($install_files)) |
| 242 | 248 | { |
@@ -251,11 +257,13 @@ discard block |
||
| 251 | 257 | } |
| 252 | 258 | |
| 253 | 259 | // Open up the old china. |
| 254 | - if (!isset($archive_content)) |
|
| 255 | - $archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
| 260 | + if (!isset($archive_content)) { |
|
| 261 | + $archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
| 262 | + } |
|
| 256 | 263 | |
| 257 | - if (empty($archive_content)) |
|
| 258 | - fatal_error($txt['add_language_error_no_response']); |
|
| 264 | + if (empty($archive_content)) { |
|
| 265 | + fatal_error($txt['add_language_error_no_response']); |
|
| 266 | + } |
|
| 259 | 267 | |
| 260 | 268 | // Now for each of the files, let's do some *stuff* |
| 261 | 269 | $context['files'] = array( |
@@ -270,8 +278,9 @@ discard block |
||
| 270 | 278 | $extension = substr($filename, strrpos($filename, '.') + 1); |
| 271 | 279 | |
| 272 | 280 | // Don't do anything with files we don't understand. |
| 273 | - if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) |
|
| 274 | - continue; |
|
| 281 | + if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) { |
|
| 282 | + continue; |
|
| 283 | + } |
|
| 275 | 284 | |
| 276 | 285 | // Basic data. |
| 277 | 286 | $context_data = array( |
@@ -290,8 +299,9 @@ discard block |
||
| 290 | 299 | // Does the file exist, is it different and can we overwrite? |
| 291 | 300 | if (file_exists($boarddir . '/' . $file['filename'])) |
| 292 | 301 | { |
| 293 | - if (is_writable($boarddir . '/' . $file['filename'])) |
|
| 294 | - $context_data['writable'] = true; |
|
| 302 | + if (is_writable($boarddir . '/' . $file['filename'])) { |
|
| 303 | + $context_data['writable'] = true; |
|
| 304 | + } |
|
| 295 | 305 | |
| 296 | 306 | // Finally, do we actually think the content has changed? |
| 297 | 307 | if ($file['size'] == filesize($boarddir . '/' . $file['filename']) && $file['md5'] == md5_file($boarddir . '/' . $file['filename'])) |
@@ -304,16 +314,17 @@ discard block |
||
| 304 | 314 | { |
| 305 | 315 | $context_data['exists'] = 'same'; |
| 306 | 316 | $context_data['default_copy'] = false; |
| 317 | + } else { |
|
| 318 | + $context_data['exists'] = 'different'; |
|
| 307 | 319 | } |
| 308 | - else |
|
| 309 | - $context_data['exists'] = 'different'; |
|
| 310 | 320 | } |
| 311 | 321 | // No overwrite? |
| 312 | 322 | else |
| 313 | 323 | { |
| 314 | 324 | // Can we at least stick it in the directory... |
| 315 | - if (is_writable($boarddir . '/' . $dirname)) |
|
| 316 | - $context_data['writable'] = true; |
|
| 325 | + if (is_writable($boarddir . '/' . $dirname)) { |
|
| 326 | + $context_data['writable'] = true; |
|
| 327 | + } |
|
| 317 | 328 | } |
| 318 | 329 | |
| 319 | 330 | // I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin... |
@@ -328,8 +339,9 @@ discard block |
||
| 328 | 339 | list ($name, $language) = explode('.', $filename); |
| 329 | 340 | |
| 330 | 341 | // Let's get the new version, I like versions, they tell me that I'm up to date. |
| 331 | - if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) |
|
| 332 | - $context_data['version'] = $match[1]; |
|
| 342 | + if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) { |
|
| 343 | + $context_data['version'] = $match[1]; |
|
| 344 | + } |
|
| 333 | 345 | |
| 334 | 346 | // Now does the old file exist - if so what is it's version? |
| 335 | 347 | if (file_exists($boarddir . '/' . $file['filename'])) |
@@ -345,34 +357,35 @@ discard block |
||
| 345 | 357 | $context_data['cur_version'] = $match[1]; |
| 346 | 358 | |
| 347 | 359 | // How does this compare? |
| 348 | - if ($context_data['cur_version'] == $context_data['version']) |
|
| 349 | - $context_data['version_compare'] = 'same'; |
|
| 350 | - elseif ($context_data['cur_version'] > $context_data['version']) |
|
| 351 | - $context_data['version_compare'] = 'older'; |
|
| 360 | + if ($context_data['cur_version'] == $context_data['version']) { |
|
| 361 | + $context_data['version_compare'] = 'same'; |
|
| 362 | + } elseif ($context_data['cur_version'] > $context_data['version']) { |
|
| 363 | + $context_data['version_compare'] = 'older'; |
|
| 364 | + } |
|
| 352 | 365 | |
| 353 | 366 | // Don't recommend copying if the version is the same. |
| 354 | - if ($context_data['version_compare'] != 'newer') |
|
| 355 | - $context_data['default_copy'] = false; |
|
| 367 | + if ($context_data['version_compare'] != 'newer') { |
|
| 368 | + $context_data['default_copy'] = false; |
|
| 369 | + } |
|
| 356 | 370 | } |
| 357 | 371 | } |
| 358 | 372 | |
| 359 | 373 | // Add the context data to the main set. |
| 360 | 374 | $context['files']['lang'][] = $context_data; |
| 361 | - } |
|
| 362 | - elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
| 375 | + } elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
| 363 | 376 | { |
| 364 | 377 | // Registration agreement is a primary file |
| 365 | 378 | $context['files']['lang'][] = $context_data; |
| 366 | - } |
|
| 367 | - else |
|
| 379 | + } else |
|
| 368 | 380 | { |
| 369 | 381 | // There shouldn't be anything else, but load this into "other" in case we decide to handle it in the future |
| 370 | 382 | $context['files']['other'][] = $context_data; |
| 371 | 383 | } |
| 372 | 384 | |
| 373 | 385 | // Collect together all non-writable areas. |
| 374 | - if (!$context_data['writable']) |
|
| 375 | - $context['make_writable'][] = $context_data['destination']; |
|
| 386 | + if (!$context_data['writable']) { |
|
| 387 | + $context['make_writable'][] = $context_data['destination']; |
|
| 388 | + } |
|
| 376 | 389 | } |
| 377 | 390 | |
| 378 | 391 | // Before we go to far can we make anything writable, eh, eh? |
@@ -387,22 +400,24 @@ discard block |
||
| 387 | 400 | { |
| 388 | 401 | if ($type == 'lang') |
| 389 | 402 | { |
| 390 | - foreach ($data as $k => $file) |
|
| 391 | - if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
| 403 | + foreach ($data as $k => $file) { |
|
| 404 | + if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
| 392 | 405 | $context['files'][$type][$k]['writable'] = true; |
| 393 | - } |
|
| 394 | - else |
|
| 406 | + } |
|
| 407 | + } else |
|
| 395 | 408 | { |
| 396 | - foreach ($data as $theme => $files) |
|
| 397 | - foreach ($files as $k => $file) |
|
| 409 | + foreach ($data as $theme => $files) { |
|
| 410 | + foreach ($files as $k => $file) |
|
| 398 | 411 | if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
| 399 | 412 | $context['files'][$type][$theme][$k]['writable'] = true; |
| 413 | + } |
|
| 400 | 414 | } |
| 401 | 415 | } |
| 402 | 416 | |
| 403 | 417 | // Are we going to need more language stuff? |
| 404 | - if (!empty($context['still_not_writable'])) |
|
| 405 | - loadLanguage('Packages'); |
|
| 418 | + if (!empty($context['still_not_writable'])) { |
|
| 419 | + loadLanguage('Packages'); |
|
| 420 | + } |
|
| 406 | 421 | } |
| 407 | 422 | |
| 408 | 423 | // This is the list for the main files. |
@@ -615,12 +630,13 @@ discard block |
||
| 615 | 630 | highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '");', true); |
| 616 | 631 | |
| 617 | 632 | // Display a warning if we cannot edit the default setting. |
| 618 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 619 | - $listOptions['additional_rows'][] = array( |
|
| 633 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 634 | + $listOptions['additional_rows'][] = array( |
|
| 620 | 635 | 'position' => 'after_title', |
| 621 | 636 | 'value' => $txt['language_settings_writable'], |
| 622 | 637 | 'class' => 'smalltext alert', |
| 623 | 638 | ); |
| 639 | + } |
|
| 624 | 640 | |
| 625 | 641 | require_once($sourcedir . '/Subs-List.php'); |
| 626 | 642 | createList($listOptions); |
@@ -662,10 +678,11 @@ discard block |
||
| 662 | 678 | |
| 663 | 679 | // Put them back. |
| 664 | 680 | $settings['actual_theme_dir'] = $backup_actual_theme_dir; |
| 665 | - if (!empty($backup_base_theme_dir)) |
|
| 666 | - $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
| 667 | - else |
|
| 668 | - unset($settings['base_theme_dir']); |
|
| 681 | + if (!empty($backup_base_theme_dir)) { |
|
| 682 | + $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
| 683 | + } else { |
|
| 684 | + unset($settings['base_theme_dir']); |
|
| 685 | + } |
|
| 669 | 686 | |
| 670 | 687 | // Get the language files and data... |
| 671 | 688 | foreach ($context['languages'] as $lang) |
@@ -694,13 +711,15 @@ discard block |
||
| 694 | 711 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 695 | 712 | { |
| 696 | 713 | // Default? |
| 697 | - if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) |
|
| 698 | - $row['lngfile'] = $language; |
|
| 714 | + if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) { |
|
| 715 | + $row['lngfile'] = $language; |
|
| 716 | + } |
|
| 699 | 717 | |
| 700 | - if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) |
|
| 701 | - $languages['english']['count'] += $row['num_users']; |
|
| 702 | - elseif (isset($languages[$row['lngfile']])) |
|
| 703 | - $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
| 718 | + if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) { |
|
| 719 | + $languages['english']['count'] += $row['num_users']; |
|
| 720 | + } elseif (isset($languages[$row['lngfile']])) { |
|
| 721 | + $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
| 722 | + } |
|
| 704 | 723 | } |
| 705 | 724 | $smcFunc['db_free_result']($request); |
| 706 | 725 | |
@@ -740,13 +759,15 @@ discard block |
||
| 740 | 759 | |
| 741 | 760 | call_integration_hook('integrate_language_settings', array(&$config_vars)); |
| 742 | 761 | |
| 743 | - if ($return_config) |
|
| 744 | - return $config_vars; |
|
| 762 | + if ($return_config) { |
|
| 763 | + return $config_vars; |
|
| 764 | + } |
|
| 745 | 765 | |
| 746 | 766 | // Get our languages. No cache |
| 747 | 767 | getLanguages(false); |
| 748 | - foreach ($context['languages'] as $lang) |
|
| 749 | - $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']); |
|
| 768 | + foreach ($context['languages'] as $lang) { |
|
| 769 | + $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']); |
|
| 770 | + } |
|
| 750 | 771 | |
| 751 | 772 | // Saving settings? |
| 752 | 773 | if (isset($_REQUEST['save'])) |
@@ -756,8 +777,9 @@ discard block |
||
| 756 | 777 | call_integration_hook('integrate_save_language_settings', array(&$config_vars)); |
| 757 | 778 | |
| 758 | 779 | saveSettings($config_vars); |
| 759 | - if (!$settings_not_writable && !$settings_backup_fail) |
|
| 760 | - $_SESSION['adm-save'] = true; |
|
| 780 | + if (!$settings_not_writable && !$settings_backup_fail) { |
|
| 781 | + $_SESSION['adm-save'] = true; |
|
| 782 | + } |
|
| 761 | 783 | redirectexit('action=admin;area=languages;sa=settings'); |
| 762 | 784 | } |
| 763 | 785 | |
@@ -766,10 +788,11 @@ discard block |
||
| 766 | 788 | $context['settings_title'] = $txt['language_settings']; |
| 767 | 789 | $context['save_disabled'] = $settings_not_writable; |
| 768 | 790 | |
| 769 | - if ($settings_not_writable) |
|
| 770 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 771 | - elseif ($settings_backup_fail) |
|
| 772 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 791 | + if ($settings_not_writable) { |
|
| 792 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 793 | + } elseif ($settings_backup_fail) { |
|
| 794 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 795 | + } |
|
| 773 | 796 | |
| 774 | 797 | // Fill the config array. |
| 775 | 798 | prepareServerSettingsContext($config_vars); |
@@ -816,8 +839,9 @@ discard block |
||
| 816 | 839 | 'theme_dir' => $settings['default_theme_dir'], |
| 817 | 840 | ), |
| 818 | 841 | ); |
| 819 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 820 | - $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 842 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 843 | + $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 844 | + } |
|
| 821 | 845 | $smcFunc['db_free_result']($request); |
| 822 | 846 | |
| 823 | 847 | // This will be where we look |
@@ -829,14 +853,16 @@ discard block |
||
| 829 | 853 | // Check we have themes with a path and a name - just in case - and add the path. |
| 830 | 854 | foreach ($themes as $id => $data) |
| 831 | 855 | { |
| 832 | - if (count($data) != 2) |
|
| 833 | - unset($themes[$id]); |
|
| 834 | - elseif (is_dir($data['theme_dir'] . '/languages')) |
|
| 835 | - $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
| 856 | + if (count($data) != 2) { |
|
| 857 | + unset($themes[$id]); |
|
| 858 | + } elseif (is_dir($data['theme_dir'] . '/languages')) { |
|
| 859 | + $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
| 860 | + } |
|
| 836 | 861 | |
| 837 | 862 | // How about image directories? |
| 838 | - if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) |
|
| 839 | - $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
| 863 | + if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) { |
|
| 864 | + $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
| 865 | + } |
|
| 840 | 866 | } |
| 841 | 867 | |
| 842 | 868 | $current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : ''; |
@@ -850,15 +876,17 @@ discard block |
||
| 850 | 876 | while ($entry = $dir->read()) |
| 851 | 877 | { |
| 852 | 878 | // We're only after the files for this language. |
| 853 | - if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) |
|
| 854 | - continue; |
|
| 879 | + if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) { |
|
| 880 | + continue; |
|
| 881 | + } |
|
| 855 | 882 | |
| 856 | - if (!isset($context['possible_files'][$theme])) |
|
| 857 | - $context['possible_files'][$theme] = array( |
|
| 883 | + if (!isset($context['possible_files'][$theme])) { |
|
| 884 | + $context['possible_files'][$theme] = array( |
|
| 858 | 885 | 'id' => $theme, |
| 859 | 886 | 'name' => $themes[$theme]['name'], |
| 860 | 887 | 'files' => array(), |
| 861 | 888 | ); |
| 889 | + } |
|
| 862 | 890 | |
| 863 | 891 | $context['possible_files'][$theme]['files'][] = array( |
| 864 | 892 | 'id' => $matches[1], |
@@ -887,31 +915,36 @@ discard block |
||
| 887 | 915 | { |
| 888 | 916 | $_SESSION['last_backup_for'] = $context['lang_id'] . '$$$'; |
| 889 | 917 | $result = package_create_backup('backup_lang_' . $context['lang_id']); |
| 890 | - if (!$result) |
|
| 891 | - fatal_lang_error('could_not_language_backup', false); |
|
| 918 | + if (!$result) { |
|
| 919 | + fatal_lang_error('could_not_language_backup', false); |
|
| 920 | + } |
|
| 892 | 921 | } |
| 893 | 922 | |
| 894 | 923 | // Second, loop through the array to remove the files. |
| 895 | 924 | foreach ($lang_dirs as $curPath) |
| 896 | 925 | { |
| 897 | - foreach ($context['possible_files'][1]['files'] as $lang) |
|
| 898 | - if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
| 926 | + foreach ($context['possible_files'][1]['files'] as $lang) { |
|
| 927 | + if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
| 899 | 928 | unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'); |
| 929 | + } |
|
| 900 | 930 | |
| 901 | 931 | // Check for the email template. |
| 902 | - if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) |
|
| 903 | - unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
| 932 | + if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) { |
|
| 933 | + unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
| 934 | + } |
|
| 904 | 935 | } |
| 905 | 936 | |
| 906 | 937 | // Third, the agreement file. |
| 907 | - if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) |
|
| 908 | - unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
| 938 | + if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) { |
|
| 939 | + unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
| 940 | + } |
|
| 909 | 941 | |
| 910 | 942 | // Fourth, a related images folder, if it exists... |
| 911 | - if (!empty($images_dirs)) |
|
| 912 | - foreach ($images_dirs as $curPath) |
|
| 943 | + if (!empty($images_dirs)) { |
|
| 944 | + foreach ($images_dirs as $curPath) |
|
| 913 | 945 | if (is_dir($curPath)) |
| 914 | 946 | deltree($curPath); |
| 947 | + } |
|
| 915 | 948 | |
| 916 | 949 | // Members can no longer use this language. |
| 917 | 950 | $smcFunc['db_query']('', ' |
@@ -995,8 +1028,9 @@ discard block |
||
| 995 | 1028 | foreach ($_POST['entry'] as $k => $v) |
| 996 | 1029 | { |
| 997 | 1030 | // Only try to save if it's changed! |
| 998 | - if ($_POST['entry'][$k] != $_POST['comp'][$k]) |
|
| 999 | - $save_strings[$k] = cleanLangString($v, false); |
|
| 1031 | + if ($_POST['entry'][$k] != $_POST['comp'][$k]) { |
|
| 1032 | + $save_strings[$k] = cleanLangString($v, false); |
|
| 1033 | + } |
|
| 1000 | 1034 | } |
| 1001 | 1035 | } |
| 1002 | 1036 | |
@@ -1030,12 +1064,13 @@ discard block |
||
| 1030 | 1064 | if ($multiline_cache) |
| 1031 | 1065 | { |
| 1032 | 1066 | preg_match('~\$(helptxt|txt|editortxt)\[\'(.+)\'\]\s?=\s?(.+);~ms', strtr($multiline_cache, array("\r" => '')), $matches); |
| 1033 | - if (!empty($matches[3])) |
|
| 1034 | - $entries[$matches[2]] = array( |
|
| 1067 | + if (!empty($matches[3])) { |
|
| 1068 | + $entries[$matches[2]] = array( |
|
| 1035 | 1069 | 'type' => $matches[1], |
| 1036 | 1070 | 'full' => $matches[0], |
| 1037 | 1071 | 'entry' => $matches[3], |
| 1038 | 1072 | ); |
| 1073 | + } |
|
| 1039 | 1074 | } |
| 1040 | 1075 | |
| 1041 | 1076 | // These are the entries we can definitely save. |
@@ -1046,8 +1081,9 @@ discard block |
||
| 1046 | 1081 | { |
| 1047 | 1082 | // Ignore some things we set separately. |
| 1048 | 1083 | $ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl'); |
| 1049 | - if (in_array($entryKey, $ignore_files)) |
|
| 1050 | - continue; |
|
| 1084 | + if (in_array($entryKey, $ignore_files)) { |
|
| 1085 | + continue; |
|
| 1086 | + } |
|
| 1051 | 1087 | |
| 1052 | 1088 | // These are arrays that need breaking out. |
| 1053 | 1089 | $arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short', 'happy_birthday_author', 'karlbenson1_author', 'nite0859_author', 'zwaldowski_author', 'geezmo_author', 'karlbenson2_author'); |
@@ -1080,9 +1116,9 @@ discard block |
||
| 1080 | 1116 | { |
| 1081 | 1117 | $save_cache['entries'][$cur_index] = strtr($save_strings[$entryKey . '-+- ' . $cur_index], array('\'' => '')); |
| 1082 | 1118 | $save_cache['enabled'] = true; |
| 1119 | + } else { |
|
| 1120 | + $save_cache['entries'][$cur_index] = $subValue; |
|
| 1083 | 1121 | } |
| 1084 | - else |
|
| 1085 | - $save_cache['entries'][$cur_index] = $subValue; |
|
| 1086 | 1122 | |
| 1087 | 1123 | $context['file_entries'][] = array( |
| 1088 | 1124 | 'key' => $entryKey . '-+- ' . $cur_index, |
@@ -1105,9 +1141,9 @@ discard block |
||
| 1105 | 1141 | { |
| 1106 | 1142 | $items[] = $k2 . ' => \'' . $v2 . '\''; |
| 1107 | 1143 | $cur_index = $k2; |
| 1144 | + } else { |
|
| 1145 | + $items[] = '\'' . $v2 . '\''; |
|
| 1108 | 1146 | } |
| 1109 | - else |
|
| 1110 | - $items[] = '\'' . $v2 . '\''; |
|
| 1111 | 1147 | |
| 1112 | 1148 | $cur_index++; |
| 1113 | 1149 | } |
@@ -1117,15 +1153,15 @@ discard block |
||
| 1117 | 1153 | 'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');', |
| 1118 | 1154 | ); |
| 1119 | 1155 | } |
| 1120 | - } |
|
| 1121 | - else |
|
| 1156 | + } else |
|
| 1122 | 1157 | { |
| 1123 | 1158 | // Saving? |
| 1124 | 1159 | if (isset($save_strings[$entryKey]) && $save_strings[$entryKey] != $entryValue['entry']) |
| 1125 | 1160 | { |
| 1126 | 1161 | // @todo Fix this properly. |
| 1127 | - if ($save_strings[$entryKey] == '') |
|
| 1128 | - $save_strings[$entryKey] = '\'\''; |
|
| 1162 | + if ($save_strings[$entryKey] == '') { |
|
| 1163 | + $save_strings[$entryKey] = '\'\''; |
|
| 1164 | + } |
|
| 1129 | 1165 | |
| 1130 | 1166 | // Set the new value. |
| 1131 | 1167 | $entryValue['entry'] = $save_strings[$entryKey]; |
@@ -1151,8 +1187,9 @@ discard block |
||
| 1151 | 1187 | checkSession(); |
| 1152 | 1188 | |
| 1153 | 1189 | $file_contents = implode('', file($current_file)); |
| 1154 | - foreach ($final_saves as $save) |
|
| 1155 | - $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
| 1190 | + foreach ($final_saves as $save) { |
|
| 1191 | + $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
| 1192 | + } |
|
| 1156 | 1193 | |
| 1157 | 1194 | // Save the actual changes. |
| 1158 | 1195 | $fp = fopen($current_file, 'w+'); |
@@ -1167,8 +1204,9 @@ discard block |
||
| 1167 | 1204 | } |
| 1168 | 1205 | |
| 1169 | 1206 | // If we saved, redirect. |
| 1170 | - if ($madeSave) |
|
| 1171 | - redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
| 1207 | + if ($madeSave) { |
|
| 1208 | + redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
| 1209 | + } |
|
| 1172 | 1210 | |
| 1173 | 1211 | createToken('admin-mlang'); |
| 1174 | 1212 | } |
@@ -1200,8 +1238,9 @@ discard block |
||
| 1200 | 1238 | // Toggle the escape. |
| 1201 | 1239 | $is_escape = !$is_escape; |
| 1202 | 1240 | // If we're now escaped don't add this string. |
| 1203 | - if ($is_escape) |
|
| 1204 | - continue; |
|
| 1241 | + if ($is_escape) { |
|
| 1242 | + continue; |
|
| 1243 | + } |
|
| 1205 | 1244 | } |
| 1206 | 1245 | // Special case - parsed string with line break etc? |
| 1207 | 1246 | elseif (($string{$i} == 'n' || $string{$i} == 't') && $in_string == 2 && $is_escape) |
@@ -1218,11 +1257,13 @@ discard block |
||
| 1218 | 1257 | if ($in_string != 2 && ($in_string != 1 || !$is_escape)) |
| 1219 | 1258 | { |
| 1220 | 1259 | // Is it the end of a single quote string? |
| 1221 | - if ($in_string == 1) |
|
| 1222 | - $in_string = 0; |
|
| 1260 | + if ($in_string == 1) { |
|
| 1261 | + $in_string = 0; |
|
| 1262 | + } |
|
| 1223 | 1263 | // Otherwise it's the start! |
| 1224 | - else |
|
| 1225 | - $in_string = 1; |
|
| 1264 | + else { |
|
| 1265 | + $in_string = 1; |
|
| 1266 | + } |
|
| 1226 | 1267 | |
| 1227 | 1268 | // Don't actually include this character! |
| 1228 | 1269 | continue; |
@@ -1235,19 +1276,22 @@ discard block |
||
| 1235 | 1276 | if ($in_string != 1 && ($in_string != 2 || !$is_escape)) |
| 1236 | 1277 | { |
| 1237 | 1278 | // Is it the end of a double quote string? |
| 1238 | - if ($in_string == 2) |
|
| 1239 | - $in_string = 0; |
|
| 1279 | + if ($in_string == 2) { |
|
| 1280 | + $in_string = 0; |
|
| 1281 | + } |
|
| 1240 | 1282 | // Otherwise it's the start! |
| 1241 | - else |
|
| 1242 | - $in_string = 2; |
|
| 1283 | + else { |
|
| 1284 | + $in_string = 2; |
|
| 1285 | + } |
|
| 1243 | 1286 | |
| 1244 | 1287 | // Don't actually include this character! |
| 1245 | 1288 | continue; |
| 1246 | 1289 | } |
| 1247 | 1290 | } |
| 1248 | 1291 | // A join/space outside of a string is simply removed. |
| 1249 | - elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) |
|
| 1250 | - continue; |
|
| 1292 | + elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) { |
|
| 1293 | + continue; |
|
| 1294 | + } |
|
| 1251 | 1295 | // Start of a variable? |
| 1252 | 1296 | elseif ($in_string == 0 && $string{$i} == '$') |
| 1253 | 1297 | { |
@@ -1281,8 +1325,7 @@ discard block |
||
| 1281 | 1325 | |
| 1282 | 1326 | // Unhtml then rehtml the whole thing! |
| 1283 | 1327 | $new_string = $smcFunc['htmlspecialchars'](un_htmlspecialchars($new_string)); |
| 1284 | - } |
|
| 1285 | - else |
|
| 1328 | + } else |
|
| 1286 | 1329 | { |
| 1287 | 1330 | // Keep track of what we're doing... |
| 1288 | 1331 | $in_string = 0; |
@@ -1311,10 +1354,11 @@ discard block |
||
| 1311 | 1354 | preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches); |
| 1312 | 1355 | if (!empty($matches[1])) |
| 1313 | 1356 | { |
| 1314 | - if ($in_string == 1) |
|
| 1315 | - $new_string .= '\' . '; |
|
| 1316 | - elseif ($new_string) |
|
| 1317 | - $new_string .= ' . '; |
|
| 1357 | + if ($in_string == 1) { |
|
| 1358 | + $new_string .= '\' . '; |
|
| 1359 | + } elseif ($new_string) { |
|
| 1360 | + $new_string .= ' . '; |
|
| 1361 | + } |
|
| 1318 | 1362 | |
| 1319 | 1363 | $new_string .= $matches[1]; |
| 1320 | 1364 | $i += strlen($matches[1]) + 3; |
@@ -1327,8 +1371,9 @@ discard block |
||
| 1327 | 1371 | elseif ($string{$i} == '<') |
| 1328 | 1372 | { |
| 1329 | 1373 | // Probably HTML? |
| 1330 | - if ($string{$i + 1} != ' ') |
|
| 1331 | - $in_html = true; |
|
| 1374 | + if ($string{$i + 1} != ' ') { |
|
| 1375 | + $in_html = true; |
|
| 1376 | + } |
|
| 1332 | 1377 | // Assume we need an entity... |
| 1333 | 1378 | else |
| 1334 | 1379 | { |
@@ -1340,8 +1385,9 @@ discard block |
||
| 1340 | 1385 | elseif ($string{$i} == '>') |
| 1341 | 1386 | { |
| 1342 | 1387 | // Will it be HTML? |
| 1343 | - if ($in_html) |
|
| 1344 | - $in_html = false; |
|
| 1388 | + if ($in_html) { |
|
| 1389 | + $in_html = false; |
|
| 1390 | + } |
|
| 1345 | 1391 | // Otherwise we need an entity... |
| 1346 | 1392 | else |
| 1347 | 1393 | { |
@@ -1350,8 +1396,9 @@ discard block |
||
| 1350 | 1396 | } |
| 1351 | 1397 | } |
| 1352 | 1398 | // Is it a slash? If so escape it... |
| 1353 | - if ($string{$i} == '\\') |
|
| 1354 | - $new_string .= '\\'; |
|
| 1399 | + if ($string{$i} == '\\') { |
|
| 1400 | + $new_string .= '\\'; |
|
| 1401 | + } |
|
| 1355 | 1402 | // The infamous double quote? |
| 1356 | 1403 | elseif ($string{$i} == '"') |
| 1357 | 1404 | { |
@@ -1374,10 +1421,11 @@ discard block |
||
| 1374 | 1421 | } |
| 1375 | 1422 | |
| 1376 | 1423 | // If we ended as a string then close it off. |
| 1377 | - if ($in_string == 1) |
|
| 1378 | - $new_string .= '\''; |
|
| 1379 | - elseif ($in_string == 2) |
|
| 1380 | - $new_string .= '"'; |
|
| 1424 | + if ($in_string == 1) { |
|
| 1425 | + $new_string .= '\''; |
|
| 1426 | + } elseif ($in_string == 2) { |
|
| 1427 | + $new_string .= '"'; |
|
| 1428 | + } |
|
| 1381 | 1429 | } |
| 1382 | 1430 | |
| 1383 | 1431 | return $new_string; |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
| 32 | 33 | |
| 33 | 34 | // Are we looking at the moderation log or the administration log. |
| 34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
| 35 | - if ($context['log_type'] == 3) |
|
| 36 | - isAllowedTo('admin_forum'); |
|
| 36 | + if ($context['log_type'] == 3) { |
|
| 37 | + isAllowedTo('admin_forum'); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
| 39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
| 40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 41 | - else |
|
| 42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
| 42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 43 | + } else { |
|
| 44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 45 | + } |
|
| 43 | 46 | |
| 44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
| 45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
| 67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
| 68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
| 69 | 72 | |
| 70 | - } |
|
| 71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 72 | 74 | { |
| 73 | 75 | checkSession(); |
| 74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
| 114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
| 115 | 117 | ); |
| 116 | 118 | |
| 117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
| 118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 119 | - else |
|
| 120 | - $search_params_string = $search_params['string']; |
|
| 119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
| 120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 121 | + } else { |
|
| 122 | + $search_params_string = $search_params['string']; |
|
| 123 | + } |
|
| 121 | 124 | |
| 122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
| 123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 124 | - else |
|
| 125 | - $search_params_type = $search_params['type']; |
|
| 125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
| 126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 127 | + } else { |
|
| 128 | + $search_params_type = $search_params['type']; |
|
| 129 | + } |
|
| 126 | 130 | |
| 127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
| 128 | 132 | $search_params = array( |
@@ -297,13 +301,14 @@ discard block |
||
| 297 | 301 | $context['sub_template'] = 'show_list'; |
| 298 | 302 | $context['default_list'] = 'moderation_log_list'; |
| 299 | 303 | |
| 300 | - if (isset($context['moderation_menu_name'])) |
|
| 301 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 304 | + if (isset($context['moderation_menu_name'])) { |
|
| 305 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 302 | 306 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
| 303 | 307 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
| 304 | 308 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
| 305 | 309 | ); |
| 306 | -} |
|
| 310 | + } |
|
| 311 | + } |
|
| 307 | 312 | |
| 308 | 313 | /** |
| 309 | 314 | * Get the number of mod log entries. |
@@ -407,30 +412,35 @@ discard block |
||
| 407 | 412 | // Add on some of the column stuff info |
| 408 | 413 | if (!empty($row['id_board'])) |
| 409 | 414 | { |
| 410 | - if ($row['action'] == 'move') |
|
| 411 | - $row['extra']['board_to'] = $row['id_board']; |
|
| 412 | - else |
|
| 413 | - $row['extra']['board'] = $row['id_board']; |
|
| 415 | + if ($row['action'] == 'move') { |
|
| 416 | + $row['extra']['board_to'] = $row['id_board']; |
|
| 417 | + } else { |
|
| 418 | + $row['extra']['board'] = $row['id_board']; |
|
| 419 | + } |
|
| 414 | 420 | } |
| 415 | 421 | |
| 416 | - if (!empty($row['id_topic'])) |
|
| 417 | - $row['extra']['topic'] = $row['id_topic']; |
|
| 418 | - if (!empty($row['id_msg'])) |
|
| 419 | - $row['extra']['message'] = $row['id_msg']; |
|
| 422 | + if (!empty($row['id_topic'])) { |
|
| 423 | + $row['extra']['topic'] = $row['id_topic']; |
|
| 424 | + } |
|
| 425 | + if (!empty($row['id_msg'])) { |
|
| 426 | + $row['extra']['message'] = $row['id_msg']; |
|
| 427 | + } |
|
| 420 | 428 | |
| 421 | 429 | // Is this associated with a topic? |
| 422 | - if (isset($row['extra']['topic'])) |
|
| 423 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 424 | - if (isset($row['extra']['new_topic'])) |
|
| 425 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 430 | + if (isset($row['extra']['topic'])) { |
|
| 431 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 432 | + } |
|
| 433 | + if (isset($row['extra']['new_topic'])) { |
|
| 434 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 435 | + } |
|
| 426 | 436 | |
| 427 | 437 | // How about a member? |
| 428 | 438 | if (isset($row['extra']['member'])) |
| 429 | 439 | { |
| 430 | 440 | // Guests don't have names! |
| 431 | - if (empty($row['extra']['member'])) |
|
| 432 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 433 | - else |
|
| 441 | + if (empty($row['extra']['member'])) { |
|
| 442 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 443 | + } else |
|
| 434 | 444 | { |
| 435 | 445 | // Try to find it... |
| 436 | 446 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -438,35 +448,42 @@ discard block |
||
| 438 | 448 | } |
| 439 | 449 | |
| 440 | 450 | // Associated with a board? |
| 441 | - if (isset($row['extra']['board_to'])) |
|
| 442 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 443 | - if (isset($row['extra']['board_from'])) |
|
| 444 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 445 | - if (isset($row['extra']['board'])) |
|
| 446 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 451 | + if (isset($row['extra']['board_to'])) { |
|
| 452 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 453 | + } |
|
| 454 | + if (isset($row['extra']['board_from'])) { |
|
| 455 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 456 | + } |
|
| 457 | + if (isset($row['extra']['board'])) { |
|
| 458 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 459 | + } |
|
| 447 | 460 | |
| 448 | 461 | // A message? |
| 449 | - if (isset($row['extra']['message'])) |
|
| 450 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 462 | + if (isset($row['extra']['message'])) { |
|
| 463 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 464 | + } |
|
| 451 | 465 | |
| 452 | 466 | // IP Info? |
| 453 | - if (isset($row['extra']['ip_range'])) |
|
| 454 | - if ($seeIP) |
|
| 467 | + if (isset($row['extra']['ip_range'])) { |
|
| 468 | + if ($seeIP) |
|
| 455 | 469 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
| 456 | - else |
|
| 457 | - $row['extra']['ip_range'] = $txt['logged']; |
|
| 470 | + } else { |
|
| 471 | + $row['extra']['ip_range'] = $txt['logged']; |
|
| 472 | + } |
|
| 458 | 473 | |
| 459 | 474 | // Email? |
| 460 | - if (isset($row['extra']['email'])) |
|
| 461 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 475 | + if (isset($row['extra']['email'])) { |
|
| 476 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 477 | + } |
|
| 462 | 478 | |
| 463 | 479 | // Bans are complex. |
| 464 | 480 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
| 465 | 481 | { |
| 466 | 482 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
| 467 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
| 468 | - if (isset($row['extra'][$type])) |
|
| 483 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
| 484 | + if (isset($row['extra'][$type])) |
|
| 469 | 485 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
| 486 | + } |
|
| 470 | 487 | } |
| 471 | 488 | |
| 472 | 489 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -502,12 +519,13 @@ discard block |
||
| 502 | 519 | foreach ($boards[$row['id_board']] as $action) |
| 503 | 520 | { |
| 504 | 521 | // Make the board number into a link - dealing with moving too. |
| 505 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
| 506 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 507 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
| 508 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 509 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
| 510 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 522 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
| 523 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 524 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
| 525 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 526 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
| 527 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 528 | + } |
|
| 511 | 529 | } |
| 512 | 530 | } |
| 513 | 531 | $smcFunc['db_free_result']($request); |
@@ -541,10 +559,11 @@ discard block |
||
| 541 | 559 | ); |
| 542 | 560 | |
| 543 | 561 | // Make the topic number into a link - dealing with splitting too. |
| 544 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
| 545 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 546 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
| 547 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 562 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
| 563 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 564 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
| 565 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 566 | + } |
|
| 548 | 567 | } |
| 549 | 568 | } |
| 550 | 569 | $smcFunc['db_free_result']($request); |
@@ -577,8 +596,9 @@ discard block |
||
| 577 | 596 | ); |
| 578 | 597 | |
| 579 | 598 | // Make the message number into a link. |
| 580 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
| 581 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 599 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
| 600 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 601 | + } |
|
| 582 | 602 | } |
| 583 | 603 | } |
| 584 | 604 | $smcFunc['db_free_result']($request); |
@@ -618,25 +638,29 @@ discard block |
||
| 618 | 638 | foreach ($entries as $k => $entry) |
| 619 | 639 | { |
| 620 | 640 | // Make any message info links so its easier to go find that message. |
| 621 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
| 622 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 641 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
| 642 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 643 | + } |
|
| 623 | 644 | |
| 624 | 645 | // Mark up any deleted members, topics and boards. |
| 625 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
| 626 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 646 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
| 647 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 627 | 648 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
| 649 | + } |
|
| 628 | 650 | |
| 629 | 651 | if (isset($entry['extra']['report'])) |
| 630 | 652 | { |
| 631 | 653 | // Member profile reports go in a different area |
| 632 | - if (stristr($entry['action'], 'user_report')) |
|
| 633 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 634 | - else |
|
| 635 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 654 | + if (stristr($entry['action'], 'user_report')) { |
|
| 655 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 656 | + } else { |
|
| 657 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 658 | + } |
|
| 636 | 659 | } |
| 637 | 660 | |
| 638 | - if (empty($entries[$k]['action_text'])) |
|
| 639 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 661 | + if (empty($entries[$k]['action_text'])) { |
|
| 662 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 663 | + } |
|
| 640 | 664 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
| 641 | 665 | function ($matches) use ($entries, $k) |
| 642 | 666 | { |