Файл: sys/fnc/aut.php
Строк: 86
<?php
function aut() {
global $set;
$rekl = mysql_result(mysql_query("SELECT COUNT(*) FROM `rekl` WHERE `sel` = '1'"), 0);
if ($rekl > 0) {
echo "<div class='rekl'>n";
rekl(1);
echo "</div>n";
}
global $user;
if (isset($user)) {
if (@$_GET['del'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `mess` WHERE `id` = '" . intval($_GET['del']) . "'"), 0) == 1) {
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `mess` WHERE `id` = '" . intval($_GET['del']) . "' LIMIT 1"));
mysql_query("DELETE FROM `mess` WHERE `id` = '$post[id]'");
}
$q = mysql_result(mysql_query("SELECT COUNT(*) FROM `mess` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
if ($q != 0) {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `mess` WHERE `id_kont` = '" . $user['id'] . "'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$qis = mysql_query("SELECT * FROM `mess` WHERE `id_kont` = '" . $user['id'] . "' ORDER BY id DESC LIMIT 1");
while ($post = mysql_fetch_array($qis)) {
echo "<div class='new'>";
echo "<div class = 'right' id = 'hide'>";
echo "<a href = '?del=$post[id]' title = 'Отметить как прочитанное'><img src = '/style/icons/hide.png' /></a>";
echo "</div>";
echo "<img src = '/style/icons/mail_red.png' /> " . output_text($post['msg']) . "<br />";
echo "</div>";
}
}
}
if (isset($user)) {
$mail = mysql_result(mysql_query("SELECT COUNT(DISTINCT `mail`.`id_user`) FROM `mail` LEFT JOIN `users_konts` ON `mail`.`id_user` = `users_konts`.`id_kont` AND `users_konts`.`id_user` = '$user[id]' WHERE `mail`.`id_kont` = '$user[id]' AND (`users_konts`.`type` IS NULL OR `users_konts`.`type` = 'common' OR `users_konts`.`type` = 'favorite') AND `mail`.`read` = '0'"), 0);
$k_new = mysql_result(mysql_query("SELECT COUNT(`mail`.`id`) FROM `mail` LEFT JOIN `users_konts` ON `mail`.`id_user` = `users_konts`.`id_kont` AND `users_konts`.`id_user` = '$user[id]' WHERE `mail`.`id_kont` = '$user[id]' AND (`users_konts`.`type` IS NULL OR `users_konts`.`type` = 'common' OR `users_konts`.`type` = 'favorite') AND `mail`.`read` = '0'"), 0);
if ($k_new == 0) {
$k_new = "";
} else {
$k_new = "" . mysql_result(mysql_query("SELECT COUNT(`mail`.`id`) FROM `mail` LEFT JOIN `users_konts` ON `mail`.`id_user` = `users_konts`.`id_kont` AND `users_konts`.`id_user` = '$user[id]' WHERE `mail`.`id_kont` = '$user[id]' AND (`users_konts`.`type` IS NULL OR `users_konts`.`type` = 'common' OR `users_konts`.`type` = 'favorite') AND `mail`.`read` = '0'"), 0) . "";
}
echo "<a href='/info.php'><table class = 'auts'><tr><td class = 'icon14'>";
echo "<img class='Photo' src='/sys/avatar/";
if (is_file(H . "sys/avatar/$user[id].gif")) {
echo "$user[id].gif";
} elseif (is_file(H . "sys/avatar/$user[id].jpg")) {
echo "$user[id].jpg";
} elseif (is_file(H . "sys/avatar/$user[id].png")) {
echo "$user[id].png";
} else {
echo "avatar.png";
}
echo "' />";
echo "</td><td class = 'null'><span class='Name'>";
echo text::gradient("$user[nick]", "$user[ncolor]", "$user[ncolor2]");
echo "</span><br />";
if ($k_new == 1 || $k_new >= 5 && $k_new <= 21 || $k_new >= 25 && $k_new <= 1111111111) {
$mes = "новое сообщение";
} elseif ($k_new >= 2 && $k_new <= 4 || $k_new >= 22 && $k_new <= 24) {
$mes = "новых сообщения";
} elseif ($k_new >= 5 && $k_new <= 20) {
$mes = "новых сообщений";
}
if ($k_new == 0) {
echo "";
} else {
echo "<span class = 'right tiptip'>";
echo "<a href = '/mails.php' class = 'button on' title = 'У Вас $k_new $mes'><span class = 'icon icon125'></span><b>$k_new</b></a>";
echo "</span>";
}
if ($user['welcome'] != NULL) {
echo "<small><i>" . text::toOutput($user['welcome']) . "</i></small>";
}
echo "</td></tr></table></a>";
} else {
echo "<div class = 'razd'><div class = 'tiptip'>";
echo "<a href = '/aut.php' class = 'button left' title = 'Авторизоваться'>Вход</a>";
echo "<a href = '/reg.php' class = 'button right' title = 'Зарегистрироваться'>Регистрация</a>";
echo "<br />Вы не авторизованы... Функционал сайта ограничен.";
echo "</div></div>";
}
if (isset($user)) {
$leader = mysql_fetch_array(mysql_query("SELECT * FROM `leader`"));
if ($leader['time'] >= TIME) {
echo "<table class = 'leader'><tr><td class = 'icon14'>";
avatar($leader['id'], '48');
echo "</td><td class = 'null'>";
user($leader['id']);
echo "<a href = '/pages/shop/'> ".img('shopping-basket--arrow.png')."</a>";
echo "</td></tr></table>";
}
}
}