Пример #1
0
 /**
  *	@fn blocked_ips_list
  *	@short Action method that creates a list of the blacklisted IP addresses.
  *	@details This method is invoked with AJAX calls to update the list
  *	of blocked IPs in a dynamic fashion.
  */
 public function blocked_ips_list()
 {
     $conn = Db::get_connection();
     $bip_factory = new BlockedIp();
     $this->blocked_ips = $bip_factory->find_all(array('where_clause' => "`ip_addr` LIKE '%{$conn->escape(@$_REQUEST['q'])}%'", 'order_by' => '`blocked_at` DESC'));
     Db::close_connection($conn);
     $this->render(array('layout' => FALSE));
 }
<?php

include 'config.php';
logincheck();
$message = [];
$title = "Create ipblock";
$ipblock = new BlockedIp();
$edit = 0;
if (isset($_GET['id'])) {
    $title = "Edit ipblock";
    $ipblock = BlockedIp::find($_GET['id']);
}
if (isset($_POST['submit'])) {
    $error = 0;
    $exists = BlockedIp::where('ip', '=', $_POST['ip'])->get();
    if (empty($_POST['ip'])) {
        $message['type'] = "error";
        $message['message'] = "ip field cannot be empty";
        $error = 1;
    }
    if ($error == 0) {
        $message['type'] = "success";
        if (isset($_GET['id'])) {
            $message['message'] = "ipblock edited";
        } else {
            $message['message'] = "ipblock Created";
        }
        $ipblock->ip = $_POST['ip'];
        $ipblock->description = $_POST['description'];
        $ipblock->save();
        redirect("manage_ipblock.php?id=" . $ipblock->id, 2000);
Пример #3
0
<?php

/**
 * Created by Tyfix 2015
 */
include 'config.php';
logincheck();
$message = [];
if (isset($_GET['delete'])) {
    $ipblock = BlockedIp::find($_GET['delete']);
    $ipblock->delete();
    $message['type'] = "success";
    $message['message'] = "Admin deleted";
}
$ipblocks = BlockedIp::all();
echo $template->view()->make('ipblocks')->with('ipblocks', $ipblocks)->with('message', $message)->render();
Пример #4
0
 /**
  *	@fn block_ip
  *	@short Filter method that interrupts response generation if the client IP is blacklisted.
  */
 protected function block_ip()
 {
     // Return if BLOCK_IPS is not set
     if (!self::BLOCK_IPS) {
         return;
     }
     if (BlockedIp::is_blocked($_SERVER['REMOTE_ADDR'])) {
         $bv = new BlockedVisit();
         $bv->save();
         die(l('Sorry, your IP address is currently blacklisted'));
     }
 }