Advertisement
h-collector

Untitled

Aug 20th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2. class IPLimit extends Database {
  3. //[..]  
  4.  public function check($id) {
  5.         $now    = time();
  6.         $result = $this->getRow($this->table, $this->ip, $this->col_ip);
  7.         if ($result) {
  8.             $last = strtotime($result[$this->col_last_access]);
  9.             if (($last + $this->expiry ) < $now) {
  10.                 $this->updateRow($this->table, array(
  11.                     $this->col_last_fileid  => $id,
  12.                     $this->col_access_count => $result[$this->col_access_count] + 1), $this->ip, $this->col_ip);
  13.             } else {
  14.                 $this->timeLeft = ( ( $last + $this->expiry) - $now);
  15.  
  16.                 return false;
  17.             }
  18.         } else {
  19.             $this->insertRow($this->table, array(
  20.                 $this->col_ip          => $this->ip,
  21.                 $this->col_last_fileid => $id
  22.             ));
  23.         }
  24.         return true;
  25.     }
  26. //[..]
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement