當前位置: 首頁>>代碼示例>>PHP>>正文


PHP match_cidr函數代碼示例

本文整理匯總了PHP中match_cidr函數的典型用法代碼示例。如果您正苦於以下問題:PHP match_cidr函數的具體用法?PHP match_cidr怎麽用?PHP match_cidr使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了match_cidr函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: bb2_yahoo

function bb2_yahoo($package)
{
    if (match_cidr($package['ip'], array("202.160.176.0/20", "67.195.0.0/16", "203.209.252.0/24", "72.30.0.0/16", "98.136.0.0/14", "74.6.0.0/16")) === FALSE) {
        return "71436a15";
    }
    return false;
}
開發者ID:splitbrain,項目名稱:dokuwiki-plugin-badbehaviour,代碼行數:7,代碼來源:yahoo.inc.php

示例2: bb2_msnbot

function bb2_msnbot($package)
{
    if (match_cidr($package['ip'], array("207.46.0.0/16", "65.52.0.0/14", "207.68.128.0/18", "207.68.192.0/20", "64.4.0.0/18", "157.54.0.0/15", "157.60.0.0/16", "157.56.0.0/14", "199.30.16.0/20", "131.253.24.0/21", "131.253.21.0/24", "131.253.22.0/23", "131.253.32.0/20")) === FALSE) {
        return "e4de0453";
    }
    return false;
}
開發者ID:NewRoute,項目名稱:glfusion,代碼行數:7,代碼來源:msnbot.inc.php

示例3: bb2_msnbot

function bb2_msnbot($package)
{
    if (match_cidr($package['ip'], "207.46.0.0/16") === FALSE && match_cidr($package['ip'], "65.52.0.0/14") === FALSE && match_cidr($package['ip'], "207.68.128.0/18") === FALSE && match_cidr($package['ip'], "207.68.192.0/20") === FALSE && match_cidr($package['ip'], "64.4.0.0/18") === FALSE) {
        return "e4de0453";
    }
    return false;
}
開發者ID:joseph-mudloff,項目名稱:pixie-cms,代碼行數:7,代碼來源:msnbot.inc.php

示例4: bb2_google

function bb2_google($package)
{
    if (match_cidr($package['ip'], "66.249.64.0/19") === FALSE && match_cidr($package['ip'], "64.233.160.0/19") === FALSE) {
        return "f1182195";
    }
    return false;
}
開發者ID:kldeepak,項目名稱:swara,代碼行數:7,代碼來源:google.inc.php

示例5: bb2_whitelist

function bb2_whitelist($package)
{
    $whitelists = @parse_ini_file(dirname(BB2_CORE) . "/whitelist.ini");
    if (@(!empty($whitelists['ip']))) {
        foreach ($whitelists['ip'] as $range) {
            if (match_cidr($package['ip'], $range)) {
                return true;
            }
        }
    }
    if (@(!empty($whitelists['useragent']))) {
        foreach ($whitelists['useragent'] as $user_agent) {
            if (!strcmp($package['headers_mixed']['User-Agent'], $user_agent)) {
                return true;
            }
        }
    }
    if (@(!empty($whitelists['url']))) {
        if (strpos($package['request_uri'], "?") === FALSE) {
            $request_uri = $package['request_uri'];
        } else {
            $request_uri = substr($package['request_uri'], 0, strpos($package['request_uri'], "?"));
        }
        foreach ($whitelists['url'] as $url) {
            if (!strcmp($request_uri, $url)) {
                return true;
            }
        }
    }
    return false;
}
開發者ID:joseph-mudloff,項目名稱:pixie-cms,代碼行數:31,代碼來源:whitelist.inc.php

示例6: bb2_reverse_proxy

function bb2_reverse_proxy($settings, $headers_mixed)
{
    # Detect if option is on when it should be off
    $header = uc_all($settings['reverse_proxy_header']);
    if (!array_key_exists($header, $headers_mixed)) {
        return false;
    }
    $addrs = @array_reverse(preg_split("/[\\s,]+/", $headers_mixed[$header]));
    # Skip our known reverse proxies and private addresses
    if (!empty($settings['reverse_proxy_addresses'])) {
        foreach ($addrs as $addr) {
            if (!match_cidr($addr, $settings['reverse_proxy_addresses']) && !is_rfc1918($addr)) {
                return $addr;
            }
        }
    } else {
        foreach ($addrs as $addr) {
            if (!is_rfc1918($addr)) {
                return $addr;
            }
        }
    }
    # If we got here, someone is playing a trick on us.
    return false;
}
開發者ID:RoadrunnerWMC,項目名稱:ABXD-plugins,代碼行數:25,代碼來源:core.inc.php

示例7: bb2_google

function bb2_google($package)
{
    if (match_cidr($package['ip'], "66.249.64.0/19") === FALSE && match_cidr($package['ip'], "64.233.160.0/19") === FALSE && match_cidr($package['ip'], "72.14.192.0/18") === FALSE && match_cidr($package['ip'], "203.208.32.0/19") === FALSE && match_cidr($package['ip'], "74.125.0.0/16") === FALSE && match_cidr($package['ip'], "216.239.32.0/19") === FALSE && match_cidr($package['ip'], "209.85.128.0/17") === FALSE) {
        return "f1182195";
    }
    return false;
}
開發者ID:splitbrain,項目名稱:dokuwiki-plugin-badbehaviour,代碼行數:7,代碼來源:google.inc.php

示例8: bb2_whitelist

function bb2_whitelist($package)
{
    // DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER!
    // Inappropriate whitelisting WILL expose you to spam, or cause Bad
    // Behavior to stop functioning entirely!  DO NOT WHITELIST unless you
    // are 100% CERTAIN that you should.
    // IP address ranges use the CIDR format.
    // Includes four examples of whitelisting by IP address and netblock.
    $bb2_whitelist_ip_ranges = array("64.191.203.34", "208.67.217.130", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16");
    // DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER!
    // Inappropriate whitelisting WILL expose you to spam, or cause Bad
    // Behavior to stop functioning entirely!  DO NOT WHITELIST unless you
    // are 100% CERTAIN that you should.
    // You should not whitelist search engines by user agent. Use the IP
    // netblock for the search engine instead. See http://whois.arin.net/
    // to locate the netblocks for an IP.
    // User agents are matched by exact match only.
    // Includes one example of whitelisting by user agent.
    // All are commented out.
    $bb2_whitelist_user_agents = array();
    // DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER!
    // Inappropriate whitelisting WILL expose you to spam, or cause Bad
    // Behavior to stop functioning entirely!  DO NOT WHITELIST unless you
    // are 100% CERTAIN that you should.
    // URLs are matched from the first / after the server name up to,
    // but not including, the ? (if any).
    // Includes two examples of whitelisting by URL.
    $bb2_whitelist_urls = array();
    // DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER!
    // Do not edit below this line
    if (!empty($bb2_whitelist_ip_ranges)) {
        foreach ($bb2_whitelist_ip_ranges as $range) {
            if (match_cidr($package['ip'], $range)) {
                return true;
            }
        }
    }
    if (!empty($bb2_whitelist_user_agents)) {
        foreach ($bb2_whitelist_user_agents as $user_agent) {
            if (!strcmp($package['headers_mixed']['User-Agent'], $user_agent)) {
                return true;
            }
        }
    }
    if (!empty($bb2_whitelist_urls)) {
        if (strpos($package['request_uri'], "?") === FALSE) {
            $request_uri = $package['request_uri'];
        } else {
            $request_uri = substr($package['request_uri'], 0, strpos($package['request_uri'], "?"));
        }
        foreach ($bb2_whitelist_urls as $url) {
            if (!strcmp($request_uri, $url)) {
                return true;
            }
        }
    }
    return false;
}
開發者ID:spacequad,項目名稱:glfusion,代碼行數:58,代碼來源:whitelist.inc.php

示例9: bb2_konqueror

function bb2_konqueror($package)
{
    // CafeKelsa is a dev project at Yahoo which indexes job listings for
    // Yahoo! HotJobs. It identifies as Konqueror so we skip these checks.
    if (stripos($package['headers_mixed']['User-Agent'], "YahooSeeker/CafeKelsa") === FALSE || match_cidr($package['ip'], "209.73.160.0/19") === FALSE) {
        if (!array_key_exists('Accept', $package['headers_mixed'])) {
            return "17566707";
        }
    }
    return false;
}
開發者ID:KeiroD,項目名稱:Elkarte,代碼行數:11,代碼來源:browser.inc.php

示例10: bb2_yahoo

function bb2_yahoo($package)
{
    if (match_cidr($package['ip'], array("202.160.176.0/20", "67.195.0.0/16", "203.209.252.0/24", "72.30.0.0/16", "98.136.0.0/14", "74.6.0.0/16")) === FALSE) {
        return '71436a15';
    }
    #	Disabled due to http://bugs.php.net/bug.php?id=53092
    #	if (!bb2_roundtripdns($package['ip'], "crawl.yahoo.net")) {
    #		return "71436a15";
    #	}
    return false;
}
開發者ID:nealpoole,項目名稱:fluxbb-bad-behavior,代碼行數:11,代碼來源:searchengine.inc.php

示例11: bb2_baidu

function bb2_baidu($package)
{
    if (@is_ipv6($package['ip'])) {
        return false;
    }
    # TODO
    if (match_cidr($package['ip'], array("119.63.192.0/21", "123.125.71.0/24", "180.76.0.0/16", "220.181.0.0/16")) === FALSE) {
        return false;
        # Soft fail, must pass other screening
    }
    return 1;
    # Real Baidu bot; bypass all other checks
}
開發者ID:KeiroD,項目名稱:Elkarte,代碼行數:13,代碼來源:searchengine.inc.php

示例12: match_cidr

function match_cidr($addr, $cidr)
{
    $output = false;
    if (is_array($cidr)) {
        foreach ($cidr as $cidrlet) {
            if (match_cidr($addr, $cidrlet)) {
                $output = true;
            }
        }
    } else {
        list($ip, $mask) = explode('/', $cidr);
        $mask = 4294967295.0 << 32 - $mask;
        $output = (ip2long($addr) & $mask) == (ip2long($ip) & $mask);
    }
    return $output;
}
開發者ID:BackupTheBerlios,項目名稱:openzaurus-svn,代碼行數:16,代碼來源:functions.inc.php

示例13: match_cidr

function match_cidr($addr, $cidr)
{
    $output = false;
    if (is_array($cidr)) {
        foreach ($cidr as $cidrlet) {
            if (match_cidr($addr, $cidrlet)) {
                $output = true;
            }
        }
    } else {
        @(list($ip, $mask) = explode('/', $cidr));
        if (!$mask) {
            $mask = 32;
        }
        $mask = pow(2, 32) - pow(2, 32 - $mask);
        $output = (ip2long($addr) & $mask) == (ip2long($ip) & $mask);
    }
    return $output;
}
開發者ID:joseph-mudloff,項目名稱:pixie-cms,代碼行數:19,代碼來源:functions.inc.php

示例14: bb2_whitelist

function bb2_whitelist($package)
{
    // DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER!
    // Inappropriate whitelisting WILL expose you to spam, or cause Bad
    // Behavior to stop functioning entirely!  DO NOT WHITELIST unless you
    // are 100% CERTAIN that you should.
    // IP address ranges use the CIDR format.
    // check for override file and use that to allow for customization for local setup
    if (file_exists(BADBEHAVIOR_PKG_PATH . 'whitelist_config_inc.php')) {
        include_once BADBEHAVIOR_PKG_PATH . 'whitelist_config_inc.php';
    } else {
        // Includes four examples of whitelisting by IP address and netblock.
        $bb2_whitelist_ip_ranges = array("64.191.203.34", "208.67.217.130", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16");
    }
    // DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER!
    // Inappropriate whitelisting WILL expose you to spam, or cause Bad
    // Behavior to stop functioning entirely!  DO NOT WHITELIST unless you
    // are 100% CERTAIN that you should.
    // You should not whitelist search engines by user agent. Use the IP
    // netblock for the search engine instead. See http://whois.arin.net/
    // to locate the netblocks for an IP.
    // User agents are matched by exact match only.
    // Includes one example of whitelisting by user agent.
    // All are commented out.
    $bb2_whitelist_user_agents = array();
    // DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER!
    // Do not edit below this line
    if (!empty($bb2_whitelist_ip_ranges)) {
        foreach ($bb2_whitelist_ip_ranges as $range) {
            if (match_cidr($package['ip'], $range)) {
                return true;
            }
        }
    }
    if (!empty($bb2_whitelist_user_agents)) {
        foreach ($bb2_whitelist_user_agents as $user_agent) {
            if (!strcmp($package['headers_mixed']['User-Agent'], $user_agent)) {
                return true;
            }
        }
    }
    return false;
}
開發者ID:bitweaver,項目名稱:badbehavior,代碼行數:43,代碼來源:whitelist.inc.php

示例15: match_cidr

function match_cidr($addr, $cidr)
{
    $output = false;
    if (is_array($cidr)) {
        foreach ($cidr as $cidrlet) {
            if (match_cidr($addr, $cidrlet)) {
                $output = true;
            }
        }
    } else {
        $_parts = explode('/', $cidr);
        $ip = $_parts[0];
        if (isset($_parts[1])) {
            $mask = $_parts[1];
        } else {
            $mask = 32;
        }
        $mask = pow(2, 32) - pow(2, 32 - $mask);
        $output = (ip2long($addr) & $mask) == (ip2long($ip) & $mask);
    }
    return $output;
}
開發者ID:aunderwo,項目名稱:sobc,代碼行數:22,代碼來源:functions.inc.php


注:本文中的match_cidr函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。