<?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 pyzor_keys(){
		return array("use_pyzor","pyzor_path","pyzor_timeout","pyzor_max",
		"pyzor_add_header","pyzor_options");
	}

	function pyzor_html(){

		$init_pyzor = get_pref("use_pyzor");
		if($init_pyzor == "") $init_pyzor = "0";

		$init_pyzor_add_header = get_pref("pyzor_add_header");
		if($init_pyzor_add_header == "") $init_pyzor_add_header = "0";

		$init_pyzor_path = (get_pref("pyzor_path") != "") ? get_pref("pyzor_path") : "/usr/bin/pyzor";
		$init_pyzor_options = (get_pref("pyzor_options") != "") ? get_pref("pyzor_options") : "";
		$init_pyzor_timeout = (get_pref("pyzor_timeout") != "") ? get_pref("pyzor_timeout") : "10";
		$init_pyzor_max = (get_pref("pyzor_max") != "") ? get_pref("pyzor_max") : "5";

		$pyzor_checked = ($init_pyzor == "1") ? "CHECKED" : "";
		$pyzor_add_header_checked = ($init_pyzor_add_header == "1") ? "CHECKED" : "";

		echo "<b><a href=\"http://pyzor.sourceforge.net\">Pyzor</a></b><br /><br />
			Pyzor is a collaborative, networked system to detect and block spam using 
			identifying digests of messages.<br /><br />

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

			    <tr>
			      <td align=\"right\" />Use Pyzor:</td>
			      <td><input type=\"checkbox\" name=\"pyzor_control\" value=\"1\" $pyzor_checked /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />Pyzor Add Header:</td>
			      <td><input type=\"checkbox\" name=\"pyzor_add_header_control\" value=\"1\" $pyzor_add_header_checked /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />Pyzor Path:</td>
			      <td><input type=\"text\" name=\"pyzor_path_control\" value=\"$init_pyzor_path\" size=\"44\" maxlength=\"128\" /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />Pyzor Options:</td>
			      <td><input type=\"text\" name=\"pyzor_options_control\" value=\"$init_pyzor_options\" size=\"44\" maxlength=\"128\" /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />Pyzor Timeout:</td>
			      <td><input type=\"text\" name=\"pyzor_timeout_control\" value=\"$init_pyzor_timeout\" size=\"6\" maxlength=\"24\" /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />Pyzor Max:</td>
			      <td><input type=\"text\" name=\"pyzor_max_control\" value=\"$init_pyzor_max\" size=\"6\" maxlength=\"24\" /></td>
			    </tr>

			</table>
		";

	}

	function pyzor_apply(){
	
		$pyzor = ($_POST[pyzor_control] != "") ? "1" : "0";
		$pyzor_add_header = ($_POST[pyzor_add_header_control] != "") ? "1" : "0";

		set_pref("use_pyzor",$pyzor);
		set_pref("pyzor_add_header",$pyzor_add_header);

		if($_POST[pyzor_path_control] != ""){
			set_pref("pyzor_path",$_POST[pyzor_path_control]);
		}

		if($_POST[pyzor_options_control] != ""){
			set_pref("pyzor_options",$_POST[pyzor_options_control]);
		}

		if($_POST[pyzor_timeout_control] != ""){
			set_pref("pyzor_timeout",$_POST[pyzor_timeout_control]);
		}

		if($_POST[pyzor_max_control] != ""){
			set_pref("pyzor_max",$_POST[pyzor_max_control]);
		}


	}

?>
