function pollim_ip_check in Poll Improved 7
1 call to pollim_ip_check()
File
- ./
pollim.module, line 431 - Module for the Pollim Entity - a starting point to create your own Entity and associated administration interface
Code
function pollim_ip_check($pollim_id, $ip_address) {
$ok = TRUE;
if (variable_get('pollim_threshold_count', 10) == 0) {
return TRUE;
//No IP restrictions
}
$votes_for_this_ip = db_query("SELECT COUNT(*) FROM {pollim_vote} " . "WHERE pollim_id = :pollim_id AND hostname = :hostname AND timestamp > :timestamp", array(
':pollim_id' => $pollim_id,
':hostname' => $ip_address,
':timestamp' => time() - variable_get('pollanon_threshold_time', 600),
))
->fetchField(0);
//Do we need to block voting for the given IP address ?
if ($votes_for_this_ip >= variable_get('pollim_threshold_count', 10)) {
$ok = FALSE;
drupal_set_message(t('Voting temporarily closed for your remote address.'));
}
return $ok;
}