home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13h.zip / interpet.in0 < prev    next >
Text File  |  1998-04-17  |  5KB  |  140 lines

  1. ;4/98 This file contains "INTERPRET" rexx-code blocks for use by
  2. ;     the INTERPRET keyphrase of SRE-http. 
  3. ;               *******************************
  4. ; OBSOLETE: We recommend use of dedicated "rexx code block files" (*.RXX files)
  5. ;           or the use of INTERPRET CODE xxx ;yyy.
  6. ;               *******************************
  7. ;
  8. ;Each rexx-code block should be labeled with a {label}, then the rexx-code
  9. ;block  follows, with the next label (or eof) signalling the end
  10. ;of the block.
  11. ;
  12. ;General Usage notes:
  13. ;
  14. ;   To include output in the document, store results in INTERRET.RESULTS
  15. ;
  16. ;   Seperate rexx-code lines with a semi-colon
  17. ;
  18. ;   In addition to the functions available through goserve (including
  19. ;   REQFIELD, SERVERNAME(), CLIENTNAME(), etc.), SRE-http the following
  20. ;  variables:
  21. ;     crlf : the line seperator
  22. ;     tmp.  : To be safe, store temporary results in tmp.xx variables
  23. ;     dir   : Working directory (i.e. E:/GOHTTP/)
  24. ;     who: ip of requester
  25. ;     whoport: port of requester
  26. ;     request : request #
  27. ;     transaction: transaction # (maybe several transactions per request)
  28. ;     tempfile: Unique file name for this transaction (use for a working file)
  29. ;     myaddr: Server's ip
  30. ;     sel : Orginal request string
  31. ;
  32. ;
  33. ;Some sample Code Blocks:
  34. ;  Several samples are included below. Of particular interest is  USE_TABLE.;
  35. ;
  36. ;  USE_TABLE : Detects whether the requesting browser understands the
  37. ;             TABLE element. If so, INCLUDES  xxx.TBL, if not, includes xxx.DEF.
  38. ;  GET_HIT:   Finds # of hits for current URL (NOT including this one).
  39. ;              Returns result in CURRENT_HIT.NUM
  40. ;  AUGMENT_HIT: Same as GET_HIT, but does include current hit (that is, it
  41. ;                modifies COUNTER.CNT.
  42. ; AUDIT_CLIENTNAME: Write the client ip name to the audit file
  43. ;
  44. ;
  45. ; Notes
  46. ;  GET_HIT and AUGMENT_HIT are useful if you
  47. ;          call an external procedure that creates counter GIFS.
  48. ;
  49. ;  Details on USE_TABLE:
  50. ;        xxx is the name of the action -- and xxx.TBL and xxx.DEF should be
  51. ;        in the SAME DIRECTORY AS THE HTML DOCUMENT!!
  52. ;
  53. ;        The ambitious user may wish to augment the TABLE_LIST stem variable.
  54. ;
  55. ;         The USETABL2.RXX  file contains a more sophisticated version of 
  56. ;         USE_TABLE,
  57. ;           ..if the browser does not appear on the
  58. ;             "table_list", a "tell me if you can handle TABLEs" document is
  59. ;              sent back.. and depending on the answer, either xxx.TBL 
  60. ;              or xxx.DEF is included.
  61. ;
  62. ;---- End comments section.
  63.  
  64. {TEST1}  interpret=results=' <h3> This is a test </h3> '
  65.  
  66. {GO_to_bed}   tmp.jj=time('h') ; SAY " BED 1 " ;
  67.              if tmp.jj<5 | tmp.jj>20 then do ;
  68.                   interpret.results= ' <STRONG> It  is very late</STRONG> ' ;
  69.          interpret.results=interpret.results||crlf||" aren't   you tired? " ;
  70.              end ;
  71.  
  72. {AUDIT_CLIENTNAME}
  73.    if clientname0=0 then ;
  74.              TMP1=clientname() ;
  75.           else ;
  76.             TMP1=clientname0 ;
  77.    audit " Client Name: " tmp1 ' on ' date() ;
  78.  
  79.  
  80.  
  81. {GOOD_MORNING }
  82.           tmp.jj=time('h') ;
  83.           select ;
  84.           when tmp.jj<7 then
  85.                tmp='<em> It is very early? </em> ' ;
  86.           when tmp.jj<12 & temp.jj > 6 then
  87.                tmp='<em> Good morning </em> ' ;
  88.           when tmp.jj<19 & temp.jj > 11 then
  89.                tmp='<em> Good afternoon </em> ' ;
  90.           otherwise
  91.                tmp='<em> Good evening.. </em> ' ;
  92.           end ;
  93.           interpret.results=tmp
  94.  
  95. {get_hit} /* Get current # of hits (NOT including this one), store in current_hit.num */
  96.            current_hit.num=lookup_count(counter_file,action) ; say ' Hits = ' current_hit.num;
  97.  
  98. {augment_hit}  /* Augment # of hits, save results in current_hit.num, do not
  99.                      display results */
  100.          current_hit.num=lookup_count(counter_file,action,'ADD') ;say ' +Hits = 'current_hit.num;
  101.  
  102.  
  103. {USE_TABLE}
  104.  
  105.   /* -- add "table capable browser" User-agent identifiers here -- */
  106.   /* Note that "abbreviation match is performed (don't worry about extra
  107.      stuff after the last character in each table_list entry) */
  108.   table_list.1='IBM WebExplorer DLL /v1.03' ;
  109.   table_list.2="Mozilla/2.0";
  110.   table_list.3="Mozilla/1.1";
  111.   table_list.4="Mozilla/1.2";
  112.   table_list.5="Mozilla/1.3";
  113.    table_list.6="IBM-WebExplorer-DLL/v1.1";
  114.  
  115.  
  116.  
  117.   table_list.0=6 ;
  118.  
  119.   /* -- do not change below here --- */
  120.  
  121.   putme=reqfield("User-Agent") ;
  122.   isat=lastpos('.',docname);
  123.   docname0=docname ;
  124.   if isat>0 then
  125.       docname0=delstr(docname,isat) ;
  126.   docname1=docname0||'.DEF' ;
  127.   if putme<>" " then do ;
  128.      do mm=1 to table_list.0 ;
  129.        if abbrev(translate(putme),translate(table_list.mm))=1 then do;
  130.          docname1=docname0||'.TBL' ;
  131.          leave ;
  132.        end ;
  133.      end;
  134.   end;
  135.   interpret.results=delim_1.1||'INCLUDE  '||docname1||delim_2.1 ;
  136.  
  137.  
  138. {END}
  139.  
  140.