home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / SREFCONF.CMD < prev    next >
OS/2 REXX Batch file  |  1999-06-19  |  73KB  |  2,299 lines

  1. /* this  is the "simple" sre-http configurator */
  2.  
  3. srefconf:
  4.  
  5. CHECKIT=0   /* Change this to 0 if you want to enable REMOTE configuration by SUPERUSERS */
  6.  
  7. /* the background color */
  8. USECOLOR='3def5f'
  9.  
  10. /* ---------------- DO NOT MODIFY BELOW THIS LINE  ------------------ */
  11.  
  12.  
  13. parse arg  ddir, tempfile, action,list,verb ,uri,user, ,
  14.           basedir ,workdir,privset,enmadd,transaction,verbose, ,
  15.          servername,host_nickname,homedir
  16.  
  17. if verb=" " then do
  18.    say "The SRE-http simple configurator is not meant to be run in standalone mode "
  19.    exit
  20. end  /* Do */
  21.  
  22. host_nickname=strip(upper(host_nickname))
  23.  
  24. call okay_client
  25. if notokay=1 then return rstatus||' Simple Configurator: Client not allowed access '
  26.  
  27.  
  28. optlist='ADD_HOST REMOVE_HOST CHECKLOG LOGON_FAIL_FILE ADD_USER REMOVE_USER '
  29. OPTLIST=OPTLIST||' ADD_INHOUSE REMOVE_INHOUSE ALLOW_ACCESS DO_HTACCESS ACCESS_FAIL_FILE '
  30. OPTLIST=OPTLIST||' ADD_ACESS REMOVE_ACCESS DEFAULT_ACCESS AUTO_NAME NOT_FOUND_URL '
  31. OPTLIST=OPTLIST||' THE_REALM HOME_NAME HOME_DIR ADD_VIRTUAL REMOVE_VIRTUAL INDEX '
  32. OPTLIST=OPTLIST||' WRITE_LOGS RECORD_OPTION HIT_CACHE_LEN HIT_OWNER_SUPPRESS ADD_ACCESS'
  33. OPTLIST=OPTLIST||' SSI_SHTML_ONLY HEADERS  WEBMASTER ADD_CUSTOM REMOVE_CUSTOM '
  34. OPTLIST=OPTLIST||' NO_SS ADD_REDIRECT REMOVE_REDIRECT  SSI_CACHE_ON  '
  35. OPTLIST=OPTLIST||' FIX_EXPIRE  SMTP_GATEWAY ADD_PUBLICURL REMOVE_PUBLICURL  '
  36.  
  37. /* intitialize possible arguments */
  38. arglist.!show=0 ;arglist.!set=0
  39.  
  40.  
  41. /* get argument list */
  42.  
  43. do until list=""
  44.   parse var list a1 '&' list
  45.   parse  var a1 atype '=' aval ; aval=strip(aval); atype=upper(strip(atype))
  46.   foo='!'||atype
  47.   arglist.foo=aval
  48. end /* do */
  49.  
  50. /* if SHOW argument, then return the appropriate request form */
  51. if arglist.!show<>0 then do
  52.    ares=show_it(arglist.!show)
  53.    return ares
  54. end  /* Do */
  55.  
  56. /* if SET argument, then go make the change*/
  57. if arglist.!set<>0 then do
  58.     ares=set_it(arglist.!set)   /*expose arglist */
  59.     return ares
  60. end  /* Do */
  61.  
  62. 'nodata'
  63.  
  64. return '400 0 Simple configurator '
  65.  
  66. /****************************/
  67. /*Change a parameter */
  68. /* based on stuff returned by client's response to show_it generated forms */
  69. set_it:procedure expose ddir optlist verbose servername enmadd host_nickname  basedir arglist. tempfile
  70. parse upper arg theopt
  71. ddir=strip(translate(ddir,'\','/'),'t','\')||'\'
  72. crlf='0d0a'x
  73. redo=1
  74.  
  75. initfile=get_value('initfilt_file')
  76. workdata=get_value('workdata_dir')
  77.  
  78. if wordpos(theopt,optlist)=0 then do
  79.   foo=sref_response('badreq',' You selected an unknown CONFIGURE parameter: '||theopt,servername)
  80.    return 0 
  81. end   
  82.  
  83. /* for each of the possible entries in optlist */
  84. select
  85.    when theopt="CHECKLOG" then do
  86.       aval='ALWAYS'
  87.       if arglist.!yesno=0 then aval='NO'
  88.       foo=change_initfilt(theopt,aval)
  89.       wow=change_okay(foo,'Client Logon Requirement','LOGON')
  90.    end
  91.  
  92.  
  93.    when theopt="LOGON_FAIL_FILE" then do
  94.       aval='LOGFAIL.HTM'
  95.       if arglist.!yesno=0 then aval='0'
  96.       foo=change_initfilt(theopt,aval)
  97.       wow=change_okay(foo,'Use Logon-Failure Response File ','LOGON')
  98.    end
  99.  
  100.    when theopt="ALLOW_ACCESS" then do
  101.       aval='YES'
  102.       if arglist.!yesno=1 then aval='INHOUSE'
  103.       foo=change_initfilt(theopt,aval)
  104.       wow=change_okay(foo,'Check SEL-specific Access Controls  ','ACCESS')
  105.    end
  106.  
  107.   when theopt="DO_HTACCESS" then do
  108.       aval='YES'
  109.       if arglist.!yesno=0 then aval='NO'
  110.       foo=chanfge_initfilt(theopt,aval)
  111.       wow=change_okay(foo,'Enable HTACCESS Method','ACCESS')
  112.   end
  113.  
  114.    when theopt="ACCESS_FAIL_FILE" then do
  115.       aval='ACCFAIL.HTM'
  116.       if arglist.!yesno=0 then aval='0'
  117.       foo=change_initfilt(theopt,aval)
  118.       wow=change_okay(foo,'Use Access-Failure Response File ','ACCESS')
  119.    end
  120.  
  121.  
  122.    when theopt="THE_REALM" then do
  123.       aval=arglist.!thevalue
  124.       aval=translate(aval,' ','+'||'00090a0d'x)
  125.       aval=packur(aval)
  126.       foo=change_initfilt(theopt,aval)
  127.       wow=change_okay(foo,'Default Realm ','NAMES')
  128.   end
  129.  
  130.    when theopt="HOME_NAME" then do
  131.       aval=arglist.!thevalue
  132.       aval=translate(aval,' ','+'||'00090a0d'x)
  133.       aval=packur(aval)
  134.       foo=change_initfilt(theopt,aval)
  135.       wow=change_okay(foo,'Colloquial Name of Site ','NAMES')
  136.   end
  137.  
  138.    when theopt="INDEX" then do
  139.       aval=arglist.!thevalue
  140.       if upper(aval)="OTHER"  then aval=arglist.!ownvalue
  141.       aval=packur(aval)
  142.       foo=change_initfilt(theopt,aval)
  143.       wow=change_okay(foo,'Default Document ','DEFAULT')
  144.   end
  145.  
  146.    when theopt="AUTO_NAME" then do
  147.       mkit=" "
  148.       if symbol('arglist.!thevalue1')='VAR' then mkit=mkit||' INDEX.HTM '
  149.       if symbol('arglist.!thevalue1a')='VAR' then mkit=mkit||' INDEX.SHT '
  150.  
  151.       if symbol('arglist.!thevalue2')='VAR' then mkit=mkit||' INDEX.HTML '
  152.       if symbol('arglist.!thevalue2a')='VAR' then mkit=mkit||' INDEX.SHTML '
  153.  
  154.       if symbol('arglist.!thevalue3')='VAR' then mkit=mkit||' *.HTM '
  155.       if symbol('arglist.!thevalue4')='VAR' then mkit=mkit||' *.HTML '
  156.       if symbol('arglist.!thevalue3a')='VAR' then mkit=mkit||' *.SHT '
  157.       if symbol('arglist.!thevalue4a')='VAR' then mkit=mkit||' *.SHTML '
  158.  
  159.       if symbol('arglist.!thevalue5')='VAR' then do
  160.             foo=translate(arglist.!thevalue5,' ','+')
  161.             mkit=mkit||' '||foo
  162.       end
  163.       if symbol('arglist.!thevalue6')='VAR' then  mkit=mkit||' !DIR  '
  164.       if symbol('arglist.!thevalue6a')='VAR' then do /* autodesecirbe */
  165.           diro=get_value('DIR_OPTIONS')
  166.           oo="" ; gota=0
  167.           do until diro=""
  168.               parse var diro v1 diro
  169.               if abbrev(upper(v1),'AUTO_DESCRIBE')=1 then do
  170.                  oo=oo||' '||'AUTO_DESCRIBE='||arglist.!thevalue6a||' '
  171.                  gota=1
  172.               end
  173.               else do
  174.                  oo=oo||' '||v1
  175.              end
  176.           end
  177.           if gota=0 then do
  178.                  oo=oo||' '||'AUTO_DESCRIBE='||arglist.!thevalue6a||' '
  179.           end  /* Do */
  180.           foo=change_initfilt('DIR_OPTIONS',oo)
  181.       end /* do */
  182.       foo=change_initfilt(theopt,mkit)
  183.       wow=change_okay(foo,' Directory Specific Default Document ','DIRS')
  184.   end
  185.  
  186.  when theopt="NOT_FOUND_URL" then do
  187.       aval=arglist.!thevalue
  188.       aval=translate(aval,' ','+'||'00090a0d'x)
  189.       aval=packur(aval)
  190.       foo=change_initfilt(theopt,aval)
  191.       wow=change_okay(foo,'Not Found Document Response ','DEFAULT')
  192.  end
  193.      
  194.    when theopt="HOME_DIR" then do
  195.       aval=arglist.!thevalue
  196.       aval=translate(aval,' ','+'||'00090a0d'x)
  197.       aval2=arglist.!thevalue2
  198.       aval2=translate(aval2,' ','+'||'00090a0d')
  199.       if aval2=' ' then do
  200.           mkit=aval
  201.       end
  202.       else do
  203.          mkit=translate(aval,'/','\')
  204.          mkit=strip(aval,'t','/')||'/$/'
  205.          AVAL2=translate(aval2,'/','\')
  206.          mkit=mkit||strip(aval2,'l','/')
  207.       end  /* Do */
  208.       foo=change_initfilt(theopt,mkit)
  209.       wow=change_okay(foo,'Home Directory','DIRS')
  210.   end
  211.  
  212.    when theopt="RECORD_OPTION" then do
  213.       aval='YES'
  214.       if arglist.!record=2 then aval='FILE'
  215.       if arglist.!record=0 then aval='NO'
  216.       foo=change_initfilt(theopt,aval)
  217.       wow=change_okay(foo,'Recording option ','RECORD')
  218.   end
  219.  
  220.  
  221.    when theopt="HIT_CACHE_LEN" then do
  222.       aval='500'
  223.       if arglist.!yesno=0 then aval=0
  224.       if arglist.!yesno=2  then aval='FILE'
  225.       foo=change_initfilt(theopt,aval)
  226.       wow=change_okay(foo,'Type of Repetitive Hits Cache','RECORD')
  227.   end
  228.  
  229.    when theopt="HIT_OWNER_SUPPRESS" then do
  230.       aval='YES'
  231.       if arglist.!yesno=0 then aval='NO'
  232.       foo=change_initfilt(theopt,aval)
  233.       wow=change_okay(foo,'Suppress Recording OWNER Requests','RECORD')
  234.    end
  235.  
  236.    when theopt="WRITE_LOGS" then do
  237.       aval='YES'
  238.       if arglist.!yesno=0 then aval='NO'
  239.       foo=change_initfilt(theopt,aval)
  240.       wow=change_okay(foo,'Enable Common-Log Audit File','RECORD')
  241.    end
  242.  
  243.  
  244.  
  245.   when theopt="SSI_SHTML_ONLY" then do
  246.       aval='YES'
  247.       if arglist.!yesno=0 then aval='NO'
  248.       foo=change_initfilt(theopt,aval)
  249.       wow=change_okay(foo,'SSI on SHTML Only','SSI')
  250.    end
  251.  
  252.   when theopt="SSI_CACHE_ON" then do
  253.       aval='YES'
  254.       if arglist.!yesno=0 then aval='NO'
  255.       foo=change_initfilt(theopt,aval)
  256.       wow=change_okay(foo,'SSI CACHE Enable','SSI')
  257.    end
  258.  
  259.  
  260.  when theopt="WEBMASTER" then do
  261.       aval=arglist.!thevalue
  262.       aval=translate(aval,' ','+'||'00090a0d'x)
  263.       aval=packur(aval)
  264.       foo=change_initfilt(theopt,aval)
  265.       wow=change_okay(foo,'WEBMASTER  ','SSI')
  266.  end
  267.  
  268.    when theopt="FIX_EXPIRE" then do
  269.       aval='0.05'
  270.       if arglist.!yesno=0 then aval=0
  271.       foo=change_initfilt(theopt,aval)
  272.       wow=change_okay(foo,'Suppress Immediate Expiration','MISC')
  273.   end
  274.  
  275.  when theopt="NO_SS" then do
  276.       no_ssi='NO'
  277.       if arglist.!no_ssi then no_ssi='YES'
  278.  
  279.       no_proc='NO' ; no_code='NO'
  280.       if arglist.!no_ssp=1 then no_proc='YES'
  281.       if arglist.!no_ssp=11 then   no_code='YES'
  282.  
  283.       foo1=change_initfilt('NO_INCLUDE',no_ssi)
  284.       foo2=change_initfilt('NO_PROCESSING',no_proc,1)
  285.       foo=change_initfilt('NO_INTERPRET_CODE',no_code,1)
  286.        wow=change_okay(foo,'Suppress SSP and SSI ','MISC')
  287.  
  288.  end  /* Do */
  289.  
  290.  
  291.  
  292.  when theopt="SMTP_GATEWAY" then do
  293.       aval=arglist.!thevalue
  294.       aval=translate(aval,' ','+'||'00090a0d'x)
  295.       aval=packur(word(aval,1))
  296.       foo=change_initfilt(theopt,aval)
  297.       wow=change_okay(foo,'SMTP_GATEWAY ','MISC')
  298.  end
  299.  
  300.  when theopt="HEADERS" then do
  301.   
  302. /* sepearte at crlfs */
  303.      ahead=packur(translate(arglist.!header,' ','+'))
  304.      afoot=packur(translate(arglist.!footer,' ','+'))
  305.      nhead=0
  306.      do until ahead=""
  307.         parse var ahead aline (crlf) ahead ; 
  308.         aline=strip(translate(aline,' ','000d0a'x))
  309.         if aline="" then iterate
  310.         nhead=nhead+1
  311.         headers.nhead=aline
  312.      end /* do */
  313.      nfoot=0
  314.      do until afoot=""
  315.         parse var afoot aline (crlf) afoot 
  316.         aline=strip(translate(aline,' ','000d0a'x))
  317.         if aline="" then iterate
  318.         nfoot=nfoot+1
  319.         footers.nfoot=aline
  320.      end /* do */
  321.      if nhead>0 then do
  322.          foo1=change_initfilt('HEADERS.1',headers.1)
  323.          do mm=2 to nhead
  324.              foo1=change_initfilt('HEADERS.'||mm,headers.mm,1)
  325.          end /* do */
  326.          nhead=nhead+1
  327.          foo=change_initfilt('HEADERS.'||nhead,0,1)
  328.      end
  329.      else do
  330.          nhead=1
  331.          foo=change_initfilt('HEADERS.1',0)
  332.      end
  333.      /* trash old headers */
  334.      foo1='1' ; joe=nhead
  335.      do until foo1<>'1'
  336.          joe=joe+1
  337.          foo1=change_initfilt('HEADERS.'||joe,,,1)
  338.      end /* do */
  339.      if nFOOT>0 then do
  340.          foo1=change_initfilt('FOOTERS.1',FOOTers.1,1)
  341.          do mm=2 to nFOOT
  342.              foo1=change_initfilt('FOOTERS.'||mm,FOOTers.mm,1)
  343.          end /* do */
  344.          nfoot=nfoot+1
  345.          foo=change_initfilt('FOOTERS.'||nFOOT,0,1)
  346.      end
  347.      else do
  348.          nfoot=1
  349.          foo=change_initfilt('FOOTERS.1',0,1)
  350.      end
  351.      foo1='1' ; joe=nfoot        /* remove old footers */
  352.      do until foo1<>'1'
  353.          joe=joe+1
  354.          foo1=change_initfilt('FOOTERS.'||joe,,,1)
  355.      end /* do */
  356.  
  357.      wow=change_okay(foo,'HEADER and FOOTER ','SSI')
  358.  end  /* Do */
  359.  
  360.  
  361.  when theopt="ADD_INHOUSE" then do
  362.     foo=strip(translate(arglist.!user,' ','+'))
  363.     foo2=strip(translate(arglist.!privs,' ','+'))
  364.     aval=word(foo,1)||' '||foo2
  365.     foo=change_stem('INHOUSEIPS.',aval)
  366.     wow=change_okay(foo,'Add an In-House User','LOGON')
  367.  end  /* Do */
  368.  
  369.  when theopt="ADD_HOST" then do
  370.     foo=strip(translate(arglist.!host,' ','+'))
  371.     foo2=strip(translate(arglist.!nickname,' ','+'))
  372.     foo3=packur(strip(translate(arglist.!datadir,' ','+')))
  373.     aval=word(foo,1)||', '||word(foo2,1)||', '||word(foo3,1)
  374.     foo=change_stem('HOSTS.',upper(aval))
  375.     wow=change_okay(foo,'Add a Host Identification','HOST')
  376.  end  /* Do */
  377.  
  378.  when theopt="REMOVE_INHOUSE" then do
  379.     remlist=make_removes()
  380.     foo=change_stem('INHOUSEIPS.',,upper(remlist))
  381.      foo1='1' ; joe=nkill       /* remove old footers */
  382.      do until foo1<>'1'
  383.          joe=joe+1
  384.          foo1=change_initfilt('INHOUSEIPS.'||joe,,,1)
  385.      end /* do */
  386.  
  387.     wow=change_okay(foo,'Remove In-House Users','LOGON',mess2)
  388.  end  /* Do */
  389.  
  390.  
  391.  when theopt="ADD_PUBLICURL2" then do   /* old version (initfilt.80) */
  392.     foo=strip(translate(arglist.!url,' ','+'))
  393.     isliteral=0 ; norecord=0
  394.     if symbol('ARGLIST.!LITERAL')='VAR' then 
  395.         isliteral=arglist.!literal
  396.     if symbol('ARGLIST.!NORECORD')='VAR' then 
  397.        norecord=arglist.!norecord
  398.     select
  399.        when isliteral=1 & norecord=1 then   foo2='LITERAL_NORECORD'
  400.        when isliteral=1 then foo2='LITERAL'
  401.        when norecord=1 then foo2='NORECORD'
  402.        otherwise foo2=' '
  403.     end
  404.     aval=word(foo,1)||' '||foo2
  405.     foo=change_stem('PUBLIC_URLS.',aval)
  406.     wow=change_okay(foo,'Add PUBLIC Area Identifier','PUBLICURL')
  407.  end  /* Do */
  408.  
  409.  
  410.  when theopt="REMOVE_PUBLICURL2" then do  /* old (initfilt.80) version */
  411.     remlist=make_removes()
  412.     foo=change_stem('PUBLIC_URLS.',,upper(remlist))
  413.     foo1='1' ; joe=inlist       /* remove old footers */
  414.     do until foo1<>'1'
  415.          joe=joe+1
  416.          foo1=change_initfilt('PUBLIC_URLS.'||joe,,,1)
  417.     end /* do */
  418.  
  419.     wow=change_okay(foo,'Remove PUBLIC Areas Identifier','PUBLICURL',mess2)
  420.  end  /* Do */
  421.  
  422.  
  423.  
  424.  
  425.  when theopt="REMOVE_HOST" then do
  426.     remlist=make_removes()
  427.     foo=change_stem('HOSTS.',,upper(remlist))
  428.     wow=change_okay(foo,'Remove Host Identification Entries','HOST',mess2)
  429.  end  /* Do */
  430.  
  431.  when theopt="ADD_USER" then do
  432.      foo1=translate(upper(strip(arglist.!user)),' ','+')
  433.      foo1=word(foo1,1)
  434.      foo2=translate(upper(strip(arglist.!pwd)),' ','+')
  435.      foo2=word(foo2,1)
  436.      foo3=translate(upper(strip(arglist.!privs)),' ','+')
  437.      if foo3=' 'then foo3='NEWUSER'
  438.      aval=foo1' 'foo2' 'foo3
  439.     foo=change_file('USER_FILE',aval)
  440.     wow=change_okay(foo,'Add Users','LOGON')
  441.  end  /* Do */
  442.  
  443.  when theopt="REMOVE_USER" then do
  444.     remlist=make_removes()
  445.     foo=change_file('USER_FILE',,upper(remlist))
  446.     wow=change_okay(foo,'Remove Users','LOGON',mess2)
  447.  end  /* Do */
  448.  
  449.  when theopt="ADD_ACCESS" then do
  450.     plist=' '
  451.     tenp='NO_SSI YES_SSI NO_CODE NO_SSP CACHE PUT DELETE NO_HTACCESS NO_VIRTUAL NO_ALIAS NO_POSTFILTER'
  452.     do po=1 to 10
  453.         axx=strip(word(tenp,po))
  454.         if symbol('ARGLIST.!'||axx)="VAR" then do
  455.              plist=plist||' '||axx
  456.         end  /* Do */
  457.     end /* do */
  458.     foo1=translate(upper(strip(arglist.!url)),' ','+')
  459.     foo1=word(foo1,1)
  460.     foo2=translate(upper(strip(arglist.!privs)),' ','+')
  461.     if foo2=' ' then foo2='*'
  462.     foo3=translate(upper(strip(arglist.!realm)),' ','+')
  463.     foo4=translate(upper(strip(arglist.!failfile)),' ','+')
  464.      aval=foo1' 'foo2' , ' plist ' , 'foo3' , ' foo4
  465.     foo=change_file('ACCESS_FILE',aval)
  466.     wow=change_okay(foo,'Add Access Control Entry','ACCESS')
  467.  end  /* Do */
  468.  
  469.  
  470.  
  471.  
  472.  when theopt="DEFAULT_ACCESS" then do
  473.      foo1=translate(upper(strip(arglist.!defprivs)),' ','+')
  474.      if foo1=' ' then foo1='*'
  475.      aval='/* '||foo1
  476.     foo=change_file('ACCESS_FILE',aval,'/* ')
  477.     wow=change_okay(foo,'Change Default Access Control Entry','ACCESS')
  478.  end  /* Do */
  479.  
  480.  
  481.  when theopt="REMOVE_ACCESS" then do
  482.     remlist=make_removes()
  483.     foo=change_file('ACCESS_FILE',,upper(remlist))
  484.     wow=change_okay(foo,'Remove Access Control Entry','ACCESS',mess2)
  485.  end  
  486.  
  487.  when theopt="ADD_VIRTUAL" then do
  488.      foo1=translate(upper(strip(arglist.!url)),' ','+')
  489.      foo1=word(foo1,1)
  490.      foo2=translate(upper(strip(arglist.!directory)),' ','+')
  491.      foo2=word(foo2,1)
  492.      foo2=translate(foo2,'\','/')
  493.      foo2=strip(foo2,'t','\')||'\* '
  494.      aval=foo1' 'foo2
  495.     foo=change_file('VIRTUAL_FILE',aval,,,1)
  496.     wow=change_okay(foo,'Add Virtual Directory Entry','DIRS')
  497.  end  
  498.  
  499.  when theopt="REMOVE_VIRTUAL" then do
  500.     remlist=make_removes()
  501.     foo=change_file('VIRTUAL_FILE',,upper(remlist))
  502.     wow=change_okay(foo,'Remove Virtual Directory  Entry','DIRS',mess2)
  503.  end  
  504.  
  505.  
  506.  when theopt="ADD_REDIRECT" then do
  507.      foo1=translate(upper(strip(arglist.!url)),' ','+')
  508.      foo1=word(foo1,1)
  509.      foo2=translate(strip(arglist.!newurl),' ','+')
  510.      foo2=word(foo2,1)
  511.      aval=foo1' 'foo2
  512.     foo=change_file('ALIAS_FILE',aval)
  513.     wow=change_okay(foo,'Add  Redirection Alias Entry','DIRS')
  514.  end  
  515.  
  516.  when theopt="REMOVE_REDIRECT" then do
  517.     remlist=make_removes()
  518.     foo=change_file('ALIAS_FILE',,upper(remlist))
  519.     wow=change_okay(foo,'Remove Redirection-Alias Entry','DIRS',mess2)
  520.  end  
  521.  
  522.  
  523.  when theopt="ADD_PUBLICURL" then do
  524.      foo1=translate(upper(strip(arglist.!url)),' ','+')
  525.  
  526.    foo1=word(foo1,1)
  527.  
  528.     isliteral=0 ; norecord=0
  529.     if symbol('ARGLIST.!LITERAL')='VAR' then 
  530.         isliteral=arglist.!literal
  531.     if symbol('ARGLIST.!NORECORD')='VAR' then 
  532.        norecord=arglist.!norecord
  533.     select
  534.        when isliteral=1 & norecord=1 then   foo2='LITERAL_NORECORD'
  535.        when isliteral=1 then foo2='LITERAL'
  536.        when norecord=1 then foo2='NORECORD'
  537.        otherwise foo2=' '
  538.     end
  539.     aval=foo1||' '||foo2
  540.  
  541.  
  542.  
  543.     foo=change_file('PUBURL_FILE',aval)
  544.     wow=change_okay(foo,'Add  Public Area (URL) Entry','DIRS')
  545.  end  
  546.  
  547.  when theopt="REMOVE_PUBLICURL" then do
  548.     remlist=make_removes()
  549.     foo=change_file('PUBURL_FILE',,upper(remlist))
  550.     wow=change_okay(foo,'Remove Public Area (PUBLIC_URL) Entry','DIRS',mess2)
  551.  end  
  552.  
  553.  when theopt="ADD_CUSTOM" then do
  554.      foo1=translate(upper(strip(arglist.!variable)),' ','+')
  555.      foo1=word(foo1,1)
  556.      foo2=packur(translate(strip(arglist.!value),' ','+'))
  557.      if host_nickname<>' ' then foo1=foo1||'.'||host_nickname
  558.      aval=foo1' 'foo2
  559.      took=host_nickname
  560.      host_nickname=' '
  561.     foo=change_file('REPSTRGS_FILE',aval)
  562.     host_nickname=took
  563.  
  564.     wow=change_okay(foo,'Add  Custom Replacement Variable','SSI')
  565.  
  566.  end  
  567.  
  568.  when theopt="REMOVE_CUSTOM" then do
  569.     remlist=make_removes()
  570.     took=host_nickname
  571.     if host_nickname<>' ' then do
  572.        arf=""
  573.        do until remlist=""
  574.           parse var remlist a1 remlist
  575.           a1=strip(a1)||'.'||host_nickname||' '
  576.        end
  577.        remlist=a1
  578.     end /* do */
  579.     host_nickname=' '
  580.     foo=change_file('REPSTRGS_FILE',,upper(remlist),,,1)
  581.     host_nickname=took
  582.  
  583.     wow=change_okay(foo,'Remove Redirection Alias  Entry','SSI',mess2)
  584.  end  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  otherwise do
  591.       string ' Modification n.a. for ' theopt
  592.       redo=0 ; wow='200 40 '
  593.  end
  594.  
  595.  
  596. end  /* select */
  597.  
  598. /* signal srefmon to refresh values ? */
  599. if redo=1 then  foo=value('SREF_REDO',1,'os2environment')
  600.  
  601.  
  602. return wow
  603.  
  604. /****************************/
  605. /* make a "removes" list from arglist.!delete.n entres */
  606. make_removes:procedure expose arglist.
  607.  
  608. ndo=arglist.!entries
  609. arf=""
  610. do mm =1 to ndo
  611.    aa='!DELETE.'||mm
  612.    oo=symbol('ARGLIST.'||aa)
  613.    if oo<>'VAR' then iterate
  614.    arf=arf||' '||arglist.aa
  615. end
  616. return arf
  617.  
  618.  
  619. /****************************/
  620. /* modify a parameter in the initfilt file */
  621.  
  622. change_initfilt:procedure expose  verbose servername enmadd host_nickname  basedir initfile
  623. parse arg aopt,aval0,noupdate,noadd
  624. aopt=strip(upper(aopt)); aval0=strip(aval0)
  625. if noupdate=' ' then noupdate=0
  626. if noadd=' ' then noadd=0
  627. foo=sref_fileread(initfile,dalines,,'E')
  628. if dalines.0=0 then return 'Could not read:'||initfile
  629.  
  630. aval0=sref_replacestrg(aval0,"'","''",'ALL')
  631.  
  632. foundit=0
  633.  
  634.  
  635. /* scan through, looking for parameter that matches aopt.
  636. Also, must be same host nickname.  Retain all non matches in 
  637. same order. If match, delete, and rewrite at end of file.
  638. Copy old file to xxx.BAK (overwrite old xxx.bak if it exists) */
  639.  
  640. inew=0
  641. do mm=1 to dalines.0
  642.    aline=strip(upper(dalines.mm))
  643.    if aline=" " | abbrev(aline,';')=1 then do /* retain comments */
  644.        inew=inew+1
  645.        newlines.inew=dalines.mm
  646.        iterate
  647.    end
  648.    if abbrev(aline,aopt)=0 then do  /* non match, retain */
  649.        inew=inew+1
  650.        newlines.inew=dalines.mm
  651.        iterate
  652.    end
  653. /* correct name, but is it correct host */
  654.    parse var aline avar '=' aval
  655.    avar=translate(avar,' ','.')
  656.    nw=words(avar)
  657.    if host_nickname<>' ' then do  /* see if it matches this host nickname */
  658.      if nw=1  then do /* no host nickname, can't match */
  659.           inew=inew+1
  660.           newlines.inew=dalines.mm
  661.           iterate
  662.       end
  663.       if strip(upper(word(avar,nw)))<>host_nickname then do /* does not match this host */
  664.           inew=inew+1
  665.           newlines.inew=dalines.mm
  666.           iterate
  667.       end
  668.    end
  669.    else do              /* generic site */
  670.        if nw>1 &  datatype(word(avar,nw))<>'NUM' then do /* host specific parameter */
  671.           inew=inew+1
  672.           newlines.inew=dalines.mm
  673.           iterate
  674.        end
  675.    end
  676. /* if here, a match. so skip it (and rewrite at end of list */
  677.    foundit=1
  678.  
  679. end
  680.  
  681. /* if nosuch paramter, and noadd mode, return */
  682. if noadd=1 & foundit=0 then return 0  /* signal no more */
  683.  
  684. if noadd=0 then do      /* add new value, if noadd=0 */
  685.   inew=inew+1
  686.   if host_nickname<>' ' then
  687.       isvar=aopt||'.'||host_nickname
  688.   else
  689.      isvar=aopt
  690.    newlines.inew=isvar||"='"||aval0||"'"
  691. end
  692. newlines.0=inew
  693.  
  694.  
  695. if noupdate<>1 then do
  696.    bakfile=initfile                /* create a .bak file */
  697.    foo=lastpos('.',bakfile)
  698.    if foo=0  then
  699.       bakfile=bakfile||'.bak'
  700.    else
  701.       bakfile=delstr(bakfile,foo)||'.bak'
  702.    wow=doscopy(initfile,bakfile,'R')
  703.    if wow<>0 then do
  704.       say " ERROR: backup copy could not be made, error code  " wow
  705.       return 'Backup copy could not be made'
  706.   end  /* Do */
  707. end
  708.  
  709. /* now write new results */
  710. foo=sref_filewrite(initfile,newlines,'R')
  711.  
  712. if foo=0 then  return 'Could not save parameters file '  
  713. return 1  /* success */
  714.  
  715.  
  716.  
  717.  
  718. /****************************/
  719. /* modify a parameter in the initfilt file */
  720.  
  721. change_stem:procedure expose  verbose servername enmadd host_nickname  basedir initfile mess2 inlist nkill
  722. parse arg lookfor, newval,remlist
  723.  
  724. foo=sref_fileread(initfile,dalines,,'E')
  725. if dalines.0=0 then return 'Could not read:'||initfile
  726. nkill=0
  727.  
  728. /* scan through, looking for inhouseips or other stem  parameters,
  729. of the appropriate host.  Pull them, and add or remove
  730. */
  731.  
  732. inew=0
  733. ninh=0
  734. do mm=1 to dalines.0
  735.    aline=strip(upper(dalines.mm))
  736.    if aline=" " | abbrev(aline,';')=1 then do /* retain comments */
  737.        inew=inew+1
  738.        newlines.inew=dalines.mm
  739.        iterate
  740.    end
  741.    if abbrev(aline,lookfor)=0 then do  /* non match, retain */
  742.        inew=inew+1
  743.        newlines.inew=dalines.mm
  744.        iterate
  745.    end
  746.  
  747. /* correct name, but is it correct host */
  748.    parse var aline avar '=' aval
  749.    avar=translate(avar,' ','.')
  750.    nw=words(avar)
  751.    if host_nickname<>' ' then do  /* see if it matches this host nickname */
  752.       if strip(upper(word(avar,nw)))<>host_nickname then do /* does not match this host */
  753.           inew=inew+1
  754.           newlines.inew=dalines.mm
  755.           iterate
  756.       end
  757.    end
  758.    else do              /* generic site */
  759.        if datatype(word(avar,nw))<>'NUM' then do /* host specific parameter */
  760.           inew=inew+1
  761.           newlines.inew=dalines.mm
  762.           iterate
  763.        end
  764.    end
  765.  
  766. /* if here, a match. If remlist=' ', then temp record and  skip it (and rewrite at end of list
  767.    of remlist<>' ', then keep only if not in remlist */
  768.    aval=strip(strip(aval),,'"')
  769.    aval=strip(aval,,"'")
  770.    if aval=0 | aval=" " then iterate /* ignore end flags */
  771.    if remlist<>' ' then do
  772.        w1=upper(strip(word(translate(aval,' ',','),1)))
  773.        if wordpos(w1,remlist)>0  then do 
  774.           nkill=nkill+1
  775.           iterate
  776.        end  /* Do */
  777.    end
  778.    ninh=ninh+1   /* else, keep it*/
  779.    inhs.ninh=aval
  780. end
  781.  
  782. if newval<>' ' then do /* add the new one */
  783.    ninh=ninh+1
  784.    inhs.ninh=newval
  785. end
  786.  
  787. /* fix up form to save */
  788. do ii=1 to ninh
  789.  if host_nickname<>' ' then do
  790.      bval=inhs.ii
  791.      inhs.ii=lookfor||ii||'.'||host_nickname||"='"||bval||"'"
  792.   end /* do */
  793.   else do
  794.      bval=inhs.ii
  795.      inhs.ii=lookfor||ii||"='"||bval||"'"
  796.   end  /* Do */
  797. end
  798. ninh=ninh+1
  799. if host_nickname<>' ' then do
  800.   inhs.ninh=lookfor||host_nickname||'.'||ninh||'=0'
  801. end
  802. else do
  803.   inhs.ninh=lookfor||ninh||'=0'
  804. end
  805.  
  806. do mm=1 to ninh
  807.    inew=inew+1
  808.    newlines.inew=inhs.mm
  809. end /* do */
  810.  
  811. newlines.0=inew
  812.  
  813. if noupdate<>1 then do
  814.    bakfile=initfile                /* create a .bak file */
  815.    foo=lastpos('.',bakfile)
  816.    if foo=0  then
  817.       bakfile=bakfile||'.bak'
  818.    else
  819.       bakfile=delstr(bakfile,foo)||'.bak'
  820.    wow=doscopy(initfile,bakfile,'R')
  821.    if wow<>0 then do
  822.       say " ERROR: backup copy could not be made, error code  " wow
  823.       return 'Backup copy could not be made'
  824.   end  /* Do */
  825. end
  826.  
  827. /* now write new results */
  828. foo=sref_filewrite(initfile,newlines,'R')
  829.  
  830. if foo=0 then  return 'Could not save parameters file '  
  831.  
  832. mess2=' Number entries deleted: '||nkill
  833. inlist=ninh
  834. return 1  /* success */
  835.  
  836.  
  837.  
  838.  
  839. /****************************/
  840. /* tell client status of parameter change */
  841. change_okay:procedure expose tempfile 
  842. parse arg status,whatis,jumpto,mess2
  843. if status<>1 then
  844.   text='Problem modifying: '||whatis
  845. else
  846.   text='Success modifying: '||whatis
  847.  
  848.  call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  849.  call lineout tempfile, "<html><head><title>"text"</title></head><body>"
  850.  if status=1 then do
  851.    call lineout tempfile,' <h2> ' whatis ' :: sucessfully modified </h2> '
  852.    call lineout tempfile,' Modification will take effect in approximately 15 seconds '
  853.  if mess2<>' ' then call lineout tempfile,'<br>  <em> ' mess2 '</em> '
  854.  end
  855.  else do
  856.    call lineout tempfile,' <h2>Sorry,  ' whatis ' could not be modified </h2> '
  857.    call lineout tempfile,' Problem: ' status
  858.  end
  859.  call lineout tempfile,'<hr> <a href="/config0.htm#'jumpto'">Return to simple configurator </a>'
  860.  call lineout tempfile, '</body><html>'
  861.  call lineout tempfile
  862. oof=dosdir(tempfile,'s')
  863.  foo=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  864.  return '200 '||oof
  865.  
  866.  
  867. /****************************/
  868. /* Load, modify, and return a parameter modification form */
  869. /* uses templates in the config_dir directory */
  870. show_it:procedure expose ddir optlist verbose servername enmadd host_nickname  basedir tempfile usecolor 
  871. parse upper  arg theopt
  872. crlf='0d0a'x
  873.  
  874. ok=0
  875. ddir=strip(translate(ddir,'\','/'),'t','\')||'\'
  876. workdata=get_value('workdata_dir')
  877.  
  878. thedir=get_value('CONFIG_DIR')
  879. if thedir=' ' then
  880.    thedir=ddir||'CONFIGS'
  881.  
  882. if dosisdir(thedir)=0 then do
  883.    'STRING Bad Setup: no CONFIG_DIR directory: ' thedir
  884.    return 0
  885. end  /* Do */
  886.  
  887. if wordpos(theopt,optlist)=0 then do
  888.   foo=sref_response('badreq',' You selected an unknown CONFIGURE parameter ',servername)
  889.   return 0
  890. end    
  891.  
  892. /* grab a file, and modify it, based on theopt */
  893. select
  894.  when theopt='ADD_HOST' then do
  895.      ok=GET_IT('ADDHOST')
  896.      ok=make_doc(theopt,1,'HOST')
  897.  end    
  898.  
  899.  when theopt='REMOVE_HOST' then do
  900.     ok=GET_IT('REMHOST')
  901.     foo=make_hosts('initfilt_file')
  902.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  903.     foo=get_value('initfilt_file')
  904.     stuff=a_replacestrg(stuff,'$initfilt_file',foo,'ALL')
  905.     ok=make_doc(theopt,1,'HOST')
  906.  end    
  907.  
  908.  when theopt='CHECKLOG' then do
  909.       ok=GET_IT('CHECKLOG')
  910.       ok=do_yesno('CHECKLOG','N','YES Y 1 ALWAYS INHOUSE ')
  911.       ok=make_doc(theopt,0,'LOGON')
  912.  end    
  913.  
  914.  
  915.  
  916.  when theopt='LOGON_FAIL_FILE' then do
  917.       ok=GET_IT('LOGFAIL')
  918.       ok=do_yesno('LOGON_FAIL_FILE','Y')
  919.       stuff=a_replacestrg(stuff,'$SERVDIR',basedir,'ALL')
  920.       ok=make_doc(theopt,0,'LOGON')
  921.  end    
  922.  
  923.  when theopt='ADD_USER' then do
  924.       ok=GET_IT('ADDUSER')
  925.       foo=get_value('USER_FILE')
  926.       stuff=a_replacestrg(stuff,'$USER_FILE',foo,'ALL')
  927.       ok=make_doc(theopt,0,'LOGON')
  928.  end    
  929.  
  930.  when theopt='REMOVE_USER' then do
  931.     ok=GET_IT('REMUSER')
  932.     foo=make_users('USER_FILE')
  933.     if foo=0 then return 0
  934.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  935.     foo=get_value('user_file')
  936.     stuff=a_replacestrg(stuff,'$user_file',foo,'ALL')
  937.     ok=make_doc(theopt,0,'LOGON')
  938.  end    
  939.  
  940.  when theopt='ADD_INHOUSE' then do
  941.      ok=GET_IT('ADDINH')
  942.       foo=get_value('USER_FILE')
  943.       stuff=a_replacestrg(stuff,'$USER_FILE',foo,'ALL')
  944.       ok=make_doc(theopt,0,'LOGON')
  945.  end    
  946.  
  947.  when theopt='REMOVE_INHOUSE' then do
  948.      ok=GET_IT('REMINH')
  949.      foo=make_inhouseips('initfilt_file')
  950.      if foo=0 then return 0
  951.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  952.     foo=get_value('initfilt_file')
  953.     stuff=a_replacestrg(stuff,'$initfilt_file',foo,'ALL')
  954.  
  955.     ok=make_doc(theopt,0,'LOGON')
  956.  end    
  957.  
  958.  when theopt='ADD_PUBLICURL2' then do  /* old (initfilt.80) version */
  959.       ok=GET_IT('ADDPURL')
  960.       stuff=a_replacestrg(stuff,'$DATADIR',ddir,'ALL')
  961.       foo=get_value('puburl_file')
  962.       stuff=a_replacestrg(stuff,'$puburl_file',foo,'ALL')
  963.       stuff=a_replacestrg(stuff,'$DATADIR',ddir,'ALL')
  964.       ok=make_doc(theopt,0,'PUBLICURL')
  965.  end    
  966.  
  967.  when theopt='REMOVE_PUBLICURL2' then do    /* old (initfilt.80) version */
  968.      ok=GET_IT('REMPURL')
  969.      foo=make_puburls('puburls_file')
  970.     if foo=0 then return 0
  971.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  972.     foo=get_value('initfilt_file')
  973.     stuff=a_replacestrg(stuff,'$initfilt_file',foo,'ALL')
  974.     ok=make_doc(theopt,0,'PUBLICURL')
  975.  end    
  976.  
  977.  when theopt='ALLOW_ACCESS' then do
  978.       ok=GET_IT('ALLOWAC')
  979.       ok=do_yesno('ALLOW_ACCESS','Y','Y YES 1','NO INHOUSE ')
  980.       ok=make_doc(theopt,0,'ACCESS')
  981.  end    
  982.  
  983.  
  984.  when theopt='DO_HTACCESS' then do
  985.       ok=GET_IT('HTACCESS')
  986.       ok=do_yesno('DO_HTACCESS','N')
  987.       ok=make_doc(theopt,0,'ACCESS')
  988.  end    
  989.  
  990.  
  991.  when theopt='ACCESS_FAIL_FILE' then do
  992.       ok=GET_IT('ACCFAIL')
  993.       ok=do_yesno('ACCESS_FAIL_FILE','Y')
  994.       stuff=a_replacestrg(stuff,'$SERVDIR',basedir,'ALL')
  995.       ok=make_doc(theopt,0,'ACCESS')
  996.  end    
  997.  
  998.  when theopt='ADD_ACCESS' then do
  999.       ok=GET_IT('ADDACC')
  1000.       foo=get_value('ACCESS_FILE')
  1001.       stuff=a_replacestrg(stuff,'$ACCESS_FILE',foo,'ALL')
  1002.       ok=make_doc(theopt,0,'ACCESS')
  1003.  end    
  1004.  
  1005.  
  1006.  when theopt='REMOVE_ACCESS' then do
  1007.     ok=GET_IT('REMACC')
  1008.     foo=make_access('ACCESS_FILE')
  1009.     if foo=0 then return 0
  1010.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  1011.     foo=get_value('access_file')
  1012.     stuff=a_replacestrg(stuff,'$ACCESS_FILE',foo,'ALL')
  1013.     ok=make_doc(theopt,0,'ACCESS')
  1014.  end    
  1015.  
  1016.  when theopt='DEFAULT_ACCESS' then do
  1017.     ok=GET_IT('DEFACC')
  1018.     foo=make_access('ACCESS_FILE',1)
  1019.    if foo=0 then return 0
  1020.     stuff=a_replacestrg(stuff,'$default_access',stuff2,'ALL')
  1021.     foo=get_value('access_file')
  1022.     stuff=a_replacestrg(stuff,'$ACCESS_FILE',foo,'ALL')
  1023.     ok=make_doc(theopt,0,'ACCESS')
  1024.  end    
  1025.  
  1026.  
  1027.  
  1028.  WHEN THEOPT="INDEX" then DO
  1029.      ok=get_it('DEFAULT')
  1030.      adef=strip(upper(get_value('DEFAULT')))
  1031.      select
  1032.        when adef="INDEX.HTM" then do
  1033.           adef1='CHECKED' ; adef2=' ' ; adef3=' ' ;afile=' '
  1034.        end  /* Do */
  1035.        when adef="INDEX.HTML" then do
  1036.          adef1=' ' ; adef2='CHECKED' ; adef3=' '; afile=' '
  1037.        end  /* Do */
  1038.        otherwise do
  1039.          adef1=' ' ; adef2=' ' ; adef3='CHECKED' ; afile=adef
  1040.        end
  1041.       end
  1042.       stuff=a_replacestrg(stuff,'$HTMINDEX',adef1,'ALL')
  1043.       stuff=a_replacestrg(stuff,'$HTMLINDEX',adef2,'ALL')
  1044.       stuff=a_replacestrg(stuff,'$INDEXOTHER',adef3,'ALL')
  1045.       stuff=a_replacestrg(stuff,'$INDEXfile',afile,'ALL')
  1046.       stuff=a_replacestrg(stuff,'$DATADIR',ddir,'ALL')
  1047.      ok=make_doc(theopt,0,'DEFAULT')
  1048.  end  /* Do */
  1049.  
  1050.  when theopt='AUTO_NAME' then do
  1051.    ok=get_it('autoname')
  1052.    adef=strip(upper(get_value('AUTO_NAME'))) 
  1053.    oks='INDEX.HTM INDEX.HTML  *.HTM  *.HTML  !CREATE !DIR '
  1054.    oks=oks||' INDEX.SHT INDEX.SHTML *.SHT *.SHTML'
  1055.    oks2='$htmindex $htmlindex $htmdirname $htmldirname $createdir $dir_dir '
  1056.    oks2=oks2||' $shtmindex $shtmlindex  $shtmdirname $shtmldirname '
  1057.    other=""
  1058.    do mm=1 to words(oks)
  1059.       a1=strip(word(oks,mm))
  1060.       ado=strip(word(oks2,mm))
  1061.       tt=1 ;ith=0
  1062.       do until tt=0
  1063.         tt=wordpos(a1,adef)
  1064.         if tt=0 then leave
  1065.         adef1='checked'
  1066.         adef=delword(adef,tt,1) 
  1067.         ith=ith+1
  1068.         if ith=1 then stuff=a_replacestrg(stuff,ado,adef1,'ALL')
  1069.       end
  1070.    end
  1071.    stuff=a_replacestrg(stuff,'$other',adef,'ALL')
  1072.  
  1073.    ok=strip(upper(get_value('DIR_OPTIONS')))
  1074.    autodno='checked' ; autodyes=' '
  1075.    if (wordpos('AUTO_DESCRIBE',ok)+wordpos('AUTO_DESCRIBE=1',ok))>0 then do
  1076.           autodno=' '; autodyes='checked'; 
  1077.    end
  1078.    stuff=a_replacestrg(stuff,'$AUTODNO',autodno,'ALL')
  1079.    stuff=a_replacestrg(stuff,'$AUTODYES',autodyes,'ALL')
  1080.  
  1081.    ok=make_doc(theopt,0,'DEFAULT')
  1082.  end    
  1083.  
  1084.  when theopt='NOT_FOUND_URL' then do
  1085.     ok=GET_IT('notfound')
  1086.     tt=get_value('NOT_FOUND_URL')
  1087.     tt=a_replacestrg(tt,'<','<','ALL')
  1088.     tt=a_replacestrg(tt,'>','>','ALL')
  1089.     tt=a_replacestrg(tt,'"','"','ALL')
  1090.     stuff=a_replacestrg(stuff,'$not_found_url',tt,'ALL')
  1091.     ok=make_doc(theopt,0,'DEFAULT')
  1092.  end    
  1093.  
  1094.  when theopt='THE_REALM' then do
  1095.     ok=GET_IT('realmnam')
  1096.     tt=get_value('THE_REALM')
  1097.     stuff=a_replacestrg(stuff,'$therealm',tt,'ALL')
  1098.     ok=make_doc(theopt,0,'NAMES')
  1099.  end    
  1100.  
  1101.  when theopt='HOME_NAME' then do
  1102.     ok=GET_IT('homename')
  1103.     tt=get_value('HOME_NAME')
  1104.     stuff=a_replacestrg(stuff,'$home_name',tt,'ALL')
  1105.     ok=make_doc(theopt,0,'NAMES')
  1106.  end    
  1107.  
  1108.  when theopt='HOME_DIR' then do
  1109.     ok=GET_IT('homedir')
  1110.     tt=get_value('HOME_DIR',0,'DIRS')
  1111.     ms=pos('$',tt)
  1112.     if ms=0 then do
  1113.        hd1=tt ; hd2=' '
  1114.     end  /* Do */
  1115.     else do
  1116.        hd1=substr(tt,1,ms-1) ;hd2=substr(tt,ms+2)
  1117.     end  /* Do */
  1118.  
  1119.     stuff=a_replacestrg(stuff,'$home_DIR',hd1,'ALL')
  1120.     stuff=a_replacestrg(stuff,'$home_subDIR',hd2,'ALL')
  1121.  
  1122.     ok=make_doc(theopt,0,'DIRS')
  1123.  end    
  1124.  
  1125.  when theopt='ADD_VIRTUAL' then do
  1126.       ok=GET_IT('ADDVIRT')
  1127.       foo=get_value('VIRTUAL_FILE')
  1128.       stuff=a_replacestrg(stuff,'$VIRTUAL_FILE',foo,'ALL')
  1129.       stuff=a_replacestrg(stuff,'$DATADIR',ddir,'ALL')
  1130.       stuff=a_replacestrg(stuff,'$SERVDrive',filespec('d',basedir),'ALL')
  1131.       stuff=a_replacestrg(stuff,'$SERVDir',basedir,'ALL')
  1132.       foo=get_value('CGI_BIN_DIR')
  1133.       stuff=a_replacestrg(stuff,'$cgi_bin_dir',foo,'ALL')
  1134.       foo=get_value('ADDON_DIR')
  1135.       stuff=a_replacestrg(stuff,'$addon_dir',foo,'ALL')
  1136.       foo=get_value('UPLOAD_DIR')
  1137.       stuff=a_replacestrg(stuff,'$upload_dir',foo,'ALL')
  1138.  
  1139.       ok=make_doc(theopt,0,'DIRS')
  1140.  end    
  1141.  
  1142.  when theopt='REMOVE_VIRTUAL' then do
  1143.   ok=GET_IT('REMVIRT')
  1144.     foo=make_virtual('VIRTUAL_FILE')
  1145.     if foo=0 then return 0
  1146.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  1147.     foo=get_value('virtual_file')
  1148.     stuff=a_replacestrg(stuff,'$virtual_file',foo,'ALL')
  1149.     stuff=a_replacestrg(stuff,'$DATADIR',ddir,'ALL')
  1150.       stuff=a_replacestrg(stuff,'$SERVDrive',filespec('d',basedir),'ALL')
  1151.     ok=make_doc(theopt,0,'DIRS')
  1152.  
  1153.  end    
  1154.  
  1155.  when theopt='RECORD_OPTION' then do
  1156.       ok=GET_IT('RECORD')
  1157.       tt=strip(upper(get_value('RECORD_OPTION')))
  1158.       fil=get_value('RECORD_ALL_FILE')
  1159.       stuff=a_replacestrg(stuff,'$record_all_file',fil,'ALL')
  1160.       isno='checked' ; isyes=' '; isurl=' '
  1161.       if  tt="YES" | tt="YES_ALL" then do
  1162.          isno=' '; isyes='checked'
  1163.       end  /* Do */
  1164.       if tt='FILE' then do
  1165.           isno=' '; isfile='checked'
  1166.       end  /* Do */
  1167.       stuff=a_replacestrg(stuff,'$isurl',isyes,'ALL')
  1168.       stuff=a_replacestrg(stuff,'$isno',isno,'ALL')
  1169.       stuff=a_replacestrg(stuff,'$isfile',isfile,'ALL')
  1170.  
  1171.       ok=make_doc(theopt,0,'RECORD')
  1172.  
  1173.  end    
  1174.  
  1175.  when theopt='HIT_CACHE_LEN' then do
  1176.       ok=get_it('HITLEN')
  1177.       foo=upper(strip(get_value('HIT_CACHE_LEN')))
  1178.       issmall=' '; isno='checked' ; isbig=' '
  1179.       if foo='FILE' then do
  1180.          isbig='CHECKED' ;isno=' '
  1181.       end  /* Do */
  1182.       if datatype(foo)="NUM" then do
  1183.          if foo>0 then do 
  1184.                 issmall='checked' ;isno=' '
  1185.          end  /* Do */
  1186.       end  /* Do */
  1187.       stuff=a_replacestrg(stuff,'$isno',isno,'ALL')
  1188.       stuff=a_replacestrg(stuff,'$issmall',issmall,'ALL')
  1189.       stuff=a_replacestrg(stuff,'$isbig',isbig,'ALL')
  1190.  
  1191.  
  1192.       ok=make_doc(theopt,0,'RECORD')
  1193.  end
  1194.  
  1195.  when theopt='HIT_OWNER_SUPPRESS' then do
  1196.       ok=get_it('HITOWNER')
  1197.       ok=do_yesno('HIT_OWNER_SUPPRESS','Y')
  1198.       hm=get_value('OWNERS')
  1199.       stuff=a_replacestrg(stuff,'$owners',hm,'ALL')
  1200.       ok=make_doc(theopt,0,'RECORD')
  1201.  end
  1202.  
  1203.  when theopt='WRITE_LOGS' then do
  1204.       ok=get_it('WRITELOG')
  1205.       ok=do_yesno('WRITE_LOGS','Y')
  1206.       stuff=a_replacestrg(stuff,'$workdata',workdata,'ALL')
  1207.  
  1208.       ok=make_doc(theopt,0,'RECORD')
  1209.  end
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  when theopt='SSI_SHTML_ONLY' then do
  1215.       ok=get_it('SHTML')
  1216.       ok=do_yesno('SSI_SHTML_ONLY','Y')
  1217.       hm=get_value('SSI_EXTENSIONS')
  1218.       stuff=a_replacestrg(stuff,'$ssi_extensions',hm,'ALL')
  1219.       ok=make_doc(theopt,0,'SSI')
  1220.  end    
  1221.  
  1222.  when theopt='SSI_CACHE_ON' then do
  1223.       ok=get_it('SSICACHE')
  1224.       ok=do_yesno('SSI_CACHE_ON','Y')
  1225.       hm=get_value('SSI_CACHE_SIZE')
  1226.       stuff=a_replacestrg(stuff,'$ssi_cache_size',hm,'ALL')
  1227.       ok=make_doc(theopt,0,'SSI')
  1228.  end    
  1229.  
  1230.  
  1231.  when theopt='HEADERS' then do
  1232.       ok=get_it('header')
  1233.       hd=strip(get_value('headers'))
  1234.       ft=strip(get_value('footers'))
  1235.       hd=strip(hd,'t','0')
  1236.       ft=strip(ft,'t','0')
  1237.       stuff=a_replacestrg(stuff,'$HD',hd,'ALL')
  1238.       stuff=a_replacestrg(stuff,'$FT',FT,'ALL')
  1239.  
  1240.       ok=make_doc(theopt,0,'SSI')
  1241.  end    
  1242.  
  1243.  when theopt='WEBMASTER' then do
  1244.       ok=get_it('WEBMASTR')
  1245.       p2=get_value('WEBMASTER')
  1246.       p2=a_replacestrg(p2,'<','<','ALL')
  1247.       p2=a_replacestrg(p2,'>','>','ALL')
  1248.       p2=a_replacestrg(p2,'"','"','ALL')
  1249.  
  1250.       stuff=a_replacestrg(stuff,'$webmaster',p2,'ALL')
  1251.       ok=make_doc(theopt,0,'SSI')
  1252.  end    
  1253.  
  1254.  when theopt='ADD_CUSTOM' then do
  1255.       ok=get_it('addcust')
  1256.       foo=get_value('REPSTRGS_FILE')
  1257.       stuff=a_replacestrg(stuff,'$REPLACE_FILE',foo,'ALL')
  1258.       ok=make_doc(theopt,0,'SSI')
  1259.   end 
  1260.  
  1261.  
  1262.  when theopt='REMOVE_CUSTOM' then do
  1263.       ok=get_it('remcust')
  1264.  
  1265.     foo=make_custom('repstrgs_file')
  1266.      if foo=0 then return 0
  1267.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  1268.     ok=make_doc(theopt,0,'SSI')
  1269.  
  1270.  end 
  1271.  
  1272.  when theopt='ADD_REDIRECT' then do
  1273.       ok=GET_IT('ADDALIAS')
  1274.       foo=get_value('ALIAS_FILE')
  1275.       stuff=a_replacestrg(stuff,'$ALIAS_FILE',foo,'ALL')
  1276.       ok=make_doc(theopt,0,'DIR')
  1277.  end 
  1278.  
  1279.  when theopt='REMOVE_REDIRECT' then do
  1280.     ok=GET_IT('REMAlias')
  1281.     foo=make_alias('alias_file')
  1282.     if foo=0 then return 0
  1283.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  1284.     foo=get_value('alias_file')
  1285.     stuff=a_replacestrg(stuff,'$alias_file',foo,'ALL')
  1286.     ok=make_doc(theopt,0,'DIR')
  1287.  end
  1288.  
  1289.  
  1290.  when theopt='ADD_PUBLICURL' then do
  1291.       ok=GET_IT('ADDPurl')
  1292.       foo=get_value('PUBURL_FILE')
  1293.       stuff=a_replacestrg(stuff,'$PUBURL_FILE',foo,'ALL')
  1294.       foo=get_value('puburl_file')
  1295.       stuff=a_replacestrg(stuff,'$DATADIR',ddir,'ALL')
  1296.       ok=make_doc(theopt,0,'DIR')
  1297.  end 
  1298.  
  1299.  when theopt='REMOVE_PUBLICURL' then do
  1300.     ok=GET_IT('REMpurl')
  1301.     foo=make_puburls('puburl_file')
  1302.     if foo=0 then return 0
  1303.     stuff=a_replacestrg(stuff,'$table',stuff2,'ALL')
  1304.     foo=get_value('puburl_file')
  1305.     stuff=a_replacestrg(stuff,'$puburl_file',foo,'ALL')
  1306.     ok=make_doc(theopt,0,'DIR')
  1307.  end
  1308.  
  1309.  
  1310.  
  1311.  when theopt='NO_SS' then do
  1312.      ok=GET_IT('noss')
  1313.      ok=do_yesno('NO_INCLUDE','N')
  1314.  
  1315.       tssp=get_value('NO_PROCESSING')
  1316.       tint=get_value('NO_INTERPRET_code')
  1317.  
  1318.       okssp=' '; nossp=' ' ; noint=' '
  1319.       if tssp=0 & tint=0 then do
  1320.          okssp='CHECKED'
  1321.       end  /* Do */
  1322.       else do
  1323.          if tint=1 & tssp=0 then
  1324.             noint='checked'
  1325.          else
  1326.             nossp='checked'
  1327.       end  /* Do */
  1328.       stuff=a_replacestrg(stuff,'$NO_SSP_INT',noint,'ALL')   /* careful, kind of confusing! */
  1329.       stuff=a_replacestrg(stuff,'$NO_SSP_YES',nossp,'ALL')
  1330.       stuff=a_replacestrg(stuff,'$NO_SSP_NO',okssp,'ALL')
  1331.       ok=make_doc(theopt,0,'MISC')
  1332.  
  1333.  end    
  1334.  when theopt='FIX_EXPIRE' then do
  1335.       ok=get_it('fixexpir')
  1336.       foo=get_value('FIX_EXPIRE')
  1337.       isyes=' ' ; isno='checked '
  1338.       if datatype(foo)="NUM" then do
  1339.          if foo>0 then do 
  1340.                 isyes='checked' ; isno=' '
  1341.          end  /* Do */
  1342.       end  /* Do */
  1343.       stuff=a_replacestrg(stuff,'$ISYES',isyes,'ALL')
  1344.       stuff=a_replacestrg(stuff,'$ISNO',isno,'ALL')
  1345.  
  1346.       ok=make_doc(theopt,0,'MISC')
  1347.  end    
  1348.  
  1349.  when theopt='SMTP_GATEWAY' then do
  1350.       ok=get_it('SMTP')
  1351.       hm=get_value('SMTP_GATEWAY')
  1352.       stuff=a_replacestrg(stuff,'$SMTP_GATEWAY',hm,'ALL')
  1353.       ok=make_doc(theopt,0,'MISC')
  1354.  
  1355.  end  
  1356.  
  1357. otherwise do
  1358.   'STRING NO SUCH Option= ' theopt
  1359.    ok='200 25'
  1360. end
  1361.  
  1362. end  /* select */
  1363.  
  1364. return ok
  1365.  
  1366.  
  1367.  
  1368. /******************/
  1369. /* READ appropriate file from config_dir directory. Return as a big string */
  1370. get_it:procedure expose thedir stuff verbose
  1371. parse arg thefile
  1372.  
  1373. stuff=' '
  1374. afile=thedir||'\'||thefile||'.CNF'
  1375. aa=stream(afile,'c','query exists')
  1376. if aa=' ' then do
  1377.   if verbose>1 then say " Missing configuration file: " afile
  1378.    return 0
  1379. end
  1380.  
  1381. lll=stream(aa,'c','query size')
  1382. stuff=charin(aa,1,lll)
  1383. stuff=strip(stuff,'t','1a'x)
  1384.  
  1385.  
  1386. aa=stream(aa,'c','close')
  1387. return 1
  1388.  
  1389. /******************/
  1390. /* replace isyes and isno in stuff */
  1391. do_yesno:procedure expose stuff servername host_nickname enmadd
  1392. parse upper arg param,def, yeses,nos
  1393. if yeses=' ' then yeses='Y YES 1'
  1394. if nos=' '  then nos='N NO 0 '
  1395. got1=0
  1396. isit=upper(get_value(param))
  1397. agin:
  1398. if  wordpos(isit,yeses)>0 then do
  1399.     isyes='CHECKED' ; isno=' ' ;got1=1
  1400. end
  1401. if wordpos(isit,nos)>0 then do
  1402.      isyes=' ' ; isno='CHECKED';got1=1
  1403. end
  1404. if got1=0 then do
  1405.    got1=1
  1406.    isit=def
  1407.    signal agin
  1408. end  /* Do */
  1409.  
  1410. stuff=a_replacestrg(stuff,'$ISYES',isyes,'ALL')
  1411. stuff=a_replacestrg(stuff,'$ISNO',isno,'ALL')
  1412.  
  1413. return 1
  1414.  
  1415.  
  1416. /******************/
  1417. /* take modified template, make into legit html document, and return */
  1418. make_doc:procedure expose stuff tempfile servername host_nickname usecolor
  1419. parse arg theopt,NOHOST,jumpto
  1420. crlf='0d0a'x
  1421. cc='<br><a href="/config0.htm#'jumpto'"><B>CANCEL</B> </a><br>'||crlf
  1422. cc=cc||'<A NAME="info"> <br> <!-- jump here for help --></A>'||crlf
  1423.  
  1424. stuff=a_replacestrg(stuff,'$CANCEL',cc,'ALL')
  1425.  
  1426. v1='<!doctype html public "-//IETF//DTD HTML 2.0//EN">'||crlf
  1427. v1=v1||"<html><head><title> SRE-http configurator: "theopt"</title></head>"||crlf
  1428. v1=v1||'<BODY bgcolor="#'||usecolor||'">'||crlf
  1429. j1='<A HREF="#info">Notes, hints, and examples</A> '||crlf
  1430. if host_nickname<>' ' & NOHOST<>1 then do
  1431.    j1=j1||'     ..... Modifying parameters for the <b>' host_nickname '</b> <em> host</em>'||crlf
  1432. end  /* Do */
  1433. j1=j1||'<br> <A NAME="setparam">   </A>'||crlf
  1434.  
  1435.  
  1436.  
  1437. v1=v1||j1||stuff||crlf
  1438. j2='<br><A HREF="#setparam">Return to parameter modification screen</A>'||crlf
  1439. v1=v1||j2||'<hr>'||crlf
  1440. v1=v1||'<a href="/config0.htm">Cancel and return to Simple Configurator Introduction </a>'||crlf
  1441. v1=v1||'<p><em> From server at: '||servername||'</em>'||crlf
  1442. v1=v1||'</body></html>'
  1443. foo=sref_gos('VAR TYPE text/html NAME v1 ',v1)
  1444. return '200 '||length(v1)
  1445.  
  1446. /* ----------- */                                                        
  1447. /* get environment value, possibly host specific
  1448. hname=0 -- do not look under hostname
  1449. hname=1 -- do not look under default
  1450.  */                      
  1451. /* ------------ */                                                       
  1452. get_value: procedure expose enmadd host_nickname                          
  1453. parse upper arg vname,hname0
  1454. if hname0=0 then 
  1455.         hname=' '
  1456. else                                                    
  1457.     hname=strip(host_nickname)                          
  1458.  
  1459. vname=strip(vname) ;
  1460. if hname<>' ' then do
  1461.    booger=strip(enmadd||vname||'.'||hname)
  1462.    aval=value(booger,,'os2environment')
  1463.    if aval<>' ' | hname0=1 Then
  1464.         return aval                                                      
  1465. end                                                                      
  1466. aval=value(enmadd||vname,,'os2environment')                              
  1467. return aval                                                              
  1468.  
  1469.  
  1470.  
  1471.  
  1472. /**************************/
  1473. /* check for legitimacy of the client */
  1474. okay_client:              /* subroutine. set the notokay variable */
  1475.  
  1476. rstatus=' '
  1477. who2=extract('CLIENTADDR')
  1478. saddr2=extract('SERVERADDR')
  1479.  
  1480. NO_REM=VALUE('SREF_NO_REMOTE_CONFIG',,'OS2ENVIRONMENT')
  1481.  
  1482. select
  1483.    when checkit=1 | NO_REM>0 then do
  1484. /* only if user = serveraddress !!! */
  1485.      if who2<>saddr2 | NO_REM=2 then do  /* auto entry if sitting at server and checkit=1, OR NO ENTRY IF NO_REM=2 */
  1486.  
  1487.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  1488.         call lineout tempfile, "<html><head><title>SRE-http remote configurator disabled </title>"
  1489.         call lineout tempfile, "</head><body>"
  1490.  
  1491.         call lineout tempfile,' <strong> The Simple Configurator can not be run remotely.</strong> '
  1492.         call lineout tempfile,' </body> </html> '
  1493.         call lineout tempfile
  1494.         fpp=sref_gos('FILE ERASE TYPE text/html NAME' tempfile)
  1495.          notokay=1
  1496.          return 1
  1497.      end
  1498.    end
  1499.    otherwise do         /* checkit=0 */
  1500.       if wordpos('SUPERUSER',upper(privset))=0 then do
  1501.           aa=sref_response('unauth','SUPERUSER privileges required for remote configuration',servername)
  1502.          rstatus='401 0'
  1503.          notokay=1
  1504.          return 1
  1505.       end
  1506.    end
  1507. end
  1508. notokay=0
  1509. return 0
  1510.  
  1511. /************************/
  1512. /* remove entries from a paramter file */
  1513. change_file:procedure expose host_nickname enmadd tempfile mess2
  1514.  
  1515. parse arg thingie, newval,remlist,noupdate,nocvt,nohost
  1516. newval0=newval
  1517. lookfor=get_value(thingie)   /* the file to change */
  1518. if lookfor=' ' then return " Could not find: " thingie
  1519. foo=sref_fileread(lookfor,dalines,,'E')
  1520. if dalines.0=0 then return 'Could not read:'||lookfor
  1521.  
  1522. /* scan through, looking for parameters that match:
  1523. if in remlist, remove. If = newval, remove and replace.
  1524. If no match, and newval<>' ', put newval at the end
  1525. */
  1526.  
  1527. remlist=strip(upper(translate(remlist,'/','\')))
  1528. remlist=strip(remlist,,'/')
  1529. newval=strip(upper(translate(newval,'/','\')))
  1530. newval=strip(newval,,'/')
  1531.  
  1532.  
  1533. inew=0
  1534. ninh=0
  1535. nkill=0
  1536. do mm=1 to dalines.0
  1537.    aline=upper(strip(dalines.mm))
  1538.    if abbrev(aline,';')=1 | aline=' ' then do /*retain comments */
  1539.       inew=inew+1
  1540.       newlines.inew=dalines.mm
  1541.       iterate
  1542.    end
  1543.    if nohost<>1 then do
  1544.      if wordpos('//',aline)=2  | right(strip(word(aline,1)),2)='//'  then do   /* host specific, does it match ? */
  1545.          parse var aline ahost '//' aline
  1546.          if strip(ahost)<>host_nickname then do /* no match, retain */
  1547.             inew=inew+1
  1548.             newlines.inew=dalines.mm
  1549.             iterate
  1550.          end  /* Do */
  1551.       end  /* Do */
  1552.       else do   /* generic== skip if host-Nickname is active */
  1553.        if host_nickname<>' ' then do
  1554.             inew=inew+1
  1555.             newlines.inew=dalines.mm
  1556.             iterate
  1557.        end  /* Do */
  1558.      end
  1559.    end  /* nohost -- so don't worry about host stuff */
  1560.  
  1561. /* if here, generic or host-matches. Is it in remlist */
  1562.    if (nohost<>1) & , 
  1563.        (wordpos('//',aline)=2  | right(strip(word(aline,1)),2)='//')  then   /* host specific, does it match ? */
  1564.           parse var aline . '//' aentry .
  1565.    else
  1566.           parse var aline aentry .
  1567.  
  1568.    if remlist<>' ' then do
  1569.      use1=upper(strip(word(aentry,1)))
  1570.      aentry=strip(translate(aentry,'/','\'),,'/')
  1571.      if wordpos(aentry,remlist)>0 then do    /* skip this one */
  1572.         nkill=nkill+1
  1573.         iterate
  1574.       end  /* Do */
  1575.    end  /* Do */
  1576.  
  1577. /*is it the newval? */
  1578.    newval1=strip(word(newval,1))
  1579.  
  1580.    if newval1=aentry then iterate /* don't copy -- will redo */
  1581.  
  1582.    inew=inew+1                  /* keep */
  1583.    newlines.inew=dalines.mm
  1584. end
  1585.  
  1586. if newval<>' ' then do /* add the new one */
  1587.    inew=inew+1
  1588.    newval=newval0
  1589.    if abbrev(strip(newval0),'*')=1 then
  1590.        newval='/'||strip(newval0)
  1591.    if nocvt=1 then newval=translate(newval,'\','/')
  1592.    if host_nickname<>' ' then
  1593.        newlines.inew=host_nickname||' // '||newval
  1594.    else
  1595.        newlines.inew=newval
  1596. end
  1597.  
  1598. if noupdate<>1 then do
  1599.    bakfile=lookfor               /* create a .bak file */
  1600.    foo=lastpos('.',bakfile)
  1601.    if foo=0  then
  1602.       bakfile=bakfile||'.bak'
  1603.    else
  1604.       bakfile=delstr(bakfile,foo)||'.bak'
  1605.    wow=doscopy(STRIP(LOOKFOR),STRIP(bakfile),'R')
  1606.    if wow<>0 then do
  1607.       say " ERROR: backup copy could not be made, error code  " wow
  1608.       return 'Backup copy could not be made'
  1609.   end  /* Do */
  1610. end
  1611. NEWLINES.0=INEW
  1612. /* now write new results */
  1613. foo=sref_filewrite(lookfor,newlines,'R')
  1614.  
  1615. if foo=0 then  return 'Could not save parameters file '
  1616.  
  1617. mess2=' Number entries deleted: '||nkill
  1618. return 1  /* success */
  1619.  
  1620.  
  1621.  
  1622. /************************/
  1623. /* extract entries from a paramter file */
  1624. make_users:procedure expose host_nickname enmadd tempfile stuff2
  1625. parse arg thingie
  1626. crlf='0d0a'x
  1627. afile=get_value(thingie)
  1628. foo=sref_fileread(afile,dalines,,'E')
  1629. if dalines.0=0 then do
  1630.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1631.     call lineout tempfile, "<html><head><title>Problem with SRE-http configurator</title></head>"
  1632.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1633.     call lineout tempfile,' <b>Error</b>: could not process USERNAME file: ' afile
  1634.     call lineout tempfile, "</body></html>"
  1635.     call lineout tempfile  /* close */
  1636.    fpp=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  1637.    return 0
  1638. end  /* Do */
  1639.  
  1640. ngot=0
  1641. do mm=1 to dalines.0
  1642.     aline=upper(strip(dalines.mm))
  1643.     if abbrev(aline,';')=1 | aline=' ' then iterate /* just a comment */
  1644.     if wordpos('//',aline)=2  | right(strip(word(aline,1)),2)='//'  then do   /* host specific, does it match ? */
  1645.          parse var aline ahost '//' aline
  1646.          if strip(ahost)<>host_nickname then iterate
  1647.     end  /* Do */
  1648.     else do   /* generic== skip if host-Nickname is active */
  1649.        if host_nickname<>' ' then iterate
  1650.    end
  1651. /* got a match, extract username */
  1652.    ngot=ngot+1
  1653.    parse var aline users.ngot .
  1654. end /* do */
  1655.  
  1656. if ngot=0 then do
  1657.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1658.     call lineout tempfile, "<html><head><title>No users in username database</title></head>"
  1659.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1660.     if host_nickname<>' ' then
  1661.        call lineout tempfile,' <b>There are no user entries (for the ' host_nickname ' Host) in the user database: ' afile
  1662.     else
  1663.        call lineout tempfile,' <b>There are no user entries  in the user database: ' afile
  1664.  
  1665.     call lineout tempfile, "</body></html>"
  1666.     call lineout tempfile  /* close */
  1667.    fpp=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  1668.    return 0
  1669. end  /* Do */
  1670.  
  1671. /* now create a  list */
  1672. aa.1='<h2> Select Entries to Remove </h2> '
  1673. aa.2='<em>Unchecked entries will be retained</em>.<br>'
  1674. aa.3='<ol> '
  1675. do mm=1 to ngot
  1676.   fee=3+mm
  1677.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||users.mm||'" > <b> '||users.mm||'</b>'
  1678. end /* do */
  1679.  
  1680. fee=3+ngot+1
  1681. aa.fee='</ol>'
  1682. fee=fee+1
  1683. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||ngot||'" >'
  1684.  
  1685. stuff2=aa.1
  1686. do mm=2 to fee
  1687.   stuff2=stuff2||crlf||aa.mm
  1688. end
  1689. return 1
  1690.  
  1691.  
  1692. /************************/
  1693. /* extract entries from a paramter file */
  1694. make_access:procedure expose host_nickname enmadd tempfile stuff2
  1695. parse arg thingie,getdef
  1696.  
  1697. crlf='0d0a'x
  1698. afile=get_value(thingie)
  1699. foo=sref_fileread(afile,dalines,,'E')
  1700. if dalines.0=0 then do
  1701.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1702.     call lineout tempfile, "<html><head><title>Problem with SRE-http configurator</title></head>"
  1703.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1704.     call lineout tempfile,' <b>Error</b>: could not process Access Control file: ' afile
  1705.     call lineout tempfile, "</body></html>"
  1706.     call lineout tempfile  /* close */
  1707.    foo=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  1708.    return 0
  1709. end  /* Do */
  1710.  
  1711. ngot=0
  1712. do mm=1 to dalines.0
  1713.     aline=upper(strip(dalines.mm))
  1714.     if abbrev(aline,';')=1 | aline=' ' then iterate /* just a comment */
  1715.     if abbrev(aline,'!')=1  then iterate /* don't do realm entries */
  1716.     if wordpos('//',aline)=2  | right(strip(word(aline,1)),2)='//' then do   /* host specific, does it match ? */
  1717.          parse var aline ahost '//' aline
  1718.          if strip(ahost)<>host_nickname then iterate
  1719.     end  /* Do */
  1720.     else do   /* generic== skip if host-Nickname is active */
  1721.        if host_nickname<>' ' then iterate
  1722.    end
  1723. /* got a match, extract access control entyr */
  1724.    parse var aline pepsi pop ; pepsi=strip(pepsi)
  1725.    parse var pop privs ',' .
  1726.    if pepsi='*' | pepsi=='/*' | pepsi='\*' then do
  1727.        if getdef=1  then do   /* looking for default, are we? */
  1728.            stuff2=privs
  1729.            return strip(stuff2)
  1730.        end  /* Do */
  1731.        iterate          /* else, ignore */
  1732.    end  /* Do */
  1733.    ngot=ngot+1
  1734.    users.ngot=pepsi
  1735.   privs=strip(space(privs))
  1736.    if length(privs)>50 then privs=left(privs,45)||' ...'
  1737.    users.ngot.2=privs
  1738. end /* do */
  1739.  
  1740. if getdef=1 then do
  1741.  stuff2=' '
  1742.  return 1
  1743. end
  1744.  
  1745. if ngot=0 then do
  1746.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1747.     call lineout tempfile, "<html><head><title>No entries in the access control </title></head>"
  1748.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1749.     if host_nickname<>' ' then
  1750.        call lineout tempfile,' <b>There are no entries (for the ' host_nickname ' Host) in the access control file: ' afile
  1751.     else
  1752.        call lineout tempfile,' <b>There are no entries  in the access control file: ' afile
  1753.     call lineout tempfile, "</body></html>"
  1754.     call lineout tempfile  /* close */
  1755.    foo=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  1756.    return 0
  1757. end  /* Do */
  1758.  
  1759. /* now create a  list */
  1760. aa.1='<h2> Select Entries to Remove </h2> '
  1761. aa.2='<em>Unchecked entries will be retained</em> <code>(first 45 characters of privilege list are displayed)</code> <br>'
  1762. aa.3='<ol> '
  1763. do mm=1 to ngot
  1764.   fee=3+mm
  1765.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||users.mm||'" > <b> '||users.mm||'</b> <code>(privs= 'users.mm.2 '</code>'
  1766. end /* do */
  1767. fee=3+ngot+1
  1768. aa.fee='</ol>'
  1769. fee=fee+1
  1770. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||ngot||'" >'
  1771.  
  1772. stuff2=aa.1
  1773. do mm=2 to fee
  1774.   stuff2=stuff2||crlf||aa.mm
  1775. end
  1776. return 1
  1777.  
  1778.  
  1779.  
  1780. /************************/
  1781. /* extract entries from a initfilt.80 parameter file */
  1782. make_inhouseips:procedure expose host_nickname enmadd tempfile stuff2
  1783. crlf='0d0a'x
  1784.  
  1785. parse arg thingie
  1786. crlf='0d0a'x
  1787. afile=get_value(thingie)
  1788. foo=sref_fileread(afile,dalines,,'E')
  1789.  
  1790. if dalines.0=0 then do
  1791.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1792.     call lineout tempfile, "<html><head><title>Problem with SRE-http configurator</title></head>"
  1793.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1794.     call lineout tempfile,' <b>Error</b>: could not process initialization file: ' afile
  1795.     call lineout tempfile, "</body></html>"
  1796.     call lineout tempfile  /* close */
  1797.    fpp=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  1798.    return 0
  1799. end  /* Do */
  1800.  
  1801. /* read initfilt.80 file, look for inhousesips entries */
  1802. igot=0
  1803. do mm=1 to dalines.0
  1804.    aline=upper(strip(dalines.mm))
  1805.    if aline=' ' | abbrev(aline,';')=1 then iterate
  1806.    if abbrev(aline,'INHOUSEIPS.')=0 then iterate
  1807.    parse var aline p1 '=' p2 ; p2=strip(p2)
  1808.    p2=strip(p2,,"'"); p2=strip(p2,,'"') ;p2=strip(p2)
  1809.    if p2=' ' | p2=0 then iterate
  1810.    p1=translate(p1,' ','.')
  1811.    if words(p1)=1 then iterate  /* error, ignore */
  1812.    if words(p1)=2 & host_nickname=' ' then do
  1813.         igot=igot+1
  1814.         gotinh.igot=word(strip(p2),1)
  1815.    end  /* Do */
  1816.    if words(p1)=3 then do            /* 3rd is host nickmane */
  1817.         if strip(word(p1,3))=host_nickname then do
  1818.             igot=igot+1
  1819.             gotinh.igot=word(strip(p2),1)
  1820.         end  /* Do */
  1821.    end /* do */
  1822. end /* do */
  1823.  
  1824. if igot=0 then do
  1825.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1826.     call lineout tempfile, "<html><head><title>No In-House Entries</title></head>"
  1827.     call lineout tempfile, "<body><h2>Nothing to do!</h2>"
  1828.     if host_nickname<>' ' then
  1829.        call lineout tempfile,' <b>There are no In-house entries (for the ' host_nickname ' Host '
  1830.     else
  1831.        call lineout tempfile,' <b>There are no In-house entries'
  1832.     call lineout tempfile, "</body></html>"
  1833.     call lineout tempfile  /* close */
  1834.    fpp=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  1835.    return 0
  1836. end  /* Do */
  1837.  
  1838.  
  1839. /* now create a  list */
  1840. aa.1='<h2> Select Entries to Remove </h2> '
  1841. aa.2='<em>Unchecked entries will be retained</em>.<br>'
  1842. aa.3='<ol> '
  1843. do mm=1 to igot
  1844.   fee=3+mm
  1845.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||gotinh.mm||'" > <b> '||gotinh.mm||'</b>'
  1846. end /* do */
  1847. fee=3+igot+1
  1848. aa.fee='</ol>'
  1849. fee=fee+1
  1850. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||igot||'" >'
  1851.  
  1852. stuff2=aa.1
  1853. do mm=2 to fee
  1854.   stuff2=stuff2||crlf||aa.mm
  1855. end
  1856. return 1
  1857.  
  1858.  
  1859.  
  1860.  
  1861. /************************/
  1862. /* extract entries from a initfilt.80 parameter file */
  1863. make_puburls:procedure expose host_nickname enmadd tempfile stuff2
  1864. crlf='0d0a'x
  1865.  
  1866. parse arg thingie
  1867. crlf='0d0a'x
  1868. afile=get_value(thingie)
  1869. foo=sref_fileread(afile,dalines,,'E')
  1870.  
  1871. if dalines.0=0 then do
  1872.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1873.     call lineout tempfile, "<html><head><title>Problem with SRE-http configurator</title></head>"
  1874.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1875.     call lineout tempfile,' <b>Error</b>: could not public urls file: ' afile
  1876.     call lineout tempfile, "</body></html>"
  1877.     call lineout tempfile  /* close */
  1878.    foo=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  1879.    return 0
  1880. end  /* Do */
  1881.  
  1882. /* read puburls.in */
  1883. igot=0
  1884. do mm=1 to dalines.0
  1885.     aline=upper(strip(dalines.mm))
  1886.     if abbrev(aline,';')=1 | aline=' ' then iterate /* just a comment */
  1887.     if wordpos('//',aline)=2  | right(strip(word(aline,1)),2)='//'  then do   /* host specific, does it match ? */
  1888.          parse var aline ahost '//' aline
  1889.          if strip(ahost)<>host_nickname then iterate
  1890.     end  /* Do */
  1891.     else do   /* generic== skip if host-Nickname is active */
  1892.        if host_nickname<>' ' then iterate
  1893.    end
  1894. /* got a match, extract username */
  1895.    igot=igot+1
  1896.    parse var aline gotinh.igot
  1897. end /* do */
  1898.  
  1899. if igot=0 then do
  1900.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1901.     call lineout tempfile, "<html><head><title>No PUBLIC area identifiers</title></head>"
  1902.     call lineout tempfile, "<body><h2>Nothing to do!</h2>"
  1903.     if host_nickname<>' ' then
  1904.        call lineout tempfile,' <b>There are no PUBLIC area  PUBLIC area identifiters (for the ' host_nickname ' Host '
  1905.     else
  1906.        call lineout tempfile,' <b>There are no PUBLIC area identifiers '
  1907.     call lineout tempfile, "</body></html>"
  1908.     call lineout tempfile  /* close */
  1909.    foo=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  1910.    return 0
  1911. end  /* Do */
  1912.  
  1913.  
  1914. /* now create a  list */
  1915. aa.1='<h2> Select Entries to Remove </h2> '
  1916. aa.2='<em>Unchecked entries will be retained</em>.<br>'
  1917. aa.3='<ol> '
  1918. do mm=1 to igot
  1919.   fee=3+mm
  1920.   parse var gotinh.mm gotinh.mm ostuff
  1921.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||gotinh.mm||'" > <b> '||gotinh.mm||'</b> '
  1922.   if ostuff<>'' then aa.fee=aa.fee||'<em>( 'ostuff')</em>'
  1923. end /* do */
  1924. fee=3+igot+1
  1925. aa.fee='</ol>'
  1926. fee=fee+1
  1927. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||igot||'" >'
  1928.  
  1929. stuff2=aa.1
  1930. do mm=2 to fee
  1931.   stuff2=stuff2||crlf||aa.mm
  1932. end
  1933. return 1
  1934.  
  1935.  
  1936.  
  1937. /************************/
  1938. /* extract entries from a initfilt.80 parameter file */
  1939. make_hosts:procedure expose host_nickname enmadd tempfile stuff2
  1940. crlf='0d0a'x
  1941.  
  1942. parse arg thingie
  1943. crlf='0d0a'x
  1944. afile=get_value(thingie)
  1945. foo=sref_fileread(afile,dalines,,'E')
  1946.  
  1947. if dalines.0=0 then do
  1948.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1949.     call lineout tempfile, "<html><head><title>Problem with SRE-http configurator</title></head>"
  1950.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  1951.     call lineout tempfile,' <b>Error</b>: could not process initialization file: ' afile
  1952.     call lineout tempfile, "</body></html>"
  1953.     call lineout tempfile  /* close */
  1954.    foo=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  1955.    return 0
  1956. end  /* Do */
  1957.  
  1958. /* read initfilt.80 file, look for host entries */
  1959. igot=0
  1960. do mm=1 to dalines.0
  1961.    aline=upper(strip(dalines.mm))
  1962.    if aline=' ' | abbrev(aline,';')=1 then iterate
  1963.    if abbrev(aline,'HOSTS.')=0 then iterate
  1964.    parse var aline p1 '=' p2 ; 
  1965.     p2=translate(p2,' ',"'"||'"') ; p2=strip(p2)
  1966.    if p2=0 then iterate
  1967.    parse var p2 anip ',' anick ',' . 
  1968.    igot=igot+1
  1969.    ahosts.igot=strip(upper(anip))
  1970.    ahosts.igot.2=strip(upper(anick))
  1971.  
  1972. end /* do */
  1973.  
  1974. if igot=0 then do
  1975.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  1976.     call lineout tempfile, "<html><head><title>No HOST definitions</title></head>"
  1977.     call lineout tempfile, "<body><h2>Nothing to do!</h2>"
  1978.     call lineout tempfile,' <b>There are no host definitions'
  1979.     call lineout tempfile, "</body></html>"
  1980.     call lineout tempfile  /* close */
  1981.    foo=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  1982.    return 0
  1983. end  /* Do */
  1984.  
  1985.  
  1986. /* now create a  list */
  1987. aa.1='<h2> Select Entries to Remove </h2> '
  1988. aa.2='<em>Unchecked entries will be retained</em>.<br>'
  1989. aa.3='<ol> '
  1990. do mm=1 to igot
  1991.   fee=3+mm
  1992.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||ahosts.mm||'" > '||ahosts.mm||'(with host nickname of <b> ' ahosts.mm.2 '</b>)'
  1993. end /* do */
  1994. fee=3+igot+1
  1995. aa.fee='</ol>'
  1996. fee=fee+1
  1997. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||igot||'" >'
  1998.  
  1999. stuff2=aa.1
  2000. do mm=2 to fee
  2001.   stuff2=stuff2||crlf||aa.mm
  2002. end
  2003. return 1
  2004.  
  2005.  
  2006.  
  2007. /************************/
  2008. /* extract entries from a virtual dir  file */
  2009. make_virtual:procedure expose host_nickname enmadd tempfile stuff2
  2010. parse arg thingie
  2011. crlf='0d0a'x
  2012. afile=get_value(thingie)
  2013. foo=sref_fileread(afile,dalines,,'E')
  2014. if dalines.0=0 then do
  2015.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  2016.     call lineout tempfile, "<html><head><title>Problem with SRE-http configurator</title></head>"
  2017.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  2018.     call lineout tempfile,' <b>Error</b>: could not process virtual directory file: ' afile
  2019.     call lineout tempfile, "</body></html>"
  2020.     call lineout tempfile  /* close */
  2021.    fpp=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  2022.    return 0
  2023. end  /* Do */
  2024.  
  2025. ngot=0
  2026. do mm=1 to dalines.0
  2027.     aline=upper(strip(dalines.mm))
  2028.     if abbrev(aline,';')=1 | aline=' ' then iterate /* just a comment */
  2029.     if wordpos('//',aline)=2 | right(strip(word(aline,1)),2)='//' then do   /* host specific, does it match ? */
  2030.          parse var aline ahost '//' aline
  2031.          if strip(ahost)<>host_nickname then iterate
  2032.     end  /* Do */
  2033.     else do   /* generic== skip if host-Nickname is active */
  2034.        if host_nickname<>' ' then iterate
  2035.    end
  2036. /* got a match, extract virtual dir */
  2037.    ngot=ngot+1
  2038.    parse var aline wow thedir
  2039.    users.ngot=strip(translate(wow,'/','\'),,'/')||'/'
  2040.    thedir=strip(translate(thedir,' ','*'))
  2041.    users.ngot.2=thedir
  2042. end /* do */
  2043.  
  2044. if ngot=0 then do
  2045.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  2046.     call lineout tempfile, "<html><head><title>No entries in virtual directory list</title></head>"
  2047.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  2048.     if host_nickname<>' ' then
  2049.     call lineout tempfile,' <b>There are no virtual directory entries (for the ' host_nickname ' Host) in: ' afile
  2050.     else
  2051.     call lineout tempfile,' <b>There are no virtual directory entries in: ' afile
  2052.  
  2053.     call lineout tempfile, "</body></html>"
  2054.     call lineout tempfile  /* close */
  2055.    fpp=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  2056.    return 0
  2057. end  /* Do */
  2058.  
  2059. /* now create a  list */
  2060. aa.1='<h2> Select Entries to Remove </h2> '
  2061. aa.2='<em>Unchecked entries will be retained</em>.<br>'
  2062. aa.3='<ol> '
  2063. do mm=1 to ngot
  2064.   fee=3+mm
  2065.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||users.mm||'" > <b> '||users.mm||'</b>      (... maps to:<tt> ' users.mm.2 '</tt>)'
  2066. end /* do */
  2067. fee=3+ngot+1
  2068. aa.fee='</ol>'
  2069. fee=fee+1
  2070. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||ngot||'" >'
  2071.  
  2072. stuff2=aa.1
  2073. do mm=2 to fee
  2074.   stuff2=stuff2||crlf||aa.mm
  2075. end
  2076. return 1
  2077.  
  2078.  
  2079. /************************/
  2080. /* extract entries from an alias file */
  2081. make_alias:procedure expose host_nickname enmadd tempfile stuff2
  2082. parse arg thingie
  2083. crlf='0d0a'x
  2084. afile=get_value(thingie)
  2085. foo=sref_fileread(afile,dalines,,'E')
  2086. if dalines.0=0 then do
  2087.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  2088.     call lineout tempfile, "<html><head><title>Problem with SRE-http configurator</title></head>"
  2089.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  2090.     call lineout tempfile,' <b>Error</b>: could not process redirection aliases file: ' afile
  2091.     call lineout tempfile, "</body></html>"
  2092.     call lineout tempfile  /* close */
  2093.    foo=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  2094.    return 0
  2095. end  /* Do */
  2096. ngot=0
  2097. do mm=1 to dalines.0
  2098.     aline=upper(strip(dalines.mm))
  2099.     if abbrev(aline,';')=1 | aline=' ' then iterate /* just a comment */
  2100.     if wordpos('//',aline)=2 | right(strip(word(aline,1)),2)='//' then do   /* host specific, does it match ? */
  2101.          parse var aline ahost '//' aline
  2102.          if strip(ahost)<>host_nickname then iterate
  2103.     end  /* Do */
  2104.     else do   /* generic== skip if host-Nickname is active */
  2105.        if host_nickname<>' ' then iterate
  2106.    end
  2107. /* got a match, extract alias */
  2108.    parse var aline wow whereto
  2109.    foo2=upper(whereto)
  2110.    jump=pos('HTTP://',foo2)+ pos('!MOVED',foo2) + pos('!TEMP',foo2)
  2111.    if jump=0 then iterate /* remote redirection only */
  2112.  
  2113.    ngot=ngot+1
  2114.    wow=strip(wow); if right(wow,1)<>'*' then
  2115.        users.ngot=strip(translate(wow,'/','\'),,'/')||'/'
  2116.    else
  2117.         users.ngot=wow
  2118.     whereto=strip(whereto)
  2119.    if length(whereto)>60 then whereto=left(whereto,55)||' ...'
  2120.    users.ngot.2=whereto
  2121.  
  2122. end /* do */
  2123.  
  2124. if ngot=0 then do
  2125.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  2126.     call lineout tempfile, "<html><head><title>No entries in redirection alias list</title></head>"
  2127.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  2128.     if host_nickname<>' ' then
  2129.       call lineout tempfile,' <b>There are no redirection aliases entries (for the ' host_nickname' Host) in: ' afile
  2130.     else
  2131.       call lineout tempfile,' <b>There are no redirection aliases entries in: ' afile
  2132.     call lineout tempfile, "</body></html>"
  2133.     call lineout tempfile  /* close */
  2134.    foo=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  2135.    return 0
  2136. end  /* Do */
  2137.  
  2138. /* now create a  list */
  2139. aa.1='<h2> Select Entries to Remove </h2> '
  2140. aa.2='<em>Unchecked entries will be retained</em> (<code> The first 55 characters are displayed. </code>) <br>'
  2141. aa.3='<ol> '
  2142. do mm=1 to ngot
  2143.   jj=' (<em> redirecting to:' users.mm.2 '</em>)'
  2144.   fee=3+mm
  2145.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||users.mm||'" > <b> '||users.mm||'</b> (redirect to:<tt> ' users.mm.2 '</tt>'
  2146. end /* do */
  2147. fee=3+ngot+1
  2148. aa.fee='</ol>'
  2149. fee=fee+1
  2150. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||ngot||'" >'
  2151.  
  2152. stuff2=aa.1
  2153. do mm=2 to fee
  2154.   stuff2=stuff2||crlf||aa.mm
  2155. end
  2156. return 1
  2157.  
  2158.  
  2159.  
  2160.  
  2161. /************************/
  2162. /* extract entries from a replacement strings file */
  2163. make_custom:procedure expose host_nickname enmadd tempfile stuff2
  2164. parse arg thingie
  2165. crlf='0d0a'x
  2166. afile=get_value(thingie)
  2167. foo=sref_fileread(afile,dalines,,'E')
  2168. if dalines.0=0 then do
  2169.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  2170.     call lineout tempfile, "<html><head><title>Problem with SRE-http configurator</title></head>"
  2171.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  2172.     call lineout tempfile,' <b>Error</b>: could not process replacement strings file: ' afile
  2173.     call lineout tempfile, "</body></html>"
  2174.     call lineout tempfile  /* close */
  2175.    foo=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  2176.    return 0
  2177. end  /* Do */
  2178. ngot=0
  2179. do mm=1 to dalines.0
  2180.     aline=upper(strip(dalines.mm))
  2181.     if aline=" " | abbrev(aline,';')=1  then iterate
  2182.     parse var aline p1 p2
  2183.     p1=translate(p1,' ','.')
  2184.     if words(p1)=1 & host_nickname<>' ' then iterate
  2185.     oo=word(p1,words(p1))
  2186.     if words(p1)>1 then do
  2187.         if datatype(oo)<>'NUM' then
  2188.             if upper(strip(oo))<>host_nickname then iterate
  2189.     end  /* Do */
  2190.     p10=p1 ; 
  2191.     if words(p1)>1 &  datatype(oo)<>'NUM' then
  2192.              p10=delword(p10,words(p10))
  2193.     ngot=ngot+1
  2194.     p2=a_replacestrg(p2,'<','<','ALL')
  2195.     p2=a_replacestrg(p2,'>','>','ALL')
  2196.     p2=a_replacestrg(p2,'"','"','ALL')
  2197.     users.ngot=translate(strip(p10),'.',' ')
  2198.    if length(p2)>60 then p2=left(p2,55)||' ...'
  2199.  
  2200.     users.ngot.2=left(p2,70)
  2201. end /* do */
  2202. if ngot=0 then do
  2203.     call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  2204.     call lineout tempfile, "<html><head><title>No entries in replacement strings list</title></head>"
  2205.     call lineout tempfile, "<body><h2>Sorry...</h2>"
  2206.     if host_nickname<>' ' then
  2207.       call lineout tempfile,' <b>There are no replacement strings (for the ' host_nickname' Host) in: ' afile
  2208.     else
  2209.       call lineout tempfile,' <b>There are no replacement strings in: ' afile
  2210.     call lineout tempfile, "</body></html>"
  2211.     call lineout tempfile  /* close */
  2212.    foo=sref_gos('FILE ERASE TYPE text/html NAME ' tempfile)
  2213.    return 0
  2214. end  /* Do */
  2215.  
  2216. /* now create a  list */
  2217. aa.1='<h2> Select Entries to Remove </h2> '
  2218. aa.2='<em>Unchecked entries will be retained <code>(the first 55 characters are displayed)</code></em>.<br>'
  2219. aa.3='<ol> '
  2220. do mm=1 to ngot
  2221.   fee=3+mm
  2222.   aa.fee='<li> <INPUT TYPE="CHECKBOX" NAME="delete.'||mm||'" VALUE="'||users.mm||'" > <b> '||users.mm||'</b> (<code> == ' users.mm.2 '</code>'
  2223. end /* do */
  2224. fee=3+ngot+1
  2225. aa.fee='</ol>'
  2226. fee=fee+1
  2227. aa.fee='<INPUT TYPE="hidden" NAME="entries" VALUE="'||ngot||'" >'
  2228.  
  2229. stuff2=aa.1
  2230. do mm=2 to fee
  2231.   stuff2=stuff2||crlf||aa.mm
  2232. end
  2233. return 1
  2234.  
  2235. /* ----------------------------------------------------------------------- */
  2236. /* REPLACESTRG:
  2237.   Arguments:
  2238.                 astring : the "haystack" to look in
  2239.                 target: the "needle" to look for
  2240.                 putme: the "new needle" to replace the "needle" with
  2241.                 type : The direction/type of search
  2242.                         FORWARD, BACKWARD, ALL
  2243.                 exact: YES-- then cases in needle and haystack must match
  2244.  
  2245.       Note taht regardless of value of exact, cases are retained in both
  2246.       astring and putme.
  2247.  
  2248.    Returns the modified astring, or the unmodified astring if target could
  2249.    not be found.
  2250. */
  2251. /* ----------------------------------------------------------------------- */
  2252.  
  2253. a_replacestrg:
  2254.  
  2255. exactmatch=0
  2256. backward=0 ; doall=0
  2257.  
  2258. parse arg astring ,  target   , putme , type , exactmatch
  2259.  
  2260. type = translate(type)
  2261. if type="BACKWARD" then backward="YES"
  2262. if type="ALL" then doall="YES"
  2263.  
  2264. iat=1
  2265. joelen=length(target)
  2266. joelen2=length(putme)
  2267.  
  2268. doagain:                /* here if doall=yes */
  2269.  if exactmatch="YES" then do
  2270.     if   backward="YES" then
  2271.         joe= lastpos(target,astring)
  2272.     else
  2273.         joe= pos(target,astring,iat)
  2274.  end
  2275.  else do
  2276.    if   backward="YES" then
  2277.         joe= lastpos(translate(target),translate(astring))
  2278.     else
  2279.         joe= pos(translate(target),translate(astring),iat)
  2280.  end
  2281.  if joe=0 then
  2282.          return astring
  2283.  
  2284.  astring=delstr(astring,joe,joelen)
  2285.  if putme<>' ' then
  2286.     astring=insert(putme,astring,joe-1)
  2287.  
  2288.  if doall="YES" then do
  2289.      iat=joe+joelen2
  2290.      signal doagain
  2291.  end
  2292. /* else, all done */
  2293.  return astring
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.