#!/usr/bin/perl MAIN: { $server = $ENV{'SERVER_NAME'}; $query = $ENV{'QUERY_STRING'}; $query0 = $query; $query0 =~ s/\&price\_range\=.*//g; $domain = $server; if ( $domain =~ m/sex\-superstore/i ) { $domain = '.sex-superstore.com' } else { $domain = '' } print &PrintHeader; #affiliate flag if ( !( $server =~ m/pexxx/i ) and !( $server =~ m/privateentertainment/i ) and !( $server =~ m/myadultwarehouse/i ) ) { $aff_flag = 1; } if ( $server =~ /shop\.sex\-superstore\.com/i or $server =~ /store\.sex\-superstore\.com/i or $server =~ /store\.dev\.sex\-superstore\.com/i or $server =~ /shop\.dev\.sex\-superstore\.com/i ) { $aff_super = 1; } $status = 'date'; #initial categories @asso00 = ( 'hotdeal', 'anal', 'gaggift', 'battery', 'bondage', 'book', 'cockring', 'condom', 'dildo', 'egg', 'enhancer', 'extension', 'couples', 'games', 'grooming', 'headcleaner', 'herbals', 'jewelry', 'lingerie', 'doll', 'lube', 'massage', 'vagina', 'pump', 'strap-on', 'vibrator' ); #init-name association @asso0 = ( 'all', 'New Releases', 'hotdeal', 'Hot Deals!', 'anal', 'Anal Toys', 'gaggift', 'Bachelorette', 'battery', 'Batteries', 'bondage', 'Bondage', 'book', 'Books', 'cockring', 'Cockrings', 'condom', 'Condoms', 'dildo', 'Dildos/Dongs', 'egg', 'Eggs/Bullets', 'enhancer', 'Enhancers', 'extension', 'Extensions', 'couples', 'For Couples', 'games', 'Games', 'grooming', 'Grooming', 'headcleaner', 'Head Cleaner', 'herbals', 'Herbals', 'jewelry', 'Jewelry', 'lingerie', 'Lingerie', 'doll', 'Love Dolls', 'lube', 'Lubricants', 'massage', 'Massage', 'vagina', 'Masturbators', 'pump', 'Penis Pumps', 'strap-on', 'Strap-Ons', 'vibrator', 'Vibrators' ); %asso0 = @asso0; use CGI; $foo = new CGI; #DATE local ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); $year = 1900 + $year; local (@month) = ( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ); local ($mo) = $month[$mon]; &ReadParse; ( $ecode, $text, $type, $criteria, $last_list, $first_list, $fam, $hotdeal, $discount, $bestseller, $init, $dozen_list, $letter, $search, $init1, $affiliate, $battery, $price_range ) = ( $in{'ecode'}, $in{'text'}, $in{'type'}, $in{'criteria'}, $in{'last_list'}, $in{'first_list'}, $in{'fam'}, $in{'hotdeal'}, $in{'discount'}, $in{'bestseller'}, $in{'init'}, $in{'dozen_list'}, $in{'letter'}, $in{'search'}, $in{'init1'}, $in{'af'}, $in{'battery'}, $in{'price_range'} ); if (length($ecode) > 10) { die('Invalid Parameter'); } if ( $text eq 'hotdeal' or $init eq 'hotdeal' ) { $hotdeal = 'Yes' } if ( $criteria eq 'voldiscount' or $init eq 'voldiscount' ) { $discount = 'Yes'; $init = 'voldiscount'; } if ( $criteria eq 'init' ) { $init = $text } if ( !$init and !$criteria ) { $init = 'all' } &get_cookie; $stock = $cookie{'stock'}; $stock = substr( $stock, 0, 1 ); if ( !$stock or ( $stock ne 'N' and $stock ne 'T' and $stock ne 'A' and $stock ne 'P' and $stock ne 'O' and $stock ne 'F' and $stock ne 'D' ) ) { $stock = 'N'; } if ( $stock ne 'N' ) { $inv_mod = " and inventory.available='$stock'"; } else { $inv_mod = " and (inventory.available='T' or inventory.available='P')"; } $res_field = 'results'; if ( $stock eq 'T' ) { $sel_T = 'selected'; $res_field = 'res_T' } if ( $stock eq 'A' ) { $sel_A = 'selected'; $inv_mod = ''; $res_field = 'res_A'; } if ( $stock eq 'P' ) { $sel_P = 'selected'; $res_field = 'res_P' } if ( $stock eq 'O' ) { $sel_O = 'selected'; $res_field = 'res_O' } if ( $stock eq 'F' ) { $sel_F = 'selected'; $res_field = 'res_F'; } if ( $stock eq 'D' ) { $sel_D = 'selected'; $res_field = 'res_D'; } if ( !( $affiliate =~ /^\d/ ) ) { $affiliate = $cookie{'affiliate'}; } $affiliate =~ s/\D.*//s; if ( !( $affiliate =~ /^\d/ ) ) { $affiliate = 0 } if ( !$dozen ) { $dozen = 1 } if ( !$dozen_list ) { $dozen_list = 1 } $dozen0 = $dozen - 1; $dozen1 = $dozen + 1; $dozen_list0 = $dozen_list - 1; $dozen_list1 = $dozen_list + 1; $first_list0 = $first_list; $last_list0 = $last_list; if ( !$init1 and ( $discount eq 'Yes' ) ) { $init1 = 'all' } $type = 'toys'; $type3 = $type; $back = $type . 'back'; $text3 = $foo->escape($text); if ($price_range) { $price_app = "&price_range=$price_range" } require("../inc/dbc.dat"); #product DB retrieve $table = 'date_' . $type; $table1 = 'aph_' . $type; if ($battery) { ( $bt_qty, $battery ) = split / /, $battery; $ecode = &getBatt($battery); } $sql1 = $dbh->prepare( " SELECT REPLACE(product_name,CHAR(34),'"') as product_name,saleprice,price,manufacturer,pimage,voldiscount,synopsis,available,bigkey,initial,family1,family2,batt,options,options_set,item_set,inventory.opt_set,sku FROM $table,inventory WHERE $table.item='$ecode' and inventory.item='$ecode' " ); $sql1->execute; ( $name, $saleprice, $price, $manufacturer, $image, $onsale, $synopsis, $available, $key, $init0, $family1, $family2, $batter, $option, $opt_set, $ecode_set, $opt_set1, $sku ) = $sql1->fetchrow_array; $sql1->finish; #get rating $sqlR = $dbh->prepare( " SELECT reviews,rating_ave FROM rating WHERE item='$ecode' LIMIT 1 " ); $sqlR->execute; ( $reviews, $rating_ave ) = $sqlR->fetchrow_array; $sqlR->finish; $init = $init0; $rating1 = sprintf "%.0f", $rating_ave; $ecode_set =~ s/ //; ###CATEGORY & family SELECT if ( $criteria eq 'init' ) { $init = $text } $text_type = $type; open( FILEHANDLE, "< store.txt" ) or print 'Cannot open file'; while () { chop $_; $code .= $_ } close(FILEHANDLE); eval($code); %assa3 = @asso3; %assa1 = @asso1; %assa0 = @asso0; $fam_number = ( $#asso1 + 1 ) / 2; $initial = $assa0{$init}; if ( !$text ) { $text = $initial } $family = $assa1{$fam}; if ( $criteria eq 'init' ) { $text1 = " > $assa3{$text}"; } if ($fam) { $fam1 = " > $family"; } if ($init1) { $fam1 = " > $asso0{$init1}"; } if ($init1) { $fam1 = " > $asso0{$init1}"; } #show stream $text1 = " > $text"; if ( $hotdeal eq 'Yes' ) { $text1 = " > Hot Deals!"; $addition = '&hotdeal=Yes'; } if ( $discount eq 'Yes' ) { $text1 = " > Volume Discounts"; $addition = '&discount=Yes'; } if ( $bestseller eq 'Yes' ) { $text1 = " > Bestsellers"; $addition = '&bestseller=Yes'; $pth = 'pimage'; } $type1 = "Sex Toys"; if ( $available eq 'T' ) { $available1 = '1 to 2 business days'; $available2 = 'IN STOCK'; } if ( $available eq 'F' ) { $available1 = '10 to 15 business days'; $available2 = 'SPECIAL ORDER'; } if ( $available eq 'P' ) { $available1 = 'upon release'; $available2 = 'PRE-ORDER'; } if ( $available eq 'O' ) { $available1 = '10 to 15 business days'; $available2 = 'ON ORDER'; } if ( $available eq 'D' ) { $available1 = 'not available'; $available2 = 'NOT AVAILABLE'; } $onsale1 = $onsale; $sale = ''; if ( $onsale eq 'T' ) { $onsale1 = 1; $sale = 'Volume Discounts'; } if ( $onsale eq 'C' ) { $sale = 'Volume Discounts'; } if ( $onsale eq 'F' ) { $onsale1 = 0; } #alphabetic list if ( $init ne 'all' ) { $where_list = "WHERE initial='$init'"; } else { $where_list = "WHERE (bigkey>=0)"; } if ( $criteria eq 'title' ) { $crt = 'product_name' } if ( $criteria eq 'manufacturer' ) { $crt = 'manufacturer' } if ( $criteria eq 'star' ) { $crt = 'stars' } if ( $criteria eq 'ecode' ) { $crt = 'inventory.item' } if ( $criteria eq 'init' ) { $crt = 'initial' } if ( $criteria eq 'sku' ) { $crt = 'sku' } if ( $text ne 'all' ) { $textE = "%" . $text . "%"; } else { $textE = "%" . "%"; } $textE = $dbh->quote($textE); if ( $criteria or $init1 ) { $where_list = "WHERE $crt LIKE $textE"; if ($init1) { $where_list = $where_list . " and initial='$init1'"; } } if ($fam) { $where_list = $where_list . " and (family1='$fam' or family2='$fam')"; } if ( $hotdeal eq 'Yes' ) { $where = "WHERE hotdeals='T'"; $where_list = "WHERE hotdeals='T'"; if ($fam) { $where_list = $where_list . " and (initial='$fam' or family1='$fam' or family2='$fam')"; } } $where_list0 = $where_list; if ($last_list) { $where_list = $where_list . " and bigkey>'$last_list'" } if ($first_list) { $where_list = $where_list . " and bigkey<'$first_list'"; $order_list = 'DESC'; } if ($letter) { $where_list = $where_list . " and product_name LIKE '$letter%'"; $where_list0 = $where_list0 . " and product_name LIKE '$letter%'"; } #price range/match if ($price_range) { #field for price if ( ( $aff_flag and !( $server =~ m/shop/ ) ) or ( $server =~ m/myadultwarehouse/ ) ) { $price_field = 'price'; } else { $price_field = 'saleprice' } if ( $price_range !~ /\-/ ) { #exact match $price_match = $price_range; if ( $price_match =~ /^\d+$/ or $price_match =~ /^\d+\.\d+$/ ) { $price_mod = "$price_field=$price_match"; $price2 = "\$$price_match"; } } else { #range ( $price_min, $price_max ) = split /-/, $price_range; if ( $price_min =~ /^\d+$/ or $price_min =~ /^\d+\.\d+$/ ) { $price_mod_min = "$price_field>$price_min"; } if ( $price_max =~ /^\d+$/ or $price_max =~ /^\d+\.\d+$/ ) { $price_mod_max = "$price_field<$price_max"; } if ( $price_mod_min and $price_mod_max ) { $price_mod = "$price_mod_min and $price_mod_max"; $price2 = "\$$price_min - \$$price_max"; } elsif ($price_mod_min) { $price_mod = $price_mod_min; $price2 = "more than \$$price_min"; } elsif ($price_mod_max) { $price_mod = $price_mod_max; $price2 = "less than \$$price_max"; } } } if ($price_mod) { if ($where_list) { $where_list = "$where_list and $price_mod"; } else { $where_list = "WHERE $price_mod"; } } $sql2 = $dbh->prepare( " SELECT $table1.item,$table1.product_name,$table1.bigkey FROM $table1,inventory $where_list and $table1.item=inventory.item $inv_mod ORDER by bigkey $order_list LIMIT 50 " ); $sql2->execute; $j = 0; while ( @record1 = $sql2->fetchrow_array ) { ( $list_ecode[$j], $list[$j], $bigkey_list[$j] ) = @record1; $j++; } $sql2->finish; #number of search results if ( $letter or ( $criteria and ( $criteria ne 'init' ) ) ) { $phrase = $dbh->quote($text); $sql0 = $dbh->prepare( " SELECT $res_field,inits FROM search WHERE phrase=$phrase and type='$type' and criteria='$criteria' and site='SuperStore' LIMIT 1 " ); $sql0->execute; ( $jj, $inits ) = $sql0->fetchrow_array; $sql0->finish; @inits = split /,/, $inits; foreach $init_dd (@inits) { $init_present{$init_dd} = 'Yes' } } if ($first_list) { @list_ecode = reverse @list_ecode; @list = reverse @list; @bigkey_list = reverse @bigkey_list; } $first_list = $bigkey_list[0]; $last_list = $bigkey_list[ $j - 1 ]; $l0 = $#list; #FILTER FOR NAMES IN LIST $l = $#list + 1; local ($lil) = 0; local ($il) = 0; while ( $lil + $il <= 100 && $il <= $l - 1 ) { local ($lilo) = 0; local ($prev) = 0; for ( $i = 0 ; $i <= ( length( $list[$il] ) - 1 ) ; $i++ ) { if ( ( substr( $list[$il], $i, 1 ) eq ' ' ) && ( ( $i - $prev ) > 25 ) && substr( $list[$il], $i + 1, 1 ) ) { $prev = $i + $prev; $lilo++; substr( $list[$il], $i, 1 ) = '*'; } } $lil = $lil + $lilo; while ( $list[$il] =~ m/\*/ ) { $list[$il] =~ s/\*/<\/a>
   /; } $il++; } for ( $i = $0 ; $i < $il ; $i++ ) { $list[ $i + $il ] = $list[ $i + $l ] } $lold = $l; $l = $il; $list_key = $list[ 2 * $l - 1 ]; $escape_batter = $foo->escape($batter); $new_option = ucfirst $option; $item_batt = $ecode; if ( $batter eq 'Included' ) { $battery = qq(Included); } if ( $batter eq 'None' ) { $battery = qq(none); } if ( $batter ne 'None' and $batter ne 'Included' ) { ( $bt_qty1, $battery1 ) = split / /, $batter; if ( &getBatt($battery1) ) { $battery = qq($batter   Batteries); } else { $battery = qq($batter  Batteries); } } $stk3[0] = $available; $sorry = "Sorry, this product is NOT AVAILABLE. Please try other products."; if ( $option ne 'none' ) { $sorry = "Sorry, this option is NOT AVAILABLE. Please try other options."; $opt_set =~ tr/\'/\`/; @stk3 = split /,/, $opt_set1; @opt_set0 = split /,/, $opt_set; @ecode_set0 = split( /,/, $ecode_set ); if ( $stk3[0] ne 'T' ) { $stk3_0 = $stk3[0]; $opt_set0_0 = $opt_set0[0]; $ecode_set0_0 = $ecode_set0[0]; COMMENTS: for ( $opt_i = 1 ; $opt_i <= $#stk3 ; $opt_i++ ) { if ( $stk3[$opt_i] eq 'T' ) { $stk3[0] = $stk3[$opt_i]; $stk3[$opt_i] = $stk3_0; $opt_set0[0] = $opt_set0[$opt_i]; $opt_set0[$opt_i] = $opt_set0_0; $ecode_set0[0] = $ecode_set0[$opt_i]; $ecode_set0[$opt_i] = $ecode_set0_0; last COMMENTS; } } } $available2 = ""; $available1 = ""; $ecode_set0[0] =~ s/ //g; } if ( $option eq 'color' ) { $imgg = $ecode_set0[0] . '.gif'; $gamma_array = qq($opt_set0[0] ); for ( $i = 1 ; $i <= $#ecode_set0 ; $i++ ) { while ( $ecode_set0[$i] =~ / / ) { $ecode_set0[$i] =~ s/ //; } $imgg = $ecode_set0[$i] . '.gif'; $gamma_array = $gamma_array . qq($opt_set0[$i] ); } } if ( $option eq 'flavor' or $option eq 'fragrance' or $option eq 'style' or $option eq 'size' or $option eq 'aroma' ) { $fragrance_array = qq(