home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / VIRTCFG.CMD < prev    next >
OS/2 REXX Batch file  |  1999-06-18  |  21KB  |  541 lines

  1. /*  */
  2. virtcfg:
  3.  
  4. CHECKIT=0   /* Change this to 0 if you want to enable REMOTE configuration by SUPERUSERS */
  5.  
  6. /* background color */
  7. USECOLOR='2dd52f'
  8.  
  9. /* ---------------- DO NOT MODIFY BELOW THIS LINE  ------------------ */
  10.  
  11. parse arg  ddir, tempfile, sel,list,verb ,uri,user, ,
  12.           basedir ,workdir,privset,enmadd,transaction,verbose, ,
  13.          servername,host_nickname,homedir,aparam,semqueue,prog_file,reqnum
  14.  
  15. /* parse arg ddir,tempfile,sel,list,verb,uri,user,basedir,workdir,privset,enmadd,transaction,verbose*/
  16.  
  17. if verb="" then do
  18.    say " This SRE-http add-on is NOT meant to be run from the command line."
  19.    say " It can be invoked by using CONFIGUR.HTM "
  20.    exit
  21. end  /* Do */
  22.  
  23.  
  24. list=translate(list, ' ', '+'||'090a0d'x)  /* Whitespace, etc. */
  25.  
  26. crlf='0d0a'x
  27. who2=extract('CLIENTADDR')
  28. saddr2=extract('SERVERADDR')
  29.  
  30. NO_REM=VALUE('SREF_NO_REMOTE_CONFIG',,'OS2ENVIRONMENT')
  31.  
  32. select
  33.    when checkit=1 | no_rem>0 then do
  34.  
  35. /* only if user = serveraddress !!! */
  36.      if who2<>saddr2 | no_rem=2 then do
  37.  
  38.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  39.         call lineout tempfile, "<html><head><title>SRE-http remote configurator disabled </title>"
  40.         call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  41.  
  42.         call lineout tempfile,' <strong> Action not allowed remotely.</strong> <pre>'
  43.         call lineout tempfile,' </body> </html> '
  44.         call lineout tempfile
  45.         foo=sref_gos('FILE ERASE TYPE text/html NAME' tempfile)
  46.         return 'VIRTCFG: action not allowed remotely. '
  47.      end
  48.    end
  49.    otherwise do
  50.       if wordpos('SUPERUSER',privset)=0 then do
  51.         'RESPONSE HTTP/1.1 401 Unauthorized '     /* Set HTTP response line */
  52.          att=sref_gmt()
  53.         'HEADER Noauto ADD Date: 'att
  54.  
  55.         'header add WWW-Authenticate: Basic Realm=<CONFIGURE>'  /* challenge */
  56.  
  57.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  58.         call lineout tempfile, "<html><head><title>Not authorized </title>"
  59.         call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  60.  
  61.         call lineout tempfile,' <strong> You do not have configuration rights.</strong> <pre>'
  62.         if who2=saddr2 then 
  63.                 call lineout tempfile,'<br> <Em> You may want to edit VIRTCFG.CMD </em> '
  64.         call lineout tempfile,' </body> </html> '
  65.         call lineout tempfile
  66.          iia=dosdir(tempfile,'s')
  67.  
  68.         'FILE ERASE TYPE text/html NAME' tempfile
  69.         return '401 'iia ' VIRTCFG: not permitted to configure. '
  70.       end
  71.    end
  72. end
  73.  
  74. list=strip(list)
  75. select 
  76.    when upper(list)='TODO=SHOW' | upper(list)='TODO=SHOW_HEADER' then
  77.         signal doshow
  78.    when upper(list)='TODO=SET' then
  79.         signal doset
  80.  
  81.    when upper(list)='TODO=CURRENT' then
  82.         signal showcurrent
  83.  
  84.    otherwise
  85.         signal dochange
  86. end  /* select */
  87.  
  88.  
  89. /* jump here to show values */
  90. doshow:
  91.  
  92. virtualfile=value(enmadd||'VIRTUAL_FILE',,'os2environment')
  93.    call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  94.    call lineout tempfile, "<html><head><title>SRE-http: Virtual Directories </title>"
  95.    call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  96.  
  97.  
  98. aa=sref_fileread(virtualfile,'lins',,'E')
  99.  
  100. call lineout tempfile, "<h1> SRE-http:  Virtual Directories  </h1> <p>"
  101.  
  102. if upper(list)='TODO=SHOW' then
  103.    call lineout tempfile, "<h2> List of "header" comments </h2> <pre> <blockquote>"
  104. else
  105.    call lineout tempfile, "<h2> Description of virtual directories </h2> <pre> <blockquote>"
  106.  
  107. /* show "header comments" */
  108. iat=0
  109. do until iat >= lins.0
  110.    iat=iat+1
  111.    if  abbrev(strip(lins.iat),';')  then do
  112.         foo=strip(lins.iat) ;foo=strip(foo,'l',';')
  113.          call lineout tempfile, foo 
  114.    end  /* Do */
  115.    else do
  116.         leave
  117.    end
  118. end /* do -- iat is the first non header comment line  */
  119. call lineout tempfile, '</blockquote></pre> '
  120.  
  121. /* view descriptive header only? */
  122. if upper(list)='TODO=SHOW_HEADER' then do
  123.    call lineout tempfile,' <hr> </body></html>'
  124.    call lineout tempfile
  125.    foo=sref_gos('file erase  type text/html name  ' tempfile)
  126.    return ' done '
  127. end  /* Do */
  128.  
  129.  
  130.  
  131. /* read in usernames, etc */
  132. nusers=0
  133.  
  134. call lineout tempfile, ' <hr> <h2> List of virtual directories </h2>  '
  135.  
  136. call lineout tempfile,' Notes: <ul> '
  137. call lineout tempfile,' <li> Virtual directories are stored in: ' virtualfile
  138. call lineout tempfile,' <li> <em>Comments are in italics </em> '
  139. call lineout tempfile, ' <li> Entries with no <strong>host nickname</strong> apply to all requests '
  140. call lineout tempfile, ' <li> Valid keywords for limitation list are: <b> !CGI-BIN !UPLOAD !ADDONS !HTML </B>'
  141. call lineout tempfile, ' <li> For remote (<code>http://</code>) directories, you can add '
  142. call lineout tempfile, ' a user:pwd (to be sent as a request header). This must follow the limitation list and be preceded by a comma </ul> <br> '
  143.  
  144. call lineout tempfile,' <table border=1> <th> Host Nickname </th>'
  145. call lineout tempfile,' <th> Candidate SEL (abbreviation) </th>'
  146. call lineout tempfile,'  <th> Fully qualified directory (or remote directory)  </th> '
  147. call lineout tempfile,' <th> Allow subdirectories <br> & <code> limitation list , user:pwd </code> </th><tr>'
  148.  
  149. do mm=iat to lins.0
  150.   if lins.mm=' ' then iterate
  151.   if  abbrev(strip(lins.mm),';') then do  
  152.        call lineout tempfile,'<td colspan=4>  <code>     </code> <em>' strip(strip(lins.mm),'l',';') '</em></td> <tr> '
  153.   end
  154.   else do
  155.       if pos('// ',lins.mm)>0 then
  156.            parse var lins.mm hostname '//' candurl targdir limlist
  157.       else do
  158.            hostname=' .. '
  159.            parse var lins.mm candurl targdir limlist
  160.       end  /* Do */
  161.       subdirok='NO'
  162.       if right(strip(targdir),1)='*' then do
  163.          targdir=delstr(targdir,length(targdir))
  164.          subdirok='YES'
  165.       end
  166.       call lineout tempfile,'<td> <STRONG> 'hostname '</STRONG> </td>'
  167.       call lineout tempfile,'<td> <STRONG> ' candurl '</STRONG> </td>'
  168.       call lineout tempfile,'<td> <STRONG> 'targdir '</STRONG> </td>'
  169.       call lineout tempfile,' <td> <strong> ' subdirok '</strong> <br> '
  170.       call lineout tempfile,'  <code> ' limlist '</code> </td> <tr> '
  171.  
  172.   end /* do */
  173.  
  174. end
  175. call lineout tempfile,' </table>'
  176.  
  177. call lineout tempfile,' <hr> Thanks for checking </body></html>'
  178. call lineout tempfile
  179.  
  180. foo=sref_gos('file erase  type text/html name  ' tempfile)
  181. return ' done '
  182.  
  183.  
  184. /* jump here if "show current" chosen */
  185. showcurrent:
  186. foo=wait_queue('VIRTUAL')
  187. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  188. call lineout tempfile, "<html><head><title>SRE-http: list of virtual directories </title>"
  189. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  190.  
  191. call lineout tempfile, '<h2>List of SRE-http VIRTUAL directories </h2>'
  192. call lineout tempfile,' This complete list of VIRTUAL directories includes entries in default and host specific copies '
  193. call lineout tempfile,' of VIRTUAL.IN and ATTRIBS.CFG <hr width="30%">'
  194. call lineout tempfile,'<table border=1>'
  195. call lineout tempfile,'<tr><th> Host <th> Selector <th> Directory  <em>(SubDir Ok?)</em>'
  196. call lineout tempfile,'<th>Username/pwd & <br> Limitlist'
  197.  
  198. do forever
  199.   if foo='' then leave
  200.   parse var foo ah '//' vu  ','  vd ',' vs ',' upwd ',' vlimit (crlf) foo
  201.   parse var vlimit . ',' vlimit
  202.   call lineout tempfile,'<tr><td> 'ah '<td> 'vu '<td> 'vd 
  203.   if vs=1  then call lineout tempfile,' <em> (ok) </em>'
  204.   call lineout tempfile,' <td> <tt>'upwd '</tT> <br> 'vlimit
  205. end
  206. call lineout tempfile,'</table></body></html>'
  207. call lineout tempfile
  208. foo=sref_gos('file erase  type text/html name  ' tempfile)
  209. return ' done '
  210.  
  211.  
  212.            dog1=dog1||virthosts.mm '// ' virturl.mm' , 'virtdir.mm ','virtsubs.mm||' , '
  213.            dog1=dog1||virtdir.mm.!upwd' , 'virtdir.mm.limitlist||'0d0a'x
  214.   
  215.  
  216.  
  217.  
  218. /* jump here if "set values" chosen */
  219. doset:
  220. virtualfile=value(enmadd||'virtual_FILE',,'os2environment')
  221. aa=sref_fileread(virtualfile,'lins',,'E')
  222.  
  223. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  224. call lineout tempfile, "<html><head><title>SRE-http: modify virtual directorires </title>"
  225. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  226.  
  227. call lineout tempfile,'<!--  a button bar. --> 'crlf ,
  228.            '<a href="/configur.htm">Configurator</a>||' crlf ,
  229.            '<a href="/config2?todo=SET">Parameters</a>||' crlf ,
  230.            '<a href="/usercfg?todo=SET">Usernames</a>||'  crlf ,
  231.            '<a href="/realmcfg?todo=SET">Define-Realms</a>||'||crlf ,
  232.            '<a href="/accescfg?todo=SET">Access-Controls||'  crlf ,
  233.            '<a href="/aliascfg?todo=SET">Aliases</a>||'  crlf ,
  234.            '<a href="/virtcfg?todo=SET">VirtualDir</a><p>'  
  235.  
  236.  
  237. /* ignore header stuff */
  238. iat=0
  239. do until iat >= lins.0
  240.    iat=iat+1
  241.    if  abbrev(strip(lins.iat),';') | lins.iat=' ' then iterate
  242.    leave
  243. end /* do -- iat is the first non header comment line  */
  244. call lineout tempfile, "<h1> SRE-http: modify <A NAME="top">virtual</A> directories </h1> <p>"
  245. call lineout tempfile,' <blockquote> You can modify, remove, or add virtual directories'
  246. call lineout tempfile,' <br><em> Questions? <A HREF="#notes">The notes might help.</A> </em> </blockquote> '
  247.  
  248. call lineout tempfile,' <h2> Modify or remove current virtual directories </h2>'
  249. call lineout tempfile,'<FORM ACTION="/virtcfg" METHOD="POST">'
  250.  
  251. call lineout tempfile,' <table border=1> <th> Host Nickname <br> (see below  for a <br>listing of <A href="#hosts">current hosts</A>)  </th>'
  252. call lineout tempfile,' <th> Candidate SEL abbreviation <br> (set to blank to  delete the entry)</th>'
  253. call lineout tempfile,'  <th> Local or remote directory   </th> '
  254. call lineout tempfile,' <th> Allow subdirectories; <br> and optional limtation_list , user:pwd? </th><tr>'
  255.  
  256. nhidden=0 ; mm=0
  257. do mm0=iat to lins.0
  258.     alin=translate(lins.mm0,' ','1a000d0a'x)
  259.     mm=mm+1
  260.     if  abbrev(strip(alin),';')=1 | alin=' ' then do
  261.         nhidden=nhidden+1
  262.         hiddens.nhidden='<INPUT TYPE="HIDDEN" name="COMMENT.'||mm||'"  value="'||alin||'" >'
  263.         iterate
  264.     end
  265.  
  266. /* non comment */
  267.     if pos('// ',alin)>0 then
  268.              parse var alin hostname '//' candurl absdir limlist
  269.         else do
  270.              hostname='  '
  271.              parse var alin candurl absdir limlist
  272.      end  /* Do */
  273.      candurl=strip(candurl)
  274.      subdirok=0
  275.      if right(strip(absdir),1)='*' then do
  276.          absdir=delstr(absdir,length(absdir))
  277.          subdirok=1
  278.      end
  279.      call lineout tempfile,'<td> <EM>Host nickname:</EM> <br> <INPUT TYPE="text" NAME="hostname.'||mm||'"'
  280.      call lineout tempfile,'value="'hostname'" SIZE=8 MAXLENGTH=15> </td> '
  281.      call lineout tempfile,'<td> <EM>Candidate:</EM> <br> <INPUT TYPE="text" NAME="candurl.'||mm||'"'
  282.      call lineout tempfile,'value="'candurl'" SIZE=18 MAXLENGTH=55> </td> '
  283.      call lineout tempfile,'<td> <EM>Target:</EM> <br> <INPUT TYPE="text" NAME="absdir.'||mm||'"'
  284.      call lineout tempfile,'value="'absdir'" SIZE=18 MAXLENGTH=55> </td> '
  285.      call lineout tempfile,'  <td> <INPUT TYPE=CHECKBOX NAME="subdirok.'mm||'" '
  286.      if subdirok=1 then
  287.           call lineout tempfile,' CHECKED >Sub directories ok? <br> '
  288.      else
  289.          call lineout tempfile,' > Sub directories ok? <br> '
  290.      call lineout tempfile,' <br>'
  291.      call lineout tempfile,'<br> <EM>Limitation_list , user:pwd:</EM> <br> <INPUT TYPE="text" NAME="limlist.'||mm||'"'
  292.      call lineout tempfile,'value="'limlist'" SIZE=12 MAXLENGTH=35> </td> '
  293.  
  294.  
  295.      if mm0<lins.0 then do
  296.            call lineout tempfile,'<tr>' ; call lineout tempfile,' '
  297.      end
  298. end
  299. call lineout tempfile,' '
  300.  
  301. /* --- allow user to enter a few new names */
  302. call lineout tempfile,' </table>  <p> <h2> Add virtual directories </h2> <table border=1>'
  303. mm0=mm
  304. do mm=mm0+1 to mm0+3
  305.      call lineout tempfile,'<td> <EM>Host nickname:</EM> <br> <INPUT TYPE="text" NAME="hostname.'||mm||'"'
  306.      call lineout tempfile,'value=" " SIZE=8 MAXLENGTH=15> </td> '
  307.      call lineout tempfile,'<td> <EM>Candidate SEL:</EM> <br> <INPUT TYPE="text" NAME="candurl.'||mm||'"'
  308.      call lineout tempfile,'value=" " SIZE=18 MAXLENGTH=55> </td> '
  309.      call lineout tempfile,'<td> <EM>Fully qualified directory:</EM> <br> <INPUT TYPE="text" NAME="absdir.'||mm||'"'
  310.      call lineout tempfile,'value=" " SIZE=18 MAXLENGTH=55> </td> '
  311.  
  312.      call lineout tempfile,'  <td> <INPUT TYPE=CHECKBOX NAME="subdirok.'mm||'"> Sub directories ok? '
  313.      call lineout tempfile,'<br> <EM>Optional limitation_list , user:pwd :</EM> <br> <INPUT TYPE="text" NAME="limlist.'||mm||'"'
  314.      call lineout tempfile,'value=" " SIZE=14 MAXLENGTH=35> </td> '
  315.  
  316.      if mm<mm0+3 then call lineout tempfile,' <tr> '
  317. end
  318.  
  319. call lineout tempfile,'</table> <p>'
  320.  
  321.  
  322. /* ----- add comments information */
  323.  
  324. do jj=1 to nhidden
  325.    call lineout tempfile,hiddens.jj
  326. end /* do */
  327. call lineout tempfile,' <input type="hidden" name="entries" value="'||mm||'">'
  328. call lineout tempfile,' <input type="submit"> <input type="reset"> </form> '
  329.  
  330.  
  331. call lineout tempfile,' <hr> <h3> <A NAME="notes">Notes </A></h3> <ul> <li> Virtual directories are stored in: 'virtualfile
  332. call lineout tempfile,' <li> If a  <em>candidate SEL</em> is an abbreviation for a <em>request selector</em>, '
  333. call lineout tempfile,' <br> the associated <em>fully qualified directory </em> is used.'
  334. call lineout tempfile,' <li> The <em>optional </em> limitation_list can contain any of the following: <b> !HTML !ADDONS  !CGI-BIN !UPLOAD </b>'
  335. call lineout tempfile,' <li> To specify a "remote" directory (on another server), use a fully specified (http://...) URL '
  336. call lineout tempfile,' as the <em>fully qualified directory </em> '
  337. call lineout tempfile,' <br> The <em>optional</em> user:pwd can contain a user:pwd (i.e.; JOE:MONSTER). This is <u>only</u> '
  338. call lineout tempfile,' used with remote virtual directories. It must follow the limitation list and be preceded by a comma.'
  339.  
  340. call lineout tempfile,' <li> Do you want to view a  more complete description of '
  341. call lineout tempfile,' <a href="/samples/in_files.doc"> virtual directories </a>?'
  342. call lineout tempfile,' <li>View the <a href="/virtcfg?TODO=CURRENT"> current set of  virtual directories </a>?'
  343.  
  344. call lineout tempfile,' <li> To add more then 3 new virtual directories, just rerun this several times, <br> or edit ' virtualfile
  345. call lineout tempfile,' <li> <em>Comments are NOT displayed </em>  <li> Case is ignored '
  346. call lineout tempfile,' <li> Selecting <em>subdirectories ok </em> permits access to the subtree under the <em>fully qualified directory </em>'
  347. call lineout tempfile, ' <li> Entries with no <strong>host nickname</strong> will apply to all requests</ul> <br>'
  348.  
  349.  
  350. call lineout tempfile,' <h3> A list of the <A NAME="hosts">current hosts</A> </h3>  <blockquote> '
  351. ii=value(enmadd||'HOSTS.0',,'os2environment')
  352. if ii=0 then do
  353.    call lineout tempfile,'<strong>There are no hosts defined</strong>'
  354. end 
  355. else do
  356.   hlist=sref_value('$HOSTS.0',,'USE')
  357.   call lineout tempfile,' <table> <th> IP address </th> <th> Host Nickname </th> <th> Data Directory </th> <tr> '
  358.   do ll=1 to words(hlist)
  359.       hh=strip(translate(word(hlist,ll)))
  360.       wow=sref_value('$HOSTS.'||hh,,'use')
  361.       parse var wow ip ',' hn ',' hdir
  362.      call lineout tempfile,' <td> ' ip  '</td> <td> ' hn ' </td> <td> ' hdir '</td> <tr> '
  363.   end /* do */
  364.   call lineout tempfile,' </table> </blockquote>'
  365. end
  366.  
  367. call lineout tempfile,' <p> <A HREF="#top">Return to the top of this form.</A>'
  368.  
  369. call lineout tempfile,'</body></html>'
  370. call lineout tempfile
  371.  
  372. foo=sref_gos('file erase  type text/html name  ' tempfile)
  373. return ' done '
  374.  
  375.  
  376.  
  377. /******************** jump here to recrod changes */
  378. dochange:
  379. parse upper var list foo 'ENTRIES=' nentries '&' .
  380. do ii1=1 to nentries
  381.    fillme.ii1.0=0
  382. end /* do */
  383.  
  384. do until list=""
  385.    parse var list aa '&' list
  386.    parse upper var aa avar '.' aind '=' aval
  387.    aval=packur(aval)
  388.    if abbrev(avar,'ENTRIES=')=1 then iterate
  389.    wow=fillme.aind.0+1
  390.    fillme.aind.0=wow
  391.    fillme.aind.wow.var=avar ; fillme.aind.wow.val=aval
  392.    select
  393.       when avar="COMMENT" then do
  394.           fillme.aind.type='COMMENT'
  395.           parse  var aa foo '=' aval
  396.           fillme.aind.wow.val=packur(aval)
  397.       end
  398.       when avar="CANDURL" then fillme.aind.type='URL'
  399.       otherwise nop
  400.    end
  401. end /* do */
  402.  
  403. virtualfile=value(enmadd||'virtual_FILE',,'os2environment')
  404. aa=sref_fileread(virtualfile,'lins',,'E')
  405.  
  406. /* pull "header comments" */
  407. iat=0
  408. do until iat >= lins.0
  409.    iat=iat+1
  410.    if  abbrev(strip(lins.iat),';')  then do
  411.        newlines.iat=lins.iat
  412.    end  /* Do */
  413.    else do
  414.         leave
  415.    end
  416. end /* do -- iat is the first non header comment line  */
  417. iat=iat-1
  418.  
  419. do uu=1 to nentries
  420.    select
  421.       when fillme.uu.type='COMMENT' then do
  422.           iat=iat+1
  423.           newlines.iat=fillme.uu.1.val
  424.       end
  425.       when fillme.uu.type='URL' then do
  426.           candurl=' ' ; absdir=' ' ; hostname=' ';subdirok=' ';limlist=" "
  427.           do uu2=1 to fillme.uu.0
  428.              chk1=fillme.uu.uu2.var
  429.              vvv=fillme.uu.uu2.val
  430.              select
  431.                 when chk1='CANDURL' then candurl=vvv
  432.                 when chk1='ABSDIR' then absdir=vvv
  433.                 when chk1='HOSTNAME' then hostname=vvv
  434.                 when chk1="LIMLIST" then limlist=vvv
  435.                 when chk1='SUBDIROK' then subdirok='*'
  436.                 otherwise nop
  437.              end
  438.           end
  439.           if candurl<>' ' then do
  440.               iat=iat+1
  441.               newlines.iat=''
  442.               if hostname<>' ' then
  443.                   newlines.iat=hostname||'// '
  444.               if subdirok='*' then do
  445.                   if pos('HTTP:',upper(absdir))>0 then
  446.                       absdir=strip(absdir,'t','/')||'/'
  447.                   else
  448.                       absdir=strip(absdir,'t','\')||'\'
  449.                end
  450.               newlines.iat=newlines.iat||candurl' ' absdir||subdirok||' '||limlist
  451.           end
  452.       end
  453.       otherwise do
  454.             nop
  455.       end  /* Do */
  456.  
  457.   end                   /* select over type */
  458. end                     /* do over entries */
  459.  
  460. /* save to virtualfile.. but rename access_file first */
  461. foo=lastpos('.',virtualfile)
  462. if foo=0 then
  463.    acf1=virtualfile||'.'
  464. else
  465.    acf1=left(virtualfile,foo)
  466. do hi=1 to 999
  467.    try1=acf1||hi
  468.    if stream(acf1||hi,'c','query exists')='' then leave
  469. end /* do */
  470. foo=dosrename(virtualfile,try1)
  471. newlines.0=iat
  472. foo=sref_filewrite(virtualfile,newlines,'R')
  473.  
  474.  
  475. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  476. call lineout tempfile, "<html><head><titLE> SRE-http: Changed the virtual directories</title>"
  477. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  478.  
  479. call lineout tempfile,' <h2>The virtual directories have been changed </h2>'
  480. call lineout tempfile,' The list of virtual directories has been saved to: ' virtualfile
  481. call lineout tempfile,' <p> The old version of 'virtualfile' has been moved to ' try1
  482. call lineout tempfile,'<p> <a href="/config2.htm">Return to Intermediate Mode Configurator</a>'
  483.  
  484. call lineout tempfile,' </body> </html> '
  485. call lineout tempfile
  486.  
  487. foo=value('SREF_REDO',1,'os2environment')
  488.  
  489.  
  490. foo=sref_gos('FILE ERASE TYPE text/html NAME' tempfile)
  491. return 'done change '
  492.  
  493.  
  494.  
  495.  
  496. /* ------------------------------------------------------ */
  497. /* query and wait on helper thread */
  498. /* ------------------------------------------------------*/
  499. wait_queue:procedure expose enmadd transaction semqueue host_nickname
  500. parse arg athread
  501. again1t:
  502.  
  503. parse var semqueue mysem myqueue
  504.  
  505. basesem='\SEM32\'||enmadd
  506.  
  507. goober=enmadd||athread
  508.  a=rxqueue('s',goober)
  509.  queue  transaction ' ' host_nickname ',' myqueue ',' mysem ', *LIST* '
  510.  
  511.   a=eventsem_reset(mysem)
  512.   dothread=basesem||athread
  513.  
  514.   a=eventsem_post(dothread)
  515. again2t:
  516.   a=eventsem_wait(mysem,90000)  /* max wait of 90 seconds */
  517.  
  518.   if a<>0 then do
  519.         ss=sref_error(mytid','athread' A Fatal Semaphore failure: 'a,1)
  520.         'response HTTP/1.1 503 Service Unavailable'
  521.         String 'Web server is temporarily busy '
  522.         exit ' '
  523.   end
  524.   a=rxqueue('s',myqueue)
  525.  
  526.   parse pull aline
  527.  
  528.   PARSE VAR ALINE idnum ',' aline
  529.   idnum=strip(translate(idnum,' ','000d0a'x));TRANSACTION=STRIP(TRANSACTION)
  530.   if idnum<>transaction then  do /*wierd error: got someone else's message! */
  531.         ss=sref_error(mytid','athread' A  Semaphore failure: 'a,1)
  532.         'response HTTP/1.1 503 Service Unavailable'
  533.         String 'Web server is temporarily busy '
  534.         exit ' '
  535.   end
  536.  
  537.   return aline
  538.  
  539.  
  540.  
  541.