/* This is the STATUS demo of SRE-FILTER's server side proceessing
Use STATUS.HTM to invoke this routine.
*/
status:
parse arg ddir, tempfile, reqstrg,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 standalone mode "
exit
end /* Do */
list=translate(list, ' ', '+'||'090a0d'x) /* Whitespace, etc. */
/* special request: initialize dircache */
if pos('INIT_DIRCACHE=1',upper(list)) then do
if wordpos('SUPERUSER',upper(privset))=0 then do
'header add WWW-Authenticate: Basic Realm=' /* challenge */
return sref_response('unauth', "You do not have !DIR cache deletion rights ",tempfile,servername)
end /* Do */
call init_dircache
'FILE ERASE TYPE text/html NAME' tempfile
return 'Done with STATUS (initialize !dir cache)'
end /* Do */
/* Information will be returned in a temporary file, whose name
is provided in the tempfile variable.
Note that it's a good idea to start your HTML documents with a dtd doctype statement
*/
call lineout tempfile, ''
call lineout tempfile, "
Results from STATUS request"
call lineout tempfile, ""
call lineout tempfile,' Results from Status Request
'
call lineout tempfile,' The arguments recieved by STATUS
'
call lineout tempfile,' '
call lineout tempfile,' - DDIR =
' ddir '
'
call lineout tempfile,' - The "data directory" (where your HTML documents should be) '
call lineout tempfile,'
- TEMPFILE =
' tempfile '
'
call lineout tempfile,' - The "temporary file" (used to build this response)'
call lineout tempfile,'
- ACTION =
' reqstrg '
'
call lineout tempfile,' - The action portion of the request selector'
call lineout tempfile,'
- LIST =
' list '
'
call lineout tempfile,' - The parameters: '
call lineout tempfile, '
... if POST method, from the "body" of the request '
call lineout tempfile,'
... if GET method , from after the "?" in the request selector. '
call lineout tempfile,' - VERB =
' VERB '
'
call lineout tempfile,' - The HTTP method '
call lineout tempfile,'
- URI =
' URI '
'
call lineout tempfile,' - The full request string '
call lineout tempfile,'
- USER =
' user '
'
call lineout tempfile,' - USERS ip addrees '
call lineout tempfile,'
- BASEDIR =
' basedir '
'
call lineout tempfile,' - The "working directory" (where SRE-FILTER and GoServe live) '
call lineout tempfile,'
- WORKDIR =
' workdir '
'
call lineout tempfile,' - Temporary working files area (for user-supplied programs ) '
call lineout tempfile,'
- Your privileges are: '
call lineout tempfile,'
-
' privset '
'
call lineout tempfile,' - The host nickname '
call lineout tempfile,'
-
' host_nickname '
'
call lineout tempfile, ' - The ~ (home directory) string '
call lineout tempfile,'
-
' homedir '
'
call lineout tempfile,'
'
/* Read the "header" -- and display the results */
'READ HEADER VAR FOO '
call lineout tempfile,' The Request Header
'
call lineout tempfile,' ' foo '
'
call lineout tempfile,' Some User & Server Info
'
/* This section demonstrates the use of some GOSERVE functions */
cname=clientname()
caddr=extract('CLIENTADDR')
ssoft=server()
sname=servername
saddr=extract('SERVERADDR')
sport=extract('SERVERPORT')
call lineout tempfile,' '
call lineout tempfile,' - Client ip address:
' caddr '
'
call lineout tempfile,' - Client name:
' cname '
'
call lineout tempfile,' - Server ip address:
' saddr '
'
call lineout tempfile,' - Server port:
' sport '
'
call lineout tempfile,' - Server name:
' sname '
'
call lineout tempfile, ' - Server software:
' ssoft '
'
aver=sref_version()
call lineout tempfile,' - Filter version:
' aver '
'
call lineout tempfile,' - Your privileges are: ' privset ' '
call lineout tempfile,'
'
/* superusers and inhouse users get to see sre-filter's parameters,
if desired (by pressing a link to configure */
if wordpos('SUPERUSER',privset)=0 then signal getuse
call lineout tempfile,' SRE-FILTER settings
'
call lineout tempfile,'
Do you want to see the current settings of SRE-FILTER'"'s parameters?
"
getuse: nop
/* get some "intensity of use " statistics */
reptime=extract('RESPONSETIME')
numtrans=extract('TRANSACTIONS')
whenstart=extract('LASTSTART')
nclients=extract('CLIENTS')
call lineout tempfile,' Use Statistics
'
call lineout tempfile,' GoServe started: ' whenstart
call lineout tempfile,'
# of transactions ' numtrans ', avg. reponsetime = 'reptime ' sec. '
call lineout tempfile,'
Current # of clients = ' nclients
/* review cache etnries */
foo=strip(get_value('tempdata_dir'),'t','\')
call lineout tempfile,' Cache status (in ' foo ')
'
dshs=foo||'\_*.DSH'
oo=sysfiletree(dshs,fred,'FO')
call lineout tempfile,' # of files in the !DIR cache = ' fred.0
aport=extract('serverport')
cshs=foo||'\_*.'||aport
oo=sysfiletree(cshs,fred,'FO')
call lineout tempfile,'
# of files in the SSI-Cache files = ' fred.0 '
'
/* Use the HOST function -- demonstrates the use of external calls */
/* but first "parse" the parameter list, and store in a simple stem variable */
m=0
do until list=""
parse var list opt1 '&' list
m=m+1
parse var opt1 optname.m '=' optvalue.m
end
optname.0=m
/* see if one of the opts is "getip" */
chkip=0 ;
do mm=1 to optname.0
if translate(optname.mm)='GETIP' then do
chkip=optvalue.mm
leave
end
end
/* if we found a GETIP, and got it's value, then lookit up */
if chkip<>0 & chkip<>"" then do
/* Note use of the address cmd xxx to call a OS/2 level command */
A=RXQUEUE('S','SESSION') /* SINCE QUEUE MIGHT BE A THREAD'S QUEUE */
do queued(); pull .; end /* flush */
address cmd '@host' chkip '| rxqueue' /* execute the command */
parse pull hostresult /* get result */
call lineout tempfile,' Look up address
'
call lineout tempfile,' ' hostresult '
'
end
/* all done, write final end-of-html elements */
call lineout tempfile,' '
call lineout tempfile
'FILE ERASE TYPE text/html NAME' tempfile
return 'Done with STATUS'
/* ----------- */
/* get environment value. Typically, look for host-specific
value first, and then look for generic value (if no host given,
skip host-specific lookup )
vname: variable to lookup
hname0: Special instructions:
hname0=0 -- do not look under host nickname
hname0=1 -- do not look under default
*/
/* ------------ */
get_value: procedure expose enmadd host_nickname
parse upper arg vname,hname0
if hname0=0 then
hname=' '
else
hname=strip(host_nickname)
vname=strip(vname) ;
if hname<>' ' then do
booger=strip(enmadd||vname||'.'||hname)
aval=value(booger,,'os2environment')
if aval<>' ' | hname0=1 Then
return aval
end
aval=value(enmadd||vname,,'os2environment')
return aval
/* *********** */
/* initialize dir cache */
init_dircache:
call lineout tempfile, ''
call lineout tempfile, "Initialize !DIR Cache"
call lineout tempfile, ""
call lineout tempfile,' Initialize !DIR Cache
'
foo=strip(get_value('tempdata_dir'),'t','\')
dshs=foo||'\_*.DSH'
oo=sysfiletree(dshs,fred,'FO')
do mm=1 to fred.0
foo2=sysfiledelete(fred.mm)
end /* do */
iid=foo||'\_DIRLIST.IDX'
foo=sysfiledelete(iid)
call lineout tempfile, ' # of files deleted from the !DIR cache = ' fred.0
/* all done, write final end-of-html elements */
call lineout tempfile,' '
call lineout tempfile
'FILE ERASE TYPE text/html NAME' tempfile
return 0