Пример #1
0
function build_ufdbguard_config()
{
    checksVersion();
    $sock = new sockets();
    $DenyUfdbWriteConf = $sock->GET_INFO("DenyUfdbWriteConf");
    if (!is_numeric($DenyUfdbWriteConf)) {
        $DenyUfdbWriteConf = 0;
    }
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    if (!is_numeric($EnableRemoteStatisticsAppliance)) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    if ($EnableRemoteStatisticsAppliance == 1) {
        return;
    }
    $unix = new unix();
    $chmod = $unix->find_program("chmod");
    $chown = $unix->find_program("chown");
    $ln = $unix->find_program("ln");
    $trace = debug_backtrace();
    if (isset($trace[1])) {
        $called = " called by " . basename($trace[1]["file"]) . " {$trace[1]["function"]}() line {$trace[1]["line"]}";
    }
    $unix->send_email_events("Order to rebuild ufdbGuard config", $called, "proxy");
    $sock = new sockets();
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
    if (!is_numeric($EnableRemoteStatisticsAppliance)) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    if (!is_numeric($EnableWebProxyStatsAppliance)) {
        $EnableWebProxyStatsAppliance = 0;
    }
    $users = new usersMenus();
    @mkdir("/var/tmp", 0775, true);
    @mkdir("/etc/ufdbguard", 0777, true);
    @mkdir("/etc/squid3", 0755, true);
    @mkdir("/var/log/squid", 0755, true);
    @mkdir("/var/lib/ufdbartica", 0755, true);
    @unlink("/etc/ufdbguard/ufdbGuard.conf");
    @unlink("/etc/squid3/ufdbGuard.conf");
    remove_bad_files();
    build_progress("Building parameters", 10);
    $ufdb = new compile_ufdbguard();
    $datas = $ufdb->buildConfig();
    if (is_file("/var/log/squid/UfdbguardCache.db")) {
        @unlink("/var/log/squid/UfdbguardCache.db");
    }
    if ($EnableWebProxyStatsAppliance == 1) {
        @file_put_contents("/usr/share/artica-postfix/ressources/databases/ufdbGuard.conf", $datas);
    }
    if ($DenyUfdbWriteConf == 0) {
        build_progress("Saving configuration", 60);
        @file_put_contents("/etc/ufdbguard/ufdbGuard.conf", $datas);
        @file_put_contents("/etc/squid3/ufdbGuard.conf", $datas);
        $sock->TOP_NOTIFY("{webfiltering_parameters_was_saved}");
    }
    shell_exec("{$chmod} 755 /etc/squid3/ufdbGuard.conf");
    shell_exec("{$chmod} -R 755 /etc/squid3/ufdbGuard.conf");
    shell_exec("{$chmod} -R 755 /etc/ufdbguard");
    shell_exec("chown -R squid:squid /etc/ufdbguard");
    shell_exec("chown -R squid:squid /var/log/squid");
    shell_exec("chown -R squid:squid /etc/squid3");
    shell_exec("chown -R squid:squid /var/lib/ufdbartica");
    build_progress("Saving configuration {done}", 65);
}
Пример #2
0
function artica_meta_client($force = false)
{
    $unix = new unix();
    $WORKDIR = "/var/lib/ftpunivtlse1fr";
    @mkdir($WORKDIR, 0755, true);
    @chmod($WORKDIR, 0755);
    $tmpdir = $unix->TEMP_DIR();
    $myVersion = intval(trim(@file_get_contents("/etc/artica-postfix/ftpunivtlse1fr.txt")));
    $tmpdir = $unix->TEMP_DIR();
    $meta = new artica_meta();
    $curl = $meta->buildCurl("/meta-updates/webfiltering/ftpunivtlse1fr.txt");
    if (!$curl->GetFile("{$tmpdir}/ftpunivtlse1fr.txt")) {
        artica_update_event(0, "Failed Downloading webfiltering/ftpunivtlse1fr.txt", @implode("\n", $curl->errors), __FILE__, __LINE__);
        $meta->events($curl->errors, __FUNCTION__, __FILE__, __LINE__);
        meta_admin_mysql(0, "Failed Downloading webfiltering/ftpunivtlse1fr.txt", @implode("\n", $curl->errors), __FILE__, __LINE__);
        return false;
    }
    $Remote_version = intval(trim(@file_get_contents("{$tmpdir}/ftpunivtlse1fr.txt")));
    @unlink("{$tmpdir}/ftpunivtlse1fr.txt");
    echo "Current............: {$myVersion}\n";
    echo "Available..........: {$Remote_version}\n";
    $datev = date("Y-m-d H:i:s", $myVersion);
    $STATUS = unserialize(@file_get_contents("/etc/artica-postfix/TLSE_LAST_DOWNLOAD"));
    $STATUS["LAST_CHECK"] = time();
    @file_put_contents("/etc/artica-postfix/TLSE_LAST_DOWNLOAD", serialize($STATUS));
    if ($myVersion > $Remote_version) {
        echo "My version {$myVersion} is newest than {$Remote_version}, aborting\n";
        build_progress("{version-up-to-date} {$datev}", 100);
        return;
    }
    if ($myVersion == $Remote_version) {
        build_progress("{version-up-to-date} {$datev}", 100);
        echo "My version {$myVersion} is the same than {$Remote_version}, aborting\n";
        return;
    }
    $curl = $meta->buildCurl("/meta-updates/webfiltering/ftpunivtlse1fr.tgz");
    $curl->Timeout = 120;
    if (!$curl->GetFile("{$tmpdir}/ftpunivtlse1fr.tgz")) {
        artica_update_event(0, "Failed Downloading webfiltering/ftpunivtlse1fr.tgz", @implode("\n", $curl->errors), __FILE__, __LINE__);
        $meta->events($curl->errors, __FUNCTION__, __FILE__, __LINE__);
        meta_admin_mysql(0, "Failed Downloading webfiltering/ftpunivtlse1fr.tgz", @implode("\n", $curl->errors), __FILE__, __LINE__);
        @unlink("{$tmpdir}/ftpunivtlse1fr.tgz");
        return false;
    }
    if (!$unix->TARGZ_TEST_CONTAINER("{$tmpdir}/ftpunivtlse1fr.tgz")) {
        artica_update_event(0, "Failed {$tmpdir}/ftpunivtlse1fr.tgz corrupted package", @implode("\n", $curl->errors), __FILE__, __LINE__);
        meta_admin_mysql(0, "Failed {$tmpdir}/ftpunivtlse1fr.tgz corrupted package", @implode("\n", $curl->errors), __FILE__, __LINE__);
        @unlink("{$tmpdir}/ftpunivtlse1fr.tgz");
        return false;
    }
    $tar = $unix->find_program("tar");
    shell_exec("{$tar} -xf {$tmpdir}/ftpunivtlse1fr.tgz -C {$WORKDIR}/");
    @unlink("{$tmpdir}/ftpunivtlse1fr.tgz");
    artica_update_event(0, "Success update categories statistics v.{$Remote_version}", @implode("\n", $curl->errors), __FILE__, __LINE__);
    meta_admin_mysql(0, "Success update categories statistics v.{$Remote_version}", @implode("\n", $curl->errors), __FILE__, __LINE__);
    @file_put_contents("/etc/artica-postfix/ftpunivtlse1fr.txt", $Remote_version);
    build_progress("Using Artica Meta server {done}", 100);
    CoherenceOffiels();
    CoherenceRepertoiresUfdb();
    BuildDatabaseStatus();
    remove_bad_files();
}