View file ignore.php

File size: 3.52Kb
<?php
include 'sys/db.php';
include 'sys/conf.php';
include 'sys/start.php';
include 'sys/functions.php';

$config_title_name = "Игнор-лист";
include 'style/head.php';



if(isset($user['login'])){
$act = isset($_GET['act']) ? $_GET['act'] : '';
switch($act){
default:
echo "<div class=title>Игнор-лист</div>";
echo "<div class=content>\n";
if ($_GET['isset']==there) {echo "Ошибка добавления в игнор!<hr>\n";}
if ($_GET['isset']==yes) {echo "Пользователь успешно добавлен в Игнор-лист!<hr>\n";}
if ($_GET['isset']==yesdel) {echo "Пользователь успешно удален из Игнор-лист!<hr>\n";}

function pages($start, $total, $page, $onpage){
if ($start != 0) echo '<a href="'.$page.'?start='.($start - $onpage).'">&lt;-Назад</a> ';
else echo '&lt;-Назад';
echo ' | ';
if ($total > $start + $onpage)
echo ' <a href="'.$page.'?start='.($start + $onpage).'">Далее-&gt;</a>';
else echo 'Далее-&gt;';}
$total = mysql_result(mysql_query("SELECT COUNT(*)FROM `ignore` WHERE `user` = '$user[id]' "),0);
$start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0;
if($start > $total) $start = 0;
if ($total < $start + 10) $end = $total;
else $end = $start + 10;

$ignore = mysql_query("SELECT * FROM `ignore` WHERE `user` = '$user[id]' ORDER BY `id` DESC LIMIT $start, 10");
if(mysql_num_rows($ignore) != 0){
while($ign = mysql_fetch_array($ignore)){
$ignend = mysql_query("SELECT login,gender FROM `users` WHERE `id` = '$ign[ignor]'");
if($igneuser = mysql_fetch_array($ignend)){
echo "<div class=box>";
if ($igneuser['gender']==1)echo "<img src='img/man.gif' alt=''> ";
elseif ($igneuser['gender']==2)echo "<img src='img/woman.gif' alt=''> ";
echo "<a href='anketa.php?id=".$ign['ignor']."'>".$igneuser['login']."</a> ";
if ($authortime > time()-600) {
echo " <img src='img/on.gif' alt=''>";
}else{
echo " <img src='img/off.gif' alt=''>";}
echo "</div>\n";
echo "<a href=''>Написать</a> |
<a href='?act=del&id=".$ign['id']."'>Удалить</a> |
<a href='friends.php?act=add&id=".$igneuser['id']."'>В друзья</a>\n";

}}
}else{ echo "<br><img src='img/error.gif' alt=''> У вас нет друзей!<br><br>\n";}
echo "</div>\n";
echo "<div class=stat>\n";
pages($start, $total, 'ignore.php', 10);
echo "</div>\n";
echo "<div class=stat><a href='index.php'>Прихожая</a>\n";
echo "</div>\n";
break;


case('add'):
$id = intval($_GET['id']);
if ($id != '0') {
$testing = mysql_fetch_array(mysql_query("SELECT * FROM `ignore` WHERE `user`='$user[id]' AND `ignor`='$id'"));
if($testing != '0'){header ("Location: ?isset=there"); exit;}
$time = time();

$testing = mysql_fetch_array(mysql_query("SELECT * FROM `friends` WHERE `user`='$user[id]' AND `friend`='$id'"));
if($testing != '0'){mysql_query("DELETE FROM `friends` WHERE id='$testing[id]'");}

mysql_query ("INSERT INTO `ignore` (user,ignor,time) VALUES ('$user[id]','$id','$time')");
header ("Location: ignore.php?isset=yes"); exit;
}else{ header ("Location: ignore.php?isset=there"); exit;}
break;

case('del'):
$id = intval($_GET['id']);
if ($id != '0') {
$delete = mysql_query("SELECT * FROM `ignore` WHERE `id` = '$id'");
if($del = mysql_fetch_array($delete)){
if ($user[id] == $del[user]){
mysql_query("DELETE FROM `ignore` WHERE id='$id'");
}else{ header ("Location: ignore.php?isset=there"); exit;}
}
header ("Location: ignore.php?isset=yesdel"); exit;
}else{ header ("Location: ignore.php?isset=there"); exit;}
break;
}
}else{ header ("Location: index.php"); exit;}
include 'style/foot.php';
?>