Beispiel #1
0
function update_ips($announced, $port)
{
    $i = get_ips();
    if (strlen($announced) > 0) {
        if ($announced == "0") {
            print "PORT?";
            die;
        } else {
            if (($t = no_duplicates($_SERVER['REMOTE_ADDR'], $i)) == -1) {
                $t = count($i);
                $i[$t][0] = $announced;
                $i[$t][1] = $port;
                $i[$t][2] = $_SERVER['REMOTE_ADDR'];
                $i[$t][3] = date('m/d/Y H:i:s');
                $i[$t][4] = $_GET['x'];
                $i[$t][5] = $_GET['y'];
            } else {
                $i[$t][0] = $announced;
                $i[$t][1] = $port;
                $i[$t][2] = $_SERVER['REMOTE_ADDR'];
                $i[$t][3] = date('m/d/Y H:i:s');
                $i[$t][4] = $_GET['x'];
                $i[$t][5] = $_GET['y'];
            }
        }
    }
    $i = sort_ip_by_xydist($i, $_GET['x'], $_GET['y']);
    echo save_ips($i);
}
Beispiel #2
0
function if_type($ip_addr)
{
    $tmp = array();
    $lan_ip = get_ips("brlan0");
    //routed IPv4 and IPv6
    $cm_ip = get_ips("wan0");
    $lan0_ip = get_ips("lan0");
    //bridged lan0, v4 only
    //Note: 3939 has no static IP, so do not need workaround as 3939B
    if (strstr($ip_addr, ".")) {
        //ipv4, something like "::ffff:10.1.10.1"
        $tmp = explode(":", $ip_addr);
        $ip_addr = array_pop($tmp);
    }
    if (in_array($ip_addr, $lan_ip) || in_array($ip_addr, $lan0_ip)) {
        return "lan_ip";
    } else {
        if (in_array($ip_addr, $cm_ip)) {
            return "cm_ip";
        } else {
            return "rg_ip";
        }
    }
    // print_r($lan_ip);
    // print_r($cm_ip);
}