コード例 #1
0
ファイル: exec.squidguard.php プロジェクト: BillTheBest/1.6.x
function build()
{
    $sock = new sockets();
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    if (!is_numeric($EnableRemoteStatisticsAppliance)) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    if ($EnableRemoteStatisticsAppliance == 1) {
        return;
    }
    send_email_events("Order to rebuild filters configuration", @implode("\nParams:", $argv), "proxy");
    $funtion = __FUNCTION__;
    if (!isset($GLOBALS["VERBOSE"])) {
        $GLOBALS["VERBOSE"] = false;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "{$funtion}::" . __LINE__ . " Loading libraries\n";
    }
    $users = new usersMenus();
    $sock = new sockets();
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $chown = $unix->find_program("chown");
    $chmod = $unix->find_program("chmod");
    $squidbin = $unix->find_program("squid3");
    $nohup = $unix->find_program("nohup");
    $unix->SystemCreateUser("squid", "squid");
    @mkdir("/var/tmp", 0775, true);
    $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    if (!is_numeric($EnableWebProxyStatsAppliance)) {
        $EnableWebProxyStatsAppliance = 0;
    }
    if (!is_numeric($EnableRemoteStatisticsAppliance)) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    $UseRemoteUfdbguardService = $sock->GET_INFO('UseRemoteUfdbguardService');
    if (!is_file($squidbin)) {
        $squidbin = $unix->find_program("squid");
    }
    $EnableUfdbGuard = intval($sock->EnableUfdbGuard());
    $SQUIDEnable = $sock->GET_INFO("SQUIDEnable");
    if (!is_numeric($SQUIDEnable)) {
        $SQUIDEnable = 1;
    }
    if (!is_numeric($UseRemoteUfdbguardService)) {
        $UseRemoteUfdbguardService = 0;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "DEBUG::{$funtion}:: EnableWebProxyStatsAppliance={$EnableWebProxyStatsAppliance}\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "DEBUG::{$funtion}:: EnableRemoteStatisticsAppliance={$EnableRemoteStatisticsAppliance}\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "DEBUG::{$funtion}:: EnableUfdbGuard={$EnableUfdbGuard}\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "DEBUG::{$funtion}:: SQUIDEnable={$SQUIDEnable}\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "DEBUG::{$funtion}:: UseRemoteUfdbguardService={$UseRemoteUfdbguardService}\n";
    }
    $GLOBALS["SQUIDBIN"] = $squidbin;
    if ($EnableWebProxyStatsAppliance == 0) {
        $installed = false;
        if ($users->SQUIDGUARD_INSTALLED) {
            $installed = true;
            echo "Starting......: " . date("H:i:s") . " SquidGuard is installed\n";
        }
        if ($users->APP_UFDBGUARD_INSTALLED) {
            $installed = true;
            echo "Starting......: " . date("H:i:s") . " Webfiltering service is installed\n";
        }
        if ($users->DANSGUARDIAN_INSTALLED) {
            $installed = true;
            echo "Starting......: " . date("H:i:s") . " Dansguardian is installed\n";
        }
        if (!$installed) {
            if ($GLOBALS["VERBOSE"]) {
                echo "No one installed...\n";
                shell_exec("{$nohup} " . LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.usrmactranslation.php >/dev/null 2>&1 &");
                return false;
            }
        }
    }
    if ($EnableUfdbGuard == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "UfDbguard is disabled ( see EnableUfdbGuard ) in line: " . __LINE__ . "\n";
        }
        return;
    }
    if ($SQUIDEnable == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "UfDbguard is disabled ( see SQUIDEnable ) in line: " . __LINE__ . "\n";
        }
        return;
    }
    if ($UseRemoteUfdbguardService == 1) {
        if ($GLOBALS["VERBOSE"]) {
            echo "UfDbguard is disabled ( see UseRemoteUfdbguardService ) in line: " . __LINE__ . "\n";
        }
        return;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "FIX_1_CATEGORY_CHECKED()\n";
    }
    FIX_1_CATEGORY_CHECKED();
    if ($EnableRemoteStatisticsAppliance == 1) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Use the Web statistics appliance to get configuration file...\n";
        }
        shell_exec("{$nohup} " . LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.usrmactranslation.php >/dev/null 2>&1 &");
        ufdbguard_remote();
        return;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "{$funtion}::" . __LINE__ . "Loading compile_dansguardian()\n";
    }
    $dans = new compile_dansguardian();
    if ($GLOBALS["VERBOSE"]) {
        echo "{$funtion}::" . __LINE__ . "Loading compile_dansguardian::->build()\n";
    }
    $dans->build();
    echo "Starting......: " . date("H:i:s") . " Dansguardian compile done...\n";
    if (function_exists('WriteToSyslogMail')) {
        WriteToSyslogMail("build() -> reconfigure UfdbGuardd", basename(__FILE__));
    }
    build_ufdbguard_config();
    ufdbguard_schedule();
    if ($EnableWebProxyStatsAppliance == 1) {
        echo "Starting......: " . date("H:i:s") . " This server is a Squid Appliance, compress databases and notify proxies\n";
        CompressCategories();
        notify_remote_proxys();
    }
    shell_exec("{$php5} /usr/share/artica-postfix/exec.initslapd.php --ufdbguard");
    CheckPermissions();
    ufdbguard_admin_events("Service will be rebuiled and restarted", __FUNCTION__, __FILE__, __LINE__, "config");
    shell_exec("{$nohup} " . LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.usrmactranslation.php >/dev/null 2>&1 &");
    if (!$GLOBALS["RESTART"]) {
        if (is_file("/etc/init.d/ufdb")) {
            echo "Starting......: " . date("H:i:s") . " Checking watchdog\n";
            ufdbguard_watchdog();
            echo "Starting......: " . date("H:i:s") . " Webfiltering service reloading service\n";
            build_ufdbguard_HUP();
        }
    }
    if ($GLOBALS["RESTART"]) {
        if (is_file("/etc/init.d/ufdb")) {
            echo "Starting......: " . date("H:i:s") . " Restarting\n";
            shell_exec("/etc/init.d/ufdb restart");
        }
    }
    if ($users->DANSGUARDIAN_INSTALLED) {
        echo "Starting......: " . date("H:i:s") . " Dansguardian reloading service\n";
        shell_exec("/usr/share/artica-postfix/bin/artica-install --reload-dansguardian --withoutconfig");
    }
}
コード例 #2
0
function build()
{
    $users = new usersMenus();
    $sock = new sockets();
    $unix = new unix();
    $chown = $unix->find_program("chown");
    $chmod = $unix->find_program("chmod");
    $squidbin = $unix->find_program("squid3");
    if (!is_file($squidbin)) {
        $squidbin = $unix->find_program("squid");
    }
    $GLOBALS["SQUIDBIN"] = $squidbin;
    $installed = false;
    if ($users->SQUIDGUARD_INSTALLED) {
        $installed = true;
    }
    if ($users->APP_UFDBGUARD_INSTALLED) {
        $installed = true;
    }
    if (!$installed) {
        return false;
    }
    $dans = new compile_dansguardian();
    $dans->build();
    $ufdb = new compile_ufdbguard();
    $datas = $ufdb->buildConfig();
    @mkdir("/etc/ufdbguard", null, true);
    @file_put_contents("/etc/ufdbguard/ufdbGuard.conf", $datas);
    if (is_file("/usr/sbin/ufdbguardd")) {
        if (!is_file("/usr/bin/ufdbguardd")) {
            $unix = new unix();
            $ln = $unix->find_program("ln");
            shell_exec("{$ln} -s /usr/sbin/ufdbguardd /usr/bin/ufdbguardd");
        }
    }
    if ($users->APP_UFDBGUARD_INSTALLED) {
        ufdbguard_schedule();
    }
    $user = GetSquidUser();
    if (!is_file("/squid/log/squid/squidGuard.log")) {
        @mkdir("/squid/log/squid", 755, true);
        @file_put_contents("/squid/log/squid/squidGuard.log", "#");
        shell_exec("{$chown} {$user} /squid/log/squid/squidGuard.log");
    }
    shell_exec("{$chown} -R {$user} /var/lib/squidguard/*");
    shell_exec("{$chown} -R {$user} /var/log/squid/*");
    shell_exec("{$chmod} -R 755 /var/lib/squidguard/*");
    shell_exec("{$chmod} -R ug+x /var/lib/squidguard/*");
    if (!is_file("/var/log/ufdbguard/ufdbguardd.log")) {
        @mkdir("/var/log/ufdbguard", 755, true);
        @file_put_contents("/var/log/ufdbguard/ufdbguardd.log", "see /var/log/squid/ufdbguardd.log\n");
    }
    shell_exec("chmod 777 /var/log/ufdbguard/ufdbguardd.log");
    ufdbguard_admin_events("Service will be rebuiled and restarted", __FUNCTION__, __FILE__, __LINE__, "config");
    if (is_file("/etc/init.d/ufdb")) {
        shell_exec("/etc/init.d/ufdb reconfig >/dev/null 2>&1");
    }
    shell_exec("{$GLOBALS["SQUIDBIN"]} -k reconfigure");
    send_email_events("SquidGuard/ufdbGuard rules was rebuilded", "This is new configuration file of the squidGuard/ufdbGuard:\n-------------------------------------\n{$datas}", "system");
    shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.c-icap.php --maint-schedule");
}