note 97725 added to function.imagefttext

From: Date: Wed, 05 May 2010 11:19:11 +0000
Subject: note 97725 added to function.imagefttext
Groups: php.notes 
Request: Send a blank email to php-notes+get-168956@lists.php.net to get a copy of this message
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(); } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 81.102.26.249 ---- Manual Page -- http://www.php.net/manual/en/function.imagefttext.php Edit -- https://master.php.net/note/edit/97725 Del: integrated -- https://master.php.net/note/delete/97725/integrated Del: useless -- https://master.php.net/note/delete/97725/useless Del: bad code -- https://master.php.net/note/delete/97725/bad+code Del: spam -- https://master.php.net/note/delete/97725/spam Del: non-english -- https://master.php.net/note/delete/97725/non-english Del: in docs -- https://master.php.net/note/delete/97725/in+docs Del: other reasons-- https://master.php.net/note/delete/97725 Reject -- https://master.php.net/note/reject/97725 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#168956) next »