<?php
class Bans extends Admin {

  public function __construct() { parent::__construct(); }

  //---[CZ]: přidání
  public function add() {
    if ($_POST["ip"]!="") {
    $sql=$this->db->query("INSERT INTO kcms_bans (ip) values ('".$this->db->escape($_POST["ip"])."')");
    if ($sql) { parent::$this->status_messages->print_success(LANG_ACTION_WAS_SUCCESSFULLY_COMPLETED); } else { parent::$this->status_messages->print_error(LANG_AN_ERROR_OCCURED); }
    } else { parent::$this->status_messages->print_error(LANG_YOU_HAVE_NOT_FILLED_SOME_ITEMS); }
  }

  //---[CZ]: smazání
  public function delete() {
    $sql=$this->db->query("DELETE FROM kcms_bans WHERE id=".intval($_GET["id"]));
    if ($sql) { parent::$this->status_messages->print_success(LANG_ACTION_WAS_SUCCESSFULLY_COMPLETED); } else { parent::$this->status_messages->print_error(LANG_AN_ERROR_OCCURED); }
  }

  //---[CZ]: vypsání
  public function output() {
    $sql=$this->db->query("SELECT id, ip FROM kcms_bans ORDER by id DESC");
    while($data=$this->db->fetch_array($sql)) {
    echo "<tr>
    <td>".$data["ip"]."</td>
    <td style=\"text-align: center;\"><input type=\"button\" class=\"redbutton\" value=\"".LANG_DELETE."\" onclick=\"if (!confirm('".LANG_ARE_YOU_SURE."')) return false; parent.location='./admin.php?function=bans&amp;action=remove&amp;id=".$data["id"]."';\" /></td>
    </tr>\n";
    }
  }

}
?>