Просмотр файла modules/forum/admin.php

Размер файла: 37.33Kb
<?php
########################################
##	           WAP-ENGINE             ##
########################################
##                                    ##
##  Автор : CHUMA (Токарев Владимир)  ##
##  e-mail : [email protected]     ##
##  WAP : http://wap-engine.ru        ##
##                                    ##
########################################
##         ВЫ НЕ ИМЕЕТЕ ПРАВО         ##
##        ИЗМЕНЯТЬ КОД СКРИПТА        ##
##  ДЛЯ ДАЛЬНЕЙШЕГО РАСПРОСТРАНЕНИЯ!  ##
########################################
include ('../../config.php');
include ('../../templates/run.php');
include ('../../templates/func.php');
####################
$id = filter($_GET['id']);
$str = filter($_GET['str']);
$str_r = filter($_GET['str_r']);
$str_t = filter($_GET['str_t']);
$page = filter($_GET['page']);

$razdel_data = '../../data/forum/razdel.php';
$razdel_f = file($razdel_data);
$razdel_count = count($razdel_f);

$podrazdel_data = '../../data/forum/podrazdel.php';
$podrazdel_f = file($podrazdel_data);
$podrazdel_count = count($podrazdel_f);
$podrazdel_arr = explode('|', $podrazdel_f[$str]);

$temy_data = '../../data/forum/podrazdel/'.$podrazdel_arr[0].'.php';
$temy_f = @file($temy_data);
$temy_count = count($temy_f);

$tem_data = '../../data/forum/temy/'.$podrazdel_arr[0].'_'.$id.'.php';
$tem_f = @file($tem_data);
$tem_count = count($tem_f);
####################
if($_GET['act']=='edit')
 {
  $mes_arr = explode('|', $tem_f[$str_t]);
  if (isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1' || $status == '2' || $status == '3' || $login == $mes_arr[0]))
   {
    $msg = str_replace('<br />', "\r\n", $mes_arr[3]);
    $msg = bb_back($msg);
    $msg = smiles_back($msg);
$title_page = 'Редактирование сообщения';
$m_polozhenie = 'Редактирует сообщение в теме';
    
    include '../../themes/'.$themes.'.php';
    echo '<p class="modul_name"align="center">Редактирование сообщения</p>';
    
    if($_GET['err'] == 1)
     {
      echo'<p class="err">Ошибка!!! Вы не ввели текст сообщения.</p>';
     }
    if($_GET['err'] == 2)
     {
      echo'<p class="err">Ошибка!!! Текст сообщения более 3000.</p>';
     }
    if($_GET['err'] == 3)
     {
      echo"<p class=\"err\">Ошибка!!! Вас забанил $banwho за $bantxt! Окончание бана: $bantime[6]$bantime[7].$bantime[4]$bantime[5].$bantime[0]$bantime[1]$bantime[2]$bantime[3] в $bantime[8]$bantime[9]:$bantime[10]$bantime[11] по времени сервера.</p>";
     }
    
    echo"<form method=\"post\" action=\"admin.php?act=editmes&amp;id=$id&amp;str=$str&amp;str_r=$str_r&amp;str_t=$str_t&amp;page=$page&amp;".session_name()."=".session_id()."\">";
    echo"<p align=\"center\" class=\"b\">Сообщение:<br /><textarea rows=\"4\" cols=\"15\" name=\"msg\">$msg</textarea><br />";
if($trans == '1')
{
echo"<input type=\"checkbox\" name=\"msgtrans\" value=\"1\" /> Транслит<br />";
}
 echo"<input value=\"Изменить\" name=\"do\" type=\"submit\" /></form></p>";
    
    echo"<p><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"showtema.php?id=$id&amp;str=$str&amp;str_r=$str_r&amp;page=$page&amp;".session_name()."=".session_id()."\">К теме</a></p>";
    include '../../templates/foot.php';
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка авторизации!!!<br /></p>";
    echo "<p><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"index.php?".session_name()."=".session_id()."\">В форум</a></p>";
    include '../../templates/foot.php';
   }
 }
####################
if($_GET['act']=='edittem')
 {
  if (isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1' || $status == '2' || $status == '3'))
   {
    $tem_arr = explode('|', $temy_f[$str_t]);
    $msg = str_replace('<br />', "\r\n", $tem_arr[4]);

$title_page = 'Редактирование названия темы';
$m_polozhenie = 'Редактирует название темы';
    
    include '../../themes/'.$themes.'.php';
    echo '<p class="modul_name"align="center">Редактирование названия темы</p>';
    
    echo"<form method=\"post\" action=\"admin.php?act=edittemy&amp;id=$id&amp;str=$str&amp;str_r=$str_r&amp;str_t=$str_t&amp;page=$page&amp;".session_name()."=".session_id()."\">";
    echo"<p align=\"center\" class=\"b\">Название:<br /><input name=\"tema\" maxlength=\"150\" value=\"$tem_arr[4]\" /><br />";
if($trans == '1')
{
echo"<input type=\"checkbox\" name=\"tematrans\" value=\"1\" /> Транслит<br />";
}
 echo"<input value=\"Изменить\" name=\"do\" type=\"submit\" /></form></p>";
    
    echo"<p><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"index.php?act=showforum&amp;id=$id&amp;str=$str&amp;str_r=$str_r&amp;page=$page&amp;".session_name()."=".session_id()."\">К темам</a></p>";
    include '../../templates/foot.php';
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo '<p class="err">Ошибка авторизации!!!<br /></p>';
    echo '<p><img src="/images/st/back.gif"align="top"alt=""/> <a href="index.php?'.session_name().'='.session_id().'">В форум</a></p>';
    include '../../templates/foot.php';
   }
 }
####################
if($_GET['act']=='movetem')
 {
  if (isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1' || $status == '2' || $status == '3'))
   {
    $tem_arr = explode('|', $temy_f[$str_t]);
    
    include '../../themes/'.$themes.'.php';
    echo '<p class="modul_name"align="center">Перенос темы "'.$tem_arr[4].'"</p>';
    
    echo'<form method="post" action="admin.php?act=move&amp;id='.$id.'&amp;str='.$str.'&amp;str_r='.$str_r.'&amp;str_t='.$str_t.'&amp;'.session_name().'='.session_id().'">';
    
    echo'<p align="center" class="b">
    Из подраздела:<br />"'.$podrazdel_arr[2].'"<br />
    В подраздел:<br />';
    
    echo'<select name="v_podrazdel">';
    for($i = 2; $i < $razdel_count - 2; $i++)
     {
      $razdel_arr = explode('|', $razdel_f[$i]);

      echo'<optgroup label="'.$razdel_arr[1].'">';

      for($ii = 2; $ii < $podrazdel_count - 2; $ii++)
       {
        $podrazdel_arr = explode('|', $podrazdel_f[$ii]);

        if($podrazdel_arr[1] == $razdel_arr[0])
         {
          echo'<option value="'.$podrazdel_arr[0].'_'.$ii.'_'.$i.'">'.$podrazdel_arr[2].'</option>';
         }
       }
      echo'</optgroup>';
     }
     
    echo'</select><br />';
    
    echo'<input value="Перенести" name="do" type="submit" /></form></p>';
    
    echo'<p><img src="/images/st/back.gif"align="top"alt=""/> <a href="index.php?act=showforum&amp;id='.$id.'&amp;str='.$str.'&amp;str_r='.$str_r.'&amp;page='.$page.'&amp;'.session_name().'='.session_id().'">К темам</a></p>';
    include '../../templates/foot.php';
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo '<p class="err">Ошибка авторизации!!!<br /></p>';
    echo '<p><img src="/images/st/back.gif"align="top"alt=""/> <a href="index.php?'.session_name().'='.session_id().'">В форум</a></p>';
    include '../../templates/foot.php';
   }
 }
####################
if($_GET['act']=='delmes')
 {
  if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1' || $status == '2' || $status == '3'))
   {
      for($i=2; $i < $temy_count - 2; $i++)
       {
        $temy_str = explode('|', $temy_f[$i]);
        if($temy_str[0] == $id)
         {
          $mes_all = $temy_str[8] - 1;
          $tema_del = $temy_str[4];
          $temy_arr[] = "$temy_str[0]|$temy_str[1]|$temy_str[2]|$temy_str[3]|$temy_str[4]|$temy_str[5]|$temy_str[6]|$temy_str[7]|$mes_all";
         }
          else
         {
          $temy_arr[] = trim($temy_f[$i]);
         }
       }
      if(!empty($temy_arr))
       { $temy_n_str = trim(implode("\r\n", $temy_arr)); } else
       { $temy_n_str = ''; }      
      
      $str_put = "<?php\r\n/*\r\n$temy_n_str\r\n*/\r\n?>";
      
      write_to_file($temy_data, $str_put);
      
      for($i=2; $i < $tem_count - 2; $i++)
       {
        $tem_str = explode('|', $tem_f[$i]);
        if($str_t != $i)
         {
          $tem_arr[] = trim($tem_f[$i]);
         }
          else
         {
          $deleted_mes = trim($tem_str[3]);
         }
       }
      if(!empty($tem_arr))
       { $tem_n_str = "\r\n".trim(implode("\r\n", $tem_arr)); } else
       { $tem_n_str = ''; }      
      
      $str_put = "<?php\r\n/*$tem_n_str\r\n*/\r\n?>";
      
      write_to_file($tem_data, $str_put);
      
      for($i=2; $i < $podrazdel_count - 2; $i++)
       {
        $pod_str = explode('|', $podrazdel_f[$i]);
        if($pod_str[0] == $podrazdel_arr[0])
         {
          $mes_all = $pod_str[5] - 1;
          $pod_arr[] = trim($pod_str[0]).'|'.trim($pod_str[1]).'|'.trim($pod_str[2]).'|'.trim($pod_str[3]).'|'.trim($pod_str[4]).'|'.$mes_all;
         }
        else
         {
          $pod_arr[] = trim($podrazdel_f[$i]);
         }
       }

      $pod_n_str = trim(implode("\r\n", $pod_arr));
      $pod_put = "<?php\r\n/*\r\n$pod_n_str\r\n*/\r\n?>";

      write_to_file($podrazdel_data, $pod_put);
      
      $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\" в теме \"$tema_del\"\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);

      write_to_file('../../data/adm_log.php', "<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");
    
      header ("location: showtema.php?id=$id&str=$str&str_r=$str_r&page=$page&".session_name()."=".session_id()."");
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo '<p class="err">Ошибка авторизации!!!<br /></p>';
    echo '<p><img src="/images/st/back.gif"align="top"alt=""/> <a href="index.php?'.session_name().'='.session_id().'">В форум</a></p>';
    include '../../templates/foot.php';
   }
 }
####################
if($_GET['act']=='editmes')
 {
  $mess_arr = explode('|', $tem_f[$str_t]);
  if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1' || $status == '2' || $status == '3' || $login == $mess_arr[0]))
   {
      $msg = filter($_POST['msg']);
      $msg = str_replace('|', '', $msg);
      if($_POST['msgtrans']==1)
       {
        $msg = tr_to_win($msg);
       }
      $msg = smiles($msg);
      $msg = antimat($msg);
      $msg = bbcodes($msg);
      $msg = stripslashes($msg);
      $msg = str_replace("\r\n", '<br />', $msg);

      $time = date('H:i:s', time() + $sdvigclock*3600);
      $date = date('d.m.Y', time() + $sdvigclock*3600);

      $date_now = date ('YmdHis', time() + $sdvigclock*3600);
      if($bantime > $date_now)
       {
        $errb = '2';
       }
       
      if($errb == '2')
       {
        header ("location: admin.php?act=edit&err=3&str_t=$str_t&id=$id&str=$str&str_r=$str_r&page=$page&".session_name()."=".session_id()."");
        exit;
       }
      elseif(empty($msg))
       {
        header ("location: admin.php?act=edit&err=1&str_t=$str_t&id=$id&str=$str&str_r=$str_r&page=$page&".session_name()."=".session_id()."");
        exit;
       }
      elseif(strlen($msg) > 3000 && $status > 3)
       {
        header ("location: admin.php?act=edit&err=2&str_t=$str_t&id=$id&str=$str&str_r=$str_r&page=$page&".session_name()."=".session_id()."");
        exit;
       }
       
      for($i=2; $i < $tem_count - 2; $i++)
       {
        $tem_str = explode('|', $tem_f[$i]);
        if($str_t != $i)
         {
          $tem_arr[] = trim($tem_f[$i]);
         }
          else
         {
          $edited_mes = trim($tem_str[3]);
          $tem_arr[] = "$tem_str[0]|$tem_str[1]|$tem_str[2]|$msg|$login|$date|$time";
         }
       }
      if(!empty($tem_arr))
       { $tem_n_str = "\r\n".trim(implode("\r\n", $tem_arr)); } else
       { $tem_n_str = ''; }      
      
      $str_put = "<?php\r\n/*$tem_n_str\r\n*/\r\n?>";

      write_to_file($tem_data, $str_put);
      
      $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|Изменил сообщение \"$edited_mes\" на \"$msg\"\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);

      write_to_file('../../data/adm_log.php', "<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");
    
      header ("location: showtema.php?id=$id&str=$str&str_r=$str_r&page=$page&".session_name()."=".session_id()."");
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo '<p class="err">Ошибка авторизации!!!<br /></p>';
    echo '<p><img src="/images/st/back.gif"align="top"alt=""/> <a href="index.php?'.session_name().'='.session_id().'">В форум</a></p>';
    include '../../templates/foot.php';
   }
 }
####################
if($_GET['act']=='deltem')
 {
  if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1' || $status == '2' || $status == '3'))
   {
 	$delstr = trim($temy_f[$str_t]);
    $buff = @file_get_contents($temy_data);
    $buff = str_replace("$delstr\r\n",'',$buff);

    write_to_file($temy_data, $buff);
    
    $temy_str = explode('|', $temy_f[$str_t]);
    $deleted_tema = trim($temy_str[4]);
    $last_temy_data = '../../data/forum/last_temy.php';
    $buff = @file_get_contents($last_temy_data);
    $delstr = "$temy_str[0]|$str|$str_r|$temy_str[1]|$temy_str[2]|$temy_str[3]|$temy_str[4]";
    $buff = str_replace("$delstr\r\n",'',$buff);

    write_to_file($last_temy_data, $buff);
    
    $last_mes_data = '../../data/forum/last_mes.php';
    $last_mes_f = file($last_mes_data);
    $last_mes_count = count($last_mes_f);
    
    for($i=2; $i < $last_mes_count - 2; $i++)
     {
      $mes_str = explode('|', $last_mes_f[$i]);
      if($mes_str[0] != $temy_str[0])
       {
        $mes_arr[] = trim($mes_str[0]).'|'.trim($mes_str[1]).'|'.trim($mes_str[2]).'|'.trim($mes_str[3]).'|'.trim($mes_str[4]).'|'.trim($mes_str[5]).'|'.trim($mes_str[6]).'|'.trim($mes_str[7]);
       }
     }

    $mes_n_str = trim(implode("\r\n", $mes_arr));
    $mes_put = "<?php\r\n/*\r\n$mes_n_str\r\n*/\r\n?>";
    
    write_to_file($last_mes_data, $mes_put);
    
    $tem_arr = explode('|', $delstr);
    $tem_file_count = count(file('../../data/forum/temy/'.$podrazdel_arr[0].'_'.$tem_arr[0].'.php'));
    $file = fopen('../../data/forum/temy/'.$podrazdel_arr[0].'_'.$tem_arr[0].'.php','w');
    fputs($file,'');
    fclose($file);
    @unlink('../../data/forum/temy/'.$podrazdel_arr[0].'_'.$tem_arr[0].'.php');
    
    for($i=2; $i < $podrazdel_count - 2; $i++)
     {
      $pod_str = explode('|', $podrazdel_f[$i]);
      if($pod_str[0] == $podrazdel_arr[0])
       {
        $tem_all = $pod_str[4] - 1;
        $mes_all = $pod_str[5] - ($tem_file_count - 4);
        $pod_arr[] = trim($pod_str[0]).'|'.trim($pod_str[1]).'|'.trim($pod_str[2]).'|'.trim($pod_str[3]).'|'.$tem_all.'|'.$mes_all;
       }
      else
       {
        $pod_arr[] = trim($podrazdel_f[$i]);
       }
     }

    $pod_n_str = trim(implode("\r\n", $pod_arr));
    $pod_put = "<?php\r\n/*\r\n$pod_n_str\r\n*/\r\n?>";

    write_to_file($podrazdel_data, $pod_put);
    
    if(file_exists('../../data/forum/temy/'.$podrazdel_arr[0].'_'.$tem_arr[0].'_podpiska.php'))
     {
      $file = fopen('../../data/forum/temy/'.$podrazdel_arr[0].'_'.$tem_arr[0].'_podpiska.php','w');
      fputs($file,'');
      fclose($file);
      @unlink('../../data/forum/temy/'.$podrazdel_arr[0].'_'.$tem_arr[0].'_podpiska.php');
     }
    
    $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_tema\"\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);

    write_to_file('../../data/adm_log.php', "<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");

    header ("location: index.php?act=showforum&id=$id&str=$str&str_r=$str_r&page=$page&".session_name()."=".session_id()."");
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка авторизации!!!<br /></p>";
    echo "<p><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"index.php?".session_name()."=".session_id()."\">В форум</a></p>";
    include '../../templates/foot.php';
   }
 }
####################
if($_GET['act']=='move')
 {
  if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1' || $status == '2' || $status == '3'))
   {
    $ids_arr = explode('_', filter($_POST['v_podrazdel']));
    $v_id = trim($ids_arr[0]);
    $v_str = trim($ids_arr[1]);
    $v_str_r = trim($ids_arr[2]);
    
    # Создание темы в новом разделе
    $v_temy_data = '../../data/forum/podrazdel/'.$v_id.'.php';
    $v_temy_f = @file($v_temy_data);
    $v_temy_count = count($v_temy_f);

    for($i=2; $i < $v_temy_count - 2; $i++)
       {
        $v_temy_n = explode('|', $v_temy_f[$i]);
        $n[] = $v_temy_n[0];
       }
      $max_num = @max($n);
      $temy_n_str = @implode('|', $n);
      $temy_n_str = '|'.$temy_n_str.'|';
      
      if($v_temy_count - 4 < $max_num)
       {
        for($i=1; $i <= $max_num; $i++)
         {
          if(!strstr($temy_n_str, '|'.$i.'|'))
           {
            $num = $i;
           }
         }
       }
        else
       {
        $num = $max_num + 1;
       }
       
      $back = @file_get_contents($v_temy_data);
      $back = str_replace("<?php\r\n/*", '', $back);
      $back = str_replace("*/\r\n?>", '', $back);
      $back = trim($back);

      $temy_str = explode('|', $temy_f[$str_t]);
      
      if(!empty($back))
       {
        $str_put = "<?php\r\n/*\r\n".trim("$num|$temy_str[1]|$temy_str[2]|$temy_str[3]|$temy_str[4]|$temy_str[5]|$temy_str[6]|$temy_str[7]|$temy_str[8]")."\r\n".$back."\r\n*/\r\n?>";
       }
        else
       {
        $str_put = "<?php\r\n/*\r\n".trim("$num|$temy_str[1]|$temy_str[2]|$temy_str[3]|$temy_str[4]|$temy_str[5]|$temy_str[6]|$temy_str[7]|$temy_str[8]")."\r\n*/\r\n?>";
       }

      write_to_file($v_temy_data, $str_put);
      
      $temy_arr = explode('|', $temy_f[$str_t]);
      $iz_tem_data = '../../data/forum/temy/'.$id.'_'.$temy_arr[0].'.php';
      $mesages_back = @file_get_contents($iz_tem_data);
      $mesages_back = trim($mesages_back);
      $v_tem_data = '../../data/forum/temy/'.$v_id.'_'.$num.'.php';

      write_to_file($v_tem_data, $mesages_back);
      
      for($i=2; $i < $podrazdel_count - 2; $i++)
       {
        $pod_str = explode('|', $podrazdel_f[$i]);
        if($pod_str[0] == $v_id)
         {
          $tem_all = $pod_str[4] + 1;
          $mes_all = $pod_str[5] + trim($temy_str[8]);
          $pod_arr[] = trim($pod_str[0]).'|'.trim($pod_str[1]).'|'.trim($pod_str[2]).'|'.trim($pod_str[3]).'|'.$tem_all.'|'.$mes_all;
         }
        elseif($pod_str[0] == $podrazdel_arr[0])
         {
          $tem_all = $pod_str[4] - 1;
          $mes_all = $pod_str[5] - trim($temy_str[8]);
          $pod_arr[] = trim($pod_str[0]).'|'.trim($pod_str[1]).'|'.trim($pod_str[2]).'|'.trim($pod_str[3]).'|'.$tem_all.'|'.$mes_all;
         }
        else
         {
          $pod_arr[] = trim($podrazdel_f[$i]);
         }
       }

      $pod_n_str = trim(implode("\r\n", $pod_arr));
      $pod_put = "<?php\r\n/*\r\n$pod_n_str\r\n*/\r\n?>";

      write_to_file($podrazdel_data, $pod_put);
      
      # Удаление старой темы
      $delstr = trim($temy_f[$str_t]);
      $buff = @file_get_contents($temy_data);
      $buff = str_replace("$delstr\r\n",'',$buff);

      write_to_file($temy_data, $buff);
      
      $tem_arr = explode('|', $delstr);
      $file = fopen($iz_tem_data,'w');
      fputs($file,'');
      fclose($file);
      @unlink($iz_tem_data);
      
      if(file_exists('../../data/forum/temy/'.$id.'_'.$temy_arr[0].'_podpiska.php'))
       {
        $buff_podpiska = @file_get_contents('../../data/forum/temy/'.$id.'_'.$temy_arr[0].'_podpiska.php');
        write_to_file('../../data/forum/temy/'.$v_id.'_'.$num.'_podpiska.php', $buff_podpiska);
        $file = fopen('../../data/forum/temy/'.$id.'_'.$temy_arr[0].'_podpiska.php','w');
        fputs($file,'');
        fclose($file);
        @unlink('../../data/forum/temy/'.$id.'_'.$temy_arr[0].'_podpiska.php');
       }
      
      # Смена идентификаторов темы п списке последних тем и сообщений
      $temy_str = explode('|', $temy_f[$str_t]);
      $deleted_tema = trim($temy_str[4]);
      $last_temy_data = '../../data/forum/last_temy.php';
      $buff = @file_get_contents($last_temy_data);
      $delstr = "$temy_str[0]|$str|$str_r|$temy_str[1]|$temy_str[2]|$temy_str[3]|$temy_str[4]";
      $newstr = "$num|$v_str|$v_str_r|$temy_str[1]|$temy_str[2]|$temy_str[3]|$temy_str[4]";
      $buff = str_replace("$delstr\r\n","$newstr\r\n",$buff);
      
      write_to_file($last_temy_data, $buff);
      
      $last_mes_data = '../../data/forum/last_mes.php';
      $buff = @file_get_contents($last_mes_data);
      $delstr = $temy_str[0].'|'.$str.'|'.$str_r;
      $newstr = $num.'|'.$v_str.'|'.$v_str_r;
      $buff = str_replace($delstr, $newstr, $buff);
      
      write_to_file($last_mes_data, $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|Переместил тему \"$temy_str[4]\"\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);

      write_to_file('../../data/adm_log.php', "<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");
      
    header ("location: index.php?act=showforum&id=$v_id&str=$v_str&str_r=$v_str_r&".session_name()."=".session_id()."");
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка авторизации!!!<br /></p>";
    echo "<p><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"index.php?".session_name()."=".session_id()."\">В форум</a></p>";
    include '../../templates/foot.php';
   }
 }
####################
if($_GET['act']=='edittemy')
 {
  if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1' || $status == '2' || $status == '3'))
   {
      $tema = filter($_POST['tema']);
      if($_POST['tematrans']==1)
       {
        $tema = tr_to_win($tema);
       }
       
      for($i=2; $i < $temy_count - 2; $i++)
       {
        $temy_str = explode('|', $temy_f[$i]);
        if($str_t != $i)
         {
          $temy_arr[] = trim($temy_f[$i]);
         }
          else
         {
          $temy_arr[] = trim("$temy_str[0]|$temy_str[1]|$temy_str[2]|$temy_str[3]|$tema|$temy_str[5]|$temy_str[6]|$temy_str[7]|$temy_str[8]");
         }
       }
      if(!empty($temy_arr))
       { $temy_n_str = "\r\n".trim(implode("\r\n", $temy_arr)); } else
       { $temy_n_str = ''; }      
      
      $str_put = "<?php\r\n/*$temy_n_str\r\n*/\r\n?>";

      write_to_file($temy_data, $str_put);
      
      $temy_str = explode('|', $temy_f[$str_t]);
      $deleted_tema = trim($temy_str[4]);
      $last_temy_data = '../../data/forum/last_temy.php';
      $buff = @file_get_contents($last_temy_data);
      $delstr = "$temy_str[0]|$str|$str_r|$temy_str[1]|$temy_str[2]|$temy_str[3]|$temy_str[4]";
      $newstr = "$temy_str[0]|$str|$str_r|$temy_str[1]|$temy_str[2]|$temy_str[3]|$tema";
      $buff = str_replace("$delstr\r\n","$newstr\r\n",$buff);
      
      write_to_file($last_temy_data, $buff);
      
      $last_mes_data = '../../data/forum/last_mes.php';
      $last_mes_f = file($last_mes_data);
      $last_mes_count = count($last_mes_f);
    
      for($i=2; $i < $last_mes_count - 2; $i++)
       {
        $mes_str = explode('|', $last_mes_f[$i]);
        if($mes_str[0] == $temy_str[0])
         {
          $mes_arr[] = trim($mes_str[0]).'|'.trim($mes_str[1]).'|'.trim($mes_str[2]).'|'.trim($mes_str[3]).'|'.trim($mes_str[4]).'|'.trim($mes_str[5]).'|'.$tema.'|'.trim($mes_str[7]);
         }
        else
         {
          $mes_arr[] = trim($mes_str[0]).'|'.trim($mes_str[1]).'|'.trim($mes_str[2]).'|'.trim($mes_str[3]).'|'.trim($mes_str[4]).'|'.trim($mes_str[5]).'|'.trim($mes_str[6]).'|'.trim($mes_str[7]);
         }
       }

      $mes_n_str = trim(implode("\r\n", $mes_arr));
      $mes_put = "<?php\r\n/*\r\n$mes_n_str\r\n*/\r\n?>";
    
      write_to_file($last_mes_data, $mes_put);
      
      $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_tema\" на \"$tema\"\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);

      write_to_file('../../data/adm_log.php', "<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");
    
      header ("location: index.php?act=showforum&id=$id&str=$str&str_r=$str_r&page=$page&".session_name()."=".session_id()."");
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка авторизации!!!<br /></p>";
    echo "<p><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"index.php?".session_name()."=".session_id()."\">В форум</a></p>";
    include '../../templates/foot.php';
   }
 }
####################
if($_GET['act']=='zakrep')
 {
  if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1' || $status == '2' || $status == '3'))
   {       
      for($i=2; $i < $temy_count - 2; $i++)
       {
        $temy_str = explode('|', $temy_f[$i]);
        if($str_t != $i)
         {
          $temy_arr[] = trim($temy_f[$i]);
         }
          else
         {
          $tema_name = trim($temy_str[4]);
          $temy_arr[] = trim("$temy_str[0]|$temy_str[1]|$temy_str[2]|$temy_str[3]|$temy_str[4]|!|$temy_str[6]|$temy_str[7]|$temy_str[8]");
         }
       }
      if(!empty($temy_arr))
       { $temy_n_str = "\r\n".trim(implode("\r\n", $temy_arr)); } else
       { $temy_n_str = ''; }      
      
      $str_put = "<?php\r\n/*$temy_n_str\r\n*/\r\n?>";

      write_to_file($temy_data, $str_put);
      
      $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|Закрепил тему \"$tema_name\"\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);

      write_to_file('../../data/adm_log.php', "<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");
    
      header ("location: index.php?act=showforum&id=$id&str=$str&str_r=$str_r&page=$page&".session_name()."=".session_id()."");
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка авторизации!!!<br /></p>";
    echo "<p><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"index.php?".session_name()."=".session_id()."\">В форум</a></p>";
    include '../../templates/foot.php';
   }
 }
####################
if($_GET['act']=='osvob')
 {
  if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1' || $status == '2' || $status == '3'))
   {       
      for($i=2; $i < $temy_count - 2; $i++)
       {
        $temy_str = explode('|', $temy_f[$i]);
        if($str_t != $i)
         {
          $temy_arr[] = trim($temy_f[$i]);
         }
          else
         {
          $tema_name = trim($temy_str[4]);
          $temy_arr[] = trim("$temy_str[0]|$temy_str[1]|$temy_str[2]|$temy_str[3]|$temy_str[4]||$temy_str[6]|$temy_str[7]|$temy_str[8]");
         }
       }
      if(!empty($temy_arr))
       { $temy_n_str = "\r\n".trim(implode("\r\n", $temy_arr)); } else
       { $temy_n_str = ''; }      
      
      $str_put = "<?php\r\n/*$temy_n_str\r\n*/\r\n?>";

      write_to_file($temy_data, $str_put);
      
      $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|Освободил тему \"$tema_name\"\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);

      write_to_file('../../data/adm_log.php', "<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");
    
      header ("location: index.php?act=showforum&id=$id&str=$str&str_r=$str_r&page=$page&".session_name()."=".session_id()."");
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка авторизации!!!<br /></p>";
    echo "<p><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"index.php?".session_name()."=".session_id()."\">В форум</a></p>";
    include '../../templates/foot.php';
   }
 }
####################
if($_GET['act']=='close')
 {
  $temy_str = explode('|', $temy_f[$str_t]);
  if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1' || $status == '2' || $status == '3' || $temy_str[1] == $login))
   {
      for($i=2; $i < $temy_count - 2; $i++)
       {
        $temy_str = explode('|', $temy_f[$i]);
        if($str_t != $i)
         {
          $temy_arr[] = trim($temy_f[$i]);
         }
          else
         {
          $tema_name = trim($temy_str[4]);
          $temy_arr[] = trim("$temy_str[0]|$temy_str[1]|$temy_str[2]|$temy_str[3]|$temy_str[4]|$temy_str[5]|#|$temy_str[7]|$temy_str[8]");
         }
       }
      if(!empty($temy_arr))
       { $temy_n_str = "\r\n".trim(implode("\r\n", $temy_arr)); } else
       { $temy_n_str = ''; }      
      
      $str_put = "<?php\r\n/*$temy_n_str\r\n*/\r\n?>";

      write_to_file($temy_data, $str_put);
      
      $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|Закрыл тему \"$tema_name\"\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);

      write_to_file('../../data/adm_log.php', "<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");
    
      header ("location: showtema.php?id=$id&str=$str&str_r=$str_r&page=$page&".session_name()."=".session_id()."");
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка авторизации!!!<br /></p>";
    echo "<p><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"index.php?".session_name()."=".session_id()."\">В форум</a></p>";
    include '../../templates/foot.php';
   }
 }
####################
if($_GET['act']=='open')
 {
  $temy_str = explode('|', $temy_f[$str_t]);
  if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1' || $status == '2' || $status == '3'))
   {
      for($i=2; $i < $temy_count - 2; $i++)
       {
        $temy_str = explode('|', $temy_f[$i]);
        if($str_t != $i)
         {
          $temy_arr[] = trim($temy_f[$i]);
         }
          else
         {
          $tema_name = trim($temy_str[4]);
          $temy_arr[] = trim("$temy_str[0]|$temy_str[1]|$temy_str[2]|$temy_str[3]|$temy_str[4]|$temy_str[5]||$temy_str[7]|$temy_str[8]");
         }
       }
      if(!empty($temy_arr))
       { $temy_n_str = "\r\n".trim(implode("\r\n", $temy_arr)); } else
       { $temy_n_str = ''; }      
      
      $str_put = "<?php\r\n/*$temy_n_str\r\n*/\r\n?>";

      write_to_file($temy_data, $str_put);
      
      $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|Открыл тему \"$tema_name\"\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);

      write_to_file('../../data/adm_log.php', "<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");
    
      header ("location: showtema.php?id=$id&str=$str&str_r=$str_r&page=$page&".session_name()."=".session_id()."");
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка авторизации!!!<br /></p>";
    echo "<p><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"index.php?".session_name()."=".session_id()."\">В форум</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><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"index.php?".session_name()."=".session_id()."\">В форум</a></p>";
    include '../../templates/foot.php';
   }
    else 
   {
    include '../../themes/'.$themes.'.php';
    echo "<p class=\"err\">Ошибка авторизации!!!<br /></p>";
    echo "<p><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"index.php?".session_name()."=".session_id()."\">В форум</a></p>";
    include '../../templates/foot.php';
   }
 }
####################
?>