* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License in GPL.txt for more details. */ session_start(); if (isset($_SESSION['login'])) { // Do nothing } else { header("Location: ."); exit(); } if (isset($_GET['logout'])) { if (isset($_SESSION['login'])) unset($_SESSION['login']); session_destroy(); header("Location: ."); exit(); } $date = date('jS F Y'); $ip = $_SERVER['REMOTE_ADDR']; require_once('../config.php'); $con = mysqli_connect($dbhost, $dbuser, $dbpassword, $dbname); if (mysqli_connect_errno()) { $sql_error = mysqli_connect_error(); die("Unable connect to database"); } $query = "SELECT @last_id := MAX(id) FROM admin_history"; $result = mysqli_query($con, $query); while ($row = mysqli_fetch_array($result)) { $last_id = $row['@last_id := MAX(id)']; } $query = "SELECT * FROM admin_history WHERE id=" . Trim($last_id); $result = mysqli_query($con, $query); while ($row = mysqli_fetch_array($result)) { $last_date = $row['last_date']; $last_ip = $row['ip']; } if ($last_ip == $ip) { if ($last_date == $date) { } else { $query = "INSERT INTO admin_history (last_date,ip) VALUES ('$date','$ip')"; mysqli_query($con, $query); } } else { $query = "INSERT INTO admin_history (last_date,ip) VALUES ('$date','$ip')"; mysqli_query($con, $query); } // Get IP from form or URL if ( $_SERVER['REQUEST_METHOD'] == 'POST' || isset( $_GET['banip'] ) ) { if ( isset( $_POST['banip'] ) ) { $ban_ip = htmlentities( Trim( $_POST['ban_ip'] ) ); } elseif ( isset( $_GET['banip'] ) ) { $ban_ip = htmlentities( Trim( $_GET['banip'] ) ); } // Check if IP is blank or already banned. if ( trim($ban_ip) == '' ) { $msg = '
Please enter an IP to ban.
'; } else { $query = "SELECT * FROM ban_user where ip='$ban_ip'"; $result = mysqli_query( $con, $query ); $num_rows = mysqli_num_rows( $result ); if ( $num_rows >= 1 ) { $msg = '
' . $ban_ip . ' already banned
'; } else { // Valid IP which is not banned. Add to database $query = "INSERT INTO ban_user (last_date,ip) VALUES ('$date','$ban_ip')"; mysqli_query( $con, $query ); if ( mysqli_errno( $con ) ) { $msg = '
' . mysqli_error($con) . '
'; } else { $msg = '
' . $ban_ip . ' added to the banlist
'; } } } } if (isset($_GET{'delete'})) { $delete = htmlentities(Trim($_GET['delete'])); $query = "DELETE FROM ban_user WHERE id=$delete"; $result = mysqli_query($con, $query); if (mysqli_errno($con)) { $msg = '
' . mysqli_error($con) . '
'; } else { $msg = '
IP removed from the banlist
'; } } ?> Paste - IP Bans
Ban an IP
Banlist
'; echo ''; echo ''; $myid = $row['id']; echo ''; $no++; } echo ''; echo ''; echo '
Date Added IP Delete
' . $row['last_date'] . '' . $row['ip'] . '' . " Delete " . '
'; // Display pagination echo '
    '; if ($left_rec < $rec_limit) { $last = $page - 2; if ($last < 0) { } else { echo @"
  • Previous
  • "; } } else if ($page == 0) { echo @"
  • Next
  • "; } else if ($page > 0) { $last = $page - 2; echo @"
  • Previous
  • "; echo @"
  • Next
  • "; } echo '
'; ?>