Location: PHPKode > projects > Jarida > jarida_1.0/admin/ban.php
<?php

include("header.php");

if(!$_GET['do'])
{
  //If $do is empty we load the default page listing all banned ips
  

  $query = "SELECT ban_id, ban_ip FROM tblBan";

  $result = $db->doQuery($query);

  while($row = $result->getArray())
    {
      $ips[] = array('id' => $row['ban_id'],
		     'ip' => $row['ban_ip']);
    }
      
  $template->assign('ips', $ips);
    
}



if($_GET['do'] == "ban")
{
  $ip = $_GET['ip'];
  $query = "INSERT INTO tblBan (ban_ip)
                    VALUES('$ip')";

  if(!$result = $db->doQuery($query))
    {
      $confirm_message = $lang['db_problem'] . "<br><br>" . $db->getError();
    }
  else
    {
      $confirm_message = "<p>" . $lang['add_success'] . "</p><p><a href=\"$PHP_SELF\">" . $lang['manage_ip'] . "</a></p>";
    }

  //Send to the template
  $template->assign('confirm_message', $confirm_message);

}


if($_GET['do'] == "unban")
{

  $query = "DELETE FROM tblBan WHERE ban_id = " . $_GET['id'];

  if(!$result = $db->doQuery($query))
    {
      $confirm_message = $lang['db_problem'] . "<br><br>" . $db->getError();
    }
  else
    {
      $confirm_message = "<p>" . $lang['delete_success'] . "</p><p><a href=\"$PHP_SELF\">" . $lang['manage_ip'] . "</a></p>";
    }
  
  $template->assign('confirm_message', $confirm_message);
}



//Lets display the template
$template->display($config['theme'].'/admin/ban.tpl');


include("footer.php");

?>
Return current item: Jarida