Location: PHPKode > scripts > Silentum Hex Check > hex_check.php
<?PHP
	/*
	Silentum Hex Check v1.2
	Modified July 8, 2012
	hex_check.php copyright 2007-2012 HyperSilence
	*/

	$hex = $_GET["hex"];
	$random = $_GET["random"];
	$websafe = $_GET["websafe"];
	if(!isset($hex) && !isset($random)) $hex = "ffffff";
	
	if(isset($random)) {
	$hex = rand(1,16)."_".rand(1,16)."_".rand(1,16)."_".rand(1,16)."_".rand(1,16)."_".rand(1,16);
	$replace_numbers = array("10", "11", "12", "13", "14", "15", "16");
	$replace_with = array("a", "b", "c", "d", "e", "f", "0");
	$hex = str_replace($replace_numbers, $replace_with, $hex);
	$hex = str_replace("_", "", $hex);
	}
	
	if(isset($websafe)) {
	$hex = rand(1,7)."_".rand(1,7)."_".rand(1,7);
	$replace_numbers = array("1", "2", "4", "5", "7");
	$replace_with = array("0", "3", "9", "c", "f",);
	$hex = str_replace($replace_numbers, $replace_with, $hex);
	$hex = str_replace("_", "", $hex);
	}

	if(strlen($hex) != 6 && strlen($hex) != 3 && isset($hex) || !preg_match("/^[A-F0-9]+$/i",$hex) && isset($hex)) {
	$hex = "ffffff";
	$message = "<b>Please enter a valid, six or three digit hex code.</b><br><br>";
	}
	else {
	$message = "You are viewing <b>#".$hex."</b><br><br>";
	}
?>
<body style="background: #<?=$hex?>">
<h2>Silentum Hex Check v1.2</h2>
<span style="background: #ff0; color: #000"><?=$message?></span>
<form action="hex_check.php" method="get">
	# <input maxlength="6" name="hex" size="5" type="text">
	<input type="submit" value="Check">
</form>
<a href="hex_check.php?random" title="Generate Random Hex Color">Generate Random Hex Color</a><br>
<a href="hex_check.php?websafe" title="Generate Web Safe Hex Color">Generate Web Safe Hex Color</a><br><br>
<u>Instructions:</u><br>
Use this form to preview how any six digit (<b>RRGGBB</b>) or three digit (<b>RGB</b>) hex color  will look. Allowed characters are 0 through 9 and A through F. Case insensitive.
</body>
Return current item: Silentum Hex Check