function TrustedNetworks()
{
    $ipClass = new IP();
    $q = new mysql();
    $sql = "SELECT * FROM postfix_whitelist_con";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "{$q->mysql_error}\n";
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($ipClass->isIPAddressOrRange($ligne["ipaddr"])) {
            $f[] = "trusted_networks {$ligne["ipaddr"]}";
        }
        $hostname = trim(strtolower($ligne["hostname"]));
        if (strlen($hostname) < 3) {
            continue;
        }
        if ($hostname == null) {
            continue;
        }
        if (!$ipClass->isIPAddressOrRange($ligne["ipaddr"])) {
            $f[] = "whitelist_from_rcvd *@*  {$hostname}";
        }
    }
    $sql = "SELECT ID,pattern FROM miltergreylist_acls WHERE `method`='whitelist' AND `type`='addr'";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        $ipaddr = trim($ligne["pattern"]);
        if ($ipaddr == null) {
            continue;
        }
        if ($ipaddr == "127.0.0.1/8") {
            $ipaddr = "127.0.0.0/8";
        }
        if (!$ipClass->isIPAddressOrRange($ipaddr)) {
            continue;
        }
        $f[] = "trusted_networks {$ipaddr}";
    }
    $sql = "SELECT ID,pattern FROM miltergreylist_acls WHERE `method`='whitelist' AND `type`='from'";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        $from = trim($ligne["pattern"]);
        if ($from == null) {
            continue;
        }
        if ($ipClass->isIPAddressOrRange($from)) {
            continue;
        }
        $from = str_replace(".*", "*", $from);
        $f[] = "whitelist_from {$from}";
    }
    $ldap = new clladp();
    $nets = $ldap->load_mynetworks();
    if (!is_array($nets)) {
        $f[] = "trusted_networks 127.0.0.0/8";
    }
    while (list($num, $network) = each($nets)) {
        $cleaned[$network] = $network;
    }
    unset($nets);
    while (list($network, $network2) = each($cleaned)) {
        $nets[] = $network;
    }
    while (list($a, $b) = each($nets)) {
        $f[] = "trusted_networks {$b}";
    }
    $sql = "SELECT * FROM postfix_global_whitelist WHERE enabled=1 AND score=0 ORDER BY sender";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $f[] = "whitelist_from {$ligne["sender"]}";
    }
    $count = count($f);
    echo "Starting......: " . date("H:i:s") . " spamassassin Whitelisted ({$count} rows) done\n";
    $user = new usersMenus();
    $init_pre = dirname($user->spamassassin_conf_path) . "/trusted_nets.pre";
    $final = @implode("\n", $f) . "\n";
    @file_put_contents($init_pre, $final);
}
Exemple #2
0
function net_list()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $ldap = new clladp();
    $sock = new sockets();
    $users = new usersMenus();
    $search = $_GET["search"];
    $search = "*{$search}*";
    $search = str_replace("***", "*", $search);
    $search = str_replace("**", "*", $search);
    $search_sql = str_replace("*", "%", $search);
    $search_sql = str_replace("%%", "%", $search_sql);
    $search_regex = str_replace(".", "\\.", $search);
    $search_regex = str_replace("*", ".*?", $search);
    $add = imgtootltip("plus-24.png", "{add}", "SMBRemoteAnnounce('0')");
    $html = "<center>\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t\t<th width=1%>{$add}</th>\n\t\t<th colspan=4>{networks}&nbsp;|&nbsp;{$search_regex}&nbsp;|&nbsp;{$search_sql}</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>";
    $q = new mysql();
    $q->BuildTables();
    $sql = "SELECT * FROM samba_remote_announce WHERE hostname='{$_GET["hostname"]}' AND ipaddr LIKE '{$search_sql}' ORDER BY ID DESC";
    writelogs("{$sql}", __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2>";
    }
    $c = 0;
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $select = imgtootltip("32-parameters.png", "{edit}", "SMBRemoteAnnounce('{$ligne["ID"]}')");
        $delete = imgtootltip("delete-32.png", "{delete}", "SMBRemoteAnnounceDel('{$ligne["ID"]}')");
        $color = "black";
        $c++;
        $html = $html . "\n\t\t\t<tr class={$classtr}>\n\t\t\t\t<td width=1%>{$select}</td>\n\t\t\t\t<td style='font-size:14px;font-weight:bold;color:{$color}'>{$ligne["ipaddr"]} ({$ligne["domain"]})</a></td>\n\t\t\t\t<td width=1%>{$delete}</td>\n\t\t\t</tr>\n\t\t\t";
    }
    if ($c = 0) {
        $ldap = new clladp();
        $smb = new samba();
        $nets = $ldap->load_mynetworks();
        if (is_array($nets)) {
            while (list($index, $ipmask) = each($nets)) {
                if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)#", $ipmask, $re)) {
                    if ($classtr == "oddRow") {
                        $classtr = null;
                    } else {
                        $classtr = "oddRow";
                    }
                    $html = $html . "\n\t\t\t\t\t<tr class={$classtr}>\n\t\t\t\t\t\t<td width=1%>&nbsp;</td>\n\t\t\t\t\t\t<td style='font-size:14px;font-weight:bold;color:{$color}'>{$re[1]}.{$re[2]}.{$re[3]}.255 ({$smb->main_array["global"]["workgroup"]})</a></td>\n\t\t\t\t\t\t<td width=1%>&nbsp;</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t";
                }
            }
        }
    }
    $html = $html . "</table></center>\n\t<script>\n\t\n\t\tvar x_SMBRemoteAnnounceDel=function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>2){alert(results);}\t\t\t\n\t\t\tBrowseSBNETSearch();\n\t\t}\n\t\n\t\n\t\tfunction SMBRemoteAnnounceDel(ID){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\tXHR.appendData('delete-id',ID);\n\t\t\t\tAnimateDiv('browse-smbnet-list');\n    \t\t\tXHR.sendAndLoad('{$page}', 'POST',x_SMBRemoteAnnounceDel);\n\t\t\t\n\t\t}\n\t\n\t\t\n\t\tfunction SMBRemoteAnnounce(ID){\n\t\t\tLoadjs('{$page}?net-id-js='+ID+'&hostname={$_GET["hostname"]}');\n\t\t}\n\n\t</script>\n\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Exemple #3
0
function snort_NetWorks(){
	$ldap=new clladp();
	$nets=$ldap->load_mynetworks();
	while (list ($index, $line) = each ($nets) ){if(preg_match("#[0-9\.]+\/[0-9]+#",$line)){$newnets[$line]=$line;}}
	$nets2=GetAllNicNets();
	while (list ($index, $line) = each ($nets) ){if(preg_match("#[0-9\.]+\/[0-9]+#",$line)){$newnets[$line]=$line;}}
	while (list ($index, $line) = each ($newnets) ){if(preg_match("#127\.0\.0#",$index)){continue;}$final[]=$index;}
	if(count($final)>1){
		$HOME_NET="[".@implode(",",$final)."]";
	}else{
		$HOME_NET=@implode("",$final);
	}
	
	@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/snort.networks",serialize($final));
	@chmod("/usr/share/artica-postfix/ressources/logs/web/snort.networks",777);
	return $HOME_NET;
}
Exemple #4
0
function MyNetworks($trust = 0)
{
    if ($trust == 1) {
        $ldap = new clladp();
        $nets = $ldap->load_mynetworks();
    }
    $nets[] = "127.0.0.0/8";
    while (list($num, $network) = each($nets)) {
        $cleaned[$network] = $network;
    }
    unset($nets);
    while (list($network, $network2) = each($cleaned)) {
        $nets[] = $network;
    }
    echo "Starting......: " . date("H:i:s") . " opendkim generating internal hosts " . count($nets) . " entries done...\n";
    $nets[] = "";
    @file_put_contents("/etc/mail/dkim/internal-hosts", @implode("\n", $nets));
}
Exemple #5
0
function TrustedNetworks(){
	
	$q=new mysql();
	$sql="SELECT * FROM postfix_whitelist_con";
	$results=$q->QUERY_SQL($sql,"artica_backup");
	if(!$q->ok){echo "$q->mysql_error\n";}
	
	while($ligne=mysql_fetch_array($results,MYSQL_ASSOC)){
			if(trim($server)==null){continue;}
			if(preg_match("#[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+#",$ligne["ipaddr"])){
				$f[]="trusted_networks {$ligne["ipaddr"]}";
			}
			
			if(!preg_match("#[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+#",$ligne["hostname"])){
		  		$f[]="whitelist_from_rcvd *@*  {$ligne["hostname"]}";
			}
		}
		
	
	
	
	$ldap=new clladp();
	$nets=$ldap->load_mynetworks();
	if(!is_array($nets)){
		$f[]="trusted_networks 127.0.0.0/8";
	}
	

	while (list ($num, $network) = each ($nets) ){$cleaned[$network]=$network;}
	unset($nets);
	while (list ($network, $network2) = each ($cleaned) ){$nets[]=$network;}
	while (list ($a, $b) = each ($nets) ){
		$f[]="trusted_networks $b";
	}
	
	
	$sql="SELECT * FROM postfix_global_whitelist WHERE enabled=1 AND score=0 ORDER BY sender";	
	$q=new mysql();
	$results=$q->QUERY_SQL($sql,"artica_backup");
	while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
		
			$f[]="whitelist_from {$ligne["sender"]}";
		
	}
	
	
	
	$count=count($f);
	echo "Starting......: spamassassin Whitelisted ($count rows) done\n";	
	$user=new usersMenus();
	$init_pre=dirname($user->spamassassin_conf_path)."/trusted_nets.pre";
	$final=@implode("\n",$f)."\n";
	@file_put_contents($init_pre,$final);	
	
	
}
Exemple #6
0
function postscreen($hostname = null)
{
    if ($GLOBALS["EnablePostfixMultiInstance"] == 1) {
        echo "Starting......: PostScreen multiple instances, running for -> {$hostname}\n";
        shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.postfix-multi.php --postscreen {$hostname}");
    }
    $user = new usersMenus();
    if (!$user->POSTSCREEN_INSTALLED) {
        echo "Starting......: PostScreen is not installed, you should upgrade to 2.8 postfix version\n";
        return;
    }
    $main = new maincf_multi("master", "master");
    $EnablePostScreen = $main->GET("EnablePostScreen");
    if ($EnablePostScreen != 1) {
        echo "Starting......: PostScreen is not enabled\n";
        return;
    }
    echo "Starting......: PostScreen configuring....\n";
    if (!is_file("/etc/postfix/postscreen_access.cidr")) {
        @file_put_contents("/etc/postfix/postscreen_access.cidr", "#");
    }
    if (!is_file("/etc/postfix/postscreen_access.hosts")) {
        @file_put_contents("/etc/postfix/postscreen_access.hosts", " ");
    }
    postconf("postscreen_access_list", "permit_mynetworks,cidr:/etc/postfix/postscreen_access.cidr");
    $postscreen_bare_newline_action = $main->GET("postscreen_bare_newline_action");
    $postscreen_bare_newline_enable = $main->GET("postscreen_bare_newline_enable");
    $postscreen_bare_newline_ttl = $main->GET("postscreen_bare_newline_ttl");
    $postscreen_cache_cleanup_interval = $main->GET("postscreen_cache_cleanup_interval");
    $postscreen_cache_retention_time = $main->GET("postscreen_cache_retention_time");
    $postscreen_client_connection_count_limit = $main->GET("postscreen_client_connection_count_limit");
    $postscreen_pipelining_enable = $main->GET("postscreen_pipelining_enable");
    $postscreen_pipelining_action = $main->GET("postscreen_pipelining_action");
    $postscreen_pipelining_ttl = $main->GET("postscreen_pipelining_ttl");
    $postscreen_post_queue_limit = $main->GET("postscreen_post_queue_limit");
    $postscreen_pre_queue_limit = $main->GET("postscreen_pre_queue_limit");
    $postscreen_non_smtp_command_enable = $main->GET("postscreen_non_smtp_command_enable");
    $postscreen_non_smtp_command_action = $main->GET("postscreen_non_smtp_command_action");
    $postscreen_non_smtp_command_ttl = $main->GET("postscreen_non_smtp_command_ttl");
    $postscreen_forbidden_commands = $main->GET("postscreen_forbidden_command");
    $postscreen_dnsbl_action = $main->GET("postscreen_dnsbl_action");
    $postscreen_dnsbl_ttl = $main->GET("postscreen_dnsbl_ttl");
    $postscreen_dnsbl_threshold = $main->GET("postscreen_dnsbl_threshold");
    if ($postscreen_bare_newline_action == null) {
        $postscreen_bare_newline_action = "ignore";
    }
    if (!is_numeric($postscreen_bare_newline_enable)) {
        $postscreen_bare_newline_enable = "0";
    }
    if ($postscreen_bare_newline_ttl == null) {
        $postscreen_bare_newline_ttl = "30d";
    }
    if ($postscreen_cache_cleanup_interval == null) {
        $postscreen_cache_cleanup_interval = "12h";
    }
    if ($postscreen_cache_retention_time == null) {
        $postscreen_cache_retention_time = "7d";
    }
    if ($postscreen_client_connection_count_limit == null) {
        $postscreen_client_connection_count_limit = "50";
    }
    if ($postscreen_pipelining_enable == null) {
        $postscreen_pipelining_enable = "0";
    }
    if ($postscreen_pipelining_action == null) {
        $postscreen_pipelining_action = "ignore";
    }
    if ($postscreen_pipelining_ttl == null) {
        $postscreen_pipelining_ttl = "30d";
    }
    if ($postscreen_post_queue_limit == null) {
        $postscreen_post_queue_limit = "100";
    }
    if ($postscreen_pre_queue_limit == null) {
        $postscreen_pre_queue_limit = "100";
    }
    if ($postscreen_non_smtp_command_enable == null) {
        $postscreen_non_smtp_command_enable = "0";
    }
    if ($postscreen_non_smtp_command_action == null) {
        $postscreen_non_smtp_command_action = "drop";
    }
    if ($postscreen_non_smtp_command_ttl == null) {
        $postscreen_non_smtp_command_ttl = "30d";
    }
    if ($postscreen_forbidden_commands == null) {
        $postscreen_forbidden_commands = "CONNECT, GET, POST";
    }
    if ($postscreen_dnsbl_action == null) {
        $postscreen_dnsbl_action = "ignore";
    }
    if ($postscreen_dnsbl_action == null) {
        $postscreen_dnsbl_action = "ignore";
    }
    if ($postscreen_dnsbl_ttl == null) {
        $postscreen_dnsbl_ttl = "1h";
    }
    if ($postscreen_dnsbl_threshold == null) {
        $postscreen_dnsbl_threshold = "1";
    }
    if ($postscreen_bare_newline_enable == 1) {
        $postscreen_bare_newline_enable = "yes";
    } else {
        $postscreen_bare_newline_enable = "no";
    }
    if ($postscreen_pipelining_enable == 1) {
        $postscreen_pipelining_enable = "yes";
    } else {
        $postscreen_pipelining_enable = "no";
    }
    if ($postscreen_non_smtp_command_enable == 1) {
        $postscreen_non_smtp_command_enable = "yes";
    } else {
        $postscreen_non_smtp_command_enable = "no";
    }
    postconf("postscreen_bare_newline_action", $postscreen_bare_newline_action);
    postconf("postscreen_bare_newline_enable", $postscreen_bare_newline_enable);
    postconf("postscreen_bare_newline_ttl", $postscreen_bare_newline_ttl);
    postconf("postscreen_cache_cleanup_interval", $postscreen_cache_cleanup_interval);
    postconf("postscreen_cache_retention_time", $postscreen_cache_retention_time);
    postconf("postscreen_client_connection_count_limit", $postscreen_client_connection_count_limit);
    postconf("postscreen_client_connection_count_limit", $postscreen_client_connection_count_limit);
    postconf("postscreen_pipelining_enable", $postscreen_pipelining_enable);
    postconf("postscreen_pipelining_action", $postscreen_pipelining_action);
    postconf("postscreen_pipelining_ttl", $postscreen_pipelining_ttl);
    postconf("postscreen_post_queue_limit", $postscreen_post_queue_limit);
    postconf("postscreen_pre_queue_limit", $postscreen_pre_queue_limit);
    postconf("postscreen_non_smtp_command_enable", $postscreen_non_smtp_command_enable);
    postconf("postscreen_non_smtp_command_action", $postscreen_non_smtp_command_action);
    postconf("postscreen_non_smtp_command_ttl", $postscreen_non_smtp_command_ttl);
    postconf("postscreen_forbidden_command", $postscreen_forbidden_commands);
    postconf("postscreen_dnsbl_action", $postscreen_dnsbl_action);
    postconf("postscreen_dnsbl_ttl", $postscreen_dnsbl_ttl);
    postconf("postscreen_dnsbl_threshold", $postscreen_dnsbl_threshold);
    postconf("postscreen_cache_map", "btree:\\\$data_directory/postscreen_master_cache");
    $dnsbl_array = unserialize(base64_decode($main->GET_BIGDATA("postscreen_dnsbl_sites")));
    if (is_array($dnsbl_array)) {
        while (list($site, $threshold) = each($dnsbl_array)) {
            if ($site == null) {
                continue;
            }
            $dnsbl_array_compiled[] = "{$site}*{$threshold}";
        }
    }
    $final_dnsbl = null;
    if (is_array($dnsbl_array_compiled)) {
        $final_dnsbl = @implode(",", $dnsbl_array_compiled);
    }
    postconf("postscreen_dnsbl_sites", $final_dnsbl);
    if (!isset($GLOBALS["CLASS_SOCKET"])) {
        $GLOBALS["CLASS_SOCKET"] = new sockets();
        $sock = $GLOBALS["CLASS_SOCKET"];
    } else {
        $sock = $GLOBALS["CLASS_SOCKET"];
    }
    $q = new mysql();
    $sql = "SELECT * FROM postfix_whitelist_con";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "{$q->mysql_error}\n";
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $nets[] = "{$ligne["ipaddr"]}\tdunno";
        $hostsname[] = "{$ligne["hostname"]}\tOK";
    }
    $ldap = new clladp();
    $networks = $ldap->load_mynetworks();
    if (is_array($networks)) {
        while (list($num, $ligne) = each($networks)) {
            if ($ligne == null) {
                continue;
            }
            if (!preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+#", $ligne)) {
                $hostsname[] = "{$ligne}\tOK";
            } else {
                $nets[] = "{$ligne}\tdunno";
            }
        }
    }
    if (isset($hostsname)) {
        if (is_array($hostsname)) {
            @file_put_contents("/etc/postfix/postscreen_access.hosts", @implode("\n", $hostsname));
        }
        $postscreen_access = ",hash:/etc/postfix/postscreen_access.hosts";
    }
    if (!is_file("/etc/postfix/postscreen_access.hosts")) {
        @file_put_contents("/etc/postfix/postscreen_access.hosts", "\n");
    }
    shell_exec("{$GLOBALS["postmap"]} hash:/etc/postfix/postscreen_access.hosts >/dev/null 2>&1");
    if (is_array($nets)) {
        @file_put_contents("/etc/postfix/postscreen_access.cidr", @implode("\n", $nets));
    }
    postconf("postscreen_access_list", "permit_mynetworks,cidr:/etc/postfix/postscreen_access.cidr{$postscreen_access}");
    MasterCFBuilder();
}
function mynetworks()
{
    if ($GLOBALS["EnablePostfixMultiInstance"] == 1) {
        echo "Starting......: Building mynetworks multiple-instances, enabled\n";
        shell_exec("{$GLOBALS["postconf"]} -e \"mynetworks =127.0.0.0/8\" >/dev/null 2>&1");
        return;
    }
    $ldap = new clladp();
    $nets = $ldap->load_mynetworks();
    if (!is_array($nets)) {
        if ($GLOBALS["DEBUG"]) {
            echo "No networks sets\n";
        }
        shell_exec("{$GLOBALS["postconf"]} -e \"mynetworks =127.0.0.0/8\" >/dev/null 2>&1");
        return;
    }
    $nets[] = "127.0.0.0/8";
    while (list($num, $network) = each($nets)) {
        $cleaned[$network] = $network;
    }
    unset($nets);
    while (list($network, $network2) = each($cleaned)) {
        $nets[] = $network;
    }
    $inline = @implode(", ", $nets);
    $inline = str_replace(',,', ',', $inline);
    $config_net = @implode("\n", $nets);
    echo "Starting......: Building mynetworks " . count($nets) . " Networks ({$inline})\n";
    @file_put_contents("/etc/artica-postfix/mynetworks", $config_net);
    shell_exec("{$GLOBALS["postconf"]} -e \"mynetworks = {$inline}\" >/dev/null 2>&1");
}
function MyNetworks($trust = 1)
{
    $ldap = new clladp();
    $nets = $ldap->load_mynetworks();
    $q = new mysql();
    $nets[] = "127.0.0.0/8";
    while (list($num, $network) = each($nets)) {
        $cleaned[$network] = $network;
    }
    unset($nets);
    while (list($network, $network2) = each($cleaned)) {
        $nets[] = $network;
    }
    $t = explode("\n", @file_get_contents("/etc/hosts"));
    while (list($num, $line) = each($t)) {
        if (preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\s+(.+?)\\s+#", $line, $re)) {
            echo "Starting......: " . date("H:i:s") . " milter-dkim Internal Host \"{$re[1]}\"\n";
            $nets[] = $re[1];
            $already[$re[1]] = true;
        } else {
            if ($GLOBALS["VERBOSE"]) {
                echo "Starting......: " . date("H:i:s") . " milter-dkim DEBUG HOSTS: {$line}, No match\n";
            }
        }
    }
    $sql = "SELECT *  FROM `postfix_multi` WHERE `key` = 'myhostname'";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "{$q->mysql_error}\n";
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if (isset($already[$ligne["ip_address"]])) {
            continue;
        }
        if (isset($already[$ligne["value"]])) {
            continue;
        }
        echo "Starting......: " . date("H:i:s") . " milter-dkim Internal Host \"{$ligne["ip_address"]}\"\n";
        echo "Starting......: " . date("H:i:s") . " milter-dkim Internal Host \"{$ligne["value"]}\"\n";
        $nets[] = $ligne["ip_address"];
        $nets[] = $ligne["value"];
        $already[$ligne["ip_address"]] = true;
        $already[$ligne["value"]] = true;
    }
    echo "Starting......: " . date("H:i:s") . " milter-dkim generating internal hosts " . count($nets) . " entries done...\n";
    @file_put_contents("/etc/mail/dkim/internal-hosts", @implode("\n", $nets));
}
Exemple #9
0
function spamassin_milter()
{
    include_once dirname(__FILE__) . "/ressources/class.spamassassin.inc";
    $spam = new spamassassin();
    $R = null;
    if (intval($spam->main_array["block_with_required_score"]) > 0) {
        $R = " -r {$spam->main_array["block_with_required_score"]} ";
    }
    $ldap = new clladp();
    $ARR[] = "127.0.0.1";
    if (!$ldap->ldapFailed) {
        $nets = $ldap->load_mynetworks();
        while (list($i, $mask) = each($nets)) {
            if (preg_match("#^127\\.0\\.0\\.#", $mask)) {
                continue;
            }
            $ARR[] = $mask;
        }
    }
    $f[] = "#!/bin/sh";
    $f[] = "#";
    $f[] = "# \$Id: spamass-milter.init 553 " . date("Y-m-d H:i:s") . " don \$";
    $f[] = "#";
    $f[] = "# Sample init script for Debian GNU/Linux";
    $f[] = "#";
    $f[] = "#  Copyright (c) 2002 Georg C. F. Greve <*****@*****.**>,";
    $f[] = "#   all rights maintained by FSF Europe e.V., ";
    $f[] = "#   Villa Vogelsang, Antonienallee 1, 45279 Essen, Germany";
    $f[] = "#";
    $f[] = "#   This program is free software; you can redistribute it and/or modify";
    $f[] = "#   it under the terms of the GNU General Public License as published by";
    $f[] = "#   the Free Software Foundation; either version 2 of the License, or";
    $f[] = "#   (at your option) any later version.";
    $f[] = "#  ";
    $f[] = "#   This program is distributed in the hope that it will be useful,";
    $f[] = "#   but WITHOUT ANY WARRANTY; without even the implied warranty of";
    $f[] = "#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the";
    $f[] = "#   GNU General Public License for more details.";
    $f[] = "#  ";
    $f[] = "#   You should have received a copy of the GNU General Public License";
    $f[] = "#   along with this program; if not, write to the Free Software";
    $f[] = "#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA";
    $f[] = "#";
    $f[] = "#   Contact:";
    $f[] = "#            Michael Brown <*****@*****.**>";
    $f[] = "";
    $f[] = "# This init script was modified on Thu, 30 Jan 2003 02:06:04 -0500 by";
    $f[] = "# Don Armstrong <*****@*****.**> from contrib/spamass-milter to";
    $f[] = "# allow force-reload and options specified in";
    $f[] = "# /etc/default/spamass-milter necessary for inclusion in debian.";
    $f[] = "";
    $f[] = "# It has been modified additionally to support LSB Boot options and";
    $f[] = "# status on Friday, July 6, 2007 14:02:44 PDT";
    $f[] = "";
    $f[] = "";
    $f[] = "### BEGIN INIT INFO";
    $f[] = "# Provides:          spamass-milter";
    $f[] = "# Required-Start:    \$syslog \$local_fs \$remote_fs";
    $f[] = "# Required-Stop:     \$syslog \$local_fs \$remote_fs";
    $f[] = "# Default-Start:     2 3 4 5";
    $f[] = "# Default-Stop:      0 1 6";
    $f[] = "# Short-Description: milter for spamassassin";
    $f[] = "# Description:       Calls spamassassin to allow filtering out";
    $f[] = "#                    spam from ham in libmilter compatible MTAs.";
    $f[] = "### END INIT INFO";
    $f[] = "";
    $f[] = "";
    $f[] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
    $f[] = "NAME=spamass-milter";
    $f[] = "DAEMON=/usr/sbin/spamass-milter";
    $f[] = "SOCKET=/var/run/spamass/spamass.sock";
    $f[] = "PIDFILE=/var/run/spamass/spamass.pid";
    $f[] = "DESC=\"Sendmail milter plugin for SpamAssassin\"";
    $f[] = "";
    $f[] = "DEFAULT=/etc/default/spamass-milter";
    $f[] = "OPTIONS=\"{$R}-u postfix -i " . @implode(",", $ARR) . " -- --socket=/var/run/spamassassin/spamd.sock\"";
    $f[] = "RUNAS=\"postfix\"";
    $f[] = "CHUID=\"\"";
    $f[] = "SOCKETMODE=\"0660\"";
    $f[] = "SOCKETOWNER=\"postfix:postfix\"";
    $f[] = "CHUID=\"--chuid \$RUNAS\";";
    $f[] = "";
    $f[] = "test -x \$DAEMON || exit 0";
    $f[] = "set -e";
    $f[] = "if [ ! -f \"/etc/artica-postfix/settings/Daemons/SpamAssMilterEnabled\" ]; then";
    $f[] = "\techo 0 >/etc/artica-postfix/settings/Daemons/SpamAssMilterEnabled || true";
    $f[] = "fi";
    $f[] = "if [ ! -f \"/etc/artica-postfix/settings/Daemons/EnableAmavisDaemon\" ]; then";
    $f[] = "\techo 0 >/etc/artica-postfix/settings/Daemons/EnableAmavisDaemon || true";
    $f[] = "fi";
    $f[] = "if [ ! -f \"/etc/artica-postfix/settings/Daemons/SpamAssBlockWithRequiredScore\" ]; then";
    $f[] = "\techo 5 >/etc/artica-postfix/settings/Daemons/SpamAssBlockWithRequiredScore || true";
    $f[] = "fi";
    $f[] = "SpamAssMilterEnabled=`cat /etc/artica-postfix/settings/Daemons/SpamAssMilterEnabled`";
    $f[] = "EnableAmavisDaemon=`cat /etc/artica-postfix/settings/Daemons/EnableAmavisDaemon`";
    $f[] = "";
    $f[] = "";
    $f[] = "start() {";
    $f[] = "if [ \$EnableAmavisDaemon != 0 ]; then";
    $f[] = "\techo \"WARNING: \$NAME Not enabled ( see EnableAmavisDaemon [ set to 1] )\";";
    $f[] = "\texit 0";
    $f[] = "fi";
    $f[] = "if [ \$SpamAssMilterEnabled != 1 ]; then";
    $f[] = "\techo \"WARNING: \$NAME Not enabled ( see SpamAssMilterEnabled )\";";
    $f[] = "\texit 0";
    $f[] = "fi";
    $f[] = "    # Because the default socket is in the same location as the";
    $f[] = "    # pidfile, we create them in this order.";
    $f[] = "    for DIR in \"\$(dirname \$PIDFILE)\" \"\$(dirname \$SOCKET)\"; do ";
    $f[] = "    # if the dirname is '.', then it's some kind of odd socket, like";
    $f[] = "    # an inet socket. Don't create the directory in such a case";
    $f[] = "\tif [ \"\$DIR\" != \".\" ] && [ ! -d \"\$DIR\" ]; then";
    $f[] = "\t    mkdir -p \"\$DIR\";";
    $f[] = "\t    if [ -x /sbin/restorecon ]; then ";
    $f[] = "\t\t/sbin/restorecon \"\$DIR\";";
    $f[] = "\t    fi;";
    $f[] = "\t    if [ -n \"\$RUNAS\" ]; then";
    $f[] = "\t\tchown \"\$RUNAS\" \"\$DIR\";";
    $f[] = "\t    fi;";
    $f[] = "\tfi;";
    $f[] = "    done;";
    $f[] = "    if [ -n \"\$RUNAS\" ] && [ -d \$(dirname \$PIDFILE) ] &&";
    $f[] = "\t[ \"\$(stat -c '%U' \$(dirname \$PIDFILE))\" != \"\$RUNAS\" ]; then";
    $f[] = "\techo \"WARNING: \$NAME will run as user \$RUNAS but \$(dirname \$PIDFILE) is not owned by \$RUNAS\";";
    $f[] = "\techo \"Either delete this directory or chown it appropriately. Startup attempts may fail.\";";
    $f[] = "    fi;";
    $f[] = "    if [ -n \"\$RUNAS\" ] && [ \$(dirname \$SOCKET) != \".\" ] &&";
    $f[] = "\t[ -d \$(dirname \$SOCKET) ] &&";
    $f[] = "\t[ \"\$(stat -c '%U' \$(dirname \$SOCKET))\" != \"\$RUNAS\" ]; then";
    $f[] = "\techo \"WARNING: \$NAME will run as user \$RUNAS but \$(dirname \$SOCKET) is not owned by \$RUNAS\";";
    $f[] = "\techo \"Either delete this directory or chown it appropriately. Startup attempts may fail.\";";
    $f[] = "    fi;";
    $f[] = "    if [ \$(dirname \$SOCKET) != \".\" ]; then ";
    $f[] = "\t/bin/rm -f \$SOCKET";
    $f[] = "    fi;";
    $f[] = "    start-stop-daemon --start -p \$PIDFILE \$CHUID --exec \$DAEMON -- -P \$PIDFILE -f -p \$SOCKET \$OPTIONS";
    $f[] = "    sleep 1s";
    $f[] = "    if [ -n \"\$SOCKETMODE\" ]; then";
    $f[] = "\tchmod \$SOCKETMODE \$SOCKET;";
    $f[] = "    fi;";
    $f[] = "    if [ -n \"\$SOCKETOWNER\" ]; then";
    $f[] = "\tchown \$SOCKETOWNER \$SOCKET;";
    $f[] = "    fi;";
    $f[] = "}";
    $f[] = "";
    $f[] = "stop(){";
    $f[] = "    start-stop-daemon --oknodo --stop -p \$PIDFILE --signal 3 --exec \$DAEMON";
    $f[] = "    /bin/sleep 5s";
    $f[] = "    /bin/rm -f \$SOCKET";
    $f[] = "    /bin/rm -f \$PIDFILE";
    $f[] = "}";
    $f[] = "";
    $f[] = "status(){";
    $f[] = "    if [ -e \$PIDFILE ]; then ";
    $f[] = "\tif kill -0 \$(cat \$PIDFILE); then";
    $f[] = "\t    echo \"\${NAME} running\";";
    $f[] = "\t    exit 0;";
    $f[] = "\telse";
    $f[] = "\t    echo \"\${NAME} dead but \$PIDFILE exists\";";
    $f[] = "\t    exit 1;";
    $f[] = "\tfi;";
    $f[] = "\techo \"\${NAME} not running\";";
    $f[] = "\texit 3;";
    $f[] = "    fi;";
    $f[] = "}";
    $f[] = "";
    $f[] = "case \"\$1\" in";
    $f[] = "  start)";
    $f[] = "\techo -n \"Starting \$DESC: \"";
    $f[] = "\tstart";
    $f[] = "\techo \"\${NAME}\"";
    $f[] = "\t;;";
    $f[] = "  stop)";
    $f[] = "\techo -n \"Stopping \$DESC: \"";
    $f[] = "\tstop";
    $f[] = "\techo \"\${NAME}\"";
    $f[] = "\t;;";
    $f[] = "  force-reload | restart)";
    $f[] = "\techo -n \"Restarting \$DESC: \"";
    $f[] = "";
    $f[] = "\tstop";
    $f[] = "  /etc/init.d/spamassassin reload >/dev/null 2>&1 || true";
    $f[] = "\tstart";
    $f[] = "\techo \"\${NAME}\"";
    $f[] = "\t;;";
    $f[] = "  status)";
    $f[] = "\tstatus";
    $f[] = "\t;;";
    $f[] = "  *)";
    $f[] = "\tN=\$0";
    $f[] = "\techo \"Usage: \$N {start|stop|restart|force-reload|status}\" >&2";
    $f[] = "\texit 1";
    $f[] = "\t;;";
    $f[] = "esac";
    $f[] = "";
    $f[] = "exit 0";
    @file_put_contents("/etc/init.d/spamass-milter", @implode("\n", $f));
    @chmod("/etc/init.d/spamass-milter", 0755);
    if (is_file('/usr/sbin/update-rc.d')) {
        shell_exec('/usr/sbin/update-rc.d -f spamass-milter >/dev/null 2>&1');
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: spamass-milter daemon success...\n";
    }
}
Exemple #10
0
function default_outgoing_rule()
{
    if (!is_file("/opt/kaspersky/klms/bin/klms-control")) {
        echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite `klms-control` no such binary\n";
        return;
    }
    $unix = new unix();
    $ruleslist = ruleslist();
    $ID = $ruleslist["From Local Network"];
    if (!is_numeric($ID)) {
        $ID = 0;
    }
    echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite default rule ID:{$ID}\n";
    $sock = new sockets();
    $MynetworksInISPMode = $sock->GET_INFO("MynetworksInISPMode");
    $PostfixBadNettr = unserialize(base64_decode($sock->GET_INFO("PostfixBadNettr")));
    if (!is_numeric($MynetworksInISPMode)) {
        $MynetworksInISPMode = 0;
    }
    $ldap = new clladp();
    $NEWAR["127.0.0.1"] = true;
    if ($MynetworksInISPMode == 0) {
        $array = $ldap->load_mynetworks();
        while (list($key, $IP) = each($array)) {
            if (isset($PostfixBadNettr[$IP])) {
                if ($PostfixBadNettr[$IP] == 1) {
                    continue;
                }
            }
            $NEWAR[$IP] = true;
        }
    }
    $tools = new DomainsTools();
    $HashDomains = $ldap->Hash_relay_domains();
    if (is_array($HashDomains)) {
        while (list($num, $ligne) = each($HashDomains)) {
            $arr = $tools->transport_maps_explode($ligne);
            $NEWAR[$arr[1]] = true;
        }
    }
    $q = new mysql();
    $sql = "SELECT ipaddr FROM postfix_whitelist_con";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $NEWAR[$ligne["ipaddr"]] = true;
    }
    $f = array();
    $f[] = "<root>";
    $f[] = "    <belongingCriteria>";
    $f[] = "        <sender>";
    while (list($key, $none) = each($NEWAR)) {
        if ($key == null) {
            continue;
        }
        $f[] = "            <item>";
        $f[] = "                <type>CIDR</type>";
        $f[] = "                <value>{$key}</value>";
        $f[] = "            </item>";
    }
    $f[] = "        </sender>";
    $f[] = "        <recipient>";
    $f[] = "            <item>";
    $f[] = "                <type>EMailMask</type>";
    $f[] = "                <value>*</value>";
    $f[] = "            </item>";
    $f[] = "        </recipient>";
    $f[] = "    </belongingCriteria>";
    $f[] = "    <scanSettings>";
    $f[] = "        <ruleDescription>Local networks will be not scanned for outgoing connexions...</ruleDescription>";
    $f[] = "        <active>1</active>";
    $f[] = "        <ruleAction>Scan</ruleAction>";
    $f[] = "        <avScanSettings>";
    $f[] = "            <engineSettings>";
    $f[] = "                <enableScan>1</enableScan>";
    $f[] = "                <maxSizeLimit>0</maxSizeLimit>";
    $f[] = "                <excludedNames />";
    $f[] = "                <excludedFormats>";
    $f[] = "                    <executableCategory>";
    $f[] = "                        <executableWin>0</executableWin>";
    $f[] = "                        <executableMsi>0</executableMsi>";
    $f[] = "                        <executableJava>0</executableJava>";
    $f[] = "                        <executableElf>0</executableElf>";
    $f[] = "                        <executableDeb>0</executableDeb>";
    $f[] = "                        <executableRpm>0</executableRpm>";
    $f[] = "                    </executableCategory>";
    $f[] = "                    <officeCategory>";
    $f[] = "                        <documentSubcategory>";
    $f[] = "                            <msOfficeDoc>0</msOfficeDoc>";
    $f[] = "                            <msOfficeDocx>0</msOfficeDocx>";
    $f[] = "                            <msOfficeDocm>0</msOfficeDocm>";
    $f[] = "                            <msOfficeDot>0</msOfficeDot>";
    $f[] = "                            <msOfficeDotx>0</msOfficeDotx>";
    $f[] = "                            <msOfficeDotm>0</msOfficeDotm>";
    $f[] = "                            <officePdf>0</officePdf>";
    $f[] = "                            <officeXps>0</officeXps>";
    $f[] = "                            <officeRtf>0</officeRtf>";
    $f[] = "                            <officeOdt>0</officeOdt>";
    $f[] = "                            <officeSxw>0</officeSxw>";
    $f[] = "                        </documentSubcategory>";
    $f[] = "                        <spreadsheetSubcategory>";
    $f[] = "                            <msOfficeXls>0</msOfficeXls>";
    $f[] = "                            <msOfficeXlsx>0</msOfficeXlsx>";
    $f[] = "                            <msOfficeXlsm>0</msOfficeXlsm>";
    $f[] = "                            <msOfficeXlsb>0</msOfficeXlsb>";
    $f[] = "                            <msOfficeXltx>0</msOfficeXltx>";
    $f[] = "                            <msOfficeXltm>0</msOfficeXltm>";
    $f[] = "                            <msOfficeXlam>0</msOfficeXlam>";
    $f[] = "                            <officeOds>0</officeOds>";
    $f[] = "                        </spreadsheetSubcategory>";
    $f[] = "                        <presentationSubcategory>";
    $f[] = "                            <msOfficePpt>0</msOfficePpt>";
    $f[] = "                            <msOfficePptx>0</msOfficePptx>";
    $f[] = "                            <msOfficePptm>0</msOfficePptm>";
    $f[] = "                            <msOfficePotx>0</msOfficePotx>";
    $f[] = "                            <msOfficePotm>0</msOfficePotm>";
    $f[] = "                            <msOfficePpsx>0</msOfficePpsx>";
    $f[] = "                            <msOfficePpsm>0</msOfficePpsm>";
    $f[] = "                            <officeOdp>0</officeOdp>";
    $f[] = "                        </presentationSubcategory>";
    $f[] = "                        <specializedSubcategory>";
    $f[] = "                            <officeMsg>0</officeMsg>";
    $f[] = "                            <officeOne>0</officeOne>";
    $f[] = "                            <officeOnepkg>0</officeOnepkg>";
    $f[] = "                            <officeVsd>0</officeVsd>";
    $f[] = "                            <officeVdx>0</officeVdx>";
    $f[] = "                            <officeXsn>0</officeXsn>";
    $f[] = "                            <msOfficePub>0</msOfficePub>";
    $f[] = "                        </specializedSubcategory>";
    $f[] = "                    </officeCategory>";
    $f[] = "                    <multimediaCategory>";
    $f[] = "                        <videoSubcategory>";
    $f[] = "                            <videoFlv>0</videoFlv>";
    $f[] = "                            <videoF4v>0</videoF4v>";
    $f[] = "                            <videoAvi>0</videoAvi>";
    $f[] = "                            <video3gpp>0</video3gpp>";
    $f[] = "                            <videoDivx>0</videoDivx>";
    $f[] = "                            <videoMkv>0</videoMkv>";
    $f[] = "                            <videoMov>0</videoMov>";
    $f[] = "                            <videoAsf>0</videoAsf>";
    $f[] = "                            <videoRm>0</videoRm>";
    $f[] = "                            <videoVob>0</videoVob>";
    $f[] = "                            <videoBik>0</videoBik>";
    $f[] = "                        </videoSubcategory>";
    $f[] = "                        <audioSubcategory>";
    $f[] = "                            <audioMp3>0</audioMp3>";
    $f[] = "                            <audioFlac>0</audioFlac>";
    $f[] = "                            <audioApe>0</audioApe>";
    $f[] = "                            <audioOgg>0</audioOgg>";
    $f[] = "                            <audioAac>0</audioAac>";
    $f[] = "                            <audioWma>0</audioWma>";
    $f[] = "                            <audioAc3>0</audioAc3>";
    $f[] = "                            <audioWav>0</audioWav>";
    $f[] = "                            <audioMka>0</audioMka>";
    $f[] = "                            <audioRa>0</audioRa>";
    $f[] = "                            <audioMidi>0</audioMidi>";
    $f[] = "                            <audioCda>0</audioCda>";
    $f[] = "                        </audioSubcategory>";
    $f[] = "                    </multimediaCategory>";
    $f[] = "                    <imageCategory>";
    $f[] = "                        <bitmapSubcategory>";
    $f[] = "                            <imageJpeg>0</imageJpeg>";
    $f[] = "                            <imageGif>0</imageGif>";
    $f[] = "                            <imagePng>0</imagePng>";
    $f[] = "                            <imageBmp>0</imageBmp>";
    $f[] = "                            <imageTiff>0</imageTiff>";
    $f[] = "                        </bitmapSubcategory>";
    $f[] = "                        <vectorSubcategory>";
    $f[] = "                            <imageEmf>0</imageEmf>";
    $f[] = "                            <imageEps>0</imageEps>";
    $f[] = "                            <imagePsd>0</imagePsd>";
    $f[] = "                            <imageCdr>0</imageCdr>";
    $f[] = "                        </vectorSubcategory>";
    $f[] = "                        <animationSubcategory>";
    $f[] = "                            <multimediaSwf>0</multimediaSwf>";
    $f[] = "                        </animationSubcategory>";
    $f[] = "                    </imageCategory>";
    $f[] = "                    <archiveCategory>";
    $f[] = "                        <archiveZip>0</archiveZip>";
    $f[] = "                        <archive7z>0</archive7z>";
    $f[] = "                        <archiveRar>0</archiveRar>";
    $f[] = "                        <archiveIso>0</archiveIso>";
    $f[] = "                        <archiveCab>0</archiveCab>";
    $f[] = "                        <archiveJar>0</archiveJar>";
    $f[] = "                        <archiveBzip2>0</archiveBzip2>";
    $f[] = "                        <archiveGzip>0</archiveGzip>";
    $f[] = "                        <archiveArj>0</archiveArj>";
    $f[] = "                    </archiveCategory>";
    $f[] = "                    <databaseCategory>";
    $f[] = "                        <databaseAccdb>0</databaseAccdb>";
    $f[] = "                        <databaseAccdc>0</databaseAccdc>";
    $f[] = "                        <databaseMdb>0</databaseMdb>";
    $f[] = "                    </databaseCategory>";
    $f[] = "                    <miscellaneousCategory>";
    $f[] = "                        <generalTxt>0</generalTxt>";
    $f[] = "                        <textChm>0</textChm>";
    $f[] = "                        <generalHtml>0</generalHtml>";
    $f[] = "                    </miscellaneousCategory>";
    $f[] = "                </excludedFormats>";
    $f[] = "                <scanArchived>1</scanArchived>";
    $f[] = "            </engineSettings>";
    $f[] = "            <intrusionThreatAction>Reject</intrusionThreatAction>";
    $f[] = "            <infectedFirstAction>Cure</infectedFirstAction>";
    $f[] = "            <infectedSecondAction>DeleteAttachment</infectedSecondAction>";
    $f[] = "            <suspiciousAction>DeleteAttachment</suspiciousAction>";
    $f[] = "            <corruptedAction>Skip</corruptedAction>";
    $f[] = "            <encryptedAction>Skip</encryptedAction>";
    $f[] = "            <intrusionThreatMark>[Intrusion Threat]</intrusionThreatMark>";
    $f[] = "            <infectedMark>[Infected]</infectedMark>";
    $f[] = "            <suspiciousMark>[Suspicious]</suspiciousMark>";
    $f[] = "            <disinfectedMark>[Cured]</disinfectedMark>";
    $f[] = "            <encryptedMark></encryptedMark>";
    $f[] = "            <corruptedMark></corruptedMark>";
    $f[] = "        </avScanSettings>";
    $f[] = "        <asScanSettings>";
    $f[] = "            <engineSettings>";
    $f[] = "                <enableScan>0</enableScan>";
    $f[] = "                <maxSizeLimit>1572864</maxSizeLimit>";
    $f[] = "                <spamRateLimit>Standard</spamRateLimit>";
    $f[] = "                <externalServices>";
    $f[] = "                    <useDns>1</useDns>";
    $f[] = "                    <useSpf>1</useSpf>";
    $f[] = "                    <useSurbl>1</useSurbl>";
    $f[] = "                    <useSurblDefaultList>1</useSurblDefaultList>";
    $f[] = "                    <useDnsbl>1</useDnsbl>";
    $f[] = "                    <useDnsblDefaultList>1</useDnsblDefaultList>";
    $f[] = "                    <dnsHostInDns>1</dnsHostInDns>";
    $f[] = "                    <dnsDynamicResolvedFrom>0</dnsDynamicResolvedFrom>";
    $f[] = "                </externalServices>";
    $f[] = "                <advancedOptions>";
    $f[] = "                    <parseRtf>0</parseRtf>";
    $f[] = "                    <useGsg>1</useGsg>";
    $f[] = "                    <disableLangChinese>0</disableLangChinese>";
    $f[] = "                    <disableLangKorean>0</disableLangKorean>";
    $f[] = "                    <disableLangThai>0</disableLangThai>";
    $f[] = "                    <disableLangJapanese>0</disableLangJapanese>";
    $f[] = "                </advancedOptions>";
    $f[] = "            </engineSettings>";
    $f[] = "            <backupSpam>0</backupSpam>";
    $f[] = "            <backupProbableSpam>0</backupProbableSpam>";
    $f[] = "            <backupBlacklisted>0</backupBlacklisted>";
    $f[] = "            <spamAction>Skip</spamAction>";
    $f[] = "            <probableSpamAction>Skip</probableSpamAction>";
    $f[] = "            <blacklistedAction>Skip</blacklistedAction>";
    $f[] = "            <spamMark>[Spam]</spamMark>";
    $f[] = "            <probableSpamMark>[Probable spam]</probableSpamMark>";
    $f[] = "            <blacklistedMark>[Blacklisted]</blacklistedMark>";
    $f[] = "        </asScanSettings>";
    $f[] = "        <cfScanSettings>";
    $f[] = "            <sizeExceededAction>Reject</sizeExceededAction>";
    $f[] = "            <bannedFileNameAction>Reject</bannedFileNameAction>";
    $f[] = "            <bannedFileFormatAction>Reject</bannedFileFormatAction>";
    $f[] = "            <backupSizeExceeded>0</backupSizeExceeded>";
    $f[] = "            <backupBannedFileName>0</backupBannedFileName>";
    $f[] = "            <backupBannedFileFormat>0</backupBannedFileFormat>";
    $f[] = "            <engineSettings>";
    $f[] = "                <enableScan>0</enableScan>";
    $f[] = "                <maxAllowedSize>0</maxAllowedSize>";
    $f[] = "                <bannedFileNames />";
    $f[] = "                <bannedFileFormats>";
    $f[] = "                    <executableCategory>";
    $f[] = "                        <executableWin>0</executableWin>";
    $f[] = "                        <executableMsi>0</executableMsi>";
    $f[] = "                        <executableJava>0</executableJava>";
    $f[] = "                        <executableElf>0</executableElf>";
    $f[] = "                        <executableDeb>0</executableDeb>";
    $f[] = "                        <executableRpm>0</executableRpm>";
    $f[] = "                    </executableCategory>";
    $f[] = "                    <officeCategory>";
    $f[] = "                        <documentSubcategory>";
    $f[] = "                            <msOfficeDoc>0</msOfficeDoc>";
    $f[] = "                            <msOfficeDocx>0</msOfficeDocx>";
    $f[] = "                            <msOfficeDocm>0</msOfficeDocm>";
    $f[] = "                            <msOfficeDot>0</msOfficeDot>";
    $f[] = "                            <msOfficeDotx>0</msOfficeDotx>";
    $f[] = "                            <msOfficeDotm>0</msOfficeDotm>";
    $f[] = "                            <officePdf>0</officePdf>";
    $f[] = "                            <officeXps>0</officeXps>";
    $f[] = "                            <officeRtf>0</officeRtf>";
    $f[] = "                            <officeOdt>0</officeOdt>";
    $f[] = "                            <officeSxw>0</officeSxw>";
    $f[] = "                        </documentSubcategory>";
    $f[] = "                        <spreadsheetSubcategory>";
    $f[] = "                            <msOfficeXls>0</msOfficeXls>";
    $f[] = "                            <msOfficeXlsx>0</msOfficeXlsx>";
    $f[] = "                            <msOfficeXlsm>0</msOfficeXlsm>";
    $f[] = "                            <msOfficeXlsb>0</msOfficeXlsb>";
    $f[] = "                            <msOfficeXltx>0</msOfficeXltx>";
    $f[] = "                            <msOfficeXltm>0</msOfficeXltm>";
    $f[] = "                            <msOfficeXlam>0</msOfficeXlam>";
    $f[] = "                            <officeOds>0</officeOds>";
    $f[] = "                        </spreadsheetSubcategory>";
    $f[] = "                        <presentationSubcategory>";
    $f[] = "                            <msOfficePpt>0</msOfficePpt>";
    $f[] = "                            <msOfficePptx>0</msOfficePptx>";
    $f[] = "                            <msOfficePptm>0</msOfficePptm>";
    $f[] = "                            <msOfficePotx>0</msOfficePotx>";
    $f[] = "                            <msOfficePotm>0</msOfficePotm>";
    $f[] = "                            <msOfficePpsx>0</msOfficePpsx>";
    $f[] = "                            <msOfficePpsm>0</msOfficePpsm>";
    $f[] = "                            <officeOdp>0</officeOdp>";
    $f[] = "                        </presentationSubcategory>";
    $f[] = "                        <specializedSubcategory>";
    $f[] = "                            <officeMsg>0</officeMsg>";
    $f[] = "                            <officeOne>0</officeOne>";
    $f[] = "                            <officeOnepkg>0</officeOnepkg>";
    $f[] = "                            <officeVsd>0</officeVsd>";
    $f[] = "                            <officeVdx>0</officeVdx>";
    $f[] = "                            <officeXsn>0</officeXsn>";
    $f[] = "                            <msOfficePub>0</msOfficePub>";
    $f[] = "                        </specializedSubcategory>";
    $f[] = "                    </officeCategory>";
    $f[] = "                    <multimediaCategory>";
    $f[] = "                        <videoSubcategory>";
    $f[] = "                            <videoFlv>0</videoFlv>";
    $f[] = "                            <videoF4v>0</videoF4v>";
    $f[] = "                            <videoAvi>0</videoAvi>";
    $f[] = "                            <video3gpp>0</video3gpp>";
    $f[] = "                            <videoDivx>0</videoDivx>";
    $f[] = "                            <videoMkv>0</videoMkv>";
    $f[] = "                            <videoMov>0</videoMov>";
    $f[] = "                            <videoAsf>0</videoAsf>";
    $f[] = "                            <videoRm>0</videoRm>";
    $f[] = "                            <videoVob>0</videoVob>";
    $f[] = "                            <videoBik>0</videoBik>";
    $f[] = "                        </videoSubcategory>";
    $f[] = "                        <audioSubcategory>";
    $f[] = "                            <audioMp3>0</audioMp3>";
    $f[] = "                            <audioFlac>0</audioFlac>";
    $f[] = "                            <audioApe>0</audioApe>";
    $f[] = "                            <audioOgg>0</audioOgg>";
    $f[] = "                            <audioAac>0</audioAac>";
    $f[] = "                            <audioWma>0</audioWma>";
    $f[] = "                            <audioAc3>0</audioAc3>";
    $f[] = "                            <audioWav>0</audioWav>";
    $f[] = "                            <audioMka>0</audioMka>";
    $f[] = "                            <audioRa>0</audioRa>";
    $f[] = "                            <audioMidi>0</audioMidi>";
    $f[] = "                            <audioCda>0</audioCda>";
    $f[] = "                        </audioSubcategory>";
    $f[] = "                    </multimediaCategory>";
    $f[] = "                    <imageCategory>";
    $f[] = "                        <bitmapSubcategory>";
    $f[] = "                            <imageJpeg>0</imageJpeg>";
    $f[] = "                            <imageGif>0</imageGif>";
    $f[] = "                            <imagePng>0</imagePng>";
    $f[] = "                            <imageBmp>0</imageBmp>";
    $f[] = "                            <imageTiff>0</imageTiff>";
    $f[] = "                        </bitmapSubcategory>";
    $f[] = "                        <vectorSubcategory>";
    $f[] = "                            <imageEmf>0</imageEmf>";
    $f[] = "                            <imageEps>0</imageEps>";
    $f[] = "                            <imagePsd>0</imagePsd>";
    $f[] = "                            <imageCdr>0</imageCdr>";
    $f[] = "                        </vectorSubcategory>";
    $f[] = "                        <animationSubcategory>";
    $f[] = "                            <multimediaSwf>0</multimediaSwf>";
    $f[] = "                        </animationSubcategory>";
    $f[] = "                    </imageCategory>";
    $f[] = "                    <archiveCategory>";
    $f[] = "                        <archiveZip>0</archiveZip>";
    $f[] = "                        <archive7z>0</archive7z>";
    $f[] = "                        <archiveRar>0</archiveRar>";
    $f[] = "                        <archiveIso>0</archiveIso>";
    $f[] = "                        <archiveCab>0</archiveCab>";
    $f[] = "                        <archiveJar>0</archiveJar>";
    $f[] = "                        <archiveBzip2>0</archiveBzip2>";
    $f[] = "                        <archiveGzip>0</archiveGzip>";
    $f[] = "                        <archiveArj>0</archiveArj>";
    $f[] = "                    </archiveCategory>";
    $f[] = "                    <databaseCategory>";
    $f[] = "                        <databaseAccdb>0</databaseAccdb>";
    $f[] = "                        <databaseAccdc>0</databaseAccdc>";
    $f[] = "                        <databaseMdb>0</databaseMdb>";
    $f[] = "                    </databaseCategory>";
    $f[] = "                    <miscellaneousCategory>";
    $f[] = "                        <generalTxt>0</generalTxt>";
    $f[] = "                        <textChm>0</textChm>";
    $f[] = "                        <generalHtml>0</generalHtml>";
    $f[] = "                    </miscellaneousCategory>";
    $f[] = "                </bannedFileFormats>";
    $f[] = "            </engineSettings>";
    $f[] = "        </cfScanSettings>";
    $f[] = "        <notificationSettings>";
    $f[] = "            <admin>";
    $f[] = "                <enableInfected>1</enableInfected>";
    $f[] = "                <enableCorrupted>0</enableCorrupted>";
    $f[] = "                <enableEncrypted>0</enableEncrypted>";
    $f[] = "                <enableCFFail>1</enableCFFail>";
    $f[] = "            </admin>";
    $f[] = "            <sender>";
    $f[] = "                <enableInfected>1</enableInfected>";
    $f[] = "                <enableCorrupted>0</enableCorrupted>";
    $f[] = "                <enableEncrypted>0</enableEncrypted>";
    $f[] = "                <enableCFFail>1</enableCFFail>";
    $f[] = "            </sender>";
    $f[] = "            <recipient>";
    $f[] = "                <enableInfected>0</enableInfected>";
    $f[] = "                <enableCorrupted>0</enableCorrupted>";
    $f[] = "                <enableEncrypted>0</enableEncrypted>";
    $f[] = "                <enableCFFail>0</enableCFFail>";
    $f[] = "            </recipient>";
    $f[] = "            <additional>";
    $f[] = "                <options>";
    $f[] = "                    <enableInfected>0</enableInfected>";
    $f[] = "                    <enableCorrupted>0</enableCorrupted>";
    $f[] = "                    <enableEncrypted>0</enableEncrypted>";
    $f[] = "                    <enableCFFail>0</enableCFFail>";
    $f[] = "                </options>";
    $f[] = "                <emailListInfected />";
    $f[] = "                <emailListCorrupted />";
    $f[] = "                <emailListEncrypted />";
    $f[] = "                <emailListCFFail />";
    $f[] = "            </additional>";
    $f[] = "        </notificationSettings>";
    $f[] = "    </scanSettings>";
    $f[] = "</root>";
    $filetemp = $unix->FILE_TEMP();
    @file_put_contents($filetemp, @implode("\n", $f));
    $cmd = "/opt/kaspersky/klms/bin/klms-control --create-rule \"From Local Network\" -f {$filetemp}";
    if ($ID > 0) {
        $cmd = "/opt/kaspersky/klms/bin/klms-control --set-rule-settings {$ID} -f {$filetemp}";
    }
    echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite `{$cmd}`\n";
    exec($cmd, $results);
    while (list($key, $line) = each($results)) {
        echo "Starting......: " . date("H:i:s") . " Kaspersky Mail security Suite \"{$line}\"\n";
    }
}