mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-15 03:17:38 +01:00
Added Feature - You can assign flag defined in config to any given IP - Also added Gypsy flag
This commit is contained in:
parent
0e5d975d83
commit
048a1c7d76
@ -1193,6 +1193,7 @@
|
||||
$config['error']['invalidtheme'] = _('That theme doesn\'t exist!');
|
||||
$config['error']['csrf'] = _('Invalid security token! Please go back and try again.');
|
||||
$config['error']['badsyntax'] = _('Your code contained PHP syntax errors. Please go back and correct them. PHP says: ');
|
||||
$config['error']['bad_gypsie'] = _('The provided Country ID is not allowed');
|
||||
|
||||
/*
|
||||
* =========================
|
||||
@ -1575,6 +1576,12 @@
|
||||
$config['mod']['flood'] = &$config['mod']['bypass_filters'];
|
||||
// Raw HTML posting
|
||||
$config['mod']['rawhtml'] = ADMIN;
|
||||
// The ability to make IP's into Gypsies
|
||||
$config['mod']['make_gypsies'] = MOD;
|
||||
$config['mod']['gypsie_countries'] = array(
|
||||
38 => 'Canada',
|
||||
256 => 'Gypsy'
|
||||
);
|
||||
|
||||
/* Administration */
|
||||
// View the report queue
|
||||
|
@ -35,6 +35,22 @@ register_shutdown_function('fatal_error_handler');
|
||||
mb_internal_encoding('UTF-8');
|
||||
loadConfig();
|
||||
|
||||
|
||||
// ipv4to6 function Moved out of /post.php
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function init_locale($locale, $error='error') {
|
||||
if (extension_loaded('gettext')) {
|
||||
if (setlocale(LC_ALL, $locale) === false) {
|
||||
|
@ -123,7 +123,7 @@ class GeoIP {
|
||||
"VU" => 234, "WF" => 235, "WS" => 236, "YE" => 237, "YT" => 238, "RS" => 239,
|
||||
"ZA" => 240, "ZM" => 241, "ME" => 242, "ZW" => 243, "A1" => 244, "A2" => 245,
|
||||
"O1" => 246, "AX" => 247, "GG" => 248, "IM" => 249, "JE" => 250, "BL" => 251,
|
||||
"MF" => 252, "BQ" => 253, "SS" => 254
|
||||
"MF" => 252, "BQ" => 253, "SS" => 254, "GX" => 255
|
||||
);
|
||||
var $GEOIP_COUNTRY_CODES = array(
|
||||
"","AP","EU","AD","AE","AF","AG","AI","AL","AM","CW",
|
||||
@ -151,7 +151,7 @@ class GeoIP {
|
||||
"TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE",
|
||||
"VG","VI","VN","VU","WF","WS","YE","YT","RS","ZA",
|
||||
"ZM","ME","ZW","A1","A2","O1","AX","GG","IM","JE",
|
||||
"BL","MF", "BQ", "SS", "O1" );
|
||||
"BL","MF", "BQ", "SS", "O1", "GX" );
|
||||
var $GEOIP_COUNTRY_CODES3 = array(
|
||||
"","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","CUW",
|
||||
"AGO","ATA","ARG","ASM","AUT","AUS","ABW","AZE","BIH","BRB",
|
||||
@ -178,7 +178,7 @@ class GeoIP {
|
||||
"TZA","UKR","UGA","UMI","USA","URY","UZB","VAT","VCT","VEN",
|
||||
"VGB","VIR","VNM","VUT","WLF","WSM","YEM","MYT","SRB","ZAF",
|
||||
"ZMB","MNE","ZWE","A1","A2","O1","ALA","GGY","IMN","JEY",
|
||||
"BLM","MAF", "BES", "SSD", "O1"
|
||||
"BLM","MAF", "BES", "SSD", "O1", "GYP"
|
||||
);
|
||||
var $GEOIP_COUNTRY_NAMES = array(
|
||||
"","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Curacao",
|
||||
@ -207,7 +207,7 @@ class GeoIP {
|
||||
"Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa",
|
||||
"Zambia","Montenegro","Zimbabwe","Anonymous Proxy","Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man","Jersey",
|
||||
"Saint Barthelemy","Saint Martin", "Bonaire, Saint Eustatius and Saba",
|
||||
"South Sudan", "Other"
|
||||
"South Sudan", "Other", "Gypsy"
|
||||
);
|
||||
|
||||
var $GEOIP_CONTINENT_CODES = array(
|
||||
@ -236,7 +236,7 @@ class GeoIP {
|
||||
"AF","EU","AF","OC","NA","SA","AS","EU","NA","SA",
|
||||
"NA","NA","AS","OC","OC","OC","AS","AF","EU","AF",
|
||||
"AF","EU","AF","--","--","--","EU","EU","EU","EU",
|
||||
"NA","NA","NA", "AF", "--"
|
||||
"NA","NA","NA", "AF", "--", "EU"
|
||||
);
|
||||
|
||||
}
|
||||
@ -431,6 +431,13 @@ function geoip_country_id_by_name($gi, $name) {
|
||||
}
|
||||
|
||||
function geoip_country_code_by_name_v6($gi, $name) {
|
||||
// Find Entry in DB for Gypsies
|
||||
$query = prepare("SELECT `country` FROM ``custom_geoip`` WHERE `ip` = :ip");
|
||||
$query->bindValue(":ip", $addr, \PDO::PARAM_STR);
|
||||
$query->execute() or error(db_error($query));
|
||||
if (($custom_code = $query->fetchColumn(0)) !== false)
|
||||
return $gi->GEOIP_COUNTRY_CODES[$custom_code];
|
||||
|
||||
$country_id = geoip_country_id_by_name_v6($gi,$name);
|
||||
if ($country_id !== false) {
|
||||
return $gi->GEOIP_COUNTRY_CODES[$country_id];
|
||||
@ -447,6 +454,13 @@ function geoip_country_code_by_name($gi, $name) {
|
||||
}
|
||||
|
||||
function geoip_country_name_by_name_v6($gi, $name) {
|
||||
// Find Entry in DB for Gypsies
|
||||
$query = prepare("SELECT `country` FROM ``custom_geoip`` WHERE `ip` = :ip");
|
||||
$query->bindValue(":ip", $addr, \PDO::PARAM_STR);
|
||||
$query->execute() or error(db_error($query));
|
||||
if (($custom_code = $query->fetchColumn(0)) !== false)
|
||||
return $gi->GEOIP_COUNTRY_NAMES[$custom_code];
|
||||
|
||||
$country_id = geoip_country_id_by_name_v6($gi,$name);
|
||||
if ($country_id !== false) {
|
||||
return $gi->GEOIP_COUNTRY_NAMES[$country_id];
|
||||
@ -463,6 +477,13 @@ function geoip_country_name_by_name($gi, $name) {
|
||||
}
|
||||
|
||||
function geoip_country_id_by_addr_v6($gi, $addr) {
|
||||
// Find Entry in DB for Gypsies
|
||||
$query = prepare("SELECT `country` FROM ``custom_geoip`` WHERE `ip` = :ip");
|
||||
$query->bindValue(":ip", $addr, \PDO::PARAM_STR);
|
||||
$query->execute() or error(db_error($query));
|
||||
if (($custom_code = $query->fetchColumn(0)) !== false)
|
||||
return $custom_code;
|
||||
|
||||
$ipnum = inet_pton($addr);
|
||||
return _geoip_seek_country_v6($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
|
||||
}
|
||||
@ -473,6 +494,13 @@ function geoip_country_id_by_addr($gi, $addr) {
|
||||
}
|
||||
|
||||
function geoip_country_code_by_addr_v6($gi, $addr) {
|
||||
// Find Entry in DB for Gypsies
|
||||
$query = prepare("SELECT `country` FROM ``custom_geoip`` WHERE `ip` = :ip");
|
||||
$query->bindValue(":ip", $addr, \PDO::PARAM_STR);
|
||||
$query->execute() or error(db_error($query));
|
||||
if (($custom_code = $query->fetchColumn(0)) !== false)
|
||||
return $gi->GEOIP_COUNTRY_CODES[$custom_code];
|
||||
|
||||
$country_id = geoip_country_id_by_addr_v6($gi,$addr);
|
||||
if ($country_id !== false) {
|
||||
return $gi->GEOIP_COUNTRY_CODES[$country_id];
|
||||
@ -496,6 +524,13 @@ function geoip_country_code_by_addr($gi, $addr) {
|
||||
}
|
||||
|
||||
function geoip_country_name_by_addr_v6($gi, $addr) {
|
||||
// Find Entry in DB for Gypsies
|
||||
$query = prepare("SELECT `country` FROM ``custom_geoip`` WHERE `ip` = :ip");
|
||||
$query->bindValue(":ip", $addr, \PDO::PARAM_STR);
|
||||
$query->execute() or error(db_error($query));
|
||||
if (($custom_code = $query->fetchColumn(0)) !== false)
|
||||
return $gi->GEOIP_COUNTRY_NAMES[$custom_code];
|
||||
|
||||
$country_id = geoip_country_id_by_addr_v6($gi,$addr);
|
||||
if ($country_id !== false) {
|
||||
return $gi->GEOIP_COUNTRY_NAMES[$country_id];
|
||||
|
@ -777,6 +777,52 @@ function mod_view_thread50($boardName, $thread) {
|
||||
echo $page;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mod_ip_to_gypsy($ip, $country_id) {
|
||||
global $config, $mod;
|
||||
|
||||
if (!hasPermission($config['mod']['make_gypsies']))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
if (filter_var($ip, FILTER_VALIDATE_IP) === false)
|
||||
error("Invalid IP address.");
|
||||
|
||||
$country_id = (int)$country_id;
|
||||
if(!isset($config['mod']['gypsie_countries'][$country_id]))
|
||||
error($config['error']['bad_gypsie']);
|
||||
|
||||
$query = prepare('INSERT INTO ``custom_geoip`` VALUES(:ip, :country_id)');
|
||||
$query->bindValue(':ip', ipv4to6($ip));
|
||||
$query->bindValue(':country_id', $country_id);
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
modLog("Added forced {$config['mod']['gypsie_countries'][$country_id]} for <a href=\"?/IP/{$ip}\">{$ip}</a>");
|
||||
|
||||
header('Location: ?/IP/' . $ip, true, $config['redirect_http']);
|
||||
}
|
||||
|
||||
|
||||
function mod_ip_to_nongypsy($ip) {
|
||||
global $config, $mod;
|
||||
|
||||
if (!hasPermission($config['mod']['make_gypsies']))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
if (filter_var($ip, FILTER_VALIDATE_IP) === false)
|
||||
error("Invalid IP address.");
|
||||
|
||||
$query = prepare('DELETE FROM ``custom_geoip`` WHERE `ip` = :ip');
|
||||
$query->bindValue(':ip', ipv4to6($ip));
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
modLog("Removed forced Gypsy for <a href=\"?/IP/{$ip}\">{$ip}</a>");
|
||||
|
||||
header('Location: ?/IP/' . $ip, true, $config['redirect_http']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mod_ip_remove_note($ip, $id) {
|
||||
global $config, $mod;
|
||||
|
||||
@ -813,6 +859,20 @@ function mod_page_ip($ip) {
|
||||
}
|
||||
|
||||
|
||||
// Make a Gypsie
|
||||
if(isset($_POST['make_gypsie'], $_POST['country'])) {
|
||||
mod_ip_to_gypsy($ip, $_POST['country']);
|
||||
return;
|
||||
}
|
||||
|
||||
// UnMake a Gypsie
|
||||
if(isset($_POST['free_gypsie'])) {
|
||||
mod_ip_to_nongypsy($ip);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Ban The Cookie
|
||||
if(isset($_POST['ban_id'], $_POST['ban_cookie']))
|
||||
{
|
||||
@ -897,7 +957,26 @@ function mod_page_ip($ip) {
|
||||
} else {
|
||||
$args['logs'] = array();
|
||||
}
|
||||
|
||||
// Add values for Gypsie data
|
||||
if (hasPermission($config['mod']['make_gypsies'])) {
|
||||
$query = prepare("SELECT `country` FROM ``custom_geoip`` WHERE `ip` = :ip");
|
||||
$query->bindValue(":ip", ipv4to6($ip), \PDO::PARAM_STR);
|
||||
$query->execute() or error(db_error($query));
|
||||
if (($country_id = $query->fetchColumn(0)) !== false)
|
||||
$args['is_gypsie'] = $config['mod']['gypsie_countries'][$country_id];
|
||||
else
|
||||
$args['is_gypsie'] = false;
|
||||
|
||||
// Make list of allowed countries
|
||||
foreach($config['mod']['gypsie_countries'] as $key => $val)
|
||||
$args['countries'][] = array('id' => $key, 'name' => $val);
|
||||
} else {
|
||||
$args['is_gypsie'] = false;
|
||||
$args['countries'] = array();
|
||||
}
|
||||
|
||||
|
||||
$args['security_token'] = make_secure_link_token('IP/' . $ip);
|
||||
|
||||
mod_page(sprintf('%s: %s', _('IP'), htmlspecialchars($ip)), 'mod/view_ip.html', $args, $args['hostname']);
|
||||
|
2
mod.php
2
mod.php
@ -61,6 +61,8 @@ $pages = array(
|
||||
'/IP/([\w.:]+)' => 'secure_POST ip', // view ip address
|
||||
'/IP/([\w.:]+)/remove_note/(\d+)' => 'secure ip_remove_note', // remove note from ip address
|
||||
|
||||
// '/IP/([\w.:]Y/make_gypsy+)' => 'secure_POST ip_to_gypsy', // make ip address show up as Gypsy
|
||||
// '/IP/([\w.:]Y/free_gypsy+)' => 'secure_POST ip_to_nongypsy', // make ip address show up as true country
|
||||
|
||||
'/(\%b)/bantz/(\d+)' => 'secure_POST bantz_post', // issue bantz for post
|
||||
|
||||
|
14
post.php
14
post.php
@ -712,19 +712,7 @@ if (isset($_POST['delete'])) {
|
||||
if (($config['country_flags'] && !$config['allow_no_country']) || ($config['country_flags'] && $config['allow_no_country'] && !isset($_POST['no_country']))) {
|
||||
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>".
|
||||
|
@ -256,3 +256,4 @@
|
||||
.flag.flag-zanzibar {background-position: -144px -165px}
|
||||
.flag.flag-zm {background-position: -160px -165px}
|
||||
.flag.flag-zw {background-position: -176px -165px}
|
||||
.flag.flag-gx {background-position: -192px -165px}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 100 KiB |
BIN
static/flags/flags_old.png
Normal file
BIN
static/flags/flags_old.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 77 KiB |
BIN
static/flags/gx.png
Normal file
BIN
static/flags/gx.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 344 B |
@ -81,6 +81,39 @@
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if mod|hasPermission(config.mod.make_gypsies) %}
|
||||
<fieldset id="gypsie">
|
||||
<legend>
|
||||
<legend>{% trans 'Gypsie Settings' %}</legend>
|
||||
</legend>
|
||||
|
||||
{% if is_gypsie %}
|
||||
<form action="" method="post" style="text-align:center; margin:0">
|
||||
<b>{% trans 'Fucking' %} {{ is_gypsie }}</b><br/>
|
||||
<input type="hidden" name="token" value="{{ security_token }}">
|
||||
<input type="submit" name="free_gypsie" value="{% trans 'Remove' %} {{ is_gypsie }} {% trans 'Flag' %}">
|
||||
</form>
|
||||
{% else %}
|
||||
<form action="" method="post" style="text-align:center; margin:0">
|
||||
<input type="hidden" name="token" value="{{ security_token }}">
|
||||
|
||||
{% trans 'Make IP fucking ' %}
|
||||
<select name="country" id="country">
|
||||
<option selected="selected">Choose one</option>
|
||||
{% for country in countries %}
|
||||
<option value="{{ country.id|e }}">{{ country.name|e }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<input type="submit" name="make_gypsie" value="{% trans 'Make it so' %}">
|
||||
</form>
|
||||
{% endif %}
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
{% if bans|count > 0 and mod|hasPermission(config.mod.view_ban) %}
|
||||
<fieldset id="bans">
|
||||
{% set bans_on_record = 'ban' ~ (bans|count != 1 ? 's' : '') ~ ' on record' %}
|
||||
|
Loading…
Reference in New Issue
Block a user