if ($GLOBALS["VERBOSE"]) {
    echo "EnablePostfixAutoBlock:: {$GLOBALS["EnablePostfixAutoBlock"]}\n";
}
if ($argv[1] == '--compile') {
    Compile_rules();
    die;
}
if ($argv[1] == '--parse-queue') {
    parsequeue();
    die;
}
if ($argv[1] == '--no-check') {
    $_GET["nocheck"] = true;
}
if ($argv[1] == '--parse-sql') {
    ParseLastEvents();
    die;
}
if ($argv[1] == '--delete-all-iptables') {
    DeleteAllIpTablesRules();
    die;
}
if ($argv[1] == '--test-white') {
    $iptablesClass = new iptables_chains();
    $GLOBALS["IPTABLES_WHITELISTED"] = $iptablesClass->LoadWhiteLists();
    $iptablesClass->isWhiteListed($argv[2]);
    die;
}
if ($argv[1] == '--export-drop') {
    ExportDrop();
    die;
include_once(dirname(__FILE__) . '/ressources/class.user.inc');
include_once(dirname(__FILE__) . '/ressources/class.ini.inc');
include_once(dirname(__FILE__) . '/ressources/class.ldap.inc');
include_once(dirname(__FILE__) . '/ressources/class.iptables-chains.inc');
include_once(dirname(__FILE__) . '/ressources/class.baseunix.inc');
include_once(dirname(__FILE__) . '/framework/class.unix.inc');
include_once(dirname(__FILE__) . '/framework/frame.class.inc');

$sock=new sockets();
$GLOBALS["EnablePostfixAutoBlock"]=trim($sock->GET_INFO("EnablePostfixAutoBlock"));
if($GLOBALS["EnablePostfixAutoBlock"]==null){$GLOBALS["EnablePostfixAutoBlock"]=0;}

if($argv[1]=='--compile'){Compile_rules();die();}
if($argv[1]=='--parse-queue'){parsequeue();die();}
if($argv[1]=='--no-check'){$_GET["nocheck"]=true;}
if($argv[1]=='--parse-sql'){ParseLastEvents();die();}
if($argv[1]=='--delete-all-iptables'){DeleteAllIpTablesRules();die();}
if($argv[1]=='--test-white'){$iptablesClass=new iptables_chains();$GLOBALS["IPTABLES_WHITELISTED"]=$iptablesClass->LoadWhiteLists();$iptablesClass->isWhiteListed($argv[2]);die();}
if($argv[1]=='--export-drop'){ExportDrop();die();}
if($argv[1]=='--transfert-white'){ParseResolvMX();die();}
if($argv[1]=='--upgrade-white'){UpgradeWhiteList();die();}
if($argv[1]=='--ipdeny'){ipdeny();die();}
if($argv[1]=='--perso'){perso();die();}

if($GLOBALS["VERBOSE"]){echo "Parsing ".@implode(" ", $argv)."\n";}


if(!Build_pid_func(__FILE__,"MAIN")){writelogs(basename(__FILE__).":Already executed.. aborting the process",basename(__FILE__),__FILE__,__LINE__);die();}

parsequeue();
if($GLOBALS["EnablePostfixAutoBlock"]<>1){events("This feature is currently disabled ({$GLOBALS["EnablePostfixAutoBlock"]})");die();}