/** * Checks if the current user has voted from the provided votes * * @param array $votes * @return bool|int */ protected function hasUserVoted(array $votes) { foreach ($votes as $oid) { foreach ($oid as $vote) { if (zula_ip2long(zula_get_client_ip()) == $vote['ip'] || $vote['uid'] != Ugmanager::_GUEST_ID && $vote['uid'] == $this->_session->getUserId()) { return (int) $vote['option_id']; } } } return false; }
/** * Gets the number of login attempts for the current remote addr * * @return int */ public function getLoginAttempts() { $remoteAddr = (int) zula_ip2long(zula_get_client_ip()); $query = $this->_sql->query('SELECT attempts, blocked FROM {PREFIX}mod_session WHERE ip = ' . $remoteAddr); $results = $query->fetch(PDO::FETCH_ASSOC); $query->closeCursor(); if ($results) { $blockedUntil = $this->_date->getDateTime($results['blocked'])->modify('+10 minutes'); if ($blockedUntil < new DateTime()) { // Remove the entry as it has now expired $this->_sql->exec('DELETE FROM {PREFIX}mod_session WHERE ip = ' . $remoteAddr); $results['attempts'] = 0; } return $results['attempts']; } return 0; }
/** * Adds a new vote to a poll option * * @param int $oid * @return bool */ public function vote($oid) { $option = $this->getOption($oid); $pdoSt = $this->_sql->prepare('INSERT INTO {PREFIX}mod_poll_votes (option_id, ip, uid) VALUES(?, ?, ?)'); return $pdoSt->execute(array($option['id'], zula_ip2long(zula_get_client_ip()), $this->_session->getUserId())); }