summaryrefslogtreecommitdiff
path: root/modules/comment
diff options
context:
space:
mode:
authorKriss Andsten <kriss@sverok.se>2011-01-27 03:05:40 +0100
committerBharat Mediratta <bharat@menalto.com>2011-03-27 11:34:52 -0700
commit10785b1e820c5e10d982c6b49125903886f7b889 (patch)
tree9af4e8700c4f45dcf2a9b9e810b6106496a13a17 /modules/comment
parentfa6f233603267505c216abc4f12663d245cd23e7 (diff)
Extend comment module field lenghts to fit IPv6 remote host addresses and long (but legally so) hostnames.
Diffstat (limited to 'modules/comment')
-rw-r--r--modules/comment/helpers/comment_installer.php19
-rw-r--r--modules/comment/models/comment.php4
2 files changed, 18 insertions, 5 deletions
diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php
index 48b6ee21..cd20ef72 100644
--- a/modules/comment/helpers/comment_installer.php
+++ b/modules/comment/helpers/comment_installer.php
@@ -37,8 +37,8 @@ class comment_installer {
`server_http_referer` varchar(255) default NULL,
`server_http_user_agent` varchar(128) default NULL,
`server_query_string` varchar(64) default NULL,
- `server_remote_addr` varchar(32) default NULL,
- `server_remote_host` varchar(64) default NULL,
+ `server_remote_addr` varchar(40) default NULL,
+ `server_remote_host` varchar(255) default NULL,
`server_remote_port` varchar(16) default NULL,
`state` varchar(15) default 'unpublished',
`text` text,
@@ -48,7 +48,7 @@ class comment_installer {
module::set_var("comment", "spam_caught", 0);
module::set_var("comment", "access_permissions", "everybody");
- module::set_version("comment", 3);
+ module::set_version("comment", 4);
}
static function upgrade($version) {
@@ -62,6 +62,19 @@ class comment_installer {
module::set_var("comment", "access_permissions", "everybody");
module::set_version("comment", $version = 3);
}
+
+ if ($version == 3) {
+ /*
+ 40 bytes for server_remote_addr is enough to swallow the longest
+ representation of an IPv6 addy.
+
+ 255 bytes for server_remote_host is enough to swallow the longest
+ legit DNS entry, with a few bytes to spare.
+ */
+ $db->query("ALTER TABLE {comments} CHANGE `server_remote_addr` `server_remote_addr` varchar(40)");
+ $db->query("ALTER TABLE {comments} CHANGE `server_remote_host` `server_remote_host` varchar(255)");
+ module::set_version("comment", $version = 4);
+ }
}
static function uninstall() {
diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php
index d5e952eb..7c189a0e 100644
--- a/modules/comment/models/comment.php
+++ b/modules/comment/models/comment.php
@@ -98,8 +98,8 @@ class Comment_Model_Core extends ORM {
$this->server_http_referer = substr($input->server("HTTP_REFERER"), 0, 255);
$this->server_http_user_agent = substr($input->server("HTTP_USER_AGENT"), 0, 128);
$this->server_query_string = substr($input->server("QUERY_STRING"), 0, 64);
- $this->server_remote_addr = substr($input->server("REMOTE_ADDR"), 0, 32);
- $this->server_remote_host = substr($input->server("REMOTE_HOST"), 0, 64);
+ $this->server_remote_addr = substr($input->server("REMOTE_ADDR"), 0, 40);
+ $this->server_remote_host = substr($input->server("REMOTE_HOST"), 0, 255);
$this->server_remote_port = substr($input->server("REMOTE_PORT"), 0, 16);
}