当前位置: 首页>>代码示例>>PHP>>正文


PHP unix::NETWORK_ALL_INTERFACES方法代码示例

本文整理汇总了PHP中unix::NETWORK_ALL_INTERFACES方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::NETWORK_ALL_INTERFACES方法的具体用法?PHP unix::NETWORK_ALL_INTERFACES怎么用?PHP unix::NETWORK_ALL_INTERFACES使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unix的用法示例。


在下文中一共展示了unix::NETWORK_ALL_INTERFACES方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run_func

function run_func()
{
    $unix = new unix();
    $sock = new sockets();
    $SquidNetworkSwitch = $sock->GET_INFO("SquidNetworkSwitch");
    if ($SquidNetworkSwitch == null) {
        run_remove();
        return;
    }
    $unix = new unix();
    if (!$unix->NETWORK_INTERFACE_OK($SquidNetworkSwitch)) {
        echo "{$SquidNetworkSwitch} unavailable\n";
        build_progress("{$SquidNetworkSwitch} {failed}", 110);
        return;
    }
    $NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
    $ipaddr = $NETWORK_ALL_INTERFACES[$SquidNetworkSwitch]["IPADDR"];
    if (!$unix->NETWORK_IS_LISTEN_ADDR_EXISTS($ipaddr)) {
        echo "{$SquidNetworkSwitch} / {$ipaddr} unavailable\n";
        build_progress("{$SquidNetworkSwitch} / {$ipaddr} {failed}", 110);
        return;
    }
    build_progress("{reconfiguring_proxy_service}", 80);
    $f = explode("\n", @file_get_contents("/etc/squid3/squid.conf"));
    while (list($num, $ligne) = each($f)) {
        if (preg_match("#tcp_outgoing_address#", $ligne)) {
            echo "Remove line {$ligne}\n";
            continue;
        }
        $newF[] = $ligne;
    }
    echo "{$SquidNetworkSwitch} -> {$ipaddr}\n";
    $newF[] = "#  Quick Network switch Interface: [{$SquidNetworkSwitch}] [" . date("Y-m-d H:i:s") . "]";
    $newF[] = "tcp_outgoing_address {$ipaddr} all";
    $newF[] = "";
    @file_put_contents("/etc/squid3/squid.conf", @implode("\n", $newF));
    build_progress("{reloading_proxy_service}", 90);
    system("/etc/init.d/squid reload --force --script=" . basename(__FILE__));
    build_progress("{done}", 100);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:40,代码来源:exec.squid.network.switch.php

示例2: build

function build()
{
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, building configuration.\n";
    }
    @mkdir("/var/lib/shorewall", 0755, true);
    $unix = new unix();
    if (!isset($GLOBALS["INTERFACES"])) {
        $GLOBALS["INTERFACES"] = $unix->NETWORK_ALL_INTERFACES();
    }
    shorewall_conf();
    build_providers();
    build_zones();
    build_interfaces();
    build_policies();
    build_rules();
    build_rtrules();
    build_masq();
    CheckConf();
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, BUILD DONE.\n";
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:23,代码来源:exec.shorewall.php

示例3: wccp_port

function wccp_port($ligne)
{
    $unix = new unix();
    $ip = $unix->find_program("ip");
    $sysctl = $unix->find_program("sysctl");
    $eth = $ligne["nic"];
    $ID = $ligne["ID"];
    $port = $ligne["port"];
    $SquidWCCPL3Addr = $ligne["SquidWCCPL3Addr"];
    $SquidWCCPL3Route = $ligne["SquidWCCPL3Route"];
    $echobin = $unix->find_program("echo");
    $iptables = $unix->find_program("iptables");
    $route = $unix->find_program("route");
    $NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
    $UseSSL = intval($ligne["UseSSL"]);
    build_progress("{building} eth:{$eth} port:{$port} id:{$ID}", 30);
    if (!isset($NETWORK_ALL_INTERFACES[$eth])) {
        if ($GLOBALS["PROGRESS"]) {
            echo "Fatal {$eth} -> no ip addr !!!!\n";
        }
        $GLOBALS["SCRIPT_CONTENT"][] = "# Fatal {$eth} -> no ip addr";
        return;
    }
    if ($NETWORK_ALL_INTERFACES[$eth]["IPADDR"] == '0.0.0.0') {
        if ($GLOBALS["PROGRESS"]) {
            echo "Fatal {$eth} -> no ip addr !!!!\n";
        }
        $GLOBALS["SCRIPT_CONTENT"][] = "# Fatal {$eth} -> no ip addr";
        return;
    }
    $local_tcp = $NETWORK_ALL_INTERFACES[$eth]["IPADDR"];
    $GLOBALS["WCCP_ROUTER"][$SquidWCCPL3Addr] = true;
    $destport = "80";
    if ($UseSSL == 1) {
        $destport = 443;
    }
    $GLOBALS["COUNTOF"] = $GLOBALS["COUNTOF"] + 1;
    $GLOBALS["SCRIPT_START"][] = "{$ip} link set {$eth} mtu 1476 || true";
    if ($GLOBALS["PROGRESS"]) {
        echo "{$ip} tunnel add wccp{$ID} mode gre remote {$SquidWCCPL3Addr} local {$local_tcp} dev {$eth}\n";
    }
    $GLOBALS["SCRIPT_START"][] = "{$ip} tunnel add wccp{$ID} mode gre remote {$SquidWCCPL3Addr} local {$local_tcp} dev {$eth} || true";
    $GLOBALS["SCRIPT_START"][] = "{$ip} addr add {$local_tcp} dev wccp{$ID}  || true";
    $GLOBALS["SCRIPT_START"][] = "{$ip} link set wccp{$ID} up  || true";
    $GLOBALS["SCRIPT_START"][] = "{$sysctl} -w net.ipv4.conf.wccp{$ID}.rp_filter=0 || true";
    $GLOBALS["SCRIPT_START"][] = "{$sysctl} -w net.ipv4.conf.{$eth}.rp_filter=0 || true";
    $GLOBALS["SCRIPT_START"][] = "{$iptables} -t nat -A PREROUTING -i wccp{$ID} -p tcp --dport {$destport} -j REDIRECT --to-port {$port} -m comment --comment \"ArticaWCCP3\" || true";
    $GLOBALS["SCRIPT_STOP"][] = "{$ip} link set wccp{$ID} down";
    $GLOBALS["SCRIPT_STOP"][] = "{$ip} tunnel del wccp{$ID}";
    if ($SquidWCCPL3Route != null) {
        $GLOBALS["SCRIPTS"][] = "{$ip} route add {$SquidWCCPL3Route} dev wccp{$ID}";
        $GLOBALS["SCRIPT_STOP"][] = "{$ip} route del {$SquidWCCPL3Route} dev wccp{$ID}";
    }
    $GLOBALS["SCRIPT_STOP"][] = "# # END ID {$ID}";
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:55,代码来源:exec.squid.wccp.php

示例4: islighttpd_error_500

function islighttpd_error_500()
{
    $sock = new sockets();
    $unix = new unix();
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $curl = $unix->find_program("curl");
    if (!is_file($curl)) {
        return;
    }
    $LighttpdArticaListenIP = $sock->GET_INFO('LighttpdArticaListenIP');
    $ArticaHttpsPort = 9000;
    $ArticaHttpUseSSL = 1;
    $ArticaHttpsPort = $sock->GET_INFO("ArticaHttpsPort");
    $ArticaHttpUseSSL = $sock->GET_INFO("ArticaHttpUseSSL");
    if (!is_numeric($ArticaHttpUseSSL)) {
        $ArticaHttpUseSSL = 1;
    }
    if (!is_numeric($ArticaHttpsPort)) {
        $ArticaHttpsPort = "9000";
    }
    $EnableArticaFrontEndToNGninx = $sock->GET_INFO("EnableArticaFrontEndToNGninx");
    if (!is_numeric($EnableArticaFrontEndToNGninx)) {
        $EnableArticaFrontEndToNGninx = 0;
    }
    $proto = "http";
    if ($ArticaHttpUseSSL == 1) {
        $proto = "https";
    }
    if ($LighttpdArticaListenIP != null) {
        $IPS = $unix->NETWORK_ALL_INTERFACES(true);
        if (!isset($IPS[$LighttpdArticaListenIP])) {
            $LighttpdArticaListenIP = null;
        }
    }
    if (strlen($LighttpdArticaListenIP) > 3) {
        $ips[$LighttpdArticaListenIP] = true;
        $uri = "{$proto}://{$LighttpdArticaListenIP}:{$ArticaHttpsPort}/logon.php";
    } else {
        $ips = $unix->NETWORK_ALL_INTERFACES(true);
        unset($ips["127.0.0.1"]);
    }
    while (list($ipaddr, $line) = each($ips)) {
        $f = array();
        $results = array();
        $uri = "{$proto}://{$ipaddr}:{$ArticaHttpsPort}/logon.php";
        $f[] = "{$curl} -I --connect-timeout 5";
        $f[] = "--insecure";
        $f[] = "--interface {$ipaddr}";
        $f[] = "--url {$uri} 2>&1";
        $cmdline = @implode(" ", $f);
        if ($GLOBALS['VERBOSE']) {
            echo "{$cmdline}\n";
        }
        exec(@implode(" ", $f), $results);
        if ($GLOBALS['VERBOSE']) {
            echo count($results) . " rows\n";
        }
        if (DetectError($results, "Artica Web Interface")) {
            if ($EnableArticaFrontEndToNGninx == 1) {
                shell_exec("/etc/init.d/nginx restart");
            } else {
                restart(true);
            }
        }
    }
    $results = array();
    if ($GLOBALS['VERBOSE']) {
        echo "done\n";
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:80,代码来源:exec.lighttpd.php

示例5: start

function start($aspid = false)
{
    $unix = new unix();
    $sock = new sockets();
    $Masterbin = $unix->find_program("bwm-ng");
    $q = new mysql();
    if (!is_file($Masterbin)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, not installed\n";
        }
        return;
    }
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $pid = PID_NUM();
    if ($unix->process_exists($pid)) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started {$pid} since {$timepid}Mn...\n";
        }
        return;
    }
    $EnableBwmNG = intval($sock->GET_INFO("EnableBwmNG"));
    $SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
    if ($SquidPerformance > 2) {
        $EnableBwmNG = 0;
    }
    if ($EnableBwmNG == 0) {
        if (is_dir("/home/artica/bwm-ng")) {
            $rm = $unix->find_program("rm");
            shell_exec("{$rm} -rf /home/artica/bwm-ng");
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see EnableKerbAuth,EnableCNTLM)\n";
        }
        return;
    }
    $php5 = $unix->LOCATE_PHP5_BIN();
    $sysctl = $unix->find_program("sysctl");
    $echo = $unix->find_program("echo");
    $nohup = $unix->find_program("nohup");
    $ETHZ = array();
    $NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
    unset($NETWORK_ALL_INTERFACES["lo"]);
    while (list($eth, $xmain) = each($NETWORK_ALL_INTERFACES)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Report {$eth} {$xmain["IPADDR"]} state:{$xmain["STATE"]}\n";
        }
        if ($xmain["STATE"] == "UNKNOWN") {
            $xmain["STATE"] = "UP";
        }
        $eth = trim($eth);
        if ($eth == null) {
            continue;
        }
        if ($xmain["IPADDR"] == "0.0.0.0") {
            continue;
        }
        if ($xmain["STATE"] != "UP") {
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "Added {$eth} {$xmain["IPADDR"]}\n";
        }
        $ETHZ[] = $eth;
    }
    if (count($ETHZ) == 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} no interface found\n";
        }
        return;
    }
    $interfaces_txt = @implode(",", $ETHZ);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Listens on {$interfaces_txt}\n";
    }
    @mkdir("/home/artica/bwm-ng", 0755, true);
    if (is_file("/home/artica/bwm-ng/interfaces.csv")) {
        @copy("/home/artica/bwm-ng/interfaces.csv", "/home/artica/bwm-ng/interfaces.csv." . time());
    }
    $cmd = "{$nohup} {$Masterbin} -D -t 5000 -o csv  -u bits -T rate -c 0 -a 0 --interfaces {$interfaces_txt} > /home/artica/bwm-ng/interfaces.csv 2>&1 &";
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service\n";
    }
    shell_exec($cmd);
    sleep(1);
    $pid = PID_NUM();
    if ($unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success PID {$pid}\n";
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.bwm-ng.php

示例6: ucarp_down

function ucarp_down()
{
    $unix = new unix();
    $interface = $_GET["ucarp-down"];
    $master = $_GET["master"];
    $NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES(true);
    if (!isset($NETWORK_ALL_INTERFACES[$interface])) {
        writelogs_framework("Interface {$interface} not up [OK]", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $nohup = $unix->find_program("nohup");
    $MN = unserialize(@file_get_contents("/usr/share/ucarp/ETH_LIST"));
    while (list($eth, $line) = each($MN)) {
        writelogs_framework("Interface {$eth} down [OK]", __FUNCTION__, __FILE__, __LINE__);
        $cmd = "{$nohup} /usr/share/ucarp/vip-eth0-down.sh >/dev/null 2>&1";
        writelogs_framework($cmd, __FUNCTION__, __FILE__, __LINE__);
        shell_exec($cmd);
        squid_admin_mysql(0, "Master [{$master}]: Ordered to shutdown {$interface} [OK]", null, __FILE__, __LINE__);
        echo "<articadatascgi>DOWN_OK</articadatascgi>";
    }
}
开发者ID:articatech,项目名称:artica,代码行数:21,代码来源:network.php

示例7: PING_GATEWAY

function PING_GATEWAY()
{
    $sock = new sockets();
    $unix = new unix();
    $MonitConfig = unserialize(base64_decode($sock->GET_INFO("SquidWatchdogMonitConfig")));
    $MonitConfig = PING_GATEWAY_DEFAULT_PARAMS($MonitConfig);
    if ($MonitConfig["ENABLE_PING_GATEWAY"] == 0) {
        return;
    }
    if (!isset($MonitConfig["PING_GATEWAY"])) {
        $MonitConfig["PING_GATEWAY"] = null;
    }
    $PING_GATEWAY = $MonitConfig["PING_GATEWAY"];
    if ($PING_GATEWAY == null) {
        $TCP_NICS_STATUS_ARRAY = $unix->NETWORK_ALL_INTERFACES();
        if (isset($TCP_NICS_STATUS_ARRAY["eth0"])) {
            $PING_GATEWAY = $TCP_NICS_STATUS_ARRAY["eth0"]["GATEWAY"];
        }
        if ($PING_GATEWAY == null) {
            if (isset($TCP_NICS_STATUS_ARRAY["eth1"])) {
                $PING_GATEWAY = $TCP_NICS_STATUS_ARRAY["eth1"]["GATEWAY"];
            }
        }
    }
    if ($PING_GATEWAY == null) {
        Events("No IP address defined in the configuration, aborting test...");
        return;
    }
    if (!$unix->isIPAddress($PING_GATEWAY)) {
        Events("\"{$PING_GATEWAY}\" not a valid ip address");
        return;
    }
    $STAMP_MAX_PING = intval(trim(@file_get_contents($GLOBALS["STAMP_MAX_PING"])));
    if (!is_numeric($STAMP_MAX_PING)) {
        $STAMP_MAX_PING = 1;
    }
    if ($STAMP_MAX_PING < 1) {
        $STAMP_MAX_PING = 1;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "PING {$PING_GATEWAY} STAMP_MAX_PING={$STAMP_MAX_PING}\n";
    }
    if ($unix->PingHost($PING_GATEWAY, true)) {
        if ($STAMP_MAX_PING > 1) {
            @file_put_contents($GLOBALS["STAMP_MAX_PING"], 1);
        }
        return;
    }
    if ($MonitConfig["PING_FAILED_RELOAD_NET"] == 0) {
        $report = $unix->NETWORK_REPORT();
        ToSyslog("kernel: [  Artica-Net] Start Network [artica-ifup] (" . basename(__FILE__) . "/" . __LINE__ . ")");
        shell_exec("/etc/init.d/artica-ifup start");
        if ($unix->PingHost($PING_GATEWAY, true)) {
            squid_admin_mysql(2, "Relink network success", "Relink network success after ping failed on {$PING_GATEWAY}:\nThe {$PING_GATEWAY} ping failed, Artica as restarted network and ping is now success.\nHere it is the network report when Ping failed\n{$report}");
            squid_admin_notifs("Relink network success after ping failed on {$PING_GATEWAY}:\nThe {$PING_GATEWAY} ping failed, Artica as restarted network and ping is now success.\nHere it is the network report when Ping failed\n{$report}", __FUNCTION__, __FILE__, __LINE__, "proxy");
            return;
        }
    }
    $MAX_PING_GATEWAY = $MonitConfig["MAX_PING_GATEWAY"];
    $STAMP_MAX_PING = $STAMP_MAX_PING + 1;
    Events("{$PING_GATEWAY} not available - {$STAMP_MAX_PING} time(s) / {$MAX_PING_GATEWAY} Max");
    @file_put_contents($GLOBALS["STAMP_MAX_PING"], $STAMP_MAX_PING);
    if ($STAMP_MAX_PING < $MAX_PING_GATEWAY) {
        return;
    }
    $UfdbguardSMTPNotifs = unserialize(base64_decode($sock->GET_INFO("UfdbguardSMTPNotifs")));
    if (!isset($UfdbguardSMTPNotifs["ENABLED_SQUID_WATCHDOG"])) {
        $UfdbguardSMTPNotifs["ENABLED_SQUID_WATCHDOG"] = 0;
    }
    if (!is_numeric($UfdbguardSMTPNotifs["ENABLED_SQUID_WATCHDOG"])) {
        $UfdbguardSMTPNotifs["ENABLED_SQUID_WATCHDOG"] = 0;
    }
    @file_put_contents($GLOBALS["STAMP_MAX_PING"], 1);
    if ($MonitConfig["PING_FAILED_REPORT"] == 1) {
        $report = $unix->NETWORK_REPORT();
        squid_admin_mysql(1, "Unable to ping {$PING_GATEWAY}", "{$report}");
        squid_admin_notifs("Unable to ping {$PING_GATEWAY}:\n{$report}", __FUNCTION__, __FILE__, __LINE__, "proxy");
    }
    if ($MonitConfig["PING_FAILED_FAILOVER"] == 1) {
        $GLOBALS["ALL_SCORES_WHY"][] = "function " . __FUNCTION__ . " return failed";
        $GLOBALS["ALL_SCORES"]++;
    }
    if ($MonitConfig["PING_FAILED_REBOOT"] == 1) {
        REBOOTING_SYSTEM();
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:86,代码来源:exec.squid.watchdog.php

示例8: ArticaHotSpotInterface

function ArticaHotSpotInterface()
{
    $ArticaHotSpotInterface = @file_get_contents("/etc/artica-postfix/settings/Daemons/ArticaHotSpotInterface");
    $ArticaSplashHotSpotPort = @file_get_contents("/etc/artica-postfix/settings/Daemons/ArticaSplashHotSpotPort");
    $ArticaSplashHotSpotPortSSL = @file_get_contents("/etc/artica-postfix/settings/Daemons/ArticaSplashHotSpotPortSSL");
    if (!is_numeric($ArticaSplashHotSpotPort)) {
        $ArticaSplashHotSpotPort = 16080;
    }
    if (!is_numeric($ArticaSplashHotSpotPortSSL)) {
        $ArticaSplashHotSpotPortSSL = 16443;
    }
    $unix = new unix();
    $NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
    while (list($interface, $line) = each($NETWORK_ALL_INTERFACES)) {
        $IP2 = $line["IPADDR"];
        if ($interface == "lo") {
            continue;
        }
        if ($IP2 == null) {
            continue;
        }
        if ($IP2 == "0.0.0.0") {
            continue;
        }
        $AVAIINT[] = $interface;
    }
    if ($ArticaHotSpotInterface == null) {
        $ArticaHotSpotInterface = $AVAIINT[0];
    }
    $ipaddr = trim($NETWORK_ALL_INTERFACES[$ArticaHotSpotInterface]["IPADDR"]);
    writelogs_framework("ArticaHotSpotInterface = {$ArticaHotSpotInterface} IPADDR:{$ipaddr}", __FUNCTION__, __FILE__, __LINE__);
    if ($ipaddr == "0.0.0.0" or $ipaddr == null) {
        $ArticaHotSpotInterface = $AVAIINT[0];
        writelogs_framework("NEw ArticaHotSpotInterface = {$AVAIINT[0]}", __FUNCTION__, __FILE__, __LINE__);
        $ipaddr = $NETWORK_ALL_INTERFACES[$ArticaHotSpotInterface]["IPADDR"];
    }
    writelogs_framework("http://{$ipaddr}:{$ArticaSplashHotSpotPort}/hotspot.php", __FUNCTION__, __FILE__, __LINE__);
    echo "<articadatascgi>http://{$ipaddr}:{$ArticaSplashHotSpotPort}/hotspot.php</articadatascgi>";
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:39,代码来源:hotspot.php

示例9: ProtectArtica

function ProtectArtica()
{
    $sock = new sockets();
    $unix = new unix();
    $q = new mysql();
    $NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES(true);
    $LighttpdArticaListenIP = $sock->GET_INFO("LighttpdArticaListenIP");
    $ArticaHttpsPort = intval($sock->GET_INFO("ArticaHttpsPort"));
    $iptables = $unix->find_program("iptables");
    if (!isset($NETWORK_ALL_INTERFACES[$LighttpdArticaListenIP])) {
        $LighttpdArticaListenIP = null;
    }
    if ($ArticaHttpsPort == 0) {
        $ArticaHttpsPort = 9000;
    }
    $MARKLOG = "-m comment --comment \"ArticaFireWall\"";
    $SCRIPT_FINAL[] = "";
    $SCRIPT_FINAL[] = "#Artica Web interface listens on `{$LighttpdArticaListenIP}` port:{$ArticaHttpsPort}";
    if ($LighttpdArticaListenIP != null) {
        $LighttpdArticaListenIP = " -d {$LighttpdArticaListenIP}";
    }
    $CountOfRules = $q->COUNT_ROWS("iptables_webint", "artica_backup");
    if ($CountOfRules == 0) {
        $sql = "SELECT `Interface`,`isFWAcceptArtica` FROM `nics` WHERE `isFW`=1 AND `isFWAcceptArtica`=1";
        $results = $q->QUERY_SQL($sql, "artica_backup");
        while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
            $SCRIPT_FINAL[] = "#This rule allow connections to the Web interface from {$ligne["Interface"]} in order to allow access to Artica Web interface";
            $SCRIPT_FINAL[] = "{$iptables} -I INPUT -i {$ligne["Interface"]} {$LighttpdArticaListenIP} -p tcp --dport {$ArticaHttpsPort} {$MARKLOG} -j ACCEPT || true";
            $SCRIPT_FINAL[] = "";
        }
        return @implode("\n", $SCRIPT_FINAL);
    }
    $SCRIPT_FINAL[] = "#This rule allow connection to the Web interface for only {$CountOfRules} items";
    $SCRIPT_FINAL[] = "{$iptables} -I INPUT{$LighttpdArticaListenIP} -p tcp --dport {$ArticaHttpsPort} {$MARKLOG} -j DROP || true";
    $SCRIPT_FINAL[] = "{$iptables} -I INPUT{$LighttpdArticaListenIP} -p tcp --dport {$ArticaHttpsPort} {$MARKLOG} --j LOG --log-level debug --log-prefix \"AID=0/INPUT/REJECT\" || true";
    $results = $q->QUERY_SQL("SELECT * FROM iptables_webint", "artica_backup");
    if (!$q->ok) {
        $q->mysql_error = str_replace("\n", "", $q->mysql_error);
        $SCRIPT_FINAL[] = "# {$q->mysql_error}";
        $SCRIPT_FINAL[] = "#This rule allow connections to the Web interface in order to allow access to Artica Web interface";
        $SCRIPT_FINAL[] = "{$iptables} -I INPUT{$LighttpdArticaListenIP} -p tcp --dport {$ArticaHttpsPort} {$MARKLOG} -j ACCEPT || true";
        $SCRIPT_FINAL[] = "";
        return @implode("\n", $SCRIPT_FINAL);
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $SCRIPT_FINAL[] = "{$iptables} -I INPUT -s {$ligne["pattern"]} {$LighttpdArticaListenIP} -p tcp --dport {$ArticaHttpsPort} {$MARKLOG} -j ACCEPT || true";
    }
    $SCRIPT_FINAL[] = "";
    return @implode("\n", $SCRIPT_FINAL);
}
开发者ID:articatech,项目名称:artica,代码行数:50,代码来源:exec.firewall.php

示例10: ebtables_rules

function ebtables_rules()
{
    $unix = new unix();
    $ebtables = $unix->find_program("ebtables");
    $aptget = $unix->find_program("apt-get");
    if ($GLOBALS["VERBOSE"]) {
        echo "EBTABLES: [" . __LINE__ . "] ebtables = {$ebtables}\n";
    }
    $NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
    $squid = new squidbee();
    $SSL_BUMP = $squid->SSL_BUMP;
    if ($GLOBALS["VERBOSE"]) {
        echo "EBTABLES: [" . __LINE__ . "] SSL_BUMP = {$SSL_BUMP}\n";
    }
    if (!is_file($ebtables)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "EBTABLES: [" . __LINE__ . "] NO BINARY apt-get = \"{$aptget}\"\n";
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " ebtables no such binary...\n";
        }
        $unix->DEBIAN_INSTALL_PACKAGE("ebtables");
    }
    $ebtables = $unix->find_program("ebtables");
    if (!is_file($ebtables)) {
        return "# ebtables, no such binary";
    }
    $q = new mysql();
    $sql = "SELECT `Interface` FROM `nics` WHERE `Bridged`=1";
    if ($GLOBALS["VERBOSE"]) {
        echo "[" . __LINE__ . "] {$sql}\n";
    }
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "{$q->mysql_error}\n";
    }
    $count = mysql_num_rows($results);
    if ($count == 0) {
        return "# ebtables, no bridge defined...";
    }
    $GLOBALS["EBTABLES"] = true;
    if ($GLOBALS["VERBOSE"]) {
        echo "[" . __LINE__ . "] EBTABLES = TRUE\n";
    }
    //iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 -j REDIRECT --to-port 3128
    $f[] = "# ebtables, {$count} Interfaces SSL_BUMP = {$SSL_BUMP}";
    $f[] = "{$ebtables} -t broute -X";
    $f[] = "{$ebtables} -t broute -F";
    $f[] = "{$ebtables} -t broute -A BROUTING -p IPv4 --ip-protocol 6 --ip-destination-port 80 -j redirect --redirect-target ACCEPT";
    if ($SSL_BUMP == 1) {
        $f[] = "{$ebtables} -t broute -A BROUTING -p IPv4 --ip-protocol 6 --ip-destination-port 443 -j redirect --redirect-target ACCEPT";
    }
    return @implode("\n", $f);
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:54,代码来源:exec.squid.transparent.php

示例11: NETWORK_ALL_INTERFACES

function NETWORK_ALL_INTERFACES()
{
    if (isset($GLOBALS["NETWORK_ALL_INTERFACES"])) {
        return $GLOBALS["NETWORK_ALL_INTERFACES"];
    }
    $unix = new unix();
    $GLOBALS["NETWORK_ALL_INTERFACES"] = $unix->NETWORK_ALL_INTERFACES(true);
    unset($GLOBALS["NETWORK_ALL_INTERFACES"]["127.0.0.1"]);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:9,代码来源:exec.zipproxy.php

示例12: apache_config

function apache_config()
{
    $sock = new sockets();
    $unix = new unix();
    $EnablePHPFPM = 0;
    $APACHE_SRC_ACCOUNT = $unix->APACHE_SRC_ACCOUNT();
    $APACHE_SRC_GROUP = $unix->APACHE_SRC_GROUP();
    if (preg_match("#APACHE_RUN_GROUP#", $APACHE_SRC_GROUP)) {
        $APACHE_SRC_GROUP = "www-data";
    }
    $LogFilePath = "/var/log/artica-wifidog/access.log";
    $directories[] = "/var/run/apache2";
    $directories[] = "/var/run/artica-apache";
    $directories[] = "/var/log/artica-wifidog";
    $directories[] = "/home/artica/hotspot/sessions";
    $directories[] = "/home/artica/hotspot/caches";
    while (list($index, $maindir) = each($directories)) {
        @mkdir($maindir, 0755, true);
        @chown($maindir, $APACHE_SRC_ACCOUNT);
        @chgrp($maindir, $APACHE_SRC_GROUP);
    }
    $ErrorLog = dirname($LogFilePath) . "/error.log";
    if (!is_file($LogFilePath)) {
        @touch($LogFilePath);
    }
    @chown($LogFilePath, $APACHE_SRC_ACCOUNT);
    @chgrp($LogFilePath, $APACHE_SRC_GROUP);
    if (!is_file($ErrorLog)) {
        @touch($ErrorLog);
    }
    @chown($ErrorLog, $APACHE_SRC_ACCOUNT);
    @chgrp($ErrorLog, $APACHE_SRC_GROUP);
    $APACHE_MODULES_PATH = $unix->APACHE_MODULES_PATH();
    $HotSpotMaxClients = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HotSpotMaxClients"));
    $HotSpotStartServers = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HotSpotStartServers"));
    $HotSpotForceDDOSDisable = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HotSpotForceDDOSDisable"));
    if ($HotSpotMaxClients == 0) {
        $HotSpotMaxClients = 20;
    }
    if ($HotSpotStartServers == 0) {
        $HotSpotStartServers = 5;
    }
    $EnableArticaHotSpot = $sock->GET_INFO("EnableArticaHotSpot");
    $SquidHotSpotPort = $sock->GET_INFO("SquidHotSpotPort");
    $ArticaHotSpotPort = $sock->GET_INFO("ArticaHotSpotPort");
    $ArticaSSLHotSpotPort = $sock->GET_INFO("ArticaSSLHotSpotPort");
    $ArticaSplashHotSpotPort = $sock->GET_INFO("ArticaSplashHotSpotPort");
    $ArticaSplashHotSpotPortSSL = $sock->GET_INFO("ArticaSplashHotSpotPortSSL");
    if (!is_numeric($ArticaHotSpotPort)) {
        $ArticaHotSpotPort = 0;
    }
    if (!is_numeric($ArticaSplashHotSpotPort)) {
        $ArticaSplashHotSpotPort = 16080;
    }
    if (!is_numeric($ArticaSplashHotSpotPortSSL)) {
        $ArticaSplashHotSpotPortSSL = 16443;
    }
    $ArticaHotSpotInterface = $sock->GET_INFO("ArticaHotSpotInterface");
    $HospotHTTPServerName = trim($sock->GET_INFO("HospotHTTPServerName"));
    $HotSpotErrorRedirect = $sock->GET_INFO("HotSpotErrorRedirect");
    if ($HotSpotErrorRedirect == null) {
        $HotSpotErrorRedirect = "http://www.msftncsi.com";
    }
    $Params = unserialize($sock->GET_INFO("HotSpotEvasive"));
    $ApacheEvasiveInstalled = intval($sock->GET_INFO("ApacheEvasiveInstalled"));
    if (!is_numeric($Params["DOSEnable"])) {
        $Params["DOSEnable"] = 1;
    }
    if (!is_numeric($Params["DOSHashTableSize"])) {
        $Params["DOSHashTableSize"] = 1024;
    }
    if (!is_numeric($Params["DOSPageCount"])) {
        $Params["DOSPageCount"] = 3;
    }
    if (!is_numeric($Params["DOSSiteCount"])) {
        $Params["DOSSiteCount"] = 20;
    }
    if (!is_numeric($Params["DOSPageInterval"])) {
        $Params["DOSPageInterval"] = 1;
    }
    if (!is_numeric($Params["DOSSiteInterval"])) {
        $Params["DOSSiteInterval"] = 10;
    }
    if (!is_numeric($Params["DOSBlockingPeriod"])) {
        $Params["DOSBlockingPeriod"] = 5;
    }
    $unix = new unix();
    $NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
    $ipaddr = $NETWORK_ALL_INTERFACES[$ArticaHotSpotInterface]["IPADDR"];
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} HotSpot run as {$ArticaHotSpotInterface} ( {$ipaddr} )\n";
    }
    if ($ipaddr == "0.0.0.0") {
        $ipaddr = "*";
    }
    if ($ipaddr == null) {
        $ipaddr = "*";
    }
    $GLOBALS["HOSTPOT_WEB_INTERFACE"] = $ipaddr;
    $phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
//.........这里部分代码省略.........
开发者ID:articatech,项目名称:artica,代码行数:101,代码来源:exec.hostpot-web.php

示例13: getFirstToken

function getFirstToken($httpaccess, $httpaccess_data, $ID)
{
    $IpClass = new IP();
    $unix = new unix();
    $valueToAdd = null;
    if ($httpaccess == "deny_access_except") {
        $reverse = true;
        $firstToken = "http_access deny";
    }
    if ($httpaccess == "access_allow") {
        $firstToken = "http_access allow";
    }
    if ($httpaccess == "access_deny") {
        $firstToken = "http_access deny";
    }
    if ($httpaccess == "cache_deny") {
        $firstToken = "cache deny";
    }
    if ($httpaccess == "http_reply_access_deny") {
        $firstToken = "http_reply_access deny";
    }
    if ($httpaccess == "http_reply_access_allow") {
        $firstToken = "http_reply_access allow";
    }
    if ($httpaccess == "url_rewrite_access_deny") {
        $firstToken = "url_rewrite_access deny";
    }
    if ($httpaccess == "url_rewrite_access_allow") {
        $firstToken = "url_rewrite_access allow";
    }
    if ($httpaccess == "tcp_outgoing_address") {
        $firstToken = "tcp_outgoing_address";
    }
    if ($httpaccess == "request_header_add") {
        $firstToken = "request_header_add";
    }
    if ($httpaccess == "log_access") {
        $firstToken = "access_log";
    }
    if ($httpaccess == "deny_log") {
        $firstToken = "access_log none";
    }
    if ($httpaccess == "tcp_outgoing_tos") {
        $valueToAdd = $httpaccess_data;
        if ($valueToAdd == null) {
            continue;
        }
        $valueToAdd = $valueToAdd . " ";
    }
    if ($httpaccess == "reply_body_max_size") {
        $valueToAdd = intval($httpaccess_data);
        if ($valueToAdd == 0) {
            continue;
        }
        $valueToAdd = $valueToAdd . " MB ";
    }
    if ($httpaccess == "tcp_outgoing_address") {
        $valueToAdd = $httpaccess_data;
        if ($valueToAdd == null) {
            continue;
        }
        if ($IpClass->isValid($valueToAdd)) {
            continue;
        }
        $LOCALSIPS = $unix->NETWORK_ALL_INTERFACES(true);
        if (preg_match("#[0-9\\.]+#", $valueToAdd)) {
            $valueToAdd = trim($valueToAdd);
            if (!isset($LOCALSIPS[$valueToAdd])) {
                $GLOBALS["tcp_outgoing_address_errors"][] = "Error tcp_outgoing_address {$valueToAdd} NO SUCH ADDRESS";
                if ($GLOBALS["VERBOSE"]) {
                    echo "tcp_outgoing_address \"{$valueToAdd}\" PORT:{$aclport} NO SUCH ADDRESS !!!\n";
                }
                continue;
            }
        }
        $valueToAdd = $valueToAdd . " ";
    }
    if ($httpaccess == "request_header_add") {
        $httpaccess_data = unserialize(base64_decode($httpaccess_data));
        $request_header_add_name = $httpaccess_data["header_name"];
        $request_header_add_value = $httpaccess_data["header_value"];
        if (trim($request_header_add_name) == null) {
            continue;
        }
        if (trim($request_header_add_value) == null) {
            continue;
        }
        $valueToAdd = "{$request_header_add_name} \"{$request_header_add_value}\" ";
    }
    if ($httpaccess == "log_access") {
        $valueToAdd = "stdio:/var/log/squid/access_acl_{$ID}.csv csv_acls ";
    }
    return "{$firstToken} {$valueToAdd}";
}
开发者ID:articatech,项目名称:artica,代码行数:94,代码来源:exec.squid-meta.php

示例14: vde_status

function vde_status($aspid = false)
{
    $unix = new unix();
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $ips = $unix->NETWORK_ALL_INTERFACES();
    $ifconfig = $unix->find_program("ifconfig");
    $ip = $unix->find_program("ip");
    while (list($eth, $ligne) = each($ips)) {
        if (!preg_match("#^virt([0-9]+)#", $eth, $re)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$eth} SKIP...\n";
            }
            continue;
        }
        $ID = $re[1];
        $ligne = unserialize(@file_get_contents("/etc/vde_switch_config/{$ID}.conf"));
        $eth = $ligne["nic"];
        $virtname = "virt{$ID}";
        $pid = vde_switch_pid($eth);
        if ($unix->process_exists($pid)) {
            $ARRAY[$virtname]["VDE"] = $pid;
            $ARRAY[$virtname]["VDE_RUN"] = $unix->PROCCESS_TIME_MIN($pid);
        }
        $pid = vde_plug2tap_pid($virtname);
        if ($unix->process_exists($pid)) {
            $ARRAY[$virtname]["PCAP"] = $pid;
            $ARRAY[$virtname]["PCAP_RUN"] = $unix->PROCCESS_TIME_MIN($pid);
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        print_r($ARRAY);
    }
    @mkdir("/usr/share/artica-postfix/ressources/logs/web", 0777, true);
    @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/vde_status", serialize($ARRAY));
    @chmod("/usr/share/artica-postfix/ressources/logs/web/vde_status", 0755);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:47,代码来源:exec.vde.php

示例15: NETWORK_INTERFACES_RXTX

function NETWORK_INTERFACES_RXTX()
{
    $unix = new unix();
    $influx = new influx();
    $NETS = $unix->NETWORK_ALL_INTERFACES();
    $hostname = $unix->hostname_g();
    $now = date("Y-m-d H:i:s", strtotime("-24 hour"));
    $q = new postgres_sql();
    // -----------------------------------------------------------------------------------------------------
    while (list($Interface, $array) = each($NETS)) {
        $sql = "SELECT SUM(RX) as size FROM ethrxtx,date_trunc('hour', zdate) as zdate \n\t\tWHERE zdate > '{$now}'\n\t\tAND eth='{$Interface}' AND proxyname='{$hostname}' GROUP BY zdate ORDER BY zdate ASC";
        if ($GLOBALS["VERBOSE"]) {
            echo "\n*****\n{$sql}\n******\n";
        }
        $MAIN = array();
        $xdata = array();
        $ydata = array();
        $results = $q->QUERY_SQL($sql);
        while ($ligne = @pg_fetch_assoc($results)) {
            $min = $ligne["zdate"];
            $size = intval($ligne["size"]) / 1024;
            if ($GLOBALS["VERBOSE"]) {
                echo "({$min}): ethrxtx {$Interface}:RX: {$min} -> {$size}\n";
            }
            $size = $size / 1024;
            if (round($size) == 0) {
                continue;
            }
            $xdata[] = $min;
            $ydata[] = round($size);
        }
        $MAIN["xdata"] = $xdata;
        $MAIN["ydata"] = $ydata;
        @file_put_contents("{$GLOBALS["BASEDIR"]}/FLUX_{$Interface}_RX", serialize($MAIN));
        if (count($xdata) < 2) {
            @unlink("{$GLOBALS["BASEDIR"]}/FLUX_{$Interface}_RX");
        }
        $sql = "SELECT SUM(TX) as size,date_trunc('hour', zdate) as zdate FROM ethrxtx \n\t\tWHERE zdate > '{$now}' AND eth='{$Interface}'  \n\t\tAND proxyname='{$hostname}' GROUP BY zdate ORDER BY zdate ASC";
        $MAIN = array();
        $xdata = array();
        $ydata = array();
        build_progress("{refresh_dashboard_values}", 15);
        $results = $q->QUERY_SQL($sql);
        while ($ligne = @pg_fetch_assoc($results)) {
            $min = $ligne["zdate"];
            $size = intval($ligne["size"]) / 1024;
            if ($GLOBALS["VERBOSE"]) {
                echo "({$min}): ethrxtx {$Interface}:RX: {$min} -> {$size}\n";
            }
            $size = $size / 1024;
            if (round($size) == 0) {
                continue;
            }
            $xdata[] = $min;
            $ydata[] = round($size);
        }
        $MAIN["xdata"] = $xdata;
        $MAIN["ydata"] = $ydata;
        @file_put_contents("{$GLOBALS["BASEDIR"]}/FLUX_{$Interface}_TX", serialize($MAIN));
        if (count($xdata) < 2) {
            @unlink("{$GLOBALS["BASEDIR"]}/FLUX_{$Interface}_TX");
        }
    }
}
开发者ID:articatech,项目名称:artica,代码行数:64,代码来源:exec.squid.interface-size.php


注:本文中的unix::NETWORK_ALL_INTERFACES方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。