Файл: info.php
Строк: 463
<?php
require_once 'sys/inc/start.php';
require_once 'sys/inc/compress.php';
require_once 'sys/inc/sess.php';
require_once 'sys/inc/settings.php';
require_once 'sys/inc/db_connect.php';
require_once 'sys/inc/ipua.php';
require_once 'sys/inc/fnc.php';
require_once 'sys/inc/user.php';
if (isset($user)) {
$ank['id'] = $user['id'];
}
if (isset($_GET['id'])) {
$ank['id'] = intval($_GET['id']);
}
only_reg('index.php');
if ($ank['id'] == 0) {
$ank = get_user($ank['id']);
$set['title'] = $ank['nick'] . ' - анкета ';
require_once 'sys/inc/thead.php';
aut();
echo "$ank[group_name]<br />n";
if ($ank['ank_about_me'] != NULL) {
echo "О себе: $ank[ank_about_me]<br />";
}
if (isset($_SESSION['refer']) && $_SESSION['refer'] != NULL && otkuda($_SESSION['refer'])) {
echo "<div class='razd'><a href='$_SESSION[refer]'>" . otkuda($_SESSION['refer']) . "</a></div>n";
}
require_once 'sys/inc/tfoot.php';
exit;
}
$ank = get_user($ank['id']);
if (!$ank) {
header("Location: /index.php?" . SID);
exit;
}
$ank['rating'] = intval(@mysql_result(mysql_query("SELECT SUM(`rating`) FROM `user_voice2` WHERE `id_kont` = '$ank[id]'"), 0));
$set['title'] = $ank['nick'] . ' - анкета '; // заголовок страницы
require_once 'sys/inc/thead.php';
if ((!isset($_SESSION['refer']) || $_SESSION['refer'] == NULL) && isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != NULL &&
!preg_match('#info.php#', $_SERVER['HTTP_REFERER'])) {
$_SESSION['refer'] = str_replace('&', '&', preg_replace('#^http://[^/]*/#', '/', $_SERVER['HTTP_REFERER']));
}
if (isset($_GET['fav']) && isset($user)) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `bookmark_user` WHERE `id_user` = '" . $user['id'] . "' AND `id_people` = '" . $ank['id'] . "' LIMIT 1"), 0) == 0 && $_GET['fav'] == 1) {
mysql_query("INSERT INTO `bookmark_user` (`id_people`, `id_user`, `time`) VALUES ('$ank[id]', '$user[id]', '$time')");
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `bookmark_user` WHERE `id_user` = '" . $user['id'] . "' AND `id_people` = '" . $ank['id'] . "' LIMIT 1"), 0) == 1 && $_GET['fav'] == 0) {
mysql_query("DELETE FROM `bookmark_user` WHERE `id_user` = '$user[id]' AND `id_people` = '$ank[id]'");
}
header("Location: /info.php?id=$ank[id]");
exit;
}
if (isset($_POST['rating']) && isset($user) && $user['id'] != $ank['id'] && $user['money'] >= 50 && mysql_result(mysql_query("SELECT SUM(`rating`) FROM `user_voice2` WHERE `id_kont` = '$user[id]'"), 0) >= 0) {
$new_r = min(max(@intval($_POST['rating']), -5), 5);
mysql_query("DELETE FROM `user_voice2` WHERE `id_user` = '$user[id]' AND `id_kont` = '$ank[id]' LIMIT 1");
if ($new_r) {
mysql_query("INSERT INTO `user_voice2` (`rating`, `id_user`, `id_kont`) VALUES ('$new_r','$user[id]','$ank[id]')");
}
$ank['rating'] = intval(mysql_result(mysql_query("SELECT SUM(`rating`) FROM `user_voice2` WHERE `id_kont` = '$ank[id]'"), 0));
mysql_query("UPDATE `user` SET `rating` = '$ank[rating]' WHERE `id` = '$ank[id]' LIMIT 1");
if ($new_r > 0) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$ank[id]', '" . ($user['sex'] ? 'добавил' : 'добавила') . " Вам рейтинг', '$time')");
}
if ($new_r < 0) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$ank[id]', '" . ($user['sex'] ? 'убавил' : 'убавила') . " Вам рейтинг', '$time')");
}
if ($new_r == 0) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$ank[id]', '" . ($user['sex'] ? 'оставил' : 'оставила') . " нейтральный рейтинг', '$time')");
}
msg('Ваше мнение о пользователе успешно изменено');
}
$timediff = mysql_result(mysql_query("SELECT `time` FROM `user` WHERE `id` = '$ank[id]' LIMIT 1", $db), 0);
$oneMinute = 60;
$oneHour = 60 * 60;
$oneDay = 60 * 60 * 24;
$dayfield = floor($timediff / $oneDay);
$hourfield = floor(($timediff - $dayfield * $oneDay) / $oneHour);
$minutefield = floor(($timediff - $dayfield * $oneDay - $hourfield * $oneHour) / $oneMinute);
$secondfield = floor(($timediff - $dayfield * $oneDay - $hourfield * $oneHour - $minutefield * $oneMinute));
$sDaysLeft = $dayfield;
$sDaysText = "дней";
$nDaysLeftLength = strlen($sDaysLeft);
$d_1 = substr($sDaysLeft, -1, 1);
if (substr($sDaysLeft, -2, 1) != 1 && $nDaysLeftLength > 1) {
if ($d_1 == 2 || $d_1 == 3 || $d_1 == 4) {
$sDaysText = "дня";
} elseif ($d_1 == 1) {
$sDaysText = "день";
}
}
if ($nDaysLeftLength == 1) {
if ($d_1 == 2 || $d_1 == 3 || $d_1 == 4) {
$sDaysText = "дня";
} elseif ($d_1 == 1) {
$sDaysText = "день";
}
}
$sHoursLeft = $hourfield;
$sHoursText = "часов";
$nHoursLeftLength = strlen($sHoursLeft);
$h_1 = substr($sHoursLeft, -1, 1);
if (substr($sHoursLeft, -2, 1) != 1 && $nHoursLeftLength > 1) {
if ($h_1 == 2 || $h_1 == 3 || $h_1 == 4) {
$sHoursText = "часа";
} elseif ($h_1 == 1) {
$sHoursText = "час";
}
}
if ($nHoursLeftLength == 1) {
if ($h_1 == 2 || $h_1 == 3 || $h_1 == 4) {
$sHoursText = "часа";
} elseif ($h_1 == 1) {
$sHoursText = "час";
}
}
$sMinsLeft = $minutefield;
$sMinsText = "минут";
$nMinsLeftLength = strlen($sMinsLeft);
$m_1 = substr($sMinsLeft, -1, 1);
if ($nMinsLeftLength > 1 && substr($sMinsLeft, -2, 1) != 1) {
if ($m_1 == 2 || $m_1 == 3 || $m_1 == 4) {
$sMinsText = "минуты";
} else if ($m_1 == 1) {
$sMinsText = "минута";
}
}
if ($nMinsLeftLength == 1) {
if ($m_1 == 2 || $m_1 == 3 || $m_1 == 4) {
$sMinsText = "минуты";
} elseif ($m_1 == "1") {
$sMinsText = "минута";
}
}
$sSecsLeft = $secondfield;
$sSecsText = "секунд";
$s_1 = substr($sSecsLeft, -1, 1);
$nSecsLeftLength = strlen($sSecsLeft);
if (substr($sSecsLeft, -2, 1) != 1 && $nSecsLeftLength > 1) {
if ($s_1 == 2 || $s_1 == 3 || $s_1 == 4) {
$sSecsText = "секунды";
} elseif ($s_1 == 1) {
$sSecsText = "секунда";
}
}
if ($nSecsLeftLength == 1) {
if ($s_1 == 2 || $s_1 == 3 || $s_1 == 4) {
$sSecsText = "секунды";
} elseif ($sSecsLeft == "1") {
$sSecsText = "секунда";
}
}
$displaystring = "" .
$sDaysLeft . " " .
$sDaysText . " " .
$sHoursLeft . " " .
$sHoursText . " " .
$sMinsLeft . " " .
$sMinsText . " " .
$sSecsLeft . " " .
$sSecsText;
if ($timediff < 0) {
$displaystring = 'дата уже наступила';
}
title();
aut();
if (isset($_POST['password'])) {
$set_cook = $_POST['password'];
setcookie("passprofile$ank[id]", $set_cook);
if (isset($_POST['password']) && $_POST['password'] == $ank['profile_password']) {
header("Location: ?id=$ank[id]");
}
}
if ($ank['profile_access'] == 'only_me') {
if ($ank['id'] == $user['id'] && isset($user) || $user['level'] >= 3) {
} else {
echo "<div class='err'>";
echo "Доступ к профилю <b>$ank[nick]</b> закрыт.";
echo "</div>";
require_once 'sys/inc/tfoot.php';
exit();
}
} elseif ($ank['profile_access'] == 'friends') {
if ($ank['id'] == $user['id'] && isset($user) || $user['level'] >= 3 || $ank['id'] == $user['id'] && isset($user) || isset($umodd) || mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE (`user` = '$user[id]' AND `friends` = '$ank[id]') OR (`user` = '$ank[id]' AND `friends` = '$user[id]')"), 0) != 0) {
} else {
echo "<div class='err'>";
echo "Доступ к профилю <b>$ank[nick]</b> открыт только для друзей.";
echo "</div>";
require_once 'sys/inc/tfoot.php';
exit();
}
} elseif ($ank['profile_access'] == 'pass') {
if (isset($_COOKIE["passprofile$ank[id]"]) && $_COOKIE["passprofile$ank[id]"] == $ank['profile_password'] || $ank['id'] == $user['id'] && isset($user) || $user['level'] >= 3) {
} else {
if (isset($_POST['password']) && $_POST['password'] != $ank['profile_password']) {
$err[] = "Пароль неправильный.";
}
err();
echo "<form class = 'err' action='' method='post'>";
echo "Доступ к профилю <b>$ank[nick]</b> доступен только по паролю:<br/>";
echo "Пароль: <br/><input name='password' aria-required = 'true' aria-invalid = 'false' required = 'required' type = 'password' value=''/>";
echo "<button class = 'btn' name = 'submited'>";
echo "<img src = '/style/icons/tick.png' />";
echo "</button></form>";
require_once 'sys/inc/tfoot.php';
exit();
}
}
#Определение гостей
if (isset($user) && $user['id'] != $ank['id']) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `myguests` WHERE `id_ank` = '$ank[id]' AND `id_user`='$user[id]' LIMIT 5"), 0) == 0) {
mysql_query("INSERT INTO `myguests` (`id_ank`, `id_user`, `time`) VALUES ('$ank[id]', '$user[id]', '$time')");
} else {
$guest = mysql_fetch_array(mysql_query("SELECT * FROM `myguests` WHERE `id_ank` = '$ank[id]' AND `id_user`='$user[id]' LIMIT 5"));
mysql_query("UPDATE `myguests` SET `count` = '" . ($guest['count'] + 1) . "', `time`='$time' WHERE `id` = '$guest[id]' LIMIT 5");
}
}
echo "<div class = 'razd'>";
echo user($ank['id']);
echo "</div><table class = 'razd'><tr><td class = 'icon14'>";
avatar($ank['id'], '150');
if ($ank['welcome'] != NULL) {
echo "<div class = 'hello' style = 'padding-top: 0px!important;'>";
echo "<div class = 'hell'><div class = 'hell-img'></div>";
echo "<small><i>" . text::toOutput($ank['welcome']) . "</i></small>";
echo "</div></div>";
}
echo "</td><td class = 'null'>";
$stat = mysql_fetch_array(mysql_query("SELECT * FROM `stat` WHERE `user_id` = '" . $ank['id'] . "'"));
if (isset($stat['user_id']) AND $stat['stat_id'] >= 1) {
$ost = TIME - $stat['time'];
if ($ost > 604800) {
mysql_query("UPDATE `stat` SET `stat_id` = '0', `time` = '0' WHERE `user_id` = '$ank[id]'");
}
echo "<span class = 'right'><img src = '/style/stat/$stat[stat_id].png' /></span>";
}
echo "</td></tr></table>";
if (is_file(H . "/sys/avatar/$ank[id].gif") || is_file(H . "/sys/avatar/$ank[id].jpg") || is_file(H . "/sys/avatar/$ank[id].png")) {
echo "<div class = 'razd'>";
echo "<div class = 'buttons'><div class = 'tiptip'>";
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_like` WHERE `id_komm` = '$ank[id]'"), 0);
echo "<a href = '/user/avatar_comm.php?id=$ank[id]' class = 'button' title = 'Комментировать'><span class = 'icon icon42' /></a>";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_like` WHERE `id_komm` = '$ank[id]' AND `id_user` = '$user[id]' LIMIT 1"), 0) == 0) {
echo "<a href = '/user/avatar_like.php?id=$ank[id]&likes' class = 'button' title = 'Мне нравится'><span class = 'icon icon104' /></a>";
} else {
echo "<a href = '/user/avatar_like.php?id=$ank[id]&unlikes' class = 'button on' title = 'Уже не нравится'><span class = 'icon icon104' /></a>";
}
echo "</div></div>";
$k_p = mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_comments` WHERE `avatar_id` = $ank[id] ", $db), 0);
if ($k_p != 0) {
echo "<span style = 'padding: 4px;'>";
echo "<a href='/user/avatar_comm.php?id=$ank[id]'><img src = '/style/icons/comment_white.png' /><small><font color = 'grey'>$k_p</font></small></a> ";
echo "</span>";
}
$kum = @mysql_result(mysql_query("SELECT `id_user` FROM `avatar_like` WHERE `id_komm` = '$ank[id]'"), 0);
$kom = @mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id`='$kum' LIMIT 1"), 0);
$kem = $like - 1;
if ($kom == $user['nick']) {
$kom = "Вам";
} else {
$kom = @mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id`='$kum' LIMIT 1"), 0);
}
if ($like == 1) {
echo "<div>";
echo "<small><font color = 'grey'>Понравилось только <a href='/info.php?id=$kum'>$kom</a></font></small>";
echo "</div>";
} elseif ($like == 2) {
echo "<div>";
echo "<small><font color = 'grey'>Понравилось <a href = '/info.php?id=$kum'>$kom</a> и <a href = '/user/avatar_like_all.php?id=$ank[id]'> ещё $kem пользователю.</a></font></small>";
echo "</div>";
} elseif ($like >= 3) {
echo "<div>";
echo "<small><font color = 'grey'>Понравилось <a href = '/info.php?id=$kum'>$kom</a> и <a href = '/user/avatar_like_all.php?id=$ank[id]'> ещё $kem пользователям.</a></font></small>";
echo "</div>";
}
echo "</div>";
}
if (isset($user) && $user['id'] != $ank['id']) {
echo "<div class = 'blok'>";
if (!isset($_GET['smenu'])) {
echo "<div class = 'right'><a href='/info.php?id=$ank[id]&smenu'><img src = '/style/icons/trios.png' /><font color = 'grey'>Еще</font></a></div>";
echo "<form method = 'post' action = '/mail.php?id=$ank[id]'>";
echo "<div class = 'button_blue'>";
echo "<button><img src = '/style/icons/mail.png'/> Отправить сообщение</button>";
echo "</div></form>";
} else {
echo "<div class = 'right'><a href='/info.php?id=$ank[id]'><img src = '/style/icons/trio.png' /></a></div>";
echo "<form method = 'post' action = '/mail.php?id=$ank[id]'>";
echo "<div class = 'button_blue'>";
echo "<button><img src = '/style/icons/mail.png'/> Отправить сообщение</button>";
echo "</div></form>";
if (isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE `user` = '$user[id]' AND `friends` = '$ank[id]'"), 0) == 0) {
echo "<form method = 'post' action = '/user/friends/add.php?id=$ank[id]'>";
echo "<div class = 'button_blue'>";
echo "<button><img src = '/style/icons/user.png'/> Предложить дружбу</button>";
echo "</div></form>";
} else {
echo "<form method = 'post' action = '/user/friends/new.php?del=$ank[id]'>";
echo "<div class = 'button_blue'>";
echo "<button><img src = '/style/icons/user.png'/> Удалить из друзей</button>";
echo "</div></form>";
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `bookmark_user` WHERE `id_user` = '" . $user['id'] . "' AND `id_people` = '" . $ank['id'] . "' LIMIT 1"), 0) == 0) {
echo "<form method = 'post' action = '?id=$ank[id]&fav=1'>";
echo "<div class = 'button_blue'>";
echo "<button><img src = '/style/icons/star1.png'/> Добавить в закладки</button>";
echo "</div></form>";
} else {
echo "<form method = 'post' action = '?id=$ank[id]&fav=0'>";
echo "<div class = 'button_blue'>";
echo "<button><img src = '/style/icons/star0.png'/> Удалить из закладок</button>";
echo "</div></form>";
}
if (isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user_blacklist` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]'"), 0) == 0) {
echo "<form method = 'post' action = '/user/blacklist/?add=$ank[id]'>";
echo "<div class = 'button_blue'>";
echo "<button><img src = '/style/icons/ban.png'/> Заблокировать</button>";
echo "</div></form>";
}
if ($ank['id'] != $user['id']) {
echo "<form method = 'post' action = '/gifts/?id=$ank[id]&do'>";
echo "<div class = 'button_blue'>";
echo "<button><img src = '/style/icons/gifts.png'/> Отправить подарок</button>";
echo "</div></form>";
}
}
echo "</div>";
}
$razdel = @$_GET['act'];
switch ($razdel) {
case 'wall':
echo "<div class = 'tabs t_bar clear_fix'>";
echo "<a href = '/info.php?id=$ank[id]'>Профиль</a>";
echo "<a href = '/info.php?id=$ank[id]&act=files'>Файлы</a>";
echo "<a href = '/info.php?id=$ank[id]&act=wall' class = 'active'>Стена</a>";
echo "</div>";
require_once 'user/wall/index.php';
break;
case 'files':
echo "<div class = 'tabs t_bar clear_fix'>";
echo "<a href = '/info.php?id=$ank[id]'>Профиль</a>";
echo "<a href = '/info.php?id=$ank[id]&act=files' class = 'active'>Файлы</a>";
echo "<a href = '/info.php?id=$ank[id]&act=wall'>Стена</a>";
echo "</div>";
require_once 'user/files/include.php';
break;
default:
echo "<div class = 'tabs t_bar clear_fix'>";
echo "<a href = '/info.php?id=$ank[id]' class = 'active'>Профиль</a>";
echo "<a href = '/info.php?id=$ank[id]&act=files'>Файлы</a>";
echo "<a href = '/info.php?id=$ank[id]&act=wall'>Стена</a>";
echo "</div>";
require_once 'user/profile/menu.php';
break;
}
if (isset($user) && $user['id'] != $ank['id'] && $user['money'] >= 50 && mysql_result(mysql_query("SELECT SUM(`rating`) FROM `user_voice2` WHERE `id_kont` = '$user[id]'"), 0) >= 0) {
echo "<b>Ваше отношение:</b><br />n";
$my_r = intval(@mysql_result(mysql_query("SELECT `rating` FROM `user_voice2` WHERE `id_user` = '$user[id]' AND `id_kont` = '$ank[id]'"), 0));
echo "<form method='post' class = 'razd' action='?id=$ank[id]&$passgen'>n";
echo "<select name='rating'>n";
echo "<option value='5' " . ($my_r == 5 ? 'selected="selected"' : null) . "> +5 </option>n";
echo "<option value='4' " . ($my_r == 4 ? 'selected="selected"' : null) . "> +4 </option>n";
echo "<option value='3' " . ($my_r == 3 ? 'selected="selected"' : null) . "> +3 </option>n";
echo "<option value='2' " . ($my_r == 2 ? 'selected="selected"' : null) . "> +2 </option>n";
echo "<option value='1' " . ($my_r == 1 ? 'selected="selected"' : null) . "> +1 </option>n";
echo "<option value='0' " . ($my_r == 0 ? 'selected="selected"' : null) . "> 0 </option>n";
echo "<option value='-1' " . ($my_r == -1 ? 'selected="selected"' : null) . "> -1 </option>n";
echo "<option value='-2' " . ($my_r == -2 ? 'selected="selected"' : null) . "> -2 </option>n";
echo "<option value='-3' " . ($my_r == -3 ? 'selected="selected"' : null) . "> -3 </option>n";
echo "<option value='-4' " . ($my_r == -4 ? 'selected="selected"' : null) . "> -4 </option>n";
echo "<option value='-5' " . ($my_r == -5 ? 'selected="selected"' : null) . "> -5 </option>n";
echo "</select>n";
echo "<button class = 'btn'>";
echo "<img src = '/style/icons/tick.png' />";
echo "</button>";
echo "</form>n";
}
if (isset($_SESSION['refer']) && $_SESSION['refer'] != NULL && otkuda($_SESSION['refer'])) {
echo "<div class = 'razd'>";
echo "<img src = '/style/icons/left.png' /> <a href='$_SESSION[refer]'>" . otkuda($_SESSION['refer']) . "</a>";
echo "</div>";
}
require_once 'sys/inc/tfoot.php';