#!/usr/bin/perl #$mail_prog = '/usr/sbin/sendmail' ; &GetFormInput; $pn = $field{'pn'}; $pn=uc($pn); #$pn="SW690"; use Mysql; $DBHOST = "AEGS2.db.4473351.hostedresource.com"; $DBNAME = "AEGS2"; $DBUSER = "AEGS2"; $DBPASS = "Cbears55"; $DB = Mysql->connect($DBHOST, $DBNAME, $DBUSER, $DBPASS); $DB->selectdb($DBNAME, $DB); $execute = $DB->query("Select COUNT(text) from tips"); $numt = $execute->fetchrow(); while ($y < 10) { $id=int(rand($numt)+1); $execute = $DB->query("SELECT text FROM tips where id=$id"); $v = $execute->fetchrow(); if (length($v) > 10) { $text=$v; $y=10;} $y++; } $prodfile="../data/aegsprods.txt"; $datafile="../data/earthupl.txt"; #$prodfile="x:/http/alternativeenergygeneralstore/data/aegsprods.txt"; #$datafile="x:/http/alternativeenergygeneralstore/data/earthupl.txt"; open (FILE,"$prodfile"); @prod=; close(FILE); $prsz=@prod; open (FILE,"$datafile"); @inv=; close (FILE); $invsz=@inv; $ti[1]=""; $ti[2]=""; $ti[3]=""; $ti[4]=""; $tx[1]="Household products for daily use that will help save energy. There are literally dozens of ways you can help save energy and reduce carbon emissions in your everyday life. Fluorescent bulbs, LED lights, solar powered gadgets, and rechargeable batteries are just a few."; $tx[2]="There are now hundreds of styles of fluorescent and LED bulbs available for everyday use, and we've selected some of the best. Any of these bulbs will pay for themselves in electric and bulb cost in 1-3 years, and you're helping reduce the demand for fossil fuel power and CO2 emissions while you're at it."; $tx[3]="The ultimate solution to the energy and CO2 crisis will come from the power of the human mind. These kits will inspire you to understand how alternative energy works, and lead you in the direction of finding solutions."; $tx[4]="For those ready to take the next step and begin building their own alternative energy solutions, we offer an array of the components you will need to make that happen."; &header; if (length($pn) < 4 || length($pn) > 8) { goto ERR;} for ($k=0;$k<$invsz;$k++) { @p = split (/\|/, $inv[$k]); if ($p[1] > 0 && $inv[$k]=~/^$pn/) { $k=$invsz+2; for ($j=0;$j<$prsz;$j++) { if ($prod[$j]=~/^$pn/) { @d = split (/\|/, $prod[$j]); if ($d[5] eq "HH") { $ty=1;} elsif ($d[5] eq "LB") { $ty=2;} elsif ($d[5] eq "KT") { $ty=3;} elsif ($d[5] eq "IC") { $ty=4;} print "
$ti[$ty]

\n"; print "

\n"; print "$tx[$ty]

\n"; &prtitem;} } } } if ($k < $invsz+2) { goto ERR;} &footer; goto DONE; ERR:; print "

We're sorry, but that part is not currently in stock. Please see our complete line of in-stock products at

The Alternative Energy General Store

"; &footer; #print "Location: http://www.alternativeenergygeneralstore.com\nURI: http://www.alternativeenergygeneralstore.com\n\n"; DONE:; sub prtitem { @pdesc = split (/\|/, $prod[$j]); chomp($pdesc[10]); $pdesc[2] =~s/\"//g; $pdesc[1] =~s/\"//g; $pic=lc($pdesc[0]).".jpg"; print ""; print "
\n"; print "
Click here to see all our
alternative energy products!

 

\n"; print "

"; print "$pdesc[1]
\n"; print "Item no: $pdesc[0]
\n"; print "$pdesc[2]
\n"; print ""; print "In stock for immediate shipment.
\n"; print "Suggested retail pr: \$$pdesc[4]
\n"; $prout=sprintf("\$%.2f",$pdesc[3]); print "Our Price: $prout

"; print "$pdesc[11]"; print "

\n"; print ""; if ($dx[2] ne $hdg) { $hdg=$dx[2]; print "Back to the top

\n"; print "

\n"; print "
$ti[$hdg]

\n"; print "$tx[$hdg]\n";} } sub header { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "Alternative Energy General Store\n"; print "\n"; print "

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

Alternative Energy General Store

\n"; print "
Green Tip #$id
\n"; print "
$text
\n"; print "
\n"; print "
\n"; @d = split (/\|/, $inv[0]); $hdg=substr($d[2],0,1); print "
$ti[$hdg]

\n"; print "
\n"; print "$tx[$hdg]
\n"; } sub footer{ print "
\n"; } sub GetFormInput { (*fval) = @_ if @_ ; local ($buf); if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN,$buf,$ENV{'CONTENT_LENGTH'}); } else { $buf=$ENV{'QUERY_STRING'}; } if ($buf eq "") { return 0 ; } else { @fval=split(/&/,$buf); foreach $i (0 .. $#fval){ ($name,$val)=split (/=/,$fval[$i],2); $val=~tr/+/ /; $val=~ s/%(..)/pack("c",hex($1))/ge; $name=~tr/+/ /; $name=~ s/%(..)/pack("c",hex($1))/ge; if (!defined($field{$name})) { $field{$name}=$val; } else { $field{$name} .= ",$val"; #if you want multi-selects to goto into an array change to: #$field{$name} .= "\0$val"; } } } return 1; }