<?php
//////////////////////////////////////////
// CHAT POWERED : http://sim-sim.h2m.ru//
// ICQ : 378036650                     //
// Email : olegarhi75@mail.ru          //
// WEB SITE Version 1.0 www.waufon.ru  //
////////////////////////////////////////
require( "../inc/conf.inc.php" );
require( "../inc/check.php" );
$login = autorize();
$sound =  $login['sound'] ;
$max = $row['num_msgs'];
if ( empty( $max ) )
{
$max = 5;
}
switch ( $mod )
{
case "addus" :
echo "<title>Список врагов</title>";
echo "<style type=\"text/css\">";
echo "body { font-size: {$fs}; color: {$tcol}; background-color: {$bcol} }";
echo "a:link,a:visited { text-decoration: underline; color: {$lcol} }";
echo "div { border-style:solid; border-width: 1px; background-color: {$rcol} }";
echo ".cp { border-style:solid; border-width: 0px; color: {$lcol} ; background-color: {$bcol}; text-align: left }";
echo "</style>";
echo "</head>";
echo "<body>";
if($sound=="1")
{
echo "<!--h--><!--h--><a><bgsound src=\"../sound/ban.wav\"></br>";
}
echo "<div align=\"center\">Добавить в список Ваших врагов</div>";
echo "<form method=\"post\" action=\"vrag.php\">";
echo "Кого:<br/>";
echo "<input name=\"usid\" maxlength=\"24\" value=\"{$usid}\"/><br/>";
if ( $row['trans'] == 1 )
{
echo "<input name=\"translit\" type=\"checkbox\" value=\"1\">Транслит<br/>";
}
echo "<input type=\"hidden\" name=\"mod\" value=\"adding\"/>\r\n";
echo"<input type=\"hidden\" name=\"id\" value=\"{$id}\"/>\r\n";
echo"<input type=\"hidden\" name=\"pass\" value=\"{$pass}\"/>\r\n";
echo"<input value=\"Добавить в список\" type=\"submit\" class=\"cp\">\r\n</form>";
##############
break;
case "adding" :
echo "<meta http-equiv=\"refresh\" content=\"1;URL=vrag.php?id={$id}&amp;pass={$pass}\"/>";
echo "<title>Добавление...</title>";
echo "<style type=\"text/css\">";
echo "body { font-size: {$fs}; color: {$tcol}; background-color: {$bcol}; text-align: center }";
echo "a:link,a:visited { text-decoration: underline; color: {$lcol} }";
echo "div { border-style:solid; border-width: 1px; background-color: {$rcol} }";
echo "</style>";
echo "</head>";
echo "<body>";
#################*/
if ( empty( $usid ) )
{
echo "<div>Кого добавим в список врагов? :)</div>";
}
else
{
$usid = check( $usid );
$q = @mysql_query( "select id, login from users where login='".$usid."';" );
if ( mysql_num_rows( $q ) == 0 )
{
echo "<div>Такого юзера не существует!</div>";
}
else
{
$data = mysql_fetch_array( $q );
$usid = $data['id'];
$login = $data['login'];
//$subject = check( $subject );
//$subject = substr( $subject, 0, 600 );
 if ( mysql_query( "Insert into evils set login='".$login."', id='".$id."', usid='".$usid."' ;" ) )
{
echo "<div>Пользователь  успешно добавлен!</div>";
}
else
{
echo "<div>Ошибка...</div>";
}
}
}
break;
case "list" :
$q = mysql_query( "select usid from evils where id='{$id}' ;" );
$num = mysql_num_rows( $q );
echo "<title>Список врагов</title>";
echo "<style type=\"text/css\">";
echo "body { font-size: {$fs}; color: {$tcol}; background-color: {$bcol} }";
echo "a:link,a:visited { text-decoration: underline; color: {$lcol} }";
echo "div { border-style:solid; border-width: 1px; background-color: {$rcol}; text-align: center }";
echo "</style>";
echo "</head>";
echo "<body>\n";
if ( $num == 0 )
{
if($sound=="1")
{
echo "<!--h--><!--h--><a><bgsound src=\"../sound/owibka.wav\"></br>";
}
echo "<div>список пуст</div>";
echo "<a href=\"vrag.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Назад</a><br/>";
break;
}
else
{
echo "<div>колличество Ваших врагов ({$num})</div>";
}
$s = intval( $s );
if ( $s < 0 )
{
$s = 0;
}
$i = $s;
$res = mysql_query( "select * from evils where id='{$id}'  order by usid desc limit {$s},{$max}" );
while ( $vrag = mysql_fetch_array( $res ) )
{
++$i;
$vragid = $vrag['id'];
$from = $vrag['login'];
$tid = $vrag['tid'];
//$subject = $ign['topic'];
$time = date( "H:i", $vrag['wtime'] );
echo "<b>{$i}.</b> <b>{$from}</b>\r был занесён Вами в список врагов<a href=\"vrag.php?id={$id}&amp;pass={$pass}&amp;mod=del&amp;tid={$tid}&amp;vragid={$vragid}&amp;ref={$ref}\">(<b>X</b>)</a><br/>";
}
echo "<a href=\"vrag.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Назад</a><br/>";
if ( !( $s + $max < $num ) )
{
break;
}
print "<a href=\"index.php?id={$id}&amp;pass={$pass}&amp;mod={$mod}&amp;s=".( $s + $max )."\">Следующие</a><br/>";
break;
case "del" :
echo "<meta http-equiv=\"refresh\" content=\"1;URL=./vrag.php?id={$id}&amp;pass={$pass}\"/>";
echo "<title>Deleting...</title>";
echo "<style type=\"text/css\">";
echo "body { font-size: {$fs}; color: {$tcol}; background-color: {$bcol}; text-align: center }";
echo "a:link,a:visited { text-decoration: underline; color: {$lcol} }";
echo "div { border-style:solid; border-width: 1px; background-color: {$rcol} }";
echo "</style>";
echo "</head>";
echo "<body><div>Пользователь удалён из списка</div>";
$vragid = intval( $vragid );
$q = mysql_query( "select usid,id from evils where id='{$vragid}'" );
$vrag = @mysql_fetch_array( $q );
$usid = $vrag['usid'];
$id = $vrag['id'];
mysql_query( "delete from evils WHERE usid = '{$usid}'" );
break;
case "delall" :
echo "<meta http-equiv=\"refresh\" content=\"1;URL=vrag.php?id={$id}&amp;pass={$pass}\"/>";
echo "<title>Deleting...</title>";
echo "<style type=\"text/css\">";
echo "body { font-size: {$fs}; color: {$tcol}; background-color: {$bcol}; text-align: center }";
echo "a:link,a:visited { text-decoration: underline; color: {$lcol} }";
echo "div { border-style:solid; border-width: 1px; background-color: {$rcol} }";
echo "</style>";
echo "</head>";
echo "<body><div>Список очищен!</div>";
mysql_query( "delete  from evils WHERE id = '{$id}'" );
mysql_query( "OPTIMIZE TABLE `evils`" );
break;
default :
echo "<title>Список врагов</title>";
echo "<style type=\"text/css\">";
echo "body { font-size: {$fs}; color: {$tcol}; background-color: {$bcol} }";
echo "a:link,a:visited { text-decoration: underline; color: {$lcol} }";
echo "div { border-style:solid; border-width: 1px; background-color: {$rcol}; text-align: center }";
echo "</style>";
echo "</head>";
echo "<body>";
if($sound=="1")
{
echo "<!--h--><!--h--><a><bgsound src=\"../sound/ban.wav\"></br>";
}
echo "<div>Список врагов</div>\n";
$q = mysql_query( "select usid from evils where id='{$id}' ;" );
$num = mysql_num_rows( $q );

echo "<a href=\"vrag.php?id={$id}&amp;pass={$pass}&amp;mod=list&amp;ref={$ref}\">Список врагов ({$num})</a><br/>\r\n---<br/>\r\n<a href=\"vrag.php?id={$id}&amp;pass={$pass}&amp;mod=addus&amp;ref={$ref}\">Добавить в список</a><br/>\r\n<a href=\"vrag.php?id={$id}&amp;pass={$pass}&amp;mod=delall&amp;ref={$ref}\">Очистить весь список</a><br/>";
break;
}
echo "---<br/>";
$end = gettime( );
echo "<a href=\"index.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Кабинет</a><br/>";
echo"<a href=\"../enter.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Прихожая</a><br/>\r\n<p align=\"center\">\r\n[".round( $end - $mystart, 5 )."]";
require("../inc/coper.php");
print "</p></body></html>";
mysql_close( $link );
?>