#!/usr/bin/perl use warnings; use strict; use CGI qw/:standard/; use CGI::Carp 'fatalsToBrowser'; use Image::Magick; print header, start_html('testing'); if (param('submit')) { my $code = param('code'); my $id = param('id'); print "ID: $id<p>"; if($code eq "$id") { print "You entered the correct code, well done<p><p>";} else { print "<font color=red>You have entered the wrong code. Please try ag +ain</font><p><p>"; } } my ($image, $x); $image=Image::Magick->new; $x = $image->Set(size=>'200x50'); $x = $image->ReadImage('xc:white'); warn "$x" if "$x"; my $chars; my @fonts = ("arial.ttf", "georgia.ttf", "verdanai.ttf"); my @chars = ( "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "M", " +N", "P" .. "Z", "a", "b", "d", "e", "n", "q", "r", 1 .. 9, ); my @yoffset = ("25", "28", "33", "35", "38", "41", "45"); my @pointsoffseth = ("5,30 199,30", "5,35 199,35", "5,40 199,40", "5,2 +4 199,24", "5,20 199,20", "5,42 199, 42", "5,50 199,50", "5, 55 199, 55"); my @pointsoffsetv = ("100,50 100,0", "90,50 90,0", "110,50 110,0", "85 +,50 85,0", "75,50 75,0", "65,50 65,0", "60,50 60,0", "50,50, 50,0", "40,50, 40,0", "25,50 25,0", "20,5 +0 20,0", "15,50 15,0", "10,50 10,0", "5,50 5,0", "115,50 115,0", "120,50 120,0", "125,50 125,0", "130,50 130,0", " +135,50 135,0", "140,50 140,0", "145,50 145,0", "150,50 150,50", "155,50 155,0", "160,50 160,50", "165,50 165,50", + "170,50 170,50", "175,50 175,50", "180,50 180,50", "185,50 185,0", "190,50 190,0", "195,50 195,0", " +199,50 199,0"); my $ID; ### randomize characters $ID = join '', map { $chars[ rand @chars ] } 1..9; ## length -- > by height ^ for (1 .. 3) { my $pointsoffseth = $pointsoffseth[rand @pointsoffseth]; ## Draw horizontal lines $x = $image->Draw( primitive => 'line', points => $pointsoffseth, stroke => 'black', ); } ## Draw verticle lines for (1 .. 6) { my $pointsoffsetv = $pointsoffsetv[rand @pointsoffsetv]; $x = $image->Draw( primitive => 'line', points => $pointsoffsetv, stroke => '#800', ); } my $xoffset = 10; foreach (split //, $ID) { my $yoffset = $yoffset[rand @yoffset]; my $font = $fonts[rand @fonts]; #print "Font: $font"; $x = $image->Annotate( font=>$font, pointsize=>'26', fill=>'blue', text=>$_, x=>$xoffset, y=>$yoffset); $xoffset = $xoffset + 21; warn "$x" if "$x"; } $x = $image->Write('test.png'); warn "$x" if "$x"; print "Image testing<br>"; print "<center><img src=\"test.png\"></center>"; print <<"ALL"; <center> <form action="random.pl" method="POST"> <input type="text" name="code"> <input type="hidden" name="id" value="$ID"> <input type="submit" value="submit" name="submit"> </form> </center> ALL
In reply to Item not refreshing with the page by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |