Example #1
0
function Popuplate_cron()
{
    if (is_file("/etc/cron.d/access-failed-parser")) {
        @unlink("/etc/cron.d/access-failed-parser");
    }
    if (is_file("/etc/cron.d/access-logs-parser")) {
        @unlink("/etc/cron.d/access-logs-parser");
    }
    testspeed();
    $CRON_RELOAD = false;
    $EnableArticaMetaServer = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableArticaMetaServer"));
    if (!is_file("/etc/cron.hourly/squidrotate.sh")) {
        $CRON[] = "#!/bin/sh";
        $CRON[] = "export LC_ALL=C";
        $CRON[] = "{$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.squid.rotate.php --cron >/dev/null 2>&1";
        $CRON[] = "";
        @file_put_contents("/etc/cron.hourly/squidrotate.sh", @implode("\n", $CRON));
        @chmod("/etc/cron.hourly/squidrotate.sh", 0755);
        $CRON_RELOAD = true;
    }
    if ($EnableArticaMetaServer == 1) {
        if (!is_file("/etc/cron.d/artica-meta-ufdb")) {
            Popuplate_cron_make("artica-meta-ufdb", "45 0,2,4,6,8,10,12,14,16,18,20,22 * * *", "exec.squid.blacklists.php --bycron");
            $CRON_RELOAD = true;
        }
    } else {
        if (is_file("/etc/cron.d/artica-meta-ufdb")) {
            @unlink("/etc/cron.d/artica-meta-ufdb");
            $CRON_RELOAD = true;
        }
    }
    if (!is_file("/etc/cron.d/artica-squid-5min")) {
        Popuplate_cron_make("artica-squid-5min", "0,5,10,15,20,25,30,35,40,45,50,55 * * * *", "exec.squidMins.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-rxtx-stats")) {
        Popuplate_cron_make("artica-rxtx-stats", "10 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * *", "exec.rxtx.hourly.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-sys-stats")) {
        Popuplate_cron_make("artica-sys-stats", "* * * * *", "exec.sys-stats.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/access-parser-logs")) {
        Popuplate_cron_make("access-parser-logs", "0 * * * *", "exec.squidparse.hourly.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/access-parser-members")) {
        Popuplate_cron_make("access-parser-members", "5,15,30,45 * * * *", "exec.squidparse.members.php --rtt");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/access-parser-members-h")) {
        Popuplate_cron_make("access-parser-members-h", "0 * * * *", "exec.squidparse.members.php --hour");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-dnsperf")) {
        Popuplate_cron_make("artica-dnsperf", "0,5,10,15,20,25,30,35,40,45,50,55 * * * *", "exec.dnsperf.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/access-parser-failed")) {
        Popuplate_cron_make("access-parser-failed", "0,5,10,15,20,25,30,35,40,45,50,55 * * * *", "exec.squidparse.hourly.php --failed");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-clean-logs")) {
        Popuplate_cron_make("artica-clean-logs", "30 0,4,6,12 * * *", "exec.clean.logs.php --clean-tmp1");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-clean-tmp")) {
        Popuplate_cron_make("artica-clean-logs", "30 1,6,20,23 * * *", "exec.clean.logs.php --clean-logs");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-whatsnew")) {
        Popuplate_cron_make("artica-whatsnew", "30 8,10,12,16,18,20,22 * * *", "exec.web-community-filter.php --whatsnew");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-interface-size")) {
        Popuplate_cron_make("artica-interface-size", "0,15,30,45 * * * *", "exec.squid.interface-size.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-interface-hour")) {
        Popuplate_cron_make("artica-interface-hour", "25 * * * *", "exec.squid.interface-size.php --flux-hour");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-sys-alert")) {
        Popuplate_cron_make("artica-sys-alert", "0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * *", "exec.mpstat.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-auth-logs")) {
        Popuplate_cron_make("artica-auth-logs", "0,5,10,15,20,25,30,35,40,45,50,55 * * * *", "exec.syslog-engine.php --auth-logs");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-loadavg-interface")) {
        Popuplate_cron_make("artica-auth-logs", "0,5,10,15,20,25,30,35,40,45,50,55 * * * *", "exec.loadavg.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-usb-scan")) {
        Popuplate_cron_make("artica-usb-scan", "0,30 * * * *", "exec.usb.scan.write.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-nightly")) {
        Popuplate_cron_make("artica-nightly", "0,30 * * * *", "exec.nightly.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-process1")) {
        $unix = new unix();
        $nice = $unix->EXEC_NICE();
        $PATH = "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/share/artica-postfix/bin";
        $CRON[] = "PATH={$PATH}";
        $CRON[] = "MAILTO=\"\"";
        $CRON[] = "0 0,2,6,8,10,14,16,18,20 * * *\troot\t{$nice} /usr/share/artica-postfix/bin/process1 --force >/dev/null 2>&1";
        $CRON[] = "";
        file_put_contents("/etc/cron.d/artica-process1", @implode("\n", $CRON));
        chmod("/etc/cron.d/artica-process1", 0640);
        chown("/etc/cron.d/artica-process1", "root");
        $CRON_RELOAD = true;
        $CRON = array();
    }
    if ($CRON_RELOAD) {
        shell_exec("/etc/init.d/cron reload");
    }
}
Example #2
0
function Popuplate_cron()
{
    Build_default_values();
    shell_exec_time("exec.sys-stats.php", 2);
    $EnableDNSPerfs = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableDNSPerfs"));
    $EnableSquidQuotasBandwidth = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableSquidQuotasBandwidth"));
    $SquidSMTPNotifs = 0;
    if (is_file("/etc/artica-postfix/settings/Daemons/UfdbguardSMTPNotifs")) {
        $UfdbguardSMTPNotifs = unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/settings/Daemons/UfdbguardSMTPNotifs")));
        if (!isset($UfdbguardSMTPNotifs["UfdbguardSMTPNotifs"]["ENABLED_SQUID_WATCHDOG"])) {
            $UfdbguardSMTPNotifs["UfdbguardSMTPNotifs"]["ENABLED_SQUID_WATCHDOG"] = 0;
        }
        $SquidSMTPNotifs = $UfdbguardSMTPNotifs["UfdbguardSMTPNotifs"]["ENABLED_SQUID_WATCHDOG"];
    }
    testspeed();
    $CRON_RELOAD = false;
    $EnableArticaMetaServer = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableArticaMetaServer"));
    if (!is_file("/etc/cron.hourly/squidrotate.sh")) {
        $CRON[] = "#!/bin/sh";
        $CRON[] = "export LC_ALL=C";
        $CRON[] = "{$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.squid.rotate.php --cron >/dev/null 2>&1";
        $CRON[] = "";
        @file_put_contents("/etc/cron.hourly/squidrotate.sh", @implode("\n", $CRON));
        @chmod("/etc/cron.hourly/squidrotate.sh", 0755);
        $CRON_RELOAD = true;
    }
    if ($EnableSquidQuotasBandwidth == 1) {
        $SquidQuotaBandwidthRefresh = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidQuotaBandwidthRefresh"));
        $SquidQuotaBandwidthRefresh_array[15] = "0,15,30,45 * * * *";
        $SquidQuotaBandwidthRefresh_array[30] = "0,30 * * * *";
        $SquidQuotaBandwidthRefresh_array[60] = "0 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * *";
        $SquidQuotaBandwidthRefresh_array[120] = "0 2,4,6,8,10,12,14,16,18,20,22 * * *";
        $FileMD5 = @md5_file("/etc/cron.d/squid-squidbandquot");
        Popuplate_cron_make("squid-squidbandquot", $SquidQuotaBandwidthRefresh_array[$SquidQuotaBandwidthRefresh], "exec.quotaband.php");
        $FileMD52 = @md5_file("/etc/cron.d/squid-squidbandquot");
        if ($FileMD5 != $FileMD52) {
            $CRON_RELOAD = true;
        }
    } else {
        if (is_file("/etc/cron.d/squid-squidbandquot")) {
            @unlink("/etc/cron.d/squid-squidbandquot");
            $CRON_RELOAD = true;
        }
    }
    if ($SquidSMTPNotifs == 1) {
        if (!is_file("/etc/cron.d/squid-notifications")) {
            Popuplate_cron_make("squid-notifications", "* * * * *", "exec.squid.smtp.notifications.php");
            $CRON_RELOAD = true;
        }
    } else {
        if (is_file("/etc/cron.d/squid-notifications")) {
            @unlink("/etc/cron.d/squid-notifications");
            $CRON_RELOAD = true;
        }
    }
    if ($EnableArticaMetaServer == 1) {
        if (!is_file("/etc/cron.d/artica-meta-ufdb")) {
            Popuplate_cron_make("artica-meta-ufdb", "45 0,2,4,6,8,10,12,14,16,18,20,22 * * *", "exec.squid.blacklists.php --bycron");
            $CRON_RELOAD = true;
        }
        if (!is_file("/etc/cron.d/ufdb-db-checkv")) {
            Popuplate_cron_make("ufdb-db-checkv", "30 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 * * *", "exec.squid.blacklists.php --get-version");
            $CRON_RELOAD = true;
        }
    } else {
        if (is_file("/etc/cron.d/artica-meta-ufdb")) {
            @unlink("/etc/cron.d/artica-meta-ufdb");
            $CRON_RELOAD = true;
        }
    }
    if (!is_file("/etc/cron.d/artica-squid-5min")) {
        Popuplate_cron_make("artica-squid-5min", "0,5,10,15,20,25,30,35,40,45,50,55 * * * *", "exec.squidMins.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-rxtx-stats")) {
        Popuplate_cron_make("artica-rxtx-stats", "10 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * *", "exec.rxtx.hourly.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-sys-stats")) {
        Popuplate_cron_make("artica-sys-stats", "* * * * *", "exec.sys-stats.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/access-parser-logs")) {
        Popuplate_cron_make("access-parser-logs", "0 * * * *", "exec.squidparse.hourly.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/apache-parser-logs")) {
        Popuplate_cron_make("apache-parser-logs", "30 * * * *", "exec.apache.hour.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/access-parser-members")) {
        Popuplate_cron_make("access-parser-members", "5,15,30,45 * * * *", "exec.squidparse.members.php --rtt");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/access-parser-members-h")) {
        Popuplate_cron_make("access-parser-members-h", "0 * * * *", "exec.squidparse.members.php --hour");
        $CRON_RELOAD = true;
    }
    if ($EnableDNSPerfs == 1) {
        if (!is_file("/etc/cron.d/artica-dnsperf")) {
            Popuplate_cron_make("artica-dnsperf", "0,5,10,15,20,25,30,35,40,45,50,55 * * * *", "exec.dnsperf.php");
            $CRON_RELOAD = true;
        }
    } else {
        if (is_file("/etc/cron.d/artica-dnsperf")) {
            @unlink("/etc/cron.d/artica-dnsperf");
            $CRON_RELOAD = true;
        }
    }
    if (!is_file("/etc/cron.d/access-parser-failed")) {
        Popuplate_cron_make("access-parser-failed", "0,5,10,15,20,25,30,35,40,45,50,55 * * * *", "exec.squidparse.hourly.php --failed");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/available-softwares")) {
        Popuplate_cron_make("available-softwares", "30 0,8,16 * * *", "exec.web-community-filter.php --updates");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-clean-logs")) {
        Popuplate_cron_make("artica-clean-logs", "30 0,4,6,12 * * *", "exec.clean.logs.php --clean-tmp1");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-clean-tmp")) {
        Popuplate_cron_make("artica-clean-logs", "30 1,6,20,23 * * *", "exec.clean.logs.php --clean-logs");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-whatsnew")) {
        Popuplate_cron_make("artica-whatsnew", "30 8,10,12,16,18,20,22 * * *", "exec.web-community-filter.php --whatsnew");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-clean-RTTSize")) {
        Popuplate_cron_make("artica-clean-RTTSize", "30 4 * * *", "exec.clean.logs.php --rttsize");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-interface-size")) {
        Popuplate_cron_make("artica-interface-size", "0,15,30,45 * * * *", "exec.squid.interface-size.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-interface-hour")) {
        Popuplate_cron_make("artica-interface-hour", "25 * * * *", "exec.squid.interface-size.php --flux-hour");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-sys-alert")) {
        Popuplate_cron_make("artica-sys-alert", "0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * *", "exec.mpstat.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-auth-logs")) {
        Popuplate_cron_make("artica-auth-logs", "0,5,10,15,20,25,30,35,40,45,50,55 * * * *", "exec.syslog-engine.php --auth-logs");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-loadavg-interface")) {
        Popuplate_cron_make("artica-auth-logs", "0,5,10,15,20,25,30,35,40,45,50,55 * * * *", "exec.loadavg.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-usb-scan")) {
        Popuplate_cron_make("artica-usb-scan", "0,30 * * * *", "exec.usb.scan.write.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-nightly")) {
        Popuplate_cron_make("artica-nightly", "0,30 * * * *", "exec.nightly.php");
        $CRON_RELOAD = true;
    }
    if (!is_file("/etc/cron.d/artica-process1")) {
        $nice = $GLOBALS["CLASS_UNIX"]->EXEC_NICE();
        $PATH = "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/share/artica-postfix/bin";
        $CRON[] = "PATH={$PATH}";
        $CRON[] = "MAILTO=\"\"";
        $CRON[] = "0 0,2,6,8,10,14,16,18,20 * * *\troot\t{$nice} /usr/share/artica-postfix/bin/process1 --force >/dev/null 2>&1";
        $CRON[] = "";
        file_put_contents("/etc/cron.d/artica-process1", @implode("\n", $CRON));
        chmod("/etc/cron.d/artica-process1", 0640);
        chown("/etc/cron.d/artica-process1", "root");
        $CRON_RELOAD = true;
        $CRON = array();
    }
    if ($CRON_RELOAD) {
        shell_exec2("/etc/init.d/cron reload");
    }
}