home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 0758 / setup.arv / GETORDER.TEM < prev    next >
Encoding:
Text File  |  1997-04-10  |  2.7 KB  |  86 lines

  1. #
  2. # get the order from the user
  3. # get order title
  4.         $TITLE="Catalog Maker Get Order";
  5. ###############################
  6. # END OF CHANGEABLE OPTIONS   #
  7. ###############################
  8.  
  9. # START MAIN PROGRAM 
  10. # ------------------
  11.  
  12. &ReadParse;
  13. $Session = $in{'SessionID'};
  14. if    ($Session eq '')               {&PrintError; exit 1;}  # An Error
  15. elsif ($Session eq '*SeSiOnId*')     {&PrintError; exit 1;};  # Get a session id
  16. print "Content-Type: text/html\n\n";
  17. $targetFile = $ENV{'PATH_TRANSLATED'};
  18. $CatTitle = $in{'CatTitle'};
  19. $CGIPath = $in{'CGIPath'};
  20. print (&ReplaceInfo($targetFile));
  21. &GetShipping; # created by CatMake
  22. &GetPayment;  # created by CatMake
  23. &ActivationAndInfo;
  24.  
  25. exit(1);
  26.  
  27. # GENERAL SUBROUTINES
  28. # -------------------
  29.  
  30. sub ReadParse {
  31.   local (*in) = @_ if @_;   local ($i, $loc, $key, $val);
  32.   if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'}; } 
  33.   elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); }
  34.   @in = split(/&/,$in);
  35.   foreach $i (0 .. $#in) {
  36.     $in[$i] =~ s/\+/ /g;
  37.     ($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
  38.     $key =~ s/%(..)/pack("c",hex($1))/ge;
  39.     $val =~ s/%(..)/pack("c",hex($1))/ge;
  40.     $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator
  41.     $in{$key} .= $val;
  42.   }
  43.   return 1; # just for fun
  44. } # ReadParse
  45.  
  46. sub PrintError {
  47. print("Content-Type: text/html\n\n");
  48. print <<EOF;
  49. <HTML> 
  50. <HEAD><TITLE>ERROR</TITLE></HEAD>
  51. <BODY>
  52. <H1 ALIGN=CENTER>$TITLE</H1>  <HR>
  53. An error occured in the script!
  54. <HR>
  55. EOF
  56. } # PrintError
  57.  
  58. sub ReplaceInfo {
  59.         local($fileName) = @_;
  60.  
  61.         open(INPUT, "<$fileName") || "Error opening order template.\n";
  62.         undef $/; # Read in the entire file 
  63.         ($data = <INPUT>) || "Error reading order template file.\n";
  64.  
  65.         $data =~ s/\*SeSiOnId\*/$Session/g;
  66.         $data =~ s/\*CatTitle\*/$CatTitle/g;
  67.         $data =~ s/\*CGIPath\*/$CGIPath/g;
  68.  
  69.         $data;
  70. } # ReplaceInfo
  71.  
  72. sub ActivationAndInfo {
  73.         print "<br><b><Additional Payment Information></b><table border>";
  74.         print "<tr><th>Card/Purchase Order # </th><td><input type=\"TEXT\" name=\"CARDNUM\" size=40></td></tr>";
  75.         print "<tr><th>Name on Card</th><td><input type=\"TEXT\" name=\"NAMEONCARD\" size=40></td></tr>";
  76.         print "<tr><th>Expiration date</th><td><input type=\"TEXT\" name=\"EXPRDATE\" size=40></td></tr></table>";
  77.  
  78.         print "<br><b>Comments</b><br>";
  79.         print "<textarea rows=4 cols=40 name=\"COMMENTS\"></TEXTAREA>";
  80.  
  81.         print "<br><input type=\"SUBMIT\" value=\"Submit\"><input type=\"RESET\" value=\"Reset\"></form>";
  82. } # ActivationAndInfo
  83.  
  84.  
  85.  
  86.