summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@n0v4.com>2011-02-17 20:58:34 +1100
committerSavetheinternet <savetheinternet@n0v4.com>2011-02-17 20:58:34 +1100
commit35325bd0110d62ff0468c2b57251678409e674f2 (patch)
tree6f1132b87151e859fae9e1caede50d3943903cfb /inc
parent7e3905d5fd54152a51d7085150213c7dded1848d (diff)
IPv6_IPv4
Diffstat (limited to 'inc')
-rw-r--r--inc/config.php2
-rw-r--r--inc/functions.php12
2 files changed, 13 insertions, 1 deletions
diff --git a/inc/config.php b/inc/config.php
index edabb330..877ff762 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -300,6 +300,8 @@
$config['url_regex'] = '/' . '(https?|ftp):\/\/' . '(([\w\-]+\.)+[a-zA-Z]{2,6}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' . '(\/([\w\-~\.#\/?=&;:+%]+)?)?' . '/';
// INSANE regular expression for IPv6 addresses
$config['ipv6_regex'] = '((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?';
+ // Make IPv4 addresses look like IPv4 addresses ("::ffff:8.8.8.8" becomes "8.8.8.8")
+ $config['ipv6_ipv4'] = true;
// Allowed file extensions
$config['allowed_ext'] = Array('jpg', 'jpeg', 'bmp', 'gif', 'png');
diff --git a/inc/functions.php b/inc/functions.php
index 14733ec8..b7b4ce90 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -2,7 +2,7 @@
loadConfig();
function loadConfig() {
- global $board, $config;
+ global $board, $config, $__ip;
require 'config.php';
if (file_exists('inc/instance-config.php')) {
@@ -54,6 +54,16 @@
error_reporting(E_ALL);
ini_set('display_errors', 1);
}
+
+ if($config['ipv6_ipv4']) {
+ // Keep the original address to properly comply with other board configuartions
+ if(!isset($__ip))
+ $__ip = $_SERVER['REMOTE_ADDR'];
+
+ // ::ffff:0.0.0.0
+ if(preg_match('/^\:\:ffff\:(\d+\.\d+\.\d+\.\d+)$/', $__ip, $m))
+ $_SERVER['REMOTE_ADDR'] = $m[1];
+ }
}
function sprintf3($str, $vars, $delim = '%') {