1<?php if (!defined('BB2_CORE')) die('I said no cheating!');
2
3function bb2_whitelist($package)
4{
5	// DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER!
6
7	// Inappropriate whitelisting WILL expose you to spam, or cause Bad
8	// Behavior to stop functioning entirely!  DO NOT WHITELIST unless you
9	// are 100% CERTAIN that you should.
10
11	// IP address ranges use the CIDR format.
12
13	// Includes four examples of whitelisting by IP address and netblock.
14	$bb2_whitelist_ip_ranges = array(
15		"64.191.203.34",	// Digg whitelisted as of 2.0.12
16		"208.67.217.130",	// Digg whitelisted as of 2.0.12
17		"10.0.0.0/8",
18		"172.16.0.0/12",
19		"192.168.0.0/16",
20//		"127.0.0.1",
21	);
22
23	// DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER!
24
25	// Inappropriate whitelisting WILL expose you to spam, or cause Bad
26	// Behavior to stop functioning entirely!  DO NOT WHITELIST unless you
27	// are 100% CERTAIN that you should.
28
29	// You should not whitelist search engines by user agent. Use the IP
30	// netblock for the search engine instead. See http://whois.arin.net/
31	// to locate the netblocks for an IP.
32
33	// User agents are matched by exact match only.
34
35	// Includes one example of whitelisting by user agent.
36	// All are commented out.
37	$bb2_whitelist_user_agents = array(
38	//	"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) It's me, let me in",
39	);
40
41	// DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER!
42
43	// Inappropriate whitelisting WILL expose you to spam, or cause Bad
44	// Behavior to stop functioning entirely!  DO NOT WHITELIST unless you
45	// are 100% CERTAIN that you should.
46
47	// URLs are matched from the first / after the server name up to,
48	// but not including, the ? (if any).
49
50	// Includes two examples of whitelisting by URL.
51	$bb2_whitelist_urls = array(
52	//	"/example.php",
53	//	"/openid/server",
54	);
55
56	// DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER! DANGER!
57
58	// Do not edit below this line
59
60	if (!empty($bb2_whitelist_ip_ranges)) {
61		foreach ($bb2_whitelist_ip_ranges as $range) {
62			if (match_cidr($package['ip'], $range)) return true;
63		}
64	}
65	if (!empty($bb2_whitelist_user_agents)) {
66		foreach ($bb2_whitelist_user_agents as $user_agent) {
67			if (!strcmp($package['headers_mixed']['User-Agent'], $user_agent)) return true;
68		}
69	}
70	if (!empty($bb2_whitelist_urls)) {
71		if (strpos($package['request_uri'], "?") === FALSE) {
72			$request_uri = $package['request_uri'];
73		} else {
74			$request_uri = substr($package['request_uri'], 0, strpos($package['request_uri'], "?"));
75		}
76		foreach ($bb2_whitelist_urls as $url) {
77			if (!strcmp($request_uri, $url)) return true;
78		}
79	}
80	return false;
81}
82
83?>
84