#!/usr/local/bin/perl -w # # # # Information Retrieval Final Project # # # Yan Gu # # and # # Zhongtian Yan # # Shopping Bot Implementation # # # # # # # # #use strict; #use Carp; use HTML::LinkExtor; use HTTP::Request; use HTTP::Response; use HTTP::Status; use LWP::RobotUA; use URI::URL; #use CGI::Carp 'fatalsToBrowser'; URI::URL::strict( 1 ); # insure that we only traverse well formed URL's require 'cgi-lib.pl'; require 'cookie.lib'; $| = 1; print "Content-type: text/html\n\n"; my $ROBOT_NAME = 'YanBot/1.0'; my $ROBOT_MAIL = 'yan@cs.jhu.edu'; my $robot = new LWP::RobotUA $ROBOT_NAME, $ROBOT_MAIL; $robot->delay(0); #--------------------------------------------------------------- # # #--------------------------------------------------------------- my $AMAZON ="amazon"; my $BOOKPOOL ="bookpool"; my $BMILLION="booksamillion"; my $ACTION = ""; my $QUERY_BOOK =""; my $METHOD = ""; my $thisBot = "http://www.ugrad.cs.jhu.edu/cgi-bin/cgiwrap/yan/shopbot.pl"; my $query_html = "query.html"; # hash of hash {BOOK NAME}{STORE NAME} # for price, author, link, etc information my %price_hash = (); my %link_hash = (); my %review_hash = (); my %shipping_hash = (); my %ordered_items = (); # hash, key is book name, value is author my %author_hash = (); my %usr_address_id =(); my %usr_staus = (); $usr_status{$AMAZON} = "new"; $usr_status{$BMILLION} = "new"; $usr_status{$BOOKPOOL} = "new"; #$BOOK_ID{$store}{$book} = id my %BOOK_ID = (); # all book ids used in actual stores #$user_log{email}{city} = $city; #$user_log{email}{phone} = $phone; my $ID = ""; my $Total = 0; # ... # my %user_log = (); my $Full_Name = " "; my $Address_1 = " "; my $Address_2 = " "; my $City = " "; my $State = " "; my $Zip =" "; my $Phone = " "; my $Country ="United States"; my $LName = " "; my $FName = " " ; #my %BOOK_ID =(); my %BOOK_CNT = (); my %Cookie_Store = (); # # # # my %store_cgi = ( "http://www.amazon.com", "http://www.amazon.com/exec/obidos/search-handle-form/ref=s_b_rs/102-3244886-3801613", "http://www.booksamillion.com", # "http://www.booksamillion.com/ncom/books", " http://www.booksamillion.com/cat/books?&type=title", "http://www.bookpool.com", "http://www.bookpool.com/.x/t5y8k4kufr/ss/1" # "http://www.amazon.com/exec/obidos/search-handle-form/ref=s_sf_b_as/103-7797859-3411850" ); # for stores that use put my %store_formdata = ("http://www.amazon.com", "ix=books&rank=%2Bsalesrank\&fqp=keywords%01"); # # # # my %book_basket = (); open USER, ">>user.log"; open STDERR, ">>err.log"; &load_user_log(); &ReadParse (*req); my $where= $req{'nextstep'}; if (!defined ($where)) { $where = "newsearch"; } if($where eq "newsearch"){ &generate_search_form(); } elsif($where eq "doSearch"){ &search_book(); } elsif($where eq "fillAddr"){ &get_address(); } elsif($where eq "post_data"){ &post_data(); } elsif($where eq "payment"){ &select_payment(); } elsif($where eq "get_payment"){ &get_payment; } elsif($where eq "confirm"){ &confirm(); } elsif($where eq "buyBooks"){ &buy_books();} elsif($where eq "SearchMore"){ &generate_search_form(); }elsif($where eq "PayNow") { # pay &pay_money(); } elsif($where eq "go_to_order"){ &dummy_request_step1; } exit(0); sub pay_money{ &restore_book_order; # restore %BOOK_ID print "

These are the books in your shopping basket"; my $i = 1; print ""; foreach my $store (keys %BOOK_ID){ while( my($book, $id) = each %{$BOOK_ID{$store}}){ print ""; my $name1 ="book\@info\@bot\@"."$index"; my $name2 = "book\@cnt\@bot\@"."$index"; my $value1 = $store."\@".$book."\@".$id."\@selected"; my $value2 = $BOOK_CNT{$store}{$id}; print ""; $i++; } } print "
$i.$book $value2
" ; # # store book ids # &restore_cookie; print "


"; print "
"; print ""; print ""; print ""; print STDERR ""; my $index = 1; &store_book_order($index); &store_cookie; print ""; print "
" ; print "
"; } sub generate_search_form{ my $index = 0; if(!defined($req{'item-row-sum'})) { $req{'item-row-sum'} = 0; } &restore_book_order; print "

Welcome to Book Shopbot"; print "

"; print ""; print "Book Title:"; print ""; print ""; print ""; print ""; # pass the book id information to next step $index = 1; &store_book_order($index); print "
"; } # search in all book stores sub search_book{ my $index = $req{'index'}; my $keyword = $req{'keywords'}; $keyword =~ s/\+/%2B/g; foreach my $store (keys %store_cgi){ my $base = $store; # print "the base is $base\n"; my $url = $store_cgi{$base}; my $request = new HTTP::Request; if($base eq "http://www.bookpool.com") { &search_bookpool($base, $request, $url, $keyword,$BOOKPOOL); } elsif($base eq "http://www.amazon.com") { &search_amazon($base, $request, $url, $keyword, $AMAZON); } elsif($base eq "http://www.booksamillion.com") { &search_booksamillion($base, $request, $url, $keyword, $BMILLION); } } &print_results; } sub buy_books{ my $num_item = &find_book_id(); # print STDERR $req{'item-row-sum'}, ":", $num_item,"\n"; # my $index = $req{'item-row-sum'} + 1; # $req{'item-row-sum'} += $num_item; &restore_book_order; &restore_cookie; print "

These are the books you just select"; print "

"; my $i = 1; foreach my $bookandstore (keys %req) { if($bookandstore =~ /\@buy$/ && $req{$bookandstore} >0){ my @book = split(/\@/,$bookandstore); my $bs = $bookandstore; $bs =~ s/\@buy//; my $bookindex1 = "$bs\@price"; my $bookindex3 = "$bs\@shipping"; my $bookindex2 = "$bs\@author"; print "

$i. $book[0]
by $req{$bookindex2}
"; print ""; print ""; print ""; print ""; print ""; print "
Price: $req{$bookindex1} Shipping: $req{$bookindex3} Quantity: $req{$bookandstore}
"; # print ""; print ""; } } print ""; print ""; #foreach my $bookandstore (keys %req) { #if($bookandstore =~ /\@basket$/){ # print ""; # } # } # # store book ids # $req{'item-row-sum'} += $num_item; print ""; $index = 1; &store_book_order($index); &store_cookie; print ""; } sub store_cookie{ my $cookie = ""; foreach my $store (keys %Cookie_Store){ $cookie =$cookie.$store."::".$Cookie_Store{$store}."&&"; } $cookie =~ s/&&$//; print ""; } sub store_book_order{ my $index = shift; foreach my $store (keys %BOOK_ID){ while( my($book, $id) = each %{$BOOK_ID{$store}}){ my $name1 ="book\@info\@bot\@"."$index"; my $name2 = "book\@cnt\@bot\@"."$index"; my $value1 = $store."\@".$book."\@".$id."\@selected"; my $value2 = $BOOK_CNT{$store}{$id}; print ""; print ""; # print "---

$index : $store: $book: $value1\n"; print STDERR "$name1*** $name2**$value1**$value2\n"; $index++; } } } sub print_results { my $book = ""; my $i = 0; my $store = ""; &restore_book_order; &restore_cookie; my @all = keys %price_hash; if($#all <0) { print "

Sorry, Search Failed For \"$req{'keywords'}\"


"; $req = (); &generate_search_form; } else { print "

Search Result for \"$req{'keywords'}\"


"; print "
"; foreach $book (keys %price_hash) { $i++; print "

$i.$book
Authors:$author_hash{$book}
"; print ""; foreach $store (keys %{$price_hash{$book}}) { print ""; print ""; print ""; print ""; if($shipping_hash{$book}{$store} ne "out of stock") { print ""; } print "

BookStore:$store

Price: $price_hash{$book}{$store} Shipping: $shipping_hash{$book}{$store}Quantity:"; } print "
"; } print ""; print ""; print ""; print ""; # print ""; foreach $book (keys %price_hash) { foreach $store (keys %{$price_hash{$book}}) { print ""; print ""; print ""; print ""; } } # books already in my basket foreach my $bookandstore (keys %req) { if($bookandstore =~ /\@basket$/){ print ""; } } &store_book_order(1); &store_cookie; print "

"; } } sub search_bookpool { my $base = shift; my $request = shift; my $url = shift; my $keyword = shift; my $store = shift; my $book_name = ""; $keyword =~ s/\s+/\+/g; $request->url($url."?qs=$keyword"); # print "command is $u1\n"; $request->method('GET'); my $response = $robot->request( $request ); if($response->code != RC_OK){ exit(1);} if($response->content !~ /No Books Found<\/i>/) { my $cookie = "NONE"; if(defined($response->header('Set-Cookie'))){ my @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; } $Cookie_Store{$store} = $cookie; # print $response->content; my @items = split(/\"POST\"/i, $response->content); shift @items; #remove text before book items # print "number of items is $#items+1\n"; if($#items==0) { # a single book is returned $response->content =~ /Bookpool:([^<\(]+)\.*<\/TITLE>/; $book_name = $1; $book_name =~ s/^\s+//; $book_name =~ s/\s+$//; # print "bookname is $book_name \n"; $link_hash{$book_name}{$base} = $url."?qs=$keyword"; if($response->content =~ /<b>Our Price:<\/b> <font color=\#990000><b>(\$[\d\.]+)<\/b>/){ $price_hash{$book_name}{$base} = $1; } else { $price_hash{$book_name}{$base} = " not available"; } if($response->content =~ /<a href=\"\/\.x\/\w+\/ss\/L\?qs=([^>]+)>([^<]+)/){ $author_hash{$book_name} = $2; } elsif(! exists $author_hash{$book_name}) { $author_hash{$book_name} = "not available"; } if($response->content =~ /<b>Availability:<\/b> <i>In-Stock<\/i>/) { $shipping_hash{$book_name}{$base} = "in stock"; } elsif($response->content =~ /<b>Availability:<\/b> Out-Of-Stock<br>/){ $shipping_hash{$book_name}{$base}= "out of stock"; } } else { # multiple matches for(my $count=0;$count<=$#items;$count++) { $items[$count] =~ /<dt><a href=\"([^\"]+)\">([^<]+)/; $book_name = $2; $book_name =~ s/^\s+//; $book_name =~ s/\s+$//; $link_hash{$book_name}{$base} = $base.$1; if($items[$count] =~ /<\/a><dd>([^\/]+)\/ <i>/){ $author_hash{$book_name} = $1; } elsif(! exists $author_hash{$book_name}) { $author_hash{$book_name} = "not available"; } if($items[$count] =~ /Our Price <b>(\$[\d\.]+)<\/b>/){ $price_hash{$book_name}{$base} = $1; } else { $price_hash{$book_name}{$base} = " not available"; } if($items[$count] =~ /src=\"\/ins.gif\" alt=\"\[In Stock!\]\">/) { $shipping_hash{$book_name}{$base} = "in stock"; } else { $shipping_hash{$book_name}{$base} = "out of stock"; } } } } } sub search_amazon { my $base = shift; my $request = shift; my $url = shift; my $keyword = shift; my $store = shift; my $FormData = $store_formdata{$base}; $FormData = $FormData.$keyword."\&nsp=fpn%011\&sz=50\&pg=1&fpn=1"; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); $request->content($FormData); my $response = $robot->request( $request ); if($response->code != RC_OK){ exit(1);} if($response->content !~ /Books search: we were unable to find exact matches for your search for/){ my $cookie = ""; my @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $Cookie_Store{$store} = $cookie; my @items = split(/<tr valign=top><td rowspan=2>/, $response->content); shift @items; #remove text before book items for(my $count=0;$count<=$#items;$count++) { $items[$count] =~ /<\s*[aA]([^>]*)>([^<\(]+)[^<]*<\/a><\/b><br>/; my $book_name = $2; $book_name =~ s/^\s+//; $book_name =~ s/\s+$//; $items[$count] =~ /<a href=\"([^\"]+)\"/; $link_hash{$book_name}{$base} = $base.$1; # print STDERR "``````` ($book_name) ($base)\\ ($link_hash{$book_name}{$base})\n"; if($items[$count] =~ /<\/a><\/b><br>\s*by([\w\.\-\,\s]+)/) { $author_hash{$book_name} = $1; } elsif(! exists $author_hash{$book_name}) { $author_hash{$book_name} = "not available"; } if($items[$count] =~ /Our Price:(\$[\d\.]+)<br>/) { $price_hash{$book_name}{$base} = $1; } else { $price_hash{$book_name}{$base} = " not available"; } if($items[$count] =~ /Usually ships in([\s\d\w]+)<BR>/) { $shipping_hash{$book_name}{$base}= $1; } else { $shipping_hash{$book_name}{$base} = "out of stock"; } } } } sub search_booksamillion { # print "begin to search for booksamillion\n"; my $base = shift; my $request = shift; my $url = shift; my $keyword = shift; my $store = shift; my $book_name = ""; $keyword =~ s/\s+/\+/g; my $u1 = $url."&find=$keyword"; $request->url($u1); # print "command is $u1\n"; $request->method('GET'); my $response = $robot->request( $request ); if($response->code != RC_OK){ exit(1);} # print $response->content; my $cookie = "NONE"; if(defined($response->header('Set-Cookie'))){ my @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; } $Cookie_Store{$store} = $cookie; my @items = split(/\d+\.  /, $response->content); shift @items; #remove text before book items # print "number of items is $#items+1\n"; for(my $count=0;$count<=$#items;$count++) { $items[$count] =~ /<A HREF=\"(\/ncom\/books[^\"]+)\"><B>([^<]+)<\/B>/; $book_name = $2; $book_name =~ s/^\s+//; $book_name =~ s/\s+$//; # print "book name is $book_name\n"; $link_hash{$book_name}{$base} = $base.$1; # print "book link is $link_hash{$book_name}{$base}\n"; my @authors = (); if(@authors = ($items[$count] =~ /&author=[^>]+>([^<]+)<\/A>/g)) { $author_hash{$book_name} = join(", ", @authors); }elsif(! exists $author_hash{$book_name}) { $author_hash{$book_name} = "not available"; } # print "authors are $author_hash{$book_name}\n"; if($items[$count] =~ /- Our Price: (\$[\d\.]+) -/) { $price_hash{$book_name}{$base} = $1; } else { $price_hash{$book_name}{$base} = " not available"; } # print "price is $price_hash{$book_name}{$base} \n"; if($items[$count] =~ /not currently available/) { $shipping_hash{$book_name}{$base} = "out of stock"; }elsif($items[$count] =~ /Allow 3-5 weeks for shipping/) { $shipping_hash{$book_name}{$base} = " Allow 3-5 weeks for shipping "; }elsif($items[$count] =~ /ships within /) { $shipping_hash{$book_name}{$base} = "Usually ships within 24 hours."; }elsif($items[$count] =~ /Ships within 2-3 days/i) { $shipping_hash{$book_name}{$base} = "Usually ships within 2-3 days"; } } } sub load_user_log{ while(<USER>){ my ($email, $item, $value) = split(/::/); next if $email eq "DUMMY"; $user_log{$email}{$item}=$value; } close(USER); } sub find_book_id{ my $sum = 0; foreach my $bookandstore (keys %req) { if($bookandstore =~ /\@buy$/ && $req{$bookandstore} >0){ $sum++; my $bs = $bookandstore; $bs =~ s/\@buy$//; my $bookindex1 = $bs."\@link"; my $link = $req{$bookindex1}; my($book, $store) = split(/\@/, $bs); $store =~ /www\.(\w+)\./; $store = $1; if( $store eq $AMAZON ){ if($link =~ /ASIN\/(\w+)\//){ if(!defined($1)){next;} $BOOK_ID{$store}{$book} = $1; print STDERR $1, ":$book:", $req{$bookandstore}, "\n"; $BOOK_CNT{$store}{$1} = $req{$bookandstore}; } } elsif( $store eq $BMILLION){ if($link =~ /id=(\w+)\&(\w+)=(\w+)/){ my $idx = $1."&".$3; $BOOK_ID{$store}{$book} = $idx; $BOOK_CNT{$store}{$idx} = $req{$bookandstore}; $ID = $idx; } } elsif($store eq $BOOKPOOL){ if($link =~ /sm\/(\w+)$/){ $BOOK_ID{$store}{$book} = $1; $BOOK_CNT{$store}{$1} = $req{$bookandstore}; } } } } return $sum; } sub dummy_request_step1{ &restore_cookie; &restore_book_order; foreach my $store (keys %BOOK_ID){ my $cookie = ""; # next if $store ne $AMAZON; if($store eq $AMAZON){ while( my ($book, $id) = each %{ $BOOK_ID{$store} }){ # # STEP 1 my $FormData = &generate_order_form_1($id, $store); my $url = &generate_order_url_1($id, $store); my $cookie = $Cookie_Store{$store}; my $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($cookie)){ $request->header('Cookie'=>$cookie); } $request->content($FormData); print STDERR $store, ":", $request->as_string(); my $response = $robot->request( $request ); if($response->code != RC_OK){ print STDERR $response->code, "\n"; exit(1);} print STDERR $response->as_string(); print STDERR $store, ":", $response->header('Set-Cookie'), "\n"; # # get cookies if($store eq $AMAZON){ my @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $cookie = $cookie.$Cookie_Store{$store}; } } # # STEP 2 # } elsif( $store eq $BMILLION){ while( my ($book, $id) = each %{ $BOOK_ID{$store} }){ my $url = &generate_order_url_1($id, $store); my $cookie = $Cookie_Store{$store}; my $request = new HTTP::Request; $request->url($url); $request->method('GET'); if(defined($cookie)){ $request->header('Cookie'=>$cookie); } print STDERR $store, ":", $request->as_string(); my $response = $robot->request( $request ); if($response->code != RC_OK){ print STDERR $response->code, "\n"; exit(1);} print STDERR $store, ":", $response->header('Set-Cookie'); if(defined($response->header('Set-Cookie'))){ my @cookie_array = split(/=/,$response->header('Set-Cookie')); $cookie = ""; for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $Cookie_Store{$store} = $cookie; } } } else { while( my ($book, $id) = each %{ $BOOK_ID{$store} }){ my $url = &generate_order_url_1($id, $store); my $cookie = $Cookie_Store{$store}; my $request = new HTTP::Request; $request->url($url); $request->method('POST'); if(defined($cookie)){ $request->header('Cookie'=>$cookie); } my $FormData = &generate_order_form_1($id, $store); $request->content($FormData); print STDERR $store, ":", $request->as_string(); my $response = $robot->request( $request ); # print $response->content; if($response->code != RC_OK){ print STDERR $response->code, "\n"; exit(1);} print STDERR $store, ":", $response->header('Set-Cookie'); if(defined($response->header('Set-Cookie'))){ my @cookie_array = split(/=/,$response->header('Set-Cookie')); $cookie = ""; for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $Cookie_Store{$store} = $cookie; } } } $cookie = &dummy_request_step2($store, $cookie); $Cookie_Store{$store} = $cookie; } &get_address; } sub dummy_request_step2{ my $store = shift; my $cookie = shift; my $id = ""; my $response =""; if( ($store eq $AMAZON) || ($store eq $BOOKPOOL)){ my $FormData = &generate_order_form_2($store); my $url = &generate_order_url_2($id, $store); my $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($cookie)){ $request->header('Cookie'=>$cookie); } $request->content($FormData); print STDERR $store, ":", $request->as_string(); $response = $robot->request( $request ); } elsif($store eq $BMILLION){ my $FormData = &generate_order_form_2($store); my $url = &generate_order_url_2($id, $store); my $request = new HTTP::Request; $request->url($url); $request->method('POST'); # $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($cookie)){ $request->header('Cookie'=>$cookie); } $request->content($FormData); print STDERR $store, ":", $request->as_string(); $response = $robot->request( $request ); } if($response->code != RC_OK){ print STDERR $store, ":", $response->code, "\n"; exit(1);} if(defined($response->header('Set-Cookie'))){ my @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; } else{ $cookie = "";} # print $response->content; print STDERR "user:",$response->header('Set-Cookie'); return $cookie; } # # # # # # sub restore_book_order{ my $num_items = $req{'item-row-sum'}; print STDERR "num: $num_items\n"; for my $i (1 .. $num_items){ my $name = "book\@info\@bot\@"; my $cnt = "book\@cnt\@bot\@"; $name = $name."$i"; print STDERR "$name $i", $req{$name}, "\n"; my $this_item = $req{$name}; print STDERR "$this_item\n"; next if $this_item !~ /([^\@]+)\@([^\@]+)\@([^\@]+)\@selected/; my $store = $1; my $book = $2; my $id = $3; $BOOK_ID{$store}{$book} = $id; $cnt = $cnt.$i; $BOOK_CNT{$store}{$id} = $req{$cnt}; } } sub generate_order_url_1{ my $id = shift; my $store = shift; if($store eq $AMAZON){ my $step1 = "http://www.amazon.com/exec/obidos/handle-buy-box="; $Cookie_Store{$store} =~ /session-id=([\w-]+)\;/; $step1 = $step1.$id."/book-glance/". $1; return $step1; } elsif( $store eq $BMILLION){ my($id1, $id2) = split(/\&/, $id); my $url = "http://www.booksamillion.com/ncom/order?"; $url = $url."id=".$id1."&buyit=".$id2; return $url; } else{ my $url = "http://www.bookpool.com/.x/m3qa6dh450/ba/"; $url = $url.$id; return $url; } } sub generate_order_url_2{ my $id = shift; my $store = shift; if($store eq $AMAZON){ my $step2 = "http://www.amazon.com/exec/obidos/shopping-basket/"; $Cookie_Store{$store} =~ /session-id=([\w-]+)\;/; $step2 = $step2.$1; return $step2; } elsif($store eq $BOOKPOOL){ my $url = "http://www.bookpool.com/.x/m3qa6doe71/ac/1"; return $url; } else{ my $url = "http://www.booksamillion.com/ncom/order?id="; my $id = &get_id($store); $url = $url.$id; return $url; } } sub generate_order_form_1{ my $id = shift; my $store = shift; print STDERR "$store----:$id\n"; my $cnt = $BOOK_CNT{$store}{$id}; if($store eq $AMAZON){ my $FormData = "colid=\"\"\&asin=".$id."\&asin\.".$id."=".$cnt; $FormData = $FormData."\&template-name=bookglance\&tag-value=\"\"\&".$id."=".$cnt; $FormData = $FormData."\&submit\.add-to-cart=Add%20to%20Shopping%20Cart"; return $FormData; } if($store eq $BOOKPOOL){ my $FormData = "junk=0&submit=Put in Basket"; return $FormData; } } sub generate_order_form_2{ my $store = shift; if($store eq $AMAZON){ my $FormData ="submit\.order-form-purchase=Proceed to Checkout"; while( my ($book, $id) = each %{ $BOOK_ID{$store} }){ $FormData = $FormData."\&quantity\.".$id."=".$BOOK_CNT{$store}{$id}; } return $FormData; } elsif($store eq $BMILLION){ my $FormData ="checkout=Check Out Now&"; my $id1 = 0; my $id2 = 0; while( my ($book, $id) = each %{ $BOOK_ID{$store} }){ ($id1, $id2) = split(/\&/, $id); $FormData = $FormData.$id2."=".$BOOK_CNT{$store}{$id}."&"; } $FormData = $FormData."id=".$id1; return $FormData; } else{ my $FormData = "submit=I'm Ready to Place My Order!&junk=0"; return $FormData; } } sub generate_order_form_3{ my $store = shift; my $email = $req{'email'}; my $passwd = $req{'passwd'}; if($store eq $AMAZON){ my $FormData = ""; # if($usr_status{$store} ne "new"){ # $FormData = "email=".$email."&password=".$passwd."&user=".$usr_status{$AMAZON}; # } # else { $FormData = "email=yakiiiiii\@yahoo\.com&user=new&passwd=\"\""; #.$usr_status{$store}."&password=".""; # } $FormData = $FormData."&action=Sign in using our Standard server"; return $FormData; } } sub generate_order_url_3{ my $store = shift; if($store eq $AMAZON){ my $url = "http://www.amazon.com/exec/obidos/checkout-sign-in/"; $Cookie_Store{$store} =~ /session-id=([\w-]+)\;/; $url = $url.$1; return $url; } } sub generate_order_form_4{ my $store = shift; if($store eq $AMAZON){ my $FormData = "name=".$req{'name'}."&"; $FormData = $FormData."address-line-1=".$req{'address-line-1'}."&"; $FormData = $FormData."address-line-2=".$req{'address-line-2'}."&"; $FormData = $FormData."city=".$req{'city'}."&"; $FormData = $FormData."state=".$req{'state'}."&"; $FormData = $FormData."zip=".$req{'zip'}."&"; $FormData = $FormData."country=".$req{'country'}."&"; $FormData = $FormData."phone-number=".$req{'phone-number'}."&"; $FormData = $FormData."Continue=submit\.continue&"; $FormData = $FormData."start-with-no-address=true"; return $FormData; } } sub generate_order_url_4{ my $store = shift; if($store eq $AMAZON){ my $url = "http://www.amazon.com/exec/obidos/checkout-shipping-address-done-add/"; $Cookie_Store{$store} =~ /session-id=([\w-]+)\;/; $url = $url.$1; return $url; } } sub generate_order_form_5{ my $store = shift; # my $address_id = "address_id".$store; if($store eq $AMAZON){ my $FormData = "item-row-sum=".$req{'item-row-sum'}."&"; $FormData = $FormData."address-id=".$req{'address_id_amazon'}."&"; $FormData = $FormData."ship-option=".$req{'ship-option'}."&"; $FormData = $FormData."action=Continue"; return $FormData; } } sub generate_order_url_5{ my $store = shift; if($store eq $AMAZON){ my $url = "http://www.amazon.com/exec/obidos/checkout-shipping-select/"; $Cookie_Store{$store} =~ /session-id=([\w-]+)\;/; $url = $url.$1; return $url; } } sub generate_order_form_6{ my $store = shift; my $passwd = $req{'passwd'}; if($store eq $AMAZON){ if($usr_status{$store} eq "new"){ my $FormData = "payment-method=new-card&"; $FormData = $FormData."issuer=".$req{'issuer'}."&"; $FormData = $FormData."password1=".$req{'passwd'}."&"; $FormData = $FormData."password2=".$req{'passwd'}."&"; $FormData = $FormData."card-number=".$req{'card-number'}."&"; $FormData = $FormData."cc-exp-month=".$req{'cc-exp-month'}."&"; $FormData = $FormData."cardholder-name=".$req{'cardholder-name'}."&"; $FormData = $FormData."billing-address-id=".$usr_address_id{$AMAZON}."&"; $FormData = $FormData."submit\.continue=continue"; # $FormData = $FormData."&password1=".$passwd."&password2=".$passwd; return $FormData; } } } sub generate_order_url_6{ my $store =shift; if($store eq $AMAZON){ my $url = "http://www.amazon.com/exec/obidos/checkout-payment-new-card/"; $Cookie_Store{$store} =~ /session-id=([\w-]+)\;/; $url = $url.$1; return $url; } } sub post_data{ &restore_cookie; &restore_book_order(); &restore_address(); $Email = $req{'email'}; $Passwd = $req{'passwd'}; $Total = $req{'item-row-sum'}; foreach my $store (keys %BOOK_ID){ if($store eq $AMAZON){ post_amazon($store); } elsif($store eq $BMILLION){ post_bmillion($store); } else{ post_bookpool($store);} } } sub post_bookpool{ my $store =shift; if($usr_status{$store} eq "new"){ $Country ="United States"; my $url = "http://www.bookpool.com/.x/m3qa6drnv8/du"; ($LName, $FName) = split(/\s+/,$Full_Name); $FormData = "afnam=".$FName."&"; $FormData = $FormData."alnam=".$LName."&"; $FormData = $FormData."aemai=".$Email."&"; $FormData = $FormData."apass=".$Passwd."&"; $FormData = $FormData."apas2=".$Passwd."&"; $FormData = $FormData."anoma=checked&"; $FormData = $FormData."sname=".$Full_Name."&"; $FormData = $FormData."scomp=&"; $FormData = $FormData."sadd1=".$Address_1."&"; $FormData = $FormData."sadd2=".$Address_2."&"; $FormData = $FormData."scity=".$City."&"; $FormData = $FormData."sstat=".$State."&"; $FormData = $FormData."szip=".$Zip."&"; $FormData = $FormData."scoun=".$Country."&"; $FormData = $FormData."fcnum=".$req{'card-number'}."&"; $FormData = $FormData."femon=".$req{'cc-exp-month'}."&"; $FormData = $FormData."feyea=".$req{'cc-exp-year'}."&"; $FormData = $FormData."fpay=CK&bsame=checked&"; $FormData = $FormData."submit=CONTINUE..."; my $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($Cookie_Store{$store})){ $request->header('cookie' => $Cookie_Store{$store}); } $request->content($FormData); print STDERR $store, ":", $request->as_string(); my $response = $robot->request( $request ); my $document = $response->content; $document =~ s/=\"\//=http\:\/\/www\.bookpool\.com\//g; print STDERR $document; print $document; #$response->content; print STDERR $response->header('Set-Cookie'); if($response->content =~ /[TYPE|type]=[hidden|HIDDEN]\s+[name|NAME]=cd\s+[VALUE|value]=([^=><]+)>/){ my $value = $1; $url ="http://www.bookpool.com/.x/".$value."/ca";#m3qa6d6fmm/ca"; my $data = "cd=".$value."&submit=I Verify The Above Information Is Correct"; $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($response->header('Set-Cookie'))){ my $cookie = ""; my @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $request->header('cookie' => $cookie); $request->content($FormData); } print STDERR $store, ":", $request->as_string(); $response = $robot->request( $request ); print $response->content; } } } sub post_amazon{ my $store =shift; my $FormData = &generate_order_form_3($store); my $url = &generate_order_url_3($store); my $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($Cookie_Store{$store})){ $request->header('cookie' => $Cookie_Store{$store}); } $request->content($FormData); print STDERR $store, ":", $request->as_string(); my $response = $robot->request( $request ); if($response->code != RC_OK){ print STDERR $store, ":", $response->code, "\n"; exit(1);} my $cookie = ""; if(defined($response->header('Set-Cookie'))){ my @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $Cookie_Store{$store} = $cookie; } # print $response->content; print STDERR "passwd ",$store, ":", $response->header('Set-Cookie'); # # STEP4 # # $FormData = &generate_order_form_4($store); $url = &generate_order_url_4($store); $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($Cookie_Store{$store})){ $request->header('cookie' => $Cookie_Store{$store}); } $request->content($FormData); print STDERR $store, ":", $request->as_string(); $response = $robot->request( $request ); if($response->code != RC_OK){ print STDERR $store, ":", $response->code, "\n"; exit(1);} $cookie = ""; if(defined($response->header('Set-Cookie'))){ @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $Cookie_Store{$store} = $cookie; } # print $response->content; print STDERR "address ",$store, ":", $response->header('Set-Cookie'); # # get the address id # $response->content =~ /name=address-id\s+value=\"(\w+)\">/; $usr_address_id{$store} = $1; # #step 5 # # $FormData = &generate_order_form_5($store); $url = &generate_order_url_5($store); $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($Cookie_Store{$store})){ $request->header('cookie' => $Cookie_Store{$store}); } $request->content($FormData); print STDERR $store, ":", $request->as_string(); $response = $robot->request( $request ); if($response->code != RC_OK){ print STDERR $store, ":", $response->code, "\n"; exit(1);} $cookie = ""; if(defined($response->header('Set-Cookie'))){ my @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $Cookie_Store{$store} = $cookie; } # print $response->content; print STDERR "passwd ",$store, ":", $response->header('Set-Cookie'); # # STEP 6 # # $FormData = &generate_order_form_6($store); $url = &generate_order_url_6($store); $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($Cookie_Store{$store})){ $request->header('cookie' => $Cookie_Store{$store}); } $request->content($FormData); print STDERR $store, ":", $request->as_string(); $response = $robot->request( $request ); if($response->code != RC_OK){ print STDERR $store, ":", $response->code, "\n"; exit(1);} $cookie = ""; if(defined($response->header('Set-Cookie'))){ @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $Cookie_Store{$store} = $cookie; } # print $response->content; # $FormData = &generate_order_form_6($store); $FormData = $FormData."&password1=".$req{'passwd'}."&password2=".$req{'passwd'}; $url = &generate_order_url_6($store); $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($Cookie_Store{$store})){ $request->header('cookie' => $Cookie_Store{$store}); } $request->content($FormData); $response = $robot->request( $request ); # print $response->content; } sub generate_order_form_32{ my $store = shift; my $email = $req{'email'}; my $passwd = $req{'passwd'}; my $id = &get_id($store); my $FormData = ""; if($usr_status{$store} ne "new"){ $FormData = "email=".$email."&pword1=".$passwd."&pword2=".$passwd; } else { $FormData = "email=".$email."&pword=".$passwd; } $FormData = $FormData."&check2=Go to Step 2"."&id=".$id; return $FormData; } sub generate_order_form_42{ my $data = "nm=".$FullName."&"."zip=".$Zip."&"."cit=".$City."&"."st=".$State."&"; $data = $data."ad1=".$Address_1."&"."ad2=".$Address_2."&"; $data = $data."card_num=".$req{'card-number'}."&"."phone=".$Phone."&"; $data = $data."card_exp_mo=".$req{'cc-exp-month'}."&"."card_exp_yr=".$req{'cc-exp-year'}."&"; $data = $data."card_type=mc&cny=USA&"."usa=y&member=N&shipusa=y&check3=Go To Step&"; return $data; } sub generate_order_form_52{ my $data= "shipnm=".$FullName."&"."shipad1=".$Address_1."&"."shipad2=".$Address_2."&"; $data = $data."shipcit=".$City."&"."shipst=".$State."&"."shipzip=".$Zip."&"."shipcny=USA&"; return $data; } sub generate_order_form_62{ my $data = "email=".$req{'email'}."&"."pword=".$req{'passwd'}."&"; $data =$data."credit_card=1&method=s&finish=Submit This Order"; return $data; } sub get_id{ my $store = shift; while(my ($book, $id) = each %{ $BOOK_ID{$store} }){ my($id1, $id2) = split(/&/, $id); return $id1; } } sub generate_order_url_32{ my $store = shift; my $id = &get_id($store); my $url = "http://www.booksamillion/ncom/order\?id="; $url = $url.$id; return $url; } sub get_hidden{ my $content = shift; $content =~ /[type|TYPE]=[hidden|HIDDEN]\s+[NAME|name]=id\s+[VALUE|value]=(\w+)>$/; my $id = $1; $content =~ /[type|TYPE]=[hidden|HIDDEN]\s+[NAME|name]=k\s+[VALUE|value]=(\w+)>$/; my $k = $1; $content =~ /[type|TYPE]=[hidden|HIDDEN]\s+[NAME|name]=vsn\s+[VALUE|value]=(\w+)>$/; my $vsn = $1; $content =~ /[type|TYPE]=[hidden|HIDDEN]\s+[NAME|name]=gc\s+[VALUE|value]=(\w+)>$/; my $gc = $1; my $data = "id=".$id."&k=".$k."&vsn=".$vsn."&gc=".$gc; return $data; } sub post_bmillion{ my $store =shift; my $FormData = &generate_order_form_32($store); my $url = &generate_order_url_32($store); my $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($Cookie_Store{$store})){ $request->header('cookie' => $Cookie_Store{$store}); } $request->content($FormData); print STDERR $store, ":", $request->as_string(); my $response = $robot->request( $request ); if($response->code != RC_OK){ print STDERR $store, ":", $response->code, "\n"; exit(1);} my $cookie = ""; if(defined($response->header('Set-Cookie'))){ my @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $Cookie_Store{$store} = $cookie; } # print $response->content; print STDERR "passwd ",$store, ":", $response->header('Set-Cookie'); # # STEP4 # # $FormData = &generate_order_form_42($store); $data1 = &get_hidden($response->content); $FormData = $FormData.$data1; $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($Cookie_Store{$store})){ $request->header('cookie' => $Cookie_Store{$store}); } $request->content($FormData); print STDERR $store, ":", $request->as_string(); $response = $robot->request( $request ); if($response->code != RC_OK){ print STDERR $store, ":", $response->code, "\n"; exit(1);} $cookie = ""; if(defined($response->header('Set-Cookie'))){ @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $Cookie_Store{$store} = $cookie; } # print $response->content; print STDERR "address ",$store, ":", $response->header('Set-Cookie'); # #step 5 # # $FormData = &generate_order_form_52($store); $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($Cookie_Store{$store})){ $request->header('cookie' => $Cookie_Store{$store}); } $request->content($FormData); print STDERR $store, ":", $request->as_string(); $response = $robot->request( $request ); if($response->code != RC_OK){ print STDERR $store, ":", $response->code, "\n"; exit(1);} $cookie = ""; if(defined($response->header('Set-Cookie'))){ my @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $Cookie_Store{$store} = $cookie; } # print $response->content; print STDERR "passwd ",$store, ":", $response->header('Set-Cookie'); # # STEP 6 # # $FormData = &generate_order_form_62($store); $request = new HTTP::Request; $request->url($url); $request->method('POST'); $request->header('content-type' => 'application/x-www-form-urlencoded'); if(defined($Cookie_Store{$store})){ $request->header('cookie' => $Cookie_Store{$store}); } $request->content($FormData); print STDERR $store, ":", $request->as_string(); $response = $robot->request( $request ); if($response->code != RC_OK){ print STDERR $store, ":", $response->code, "\n"; exit(1);} $cookie = ""; if(defined($response->header('Set-Cookie'))){ @cookie_array = split(/=/,$response->header('Set-Cookie')); for my $i (0 .. $#cookie_array){ $cookie = $cookie."=".$cookie_array[$i]; } $cookie =~ s/^\s+//; $cookie =~ s/^=//; $Cookie_Store{$store} = $cookie; } # print $response->content; print STDERR "address ",$store, ":", $response->header('Set-Cookie'); # } sub get_payment{ my $num_items = $req{'item-row-sum'}; my $usr_addr_1 = "NONE"; my $usr_addr_2 = "NONE"; my $usr_addr_3 = "NONE"; if(defined($usr_address_id{$AMAZON})){ $usr_addr_1 = $usr_address_id{$AMAZON}; } if(defined($usr_address_id{$BOOKPOOL})){ $usr_addr_2 = $usr_address_id{$BOOKPOOL}; } if(defined($usr_address_id{$BMILLION})){ $usr_addr_3 = $usr_address_id{$BMILLION}; } my $cookie = ""; while( my ($store, $value) = each %Cookie_Store){ $cookie = $cookie.$store."::".$value."&&"; } $cookie =~ s/&&$//; my $passwd = $req{'passwd'}; my $email = $req{'email'}; &restore_cookie; &restore_book_order(); &restore_address; print << "ThisForm"; <form action="$thisBot" method=POST> <strong><font face=verdana,arial,helvetica>Choose shipping options.</font></strong><br> <input type=hidden name="passwd" value=$passwd> <input type=hidden name="email" value=$email> <input type=hidden name ="cookie" value=$cookie> <input type="hidden" name="nextstep" value ="post_data"> <input type="hidden" name=item-row-sum value= $num_items> <input type="hidden" name=address-id-amazon value=$usr_addr_1> <input type="hidden" name=address-id-bookpool value=$usr_addr_2> <input type="hidden" name=address-id-booksmillion value=$usr_addr_3> <table border=0 cellspacing=0 cellpadding=4 width=100%> <tr><td valign=top> <font face=verdana,arial,helvetica size=-1> </font><br> </table> <input type=radio name=ship-option value="first" checked> Standard Shipping(3-7 business days)<br> <input type=radio name=ship-option value="second" > Second Day Air(2 business days)<br> <input type=radio name=ship-option value="next" > Next Day Air(1 business day)<br> <hr> Payment Method:<br> <td><input type=radio value=new-card name=payment-method checked ></td> <td> <select name=issuer> <option value=M>MasterCard <option value=V>Visa <option value=A>American Express <option value=I>Diners Club <option value=D>Discover <option value=J>JCB </select> </td> Credit Card No. <input type=text size=20 name=card-number><br> Expiration Date <select name=cc-exp-month> <option value="01"> 01<option value="02"> 02<option value="03"> 03<option value="04"> 04<option value="05"> 05<option value="06"> 06<option value="07"> 07<option value="08"> 08<option value="09"> 09<option value="10"> 10<option value="11"> 11<option value="12"> 12 </select> <nobr> <select name=cc-exp-year> <option value="2000"> 2000<option value="2001"> 2001<option value="2002"> 2002<option value="2003"> 2003<option value="2004"> 2004<option value="2005"> 2005<option value="2006"> 2006<option value="2007"> 2007<option value="2008"> 2008<option value="2009"> 2009<option value="2010"> 2010<option value="2011"> 2011<option value="2012"> 2012<option value="2013"> 2013<option value="2014"> 2014<option value="2015"> 2015<option value="2016"> 2016<option value="2017"> 2017<option value="2018"> 2018 </select> </nobr> Cardholder's Name <input type=text size=20 value="" name=cardholder-name> <br> <input type=submit name=submit.continue value=continue > ThisForm ; my $index = 1; &store_book_order($index); &store_cookie; &store_address; print "</form>"; } sub restore_cookie{ my $tmp_cookie = $req{'cookie'}; my @store_cookie = split(/&&/, $tmp_cookie); for my $i (0 .. $#store_cookie){ my($store, $cookie) = split(/::/, $store_cookie[$i]); $Cookie_Store{$store} = $cookie; } } sub restore_address{ $Full_Name = $req{'name'}; $Address_1 = $req{'address-line-1'}; $Address_2 = $req{'address-line-2'}; $City = $req{'city'}; $State = $req{'state'}; $Zip = $req{'zip'}; $Phone = $req{'phone-number'}; $Country = $req{'country'}; ($FName, $LName) = split(/\s+/, $Full_Name); } sub store_address{ print "<input type=\"hidden\" name=\"name\" value=$Full_Name>"; print "<input type=\"hidden\" name=\"address-line-1\" value=$Address_1>"; print "<input type=\"hidden\" name=\"address-line-2\" value=$Address_2>"; print "<input type=\"hidden\" name=\"city\" value=$City>"; print "<input type=\"hidden\" name=\"state\" value=$State>"; print "<input type=\"hidden\" name=\"zip\" value=$Zip>"; print "<input type=\"hidden\" name=\"phone-number\" value=$Phone>"; print "<input type=\"hidden\" name=\"country\" value=$Country>"; } sub get_address{ &restore_cookie; &restore_book_order; ################################################################### # # Address filling form HTML stuff # # #################################################################### print << "ThisForm"; <form method=POST action=$thisBot> <!---input type="text" name ="email" value=""> <!----input type=password name=passwd value=""> <input type=hidden name ="nextstep" value="get_payment"> <input type=hidden name="start-with-no-address" value="true"> <table border=0 cellspacing=2 cellpadding=2 width=100%> <tr><td align=right><strong><font face=verdana,arial,helvetica size=-1>Email; </font></strong></td><td width=50%><input type="text" name=email value=" " size=50 maxlength=60></td> </tr> <tr><td align=right><strong><font face=verdana,arial,helvetica size=-1>Password; </font></strong></td><td width=50%><input type=password name=passwd value=" " size=50 maxlength=60></td> </tr> <tr><td align=right><strong><font face=verdana,arial,helvetica size=-1>Full Name: </font></strong></td><td width=50%><input type="text" name=name value= " " size=50 maxlength=60></td> </tr> <tr><td align=right><strong><font face=verdana,arial,helvetica size=-1>Address Line 1 </font></strong><br><font face=verdana,arial,helvetica size=-2>(or company name):</font></td><td><input type="text" name=address-line-1 value=" " size=50 maxlength=60></td> </tr> <tr><td align=right><strong><font face=verdana,arial,helvetica size=-1>Address Line 2 </font></strong><br><font face=verdana,arial,helvetica size=-2>(optional):</font></td><td><input type="text" name=address-line-2 value= " " size=50 maxlength=60></td> </tr> <tr><td align=right><strong><font face=verdana,arial,helvetica size=-1>City: </font></strong></td><td><input type="text" name=city value=" " size=25></td> </tr> <tr><td align=right><strong><font face=verdana,arial,helvetica size=-1>State/Province/Region: </font></strong></td><td><input type="text" name=state value=" " size=15></td> </tr> <tr><td align=right><strong><font face=verdana,arial,helvetica size=-1>ZIP/Postal Code: </font></strong></td><td><input type="text" name=zip value=" " size=20></td> </tr> <tr><td align=right><strong><font face=verdana,arial,helvetica size=-1>Country: </font></strong></td><td> <select name=country> <option> Albania<option> Algeria<option> American Samoa<option> Andorra<option> Angola<option> Anguilla<option> Antarctica<option> Antigua And Barbuda<option> Argentina<option> Armenia<option> Aruba<option> Australia<option> Austria<option> Azerbaijan<option> Bahamas<option> Bahrain<option> Bangladesh<option> Barbados<option> Belarus<option> Belgium<option> Belize<option> Benin<option> Bermuda<option> Bhutan<option> Bolivia<option> Bosnia and Herzegowina<option> Botswana<option> Bouvet Island<option> Brazil<option> British Indian Ocean Territory<option> Brunei Darussalam<option> Bulgaria<option> Burkina Faso<option> Burma<option> Burundi<option> Cambodia<option> Cameroon<option> Canada<option> Cape Verde<option> Cayman Islands<option> Central African Republic<option> Chad<option> Chile<option> China<option> Christmas Island<option> Cocos (Keeling) Islands<option> Colombia<option> Comoros<option> Congo<option> Congo, the Democratic Republic of the<option> Cook Islands<option> Costa Rica<option> Cote d'Ivoire<option> Croatia<option> Cyprus<option> Czech Republic<option> Denmark<option> Djibouti<option> Dominica<option> Dominican Republic<option> East Timor<option> Ecuador<option> Egypt<option> El Salvador<option> England<option> Equatorial Guinea<option> Eritrea<option> Espana<option> Estonia<option> Ethiopia<option> Falkland Islands<option> Faroe Islands<option> Fiji<option> Finland<option> France<option> French Guiana<option> French Polynesia<option> French Southern Territories<option> Gabon<option> Gambia<option> Georgia<option> Germany<option> Ghana<option> Gibraltar<option> Great Britain<option> Greece<option> Greenland<option> Grenada<option> Guadeloupe<option> Guam<option> Guatemala<option> Guinea<option> Guinea-Bissau<option> Guyana<option> Haiti<option> Heard and Mc Donald Islands<option> Honduras<option> Hong Kong<option> Hungary<option> Iceland<option> India<option> Indonesia<option> Ireland<option> Israel<option> Italy<option> Jamaica<option> Japan<option> Jordan<option> Kazakhstan<option> Kenya<option> Kiribati<option> Korea (South)<option> Korea, Republic of<option> Kuwait<option> Kyrgyzstan<option> Lao People's Democratic Republic<option> Latvia<option> Lebanon<option> Lesotho<option> Liberia<option> Liechtenstein<option> Lithuania<option> Luxembourg<option> Macau<option> Macedonia<option> Madagascar<option> Malawi<option> Malaysia<option> Maldives<option> Mali<option> Malta<option> Marshall Islands<option> Martinique<option> Mauritania<option> Mauritius<option> Mayotte<option> Mexico<option> Micronesia, Federated States of<option> Moldova, Republic of<option> Monaco<option> Mongolia<option> Montserrat<option> Morocco<option> Mozambique<option> Myanmar<option> Namibia<option> Nauru<option> Nepal<option> Netherlands<option> Netherlands Antilles<option> New Caledonia<option> New Zealand<option> Nicaragua<option> Niger<option> Nigeria<option> Niue<option> Norfolk Island<option> Northern Ireland<option> Northern Mariana Islands<option> Norway<option> Oman<option> Pakistan<option> Palau<option> Panama<option> Papua New Guinea<option> Paraguay<option> Peru<option> Philippines<option> Pitcairn<option> Poland<option> Portugal<option> Puerto Rico<option> Qatar<option> Reunion<option> Romania<option> Russia<option> Russian Federation<option> Rwanda<option> Saint Kitts and Nevis<option> Saint Lucia<option> Saint Vincent and the Grenadines<option> Samoa (Independent)<option> San Marino<option> Sao Tome and Principe<option> Saudi Arabia<option> Scotland<option> Senegal<option> Seychelles<option> Sierra Leone<option> Singapore<option> Slovakia<option> Slovenia<option> Solomon Islands<option> Somalia<option> South Africa<option> South Georgia and the South Sandwich Islands<option> South Korea<option> Spain<option> Sri Lanka<option> St. Helena<option> St. Pierre and Miquelon<option> Suriname<option> Svalbard and Jan Mayen Islands<option> Swaziland<option> Sweden<option> Switzerland<option> Taiwan<option> Tajikistan<option> Tanzania<option> Thailand<option> Togo<option> Tokelau<option> Tonga<option> Trinidad<option> Trinidad and Tobago<option> Tunisia<option> Turkey<option> Turkmenistan<option> Turks and Caicos Islands<option> Tuvalu<option> USA<option> Uganda<option> Ukraine<option> United Arab Emirates<option> United Kingdom<option selected> United States<option> United States Minor Outlying Islands<option> Uruguay<option> Uzbekistan<option> Vanuatu<option> Vatican City State (Holy See)<option> Venezuela<option> Viet Nam<option> Virgin Islands (British)<option> Virgin Islands (U.S.)<option> Wales<option> Wallis and Futuna Islands<option> Western Sahara<option> Yemen<option> Zambia<option> Zimbabwe </select> </td> </tr> <tr><td align=right><strong><font face=verdana,arial,helvetica size=-1>Phone Number: </font></strong></td><td><input type="text" name=phone-number value=" " size=15></td> </tr> <tr><td> </td><td> <br> <input type=submit value = "Continue" name=submit.continue alt="Continue" height=23 width=89> </td></tr> <tr><td> </td><td><br> </td> </tr> </table> <!----/form> ThisForm ; print "<input type=\"hidden\" name=\"item-row-sum\" value=$req{'item-row-sum'}>"; my $index = 1; &store_book_order($index); &store_cookie; print "</form>"; }