home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13h.zip / PREFILTR.80 < prev    next >
Text File  |  1998-04-11  |  3KB  |  88 lines

  1. /*A pre filter for SRE-http.
  2.  
  3. This pre-filter implements support for the GOREMOTE server
  4. remote control package of GoServe.
  5.  
  6. If PRE_FILTER=YES, then only SUPERUSERs will be allowed acces to
  7. GoRemore.  If PRE_FILTER=FIRST, then everyone is given access.
  8.  
  9. In this version, PREFILTR will check to see if the request is for
  10. GORMxxx or GOREMOTE.HTM, or GOREMOTE/GORMxxx and GOREMOTE/GOREMOTE.HTM.
  11. Thus, GOREMOTE must be installed either in the root of the data directory,
  12. or in the GOREMOTE/ subdirectory of the data directory.
  13.  
  14. PREFILTR should return: status , message:
  15. status=0:  SRE-http should continue
  16. status=1:  some form of completion, SRE-http should end (perhaps after
  17. recording request info)
  18.  
  19. The message will be saved as the PREFILTER_RESULT variable 
  20.  
  21.  
  22. */
  23.  
  24. prefiltr:
  25.  
  26. parse arg source,request,sel,privs,servername,otherargs
  27.  
  28. call pmprintf_sref(' in prefilter 80 'source' 'request)
  29. issent=completed()
  30. if issent=1 then  /* if cached request, nothing here to do.. */
  31.   return '1 , ok cached'
  32.  
  33. tsel=translate(sel)
  34. if abbrev(tsel,'GOR')=0 & abbrev(tsel,'GOS')=0 then return '0 , ok'   /* quick check */
  35.  
  36. /* see it this is GOREMOTE.HTM or GORM*.HTM, in either main or
  37. GOREMOTE directory */
  38.  
  39. foo=translate(sel,' ','/\')
  40. endword=word(foo,words(foo))
  41.  
  42. sel1=strip(tsel,,'/')
  43.  
  44. hi1=abbrev(sel1,"GOREMOTE")
  45. hi2=abbrev(sel1,"GORM")
  46. hi3=abbrev(sel1,"GOREMOTE/GORM")
  47. hi4=abbrev(sel1,"GOREMOTE/GOREMOTE")
  48. if hi1+hi2+hi3+hi4=0 then
  49.         return '0 , ok'
  50.  
  51.  
  52. /* if here, it's a goremote command -- srehttp will not have to
  53. do anything with this request (except record it). */
  54.  
  55. verb=word(request,1)
  56. /* check privs? */
  57. if privs<>" " then do
  58.   tp=translate(privs)
  59.   IF verb="GET" then do
  60.     if (wordpos("SUPERUSER",tp)+wordpos("INHOUSE",tp))=0   then do
  61.         foo=sref_response('unauth', 'you do not have sufficient privileges for '||endword,servername)
  62.         return '1, not allowed ' /* let sre-http record this .. */
  63.     END
  64.   end
  65.   if verb="POST" then do
  66.     if wordpos("SUPERUSER",tp)=0   then DO
  67.         foo=sref_response('unauth', 'you do not have sufficient privileges for '||endword,servername)
  68.         return '1, not allowed ' /* let sre-http record this .. */
  69.     END
  70.   end
  71. end
  72.  
  73. sel=sref_replacestrg(sel,'GOREMOTE.HTM','GOREMOTE')  /* a common error .. */
  74.  
  75. /* if here, goremote and sufficient privs -- do it ! */
  76. if verb="GET" then do
  77.   say " GoRemote= " verb sel
  78.   foo=goremote(verb,sel)
  79.  
  80. end
  81. else do
  82.     say " GOREMOTE= " verb endword
  83.    foo=goremote(verb,endword)
  84. end
  85. return ' 1 , did goremote '
  86.  
  87.  
  88.