Просмотр файла modules/kabinet/set_friend.php

Размер файла: 6.35Kb
<?php
########################################
##	           WAP-ENGINE             ##
########################################
##                                    ##
##  Автор : CHUMA (Токарев Владимир)  ##
##  e-mail : [email protected]     ##
##  WAP : http://wap-engine.ru        ##
##                                    ##
########################################
##         ВЫ НЕ ИМЕЕТЕ ПРАВО         ##
##        ИЗМЕНЯТЬ КОД СКРИПТА        ##
##  ДЛЯ ДАЛЬНЕЙШЕГО РАСПРОСТРАНЕНИЯ!  ##
########################################
include ('../../config.php');
include ('../../templates/run.php');
include ('../../templates/func.php');
####################
if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw)
 {
  if($_GET['act']=='del')
   {
    $friends_f = file('../../data/users/'.$login.'_friends.php');
    $friends_count = count($friends_f);
    $id = filter($_GET['id']);
    $page = filter($_GET['page']);
    
    for($i=2;
$i < $friends_count - 2;
$i++)
     {
      $friends[] = "$friends_f[$i]";
     }

    $fr_count = count($friends);

    for($i=0;
$i < $fr_count;
$i++)
     {
      if($i != $id)
       {	
        $fr_to_file .= trim($friends[$i])."\r\n";
       }
     }
    $fr_to_file = trim($fr_to_file);
    if(!empty($fr_to_file))
     { $fr_to_file = "\r\n".$fr_to_file;
} else
     { $fr_to_file = '';
}

    $friends_file = fopen("../../data/users/$login"."_friends.php","w");
    flock ($friends_file,LOCK_EX);
    fputs($friends_file,"<?php\r\n/*$fr_to_file\r\n*/\r\n?>");
    fflush ($friends_file);
    flock ($friends_file,LOCK_UN);
fclose($friends_file);

$fr = filter($_GET['f']);


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


$inbox_f = @file('../../data/inbox/'.$kogo.'.php');
$inbox_count = count($inbox_f) - 2;
 $nicks = file('../../data/nicks.php');
$count_nicks = count($nicks);
$count_nicks = $count_nicks - 2;
$user_est = 0;
for($i=2;
$i <= $count_nicks;
$i++) { if($kogo == trim($nicks[$i])) { $user_est = 1;
break;
} } if($user_est == 1 && $inbox_count < $kolmesls + 2) { $mes_to_inbox_file = "CICTEMA|$date|Пользователь <a href=\"/modules/kabinet/user_info.php?nick=$login\">$login</a> удалил Вас из своего списка друзей.|1\r\n";
for($iii=2;
$iii < $inbox_count;
$iii++) { $mes_to_inbox_file .= $inbox_f[$iii];
} $mes_to_inbox_file = trim($mes_to_inbox_file);
 write_to_file('../../data/inbox/'.$kogo.'.php', "<?php\r\n/*\r\n$mes_to_inbox_file\r\n*/\r\n?>");
 user_data('../../data/users/'.$kogo.'.php');
$new_ls = $new_ls + 1;
$str_to_user_file = str_user_data();
write_to_file('../../data/users/'.$kogo.'.php', "<?php\r\n/*\r\n$str_to_user_file\r\n*/\r\n?>");
}

     header ("Location: friends.php?page=$page&".session_name()."=".session_id()."");
   }

####################
  if($_GET['act']=='add')

   {


    $friends_f = @file("../../data/users/$login"."_friends.php");
    $friends_count = count($friends_f);

    if(isset($_POST['kto']))
     {
      $kto = filter($_POST['kto']);
     }
    elseif(isset($_GET['kto']))
     {
      $kto = filter($_GET['kto']);
     }
    
    $nicks = file('../../data/nicks.php');
    $count_nicks = count($nicks);
    $count_nicks = $count_nicks - 2;
	$user_est = 0;
    for($i=2;
$i <= $count_nicks;
$i++)
     {
      if($kto == trim($nicks[$i]))
	   {
	    $user_est = 1;
	    break;
	   }
     }
     
    if(empty($kto))
     {
      header("Location: friends.php?err=1&".session_name()."=".session_id()."");
      exit;
     }
    
    $drug_est = 0;
    for($i=2;
$i < $friends_count - 2;
$i++)
     {
      if(strstr($friends_f[$i], "$kto"))
       {
        $drug_est = 1;
        break;
       }
        else
       {
        $friends[] = "$friends_f[$i]";
       }
     }
    
    
    if($kto == $login)
     {
      header("Location: friends.php?err=2&".session_name()."=".session_id()."");
      exit;
     }
    elseif($user_est == 0)
     {
      header("Location: friends.php?err=3&".session_name()."=".session_id()."");
      exit;
     }
    elseif($drug_est == 1)
     {
      header("Location: friends.php?err=4&".session_name()."=".session_id()."");
      exit;
     }
    
    $fr_count = count($friends);
    
    $fr_to_file = "$kto\r\n";
    for($i=0;
$i < $fr_count;
$i++)
     {
      $fr_to_file .= trim($friends[$i])."\r\n";
     }
    $fr_to_file = trim($fr_to_file);
    
    $friends_file = fopen("../../data/users/$login"."_friends.php","w");
    flock ($friends_file,LOCK_EX);
    fputs($friends_file,"<?php\r\n/*\r\n$fr_to_file\r\n*/\r\n?>");
    fflush ($friends_file);
    flock ($friends_file,LOCK_UN);
    fclose($friends_file);

$date = date('d.m.Y / H:i:s', time() + ($sdvigclock*3600));
$inbox_f = @file('../../data/inbox/'.$kto.'.php');
$inbox_count = count($inbox_f) - 2;

$nicks = file('../../data/nicks.php');
$count_nicks = count($nicks);
$count_nicks = $count_nicks - 2;
$user_est = 0;
for($i=2;
$i <= $count_nicks;
$i++)
{
if($kto == trim($nicks[$i]))
{
$user_est = 1;
break;
}
}
if($user_est == 1 && $inbox_count < $kolmesls + 2)
{
$mes_to_inbox_file = "CICTEMA|$date|Пользователь <a href=\"/modules/kabinet/user_info.php?nick=$login\">$login</a> добавил Вас в свой список друзей.|1\r\n";
for($iii=2;
$iii < $inbox_count;
$iii++)
{
$mes_to_inbox_file .= $inbox_f[$iii];
}
$mes_to_inbox_file = trim($mes_to_inbox_file);

write_to_file('../../data/inbox/'.$kto.'.php', "<?php\r\n/*\r\n$mes_to_inbox_file\r\n*/\r\n?>");

user_data('../../data/users/'.$kto.'.php');
$new_ls = $new_ls + 1;
$str_to_user_file = str_user_data();
write_to_file('../../data/users/'.$kto.'.php', "<?php\r\n/*\r\n$str_to_user_file\r\n*/\r\n?>");
}
   
    header ("Location: friends.php?".session_name()."=".session_id()."");
   }
####################
 }
  else
 {
  include ("../../themes/$themes.php");
  echo"<p class=\"b\">Вы не авторизованы!!! Войдите в личный кабинет.<br /></p>";
  echo"<p><img src=\"/images/st/back.gif\"align=\"top\"alt=\"\"/> <a href=\"index.php?".session_name()."=".session_id()."\">В кабинет</a><br /></p>";
  include ('../../templates/foot.php');
 }
####################
?>