home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / CONFCOLR.CMD < prev    next >
OS/2 REXX Batch file  |  1998-04-12  |  5KB  |  173 lines

  1. /* modify the colors used in the SRE-http configurator routines */
  2.  
  3. parse arg  ddir, tempfile, reqstrg,list,verb ,uri,user, ,
  4.           basedir ,workdir,privset,enmadd,transaction,verbose, ,
  5.          servername,host_nickname,homedir
  6.  
  7. if verb="" then do
  8.    say " This SRE-http add-on is NOT meant to be run from the command line."
  9.    say " It can be invoked by using CONFIGUR.HTM "
  10.    exit
  11. end  /* Do */
  12.  
  13. /* chekc for needed_privs superuser */
  14. if wordpos('SUPERUSER',upper(privset))=0 then do
  15.     'header add WWW-Authenticate: Basic Realm=<CONFIGURE>'  /* challenge */
  16.      return sref_response('unauth', "You do not have Superuser privileges ",tempfile,servername)
  17. end
  18.  
  19. addon_dir=value(enmadd||'ADDON_DIR',,'os2environment')
  20.  
  21.  call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  22.  
  23.   call lineout tempfile, "<html><head><title>SRE-http: Modify Configurator Colors  </title>"
  24.   call lineout tempfile, "</head><body>"
  25.   call lineout tempfile,' <h1>Modify Configurator Colors </h1> <hr>'
  26.  
  27. do until list=""                /* get user input */
  28.    parse var list a1 '&' list
  29.    parse var a1 a1a '=' a1b
  30.    ook='!'||strip(upper(a1a))
  31.    stuff.ook=strip(upper(a1b))
  32. end /* do */
  33.  
  34. /* check custom colors for proper syntax */
  35. checks="!CONFIG !CONFIG0 !CONFIG2 !CONFIG3 "
  36. checks2="!CONFIGC !CONFIG0C !CONFIG2C !CONFIG3C "
  37.  
  38. mess.1='Configurator Introduction'
  39. mess.2='Simple mode configurator'
  40. mess.3='Intermediate mode configurator'
  41. mess.4='Expert mode configurator'
  42.  
  43. do mm=1 to 4
  44.    ae=strip(word(checks,mm))
  45.    is1=stuff.ae
  46.    if is1 <>3 then iterate
  47.    ill=strip(word(checks2,mm))
  48.    af=left(stuff.ill,6)
  49.    woo=verify(af,'0123456789ABCDEF')
  50.    if woo>0 then do
  51.       call lineout tempfile,' <h2>Error in Color Entry </h2> <hr>'
  52.       call lineout tempfile,'<b>'af '</b>, your color entry for the ' mess.mm ', is invalid '
  53.       call lineout tempfile, ' <bR> The entry must be contain six hex (0123456789ABCDEF) digits '
  54.       call lineout tempfile,'</body></html>'
  55.       call lineout tempfile
  56.      fpp=sref_gos('FILE ERASE TYPE text/html NAME' tempfile)
  57.       return 'Error in FIXCOLOR'
  58.    end
  59. end /* do */
  60.  
  61.  
  62. /* now change the colors
  63. DEFAULTS:
  64. INTRO: '10e581'
  65. SIMPLE :'3DEF5F'
  66. INTERMEDIATE: '2DD52F'
  67. ADVANCED: '40C541'
  68. */
  69.  
  70.  
  71. /* FIRST: the configurator intro  */
  72.  
  73. usec='CCCCCC'
  74. if stuff.!config=1 then usec='10e581 '
  75. if stuff.!config=3 then usec=stuff.!configc
  76. useme='<BODY bgcolor="#'||usec||'" > '
  77.  
  78. call htmlfix 'CONFIGUR.HTM'
  79.  
  80. call lineout tempfile,'<br> Configurator introduction color: ' usec ' ( <font color="#'||usec||'"> XXXXXXXXXXXXXXXXXXXXXXX </font><p>'
  81.  
  82.  
  83. /* SECOND:the simple mode configurator  */
  84.  
  85. usec='BBBBBB'
  86. usec="3def5f" 
  87. if stuff.!config0=3 then usec=stuff.!config0c
  88. useme='<BODY bgcolor="#'||usec||'" > '
  89.  
  90. call htmlfix 'CONFIG0.HTM'
  91. call cmdfix 'SREFCONF.CMD'
  92.  
  93. call lineout tempfile,' <br> Simple  mode Configurator color: '  usec ' ( <font color="#'||usec||'"> XXXXXXXXXXXXXXXXXXXXXXX </font><p>'
  94.  
  95.  
  96. /*  THIRD: the intermediate mode configurator */
  97. usec='DDDDDD'
  98. if stuff.!config2=1 then usec='2dd52f'
  99. if stuff.!config2=3 then usec=stuff.!config2c
  100. useme='<BODY bgcolor="#'||usec||'" > '
  101.  
  102. call htmlfix 'CONFIG2.HTM'
  103.  
  104. call cmdfix 'CONFIG2.CMD'
  105. call cmdfix 'VIRTCFG.CMD'
  106. call cmdfix 'ALIASCFG.CMD'
  107. call cmdfix 'ACCESCFG.CMD'
  108. call cmdfix 'USERCFG.CMD'
  109. call cmdfix 'HTACCFG.CMD'
  110.  
  111. call lineout tempfile,' <br> Intermediate mode Configurator color: '  usec ' ( <font color="#'||usec||'"> XXXXXXXXXXXXXXXXXXXXXXX </font><p>'
  112.  
  113. /* FOURTH: the expert mode configurator */
  114.  
  115. usec='aaaaaa'
  116. if stuff.!config3=1 then usec='40C541'
  117. if stuff.!config3=3 then usec=stuff.!config3c
  118. useme='<BODY bgcolor="#'||usec||'"> '
  119. call htmlfix 'CONFIG3.HTM'
  120. call lineout tempfile,' <br> Expert mode Configurator color: '  usec ' ( <font color="#'||usec||'"> XXXXXXXXXXXXXXXXXXXXXXX </font>'
  121.  
  122.  
  123. call lineout tempfile,'</body></html>'
  124. call lineout tempfile
  125. fpp=sref_gos('FILE ERASE TYPE text/html NAME' tempfile)
  126. return 'FIXCOLOR completed'
  127.  
  128.  
  129. /********** change bgcolor in html file, use global useme */
  130. htmlfix:
  131. parse arg bfile
  132.  
  133. afile=strip(translate(ddir,'\','/'),'t','\')'\'||bfile
  134. if stream(afile,'c','query exists')='' then do
  135.       call lineout tempfile,'<br> Configurator document file,'afile', could not be found '
  136.       return 0
  137. end  /* Do */
  138. foo=charin(afile,1,chars(afile))
  139. parse var foo t1 '<BODY ' . '>' t3
  140. woops=t1||useme||t3
  141. foo=sysfiledelete(afile)
  142. op=charout(afile,woops,1)
  143.  call lineout tempfile,' <br> Successfully modified (HTML document): ' afile
  144.  
  145. return 1
  146.  
  147.  
  148. /********* part 3 fixer (uses global usec )*/
  149. cmdfix:
  150. parse arg ado
  151.  
  152. /* 3rd part 4: the intermediate mode configurator 
  153. The files are expected to be in the addon directory.
  154. If not there, we give up */
  155. afile=strip(translate(addon_dir,'\','/'),'t','\')'\'ado
  156. if stream(afile,'c','query exists')='' then do
  157.       call lineout tempfile,' <br> Configurator file, 'afile', could not be found '
  158.       return 0
  159. end  /* Do */
  160. foo=charin(afile,1,chars(afile))
  161. crlf='0d0a'x
  162.  
  163. oops=pos('USECOLOR=',upper(foo))
  164. oop2=pos(crlf,foo,oops)
  165. t1=left(foo,oops-1)
  166. t3=substr(foo,oop2+2)
  167. woops=t1||"USECOLOR='"||usec||"'"||crlf||t3
  168. foo=sysfiledelete(afile)
  169. op=charout(afile,woops,1)
  170.   call lineout tempfile,' <br> Successfully modified (configuration file): ' afile
  171. return 0
  172.  
  173.