#!/usr/bin/perl require 'session.cgi'; my %form = map { $_ => join "\0",$cgi->param($_) } $cgi->param(); $form{'start'} = $form{'start'} || 0; if($form{'books'}){ $sth = &GetBooks; &ShowShort($sth); } elsif($form{'promo'}){ ($sth,$rows) = &GetPromos; &ShowShort2($sth,$rows); } else{ } $dbh->disconnect; ## ---------- sub routines -------------- sub GetPromos{ my($id) = shift; my($statement, $sth, $rv,$total_rows); my $site = "us"; $statement = "SELECT product_piece.id,product_piece.name,product_piece.thumb,our_$site AS our,retail_$site AS retail,sale_$site AS sale,available.name AS available FROM product_piece,product_set,man_link,piece_link,available,piece_prices WHERE product_piece.available='4' AND product_piece.available=available.id AND product_piece.id=piece_prices.pieceid AND product_piece.id=piece_link.pieceid AND piece_link.siteid='1' AND product_piece.setid=product_set.id AND product_set.manid=man_link.manid AND man_link.siteid='1' ORDER BY name"; $sth = $dbh->prepare($statement) || die "Can't prepare $statement: $dbh->errstr\n"; $rv = $sth->execute || die "Can't execute the query: $sth->errstr\n"; $total_rows = $sth->rows; $statement = "SELECT product_piece.id,product_piece.name,product_piece.thumb,our_$site AS our,retail_$site AS retail,sale_$site AS sale,available.name AS available FROM product_piece,product_set,man_link,piece_link,available,piece_prices WHERE product_piece.available='4' AND product_piece.available=available.id AND product_piece.id=piece_prices.pieceid AND product_piece.id=piece_link.pieceid AND piece_link.siteid='1' AND product_piece.setid=product_set.id AND product_set.manid=man_link.manid AND man_link.siteid='1' ORDER BY name LIMIT $form{'start'},10"; $sth = $dbh->prepare($statement) || die "Can't prepare $statement: $dbh->errstr\n"; $rv = $sth->execute || die "Can't execute the query: $sth->errstr\n"; return ($sth,$total_rows); } # ----------------------------- sub GetBrandSetNames{ my $id = shift; my($statement, $sth, $rv); $statement = "SELECT top_manufacture.name,product_set.setname FROM top_manufacture,product_set,dept_relations,dept_link,product_piece WHERE product_piece.id='$id' AND product_piece.setID=product_set.id AND product_set.id=dept_relations.setid AND dept_relations.deptid=dept_link.deptid AND dept_link.top_manid=top_manufacture.id"; $sth = $dbh->prepare($statement) || die "Can't prepare statement: $!\n"; $rv = $sth->execute || die "Can't execute statement: $!\n"; @names = $sth->fetchrow_array; return @names; } # ----------------------------- sub GetBooks{ my($statement,$sth,$rv); $statement = "SELECT * FROM books ORDER BY title"; $sth = $dbh->prepare($statement) || die "Can't prepare $statement: $dbh->errstr\n"; $rv = $sth->execute || die "Can't execute the query: $sth->errstr\n"; return $sth; } # ----------------------------- sub ShowShort2{ my($sth,$rows) = @_; my($manufacture, $man_name); my($header) = "header.inc"; my($footer) = "footer.inc"; my($count) = 0; my $form_string = "action.cgi?SID=$SID\&promo=1"; $form{'start'} = 0 if($form{'start'}==1); my $next_start = $form{'start'} + 10; my $prev_start = $form{'start'} - 10 || 1; my $start = $form{'start'}+1; $next_start = $rows if($next_start>$rows); &IncludeFile($header,\%form); print "\n"; while($info = $sth->fetchrow_hashref){ ($manname,$setname) = &GetBrandSetNames($info->{'id'}); if(!$count){ print "\n"; print "\n"; print "\n"; } if($count%2==0){ print "\n"; } $count++; } if($count%2){ print "\n"; print "
Luggageworld Promotions
$rows Items
Displayed items $start - $next_start
\ \;
\n"; print "\t\n"; } if($count%2>0){ print "
\n"; print "
\ \;\n"; print "\t\n"; } if($info->{'thumb'}){ print "\t\n"; $info->{'name'} =~ s/(\n+)//g; print "\t\n"; #print "\t\n"; print "\t\n"; print "\t\n"; if($count%2){ print "\n"; print "
{'id'}\">{'thumb'}\" alt=\"$info->{'name'}\" border=\"0\">"; } else{ print "\t
{'id'}\">\"$info-{'name'}\" border=\"0\">"; } print "
Click for Details
$info->{'name'}
$manname
$info->{'name'}
\n"; print "\tRegular Price\: \$$info->{'retail'}
\n" if($info->{'retail'} > 0); if(($info->{'retail'} > $info->{'sale'})&&($info->{'sale'} > 0)){ $display_price = $info->{'sale'}; print "\tPromotional Price\: \$$display_price
\n"; } else{ print "\tOur Price\: \$$info->{'our'}\n"; } print "\t
\n"; print "
\n"; print "\n"; } print "\ \;\n"; print "
"; print "Previous Page\ \;\ \;\ \;" if($prev_start>0); print "Next Page" if($next_start<$rows); print "
\n"; print "\ \;\n"; print "\n"; &IncludeFile($footer); } # ----------------------------- sub ShowShort{ my($sth) = shift; my($header) = "header.inc"; my($footer) = "footer.inc"; my($count) = 0; &IncludeFile($header); print "\n"; print "\n"; print "\n"; while($info = $sth->fetchrow_hashref){ if($count == 2){ print "\n"; $count = 0; } $alt = $info->{'title'}; $alt =~ s/\"//g; print "\n"; print "\n"; print "\n"; $count++; } print "\n" if($count < 2); print "

Luggageworld Affiliate Shopping

\ \;
{'url'}\">{'image'}\" alt=\"$alt\" border=\"0\">\"\"\ \;
$info->{'title'}
\n"; &IncludeFile($footer); }