settings['disable_gd'] != 1){
$image = @imagecreatefrompng("./colors.png");
// Use GD method
return "
$txt[128]
";
}else{
// Use old fashioned way
return "
";
}
}
function color_update(){
global $x7c, $txt;
// This extra page function is needed if you use GD to update the
// actual color since the old method is client-side and GD is
// server-side we have to send the data to the server before
// upating the input form.
// See if the user submitted a custom RGB value or if they clicked it
if(isset($_POST['custom_color'])){
if(strlen($_POST['custom_color']) == 6){
$color = "#".$_POST['custom_color'];
}elseif(strlen($_POST['custom_color']) == 7){
$color = $_POST['custom_color'];
}else{
$color = "#00000";
}
// See what form they want it routed to
if(!isset($_GET['toform']))
$form = 'chatIn';
else
$form = $_GET['toform'];
if(!isset($_GET['tofield']))
$field = "curcolor";
else
$field = $_GET['tofield'];
if(isset($_GET['extra'])){
$extra = "opener.document.getElementById('{$field}d').innerHTML = '$color';\n
opener.document.getElementById('{$field}d').style.color = '$color';";
}else{
$extra = "";
}
return "$txt[134]";
}
// Get the coordinates from the image map
$coords = eregi_replace("^\?","",$_GET['coords']);
$coords = explode(",",$coords);
// Test once more for GD support
if(function_exists("imagecreatefrompng") && file_exists("./colors.png") && $x7c->settings['disable_gd'] != 1){
$image = @imagecreatefrompng("./colors.png");
// Get the location of the color they picked
$rgb = imagecolorat($image,$coords[0],$coords[1]);
$rgb = imagecolorsforindex($image,$rgb);
// Convert from decimal to hexidecimal
$r = dechex($rgb['red']);
$b = dechex($rgb['blue']);
$g = dechex($rgb['green']);
// Since PHP will automatically chop the leading zero off a
// single digit number we need to add it back on
if(strlen($r) == 1)
$r = "0".$r;
if(strlen($g) == 1)
$g = "0".$g;
if(strlen($b) == 1)
$b = "0".$b;
// See what form they want it routed to
if(!isset($_GET['toform']))
$form = 'chatIn';
else
$form = $_GET['toform'];
if(!isset($_GET['tofield']))
$field = "curcolor";
else
$field = $_GET['tofield'];
if(isset($_GET['extra'])){
$extra = "opener.document.getElementById('{$field}d').innerHTML = '#$r$g$b';\n
opener.document.getElementById('{$field}d').style.color = '#$r$g$b';";
}else{
$extra = "";
}
// Output the changer
return "$txt[134]";
}else{
// Somehow they made it to this page and GD isn't working, tell them an error occured.
// This is not translated because they should never be able to get here in the first place.
return "* Critcal Library Error * The GD Library required for this color picker is missing. Please contact the administrator of this chat room.";
}
}
?>