home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / ONLINE / SREFPRC1 / ISAMOVE.SRF < prev    next >
Text File  |  1996-09-29  |  3KB  |  74 lines

  1. /* -------------- See if this a "moved" alias -- and do the move */
  2. sref_isa_move:
  3. parse arg tsel,sel,servername,serverport,tempfile,verbose,seloriginal
  4.  
  5. mvwords=" HTTP:// !HTTP:// !MOVED= !MOVED !TEMP=  !TEMP !NOTIFY "
  6. mvtype0="301 301 301 301 302 302  200 "
  7.  
  8. do mm=1 to words(mvwords)
  9.    cw=strip(word(mvwords,mm))
  10.  
  11.    yikes=abbrev(tsel,cw)
  12.    if yikes=0 then  iterate
  13.  
  14.    if mm>2 then
  15.       sel=delstr(sel,1,length(cw))
  16.    if mm=2 then
  17.       sel=delstr(sel,1,1)
  18.    mvtype=strip(word(mvtype0,mm))
  19.  
  20.    sel=sref_fix_url(sel,servername,serverport)
  21.    dog=moved(sel,mvtype,seloriginal)  /* do the move */
  22.    return 1
  23. end
  24. return 0
  25.  
  26.  
  27. /* ----------------------------------------------------------------------- */
  28. /* MOVED: Return a 'moved' response  -- it calls a macrospace routine      */
  29. /* ----------------------------------------------------------------------- */
  30. /* Argument is new URL or partial URI                                      */
  31.  
  32. moved: procedure expose serverport tempfile   verbose   servername 
  33.   parse arg uri , mtype,seloriginal
  34.   port=serverport
  35.  
  36.   if left(translate(uri),5)=='HTTP:' then /* got full URI */ 
  37.          url=uri
  38.    else /* got partial URI */ do
  39.     if port=80 then pp=''; else pp=':'port
  40.     url='http://'servername||pp'/'uri        /* relocation */
  41.     end
  42.  
  43.   call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  44.   call lineout tempfile, "<html><head><title>Moved</title></head>"
  45.  
  46.   /* Now set the response and build the response file */
  47.    if mtype=301 then
  48.       'RESPONSE HTTP/1.0 301 Moved Permanently'  /* Set HTTP response line */
  49.    if mtype=302 then
  50.       'RESPONSE HTTP/1.0 302 Moved Temporarily'  /* Set HTTP response line */
  51.  
  52.    if mtype=200 then do         /* must be a !notify */
  53.        call lineout tempfile,'<h2>This Resource has been Relocated.</h2>'
  54.        call lineout tempfile,'<hr size=4>The resource "'seloriginal'" has been moved to:'
  55.        call lineout tempfile,'<A HREF="'url'">'url'</A>.<p>'
  56.        call lineout tempfile,'Please make a note of the new URI, and update any references you can.<p>'
  57.        call lineout tempfile, "</body></html>"
  58.    end
  59.    else do               /* a redirection */
  60.       'HEADER ADD Location:' url
  61.      call lineout tempfile, "<body><h2>Document moved...</h2>"
  62.      call lineout tempfile, "<p>This document has moved"
  63.      call lineout tempfile, "<a href="""url""">here<a>."
  64.      call lineout tempfile, "</body></html>"
  65.    end
  66.  
  67.   
  68.   call lineout tempfile  /* close */
  69.  
  70.  'FILE ERASE TYPE text/html NAME' tempfile
  71.  return 1
  72.  
  73.  
  74.