home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / System / DOpus / DAWCB / ARexx / DAWCB.dopus5
Text File  |  2000-03-04  |  4KB  |  155 lines

  1. /*
  2. $VER: DAWCB.dopus5 0.1 (3.3.00) D.Clarke
  3. */
  4.  
  5. CookieFile = 'AWeb3:Cache/AWCK'
  6.  
  7. options results
  8. parse arg port .
  9. address value port
  10. plural. = 's'
  11. plural.1 = ''
  12.  
  13. if ~show('l','rexxtricks.library') then call addlib('rexxtricks.library',0,-30)
  14.  
  15. if ~exists(CookieFile) then do
  16.   call displayerror('"DAWCB: Cookie file not found!" OK')
  17.   exit
  18.   end
  19.  
  20. call forbid()
  21. myportname = "DAWCB.0"
  22. do i = 0 while show("p",myportname)
  23.   myportname = "DAWCB."i
  24. end
  25. if ~openport(myportname) then do
  26.   call permit()
  27.   call displayerror('DAWCB: Could not open message port')
  28.   exit
  29.   end
  30. call permit()
  31.  
  32. lister new
  33. handle = result
  34. lister set handle case on
  35. lister set handle display name
  36. lister set handle header 'Save BEFORE closing!'
  37. lister set handle commentlength numlength
  38. lister set handle namelength nlength
  39. lister set handle handler myportname
  40. lister set handle label 'DAWCB'
  41.  
  42. dopus addtrap '*' myportname
  43. call ReadCookies
  44. call LoadLister
  45. lister refresh handle full
  46.  
  47. do forever
  48.   if waitpkt(myportname) then do
  49.     packet = getpkt(myportname)
  50.     if packet ~= '00000000'x then do
  51.       event = getarg(packet,0)
  52.       pname = getarg(packet,2)
  53.       arg3 = getarg(packet,3)
  54.  
  55.       select
  56.       when event = 'inactive' then leave
  57.       when event = 'menu' & arg3 = 2 then call DoView(pname)
  58.       when event = 'Delete' | (event = 'menu' & arg3 = 0) then call DoDelete(pname)
  59.       when event = 'menu' & arg3 = 1 then call WriteCookies()
  60.       otherwise nop
  61.       end
  62.       end
  63.     end
  64. end
  65.  
  66. dopus remtrap '*'
  67. call closeport(myportname)
  68.  
  69. exit
  70.  
  71. LoadLister:
  72. popup.COUNT = 2
  73. popup.0 = 'Delete'
  74. popup.1 = 'Save'
  75. popup.2 = 'View'
  76. ovfrom = copies(' ',30)
  77. ovexpire = copies(' ',30)
  78. ovcpath = copies(' ',80)
  79. do i = 1 to cookie.0
  80.   parse var cookie.i ident';'from';'cpath';'accept';'expire
  81.   if index(accept,'EXPIRE') > 0 then do
  82.     expire = accept
  83.     accept = 0
  84.     end
  85.   accept = (index(accept,'ACCEPT') > 0)
  86.   session = (index(upper(ident),'SESSION') > 0)
  87.   from = strip(substr(from,pos('DOMAIN=',from) + 7),,'"')
  88.   expire = strip(substr(expire,pos('EXPIRES=',expire) + 8),,'"')
  89.   cpath = strip(substr(cpath,pos('PATH=',cpath) + 5),,'"')
  90.   info.NAME = i
  91.   info.DISPLAY = ' '||accept||' '||session||' 'overlay(from,ovfrom)||'  '||overlay(expire,ovexpire)||'  '||overlay(cpath,ovcpath)
  92.   info.MENU = popup.
  93.   lister addstem handle info.
  94.   lister refresh handle
  95. end
  96. x = cookie.0
  97. lister set handle title cookie.0' Cookie'||plural.x
  98. lister refresh handle full
  99. return
  100.  
  101. DoDelete: procedure expose cookie. handle plural.
  102. parse arg ncookie
  103. revcookies = ''
  104. do while ncookie ~= ''
  105.   parse var ncookie which ncookie
  106.   revcookies = which' 'revcookies
  107. end
  108. do while revcookies ~= ''
  109.   parse var revcookies which revcookies
  110.   if ~stemremove('cookie',which) then do
  111.     call displayerror('"DAWCB: Error removing cookie!" OK')
  112.     return
  113.     end
  114. end
  115. lister clear handle
  116. call LoadLister
  117. return
  118.  
  119. DoView: procedure expose cookie.
  120. parse arg ncookie
  121. buffer = copies(' ',80)
  122. parse var cookie.ncookie ident';'from';'cpath';'accept';'expire
  123. if index(accept,'EXPIRE') > 0 then do
  124.   expire = accept
  125.   accept = 0
  126.   end
  127. text = overlay(expire,buffer)
  128. say '|'text'|'
  129. dopus request '"'translate(overlay(ident,buffer),'""','"')'" OK'
  130. dopus request '"'translate(overlay(from,buffer),'""','"')'" OK'
  131. dopus request '"'translate(overlay(cpath,buffer),'""','"')'" OK'
  132. dopus request '"'translate(overlay(expire,buffer),'""','"')'" OK'
  133. dopus request '"'translate(overlay(accept,buffer),'""','"')'" OK'
  134. return
  135.  
  136. displayerror: procedure
  137. parse arg message
  138. command flash
  139. dopus request '"'message'" OK'
  140. return
  141.  
  142. ReadCookies:
  143. if ~readfile(CookieFile,'cookie') then do
  144.   call DoRequest('DAWCB: Unable to read cookie file!" OK')
  145.   exit
  146.   end
  147. return
  148.  
  149. WriteCookies:
  150. if ~writefile(CookieFile,'cookie') then do
  151.   call displayerror('"DAWCB: Error writing cookie file!" OK')
  152.   exit
  153.   end
  154. return
  155.