$debug = 0;
$max_execution_time = 5;
$commandpath = "/tmp/surftool";
$delay = 2;
if (isset($argv[1])) {
    if ($argv[1] >= 0 and $argv[1] < 600) {
        $delay = $argv[1];
    }
}
//check
set_time_limit($max_execution_time);
if (ini_get('max_execution_time') != $max_execution_time) {
    echo "Warning max_execution_time is " . ini_get('max_execution_time') . "s should be " . $max_execution_time . "s\n";
}
include "surftool_class.inc";
$sgcommands = new commandReader($commandpath);
//Are there any changes?
if ($sgcommands->changes) {
    //read squidGuard.conf
    $sgconf = new surftoolSquidGuardConf($config);
    //activate domain changes
    $sgconf->setDomains("onplus", $sgcommands->domainsOnplusAdd, $sgcommands->domainsOnplusRemove);
    $sgconf->setDomains("only", $sgcommands->domainsOnlyAdd, $sgcommands->domainsOnlyRemove);
    $sgconf->write_squidGuardDomains();
    //activate acl mode changes
    $sgconf->setAclMode($sgcommands->aclChangeMode);
    $sgconf->write_squidGuardConf();
    //Reload Squid Configuration
    $sgconf->squidReload();
    $sgcommands->deleteCommandFiles();
}