home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Spezial
/
SPEZIAL2_97.zip
/
SPEZIAL2_97.iso
/
ANWEND
/
ONLINE
/
SREFPRC1
/
ISAMOVE.SRF
< prev
next >
Wrap
Text File
|
1996-09-29
|
3KB
|
74 lines
/* -------------- See if this a "moved" alias -- and do the move */
sref_isa_move:
parse arg tsel,sel,servername,serverport,tempfile,verbose,seloriginal
mvwords=" HTTP:// !HTTP:// !MOVED= !MOVED !TEMP= !TEMP !NOTIFY "
mvtype0="301 301 301 301 302 302 200 "
do mm=1 to words(mvwords)
cw=strip(word(mvwords,mm))
yikes=abbrev(tsel,cw)
if yikes=0 then iterate
if mm>2 then
sel=delstr(sel,1,length(cw))
if mm=2 then
sel=delstr(sel,1,1)
mvtype=strip(word(mvtype0,mm))
sel=sref_fix_url(sel,servername,serverport)
dog=moved(sel,mvtype,seloriginal) /* do the move */
return 1
end
return 0
/* ----------------------------------------------------------------------- */
/* MOVED: Return a 'moved' response -- it calls a macrospace routine */
/* ----------------------------------------------------------------------- */
/* Argument is new URL or partial URI */
moved: procedure expose serverport tempfile verbose servername
parse arg uri , mtype,seloriginal
port=serverport
if left(translate(uri),5)=='HTTP:' then /* got full URI */
url=uri
else /* got partial URI */ do
if port=80 then pp=''; else pp=':'port
url='http://'servername||pp'/'uri /* relocation */
end
call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
call lineout tempfile, "<html><head><title>Moved</title></head>"
/* Now set the response and build the response file */
if mtype=301 then
'RESPONSE HTTP/1.0 301 Moved Permanently' /* Set HTTP response line */
if mtype=302 then
'RESPONSE HTTP/1.0 302 Moved Temporarily' /* Set HTTP response line */
if mtype=200 then do /* must be a !notify */
call lineout tempfile,'<h2>This Resource has been Relocated.</h2>'
call lineout tempfile,'<hr size=4>The resource "'seloriginal'" has been moved to:'
call lineout tempfile,'<A HREF="'url'">'url'</A>.<p>'
call lineout tempfile,'Please make a note of the new URI, and update any references you can.<p>'
call lineout tempfile, "</body></html>"
end
else do /* a redirection */
'HEADER ADD Location:' url
call lineout tempfile, "<body><h2>Document moved...</h2>"
call lineout tempfile, "<p>This document has moved"
call lineout tempfile, "<a href="""url""">here<a>."
call lineout tempfile, "</body></html>"
end
call lineout tempfile /* close */
'FILE ERASE TYPE text/html NAME' tempfile
return 1