Jump to content

Add background image to catchpa


ginger76

Recommended Posts

Hi,

 

I have a set of scripts that use a catchpa on the login form, but it just uses a background colour. How can I change the following to make it use a background image (catchpa.png) and a different font?

 

<?php 
/*************************************************************************** 
* 
* Filename : image.php 
* Began : 2005/04/04 
* Modified : 
* Copyright : (c) 2005 xkare.com 
* Version : 1.0 
* Written by : Mert ÖÐÜT in istanbul / TURKEY 
* 
* You are encouraged to redistribute and / or modify this program under the terms of 
* the GNU General Public License as published by the Free Software Foundation 
* (www.fsf.org); any version as from version 2 of the License. 
* 
***************************************************************************/ 
session_start(); 
function strrand($length) 
{ 
$str = ""; 
while(strlen($str)<$length){ 
$random=rand(48,122); 
if( ($random>47 && $random<58) ){ 
$str.=chr($random); 
} 
} 
return $str; 
} 
$text = $_SESSION['string']=strrand(5); 
$img_number = imagecreate(47,17); 
$backcolor = imagecolorallocate($img_number,244,244,244); 
$textcolor = imagecolorallocate($img_number,0,0,0); 
imagefill($img_number,0,0,$backcolor); 
imagestring($img_number,50,1,1,$text,$textcolor); 
header("Content-type: image/png"); 
imagejpeg($img_number); 
?>

Link to comment
https://forums.phpfreaks.com/topic/97625-add-background-image-to-catchpa/
Share on other sites

This will get you started....replace everything you have after the $text = $_SESSION line

 

$font = "Arial.ttf";
$width = 300;
$height = 100;
$image = imagecreatefrompng('blank.png');
$text_color = imagecolorallocate ($image, 255, 0, 0);

imagettftext($image, 20, 0, 10, 20, $black_color, $font, $text);
header("Content-type: image/png"); 
imagepng ($image);

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.