コード例 #1
0
$GLOBALS["CACHE_SQL"] = array();
$timezones = @file_get_contents("/etc/artica-postfix/settings/Daemons/timezones");
$GLOBALS["LogFileDeamonLogDir"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/LogFileDeamonLogDir");
if ($GLOBALS["LogFileDeamonLogDir"] == null) {
    $GLOBALS["LogFileDeamonLogDir"] = "/home/artica/squid/realtime-events";
}
if (!isset($GLOBALS["ARTICALOGDIR"])) {
    $GLOBALS["ARTICALOGDIR"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/ArticaLogDir");
    if ($GLOBALS["ARTICALOGDIR"] == null) {
        $GLOBALS["ARTICALOGDIR"] = "{$GLOBALS["ARTICALOGDIR"]}";
    }
}
if ($timezones != null) {
    @date_default_timezone_set($timezones);
}
parseconfig();
CheckDirs();
error_reporting(0);
//ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);ini_set('error_append_string',null);
if ($argv[1] == "--no-disk") {
    $GLOBALS["NO_DISK"] = true;
}
if ($argv[1] == "--dump-mac") {
    print_r(unserialize(@file_get_contents("/etc/squid3/usersMacs.db")));
    exit;
}
$logthis = array();
if ($GLOBALS["VERBOSE"]) {
    $logthis[] = "Verbosed";
}
if ($GLOBALS["ACT_AS_REVERSE"]) {
コード例 #2
0
function nanoweb_init($conffile)
{
    global $conf, $themes, $cmdline_conf_overrides, $cmdline_conf_adds, $modules, $posix_av, $pcntl_av, $gz_av, $mime, $access_policy, $sysusr, $sysgrp, $icnt, $banned_ips, $srvlog_levels;
    $dc = get_defined_constants();
    foreach ($dc as $cname => $cval) {
        if (substr($cname, 0, 6) == "NW_EL_") {
            $srvlog_levels[strtolower(substr($cname, 6))] = $cval;
        }
    }
    $iconf = parseconfig(file($conffile));
    if (is_string($iconf)) {
        if ($icnt) {
            techo($iconf, NW_EL_WARNING);
            return false;
        } else {
            errexit($iconf);
        }
    } else {
        if (is_array($iconf)) {
            $conf = $iconf;
        }
    }
    $conf = cmdline_conf_upd($conf, $cmdline_conf_overrides, $cmdline_conf_adds);
    $modules = load_modules($conf);
    modules_init();
    $themes = load_themes($conf);
    ++$icnt;
    $ap_aliases = array("parseext" => "_parseext", "alias" => "_aliases", "errordocument" => "_errordocument", "errorheader" => "_errorheader");
    $access_policy = array();
    foreach ($conf["global"]["accessoverride"] as $ov_dir) {
        if ($ov_dir) {
            $access_policy[strtolower($ov_dir)] = "override";
        }
    }
    foreach ($conf["global"]["accessmerge"] as $mg_dir) {
        if ($mg_dir) {
            $access_policy[strtolower($mg_dir)] = "merge";
        }
    }
    foreach ($conf["global"]["accessblock"] as $bl_dir) {
        if ($bl_dir) {
            $access_policy[strtolower($bl_dir)] = "block";
        }
    }
    foreach ($ap_aliases as $rk => $ak) {
        if ($access_policy[$rk]) {
            $access_policy[$ak] = $access_policy[$rk];
        }
    }
    $posix_av = is_callable("posix_setuid");
    $pcntl_av = is_callable("pcntl_fork");
    $gz_av = is_callable("gzencode");
    if (count($themes) == 0) {
        techo("WARN: No theme loaded, server generated content is disabled", NW_EL_WARNING);
    }
    if ($posix_av) {
        foreach ($conf as $vconf) {
            if ($u = $vconf["user"][0]) {
                $sysusr[$u] = @posix_getpwnam($u);
            }
            if ($g = $vconf["group"][0]) {
                $sysgrp[$g] = @posix_getgrnam($g);
            }
        }
    }
    if (!$conf["global"]["singleprocessmode"][0] && (!$posix_av || !$pcntl_av || $conf["global"]["servermode"][0] == "inetd")) {
        techo("WARN: forcing single process mode", NW_EL_WARNING);
        $conf["global"]["singleprocessmode"][0] = true;
    }
    if ($conf["global"]["servermode"][0] == "inetd") {
        unset($conf["global"]["logtoconsole"]);
        unset($conf["global"]["pidfile"]);
    }
    if ($conf["global"]["singleprocessmode"][0]) {
        $conf["global"]["loggerprocess"] = 0;
        if ($conf["global"]["keepalive"][0]) {
            techo("WARN: KeepAlive should be set to 0 in single process mode", NW_EL_WARNING);
        }
    }
    if ($pcntl_av) {
        pcntl_signal(SIGTERM, "nanoweb_shutdown");
        pcntl_signal(SIGHUP, "nanoweb_reload");
    }
    $mime = array();
    if (!@is_readable($conf["global"]["mimetypes"][0])) {
        techo("WARN: unable to read mime types file (" . $conf["global"]["mimetypes"][0] . "), using internals", NW_EL_WARNING);
        $mime = array("html" => "text/html", "xml" => "text/xml", "gif" => "image/gif", "jpeg" => "image/jpeg", "png" => "image/png", "tgz" => "application/gtar");
    } else {
        if ($mimetypes = @file($conf["global"]["mimetypes"][0])) {
            foreach ($mimetypes as $s) {
                if (trim($s) && $s[0] != "#") {
                    if (ereg("([a-zA-Z0-9/.-]+)[ \t]+([a-zA-Z0-9 -]+)", $s, $res)) {
                        if ($exts = explode(" ", trim($res[2]))) {
                            foreach ($exts as $ext) {
                                if (trim($res[1]) && trim($ext)) {
                                    $mime[$ext] = trim($res[1]);
                                }
                            }
                        }
                    }
                }
            }
            unset($mimetypes);
        }
    }
    if ($at = $conf["global"]["addtype"]) {
        foreach ($at as $adt) {
            $mt = strtok(trim($adt), " ");
            while ($s = strtok(" ")) {
                $mime[ltrim($s, ".")] = $mt;
            }
        }
    }
    $conf["_complete"] = true;
    $banned_ips = array();
    if (is_array($conf["global"]["blockipaddr"])) {
        foreach ($conf["global"]["blockipaddr"] as $ip) {
            nw_block_ip_address($ip, "PERM", "config.BlockIPAddr");
        }
    }
    return true;
}