summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJano Slota <jano@alokal.eu>2014-02-18 18:31:09 +0100
committerczaks <marcin@6irc.net>2014-02-18 23:50:01 +0100
commit9dad842c2471602dbcfad0de0291bfd54d39f852 (patch)
treedf8b26f9d5288c96d6c1d3dadadb47cffb0fb8d7
parentada45312a4b1ddc4f975dcd9c1d272a73a701ffd (diff)
Moved the external geoip files to inc/lib/geoip and made the geoip code a bit prettier
-rw-r--r--inc/lib/geoip/GeoIPv6.dat (renamed from GeoIPv6.dat)bin1127489 -> 1127489 bytes
-rw-r--r--inc/lib/geoip/geoip.inc (renamed from geoip.inc)0
-rw-r--r--post.php27
3 files changed, 13 insertions, 14 deletions
diff --git a/GeoIPv6.dat b/inc/lib/geoip/GeoIPv6.dat
index 1c2658c5..1c2658c5 100644
--- a/GeoIPv6.dat
+++ b/inc/lib/geoip/GeoIPv6.dat
Binary files differ
diff --git a/geoip.inc b/inc/lib/geoip/geoip.inc
index 99eb244e..99eb244e 100644
--- a/geoip.inc
+++ b/inc/lib/geoip/geoip.inc
diff --git a/post.php b/post.php
index 2f2d3ff4..0bfd0327 100644
--- a/post.php
+++ b/post.php
@@ -447,26 +447,25 @@ if (isset($_POST['delete'])) {
}
if ($config['country_flags']) {
- require 'geoip.inc';
- $gi=geoip_open('GeoIPv6.dat', GEOIP_STANDARD);
+ require 'inc/lib/geoip/geoip.inc';
+ $gi=geoip_open('inc/lib/geoip/GeoIPv6.dat', GEOIP_STANDARD);
- function IPv4To6($ip) {
+ function ipv4to6($ip) {
if (strpos($ip, ':') !== false) {
- if (strpos($ip, '.') > 0) {
+ if (strpos($ip, '.') > 0)
$ip = substr($ip, strrpos($ip, ':')+1);
- }
else return $ip; //native ipv6
- }
- $iparr = array_pad(explode('.', $ip), 4, 0);
- $Part7 = base_convert(($iparr[0] * 256) + $iparr[1], 10, 16);
- $Part8 = base_convert(($iparr[2] * 256) + $iparr[3], 10, 16);
- return '::ffff:'.$Part7.':'.$Part8;
+ }
+ $iparr = array_pad(explode('.', $ip), 4, 0);
+ $part7 = base_convert(($iparr[0] * 256) + $iparr[1], 10, 16);
+ $part8 = base_convert(($iparr[2] * 256) + $iparr[3], 10, 16);
+ return '::ffff:'.$part7.':'.$part8;
}
- if ($country_code = geoip_country_code_by_addr_v6($gi, IPv4To6($_SERVER['REMOTE_ADDR']))) {
- if (!in_array(strtolower($country_code), array('eu', 'ap', 'o1', 'a1', 'a2')))
- $post['body'] .= "\n<tinyboard flag>" . strtolower($country_code) . "</tinyboard>" .
- "\n<tinyboard flag alt>" . geoip_country_name_by_addr_v6($gi, IPv4To6($_SERVER['REMOTE_ADDR'])) . "</tinyboard>";
+ if ($country_code = geoip_country_code_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR']))) {
+ if (!in_array(strtolower($country_code), array('eu', 'ap', 'o1', 'a1', 'a2')))
+ $post['body'] .= "\n<tinyboard flag>".strtolower($country_code)."</tinyboard>".
+ "\n<tinyboard flag alt>".geoip_country_name_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR']))."</tinyboard>";
}
}