fix duplicate error

This commit is contained in:
Claude 2012-08-31 14:05:40 +02:00
parent 370b3e3f1d
commit a2f3ec8677

View File

@ -45,13 +45,18 @@ class Spamadmin extends CI_Controller
$this->db->where('ip_address', $ip_address); $this->db->where('ip_address', $ip_address);
$this->db->delete('pastes'); $this->db->delete('pastes');
//todo: catch duplicate error
if ($this->input->post('block_ip')) if ($this->input->post('block_ip'))
{ {
$this->db->insert('blocked_ips', array( $query = $this->db->get_where('blocked_ips', array(
'ip_address' => $ip_address 'ip_address' => $ip_address
)); ));
if ($query->num_rows() == 0)
{
$this->db->insert('blocked_ips', array(
'ip_address' => $ip_address
));
}
} }
} }