Просмотр файла modules/chat/admin_1.php

Размер файла: 11.08Kb
<?php
########################################
##	           WAP-ENGINE             ##
########################################
##                                    ##
##  Автор : CHUMA (Токарев Владимир)  ##
##  e-mail : [email protected]     ##
##  WAP : http://wap-engine.ru        ##
##                                    ##
########################################
##         ВЫ НЕ ИМЕЕТЕ ПРАВО         ##
##        ИЗМЕНЯТЬ КОД СКРИПТА        ##
##  ДЛЯ ДАЛЬНЕЙШЕГО РАСПРОСТРАНЕНИЯ!  ##
########################################
include ('../../config.php');
include ('../../templates/run.php');
include ('../../templates/func.php');
include ('../../modules/chat/config.php');
####################
$str = filter($_GET['str']);
$page = filter($_GET['page']);
$for = filter($_GET['for']);
####################
if($_GET[act]=='ans')
 {
  include '../../themes/'.$themes.'.php';
  if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && $status == "1")
   {
    $for_user_f = @file('../../data/users/'.$for.'.php');
    $for_nick_name = trim($for_user_f[37]);
    $for = $for.'::'.$for_nick_name;
    $for = nick_user($for);

    echo '<p class="modul_name">Ответ админа</p>';
    echo "<form action=\"admin_1.php?act=send&amp;str=$str&amp;page=$page&amp;".session_name()."=".session_id()."\" method=\"post\">";
    echo "<p class=\"b\">Ответ для $for[1]<br /><textarea rows=\"4\" cols=\"15\" name=\"otv\"></textarea><br />
    <input type=\"checkbox\" name=\"msgtrans\" value=\"1\" /> Транслит";
    echo "<br />";
    echo "<input type=\"submit\" value=\"Ответить\" /></p></form>";
    echo "<p><a href=\"index_1.php?page=$page&amp;".session_name()."=".session_id()."\">В $room1</a></p>";
   }
    else
   {
    echo "<p class=\"err\">Ошибка!!! Вы не авторизованы. Войдите в личный кабинет.<br /></p>";
    echo "<p><a href=\"index_1.php?".session_name()."=".session_id()."\">В $room1</a></p>";
   }
  include ('../../templates/foot.php');
 }
####################
if($_GET[act]=='banuser')
 {
  if (isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == "1" || $status == "2" || $status == "3"))
   {
    include '../../themes/'.$themes.'.php';
    $kogo = filter($_GET['ban']);

      echo'<p class="modul_name"align="center">Забанить пользователя '.$kogo.'</p>';
      echo"<form method=\"post\" action=\"../admin/users.php?act=ban&amp;nick=$kogo&amp;".session_name()."=".session_id()."\"><p class=\"b\">";
      echo"До какого времени:<br />";
      echo"Год: <select name=\"god\" class=\"textbox\">";
      for($g=2010; $g <= 2020; $g++)
       {
        if($g == date ("Y", time() + ($sdvigclock*3600)))
         { echo"<option selected=\"selected\">$g</option>"; } else
         { echo"<option>$g</option>"; }
       }
      echo "</select>";
      echo "Сейчас: ".date ("Y", time() + ($sdvigclock*3600))."<br />";
      echo"Месяц: <select name=\"mes\" class=\"textbox\">";
      for($m=1; $m <= 12; $m++)
       {
        if($m < 10) { $m = "0".$m; }
        if($m == date ("m", time() + ($sdvigclock*3600)))
         { echo"<option selected=\"selected\">$m</option>"; } else
         { echo"<option>$m</option>"; }
       }
      echo "</select>";
      echo "Сейчас: ".date ("m", time() + ($sdvigclock*3600))."<br />";
      echo"День: <select name=\"den\" class=\"textbox\">";
      for($d=1; $d <= 31; $d++)
       {
        if($d < 10) { $d = "0".$d; }
        if($d == date ("d", time() + ($sdvigclock*3600)))
         { echo"<option selected=\"selected\">$d</option>"; } else
         { echo"<option>$d</option>"; }
       }
      echo "</select>";
      echo "Сейчас: ".date ("d", time() + ($sdvigclock*3600))."<br />";
      echo"Час: <select name=\"chas\" class=\"textbox\">";
      for($ch=0; $ch <= 23; $ch++)
       {
        if($ch < 10) { $ch = "0".$ch; }
        if($ch == date ("H", time() + ($sdvigclock*3600)))
         { echo"<option selected=\"selected\">$ch</option>"; } else
         { echo"<option>$ch</option>"; }
       }
      echo "</select>";
      echo "Сейчас: ".date ("H", time() + ($sdvigclock*3600))."<br />";
      echo"Минут: <select name=\"minut\" class=\"textbox\">";
      for($mi=0; $mi <= 59; $mi++)
       {
        if($mi < 10) { $mi = "0".$mi; }
        if($mi == date ("i", time() + ($sdvigclock*3600)))
         { echo"<option selected=\"selected\">$mi</option>"; } else
         { echo"<option>$mi</option>"; }
       }
      echo "</select>";
      echo "Сейчас: ".date ("i", time() + ($sdvigclock*3600))."<br />";
      echo"За (что?):<br /><input name=\"why\" value=\"плохое поведение\" /><br />";
      echo"<input value=\"Применить\" type=\"submit\" /></p></form>";

    echo "<p><a href=\"index_1.php?".session_name()."=".session_id()."\">В $room1</a></p>";
    include ('../../templates/foot.php');
   }
    else
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка!!! Вы не авторизованы. Войдите в личный кабинет<br /></p>";
    echo "<p><a href=\"index_1.php?".session_name()."=".session_id()."\">В $room1</a></p>";
    include ('../../templates/foot.php');
   }
 }
####################
if($_GET['act']=='send')
 {
  if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && $status == "1")
   {
    $otv = filter($_POST['otv']);
    if ($_POST[msgtrans]==1)
     {
      $otv = tr_to_win($otv);
     }
    $otv = stripslashes(smiles(bbcodes($otv)));
    $otv = str_replace("\r\n", '<br />', $otv);
    $base    = '../../data/chat/1.txt';
 	$basestr = file($base);
 	$restr   = trim($basestr[$str]);
    $buff    = @file_get_contents($base);
    $buff    = str_replace("$restr\r\n","$restr|$otv\r\n",$buff);

    write_to_file($base, $buff);

    header ("Location: index_1.php?page=$page&".session_name()."=".session_id()."");
   }
    else
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка!!! Вы не авторизованы. Войдите в личный кабинет.<br /></p>";
    echo "<p><a href=\"index_1.php?".session_name()."=".session_id()."\">В $room1</a></p>";
    include '../../templates/foot.php';
   }
 }
####################
if($_GET[act]=='del')
 {
  if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == "1" || $status == "2" || $status == "3"))
   {
   	$basedel = '../../data/chat/1.txt';
 	$basestr = file($basedel);
 	$delstr = trim($basestr[$str]);

 	$mes_exp = explode('|', $basestr[$str]);
 	$deleted_mes = trim($mes_exp[6]);

    $buff = @file_get_contents($basedel);
    $buff = str_replace("$delstr\r\n",'',$buff);

    write_to_file($basedel, $buff);

    $date = date('d.m.Y / H:i:s', time() + ($sdvigclock*3600));
    $adm_log_f = @file('../../data/adm_log.php');
    $adm_log_count = count($adm_log_f) - 2;
    $mes_to_adm_log = "$login|$date|Удалил сообщение \"$deleted_mes\" в чате $room1\r\n";
    for($i=2; $i < $adm_log_count; $i++)
     {
      $mes_to_adm_log .= $adm_log_f[$i];
     }
    $mes_to_adm_log = trim($mes_to_adm_log);

    $adm_log_file = fopen('../../data/adm_log.php','w');
    flock ($adm_log_file,LOCK_EX);
    fputs($adm_log_file,"<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");
    fflush ($adm_log_file);
    flock ($adm_log_file,LOCK_UN);
    fclose($adm_log_file);

    header ("Location: index_1.php?page=$page&".session_name()."=".session_id()."");
   }
    else
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка!!! Вы не авторизованы. Войдите в личный кабинет.<br /></p>";
    echo "<p><a href=\"index_1.php?".session_name()."=".session_id()."\">В $room1</a></p>";
    include '../../templates/foot.php';
   }
 }
####################
if($_GET[act]=='ban')
 {
  if (isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == "1" || $status == "2" || $status == "3"))
   {
    $ban_ip = htmlspecialchars(stripslashes(trim($_GET['ban'])));

	$banlist = '../../data/ban.txt';
    $file = fopen($banlist,'a+');
    fputs($file,"$ban_ip\r\n");
    fclose($file);

    $ban_exp = explode('||', $ban_ip);
    $ban_ip = $ban_exp[0].' - '.$ban_exp[1];
    $date = date('d.m.Y / H:i:s', time() + ($sdvigclock*3600));
    $adm_log_f = @file('../../data/adm_log.php');
    $adm_log_count = count($adm_log_f) - 2;
    $mes_to_adm_log = "$login|$date|Забанил IP $ban_ip\r\n";
    for($i=2; $i < $adm_log_count; $i++)
     {
      $mes_to_adm_log .= $adm_log_f[$i];
     }
    $mes_to_adm_log = trim($mes_to_adm_log);

    $adm_log_file = fopen('../../data/adm_log.php','w');
    flock ($adm_log_file,LOCK_EX);
    fputs($adm_log_file,"<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");
    fflush ($adm_log_file);
    flock ($adm_log_file,LOCK_UN);
    fclose($adm_log_file);

    include '../../themes/'.$themes.'.php';
    echo "<p class=\"b\">IP и браузер забанены!<br /></p>";
    echo "<p><a href=\"index_1.php?".session_name()."=".session_id()."\">В $room1</a></p>";
    include ("../../templates/foot.php");
   }
    else
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка!!! Вы не авторизованы. Войдите в личный кабинет.<br /></p>";
    echo "<p><a href=\"index_1.php?".session_name()."=".session_id()."\">В $room1</a></p>";
    include ('../../templates/foot.php');
   }
 }
####################
if ($_GET[act]=='clear')
 {
  if (isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == "1" || $status == "2"))
   {
   	$basedel = '../../data/chat/1.txt';
 	$basestr = file($basedel);
 	$buff = "$basestr[0]$basestr[1]$basestr[2]$basestr[3]$basestr[4]";
    $file = fopen($basedel,'w');
    flock ($file,LOCK_EX);
    fputs($file,$buff);
    fflush ($file);
    flock ($file,LOCK_UN);
    fclose($file);

    $date = date('d.m.Y / H:i:s', time() + ($sdvigclock*3600));
    $adm_log_f = @file('../../data/adm_log.php');
    $adm_log_count = count($adm_log_f) - 2;
    $mes_to_adm_log = "$login|$date|Очистил комнату в чате $room1\r\n";
    for($i=2; $i < $adm_log_count; $i++)
     {
      $mes_to_adm_log .= $adm_log_f[$i];
     }
    $mes_to_adm_log = trim($mes_to_adm_log);

    $adm_log_file = fopen('../../data/adm_log.php','w');
    flock ($adm_log_file,LOCK_EX);
    fputs($adm_log_file,"<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");
    fflush ($adm_log_file);
    flock ($adm_log_file,LOCK_UN);
    fclose($adm_log_file);

    header ("Location: index_1.php?".session_name()."=".session_id()."");
   }
    else
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка!!! Вы не авторизованы. Войдите в личный кабинет.<br /></p>";
    echo "<p><a href=\"index_1.php?".session_name()."=".session_id()."\">В $room1</a></p>";
    include ('../../templates/foot.php');
   }
 }
####################
?>