home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / ONLINE / SREFPRC1 / CGIVARS.SRF < prev    next >
Text File  |  1996-10-08  |  4KB  |  121 lines

  1. /* Procedure to return a value of one of the CGI-Bin variables
  2.  
  3. Note that:h SCRIPT_NAME, PATH_INFO, PATH_TRANSLATED, and REMOTE_IDENT,
  4. PATH_INFO, PATH_TRANSLATED, and QUERY_STRING are not available. When
  5. one of these variables is requested, a ' ' is returned
  6.  
  7. Note that this will NOT look in environment, but will determine the
  8. values each time.  In other words, this not designed for use
  9. in cgi-bin scripts (you should use x=value(varname,,'os2environment)
  10. instead); it is designed for use in INTERPRET includes and in
  11. directly called REXX server side programs).
  12.  
  13. */
  14. sref_cgivars:
  15.   parse arg findme
  16.  
  17.   findme=strip(strip(findme),,'"')
  18.   putme=' '
  19.   select
  20.          when findme="DOCUMENT_NAME" then  do
  21.              if symBol('AFILE')='VAR' then putme=afile
  22.          end
  23.          when findme="DOCUMENT_URI" then do
  24.              if symBol('SELORIGINAL')='VAR' then putme=seloriginal
  25.          end
  26.          when findme="DATE_LOCAL" then do
  27.                putme=date()
  28.                putme=putme||' '||time()
  29.          end
  30.          when findme="DATE_GMT" then do
  31.                putme=sref_new_gmt()
  32.                parse var putme eek ',' d1 d2 d3 .
  33.                putme=d1||' '||d2||' '||d3
  34.         end
  35.         when findme="LAST_MODIFIED" then do
  36.              if symBol('AFILE')='VAR' then do
  37.                  eek=sysfiletree(translate(afile,'\','/'),gosh,'F')
  38.                  poop=gosh.1
  39.                  parse var poop adate atime .
  40.                  putme =adate
  41.                  putme=putme||' '||atime
  42.               end
  43.         end     /* last modified */
  44.         when findme="SERVER_SOFTWARE" then do
  45.                 filter_name=sref_version()
  46.                  putme=server('H')||' '||filter_name
  47.         end
  48.         when findme="SERVER_NAME" then
  49.                 putme=servername()
  50.         when findme="GATEWAY_INTERFACE" then
  51.                 putme="CGI/1.1"
  52.         when findme="SERVER_PROTOCOL" then do
  53.                 putme=extract(serverprotocol)
  54.         end
  55.         when findme="SERVER_PORT" Then do
  56.                 putme=extract(serverport)
  57.         end
  58.         when findme="REQUEST_METHOD" then do
  59.                 putme=extract(clientmethod)
  60.         end
  61.         when findme="PATH_INFO" then 
  62.                 putme=" "
  63.         when findme="PATH_TRANSLATED" Then
  64.                 putme=" "
  65.  
  66.         when findme="SCRIPT_NAME" then do
  67.               putme=' '
  68.         end
  69.         when findme="QUERY_STRING" then
  70.              if symBol('awords')='VAR' then putme=awords
  71.         when findme="REMOTE_HOST" then DO
  72.               putme=clientname()
  73.         end
  74.         when findme="REMOTE_ADDR" then do
  75.                 putme=extract(clientaddr)
  76.         end
  77.         when findme="AUTH_TYPE" then
  78.                 putme="Basic Access Authentication Scheme"
  79.         when findme="AUTH_NAME" then do
  80.             afield=reqfield('Authorization')
  81.             parse var afield . m64 .              /* get the encoded cookie */
  82.             dec=pack64(m64)                       /* and decode it */
  83.             parse upper var dec putme ':' .      
  84.         end
  85.         when findme="REMOTE_IDENT" then
  86.                 putme=" "
  87.  
  88.         when findme="CONTENT_TYPE" then
  89.             putme=REQFIELD("Content-type")
  90.         when findme="CONTENT_LENGTH" then
  91.             putme=REQFIELD("Content-length")
  92.         when abbrev(findme,"HTTP_") then do
  93.           if findme="HTTP_ACCEPT" then do
  94.                i = 1
  95.                 _acc = REQFIELD("accept")
  96.                acc = '%'
  97.                ClientAccepts = ''
  98.                do while (acc \= _acc)
  99.                  acc = REQFIELD("accept", i)
  100.                  if (ClientAccepts \= '') then ClientAccepts = ClientAccepts', 'acc
  101.                  else ClientAccepts = acc
  102.                  i = i+1
  103.              end
  104.  
  105.               putme=clientaccepts
  106.           end
  107.           else do
  108.                 parse var findme . '_' findme2
  109.                 putme=reqfield(findme2)
  110.           end
  111.         end
  112.      otherwise
  113.          putme=' '
  114.  
  115.      end                /* select */
  116.  
  117.      return putme
  118.  
  119.  
  120.  
  121.