Click to See Complete Forum and Search --> : Graphic password/code script?
HEADSTRONG
09-09-2005, 10:26 AM
I have been to some sites where you have to type in a code or password that appears as a graphic. I believe it is done to prevent SPAM or attacks to the site.
How can I add this to my site? is there a script that creates these graphical passwords?
thanks for any help :confused:
JPnyc
09-09-2005, 10:35 AM
Scripts can't generate images. Those are images you're seeing. You have to create those yourself. The script can bring them up at random, but it can't make them
HEADSTRONG
09-09-2005, 10:41 AM
Thanks for the quick reply
can you direct me in the right direction on how I can find the script or maybe purchase it? I assume the script also has to somehow authenicate or check the entered password with the graphical displayed password.
thanks again
bathurst_guy
09-09-2005, 10:49 AM
Scripts can't generate images. Those are images you're seeing. You have to create those yourself. The script can bring them up at random, but it can't make them
php can do it, but i cant remember how atm, there was a post on this a little while ago
JPnyc
09-09-2005, 10:52 AM
Finding one, I dunno. I would try all the major search engines. I've never written one of these but I have a good idea how it would be done. In fact it could be done clientside with Javascript. You'd place all the image file names into an array and use randomImageFile=Math.floor(Math.random()*totalNumberOfImagesHere) to pull them at random.
You'd need to create the image files 1st, then I would name the files the same as the contained password. Example: if the image shows 4RTMJ, name that pic file 4RTMJ.gif (or jpg, whatever). Then all you'd have to do is compare the contents of the text field with the file name held in your array index (the one that came up that time), and strip off the suffix.
bathurst_guy
09-09-2005, 10:53 AM
talked about here by bokeh http://www.webdeveloper.com/forum/showthread.php?t=77412
CAPCHA verification ;)
bokeh
09-09-2005, 10:54 AM
Bathurst pointed me here. It is called capcha verification. Do a search on google. PHP can create the images without a problem. Go and read up first and see if it is for you though. Also consider how this effects blind people. For them you should offer an audio version of the image.
HEADSTRONG
09-09-2005, 11:04 AM
Thanks everybody, for your help!
I prefer to do it in Javascript or ASP/vbscript if possible, I don't know PHP
But at least I know that it's called CAPCHA verification.
I will google some more
You guys rock!
thanks again
bokeh
09-09-2005, 11:43 AM
If you do it client side (javascript) it is easy to bypass. I am going to write a script now to do this. I need time to think about it though.
HEADSTRONG
09-09-2005, 12:10 PM
Great. thanks!
ray326
09-09-2005, 12:59 PM
This has been done with Perl in the past using the Perl gd library or with an interface to the GIMP API.
bokeh
09-09-2005, 03:35 PM
This has been done with Perl in the past using the Perl gd library or with an interface to the GIMP API.Sometimes it's writing it that is the challenge!
Edited to simplify the code
<?php
session_start();
function rand_string($len = 10){
$e = base64_encode(pack("h*", sha1(mt_rand())));
return substr(strtr($e, "+/=", "xyz"), 0, $len);
}
function capcha_image(){
header ('Content-type: image/jpeg');
$image = @imagecreate(110, 24);
$background = imagecolorallocate($image, 130,130,130);
$text_colour = imagecolorallocate($image, 90, 90, 90);
imagestring($image, 5, 9, 4, $_SESSION['capcha'], $text_colour);
imagejpeg($image, null, 100);
imagedestroy($image);
exit;
}
if(isset($_GET['image'])){ //create the image
if(empty($_SESSION['capcha']))exit;
capcha_image();
}else{ // html section
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n".
'<html>'."\n".
'<head>'."\n".
'<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />'."\n".
'<title>Capcha demo</title>'."\n".
'</head>'."\n".
'<body>'."\n".
'<div style="margin-left: 50px;">'."\n".
'<h2>Capcha demo</h2>'."\n";
if(isset($_POST['submit'])){
if($_POST['capcha'] == $_SESSION['capcha']){
print '<p>Success! <br>You entered the correct code! <br>Here\'s another one to try!</p>';
}else{
print '<p>Failure! <br>You entered the wrong code! <br>Here\'s another one to try!</p>';
}
}
$_SESSION['capcha'] = rand_string();
print '<img style="border: 1px solid #555;" src="http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].
'?image" width="110" height="24" alt="capcha image">'."\n".
'<form style="margin-top: 0; action="http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'" method="post">'."\n".
'<input type="text" name="capcha" style="width: 112px; margin-top: 5px; border: 1px solid #555; text-align: center;">'."\n".
'<span style="color: red;"> *</span><br>'."\n".
'<input type="submit" name="submit" value="try me" style="width: 112px; margin-top: 5px;">'."\n".
'</form>'."\n".
'<br><span style="color: red;">*</span> <i>case sensitive</i></div>'."\n".
'</body>'."\n".
'</html>';
}
?>
HEADSTRONG
09-09-2005, 04:36 PM
anyway to do it in Javascript or VBscript/ASP?
Sorry, I don't know PHP
Thanks
JPnyc
09-09-2005, 05:05 PM
You don't have to know it, he wrote it for you. All you need to know is if your host supports PHP. If it does, just call the script file onclick like any other file.
bokeh
09-09-2005, 05:15 PM
If you didn't want a PHP solution why did you ask your question in the PHP forum? Well maybe someone else will find this working solution of some use. By th way once you've written your ASP solution would you come back and post it here as I would be interested to see it.
bokeh
09-09-2005, 06:34 PM
Why has this script been kidnapped from the PHP forum? It is a PHP question and the solution will be wasted if it is not left in the PHP forum.
HEADSTRONG
09-09-2005, 10:57 PM
what happend?
HEADSTRONG
09-09-2005, 11:55 PM
HI All
Sorry I thought I was in the general forum...
anyways I found some code in ASP.NET for anyone interested.
Go to planetSourceCode.com and search for "Image verification" under .NET
I have not used it yet, but all the code is there.
Thanks for all your help