Skip to content
Snippets Groups Projects
Commit 2b0733f3 authored by Brett Bieber's avatar Brett Bieber
Browse files

Change voter IP to an unsigned integer for speed.

parent 6ef150da
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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]
......
......@@ -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 ;
......@@ -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'])) {
......@@ -133,7 +133,7 @@ class Voting_System
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'];
$this->voter->ip = ip2long($_SERVER['REMOTE_ADDR']);
if ($this->voter->find() && $this->voter->fetch()) {
$found = true;
$_SESSION['voter_id'] = $this->getVoterId();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment