|
<?php
/*
----------------------------------------
Файл: ava.php
-------------------------------------------
*/
//-----Создаем титл страницы-----//
$title = 'Аватар';
//-----Подключаем функции-----//
require_once ('../system/function.php');
//-----Подключаем вверх-----//
require_once ('../system/header.php');
//-----Если гость,то...----//
if(!$user['id']) {
header('Location: /index.php');
exit();
}
$id = abs(intval($_GET['id']));
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$id."'"));
$perehodu = mysql_result(mysql_query("SELECT `perehodu` FROM `users` WHERE `id` = '$ank[id]' LIMIT 1",$db), 0);
switch($_GET['act'])
{
default:
echo '<div class="title"><center>Анкета '.$ank['login'].'</center></div>
<div class="podmenu">Пользователь: '.nick($ank['id']).'</div>';
echo '<div class="podmenu">';
echo (empty($ank['avatar'])?'<img src="/files/ava/net.jpg" alt="*" style="max-width: 210px; max-height: 210px;">':'<a href="/files/ava/'.$ank['avatar'].'"><img src="/files/ava/'.$ank['avatar'].'" alt="*" style="max-width: 210px; max-height: 210px;"></a>');
echo '<br>';
$photo_like = mysql_fetch_assoc(mysql_query("SELECT * FROM `ava_like` WHERE `ava` = '".$id."' and `kto` = '".$user['id']."'"));
$photo_l_count = mysql_result(mysql_query('select count(`id`) from `ava_like` where `ava` = "'.$id.'"'),0);
echo '<div class="st_2">';
if($photo_like == 0) {
echo '<a href="'.$HOME.'/user/avalike'.$id.'"><img src="/images/plus.png" alt="*" /> Мне нравится <b>'.$photo_l_count.'</b></a>';
} else {
echo '<a href="'.$HOME.'/user/avalike'.$id.'"><img src="/images/plus.png" alt="*" /> Мне нравится <b>'.$photo_l_count.'</b></a>';
}
echo '</div>';
#####################################
$id = abs(intval($_GET['id']));
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$id."'"));
switch($_GET['act'])
{
default:
echo '<div class="title">Комментарии</div>';
if(isset($_REQUEST['ok'])) {
$msg = strong($_POST['msg']);
if(empty($msg)) {
echo '<div class="podmenu"><center><b>Введите сообщение!</b></center></div>';
//-----Подключаем низ-----//
echo '<div class="podmenu"><a href="/user/ava.php?id='.$user['id'].'">Назад</a></div>';
require_once ('../system/footer.php');
exit();
}
if(mb_strlen($msg) < 3) {
echo '<div class="podmenu"><center><b>Введите сообщение минимум 3 символа!</b></center></div>';
echo '<div class="podmenu"><a href="/user/ava.php?id='.$user['id'].'">Назад</a></div>';
require_once ('../system/footer.php');
exit();
}
$ttte = mysql_fetch_array(mysql_query('select * from `komav` where `avtor` = "'.$user['id'].'" and `msg` = "'.$msg.'"'));
if($ttte != 0) {
echo '<div class="podmenu"><center><b>Вы такой пост уже писали!</b></center></div>';
echo '<div class="podmenu"><a href="/user/ava.php?id='.$user['id'].'">Назад</a></div>';
require_once ('../system/footer.php');
exit();
}
$tim = mysql_query("SELECT * FROM `komav` WHERE `avtor`='".$user['id']."' ORDER BY `time` DESC");
while($ncm2 = mysql_fetch_assoc($tim)){
$news_antispam = mysql_fetch_assoc(mysql_query("SELECT * FROM `antispam` WHERE `komav` "));
$ncm_timeout = $ncm2['time'];
if((time()-$ncm_timeout) < $news_antispam['stena'])
{
echo '<div class="podmenu"><center><b>Пишите не чаще чем раз в '.$news_antispam['stena'].' секунд!</b></center></div>';
echo '<div class="podmenu"><a href="/user/ava.php?id='.$user['id'].'">Назад</a></div>';
require_once ('../system/footer.php');
exit();
}
}
mysql_query("INSERT INTO `komav` SET `msg` = '".$msg."', `avtor` = '".$user['id']."', `ukogo` = '".$id."', `time` = '".time()."'");
if($user['id'] != $ank['id'])
{
mysql_query("INSERT INTO `lenta` SET `readlen` = '0', `time` = '".time()."', `komy` = '".$ank['id']."', `kto` = '".$user['id']."', `text` = 'оставил Вам комментарий [url=".$HOME."/user/ava.php?id=".$ank['id']."]к аватару[/url]'");
}
header('Location: '.$HOME.'/user/ava.php?id='.$id.'');
}
echo '<div class="podmenu">
<form action="" method="POST">
*Сообщение:
<textarea name="msg"></textarea>
<input type="submit" name="ok" value="Написать" />
</form></div>';
if (empty($user['max'])) $user['max']=10;
$max = $user['max'];
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `komav` WHERE `ukogo` = '".$id."'"),0);
$k_page = k_page($k_post,$max);
$page = page($k_page);
$start = $max*$page-$max;
$stena = mysql_query("SELECT * FROM `komav` WHERE `ukogo` = '".$id."' ORDER BY `time` DESC LIMIT $start, $max");
while($st = mysql_fetch_assoc($stena))
{
echo '<div class="links">'.nick($st['avtor']).' ('.vremja($st['time']).')';
if($id == $user['id'] or $user['level'] >= 1) echo ' [<a href="'.$HOME.'/user/ava.php?act=delmsg&id='.$st['id'].'">уд</a>]';
echo '</div><div class="podmenu">'.bb($st['msg']).'</div>';
}
if($k_post < 1) {
echo '<div class="podmenu"><center><b>Сообщений пока еще нет!</b></center></div>';
}
if ($k_page>1) {
echo str(''.$HOME.'/user/ava.php?id='.$id.'&',$k_page,$page); // Вывод страниц
}else{
echo '<div class="links">» <a href="'.$HOME.'/user_'.$id.'">На страницу к '.$ank['login'].'</a></div>';
}
break;
case 'like':
$id = abs(intval($_GET['id']));
if(empty($ank['avatar'])) {
echo '<div class="title"><a href="'.$HOME.'/user_'.$id.'">'.$title.'</a> | Ошибка</div><div class="podmenu"><center><b>Аватара нет!</b></center></div>';
require_once ('../system/footer.php');
exit();
}
$photo_like = mysql_fetch_assoc(mysql_query("SELECT * FROM `ava_like` WHERE `ava` = '".$id."' and `kto` = '".$user['id']."'"));
if($photo_like == 0) {
mysql_query("INSERT INTO `ava_like` SET `kto` = '".$user['id']."',`ava` = '".$id."'");
header('Location: '.$HOME.'/ava_'.$id.'');
exit();
} else {
mysql_query("DELETE FROM `ava_like` WHERE `id` = '".$photo_like['id']."'");
header('Location: '.$HOME.'/ava_'.$id.'');
exit();
}
break;
case 'delmsg':
$id = abs(intval($_GET['id']));
$stenka = mysql_fetch_assoc(mysql_query("SELECT * FROM `komav` WHERE `id` = '".$id."'"));
$anks = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$stenka['ukogo']."'"));
if($stenka == 0) {
echo '<div class="title">Аватар | Ошибка</div><div class="podmenu"><center><b>Такого комментария не существует!</b></center></div>';
echo '<div class="podmenu"><a href="/user/ava.php?id='.$user['id'].'">Назад</a></div>';
require_once ('../system/footer.php');
exit();
}
if($anks['id'] == $user['id'] or $user['level'] >= 1) {
mysql_query("DELETE FROM `komav` WHERE `id` = '".$id."'");
header('Location: '.$HOME.'/user/ava.php?id='.$anks['id'].'');
exit();
} else {
header('Location: '.$HOME.'/user/ava.php?id='.$anks['id'].'');
exit();
}
break;
}
#####################################
}
//-----Подключаем низ-----//
require_once ('../system/footer.php');
?>