home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / readmein.zip / readmein.cmd < prev   
OS/2 REXX Batch file  |  1998-06-12  |  6KB  |  235 lines

  1. /*                                                                     */ 
  2.  /***************************************************************************
  3.  *  form processor
  4.  * grabs all fields on a web page and creates an e-mail and 
  5.  * send it to the user via a hidden field in the html call email
  6.  * it then sends the user to a predefined location also specified
  7.  * by hidden field in refering the HTML page
  8.  * 
  9.  *
  10.  *  Author:  Eddie Shultz eddie@web-dock.com
  11.  *  version 00.02.00
  12.  *  June 12 ,1998 
  13.  *
  14.  * example HTML code copy the following to a blank html page
  15.  * change the cgi server location
  16.  * change the e-mail address 
  17.  * change the send to web page
  18.  * the remaining fields are just for demo (name,age,os)
  19.  *
  20.  * <FORM action="http://lucent.web-dock.com/cgi-bin/readmein.cmd" method="POST">
  21.  * <INPUT type="hidden" name="myaddress" value="support@nowselling.com">
  22.  * <INPUT type="hidden" name="mywebpage" value="http://lucent.web-dock.com/formprocess.html">
  23.  * name<INPUT name="name" size="20"><BR>
  24.  * age<INPUT name="age" size="20"><BR>
  25.  * os<INPUT name="os" size="20"><BR>
  26.  * <INPUT type="submit">
  27.  * </FORM>
  28.  *
  29.  *  6-12-98
  30.  * added field verification
  31.  * the script now check to see that data was entered in *ALL* fields
  32.  * if you want a field that a user does not have to fill out
  33.  * then in the HTML put a default value of something
  34.  * anything ie.. NA, not required , * 
  35.  * 
  36.  * 4-24-98
  37.  * add url field so user can specify a place to go after the form has
  38.  * been processed
  39.  * add e-mail field 
  40.  * add security to insure that only allowed domains are using the form  processor
  41.  **************************************************************************/
  42.  
  43. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  44. Call SysLoadFuncs
  45.  
  46. /* user defines 
  47.  * change to suite your needs
  48.  * nothing else requires changeing but feel free
  49.  */
  50.  
  51. pageBackground ='http://www.web-dock.com/images/globe_background.gif'
  52. pageBgColor='#ffffff'
  53. pageMessage ='Please go back an ensure that you have submitted all the required information'
  54.  
  55. /* end user defines */
  56.  
  57.  
  58. /* inits */
  59. uft = time()
  60. ft = translate(uft,"_",":")
  61. dt = date()
  62. dtt = translate(dt,"_"," ")
  63. mailFile = ft||dtt.wdd
  64.  
  65.  
  66.  
  67. call CGIParse
  68.  
  69. sendtoaddress = cgi.1
  70. newlocation = cgi.2
  71.  
  72. /* get HTML information for e-mail and relocate */
  73. parse var sendtoaddress  trash "=" mailto
  74. mailtoaddress = strip(mailto)
  75. parse var newlocation  trash "=" newlocation
  76. newlocation= strip(newlocation)
  77.  
  78.  
  79. /* check if all data from page was filled in if not then exit 
  80.  * this routine checks to see if the value returned is blank
  81.  * and if the length if the returned variable = 0
  82.  * if yes then error
  83. */
  84.  
  85.  
  86. data_error = 0
  87. DO i = 1 to cgi.0
  88.     parse value cgi.i with remark "=" value
  89.     if compare(substr(value,1,3)," ") = 0 then data_error = 1
  90.     if length(value) = 0 then data_error = 1
  91. /* debug    Say 'var=:' remark  ' value = :' value ' and length =:' rxd' and error = :' data_error || '<BR>' */
  92. END
  93.  
  94.  
  95.  
  96.  
  97. /* error no e-mail address was specified */
  98.  
  99. if data_error = 1 then DO
  100.  
  101.     Say "Content-type: text/html"
  102.     Say 
  103.     Say "<HTML>"
  104.     Say "<HEAD>"
  105.     Say "<TITLE>Shop</TITLE>"
  106.     Say "</HEAD>"
  107.     Say '<BODY background="'pageBackground'"  bgcolor="'pageBgColor'">'
  108.     Say '<BR>'
  109.     
  110.     Say '<center>'
  111.     Say  pageMessage
  112.     Say '<BR>'
  113.     Say '</Body>'
  114.     Say '</HTML>'
  115.     return 0
  116.     exit
  117.  
  118. END
  119.  
  120.  
  121.  
  122.  
  123. /* create e-mail   */
  124.  
  125. go=lineout(mailFile ,"subject:Form Information.")
  126. go=lineout(mailFile ,"from:WebDock Form Processor")
  127. go=lineout(mailFile ,"------------------------------------------------------")
  128. go=lineout(mailFile,"Form Information")
  129. go=lineout(mailFile ,"Date:  " || date()|| "  Time: " || time())
  130. go=lineout(mailFile ,"------------------------------------------------------")
  131. go=lineout(mailFile ," ")
  132. go=lineout(mailFile ," ")
  133.  
  134. DO i = 3 to cgi.0
  135.     go=lineout(mailFile ,cgi.i)
  136. END
  137. go=lineout(mailFile ," ")
  138. go=lineout(mailFile ," ")
  139. go=lineout(mailFile ,"--------End of Transmission--------")
  140. go = lineout(mailFile)
  141.  
  142. /* end mail file creation */
  143.  
  144.  
  145.  
  146. /* relocate the user */
  147.  
  148. Say "HTTP/1.0 302 Found:"
  149. Say  "Location: "||newlocation
  150. Say
  151.  
  152.  
  153. /* mail information  */
  154. "sendmail -af "|| mailFile  mailtoaddress  
  155.  
  156.  
  157. /* remove the temp mail file */
  158. 'del '||mailFile 
  159.  
  160.  
  161. /* exit */
  162. return 0 
  163.  
  164.  
  165.  
  166.  
  167.  
  168. /* cgi parse */
  169.  
  170. CGIParse:PROCEDURE EXPOSE cgi.
  171.  
  172. queryString=''
  173.  
  174. IF getEnv('REQUEST_METHOD') = 'POST' THEN
  175.  DO
  176.     IF getEnv('CONTENT_TYPE') \= 'application/x-www-form-urlencoded' THEN RETURN 1
  177.     j= getEnv('CONTENT_LENGTH')
  178.     IF DATATYPE(j, 'W') \= 1 THEN queryString=''
  179.     ELSE queryString= LINEIN()
  180.  END
  181.  
  182. queryString= TRANSLATE(queryString, ' ', '+')
  183. i = 0
  184. DO WHILE LENGTH(queryString) > 0
  185.  varCouple= ''
  186.  PARSE VAR queryString varCouple'&'queryString
  187.  PARSE VAR varCouple varName'='varVal
  188.  IF varName = ''  THEN ITERATE /* | varVal= '' THEN ITERATE */
  189.  i = i +1
  190.  varNametag= varName
  191.  varName= 'cgi.' || i
  192.  varVal=  urlDecode(varNametag)||" = "||urlDecode(varVal)
  193.  IF SYMBOL(varName) = 'BAD' THEN ITERATE
  194.  IF VALUE(varName) \= TRANSLATE(varName) THEN call VALUE varName, VALUE(varName) || '0d'x || varVal
  195.  ELSE call VALUE varName, varVal
  196. END
  197. cgi.0=i
  198. RETURN 0
  199.  
  200. /*********************************************************************/
  201. URLDecode:PROCEDURE EXPOSE cgi.
  202.  
  203. IF ARG()\=1 THEN RETURN ''
  204. line= ARG(1)
  205. lineLen= LENGTH(line)
  206. newLine= ''
  207.  
  208. i=1
  209. DO WHILE i <= lineLen
  210.  c= SUBSTR(line, i, 1)
  211.  IF c \= '%' THEN newLine = newLine || c
  212.  ELSE IF i+2 <= lineLen THEN
  213.                         DO
  214.                            newLine= newLine || x2c(SUBSTR(line, i+1, 2))
  215.                            i=i+2
  216.                         END
  217.  i= i+1
  218. END
  219. RETURN newLine
  220.  
  221.  
  222. /*********************************************************************/
  223. getEnv:PROCEDURE
  224. RETURN VALUE(ARG(1),, 'OS2ENVIRONMENT')
  225.  
  226. /*********************************************************************/
  227. putEnv:PROCEDURE
  228. RETURN VALUE(ARG(1), ARG(2), 'OS2ENVIRONMENT')
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.