コード例 #1
0
ファイル: exec.squidguard.php プロジェクト: BillTheBest/1.6.x
        exit;
    }
    if ($argv[1] == "--ufdbguard-start") {
        ufdbguard_start();
        exit;
    }
    if ($argv[1] == "--list-missdbs") {
        BuildMissingUfdBguardDBS(false, true);
        exit;
    }
    if ($argv[1] == "--parsedir") {
        ParseDirectory($argv[2]);
        exit;
    }
    if ($argv[1] == "--notify-dnsmasq") {
        notify_remote_proxys_dnsmasq();
        exit;
    }
    if ($argv[1] == '--build-ufdb-smoothly') {
        $GLOBALS["FORCE"] = true;
        echo build_ufdbguard_smooth();
        echo "Starting......: " . date("H:i:s") . " Starting UfdGuard FINISH DONE\n";
        exit;
    }
    if ($argv[1] == '--apply-restart') {
        $GLOBALS["FORCE"] = true;
        echo build_ufdbguard_restart();
        exit;
    }
}
$unix = new unix();
コード例 #2
0
ファイル: exec.dnsmasq.php プロジェクト: articatech/artica
function build($aspid = false)
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
    if (!$aspid) {
        if (!$GLOBALS["FORCE"]) {
            $pid = @file_get_contents($pidfile);
            if ($unix->process_exists($pid, basename(__FILE__))) {
                writelogs("Already executed pid {$pid}, aborting...", "MAIN", __FILE__, __LINE__);
                die;
            }
            $time = $unix->file_time_min($pidtime);
            if ($time < 2) {
                if ($time > 0) {
                    if ($GLOBALS["OUTPUT"]) {
                        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Current {$time}Mn Requested 2mn, schedule this task\n";
                    }
                    writelogs("Current {$time}Mn Requested 2mn, schedule this task", "MAIN", __FILE__, __LINE__);
                    $unix->THREAD_COMMAND_SET($unix->LOCATE_PHP5_BIN() . " " . __FILE__);
                }
                die;
            }
        }
        @unlink($pidtime);
        @file_put_contents($pidtime, time());
        @file_put_contents($pidfile, getmypid());
    }
    $Masterbin = $unix->find_program("dnsmasq");
    $users = new settings_inc();
    if (!$users->dnsmasq_installed) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} is not installed, aborting\n";
        writelogs("DNSMasq is not installed, aborting", "MAIN", __FILE__, __LINE__);
        return;
    }
    $sock = new sockets();
    $EnableDNSMASQ = $sock->dnsmasq_enabled();
    $EnableRemoteStatisticsAppliance = intval($sock->GET_INFO("EnableRemoteStatisticsAppliance"));
    $DNSMasqUseStatsAppliance = intval($sock->GET_INFO("DNSMasqUseStatsAppliance"));
    $EnableWebProxyStatsAppliance = intval($sock->GET_INFO("EnableWebProxyStatsAppliance"));
    $UnlockWebStats = intval($sock->GET_INFO("UnlockWebStats"));
    if ($UnlockWebStats == 1) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    if ($EnableDNSMASQ == 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} DnsMasq is disabled\n";
        }
        return;
    }
    $php = $unix->LOCATE_PHP5_BIN();
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} patching local hosts..\n";
    }
    shell_exec("{$php} /usr/share/artica-postfix/exec.virtuals-ip.php --hosts");
    @file_put_contents("/etc/dnsmasq.conf.empty", "");
    $GLOBALS["MYSQL_ERROR_DNSMASQ"] = false;
    $DNsServers = GetDNSSservers();
    if ($GLOBALS["MYSQL_ERROR_DNSMASQ"]) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} MySQL error!\n";
        }
        build_progress("{error}", 110);
        return;
    }
    $GetSpecificDnsServers = GetSpecificDnsServers();
    $getdomains = getdomains();
    $LocalDNSMASQItems = $sock->GET_INFO('LocalDNSMASQItems');
    if (!is_numeric($LocalDNSMASQItems)) {
        $LocalDNSMASQItems = 250000;
    }
    build_progress("{building_service}", 20);
    $cf = new dnsmasq();
    $G = array();
    $G[] = "--local-ttl=3600";
    $G[] = "--conf-file=/etc/dnsmasq.conf.empty";
    $G[] = "--pid-file=/var/run/dnsmasq.pid";
    $G[] = "--strict-order";
    $G[] = "--domain-needed";
    $G[] = "--expand-hosts";
    $G[] = "--bogus-priv";
    $G[] = "--dns-forward-max={$cf->main_array["dns-forward-max"]}";
    if ($GetSpecificDnsServers != null) {
        $G[] = $GetSpecificDnsServers;
    }
    if ($DNsServers != null) {
        $G[] = $DNsServers;
    }
    if ($getdomains != null) {
        $G[] = $getdomains;
    }
    $G[] = "--cache-size={$LocalDNSMASQItems}";
    $G[] = "--filterwin2k";
    $G[] = "--log-facility=DAEMON";
    if ($cf->main_array["log-queries"] == "yes") {
        $G[] = "--log-queries";
    }
    build_progress("{building_service}", 30);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} CONFIGURATOR " . count($G) . " line(s) LINE:" . __LINE__ . "\n";
    }
    $GLOBALS["MYSQL_ERROR_DNSMASQ"] = false;
    $G = cachednshosts_records($G);
    if ($GLOBALS["MYSQL_ERROR_DNSMASQ"]) {
        build_progress("{error}", 110);
        return;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} CONFIGURATOR " . count($G) . " line(s) LINE:" . __LINE__ . "\n";
    }
    @mkdir("/var/run/dnsmasq", 0755, true);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} CONFIGURATOR /etc/dnsmasq.cmdlines.array done\n";
    }
    @file_put_contents("/etc/dnsmasq.cmdlines.array", serialize($G));
    if (!install_service_main($G)) {
        build_progress("{building_service} {failed}", 110);
        return;
    }
    if ($EnableWebProxyStatsAppliance == 1) {
        notify_remote_proxys_dnsmasq();
    }
    build_progress("{building_service}", 30);
}