Passed
Push — patch_1-1-9 ( 33104f...4749cf )
by Spuds
18:43 queued 12:51
created
sources/subs/Graphics.subs.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -377,7 +377,7 @@
 block discarded – undo
377 377
 
378 378
 			// The behavior of bestfit changed in Imagick 3.0.0 and it will now scale up, we prevent that
379 379
 			$dest_width = empty($max_width) ? $src_width : ($force_resize ? $max_width : min($max_width, $src_width));
380
-			$dest_height = empty($max_height) ? $src_height : ($force_resize ? $max_height :  min($max_height, $src_height));
380
+			$dest_height = empty($max_height) ? $src_height : ($force_resize ? $max_height : min($max_height, $src_height));
381 381
 
382 382
 			// Set jpeg image quality to 80
383 383
 			if ($default_formats[$preferred_format] === 'jpeg')
Please login to merge, or discard this patch.
Braces   +218 added lines, -87 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
 	$destName = substr($destName, 0, -4);
44 44
 
45 45
 	if ($success && @rename($destName . '.tmp', $destName))
46
-		return true;
46
+	{
47
+			return true;
48
+	}
47 49
 	else
48 50
 	{
49 51
 		@unlink($destName . '.tmp');
@@ -79,13 +81,17 @@  discard block
 block discarded – undo
79 81
 	if (!resizeImageFile($fileName, $fileName . '.tmp', null, null, $preferred_format, true))
80 82
 	{
81 83
 		if (file_exists($fileName . '.tmp'))
82
-			unlink($fileName . '.tmp');
84
+		{
85
+					unlink($fileName . '.tmp');
86
+		}
83 87
 
84 88
 		return false;
85 89
 	}
86 90
 
87 91
 	if (!unlink($fileName))
88
-		return false;
92
+	{
93
+			return false;
94
+	}
89 95
 
90 96
 	return rename($fileName . '.tmp', $fileName);
91 97
 }
@@ -162,7 +168,9 @@  discard block
 block discarded – undo
162 168
 
163 169
 	// Check to see if GD is installed and what version.
164 170
 	if (($extensionFunctions = get_extension_funcs('gd')) === false)
165
-		return false;
171
+	{
172
+			return false;
173
+	}
166 174
 
167 175
 	// Also determine if GD2 is installed and store it in a global.
168 176
 	$gd2 = in_array('imagecreatetruecolor', $extensionFunctions) && function_exists('imagecreatetruecolor');
@@ -267,7 +275,9 @@  discard block
 block discarded – undo
267 275
 
268 276
 	// Nothing to do without GD or IM
269 277
 	if (!checkGD() && !checkImagick())
270
-		return false;
278
+	{
279
+			return false;
280
+	}
271 281
 
272 282
 	if (!file_exists($source) && substr($source, 0, 7) !== 'http://' && substr($source, 0, 8) !== 'https://')
273 283
 	{
@@ -310,25 +320,33 @@  discard block
 block discarded – undo
310 320
 			}
311 321
 			fclose($fp_source);
312 322
 		}
313
-		else
314
-			$sizes = array(-1, -1, -1);
323
+		else {
324
+					$sizes = array(-1, -1, -1);
325
+		}
315 326
 
316 327
 		fclose($fp_destination);
317 328
 	}
318 329
 	// We can't get to the file.
319
-	else
320
-		$sizes = array(-1, -1, -1);
330
+	else {
331
+			$sizes = array(-1, -1, -1);
332
+	}
321 333
 
322 334
 	if ($sizes[0] === -1)
323
-		return false;
335
+	{
336
+			return false;
337
+	}
324 338
 
325 339
 	// See if we have -or- can get the needed memory for this operation
326 340
 	if (checkGD() && !imageMemoryCheck($sizes))
327
-		return false;
341
+	{
342
+			return false;
343
+	}
328 344
 
329 345
 	// Not allowed to save webp or can't support webp input
330 346
 	if ((empty($modSettings['attachment_webp_enable']) && $preferred_format == 18) || ($sizes[2] == 18 && !hasWebpSupport()))
331
-		return false;
347
+	{
348
+			return false;
349
+	}
332 350
 
333 351
 	// A known and supported format?
334 352
 	if (checkImagick() && isset($default_formats[$sizes[2]]))
@@ -404,7 +422,9 @@  discard block
 block discarded – undo
404 422
 
405 423
 		// Just to be sure, if the admin does not want webp
406 424
 		if (empty($modSettings['attachment_webp_enable']))
407
-			unset($default_formats[18]);
425
+		{
426
+					unset($default_formats[18]);
427
+		}
408 428
 
409 429
 		$preferred_format = empty($preferred_format) || !isset($default_formats[$preferred_format]) ? 2 : $preferred_format;
410 430
 
@@ -506,33 +526,46 @@  discard block
 block discarded – undo
506 526
 					imagecopyresamplebicubic($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
507 527
 				}
508 528
 			}
509
-			else
510
-				$dst_img = $src_img;
529
+			else {
530
+							$dst_img = $src_img;
531
+			}
532
+		}
533
+		else {
534
+					$dst_img = $src_img;
511 535
 		}
512
-		else
513
-			$dst_img = $src_img;
514 536
 
515 537
 		// Save the image as ...
516 538
 		if (!empty($preferred_format) && ($preferred_format == 3) && function_exists('imagepng'))
517
-			$success = imagepng($dst_img, $destName, 9, PNG_ALL_FILTERS);
539
+		{
540
+					$success = imagepng($dst_img, $destName, 9, PNG_ALL_FILTERS);
541
+		}
518 542
 		elseif (!empty($preferred_format) && ($preferred_format == 1) && function_exists('imagegif'))
519
-			$success = imagegif($dst_img, $destName);
543
+		{
544
+					$success = imagegif($dst_img, $destName);
545
+		}
520 546
 		elseif (!empty($preferred_format) && $preferred_format == 18 && function_exists('imagewebp'))
521
-			$success = imagewebp($dst_img, $destName, 80);
547
+		{
548
+					$success = imagewebp($dst_img, $destName, 80);
549
+		}
522 550
 		elseif (function_exists('imagejpeg'))
523
-			$success = imagejpeg($dst_img, $destName, 80);
551
+		{
552
+					$success = imagejpeg($dst_img, $destName, 80);
553
+		}
524 554
 
525 555
 		// Free the memory.
526 556
 		imagedestroy($src_img);
527 557
 		if ($dst_img != $src_img)
528
-			imagedestroy($dst_img);
558
+		{
559
+					imagedestroy($dst_img);
560
+		}
529 561
 
530 562
 		return $success;
531 563
 	}
532 564
 	// Without Imagick or GD, no image resizing at all.
533
-	else
534
-		return false;
535
-}
565
+	else {
566
+			return false;
567
+	}
568
+	}
536 569
 
537 570
 /*
538 571
  * Determines if an image has any alpha pixels
@@ -543,13 +576,17 @@  discard block
 block discarded – undo
543 576
 function hasTransparency($fileName, $png = true)
544 577
 {
545 578
 	if (empty($fileName) || !file_exists($fileName))
546
-		return false;
579
+	{
580
+			return false;
581
+	}
547 582
 
548 583
 	$header = file_get_contents($fileName, false, null, 0, 26);
549 584
 
550 585
 	// Does it even claim to have been saved with transparency
551 586
 	if ($png && !ord($header[25]) & 4)
552
-		return false;
587
+	{
588
+			return false;
589
+	}
553 590
 
554 591
 	// Webp has its own
555 592
 	if (!$png)
@@ -599,11 +636,16 @@  discard block
 block discarded – undo
599 636
 		list ($width, $height, $type) = elk_getimagesize($fileName);
600 637
 
601 638
 		if ($type === 18 && hasWebpSupport())
602
-			$image = imagecreatefromwebp($fileName);
639
+		{
640
+					$image = imagecreatefromwebp($fileName);
641
+		}
603 642
 		elseif ($type === 3)
604
-			$image = imagecreatefrompng($fileName);
605
-		else
606
-			return false;
643
+		{
644
+					$image = imagecreatefrompng($fileName);
645
+		}
646
+		else {
647
+					return false;
648
+		}
607 649
 
608 650
 		for ($i = 0; $i < $width; $i++)
609 651
 		{
@@ -1009,7 +1051,9 @@  discard block
 block discarded – undo
1009 1051
 			if ($color == -1)
1010 1052
 			{
1011 1053
 				if ($palsize++ < 256)
1012
-					imagecolorallocate($dst_img, $red, $green, $blue);
1054
+				{
1055
+									imagecolorallocate($dst_img, $red, $green, $blue);
1056
+				}
1013 1057
 				$color = imagecolorclosest($dst_img, $red, $green, $blue);
1014 1058
 			}
1015 1059
 
@@ -1050,13 +1094,18 @@  discard block
 block discarded – undo
1050 1094
 
1051 1095
 		// Not a standard bitmap, bail out
1052 1096
 		if ($header['type'] != 0x4D42)
1053
-			return false;
1097
+		{
1098
+					return false;
1099
+		}
1054 1100
 
1055 1101
 		// Create our image canvas with the given WxH
1056 1102
 		if ($gd2)
1057
-			$dst_img = imagecreatetruecolor($info['width'], $info['height']);
1058
-		else
1059
-			$dst_img = imagecreate($info['width'], $info['height']);
1103
+		{
1104
+					$dst_img = imagecreatetruecolor($info['width'], $info['height']);
1105
+		}
1106
+		else {
1107
+					$dst_img = imagecreate($info['width'], $info['height']);
1108
+		}
1060 1109
 
1061 1110
 		// Color bitCounts 1,4,8 have palette information we use
1062 1111
 		$palette = array();
@@ -1088,7 +1137,9 @@  discard block
 block discarded – undo
1088 1137
 			$scan_line = fread($fp, $scan_line_size);
1089 1138
 
1090 1139
 			if (strlen($scan_line) < $scan_line_size)
1091
-				continue;
1140
+			{
1141
+							continue;
1142
+			}
1092 1143
 
1093 1144
 			// 32 bits per pixel
1094 1145
 			if ($info['bits'] == 32)
@@ -1108,7 +1159,9 @@  discard block
 block discarded – undo
1108 1159
 
1109 1160
 						// Gah!  Out of colors?  Stupid GD 1... try anyhow.
1110 1161
 						if ($color == -1)
1111
-							$color = imagecolorclosest($dst_img, $r, $g, $b);
1162
+						{
1163
+													$color = imagecolorclosest($dst_img, $r, $g, $b);
1164
+						}
1112 1165
 					}
1113 1166
 
1114 1167
 					imagesetpixel($dst_img, $x, $y, $color);
@@ -1131,7 +1184,9 @@  discard block
 block discarded – undo
1131 1184
 
1132 1185
 						// Gah!  Out of colors?  Stupid GD 1... try anyhow.
1133 1186
 						if ($color == -1)
1134
-							$color = imagecolorclosest($dst_img, $r, $g, $b);
1187
+						{
1188
+													$color = imagecolorclosest($dst_img, $r, $g, $b);
1189
+						}
1135 1190
 					}
1136 1191
 
1137 1192
 					imagesetpixel($dst_img, $x, $y, $color);
@@ -1160,7 +1215,9 @@  discard block
 block discarded – undo
1160 1215
 
1161 1216
 						// Gah!  Out of colors?  Stupid GD 1... try anyhow.
1162 1217
 						if ($color == -1)
1163
-							$color = imagecolorclosest($dst_img, $r, $g, $b);
1218
+						{
1219
+													$color = imagecolorclosest($dst_img, $r, $g, $b);
1220
+						}
1164 1221
 					}
1165 1222
 
1166 1223
 					imagesetpixel($dst_img, $x, $y, $color);
@@ -1171,7 +1228,9 @@  discard block
 block discarded – undo
1171 1228
 			{
1172 1229
 				$x = 0;
1173 1230
 				for ($j = 0; $j < $scan_line_size; $x++)
1174
-					imagesetpixel($dst_img, $x, $y, $palette[ord($scan_line[$j++])]);
1231
+				{
1232
+									imagesetpixel($dst_img, $x, $y, $palette[ord($scan_line[$j++])]);
1233
+				}
1175 1234
 			}
1176 1235
 			// 4 bits per pixel
1177 1236
 			elseif ($info['bits'] == 4)
@@ -1183,7 +1242,9 @@  discard block
 block discarded – undo
1183 1242
 
1184 1243
 					imagesetpixel($dst_img, $x, $y, $palette[(int) ($byte / 16)]);
1185 1244
 					if (++$x < $info['width'])
1186
-						imagesetpixel($dst_img, $x, $y, $palette[$byte & 15]);
1245
+					{
1246
+											imagesetpixel($dst_img, $x, $y, $palette[$byte & 15]);
1247
+					}
1187 1248
 				}
1188 1249
 			}
1189 1250
 			// 1 bit
@@ -1198,7 +1259,9 @@  discard block
 block discarded – undo
1198 1259
 					for ($shift = 1; $shift < 8; $shift++)
1199 1260
 					{
1200 1261
 						if (++$x < $info['width'])
1201
-							imagesetpixel($dst_img, $x, $y, $palette[(($byte << $shift) & 128) != 0]);
1262
+						{
1263
+													imagesetpixel($dst_img, $x, $y, $palette[(($byte << $shift) & 128) != 0]);
1264
+						}
1202 1265
 					}
1203 1266
 				}
1204 1267
 			}
@@ -1231,7 +1294,9 @@  discard block
 block discarded – undo
1231 1294
 	global $gd2, $settings, $user_info, $modSettings;
1232 1295
 
1233 1296
 	if (!checkGD())
1234
-		return false;
1297
+	{
1298
+			return false;
1299
+	}
1235 1300
 
1236 1301
 	// What type are we going to be doing?
1237 1302
 	// Note: The higher the value of visual_verification_type the harder the verification is
@@ -1240,7 +1305,9 @@  discard block
 block discarded – undo
1240 1305
 
1241 1306
 	// Special case to allow the admin center to show samples.
1242 1307
 	if ($user_info['is_admin'] && isset($_GET['type']))
1243
-		$imageType = (int) $_GET['type'];
1308
+	{
1309
+			$imageType = (int) $_GET['type'];
1310
+	}
1244 1311
 
1245 1312
 	// Some quick references for what we do.
1246 1313
 	// Do we show no, low or high noise?
@@ -1275,24 +1342,33 @@  discard block
 block discarded – undo
1275 1342
 
1276 1343
 	// What color is the background - generally white unless we're on "hard".
1277 1344
 	if ($simpleBGColor)
1278
-		$background_color = array(255, 255, 255);
1279
-	else
1280
-		$background_color = isset($settings['verification_background']) ? $settings['verification_background'] : array(236, 237, 243);
1345
+	{
1346
+			$background_color = array(255, 255, 255);
1347
+	}
1348
+	else {
1349
+			$background_color = isset($settings['verification_background']) ? $settings['verification_background'] : array(236, 237, 243);
1350
+	}
1281 1351
 
1282 1352
 	// The color of the characters shown (red, green, blue).
1283 1353
 	if ($simpleFGColor)
1284
-		$foreground_color = array(0, 0, 0);
1354
+	{
1355
+			$foreground_color = array(0, 0, 0);
1356
+	}
1285 1357
 	else
1286 1358
 	{
1287 1359
 		$foreground_color = array(64, 101, 136);
1288 1360
 
1289 1361
 		// Has the theme author requested a custom color?
1290 1362
 		if (isset($settings['verification_foreground']))
1291
-			$foreground_color = $settings['verification_foreground'];
1363
+		{
1364
+					$foreground_color = $settings['verification_foreground'];
1365
+		}
1292 1366
 	}
1293 1367
 
1294 1368
 	if (!is_dir($settings['default_theme_dir'] . '/fonts'))
1295
-		return false;
1369
+	{
1370
+			return false;
1371
+	}
1296 1372
 
1297 1373
 	// Can we use true type fonts?
1298 1374
 	$can_do_ttf = function_exists('imagettftext');
@@ -1304,13 +1380,19 @@  discard block
 block discarded – undo
1304 1380
 	while ($entry = $font_dir->read())
1305 1381
 	{
1306 1382
 		if (preg_match('~^(.+)\.gdf$~', $entry, $matches) === 1)
1307
-			$font_list[] = $entry;
1383
+		{
1384
+					$font_list[] = $entry;
1385
+		}
1308 1386
 		elseif (preg_match('~^(.+)\.ttf$~', $entry, $matches) === 1)
1309
-			$ttfont_list[] = $entry;
1387
+		{
1388
+					$ttfont_list[] = $entry;
1389
+		}
1310 1390
 	}
1311 1391
 
1312 1392
 	if (empty($font_list) && ($can_do_ttf && empty($ttfont_list)))
1313
-		return false;
1393
+	{
1394
+			return false;
1395
+	}
1314 1396
 
1315 1397
 	// For non-hard things don't even change fonts.
1316 1398
 	if (!$varyFonts)
@@ -1319,9 +1401,12 @@  discard block
 block discarded – undo
1319 1401
 
1320 1402
 		// Try use OpenSans if we can - it looks good!
1321 1403
 		if (in_array('OpenSans.ttf', $ttfont_list))
1322
-			$ttfont_list = array('OpenSans.ttf');
1323
-		else
1324
-			$ttfont_list = empty($ttfont_list) ? array() : array($ttfont_list[0]);
1404
+		{
1405
+					$ttfont_list = array('OpenSans.ttf');
1406
+		}
1407
+		else {
1408
+					$ttfont_list = empty($ttfont_list) ? array() : array($ttfont_list[0]);
1409
+		}
1325 1410
 	}
1326 1411
 
1327 1412
 	// Create a list of characters to be shown.
@@ -1340,8 +1425,10 @@  discard block
 block discarded – undo
1340 1425
 
1341 1426
 	// Load all fonts and determine the maximum font height.
1342 1427
 	if (!$can_do_ttf)
1343
-		foreach ($loaded_fonts as $font_index => $dummy)
1428
+	{
1429
+			foreach ($loaded_fonts as $font_index => $dummy)
1344 1430
 			$loaded_fonts[$font_index] = imageloadfont($settings['default_theme_dir'] . '/fonts/' . $font_list[$font_index]);
1431
+	}
1345 1432
 
1346 1433
 	// Determine the dimensions of each character.
1347 1434
 	$extra = ($imageType == 4 || $imageType == 5) ? 80 : 45;
@@ -1353,9 +1440,12 @@  discard block
 block discarded – undo
1353 1440
 		{
1354 1441
 			// GD2 handles font size differently.
1355 1442
 			if ($fontSizeRandom)
1356
-				$font_size = $gd2 ? mt_rand(17, 19) : mt_rand(25, 27);
1357
-			else
1358
-				$font_size = $gd2 ? 17 : 27;
1443
+			{
1444
+							$font_size = $gd2 ? mt_rand(17, 19) : mt_rand(25, 27);
1445
+			}
1446
+			else {
1447
+							$font_size = $gd2 ? 17 : 27;
1448
+			}
1359 1449
 
1360 1450
 			$img_box = imagettfbbox($font_size, 0, $settings['default_theme_dir'] . '/fonts/' . $ttfont_list[$character['font']], $character['id']);
1361 1451
 
@@ -1381,13 +1471,17 @@  discard block
 block discarded – undo
1381 1471
 
1382 1472
 	// Randomize the foreground color a little.
1383 1473
 	for ($i = 0; $i < 3; $i++)
1384
-		$foreground_color[$i] = mt_rand(max($foreground_color[$i] - 3, 0), min($foreground_color[$i] + 3, 255));
1474
+	{
1475
+			$foreground_color[$i] = mt_rand(max($foreground_color[$i] - 3, 0), min($foreground_color[$i] + 3, 255));
1476
+	}
1385 1477
 	$fg_color = imagecolorallocate($code_image, $foreground_color[0], $foreground_color[1], $foreground_color[2]);
1386 1478
 
1387 1479
 	// Color for the noise dots.
1388 1480
 	$dotbgcolor = array();
1389 1481
 	for ($i = 0; $i < 3; $i++)
1390
-		$dotbgcolor[$i] = $background_color[$i] < $foreground_color[$i] ? mt_rand(0, max($foreground_color[$i] - 20, 0)) : mt_rand(min($foreground_color[$i] + 20, 255), 255);
1482
+	{
1483
+			$dotbgcolor[$i] = $background_color[$i] < $foreground_color[$i] ? mt_rand(0, max($foreground_color[$i] - 20, 0)) : mt_rand(min($foreground_color[$i] + 20, 255), 255);
1484
+	}
1391 1485
 	$randomness_color = imagecolorallocate($code_image, $dotbgcolor[0], $dotbgcolor[1], $dotbgcolor[2]);
1392 1486
 
1393 1487
 	// Some squares/rectangles for new extreme level
@@ -1414,9 +1508,12 @@  discard block
 block discarded – undo
1414 1508
 		{
1415 1509
 			// How much rotation will we give?
1416 1510
 			if ($rotationType == 'none')
1417
-				$angle = 0;
1418
-			else
1419
-				$angle = mt_rand(-100, 100) / ($rotationType == 'high' ? 6 : 10);
1511
+			{
1512
+							$angle = 0;
1513
+			}
1514
+			else {
1515
+							$angle = mt_rand(-100, 100) / ($rotationType == 'high' ? 6 : 10);
1516
+			}
1420 1517
 
1421 1518
 			// What color shall we do it?
1422 1519
 			if ($fontColorType == 'cyclic')
@@ -1434,22 +1531,30 @@  discard block
 block discarded – undo
1434 1531
 				// Pick a color, but not the same one twice in a row
1435 1532
 				$new_index = $last_index;
1436 1533
 				while ($last_index == $new_index)
1437
-					$new_index = mt_rand(0, count($colors) - 1);
1534
+				{
1535
+									$new_index = mt_rand(0, count($colors) - 1);
1536
+				}
1438 1537
 				$char_fg_color = $colors[$new_index];
1439 1538
 				$last_index = $new_index;
1440 1539
 			}
1441 1540
 			elseif ($fontColorType == 'random')
1442
-				$char_fg_color = array(mt_rand(max($foreground_color[0] - 2, 0), $foreground_color[0]), mt_rand(max($foreground_color[1] - 2, 0), $foreground_color[1]), mt_rand(max($foreground_color[2] - 2, 0), $foreground_color[2]));
1443
-			else
1444
-				$char_fg_color = array($foreground_color[0], $foreground_color[1], $foreground_color[2]);
1541
+			{
1542
+							$char_fg_color = array(mt_rand(max($foreground_color[0] - 2, 0), $foreground_color[0]), mt_rand(max($foreground_color[1] - 2, 0), $foreground_color[1]), mt_rand(max($foreground_color[2] - 2, 0), $foreground_color[2]));
1543
+			}
1544
+			else {
1545
+							$char_fg_color = array($foreground_color[0], $foreground_color[1], $foreground_color[2]);
1546
+			}
1445 1547
 
1446 1548
 			if (!empty($can_do_ttf))
1447 1549
 			{
1448 1550
 				// GD2 handles font size differently.
1449 1551
 				if ($fontSizeRandom)
1450
-					$font_size = $gd2 ? mt_rand(17, 19) : mt_rand(18, 25);
1451
-				else
1452
-					$font_size = $gd2 ? 18 : 24;
1552
+				{
1553
+									$font_size = $gd2 ? mt_rand(17, 19) : mt_rand(18, 25);
1554
+				}
1555
+				else {
1556
+									$font_size = $gd2 ? 18 : 24;
1557
+				}
1453 1558
 
1454 1559
 				// Work out the sizes - also fix the character width cause TTF not quite so wide!
1455 1560
 				$font_x = $fontHorSpace === 'minus' && $cur_x > 0 ? $cur_x - 3 : $cur_x + 5;
@@ -1457,7 +1562,9 @@  discard block
 block discarded – undo
1457 1562
 
1458 1563
 				// What font face?
1459 1564
 				if (!empty($ttfont_list))
1460
-					$fontface = $settings['default_theme_dir'] . '/fonts/' . $ttfont_list[mt_rand(0, count($ttfont_list) - 1)];
1565
+				{
1566
+									$fontface = $settings['default_theme_dir'] . '/fonts/' . $ttfont_list[mt_rand(0, count($ttfont_list) - 1)];
1567
+				}
1461 1568
 
1462 1569
 				// What color are we to do it in?
1463 1570
 				$is_reverse = $showReverseChars ? mt_rand(0, 1) : false;
@@ -1465,20 +1572,27 @@  discard block
 block discarded – undo
1465 1572
 
1466 1573
 				$fontcord = @imagettftext($code_image, $font_size, $angle, $font_x, $font_y, $char_color, $fontface, $character['id']);
1467 1574
 				if (empty($fontcord))
1468
-					$can_do_ttf = false;
1575
+				{
1576
+									$can_do_ttf = false;
1577
+				}
1469 1578
 				elseif ($is_reverse !== false)
1470 1579
 				{
1471 1580
 					if (version_compare(PHP_VERSION, '8.1.0') === -1)
1472
-						imagefilledpolygon($code_image, $fontcord, 4, $fg_color);
1473
-					else
1474
-						imagefilledpolygon($code_image, $fontcord, $fg_color);
1581
+					{
1582
+											imagefilledpolygon($code_image, $fontcord, 4, $fg_color);
1583
+					}
1584
+					else {
1585
+											imagefilledpolygon($code_image, $fontcord, $fg_color);
1586
+					}
1475 1587
 
1476 1588
 					// Put the character back!
1477 1589
 					imagettftext($code_image, $font_size, $angle, $font_x, $font_y, $randomness_color, $fontface, $character['id']);
1478 1590
 				}
1479 1591
 
1480 1592
 				if ($can_do_ttf)
1481
-					$cur_x = max($fontcord[2], $fontcord[4]) + ($angle == 0 ? 0 : 3);
1593
+				{
1594
+									$cur_x = max($fontcord[2], $fontcord[4]) + ($angle == 0 ? 0 : 3);
1595
+				}
1482 1596
 			}
1483 1597
 
1484 1598
 			if (!$can_do_ttf)
@@ -1505,17 +1619,26 @@  discard block
 block discarded – undo
1505 1619
 
1506 1620
 	// Make the background color transparent on the hard image.
1507 1621
 	if (!$simpleBGColor)
1508
-		imagecolortransparent($code_image, $bg_color);
1622
+	{
1623
+			imagecolortransparent($code_image, $bg_color);
1624
+	}
1509 1625
 
1510 1626
 	if ($hasBorder)
1511
-		imagerectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $fg_color);
1627
+	{
1628
+			imagerectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $fg_color);
1629
+	}
1512 1630
 
1513 1631
 	// Add some noise to the background?
1514 1632
 	if ($noiseType != 'none')
1515 1633
 	{
1516 1634
 		for ($i = mt_rand(0, 2); $i < $max_height; $i += mt_rand(1, 2))
1517
-			for ($j = mt_rand(0, 10); $j < $total_width; $j += mt_rand(1, 10))
1518
-				imagesetpixel($code_image, $j, $i, mt_rand(0, 1) ? $fg_color : $randomness_color);
1635
+		{
1636
+					for ($j = mt_rand(0, 10);
1637
+		}
1638
+		$j < $total_width; $j += mt_rand(1, 10))
1639
+			{
1640
+							imagesetpixel($code_image, $j, $i, mt_rand(0, 1) ? $fg_color : $randomness_color);
1641
+			}
1519 1642
 
1520 1643
 		// Put in some lines too?
1521 1644
 		if ($noiseType != 'extreme')
@@ -1594,24 +1717,32 @@  discard block
 block discarded – undo
1594 1717
 	global $settings;
1595 1718
 
1596 1719
 	if (!is_dir($settings['default_theme_dir'] . '/fonts'))
1597
-		return false;
1720
+	{
1721
+			return false;
1722
+	}
1598 1723
 
1599 1724
 	// Get a list of the available font directories.
1600 1725
 	$font_dir = dir($settings['default_theme_dir'] . '/fonts');
1601 1726
 	$font_list = array();
1602 1727
 	while ($entry = $font_dir->read())
1603
-		if ($entry[0] !== '.' && is_dir($settings['default_theme_dir'] . '/fonts/' . $entry) && file_exists($settings['default_theme_dir'] . '/fonts/' . $entry . '.gdf'))
1728
+	{
1729
+			if ($entry[0] !== '.' && is_dir($settings['default_theme_dir'] . '/fonts/' . $entry) && file_exists($settings['default_theme_dir'] . '/fonts/' . $entry . '.gdf'))
1604 1730
 			$font_list[] = $entry;
1731
+	}
1605 1732
 
1606 1733
 	if (empty($font_list))
1607
-		return false;
1734
+	{
1735
+			return false;
1736
+	}
1608 1737
 
1609 1738
 	// Pick a random font.
1610 1739
 	$random_font = $font_list[array_rand($font_list)];
1611 1740
 
1612 1741
 	// Check if the given letter exists.
1613 1742
 	if (!file_exists($settings['default_theme_dir'] . '/fonts/' . $random_font . '/' . $letter . '.gif'))
1614
-		return false;
1743
+	{
1744
+			return false;
1745
+	}
1615 1746
 
1616 1747
 	// Include it!
1617 1748
 	header('Content-type: image/gif');
Please login to merge, or discard this patch.