<?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 razor_keys(){
		return array("use_razor1","use_razor2","razor_config","razor_timeout");
	}

	function razor_html(){

		$init_razor1 = get_pref("use_razor1");
		if($init_razor1 == "") $init_razor1 = "0";

		$init_razor2 = get_pref("use_razor2");
		if($init_razor2 == "") $init_razor2 = "0";

		$init_razor_config = (get_pref("razor_config") != "") ? get_pref("razor_config") : "/home/spamd/.razor/razor-agent.conf";
		$init_razor_timeout = (get_pref("razor_timeout") != "") ? get_pref("razor_timeout") : "10";

		$razor1_checked = ($init_razor1 == "1") ? "CHECKED" : "";
		$razor2_checked = ($init_razor2 == "1") ? "CHECKED" : "";

		echo "<b><a href=\"http://razor.sourceforge.net\">Vipul's Razor</a></b><br /><br />

			Vipul's Razor is a distributed, collaborative, spam detection and filtering network.<br /><br />

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

			    <tr>
			      <td rowspan=\"1\" colspan=\"2\" />
			      <input type=\"checkbox\" name=\"razor1_control\" value=\"1\" $razor1_checked /> Use Razor v1 | 
			      <input type=\"checkbox\" name=\"razor2_control\" value=\"1\" $razor2_checked /> Use Razor v2 
			      </td>
			    </tr>

			    <tr>
			      <td rowspan=\"1\" colspan=\"2\" /><hr></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />Razor Config:</td>
			      <td><input type=\"text\" name=\"razor_config_control\" value=\"$init_razor_config\" size=\"44\" maxlength=\"128\" /></td>
			    </tr>

			    <tr>
			      <td align=\"right\" />Razor Timeout:</td>
			      <td><input type=\"text\" name=\"razor_timeout_control\" value=\"$init_razor_timeout\" size=\"6\" maxlength=\"24\" /></td>
			    </tr>

			</table>
		";

	}

	function razor_apply(){
	
		$razor1	= ($_POST[razor1_control] != "") ? "1" : "0";
		$razor2	= ($_POST[razor2_control] != "") ? "1" : "0";

		set_pref("use_razor1",$razor1);
		set_pref("use_razor2",$razor2);


		if($_POST[razor_config_control] != ""){
			set_pref("razor_config",$_POST[razor_config_control]);
		}

		if($_POST[razor_timeout_control] != ""){
			set_pref("razor_timeout",$_POST[razor_timeout_control]);
		}

	}

?>
