<?php
include("postget.php");
include_once("common.php");
checklevel(2,$_REQUEST['clientid']);
if($userclick=="Post")
{

	$query="UPDATE hd_spamfilters SET type='$newtype', text='$newtext' WHERE id ='$id'";

	if(!mysql_query($query,$db_link)){
		messagetop("ERROR","DEBUG: ".$query."<br>MYSQL ERROR: ".mysql_error(),'spamfilters.php',0); 
	}else{
		//		message(_THE_CHANGES_WHERE_MADE_SUCCESSFULLY,'','periods.php',_RETURN); exit;
		messagetop(_THE_CHANGES_WHERE_MADE_SUCCESSFULLY,'','spamfilters.php',1); 
	}

}else if($userclick=="Add" AND $newtext<>"")
{
	$query="INSERT INTO hd_spamfilters (type,text) VALUES ('$newtype','$newtext')";
	if(!mysql_query($query,$db_link)){
		messagetop("ERROR","DEBUG: ".$query."<br>MYSQL ERROR: ".mysql_error(),'spamfilters.php',0); 
	}else{
		//		message(_THE_CHANGES_WHERE_MADE_SUCCESSFULLY,'','periods.php',_RETURN); exit;
		messagetop(_THE_CHANGES_WHERE_MADE_SUCCESSFULLY,'','spamfilters.php',1); 
	}

}else{
	if($id)
	{
		$query="SELECT * FROM hd_spamfilters WHERE id='$id'";
		$output=mysql_query($query,$db_link);
		$row=mysql_fetch_array($output);
	}
	include("head_template.php");
	echo '
<div class="container">
	<div class="row">


<table width="98%" class="table table-bordered">
		<tr>
		<td align="center" width="100%">
';

	print(ucfirst(_SPAM_FILTERS));

echo '
		</td>
		</tr>
';	
echo '
			<tr valign="top">
				<td>

';

	//	viewhelp(48);

	print("<form method='POST'><table><tr><td><b>".ucfirst(_TYPE).":</b></td><td>
	".ucfirst(_BY)." <select name='newtype'>");
	print ("<option value='Domain' ".sele($row[type],'Domain').">".ucfirst(_DOMAIN)."</option>");
	print ("<option value='Email' ".sele($row[type],'Email').">".ucfirst(_EMAIL)."</option>");
	print ("<option value='Subject' ".sele($row[type],'Subject').">".ucfirst(_SUBJECT)."</option>");
	print ("<option value='Body' ".sele($row[type],'Body').">".ucfirst(_BODY)."</option>");
	print("
	</select>");
	print("</td></tr>");

	print("<tr><td><b>".ucfirst(_TEXT).":</b></td><td>
	<TEXTAREA cols=60 rows=6 name=newtext>".$row[text]."</TEXTAREA>");
	print("</td></tr>");

	print("</table><br><input type=hidden name=id value='$id'>");
	if($id){
		print("<input type=submit name=userclick value=Post><br>");
	}else{
		print("<input type=submit name=userclick value=Add><br>");
	}
	print("</form>");
echo '
		</td>
		</tr>
		</table>
</div>
</div>
';
	include("foot_template.php");
}
?>