saga
Sep 27 2005, 01:14 PM
hi everbody, I am creating this website for an online game KHAN which is of course hosted by Trap17.com. Anyway, it accepts membership since its services includes message board for every member and message board for groups that members created and of course personal messages. So here is my problem, since it accepts membership it requires applicants to fill up forms which ask their e-mail address, I want to know how make an activation code that is an image. Get my point?  it is basically like here in trap17 where before you could click register or submit during registration you need to copy the numbers and letters in an image to a text box. I need this to avoid automated registration which can use up all my 150mb disk space or worst used my registration to annoy other people by using their e-mail add in the registration form. actualy I was thinking of creating hundreds or more images with numbers and letters on it. Everytime there is need to send the registration form to a browser i will pick 1 image randomly then change its filename randomly and put it in the registration form. In that case images will not use the same filename everytime it is used. But creating all those images (more thatn 100) is more than a headache. Thats why I'm hoping that someone could share to me how this kind of problem realy are taken care of. Thanks in advance 
Reply
SystemWisdom
Sep 27 2005, 01:27 PM
I wrote a script like this not too long ago... The theory is: You make a random string, save that random string to your sessions (for later comparison), and then generate and output the image.. First, the class file: CODE <?php
class TuringImage { // Font Settings var $m_szFontFace; var $m_iFontSize; // Image Object var $m_oImage;
// Image Bounds var $m_aImageSize;
// Image Text var $m_szImageText;
function TuringImage() { // Font Settings $this->m_szFontFace = 'fonts/mtcorsva.ttf'; $this->m_iFontSize = 20;
$this->m_oImage = 0; $this->m_aImageSize = array( 110, 40 ); // Image Width & Height $this->m_szImageText = ''; }
function GenerateKey( $iLen ) { $szRandStr = md5( uniqid( rand(), true ) ); $iRandIdx = rand( 0, (strlen($szRandStr) - $iLen - 1) ); $szRandStr = substr( $szRandStr, $iRandIdx, $iLen ); // Replace O's and 0's to reduce confusion $szRandStr = str_replace( "O", "X", $szRandStr ); $szRandStr = str_replace( "0", "4", $szRandStr ); $this->m_szImageText = strtoupper( $szRandStr ); return; }
function GetKey() { return $this->m_szImageText; }
function Create() { $iTextLen = 5; // Create Image $this->m_oImage = imagecreate( $this->m_aImageSize[0], $this->m_aImageSize[1] );
// Get Colors $oColorFG = imagecolorallocate( $this->m_oImage, 143, 168, 183 ); $oColorBG = imagecolorallocate( $this->m_oImage, 30, 42, 49 );
// Set Background Color of Image imagefilledrectangle( $this->m_oImage, 0, 0, $this->m_aImageSize[0], $this->m_aImageSize[1], $oColorFG ); imagefilledrectangle( $this->m_oImage, 1, 1, $this->m_aImageSize[0]-2, $this->m_aImageSize[1]-2, $oColorBG );
// Obfuscate Image $this->ObfuscateImage(); // Write Verification String to Image for( $i = 0; $i < $iTextLen; $i++ ) $this->WriteTTF( (10 + ($i * 18)), (24 + rand(0, 5)), rand(-15, 15), $this->m_szImageText[$i] ); // Output Image to Browser imagegif( $this->m_oImage );
// Free Image Resources imagedestroy( $this->m_oImage ); return; }
function ObfuscateImage() { $oColor = imagecolorallocate( $this->m_oImage, 143, 168, 183 ); // Random Pixels for( $x = 0; $x < $this->m_aImageSize[0]; $x += rand( 3, 7 ) ) for( $y = 0; $y < $this->m_aImageSize[1]; $y += rand( 3, 7 ) ) imagesetpixel( $this->m_oImage, $x, $y, $oColor ); // Random Diagonal Lines for( $x = 0; $x < $this->m_aImageSize[0]; $x += rand( 15, 25 ) ) imageline( $this->m_oImage, $x, 0, $x + rand( -50, 50 ), $this->m_aImageSize[1], $oColor );
for( $y = 0; $y < $this->m_aImageSize[1]; $y += rand( 15, 25 ) ) imageline( $this->m_oImage, 0, $y, $this->m_aImageSize[0], $y + rand( -50, 50 ), $oColor );
return; }
function WriteTTF( $iLocX, $iLocY, $iAngle, $szText ) { $oColor = imagecolorallocate( $this->m_oImage, 255, 255, 255 ); imagettftext( $this->m_oImage, $this->m_iFontSize, $iAngle, $iLocX, $iLocY, $oColor, $this->m_szFontFace, $szText ); } } ?>
Now, that class uses a True-Type font, which you can find in your c:\windows\fonts\ directory, but it should be placed in your web server where the script can access it.. Next, you will want to output that image.. something like: CODE // Create Turing Test Object $oTuringTest = new TuringImage(); $oTuringTest->GenerateKey( 5 ); // Length of Key (5)
// Store key in sessions for later comparison $_SESSION['SECURITY_KEY'] = $oTuringTest->GetKey();
// Set Content Type to GIF with NoCache header( 'Content-type: image/gif' ); header( 'Expires: ' . gmdate('D, d M Y H:i:s') . 'GMT' ); header( 'Cache-control: no-cache' );
// Output Image $oTuringTest->Create();
Now, all you need to do, is create a form that will allow the user to enter the text they see, and then submit that form back to one of your PHP pages, where you can then get the Posted Form variable, and compare it with the session value.. If it is correct, well, you know what to do!! I hope that helps!
Reply
saga
Sep 27 2005, 03:13 PM
tnx for the code, its a great help... coz i dont have the time and resources to study the use of PHP in generating images.. tanx...
Reply
wariorpk
Sep 27 2005, 07:03 PM
Nice code I have always wondered how people got that to work. This is a great feature that is a must have for any site that lets you register for it.
Reply
Similar Topics
Keywords : activation, code, images, activation, code, images
- Web Design Code
you can leep the design in place with code (3)
How Do I Code A Design?
(5) Okey, so I saw another topic here regarding how to make a design. I know how to do that, so that is
no problem. But I have always had some problems on how to code a design. I am tired of that I always
need to use some sort of program, drag&drop webhost (like piczo) or use a free design I found
online. I have noticed that people need to "cut" the design in different parts, but I have never
understood what way the do it. So I do not understand anything about this, and really need some
help. I will be happy for all help I get. /smile.gif" style="vertical-align:middle"....
Target Links To A Div Layer
Is there such code that allows you to change ur link target so that it (22) Hey i need help I was wondering if there is a code that allows you to target ur link to a div
layer.. lets say eg.. i got CODE <a href="www.example.com">Example</a>
i want that page to show in the div layer below on the same page. Is there a way i can do that? .
im tryin to avoid using frames. thanks....
Is There An Xbox Live Gamertag Code To Shw The Gamercard On A Website?
The title says all! (1) Hi everyone, im looking for a code that will display a users xbox live gamercard. Ive seen one
little widget but that was for the igoogle page ao its not suitable for what i want. Ideally I want
one thats written with HTML or something like that so its easy for me to modify and such. What i
want it to do is t have a URL in the code which the user can then insert their gamertag ID into and
have the widget display their gamercard for all to see. if i ever use this code it will be on a
money making site, hopefully, so something thats free to use even for commercial things ....
Almost There
Creation of activation (8) I got my mail() function to work on my local machine, thanks to jhaslip's excellent help.
(Sincere thanks for that). Now, I am one step away from completing a script to let it do exactly
what I want. I already have a page where people can fill in a form to subscribe to a newsletter,
and they get an email to confirm they have subscribed. However, i would like to be able to put a
link in there, when they click on it it sends them to a webpage to tell them their subscription is
now active. To achieve that, i have added one field to the table called 'active', wi....
How Do I Learn Web Design?
Not coding, i can code well already but how to make it look good? (48) Hi all. In my quest to become a website creator I have a big obstacle.. when it comes to design, eg
making things look good i might as well be blind. Im useless! I can code to a decent standard
in HTML PHP CSS MYSQL and JS but i am useless at making a nice design. So wha im after is advice on
how to learn this, what i fear is a response of "you can *learn* how to design, you either can or
you cant.". Its really important that im able to design a nice looking website because not many
people have a concise set of drawings from which to code the website. Any advice ....
Forum Rpgs
Is the PHP code convertable? (1) I use Proboards Forums, which doesn't allow PHP. I've been looking for a RPG forum game for
Proboards. But sadly, they only come in PHP. So, I was wondering, is it possible to convert that PHP
into HTML? Can Java Script be converted into HTML, too? Some of these codes are in java, as well.
If you don't know, the RPGs have stats, classes, battling, shops, ect. I've seen it on many
forums. I know that boards like InvisionFree abd PHPBB are great for this kind of thing, but I feel
comfortable on Proboards. Plus, those boards confuse me. I know it's sil....
Getting Flash Images On A Site
(1) well, i don' t have a site yet, but about 6 months ago i made a template, with flash buttons and
all, with sound and everything i was so proud so i tryed to put em on there with a special code u
needet or something ,so i did, but i got blank images,, i even tryed uploading it on the site it
didn't work, so i asked around they said u can' t install them on a cpanel, u need ftp, so i
downloadet the program needet and i got stuck there, so basicly how do u do that,and could some1
help me out how to get it working on a cpanel....
Best Way For Role-over Images?
(2) Hi Guys, I'm trying to work out the best way to make this site. This is what I have made so
far using CSS, divs, and spans: Site: http://www.frusciante.trap17.com/slices/coded.html CSS:
http://www.frusciante.trap17.com/slices/style.css I found a problem with this attempt when you
resize the browser window all the images move with it. Any suggestions on how to fix this? So
basically what i want to be able to do with this is have those buttons light up some how when i roll
over them. My idea was to have each button on a fairly small image, that way you don....
Hoverbox Image Gallery
a pretty cool way to present Images on a page (1) Hoverbox is an Image Gallery which I found some time ago. The feature I like the most about it is
the effect of the "on-hover" state which changes the image from a small thumbnail size to a
"mid-size" image. Essentially, it doubles the size of the picture when your mouse hovers on it. The
Hoverbox uses CSS for the size change and needs no javascript to perform. In fact, it works the same
without javascript. And... it apparently works in IE. The CSS method used includes 'hiding'
the larger image until the 'on-hover' state is reached. As you know, IE....
Phpbb And Mysql Relations?
Need forum code for my website (2) Hi if someone could get back to me as fast as they can that would be great! i got a couple of
questions what do you use my sql for what does that have to do with forums? and secondally can
someone give me the php code for the forum thanks /biggrin.gif" style="vertical-align:middle"
emoid=":D" border="0" alt="biggrin.gif" />....
View Souce Code
do you know this site? (8) I have seen this site before.The site is simple.there are a box that you can put a url link then
press enter you can see the code of the page (see everything include meta,comment...),even it is
written in php,asp... If anyone know this site,please let me know(I have format my computer,so I
lost it).thank you. ....
Oscommerce Images?
(4) Does anyone know where I can find some really good oscommerce replacement images? The ones that
come with the program don't fit in with my store. I found a contribution that gets rid of them,
but I am looking for some cool images to replace them with. I'm also looking for them in pink
preferrably, but I can always change the color in photoshop. Also, for anyone who wants to know,
I found a cool program that lets you generate oscommerce buttons to fit the color pallete of your
store at http://oscommerce-buttons.org/ Well back to the grind. Hopefully my st....
Html Code Problem
(7) Hi! Im working on a little HTML project for myself and am teaching myself.. So I would like to
know how to set roll over effects and a short guide on it! What I mean is, I would like to know
the code of making the mouse over on links make the links go red... Or if anyone can give me a way
to do it on frontpage, because I cant find it! Thnx in advance!....
Pre Load Images
(12) I want to preload some images with my page and after searching in google I found this code but it
doesn't seem to work. Cany anyone tell me what is wrong? <script language="JavaScript">
<!-- Image1= new Image() Image1.src = "Slice3_over.gif" Image2 = new Image() Image2.src
= "Slice4_over.gif" Image3 = new Image() Image3.src = "Slice5_over.gif" Image3 = new Image()
Image3.src = "Slice6_over.gif" --> ....
Great Background Images
Don't miss them! (1) Here it is: http://home.arcor.de/stefun132/Hintergrund/ ....
Great Background Images
Don't miss them! (2) Here it is: http://home.arcor.de/stefun132/Hintergrund/ ....
I Have A Souce Code And I Was Wondering
(2) How do i download it on to a message board?....
Asp - Code Generator Wizard
Very good (0) If anyone likes asp, or makes his websites in asp, just go here: They have this online code
generator tools: Data Command Wizard Form Wizard Response.Write Wizard Meta Tag Generator CODE
http://www.powerasp.com/code_wizards/default.asp They are very cool!....
How Do I Embed Scripts Into Images?
(7) I've always wondered but I never really knew how.......
1000 Free Psd Icon Images
They are very cool (10) Here it is: CODE http://www.stud.uni-hannover.de/~ngthanh/1000_ico/page_01.htm
http://www.stud.uni-hannover.de/~ngthanh/1000_ico/page_02.htm
http://www.stud.uni-hannover.de/~ngthanh/1000_ico/page_03.htm
http://www.stud.uni-hannover.de/~ngthanh/1000_ico/page_04.htm
http://www.stud.uni-hannover.de/~ngthanh/1000_ico/page_05.htm Carpe diem.....
[Code] - Shout Box
Invision Power Board v1.3.0g (4) Code for Invision Power Board v1.3.0g Just please in headers/footers in admin CODE
<script> // IF Shoutbox v1.0 - Leave Copyright Intact Wherever Used // Created For Invision
Free // Author: Zero Tolerance © Game Zone | Evolution 2004 [http://gzevolution.net]
// Special Thanks To ffmasters.us For Hosting PHP Data + mySQL Allowance Site =
"http://"+document.domain+"/" Site =
location.href.substring(Site.length) if(Site.match('/')){ Site =
Site.split('/')[0] } thissit....
Cropped Thumnail Images?
newbie.. (0) Is there software that will allow you to crop images when you make a have a lot of pics that's
different sizes? I only use Frontpage & whenever I auto thumbnail images that are different
sizes..they come out looking very disorganized. I've seen on some sites where they're able
to make thumbnails all the same size & the thumbnail is not the entire pic, but rather the central
focus..for example the thumbnail just shows the head, while the actual picture is a view of the
entire body.....
Looking for activation, code, images, activation, code, images
|
|
Searching Video's for activation, code, images, activation, code, images
|
advertisement
|
|