include_once 'ressources/class.templates.inc';
include_once 'ressources/class.ldap.inc';
include_once 'ressources/class.users.menus.inc';
include_once 'ressources/class.main_cf.inc';
$users = new usersMenus();
$tpl = new templates();
if (!$users->AsPostfixAdministrator) {
    echo $tpl->javascript_parse_text("alert('{ERROR_NO_PRIVS}');");
    die;
}
if (isset($_GET["popup"])) {
    smtpd_client_restrictions_popup();
    exit;
}
if (isset($_GET["reject_unknown_client_hostname"])) {
    smtpd_client_restrictions_save();
    exit;
}
js();
function js_smtpd_client_restrictions_save()
{
    $page = CurrentPageName();
    return "\nfunction smtpd_client_restrictions_save(){\n\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById('reject_unknown_client_hostname').checked){XHR.appendData('reject_unknown_client_hostname',1);}\n\t\telse{XHR.appendData('reject_unknown_client_hostname',0);}\n\t\n\t\tif(document.getElementById('reject_unknown_reverse_client_hostname').checked){XHR.appendData('reject_unknown_reverse_client_hostname',1);}\n\t\telse{XHR.appendData('reject_unknown_reverse_client_hostname',0);}\t\t\n\t\t\n\t\tif(document.getElementById('reject_unknown_sender_domain').checked){XHR.appendData('reject_unknown_sender_domain',1);}\n\t\telse{XHR.appendData('reject_unknown_sender_domain',0);}\t\n\t\t\n\t\t\n\t\tif(document.getElementById('reject_invalid_hostname').checked){XHR.appendData('reject_invalid_hostname',1);}\n\t\telse{XHR.appendData('reject_invalid_hostname',0);}\t\n\t\t\t\t\n\t\tif(document.getElementById('reject_non_fqdn_sender').checked){XHR.appendData('reject_non_fqdn_sender',1);}\n\t\telse{XHR.appendData('reject_non_fqdn_sender',0);}\n\n\t\tif(document.getElementById('EnablePostfixAntispamPack').checked){XHR.appendData('EnablePostfixAntispamPack',1);}\n\t\telse{XHR.appendData('EnablePostfixAntispamPack',0);}\t\t\n\t\t\t\n\t\tif(document.getElementById('reject_forged_mails').checked){XHR.appendData('reject_forged_mails',1);}\n\t\telse{XHR.appendData('reject_forged_mails',0);}\t\t\n\t\t\t\t\t\n\t\t\n\t\t\n\t\tdocument.getElementById('smtpd_client_restrictions_div').innerHTML='<center style=\"width:100%\"><img src=img/wait_verybig.gif></center>';\n\t\tXHR.sendAndLoad('{$page}', 'GET',x_smtpd_client_restrictions_save);\t\n\t}\n\t\n\t\n\t";
}
function smtpd_client_restrictions_popup()
{
    $sock = new sockets();
    $EnablePostfixAntispamPack_value = $sock->GET_INFO('EnablePostfixAntispamPack');
    $reject_forged_mails = $sock->GET_INFO('reject_forged_mails');
    $restrictions = get_restrictions_classes();
    $whitelists = Paragraphe("routing-domain-relay.png", "{PostfixAutoBlockDenyAddWhiteList}", "{PostfixAutoBlockDenyAddWhiteList_explain}", "javascript:Loadjs('postfix.iptables.php?white-js=yes')");
<?php
	include_once('ressources/class.templates.inc');
	include_once('ressources/class.ldap.inc');
	include_once('ressources/class.users.menus.inc');
	include_once('ressources/class.maincf.multi.inc');
	if(isset($_GET["org"])){$_GET["ou"]=$_GET["org"];}
	
	if(!PostFixMultiVerifyRights()){
		$tpl=new templates();
		echo "alert('". $tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
		die();exit();
	}	
	
if(isset($_GET["popup"])){smtpd_client_restrictions_popup();exit;}
if(isset($_GET["reject_unknown_client_hostname"])){smtpd_client_restrictions_save();exit;}


js();

function js(){
	$page=CurrentPageName();
	$tpl=new templates();
	$title=$tpl->_ENGINE_parse_body('{smtpd_client_restrictions_icon}',"postfix.index.php");
	$title2=$tpl->_ENGINE_parse_body('{PostfixAutoBlockManageFW}',"postfix.index.php");
	$title_compile=$tpl->_ENGINE_parse_body('{PostfixAutoBlockCompileFW}',"postfix.index.php");
	$ou=$_GET["ou"];
	$hostname=$_GET["hostname"];
	
	$prefix="smtpd_client_restriction_multi";
	$PostfixAutoBlockDenyAddWhiteList_explain=$tpl->_ENGINE_parse_body('{PostfixAutoBlockDenyAddWhiteList_explain}');
	$html="