diff --git a/Controller/VoteController.php b/Controller/VoteController.php index 93be4bf..e42be1b 100644 --- a/Controller/VoteController.php +++ b/Controller/VoteController.php @@ -1,4 +1,27 @@ loadModel('Vote.Vote'); - if (!$this->Vote->can($this->Session->read('vote.user'), $this->Util->getIP(), $website['Website'])) - return $this->sendJSON(['status' => false, 'error' => $this->Lang->get('VOTE__SET_WEBSITE_ERROR_NEED_WAIT', ['{TIME}' => $this->Util->generateStringFromTime($this->Vote->getNextVoteTime($this->Session->read('vote.user'), $this->Util->getIP(), $website['Website']))])]); + if (!$this->Vote->can($this->Session->read('vote.user'), getUserIP(), $website['Website'])) + return $this->sendJSON(['status' => false, 'error' => $this->Lang->get('VOTE__SET_WEBSITE_ERROR_NEED_WAIT', ['{TIME}' => $this->Util->generateStringFromTime($this->Vote->getNextVoteTime($this->Session->read('vote.user'), getUserIP(), $website['Website']))])]); // Store it $this->Session->write('vote.website.id', $this->request->data['website_id']); @@ -152,7 +175,7 @@ public function checkVote() if (empty($website)) throw new NotFoundException(); $this->loadModel('Vote.Vote'); - if (!$this->Website->valid($this->Session->read('vote.user'), $this->Util->getIP(), $website['Website'])) + if (!$this->Website->valid($this->Session->read('vote.user'), getUserIP(), $website['Website'])) return $this->sendJSON(['status' => false]); // Store it @@ -173,7 +196,7 @@ public function getReward() if ($this->Session->check('voted')) { // Fail // Get last vote not collected - $findVote = $this->Vote->find('first', ['conditions' => ['collected' => 0, 'vote.ip' => $this->Util->getIP()], 'recursive' => 1]); + $findVote = $this->Vote->find('first', ['conditions' => ['collected' => 0, 'vote.ip' => getUserIP()], 'recursive' => 1]); if (empty($findVote)) throw new ForbiddenException(); $this->loadModel('Vote.Reward'); @@ -206,8 +229,8 @@ public function getReward() // Check if user can vote $this->loadModel('Vote.Vote'); - if (!$this->Vote->can($this->Session->read('vote.user'), $this->Util->getIP(), $website['Website'])) - return $this->sendJSON(['status' => false, 'error' => $this->Lang->get('VOTE__SET_WEBSITE_ERROR_NEED_WAIT', ['{TIME}' => $this->Util->generateStringFromTime($this->Vote->getNextVoteTime($this->Session->read('vote.user'), $this->Util->getIP(), $website['Website']))])]); + if (!$this->Vote->can($this->Session->read('vote.user'), getUserIP(), $website['Website'])) + return $this->sendJSON(['status' => false, 'error' => $this->Lang->get('VOTE__SET_WEBSITE_ERROR_NEED_WAIT', ['{TIME}' => $this->Util->generateStringFromTime($this->Vote->getNextVoteTime($this->Session->read('vote.user'), getUserIP(), $website['Website']))])]); // Generate random reward $this->loadModel('Vote.Reward'); @@ -222,7 +245,7 @@ public function getReward() 'reward_id' => $reward['id'], 'collected' => 0, 'website_id' => $website['Website']['id'], - 'ip' => $this->Util->getIP() + 'ip' => getUserIP() ]); $this->Vote->save();