home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / POSTRCRD.80 < prev    next >
Text File  |  1997-07-01  |  3KB  |  95 lines

  1. /* a simple "event specific" client&request info recorder 
  2.  
  3.  
  4. This will record clientname and other information when certain
  5. events happen. These events are the transferal of a file,
  6. or the request for a URL.  To specify which events, add entries
  7. to the EVENTS.  stem variable.  These should have the form:
  8.     EVENTS.m = ' type   value   putfile '
  9. where:
  10.      Type:  FILE or URL  --  check the USED_FILE or the URL (the SEL)
  11.     value:  If the FILE or URL matches the value (wildcard matches okay), then
  12.             save information
  13.   putfile:  Fully qualified file name (results will be written there )
  14.  
  15. Example:
  16.  events.1=' file  d:\www\zoo\tigers.htm  d:\goserve\tigers.lst '
  17.  events.2=' url   members\renewal.htm  d:\users\incoming\renew.in '
  18.  events.3=' url   staff\*    d:\staff\wwwbiz.log'
  19.  events.0=3
  20.  
  21.  
  22. Notes:
  23.    Make sure you set EVENTS.0 (in this case, EVENTS.0=3) !
  24.    All matches will be honored -- more then one "recording" may occur.
  25.  
  26.  
  27. **/
  28. postrcrd:
  29.  
  30. CRLF = '0d0a'x
  31.  
  32. /*  ==============  INSERT  EVENTS list here   ================  */
  33.  
  34. events.0=0
  35.  
  36.  
  37.  
  38. /* ============ DO NOT CHANGE BELOW HERE  ===================== */
  39.  
  40.  
  41. parse arg amessage,source,request,sel,tempfile,SERVERNAME,HOST_NICKNAME,used_file,thereferer,tcache
  42.  
  43. sel=packur(sel) ; request=packur(request)
  44.  
  45.  
  46. parse var source serveraddr serverport transaction_number clientaddr clientport
  47. do mm=1 to events.0
  48.  
  49.   parse upper var events.mm type avalue afile
  50.   type=strip(type); avalue=strip(avalue); afile=strip(afile)
  51.   select
  52.     when type='FILE' then do
  53.        ares=sref_wildcard(strip(upper(used_file)),strip(avalue),0)
  54.        parse var ares astat "," .
  55.        if astat=0 then iterate   /* no match */
  56.     end
  57.     when type='URL' | type='SEL' then do
  58.        avalue=translate(avalue,'/','\')
  59.        ares=sref_wildcard(strip(upper(sel)),strip(avalue),0)
  60.        parse var ares astat "," .
  61.        if astat=0 then iterate   /* no match */
  62.     end
  63.     otherwise do
  64.         call pmprintf_sref(' Error in post-filter recorder. Bad Event entry: ' events.mm)
  65.         iterate
  66.     end   /* otherwise */
  67.   end   /* select */
  68.  
  69. /* got match -- write results. */
  70.   foo=stream(afile,'c','open')
  71.   if abbrev(foo,'READY')=0 then do
  72.       call pmprintf_sref(foo' ERROR in post-filter recorder: unfortunate output file : ' afile)
  73.       iterate
  74.   end
  75.  foo=stream(afile,'c','close')
  76.  
  77.  astat=sockgethostbyaddr(clientaddr,'stuff.!')
  78.  cname=upper(stuff.!name)
  79.  if abbrev(cname,'STUFF.!')=1 then cname=clientaddr
  80.  adate=date() ; atime=time()
  81.  amess=crlf||date() ' ' time()||crlf
  82.  amess=amess||' Request from: ' clientaddr ' ( ' cname' )'||crlf
  83.  amess=amess||' Referer: '||thereferer||crlf
  84.  amess=amess||' File= ' used_File ' ; URL= '  sel|| crlf
  85.  amess=amess||' Message: ' amessage
  86.  call lineout afile,amess
  87.  call lineout afile                   
  88.  
  89. end                     /* end do */
  90. return ' '
  91.  
  92.  
  93.  
  94.  
  95.