diff --git a/DesignSurvey/Voter.php b/DesignSurvey/Voter.php index 0b523cb5d5b5ba970b2566f02a5df37a85892ddb..481b3f93d8ac6d15d07a700b153d6dc5fd10622f 100644 --- a/DesignSurvey/Voter.php +++ b/DesignSurvey/Voter.php @@ -14,7 +14,7 @@ class DesignSurvey_Voter extends DB_DataObject var $audience_id; // int(11) var $age_group_id; // int(11) var $gender; // string(1) - var $ip; // string(15) not_null + var $ip; // int(32) not_null var $step; // int(10) unsigned var $prototype_order; // blob(16777215) blob var $viewport; // string(50) diff --git a/DesignSurvey/designsurvey.ini b/DesignSurvey/designsurvey.ini index e37f0ff357a2ae4eaff8af81c3f590b910b126a5..53e475951be6843316cfdb9f315d1abbcf938001 100644 --- a/DesignSurvey/designsurvey.ini +++ b/DesignSurvey/designsurvey.ini @@ -99,9 +99,10 @@ id = 129 audience_id = 1 age_group_id = 1 gender = 2 -ip = 130 +ip = 129 step = 1 prototype_order = 66 +viewport = 130 submitdatetime = 14 [voter__keys] diff --git a/database/designsurvey.sql b/database/designsurvey.sql index d7bef19597eb561b571e5c2b08c0e85cf1bc7e20..b257044bb204a6f9c4e610d3f56a1ea2de5b8cd6 100644 --- a/database/designsurvey.sql +++ b/database/designsurvey.sql @@ -209,11 +209,12 @@ CREATE TABLE IF NOT EXISTS `voter` ( `audience_id` int(11) default NULL, `age_group_id` int(11) default NULL, `gender` char(1) default NULL, - `ip` varchar(15) NOT NULL default '', + `ip` int(32) unsigned NOT NULL, `step` int(10) unsigned default NULL, `prototype_order` mediumtext, `viewport` varchar(50) default NULL, `submitdatetime` datetime default NULL, PRIMARY KEY (`id`), KEY `ip` (`ip`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; + diff --git a/functions.php b/functions.php index 85f3d1f755e58894bb91a87bd12708a0b6b8583e..9ad2d3de1f90f9945dcdbcd1f80453ced2f81638 100644 --- a/functions.php +++ b/functions.php @@ -51,7 +51,7 @@ class Voting_System function initializeVoter() { $options = &PEAR::getStaticProperty('DB_DataObject', 'options'); - $this->voter->ip = $_SERVER['REMOTE_ADDR']; + $this->voter->ip = ip2long($_SERVER['REMOTE_ADDR']); $this->voter->step = START; $this->voter->submitdatetime = date('Y-m-d H:i:s'); if (isset($_GET['at'])) { @@ -132,8 +132,8 @@ class Voting_System $this->voter = DB_DataObject::factory('voter'); if (isset($_SESSION['voter_id']) && $this->voter->get($_SESSION['voter_id'])) { $found = true; - } elseif (!in_array($_SERVER['REMOTE_ADDR'],$sharedIPs)) { - $this->voter->ip = $_SERVER['REMOTE_ADDR']; + } elseif (!in_array($_SERVER['REMOTE_ADDR'], $sharedIPs)) { + $this->voter->ip = ip2long($_SERVER['REMOTE_ADDR']); if ($this->voter->find() && $this->voter->fetch()) { $found = true; $_SESSION['voter_id'] = $this->getVoterId();