Example #1
0
function build()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $oldpid = @file_get_contents($pidfile);
    if ($unix->process_exists($oldpid)) {
        echo "Starting......: c-icap " . __FUNCTION__ . "() already running PID:{$oldpid}\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $cicap = new cicap();
    $cicap->buildconf();
    $squid = new squidbee();
    $conf = $squid->BuildSquidConf();
    $SQUID_CONFIG_PATH = $unix->SQUID_CONFIG_PATH();
    echo "Starting......: c-icap reconfigure squid done...\n";
    @file_put_contents($SQUID_CONFIG_PATH, $conf);
    @mkdir("/usr/etc", 0755, true);
    CicapMagic("/usr/etc/c-icap.magic");
    dbMaintenanceSchedule();
}
Example #2
0
function save_settings()
{
    $sock = new sockets();
    if (isset($_GET["EnableClamavInCiCap"])) {
        $ci = new cicap();
        if ($ci->EnableClamavInCiCap != $_GET["EnableClamavInCiCap"]) {
            $sock->SET_INFO("EnableClamavInCiCap", $_GET["EnableClamavInCiCap"]);
            $reconfigure_squid = true;
            $sock->getFrameWork("cmd.php?squid-reconfigure=yes");
        }
    }
    if (isset($_GET["EnableSquidGuardInCiCAP"])) {
        if ($sock->GET_INFO("EnableSquidGuardInCiCAP") != $_GET["EnableSquidGuardInCiCAP"]) {
            $sock->SET_INFO("EnableSquidGuardInCiCAP", $_GET["EnableSquidGuardInCiCAP"]);
            $reconfigure_squid = true;
        }
    }
    if (isset($_GET["CICAPListenAddress"])) {
        if ($sock->GET_INFO("CICAPListenAddress") != $_GET["CICAPListenAddress"]) {
            $sock->SET_INFO("CICAPListenAddress", $_GET["CICAPListenAddress"]);
            writelogs("CICAPListenAddress -> `{$_GET["CICAPListenAddress"]}`", __FUNCTION__, __FILE__, __LINE__);
            $reconfigure_squid = true;
        }
    }
    if ($reconfigure_squid) {
        $sock->getFrameWork("cmd.php?squid-reconfigure=yes");
    }
    $ci = new cicap();
    while (list($num, $line) = each($_GET)) {
        if (preg_match('#^srv_clamav_(.+)#', $num, $re)) {
            $num = "srv_clamav.{$re[1]}";
        }
        writelogs("Save {$num} => {$line}", __FUNCTION__, __FILE__, __LINE__);
        $ci->main_array["CONF"][$num] = $line;
    }
    $tpl = new templates();
    $ci->Save();
    $sock->getFrameWork("cmd.php?clamd-restart=yes");
    NotifyServers();
}
function save_settings_post()
{
    $sock = new sockets();
    if (isset($_POST["CicapEnabled"])) {
        $sock->SET_INFO("EnableClamavInCiCap", $_POST["CicapEnabled"]);
        $sock->SET_INFO("CicapEnabled", $_POST["CicapEnabled"]);
        writelogs("EnableClamavInCiCap -> `{$_POST["EnableClamavInCiCap"]}`", __FUNCTION__, __FILE__, __LINE__);
        $sock->getFrameWork("cmd.php?squid-reconfigure=yes");
        $sock->getFrameWork("services.php?restart-artica-status=yes");
    }
    $ci = new cicap();
    while (list($num, $line) = each($_POST)) {
        if (preg_match('#^srv_clamav_(.+)#', $num, $re)) {
            $num = "srv_clamav.{$re[1]}";
        }
        writelogs("Save {$num} => {$line}", __FUNCTION__, __FILE__, __LINE__);
        $ci->main_array["CONF"][$num] = $line;
    }
    $tpl = new templates();
    $ci->Save();
    NotifyServers();
}
Example #4
0
function save_settings(){
	$sock=new sockets();
	if(isset($_GET["EnableClamavInCiCap"])){
		$ci=new cicap();
		if($ci->EnableClamavInCiCap<>$_GET["EnableClamavInCiCap"]){
			$sock->SET_INFO("EnableClamavInCiCap",$_GET["EnableClamavInCiCap"]);
			$sock->getFrameWork("cmd.php?squid-reconfigure=yes");
		}
	}
	if(isset($_GET["EnableSquidGuardInCiCAP"])){
		if($sock->GET_INFO("EnableSquidGuardInCiCAP")<>$_GET["EnableSquidGuardInCiCAP"]){
				$sock->SET_INFO("EnableSquidGuardInCiCAP",$_GET["EnableSquidGuardInCiCAP"]);
				$sock->getFrameWork("cmd.php?squid-reconfigure=yes");
		}
	}
	
	
	$ci=new cicap();
	while (list ($num, $line) = each ($_GET)){	
		if(preg_match('#^srv_clamav_(.+)#',$num,$re)){
			$num="srv_clamav.{$re[1]}";
		}
		
		writelogs("Save $num => $line",__FUNCTION__,__FILE__,__LINE__);
		$ci->main_array["CONF"][$num]=$line;
	}
	
	$tpl=new templates();
	$ci->Save();
	
}
Example #5
0
function save_settings()
{
    $ci = new cicap();
    while (list($num, $line) = each($_GET)) {
        if (preg_match('#^srv_clamav_(.+)#', $num, $re)) {
            $num = "srv.clamav.{$re[1]}";
        }
        $ci->main_array["CONF"][$num] = $line;
    }
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body('{success}');
    $ci->Save();
}
Example #6
0
function build($aspid = false)
{
    $unix = new unix();
    $ln = $unix->find_program("ln");
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = @file_get_contents($pidfile);
    if (!$aspid) {
        if ($unix->process_exists($pid)) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: c-icap service " . __FUNCTION__ . "() already running PID:{$pid}\n";
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $chmod = $unix->find_program("chmod");
    $cicap = new cicap();
    $cicap->buildconf();
    $ln = $unix->find_program("ln");
    if (is_file("/opt/kaspersky/khse/libexec/libframework.so")) {
        if (!is_file("/lib/libframework.so")) {
            shell_exec("{$ln} -s /opt/kaspersky/khse/libexec/libframework.so /lib/libframework.so");
        }
    }
    if (is_file("/opt/kaspersky/khse/libexec/libyaml-cpp.so.0.2")) {
        if (!is_file("/lib/libyaml-cpp.so.0.2")) {
            shell_exec("{$ln} -s /opt/kaspersky/khse/libexec/libyaml-cpp.so.0.2 /lib/libyaml-cpp.so.0.2");
        }
    }
    if (!is_file("/lib/libbz2.so.1.0")) {
        if (is_file("/usr/lib/c_icap/libbz2.so.1.0.4")) {
            shell_exec("{$ln} -s /usr/lib/c_icap/libbz2.so.1.0.4 /lib/libbz2.so.1.0");
        }
    }
    if (is_dir("/opt/kaspersky/khse/libexec")) {
        shell_exec("{$chmod} 755 /opt/kaspersky/khse/libexec >/dev/null 2>&1");
        shell_exec("{$chmod} -R 755 /opt/kaspersky/khse/libexec/ >/dev/null 2>&1");
        @unlink("/opt/kaspersky/khse/etc/notify/object_infected");
        shell_exec("{$ln} -s /opt/kaspersky/kav4proxy/share/notify/object_infected /opt/kaspersky/khse/etc/notify/object_infected");
    }
    $unix = new unix();
    $squidbin = $unix->LOCATE_SQUID_BIN();
    $unix->SystemCreateUser("clamav", "clamav");
    if (!$unix->SystemUserExists("squid")) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: c-icap service creating user `squid`\n";
        $unix->SystemCreateUser("squid", "squid");
    } else {
        echo "Starting......: " . date("H:i:s") . " [INIT]: c-icap service user `squid` exists...\n";
    }
    if (is_file($squidbin)) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: c-icap service squid binary is `{$squidbin}`\n";
    }
    if (is_file($squidbin)) {
        $squid = new squidbee();
        $conf = $squid->BuildSquidConf();
        memboost();
        $SQUID_CONFIG_PATH = $unix->SQUID_CONFIG_PATH();
        echo "Starting......: " . date("H:i:s") . " [INIT]: c-icap service reconfigure squid done...\n";
        @file_put_contents($SQUID_CONFIG_PATH, $conf);
    } else {
        echo "Starting......: " . date("H:i:s") . " [INIT]: c-icap service skip reconfigure squid (not installed)...\n";
    }
    @mkdir("/usr/etc", 0755, true);
    CicapMagic("/usr/etc/c-icap.magic");
    echo "Starting......: " . date("H:i:s") . " [INIT]: c-icap service generate template...\n";
    gen_template();
    if (is_file($squidbin)) {
        dbMaintenanceSchedule();
    }
}