| @@ -180,7 +180,7 @@ | ||
| 180 | 180 | * | 
| 181 | 181 | * @access public | 
| 182 | 182 | * @param string $dir A valid path | 
| 183 | - * @return boolean If this was successful or not. | |
| 183 | + * @return boolean|null If this was successful or not. | |
| 184 | 184 | */ | 
| 185 | 185 | public function setCachedir($dir = null) | 
| 186 | 186 |  	{ | 
| @@ -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 | * Our Cache API class | 
| @@ -43,8 +44,9 @@ discard block | ||
| 43 | 44 |  	{ | 
| 44 | 45 | $supported = is_writable($this->cachedir); | 
| 45 | 46 | |
| 46 | - if ($test) | |
| 47 | - return $supported; | |
| 47 | +		if ($test) { | |
| 48 | + return $supported; | |
| 49 | + } | |
| 48 | 50 | return parent::isSupported() && $supported; | 
| 49 | 51 | } | 
| 50 | 52 | |
| @@ -61,11 +63,13 @@ discard block | ||
| 61 | 63 |  		{ | 
| 62 | 64 | // Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds | 
| 63 | 65 | // causing newer files to take effect a while later. | 
| 64 | -			if (function_exists('opcache_invalidate')) | |
| 65 | - opcache_invalidate($cachedir . '/data_' . $key . '.php', true); | |
| 66 | +			if (function_exists('opcache_invalidate')) { | |
| 67 | + opcache_invalidate($cachedir . '/data_' . $key . '.php', true); | |
| 68 | + } | |
| 66 | 69 | |
| 67 | -			if (function_exists('apc_delete_file')) | |
| 68 | - @apc_delete_file($cachedir . '/data_' . $key . '.php'); | |
| 70 | +			if (function_exists('apc_delete_file')) { | |
| 71 | + @apc_delete_file($cachedir . '/data_' . $key . '.php'); | |
| 72 | + } | |
| 69 | 73 | |
| 70 | 74 | // php will cache file_exists et all, we can't 100% depend on its results so proceed with caution | 
| 71 | 75 | @include($cachedir . '/data_' . $key . '.php'); | 
| @@ -89,16 +93,18 @@ discard block | ||
| 89 | 93 | |
| 90 | 94 | // Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds | 
| 91 | 95 | // causing newer files to take effect a while later. | 
| 92 | -		if (function_exists('opcache_invalidate')) | |
| 93 | - opcache_invalidate($cachedir . '/data_' . $key . '.php', true); | |
| 96 | +		if (function_exists('opcache_invalidate')) { | |
| 97 | + opcache_invalidate($cachedir . '/data_' . $key . '.php', true); | |
| 98 | + } | |
| 94 | 99 | |
| 95 | -		if (function_exists('apc_delete_file')) | |
| 96 | - @apc_delete_file($cachedir . '/data_' . $key . '.php'); | |
| 100 | +		if (function_exists('apc_delete_file')) { | |
| 101 | + @apc_delete_file($cachedir . '/data_' . $key . '.php'); | |
| 102 | + } | |
| 97 | 103 | |
| 98 | 104 | // Otherwise custom cache? | 
| 99 | - if ($value === null) | |
| 100 | - @unlink($cachedir . '/data_' . $key . '.php'); | |
| 101 | - else | |
| 105 | +		if ($value === null) { | |
| 106 | + @unlink($cachedir . '/data_' . $key . '.php'); | |
| 107 | + } else | |
| 102 | 108 |  		{ | 
| 103 | 109 |  			$cache_data = '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>'; | 
| 104 | 110 | |
| @@ -109,9 +115,9 @@ discard block | ||
| 109 | 115 |  			{ | 
| 110 | 116 | @unlink($cachedir . '/data_' . $key . '.php'); | 
| 111 | 117 | return false; | 
| 118 | +			} else { | |
| 119 | + return true; | |
| 112 | 120 | } | 
| 113 | - else | |
| 114 | - return true; | |
| 115 | 121 | } | 
| 116 | 122 | } | 
| 117 | 123 | |
| @@ -123,15 +129,17 @@ discard block | ||
| 123 | 129 | $cachedir = $this->cachedir; | 
| 124 | 130 | |
| 125 | 131 | // No directory = no game. | 
| 126 | - if (!is_dir($cachedir)) | |
| 127 | - return; | |
| 132 | +		if (!is_dir($cachedir)) { | |
| 133 | + return; | |
| 134 | + } | |
| 128 | 135 | |
| 129 | 136 | // Remove the files in SMF's own disk cache, if any | 
| 130 | 137 | $dh = opendir($cachedir); | 
| 131 | 138 | while ($file = readdir($dh)) | 
| 132 | 139 |  		{ | 
| 133 | - if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) | |
| 134 | - @unlink($cachedir . '/' . $file); | |
| 140 | +			if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) { | |
| 141 | + @unlink($cachedir . '/' . $file); | |
| 142 | + } | |
| 135 | 143 | } | 
| 136 | 144 | closedir($dh); | 
| 137 | 145 | |
| @@ -165,8 +173,9 @@ discard block | ||
| 165 | 173 | $config_vars[] = $txt['cache_smf_settings']; | 
| 166 | 174 |  		$config_vars[] = array('cachedir', $txt['cachedir'], 'file', 'text', 36, 'cache_cachedir'); | 
| 167 | 175 | |
| 168 | - if (!isset($context['settings_post_javascript'])) | |
| 169 | - $context['settings_post_javascript'] = ''; | |
| 176 | +		if (!isset($context['settings_post_javascript'])) { | |
| 177 | + $context['settings_post_javascript'] = ''; | |
| 178 | + } | |
| 170 | 179 | |
| 171 | 180 | $context['settings_post_javascript'] .= ' | 
| 172 | 181 |  			$("#cache_accelerator").change(function (e) { | 
| @@ -187,10 +196,11 @@ discard block | ||
| 187 | 196 | global $cachedir; | 
| 188 | 197 | |
| 189 | 198 | // If its invalid, use SMF's. | 
| 190 | - if (is_null($dir) || !is_writable($dir)) | |
| 191 | - $this->cachedir = $cachedir; | |
| 192 | - else | |
| 193 | - $this->cachedir = $dir; | |
| 199 | +		if (is_null($dir) || !is_writable($dir)) { | |
| 200 | + $this->cachedir = $cachedir; | |
| 201 | +		} else { | |
| 202 | + $this->cachedir = $dir; | |
| 203 | + } | |
| 194 | 204 | } | 
| 195 | 205 | |
| 196 | 206 | /** | 
| @@ -44,6 +44,10 @@ discard block | ||
| 44 | 44 | $this->Buf = range(0, 279); | 
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | + /** | |
| 48 | + * @param string $data | |
| 49 | + * @param integer $datLen | |
| 50 | + */ | |
| 47 | 51 | public function decompress($data, &$datLen) | 
| 48 | 52 |  	{ | 
| 49 | 53 | $stLen = strlen($data); | 
| @@ -63,6 +67,11 @@ discard block | ||
| 63 | 67 | return $ret; | 
| 64 | 68 | } | 
| 65 | 69 | |
| 70 | + /** | |
| 71 | + * @param boolean $bInit | |
| 72 | + * | |
| 73 | + * @return integer | |
| 74 | + */ | |
| 66 | 75 | public function LZWCommand(&$data, $bInit) | 
| 67 | 76 |  	{ | 
| 68 | 77 | if ($bInit) | 
| @@ -253,6 +262,10 @@ discard block | ||
| 253 | 262 | unset($this->m_nColors, $this->m_arColors); | 
| 254 | 263 | } | 
| 255 | 264 | |
| 265 | + /** | |
| 266 | + * @param string $lpData | |
| 267 | + * @param integer $num | |
| 268 | + */ | |
| 256 | 269 | public function load($lpData, $num) | 
| 257 | 270 |  	{ | 
| 258 | 271 | $this->m_nColors = 0; | 
| @@ -324,6 +337,9 @@ discard block | ||
| 324 | 337 | unset($this->m_bSorted, $this->m_nTableSize, $this->m_nBgColor, $this->m_nPixelRatio, $this->m_colorTable); | 
| 325 | 338 | } | 
| 326 | 339 | |
| 340 | + /** | |
| 341 | + * @param integer $hdrLen | |
| 342 | + */ | |
| 327 | 343 | public function load($lpData, &$hdrLen) | 
| 328 | 344 |  	{ | 
| 329 | 345 | $hdrLen = 0; | 
| @@ -370,6 +386,10 @@ discard block | ||
| 370 | 386 | unset($this->m_bInterlace, $this->m_bSorted, $this->m_nTableSize, $this->m_colorTable); | 
| 371 | 387 | } | 
| 372 | 388 | |
| 389 | + /** | |
| 390 | + * @param string $lpData | |
| 391 | + * @param integer $hdrLen | |
| 392 | + */ | |
| 373 | 393 | public function load($lpData, &$hdrLen) | 
| 374 | 394 |  	{ | 
| 375 | 395 | $hdrLen = 0; | 
| @@ -412,6 +432,10 @@ discard block | ||
| 412 | 432 | $this->m_lzw = new gif_lzw_compression(); | 
| 413 | 433 | } | 
| 414 | 434 | |
| 435 | + /** | |
| 436 | + * @param string $data | |
| 437 | + * @param integer $datLen | |
| 438 | + */ | |
| 415 | 439 | public function load($data, &$datLen) | 
| 416 | 440 |  	{ | 
| 417 | 441 | $datLen = 0; | 
| @@ -464,6 +488,10 @@ discard block | ||
| 464 | 488 | return false; | 
| 465 | 489 | } | 
| 466 | 490 | |
| 491 | + /** | |
| 492 | + * @param string $data | |
| 493 | + * @param integer $extLen | |
| 494 | + */ | |
| 467 | 495 | public function skipExt(&$data, &$extLen) | 
| 468 | 496 |  	{ | 
| 469 | 497 | $extLen = 0; | 
| @@ -19,8 +19,9 @@ discard block | ||
| 19 | 19 | * @version 2.1 Beta 4 | 
| 20 | 20 | */ | 
| 21 | 21 | |
| 22 | -if (!defined('SMF')) | |
| 22 | +if (!defined('SMF')) { | |
| 23 | 23 |  	die('No direct access...'); | 
| 24 | +} | |
| 24 | 25 | |
| 25 | 26 | /** | 
| 26 | 27 | * Class gif_lzw_compression | 
| @@ -52,13 +53,15 @@ discard block | ||
| 52 | 53 | |
| 53 | 54 | $this->LZWCommand($data, true); | 
| 54 | 55 | |
| 55 | - while (($iIndex = $this->LZWCommand($data, false)) >= 0) | |
| 56 | - $ret .= chr($iIndex); | |
| 56 | +		while (($iIndex = $this->LZWCommand($data, false)) >= 0) { | |
| 57 | + $ret .= chr($iIndex); | |
| 58 | + } | |
| 57 | 59 | |
| 58 | 60 | $datLen = $stLen - strlen($data); | 
| 59 | 61 | |
| 60 | - if ($iIndex != -2) | |
| 61 | - return false; | |
| 62 | +		if ($iIndex != -2) { | |
| 63 | + return false; | |
| 64 | + } | |
| 62 | 65 | |
| 63 | 66 | return $ret; | 
| 64 | 67 | } | 
| @@ -140,8 +143,9 @@ discard block | ||
| 140 | 143 | return $this->FirstCode; | 
| 141 | 144 | } | 
| 142 | 145 | |
| 143 | - if ($Code == $this->EndCode) | |
| 144 | - return -2; | |
| 146 | +			if ($Code == $this->EndCode) { | |
| 147 | + return -2; | |
| 148 | + } | |
| 145 | 149 | |
| 146 | 150 | $InCode = $Code; | 
| 147 | 151 | if ($Code >= $this->MaxCode) | 
| @@ -156,8 +160,10 @@ discard block | ||
| 156 | 160 | $this->Stack[$this->sp] = $this->Vals[$Code]; | 
| 157 | 161 | $this->sp++; | 
| 158 | 162 | |
| 159 | - if ($Code == $this->Next[$Code]) // Circular table entry, big GIF Error! | |
| 163 | +				if ($Code == $this->Next[$Code]) { | |
| 164 | + // Circular table entry, big GIF Error! | |
| 160 | 165 | return -1; | 
| 166 | + } | |
| 161 | 167 | |
| 162 | 168 | $Code = $this->Next[$Code]; | 
| 163 | 169 | } | 
| @@ -207,8 +213,9 @@ discard block | ||
| 207 | 213 | if ($this->Done) | 
| 208 | 214 |  			{ | 
| 209 | 215 | // Ran off the end of my bits... | 
| 210 | - if ($this->CurBit >= $this->LastBit) | |
| 211 | - return 0; | |
| 216 | +				if ($this->CurBit >= $this->LastBit) { | |
| 217 | + return 0; | |
| 218 | + } | |
| 212 | 219 | |
| 213 | 220 | return -1; | 
| 214 | 221 | } | 
| @@ -221,13 +228,14 @@ discard block | ||
| 221 | 228 | |
| 222 | 229 | if ($count) | 
| 223 | 230 |  			{ | 
| 224 | - for ($i = 0; $i < $count; $i++) | |
| 225 | -					$this->Buf[2 + $i] = ord($data{$i}); | |
| 231 | +				for ($i = 0; $i < $count; $i++) { | |
| 232 | +									$this->Buf[2 + $i] = ord($data{$i}); | |
| 233 | + } | |
| 226 | 234 | |
| 227 | 235 | $data = substr($data, $count); | 
| 236 | +			} else { | |
| 237 | + $this->Done = 1; | |
| 228 | 238 | } | 
| 229 | - else | |
| 230 | - $this->Done = 1; | |
| 231 | 239 | |
| 232 | 240 | $this->LastByte = 2 + $count; | 
| 233 | 241 | $this->CurBit = ($this->CurBit - $this->LastBit) + 16; | 
| @@ -235,8 +243,9 @@ discard block | ||
| 235 | 243 | } | 
| 236 | 244 | |
| 237 | 245 | $iRet = 0; | 
| 238 | - for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) | |
| 239 | - $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j; | |
| 246 | +		for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) { | |
| 247 | + $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j; | |
| 248 | + } | |
| 240 | 249 | |
| 241 | 250 | $this->CurBit += $this->CodeSize; | 
| 242 | 251 | return $iRet; | 
| @@ -261,8 +270,9 @@ discard block | ||
| 261 | 270 | for ($i = 0; $i < $num; $i++) | 
| 262 | 271 |  		{ | 
| 263 | 272 | $rgb = substr($lpData, $i * 3, 3); | 
| 264 | - if (strlen($rgb) < 3) | |
| 265 | - return false; | |
| 273 | +			if (strlen($rgb) < 3) { | |
| 274 | + return false; | |
| 275 | + } | |
| 266 | 276 | |
| 267 | 277 | $this->m_arColors[] = (ord($rgb[2]) << 16) + (ord($rgb[1]) << 8) + ord($rgb[0]); | 
| 268 | 278 | $this->m_nColors++; | 
| @@ -329,13 +339,15 @@ discard block | ||
| 329 | 339 | $hdrLen = 0; | 
| 330 | 340 | |
| 331 | 341 | $this->m_lpVer = substr($lpData, 0, 6); | 
| 332 | - if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) | |
| 333 | - return false; | |
| 342 | +		if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) { | |
| 343 | + return false; | |
| 344 | + } | |
| 334 | 345 | |
| 335 | 346 |  		list ($this->m_nWidth, $this->m_nHeight) = array_values(unpack('v2', substr($lpData, 6, 4))); | 
| 336 | 347 | |
| 337 | - if (!$this->m_nWidth || !$this->m_nHeight) | |
| 338 | - return false; | |
| 348 | +		if (!$this->m_nWidth || !$this->m_nHeight) { | |
| 349 | + return false; | |
| 350 | + } | |
| 339 | 351 | |
| 340 | 352 | $b = ord(substr($lpData, 10, 1)); | 
| 341 | 353 | $this->m_bGlobalClr = ($b & 0x80) ? true : false; | 
| @@ -349,8 +361,9 @@ discard block | ||
| 349 | 361 | if ($this->m_bGlobalClr) | 
| 350 | 362 |  		{ | 
| 351 | 363 | $this->m_colorTable = new gif_color_table(); | 
| 352 | - if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) | |
| 353 | - return false; | |
| 364 | +			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) { | |
| 365 | + return false; | |
| 366 | + } | |
| 354 | 367 | |
| 355 | 368 | $hdrLen += 3 * $this->m_nTableSize; | 
| 356 | 369 | } | 
| @@ -377,8 +390,9 @@ discard block | ||
| 377 | 390 | // Get the width/height/etc. from the header. | 
| 378 | 391 |  		list ($this->m_nLeft, $this->m_nTop, $this->m_nWidth, $this->m_nHeight) = array_values(unpack('v4', substr($lpData, 0, 8))); | 
| 379 | 392 | |
| 380 | - if (!$this->m_nWidth || !$this->m_nHeight) | |
| 381 | - return false; | |
| 393 | +		if (!$this->m_nWidth || !$this->m_nHeight) { | |
| 394 | + return false; | |
| 395 | + } | |
| 382 | 396 | |
| 383 | 397 | $b = ord($lpData[8]); | 
| 384 | 398 | $this->m_bLocalClr = ($b & 0x80) ? true : false; | 
| @@ -390,8 +404,9 @@ discard block | ||
| 390 | 404 | if ($this->m_bLocalClr) | 
| 391 | 405 |  		{ | 
| 392 | 406 | $this->m_colorTable = new gif_color_table(); | 
| 393 | - if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) | |
| 394 | - return false; | |
| 407 | +			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) { | |
| 408 | + return false; | |
| 409 | + } | |
| 395 | 410 | |
| 396 | 411 | $hdrLen += 3 * $this->m_nTableSize; | 
| 397 | 412 | } | 
| @@ -427,8 +442,9 @@ discard block | ||
| 427 | 442 | // Extension... | 
| 428 | 443 | case 0x21: | 
| 429 | 444 | $len = 0; | 
| 430 | - if (!$this->skipExt($data, $len)) | |
| 431 | - return false; | |
| 445 | +					if (!$this->skipExt($data, $len)) { | |
| 446 | + return false; | |
| 447 | + } | |
| 432 | 448 | |
| 433 | 449 | $datLen += $len; | 
| 434 | 450 | break; | 
| @@ -437,21 +453,24 @@ discard block | ||
| 437 | 453 | case 0x2C: | 
| 438 | 454 | // Load the header and color table. | 
| 439 | 455 | $len = 0; | 
| 440 | - if (!$this->m_gih->load($data, $len)) | |
| 441 | - return false; | |
| 456 | +					if (!$this->m_gih->load($data, $len)) { | |
| 457 | + return false; | |
| 458 | + } | |
| 442 | 459 | |
| 443 | 460 | $data = substr($data, $len); | 
| 444 | 461 | $datLen += $len; | 
| 445 | 462 | |
| 446 | 463 | // Decompress the data, and ride on home ;). | 
| 447 | 464 | $len = 0; | 
| 448 | - if (!($this->m_data = $this->m_lzw->decompress($data, $len))) | |
| 449 | - return false; | |
| 465 | +					if (!($this->m_data = $this->m_lzw->decompress($data, $len))) { | |
| 466 | + return false; | |
| 467 | + } | |
| 450 | 468 | |
| 451 | 469 | $datLen += $len; | 
| 452 | 470 | |
| 453 | - if ($this->m_gih->m_bInterlace) | |
| 454 | - $this->deInterlace(); | |
| 471 | +					if ($this->m_gih->m_bInterlace) { | |
| 472 | + $this->deInterlace(); | |
| 473 | + } | |
| 455 | 474 | |
| 456 | 475 | return true; | 
| 457 | 476 | |
| @@ -571,17 +590,20 @@ discard block | ||
| 571 | 590 | |
| 572 | 591 | public function loadFile($filename, $iIndex) | 
| 573 | 592 |  	{ | 
| 574 | - if ($iIndex < 0) | |
| 575 | - return false; | |
| 593 | +		if ($iIndex < 0) { | |
| 594 | + return false; | |
| 595 | + } | |
| 576 | 596 | |
| 577 | 597 | $this->data = @file_get_contents($filename); | 
| 578 | - if ($this->data === false) | |
| 579 | - return false; | |
| 598 | +		if ($this->data === false) { | |
| 599 | + return false; | |
| 600 | + } | |
| 580 | 601 | |
| 581 | 602 | // Tell the header to load up.... | 
| 582 | 603 | $len = 0; | 
| 583 | - if (!$this->header->load($this->data, $len)) | |
| 584 | - return false; | |
| 604 | +		if (!$this->header->load($this->data, $len)) { | |
| 605 | + return false; | |
| 606 | + } | |
| 585 | 607 | |
| 586 | 608 | $this->data = substr($this->data, $len); | 
| 587 | 609 | |
| @@ -589,8 +611,9 @@ discard block | ||
| 589 | 611 | for ($j = 0; $j <= $iIndex; $j++) | 
| 590 | 612 |  		{ | 
| 591 | 613 | $imgLen = 0; | 
| 592 | - if (!$this->image->load($this->data, $imgLen)) | |
| 593 | - return false; | |
| 614 | +			if (!$this->image->load($this->data, $imgLen)) { | |
| 615 | + return false; | |
| 616 | + } | |
| 594 | 617 | |
| 595 | 618 | $this->data = substr($this->data, $imgLen); | 
| 596 | 619 | } | 
| @@ -601,8 +624,9 @@ discard block | ||
| 601 | 624 | |
| 602 | 625 | public function get_png_data($background_color) | 
| 603 | 626 |  	{ | 
| 604 | - if (!$this->loaded) | |
| 605 | - return false; | |
| 627 | +		if (!$this->loaded) { | |
| 628 | + return false; | |
| 629 | + } | |
| 606 | 630 | |
| 607 | 631 | // Prepare the color table. | 
| 608 | 632 | if ($this->image->m_gih->m_bLocalClr) | 
| @@ -610,25 +634,26 @@ discard block | ||
| 610 | 634 | $colors = $this->image->m_gih->m_nTableSize; | 
| 611 | 635 | $pal = $this->image->m_gih->m_colorTable->toString(); | 
| 612 | 636 | |
| 613 | - if ($background_color != -1) | |
| 614 | - $background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color); | |
| 615 | - } | |
| 616 | - elseif ($this->header->m_bGlobalClr) | |
| 637 | +			if ($background_color != -1) { | |
| 638 | + $background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color); | |
| 639 | + } | |
| 640 | + } elseif ($this->header->m_bGlobalClr) | |
| 617 | 641 |  		{ | 
| 618 | 642 | $colors = $this->header->m_nTableSize; | 
| 619 | 643 | $pal = $this->header->m_colorTable->toString(); | 
| 620 | 644 | |
| 621 | - if ($background_color != -1) | |
| 622 | - $background_color = $this->header->m_colorTable->colorIndex($background_color); | |
| 623 | - } | |
| 624 | - else | |
| 645 | +			if ($background_color != -1) { | |
| 646 | + $background_color = $this->header->m_colorTable->colorIndex($background_color); | |
| 647 | + } | |
| 648 | + } else | |
| 625 | 649 |  		{ | 
| 626 | 650 | $colors = 0; | 
| 627 | 651 | $background_color = -1; | 
| 628 | 652 | } | 
| 629 | 653 | |
| 630 | - if ($background_color == -1) | |
| 631 | - $background_color = $this->header->m_nBgColor; | |
| 654 | +		if ($background_color == -1) { | |
| 655 | + $background_color = $this->header->m_nBgColor; | |
| 656 | + } | |
| 632 | 657 | |
| 633 | 658 | $data = &$this->image->m_data; | 
| 634 | 659 | $header = &$this->image->m_gih; | 
| @@ -644,11 +669,13 @@ discard block | ||
| 644 | 669 | for ($x = 0; $x < $this->header->m_nWidth; $x++, $i++) | 
| 645 | 670 |  			{ | 
| 646 | 671 | // Is this in the proper range? If so, get the specific pixel data... | 
| 647 | - if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) | |
| 648 | -					$bmp .= $data{$i}; | |
| 672 | +				if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) { | |
| 673 | +									$bmp .= $data{$i}; | |
| 674 | + } | |
| 649 | 675 | // Otherwise, this is background... | 
| 650 | - else | |
| 651 | - $bmp .= chr($background_color); | |
| 676 | +				else { | |
| 677 | + $bmp .= chr($background_color); | |
| 678 | + } | |
| 652 | 679 | } | 
| 653 | 680 | } | 
| 654 | 681 | |
| @@ -677,8 +704,9 @@ discard block | ||
| 677 | 704 | $tmp = 'tRNS'; | 
| 678 | 705 | |
| 679 | 706 | // Stick each color on - full transparency or none. | 
| 680 | - for ($i = 0; $i < $colors; $i++) | |
| 681 | - $tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF"; | |
| 707 | +			for ($i = 0; $i < $colors; $i++) { | |
| 708 | + $tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF"; | |
| 709 | + } | |
| 682 | 710 | |
| 683 | 711 |  			$out .= $tmp . pack('N', smf_crc32($tmp)); | 
| 684 | 712 | } | 
| @@ -56,6 +56,7 @@ discard block | ||
| 56 | 56 | * @param array $wordsSearch Search words | 
| 57 | 57 | * @param array $wordsExclude Words to exclude | 
| 58 | 58 | * @param bool $isExcluded Whether the specfied word should be excluded | 
| 59 | + * @return void | |
| 59 | 60 | */ | 
| 60 | 61 | public function prepareIndexes($word, array &$wordsSearch, array &$wordsExclude, $isExcluded); | 
| 61 | 62 | |
| @@ -130,7 +131,7 @@ discard block | ||
| 130 | 131 | * @param array $excludedIndexWords Indexed words that should be excluded | 
| 131 | 132 | * @param array $participants | 
| 132 | 133 | * @param array $searchArray | 
| 133 | - * @return mixed | |
| 134 | + * @return integer | |
| 134 | 135 | */ | 
| 135 | 136 | public function searchQuery(array $query_params, array $searchWords, array $excludedIndexWords, array &$participants, array &$searchArray); | 
| 136 | 137 | } | 
| @@ -233,11 +233,13 @@ | ||
| 233 | 233 | ); | 
| 234 | 234 | |
| 235 | 235 | $id_searchs = array(); | 
| 236 | - while ($row = $smcFunc['db_fetch_assoc']($result)) | |
| 237 | - $id_searchs[] = $row['id_search']; | |
| 236 | +		while ($row = $smcFunc['db_fetch_assoc']($result)) { | |
| 237 | + $id_searchs[] = $row['id_search']; | |
| 238 | + } | |
| 238 | 239 | |
| 239 | - if (count($id_searchs) < 1) | |
| 240 | - return; | |
| 240 | +		if (count($id_searchs) < 1) { | |
| 241 | + return; | |
| 242 | + } | |
| 241 | 243 | |
| 242 | 244 |  		$smcFunc['db_query']('',' | 
| 243 | 245 |  			DELETE FROM {db_prefix}log_search_results | 
| @@ -279,7 +279,7 @@ discard block | ||
| 279 | 279 | /** | 
| 280 | 280 | * Generate the timestamp for the calculation | 
| 281 | 281 | * | 
| 282 | - * @return integer Timestamp | |
| 282 | + * @return double Timestamp | |
| 283 | 283 | */ | 
| 284 | 284 | public function generateTimestamp() | 
| 285 | 285 |  	{ | 
| @@ -290,7 +290,7 @@ discard block | ||
| 290 | 290 | * Truncate the given hash down to just what we need | 
| 291 | 291 | * | 
| 292 | 292 | * @param string $hash Hash to truncate | 
| 293 | - * @return string Truncated hash value | |
| 293 | + * @return integer Truncated hash value | |
| 294 | 294 | */ | 
| 295 | 295 | public function truncateHash($hash) | 
| 296 | 296 |  	{ | 
| @@ -382,7 +382,7 @@ | ||
| 382 | 382 | * @param array $parameters Not used? | 
| 383 | 383 | * @param string $if_exists What to do if the index exists. If 'update', the definition will be updated. | 
| 384 | 384 | * @param string $error | 
| 385 | - * @return boolean Whether or not the operation was successful | |
| 385 | + * @return false|null Whether or not the operation was successful | |
| 386 | 386 | */ | 
| 387 | 387 | function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_exists = 'update', $error = 'fatal') | 
| 388 | 388 |  { | 
| @@ -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 | * Add the file functions to the $smcFunc array. | 
| @@ -53,8 +54,9 @@ discard block | ||
| 53 | 54 | 'messages', 'moderator_groups', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', | 
| 54 | 55 | 'pm_labeled_messages', 'pm_labels', 'pm_recipients', 'pm_rules', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', | 
| 55 | 56 | 'spiders', 'subscriptions', 'themes', 'topics', 'user_alerts', 'user_alerts_prefs', 'user_drafts', 'user_likes'); | 
| 56 | - foreach ($reservedTables as $k => $table_name) | |
| 57 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); | |
| 57 | +	foreach ($reservedTables as $k => $table_name) { | |
| 58 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); | |
| 59 | + } | |
| 58 | 60 | |
| 59 | 61 | // We in turn may need the extra stuff. | 
| 60 | 62 |  	db_extend('extra'); | 
| @@ -109,8 +111,9 @@ discard block | ||
| 109 | 111 |  	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name); | 
| 110 | 112 | |
| 111 | 113 | // First - no way do we touch SMF tables. | 
| 112 | - if (in_array(strtolower($table_name), $reservedTables)) | |
| 113 | - return false; | |
| 114 | +	if (in_array(strtolower($table_name), $reservedTables)) { | |
| 115 | + return false; | |
| 116 | + } | |
| 114 | 117 | |
| 115 | 118 | // Log that we'll want to remove this on uninstall. | 
| 116 | 119 |  	$db_package_log[] = array('remove_table', $table_name); | 
| @@ -120,9 +123,9 @@ discard block | ||
| 120 | 123 | if (in_array($full_table_name, $tables)) | 
| 121 | 124 |  	{ | 
| 122 | 125 | // This is a sad day... drop the table? If not, return false (error) by default. | 
| 123 | - if ($if_exists == 'overwrite') | |
| 124 | - $smcFunc['db_drop_table']($table_name); | |
| 125 | - else if ($if_exists == 'update') | |
| 126 | +		if ($if_exists == 'overwrite') { | |
| 127 | + $smcFunc['db_drop_table']($table_name); | |
| 128 | + } else if ($if_exists == 'update') | |
| 126 | 129 |  		{ | 
| 127 | 130 |  			$smcFunc['db_transaction']('begin'); | 
| 128 | 131 | $db_trans = true; | 
| @@ -134,15 +137,16 @@ discard block | ||
| 134 | 137 | ) | 
| 135 | 138 | ); | 
| 136 | 139 | $old_table_exists = true; | 
| 140 | +		} else { | |
| 141 | + return $if_exists == 'ignore'; | |
| 137 | 142 | } | 
| 138 | - else | |
| 139 | - return $if_exists == 'ignore'; | |
| 140 | 143 | } | 
| 141 | 144 | |
| 142 | 145 | // Righty - let's do the damn thing! | 
| 143 | 146 |  	$table_query = 'CREATE TABLE ' . $table_name . "\n" . '('; | 
| 144 | - foreach ($columns as $column) | |
| 145 | - $table_query .= "\n\t" . smf_db_create_query_column($column) . ','; | |
| 147 | +	foreach ($columns as $column) { | |
| 148 | + $table_query .= "\n\t" . smf_db_create_query_column($column) . ','; | |
| 149 | + } | |
| 146 | 150 | |
| 147 | 151 | // Loop through the indexes next... | 
| 148 | 152 | foreach ($indexes as $index) | 
| @@ -150,19 +154,21 @@ discard block | ||
| 150 | 154 |  		$columns = implode(',', $index['columns']); | 
| 151 | 155 | |
| 152 | 156 | // Is it the primary? | 
| 153 | - if (isset($index['type']) && $index['type'] == 'primary') | |
| 154 | -			$table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; | |
| 155 | - else | |
| 157 | +		if (isset($index['type']) && $index['type'] == 'primary') { | |
| 158 | +					$table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; | |
| 159 | + } else | |
| 156 | 160 |  		{ | 
| 157 | - if (empty($index['name'])) | |
| 158 | -				$index['name'] = implode('_', $index['columns']); | |
| 161 | +			if (empty($index['name'])) { | |
| 162 | +							$index['name'] = implode('_', $index['columns']); | |
| 163 | + } | |
| 159 | 164 |  			$table_query .= "\n\t" . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : 'KEY') . ' ' . $index['name'] . ' (' . $columns . '),'; | 
| 160 | 165 | } | 
| 161 | 166 | } | 
| 162 | 167 | |
| 163 | 168 | // No trailing commas! | 
| 164 | - if (substr($table_query, -1) == ',') | |
| 165 | - $table_query = substr($table_query, 0, -1); | |
| 169 | +	if (substr($table_query, -1) == ',') { | |
| 170 | + $table_query = substr($table_query, 0, -1); | |
| 171 | + } | |
| 166 | 172 | |
| 167 | 173 | // Which engine do we want here? | 
| 168 | 174 | if (empty($engines)) | 
| @@ -172,8 +178,9 @@ discard block | ||
| 172 | 178 | |
| 173 | 179 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) | 
| 174 | 180 |  		{ | 
| 175 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') | |
| 176 | - $engines[] = $row['Engine']; | |
| 181 | +			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { | |
| 182 | + $engines[] = $row['Engine']; | |
| 183 | + } | |
| 177 | 184 | } | 
| 178 | 185 | |
| 179 | 186 | $smcFunc['db_free_result']($get_engines); | 
| @@ -187,8 +194,9 @@ discard block | ||
| 187 | 194 | } | 
| 188 | 195 | |
| 189 | 196 | $table_query .= ') ENGINE=' . $parameters['engine']; | 
| 190 | - if (!empty($db_character_set) && $db_character_set == 'utf8') | |
| 191 | - $table_query .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; | |
| 197 | +	if (!empty($db_character_set) && $db_character_set == 'utf8') { | |
| 198 | + $table_query .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; | |
| 199 | + } | |
| 192 | 200 | |
| 193 | 201 | // Create the table! | 
| 194 | 202 |  	$smcFunc['db_query']('', $table_query, | 
| @@ -255,8 +263,9 @@ discard block | ||
| 255 | 263 |  	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name); | 
| 256 | 264 | |
| 257 | 265 | // God no - dropping one of these = bad. | 
| 258 | - if (in_array(strtolower($table_name), $reservedTables)) | |
| 259 | - return false; | |
| 266 | +	if (in_array(strtolower($table_name), $reservedTables)) { | |
| 267 | + return false; | |
| 268 | + } | |
| 260 | 269 | |
| 261 | 270 | // Does it exist? | 
| 262 | 271 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) | 
| @@ -297,14 +306,16 @@ discard block | ||
| 297 | 306 | |
| 298 | 307 | // Does it exist - if so don't add it again! | 
| 299 | 308 | $columns = $smcFunc['db_list_columns']($table_name, false); | 
| 300 | - foreach ($columns as $column) | |
| 301 | - if ($column == $column_info['name']) | |
| 309 | +	foreach ($columns as $column) { | |
| 310 | + if ($column == $column_info['name']) | |
| 302 | 311 |  		{ | 
| 303 | 312 | // If we're going to overwrite then use change column. | 
| 304 | 313 | if ($if_exists == 'update') | 
| 305 | 314 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); | 
| 306 | - else | |
| 307 | - return false; | |
| 315 | + } | |
| 316 | +			else { | |
| 317 | + return false; | |
| 318 | + } | |
| 308 | 319 | } | 
| 309 | 320 | |
| 310 | 321 | // Get the specifics... | 
| @@ -340,8 +351,8 @@ discard block | ||
| 340 | 351 | |
| 341 | 352 | // Does it exist? | 
| 342 | 353 | $columns = $smcFunc['db_list_columns']($table_name, true); | 
| 343 | - foreach ($columns as $column) | |
| 344 | - if ($column['name'] == $column_name) | |
| 354 | +	foreach ($columns as $column) { | |
| 355 | + if ($column['name'] == $column_name) | |
| 345 | 356 |  		{ | 
| 346 | 357 |  			$smcFunc['db_query']('', ' | 
| 347 | 358 | ALTER TABLE ' . $table_name . ' | 
| @@ -350,6 +361,7 @@ discard block | ||
| 350 | 361 | 'security_override' => true, | 
| 351 | 362 | ) | 
| 352 | 363 | ); | 
| 364 | + } | |
| 353 | 365 | |
| 354 | 366 | return true; | 
| 355 | 367 | } | 
| @@ -375,37 +387,47 @@ discard block | ||
| 375 | 387 | // Check it does exist! | 
| 376 | 388 | $columns = $smcFunc['db_list_columns']($table_name, true); | 
| 377 | 389 | $old_info = null; | 
| 378 | - foreach ($columns as $column) | |
| 379 | - if ($column['name'] == $old_column) | |
| 390 | +	foreach ($columns as $column) { | |
| 391 | + if ($column['name'] == $old_column) | |
| 380 | 392 | $old_info = $column; | 
| 393 | + } | |
| 381 | 394 | |
| 382 | 395 | // Nothing? | 
| 383 | - if ($old_info == null) | |
| 384 | - return false; | |
| 396 | +	if ($old_info == null) { | |
| 397 | + return false; | |
| 398 | + } | |
| 385 | 399 | |
| 386 | 400 | // Get the right bits. | 
| 387 | - if (!isset($column_info['name'])) | |
| 388 | - $column_info['name'] = $old_column; | |
| 389 | - if (!isset($column_info['default'])) | |
| 390 | - $column_info['default'] = $old_info['default']; | |
| 391 | - if (!isset($column_info['null'])) | |
| 392 | - $column_info['null'] = $old_info['null']; | |
| 393 | - if (!isset($column_info['auto'])) | |
| 394 | - $column_info['auto'] = $old_info['auto']; | |
| 395 | - if (!isset($column_info['type'])) | |
| 396 | - $column_info['type'] = $old_info['type']; | |
| 397 | - if (!isset($column_info['size']) || !is_numeric($column_info['size'])) | |
| 398 | - $column_info['size'] = $old_info['size']; | |
| 399 | -	if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint'))) | |
| 400 | - $column_info['unsigned'] = ''; | |
| 401 | +	if (!isset($column_info['name'])) { | |
| 402 | + $column_info['name'] = $old_column; | |
| 403 | + } | |
| 404 | +	if (!isset($column_info['default'])) { | |
| 405 | + $column_info['default'] = $old_info['default']; | |
| 406 | + } | |
| 407 | +	if (!isset($column_info['null'])) { | |
| 408 | + $column_info['null'] = $old_info['null']; | |
| 409 | + } | |
| 410 | +	if (!isset($column_info['auto'])) { | |
| 411 | + $column_info['auto'] = $old_info['auto']; | |
| 412 | + } | |
| 413 | +	if (!isset($column_info['type'])) { | |
| 414 | + $column_info['type'] = $old_info['type']; | |
| 415 | + } | |
| 416 | +	if (!isset($column_info['size']) || !is_numeric($column_info['size'])) { | |
| 417 | + $column_info['size'] = $old_info['size']; | |
| 418 | + } | |
| 419 | +	if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint'))) { | |
| 420 | + $column_info['unsigned'] = ''; | |
| 421 | + } | |
| 401 | 422 | |
| 402 | 423 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); | 
| 403 | 424 | |
| 404 | 425 | // Allow for unsigned integers (mysql only) | 
| 405 | 426 |  	$unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column_info['unsigned']) ? 'unsigned ' : ''; | 
| 406 | 427 | |
| 407 | - if ($size !== null) | |
| 408 | -		$type = $type . '(' . $size . ')'; | |
| 428 | +	if ($size !== null) { | |
| 429 | +			$type = $type . '(' . $size . ')'; | |
| 430 | + } | |
| 409 | 431 | |
| 410 | 432 |  	$smcFunc['db_query']('', ' | 
| 411 | 433 | ALTER TABLE ' . $table_name . ' | 
| @@ -435,18 +457,20 @@ discard block | ||
| 435 | 457 |  	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name); | 
| 436 | 458 | |
| 437 | 459 | // No columns = no index. | 
| 438 | - if (empty($index_info['columns'])) | |
| 439 | - return false; | |
| 460 | +	if (empty($index_info['columns'])) { | |
| 461 | + return false; | |
| 462 | + } | |
| 440 | 463 |  	$columns = implode(',', $index_info['columns']); | 
| 441 | 464 | |
| 442 | 465 | // No name - make it up! | 
| 443 | 466 | if (empty($index_info['name'])) | 
| 444 | 467 |  	{ | 
| 445 | 468 | // No need for primary. | 
| 446 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') | |
| 447 | - $index_info['name'] = ''; | |
| 448 | - else | |
| 449 | -			$index_info['name'] = implode('_', $index_info['columns']); | |
| 469 | +		if (isset($index_info['type']) && $index_info['type'] == 'primary') { | |
| 470 | + $index_info['name'] = ''; | |
| 471 | +		} else { | |
| 472 | +					$index_info['name'] = implode('_', $index_info['columns']); | |
| 473 | + } | |
| 450 | 474 | } | 
| 451 | 475 | |
| 452 | 476 | // Log that we are going to want to remove this! | 
| @@ -460,10 +484,11 @@ discard block | ||
| 460 | 484 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) | 
| 461 | 485 |  		{ | 
| 462 | 486 | // If we want to overwrite simply remove the current one then continue. | 
| 463 | - if ($if_exists != 'update' || $index['type'] == 'primary') | |
| 464 | - return false; | |
| 465 | - else | |
| 466 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); | |
| 487 | +			if ($if_exists != 'update' || $index['type'] == 'primary') { | |
| 488 | + return false; | |
| 489 | +			} else { | |
| 490 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); | |
| 491 | + } | |
| 467 | 492 | } | 
| 468 | 493 | } | 
| 469 | 494 | |
| @@ -477,8 +502,7 @@ discard block | ||
| 477 | 502 | 'security_override' => true, | 
| 478 | 503 | ) | 
| 479 | 504 | ); | 
| 480 | - } | |
| 481 | - else | |
| 505 | + } else | |
| 482 | 506 |  	{ | 
| 483 | 507 |  		$smcFunc['db_query']('', ' | 
| 484 | 508 | ALTER TABLE ' . $table_name . ' | 
| @@ -562,8 +586,7 @@ discard block | ||
| 562 | 586 | $types = array( | 
| 563 | 587 | 'inet' => 'varbinary', | 
| 564 | 588 | ); | 
| 565 | - } | |
| 566 | - else | |
| 589 | + } else | |
| 567 | 590 |  	{ | 
| 568 | 591 | $types = array( | 
| 569 | 592 | 'varbinary' => 'inet', | 
| @@ -577,16 +600,15 @@ discard block | ||
| 577 | 600 |  		{ | 
| 578 | 601 | $type_size = 16; | 
| 579 | 602 | $type_name = 'varbinary'; | 
| 580 | - } | |
| 581 | - elseif ($type_name == 'varbinary' && $reverse && $type_size == 16) | |
| 603 | + } elseif ($type_name == 'varbinary' && $reverse && $type_size == 16) | |
| 582 | 604 |  		{ | 
| 583 | 605 | $type_name = 'inet'; | 
| 584 | 606 | $type_size = null; | 
| 607 | +		} elseif ($type_name == 'varbinary') { | |
| 608 | + $type_name = 'varbinary'; | |
| 609 | +		} else { | |
| 610 | + $type_name = $types[$type_name]; | |
| 585 | 611 | } | 
| 586 | - elseif ($type_name == 'varbinary') | |
| 587 | - $type_name = 'varbinary'; | |
| 588 | - else | |
| 589 | - $type_name = $types[$type_name]; | |
| 590 | 612 | } | 
| 591 | 613 | |
| 592 | 614 | return array($type_name, $type_size); | 
| @@ -653,8 +675,7 @@ discard block | ||
| 653 | 675 | if (!$detail) | 
| 654 | 676 |  		{ | 
| 655 | 677 | $columns[] = $row['Field']; | 
| 656 | - } | |
| 657 | - else | |
| 678 | + } else | |
| 658 | 679 |  		{ | 
| 659 | 680 | // Is there an auto_increment? | 
| 660 | 681 | $auto = strpos($row['Extra'], 'auto_increment') !== false ? true : false; | 
| @@ -664,10 +685,10 @@ discard block | ||
| 664 | 685 |  			{ | 
| 665 | 686 | $type = $matches[1]; | 
| 666 | 687 | $size = $matches[2]; | 
| 667 | - if (!empty($matches[3]) && $matches[3] == 'unsigned') | |
| 668 | - $unsigned = true; | |
| 669 | - } | |
| 670 | - else | |
| 688 | +				if (!empty($matches[3]) && $matches[3] == 'unsigned') { | |
| 689 | + $unsigned = true; | |
| 690 | + } | |
| 691 | + } else | |
| 671 | 692 |  			{ | 
| 672 | 693 | $type = $row['Type']; | 
| 673 | 694 | $size = null; | 
| @@ -718,19 +739,20 @@ discard block | ||
| 718 | 739 | $indexes = array(); | 
| 719 | 740 | while ($row = $smcFunc['db_fetch_assoc']($result)) | 
| 720 | 741 |  	{ | 
| 721 | - if (!$detail) | |
| 722 | - $indexes[] = $row['Key_name']; | |
| 723 | - else | |
| 742 | +		if (!$detail) { | |
| 743 | + $indexes[] = $row['Key_name']; | |
| 744 | + } else | |
| 724 | 745 |  		{ | 
| 725 | 746 | // What is the type? | 
| 726 | - if ($row['Key_name'] == 'PRIMARY') | |
| 727 | - $type = 'primary'; | |
| 728 | - elseif (empty($row['Non_unique'])) | |
| 729 | - $type = 'unique'; | |
| 730 | - elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') | |
| 731 | - $type = 'fulltext'; | |
| 732 | - else | |
| 733 | - $type = 'index'; | |
| 747 | +			if ($row['Key_name'] == 'PRIMARY') { | |
| 748 | + $type = 'primary'; | |
| 749 | +			} elseif (empty($row['Non_unique'])) { | |
| 750 | + $type = 'unique'; | |
| 751 | +			} elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') { | |
| 752 | + $type = 'fulltext'; | |
| 753 | +			} else { | |
| 754 | + $type = 'index'; | |
| 755 | + } | |
| 734 | 756 | |
| 735 | 757 | // This is the first column we've seen? | 
| 736 | 758 | if (empty($indexes[$row['Key_name']])) | 
| @@ -743,10 +765,11 @@ discard block | ||
| 743 | 765 | } | 
| 744 | 766 | |
| 745 | 767 | // Is it a partial index? | 
| 746 | - if (!empty($row['Sub_part'])) | |
| 747 | -				$indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')'; | |
| 748 | - else | |
| 749 | - $indexes[$row['Key_name']]['columns'][] = $row['Column_name']; | |
| 768 | +			if (!empty($row['Sub_part'])) { | |
| 769 | +							$indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')'; | |
| 770 | +			} else { | |
| 771 | + $indexes[$row['Key_name']]['columns'][] = $row['Column_name']; | |
| 772 | + } | |
| 750 | 773 | } | 
| 751 | 774 | } | 
| 752 | 775 | $smcFunc['db_free_result']($result); | 
| @@ -768,11 +791,11 @@ discard block | ||
| 768 | 791 | if (!empty($column['auto'])) | 
| 769 | 792 |  	{ | 
| 770 | 793 | $default = 'auto_increment'; | 
| 794 | +	} elseif (isset($column['default']) && $column['default'] !== null) { | |
| 795 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; | |
| 796 | +	} else { | |
| 797 | + $default = ''; | |
| 771 | 798 | } | 
| 772 | - elseif (isset($column['default']) && $column['default'] !== null) | |
| 773 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; | |
| 774 | - else | |
| 775 | - $default = ''; | |
| 776 | 799 | |
| 777 | 800 | // Sort out the size... and stuff... | 
| 778 | 801 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; | 
| @@ -781,8 +804,9 @@ discard block | ||
| 781 | 804 | // Allow unsigned integers (mysql only) | 
| 782 | 805 |  	$unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column['unsigned']) ? 'unsigned ' : ''; | 
| 783 | 806 | |
| 784 | - if ($size !== null) | |
| 785 | -		$type = $type . '(' . $size . ')'; | |
| 807 | +	if ($size !== null) { | |
| 808 | +			$type = $type . '(' . $size . ')'; | |
| 809 | + } | |
| 786 | 810 | |
| 787 | 811 | // Now just put it together! | 
| 788 | 812 | return '`' . $column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default; | 
| @@ -475,7 +475,7 @@ | ||
| 475 | 475 | * Used by fatal_error(), fatal_lang_error() | 
| 476 | 476 | * | 
| 477 | 477 | * @param string $error The error | 
| 478 | - * @param array $sprintf An array of data to be sprintf()'d into the specified message | |
| 478 | + * @param boolean $sprintf An array of data to be sprintf()'d into the specified message | |
| 479 | 479 | */ | 
| 480 | 480 | function log_error_online($error, $sprintf = array()) | 
| 481 | 481 |  { | 
| @@ -15,8 +15,9 @@ discard block | ||
| 15 | 15 | * @version 2.1 Beta 4 | 
| 16 | 16 | */ | 
| 17 | 17 | |
| 18 | -if (!defined('SMF')) | |
| 18 | +if (!defined('SMF')) { | |
| 19 | 19 |  	die('No direct access...'); | 
| 20 | +} | |
| 20 | 21 | |
| 21 | 22 | /** | 
| 22 | 23 | * Log an error, if the error logging is enabled. | 
| @@ -39,10 +40,11 @@ discard block | ||
| 39 | 40 | $error_call++; | 
| 40 | 41 | |
| 41 | 42 | // Collect a backtrace | 
| 42 | - if (!isset($db_show_debug) || $db_show_debug === false) | |
| 43 | - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | |
| 44 | - else | |
| 45 | - $backtrace = debug_backtrace(); | |
| 43 | +	if (!isset($db_show_debug) || $db_show_debug === false) { | |
| 44 | + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | |
| 45 | +	} else { | |
| 46 | + $backtrace = debug_backtrace(); | |
| 47 | + } | |
| 46 | 48 | |
| 47 | 49 | // are we in a loop? | 
| 48 | 50 | if($error_call > 2) | 
| @@ -52,8 +54,9 @@ discard block | ||
| 52 | 54 | } | 
| 53 | 55 | |
| 54 | 56 | // Check if error logging is actually on. | 
| 55 | - if (empty($modSettings['enableErrorLogging'])) | |
| 56 | - return $error_message; | |
| 57 | +	if (empty($modSettings['enableErrorLogging'])) { | |
| 58 | + return $error_message; | |
| 59 | + } | |
| 57 | 60 | |
| 58 | 61 | // Basically, htmlspecialchars it minus &. (for entities!) | 
| 59 | 62 |  	$error_message = strtr($error_message, array('<' => '<', '>' => '>', '"' => '"')); | 
| @@ -61,33 +64,39 @@ discard block | ||
| 61 | 64 | |
| 62 | 65 | // Add a file and line to the error message? | 
| 63 | 66 | // Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line | 
| 64 | - if ($file == null) | |
| 65 | - $file = ''; | |
| 66 | - else | |
| 67 | - // Window style slashes don't play well, lets convert them to the unix style. | |
| 67 | +	if ($file == null) { | |
| 68 | + $file = ''; | |
| 69 | +	} else { | |
| 70 | + // Window style slashes don't play well, lets convert them to the unix style. | |
| 68 | 71 |  		$file = str_replace('\\', '/', $file); | 
| 72 | + } | |
| 69 | 73 | |
| 70 | - if ($line == null) | |
| 71 | - $line = 0; | |
| 72 | - else | |
| 73 | - $line = (int) $line; | |
| 74 | +	if ($line == null) { | |
| 75 | + $line = 0; | |
| 76 | +	} else { | |
| 77 | + $line = (int) $line; | |
| 78 | + } | |
| 74 | 79 | |
| 75 | 80 | // Just in case there's no id_member or IP set yet. | 
| 76 | - if (empty($user_info['id'])) | |
| 77 | - $user_info['id'] = 0; | |
| 78 | - if (empty($user_info['ip'])) | |
| 79 | - $user_info['ip'] = ''; | |
| 81 | +	if (empty($user_info['id'])) { | |
| 82 | + $user_info['id'] = 0; | |
| 83 | + } | |
| 84 | +	if (empty($user_info['ip'])) { | |
| 85 | + $user_info['ip'] = ''; | |
| 86 | + } | |
| 80 | 87 | |
| 81 | 88 | // Find the best query string we can... | 
| 82 | 89 | $query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING']; | 
| 83 | 90 | |
| 84 | 91 | // Don't log the session hash in the url twice, it's a waste. | 
| 85 | - if (!empty($smcFunc['htmlspecialchars'])) | |
| 86 | -		$query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); | |
| 92 | +	if (!empty($smcFunc['htmlspecialchars'])) { | |
| 93 | +			$query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); | |
| 94 | + } | |
| 87 | 95 | |
| 88 | 96 | // Just so we know what board error messages are from. | 
| 89 | - if (isset($_POST['board']) && !isset($_GET['board'])) | |
| 90 | - $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; | |
| 97 | +	if (isset($_POST['board']) && !isset($_GET['board'])) { | |
| 98 | + $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; | |
| 99 | + } | |
| 91 | 100 | |
| 92 | 101 | // What types of categories do we have? | 
| 93 | 102 | $known_error_types = array( | 
| @@ -140,9 +149,9 @@ discard block | ||
| 140 | 149 | |
| 141 | 150 | list($context['num_errors']) = $smcFunc['db_fetch_row']($query); | 
| 142 | 151 | $smcFunc['db_free_result']($query); | 
| 152 | +		} else { | |
| 153 | + $context['num_errors']++; | |
| 143 | 154 | } | 
| 144 | - else | |
| 145 | - $context['num_errors']++; | |
| 146 | 155 | } | 
| 147 | 156 | |
| 148 | 157 | // reset error call | 
| @@ -164,12 +173,14 @@ discard block | ||
| 164 | 173 | global $txt; | 
| 165 | 174 | |
| 166 | 175 | // Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all | 
| 167 | - if (!empty($status)) | |
| 168 | - send_http_status($status); | |
| 176 | +	if (!empty($status)) { | |
| 177 | + send_http_status($status); | |
| 178 | + } | |
| 169 | 179 | |
| 170 | 180 | // We don't have $txt yet, but that's okay... | 
| 171 | - if (empty($txt)) | |
| 172 | - die($error); | |
| 181 | +	if (empty($txt)) { | |
| 182 | + die($error); | |
| 183 | + } | |
| 173 | 184 | |
| 174 | 185 | log_error_online($error, false); | 
| 175 | 186 | setup_fatal_error_context($log ? log_error($error, $log) : $error); | 
| @@ -196,8 +207,9 @@ discard block | ||
| 196 | 207 | static $fatal_error_called = false; | 
| 197 | 208 | |
| 198 | 209 | // Send the status header - set this to 0 or false if you don't want to send one at all | 
| 199 | - if (!empty($status)) | |
| 200 | - send_http_status($status); | |
| 210 | +	if (!empty($status)) { | |
| 211 | + send_http_status($status); | |
| 212 | + } | |
| 201 | 213 | |
| 202 | 214 | // Try to load a theme if we don't have one. | 
| 203 | 215 | if (empty($context['theme_loaded']) && empty($fatal_error_called)) | 
| @@ -207,8 +219,9 @@ discard block | ||
| 207 | 219 | } | 
| 208 | 220 | |
| 209 | 221 | // If we have no theme stuff we can't have the language file... | 
| 210 | - if (empty($context['theme_loaded'])) | |
| 211 | - die($error); | |
| 222 | +	if (empty($context['theme_loaded'])) { | |
| 223 | + die($error); | |
| 224 | + } | |
| 212 | 225 | |
| 213 | 226 | $reload_lang_file = true; | 
| 214 | 227 | // Log the error in the forum's language, but don't waste the time if we aren't logging | 
| @@ -244,8 +257,9 @@ discard block | ||
| 244 | 257 | global $settings, $modSettings, $db_show_debug; | 
| 245 | 258 | |
| 246 | 259 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 | 
| 247 | - if (error_reporting() == 0) | |
| 248 | - return; | |
| 260 | +	if (error_reporting() == 0) { | |
| 261 | + return; | |
| 262 | + } | |
| 249 | 263 | |
| 250 | 264 | if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename'])) | 
| 251 | 265 |  	{ | 
| @@ -253,19 +267,22 @@ discard block | ||
| 253 | 267 | $count = count($array); | 
| 254 | 268 | for ($i = 0; $i < $count; $i++) | 
| 255 | 269 |  		{ | 
| 256 | - if ($array[$i]['function'] != 'loadSubTemplate') | |
| 257 | - continue; | |
| 270 | +			if ($array[$i]['function'] != 'loadSubTemplate') { | |
| 271 | + continue; | |
| 272 | + } | |
| 258 | 273 | |
| 259 | 274 | // This is a bug in PHP, with eval, it seems! | 
| 260 | - if (empty($array[$i]['args'])) | |
| 261 | - $i++; | |
| 275 | +			if (empty($array[$i]['args'])) { | |
| 276 | + $i++; | |
| 277 | + } | |
| 262 | 278 | break; | 
| 263 | 279 | } | 
| 264 | 280 | |
| 265 | - if (isset($array[$i]) && !empty($array[$i]['args'])) | |
| 266 | -			$file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; | |
| 267 | - else | |
| 268 | - $file = realpath($settings['current_include_filename']) . ' (eval?)'; | |
| 281 | +		if (isset($array[$i]) && !empty($array[$i]['args'])) { | |
| 282 | +					$file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; | |
| 283 | +		} else { | |
| 284 | + $file = realpath($settings['current_include_filename']) . ' (eval?)'; | |
| 285 | + } | |
| 269 | 286 | } | 
| 270 | 287 | |
| 271 | 288 | if (isset($db_show_debug) && $db_show_debug === true) | 
| @@ -274,8 +291,9 @@ discard block | ||
| 274 | 291 | if ($error_level % 255 != E_ERROR) | 
| 275 | 292 |  		{ | 
| 276 | 293 | $temporary = ob_get_contents(); | 
| 277 | - if (substr($temporary, -2) == '="') | |
| 278 | - echo '"'; | |
| 294 | +			if (substr($temporary, -2) == '="') { | |
| 295 | + echo '"'; | |
| 296 | + } | |
| 279 | 297 | } | 
| 280 | 298 | |
| 281 | 299 | // Debugging! This should look like a PHP error message. | 
| @@ -291,23 +309,27 @@ discard block | ||
| 291 | 309 |  	call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); | 
| 292 | 310 | |
| 293 | 311 | // Dying on these errors only causes MORE problems (blank pages!) | 
| 294 | - if ($file == 'Unknown') | |
| 295 | - return; | |
| 312 | +	if ($file == 'Unknown') { | |
| 313 | + return; | |
| 314 | + } | |
| 296 | 315 | |
| 297 | 316 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. | 
| 298 | - if ($error_level % 255 == E_ERROR) | |
| 299 | - obExit(false); | |
| 300 | - else | |
| 301 | - return; | |
| 317 | +	if ($error_level % 255 == E_ERROR) { | |
| 318 | + obExit(false); | |
| 319 | +	} else { | |
| 320 | + return; | |
| 321 | + } | |
| 302 | 322 | |
| 303 | 323 | // If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die. Violently so. | 
| 304 | - if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) | |
| 305 | -		fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); | |
| 324 | +	if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) { | |
| 325 | +			fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); | |
| 326 | + } | |
| 306 | 327 | |
| 307 | 328 | // We should NEVER get to this point. Any fatal error MUST quit, or very bad things can happen. | 
| 308 | - if ($error_level % 255 == E_ERROR) | |
| 309 | -		die('No direct access...'); | |
| 310 | -} | |
| 329 | +	if ($error_level % 255 == E_ERROR) { | |
| 330 | +			die('No direct access...'); | |
| 331 | + } | |
| 332 | + } | |
| 311 | 333 | |
| 312 | 334 | /** | 
| 313 | 335 |   * It is called by {@link fatal_error()} and {@link fatal_lang_error()}. | 
| @@ -323,24 +345,28 @@ discard block | ||
| 323 | 345 | |
| 324 | 346 | // Attempt to prevent a recursive loop. | 
| 325 | 347 | ++$level; | 
| 326 | - if ($level > 1) | |
| 327 | - return false; | |
| 348 | +	if ($level > 1) { | |
| 349 | + return false; | |
| 350 | + } | |
| 328 | 351 | |
| 329 | 352 | // Maybe they came from dlattach or similar? | 
| 330 | - if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) | |
| 331 | - loadTheme(); | |
| 353 | +	if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) { | |
| 354 | + loadTheme(); | |
| 355 | + } | |
| 332 | 356 | |
| 333 | 357 | // Don't bother indexing errors mate... | 
| 334 | 358 | $context['robot_no_index'] = true; | 
| 335 | 359 | |
| 336 | - if (!isset($context['error_title'])) | |
| 337 | - $context['error_title'] = $txt['error_occured']; | |
| 360 | +	if (!isset($context['error_title'])) { | |
| 361 | + $context['error_title'] = $txt['error_occured']; | |
| 362 | + } | |
| 338 | 363 | $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message; | 
| 339 | 364 | |
| 340 | 365 | $context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : ''; | 
| 341 | 366 | |
| 342 | - if (empty($context['page_title'])) | |
| 343 | - $context['page_title'] = $context['error_title']; | |
| 367 | +	if (empty($context['page_title'])) { | |
| 368 | + $context['page_title'] = $context['error_title']; | |
| 369 | + } | |
| 344 | 370 | |
| 345 | 371 |  	loadTemplate('Errors'); | 
| 346 | 372 | $context['sub_template'] = 'fatal_error'; | 
| @@ -348,23 +374,26 @@ discard block | ||
| 348 | 374 | // If this is SSI, what do they want us to do? | 
| 349 | 375 | if (SMF == 'SSI') | 
| 350 | 376 |  	{ | 
| 351 | - if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) | |
| 352 | - $ssi_on_error_method(); | |
| 353 | - elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) | |
| 354 | -			loadSubTemplate('fatal_error'); | |
| 377 | +		if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) { | |
| 378 | + $ssi_on_error_method(); | |
| 379 | +		} elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { | |
| 380 | +					loadSubTemplate('fatal_error'); | |
| 381 | + } | |
| 355 | 382 | |
| 356 | 383 | // No layers? | 
| 357 | - if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) | |
| 358 | - exit; | |
| 384 | +		if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { | |
| 385 | + exit; | |
| 386 | + } | |
| 359 | 387 | } | 
| 360 | 388 | // Alternatively from the cron call? | 
| 361 | 389 | elseif (SMF == 'BACKGROUND') | 
| 362 | 390 |  	{ | 
| 363 | 391 | // We can't rely on even having language files available. | 
| 364 | -		if (defined('FROM_CLI') && FROM_CLI) | |
| 365 | - echo 'cron error: ', $context['error_message']; | |
| 366 | - else | |
| 367 | - echo 'An error occurred. More information may be available in your logs.'; | |
| 392 | +		if (defined('FROM_CLI') && FROM_CLI) { | |
| 393 | + echo 'cron error: ', $context['error_message']; | |
| 394 | +		} else { | |
| 395 | + echo 'An error occurred. More information may be available in your logs.'; | |
| 396 | + } | |
| 368 | 397 | exit; | 
| 369 | 398 | } | 
| 370 | 399 | |
| @@ -392,8 +421,8 @@ discard block | ||
| 392 | 421 | |
| 393 | 422 | set_fatal_error_headers(); | 
| 394 | 423 | |
| 395 | - if (!empty($maintenance)) | |
| 396 | - echo '<!DOCTYPE html> | |
| 424 | +	if (!empty($maintenance)) { | |
| 425 | + echo '<!DOCTYPE html> | |
| 397 | 426 | <html> | 
| 398 | 427 | <head> | 
| 399 | 428 | <meta name="robots" content="noindex"> | 
| @@ -404,6 +433,7 @@ discard block | ||
| 404 | 433 | ', $mmessage, ' | 
| 405 | 434 | </body> | 
| 406 | 435 | </html>'; | 
| 436 | + } | |
| 407 | 437 | |
| 408 | 438 | die(); | 
| 409 | 439 | } | 
| @@ -425,15 +455,17 @@ discard block | ||
| 425 | 455 | // For our purposes, we're gonna want this on if at all possible. | 
| 426 | 456 | $modSettings['cache_enable'] = '1'; | 
| 427 | 457 | |
| 428 | -	if (($temp = cache_get_data('db_last_error', 600)) !== null) | |
| 429 | - $db_last_error = max($db_last_error, $temp); | |
| 458 | +	if (($temp = cache_get_data('db_last_error', 600)) !== null) { | |
| 459 | + $db_last_error = max($db_last_error, $temp); | |
| 460 | + } | |
| 430 | 461 | |
| 431 | 462 | if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) | 
| 432 | 463 |  	{ | 
| 433 | 464 | // Avoid writing to the Settings.php file if at all possible; use shared memory instead. | 
| 434 | 465 |  		cache_put_data('db_last_error', time(), 600); | 
| 435 | -		if (($temp = cache_get_data('db_last_error', 600)) === null) | |
| 436 | - logLastDatabaseError(); | |
| 466 | +		if (($temp = cache_get_data('db_last_error', 600)) === null) { | |
| 467 | + logLastDatabaseError(); | |
| 468 | + } | |
| 437 | 469 | |
| 438 | 470 | // Language files aren't loaded yet :(. | 
| 439 | 471 | $db_error = @$smcFunc['db_error']($db_connection); | 
| @@ -490,8 +522,9 @@ discard block | ||
| 490 | 522 | */ | 
| 491 | 523 | function set_fatal_error_headers() | 
| 492 | 524 |  { | 
| 493 | - if (headers_sent()) | |
| 494 | - return; | |
| 525 | +	if (headers_sent()) { | |
| 526 | + return; | |
| 527 | + } | |
| 495 | 528 | |
| 496 | 529 | // Don't cache this page! | 
| 497 | 530 |  	header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); | 
| @@ -517,12 +550,14 @@ discard block | ||
| 517 | 550 | global $smcFunc, $user_info, $modSettings; | 
| 518 | 551 | |
| 519 | 552 | // Don't bother if Who's Online is disabled. | 
| 520 | - if (empty($modSettings['who_enabled'])) | |
| 521 | - return; | |
| 553 | +	if (empty($modSettings['who_enabled'])) { | |
| 554 | + return; | |
| 555 | + } | |
| 522 | 556 | |
| 523 | 557 | // Maybe they came from SSI or similar where sessions are not recorded? | 
| 524 | - if (SMF == 'SSI' || SMF == 'BACKGROUND') | |
| 525 | - return; | |
| 558 | +	if (SMF == 'SSI' || SMF == 'BACKGROUND') { | |
| 559 | + return; | |
| 560 | + } | |
| 526 | 561 | |
| 527 | 562 | $session_id = !empty($user_info['is_guest']) ? 'ip' . $user_info['ip'] : session_id(); | 
| 528 | 563 | |
| @@ -548,11 +583,13 @@ discard block | ||
| 548 | 583 | $url = $smcFunc['json_decode']($url, true); | 
| 549 | 584 | $url['error'] = $error; | 
| 550 | 585 | // Url field got a max length of 1024 in db | 
| 551 | - if (strlen($url['error']) > 500) | |
| 552 | - $url['error'] = substr($url['error'],0,500); | |
| 586 | +		if (strlen($url['error']) > 500) { | |
| 587 | + $url['error'] = substr($url['error'],0,500); | |
| 588 | + } | |
| 553 | 589 | |
| 554 | - if (!empty($sprintf)) | |
| 555 | - $url['error_params'] = $sprintf; | |
| 590 | +		if (!empty($sprintf)) { | |
| 591 | + $url['error_params'] = $sprintf; | |
| 592 | + } | |
| 556 | 593 | |
| 557 | 594 |  		$smcFunc['db_query']('', ' | 
| 558 | 595 |  			UPDATE {db_prefix}log_online | 
| @@ -583,10 +620,11 @@ discard block | ||
| 583 | 620 | |
| 584 | 621 |  	$protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; | 
| 585 | 622 | |
| 586 | - if (!isset($statuses[$code])) | |
| 587 | - header($protocol . ' 500 Internal Server Error'); | |
| 588 | - else | |
| 589 | - header($protocol . ' ' . $code . ' ' . $statuses[$code]); | |
| 590 | -} | |
| 623 | +	if (!isset($statuses[$code])) { | |
| 624 | + header($protocol . ' 500 Internal Server Error'); | |
| 625 | +	} else { | |
| 626 | + header($protocol . ' ' . $code . ' ' . $statuses[$code]); | |
| 627 | + } | |
| 628 | + } | |
| 591 | 629 | |
| 592 | 630 | ?> | 
| 593 | 631 | \ No newline at end of file | 
| @@ -929,7 +929,7 @@ discard block | ||
| 929 | 929 | * Doesn't clean the inputs | 
| 930 | 930 | * | 
| 931 | 931 | * @param array $items_ids The items to remove | 
| 932 | - * @param bool|int $group_id The ID of the group these triggers are associated with or false if deleting them from all groups | |
| 932 | + * @param integer $group_id The ID of the group these triggers are associated with or false if deleting them from all groups | |
| 933 | 933 | * @return bool Always returns true | 
| 934 | 934 | */ | 
| 935 | 935 | function removeBanTriggers($items_ids = array(), $group_id = false) | 
| @@ -1123,7 +1123,7 @@ discard block | ||
| 1123 | 1123 | * Errors in $context['ban_errors'] | 
| 1124 | 1124 | * | 
| 1125 | 1125 | * @param array $triggers The triggers to validate | 
| 1126 | - * @return array An array of riggers and log info ready to be used | |
| 1126 | + * @return integer An array of riggers and log info ready to be used | |
| 1127 | 1127 | */ | 
| 1128 | 1128 | function validateTriggers(&$triggers) | 
| 1129 | 1129 |  { | 
| @@ -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( | 
| @@ -320,8 +325,9 @@ discard block | ||
| 320 | 325 | ) | 
| 321 | 326 | ); | 
| 322 | 327 | $bans = array(); | 
| 323 | - while ($row = $smcFunc['db_fetch_assoc']($request)) | |
| 324 | - $bans[] = $row; | |
| 328 | +	while ($row = $smcFunc['db_fetch_assoc']($request)) { | |
| 329 | + $bans[] = $row; | |
| 330 | + } | |
| 325 | 331 | |
| 326 | 332 | $smcFunc['db_free_result']($request); | 
| 327 | 333 | |
| @@ -363,8 +369,9 @@ discard block | ||
| 363 | 369 |  { | 
| 364 | 370 | global $txt, $modSettings, $context, $scripturl, $smcFunc, $sourcedir; | 
| 365 | 371 | |
| 366 | - if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) | |
| 367 | - BanEdit2(); | |
| 372 | +	if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) { | |
| 373 | + BanEdit2(); | |
| 374 | + } | |
| 368 | 375 | |
| 369 | 376 | $ban_group_id = isset($context['ban']['id']) ? $context['ban']['id'] : (isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0); | 
| 370 | 377 | |
| @@ -373,11 +380,10 @@ discard block | ||
| 373 | 380 |  	createToken('admin-bet'); | 
| 374 | 381 | $context['form_url'] = $scripturl . '?action=admin;area=ban;sa=edit'; | 
| 375 | 382 | |
| 376 | - if (!empty($context['ban_errors'])) | |
| 377 | - foreach ($context['ban_errors'] as $error) | |
| 383 | +	if (!empty($context['ban_errors'])) { | |
| 384 | + foreach ($context['ban_errors'] as $error) | |
| 378 | 385 | $context['error_messages'][$error] = $txt[$error]; | 
| 379 | - | |
| 380 | - else | |
| 386 | + } else | |
| 381 | 387 |  	{ | 
| 382 | 388 | // If we're editing an existing ban, get it from the database. | 
| 383 | 389 | if (!empty($ban_group_id)) | 
| @@ -413,12 +419,13 @@ discard block | ||
| 413 | 419 | 'data' => array( | 
| 414 | 420 | 'function' => function($ban_item) use ($txt) | 
| 415 | 421 |  							{ | 
| 416 | -								if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) | |
| 417 | - return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; | |
| 418 | - elseif ($ban_item['type'] == 'user') | |
| 419 | - return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; | |
| 420 | - else | |
| 421 | - return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; | |
| 422 | +								if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) { | |
| 423 | + return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; | |
| 424 | +								} elseif ($ban_item['type'] == 'user') { | |
| 425 | + return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; | |
| 426 | +								} else { | |
| 427 | + return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; | |
| 428 | + } | |
| 422 | 429 | }, | 
| 423 | 430 | 'style' => 'text-align: left;', | 
| 424 | 431 | ), | 
| @@ -556,8 +563,9 @@ discard block | ||
| 556 | 563 | $context['ban']['from_user'] = true; | 
| 557 | 564 | |
| 558 | 565 | // Would be nice if we could also ban the hostname. | 
| 559 | -					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'])) | |
| 560 | - $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); | |
| 566 | +					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'])) { | |
| 567 | + $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); | |
| 568 | + } | |
| 561 | 569 | |
| 562 | 570 | $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); | 
| 563 | 571 | } | 
| @@ -625,8 +633,9 @@ discard block | ||
| 625 | 633 | 'items_per_page' => $items_per_page, | 
| 626 | 634 | ) | 
| 627 | 635 | ); | 
| 628 | - if ($smcFunc['db_num_rows']($request) == 0) | |
| 629 | -		fatal_lang_error('ban_not_found', false); | |
| 636 | +	if ($smcFunc['db_num_rows']($request) == 0) { | |
| 637 | +			fatal_lang_error('ban_not_found', false); | |
| 638 | + } | |
| 630 | 639 | |
| 631 | 640 | while ($row = $smcFunc['db_fetch_assoc']($request)) | 
| 632 | 641 |  	{ | 
| @@ -663,18 +672,15 @@ discard block | ||
| 663 | 672 |  			{ | 
| 664 | 673 | $ban_items[$row['id_ban']]['type'] = 'ip'; | 
| 665 | 674 | $ban_items[$row['id_ban']]['ip'] = range2ip($row['ip_low'], $row['ip_high']); | 
| 666 | - } | |
| 667 | - elseif (!empty($row['hostname'])) | |
| 675 | + } elseif (!empty($row['hostname'])) | |
| 668 | 676 |  			{ | 
| 669 | 677 | $ban_items[$row['id_ban']]['type'] = 'hostname'; | 
| 670 | 678 |  				$ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); | 
| 671 | - } | |
| 672 | - elseif (!empty($row['email_address'])) | |
| 679 | + } elseif (!empty($row['email_address'])) | |
| 673 | 680 |  			{ | 
| 674 | 681 | $ban_items[$row['id_ban']]['type'] = 'email'; | 
| 675 | 682 |  				$ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); | 
| 676 | - } | |
| 677 | - elseif (!empty($row['id_member'])) | |
| 683 | + } elseif (!empty($row['id_member'])) | |
| 678 | 684 |  			{ | 
| 679 | 685 | $ban_items[$row['id_ban']]['type'] = 'user'; | 
| 680 | 686 | $ban_items[$row['id_ban']]['user'] = array( | 
| @@ -740,9 +746,10 @@ discard block | ||
| 740 | 746 |  	$search_list += array('ips_in_messages' => 'banLoadAdditionalIPsMember', 'ips_in_errors' => 'banLoadAdditionalIPsError'); | 
| 741 | 747 | |
| 742 | 748 | $return = array(); | 
| 743 | - foreach ($search_list as $key => $callable) | |
| 744 | - if (is_callable($callable)) | |
| 749 | +	foreach ($search_list as $key => $callable) { | |
| 750 | + if (is_callable($callable)) | |
| 745 | 751 | $return[$key] = call_user_func($callable, $member_id); | 
| 752 | + } | |
| 746 | 753 | |
| 747 | 754 | return $return; | 
| 748 | 755 | } | 
| @@ -767,8 +774,9 @@ discard block | ||
| 767 | 774 | 'current_user' => $member_id, | 
| 768 | 775 | ) | 
| 769 | 776 | ); | 
| 770 | - while ($row = $smcFunc['db_fetch_assoc']($request)) | |
| 771 | - $message_ips[] = inet_dtop($row['poster_ip']); | |
| 777 | +	while ($row = $smcFunc['db_fetch_assoc']($request)) { | |
| 778 | + $message_ips[] = inet_dtop($row['poster_ip']); | |
| 779 | + } | |
| 772 | 780 | $smcFunc['db_free_result']($request); | 
| 773 | 781 | |
| 774 | 782 | return $message_ips; | 
| @@ -793,8 +801,9 @@ discard block | ||
| 793 | 801 | 'current_user' => $member_id, | 
| 794 | 802 | ) | 
| 795 | 803 | ); | 
| 796 | - while ($row = $smcFunc['db_fetch_assoc']($request)) | |
| 797 | - $error_ips[] = inet_dtop($row['ip']); | |
| 804 | +	while ($row = $smcFunc['db_fetch_assoc']($request)) { | |
| 805 | + $error_ips[] = inet_dtop($row['ip']); | |
| 806 | + } | |
| 798 | 807 | $smcFunc['db_free_result']($request); | 
| 799 | 808 | |
| 800 | 809 | return $error_ips; | 
| @@ -835,11 +844,13 @@ discard block | ||
| 835 | 844 | $ban_info['cannot']['login'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_login']) ? 0 : 1; | 
| 836 | 845 | |
| 837 | 846 | // Adding a new ban group | 
| 838 | - if (empty($_REQUEST['bg'])) | |
| 839 | - $ban_group_id = insertBanGroup($ban_info); | |
| 847 | +		if (empty($_REQUEST['bg'])) { | |
| 848 | + $ban_group_id = insertBanGroup($ban_info); | |
| 849 | + } | |
| 840 | 850 | // Editing an existing ban group | 
| 841 | - else | |
| 842 | - $ban_group_id = updateBanGroup($ban_info); | |
| 851 | +		else { | |
| 852 | + $ban_group_id = updateBanGroup($ban_info); | |
| 853 | + } | |
| 843 | 854 | |
| 844 | 855 | if (is_numeric($ban_group_id)) | 
| 845 | 856 |  		{ | 
| @@ -850,9 +861,10 @@ discard block | ||
| 850 | 861 | $context['ban'] = $ban_info; | 
| 851 | 862 | } | 
| 852 | 863 | |
| 853 | - if (isset($_POST['ban_suggestions'])) | |
| 854 | - // @TODO: is $_REQUEST['bi'] ever set? | |
| 864 | +	if (isset($_POST['ban_suggestions'])) { | |
| 865 | + // @TODO: is $_REQUEST['bi'] ever set? | |
| 855 | 866 | $saved_triggers = saveTriggers($_POST['ban_suggestions'], $ban_info['id'], isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : 0, isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0); | 
| 867 | + } | |
| 856 | 868 | |
| 857 | 869 | // Something went wrong somewhere... Oh well, let's go back. | 
| 858 | 870 | if (!empty($context['ban_errors'])) | 
| @@ -862,8 +874,9 @@ discard block | ||
| 862 | 874 | $context['ban_suggestions'] = array_merge($context['ban_suggestions'], getMemberData((int) $_REQUEST['u'])); | 
| 863 | 875 | |
| 864 | 876 | // Not strictly necessary, but it's nice | 
| 865 | - if (!empty($context['ban_suggestions']['member']['id'])) | |
| 866 | - $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); | |
| 877 | +		if (!empty($context['ban_suggestions']['member']['id'])) { | |
| 878 | + $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); | |
| 879 | + } | |
| 867 | 880 | return BanEdit(); | 
| 868 | 881 | } | 
| 869 | 882 | $context['ban_suggestions']['saved_triggers'] = !empty($saved_triggers) ? $saved_triggers : array(); | 
| @@ -910,10 +923,11 @@ discard block | ||
| 910 | 923 | |
| 911 | 924 | foreach ($suggestions as $key => $value) | 
| 912 | 925 |  	{ | 
| 913 | - if (is_array($value)) | |
| 914 | - $triggers[$key] = $value; | |
| 915 | - else | |
| 916 | - $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; | |
| 926 | +		if (is_array($value)) { | |
| 927 | + $triggers[$key] = $value; | |
| 928 | +		} else { | |
| 929 | + $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; | |
| 930 | + } | |
| 917 | 931 | } | 
| 918 | 932 | |
| 919 | 933 | $ban_triggers = validateTriggers($triggers); | 
| @@ -921,16 +935,18 @@ discard block | ||
| 921 | 935 | // Time to save! | 
| 922 | 936 | if (!empty($ban_triggers['ban_triggers']) && empty($context['ban_errors'])) | 
| 923 | 937 |  	{ | 
| 924 | - if (empty($ban_id)) | |
| 925 | - addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); | |
| 926 | - else | |
| 927 | - updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); | |
| 938 | +		if (empty($ban_id)) { | |
| 939 | + addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); | |
| 940 | +		} else { | |
| 941 | + updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); | |
| 942 | + } | |
| 943 | + } | |
| 944 | +	if (!empty($context['ban_errors'])) { | |
| 945 | + return $triggers; | |
| 946 | +	} else { | |
| 947 | + return false; | |
| 948 | + } | |
| 928 | 949 | } | 
| 929 | - if (!empty($context['ban_errors'])) | |
| 930 | - return $triggers; | |
| 931 | - else | |
| 932 | - return false; | |
| 933 | -} | |
| 934 | 950 | |
| 935 | 951 | /** | 
| 936 | 952 | * This function removes a bunch of triggers based on ids | 
| @@ -944,14 +960,17 @@ discard block | ||
| 944 | 960 |  { | 
| 945 | 961 | global $smcFunc, $scripturl; | 
| 946 | 962 | |
| 947 | - if ($group_id !== false) | |
| 948 | - $group_id = (int) $group_id; | |
| 963 | +	if ($group_id !== false) { | |
| 964 | + $group_id = (int) $group_id; | |
| 965 | + } | |
| 949 | 966 | |
| 950 | - if (empty($group_id) && empty($items_ids)) | |
| 951 | - return false; | |
| 967 | +	if (empty($group_id) && empty($items_ids)) { | |
| 968 | + return false; | |
| 969 | + } | |
| 952 | 970 | |
| 953 | - if (!is_array($items_ids)) | |
| 954 | - $items_ids = array($items_ids); | |
| 971 | +	if (!is_array($items_ids)) { | |
| 972 | + $items_ids = array($items_ids); | |
| 973 | + } | |
| 955 | 974 | |
| 956 | 975 | $log_info = array(); | 
| 957 | 976 | $ban_items = array(); | 
| @@ -989,8 +1008,7 @@ discard block | ||
| 989 | 1008 | 'bantype' => ($is_range ? 'ip_range' : 'main_ip'), | 
| 990 | 1009 | 'value' => $ban_items[$row['id_ban']]['ip'], | 
| 991 | 1010 | ); | 
| 992 | - } | |
| 993 | - elseif (!empty($row['hostname'])) | |
| 1011 | + } elseif (!empty($row['hostname'])) | |
| 994 | 1012 |  			{ | 
| 995 | 1013 | $ban_items[$row['id_ban']]['type'] = 'hostname'; | 
| 996 | 1014 |  				$ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); | 
| @@ -998,8 +1016,7 @@ discard block | ||
| 998 | 1016 | 'bantype' => 'hostname', | 
| 999 | 1017 | 'value' => $row['hostname'], | 
| 1000 | 1018 | ); | 
| 1001 | - } | |
| 1002 | - elseif (!empty($row['email_address'])) | |
| 1019 | + } elseif (!empty($row['email_address'])) | |
| 1003 | 1020 |  			{ | 
| 1004 | 1021 | $ban_items[$row['id_ban']]['type'] = 'email'; | 
| 1005 | 1022 |  				$ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); | 
| @@ -1007,8 +1024,7 @@ discard block | ||
| 1007 | 1024 | 'bantype' => 'email', | 
| 1008 | 1025 | 'value' => $ban_items[$row['id_ban']]['email'], | 
| 1009 | 1026 | ); | 
| 1010 | - } | |
| 1011 | - elseif (!empty($row['id_member'])) | |
| 1027 | + } elseif (!empty($row['id_member'])) | |
| 1012 | 1028 |  			{ | 
| 1013 | 1029 | $ban_items[$row['id_ban']]['type'] = 'user'; | 
| 1014 | 1030 | $ban_items[$row['id_ban']]['user'] = array( | 
| @@ -1041,8 +1057,7 @@ discard block | ||
| 1041 | 1057 | 'ban_group' => $group_id, | 
| 1042 | 1058 | ) | 
| 1043 | 1059 | ); | 
| 1044 | - } | |
| 1045 | - elseif (!empty($items_ids)) | |
| 1060 | + } elseif (!empty($items_ids)) | |
| 1046 | 1061 |  	{ | 
| 1047 | 1062 |  		$smcFunc['db_query']('', ' | 
| 1048 | 1063 |  			DELETE FROM {db_prefix}ban_items | 
| @@ -1067,13 +1082,15 @@ discard block | ||
| 1067 | 1082 |  { | 
| 1068 | 1083 | global $smcFunc; | 
| 1069 | 1084 | |
| 1070 | - if (!is_array($group_ids)) | |
| 1071 | - $group_ids = array($group_ids); | |
| 1085 | +	if (!is_array($group_ids)) { | |
| 1086 | + $group_ids = array($group_ids); | |
| 1087 | + } | |
| 1072 | 1088 | |
| 1073 | 1089 | $group_ids = array_unique($group_ids); | 
| 1074 | 1090 | |
| 1075 | - if (empty($group_ids)) | |
| 1076 | - return false; | |
| 1091 | +	if (empty($group_ids)) { | |
| 1092 | + return false; | |
| 1093 | + } | |
| 1077 | 1094 | |
| 1078 | 1095 |  	$smcFunc['db_query']('', ' | 
| 1079 | 1096 |  		DELETE FROM {db_prefix}ban_groups | 
| @@ -1097,21 +1114,23 @@ discard block | ||
| 1097 | 1114 |  { | 
| 1098 | 1115 | global $smcFunc; | 
| 1099 | 1116 | |
| 1100 | - if (empty($ids)) | |
| 1101 | -		$smcFunc['db_query']('truncate_table', ' | |
| 1117 | +	if (empty($ids)) { | |
| 1118 | +			$smcFunc['db_query']('truncate_table', ' | |
| 1102 | 1119 |  			TRUNCATE {db_prefix}log_banned', | 
| 1103 | 1120 | array( | 
| 1104 | 1121 | ) | 
| 1105 | 1122 | ); | 
| 1106 | - else | |
| 1123 | + } else | |
| 1107 | 1124 |  	{ | 
| 1108 | - if (!is_array($ids)) | |
| 1109 | - $ids = array($ids); | |
| 1125 | +		if (!is_array($ids)) { | |
| 1126 | + $ids = array($ids); | |
| 1127 | + } | |
| 1110 | 1128 | |
| 1111 | 1129 | $ids = array_unique($ids); | 
| 1112 | 1130 | |
| 1113 | - if (empty($ids)) | |
| 1114 | - return false; | |
| 1131 | +		if (empty($ids)) { | |
| 1132 | + return false; | |
| 1133 | + } | |
| 1115 | 1134 | |
| 1116 | 1135 |  		$smcFunc['db_query']('', ' | 
| 1117 | 1136 |  			DELETE FROM {db_prefix}log_banned | 
| @@ -1137,8 +1156,9 @@ discard block | ||
| 1137 | 1156 |  { | 
| 1138 | 1157 | global $context, $smcFunc; | 
| 1139 | 1158 | |
| 1140 | - if (empty($triggers)) | |
| 1141 | - $context['ban_erros'][] = 'ban_empty_triggers'; | |
| 1159 | +	if (empty($triggers)) { | |
| 1160 | + $context['ban_erros'][] = 'ban_empty_triggers'; | |
| 1161 | + } | |
| 1142 | 1162 | |
| 1143 | 1163 | $ban_triggers = array(); | 
| 1144 | 1164 | $log_info = array(); | 
| @@ -1147,39 +1167,39 @@ discard block | ||
| 1147 | 1167 |  	{ | 
| 1148 | 1168 | if (!empty($value)) | 
| 1149 | 1169 |  		{ | 
| 1150 | - if ($key == 'member') | |
| 1151 | - continue; | |
| 1170 | +			if ($key == 'member') { | |
| 1171 | + continue; | |
| 1172 | + } | |
| 1152 | 1173 | |
| 1153 | 1174 | if ($key == 'main_ip') | 
| 1154 | 1175 |  			{ | 
| 1155 | 1176 | $value = trim($value); | 
| 1156 | 1177 | $ip_parts = ip2range($value); | 
| 1157 | - if (!checkExistingTriggerIP($ip_parts, $value)) | |
| 1158 | - $context['ban_erros'][] = 'invalid_ip'; | |
| 1159 | - else | |
| 1178 | +				if (!checkExistingTriggerIP($ip_parts, $value)) { | |
| 1179 | + $context['ban_erros'][] = 'invalid_ip'; | |
| 1180 | + } else | |
| 1160 | 1181 |  				{ | 
| 1161 | 1182 | $ban_triggers['main_ip'] = array( | 
| 1162 | 1183 | 'ip_low' => $ip_parts['low'], | 
| 1163 | 1184 | 'ip_high' => $ip_parts['high'] | 
| 1164 | 1185 | ); | 
| 1165 | 1186 | } | 
| 1166 | - } | |
| 1167 | - elseif ($key == 'hostname') | |
| 1187 | + } elseif ($key == 'hostname') | |
| 1168 | 1188 |  			{ | 
| 1169 | -				if (preg_match('/[^\w.\-*]/', $value) == 1) | |
| 1170 | - $context['ban_erros'][] = 'invalid_hostname'; | |
| 1171 | - else | |
| 1189 | +				if (preg_match('/[^\w.\-*]/', $value) == 1) { | |
| 1190 | + $context['ban_erros'][] = 'invalid_hostname'; | |
| 1191 | + } else | |
| 1172 | 1192 |  				{ | 
| 1173 | 1193 | // Replace the * wildcard by a MySQL wildcard %. | 
| 1174 | 1194 |  					$value = substr(str_replace('*', '%', $value), 0, 255); | 
| 1175 | 1195 | |
| 1176 | 1196 | $ban_triggers['hostname']['hostname'] = $value; | 
| 1177 | 1197 | } | 
| 1178 | - } | |
| 1179 | - elseif ($key == 'email') | |
| 1198 | + } elseif ($key == 'email') | |
| 1180 | 1199 |  			{ | 
| 1181 | -				if (preg_match('/[^\w.\-\+*@]/', $value) == 1) | |
| 1182 | - $context['ban_erros'][] = 'invalid_email'; | |
| 1200 | +				if (preg_match('/[^\w.\-\+*@]/', $value) == 1) { | |
| 1201 | + $context['ban_erros'][] = 'invalid_email'; | |
| 1202 | + } | |
| 1183 | 1203 | |
| 1184 | 1204 | // Check the user is not banning an admin. | 
| 1185 | 1205 |  				$request = $smcFunc['db_query']('', ' | 
| @@ -1193,15 +1213,15 @@ discard block | ||
| 1193 | 1213 | 'email' => $value, | 
| 1194 | 1214 | ) | 
| 1195 | 1215 | ); | 
| 1196 | - if ($smcFunc['db_num_rows']($request) != 0) | |
| 1197 | - $context['ban_erros'][] = 'no_ban_admin'; | |
| 1216 | +				if ($smcFunc['db_num_rows']($request) != 0) { | |
| 1217 | + $context['ban_erros'][] = 'no_ban_admin'; | |
| 1218 | + } | |
| 1198 | 1219 | $smcFunc['db_free_result']($request); | 
| 1199 | 1220 | |
| 1200 | 1221 |  				$value = substr(strtolower(str_replace('*', '%', $value)), 0, 255); | 
| 1201 | 1222 | |
| 1202 | 1223 | $ban_triggers['email']['email_address'] = $value; | 
| 1203 | - } | |
| 1204 | - elseif ($key == 'user') | |
| 1224 | + } elseif ($key == 'user') | |
| 1205 | 1225 |  			{ | 
| 1206 | 1226 |  				$user = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $smcFunc['htmlspecialchars']($value, ENT_QUOTES)); | 
| 1207 | 1227 | |
| @@ -1215,8 +1235,9 @@ discard block | ||
| 1215 | 1235 | 'username' => $user, | 
| 1216 | 1236 | ) | 
| 1217 | 1237 | ); | 
| 1218 | - if ($smcFunc['db_num_rows']($request) == 0) | |
| 1219 | - $context['ban_erros'][] = 'invalid_username'; | |
| 1238 | +				if ($smcFunc['db_num_rows']($request) == 0) { | |
| 1239 | + $context['ban_erros'][] = 'invalid_username'; | |
| 1240 | + } | |
| 1220 | 1241 | list ($value, $isAdmin) = $smcFunc['db_fetch_row']($request); | 
| 1221 | 1242 | $smcFunc['db_free_result']($request); | 
| 1222 | 1243 | |
| @@ -1224,25 +1245,25 @@ discard block | ||
| 1224 | 1245 |  				{ | 
| 1225 | 1246 | unset($value); | 
| 1226 | 1247 | $context['ban_erros'][] = 'no_ban_admin'; | 
| 1248 | +				} else { | |
| 1249 | + $ban_triggers['user']['id_member'] = $value; | |
| 1227 | 1250 | } | 
| 1228 | - else | |
| 1229 | - $ban_triggers['user']['id_member'] = $value; | |
| 1230 | - } | |
| 1231 | -			elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) | |
| 1251 | +			} elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) | |
| 1232 | 1252 |  			{ | 
| 1233 | 1253 | // Special case, those two are arrays themselves | 
| 1234 | 1254 | $values = array_unique($value); | 
| 1235 | 1255 | // Don't add the main IP again. | 
| 1236 | - if (isset($triggers['main_ip'])) | |
| 1237 | - $values = array_diff($values, array($triggers['main_ip'])); | |
| 1256 | +				if (isset($triggers['main_ip'])) { | |
| 1257 | + $values = array_diff($values, array($triggers['main_ip'])); | |
| 1258 | + } | |
| 1238 | 1259 | unset($value); | 
| 1239 | 1260 | foreach ($values as $val) | 
| 1240 | 1261 |  				{ | 
| 1241 | 1262 | $val = trim($val); | 
| 1242 | 1263 | $ip_parts = ip2range($val); | 
| 1243 | - if (!checkExistingTriggerIP($ip_parts, $val)) | |
| 1244 | - $context['ban_erros'][] = 'invalid_ip'; | |
| 1245 | - else | |
| 1264 | +					if (!checkExistingTriggerIP($ip_parts, $val)) { | |
| 1265 | + $context['ban_erros'][] = 'invalid_ip'; | |
| 1266 | + } else | |
| 1246 | 1267 |  					{ | 
| 1247 | 1268 | $ban_triggers[$key][] = array( | 
| 1248 | 1269 | 'ip_low' => $ip_parts['low'], | 
| @@ -1255,15 +1276,16 @@ discard block | ||
| 1255 | 1276 | ); | 
| 1256 | 1277 | } | 
| 1257 | 1278 | } | 
| 1279 | +			} else { | |
| 1280 | + $context['ban_erros'][] = 'no_bantype_selected'; | |
| 1258 | 1281 | } | 
| 1259 | - else | |
| 1260 | - $context['ban_erros'][] = 'no_bantype_selected'; | |
| 1261 | 1282 | |
| 1262 | - if (isset($value) && !is_array($value)) | |
| 1263 | - $log_info[] = array( | |
| 1283 | +			if (isset($value) && !is_array($value)) { | |
| 1284 | + $log_info[] = array( | |
| 1264 | 1285 | 'value' => $value, | 
| 1265 | 1286 | 'bantype' => $key, | 
| 1266 | 1287 | ); | 
| 1288 | + } | |
| 1267 | 1289 | } | 
| 1268 | 1290 | } | 
| 1269 | 1291 |  	return array('ban_triggers' => $ban_triggers, 'log_info' => $log_info); | 
| @@ -1283,8 +1305,9 @@ discard block | ||
| 1283 | 1305 |  { | 
| 1284 | 1306 | global $smcFunc, $context; | 
| 1285 | 1307 | |
| 1286 | - if (empty($group_id)) | |
| 1287 | - $context['ban_errors'][] = 'ban_id_empty'; | |
| 1308 | +	if (empty($group_id)) { | |
| 1309 | + $context['ban_errors'][] = 'ban_id_empty'; | |
| 1310 | + } | |
| 1288 | 1311 | |
| 1289 | 1312 | // Preset all values that are required. | 
| 1290 | 1313 | $values = array( | 
| @@ -1309,18 +1332,21 @@ discard block | ||
| 1309 | 1332 | foreach ($triggers as $key => $trigger) | 
| 1310 | 1333 |  	{ | 
| 1311 | 1334 | // Exceptions, exceptions, exceptions...always exceptions... :P | 
| 1312 | -		if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) | |
| 1313 | - foreach ($trigger as $real_trigger) | |
| 1335 | +		if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) { | |
| 1336 | + foreach ($trigger as $real_trigger) | |
| 1314 | 1337 | $insertTriggers[] = array_merge($values, $real_trigger); | 
| 1315 | - else | |
| 1316 | - $insertTriggers[] = array_merge($values, $trigger); | |
| 1338 | +		} else { | |
| 1339 | + $insertTriggers[] = array_merge($values, $trigger); | |
| 1340 | + } | |
| 1317 | 1341 | } | 
| 1318 | 1342 | |
| 1319 | - if (empty($insertTriggers)) | |
| 1320 | - $context['ban_errors'][] = 'ban_no_triggers'; | |
| 1343 | +	if (empty($insertTriggers)) { | |
| 1344 | + $context['ban_errors'][] = 'ban_no_triggers'; | |
| 1345 | + } | |
| 1321 | 1346 | |
| 1322 | - if (!empty($context['ban_errors'])) | |
| 1323 | - return false; | |
| 1347 | +	if (!empty($context['ban_errors'])) { | |
| 1348 | + return false; | |
| 1349 | + } | |
| 1324 | 1350 | |
| 1325 | 1351 |  	$smcFunc['db_insert']('', | 
| 1326 | 1352 |  		'{db_prefix}ban_items', | 
| @@ -1348,15 +1374,19 @@ discard block | ||
| 1348 | 1374 |  { | 
| 1349 | 1375 | global $smcFunc, $context; | 
| 1350 | 1376 | |
| 1351 | - if (empty($ban_item)) | |
| 1352 | - $context['ban_errors'][] = 'ban_ban_item_empty'; | |
| 1353 | - if (empty($group_id)) | |
| 1354 | - $context['ban_errors'][] = 'ban_id_empty'; | |
| 1355 | - if (empty($trigger)) | |
| 1356 | - $context['ban_errors'][] = 'ban_no_triggers'; | |
| 1377 | +	if (empty($ban_item)) { | |
| 1378 | + $context['ban_errors'][] = 'ban_ban_item_empty'; | |
| 1379 | + } | |
| 1380 | +	if (empty($group_id)) { | |
| 1381 | + $context['ban_errors'][] = 'ban_id_empty'; | |
| 1382 | + } | |
| 1383 | +	if (empty($trigger)) { | |
| 1384 | + $context['ban_errors'][] = 'ban_no_triggers'; | |
| 1385 | + } | |
| 1357 | 1386 | |
| 1358 | - if (!empty($context['ban_errors'])) | |
| 1359 | - return; | |
| 1387 | +	if (!empty($context['ban_errors'])) { | |
| 1388 | + return; | |
| 1389 | + } | |
| 1360 | 1390 | |
| 1361 | 1391 | // Preset all values that are required. | 
| 1362 | 1392 | $values = array( | 
| @@ -1397,8 +1427,9 @@ discard block | ||
| 1397 | 1427 | */ | 
| 1398 | 1428 | function logTriggersUpdates($logs, $new = true, $removal = false) | 
| 1399 | 1429 |  { | 
| 1400 | - if (empty($logs)) | |
| 1401 | - return; | |
| 1430 | +	if (empty($logs)) { | |
| 1431 | + return; | |
| 1432 | + } | |
| 1402 | 1433 | |
| 1403 | 1434 | $log_name_map = array( | 
| 1404 | 1435 | 'main_ip' => 'ip_range', | 
| @@ -1409,14 +1440,15 @@ discard block | ||
| 1409 | 1440 | ); | 
| 1410 | 1441 | |
| 1411 | 1442 | // Log the addion of the ban entries into the moderation log. | 
| 1412 | - foreach ($logs as $log) | |
| 1413 | -		logAction('ban' . ($removal == true ? 'remove' : ''), array( | |
| 1443 | +	foreach ($logs as $log) { | |
| 1444 | +			logAction('ban' . ($removal == true ? 'remove' : ''), array( | |
| 1414 | 1445 | $log_name_map[$log['bantype']] => $log['value'], | 
| 1415 | 1446 | 'new' => empty($new) ? 0 : 1, | 
| 1416 | 1447 | 'remove' => empty($removal) ? 0 : 1, | 
| 1417 | 1448 | 'type' => $log['bantype'], | 
| 1418 | 1449 | )); | 
| 1419 | -} | |
| 1450 | + } | |
| 1451 | + } | |
| 1420 | 1452 | |
| 1421 | 1453 | /** | 
| 1422 | 1454 | * Updates an existing ban group | 
| @@ -1430,12 +1462,15 @@ discard block | ||
| 1430 | 1462 |  { | 
| 1431 | 1463 | global $smcFunc, $context; | 
| 1432 | 1464 | |
| 1433 | - if (empty($ban_info['name'])) | |
| 1434 | - $context['ban_errors'][] = 'ban_name_empty'; | |
| 1435 | - if (empty($ban_info['id'])) | |
| 1436 | - $context['ban_errors'][] = 'ban_id_empty'; | |
| 1437 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) | |
| 1438 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; | |
| 1465 | +	if (empty($ban_info['name'])) { | |
| 1466 | + $context['ban_errors'][] = 'ban_name_empty'; | |
| 1467 | + } | |
| 1468 | +	if (empty($ban_info['id'])) { | |
| 1469 | + $context['ban_errors'][] = 'ban_id_empty'; | |
| 1470 | + } | |
| 1471 | +	if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { | |
| 1472 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; | |
| 1473 | + } | |
| 1439 | 1474 | |
| 1440 | 1475 | if (!empty($ban_info['id'])) | 
| 1441 | 1476 |  	{ | 
| @@ -1450,8 +1485,9 @@ discard block | ||
| 1450 | 1485 | ) | 
| 1451 | 1486 | ); | 
| 1452 | 1487 | |
| 1453 | - if ($smcFunc['db_num_rows']($request) == 0) | |
| 1454 | - $context['ban_errors'][] = 'ban_not_found'; | |
| 1488 | +		if ($smcFunc['db_num_rows']($request) == 0) { | |
| 1489 | + $context['ban_errors'][] = 'ban_not_found'; | |
| 1490 | + } | |
| 1455 | 1491 | $smcFunc['db_free_result']($request); | 
| 1456 | 1492 | } | 
| 1457 | 1493 | |
| @@ -1469,13 +1505,15 @@ discard block | ||
| 1469 | 1505 | 'new_ban_name' => $ban_info['name'], | 
| 1470 | 1506 | ) | 
| 1471 | 1507 | ); | 
| 1472 | - if ($smcFunc['db_num_rows']($request) != 0) | |
| 1473 | - $context['ban_errors'][] = 'ban_name_exists'; | |
| 1508 | +		if ($smcFunc['db_num_rows']($request) != 0) { | |
| 1509 | + $context['ban_errors'][] = 'ban_name_exists'; | |
| 1510 | + } | |
| 1474 | 1511 | $smcFunc['db_free_result']($request); | 
| 1475 | 1512 | } | 
| 1476 | 1513 | |
| 1477 | - if (!empty($context['ban_errors'])) | |
| 1478 | - return $ban_info['id']; | |
| 1514 | +	if (!empty($context['ban_errors'])) { | |
| 1515 | + return $ban_info['id']; | |
| 1516 | + } | |
| 1479 | 1517 | |
| 1480 | 1518 |  	$smcFunc['db_query']('', ' | 
| 1481 | 1519 |  		UPDATE {db_prefix}ban_groups | 
| @@ -1519,10 +1557,12 @@ discard block | ||
| 1519 | 1557 |  { | 
| 1520 | 1558 | global $smcFunc, $context; | 
| 1521 | 1559 | |
| 1522 | - if (empty($ban_info['name'])) | |
| 1523 | - $context['ban_errors'][] = 'ban_name_empty'; | |
| 1524 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) | |
| 1525 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; | |
| 1560 | +	if (empty($ban_info['name'])) { | |
| 1561 | + $context['ban_errors'][] = 'ban_name_empty'; | |
| 1562 | + } | |
| 1563 | +	if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { | |
| 1564 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; | |
| 1565 | + } | |
| 1526 | 1566 | |
| 1527 | 1567 | if (!empty($ban_info['name'])) | 
| 1528 | 1568 |  	{ | 
| @@ -1537,13 +1577,15 @@ discard block | ||
| 1537 | 1577 | ) | 
| 1538 | 1578 | ); | 
| 1539 | 1579 | |
| 1540 | - if ($smcFunc['db_num_rows']($request) == 1) | |
| 1541 | - $context['ban_errors'][] = 'ban_name_exists'; | |
| 1580 | +		if ($smcFunc['db_num_rows']($request) == 1) { | |
| 1581 | + $context['ban_errors'][] = 'ban_name_exists'; | |
| 1582 | + } | |
| 1542 | 1583 | $smcFunc['db_free_result']($request); | 
| 1543 | 1584 | } | 
| 1544 | 1585 | |
| 1545 | - if (!empty($context['ban_errors'])) | |
| 1546 | - return; | |
| 1586 | +	if (!empty($context['ban_errors'])) { | |
| 1587 | + return; | |
| 1588 | + } | |
| 1547 | 1589 | |
| 1548 | 1590 | // Yes yes, we're ready to add now. | 
| 1549 | 1591 |  	$ban_info['id'] = $smcFunc['db_insert']('', | 
| @@ -1560,8 +1602,9 @@ discard block | ||
| 1560 | 1602 | 1 | 
| 1561 | 1603 | ); | 
| 1562 | 1604 | |
| 1563 | - if (empty($ban_info['id'])) | |
| 1564 | - $context['ban_errors'][] = 'impossible_insert_new_bangroup'; | |
| 1605 | +	if (empty($ban_info['id'])) { | |
| 1606 | + $context['ban_errors'][] = 'impossible_insert_new_bangroup'; | |
| 1607 | + } | |
| 1565 | 1608 | |
| 1566 | 1609 | return $ban_info['id']; | 
| 1567 | 1610 | } | 
| @@ -1586,24 +1629,24 @@ discard block | ||
| 1586 | 1629 | $ban_group = isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0; | 
| 1587 | 1630 | $ban_id = isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0; | 
| 1588 | 1631 | |
| 1589 | - if (empty($ban_group)) | |
| 1590 | -		fatal_lang_error('ban_not_found', false); | |
| 1632 | +	if (empty($ban_group)) { | |
| 1633 | +			fatal_lang_error('ban_not_found', false); | |
| 1634 | + } | |
| 1591 | 1635 | |
| 1592 | 1636 | if (isset($_POST['add_new_trigger']) && !empty($_POST['ban_suggestions'])) | 
| 1593 | 1637 |  	{ | 
| 1594 | 1638 | saveTriggers($_POST['ban_suggestions'], $ban_group, 0, $ban_id); | 
| 1595 | 1639 |  		redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); | 
| 1596 | - } | |
| 1597 | - elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) | |
| 1640 | + } elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) | |
| 1598 | 1641 |  	{ | 
| 1599 | 1642 | // The first replaces the old one, the others are added new (simplification, otherwise it would require another query and some work...) | 
| 1600 | 1643 | saveTriggers(array_shift($_POST['ban_suggestions']), $ban_group, 0, $ban_id); | 
| 1601 | - if (!empty($_POST['ban_suggestions'])) | |
| 1602 | - saveTriggers($_POST['ban_suggestions'], $ban_group); | |
| 1644 | +		if (!empty($_POST['ban_suggestions'])) { | |
| 1645 | + saveTriggers($_POST['ban_suggestions'], $ban_group); | |
| 1646 | + } | |
| 1603 | 1647 | |
| 1604 | 1648 |  		redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); | 
| 1605 | - } | |
| 1606 | - elseif (isset($_POST['edit_trigger'])) | |
| 1649 | + } elseif (isset($_POST['edit_trigger'])) | |
| 1607 | 1650 |  	{ | 
| 1608 | 1651 | removeBanTriggers($ban_id); | 
| 1609 | 1652 |  		redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); | 
| @@ -1634,8 +1677,7 @@ discard block | ||
| 1634 | 1677 | ), | 
| 1635 | 1678 | 'is_new' => true, | 
| 1636 | 1679 | ); | 
| 1637 | - } | |
| 1638 | - else | |
| 1680 | + } else | |
| 1639 | 1681 |  	{ | 
| 1640 | 1682 |  		$request = $smcFunc['db_query']('', ' | 
| 1641 | 1683 | SELECT | 
| @@ -1652,8 +1694,9 @@ discard block | ||
| 1652 | 1694 | 'ban_group' => $ban_group, | 
| 1653 | 1695 | ) | 
| 1654 | 1696 | ); | 
| 1655 | - if ($smcFunc['db_num_rows']($request) == 0) | |
| 1656 | -			fatal_lang_error('ban_not_found', false); | |
| 1697 | +		if ($smcFunc['db_num_rows']($request) == 0) { | |
| 1698 | +					fatal_lang_error('ban_not_found', false); | |
| 1699 | + } | |
| 1657 | 1700 | $row = $smcFunc['db_fetch_assoc']($request); | 
| 1658 | 1701 | $smcFunc['db_free_result']($request); | 
| 1659 | 1702 | |
| @@ -1702,8 +1745,9 @@ discard block | ||
| 1702 | 1745 | removeBanTriggers($_POST['remove']); | 
| 1703 | 1746 | |
| 1704 | 1747 | // Rehabilitate some members. | 
| 1705 | - if ($_REQUEST['entity'] == 'member') | |
| 1706 | - updateBanMembers(); | |
| 1748 | +		if ($_REQUEST['entity'] == 'member') { | |
| 1749 | + updateBanMembers(); | |
| 1750 | + } | |
| 1707 | 1751 | |
| 1708 | 1752 | // Make sure the ban cache is refreshed. | 
| 1709 | 1753 |  		updateSettings(array('banLastUpdated' => time())); | 
| @@ -1816,8 +1860,7 @@ discard block | ||
| 1816 | 1860 | 'default' => 'bi.ip_low, bi.ip_high, bi.ip_low', | 
| 1817 | 1861 | 'reverse' => 'bi.ip_low DESC, bi.ip_high DESC', | 
| 1818 | 1862 | ); | 
| 1819 | - } | |
| 1820 | - elseif ($context['selected_entity'] === 'hostname') | |
| 1863 | + } elseif ($context['selected_entity'] === 'hostname') | |
| 1821 | 1864 |  	{ | 
| 1822 | 1865 | $listOptions['columns']['banned_entity']['data'] = array( | 
| 1823 | 1866 | 'function' => function($rowData) use ($smcFunc) | 
| @@ -1829,8 +1872,7 @@ discard block | ||
| 1829 | 1872 | 'default' => 'bi.hostname', | 
| 1830 | 1873 | 'reverse' => 'bi.hostname DESC', | 
| 1831 | 1874 | ); | 
| 1832 | - } | |
| 1833 | - elseif ($context['selected_entity'] === 'email') | |
| 1875 | + } elseif ($context['selected_entity'] === 'email') | |
| 1834 | 1876 |  	{ | 
| 1835 | 1877 | $listOptions['columns']['banned_entity']['data'] = array( | 
| 1836 | 1878 | 'function' => function($rowData) use ($smcFunc) | 
| @@ -1842,8 +1884,7 @@ discard block | ||
| 1842 | 1884 | 'default' => 'bi.email_address', | 
| 1843 | 1885 | 'reverse' => 'bi.email_address DESC', | 
| 1844 | 1886 | ); | 
| 1845 | - } | |
| 1846 | - elseif ($context['selected_entity'] === 'member') | |
| 1887 | + } elseif ($context['selected_entity'] === 'member') | |
| 1847 | 1888 |  	{ | 
| 1848 | 1889 | $listOptions['columns']['banned_entity']['data'] = array( | 
| 1849 | 1890 | 'sprintf' => array( | 
| @@ -1907,8 +1948,9 @@ discard block | ||
| 1907 | 1948 | ) | 
| 1908 | 1949 | ); | 
| 1909 | 1950 | $ban_triggers = array(); | 
| 1910 | - while ($row = $smcFunc['db_fetch_assoc']($request)) | |
| 1911 | - $ban_triggers[] = $row; | |
| 1951 | +	while ($row = $smcFunc['db_fetch_assoc']($request)) { | |
| 1952 | + $ban_triggers[] = $row; | |
| 1953 | + } | |
| 1912 | 1954 | $smcFunc['db_free_result']($request); | 
| 1913 | 1955 | |
| 1914 | 1956 | return $ban_triggers; | 
| @@ -1964,8 +2006,9 @@ discard block | ||
| 1964 | 2006 |  		validateToken('admin-bl'); | 
| 1965 | 2007 | |
| 1966 | 2008 | // 'Delete all entries' button was pressed. | 
| 1967 | - if (!empty($_POST['removeAll'])) | |
| 1968 | - removeBanLogs(); | |
| 2009 | +		if (!empty($_POST['removeAll'])) { | |
| 2010 | + removeBanLogs(); | |
| 2011 | + } | |
| 1969 | 2012 | // 'Delete selection' button was pressed. | 
| 1970 | 2013 | else | 
| 1971 | 2014 |  		{ | 
| @@ -2174,12 +2217,15 @@ discard block | ||
| 2174 | 2217 | $low = inet_dtop($low); | 
| 2175 | 2218 | $high = inet_dtop($high); | 
| 2176 | 2219 | |
| 2177 | - if ($low == '255.255.255.255') return 'unknown'; | |
| 2178 | - if ($low == $high) | |
| 2179 | - return $low; | |
| 2180 | - else | |
| 2181 | - return $low . '-' . $high; | |
| 2182 | -} | |
| 2220 | +	if ($low == '255.255.255.255') { | |
| 2221 | + return 'unknown'; | |
| 2222 | + } | |
| 2223 | +	if ($low == $high) { | |
| 2224 | + return $low; | |
| 2225 | +	} else { | |
| 2226 | + return $low . '-' . $high; | |
| 2227 | + } | |
| 2228 | + } | |
| 2183 | 2229 | |
| 2184 | 2230 | /** | 
| 2185 | 2231 | * Checks whether a given IP range already exists in the trigger list. | 
| @@ -2255,15 +2301,17 @@ discard block | ||
| 2255 | 2301 | $memberEmailWild = array(); | 
| 2256 | 2302 | while ($row = $smcFunc['db_fetch_assoc']($request)) | 
| 2257 | 2303 |  	{ | 
| 2258 | - if ($row['id_member']) | |
| 2259 | - $memberIDs[$row['id_member']] = $row['id_member']; | |
| 2304 | +		if ($row['id_member']) { | |
| 2305 | + $memberIDs[$row['id_member']] = $row['id_member']; | |
| 2306 | + } | |
| 2260 | 2307 | if ($row['email_address']) | 
| 2261 | 2308 |  		{ | 
| 2262 | 2309 | // Does it have a wildcard - if so we can't do a IN on it. | 
| 2263 | - if (strpos($row['email_address'], '%') !== false) | |
| 2264 | - $memberEmailWild[$row['email_address']] = $row['email_address']; | |
| 2265 | - else | |
| 2266 | - $memberEmails[$row['email_address']] = $row['email_address']; | |
| 2310 | +			if (strpos($row['email_address'], '%') !== false) { | |
| 2311 | + $memberEmailWild[$row['email_address']] = $row['email_address']; | |
| 2312 | +			} else { | |
| 2313 | + $memberEmails[$row['email_address']] = $row['email_address']; | |
| 2314 | + } | |
| 2267 | 2315 | } | 
| 2268 | 2316 | } | 
| 2269 | 2317 | $smcFunc['db_free_result']($request); | 
| @@ -2314,14 +2362,15 @@ discard block | ||
| 2314 | 2362 | } | 
| 2315 | 2363 | |
| 2316 | 2364 | // We welcome our new members in the realm of the banned. | 
| 2317 | - if (!empty($newMembers)) | |
| 2318 | -		$smcFunc['db_query']('', ' | |
| 2365 | +	if (!empty($newMembers)) { | |
| 2366 | +			$smcFunc['db_query']('', ' | |
| 2319 | 2367 |  			DELETE FROM {db_prefix}log_online | 
| 2320 | 2368 |  			WHERE id_member IN ({array_int:new_banned_members})', | 
| 2321 | 2369 | array( | 
| 2322 | 2370 | 'new_banned_members' => $newMembers, | 
| 2323 | 2371 | ) | 
| 2324 | 2372 | ); | 
| 2373 | + } | |
| 2325 | 2374 | |
| 2326 | 2375 | // Find members that are wrongfully marked as banned. | 
| 2327 | 2376 |  	$request = $smcFunc['db_query']('', ' | 
| @@ -2348,9 +2397,10 @@ discard block | ||
| 2348 | 2397 | } | 
| 2349 | 2398 | $smcFunc['db_free_result']($request); | 
| 2350 | 2399 | |
| 2351 | - if (!empty($updates)) | |
| 2352 | - foreach ($updates as $newStatus => $members) | |
| 2400 | +	if (!empty($updates)) { | |
| 2401 | + foreach ($updates as $newStatus => $members) | |
| 2353 | 2402 |  			updateMemberData($members, array('is_activated' => $newStatus)); | 
| 2403 | + } | |
| 2354 | 2404 | |
| 2355 | 2405 | // Update the latest member and our total members as banning may change them. | 
| 2356 | 2406 |  	updateStats('member'); | 
| @@ -1452,7 +1452,7 @@ | ||
| 1452 | 1452 | * | 
| 1453 | 1453 | * @param int $id_subscribe The subscription ID | 
| 1454 | 1454 | * @param int $id_member The ID of the member | 
| 1455 | - * @param int|string $renewal 0 if we're forcing start/end time, otherwise a string indicating how long to renew the subscription for ('D', 'W', 'M' or 'Y') | |
| 1455 | + * @param integer $renewal 0 if we're forcing start/end time, otherwise a string indicating how long to renew the subscription for ('D', 'W', 'M' or 'Y') | |
| 1456 | 1456 | * @param int $forceStartTime If set, forces the subscription to start at the specified time | 
| 1457 | 1457 | * @param int $forceEndTime If set, forces the subscription to end at the specified time | 
| 1458 | 1458 | */ | 
| @@ -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 | * The main entrance point for the 'Paid Subscription' screen, calling | 
| @@ -32,18 +33,19 @@ discard block | ||
| 32 | 33 |  	loadLanguage('ManagePaid'); | 
| 33 | 34 |  	loadTemplate('ManagePaid'); | 
| 34 | 35 | |
| 35 | - if (!empty($modSettings['paid_enabled'])) | |
| 36 | - $subActions = array( | |
| 36 | +	if (!empty($modSettings['paid_enabled'])) { | |
| 37 | + $subActions = array( | |
| 37 | 38 |  			'modify' => array('ModifySubscription', 'admin_forum'), | 
| 38 | 39 |  			'modifyuser' => array('ModifyUserSubscription', 'admin_forum'), | 
| 39 | 40 |  			'settings' => array('ModifySubscriptionSettings', 'admin_forum'), | 
| 40 | 41 |  			'view' => array('ViewSubscriptions', 'admin_forum'), | 
| 41 | 42 |  			'viewsub' => array('ViewSubscribedUsers', 'admin_forum'), | 
| 42 | 43 | ); | 
| 43 | - else | |
| 44 | - $subActions = array( | |
| 44 | +	} else { | |
| 45 | + $subActions = array( | |
| 45 | 46 |  			'settings' => array('ModifySubscriptionSettings', 'admin_forum'), | 
| 46 | 47 | ); | 
| 48 | + } | |
| 47 | 49 | |
| 48 | 50 | // Default the sub-action to 'view subscriptions', but only if they have already set things up.. | 
| 49 | 51 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (!empty($modSettings['paid_currency_symbol']) && !empty($modSettings['paid_enabled']) ? 'view' : 'settings'); | 
| @@ -59,8 +61,8 @@ discard block | ||
| 59 | 61 | 'help' => '', | 
| 60 | 62 | 'description' => $txt['paid_subscriptions_desc'], | 
| 61 | 63 | ); | 
| 62 | - if (!empty($modSettings['paid_enabled'])) | |
| 63 | - $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( | |
| 64 | +	if (!empty($modSettings['paid_enabled'])) { | |
| 65 | + $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( | |
| 64 | 66 | 'view' => array( | 
| 65 | 67 | 'description' => $txt['paid_subs_view_desc'], | 
| 66 | 68 | ), | 
| @@ -68,6 +70,7 @@ discard block | ||
| 68 | 70 | 'description' => $txt['paid_subs_settings_desc'], | 
| 69 | 71 | ), | 
| 70 | 72 | ); | 
| 73 | + } | |
| 71 | 74 | |
| 72 | 75 |  	call_integration_hook('integrate_manage_subscriptions', array(&$subActions)); | 
| 73 | 76 | |
| @@ -92,8 +95,9 @@ discard block | ||
| 92 | 95 |  	{ | 
| 93 | 96 | // If the currency is set to something different then we need to set it to other for this to work and set it back shortly. | 
| 94 | 97 | $modSettings['paid_currency'] = !empty($modSettings['paid_currency_code']) ? $modSettings['paid_currency_code'] : ''; | 
| 95 | -		if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp', 'cad', 'aud'))) | |
| 96 | - $modSettings['paid_currency'] = 'other'; | |
| 98 | +		if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp', 'cad', 'aud'))) { | |
| 99 | + $modSettings['paid_currency'] = 'other'; | |
| 100 | + } | |
| 97 | 101 | |
| 98 | 102 | // These are all the default settings. | 
| 99 | 103 | $config_vars = array( | 
| @@ -156,8 +160,7 @@ discard block | ||
| 156 | 160 | } | 
| 157 | 161 | } | 
| 158 | 162 | toggleOther();', true); | 
| 159 | - } | |
| 160 | - else | |
| 163 | + } else | |
| 161 | 164 |  	{ | 
| 162 | 165 | $config_vars = array( | 
| 163 | 166 |  			array('check', 'paid_enabled'), | 
| @@ -166,8 +169,9 @@ discard block | ||
| 166 | 169 | } | 
| 167 | 170 | |
| 168 | 171 | // Just searching? | 
| 169 | - if ($return_config) | |
| 170 | - return $config_vars; | |
| 172 | +	if ($return_config) { | |
| 173 | + return $config_vars; | |
| 174 | + } | |
| 171 | 175 | |
| 172 | 176 | // Get the settings template fired up. | 
| 173 | 177 | require_once($sourcedir . '/ManageServer.php'); | 
| @@ -211,8 +215,9 @@ discard block | ||
| 211 | 215 |  			foreach (explode(',', $_POST['paid_email_to']) as $email) | 
| 212 | 216 |  			{ | 
| 213 | 217 | $email = trim($email); | 
| 214 | - if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) | |
| 215 | - $email_addresses[] = $email; | |
| 218 | +				if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) { | |
| 219 | + $email_addresses[] = $email; | |
| 220 | + } | |
| 216 | 221 |  				$_POST['paid_email_to'] = implode(',', $email_addresses); | 
| 217 | 222 | } | 
| 218 | 223 | } | 
| @@ -249,8 +254,9 @@ discard block | ||
| 249 | 254 | global $context, $txt, $modSettings, $sourcedir, $scripturl; | 
| 250 | 255 | |
| 251 | 256 | // Not made the settings yet? | 
| 252 | - if (empty($modSettings['paid_currency_symbol'])) | |
| 253 | -		fatal_lang_error('paid_not_set_currency', false, $scripturl . '?action=admin;area=paidsubscribe;sa=settings'); | |
| 257 | +	if (empty($modSettings['paid_currency_symbol'])) { | |
| 258 | +			fatal_lang_error('paid_not_set_currency', false, $scripturl . '?action=admin;area=paidsubscribe;sa=settings'); | |
| 259 | + } | |
| 254 | 260 | |
| 255 | 261 | // Some basic stuff. | 
| 256 | 262 | $context['page_title'] = $txt['paid_subs_view']; | 
| @@ -270,10 +276,11 @@ discard block | ||
| 270 | 276 | |
| 271 | 277 | foreach ($context['subscriptions'] as $data) | 
| 272 | 278 |  				{ | 
| 273 | - if (++$counter < $start) | |
| 274 | - continue; | |
| 275 | - elseif ($counter == $start + $items_per_page) | |
| 276 | - break; | |
| 279 | +					if (++$counter < $start) { | |
| 280 | + continue; | |
| 281 | +					} elseif ($counter == $start + $items_per_page) { | |
| 282 | + break; | |
| 283 | + } | |
| 277 | 284 | |
| 278 | 285 | $subscriptions[] = $data; | 
| 279 | 286 | } | 
| @@ -450,8 +457,9 @@ discard block | ||
| 450 | 457 | ); | 
| 451 | 458 | $id_group = 0; | 
| 452 | 459 | $add_groups = ''; | 
| 453 | - if ($smcFunc['db_num_rows']($request)) | |
| 454 | - list ($id_group, $add_groups) = $smcFunc['db_fetch_row']($request); | |
| 460 | +			if ($smcFunc['db_num_rows']($request)) { | |
| 461 | + list ($id_group, $add_groups) = $smcFunc['db_fetch_row']($request); | |
| 462 | + } | |
| 455 | 463 | $smcFunc['db_free_result']($request); | 
| 456 | 464 | |
| 457 | 465 | $changes = array(); | 
| @@ -463,8 +471,9 @@ discard block | ||
| 463 | 471 |  				{ | 
| 464 | 472 | // If their current primary group isn't what they had before the subscription, and their current group was | 
| 465 | 473 | // granted by the sub, remove it. | 
| 466 | - if ($member_data['old_id_group'] != $member_data['id_group'] && $member_data['id_group'] == $id_group) | |
| 467 | - $changes[$id_member]['id_group'] = $member_data['old_id_group']; | |
| 474 | +					if ($member_data['old_id_group'] != $member_data['id_group'] && $member_data['id_group'] == $id_group) { | |
| 475 | + $changes[$id_member]['id_group'] = $member_data['old_id_group']; | |
| 476 | + } | |
| 468 | 477 | } | 
| 469 | 478 | } | 
| 470 | 479 | |
| @@ -477,15 +486,17 @@ discard block | ||
| 477 | 486 | // First let's get their groups sorted. | 
| 478 | 487 |  					$current_groups = explode(',', $member_data['additional_groups']); | 
| 479 | 488 |  					$new_groups = implode(',', array_diff($current_groups, $add_groups)); | 
| 480 | - if ($new_groups != $member_data['additional_groups']) | |
| 481 | - $changes[$id_member]['additional_groups'] = $new_groups; | |
| 489 | +					if ($new_groups != $member_data['additional_groups']) { | |
| 490 | + $changes[$id_member]['additional_groups'] = $new_groups; | |
| 491 | + } | |
| 482 | 492 | } | 
| 483 | 493 | } | 
| 484 | 494 | |
| 485 | 495 | // We're going through changes... | 
| 486 | - if (!empty($changes)) | |
| 487 | - foreach ($changes as $id_member => $new_values) | |
| 496 | +			if (!empty($changes)) { | |
| 497 | + foreach ($changes as $id_member => $new_values) | |
| 488 | 498 | updateMemberData($id_member, $new_values); | 
| 499 | + } | |
| 489 | 500 | } | 
| 490 | 501 | |
| 491 | 502 | // Delete the subscription | 
| @@ -533,11 +544,13 @@ discard block | ||
| 533 | 544 | 'M' => 24, | 
| 534 | 545 | 'Y' => 5, | 
| 535 | 546 | ); | 
| 536 | - if (empty($_POST['span_unit']) || empty($limits[$_POST['span_unit']]) || empty($_POST['span_value']) || $_POST['span_value'] < 1) | |
| 537 | -				fatal_lang_error('paid_invalid_duration', false); | |
| 547 | +			if (empty($_POST['span_unit']) || empty($limits[$_POST['span_unit']]) || empty($_POST['span_value']) || $_POST['span_value'] < 1) { | |
| 548 | +							fatal_lang_error('paid_invalid_duration', false); | |
| 549 | + } | |
| 538 | 550 | |
| 539 | - if ($_POST['span_value'] > $limits[$_POST['span_unit']]) | |
| 540 | -				fatal_lang_error('paid_invalid_duration_' . $_POST['span_unit'], false); | |
| 551 | +			if ($_POST['span_value'] > $limits[$_POST['span_unit']]) { | |
| 552 | +							fatal_lang_error('paid_invalid_duration_' . $_POST['span_unit'], false); | |
| 553 | + } | |
| 541 | 554 | |
| 542 | 555 | // Clean the span. | 
| 543 | 556 | $span = $_POST['span_value'] . $_POST['span_unit']; | 
| @@ -546,8 +559,9 @@ discard block | ||
| 546 | 559 |  			$cost = array('fixed' => sprintf('%01.2f', strtr($_POST['cost'], ',', '.'))); | 
| 547 | 560 | |
| 548 | 561 | // There needs to be something. | 
| 549 | - if (empty($_POST['span_value']) || empty($_POST['cost'])) | |
| 550 | -				fatal_lang_error('paid_no_cost_value'); | |
| 562 | +			if (empty($_POST['span_value']) || empty($_POST['cost'])) { | |
| 563 | +							fatal_lang_error('paid_no_cost_value'); | |
| 564 | + } | |
| 551 | 565 | } | 
| 552 | 566 | // Flexible is harder but more fun ;) | 
| 553 | 567 | else | 
| @@ -561,8 +575,9 @@ discard block | ||
| 561 | 575 |  				'year' => sprintf('%01.2f', strtr($_POST['cost_year'], ',', '.')), | 
| 562 | 576 | ); | 
| 563 | 577 | |
| 564 | - if (empty($_POST['cost_day']) && empty($_POST['cost_week']) && empty($_POST['cost_month']) && empty($_POST['cost_year'])) | |
| 565 | -				fatal_lang_error('paid_all_freq_blank'); | |
| 578 | +			if (empty($_POST['cost_day']) && empty($_POST['cost_week']) && empty($_POST['cost_month']) && empty($_POST['cost_year'])) { | |
| 579 | +							fatal_lang_error('paid_all_freq_blank'); | |
| 580 | + } | |
| 566 | 581 | } | 
| 567 | 582 | $cost = $smcFunc['json_encode']($cost); | 
| 568 | 583 | |
| @@ -571,9 +586,10 @@ discard block | ||
| 571 | 586 | |
| 572 | 587 | // Yep, time to do additional groups. | 
| 573 | 588 | $addgroups = array(); | 
| 574 | - if (!empty($_POST['addgroup'])) | |
| 575 | - foreach ($_POST['addgroup'] as $id => $dummy) | |
| 589 | +		if (!empty($_POST['addgroup'])) { | |
| 590 | + foreach ($_POST['addgroup'] as $id => $dummy) | |
| 576 | 591 | $addgroups[] = (int) $id; | 
| 592 | + } | |
| 577 | 593 |  		$addgroups = implode(',', $addgroups); | 
| 578 | 594 | |
| 579 | 595 | // Is it new?! | 
| @@ -683,18 +699,18 @@ discard block | ||
| 683 | 699 |  			{ | 
| 684 | 700 | $span_value = $match[1]; | 
| 685 | 701 | $span_unit = $match[2]; | 
| 686 | - } | |
| 687 | - else | |
| 702 | + } else | |
| 688 | 703 |  			{ | 
| 689 | 704 | $span_value = 0; | 
| 690 | 705 | $span_unit = 'D'; | 
| 691 | 706 | } | 
| 692 | 707 | |
| 693 | 708 | // Is this a flexible one? | 
| 694 | - if ($row['length'] == 'F') | |
| 695 | - $isFlexible = true; | |
| 696 | - else | |
| 697 | - $isFlexible = false; | |
| 709 | +			if ($row['length'] == 'F') { | |
| 710 | + $isFlexible = true; | |
| 711 | +			} else { | |
| 712 | + $isFlexible = false; | |
| 713 | + } | |
| 698 | 714 | |
| 699 | 715 | $context['sub'] = array( | 
| 700 | 716 | 'name' => $row['name'], | 
| @@ -743,8 +759,9 @@ discard block | ||
| 743 | 759 | ) | 
| 744 | 760 | ); | 
| 745 | 761 | $context['groups'] = array(); | 
| 746 | - while ($row = $smcFunc['db_fetch_assoc']($request)) | |
| 747 | - $context['groups'][$row['id_group']] = $row['group_name']; | |
| 762 | +	while ($row = $smcFunc['db_fetch_assoc']($request)) { | |
| 763 | + $context['groups'][$row['id_group']] = $row['group_name']; | |
| 764 | + } | |
| 748 | 765 | $smcFunc['db_free_result']($request); | 
| 749 | 766 | |
| 750 | 767 | // This always happens. | 
| @@ -778,8 +795,9 @@ discard block | ||
| 778 | 795 | ) | 
| 779 | 796 | ); | 
| 780 | 797 | // Something wrong? | 
| 781 | - if ($smcFunc['db_num_rows']($request) == 0) | |
| 782 | -		fatal_lang_error('no_access', false); | |
| 798 | +	if ($smcFunc['db_num_rows']($request) == 0) { | |
| 799 | +			fatal_lang_error('no_access', false); | |
| 800 | + } | |
| 783 | 801 | // Do the subscription context. | 
| 784 | 802 | $row = $smcFunc['db_fetch_assoc']($request); | 
| 785 | 803 | $context['subscription'] = array( | 
| @@ -1014,8 +1032,8 @@ discard block | ||
| 1014 | 1032 | )) | 
| 1015 | 1033 | ); | 
| 1016 | 1034 | $subscribers = array(); | 
| 1017 | - while ($row = $smcFunc['db_fetch_assoc']($request)) | |
| 1018 | - $subscribers[] = array( | |
| 1035 | +	while ($row = $smcFunc['db_fetch_assoc']($request)) { | |
| 1036 | + $subscribers[] = array( | |
| 1019 | 1037 | 'id' => $row['id_sublog'], | 
| 1020 | 1038 | 'id_member' => $row['id_member'], | 
| 1021 | 1039 | 'name' => $row['name'], | 
| @@ -1025,6 +1043,7 @@ discard block | ||
| 1025 | 1043 | 'status' => $row['status'], | 
| 1026 | 1044 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] == 0 ? $txt['paid_finished'] : $txt['paid_pending']) : $txt['paid_active'], | 
| 1027 | 1045 | ); | 
| 1046 | + } | |
| 1028 | 1047 | $smcFunc['db_free_result']($request); | 
| 1029 | 1048 | |
| 1030 | 1049 | return $subscribers; | 
| @@ -1059,14 +1078,16 @@ discard block | ||
| 1059 | 1078 | 'current_log_item' => $context['log_id'], | 
| 1060 | 1079 | ) | 
| 1061 | 1080 | ); | 
| 1062 | - if ($smcFunc['db_num_rows']($request) == 0) | |
| 1063 | -			fatal_lang_error('no_access', false); | |
| 1081 | +		if ($smcFunc['db_num_rows']($request) == 0) { | |
| 1082 | +					fatal_lang_error('no_access', false); | |
| 1083 | + } | |
| 1064 | 1084 | list ($context['sub_id']) = $smcFunc['db_fetch_row']($request); | 
| 1065 | 1085 | $smcFunc['db_free_result']($request); | 
| 1066 | 1086 | } | 
| 1067 | 1087 | |
| 1068 | - if (!isset($context['subscriptions'][$context['sub_id']])) | |
| 1069 | -		fatal_lang_error('no_access', false); | |
| 1088 | +	if (!isset($context['subscriptions'][$context['sub_id']])) { | |
| 1089 | +			fatal_lang_error('no_access', false); | |
| 1090 | + } | |
| 1070 | 1091 | $context['current_subscription'] = $context['subscriptions'][$context['sub_id']]; | 
| 1071 | 1092 | |
| 1072 | 1093 | // Searching? | 
| @@ -1099,8 +1120,9 @@ discard block | ||
| 1099 | 1120 | 'name' => $_POST['name'], | 
| 1100 | 1121 | ) | 
| 1101 | 1122 | ); | 
| 1102 | - if ($smcFunc['db_num_rows']($request) == 0) | |
| 1103 | -				fatal_lang_error('error_member_not_found'); | |
| 1123 | +			if ($smcFunc['db_num_rows']($request) == 0) { | |
| 1124 | +							fatal_lang_error('error_member_not_found'); | |
| 1125 | + } | |
| 1104 | 1126 | |
| 1105 | 1127 | list ($id_member, $id_group) = $smcFunc['db_fetch_row']($request); | 
| 1106 | 1128 | $smcFunc['db_free_result']($request); | 
| @@ -1116,14 +1138,15 @@ discard block | ||
| 1116 | 1138 | 'current_member' => $id_member, | 
| 1117 | 1139 | ) | 
| 1118 | 1140 | ); | 
| 1119 | - if ($smcFunc['db_num_rows']($request) != 0) | |
| 1120 | -				fatal_lang_error('member_already_subscribed'); | |
| 1141 | +			if ($smcFunc['db_num_rows']($request) != 0) { | |
| 1142 | +							fatal_lang_error('member_already_subscribed'); | |
| 1143 | + } | |
| 1121 | 1144 | $smcFunc['db_free_result']($request); | 
| 1122 | 1145 | |
| 1123 | 1146 | // Actually put the subscription in place. | 
| 1124 | - if ($status == 1) | |
| 1125 | - addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); | |
| 1126 | - else | |
| 1147 | +			if ($status == 1) { | |
| 1148 | + addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); | |
| 1149 | + } else | |
| 1127 | 1150 |  			{ | 
| 1128 | 1151 |  				$smcFunc['db_insert']('', | 
| 1129 | 1152 |  					'{db_prefix}log_subscribed', | 
| @@ -1150,20 +1173,20 @@ discard block | ||
| 1150 | 1173 | 'current_log_item' => $context['log_id'], | 
| 1151 | 1174 | ) | 
| 1152 | 1175 | ); | 
| 1153 | - if ($smcFunc['db_num_rows']($request) == 0) | |
| 1154 | -				fatal_lang_error('no_access', false); | |
| 1176 | +			if ($smcFunc['db_num_rows']($request) == 0) { | |
| 1177 | +							fatal_lang_error('no_access', false); | |
| 1178 | + } | |
| 1155 | 1179 | |
| 1156 | 1180 | list ($id_member, $old_status) = $smcFunc['db_fetch_row']($request); | 
| 1157 | 1181 | $smcFunc['db_free_result']($request); | 
| 1158 | 1182 | |
| 1159 | 1183 | // Pick the right permission stuff depending on what the status is changing from/to. | 
| 1160 | - if ($old_status == 1 && $status != 1) | |
| 1161 | - removeSubscription($context['sub_id'], $id_member); | |
| 1162 | - elseif ($status == 1 && $old_status != 1) | |
| 1184 | +			if ($old_status == 1 && $status != 1) { | |
| 1185 | + removeSubscription($context['sub_id'], $id_member); | |
| 1186 | + } elseif ($status == 1 && $old_status != 1) | |
| 1163 | 1187 |  			{ | 
| 1164 | 1188 | addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); | 
| 1165 | - } | |
| 1166 | - else | |
| 1189 | + } else | |
| 1167 | 1190 |  			{ | 
| 1168 | 1191 |  				$smcFunc['db_query']('', ' | 
| 1169 | 1192 |  					UPDATE {db_prefix}log_subscribed | 
| @@ -1191,8 +1214,9 @@ discard block | ||
| 1191 | 1214 | if (!empty($_REQUEST['delsub'])) | 
| 1192 | 1215 |  		{ | 
| 1193 | 1216 | $toDelete = array(); | 
| 1194 | - foreach ($_REQUEST['delsub'] as $id => $dummy) | |
| 1195 | - $toDelete[] = (int) $id; | |
| 1217 | +			foreach ($_REQUEST['delsub'] as $id => $dummy) { | |
| 1218 | + $toDelete[] = (int) $id; | |
| 1219 | + } | |
| 1196 | 1220 | |
| 1197 | 1221 |  			$request = $smcFunc['db_query']('', ' | 
| 1198 | 1222 | SELECT id_subscribe, id_member | 
| @@ -1202,8 +1226,9 @@ discard block | ||
| 1202 | 1226 | 'subscription_list' => $toDelete, | 
| 1203 | 1227 | ) | 
| 1204 | 1228 | ); | 
| 1205 | - while ($row = $smcFunc['db_fetch_assoc']($request)) | |
| 1206 | - removeSubscription($row['id_subscribe'], $row['id_member'], isset($_REQUEST['delete'])); | |
| 1229 | +			while ($row = $smcFunc['db_fetch_assoc']($request)) { | |
| 1230 | + removeSubscription($row['id_subscribe'], $row['id_member'], isset($_REQUEST['delete'])); | |
| 1231 | + } | |
| 1207 | 1232 | $smcFunc['db_free_result']($request); | 
| 1208 | 1233 | } | 
| 1209 | 1234 |  		redirectexit('action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id']); | 
| @@ -1247,9 +1272,9 @@ discard block | ||
| 1247 | 1272 | ); | 
| 1248 | 1273 | list ($context['sub']['username']) = $smcFunc['db_fetch_row']($request); | 
| 1249 | 1274 | $smcFunc['db_free_result']($request); | 
| 1275 | +		} else { | |
| 1276 | + $context['sub']['username'] = ''; | |
| 1250 | 1277 | } | 
| 1251 | - else | |
| 1252 | - $context['sub']['username'] = ''; | |
| 1253 | 1278 | } | 
| 1254 | 1279 | // Otherwise load the existing info. | 
| 1255 | 1280 | else | 
| @@ -1266,8 +1291,9 @@ discard block | ||
| 1266 | 1291 | 'blank_string' => '', | 
| 1267 | 1292 | ) | 
| 1268 | 1293 | ); | 
| 1269 | - if ($smcFunc['db_num_rows']($request) == 0) | |
| 1270 | -			fatal_lang_error('no_access', false); | |
| 1294 | +		if ($smcFunc['db_num_rows']($request) == 0) { | |
| 1295 | +					fatal_lang_error('no_access', false); | |
| 1296 | + } | |
| 1271 | 1297 | $row = $smcFunc['db_fetch_assoc']($request); | 
| 1272 | 1298 | $smcFunc['db_free_result']($request); | 
| 1273 | 1299 | |
| @@ -1288,13 +1314,13 @@ discard block | ||
| 1288 | 1314 |  					{ | 
| 1289 | 1315 | foreach ($costs as $duration => $cost) | 
| 1290 | 1316 |  						{ | 
| 1291 | - if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) | |
| 1292 | - $context['pending_payments'][$id] = array( | |
| 1317 | +							if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) { | |
| 1318 | + $context['pending_payments'][$id] = array( | |
| 1293 | 1319 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $cost . '/' . $txt[$duration]), | 
| 1294 | 1320 | ); | 
| 1321 | + } | |
| 1295 | 1322 | } | 
| 1296 | - } | |
| 1297 | - elseif ($costs['fixed'] == $pending[1]) | |
| 1323 | + } elseif ($costs['fixed'] == $pending[1]) | |
| 1298 | 1324 |  					{ | 
| 1299 | 1325 | $context['pending_payments'][$id] = array( | 
| 1300 | 1326 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $costs['fixed']), | 
| @@ -1312,8 +1338,9 @@ discard block | ||
| 1312 | 1338 | if ($_GET['pending'] == $id && $pending[3] == 'payback' && isset($context['pending_payments'][$id])) | 
| 1313 | 1339 |  					{ | 
| 1314 | 1340 | // Flexible? | 
| 1315 | - if (isset($_GET['accept'])) | |
| 1316 | - addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] == 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); | |
| 1341 | +						if (isset($_GET['accept'])) { | |
| 1342 | + addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] == 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); | |
| 1343 | + } | |
| 1317 | 1344 | unset($pending_details[$id]); | 
| 1318 | 1345 | |
| 1319 | 1346 | $new_details = $smcFunc['json_encode']($pending_details); | 
| @@ -1375,8 +1402,9 @@ discard block | ||
| 1375 | 1402 | global $smcFunc; | 
| 1376 | 1403 | |
| 1377 | 1404 | // Make it an array. | 
| 1378 | - if (!is_array($users)) | |
| 1379 | - $users = array($users); | |
| 1405 | +	if (!is_array($users)) { | |
| 1406 | + $users = array($users); | |
| 1407 | + } | |
| 1380 | 1408 | |
| 1381 | 1409 | // Get all the members current groups. | 
| 1382 | 1410 | $groups = array(); | 
| @@ -1414,14 +1442,16 @@ discard block | ||
| 1414 | 1442 | if ($row['id_group'] != 0) | 
| 1415 | 1443 |  		{ | 
| 1416 | 1444 | // If this is changing - add the old one to the additional groups so it's not lost. | 
| 1417 | - if ($row['id_group'] != $groups[$row['id_member']]['primary']) | |
| 1418 | - $groups[$row['id_member']]['additional'][] = $groups[$row['id_member']]['primary']; | |
| 1445 | +			if ($row['id_group'] != $groups[$row['id_member']]['primary']) { | |
| 1446 | + $groups[$row['id_member']]['additional'][] = $groups[$row['id_member']]['primary']; | |
| 1447 | + } | |
| 1419 | 1448 | $groups[$row['id_member']]['primary'] = $row['id_group']; | 
| 1420 | 1449 | } | 
| 1421 | 1450 | |
| 1422 | 1451 | // Additional groups. | 
| 1423 | - if (!empty($row['add_groups'])) | |
| 1424 | -			$groups[$row['id_member']]['additional'] = array_merge($groups[$row['id_member']]['additional'], explode(',', $row['add_groups'])); | |
| 1452 | +		if (!empty($row['add_groups'])) { | |
| 1453 | +					$groups[$row['id_member']]['additional'] = array_merge($groups[$row['id_member']]['additional'], explode(',', $row['add_groups'])); | |
| 1454 | + } | |
| 1425 | 1455 | } | 
| 1426 | 1456 | $smcFunc['db_free_result']($request); | 
| 1427 | 1457 | |
| @@ -1429,9 +1459,10 @@ discard block | ||
| 1429 | 1459 | foreach ($groups as $id => $group) | 
| 1430 | 1460 |  	{ | 
| 1431 | 1461 | $group['additional'] = array_unique($group['additional']); | 
| 1432 | - foreach ($group['additional'] as $key => $value) | |
| 1433 | - if (empty($value)) | |
| 1462 | +		foreach ($group['additional'] as $key => $value) { | |
| 1463 | + if (empty($value)) | |
| 1434 | 1464 | unset($group['additional'][$key]); | 
| 1465 | + } | |
| 1435 | 1466 |  		$addgroups = implode(',', $group['additional']); | 
| 1436 | 1467 | |
| 1437 | 1468 |  		$smcFunc['db_query']('', ' | 
| @@ -1465,8 +1496,9 @@ discard block | ||
| 1465 | 1496 | loadSubscriptions(); | 
| 1466 | 1497 | |
| 1467 | 1498 | // Exists, yes? | 
| 1468 | - if (!isset($context['subscriptions'][$id_subscribe])) | |
| 1469 | - return; | |
| 1499 | +	if (!isset($context['subscriptions'][$id_subscribe])) { | |
| 1500 | + return; | |
| 1501 | + } | |
| 1470 | 1502 | |
| 1471 | 1503 | $curSub = $context['subscriptions'][$id_subscribe]; | 
| 1472 | 1504 | |
| @@ -1514,16 +1546,19 @@ discard block | ||
| 1514 | 1546 | list ($id_sublog, $endtime, $starttime) = $smcFunc['db_fetch_row']($request); | 
| 1515 | 1547 | |
| 1516 | 1548 | // If this has already expired but is active, extension means the period from now. | 
| 1517 | - if ($endtime < time()) | |
| 1518 | - $endtime = time(); | |
| 1519 | - if ($starttime == 0) | |
| 1520 | - $starttime = time(); | |
| 1549 | +		if ($endtime < time()) { | |
| 1550 | + $endtime = time(); | |
| 1551 | + } | |
| 1552 | +		if ($starttime == 0) { | |
| 1553 | + $starttime = time(); | |
| 1554 | + } | |
| 1521 | 1555 | |
| 1522 | 1556 | // Work out the new expiry date. | 
| 1523 | 1557 | $endtime += $duration; | 
| 1524 | 1558 | |
| 1525 | - if ($forceEndTime != 0) | |
| 1526 | - $endtime = $forceEndTime; | |
| 1559 | +		if ($forceEndTime != 0) { | |
| 1560 | + $endtime = $forceEndTime; | |
| 1561 | + } | |
| 1527 | 1562 | |
| 1528 | 1563 | // As everything else should be good, just update! | 
| 1529 | 1564 |  		$smcFunc['db_query']('', ' | 
| @@ -1553,8 +1588,9 @@ discard block | ||
| 1553 | 1588 | ); | 
| 1554 | 1589 | |
| 1555 | 1590 | // Just in case the member doesn't exist. | 
| 1556 | - if ($smcFunc['db_num_rows']($request) == 0) | |
| 1557 | - return; | |
| 1591 | +	if ($smcFunc['db_num_rows']($request) == 0) { | |
| 1592 | + return; | |
| 1593 | + } | |
| 1558 | 1594 | |
| 1559 | 1595 | list ($old_id_group, $additional_groups) = $smcFunc['db_fetch_row']($request); | 
| 1560 | 1596 | $smcFunc['db_free_result']($request); | 
| @@ -1571,16 +1607,18 @@ discard block | ||
| 1571 | 1607 | $id_group = $curSub['prim_group']; | 
| 1572 | 1608 | |
| 1573 | 1609 | // Ensure their old privileges are maintained. | 
| 1574 | - if ($old_id_group != 0) | |
| 1575 | - $newAddGroups[] = $old_id_group; | |
| 1610 | +		if ($old_id_group != 0) { | |
| 1611 | + $newAddGroups[] = $old_id_group; | |
| 1612 | + } | |
| 1613 | +	} else { | |
| 1614 | + $id_group = $old_id_group; | |
| 1576 | 1615 | } | 
| 1577 | - else | |
| 1578 | - $id_group = $old_id_group; | |
| 1579 | 1616 | |
| 1580 | 1617 | // Yep, make sure it's unique, and no empties. | 
| 1581 | - foreach ($newAddGroups as $k => $v) | |
| 1582 | - if (empty($v)) | |
| 1618 | +	foreach ($newAddGroups as $k => $v) { | |
| 1619 | + if (empty($v)) | |
| 1583 | 1620 | unset($newAddGroups[$k]); | 
| 1621 | + } | |
| 1584 | 1622 | $newAddGroups = array_unique($newAddGroups); | 
| 1585 | 1623 |  	$newAddGroups = implode(',', $newAddGroups); | 
| 1586 | 1624 | |
| @@ -1616,16 +1654,19 @@ discard block | ||
| 1616 | 1654 | list ($id_sublog, $endtime, $starttime) = $smcFunc['db_fetch_row']($request); | 
| 1617 | 1655 | |
| 1618 | 1656 | // If this has already expired but is active, extension means the period from now. | 
| 1619 | - if ($endtime < time()) | |
| 1620 | - $endtime = time(); | |
| 1621 | - if ($starttime == 0) | |
| 1622 | - $starttime = time(); | |
| 1657 | +		if ($endtime < time()) { | |
| 1658 | + $endtime = time(); | |
| 1659 | + } | |
| 1660 | +		if ($starttime == 0) { | |
| 1661 | + $starttime = time(); | |
| 1662 | + } | |
| 1623 | 1663 | |
| 1624 | 1664 | // Work out the new expiry date. | 
| 1625 | 1665 | $endtime += $duration; | 
| 1626 | 1666 | |
| 1627 | - if ($forceEndTime != 0) | |
| 1628 | - $endtime = $forceEndTime; | |
| 1667 | +		if ($forceEndTime != 0) { | |
| 1668 | + $endtime = $forceEndTime; | |
| 1669 | + } | |
| 1629 | 1670 | |
| 1630 | 1671 | // As everything else should be good, just update! | 
| 1631 | 1672 |  		$smcFunc['db_query']('', ' | 
| @@ -1648,13 +1689,15 @@ discard block | ||
| 1648 | 1689 | |
| 1649 | 1690 | // Otherwise a very simple insert. | 
| 1650 | 1691 | $endtime = time() + $duration; | 
| 1651 | - if ($forceEndTime != 0) | |
| 1652 | - $endtime = $forceEndTime; | |
| 1692 | +	if ($forceEndTime != 0) { | |
| 1693 | + $endtime = $forceEndTime; | |
| 1694 | + } | |
| 1653 | 1695 | |
| 1654 | - if ($forceStartTime == 0) | |
| 1655 | - $starttime = time(); | |
| 1656 | - else | |
| 1657 | - $starttime = $forceStartTime; | |
| 1696 | +	if ($forceStartTime == 0) { | |
| 1697 | + $starttime = time(); | |
| 1698 | +	} else { | |
| 1699 | + $starttime = $forceStartTime; | |
| 1700 | + } | |
| 1658 | 1701 | |
| 1659 | 1702 |  	$smcFunc['db_insert']('', | 
| 1660 | 1703 |  		'{db_prefix}log_subscribed', | 
| @@ -1727,15 +1770,17 @@ discard block | ||
| 1727 | 1770 | $new_id_group = -1; | 
| 1728 | 1771 | while ($row = $smcFunc['db_fetch_assoc']($request)) | 
| 1729 | 1772 |  	{ | 
| 1730 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) | |
| 1731 | - continue; | |
| 1773 | +		if (!isset($context['subscriptions'][$row['id_subscribe']])) { | |
| 1774 | + continue; | |
| 1775 | + } | |
| 1732 | 1776 | |
| 1733 | 1777 | // The one we're removing? | 
| 1734 | 1778 | if ($row['id_subscribe'] == $id_subscribe) | 
| 1735 | 1779 |  		{ | 
| 1736 | 1780 |  			$removals = explode(',', $context['subscriptions'][$row['id_subscribe']]['add_groups']); | 
| 1737 | - if ($context['subscriptions'][$row['id_subscribe']]['prim_group'] != 0) | |
| 1738 | - $removals[] = $context['subscriptions'][$row['id_subscribe']]['prim_group']; | |
| 1781 | +			if ($context['subscriptions'][$row['id_subscribe']]['prim_group'] != 0) { | |
| 1782 | + $removals[] = $context['subscriptions'][$row['id_subscribe']]['prim_group']; | |
| 1783 | + } | |
| 1739 | 1784 | $old_id_group = $row['old_id_group']; | 
| 1740 | 1785 | } | 
| 1741 | 1786 | // Otherwise things we allow. | 
| @@ -1753,30 +1798,33 @@ discard block | ||
| 1753 | 1798 | |
| 1754 | 1799 | // Now, for everything we are removing check they definitely are not allowed it. | 
| 1755 | 1800 |  	$existingGroups = explode(',', $additional_groups); | 
| 1756 | - foreach ($existingGroups as $key => $group) | |
| 1757 | - if (empty($group) || (in_array($group, $removals) && !in_array($group, $allowed))) | |
| 1801 | +	foreach ($existingGroups as $key => $group) { | |
| 1802 | + if (empty($group) || (in_array($group, $removals) && !in_array($group, $allowed))) | |
| 1758 | 1803 | unset($existingGroups[$key]); | 
| 1804 | + } | |
| 1759 | 1805 | |
| 1760 | 1806 | // Finally, do something with the current primary group. | 
| 1761 | 1807 | if (in_array($id_group, $removals)) | 
| 1762 | 1808 |  	{ | 
| 1763 | 1809 | // If this primary group is actually allowed keep it. | 
| 1764 | - if (in_array($id_group, $allowed)) | |
| 1765 | - $existingGroups[] = $id_group; | |
| 1810 | +		if (in_array($id_group, $allowed)) { | |
| 1811 | + $existingGroups[] = $id_group; | |
| 1812 | + } | |
| 1766 | 1813 | |
| 1767 | 1814 | // Either way, change the id_group back. | 
| 1768 | 1815 | if ($new_id_group < 1) | 
| 1769 | 1816 |  		{ | 
| 1770 | 1817 | // If we revert to the old id-group we need to ensure it wasn't from a subscription. | 
| 1771 | - foreach ($context['subscriptions'] as $id => $group) | |
| 1772 | - // It was? Make them a regular member then! | |
| 1818 | +			foreach ($context['subscriptions'] as $id => $group) { | |
| 1819 | + // It was? Make them a regular member then! | |
| 1773 | 1820 | if ($group['prim_group'] == $old_id_group) | 
| 1774 | 1821 | $old_id_group = 0; | 
| 1822 | + } | |
| 1775 | 1823 | |
| 1776 | 1824 | $id_group = $old_id_group; | 
| 1825 | +		} else { | |
| 1826 | + $id_group = $new_id_group; | |
| 1777 | 1827 | } | 
| 1778 | - else | |
| 1779 | - $id_group = $new_id_group; | |
| 1780 | 1828 | } | 
| 1781 | 1829 | |
| 1782 | 1830 | // Crazy stuff, we seem to have our groups fixed, just make them unique | 
| @@ -1796,8 +1844,8 @@ discard block | ||
| 1796 | 1844 | ); | 
| 1797 | 1845 | |
| 1798 | 1846 | // Disable the subscription. | 
| 1799 | - if (!$delete) | |
| 1800 | -		$smcFunc['db_query']('', ' | |
| 1847 | +	if (!$delete) { | |
| 1848 | +			$smcFunc['db_query']('', ' | |
| 1801 | 1849 |  			UPDATE {db_prefix}log_subscribed | 
| 1802 | 1850 |  			SET status = {int:not_active} | 
| 1803 | 1851 |  			WHERE id_member = {int:current_member} | 
| @@ -1808,9 +1856,10 @@ discard block | ||
| 1808 | 1856 | 'current_subscription' => $id_subscribe, | 
| 1809 | 1857 | ) | 
| 1810 | 1858 | ); | 
| 1859 | + } | |
| 1811 | 1860 | // Otherwise delete it! | 
| 1812 | - else | |
| 1813 | -		$smcFunc['db_query']('', ' | |
| 1861 | +	else { | |
| 1862 | +			$smcFunc['db_query']('', ' | |
| 1814 | 1863 |  			DELETE FROM {db_prefix}log_subscribed | 
| 1815 | 1864 |  			WHERE id_member = {int:current_member} | 
| 1816 | 1865 |  				AND id_subscribe = {int:current_subscription}', | 
| @@ -1819,7 +1868,8 @@ discard block | ||
| 1819 | 1868 | 'current_subscription' => $id_subscribe, | 
| 1820 | 1869 | ) | 
| 1821 | 1870 | ); | 
| 1822 | -} | |
| 1871 | + } | |
| 1872 | + } | |
| 1823 | 1873 | |
| 1824 | 1874 | /** | 
| 1825 | 1875 | * This just kind of caches all the subscription data. | 
| @@ -1828,8 +1878,9 @@ discard block | ||
| 1828 | 1878 |  { | 
| 1829 | 1879 | global $context, $txt, $modSettings, $smcFunc; | 
| 1830 | 1880 | |
| 1831 | - if (!empty($context['subscriptions'])) | |
| 1832 | - return; | |
| 1881 | +	if (!empty($context['subscriptions'])) { | |
| 1882 | + return; | |
| 1883 | + } | |
| 1833 | 1884 | |
| 1834 | 1885 | // Make sure this is loaded, just in case. | 
| 1835 | 1886 |  	loadLanguage('ManagePaid'); | 
| @@ -1846,10 +1897,11 @@ discard block | ||
| 1846 | 1897 | // Pick a cost. | 
| 1847 | 1898 | $costs = $smcFunc['json_decode']($row['cost'], true); | 
| 1848 | 1899 | |
| 1849 | - if ($row['length'] != 'F' && !empty($modSettings['paid_currency_symbol']) && !empty($costs['fixed'])) | |
| 1850 | - $cost = sprintf($modSettings['paid_currency_symbol'], $costs['fixed']); | |
| 1851 | - else | |
| 1852 | - $cost = '???'; | |
| 1900 | +		if ($row['length'] != 'F' && !empty($modSettings['paid_currency_symbol']) && !empty($costs['fixed'])) { | |
| 1901 | + $cost = sprintf($modSettings['paid_currency_symbol'], $costs['fixed']); | |
| 1902 | +		} else { | |
| 1903 | + $cost = '???'; | |
| 1904 | + } | |
| 1853 | 1905 | |
| 1854 | 1906 | // Do the span. | 
| 1855 | 1907 |  		preg_match('~(\d*)(\w)~', $row['length'], $match); | 
| @@ -1876,9 +1928,9 @@ discard block | ||
| 1876 | 1928 | $num_length *= 31556926; | 
| 1877 | 1929 | break; | 
| 1878 | 1930 | } | 
| 1931 | +		} else { | |
| 1932 | + $length = '??'; | |
| 1879 | 1933 | } | 
| 1880 | - else | |
| 1881 | - $length = '??'; | |
| 1882 | 1934 | |
| 1883 | 1935 | $context['subscriptions'][$row['id_subscribe']] = array( | 
| 1884 | 1936 | 'id' => $row['id_subscribe'], | 
| @@ -1913,8 +1965,9 @@ discard block | ||
| 1913 | 1965 |  	{ | 
| 1914 | 1966 | $ind = $row['status'] == 0 ? 'finished' : 'total'; | 
| 1915 | 1967 | |
| 1916 | - if (isset($context['subscriptions'][$row['id_subscribe']])) | |
| 1917 | - $context['subscriptions'][$row['id_subscribe']][$ind] = $row['member_count']; | |
| 1968 | +		if (isset($context['subscriptions'][$row['id_subscribe']])) { | |
| 1969 | + $context['subscriptions'][$row['id_subscribe']][$ind] = $row['member_count']; | |
| 1970 | + } | |
| 1918 | 1971 | } | 
| 1919 | 1972 | $smcFunc['db_free_result']($request); | 
| 1920 | 1973 | |
| @@ -1928,8 +1981,9 @@ discard block | ||
| 1928 | 1981 | ); | 
| 1929 | 1982 | while ($row = $smcFunc['db_fetch_assoc']($request)) | 
| 1930 | 1983 |  	{ | 
| 1931 | - if (isset($context['subscriptions'][$row['id_subscribe']])) | |
| 1932 | - $context['subscriptions'][$row['id_subscribe']]['pending'] = $row['total_pending']; | |
| 1984 | +		if (isset($context['subscriptions'][$row['id_subscribe']])) { | |
| 1985 | + $context['subscriptions'][$row['id_subscribe']]['pending'] = $row['total_pending']; | |
| 1986 | + } | |
| 1933 | 1987 | } | 
| 1934 | 1988 | $smcFunc['db_free_result']($request); | 
| 1935 | 1989 | } | 
| @@ -2183,7 +2183,7 @@ discard block | ||
| 2183 | 2183 | * Deletes a single or a group of alerts by ID | 
| 2184 | 2184 | * | 
| 2185 | 2185 | * @param int|array The ID of a single alert to delete or an array containing the IDs of multiple alerts. The function will convert integers into an array for better handling. | 
| 2186 | - * @param bool|int $memID The user ID. Used to update the user unread alerts count. | |
| 2186 | + * @param integer $memID The user ID. Used to update the user unread alerts count. | |
| 2187 | 2187 | * @return void|int If the $memID param is set, returns the new amount of unread alerts. | 
| 2188 | 2188 | */ | 
| 2189 | 2189 | function alert_delete($toDelete, $memID = false) | 
| @@ -2839,7 +2839,7 @@ discard block | ||
| 2839 | 2839 | /** | 
| 2840 | 2840 | * Handles the "manage groups" section of the profile | 
| 2841 | 2841 | * | 
| 2842 | - * @return true Always returns true | |
| 2842 | + * @return boolean Always returns true | |
| 2843 | 2843 | */ | 
| 2844 | 2844 | function profileLoadGroups() | 
| 2845 | 2845 |  { | 
| @@ -2896,7 +2896,7 @@ discard block | ||
| 2896 | 2896 | /** | 
| 2897 | 2897 | * Load key signature context data. | 
| 2898 | 2898 | * | 
| 2899 | - * @return true Always returns true | |
| 2899 | + * @return boolean Always returns true | |
| 2900 | 2900 | */ | 
| 2901 | 2901 | function profileLoadSignatureData() | 
| 2902 | 2902 |  { | 
| @@ -2960,7 +2960,7 @@ discard block | ||
| 2960 | 2960 | /** | 
| 2961 | 2961 | * Load avatar context data. | 
| 2962 | 2962 | * | 
| 2963 | - * @return true Always returns true | |
| 2963 | + * @return boolean Always returns true | |
| 2964 | 2964 | */ | 
| 2965 | 2965 | function profileLoadAvatarData() | 
| 2966 | 2966 |  { | 
| @@ -3033,7 +3033,7 @@ discard block | ||
| 3033 | 3033 | * Save a members group. | 
| 3034 | 3034 | * | 
| 3035 | 3035 | * @param int &$value The ID of the (new) primary group | 
| 3036 | - * @return true Always returns true | |
| 3036 | + * @return boolean Always returns true | |
| 3037 | 3037 | */ | 
| 3038 | 3038 | function profileSaveGroups(&$value) | 
| 3039 | 3039 |  { | 
| @@ -3138,7 +3138,7 @@ discard block | ||
| 3138 | 3138 | * @todo argh, the avatar here. Take this out of here! | 
| 3139 | 3139 | * | 
| 3140 | 3140 | * @param string &$value What kind of avatar we're expecting. Can be 'none', 'server_stored', 'gravatar', 'external' or 'upload' | 
| 3141 | - * @return bool|string False if success (or if memID is empty and password authentication failed), otherwise a string indicating what error occurred | |
| 3141 | + * @return false|string False if success (or if memID is empty and password authentication failed), otherwise a string indicating what error occurred | |
| 3142 | 3142 | */ | 
| 3143 | 3143 | function profileSaveAvatarData(&$value) | 
| 3144 | 3144 |  { | 
| @@ -15,8 +15,9 @@ discard block | ||
| 15 | 15 | * @version 2.1 Beta 4 | 
| 16 | 16 | */ | 
| 17 | 17 | |
| 18 | -if (!defined('SMF')) | |
| 18 | +if (!defined('SMF')) { | |
| 19 | 19 |  	die('No direct access...'); | 
| 20 | +} | |
| 20 | 21 | |
| 21 | 22 | /** | 
| 22 | 23 | * This defines every profile field known to man. | 
| @@ -29,8 +30,9 @@ discard block | ||
| 29 | 30 | global $sourcedir, $profile_vars; | 
| 30 | 31 | |
| 31 | 32 | // Don't load this twice! | 
| 32 | - if (!empty($profile_fields) && !$force_reload) | |
| 33 | - return; | |
| 33 | +	if (!empty($profile_fields) && !$force_reload) { | |
| 34 | + return; | |
| 35 | + } | |
| 34 | 36 | |
| 35 | 37 | /* This horrific array defines all the profile fields in the whole world! | 
| 36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item | 
| @@ -103,13 +105,14 @@ discard block | ||
| 103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) | 
| 104 | 106 |  				{ | 
| 105 | 107 | // Set to blank? | 
| 106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) | |
| 107 | - $value = '1004-01-01'; | |
| 108 | - else | |
| 109 | -						$value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; | |
| 108 | +					if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { | |
| 109 | + $value = '1004-01-01'; | |
| 110 | +					} else { | |
| 111 | +											$value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; | |
| 112 | + } | |
| 113 | +				} else { | |
| 114 | + $value = '1004-01-01'; | |
| 110 | 115 | } | 
| 111 | - else | |
| 112 | - $value = '1004-01-01'; | |
| 113 | 116 | |
| 114 | 117 | $profile_vars['birthdate'] = $value; | 
| 115 | 118 | $cur_profile['birthdate'] = $value; | 
| @@ -127,8 +130,7 @@ discard block | ||
| 127 | 130 |  				{ | 
| 128 | 131 |  					$value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '1004-01-01'; | 
| 129 | 132 | return true; | 
| 130 | - } | |
| 131 | - else | |
| 133 | + } else | |
| 132 | 134 |  				{ | 
| 133 | 135 | $value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate']; | 
| 134 | 136 | return false; | 
| @@ -150,10 +152,11 @@ discard block | ||
| 150 | 152 |  					return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); | 
| 151 | 153 | } | 
| 152 | 154 | // As long as it doesn't equal "N/A"... | 
| 153 | -				elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) | |
| 154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; | |
| 155 | - else | |
| 156 | - $value = $cur_profile['date_registered']; | |
| 155 | +				elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { | |
| 156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; | |
| 157 | +				} else { | |
| 158 | + $value = $cur_profile['date_registered']; | |
| 159 | + } | |
| 157 | 160 | |
| 158 | 161 | return true; | 
| 159 | 162 | }, | 
| @@ -177,8 +180,9 @@ discard block | ||
| 177 | 180 |  			{ | 
| 178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; | 
| 179 | 182 | |
| 180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) | |
| 181 | - return false; | |
| 183 | +				if (strtolower($value) == strtolower($old_profile['email_address'])) { | |
| 184 | + return false; | |
| 185 | + } | |
| 182 | 186 | |
| 183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); | 
| 184 | 188 | |
| @@ -254,11 +258,11 @@ discard block | ||
| 254 | 258 | |
| 255 | 259 | if (isset($context['profile_languages'][$value])) | 
| 256 | 260 |  				{ | 
| 257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) | |
| 258 | - $_SESSION['language'] = $value; | |
| 261 | +					if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { | |
| 262 | + $_SESSION['language'] = $value; | |
| 263 | + } | |
| 259 | 264 | return true; | 
| 260 | - } | |
| 261 | - else | |
| 265 | + } else | |
| 262 | 266 |  				{ | 
| 263 | 267 | $value = $cur_profile['lngfile']; | 
| 264 | 268 | return false; | 
| @@ -282,13 +286,14 @@ discard block | ||
| 282 | 286 | |
| 283 | 287 | // Maybe they are trying to change their password as well? | 
| 284 | 288 | $resetPassword = true; | 
| 285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) | |
| 286 | - $resetPassword = false; | |
| 289 | +					if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { | |
| 290 | + $resetPassword = false; | |
| 291 | + } | |
| 287 | 292 | |
| 288 | 293 | // Do the reset... this will send them an email too. | 
| 289 | - if ($resetPassword) | |
| 290 | - resetPassword($context['id_member'], $value); | |
| 291 | - elseif ($value !== null) | |
| 294 | +					if ($resetPassword) { | |
| 295 | + resetPassword($context['id_member'], $value); | |
| 296 | + } elseif ($value !== null) | |
| 292 | 297 |  					{ | 
| 293 | 298 |  						validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); | 
| 294 | 299 |  						updateMemberData($context['id_member'], array('member_name' => $value)); | 
| @@ -312,20 +317,23 @@ discard block | ||
| 312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) | 
| 313 | 318 |  			{ | 
| 314 | 319 | // If we didn't try it then ignore it! | 
| 315 | - if ($value == '') | |
| 316 | - return false; | |
| 320 | +				if ($value == '') { | |
| 321 | + return false; | |
| 322 | + } | |
| 317 | 323 | |
| 318 | 324 | // Do the two entries for the password even match? | 
| 319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) | |
| 320 | - return 'bad_new_password'; | |
| 325 | +				if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { | |
| 326 | + return 'bad_new_password'; | |
| 327 | + } | |
| 321 | 328 | |
| 322 | 329 | // Let's get the validation function into play... | 
| 323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); | 
| 324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); | 
| 325 | 332 | |
| 326 | 333 | // Were there errors? | 
| 327 | - if ($passwordErrors != null) | |
| 328 | - return 'password_' . $passwordErrors; | |
| 334 | +				if ($passwordErrors != null) { | |
| 335 | + return 'password_' . $passwordErrors; | |
| 336 | + } | |
| 329 | 337 | |
| 330 | 338 | // Set up the new password variable... ready for storage. | 
| 331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); | 
| @@ -350,8 +358,9 @@ discard block | ||
| 350 | 358 | 'permission' => 'profile_blurb', | 
| 351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) | 
| 352 | 360 |  			{ | 
| 353 | - if ($smcFunc['strlen']($value) > 50) | |
| 354 | - return 'personal_text_too_long'; | |
| 361 | +				if ($smcFunc['strlen']($value) > 50) { | |
| 362 | + return 'personal_text_too_long'; | |
| 363 | + } | |
| 355 | 364 | |
| 356 | 365 | return true; | 
| 357 | 366 | }, | 
| @@ -386,10 +395,11 @@ discard block | ||
| 386 | 395 | 'permission' => 'moderate_forum', | 
| 387 | 396 | 'input_validate' => function(&$value) | 
| 388 | 397 |  			{ | 
| 389 | - if (!is_numeric($value)) | |
| 390 | - return 'digits_only'; | |
| 391 | - else | |
| 392 | -					$value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; | |
| 398 | +				if (!is_numeric($value)) { | |
| 399 | + return 'digits_only'; | |
| 400 | +				} else { | |
| 401 | +									$value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; | |
| 402 | + } | |
| 393 | 403 | return true; | 
| 394 | 404 | }, | 
| 395 | 405 | ), | 
| @@ -405,15 +415,16 @@ discard block | ||
| 405 | 415 |  			{ | 
| 406 | 416 |  				$value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); | 
| 407 | 417 | |
| 408 | - if (trim($value) == '') | |
| 409 | - return 'no_name'; | |
| 410 | - elseif ($smcFunc['strlen']($value) > 60) | |
| 411 | - return 'name_too_long'; | |
| 412 | - elseif ($cur_profile['real_name'] != $value) | |
| 418 | +				if (trim($value) == '') { | |
| 419 | + return 'no_name'; | |
| 420 | +				} elseif ($smcFunc['strlen']($value) > 60) { | |
| 421 | + return 'name_too_long'; | |
| 422 | + } elseif ($cur_profile['real_name'] != $value) | |
| 413 | 423 |  				{ | 
| 414 | 424 | require_once($sourcedir . '/Subs-Members.php'); | 
| 415 | - if (isReservedName($value, $context['id_member'])) | |
| 416 | - return 'name_taken'; | |
| 425 | +					if (isReservedName($value, $context['id_member'])) { | |
| 426 | + return 'name_taken'; | |
| 427 | + } | |
| 417 | 428 | } | 
| 418 | 429 | return true; | 
| 419 | 430 | }, | 
| @@ -471,8 +482,9 @@ discard block | ||
| 471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] | 
| 472 | 483 | ); | 
| 473 | 484 | |
| 474 | - if ($context['smiley_sets'][$i]['selected']) | |
| 475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; | |
| 485 | +					if ($context['smiley_sets'][$i]['selected']) { | |
| 486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; | |
| 487 | + } | |
| 476 | 488 | } | 
| 477 | 489 | return true; | 
| 478 | 490 | }, | 
| @@ -481,8 +493,9 @@ discard block | ||
| 481 | 493 | global $modSettings; | 
| 482 | 494 | |
| 483 | 495 |  				$smiley_sets = explode(',', $modSettings['smiley_sets_known']); | 
| 484 | - if (!in_array($value, $smiley_sets) && $value != 'none') | |
| 485 | - $value = ''; | |
| 496 | +				if (!in_array($value, $smiley_sets) && $value != 'none') { | |
| 497 | + $value = ''; | |
| 498 | + } | |
| 486 | 499 | return true; | 
| 487 | 500 | }, | 
| 488 | 501 | ), | 
| @@ -497,8 +510,9 @@ discard block | ||
| 497 | 510 |  				loadLanguage('Settings'); | 
| 498 | 511 | |
| 499 | 512 | $context['allow_no_censored'] = false; | 
| 500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) | |
| 501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); | |
| 513 | +				if ($user_info['is_admin'] || $context['user']['is_owner']) { | |
| 514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); | |
| 515 | + } | |
| 502 | 516 | |
| 503 | 517 | return true; | 
| 504 | 518 | }, | 
| @@ -545,8 +559,9 @@ discard block | ||
| 545 | 559 | 'input_validate' => function($value) | 
| 546 | 560 |  			{ | 
| 547 | 561 | $tz = smf_list_timezones(); | 
| 548 | - if (!isset($tz[$value])) | |
| 549 | - return 'bad_timezone'; | |
| 562 | +				if (!isset($tz[$value])) { | |
| 563 | + return 'bad_timezone'; | |
| 564 | + } | |
| 550 | 565 | |
| 551 | 566 | return true; | 
| 552 | 567 | }, | 
| @@ -561,8 +576,9 @@ discard block | ||
| 561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), | 
| 562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) | 
| 563 | 578 |  			{ | 
| 564 | - if ($smcFunc['strlen']($value) > 50) | |
| 565 | - return 'user_title_too_long'; | |
| 579 | +				if ($smcFunc['strlen']($value) > 50) { | |
| 580 | + return 'user_title_too_long'; | |
| 581 | + } | |
| 566 | 582 | |
| 567 | 583 | return true; | 
| 568 | 584 | }, | 
| @@ -584,10 +600,12 @@ discard block | ||
| 584 | 600 | // Fix the URL... | 
| 585 | 601 | 'input_validate' => function(&$value) | 
| 586 | 602 |  			{ | 
| 587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) | |
| 588 | - $value = 'http://' . $value; | |
| 589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) | |
| 590 | - $value = ''; | |
| 603 | +				if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { | |
| 604 | + $value = 'http://' . $value; | |
| 605 | + } | |
| 606 | +				if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { | |
| 607 | + $value = ''; | |
| 608 | + } | |
| 591 | 609 | $value = (string) validate_iri(sanitize_iri($value)); | 
| 592 | 610 | return true; | 
| 593 | 611 | }, | 
| @@ -602,16 +620,19 @@ discard block | ||
| 602 | 620 | foreach ($profile_fields as $key => $field) | 
| 603 | 621 |  	{ | 
| 604 | 622 | // Do we have permission to do this? | 
| 605 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) | |
| 606 | - unset($profile_fields[$key]); | |
| 623 | +		if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { | |
| 624 | + unset($profile_fields[$key]); | |
| 625 | + } | |
| 607 | 626 | |
| 608 | 627 | // Is it enabled? | 
| 609 | - if (isset($field['enabled']) && !$field['enabled']) | |
| 610 | - unset($profile_fields[$key]); | |
| 628 | +		if (isset($field['enabled']) && !$field['enabled']) { | |
| 629 | + unset($profile_fields[$key]); | |
| 630 | + } | |
| 611 | 631 | |
| 612 | 632 | // Is it specifically disabled? | 
| 613 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) | |
| 614 | - unset($profile_fields[$key]); | |
| 633 | +		if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { | |
| 634 | + unset($profile_fields[$key]); | |
| 635 | + } | |
| 615 | 636 | } | 
| 616 | 637 | } | 
| 617 | 638 | |
| @@ -636,9 +657,10 @@ discard block | ||
| 636 | 657 | loadProfileFields(true); | 
| 637 | 658 | |
| 638 | 659 | // First check for any linked sets. | 
| 639 | - foreach ($profile_fields as $key => $field) | |
| 640 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) | |
| 660 | +	foreach ($profile_fields as $key => $field) { | |
| 661 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) | |
| 641 | 662 | $fields[] = $key; | 
| 663 | + } | |
| 642 | 664 | |
| 643 | 665 | $i = 0; | 
| 644 | 666 | $last_type = ''; | 
| @@ -650,38 +672,46 @@ discard block | ||
| 650 | 672 | $cur_field = &$profile_fields[$field]; | 
| 651 | 673 | |
| 652 | 674 | // Does it have a preload and does that preload succeed? | 
| 653 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) | |
| 654 | - continue; | |
| 675 | +			if (isset($cur_field['preload']) && !$cur_field['preload']()) { | |
| 676 | + continue; | |
| 677 | + } | |
| 655 | 678 | |
| 656 | 679 | // If this is anything but complex we need to do more cleaning! | 
| 657 | 680 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') | 
| 658 | 681 |  			{ | 
| 659 | - if (!isset($cur_field['label'])) | |
| 660 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; | |
| 682 | +				if (!isset($cur_field['label'])) { | |
| 683 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; | |
| 684 | + } | |
| 661 | 685 | |
| 662 | 686 | // Everything has a value! | 
| 663 | - if (!isset($cur_field['value'])) | |
| 664 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; | |
| 687 | +				if (!isset($cur_field['value'])) { | |
| 688 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; | |
| 689 | + } | |
| 665 | 690 | |
| 666 | 691 | // Any input attributes? | 
| 667 | 692 |  				$cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; | 
| 668 | 693 | } | 
| 669 | 694 | |
| 670 | 695 | // Was there an error with this field on posting? | 
| 671 | - if (isset($context['profile_errors'][$field])) | |
| 672 | - $cur_field['is_error'] = true; | |
| 696 | +			if (isset($context['profile_errors'][$field])) { | |
| 697 | + $cur_field['is_error'] = true; | |
| 698 | + } | |
| 673 | 699 | |
| 674 | 700 | // Any javascript stuff? | 
| 675 | - if (!empty($cur_field['js_submit'])) | |
| 676 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; | |
| 677 | - if (!empty($cur_field['js'])) | |
| 678 | - $context['profile_javascript'] .= $cur_field['js']; | |
| 701 | +			if (!empty($cur_field['js_submit'])) { | |
| 702 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; | |
| 703 | + } | |
| 704 | +			if (!empty($cur_field['js'])) { | |
| 705 | + $context['profile_javascript'] .= $cur_field['js']; | |
| 706 | + } | |
| 679 | 707 | |
| 680 | 708 | // Any template stuff? | 
| 681 | - if (!empty($cur_field['prehtml'])) | |
| 682 | - $context['profile_prehtml'] .= $cur_field['prehtml']; | |
| 683 | - if (!empty($cur_field['posthtml'])) | |
| 684 | - $context['profile_posthtml'] .= $cur_field['posthtml']; | |
| 709 | +			if (!empty($cur_field['prehtml'])) { | |
| 710 | + $context['profile_prehtml'] .= $cur_field['prehtml']; | |
| 711 | + } | |
| 712 | +			if (!empty($cur_field['posthtml'])) { | |
| 713 | + $context['profile_posthtml'] .= $cur_field['posthtml']; | |
| 714 | + } | |
| 685 | 715 | |
| 686 | 716 | // Finally put it into context? | 
| 687 | 717 | if ($cur_field['type'] != 'hidden') | 
| @@ -714,12 +744,14 @@ discard block | ||
| 714 | 744 | }, false);' : ''), true); | 
| 715 | 745 | |
| 716 | 746 | // Any onsubmit javascript? | 
| 717 | - if (!empty($context['profile_onsubmit_javascript'])) | |
| 718 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); | |
| 747 | +	if (!empty($context['profile_onsubmit_javascript'])) { | |
| 748 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); | |
| 749 | + } | |
| 719 | 750 | |
| 720 | 751 | // Any totally custom stuff? | 
| 721 | - if (!empty($context['profile_javascript'])) | |
| 722 | - addInlineJavaScript($context['profile_javascript'], true); | |
| 752 | +	if (!empty($context['profile_javascript'])) { | |
| 753 | + addInlineJavaScript($context['profile_javascript'], true); | |
| 754 | + } | |
| 723 | 755 | |
| 724 | 756 | // Free up some memory. | 
| 725 | 757 | unset($profile_fields); | 
| @@ -740,8 +772,9 @@ discard block | ||
| 740 | 772 | |
| 741 | 773 | // This allows variables to call activities when they save - by default just to reload their settings | 
| 742 | 774 | $context['profile_execute_on_save'] = array(); | 
| 743 | - if ($context['user']['is_owner']) | |
| 744 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; | |
| 775 | +	if ($context['user']['is_owner']) { | |
| 776 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; | |
| 777 | + } | |
| 745 | 778 | |
| 746 | 779 | // Assume we log nothing. | 
| 747 | 780 | $context['log_changes'] = array(); | 
| @@ -749,8 +782,9 @@ discard block | ||
| 749 | 782 | // Cycle through the profile fields working out what to do! | 
| 750 | 783 | foreach ($profile_fields as $key => $field) | 
| 751 | 784 |  	{ | 
| 752 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) | |
| 753 | - continue; | |
| 785 | +		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { | |
| 786 | + continue; | |
| 787 | + } | |
| 754 | 788 | |
| 755 | 789 | // What gets updated? | 
| 756 | 790 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; | 
| @@ -778,12 +812,13 @@ discard block | ||
| 778 | 812 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; | 
| 779 | 813 | |
| 780 | 814 | // Finally, clean up certain types. | 
| 781 | - if ($field['cast_type'] == 'int') | |
| 782 | - $_POST[$key] = (int) $_POST[$key]; | |
| 783 | - elseif ($field['cast_type'] == 'float') | |
| 784 | - $_POST[$key] = (float) $_POST[$key]; | |
| 785 | - elseif ($field['cast_type'] == 'check') | |
| 786 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; | |
| 815 | +		if ($field['cast_type'] == 'int') { | |
| 816 | + $_POST[$key] = (int) $_POST[$key]; | |
| 817 | +		} elseif ($field['cast_type'] == 'float') { | |
| 818 | + $_POST[$key] = (float) $_POST[$key]; | |
| 819 | +		} elseif ($field['cast_type'] == 'check') { | |
| 820 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; | |
| 821 | + } | |
| 787 | 822 | |
| 788 | 823 | // If we got here we're doing OK. | 
| 789 | 824 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) | 
| @@ -794,11 +829,12 @@ discard block | ||
| 794 | 829 | $cur_profile[$key] = $_POST[$key]; | 
| 795 | 830 | |
| 796 | 831 | // Are we logging it? | 
| 797 | - if (!empty($field['log_change']) && isset($old_profile[$key])) | |
| 798 | - $context['log_changes'][$key] = array( | |
| 832 | +			if (!empty($field['log_change']) && isset($old_profile[$key])) { | |
| 833 | + $context['log_changes'][$key] = array( | |
| 799 | 834 | 'previous' => $old_profile[$key], | 
| 800 | 835 | 'new' => $_POST[$key], | 
| 801 | 836 | ); | 
| 837 | + } | |
| 802 | 838 | } | 
| 803 | 839 | |
| 804 | 840 | // Logging group changes are a bit different... | 
| @@ -831,10 +867,11 @@ discard block | ||
| 831 | 867 |  				{ | 
| 832 | 868 | foreach ($groups as $id => $group) | 
| 833 | 869 |  					{ | 
| 834 | - if (isset($context['member_groups'][$group])) | |
| 835 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; | |
| 836 | - else | |
| 837 | - unset($additional_groups[$type][$id]); | |
| 870 | +						if (isset($context['member_groups'][$group])) { | |
| 871 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; | |
| 872 | +						} else { | |
| 873 | + unset($additional_groups[$type][$id]); | |
| 874 | + } | |
| 838 | 875 | } | 
| 839 | 876 |  					$additional_groups[$type] = implode(', ', $additional_groups[$type]); | 
| 840 | 877 | } | 
| @@ -845,10 +882,11 @@ discard block | ||
| 845 | 882 | } | 
| 846 | 883 | |
| 847 | 884 | // @todo Temporary | 
| 848 | - if ($context['user']['is_owner']) | |
| 849 | -		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); | |
| 850 | - else | |
| 851 | -		$changeOther = allowedTo('profile_extra_any'); | |
| 885 | +	if ($context['user']['is_owner']) { | |
| 886 | +			$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); | |
| 887 | +	} else { | |
| 888 | +			$changeOther = allowedTo('profile_extra_any'); | |
| 889 | + } | |
| 852 | 890 | if ($changeOther && empty($post_errors)) | 
| 853 | 891 |  	{ | 
| 854 | 892 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); | 
| @@ -856,8 +894,9 @@ discard block | ||
| 856 | 894 |  		{ | 
| 857 | 895 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); | 
| 858 | 896 | |
| 859 | - if (!empty($custom_fields_errors)) | |
| 860 | - $post_errors = array_merge($post_errors, $custom_fields_errors); | |
| 897 | +			if (!empty($custom_fields_errors)) { | |
| 898 | + $post_errors = array_merge($post_errors, $custom_fields_errors); | |
| 899 | + } | |
| 861 | 900 | } | 
| 862 | 901 | } | 
| 863 | 902 | |
| @@ -883,9 +922,9 @@ discard block | ||
| 883 | 922 | if ($context['user']['is_owner']) | 
| 884 | 923 |  	{ | 
| 885 | 924 |  		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); | 
| 925 | +	} else { | |
| 926 | +			$changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); | |
| 886 | 927 | } | 
| 887 | - else | |
| 888 | -		$changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); | |
| 889 | 928 | |
| 890 | 929 | // Arrays of all the changes - makes things easier. | 
| 891 | 930 | $profile_bools = array(); | 
| @@ -896,22 +935,25 @@ discard block | ||
| 896 | 935 | 'ignore_boards', | 
| 897 | 936 | ); | 
| 898 | 937 | |
| 899 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) | |
| 900 | - $_POST['ignore_brd'] = array(); | |
| 938 | +	if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { | |
| 939 | + $_POST['ignore_brd'] = array(); | |
| 940 | + } | |
| 901 | 941 | |
| 902 | 942 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. | 
| 903 | 943 | if (isset($_POST['ignore_brd'])) | 
| 904 | 944 |  	{ | 
| 905 | - if (!is_array($_POST['ignore_brd'])) | |
| 906 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); | |
| 945 | +		if (!is_array($_POST['ignore_brd'])) { | |
| 946 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); | |
| 947 | + } | |
| 907 | 948 | |
| 908 | 949 | foreach ($_POST['ignore_brd'] as $k => $d) | 
| 909 | 950 |  		{ | 
| 910 | 951 | $d = (int) $d; | 
| 911 | - if ($d != 0) | |
| 912 | - $_POST['ignore_brd'][$k] = $d; | |
| 913 | - else | |
| 914 | - unset($_POST['ignore_brd'][$k]); | |
| 952 | +			if ($d != 0) { | |
| 953 | + $_POST['ignore_brd'][$k] = $d; | |
| 954 | +			} else { | |
| 955 | + unset($_POST['ignore_brd'][$k]); | |
| 956 | + } | |
| 915 | 957 | } | 
| 916 | 958 |  		$_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); | 
| 917 | 959 | unset($_POST['ignore_brd']); | 
| @@ -923,21 +965,26 @@ discard block | ||
| 923 | 965 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); | 
| 924 | 966 | //makeAvatarChanges($memID, $post_errors); | 
| 925 | 967 | |
| 926 | - if (!empty($_REQUEST['sa'])) | |
| 927 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); | |
| 968 | +		if (!empty($_REQUEST['sa'])) { | |
| 969 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); | |
| 970 | + } | |
| 928 | 971 | |
| 929 | - foreach ($profile_bools as $var) | |
| 930 | - if (isset($_POST[$var])) | |
| 972 | +		foreach ($profile_bools as $var) { | |
| 973 | + if (isset($_POST[$var])) | |
| 931 | 974 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; | 
| 932 | - foreach ($profile_ints as $var) | |
| 933 | - if (isset($_POST[$var])) | |
| 975 | + } | |
| 976 | +		foreach ($profile_ints as $var) { | |
| 977 | + if (isset($_POST[$var])) | |
| 934 | 978 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; | 
| 935 | - foreach ($profile_floats as $var) | |
| 936 | - if (isset($_POST[$var])) | |
| 979 | + } | |
| 980 | +		foreach ($profile_floats as $var) { | |
| 981 | + if (isset($_POST[$var])) | |
| 937 | 982 | $profile_vars[$var] = (float) $_POST[$var]; | 
| 938 | - foreach ($profile_strings as $var) | |
| 939 | - if (isset($_POST[$var])) | |
| 983 | + } | |
| 984 | +		foreach ($profile_strings as $var) { | |
| 985 | + if (isset($_POST[$var])) | |
| 940 | 986 | $profile_vars[$var] = $_POST[$var]; | 
| 987 | + } | |
| 941 | 988 | } | 
| 942 | 989 | } | 
| 943 | 990 | |
| @@ -971,8 +1018,9 @@ discard block | ||
| 971 | 1018 | ); | 
| 972 | 1019 | |
| 973 | 1020 | // Can't change reserved vars. | 
| 974 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) | |
| 975 | -		fatal_lang_error('no_access', false); | |
| 1021 | +	if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { | |
| 1022 | +			fatal_lang_error('no_access', false); | |
| 1023 | + } | |
| 976 | 1024 | |
| 977 | 1025 | // Don't allow any overriding of custom fields with default or non-default options. | 
| 978 | 1026 |  	$request = $smcFunc['db_query']('', ' | 
| @@ -984,8 +1032,9 @@ discard block | ||
| 984 | 1032 | ) | 
| 985 | 1033 | ); | 
| 986 | 1034 | $custom_fields = array(); | 
| 987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) | |
| 988 | - $custom_fields[] = $row['col_name']; | |
| 1035 | +	while ($row = $smcFunc['db_fetch_assoc']($request)) { | |
| 1036 | + $custom_fields[] = $row['col_name']; | |
| 1037 | + } | |
| 989 | 1038 | $smcFunc['db_free_result']($request); | 
| 990 | 1039 | |
| 991 | 1040 | // These are the theme changes... | 
| @@ -994,33 +1043,39 @@ discard block | ||
| 994 | 1043 |  	{ | 
| 995 | 1044 | foreach ($_POST['options'] as $opt => $val) | 
| 996 | 1045 |  		{ | 
| 997 | - if (in_array($opt, $custom_fields)) | |
| 998 | - continue; | |
| 1046 | +			if (in_array($opt, $custom_fields)) { | |
| 1047 | + continue; | |
| 1048 | + } | |
| 999 | 1049 | |
| 1000 | 1050 | // These need to be controlled. | 
| 1001 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') | |
| 1002 | - $val = max(0, min($val, 50)); | |
| 1051 | +			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { | |
| 1052 | + $val = max(0, min($val, 50)); | |
| 1053 | + } | |
| 1003 | 1054 | // We don't set this per theme anymore. | 
| 1004 | - elseif ($opt == 'allow_no_censored') | |
| 1005 | - continue; | |
| 1055 | +			elseif ($opt == 'allow_no_censored') { | |
| 1056 | + continue; | |
| 1057 | + } | |
| 1006 | 1058 | |
| 1007 | 1059 |  			$themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); | 
| 1008 | 1060 | } | 
| 1009 | 1061 | } | 
| 1010 | 1062 | |
| 1011 | 1063 | $erase_options = array(); | 
| 1012 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) | |
| 1013 | - foreach ($_POST['default_options'] as $opt => $val) | |
| 1064 | +	if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { | |
| 1065 | + foreach ($_POST['default_options'] as $opt => $val) | |
| 1014 | 1066 |  		{ | 
| 1015 | 1067 | if (in_array($opt, $custom_fields)) | 
| 1016 | 1068 | continue; | 
| 1069 | + } | |
| 1017 | 1070 | |
| 1018 | 1071 | // These need to be controlled. | 
| 1019 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') | |
| 1020 | - $val = max(0, min($val, 50)); | |
| 1072 | +			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { | |
| 1073 | + $val = max(0, min($val, 50)); | |
| 1074 | + } | |
| 1021 | 1075 | // Only let admins and owners change the censor. | 
| 1022 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) | |
| 1023 | - continue; | |
| 1076 | +			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { | |
| 1077 | + continue; | |
| 1078 | + } | |
| 1024 | 1079 | |
| 1025 | 1080 |  			$themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); | 
| 1026 | 1081 | $erase_options[] = $opt; | 
| @@ -1056,8 +1111,9 @@ discard block | ||
| 1056 | 1111 | |
| 1057 | 1112 | // Admins can choose any theme, even if it's not enabled... | 
| 1058 | 1113 |  		$themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); | 
| 1059 | - foreach ($themes as $t) | |
| 1060 | -			cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); | |
| 1114 | +		foreach ($themes as $t) { | |
| 1115 | +					cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); | |
| 1116 | + } | |
| 1061 | 1117 | } | 
| 1062 | 1118 | } | 
| 1063 | 1119 | |
| @@ -1076,8 +1132,9 @@ discard block | ||
| 1076 | 1132 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) | 
| 1077 | 1133 |  	{ | 
| 1078 | 1134 | // Make sure only integers are deleted. | 
| 1079 | - foreach ($_POST['notify_boards'] as $index => $id) | |
| 1080 | - $_POST['notify_boards'][$index] = (int) $id; | |
| 1135 | +		foreach ($_POST['notify_boards'] as $index => $id) { | |
| 1136 | + $_POST['notify_boards'][$index] = (int) $id; | |
| 1137 | + } | |
| 1081 | 1138 | |
| 1082 | 1139 | // id_board = 0 is reserved for topic notifications. | 
| 1083 | 1140 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); | 
| @@ -1096,8 +1153,9 @@ discard block | ||
| 1096 | 1153 | // We are editing topic notifications...... | 
| 1097 | 1154 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) | 
| 1098 | 1155 |  	{ | 
| 1099 | - foreach ($_POST['notify_topics'] as $index => $id) | |
| 1100 | - $_POST['notify_topics'][$index] = (int) $id; | |
| 1156 | +		foreach ($_POST['notify_topics'] as $index => $id) { | |
| 1157 | + $_POST['notify_topics'][$index] = (int) $id; | |
| 1158 | + } | |
| 1101 | 1159 | |
| 1102 | 1160 | // Make sure there are no zeros left. | 
| 1103 | 1161 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); | 
| @@ -1111,16 +1169,18 @@ discard block | ||
| 1111 | 1169 | 'selected_member' => $memID, | 
| 1112 | 1170 | ) | 
| 1113 | 1171 | ); | 
| 1114 | - foreach ($_POST['notify_topics'] as $topic) | |
| 1115 | -			setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); | |
| 1172 | +		foreach ($_POST['notify_topics'] as $topic) { | |
| 1173 | +					setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); | |
| 1174 | + } | |
| 1116 | 1175 | } | 
| 1117 | 1176 | |
| 1118 | 1177 | // We are removing topic preferences | 
| 1119 | 1178 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) | 
| 1120 | 1179 |  	{ | 
| 1121 | 1180 | $prefs = array(); | 
| 1122 | - foreach ($_POST['notify_topics'] as $topic) | |
| 1123 | - $prefs[] = 'topic_notify_' . $topic; | |
| 1181 | +		foreach ($_POST['notify_topics'] as $topic) { | |
| 1182 | + $prefs[] = 'topic_notify_' . $topic; | |
| 1183 | + } | |
| 1124 | 1184 | deleteNotifyPrefs($memID, $prefs); | 
| 1125 | 1185 | } | 
| 1126 | 1186 | |
| @@ -1128,8 +1188,9 @@ discard block | ||
| 1128 | 1188 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) | 
| 1129 | 1189 |  	{ | 
| 1130 | 1190 | $prefs = array(); | 
| 1131 | - foreach ($_POST['notify_boards'] as $board) | |
| 1132 | - $prefs[] = 'board_notify_' . $board; | |
| 1191 | +		foreach ($_POST['notify_boards'] as $board) { | |
| 1192 | + $prefs[] = 'board_notify_' . $board; | |
| 1193 | + } | |
| 1133 | 1194 | deleteNotifyPrefs($memID, $prefs); | 
| 1134 | 1195 | } | 
| 1135 | 1196 | } | 
| @@ -1150,8 +1211,9 @@ discard block | ||
| 1150 | 1211 | |
| 1151 | 1212 | $errors = array(); | 
| 1152 | 1213 | |
| 1153 | - if ($sanitize && isset($_POST['customfield'])) | |
| 1154 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); | |
| 1214 | +	if ($sanitize && isset($_POST['customfield'])) { | |
| 1215 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); | |
| 1216 | + } | |
| 1155 | 1217 | |
| 1156 | 1218 |  	$where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; | 
| 1157 | 1219 | |
| @@ -1177,26 +1239,29 @@ discard block | ||
| 1177 | 1239 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) | 
| 1178 | 1240 | - The area isn't registration, and if it is that the field is not supposed to be shown there. | 
| 1179 | 1241 | */ | 
| 1180 | -		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) | |
| 1181 | - continue; | |
| 1242 | +		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { | |
| 1243 | + continue; | |
| 1244 | + } | |
| 1182 | 1245 | |
| 1183 | 1246 | // Validate the user data. | 
| 1184 | - if ($row['field_type'] == 'check') | |
| 1185 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; | |
| 1186 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') | |
| 1247 | +		if ($row['field_type'] == 'check') { | |
| 1248 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; | |
| 1249 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') | |
| 1187 | 1250 |  		{ | 
| 1188 | 1251 | $value = $row['default_value']; | 
| 1189 | -			foreach (explode(',', $row['field_options']) as $k => $v) | |
| 1190 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) | |
| 1252 | +			foreach (explode(',', $row['field_options']) as $k => $v) { | |
| 1253 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) | |
| 1191 | 1254 | $value = $v; | 
| 1255 | + } | |
| 1192 | 1256 | } | 
| 1193 | 1257 | // Otherwise some form of text! | 
| 1194 | 1258 | else | 
| 1195 | 1259 |  		{ | 
| 1196 | 1260 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; | 
| 1197 | 1261 | |
| 1198 | - if ($row['field_length']) | |
| 1199 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); | |
| 1262 | +			if ($row['field_length']) { | |
| 1263 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); | |
| 1264 | + } | |
| 1200 | 1265 | |
| 1201 | 1266 | // Any masks? | 
| 1202 | 1267 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') | 
| @@ -1205,36 +1270,34 @@ discard block | ||
| 1205 | 1270 | $valueReference = un_htmlspecialchars($value); | 
| 1206 | 1271 | |
| 1207 | 1272 | // Try and avoid some checks. '0' could be a valid non-empty value. | 
| 1208 | - if (empty($value) && !is_numeric($value)) | |
| 1209 | - $value = ''; | |
| 1273 | +				if (empty($value) && !is_numeric($value)) { | |
| 1274 | + $value = ''; | |
| 1275 | + } | |
| 1210 | 1276 | |
| 1211 | 1277 |  				if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference))) | 
| 1212 | 1278 |  				{ | 
| 1213 | - if ($returnErrors) | |
| 1214 | - $errors[] = 'custom_field_nohtml_fail'; | |
| 1215 | - | |
| 1216 | - else | |
| 1217 | - $value = ''; | |
| 1218 | - } | |
| 1219 | - elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) | |
| 1279 | +					if ($returnErrors) { | |
| 1280 | + $errors[] = 'custom_field_nohtml_fail'; | |
| 1281 | +					} else { | |
| 1282 | + $value = ''; | |
| 1283 | + } | |
| 1284 | + } elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) | |
| 1220 | 1285 |  				{ | 
| 1221 | - if ($returnErrors) | |
| 1222 | - $errors[] = 'custom_field_mail_fail'; | |
| 1223 | - | |
| 1224 | - else | |
| 1225 | - $value = ''; | |
| 1226 | - } | |
| 1227 | - elseif ($row['mask'] == 'number') | |
| 1286 | +					if ($returnErrors) { | |
| 1287 | + $errors[] = 'custom_field_mail_fail'; | |
| 1288 | +					} else { | |
| 1289 | + $value = ''; | |
| 1290 | + } | |
| 1291 | + } elseif ($row['mask'] == 'number') | |
| 1228 | 1292 |  				{ | 
| 1229 | 1293 | $value = (int) $value; | 
| 1230 | - } | |
| 1231 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) | |
| 1294 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) | |
| 1232 | 1295 |  				{ | 
| 1233 | - if ($returnErrors) | |
| 1234 | - $errors[] = 'custom_field_regex_fail'; | |
| 1235 | - | |
| 1236 | - else | |
| 1237 | - $value = ''; | |
| 1296 | +					if ($returnErrors) { | |
| 1297 | + $errors[] = 'custom_field_regex_fail'; | |
| 1298 | +					} else { | |
| 1299 | + $value = ''; | |
| 1300 | + } | |
| 1238 | 1301 | } | 
| 1239 | 1302 | |
| 1240 | 1303 | unset($valueReference); | 
| @@ -1258,8 +1321,7 @@ discard block | ||
| 1258 | 1321 |  			{ | 
| 1259 | 1322 |  				$deletes = array('id_theme' => 1 , 'variable' => $row['col_name'], 'id_member' => $memID); | 
| 1260 | 1323 | unset($user_profile[$memID]['options'][$row['col_name']]); | 
| 1261 | - } | |
| 1262 | - else | |
| 1324 | + } else | |
| 1263 | 1325 |  			{ | 
| 1264 | 1326 | $changes[] = array(1, $row['col_name'], $value, $memID); | 
| 1265 | 1327 | $user_profile[$memID]['options'][$row['col_name']] = $value; | 
| @@ -1270,27 +1332,30 @@ discard block | ||
| 1270 | 1332 | |
| 1271 | 1333 |  	$hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize, &$deletes)); | 
| 1272 | 1334 | |
| 1273 | - if (!empty($hook_errors) && is_array($hook_errors)) | |
| 1274 | - $errors = array_merge($errors, $hook_errors); | |
| 1335 | +	if (!empty($hook_errors) && is_array($hook_errors)) { | |
| 1336 | + $errors = array_merge($errors, $hook_errors); | |
| 1337 | + } | |
| 1275 | 1338 | |
| 1276 | 1339 | // Make those changes! | 
| 1277 | 1340 | if ((!empty($changes) || !empty($deletes)) && empty($context['password_auth_failed']) && empty($errors)) | 
| 1278 | 1341 |  	{ | 
| 1279 | - if (!empty($changes)) | |
| 1280 | -			$smcFunc['db_insert']('replace', | |
| 1342 | +		if (!empty($changes)) { | |
| 1343 | +					$smcFunc['db_insert']('replace', | |
| 1281 | 1344 |  				'{db_prefix}themes', | 
| 1282 | 1345 |  				array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534', 'id_member' => 'int'), | 
| 1283 | 1346 | $changes, | 
| 1284 | 1347 |  				array('id_theme', 'variable', 'id_member') | 
| 1285 | 1348 | ); | 
| 1286 | - if (!empty($deletes)) | |
| 1287 | -			$smcFunc['db_query']('',' | |
| 1349 | + } | |
| 1350 | +		if (!empty($deletes)) { | |
| 1351 | +					$smcFunc['db_query']('',' | |
| 1288 | 1352 |  				DELETE FROM {db_prefix}themes | 
| 1289 | 1353 |  				WHERE id_theme = {int:id_theme} AND | 
| 1290 | 1354 |  						variable = {string:variable} AND | 
| 1291 | 1355 |  						id_member = {int:id_member}', | 
| 1292 | 1356 | $deletes | 
| 1293 | 1357 | ); | 
| 1358 | + } | |
| 1294 | 1359 | if (!empty($log_changes) && !empty($modSettings['modlog_enabled'])) | 
| 1295 | 1360 |  		{ | 
| 1296 | 1361 | require_once($sourcedir . '/Logging.php'); | 
| @@ -1298,9 +1363,10 @@ discard block | ||
| 1298 | 1363 | } | 
| 1299 | 1364 | } | 
| 1300 | 1365 | |
| 1301 | - if ($returnErrors) | |
| 1302 | - return $errors; | |
| 1303 | -} | |
| 1366 | +	if ($returnErrors) { | |
| 1367 | + return $errors; | |
| 1368 | + } | |
| 1369 | + } | |
| 1304 | 1370 | |
| 1305 | 1371 | /** | 
| 1306 | 1372 | * Show all the users buddies, as well as a add/delete interface. | 
| @@ -1312,8 +1378,9 @@ discard block | ||
| 1312 | 1378 | global $context, $txt, $modSettings; | 
| 1313 | 1379 | |
| 1314 | 1380 | // Do a quick check to ensure people aren't getting here illegally! | 
| 1315 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) | |
| 1316 | -		fatal_lang_error('no_access', false); | |
| 1381 | +	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { | |
| 1382 | +			fatal_lang_error('no_access', false); | |
| 1383 | + } | |
| 1317 | 1384 | |
| 1318 | 1385 | // Can we email the user direct? | 
| 1319 | 1386 |  	$context['can_moderate_forum'] = allowedTo('moderate_forum'); | 
| @@ -1343,9 +1410,10 @@ discard block | ||
| 1343 | 1410 | $context['sub_template'] = $subActions[$context['list_area']][0]; | 
| 1344 | 1411 | $call = call_helper($subActions[$context['list_area']][0], true); | 
| 1345 | 1412 | |
| 1346 | - if (!empty($call)) | |
| 1347 | - call_user_func($call, $memID); | |
| 1348 | -} | |
| 1413 | +	if (!empty($call)) { | |
| 1414 | + call_user_func($call, $memID); | |
| 1415 | + } | |
| 1416 | + } | |
| 1349 | 1417 | |
| 1350 | 1418 | /** | 
| 1351 | 1419 | * Show all the users buddies, as well as a add/delete interface. | 
| @@ -1359,9 +1427,10 @@ discard block | ||
| 1359 | 1427 | |
| 1360 | 1428 | // For making changes! | 
| 1361 | 1429 |  	$buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); | 
| 1362 | - foreach ($buddiesArray as $k => $dummy) | |
| 1363 | - if ($dummy == '') | |
| 1430 | +	foreach ($buddiesArray as $k => $dummy) { | |
| 1431 | + if ($dummy == '') | |
| 1364 | 1432 | unset($buddiesArray[$k]); | 
| 1433 | + } | |
| 1365 | 1434 | |
| 1366 | 1435 | // Removing a buddy? | 
| 1367 | 1436 | if (isset($_GET['remove'])) | 
| @@ -1373,10 +1442,11 @@ discard block | ||
| 1373 | 1442 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; | 
| 1374 | 1443 | |
| 1375 | 1444 | // Heh, I'm lazy, do it the easy way... | 
| 1376 | - foreach ($buddiesArray as $key => $buddy) | |
| 1377 | - if ($buddy == (int) $_GET['remove']) | |
| 1445 | +		foreach ($buddiesArray as $key => $buddy) { | |
| 1446 | + if ($buddy == (int) $_GET['remove']) | |
| 1378 | 1447 |  			{ | 
| 1379 | 1448 | unset($buddiesArray[$key]); | 
| 1449 | + } | |
| 1380 | 1450 | $_SESSION['prf-save'] = true; | 
| 1381 | 1451 | } | 
| 1382 | 1452 | |
| @@ -1386,8 +1456,7 @@ discard block | ||
| 1386 | 1456 | |
| 1387 | 1457 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. | 
| 1388 | 1458 |  		redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); | 
| 1389 | - } | |
| 1390 | - elseif (isset($_POST['new_buddy'])) | |
| 1459 | + } elseif (isset($_POST['new_buddy'])) | |
| 1391 | 1460 |  	{ | 
| 1392 | 1461 | checkSession(); | 
| 1393 | 1462 | |
| @@ -1400,8 +1469,9 @@ discard block | ||
| 1400 | 1469 |  		{ | 
| 1401 | 1470 |  			$new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); | 
| 1402 | 1471 | |
| 1403 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) | |
| 1404 | - unset($new_buddies[$k]); | |
| 1472 | +			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { | |
| 1473 | + unset($new_buddies[$k]); | |
| 1474 | + } | |
| 1405 | 1475 | } | 
| 1406 | 1476 | |
| 1407 | 1477 |  		call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); | 
| @@ -1421,16 +1491,18 @@ discard block | ||
| 1421 | 1491 | ) | 
| 1422 | 1492 | ); | 
| 1423 | 1493 | |
| 1424 | - if ($smcFunc['db_num_rows']($request) != 0) | |
| 1425 | - $_SESSION['prf-save'] = true; | |
| 1494 | +			if ($smcFunc['db_num_rows']($request) != 0) { | |
| 1495 | + $_SESSION['prf-save'] = true; | |
| 1496 | + } | |
| 1426 | 1497 | |
| 1427 | 1498 | // Add the new member to the buddies array. | 
| 1428 | 1499 | while ($row = $smcFunc['db_fetch_assoc']($request)) | 
| 1429 | 1500 |  			{ | 
| 1430 | - if (in_array($row['id_member'], $buddiesArray)) | |
| 1431 | - continue; | |
| 1432 | - else | |
| 1433 | - $buddiesArray[] = (int) $row['id_member']; | |
| 1501 | +				if (in_array($row['id_member'], $buddiesArray)) { | |
| 1502 | + continue; | |
| 1503 | +				} else { | |
| 1504 | + $buddiesArray[] = (int) $row['id_member']; | |
| 1505 | + } | |
| 1434 | 1506 | } | 
| 1435 | 1507 | $smcFunc['db_free_result']($request); | 
| 1436 | 1508 | |
| @@ -1460,18 +1532,20 @@ discard block | ||
| 1460 | 1532 | |
| 1461 | 1533 | $context['custom_pf'] = array(); | 
| 1462 | 1534 |  	$disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); | 
| 1463 | - while ($row = $smcFunc['db_fetch_assoc']($request)) | |
| 1464 | - if (!isset($disabled_fields[$row['col_name']])) | |
| 1535 | +	while ($row = $smcFunc['db_fetch_assoc']($request)) { | |
| 1536 | + if (!isset($disabled_fields[$row['col_name']])) | |
| 1465 | 1537 | $context['custom_pf'][$row['col_name']] = array( | 
| 1466 | 1538 | 'label' => $row['field_name'], | 
| 1467 | 1539 | 'type' => $row['field_type'], | 
| 1468 | 1540 | 'bbc' => !empty($row['bbc']), | 
| 1469 | 1541 | 'enclose' => $row['enclose'], | 
| 1470 | 1542 | ); | 
| 1543 | + } | |
| 1471 | 1544 | |
| 1472 | 1545 | // Gotta disable the gender option. | 
| 1473 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') | |
| 1474 | - unset($context['custom_pf']['cust_gender']); | |
| 1546 | +	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') { | |
| 1547 | + unset($context['custom_pf']['cust_gender']); | |
| 1548 | + } | |
| 1475 | 1549 | |
| 1476 | 1550 | $smcFunc['db_free_result']($request); | 
| 1477 | 1551 | |
| @@ -1488,8 +1562,9 @@ discard block | ||
| 1488 | 1562 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, | 
| 1489 | 1563 | ) | 
| 1490 | 1564 | ); | 
| 1491 | - while ($row = $smcFunc['db_fetch_assoc']($result)) | |
| 1492 | - $buddies[] = $row['id_member']; | |
| 1565 | +		while ($row = $smcFunc['db_fetch_assoc']($result)) { | |
| 1566 | + $buddies[] = $row['id_member']; | |
| 1567 | + } | |
| 1493 | 1568 | $smcFunc['db_free_result']($result); | 
| 1494 | 1569 | } | 
| 1495 | 1570 | |
| @@ -1517,30 +1592,32 @@ discard block | ||
| 1517 | 1592 | continue; | 
| 1518 | 1593 | } | 
| 1519 | 1594 | |
| 1520 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) | |
| 1521 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); | |
| 1522 | - | |
| 1523 | - elseif ($column['type'] == 'check') | |
| 1524 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; | |
| 1595 | +				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { | |
| 1596 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); | |
| 1597 | +				} elseif ($column['type'] == 'check') { | |
| 1598 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; | |
| 1599 | + } | |
| 1525 | 1600 | |
| 1526 | 1601 | // Enclosing the user input within some other text? | 
| 1527 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) | |
| 1528 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( | |
| 1602 | +				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { | |
| 1603 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( | |
| 1529 | 1604 |  						'{SCRIPTURL}' => $scripturl, | 
| 1530 | 1605 |  						'{IMAGES_URL}' => $settings['images_url'], | 
| 1531 | 1606 |  						'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], | 
| 1532 | 1607 |  						'{INPUT}' => $context['buddies'][$buddy]['options'][$key], | 
| 1533 | 1608 | )); | 
| 1609 | + } | |
| 1534 | 1610 | } | 
| 1535 | 1611 | } | 
| 1536 | 1612 | } | 
| 1537 | 1613 | |
| 1538 | 1614 | if (isset($_SESSION['prf-save'])) | 
| 1539 | 1615 |  	{ | 
| 1540 | - if ($_SESSION['prf-save'] === true) | |
| 1541 | - $context['saved_successful'] = true; | |
| 1542 | - else | |
| 1543 | - $context['saved_failed'] = $_SESSION['prf-save']; | |
| 1616 | +		if ($_SESSION['prf-save'] === true) { | |
| 1617 | + $context['saved_successful'] = true; | |
| 1618 | +		} else { | |
| 1619 | + $context['saved_failed'] = $_SESSION['prf-save']; | |
| 1620 | + } | |
| 1544 | 1621 | |
| 1545 | 1622 | unset($_SESSION['prf-save']); | 
| 1546 | 1623 | } | 
| @@ -1560,9 +1637,10 @@ discard block | ||
| 1560 | 1637 | |
| 1561 | 1638 | // For making changes! | 
| 1562 | 1639 |  	$ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); | 
| 1563 | - foreach ($ignoreArray as $k => $dummy) | |
| 1564 | - if ($dummy == '') | |
| 1640 | +	foreach ($ignoreArray as $k => $dummy) { | |
| 1641 | + if ($dummy == '') | |
| 1565 | 1642 | unset($ignoreArray[$k]); | 
| 1643 | + } | |
| 1566 | 1644 | |
| 1567 | 1645 | // Removing a member from the ignore list? | 
| 1568 | 1646 | if (isset($_GET['remove'])) | 
| @@ -1572,10 +1650,11 @@ discard block | ||
| 1572 | 1650 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; | 
| 1573 | 1651 | |
| 1574 | 1652 | // Heh, I'm lazy, do it the easy way... | 
| 1575 | - foreach ($ignoreArray as $key => $id_remove) | |
| 1576 | - if ($id_remove == (int) $_GET['remove']) | |
| 1653 | +		foreach ($ignoreArray as $key => $id_remove) { | |
| 1654 | + if ($id_remove == (int) $_GET['remove']) | |
| 1577 | 1655 |  			{ | 
| 1578 | 1656 | unset($ignoreArray[$key]); | 
| 1657 | + } | |
| 1579 | 1658 | $_SESSION['prf-save'] = true; | 
| 1580 | 1659 | } | 
| 1581 | 1660 | |
| @@ -1585,8 +1664,7 @@ discard block | ||
| 1585 | 1664 | |
| 1586 | 1665 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. | 
| 1587 | 1666 |  		redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); | 
| 1588 | - } | |
| 1589 | - elseif (isset($_POST['new_ignore'])) | |
| 1667 | + } elseif (isset($_POST['new_ignore'])) | |
| 1590 | 1668 |  	{ | 
| 1591 | 1669 | checkSession(); | 
| 1592 | 1670 | // Prepare the string for extraction... | 
| @@ -1598,8 +1676,9 @@ discard block | ||
| 1598 | 1676 |  		{ | 
| 1599 | 1677 |  			$new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); | 
| 1600 | 1678 | |
| 1601 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) | |
| 1602 | - unset($new_entries[$k]); | |
| 1679 | +			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { | |
| 1680 | + unset($new_entries[$k]); | |
| 1681 | + } | |
| 1603 | 1682 | } | 
| 1604 | 1683 | |
| 1605 | 1684 | $_SESSION['prf-save'] = $txt['could_not_add_person']; | 
| @@ -1617,16 +1696,18 @@ discard block | ||
| 1617 | 1696 | ) | 
| 1618 | 1697 | ); | 
| 1619 | 1698 | |
| 1620 | - if ($smcFunc['db_num_rows']($request) != 0) | |
| 1621 | - $_SESSION['prf-save'] = true; | |
| 1699 | +			if ($smcFunc['db_num_rows']($request) != 0) { | |
| 1700 | + $_SESSION['prf-save'] = true; | |
| 1701 | + } | |
| 1622 | 1702 | |
| 1623 | 1703 | // Add the new member to the buddies array. | 
| 1624 | 1704 | while ($row = $smcFunc['db_fetch_assoc']($request)) | 
| 1625 | 1705 |  			{ | 
| 1626 | - if (in_array($row['id_member'], $ignoreArray)) | |
| 1627 | - continue; | |
| 1628 | - else | |
| 1629 | - $ignoreArray[] = (int) $row['id_member']; | |
| 1706 | +				if (in_array($row['id_member'], $ignoreArray)) { | |
| 1707 | + continue; | |
| 1708 | +				} else { | |
| 1709 | + $ignoreArray[] = (int) $row['id_member']; | |
| 1710 | + } | |
| 1630 | 1711 | } | 
| 1631 | 1712 | $smcFunc['db_free_result']($request); | 
| 1632 | 1713 | |
| @@ -1655,8 +1736,9 @@ discard block | ||
| 1655 | 1736 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, | 
| 1656 | 1737 | ) | 
| 1657 | 1738 | ); | 
| 1658 | - while ($row = $smcFunc['db_fetch_assoc']($result)) | |
| 1659 | - $ignored[] = $row['id_member']; | |
| 1739 | +		while ($row = $smcFunc['db_fetch_assoc']($result)) { | |
| 1740 | + $ignored[] = $row['id_member']; | |
| 1741 | + } | |
| 1660 | 1742 | $smcFunc['db_free_result']($result); | 
| 1661 | 1743 | } | 
| 1662 | 1744 | |
| @@ -1675,10 +1757,11 @@ discard block | ||
| 1675 | 1757 | |
| 1676 | 1758 | if (isset($_SESSION['prf-save'])) | 
| 1677 | 1759 |  	{ | 
| 1678 | - if ($_SESSION['prf-save'] === true) | |
| 1679 | - $context['saved_successful'] = true; | |
| 1680 | - else | |
| 1681 | - $context['saved_failed'] = $_SESSION['prf-save']; | |
| 1760 | +		if ($_SESSION['prf-save'] === true) { | |
| 1761 | + $context['saved_successful'] = true; | |
| 1762 | +		} else { | |
| 1763 | + $context['saved_failed'] = $_SESSION['prf-save']; | |
| 1764 | + } | |
| 1682 | 1765 | |
| 1683 | 1766 | unset($_SESSION['prf-save']); | 
| 1684 | 1767 | } | 
| @@ -1694,8 +1777,9 @@ discard block | ||
| 1694 | 1777 | global $context, $txt; | 
| 1695 | 1778 | |
| 1696 | 1779 | loadThemeOptions($memID); | 
| 1697 | -	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) | |
| 1698 | - loadCustomFields($memID, 'account'); | |
| 1780 | +	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { | |
| 1781 | + loadCustomFields($memID, 'account'); | |
| 1782 | + } | |
| 1699 | 1783 | |
| 1700 | 1784 | $context['sub_template'] = 'edit_options'; | 
| 1701 | 1785 | $context['page_desc'] = $txt['account_info']; | 
| @@ -1722,8 +1806,9 @@ discard block | ||
| 1722 | 1806 | global $context, $txt; | 
| 1723 | 1807 | |
| 1724 | 1808 | loadThemeOptions($memID); | 
| 1725 | -	if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) | |
| 1726 | - loadCustomFields($memID, 'forumprofile'); | |
| 1809 | +	if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { | |
| 1810 | + loadCustomFields($memID, 'forumprofile'); | |
| 1811 | + } | |
| 1727 | 1812 | |
| 1728 | 1813 | $context['sub_template'] = 'edit_options'; | 
| 1729 | 1814 | $context['page_desc'] = $txt['forumProfile_info']; | 
| @@ -1756,18 +1841,21 @@ discard block | ||
| 1756 | 1841 | $dirs = array(); | 
| 1757 | 1842 | $files = array(); | 
| 1758 | 1843 | |
| 1759 | - if (!$dir) | |
| 1760 | - return array(); | |
| 1844 | +	if (!$dir) { | |
| 1845 | + return array(); | |
| 1846 | + } | |
| 1761 | 1847 | |
| 1762 | 1848 | while ($line = $dir->read()) | 
| 1763 | 1849 |  	{ | 
| 1764 | -		if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) | |
| 1765 | - continue; | |
| 1850 | +		if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { | |
| 1851 | + continue; | |
| 1852 | + } | |
| 1766 | 1853 | |
| 1767 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) | |
| 1768 | - $dirs[] = $line; | |
| 1769 | - else | |
| 1770 | - $files[] = $line; | |
| 1854 | +		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { | |
| 1855 | + $dirs[] = $line; | |
| 1856 | +		} else { | |
| 1857 | + $files[] = $line; | |
| 1858 | + } | |
| 1771 | 1859 | } | 
| 1772 | 1860 | $dir->close(); | 
| 1773 | 1861 | |
| @@ -1788,14 +1876,15 @@ discard block | ||
| 1788 | 1876 | foreach ($dirs as $line) | 
| 1789 | 1877 |  	{ | 
| 1790 | 1878 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); | 
| 1791 | - if (!empty($tmp)) | |
| 1792 | - $result[] = array( | |
| 1879 | +		if (!empty($tmp)) { | |
| 1880 | + $result[] = array( | |
| 1793 | 1881 | 'filename' => $smcFunc['htmlspecialchars']($line), | 
| 1794 | 1882 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, | 
| 1795 | 1883 |  				'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', | 
| 1796 | 1884 | 'is_dir' => true, | 
| 1797 | 1885 | 'files' => $tmp | 
| 1798 | 1886 | ); | 
| 1887 | + } | |
| 1799 | 1888 | unset($tmp); | 
| 1800 | 1889 | } | 
| 1801 | 1890 | |
| @@ -1805,8 +1894,9 @@ discard block | ||
| 1805 | 1894 | $extension = substr(strrchr($line, '.'), 1); | 
| 1806 | 1895 | |
| 1807 | 1896 | // Make sure it is an image. | 
| 1808 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) | |
| 1809 | - continue; | |
| 1897 | +		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { | |
| 1898 | + continue; | |
| 1899 | + } | |
| 1810 | 1900 | |
| 1811 | 1901 | $result[] = array( | 
| 1812 | 1902 | 'filename' => $smcFunc['htmlspecialchars']($line), | 
| @@ -1814,8 +1904,9 @@ discard block | ||
| 1814 | 1904 |  			'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), | 
| 1815 | 1905 | 'is_dir' => false | 
| 1816 | 1906 | ); | 
| 1817 | - if ($level == 1) | |
| 1818 | - $context['avatar_list'][] = $directory . '/' . $line; | |
| 1907 | +		if ($level == 1) { | |
| 1908 | + $context['avatar_list'][] = $directory . '/' . $line; | |
| 1909 | + } | |
| 1819 | 1910 | } | 
| 1820 | 1911 | |
| 1821 | 1912 | return $result; | 
| @@ -1837,8 +1928,9 @@ discard block | ||
| 1837 | 1928 |  	call_integration_hook('integrate_theme_options'); | 
| 1838 | 1929 | |
| 1839 | 1930 | loadThemeOptions($memID); | 
| 1840 | -	if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) | |
| 1841 | - loadCustomFields($memID, 'theme'); | |
| 1931 | +	if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { | |
| 1932 | + loadCustomFields($memID, 'theme'); | |
| 1933 | + } | |
| 1842 | 1934 | |
| 1843 | 1935 | $context['sub_template'] = 'edit_options'; | 
| 1844 | 1936 | $context['page_desc'] = $txt['theme_info']; | 
| @@ -1892,16 +1984,19 @@ discard block | ||
| 1892 | 1984 |  { | 
| 1893 | 1985 | global $txt, $context, $modSettings, $smcFunc, $sourcedir; | 
| 1894 | 1986 | |
| 1895 | - if (!isset($context['token_check'])) | |
| 1896 | - $context['token_check'] = 'profile-nt' . $memID; | |
| 1987 | +	if (!isset($context['token_check'])) { | |
| 1988 | + $context['token_check'] = 'profile-nt' . $memID; | |
| 1989 | + } | |
| 1897 | 1990 | |
| 1898 | 1991 | is_not_guest(); | 
| 1899 | - if (!$context['user']['is_owner']) | |
| 1900 | -		isAllowedTo('profile_extra_any'); | |
| 1992 | +	if (!$context['user']['is_owner']) { | |
| 1993 | +			isAllowedTo('profile_extra_any'); | |
| 1994 | + } | |
| 1901 | 1995 | |
| 1902 | 1996 | // Set the post action if we're coming from the profile... | 
| 1903 | - if (!isset($context['action'])) | |
| 1904 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; | |
| 1997 | +	if (!isset($context['action'])) { | |
| 1998 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; | |
| 1999 | + } | |
| 1905 | 2000 | |
| 1906 | 2001 | // What options are set | 
| 1907 | 2002 | loadThemeOptions($memID); | 
| @@ -1988,28 +2083,34 @@ discard block | ||
| 1988 | 2083 | ); | 
| 1989 | 2084 | |
| 1990 | 2085 | // There are certain things that are disabled at the group level. | 
| 1991 | - if (empty($modSettings['cal_enabled'])) | |
| 1992 | - unset($alert_types['calendar']); | |
| 2086 | +	if (empty($modSettings['cal_enabled'])) { | |
| 2087 | + unset($alert_types['calendar']); | |
| 2088 | + } | |
| 1993 | 2089 | |
| 1994 | 2090 | // Disable paid subscriptions at group level if they're disabled | 
| 1995 | - if (empty($modSettings['paid_enabled'])) | |
| 1996 | - unset($alert_types['paidsubs']); | |
| 2091 | +	if (empty($modSettings['paid_enabled'])) { | |
| 2092 | + unset($alert_types['paidsubs']); | |
| 2093 | + } | |
| 1997 | 2094 | |
| 1998 | 2095 | // Disable membergroup requests at group level if they're disabled | 
| 1999 | - if (empty($modSettings['show_group_membership'])) | |
| 2000 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); | |
| 2096 | +	if (empty($modSettings['show_group_membership'])) { | |
| 2097 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); | |
| 2098 | + } | |
| 2001 | 2099 | |
| 2002 | 2100 | // Disable mentions if they're disabled | 
| 2003 | - if (empty($modSettings['enable_mentions'])) | |
| 2004 | - unset($alert_types['msg']['msg_mention']); | |
| 2101 | +	if (empty($modSettings['enable_mentions'])) { | |
| 2102 | + unset($alert_types['msg']['msg_mention']); | |
| 2103 | + } | |
| 2005 | 2104 | |
| 2006 | 2105 | // Disable likes if they're disabled | 
| 2007 | - if (empty($modSettings['enable_likes'])) | |
| 2008 | - unset($alert_types['msg']['msg_like']); | |
| 2106 | +	if (empty($modSettings['enable_likes'])) { | |
| 2107 | + unset($alert_types['msg']['msg_like']); | |
| 2108 | + } | |
| 2009 | 2109 | |
| 2010 | 2110 | // Disable buddy requests if they're disabled | 
| 2011 | - if (empty($modSettings['enable_buddylist'])) | |
| 2012 | - unset($alert_types['members']['buddy_request']); | |
| 2111 | +	if (empty($modSettings['enable_buddylist'])) { | |
| 2112 | + unset($alert_types['members']['buddy_request']); | |
| 2113 | + } | |
| 2013 | 2114 | |
| 2014 | 2115 | // Now, now, we could pass this through global but we should really get into the habit of | 
| 2015 | 2116 | // passing content to hooks, not expecting hooks to splatter everything everywhere. | 
| @@ -2037,15 +2138,17 @@ discard block | ||
| 2037 | 2138 | $perms_cache['manage_membergroups'] = in_array($memID, $members); | 
| 2038 | 2139 | } | 
| 2039 | 2140 | |
| 2040 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) | |
| 2041 | - unset($alert_types['members']['request_group']); | |
| 2141 | +		if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { | |
| 2142 | + unset($alert_types['members']['request_group']); | |
| 2143 | + } | |
| 2042 | 2144 | |
| 2043 | 2145 | foreach ($alert_types as $group => $items) | 
| 2044 | 2146 |  		{ | 
| 2045 | 2147 | foreach ($items as $alert_key => $alert_value) | 
| 2046 | 2148 |  			{ | 
| 2047 | - if (!isset($alert_value['permission'])) | |
| 2048 | - continue; | |
| 2149 | +				if (!isset($alert_value['permission'])) { | |
| 2150 | + continue; | |
| 2151 | + } | |
| 2049 | 2152 | if (!isset($perms_cache[$alert_value['permission']['name']])) | 
| 2050 | 2153 |  				{ | 
| 2051 | 2154 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; | 
| @@ -2053,12 +2156,14 @@ discard block | ||
| 2053 | 2156 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); | 
| 2054 | 2157 | } | 
| 2055 | 2158 | |
| 2056 | - if (!$perms_cache[$alert_value['permission']['name']]) | |
| 2057 | - unset ($alert_types[$group][$alert_key]); | |
| 2159 | +				if (!$perms_cache[$alert_value['permission']['name']]) { | |
| 2160 | + unset ($alert_types[$group][$alert_key]); | |
| 2161 | + } | |
| 2058 | 2162 | } | 
| 2059 | 2163 | |
| 2060 | - if (empty($alert_types[$group])) | |
| 2061 | - unset ($alert_types[$group]); | |
| 2164 | +			if (empty($alert_types[$group])) { | |
| 2165 | + unset ($alert_types[$group]); | |
| 2166 | + } | |
| 2062 | 2167 | } | 
| 2063 | 2168 | } | 
| 2064 | 2169 | |
| @@ -2090,9 +2195,9 @@ discard block | ||
| 2090 | 2195 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; | 
| 2091 | 2196 | break; | 
| 2092 | 2197 | case 'select': | 
| 2093 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) | |
| 2094 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; | |
| 2095 | - else | |
| 2198 | +						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { | |
| 2199 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; | |
| 2200 | + } else | |
| 2096 | 2201 |  						{ | 
| 2097 | 2202 | // We didn't have a sane value. Let's grab the first item from the possibles. | 
| 2098 | 2203 | $keys = array_keys($this_option['opts']); | 
| @@ -2112,23 +2217,28 @@ discard block | ||
| 2112 | 2217 | $this_value = 0; | 
| 2113 | 2218 | foreach ($context['alert_bits'] as $type => $bitvalue) | 
| 2114 | 2219 |  				{ | 
| 2115 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') | |
| 2116 | - $this_value |= $bitvalue; | |
| 2220 | +					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { | |
| 2221 | + $this_value |= $bitvalue; | |
| 2222 | + } | |
| 2223 | + } | |
| 2224 | +				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { | |
| 2225 | + $update_prefs[$item_key] = $this_value; | |
| 2117 | 2226 | } | 
| 2118 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) | |
| 2119 | - $update_prefs[$item_key] = $this_value; | |
| 2120 | 2227 | } | 
| 2121 | 2228 | } | 
| 2122 | 2229 | |
| 2123 | - if (!empty($_POST['opt_alert_timeout'])) | |
| 2124 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; | |
| 2230 | +		if (!empty($_POST['opt_alert_timeout'])) { | |
| 2231 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; | |
| 2232 | + } | |
| 2125 | 2233 | |
| 2126 | - if (!empty($_POST['notify_announcements'])) | |
| 2127 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; | |
| 2234 | +		if (!empty($_POST['notify_announcements'])) { | |
| 2235 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; | |
| 2236 | + } | |
| 2128 | 2237 | |
| 2129 | 2238 | setNotifyPrefs((int) $memID, $update_prefs); | 
| 2130 | - foreach ($update_prefs as $pref => $value) | |
| 2131 | - $context['alert_prefs'][$pref] = $value; | |
| 2239 | +		foreach ($update_prefs as $pref => $value) { | |
| 2240 | + $context['alert_prefs'][$pref] = $value; | |
| 2241 | + } | |
| 2132 | 2242 | |
| 2133 | 2243 | makeNotificationChanges($memID); | 
| 2134 | 2244 | |
| @@ -2158,8 +2268,9 @@ discard block | ||
| 2158 | 2268 | |
| 2159 | 2269 | // Now we're all set up. | 
| 2160 | 2270 | is_not_guest(); | 
| 2161 | - if (!$context['user']['is_owner']) | |
| 2162 | -		fatal_error('no_access'); | |
| 2271 | +	if (!$context['user']['is_owner']) { | |
| 2272 | +			fatal_error('no_access'); | |
| 2273 | + } | |
| 2163 | 2274 | |
| 2164 | 2275 |  	checkSession('get'); | 
| 2165 | 2276 | |
| @@ -2191,8 +2302,9 @@ discard block | ||
| 2191 | 2302 |  { | 
| 2192 | 2303 | global $smcFunc; | 
| 2193 | 2304 | |
| 2194 | - if (empty($toMark) || empty($memID)) | |
| 2195 | - return false; | |
| 2305 | +	if (empty($toMark) || empty($memID)) { | |
| 2306 | + return false; | |
| 2307 | + } | |
| 2196 | 2308 | |
| 2197 | 2309 | $toMark = (array) $toMark; | 
| 2198 | 2310 | |
| @@ -2226,8 +2338,9 @@ discard block | ||
| 2226 | 2338 |  { | 
| 2227 | 2339 | global $smcFunc; | 
| 2228 | 2340 | |
| 2229 | - if (empty($toDelete)) | |
| 2230 | - return false; | |
| 2341 | +	if (empty($toDelete)) { | |
| 2342 | + return false; | |
| 2343 | + } | |
| 2231 | 2344 | |
| 2232 | 2345 | $toDelete = (array) $toDelete; | 
| 2233 | 2346 | |
| @@ -2262,8 +2375,9 @@ discard block | ||
| 2262 | 2375 |  { | 
| 2263 | 2376 | global $smcFunc; | 
| 2264 | 2377 | |
| 2265 | - if (empty($memID)) | |
| 2266 | - return false; | |
| 2378 | +	if (empty($memID)) { | |
| 2379 | + return false; | |
| 2380 | + } | |
| 2267 | 2381 | |
| 2268 | 2382 |  	$request = $smcFunc['db_query']('', ' | 
| 2269 | 2383 | SELECT id_alert | 
| @@ -2340,8 +2454,9 @@ discard block | ||
| 2340 | 2454 |  					{ | 
| 2341 | 2455 | $link = $topic['link']; | 
| 2342 | 2456 | |
| 2343 | - if ($topic['new']) | |
| 2344 | - $link .= ' <a href="' . $topic['new_href'] . '" class="new_posts">' . $txt['new'] . '</a>'; | |
| 2457 | +						if ($topic['new']) { | |
| 2458 | + $link .= ' <a href="' . $topic['new_href'] . '" class="new_posts">' . $txt['new'] . '</a>'; | |
| 2459 | + } | |
| 2345 | 2460 | |
| 2346 | 2461 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; | 
| 2347 | 2462 | |
| @@ -2492,8 +2607,9 @@ discard block | ||
| 2492 | 2607 |  					{ | 
| 2493 | 2608 | $link = $board['link']; | 
| 2494 | 2609 | |
| 2495 | - if ($board['new']) | |
| 2496 | - $link .= ' <a href="' . $board['href'] . '" class="new_posts">' . $txt['new'] . '</a>'; | |
| 2610 | +						if ($board['new']) { | |
| 2611 | + $link .= ' <a href="' . $board['href'] . '" class="new_posts">' . $txt['new'] . '</a>'; | |
| 2612 | + } | |
| 2497 | 2613 | |
| 2498 | 2614 | return $link; | 
| 2499 | 2615 | }, | 
| @@ -2693,8 +2809,8 @@ discard block | ||
| 2693 | 2809 | ) | 
| 2694 | 2810 | ); | 
| 2695 | 2811 | $notification_boards = array(); | 
| 2696 | - while ($row = $smcFunc['db_fetch_assoc']($request)) | |
| 2697 | - $notification_boards[] = array( | |
| 2812 | +	while ($row = $smcFunc['db_fetch_assoc']($request)) { | |
| 2813 | + $notification_boards[] = array( | |
| 2698 | 2814 | 'id' => $row['id_board'], | 
| 2699 | 2815 | 'name' => $row['name'], | 
| 2700 | 2816 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', | 
| @@ -2702,6 +2818,7 @@ discard block | ||
| 2702 | 2818 | 'new' => $row['board_read'] < $row['id_msg_updated'], | 
| 2703 | 2819 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), | 
| 2704 | 2820 | ); | 
| 2821 | + } | |
| 2705 | 2822 | $smcFunc['db_free_result']($request); | 
| 2706 | 2823 | |
| 2707 | 2824 | return $notification_boards; | 
| @@ -2716,17 +2833,18 @@ discard block | ||
| 2716 | 2833 |  { | 
| 2717 | 2834 | global $context, $options, $cur_profile, $smcFunc; | 
| 2718 | 2835 | |
| 2719 | - if (isset($_POST['default_options'])) | |
| 2720 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; | |
| 2836 | +	if (isset($_POST['default_options'])) { | |
| 2837 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; | |
| 2838 | + } | |
| 2721 | 2839 | |
| 2722 | 2840 | if ($context['user']['is_owner']) | 
| 2723 | 2841 |  	{ | 
| 2724 | 2842 | $context['member']['options'] = $options; | 
| 2725 | - if (isset($_POST['options']) && is_array($_POST['options'])) | |
| 2726 | - foreach ($_POST['options'] as $k => $v) | |
| 2843 | +		if (isset($_POST['options']) && is_array($_POST['options'])) { | |
| 2844 | + foreach ($_POST['options'] as $k => $v) | |
| 2727 | 2845 | $context['member']['options'][$k] = $v; | 
| 2728 | - } | |
| 2729 | - else | |
| 2846 | + } | |
| 2847 | + } else | |
| 2730 | 2848 |  	{ | 
| 2731 | 2849 |  		$request = $smcFunc['db_query']('', ' | 
| 2732 | 2850 | SELECT id_member, variable, value | 
| @@ -2747,8 +2865,9 @@ discard block | ||
| 2747 | 2865 | continue; | 
| 2748 | 2866 | } | 
| 2749 | 2867 | |
| 2750 | - if (isset($_POST['options'][$row['variable']])) | |
| 2751 | - $row['value'] = $_POST['options'][$row['variable']]; | |
| 2868 | +			if (isset($_POST['options'][$row['variable']])) { | |
| 2869 | + $row['value'] = $_POST['options'][$row['variable']]; | |
| 2870 | + } | |
| 2752 | 2871 | $context['member']['options'][$row['variable']] = $row['value']; | 
| 2753 | 2872 | } | 
| 2754 | 2873 | $smcFunc['db_free_result']($request); | 
| @@ -2756,8 +2875,9 @@ discard block | ||
| 2756 | 2875 | // Load up the default theme options for any missing. | 
| 2757 | 2876 | foreach ($temp as $k => $v) | 
| 2758 | 2877 |  		{ | 
| 2759 | - if (!isset($context['member']['options'][$k])) | |
| 2760 | - $context['member']['options'][$k] = $v; | |
| 2878 | +			if (!isset($context['member']['options'][$k])) { | |
| 2879 | + $context['member']['options'][$k] = $v; | |
| 2880 | + } | |
| 2761 | 2881 | } | 
| 2762 | 2882 | } | 
| 2763 | 2883 | } | 
| @@ -2772,8 +2892,9 @@ discard block | ||
| 2772 | 2892 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; | 
| 2773 | 2893 | |
| 2774 | 2894 | // Have the admins enabled this option? | 
| 2775 | - if (empty($modSettings['allow_ignore_boards'])) | |
| 2776 | -		fatal_lang_error('ignoreboards_disallowed', 'user'); | |
| 2895 | +	if (empty($modSettings['allow_ignore_boards'])) { | |
| 2896 | +			fatal_lang_error('ignoreboards_disallowed', 'user'); | |
| 2897 | + } | |
| 2777 | 2898 | |
| 2778 | 2899 | // Find all the boards this user is allowed to see. | 
| 2779 | 2900 |  	$request = $smcFunc['db_query']('order_by_board_order', ' | 
| @@ -2793,12 +2914,13 @@ discard block | ||
| 2793 | 2914 | while ($row = $smcFunc['db_fetch_assoc']($request)) | 
| 2794 | 2915 |  	{ | 
| 2795 | 2916 | // This category hasn't been set up yet.. | 
| 2796 | - if (!isset($context['categories'][$row['id_cat']])) | |
| 2797 | - $context['categories'][$row['id_cat']] = array( | |
| 2917 | +		if (!isset($context['categories'][$row['id_cat']])) { | |
| 2918 | + $context['categories'][$row['id_cat']] = array( | |
| 2798 | 2919 | 'id' => $row['id_cat'], | 
| 2799 | 2920 | 'name' => $row['cat_name'], | 
| 2800 | 2921 | 'boards' => array() | 
| 2801 | 2922 | ); | 
| 2923 | + } | |
| 2802 | 2924 | |
| 2803 | 2925 | // Set this board up, and let the template know when it's a child. (indent them..) | 
| 2804 | 2926 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( | 
| @@ -2828,18 +2950,20 @@ discard block | ||
| 2828 | 2950 | } | 
| 2829 | 2951 | |
| 2830 | 2952 | $max_boards = ceil(count($temp_boards) / 2); | 
| 2831 | - if ($max_boards == 1) | |
| 2832 | - $max_boards = 2; | |
| 2953 | +	if ($max_boards == 1) { | |
| 2954 | + $max_boards = 2; | |
| 2955 | + } | |
| 2833 | 2956 | |
| 2834 | 2957 | // Now, alternate them so they can be shown left and right ;). | 
| 2835 | 2958 | $context['board_columns'] = array(); | 
| 2836 | 2959 | for ($i = 0; $i < $max_boards; $i++) | 
| 2837 | 2960 |  	{ | 
| 2838 | 2961 | $context['board_columns'][] = $temp_boards[$i]; | 
| 2839 | - if (isset($temp_boards[$i + $max_boards])) | |
| 2840 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; | |
| 2841 | - else | |
| 2842 | - $context['board_columns'][] = array(); | |
| 2962 | +		if (isset($temp_boards[$i + $max_boards])) { | |
| 2963 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; | |
| 2964 | +		} else { | |
| 2965 | + $context['board_columns'][] = array(); | |
| 2966 | + } | |
| 2843 | 2967 | } | 
| 2844 | 2968 | |
| 2845 | 2969 | loadThemeOptions($memID); | 
| @@ -2908,8 +3032,9 @@ discard block | ||
| 2908 | 3032 | while ($row = $smcFunc['db_fetch_assoc']($request)) | 
| 2909 | 3033 |  	{ | 
| 2910 | 3034 | // We should skip the administrator group if they don't have the admin_forum permission! | 
| 2911 | -		if ($row['id_group'] == 1 && !allowedTo('admin_forum')) | |
| 2912 | - continue; | |
| 3035 | +		if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { | |
| 3036 | + continue; | |
| 3037 | + } | |
| 2913 | 3038 | |
| 2914 | 3039 | $context['member_groups'][$row['id_group']] = array( | 
| 2915 | 3040 | 'id' => $row['id_group'], | 
| @@ -2955,16 +3080,17 @@ discard block | ||
| 2955 | 3080 | $context['max_signature_length'] = $context['signature_limits']['max_length']; | 
| 2956 | 3081 | // Warning message for signature image limits? | 
| 2957 | 3082 | $context['signature_warning'] = ''; | 
| 2958 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) | |
| 2959 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); | |
| 2960 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) | |
| 2961 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); | |
| 3083 | +	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { | |
| 3084 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); | |
| 3085 | +	} elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { | |
| 3086 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); | |
| 3087 | + } | |
| 2962 | 3088 | |
| 2963 | 3089 |  	$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv')))); | 
| 2964 | 3090 | |
| 2965 | - if (empty($context['do_preview'])) | |
| 2966 | -		$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); | |
| 2967 | - else | |
| 3091 | +	if (empty($context['do_preview'])) { | |
| 3092 | +			$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); | |
| 3093 | + } else | |
| 2968 | 3094 |  	{ | 
| 2969 | 3095 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; | 
| 2970 | 3096 | $validation = profileValidateSignature($signature); | 
| @@ -2974,8 +3100,9 @@ discard block | ||
| 2974 | 3100 | $context['post_errors'] = array(); | 
| 2975 | 3101 | } | 
| 2976 | 3102 | $context['post_errors'][] = 'signature_not_yet_saved'; | 
| 2977 | - if ($validation !== true && $validation !== false) | |
| 2978 | - $context['post_errors'][] = $validation; | |
| 3103 | +		if ($validation !== true && $validation !== false) { | |
| 3104 | + $context['post_errors'][] = $validation; | |
| 3105 | + } | |
| 2979 | 3106 | |
| 2980 | 3107 | censorText($context['member']['signature']); | 
| 2981 | 3108 | $context['member']['current_signature'] = $context['member']['signature']; | 
| @@ -2985,8 +3112,9 @@ discard block | ||
| 2985 | 3112 | } | 
| 2986 | 3113 | |
| 2987 | 3114 | // Load the spell checker? | 
| 2988 | - if ($context['show_spellchecking']) | |
| 2989 | -		loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck'); | |
| 3115 | +	if ($context['show_spellchecking']) { | |
| 3116 | +			loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck'); | |
| 3117 | + } | |
| 2990 | 3118 | |
| 2991 | 3119 | return true; | 
| 2992 | 3120 | } | 
| @@ -3020,8 +3148,7 @@ discard block | ||
| 3020 | 3148 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) | 
| 3021 | 3149 | ); | 
| 3022 | 3150 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); | 
| 3023 | - } | |
| 3024 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) | |
| 3151 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) | |
| 3025 | 3152 |  	{ | 
| 3026 | 3153 | $context['member']['avatar'] += array( | 
| 3027 | 3154 | 'choice' => 'upload', | 
| @@ -3031,33 +3158,34 @@ discard block | ||
| 3031 | 3158 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; | 
| 3032 | 3159 | } | 
| 3033 | 3160 | // Use "avatar_original" here so we show what the user entered even if the image proxy is enabled | 
| 3034 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) | |
| 3035 | - $context['member']['avatar'] += array( | |
| 3161 | +	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { | |
| 3162 | + $context['member']['avatar'] += array( | |
| 3036 | 3163 | 'choice' => 'external', | 
| 3037 | 3164 | 'server_pic' => 'blank.png', | 
| 3038 | 3165 | 'external' => $cur_profile['avatar_original'] | 
| 3039 | 3166 | ); | 
| 3040 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) | |
| 3041 | - $context['member']['avatar'] += array( | |
| 3167 | +	} elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { | |
| 3168 | + $context['member']['avatar'] += array( | |
| 3042 | 3169 | 'choice' => 'server_stored', | 
| 3043 | 3170 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], | 
| 3044 | 3171 | 'external' => 'http://' | 
| 3045 | 3172 | ); | 
| 3046 | - else | |
| 3047 | - $context['member']['avatar'] += array( | |
| 3173 | +	} else { | |
| 3174 | + $context['member']['avatar'] += array( | |
| 3048 | 3175 | 'choice' => 'none', | 
| 3049 | 3176 | 'server_pic' => 'blank.png', | 
| 3050 | 3177 | 'external' => 'http://' | 
| 3051 | 3178 | ); | 
| 3179 | + } | |
| 3052 | 3180 | |
| 3053 | 3181 | // Get a list of all the avatars. | 
| 3054 | 3182 | if ($context['member']['avatar']['allow_server_stored']) | 
| 3055 | 3183 |  	{ | 
| 3056 | 3184 | $context['avatar_list'] = array(); | 
| 3057 | 3185 |  		$context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); | 
| 3186 | +	} else { | |
| 3187 | + $context['avatars'] = array(); | |
| 3058 | 3188 | } | 
| 3059 | - else | |
| 3060 | - $context['avatars'] = array(); | |
| 3061 | 3189 | |
| 3062 | 3190 | // Second level selected avatar... | 
| 3063 | 3191 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); | 
| @@ -3086,19 +3214,22 @@ discard block | ||
| 3086 | 3214 | ) | 
| 3087 | 3215 | ); | 
| 3088 | 3216 | $protected_groups = array(1); | 
| 3089 | - while ($row = $smcFunc['db_fetch_assoc']($request)) | |
| 3090 | - $protected_groups[] = $row['id_group']; | |
| 3217 | +		while ($row = $smcFunc['db_fetch_assoc']($request)) { | |
| 3218 | + $protected_groups[] = $row['id_group']; | |
| 3219 | + } | |
| 3091 | 3220 | $smcFunc['db_free_result']($request); | 
| 3092 | 3221 | |
| 3093 | 3222 | $protected_groups = array_unique($protected_groups); | 
| 3094 | 3223 | } | 
| 3095 | 3224 | |
| 3096 | 3225 | // The account page allows the change of your id_group - but not to a protected group! | 
| 3097 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) | |
| 3098 | - $value = (int) $value; | |
| 3226 | +	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { | |
| 3227 | + $value = (int) $value; | |
| 3228 | + } | |
| 3099 | 3229 | // ... otherwise it's the old group sir. | 
| 3100 | - else | |
| 3101 | - $value = $old_profile['id_group']; | |
| 3230 | +	else { | |
| 3231 | + $value = $old_profile['id_group']; | |
| 3232 | + } | |
| 3102 | 3233 | |
| 3103 | 3234 | // Find the additional membergroups (if any) | 
| 3104 | 3235 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) | 
| @@ -3107,16 +3238,18 @@ discard block | ||
| 3107 | 3238 | foreach ($_POST['additional_groups'] as $group_id) | 
| 3108 | 3239 |  		{ | 
| 3109 | 3240 | $group_id = (int) $group_id; | 
| 3110 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) | |
| 3111 | - $additional_groups[] = $group_id; | |
| 3241 | +			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { | |
| 3242 | + $additional_groups[] = $group_id; | |
| 3243 | + } | |
| 3112 | 3244 | } | 
| 3113 | 3245 | |
| 3114 | 3246 | // Put the protected groups back in there if you don't have permission to take them away. | 
| 3115 | 3247 |  		$old_additional_groups = explode(',', $old_profile['additional_groups']); | 
| 3116 | 3248 | foreach ($old_additional_groups as $group_id) | 
| 3117 | 3249 |  		{ | 
| 3118 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) | |
| 3119 | - $additional_groups[] = $group_id; | |
| 3250 | +			if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { | |
| 3251 | + $additional_groups[] = $group_id; | |
| 3252 | + } | |
| 3120 | 3253 | } | 
| 3121 | 3254 | |
| 3122 | 3255 |  		if (implode(',', $additional_groups) !== $old_profile['additional_groups']) | 
| @@ -3148,18 +3281,20 @@ discard block | ||
| 3148 | 3281 | list ($another) = $smcFunc['db_fetch_row']($request); | 
| 3149 | 3282 | $smcFunc['db_free_result']($request); | 
| 3150 | 3283 | |
| 3151 | - if (empty($another)) | |
| 3152 | -				fatal_lang_error('at_least_one_admin', 'critical'); | |
| 3284 | +			if (empty($another)) { | |
| 3285 | +							fatal_lang_error('at_least_one_admin', 'critical'); | |
| 3286 | + } | |
| 3153 | 3287 | } | 
| 3154 | 3288 | } | 
| 3155 | 3289 | |
| 3156 | 3290 | // If we are changing group status, update permission cache as necessary. | 
| 3157 | 3291 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) | 
| 3158 | 3292 |  	{ | 
| 3159 | - if ($context['user']['is_owner']) | |
| 3160 | - $_SESSION['mc']['time'] = 0; | |
| 3161 | - else | |
| 3162 | -			updateSettings(array('settings_updated' => time())); | |
| 3293 | +		if ($context['user']['is_owner']) { | |
| 3294 | + $_SESSION['mc']['time'] = 0; | |
| 3295 | +		} else { | |
| 3296 | +					updateSettings(array('settings_updated' => time())); | |
| 3297 | + } | |
| 3163 | 3298 | } | 
| 3164 | 3299 | |
| 3165 | 3300 | // Announce to any hooks that we have changed groups, but don't allow them to change it. | 
| @@ -3180,8 +3315,9 @@ discard block | ||
| 3180 | 3315 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; | 
| 3181 | 3316 | |
| 3182 | 3317 | $memID = $context['id_member']; | 
| 3183 | - if (empty($memID) && !empty($context['password_auth_failed'])) | |
| 3184 | - return false; | |
| 3318 | +	if (empty($memID) && !empty($context['password_auth_failed'])) { | |
| 3319 | + return false; | |
| 3320 | + } | |
| 3185 | 3321 | |
| 3186 | 3322 | require_once($sourcedir . '/ManageAttachments.php'); | 
| 3187 | 3323 | |
| @@ -3192,8 +3328,9 @@ discard block | ||
| 3192 | 3328 | $downloadedExternalAvatar = false; | 
| 3193 | 3329 |  	if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) | 
| 3194 | 3330 |  	{ | 
| 3195 | - if (!is_writable($uploadDir)) | |
| 3196 | -			fatal_lang_error('attachments_no_write', 'critical'); | |
| 3331 | +		if (!is_writable($uploadDir)) { | |
| 3332 | +					fatal_lang_error('attachments_no_write', 'critical'); | |
| 3333 | + } | |
| 3197 | 3334 | |
| 3198 | 3335 | $url = parse_url($_POST['userpicpersonal']); | 
| 3199 | 3336 |  		$contents = fetch_web_data($url['scheme'] . '://' . $url['host'] . (empty($url['port']) ? '' : ':' . $url['port']) . str_replace(' ', '%20', trim($url['path']))); | 
| @@ -3235,19 +3372,18 @@ discard block | ||
| 3235 | 3372 | |
| 3236 | 3373 | // Get rid of their old avatar. (if uploaded.) | 
| 3237 | 3374 |  		removeAttachments(array('id_member' => $memID)); | 
| 3238 | - } | |
| 3239 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) | |
| 3375 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) | |
| 3240 | 3376 |  	{ | 
| 3241 | 3377 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. | 
| 3242 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) | |
| 3243 | - $profile_vars['avatar'] = 'gravatar://'; | |
| 3244 | - else | |
| 3245 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); | |
| 3378 | +		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { | |
| 3379 | + $profile_vars['avatar'] = 'gravatar://'; | |
| 3380 | +		} else { | |
| 3381 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); | |
| 3382 | + } | |
| 3246 | 3383 | |
| 3247 | 3384 | // Get rid of their old avatar. (if uploaded.) | 
| 3248 | 3385 |  		removeAttachments(array('id_member' => $memID)); | 
| 3249 | - } | |
| 3250 | -	elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) | |
| 3386 | +	} elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) | |
| 3251 | 3387 |  	{ | 
| 3252 | 3388 | // We need these clean... | 
| 3253 | 3389 | $cur_profile['id_attach'] = 0; | 
| @@ -3259,11 +3395,13 @@ discard block | ||
| 3259 | 3395 | |
| 3260 | 3396 |  		$profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); | 
| 3261 | 3397 | |
| 3262 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') | |
| 3263 | - $profile_vars['avatar'] = ''; | |
| 3398 | +		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { | |
| 3399 | + $profile_vars['avatar'] = ''; | |
| 3400 | + } | |
| 3264 | 3401 | // Trying to make us do something we'll regret? | 
| 3265 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') | |
| 3266 | - return 'bad_avatar_invalid_url'; | |
| 3402 | +		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { | |
| 3403 | + return 'bad_avatar_invalid_url'; | |
| 3404 | + } | |
| 3267 | 3405 | // Should we check dimensions? | 
| 3268 | 3406 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) | 
| 3269 | 3407 |  		{ | 
| @@ -3273,9 +3411,9 @@ discard block | ||
| 3273 | 3411 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) | 
| 3274 | 3412 |  			{ | 
| 3275 | 3413 | // Houston, we have a problem. The avatar is too large!! | 
| 3276 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') | |
| 3277 | - return 'bad_avatar_too_large'; | |
| 3278 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') | |
| 3414 | +				if ($modSettings['avatar_action_too_large'] == 'option_refuse') { | |
| 3415 | + return 'bad_avatar_too_large'; | |
| 3416 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') | |
| 3279 | 3417 |  				{ | 
| 3280 | 3418 | // @todo remove this if appropriate | 
| 3281 | 3419 | require_once($sourcedir . '/Subs-Graphics.php'); | 
| @@ -3285,26 +3423,27 @@ discard block | ||
| 3285 | 3423 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; | 
| 3286 | 3424 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; | 
| 3287 | 3425 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; | 
| 3426 | +					} else { | |
| 3427 | + return 'bad_avatar'; | |
| 3288 | 3428 | } | 
| 3289 | - else | |
| 3290 | - return 'bad_avatar'; | |
| 3291 | 3429 | } | 
| 3292 | 3430 | } | 
| 3293 | 3431 | } | 
| 3294 | - } | |
| 3295 | -	elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) | |
| 3432 | +	} elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) | |
| 3296 | 3433 |  	{ | 
| 3297 | 3434 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) | 
| 3298 | 3435 |  		{ | 
| 3299 | 3436 | // Get the dimensions of the image. | 
| 3300 | 3437 | if (!$downloadedExternalAvatar) | 
| 3301 | 3438 |  			{ | 
| 3302 | - if (!is_writable($uploadDir)) | |
| 3303 | -					fatal_lang_error('attachments_no_write', 'critical'); | |
| 3439 | +				if (!is_writable($uploadDir)) { | |
| 3440 | +									fatal_lang_error('attachments_no_write', 'critical'); | |
| 3441 | + } | |
| 3304 | 3442 | |
| 3305 | 3443 |  				$new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); | 
| 3306 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) | |
| 3307 | -					fatal_lang_error('attach_timeout', 'critical'); | |
| 3444 | +				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { | |
| 3445 | +									fatal_lang_error('attach_timeout', 'critical'); | |
| 3446 | + } | |
| 3308 | 3447 | |
| 3309 | 3448 | $_FILES['attachment']['tmp_name'] = $new_filename; | 
| 3310 | 3449 | } | 
| @@ -3417,17 +3556,19 @@ discard block | ||
| 3417 | 3556 | $profile_vars['avatar'] = ''; | 
| 3418 | 3557 | |
| 3419 | 3558 | // Delete any temporary file. | 
| 3420 | - if (file_exists($_FILES['attachment']['tmp_name'])) | |
| 3421 | - @unlink($_FILES['attachment']['tmp_name']); | |
| 3559 | +			if (file_exists($_FILES['attachment']['tmp_name'])) { | |
| 3560 | + @unlink($_FILES['attachment']['tmp_name']); | |
| 3561 | + } | |
| 3422 | 3562 | } | 
| 3423 | 3563 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. | 
| 3424 | - else | |
| 3564 | +		else { | |
| 3565 | + $profile_vars['avatar'] = ''; | |
| 3566 | + } | |
| 3567 | +	} elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { | |
| 3568 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); | |
| 3569 | +	} else { | |
| 3425 | 3570 | $profile_vars['avatar'] = ''; | 
| 3426 | 3571 | } | 
| 3427 | -	elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) | |
| 3428 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); | |
| 3429 | - else | |
| 3430 | - $profile_vars['avatar'] = ''; | |
| 3431 | 3572 | |
| 3432 | 3573 | // Setup the profile variables so it shows things right on display! | 
| 3433 | 3574 | $cur_profile['avatar'] = $profile_vars['avatar']; | 
| @@ -3475,9 +3616,9 @@ discard block | ||
| 3475 | 3616 | $smiley_parsed = $unparsed_signature; | 
| 3476 | 3617 | parsesmileys($smiley_parsed); | 
| 3477 | 3618 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); | 
| 3478 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) | |
| 3479 | - return 'signature_allow_smileys'; | |
| 3480 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) | |
| 3619 | +		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { | |
| 3620 | + return 'signature_allow_smileys'; | |
| 3621 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) | |
| 3481 | 3622 |  		{ | 
| 3482 | 3623 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); | 
| 3483 | 3624 | return 'signature_max_smileys'; | 
| @@ -3490,14 +3631,15 @@ discard block | ||
| 3490 | 3631 |  			{ | 
| 3491 | 3632 | $limit_broke = 0; | 
| 3492 | 3633 | // Attempt to allow all sizes of abuse, so to speak. | 
| 3493 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) | |
| 3494 | - $limit_broke = $sig_limits[7] . 'px'; | |
| 3495 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) | |
| 3496 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; | |
| 3497 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) | |
| 3498 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; | |
| 3499 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) | |
| 3500 | - $limit_broke = 'large'; | |
| 3634 | +				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { | |
| 3635 | + $limit_broke = $sig_limits[7] . 'px'; | |
| 3636 | +				} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { | |
| 3637 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; | |
| 3638 | +				} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { | |
| 3639 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; | |
| 3640 | +				} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { | |
| 3641 | + $limit_broke = 'large'; | |
| 3642 | + } | |
| 3501 | 3643 | |
| 3502 | 3644 | if ($limit_broke) | 
| 3503 | 3645 |  				{ | 
| @@ -3539,24 +3681,26 @@ discard block | ||
| 3539 | 3681 | $width = -1; $height = -1; | 
| 3540 | 3682 | |
| 3541 | 3683 | // Does it have predefined restraints? Width first. | 
| 3542 | - if ($matches[6][$key]) | |
| 3543 | - $matches[2][$key] = $matches[6][$key]; | |
| 3684 | +					if ($matches[6][$key]) { | |
| 3685 | + $matches[2][$key] = $matches[6][$key]; | |
| 3686 | + } | |
| 3544 | 3687 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) | 
| 3545 | 3688 |  					{ | 
| 3546 | 3689 | $width = $sig_limits[5]; | 
| 3547 | 3690 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); | 
| 3691 | +					} elseif ($matches[2][$key]) { | |
| 3692 | + $width = $matches[2][$key]; | |
| 3548 | 3693 | } | 
| 3549 | - elseif ($matches[2][$key]) | |
| 3550 | - $width = $matches[2][$key]; | |
| 3551 | 3694 | // ... and height. | 
| 3552 | 3695 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) | 
| 3553 | 3696 |  					{ | 
| 3554 | 3697 | $height = $sig_limits[6]; | 
| 3555 | - if ($width != -1) | |
| 3556 | - $width = $width * ($height / $matches[4][$key]); | |
| 3698 | +						if ($width != -1) { | |
| 3699 | + $width = $width * ($height / $matches[4][$key]); | |
| 3700 | + } | |
| 3701 | +					} elseif ($matches[4][$key]) { | |
| 3702 | + $height = $matches[4][$key]; | |
| 3557 | 3703 | } | 
| 3558 | - elseif ($matches[4][$key]) | |
| 3559 | - $height = $matches[4][$key]; | |
| 3560 | 3704 | |
| 3561 | 3705 | // If the dimensions are still not fixed - we need to check the actual image. | 
| 3562 | 3706 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) | 
| @@ -3574,21 +3718,24 @@ discard block | ||
| 3574 | 3718 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) | 
| 3575 | 3719 |  							{ | 
| 3576 | 3720 | $height = $sig_limits[6]; | 
| 3577 | - if ($width == -1) | |
| 3578 | - $width = $sizes[0]; | |
| 3721 | +								if ($width == -1) { | |
| 3722 | + $width = $sizes[0]; | |
| 3723 | + } | |
| 3579 | 3724 | $width = $width * ($height / $sizes[1]); | 
| 3725 | +							} elseif ($width != -1) { | |
| 3726 | + $height = $sizes[1]; | |
| 3580 | 3727 | } | 
| 3581 | - elseif ($width != -1) | |
| 3582 | - $height = $sizes[1]; | |
| 3583 | 3728 | } | 
| 3584 | 3729 | } | 
| 3585 | 3730 | |
| 3586 | 3731 | // Did we come up with some changes? If so remake the string. | 
| 3587 | - if ($width != -1 || $height != -1) | |
| 3588 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; | |
| 3732 | +					if ($width != -1 || $height != -1) { | |
| 3733 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; | |
| 3734 | + } | |
| 3735 | + } | |
| 3736 | +				if (!empty($replaces)) { | |
| 3737 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); | |
| 3589 | 3738 | } | 
| 3590 | - if (!empty($replaces)) | |
| 3591 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); | |
| 3592 | 3739 | } | 
| 3593 | 3740 | } | 
| 3594 | 3741 | |
| @@ -3632,10 +3779,12 @@ discard block | ||
| 3632 | 3779 |  	$email = strtr($email, array(''' => '\'')); | 
| 3633 | 3780 | |
| 3634 | 3781 | // Check the name and email for validity. | 
| 3635 | - if (trim($email) == '') | |
| 3636 | - return 'no_email'; | |
| 3637 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) | |
| 3638 | - return 'bad_email'; | |
| 3782 | +	if (trim($email) == '') { | |
| 3783 | + return 'no_email'; | |
| 3784 | + } | |
| 3785 | +	if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { | |
| 3786 | + return 'bad_email'; | |
| 3787 | + } | |
| 3639 | 3788 | |
| 3640 | 3789 | // Email addresses should be and stay unique. | 
| 3641 | 3790 |  	$request = $smcFunc['db_query']('', ' | 
| @@ -3650,8 +3799,9 @@ discard block | ||
| 3650 | 3799 | ) | 
| 3651 | 3800 | ); | 
| 3652 | 3801 | |
| 3653 | - if ($smcFunc['db_num_rows']($request) > 0) | |
| 3654 | - return 'email_taken'; | |
| 3802 | +	if ($smcFunc['db_num_rows']($request) > 0) { | |
| 3803 | + return 'email_taken'; | |
| 3804 | + } | |
| 3655 | 3805 | $smcFunc['db_free_result']($request); | 
| 3656 | 3806 | |
| 3657 | 3807 | return true; | 
| @@ -3664,8 +3814,9 @@ discard block | ||
| 3664 | 3814 |  { | 
| 3665 | 3815 | global $modSettings, $context, $cur_profile; | 
| 3666 | 3816 | |
| 3667 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') | |
| 3668 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); | |
| 3817 | +	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { | |
| 3818 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); | |
| 3819 | + } | |
| 3669 | 3820 | |
| 3670 | 3821 | loadUserSettings(); | 
| 3671 | 3822 | writeLog(); | 
| @@ -3681,8 +3832,9 @@ discard block | ||
| 3681 | 3832 | require_once($sourcedir . '/Subs-Post.php'); | 
| 3682 | 3833 | |
| 3683 | 3834 | // Shouldn't happen but just in case. | 
| 3684 | - if (empty($profile_vars['email_address'])) | |
| 3685 | - return; | |
| 3835 | +	if (empty($profile_vars['email_address'])) { | |
| 3836 | + return; | |
| 3837 | + } | |
| 3686 | 3838 | |
| 3687 | 3839 | $replacements = array( | 
| 3688 | 3840 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], | 
| @@ -3705,8 +3857,9 @@ discard block | ||
| 3705 | 3857 | $_SESSION['log_time'] = 0; | 
| 3706 | 3858 | $_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0)); | 
| 3707 | 3859 | |
| 3708 | - if (isset($_COOKIE[$cookiename])) | |
| 3709 | - $_COOKIE[$cookiename] = ''; | |
| 3860 | +	if (isset($_COOKIE[$cookiename])) { | |
| 3861 | + $_COOKIE[$cookiename] = ''; | |
| 3862 | + } | |
| 3710 | 3863 | |
| 3711 | 3864 | loadUserSettings(); | 
| 3712 | 3865 | |
| @@ -3739,11 +3892,13 @@ discard block | ||
| 3739 | 3892 | $groups[] = $curMember['id_group']; | 
| 3740 | 3893 | |
| 3741 | 3894 | // Ensure the query doesn't croak! | 
| 3742 | - if (empty($groups)) | |
| 3743 | - $groups = array(0); | |
| 3895 | +	if (empty($groups)) { | |
| 3896 | + $groups = array(0); | |
| 3897 | + } | |
| 3744 | 3898 | // Just to be sure... | 
| 3745 | - foreach ($groups as $k => $v) | |
| 3746 | - $groups[$k] = (int) $v; | |
| 3899 | +	foreach ($groups as $k => $v) { | |
| 3900 | + $groups[$k] = (int) $v; | |
| 3901 | + } | |
| 3747 | 3902 | |
| 3748 | 3903 | // Get all the membergroups they can join. | 
| 3749 | 3904 |  	$request = $smcFunc['db_query']('', ' | 
| @@ -3773,12 +3928,14 @@ discard block | ||
| 3773 | 3928 | while ($row = $smcFunc['db_fetch_assoc']($request)) | 
| 3774 | 3929 |  	{ | 
| 3775 | 3930 | // Can they edit their primary group? | 
| 3776 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) | |
| 3777 | - $context['can_edit_primary'] = true; | |
| 3931 | +		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { | |
| 3932 | + $context['can_edit_primary'] = true; | |
| 3933 | + } | |
| 3778 | 3934 | |
| 3779 | 3935 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. | 
| 3780 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) | |
| 3781 | - continue; | |
| 3936 | +		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { | |
| 3937 | + continue; | |
| 3938 | + } | |
| 3782 | 3939 | |
| 3783 | 3940 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( | 
| 3784 | 3941 | 'id' => $row['id_group'], | 
| @@ -3807,13 +3964,15 @@ discard block | ||
| 3807 | 3964 | ); | 
| 3808 | 3965 | |
| 3809 | 3966 | // No changing primary one unless you have enough groups! | 
| 3810 | - if (count($context['groups']['member']) < 2) | |
| 3811 | - $context['can_edit_primary'] = false; | |
| 3967 | +	if (count($context['groups']['member']) < 2) { | |
| 3968 | + $context['can_edit_primary'] = false; | |
| 3969 | + } | |
| 3812 | 3970 | |
| 3813 | 3971 | // In the special case that someone is requesting membership of a group, setup some special context vars. | 
| 3814 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) | |
| 3815 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; | |
| 3816 | -} | |
| 3972 | +	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { | |
| 3973 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; | |
| 3974 | + } | |
| 3975 | + } | |
| 3817 | 3976 | |
| 3818 | 3977 | /** | 
| 3819 | 3978 | * This function actually makes all the group changes | 
| @@ -3828,10 +3987,12 @@ discard block | ||
| 3828 | 3987 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; | 
| 3829 | 3988 | |
| 3830 | 3989 | // Let's be extra cautious... | 
| 3831 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) | |
| 3832 | -		isAllowedTo('manage_membergroups'); | |
| 3833 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) | |
| 3834 | -		fatal_lang_error('no_access', false); | |
| 3990 | +	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { | |
| 3991 | +			isAllowedTo('manage_membergroups'); | |
| 3992 | + } | |
| 3993 | +	if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { | |
| 3994 | +			fatal_lang_error('no_access', false); | |
| 3995 | + } | |
| 3835 | 3996 | |
| 3836 | 3997 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); | 
| 3837 | 3998 | |
| @@ -3850,8 +4011,9 @@ discard block | ||
| 3850 | 4011 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; | 
| 3851 | 4012 | |
| 3852 | 4013 | // Sanity check!! | 
| 3853 | - if ($group_id == 1) | |
| 3854 | -		isAllowedTo('admin_forum'); | |
| 4014 | +	if ($group_id == 1) { | |
| 4015 | +			isAllowedTo('admin_forum'); | |
| 4016 | + } | |
| 3855 | 4017 | // Protected groups too! | 
| 3856 | 4018 | else | 
| 3857 | 4019 |  	{ | 
| @@ -3868,8 +4030,9 @@ discard block | ||
| 3868 | 4030 | list ($is_protected) = $smcFunc['db_fetch_row']($request); | 
| 3869 | 4031 | $smcFunc['db_free_result']($request); | 
| 3870 | 4032 | |
| 3871 | - if ($is_protected == 1) | |
| 3872 | -			isAllowedTo('admin_forum'); | |
| 4033 | +		if ($is_protected == 1) { | |
| 4034 | +					isAllowedTo('admin_forum'); | |
| 4035 | + } | |
| 3873 | 4036 | } | 
| 3874 | 4037 | |
| 3875 | 4038 | // What ever we are doing, we need to determine if changing primary is possible! | 
| @@ -3891,36 +4054,43 @@ discard block | ||
| 3891 | 4054 | $group_name = $row['group_name']; | 
| 3892 | 4055 | |
| 3893 | 4056 | // Does the group type match what we're doing - are we trying to request a non-requestable group? | 
| 3894 | - if ($changeType == 'request' && $row['group_type'] != 2) | |
| 3895 | -				fatal_lang_error('no_access', false); | |
| 4057 | +			if ($changeType == 'request' && $row['group_type'] != 2) { | |
| 4058 | +							fatal_lang_error('no_access', false); | |
| 4059 | + } | |
| 3896 | 4060 | // What about leaving a requestable group we are not a member of? | 
| 3897 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) | |
| 3898 | -				fatal_lang_error('no_access', false); | |
| 3899 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) | |
| 3900 | -				fatal_lang_error('no_access', false); | |
| 4061 | +			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { | |
| 4062 | +							fatal_lang_error('no_access', false); | |
| 4063 | +			} elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { | |
| 4064 | +							fatal_lang_error('no_access', false); | |
| 4065 | + } | |
| 3901 | 4066 | |
| 3902 | 4067 | // We can't change the primary group if this is hidden! | 
| 3903 | - if ($row['hidden'] == 2) | |
| 3904 | - $canChangePrimary = false; | |
| 4068 | +			if ($row['hidden'] == 2) { | |
| 4069 | + $canChangePrimary = false; | |
| 4070 | + } | |
| 3905 | 4071 | } | 
| 3906 | 4072 | |
| 3907 | 4073 | // If this is their old primary, can we change it? | 
| 3908 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) | |
| 3909 | - $canChangePrimary = 1; | |
| 4074 | +		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { | |
| 4075 | + $canChangePrimary = 1; | |
| 4076 | + } | |
| 3910 | 4077 | |
| 3911 | 4078 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. | 
| 3912 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) | |
| 3913 | - $canChangePrimary = false; | |
| 4079 | +		if ($changeType != 'primary' && $old_profile['id_group'] != 0) { | |
| 4080 | + $canChangePrimary = false; | |
| 4081 | + } | |
| 3914 | 4082 | |
| 3915 | 4083 | // If this is the one we are acting on, can we even act? | 
| 3916 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) | |
| 3917 | - $canChangePrimary = false; | |
| 4084 | +		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { | |
| 4085 | + $canChangePrimary = false; | |
| 4086 | + } | |
| 3918 | 4087 | } | 
| 3919 | 4088 | $smcFunc['db_free_result']($request); | 
| 3920 | 4089 | |
| 3921 | 4090 | // Didn't find the target? | 
| 3922 | - if (!$foundTarget) | |
| 3923 | -		fatal_lang_error('no_access', false); | |
| 4091 | +	if (!$foundTarget) { | |
| 4092 | +			fatal_lang_error('no_access', false); | |
| 4093 | + } | |
| 3924 | 4094 | |
| 3925 | 4095 | // Final security check, don't allow users to promote themselves to admin. | 
| 3926 | 4096 |  	if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) | 
| @@ -3940,8 +4110,9 @@ discard block | ||
| 3940 | 4110 | list ($disallow) = $smcFunc['db_fetch_row']($request); | 
| 3941 | 4111 | $smcFunc['db_free_result']($request); | 
| 3942 | 4112 | |
| 3943 | - if ($disallow) | |
| 3944 | -			isAllowedTo('admin_forum'); | |
| 4113 | +		if ($disallow) { | |
| 4114 | +					isAllowedTo('admin_forum'); | |
| 4115 | + } | |
| 3945 | 4116 | } | 
| 3946 | 4117 | |
| 3947 | 4118 | // If we're requesting, add the note then return. | 
| @@ -3959,8 +4130,9 @@ discard block | ||
| 3959 | 4130 | 'status_open' => 0, | 
| 3960 | 4131 | ) | 
| 3961 | 4132 | ); | 
| 3962 | - if ($smcFunc['db_num_rows']($request) != 0) | |
| 3963 | -			fatal_lang_error('profile_error_already_requested_group'); | |
| 4133 | +		if ($smcFunc['db_num_rows']($request) != 0) { | |
| 4134 | +					fatal_lang_error('profile_error_already_requested_group'); | |
| 4135 | + } | |
| 3964 | 4136 | $smcFunc['db_free_result']($request); | 
| 3965 | 4137 | |
| 3966 | 4138 | // Log the request. | 
| @@ -3994,10 +4166,11 @@ discard block | ||
| 3994 | 4166 | // Are we leaving? | 
| 3995 | 4167 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) | 
| 3996 | 4168 |  		{ | 
| 3997 | - if ($old_profile['id_group'] == $group_id) | |
| 3998 | - $newPrimary = 0; | |
| 3999 | - else | |
| 4000 | - unset($addGroups[$group_id]); | |
| 4169 | +			if ($old_profile['id_group'] == $group_id) { | |
| 4170 | + $newPrimary = 0; | |
| 4171 | +			} else { | |
| 4172 | + unset($addGroups[$group_id]); | |
| 4173 | + } | |
| 4001 | 4174 | } | 
| 4002 | 4175 | // ... if not, must be joining. | 
| 4003 | 4176 | else | 
| @@ -4005,36 +4178,42 @@ discard block | ||
| 4005 | 4178 | // Can we change the primary, and do we want to? | 
| 4006 | 4179 | if ($canChangePrimary) | 
| 4007 | 4180 |  			{ | 
| 4008 | - if ($old_profile['id_group'] != 0) | |
| 4009 | - $addGroups[$old_profile['id_group']] = -1; | |
| 4181 | +				if ($old_profile['id_group'] != 0) { | |
| 4182 | + $addGroups[$old_profile['id_group']] = -1; | |
| 4183 | + } | |
| 4010 | 4184 | $newPrimary = $group_id; | 
| 4011 | 4185 | } | 
| 4012 | 4186 | // Otherwise it's an additional group... | 
| 4013 | - else | |
| 4014 | - $addGroups[$group_id] = -1; | |
| 4187 | +			else { | |
| 4188 | + $addGroups[$group_id] = -1; | |
| 4189 | + } | |
| 4015 | 4190 | } | 
| 4016 | 4191 | } | 
| 4017 | 4192 | // Finally, we must be setting the primary. | 
| 4018 | 4193 | elseif ($canChangePrimary) | 
| 4019 | 4194 |  	{ | 
| 4020 | - if ($old_profile['id_group'] != 0) | |
| 4021 | - $addGroups[$old_profile['id_group']] = -1; | |
| 4022 | - if (isset($addGroups[$group_id])) | |
| 4023 | - unset($addGroups[$group_id]); | |
| 4195 | +		if ($old_profile['id_group'] != 0) { | |
| 4196 | + $addGroups[$old_profile['id_group']] = -1; | |
| 4197 | + } | |
| 4198 | +		if (isset($addGroups[$group_id])) { | |
| 4199 | + unset($addGroups[$group_id]); | |
| 4200 | + } | |
| 4024 | 4201 | $newPrimary = $group_id; | 
| 4025 | 4202 | } | 
| 4026 | 4203 | |
| 4027 | 4204 | // Finally, we can make the changes! | 
| 4028 | - foreach ($addGroups as $id => $dummy) | |
| 4029 | - if (empty($id)) | |
| 4205 | +	foreach ($addGroups as $id => $dummy) { | |
| 4206 | + if (empty($id)) | |
| 4030 | 4207 | unset($addGroups[$id]); | 
| 4208 | + } | |
| 4031 | 4209 |  	$addGroups = implode(',', array_flip($addGroups)); | 
| 4032 | 4210 | |
| 4033 | 4211 | // Ensure that we don't cache permissions if the group is changing. | 
| 4034 | - if ($context['user']['is_owner']) | |
| 4035 | - $_SESSION['mc']['time'] = 0; | |
| 4036 | - else | |
| 4037 | -		updateSettings(array('settings_updated' => time())); | |
| 4212 | +	if ($context['user']['is_owner']) { | |
| 4213 | + $_SESSION['mc']['time'] = 0; | |
| 4214 | +	} else { | |
| 4215 | +			updateSettings(array('settings_updated' => time())); | |
| 4216 | + } | |
| 4038 | 4217 | |
| 4039 | 4218 |  	updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); | 
| 4040 | 4219 | |
| @@ -4057,8 +4236,9 @@ discard block | ||
| 4057 | 4236 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) | 
| 4058 | 4237 |  	{ | 
| 4059 | 4238 | // Check to ensure we're forcing SSL for authentication | 
| 4060 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) | |
| 4061 | -			fatal_lang_error('login_ssl_required'); | |
| 4239 | +		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { | |
| 4240 | +					fatal_lang_error('login_ssl_required'); | |
| 4241 | + } | |
| 4062 | 4242 | |
| 4063 | 4243 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, | 
| 4064 | 4244 | // we do not want too much AJAX to confuse them. | 
| @@ -4095,8 +4275,7 @@ discard block | ||
| 4095 | 4275 | $context['sub_template'] = 'tfasetup_backup'; | 
| 4096 | 4276 | |
| 4097 | 4277 | return; | 
| 4098 | - } | |
| 4099 | - else | |
| 4278 | + } else | |
| 4100 | 4279 |  			{ | 
| 4101 | 4280 | $context['tfa_secret'] = $_SESSION['tfa_secret']; | 
| 4102 | 4281 | $context['tfa_error'] = !$valid_code; | 
| @@ -4104,8 +4283,7 @@ discard block | ||
| 4104 | 4283 | $context['tfa_pass_value'] = $_POST['passwd']; | 
| 4105 | 4284 | $context['tfa_value'] = $_POST['tfa_code']; | 
| 4106 | 4285 | } | 
| 4107 | - } | |
| 4108 | - else | |
| 4286 | + } else | |
| 4109 | 4287 |  		{ | 
| 4110 | 4288 | $totp = new \TOTP\Auth(); | 
| 4111 | 4289 | $secret = $totp->generateCode(); | 
| @@ -4115,17 +4293,16 @@ discard block | ||
| 4115 | 4293 | } | 
| 4116 | 4294 | |
| 4117 | 4295 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); | 
| 4118 | - } | |
| 4119 | - elseif (isset($_REQUEST['disable'])) | |
| 4296 | + } elseif (isset($_REQUEST['disable'])) | |
| 4120 | 4297 |  	{ | 
| 4121 | 4298 | updateMemberData($memID, array( | 
| 4122 | 4299 | 'tfa_secret' => '', | 
| 4123 | 4300 | 'tfa_backup' => '', | 
| 4124 | 4301 | )); | 
| 4125 | 4302 |  		redirectexit('action=profile;area=account;u=' . $memID); | 
| 4303 | +	} else { | |
| 4304 | +			redirectexit('action=profile;area=account;u=' . $memID); | |
| 4305 | + } | |
| 4126 | 4306 | } | 
| 4127 | - else | |
| 4128 | -		redirectexit('action=profile;area=account;u=' . $memID); | |
| 4129 | -} | |
| 4130 | 4307 | |
| 4131 | 4308 | ?> | 
| 4132 | 4309 | \ No newline at end of file |