Rework the GeoIP code, add country-based poster names
This commit is contained in:
22
post.php
22
post.php
@@ -488,26 +488,8 @@ if (isset($_POST['delete'])) {
|
||||
}
|
||||
|
||||
if ($config['country_flags']) {
|
||||
require 'inc/lib/geoip/geoip.inc';
|
||||
$gi=geoip\geoip_open('inc/lib/geoip/GeoIPv6.dat', GEOIP_STANDARD);
|
||||
|
||||
function ipv4to6($ip) {
|
||||
if (strpos($ip, ':') !== false) {
|
||||
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;
|
||||
}
|
||||
|
||||
if ($country_code = geoip\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\geoip_country_name_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR']))."</tinyboard>";
|
||||
}
|
||||
if (!in_array($country_code, array('eu', 'ap', 'o1', 'a1', 'a2')))
|
||||
$post['body'] .= "\n<tinyboard flag>".$country_code."</tinyboard>\n<tinyboard flag alt>".$country_name."</tinyboard>";
|
||||
}
|
||||
|
||||
if ($config['user_flag'] && isset($_POST['user_flag']))
|
||||
|
Reference in New Issue
Block a user