#!/usr/bin/perl
#
# wanted-is-SCRIPT
#
# (c) 2002-2008 CREEQ <creeq@web.de>
#

use strict;
use vars qw/$form %form @form $a $b @did $count @pre @last @names @month $name $wantdir $link $index $begin/;

@did = ("DISTRIBUTE CHILD PORNOGRAPHY", "MURDER", "KIDNAPPING", "ASSAULTING FEDERAL AGENTS", "BANK ROBBERY", "UNLAWFUL FLIGHT TO AVOID PROSECUTION", "CONSPIRACY TO IMPORT COCAINE AND MARIJUANA", "MURDER OF U.S. NATIONALS OUTSIDE THE UNITED STATES", "ATTACK ON A FEDERAL FACILITY RESULTING IN DEATH", "AGGRAVATED SEXUAL ABUSE WITH CHILDREN", "DRUG CONSPIRACY", "NARCOTICS DISTRIBUTION", "MONEY LAUNDERING", "ESCAPE");
@pre = ("Horst", "Klaus", "Werner", "Herbert", "Manfred", "Fred", "Fritz", "Usama", "Detlef", "Dieter", "Peer", "Eberhardt", "Fridolin", "Günther", "Klaus-Dieter", "Karl-Heinz", "Heinz-Steffen", "Markus-Maria", "Klaus-Gustav", "Peter", "Norbert");
@last = ("Müller", "Bin Laden", "Schmidt", "Nüscher", "Brown", "Abdullah", "Mugniyah", "Msalam", "Tse-tung");
@month = ("January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

$wantdir = '/usr/lib/cgi-bin/wanted';

@form = split("&", $ENV{QUERY_STRING});
foreach $form (@form) {
  ($a,$b) = split("=", $form);
  $form{$a} = $b;
}

@names = split('\+', $form{is});
for ($a=0;$a<=$#names;$a++) { $names[$a] = $names[$a]; }
$count = 0;
foreach $name (@names) {
  for ($a = 0; $a <= length($name); $a++) { $count += ord(substr($name, $a, 1)); }
}

$link = `cat "$wantdir/$form{is}"`;
if (!$link) {
  $index = `wget -q -O - www.uglypeople.com`;

  $begin = index($index, 'Add this picture to your Myspace profile');
  $link = substr($index, index($index, "img src=", $begin)+8, index($index, " border=", $begin)-index($index, "img src=", $begin)-9);

  system("echo '$link' > $wantdir/$form{is}");

}

print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>FBI Crime Alert -";
foreach (@names) { print (" " . $_); }
print "</TITLE>\n";
print "</HEAD>\n";
print "<BODY BGCOLOR=\"#ffffff\" LINK=\"#ff0000\" VLINK=\"#666666\">\n";
print "<TABLE WIDTH=\"590\" BORDER=\"0\" CELLSPACING=\"2\" CELLPADDING=\"0\">\n";
print "<TR>\n";
print "<TD>\n";
print "<P><CENTER><FONT SIZE=\"+1\"><IMG SRC=\"/pix/wanted.gif\" ALIGN=\"BOTTOM\" BORDER=\"0\" ALT=\"Wanted By The FBI\"></FONT></CENTER></P>\n";
print "<P><CENTER><B><FONT SIZE=\"+1\">" . $did[$count %($#did+1)] . "</FONT></B></CENTER></TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD HEIGHT=\"60\">\n";
print "<P><CENTER><B><FONT COLOR=\"#ff0000\" SIZE=\"+3\">";
foreach (@names) { print (" " . $_); }
print "</FONT></B></CENTER></TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD>\n";
print "<P><CENTER><TABLE BORDER=\"0\" CELLSPACING=\"3\" CELLPADDING=\"0\">\n";
print "<TR>\n";
print "<TD VALIGN=\"TOP\">\n";
#print "<IMG SRC=\"$link\" WIDTH=\"150\" HEIGHT=\"200\" ALIGN=\"TOP\" BORDER=\"1\" NATURALSIZEFLAG=\"3\" ALT=\"This is a photograph of";
print "<a href=\"http://www.uglypeople.com\"><IMG SRC=\"$link\" WIDTH=\"150\" HEIGHT=\"200\" ALIGN=\"TOP\" BORDER=\"1\" NATURALSIZEFLAG=\"3\" ALT=\"This is a photograph of";
foreach (@names) { print (" " . $_); }
print "\"></a><br><a href=\"http://www.uglypeople.com\" title=\"Ugly People Pictures\" target=\"_blank\">Ugly People Pictures!</a>\n";
print "</TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD COLSPAN=\"2\" ALIGN=\"CENTER\">\n";
print "<FONT SIZE=\"-1\">Photograph taken in 2002</FONT></TD>\n";
print "</TR>\n";
print "</TABLE></CENTER></P>\n";
print "<P><TABLE WIDTH=\"590\" BORDER=\"0\" CELLSPACING=\"2\" CELLPADDING=\"0\">\n";
print "<TR>\n";
print "<TD VALIGN=\"TOP\" WIDTH=\"65\">\n";
print "<B>Aliases:</B></TD>\n";
print "<TD VALIGN=\"TOP\" WIDTH=\"530\">\n";
if (not defined @names[1]) { print @pre[$count %($#pre+1)] . " " . @names[0]; } else {
  print @pre[$count %($#pre+1)] . " " . @names[$#names] . ", ";
  print @names[0] . " " . @last[$count %($#last+1)];
}
print "</TD>\n";
print "</TR>\n";
print "</TABLE></P>\n";
print "<P><CENTER><B><FONT COLOR=\"#ff0000\" SIZE=\"+1\">DESCRIPTION</FONT></B></CENTER></P>\n";
print "<P><TABLE WIDTH=\"590\" BORDER=\"0\" CELLSPACING=\"2\" CELLPADDING=\"0\" HEIGHT=\"202\">\n";
print "<TR>\n";
print "<TD WIDTH=\"150\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "<B>Date of Birth Used:</B>&nbsp;</TD>\n";
print "<TD WIDTH=\"230\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print @month[$count %12] . " " . $count %30 .", 198" . $count %5 . "</TD>\n";
print "<TD WIDTH=\"90\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "<B>Hair:</B></TD>\n";
print "<TD VALIGN=\"TOP\" WIDTH=\"120\" HEIGHT=\"23\">\n";
print "Blonde</TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD WIDTH=\"150\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "<B>Place of Birth:</B></TD>\n";
print "<TD WIDTH=\"230\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "Unknown</TD>\n";
print "<TD WIDTH=\"90\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "<B>Eyes:</B></TD>\n";
print "<TD VALIGN=\"TOP\" WIDTH=\"120\" HEIGHT=\"23\">\n";
print "Brown</TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD WIDTH=\"150\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "<B>Height:</B></TD>\n";
print "<TD WIDTH=\"230\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "5'5&quot;</TD>\n";
print "<TD WIDTH=\"90\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "<B>Sex:</B></TD>\n";
print "<TD VALIGN=\"TOP\" WIDTH=\"120\" HEIGHT=\"23\">\n";
print "Male</TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD WIDTH=\"150\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "<B>Weight:</B></TD>\n";
print "<TD WIDTH=\"230\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print 120 + ($count %30) . " pounds</TD>\n";
print "<TD WIDTH=\"90\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "<B>Race:</B></TD>\n";
print "<TD VALIGN=\"TOP\" WIDTH=\"120\" HEIGHT=\"23\">\n";
print "White</TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD VALIGN=\"TOP\" WIDTH=\"90\" HEIGHT=\"23\">\n";
print "<B>Occupation:</B></TD>\n";
print "<TD VALIGN=\"TOP\" WIDTH=\"120\" HEIGHT=\"23\">\n";
print "Unknown</TD>\n";
print "<TD WIDTH=\"90\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "<B>Nationality:</B></TD>\n";
print "<TD VALIGN=\"TOP\" WIDTH=\"120\" HEIGHT=\"23\">\n";
print "German</TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD WIDTH=\"150\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "<B>Scars and Marks:</B></TD>\n";
print "<TD COLSPAN=\"3\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "None known</TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD WIDTH=\"150\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "<B>Remarks:</B></TD>\n";
print "<TD COLSPAN=\"3\" VALIGN=\"TOP\" HEIGHT=\"23\">\n";
print "None</TD>\n";
print "</TR>\n";
print "</TABLE></P>\n";
print "<P><CENTER><B><FONT COLOR=\"#ff0000\">SHOULD BE CONSIDERED ARMED AND DANGEROUS</FONT></B></CENTER></P>\n";
print "<P><B>IF YOU HAVE ANY INFORMATION CONCERNING THIS PERSON, PLEASE CONTACT YOUR <A HREF=\"http://www.fbi.gov/contact/fo/fo.htm\">LOCAL FBI OFFICE</A> OR THE NEAREST <A HREF=\"http://www.fbi.gov/contact/legat/legat.htm\">AMERICAN EMBASSY OR CONSULATE</A>.</B></TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD ALIGN=\"RIGHT\">\n";
print "<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">\n";
print "<TR>\n";
print "<TD>\n";
print "<FONT SIZE=\"-1\"><IMG SRC=\"/pix/sig.gif\" ALIGN=\"BOTTOM\" BORDER=\"0\" ALT=\"Louis Freeh\"><BR>\n";
print "DIRECTOR<BR>\n";
print "FEDERAL BUREAU OF INVESTIGATION<BR>\n";
print "UNITED STATES DEPARTMENT OF JUSTICE<BR>\n";
print "WASHINGTON, D.C. 20535<BR>\n";
print "TELEPHONE: (202) 324-3000</FONT>&nbsp;</TD>\n";
print "</TR>\n";
print "</TABLE></TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD>\n";
print "<P><CENTER><FONT SIZE=\"-1\"><HR></FONT></CENTER></P>\n";
print "<P><CENTER>[ <A HREF=\"http://www.fbi.gov/mostwant/fugitive/fo/cgwanted.htm\">Chicago Field Office</A> ] [ <A HREF=\"http://www.fbi.gov/mostwant/alert/alert.htm\">Crime Alerts</A> ] [ <A HREF=\"http://www.fbi.gov/homepage.htm\">FBI Home Page</A> ] [ <A HREF=\"http://www.fbi.gov/contact/fo/fo.htm\">FBI Field Offices</A> ]</CENTER></TD>\n";
print "</TR>\n";
print "</TABLE>\n";   

print "</BODY>\n";
print "</HTML>\n";

sub error {
  print $_[0] . "\n";
  print "</BODY>\n";
  print "</HTML>\n";
  exit;
}
