From dc01a2d1b003f750dad0449b64e029b4eb681841 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 14 Aug 2012 12:28:05 +0200 Subject: [PATCH] more strict ip blocker --- htdocs/application/controllers/main.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index de1299a..bff3323 100755 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -483,10 +483,21 @@ class Main extends CI_Controller function _valid_ip() { + + //get ip + $ip = $this->input->ip_address(); + $ip = explode('.', $ip); + $ip_firstpart = $ip[0] . '.' . $ip[1] . '.'; + + //setup message $this->form_validation->set_message('_valid_ip', 'You are not allowed to paste.'); - $query = $this->db->get_where('blocked_ips', array( - 'ip_address' => $this->input->ip_address() - ) , 1); + + //lookup + $this->db->select('ip_address'); + $this->db->like('ip_address', $ip_firstpart, 'after'); + $query = $this->db->get('blocked_ips'); + + //return return count($query->result_array()) == 0; }