#!/usr/local/bin/perl##    postinfo.pl##    process cgi-bin QUERY_STRING ##    Usage:  %qstring = &process_qstring($ENV{'QUERY_STRING'});##    $Source: /usr/local/CVS/SETREF_1_0_Release/webdemo/merchant/cgi-bin/set-demo/postinfo.pl,v #    $Revision: 1.4 #    $Date: 1997/06/06 00:53:04 #    $Name: SETREF_1_0_Release #    $Disclaimer: #    ----------------------------------------------------------------------#    SET Draft Reference Implementation Disclaimer/License#    June 30, 1997#    #    This is a beta version of the SET Draft Reference Implementation#    ("DRI").  It is a work in progress and is being provided at this#    stage and in this form to help developers and other interested#    parties to understand the SET protocol.  This version of the DRI#    provides the core functionality required to process a simple#    transaction.  This release does not support certificate authority#    messages. Nor does it support the SET option to perform#    transactions without cardholder certificates.  For more details#    on the functionality in this beta version, please refer to the#    attached documentation.  #    #    Later versions of the DRI will include additional functionality#    and may include other changes.  DO NOT RELY UPON THIS CODE IN YOUR#    DEVELOPMENT.  If you discover a bug, please let us know by posting#    a message to the SET-DEV mailing list.  Our lawyers made us include#    the next four paragraphs, so PLEASE READ THE TEXT BELOW because it#    describes what you can do with the DRI.#     #    Copyright (C) 1996, 1997, Visa International Service Association and#    MasterCard International Incorporated.  All rights reserved.  #    Permission to copy and implement the material contained herein is#    granted subject to the conditions that (i) any copy or re-publication#    must bear this legend in full; (ii) any derivative work must bear#    a notice that it is not the Draft Reference Implementation ("DRI")#    for SET and (iii) that none of the copyright holders shall have any#    responsibility or liability whatsoever to any other party arising#    from the use or publication of the material contained herein.#    #    Visa and MasterCard ("Licensors") hereby grant you ("Licensee") a#    limited license to (i) make, use, copy and modify the DRI for the#    purpose of developing software that complies with the SET#    Specification ("SET Products") and for the purpose of achieving a#    better understanding of the SET Protocol; and (ii) distribute SET#    Products that incorporate all or a portion of the DRI and other#    software, which together are provided under a defined interface#    different from that provided by the DRI's API.  Licensee shall not#    redistribute or sell a license to the DRI nor shall Licensee#    incorporate any part of the DRI into a SET Toolkit.  A "Toolkit"#    means a product that provides comprehensive facilities to enable#    other parties to create software products for distribution. #    Bolt-on applications and payment modules shall not be considered#    Toolkits for the purpose of this license.  The DRI is not intended#    to be used as a Toolkit.#    #    Licensors make no representation or warranty of any kind, express#    or implied, relating to the DRI.  Licensors are making the DRI#    publicly available as an aid to understanding, creating, and#    testing SET Products.  Licensees are solely responsible for any#    use of the DRI and agree to hold Licensors harmless for any claim#    that may arise out of any product created with the DRI.  #    #    Licensee expressly acknowledges Terisa Systems, Inc., a Delaware#    Corporation with offices at 4984 El Camino Real, Los Altos,#    California, as a third party beneficiary of this license.#    #    This software is controlled material under U.S. law and the laws#    of other jurisdictions and you hereby acknowledge and agree that#    you must fully comply with all the current laws of the United States#    including, without limitation, rules and regulations of the United#    States Office of Export Administration and other applicable U.S.#    governmental agencies.  #    ----------------------------------------------------------------------#     $##    Copyright (C) 1996, 1997, Visa International Service Association and MasterCard International Incorporated#    All Rights Reserved.##    briank@terisa.com#package postinfo;sub main'process_qstring {    local($QUERY_STRING) = @_;    local(@al, %qstring, $v, $k);    @al = &split_qstring($QUERY_STRING);    foreach(@al){      ($k,$v)=split(/=/,$_);      next unless $k;      $k = &unmangle_qstring_arg($k);      $v = &unmangle_qstring_arg($v);      $qstring{$k}=$v;    }    return(%qstring);}sub main'process_qstring_additively {    local($QUERY_STRING) = @_;    local(@al, %qstring, $v, $k);    @al = &split_qstring($QUERY_STRING);    foreach(@al){      ($k,$v)=split(/=/,$_);      next unless $k;      $k = &unmangle_qstring_arg($k);      $v = &unmangle_qstring_arg($v);      if (defined($qstring{$k})) {        $qstring{$k} .= "@@";      }      $qstring{$k} .= $v;    }    return(%qstring);}sub obtain_qstring_post {   local(@al, @QS, $line, $rin, $nfound, $timeleft);    $rin = '';    vec($rin, fileno(STDIN), 1) = 1;    ($nfound, $timeleft) = select($rout=$rin, undef, undef, 0);    if ($nfound) {      do {        $line = <STDIN>;        $line =~ s/\s+$//g;        @al = split(/\&/, $line);        foreach $line (split(/\&/, $line)) {          $line = &unmangle_qstring_arg($line);          push(@QS, $line);         }        ($nfound, $timeleft) = select($rout=$rin, undef, undef, 0.1);      } while ($nfound > 0);    }  return(@QS);}sub unmangle_qstring_arg {  local($arg) = @_;  $arg =~ tr/+/ /;  $arg =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("H2", $1)/eg;  return ($arg);}  sub split_qstring {  local($QUERY_STRING) = @_;  if ($ENV{'REQUEST_METHOD'} =~ /POST/i) {    return(&obtain_qstring_post());  }  else {    return(split(/\&/,$QUERY_STRING));  }}1; # in case this file is require'd