Location: PHPKode > projects > IntraMessenger > admin/list_ban.php
<?php 	
/*******************************************************
 **                  IntraMessenger - server          **
 **                                                   **
 **  Copyright:      (C) 2006 - 2010 THeUDS           **
 **  Web:            http://www.theuds.com            **
 **                  http://www.intramessenger.net    **
 **  Licence :       GPL (GNU Public License)         **
 **  http://opensource.org/licenses/gpl-license.php   **
 *******************************************************/

/*******************************************************
 **       This file is part of IntraMessenger-server  **
 **                                                   **
 **  IntraMessenger is a free software.               **
 **  IntraMessenger is distributed in the hope that   **
 **  it will be useful, but WITHOUT ANY WARRANTY.     **
 *******************************************************/
//
//
require ("../common/display_errors.inc.php"); 
//
if (isset($_GET['ban'])) $ban = strtolower($_GET['ban']);  else  $ban = "";
if (isset($_GET['lang'])) $lang = $_GET['lang']; else $lang = "";
//
define('INTRAMESSENGER',true);
require ("../common/styles/style.css.inc.php"); 
require ("../common/config/config.inc.php");
require ("lang.inc.php");
require ("../common/menu.inc.php"); // apr├Ęs config.inc.php !
//echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
echo "<html><head>";
//
switch ($ban)
{
  case "ip" : // ip address
    $title = $l_admin_ban_ip;
    $add_button = $l_admin_ban_add_ip;
    $ban_type = "I";
    break;
  case "pc" : // computer
    $title = $l_admin_ban_pc;
    $add_button = $l_admin_ban_add_pc;
    $ban_type = "P";
    break;
  default : // user
    $title = $l_admin_ban_users;
    $add_button = $l_admin_ban_add_user;
    $ban_type = "U";
    break; 
}
//
echo "<title>[IM] " . $title . "</title>";
display_header();
echo '<META http-equiv="refresh" content="120;url="> ';
echo "</head>";
echo "<body>";
//
display_menu();
//
echo "<font face=verdana size=2>";
//
require ("../common/sql.inc.php");
//
//
echo "<BR/>";
echo "<TABLE cellspacing='1' cellpadding='1' class='forumline'>";
echo "<TR>";
echo "<TH align='center' COLSPAN='2' class='thHead'>";
echo "<font face=verdana size=3><b>&nbsp;" . $title . "&nbsp;</b></font>";
echo "</TH>";
echo "</TR>";

echo "<TR>";
echo "<TD align='center' COLSPAN='2' class='catHead'>";
echo "<font face=verdana size=3><b>&nbsp;" . $add_button . "&nbsp;</b></font>";
echo "</TD>";
echo "</TR>";
echo "<TR>";

echo "<FORM METHOD='POST' ACTION='ban_add.php?'>";
echo "<TD class='row1' align='left'>";
echo "<font face=verdana size=2>";
echo "<input type='text' name='ban_value' maxlength='50' value='' size='35' class='post' />";
//echo "<BR/>";
echo "</TD>";
echo "<TD class='row1' align='right'>";
echo "<INPUT TYPE='submit' VALUE = '" . $l_admin_bt_add . "' class='liteoption' />";
echo "<input type='hidden' name='ban' value = '" . $ban . "' />";
echo "<input type='hidden' name='ban_type' value = '" . $ban_type . "' />";
echo "<INPUT TYPE='hidden' name='lang' value = '" . $lang . "' />";
echo "</TD></TR>";
echo "</FORM>";
//
if ($ban == "pc")
{
  echo "<TR>";
  echo "<TD align='left' COLSPAN='9' class='row2' >"; //  'style:'
    echo "<font face=verdana size=2>";
    echo "";
    echo "<IMG SRC='" . _FOLDER_IMAGES . "bt_user_pc_ban.png' ALT='" . $l_admin_users_ban_pc . "' TITLE='" . $l_admin_users_ban_pc . "' WIDTH='32' HEIGHT='32' ALIGN='LEFT' BORDER='0'>";
    echo $l_admin_users_how_to_ban_pc;
  echo "</TD>";
  echo "</TR>";
}
echo "</TABLE>";
//
//
$requete  = " SELECT BAN_VALUE ";
$requete .= " FROM " . $PREFIX_IM_TABLE . "BAN_BANNED ";
$requete .= " WHERE BAN_TYPE = '" . $ban_type . "' ";
$requete .= " ORDER BY UPPER(BAN_VALUE) ";
$result = mysql_query($requete);
if (!$result) error_sql_log("[ERR-L6a]", $requete);
if ( mysql_num_rows($result) > 0 )
{
  echo "<BR/>";
  echo "<TABLE cellspacing='1' cellpadding='1' class='forumline'>";
  echo "<THEAD>";
  echo "<TR>";
    echo "<TH align='center' COLSPAN='10' class='thHead'>";
    echo "<font face=verdana size=3><b>" . $l_menu_list . " </B></font></TH>";
  echo "</TR>";
  echo "</THEAD>";
  echo "<TBODY>";
  //
  //
  $num_col = 0;
  echo "<TR>";
  while( list ($tban) = mysql_fetch_row ($result) )
  {
    if ($num_col > 2) 
    {
      echo "</TR>\n";
      echo "<TR>";
      $num_col = 0;
    }
    $num_col++;
    //echo "<TR>";
    echo "<TD class='row1'><font face=verdana size=2>&nbsp;" . $tban . "&nbsp;</TD>";
    //
    echo "<TD valign='bottom' align='center' class='row1'>";
    //echo "<A HREF='user_delete.php?id_user=" . $id_user . "&tri=" . $tri . "&page=" . $page . "&lang=" . $lang . "' title='" . $l_admin_bt_delete . "'>";
    echo " <A HREF='ban_delete.php?ban_type=" . $ban_type . "&ban_value=" . $tban . "&ban=" . $ban . "&lang=" . $lang . "&' title='" . $l_admin_bt_delete . "'>";
    echo "<IMG SRC='" . _FOLDER_IMAGES . "b_drop.png' ALT='" . $l_admin_bt_delete . "' TITLE='" . $l_admin_bt_delete . "' WIDTH='16' HEIGHT='16' BORDER='0'></A>";
    echo " </TD>";
    echo " <TD class='row2'>";
    echo "<font face=verdana size=1>&nbsp;";
    echo " </TD>";
/*
    echo "<FORM METHOD='POST' ACTION='ban_delete.php?'>";
    echo "<TD valign='bottom' align='center' class='row2'>";
      echo "<INPUT TYPE='submit' VALUE = '" . $l_admin_bt_delete . "' class='liteoption' />";
      echo "<input type='hidden' name='ban' value = '" . $ban . "' />";
      echo "<input type='hidden' name='ban_type' value = '" . $ban_type . "' />";
      echo "<input type='hidden' name='ban_value' value = '" . $tban . "' />";
      echo "<INPUT TYPE='hidden' name='lang' value = '" . $lang . "'/>";
    echo "</TD>";
    echo "</FORM>";
    */
    //echo "</TR>\n";
  }
  echo "</TBODY>";
  //
  echo "</TABLE>";
}
//
mysql_close($id_connect);
//
//
function display_file($file)
{
  $handle = fopen($file, "r");
  if ($handle) 
  {
    echo "<table width='250' cellspacing='1' cellpadding='1' class='forumline'>";
    echo "<TR>";
    echo "<TH class='thHead' colspan='6' align='center'>";
    echo $file;
    echo "</TH>";
    echo "</TR>\n";
    echo "<TR>";
    $num_col = 0;
    while (!feof($handle)) 
    {
      $buffer = fgets($handle, 4096);
      $buffer = trim($buffer);
      if (strlen($buffer) > 1)
      {
        if ($num_col > 5) 
        {
          echo "</TR>\n";
          echo "<TR>";
          $num_col = 0;
        }
        $num_col++;
        echo "<TD class='row2'><font face='verdana' size='2'>";
        echo $buffer;
        echo "</TD>";
      }
    }
    echo "</TR>";
    fclose($handle);
    echo "</TABLE>";
  }
}
$folder = "../common/config/";
//
if ( ($ban_type == "U") and (is_readable($folder . "ban_nickname.txt")) )
{
  $l_admin_ban_dont_need_file = str_replace("zzz", "<I>" . $folder . "ban_nickname.txt</I>", $l_admin_ban_dont_need_file);
  echo "<FORM METHOD='POST' ACTION='ban_import_file.php?'>";
  echo "<BR/><BR/><div class='notice'><FONT COLOR='RED'>" . $l_admin_ban_dont_need_file . "</font>";
  echo "<BR/><BR/><INPUT TYPE='submit' VALUE = '" . $l_admin_ban_import_delete . "' class='liteoption' />";
  echo "<input type='hidden' name='ban' value = '" . $ban . "' />";
  echo "<input type='hidden' name='ban_type' value = '" . $ban_type . "' />";
  echo "<INPUT TYPE='hidden' name='lang' value = '" . $lang . "' />";
  echo "</div>";
  echo "</FORM>";
  display_file($folder . "ban_nickname.txt");
}
//
if ( ($ban_type == "I") and (is_readable($folder . "ban_ip.txt")) )  
{
  $l_admin_ban_dont_need_file = str_replace("zzz", "<I>" . $folder . "ban_ip.txt</I>", $l_admin_ban_dont_need_file);
  echo "<FORM METHOD='POST' ACTION='ban_import_file.php?'>";
  echo "<BR/><BR/><div class='notice'><FONT COLOR='RED'>" . $l_admin_ban_dont_need_file . "</font>";
  echo "<BR/><BR/><INPUT TYPE='submit' VALUE = '" . $l_admin_ban_import_delete . "' class='liteoption' />";
  echo "<input type='hidden' name='ban' value = '" . $ban . "' />";
  echo "<input type='hidden' name='ban_type' value = '" . $ban_type . "' />";
  echo "<INPUT TYPE='hidden' name='lang' value = '" . $lang . "' />";
  echo "</div>";
  echo "</FORM>";
  display_file($folder . "ban_ip.txt");
}
//
//
display_menu_footer();
//
echo "</body></html>";
?>
Return current item: IntraMessenger