note 97725 deleted from function.imagefttext by danbrown

From: Date: Wed, 05 May 2010 14:16:29 +0000
Subject: note 97725 deleted from function.imagefttext by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-168967@lists.php.net to get a copy of this message
Note Submitter: Roger Thomas ---- I put this together this morning, and it seems to work rather well. It outputs text using an embedded font file, but won't allow remote sites to use the script. If it's useful then use it :) <?php $yoursite=array("mysite.com","www.mysite.com","nextsite.mysite.com"); $AttemptedTheftRedirect="http://www.mysite.com/copyright-statement"; // set the text below $TextForImage="It works fine"; // set the font file below $FontFace = './dakota.ttf'; $Width=300; $Height=30; // // begin the checks below // $requestfrom = $_SERVER['HTTP_REFERER']; //Check if browser sends referrer url or not if ($requestfrom== "") { //If not, set referrer as your domain $domainfrom = $yoursite; } else { // below we parse the referer url $domainfrom = parse_url($requestfrom); } foreach($yoursite as $d) { if ($d==$domainfrom['host']) { $show="yes"; } } if($show=="yes") { // imagefttext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text [, array $extrainfo ] ) // Create a 300x100 image $Image = imagecreatetruecolor($Width, $Height); $background = imagecolorallocate($Image, 0xFF, 0xFF, 0xFF); $FontColor = imagecolorallocate($Image, 0x00, 0x00, 0x00); // Make the background color imagefilledrectangle($Image, 0, 0, 299, 99, $background); // create the image below // | Dimensions | Font Size | Angle | HorizontalStart | VerticalStart | Font Color | Font File | Text imagefttext($Image, 20, 0, 0, 25, $FontColor, $FontFace, $TextForImage); // Send the headers for the image header('Content-Type: image/png'); imagepng($Image); imagedestroy($Image); } else { // if they tried to steal, then redirect them to a theft page header("Location: ".$AttemptedTheftRedirect.""); exit(); } ?>

« previous php.notes (#168967) next »