/*3/97. this is the SRE-FILTER configuration routine */ /* to add variables: 1) Create a new Param.nn line (say, Param.30='NEW_CONTROL') 2) Create a new set of output lines in the DISPLAY THEM section 3) Create a new set of output lines in the CHANGE THEM section */ config2: CHECKIT=0 /* Change this to 0 if you want to enable REMOTE configuration by SUPERUSERS */ USECOLOR='2dd52f' /* ---------------- DO NOT MODIFY BELOW THIS LINE ------------------ */ parse arg ddir,tempfile,sel,list,verb,uri,user,basedir,workdir,privset, , enmadd,transaction,verbose,servername,host_nickname,homedir if verb="" then do say " This SRE-Filter procedure is not meant to be run in stand-alone mode. " say " You should invoke it using CONFIGUR.HTM ! " exit end /* Do */ list=translate(list, ' ', '+'||'090a0d'x) /* Whitespace, etc. */ crlf = '0d0a'x who2=extract('CLIENTADDR') saddr2=extract('SERVERADDR') select when checkit=1 then do /* only if user = serveraddress !!! */ if who2<>saddr2 then do call lineout tempfile, '' call lineout tempfile, "
' call lineout tempfile,' ' call lineout tempfile 'FILE ERASE TYPE text/html NAME' tempfile return 'CONFIG2: action not allowed remotely. ' end end otherwise do if wordpos('SUPERUSER',privset)=0 then do 'header add WWW-Authenticate: Basic Realm=' /* challenge */ call lineout tempfile, '' call lineout tempfile, " Not authorized " call lineout tempfile, '' call lineout tempfile,' You do not have configuration rights.' if who2=saddr2 then call lineout tempfile,'
You may want to edit CONFIG2.CMD ' call lineout tempfile,' ' call lineout tempfile return sref_response('unauth', "You do not have configuration rights ",tempfile,servername) end end end /* go get initfilt */ aport=extract(serverport) afile=basedir||"\INITFILT."||aport /* the following directories and files are subject to change */ fd.1="messbox_dir" /* location of message boxes */ fd.2="tempfile_dir" /* workspace for server side programs */ fd.3="counter_file" /* used by REPLACE HITS and REPLACE COUNTS keyphrase */ fd.4="record_all_file" /* used if record_option =YES or YES_ALL */ fd.5="sendfile_file" /* used by the SENDFILE facility*/ fd.6="access_file" /* used if ALLOW_ACCESS=YES or INHOUSE*/ fd.7="alias_file" /* list of aliases */ fd.8="repstrgs_file" /* custom written variables for REPLACE keyphrase */ fd.9="user_file" /* username/password/privileges file */ fd.10="upload_dir" /* upload directory (used by GET_URL) */ fd.11="upload_log" /* log file for upload tracking */ fd.12="cgi_bin_dir" /* cgi-bin directory */ fd.13="virtual_file" /* file containing virtual directory information */ fd.14="mailbox_dir" /* location of incoming e-mail box */ fd.15="tempdata_dir" /* workspace for srefilter */ fd.16="workdata_dir" /* permanent sre-filter "data file" directory */ fd.17='logon_fail_file' /* file sent if logon failure */ fd.18='access_fail_file' /* file sent if sel-specific access failure */ fd.0=18 do mm=1 to fd.0 fd.mm=translate(strip(fd.mm)) end /* IF THE VERB IS POST-- THEN THIS IS A "WRITE INFO CALL IF IT'S GET, THEN ITS A "SHOW INFO" OR "LET ME CHANGE INFO" CALL */ if translate(verb)="POST" then signal write_it /* IF HERE, VERB=GET --- so show vars or request changes */ parse upper var list foo '=' todo ll=list nickname=' ' do until ll=' ' parse var ll a1 '&' ll parse var a1 a1a '=' a2a ; a2a=packur(a2a) ; a1a=packur(a1a) if upper(a1a)='TODO' then todo=upper(a2a) if upper(a1a)='HOST_NICKNAME' then nickname=strip(upper(a2a)) end /* do */ /* read initfilt.80 file into internal storage */ FOO=fileREAD(AFILE,'FILELINES',,'E') IF FOO=0 THEN DO SAY " CONFIG2 ERROR: COULD NOT READ INITFILT FILE " 'String Error reading initfilt file ' return "CONFIG2 ERROR: Could Not read INITFILT FILE " end /* convert < to < and > to > */ i=0 do mm=1 to filelines.0 big=fix_me(filelines.mm) filelines.mm.igot=0 /* fill this is later */ filelines.mm.name=0 /* assume it's comment/blank */ filelines.mm.stem=' ' /* assume is non stem var */ filelines.mm.value=' ' if big <>" " then do big=sref_replacestrg(big,'<','<','all') big=sref_replacestrg(big,'>','>','all') filelines.mm=big if abbrev(strip(big),';')=0 then do parse var big atype '=' avalue if words(atype)=1 then do parse upper var atype aname '.' astem filelines.mm.name=upper(strip(aname)) filelines.mm.value=strip(strip(avalue),,"'") if astem<>' ' then filelines.mm.stem=astem opop=filelines.mm.name if nickname=' ' & verify(astem,'0123456789 .')>0 then do nop /* no nickname, but nickname in entry */ end else do if symbol('quiklist.opop')='VAR' then do quiklist.opop=quiklist.opop' 'mm end else do quiklist.opop=mm end /* quiklist */ end /* verify/nickname */ end /* one work name */ end /* comment */ end /* not ' ' line */ end /* loop over lines */ /* the following is a list of parameters that we will adjust (if end in ., it's a stem variable)*/ /* logon control variables */ param.1="checklog" /* whether require logon: NO YES ALWAYS INHOUSE*/ param.2="owners" /* list of owners */ param.3="inhouseips." /* stem variable of inhouse ips */ param.4="unallowedips." /* stem variable of unallowed ip */ /* request string modification variables */ param.5="default" /* the default page : A file name relative to ddir*/ param.6="xxxyyyzzz" /* fill in later */ param.7="home_dir" /* the ~ substitution */ param.8="auto_name" /* list of potential "default documents" for directories */ /* access and auditing variables */ param.9="allow_access" /*File specific: YES=no control, INHOUSE=inhouse only, NO=Superusrs */ param.10="record_option" /*NO YES YES_ALL FILE arguments*/ param.11="verbose" /* */ /* stem variables for REPLACE keyphrase */ param.12="headers." /* stem variable of headers */ param.13="footers." /* stem variable of footers */ param.14="inhouse." /* stem variables for replace inhouse. static variables */ param.15="superuser." /* stem variables for replace superuser. static variables*/ /* static variables for REPLACE keyphrase */ param.16="webmaster" /* string containing the webmasters url */ param.17="home_name" /* colloquial name of this server */ /* misc. static variables (used for a variety of internally generated messages */ param.18="the_realm" /* Colloquial name of "inhouse" folks*/ param.19="option_hit_line" /* variable used with option_hit.n and option_count.n */ param.20="not_found_url" /* string returned with 404 error */ /* late additions */ param.21="INHOUSE_PRIVS" param.22="PUBLIC_PRIVS" param.23="PUBLIC_URLS." /* stem var of public urls */ param.24="AUTO_HEADER" param.25="UPLOAD_MAXSIZE" param.26="UPLOAD_MINFREE" param.27="NOEXT_TYPE" param.28="POST_FILTER" param.29="PRE_FILTER" param.30="DNS_CHECK" param.31="SMTP_GATEWAY" param.32='SSI_SHTML_ONLY' param.33='HOSTS.' param.34='DO_HTACCESS' param.35='FIX_EXPIRE' param.36='HIT_CACHE_LEN' param.37='HIT_CACHE_DURATION' param.38='HIT_OWNER_SUPPRESS' param.39='CHECK_ADD_PRIVS' param.40='DIR_OPTIONS' param.41='DIR_EXCLUSION' param.42='SSI_CACHE_ON' param.43='WRITE_LOGS' param.0=43 do mm=1 to param.0 param.mm=strip(translate(param.mm)) param.mm.stem=0 if pos('.',param.mm)>0 then param.mm.stem=1 param.mm=strip(param.mm,,'.') end /* Note that a number of variables will NOT be settable by this program. Ambitious users can go into INITFILT.80 and edit these parameters. */ /* ************************ DISPLAY THEM --------------------------------*/ if todo="SHOW" then do call lineout tempfile, '' call lineout tempfile, "SRE-Filter Configurator: Current Parameters " call lineout tempfile, '' call lineout tempfile,"
Current Settings of SRE-FILTER's Parameters
" if nickname<>'' then do call lineout tempfile,'For parameters specific to the ' nickname ' host.
' call lineout tempfile,'You selected ' nickname ' as the target "host nickname" ' call lineout tempfile,' The top half of this document contains only parameters specific to ' nickname '. ' call lineout tempfile,' Non host-specific parameters, which are used when a host-specific parameter is ' call lineout tempfile,' not specified, are listed at ' call lineout tempfile,' the bottom half of the document. ' end /* Do */ call lineout tempfile, 'Logon Control Variables
PUBLIC_URLS
HOST Identifiers
Request modification variables
Reponse header creation, Pre and Post filters
File access and auditing variables
SSI control and stem variables for REPLACE keyphrase
Other variables for REPLACE keyphrase
Upload control, and E-Mail support, variables
Miscellanous variables (used for error messages, etc.)
Files and Directories ..
' call lineout tempfile,'
Other SRE-FILTER Parameters
' call lineout tempfile,' Note that the following parameters and filenames:' call lineout tempfile,'
- Either apply to a different HOST. To change them, ' call lineout tempfile,' re-run this configurator with a different HOST NICKNAME' if nickname<>' ' then do call lineout tempfile,'
- Are non-host specific parameters (which may' call lineout tempfile,' be used if there is no host-specific entry for the parameter)' end call lineout tempfile,'
- Are parameters that this configurator will not modify.' call lineout tempfile," To change them, you'll have to edit INITFILT."aport call lineout tempfile,'
' call lineout tempfile, '
' call lineout tempfile,' ' call lineout tempfile,'Note: REXX Comments may point to parameter-entry errors! ' call lineout tempfile,'
' call lineout tempfile tt=sref_expire_response(0.05,dosdir(tempfile,'s')) 'FILE ERASE TYPE text/html NAME' tempfile return ' ' end /* **************** CHANGE THEM --------------------------------. */ else do call lineout tempfile, '' call lineout tempfile, "SRE-Filter Intermediate Mode Configurator: Modify Parameters " call lineout tempfile, '' call lineout tempfile,'SRE-Filter Configurator: Intermediate Mode
' call lineout tempfile,'Change parameter values
' call lineout tempfile,'This form allows you to change most (but not all) of the SRE-Filter parameters. ' call lineout tempfile,'The current values are shown, and are retained if not explicitily modified.' if nickname<>' 'then do call lineout tempfile,'You selected the ' nickname ' host nickname.' call lineout tempfile,' Parameters specific to ' nickname ' ' call lineout tempfile,'will be displayed (and modified). ' call lineout tempfile,'
Note: When a ' nickname ' specific parameter is not available,' call lineout tempfile,' the default (non host-specific) version is used.' end /* Do */ call lineout tempfile,'If the explanations here are insufficient, ' call lineout tempfile,' INITFILT.DOC' call lineout tempfile,'might help!' call lineout tempfile,'
' call lineout tempfile,' Notes:' if nickname<>' ' then do call lineout tempfile,'
- If you want to leave a field blank, we advise inserting a 0 -- since SRE-Filter will attempt ' call lineout tempfile,' to use the default (non host-specific) parameter whenever it finds an empty variable (this' call lineout tempfile,' is a design "feature" ' " of REXX's use of the OS/2 environment)!
" end call lineout tempfile,'- To change the "more obscure" parameters not mentioned here you will have to' call lineout tempfile,' edit INITFILT.'||aport ' by hand (see INITFILT.DOC for details) ' call lineout tempfile,'
- A caution: ' call lineout tempfile," do not use
single quote
(') characters (they will cause errors)!" call lineout tempfile,'
' call lineout tempfile,'
' call lineout tempfile,'Special feature: Look up an IP address
' call lineout tempfile,' For several of these variables (i.e.; OWNERS), numeric IP ' call lineout tempfile,' addresses are expected. If you need to lookup a numeric address:' call lineout tempfile,' ' call lineout tempfile,'
' call lineout tempfile end tt=sref_expire_response(0.05,dosdir(tempfile,'s')) 'FILE ERASE TYPE text/html NAME' tempfile return ' Done with Config2 -- submitted parameters ' /****************************************************/ /* JUMP HERE ON POST CALLS, which are always "write info" calls */ /* you should never need to modify this */ write_It: nop crlf = '0d0a'x ooks=fd.1 do pp=2 to fd.0 ooks=ooks||' '||fd.pp end call lineout tempfile, '' call lineout tempfile, "FILTINST Results " call lineout tempfile, '' call lineout tempfile,'SRE-FILTER Configurator
' foo=stream(afile,'c','query exists') if foo="" then do call lineout tempfile,' Warning: Old INITFILT.'aport ' did not exist ' end else do acf1='INITFILT.B' do hi=1 to 99 try1=acf1||hi if stream(acf1||hi,'c','query exists')='' then leave end /* do */ foo=dosrename(aFILE,try1) CALL LINEOUT TEMPFILE,'The old version of ' Afile ' has been saved as ' try1 end /* Parse the argument list. Extract current file (in LINES.n) variables to the FILELINES. array. Check for arguments. Note that if no arguments, error. */ param.0=0 ; fparam.0=0 do until list="" parse var list a0 '&' list parse var a0 a1 '=' a2 a1=packur(a1) ; a2=strip(packur(a2)) a1=upper(strip(a1)) select when abbrev(a1,'LINES.')=1 then do parse var a1 foo '.' ith a2=translate(a2,' ','+') filelines.ith=packur(a2) end /* Do */ when abbrev(a1,'NICKNAME')=1 then do nickname=a2 end otherwise do a2=translate(a2,' ','+') if wordpos(a1,ooks)>0 then do fparam.0=fparam.0+1 ; IARF0=fPARAM.0 fparam.iarf0=a2 ; fparam.iarf0.name=a1 end /* Do */ else do param.0=param.0+1 ; IARF=PARAM.0 param.IARF=a2 ; PARAM.IARF.NAME=A1 end end end end POOP=afile call lineout poop,'; Last modified on : ' time() ' ' Date() do mm=1 to filelines.0 aa=sref_replacestrg(filelines.mm,'<','<','ALL') aa=sref_replacestrg(aa,'>','>','ALL') if aa=' ' then iterate if abbrev(aa,'; Last modified on')=1 then iterate call lineout POOP,packur(aa) end /* do */ do mm=1 to fparam.0 yow=fPARAM.MM.NAME "= '"fPARAM.MM "'" yow=translate(yow,' ','000d0a1a'x) call lineout POOP,yow end do mm=1 to param.0 gosh1=param.mm ; name1=param.mm.name ; inthis=0 if pos('.',name1)>0 then do /* is a stem var */ do until gosh1="" parse var gosh1 al1 (crlf) gosh1 al1=packur(translate(al1,' ','0d0a00'x)) if al1=' ' then iterate inthis=inthis+1 if nickname=' ' | abbrev(upper(name1),'HOSTS')=1 then do yow=name1||inthis " = '" al1 "' " end else do yow=name1||inthis||'.'||nickname " = '" al1 "' " end yow=translate(yow,' ','000d0a1a'x) call lineout poop, yow end /* do */ end /* Do */ else do param.mm=packur(param.mm) if nickname=' ' then do yow=PARAM.MM.NAME "= '"PARAM.MM "'" end else do yow=PARAM.MM.NAME||'.'||nickname|| "= '"PARAM.MM "'" end yow=translate(yow,' ','000d0a1a'x) call lineout poop,yow end end /* do */ CALL LINEOUT POOP call lineout tempfile,'' afile ' succesfully created.' call lineout tempfile,'
' call lineout tempfile foo=value('SREF_REDO',1,'os2environment') tt=sref_expire_response(0.05,dosdir(tempfile,'s')) 'FILE ERASE TYPE text/html NAME' tempfile return 'Done with FILTINST -- saved parameters' /********************************************/ /* --- create a row of radio buttons */ do_radio: procedure expose param. filelines. v. tempfile nickname quiklist. parse arg ith,inlist,nonick unickname=nickname if nonick=1 then unickname=' ' got1=0 ; domark=1 /* domark=0 prevents marking for comments -- use on 2nd pass */ foobax: do jj=1 to inlist v2.jj=' ' end findit=strip(param.ith) if symbol('quiklist.findit')<>'VAR' then do /* no candiate entries */ call lineout tempfile,' ' v.mm ' , ' return ' ' end /* look at candidates only */ candlist=quiklist.findit do mm0=1 to words(candlist) mm=strip(word(candlist,mm0)) if mm=' ' then iterate bval=strip(upper(filelines.mm.name)) if bval<>findit then iterate /* check nickname stuff */ if unickname<>' ' then do /* check for .nickname at end of name */ if pos(unickname,filelines.mm.stem)=0 then iterate end /* Do */ if unickname=' ' & filelines.mm.stem<>' ' & nonick<>1 then do /* check for nickname */ foo1=lastpos('.',filelines.mm.stem) if datatype(substr(filelines.mm.stem,foo1+1))<>'NUM' then iterate end /* Do */ if domark=1 then FILELINES.MM.IGOT=1 got1=1 do mm2=1 to inlist cval=strip(filelines.mm.value) if v.mm2=cval then v2.mm2="CHECKED" else v2.mm2=' ' end end /* always use last match, if more then one */ if got1=0 then do if unickname=' ' | nonick>0 then nop else do unickname=' ' ; domark=0 signal foobax /* try looking for non host specific value */ end end do mm=1 to inlist call lineout tempfile,' ' v.mm ' , ' end return isit /***********************************/ /* write out values for a variable (or a stem variable ) isfile=1 use file list isfile=2 don't use hostnickname */ write_1:procedure expose param. filelines. tempfile fd. nickname quiklist. parse arg iat,isfile unickname=strip(nickname) if isfile>0 then unickname=' ' isstem=0 ;dostem=0 if isfile<>1 then do findit=param.iat dostem=param.iat.stem end else do findit=fd.iat end towrite=0 /* search filelines for findit */ if symbol('quiklist.findit')<>'VAR' then do /* no candiate entries */ call lineout tempfile, "" findit " = n.a.
" return ' ' end /* look at candidates only */ candlist=quiklist.findit do mm0=1 to words(candlist) mm=strip(word(candlist,mm0)) if mm=' ' then iterate if unickname<>' ' & filelines.mm.stem=' ' then iterate if filelines.mm.name=findit then do if unickname<>' ' & pos(unickname,filelines.mm.stem)=0 then iterate if unickname=' ' & filelines.mm.stem<>' ' then do /* check for unickname */ foo1=lastpos('.',filelines.mm.stem) if datatype(substr(filelines.mm.stem,foo1+1))<>'NUM' then iterate end /* Do */ wow1=filelines.mm.value filelines.mm.igot=1 if dostem=0 then do towrite=1 dowrite="" ||findit ||" = "|| wow1 ||'
' iterate /* get latter ones? */ end astem=filelines.mm.stem if unickname=' ' & pos('.',astem)>0 then iterate poop='.'||unickname if unickname<>' ' then astem=sref_replacestrg(astem,poop,'') if unickname<>' ' then astem=sref_replacestrg(astem,unickname||'.','') towrite=towrite+1 dowrite.towrite=""|| findit ||'.' ||astem ||" = " ||wow1|| '
' isstem=1+isstem end end select when towrite=0 then call lineout tempfile, "" findit " = n.a.
" when dostem=0 then call lineout tempfile,dowrite otherwise do do mm=1 to towrite call lineout tempfile,dowrite.mm end end end return ' ' /* ----------- */ /* get environment value, possibly host specific */ /* ------------ */ get_value: procedure expose enmadd host_nickname parse arg vname,hname0 if hname0=0 then hname=' ' else hname=strip(host_nickname) vname=strip(vname) ; if hname<>' ' then do aval=value(enmadd||vname||'.'||hname,,'os2environment') if aval<>' ' Then return aval end aval=value(enmadd||vname,,'os2environment') return aval /* ************************************** get current value of a parameter. If stem variable, return in sorted order nonick=' ' -- check for nickname 1= never check nickname 2= only check for nickname */ find_val:procedure expose param. filelines. nickname quiklist. parse arg ith,nonick unickname=nickname if nonick=1 then unickname=' ' findit=param.ith isstem=param.ith.stem domark=1 /* domark=0 prevents marking for comments -- use on 2nd pass */ if symbol('quiklist.findit')<>'VAR' then do /* no candiate entries */ return ' ' end bowser: gots=0 dowrite=0 /* look at candidates only */ candlist=quiklist.findit do mm0=1 to words(candlist) mm=strip(word(candlist,mm0)) if mm=' ' then iterate aval=filelines.mm.name if aval<>findit then iterate if unickname<>' ' then do /* check for unickname at end of name */ if pos(unickname,filelines.mm.stem)=0 then iterate end /* Do */ if unickname=' ' & filelines.mm.stem<>' ' then do /* check for unickname */ foo1=lastpos('.',filelines.mm.stem) if datatype(substr(filelines.mm.stem,foo1+1))<>'NUM' then iterate end /* Do */ if domark=1 then FILELINES.MM.IGOT=1 gogo=translate(filelines.mm.value, ' ','00090a0d'x) if isstem=0 then do dowrite=1 towrite=gogo end else do dowrite=1 if filelines.mm.stem=' ' then iterate /* bad entry */ fii=translate(filelines.mm.stem,' ','.') ; fii=strip(word(fii,1)) if datatype(fii)<>'NUM' then iterate got.value.fii=gogo gots=max(gots,fii) end end /* all lines in file */ if dowrite=0 then do if unickname=' ' | nonick>0 then return ' ' unickname=' ' ; domark=0 signal bowser /* try looking for non host specific value */ end if isstem=0 then return towrite eek=' ' do jj=1 to gots if symbol('got.value.jj')<>'VAR' then iterate eek=eek||strip(got.value.jj)||'0d0a'x end /* do */ return strip(eek) /* ***************** fill in file names */ find_fnames: procedure expose fd. filelines. do mm=1 to fd.0 findit=strip(fd.mm) do mm2=1 to filelines.0 aval=strip(filelines.mm2.name) if aval<>findit then iterate fd.mm.val=filelines.mm2.value FILELINES.MM2.IGOT=1 leave end /* do */ end /* do */ return 0 /* --- variable names of convert foo.bar.1 to foo.1.bar */ fix_me:procedure parse arg a1 if a1=' ' then return a1 a1=strip(a1) if abbrev(a1,';') then return a1 parse var a1 aname '=' avalue if pos('.',aname)=0 then return a1 foo=translate(aname,' ','.') if words(foo)<>3 then return a1 /* if here, array.x.y (3 elements) */ if datatype(word(foo,3))='NUM' & datatype(word(foo,2))<>'NUM' then do /* rearrange */ foo2=word(foo,1)||'.'||word(foo,3)||'.'||word(foo,2)||' = '||avalue return foo2 end /* Do */ else do return a1 end /* Do */