OK, here's the full code that creates the image password:
$cities = "cities.txt"; # number/letters - city correspondences $cities_st = "cities_st.txt"; # city standard file $tmp = "temp.txt"; # temp file to keep the password # choose random letters or numbers @array = (0..9,a..z,A..Z); srand; foreach (1..5) { $rand = int(rand scalar(@array)); push (@selected, $rand); } # save the chosen password to file open TMP, ">$tmp"; print TMP @selected; close TMP; # open file with number/letter - cities correspondences open CITIES, $cities; while (<CITIES>) { for ($x; $x<5; $x++) { $match = $selected[$x]; if (/\+$match\+(\w+)/) {$selected[$x] = $1;} } } close CITIES; # erase file with number/letter - city correspondences unlink $cities; # read "cities_st.txt" open CITIES_ST, $cities_st; while (<CITIES_ST>) { /(\w+)/; push (@cities, $1); } close CITIES_ST; # randomize cities foreach (0..99) { $rand = int(rand scalar(@cities)); splice (@cities, $rand, 1); push (@cities, $_); } # create new "cities.txt" open CITIES, ">$cities"; foreach (a..z) { $city = 0; $out = "+",$_,"+",$cities[$city]; $city++; print CITIES $out; } foreach (A..Z) { $city = 26; $out = "+",$_,"+",$cities[$city]; $city++; print CITIES $out; } foreach (0..9) { $city = 51; $out = "+",$_,"+",$cities[$city]; $city++; print CITIES $out; } close CITIES; # print the html code for ($i; $i<5; $i++){ print "<img src='image_dir/$selected[$i].jpg' border=0>"; }
No hidden field is involved, which, of course, would have compromised any kind of security. The script that is called to check the password will read it from the $tmp file, erase it, and erase/create all the image files based on the file ($cities) that contains the new correspondences.

I don't think there is a way that a bot or even a mischievous individual could bypass this password check without hacking into the system first.

PS: Of course, the code that changes the correspondences is only included here for reference purposes. It should be included in the second perl script that checks the password as $cities should change together with the image files.


In reply to Re^7: Stop Form Hurling by emav
in thread Stop Form Hurling by awohld

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.