<?php
/*
 *      Patrick Bores - WebUserPrefs - SpamAssassin user_prefs file editor
 *      Copyright (C) 2003  Patrick Bores
 *      This program is free software; you can redistribute it and/or
 *      modify it under the terms of the GNU General Public License
 *      as published by the Free Software Foundation; either version 2
 *      of the License, or (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 *      This drop in module was coded by Oden Eriksson <oden.eriksson@imega.se>
 *      Copyright (C) 2003 Oden Eriksson - [ imega ] System AB
 *      http://www.imega.se
 *
 */
	function dcc_keys(){
		return array("use_dcc","dcc_path","dcc_options","dcc_timeout","dcc_body_max",
		"dcc_fuz1_max","dcc_fuz2_max","dcc_add_header");
	}

	function dcc_html(){

		$init_dcc	= get_pref("use_dcc");
		if($init_dcc == "") $init_dcc = "0";

		$init_dcc_add_header	= get_pref("dcc_add_header");
		if($init_dcc_add_header == "") $init_dcc_add_header = "0";

		$init_dcc_path = (get_pref("dcc_path") != "") ? get_pref("dcc_path") : "/usr/bin/dccproc";
		$init_dcc_options = (get_pref("dcc_options") != "") ? get_pref("dcc_options") : "-h /var/lib/dcc -m /var/lib/dcc/map";
		$init_dcc_timeout = (get_pref("dcc_timeout") != "") ? get_pref("dcc_timeout") : "10";
		$init_dcc_body_max = (get_pref("dcc_body_max") != "") ? get_pref("dcc_body_max") : "999999";
		$init_dcc_fuz1_max = (get_pref("dcc_fuz1_max") != "") ? get_pref("dcc_fuz1_max") : "999999";
		$init_dcc_fuz2_max = (get_pref("dcc_fuz2_max") != "") ? get_pref("dcc_fuz2_max") : "999999";

		$dcc_checked = ($init_dcc == "1") ? "CHECKED" : "";
		$dcc_add_header_checked = ($init_dcc_add_header == "1") ? "CHECKED" : "";

		echo "<b>Distributed Checksum Clearinghouse (<a href=\"http://www.dcc-servers.net/dcc/\">DCC</a>)</b><br /><br />

			<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" />

			    <tr>
			      <td align=\"right\" />Use DCC:</td>
			      <td><input type=\"checkbox\" name=\"dcc_control\" value=\"1\" $dcc_checked /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />DCC Add Header:</td>
			      <td><input type=\"checkbox\" name=\"dcc_add_header_control\" value=\"1\" $dcc_add_header_checked /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />DCC Path:</td>
			      <td><input type=\"text\" name=\"dcc_path_control\" value=\"$init_dcc_path\" size=\"44\" maxlength=\"128\" /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />DCC Options:</td>
			      <td><input type=\"text\" name=\"dcc_options_control\" value=\"$init_dcc_options\" size=\"44\" maxlength=\"128\" /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />DCC Timeout:</td>
			      <td><input type=\"text\" name=\"dcc_timeout_control\" value=\"$init_dcc_timeout\" size=\"4\" maxlength=\"10\" /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />DCC Body Max:</td>
			      <td><input type=\"text\" name=\"dcc_body_max_control\" value=\"$init_dcc_body_max\" size=\"6\" maxlength=\"24\" /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />DCC Fuz1 Max:</td>
			      <td><input type=\"text\" name=\"dcc_fuz1_max_control\" value=\"$init_dcc_fuz1_max\" size=\"6\" maxlength=\"24\" /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />DCC Fuz2 Max:</td>
			      <td><input type=\"text\" name=\"dcc_fuz2_max_control\" value=\"$init_dcc_fuz2_max\" size=\"6\" maxlength=\"24\" /></td>
			    </tr>

			</table>
		";

	}

	function dcc_apply(){
	
		$dcc = ($_POST[dcc_control] != "") ? "1" : "0";
		$dcc_add_header = ($_POST[dcc_add_header_control] != "") ? "1" : "0";

		set_pref("use_dcc",$dcc);
		set_pref("dcc_add_header",$dcc_add_header);

		if($_POST[dcc_path_control] != ""){
			set_pref("dcc_path",$_POST[dcc_path_control]);
		}

		if($_POST[dcc_options_control] != ""){
			set_pref("dcc_options",$_POST[dcc_options_control]);
		}

		if($_POST[dcc_timeout_control] != ""){
			set_pref("dcc_timeout",$_POST[dcc_timeout_control]);
		}

		if($_POST[dcc_body_max_control] != ""){
			set_pref("dcc_body_max",$_POST[dcc_body_max_control]);
		}

		if($_POST[dcc_fuz1_max_control] != ""){
			set_pref("dcc_fuz1_max",$_POST[dcc_fuz1_max_control]);
		}

		if($_POST[dcc_fuz2_max_control] != ""){
			set_pref("dcc_fuz2_max",$_POST[dcc_fuz2_max_control]);
		}

	}

?>
