#!/usr/bin/perl %data_received = &User_Data; &No_SSI(*data_received); $query_string = $data_received{'q'}; if ($query_string eq '') { print "Location: http://www.monstercostumes.co.uk\n\n"; exit; } print "Content-type: text/html\n\n"; $startresults=$data_received{'start'}; $startresults=~s/\D//g; if ($startresults eq '') { $startresults=1; } ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear , $IsDST) = gmtime(time) ; $Year=$Year+1900; $Month=$Month+1; $metadate=sprintf("%02d/%02d/%04d", $Month, $Day, $Year); $CATDROPDOWN="/var/www/monstercostumes/catdropdown"; open CATDROPDOWN or die "can't open $CATDROPDOWN"; @varcatdropdowns=; close CATDROPDOWN; foreach $cd (@varcatdropdowns) { $varcatdropdown="$varcatdropdown\n$cd"; } $EXPORT="/var/www/monstercostumes/db"; open EXPORT or die "Cannot open database."; @products=; close EXPORT; #$query_string = $ENV{'QUERY_STRING'}; $input=$query_string; $input =~ s/&button=Search//g; #$input=substr $input, 2; $input =~ s/<.*?>//gs; $input=~ s///g; $input=~ s/\!//g; $input=reverse $input; chomp $input; $input=reverse $input; chomp $input; $gettable=$input; $gettable=~ s/ /\+/g; if ((substr $input, 0, 2) eq 'a+') { $input=substr $input, 2; } $input =~ s/\+/ /g; $input =~ s/%22//g; $user_input = $input; $input =~ tr/A-Z/a-z/; $input =~ s/unisex//g; $input =~ s/cheap//g; $input =~ s/mummies/mummy/g; $input =~ s/grease costumes/official grease/g; $input =~ s/super french mascot costumes/france mascot/g; $input =~ s/pink lady/pink lad/g; $input =~ s/pink ladies/pink lad/g; $input =~ s/star wars baby/baby bunting/g; $input =~ s/banana man/banana/g; $input =~ s/bananaman/banana/g; $input =~ s/category//g; $input =~ s/products//g; $input =~ s/constume/costume/g; $input =~ s/custume/costume/g; $input =~ s/uniform/costume/g; $input =~ s/kids/child/g; $input =~ s/pink lady costume/pink lady fifties/g; $input =~ s/star wars/episode/g; $input =~ s/obi wan/obi-wan/g; $input =~ s/scooby doo/scooby/g; $input =~ s/scooby do/scooby/g; $input =~ s/hippy/hippie/g; $input =~ s/clwon/clown/g; $input =~ s/inflatible/inflatable/g; $input =~ s/pesant/peasant/g; $input =~ s/peasent/peasant/g; $input =~ s/tits/boobs/g; $input =~ s/titties/boobs/g; $input =~ s/adams/addams/g; $input =~ s/amidala/armidala/g; $input =~ s/jarjar/jar-jar/g; $input =~ s/muscular/muscle chest/g; $input =~ s/maralin/marilyn/g; $input =~ s/chewbaca/chewbacca/g; $input =~ s/charachter/character/g; $input =~ s/berd/beard/g; $input =~ s/unix/wizard beard/g; $input =~ s/hacker/wizard beard/g; $input =~ s/fnacy/fancy/g; $input =~ s/color/colour/g; $input =~ s/sabre/saber/g; $input =~ s/egyptians/egyptian/g; $input =~ s/witches/witch halloween/g; $input =~ s/nuns/clergy nun/g; $input =~ s/ghosts/ghost/g; $input =~ s/vampires/vampire/g; $input =~ s/20s/twenties/g; $input =~ s/30s/thirties/g; $input =~ s/40s/forties/g; $input =~ s/50s/fifties/g; $input =~ s/60s/sixties/g; $input =~ s/70s/seventies/g; $input =~ s/80s/eighties/g; $input =~ s/british//g; $oldinput = $input; $input =~ s/ with//g; $input =~ s/ and//g; $input =~ s/ the//g; $input =~ s/ an / /g; $input =~ s/fancy dress//g; $input =~ s/fancydress //g; $input =~ s/costumes//g; $input =~ s/costume//g; $input =~ s/outfit//g; $input =~ s/gear//g; $input =~ s/ guy//g; if ($input eq '') { $input = $oldinput; } @words=split / /, $input; $simpleword=@words[0]; if ($simpleword eq '') { $simpleword = @words[1]; } print " $user_input
\"Monster
$varcatdropdown
 
"; $prevproductid=0; unless ($input eq '') { print "
Search Results - $user_input

"; print ""; $matches = 0; foreach $product (@products) { chop $product; ($productid, $title, $description, $category, $price, $quantity, $url, $imagelarge, $imagemedium, $imagesmall, $longdescription, $department, $suppliercode) = split "\t", $product; unless ($category eq 'PC_BONUS_CATEGORY' or $category eq 'DISCONTINUED' or $category eq 'Gift Certificates') { # $quantity eq 0) { # or # $prevproductid eq $productid) { $url="http://www.awin1.com/awclick.php?mid=854&id=66611&p=$url"; $dup = 0; if ($prevproductid eq $productid) { $dup =1; } if ($description eq '' or $description eq ' ' or $description eq ' ') { $description="$title"; } $description =~ s/outfit/costume/g; $description =~ s/Headpiece/Head-piece/g; $description =~ s/Super Deluxe/Deluxe/g; $description =~ s/footwear/foot wear/g; $catfile=$category; $catfile=~s/Adult //; $catfile =~ s/™//g; $catfile =~ s/&//g; $catfile =~ s/[^a-zA-Z_0-9 \t\n\r\f]//g; $catfile =~ s/\s+/ /g; $catfile =~ s/\s/_/g; $catfile =~ s/\W//g; $catfile =~ s/_/-/g; # $catfile =~ tr/A-Z/a-z/; $titlefile=$title; $titlefile =~ s/™//g; $titlefile =~ s/&//g; $titlefile =~ s/[^a-zA-Z_0-9 \t\n\r\f]//g; $titlefile =~ s/\s+/ /g; $titlefile =~ s/\s/_/g; $titlefile =~ s/\W//g; $catfile =~ s/_/-/g; # $titlefile =~ tr/A-Z/a-z/; $titlefile = "$titlefile.htm"; $dept=''; $altdept=''; unless ($department eq '') { $dept = substr ($department, 0, 1); if ($dept eq 'W' or $dept eq 'M') { $altdept = "adult"; } elsif ($dept eq 'B' or $dept eq 'G') { $altdept = "child"; } } $searchabledata=" search $productid $title $description $category $department deluxe $altdept"; $searchabledata =~ tr/A-Z/a-z/; $allmatch=1; foreach $word (@words) { if ($simpleword eq 0) { $simpleword=$word; } $foo= index $searchabledata, $word; unless ($allmatch eq 1 and $foo > 0) { $allmatch=0; } } if ($allmatch > 0) { unless ($dup eq 1) { $matches=$matches+1; } $prevproductid=$productid; $image = $imagemedium; unless ($department eq '') { $department = substr ($department, 0, 1); if ($department eq 'W') { $description="Women's outfit: $description"; } elsif ($department eq 'M') { $description="Men's outfit: $description"; } elsif ($department eq 'G' or $department eq 'B') { $description="Kids outfit: $description"; } } unless (($matches < $startresults) or ($matches > $startresults + 19)) { if ($dup eq 0) { print "\n\n"; } } } } } if ($matches eq 0) { print "
\"$title\"

$title

$category.

$description

£ $price

"; print "
No match for "$user_input"!
"; print "





"; } else { if ($startresults+19 > $matches) { $endresults=$matches; } else { $endresults=$startresults+19; } # $index=$startresults-1; # while ($index < $endresults) { # print @outputlines[$index]; # $index = $index + 1; # } } unless ($matches eq 0) { print "
"; print "

Results $startresults - $endresults of $matches"; if ($endresults < $matches) { $nextresults=$startresults+20; print "  Next Results"; } print "

\n
"; print "
"; } } print "
\n"; print "

See also: Cheeky, Jedi Outfit, Shrek Costume, Angel .

"; print "\n\n"; print "\n\n"; sub No_SSI { local (*data) = @_; foreach $key (sort keys(%data)) { $data{$key} =~ s///g; } } sub User_Data { local (%user_data, $user_string, $name_value_pair, @name_value_pairs, $name, $value); if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$user_string,$ENV{'CONTENT_LENGTH'}); } else { $user_string = $ENV{'QUERY_STRING'}; } $user_string =~ s/\+/ /g; @name_value_pairs = split(/&/, $user_string); foreach $name_value_pair (@name_value_pairs) { ($name, $value) = split(/=/, $name_value_pair); $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge; if (defined($user_data{$name})) { $user_data{$name} .= " : " . $value; } else { $user_data{$name} = $value; } } return %user_data; }