;;; logging.mhtml: -*- Meta-HTML -*-  DESCRIPTIVE TEXT.

;;;  Copyright (c) 1996 Brian J. Fox
;;;  Author: Brian J. Fox (bfox@ai.mit.edu) Sun Jul 14 18:39:36 1996.
<set-var "Set Server Logfiles">
<include header.mhtml>

<if <string-eq <get-var posted::action> Cancel>
    <redirect <get-var mhtml::url-to-dir>/>>

<when <not <get-var posted::action>>>
  <set-var access-log = <get-var mhtml::access-log>>
  <set-var error-log = <get-var mhtml::error-log>>
  <set-var referer-log = <get-var mhtml::referer-log>>
  <set-var debug-log = <get-var mhtml::debug-log>>
</when>

<when <get-var posted::action>>
  ;;; Default log files to off if not set.
  <defvar access-log false>
  <defvar error-log false>
  <defvar referer-log false>
  <defvar debug-log false>

  ;;; Write the logging.local file.
  <with-open-stream dest <get-var mhtml::server-root>/conf/logging.local
		    type=file mode=write-create>
    <with-open-stream s <get-var mhtml::include-prefix>/includes/warning.txt
		      type=file mode=read>
      <stream-get-contents s contents>
      <stream-put-contents dest contents>
      <stream-put-contents dest "\n">
    </with-open-stream>

    <stream-put-contents dest "\n">
    <if <not <get-var access-log-on>>
	<prog <stream-put dest ";;"> <stream-put dest "; ">>>
    <stream-put dest "<">
    <stream-put dest "defvar mhtml::access-log <get-var access-log>>\n">
    <if <not <get-var access-log-on>>
	<prog
	  <stream-put dest "<">
	  <stream-put dest "defvar mhtml::access-log false>\n">>>

    <stream-put-contents dest "\n">
    <if <not <get-var error-log-on>>
	<prog <stream-put dest ";;"> <stream-put dest "; ">>>
    <stream-put dest "<">
    <stream-put dest "defvar mhtml::error-log <get-var error-log>>\n">
    <if <not <get-var error-log-on>>
	<prog
	  <stream-put dest "<">
	  <stream-put dest "defvar mhtml::error-log false>\n">>>

    <stream-put-contents dest "\n">
    <if <not <get-var referer-log-on>>
	<prog <stream-put dest ";;"> <stream-put dest "; ">>>
    <stream-put dest "<">
    <stream-put dest "defvar mhtml::referer-log <get-var referer-log>>\n">
    <if <not <get-var referer-log-on>>
	<prog
	  <stream-put dest "<">
	  <stream-put dest "defvar mhtml::referer-log false>\n">>>

    <stream-put-contents dest "\n">
    <if <not <get-var debug-log-on>>
	<prog <stream-put dest ";;"> <stream-put dest "; ">>>
    <stream-put dest "<">
    <stream-put dest "defvar mhtml::debug-log <get-var debug-log>>\n">
    <if <not <get-var debug-log-on>>
	<prog
	  <stream-put dest "<">
	  <stream-put dest "defvar mhtml::debug-log false>\n">>>

  </with-open-stream>
  <message The Server Logfile settings have been changed.>
  <redirect <get-var mhtml::url-to-dir>/>
</when>

<layout::page>
  <center>
    <form method=post action="<thisdoc>">
      <table>
	<tr>
	  <td align=right>
	    <input type=checkbox name=access-log-on value=true
		   <if <or <get-var access-log-on>
			   <get-var access-log>>
		       CHECKED>>
	  </td>
	  <td align=left> <b> Access Log: </b> </td>
	  <td align=left>
	    <input type=text size=30 name=access-log
		   value="<get-var access-log>">
	  </td>
	</tr>
	<tr>
	  <td align=right>
	    <input type=checkbox name=error-log-on value=true
		   <if <or <get-var error-log-on>
			   <get-var error-log>>
		       CHECKED>>
	  </td>
	  <td align=left> <b> Error Log: </b> </td>
	  <td align=left>
	    <input type=text size=30 name=error-log
		   value="<get-var error-log>">
	  </td>
	</tr>
	<tr>
	  <td align=right>
	    <input type=checkbox name=referer-log-on value=true
		   <if <or <get-var referer-log-on>
			   <get-var referer-log>>
		       CHECKED>>
	  </td>
	  <td align=left> <b> Referer Log: </b> </td>
	  <td align=left>
	    <input type=text size=30 name=referer-log
		   value="<get-var referer-log>">
	  </td>
	</tr>
	<tr>
	  <td align=right>
	    <input type=checkbox name=debug-log-on value=true
		   <if <or <get-var debug-log-on>
			   <get-var debug-log>>
		       CHECKED>>
	  </td>
	  <td align=left> <b> Debug Log: </b> </td>
	  <td align=left>
	    <input type=text size=30 name=debug-log
		   value="<get-var debug-log>">
	  </td>
	</tr>
      </table>
      <p>
      <input type=submit name=action value="Set Server Logfiles">
      <input type=submit name=action value="Cancel">
    </form>
  </center>
</layout::page>

<include footer.mhtml>
