Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl use CGI qw/:html3 :standard/; use Fcntl qw/:flock/; # ################################################# # # # My Capcha # # # # Starting Date: April 20, 2017 # # Last Modified: May 21, 2017 # # # # Written by Troy Hammack # # Email: troylh@pacbell.net # # # ################################################# # # $ENV{"PATH"}=''; $ENV{"BASH_ENV"}=''; print "Content-type:text/html\n\n"; if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); } else { print "Content-type: text/html\n\n"; print "<P>Use Post or Get"; } foreach $pair (@pairs) { ($key, $value) = split (/=/, $pair); $key =~ tr/+/ /; $key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~s/<!--(.|\n)*-->//g; if ($formdata{$key}) { $formdata{$key} .= ", $value"; } else { $formdata{$key} = $value; } # # Test to see if Reset button was selected and clear all values in the + keys # if ($formdata{'reset'} eq "Reset") { foreach $pair (@pairs) { ($key, $value) = split (/=/, $pair); $formdata{$key} = ""; } } # # The answer < -- If I use this it doesn't work! # my @chars = ("A".."Z", "a".."z"); my $answer; $answer .= $chars[rand @chars] for 0..4; # # $answer = "ghRuE"; <-- If I use this it works fine. # print <<EndHTML; <html><head> <meta http-equiv="Content-Type" content="text/html; charset=windows-12 +52"> <title>My Capcha</title></head> <body background="http://www.astrologybythesea.com/images/bg_coastR.jp +g"> <!-- <p><u><font size="5" color="#0000FF">My Capcha</font></u></p> --> <form action="/cgi/mycapcha.cgi" method="post"> <table border="0" width="100%"> <center> <H5>AntiBot Verifiication</H><br> <div style='height:20px;width:70px;border:1px solid blue'> <font size="2">$answer</font></div> <!-- Now get users input --> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" size="8" maxlength="8" name="useranswer" value="$fo +rmdata{'useranswer'}"> <input type="submit" name="verify" value="Verify"><br>&nbsp;&nbsp;&nbs +p;Type the above characters</center> EndHTML # # $UpperCaseUserAnswer is UserAnswer converted to uppercase # $UpperCaseUserAnswer = uc $formdata{'useranswer'}; # # $UpperCaseAnswer is Upper case of $anwser # ================================================= $UpperCaseAnswer = uc $answer; if ($UpperCaseUserAnswer eq $UpperCaseAnswer) { goto END; exit(0); } print <<EndHTML; </table></form></body></html> EndHTML exit(0); #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= END: print "<br>Finished Capcha; exit(0);

In reply to Re^2: Random F%^k up strings! by TroyH
in thread Random F%^k up strings! by TroyH

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-24 15:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found