This commit is contained in:
Claude 2012-08-31 21:41:48 +02:00
parent a038d24664
commit 2f9a21383b
3 changed files with 10 additions and 7 deletions

View File

@ -5,7 +5,7 @@
* - __construct() * - __construct()
* - index() * - index()
* - spam_detail() * - spam_detail()
* - blocked_ips() * - blacklist()
* Classes list: * Classes list:
* - Spamadmin extends CI_Controller * - Spamadmin extends CI_Controller
*/ */
@ -55,7 +55,8 @@ class Spamadmin extends CI_Controller
if ($query->num_rows() == 0) if ($query->num_rows() == 0)
{ {
$this->db->insert('blocked_ips', array( $this->db->insert('blocked_ips', array(
'ip_address' => $ip_address 'ip_address' => $ip_address,
'blocked_at' => mktime() ,
)); ));
} }
} }
@ -74,10 +75,12 @@ class Spamadmin extends CI_Controller
function blacklist() function blacklist()
{ {
$this->db->select('ip_address'); $this->db->select('ip_address, blocked_at, spam_attempts');
$this->db->order_by('blocked_at'); $this->db->order_by('blocked_at', 'desc');
$query = $this->db->get('blocked_ips'); $query = $this->db->get('blocked_ips');
$data['blocked_ips'] = $query->result_array(); $data['blocked_ips'] = $query->result_array();
//view
$this->load->view('list_blocked_ips', $data); $this->load->view('list_blocked_ips', $data);
} }
} }

View File

@ -30,7 +30,7 @@
<tr class="<?php echo $eo; ?>"> <tr class="<?php echo $eo; ?>">
<td class="first"><?php echo $ip_range; ?></td> <td class="first"><?php echo $ip_range; ?></td>
<td><?php $p = explode(",", timespan($ip_address['blocked_at'], time())); echo $p[0]; ?> ago.</td> <td><?php $p = explode(",", timespan($ip_address['blocked_at'], time())); echo $p[0]; ?> ago.</td>
<td><?php echo '43'; ?></td> <td><?php echo $ip_address['spam_attempts']; ?></td>
<td><a href="<?php echo site_url('spamadmin/blacklist/unblock/' . $ip_address['ip_address']) ?>">Unblock</a></td> <td><a href="<?php echo site_url('spamadmin/blacklist/unblock/' . $ip_address['ip_address']) ?>">Unblock</a></td>
</tr> </tr>
@ -38,7 +38,7 @@
</tbody> </tbody>
</table> </table>
<?php } else { ?> <?php } else { ?>
<p>There have been no pastes :(</p> <p>No IP ranges blocked.</p>
<?php }?> <?php }?>
<?php echo $pages; ?> <?php echo $pages; ?>
<div class="spacer"></div> <div class="spacer"></div>

View File

@ -1,6 +1,6 @@
<?php $this->load->view('defaults/header');?> <?php $this->load->view('defaults/header');?>
<h1>Spamadmin</h1> <h1>Spamadmin</h1>
<p>51 spam-pastes eaten so far. <a href="<?php echo site_url('spamadmin/blocked_ips'); ?>">View blocked IPs</a>.</p> <p>51 spam-pastes eaten so far. <a href="<?php echo site_url('spamadmin/blacklist'); ?>">View blocked IPs</a>.</p>
<?php <?php
function checkNum($num){ function checkNum($num){