| Coding Forum Problems with your code? Let's hear about it. |
02-12-2006, 02:02 AM
|
#1 (permalink)
|
|
v7n Mentor
Join Date: 05-06-04
Location: London, UK
Posts: 1,452
Latest Blog: None
|
Image Validation
I have been looking on HotScripts.com for this type of script but I haven't been able to find one.
I want a pretty simple one, hopefully one in a small function that is easy to read and change.
http://cracker.com.au/classifieds/me...142035706.aspx
The box down the bottom is what I'm looking for.
If anyone knows of one of these scripts can they please post me a link and I shall go download it
Thanks in advance.
|
|
|
02-12-2006, 10:41 AM
|
#2 (permalink)
|
|
Possible Terrorist
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 4,904
|
If you would like to edit it in yourself then you can use this
From www.php.net/gd
PHP Code:
<?php
function generateValidationImage($rand) {
global $site_font_path;
global $site_font_validation;
$width = 120;
$height = 40;
$image = imagecreate($width, $height);
$bgColor = imagecolorallocate ($image, 255, 255, 255);
$textColor = imagecolorallocate ($image, 0, 0, 0);
// Add Random noise
for ($i = 0; $i < 250; $i++) {
$rx1 = rand(0,$width);
$rx2 = rand(0,$width);
$ry1 = rand(0,$height);
$ry2 = rand(0,$height);
$rcVal = rand(0,255);
$rc1 = imagecolorallocate($image,
rand(0,255),
rand(0,255),
rand(100,255));
imageline ($image, $rx1, $ry1, $rx2, $ry2, $rc1);
}
// write the random number
$font = imageloadfont($site_font_path."/".$site_font_validation);
imagestring($image, $font, 3, 0, $rand, $textColor);
// send several headers to make sure the image is not cached
// Date in the past
header("Expires: Mon, 23 Jul 1993 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
// send the content type header so the image is displayed properly
header('Content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
}
?>
The $site_font_path should be set to something like "/home/user/www/fonts".
The $site_font_validation should be set to the name of the GD font file,
like "anonymous.gdf".
You can view and download the code here:
http://www.digital-seven.net/?option...ask=view&id=67
__________________
Kyle Varga
"m3lt/theSpear"
student, web designer/coder, future IT consultant
Experience: PHP/MySQL, Java, C++, MS-SQL
|
|
|
02-12-2006, 07:21 PM
|
#3 (permalink)
|
|
v7n Mentor
Join Date: 05-06-04
Location: London, UK
Posts: 1,452
Latest Blog: None
|
Woh thanks m3lt I never knew what it was called. I will look into it now.
Cheers
|
|
|
02-14-2006, 04:56 AM
|
#4 (permalink)
|
|
v7n Mentor
Join Date: 05-06-04
Location: London, UK
Posts: 1,452
Latest Blog: None
|
|
|
|
02-14-2006, 06:05 AM
|
#5 (permalink)
|
|
Possible Terrorist
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 4,904
|
No problem, looks good 
__________________
Kyle Varga
"m3lt/theSpear"
student, web designer/coder, future IT consultant
Experience: PHP/MySQL, Java, C++, MS-SQL
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 04:39 AM.
© Copyright 2008 V7 Inc
|