Файл: user/mail/index.php
Строк: 960
<?php
/* DCMS S (Special)
* Версия файла 0.0.1
* Дата последнего редактирования 29.10.2015
* Модифицировал densnet
*/
require_once '../../sys/inc/start.php';
require_once H . 'sys/inc/compress.php';
require_once H . 'sys/inc/sess.php';
require_once H . 'sys/inc/settings.php';
require_once H . 'sys/inc/db_connect.php';
require_once H . 'sys/inc/ipua.php';
require_once H . 'sys/inc/fnc.php';
require_once H . 'sys/inc/user.php';
user::only_reg();
function msg_mail($msg) {
echo "<div class = 'msgs'>$msg</div>";
}
$q = mysql_query("SELECT * FROM `mail` WHERE `id_user` = '$user[id]' AND `favorite` = '1'");
$array = array();
while ($post = mysql_fetch_array($q)) {
$cont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id` = '$post[id_cont]'"));
$ank = user::get_user($cont['id_ank']);
foreach ($array AS $key => $value) {
if ($key != NULL && $key == $ank['id']) {
$trim = 1;
}
}
if (!isset($trim)) {
$array[$ank['id']] = 0;
}
}
foreach ($array AS $key => $value) {
$ank = user::get_user($key);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'favorite'"), 0) == 0) {
mysql_query("INSERT INTO `mail_conts` (`id_user`, `id_ank`, `time`, `nick`, `type`) VALUES ('$user[id]', '$ank[id]', '$time', '$ank[nick]', 'favorite')");
}
}
$q = mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `type` != 'all'");
while ($post = mysql_fetch_array($q)) {
if ($post['type'] == 'favorite') {
$cont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$post[id_ank]' AND `type` = 'all'"));
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` INNER JOIN `mail` ON `mail`.`id_cont`=`mail_conts`.`id` WHERE `mail`.`favorite` = '1' AND `mail`.`id_user` = '$user[id]' AND (`mail_conts`.`type` = 'all' OR `mail_conts`.`type` = 'arhive') AND `mail`.`id_cont` = '$cont[id]'"), 0);
} else {
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id_cont` = '$post[id]'"), 0);
}
if ($count == 0) {
mysql_query("DELETE FROM `mail_conts` WHERE `id` = '$post[id]'");
}
}
if (isset($_GET['mail_access'])) {
$set['title'] = 'Настройки почты';
require_once H . 'sys/inc/thead.php';
title();
aut();
if (isset($_POST['mask'])) {
if ($_POST['mask'] == 2) {
$sm = 2;
} else {
$sm = 1;
}
mysql_query("UPDATE `user` SET `set_mail` = '$sm' WHERE `id` = '$user[id]'");
header("Location: /user/mail/");
exit;
}
err();
echo "<div class = 'comm'><center><b>Настройки приватности</b></center></div>";
echo "<form method='post' class = 'comm'>";
echo "<b>Кто может Вам писать?</b><br />";
echo "<input type='radio' name='mask' value='1'" . ($user['set_mail'] == 1 ? " checked='checked'" : NULL) . "/><img src = '/style/icons/vol.png'/> Все<br/>n
<input type='radio' name='mask' value='2'" . ($user['set_mail'] == 2 ? " checked='checked'" : NULL) . " /><img src = '/style/icons/users.png'/> Только друзья <br/>n
<button class = 'button-green'>Сохранить</button>n
</form>n
<div class='comm'>Все существующие контакты смогут вам писать независимо от настроек.<br/>n
Нежелательные контакты можете занести в черный список.</div>";
echo "<div class = 'comm'><a href = '/user/mail/' style = 'color:#88C057;'><img src = '/style/icons/left.png' /> Назад</a></div>";
require_once H . 'sys/inc/tfoot.php';
}
if (isset($_GET['mail_admin_access'])) {
user::access('adm_mysql', null, 'index.php?' . SID);
$set['title'] = 'Админка почты';
require_once H . 'sys/inc/thead.php';
title();
aut();
if (isset($_POST['adm'])) {
if ($_POST['adm'] == 2) {
$sm = 2;
} else {
$sm = 1;
}
mysql_query("UPDATE `user` SET `adm_set` = '$sm' WHERE `id` = '$user[id]'");
header("Location:/user/mail/");
exit;
}
err();
echo "<div class = 'comm'><center><b>Настройка почты создателя</b></center></div>";
echo "<form method='post' class = 'comm'>";
echo "Ваша почта открыта:<br/>";
echo "<input type='radio' name='adm' value='1'" . ($user['adm_set'] == 1 ? " checked='checked'" : NULL) . "/> Да<br/>n
<input type='radio' name='adm' value='2'" . ($user['adm_set'] == 2 ? " checked='checked'" : NULL) . " /> Нет<br/>n
<button class = 'button-green'>Сохранить</button>n
</form>n
<div class='comm'>Все существующие контакты смогут вам писать независимо от настроек.<br/></div>";
echo "<div class = 'comm'><a href = '/user/mail/' style = 'color:#88C057;'><img src = '/style/icons/left.png' /> Назад</a></div>";
require_once H . 'sys/inc/tfoot.php';
}
if (isset($_GET['new_message'])) {
$set['title'] = 'Написать сообщение';
require_once H . 'sys/inc/thead.php';
title();
aut();
if ($_GET['new_message'] != NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '" . intval($_GET['new_message']) . "'"), 0) != 0 && is_numeric(intval($_GET['new_message']))) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '" . intval($_GET['new_message']) . "'"));
$anku = $ank;
}
if (isset($ank) && $ank['set_mail'] == 2 && 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 && mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$ank[id]' AND `id_ank` = '$user[id]' AND `type` = 'all'"), 0) == 0) {
echo "<div class = 'errs'>Операция невозможна.<br />Писать пользователю могут только друзья.</div>";
echo "<div class = 'comm'><a href = '/info.php?id=$ank[id]' style = 'color:#88C057;'><img src = '/style/icons/left.png' /> Назад</a></div>";
require_once H . 'sys/inc/tfoot.php';
}
if (isset($ank) && @$ank['adm_set'] == 2 && mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$ank[id]' AND `id_ank` = '$user[id]' AND `type` = 'all'"), 0) == 0) {
echo "<div class = 'comm'>";
echo "Извините, но у администрации нет возможности читать все письма обитателей. Мы просто не успеваем это делать.<br /><br />";
echo "Ответы на многие вопросы Вы можете найти в <a href='/modules/info/'>Справке</a>.<br /><br />";
echo "Если там нет ответа на Ваш вопрос, обратитесь к <a href='/modules/info/?act=help'>Онлайн-помощникам</a>.<br /><br />";
//echo "Также можете обратиться в сообщество <a>help</a>.<br /><br />";
//echo "Со всеми проблемами обращайтесь в сообщество <a href='/'>Support</a> (Служба поддержки пользователей)<br /><br />";
//echo "Предложение можно сделать в сообществе <a href='/'>ToDo</a>.<br /><br />Спасибо за понимание!";
echo "</div>n";
echo "<div class = 'comm'><a href = '/info.php?id=$ank[id]' style = 'color:#88C057;'><img src = '/style/icons/left.png' /> Назад</a></div>n";
require_once H . 'sys/inc/tfoot.php';
}
if (isset($_POST['nick']) && isset($_POST['msg'])) {
$msg = $_POST['msg'];
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `nick` = '" . htmlspecialchars($_POST['nick']) . "'"), 0) != 0) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `nick` = '" . htmlspecialchars($_POST['nick']) . "'"));
$anku = $ank;
}
if (!isset($ank)) {
$err[] = "Пользователь не найден";
}
if (text::utf8_strlen($msg) > 10024) {
$err[] = 'Сообщение превышает 10024 символа';
}
if (text::utf8_strlen($msg) < 2) {
$err[] = 'Слишком короткое сообщение';
}
if ($user['id'] == 0) {
$err[] = 'Ошибка! Системе писать нельзя.';
}
if (!isset($err)) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$ank[id]' AND `id_ank` = '$user[id]' AND `type` = 'all'"), 0) == 0) {
mysql_query("INSERT INTO `mail_conts` (`id_user`, `id_ank`, `time`, `nick`, `time_last`, `count`) VALUES ('$ank[id]', '$user[id]', '$time', '$user[nick]', '$time', '1')");
mysql_query("INSERT INTO `mail` SET `id_user` = '$ank[id]', `id_cont` = '" . mysql_insert_id() . "', `msg` = '" . mysql_real_escape_string($msg) . "', `time` = '$time', `type` = 'to', `read` = '0'");
} else {
$acont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$ank[id]' AND `id_ank` = '$user[id]' AND `type` = 'all'"));
mysql_query("INSERT INTO `mail` SET `id_user` = '$ank[id]', `id_cont` = '$acont[id]', `msg` = '" . mysql_real_escape_string($msg) . "', `time` = '$time', `type` = 'to', `read` = '0'");
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id_cont` = '$acont[id]' AND `read` = '0'"), 0);
mysql_query("UPDATE `mail_conts` SET `time_last` = '$time', `count` = '$count' WHERE `id` = '$acont[id]'");
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"), 0) == 0) {
mysql_query("INSERT INTO `mail_conts` (`id_user`, `id_ank`, `time`, `nick`, `time_last`) VALUES ('$user[id]', '$ank[id]', '$time', '" . mysql_real_escape_string($ank[nick]) . "', '$time')");
$hid = mysql_insert_id();
mysql_query("INSERT INTO `mail` SET `id_user` = '$user[id]', `id_cont` = '" . mysql_insert_id() . "', `msg` = '" . mysql_real_escape_string($msg) . "', `time` = '$time', `type` = 'at', `read` = '0'");
} else {
$ucont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"));
mysql_query("UPDATE `mail_conts` SET `time_last` = '$time' WHERE `id` = '$ucont[id]'");
mysql_query("INSERT INTO `mail` SET `id_user` = '$user[id]', `id_cont` = '$ucont[id]', `msg` = '" . mysql_real_escape_string($msg) . "', `time` = '$time', `type` = 'at', `read` = '0'");
$hid = $ucont['id'];
}
header("Location:?cid=$hid");
exit;
}
} else {
if ($_GET['new_message'] != NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '" . intval($_GET['new_message']) . "'"), 0) != 0 && is_numeric(intval($_GET['new_message']))) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '" . intval($_GET['new_message']) . "'"));
$anku = $ank;
}
}
err();
echo "<form method = 'post' class = 'comm'>";
echo "<b>Кому:</b><br />";
if (isset($ank['id'])) {
echo "<b>$ank[nick]</b> <input type = 'hidden' name = 'nick' value = '$ank[nick]'/>";
} else {
echo "<input type = 'text' value = '' name = 'nick'>";
}
echo "<br />";
echo "<textarea name = 'msg'></textarea><br />";
echo "<input type = 'hidden' name = 'mdp' value = '" . md5($user['pass']) . "'/>";
echo "<button class = 'button-green'>Отправить</button>";
echo "</form>";
echo "<div class = 'comm'><a href = '/user/mail/' style = 'color:#88C057;'><img src = '/style/icons/left.png' /> Назад</a></div>";
require_once H . 'sys/inc/tfoot.php';
}
if (isset($_GET['cid']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id` = '" . intval($_GET['cid']) . "' AND `id_user` = '$user[id]'"), 0) != 0) {
$cont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id` = '" . intval($_GET['cid']) . "' AND `id_user` = '$user[id]'"));
mysql_query("UPDATE `mail_conts` SET `count` = '0' WHERE `id` = '$cont[id]'");
$ank = user::get_user($cont['id_ank']);
if ($cont['type'] == 'favorite' || $cont['type'] == 'arhive') {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"), 0) != 0) {
$cont2 = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"));
$fl = 1;
if ($cont['type'] == 'favorite') {
$flf = 1;
}
}
}
$set['title'] = 'Переписка с ' . $cont['nick'];
require_once H . 'sys/inc/thead.php';
title();
if (isset($_GET['reply']) && intval($_GET['reply']) != NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id_user` = '$user[id]' AND `id_cont` = '$cont[id]' AND `id` = '" . intval($_GET['reply']) . "' LIMIT 1"), 0) != 0) {
$msg = mysql_fetch_array(mysql_query("SELECT * FROM `mail` WHERE `id_user` = '$user[id]' AND `id_cont` = '$cont[id]' AND `id` = '" . intval($_GET['reply']) . "'"));
if ($msg['type'] == 'to') {
aut();
err();
echo "<form class = 'comm' method = 'post' action = '?cid=$cont[id]'>";
echo "<b>Кому:</b> ";
echo "<b>$ank[nick]</b><br />" . text::toOutput($msg['msg']) . "<br />";
if ($ank['id'] != 0) {
?>
<textarea name="msg"></textarea><br />
<input type="hidden" name="mdp" value="<?php echo md5($user['pass']); ?>"/>
<button class="button-green">Отправить</button>
<?php
echo "</form>";
echo "<div class = 'comm'><a href = '/user/mail/' style = 'color:#88C057;'><img src = '/style/icons/left.png' /> Назад</a></div>";
} else {
echo '<div class = "err">Системе писать запрещено!</div>';
}
require_once H . 'sys/inc/tfoot.php';
}
}
// помечаем сообщения как прочитанные
mysql_query("UPDATE `mail` SET `read` = '1' WHERE `id_cont` = '$cont[id]' AND `id_user` = '$user[id]'");
// удаляем сообщение
if (isset($_GET['delete']) && intval($_GET['delete']) != NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id` = '" . intval($_GET['delete']) . "' AND `id_user` = '$user[id]' AND `id_cont` = '$cont[id]' LIMIT 1"), 0) != 0) {
if ($cont['type'] == 'trash') {
mysql_query("DELETE FROM `mail` WHERE `id` = '" . intval($_GET['delete']) . "' AND `id_user` = '$user[id]'");
} else {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'trash'"), 0) == 0) {
mysql_query("INSERT INTO `mail_conts` (`id_user`, `id_ank`, `time`, `nick`, `type`) VALUES ('$user[id]', '$ank[id]', '$time', '$ank[nick]', 'trash')");
mysql_query("UPDATE `mail` SET `id_cont` = '" . mysql_insert_id() . "' WHERE `id` = '" . intval($_GET['delete']) . "'");
} else {
$tcont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'trash'"));
mysql_query("UPDATE `mail` SET `id_cont` = '$tcont[id]' WHERE `id` = '" . intval($_GET['delete']) . "'");
}
}
header("Location:?cid=$cont[id]");
exit;
}
if (($cont['type'] == 'all' || $cont['type'] == 'arhive' || $cont['type'] == 'favorite') && isset($_GET['favorite']) && intval($_GET['favorite']) != NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id` = '" . intval($_GET['favorite']) . "' AND `id_user` = '$user[id]' LIMIT 1"), 0) != 0) {
$fav = mysql_fetch_array(mysql_query("SELECT * FROM `mail` WHERE `id` = '" . intval($_GET['favorite']) . "' AND `id_user` = '$user[id]' LIMIT 1"));
$fcont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id` = '$fav[id_cont]' AND `id_user` = '$user[id]'"));
if ($fcont['type'] == 'all' || $fcont['type'] == 'arhive') {
if ($fav['favorite'] == 1) {
$fav_new = 0;
} else {
$fav_new = 1;
}
mysql_query("UPDATE `mail` SET `favorite` = '$fav_new' WHERE `id` = '$fav[id]'");
} elseif ($cont2['id'] == $fcont['id']) {
mysql_query("UPDATE `mail` SET `favorite` = '0' WHERE `id` = '$fav[id]'");
}
}
if (isset($_GET['reset']) && intval($_GET['reset']) != NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id` = '" . intval($_GET['reset']) . "' AND `id_user` = '$user[id]' AND `id_cont` = '$cont[id]' LIMIT 1"), 0) != 0) {
if ($cont['type'] == 'trash') {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"), 0) == 0) {
mysql_query("INSERT INTO `mail_conts` (`id_user`, `id_ank`, `time`, `nick`, `type`) VALUES ('$user[id]', '$ank[id]', '$time', '$ank[nick]', 'all')");
mysql_query("UPDATE `mail` SET `id_cont` = '" . mysql_insert_id() . "' WHERE `id` = '" . intval($_GET['reset']) . "'");
} else {
$tcont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"));
mysql_query("UPDATE `mail` SET `id_cont` = '$tcont[id]' WHERE `id` = '" . intval($_GET['reset']) . "'");
}
}
header("Location:?cid=$cont[id]");
exit;
}
if (isset($_GET['in_arhive']) && $cont['type'] == 'all') {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'arhive'"), 0) == 0) {
mysql_query("UPDATE `mail_conts` SET `type` = 'arhive' WHERE `id` = '$cont[id]'");
} else {
$tcont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'arhive'"));
mysql_query("UPDATE `mail` SET `id_cont` = '$tcont[id]' WHERE `id_cont` = '$cont[id]'");
mysql_query("DELETE FROM `mail_conts` WHERE `id` = '$cont[id]'");
}
$_SESSION['msg'] = "Контакт <b>$cont[nick]</b> успешно перенесен в архив";
header("Location: /user/mail/");
exit;
}
if (isset($_GET['in_all']) && $cont['type'] == 'arhive') {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"), 0) == 0) {
mysql_query("UPDATE `mail_conts` SET `type` = 'all' WHERE `id` = '$cont[id]'");
} else {
$tcont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"));
mysql_query("UPDATE `mail` SET `id_cont` = '$tcont[id]' WHERE `id_cont` = '$cont[id]'");
mysql_query("DELETE FROM `mail_conts` WHERE `id` = '$cont[id]'");
}
$_SESSION['msg'] = "Контакт <b>$cont[nick]</b> успешно перенесен";
header("Location: /user/mail/");
exit;
}
if (isset($_GET['in_trash']) && $cont['type'] != 'favorite') {
if ($cont['type'] == 'trash') {
mysql_query("DELETE FROM `mail_conts` WHERE `id` = '$cont[id]'");
mysql_query("DELETE FROM `mail` WHERE `id_cont` = '$cont[id]'");
$_SESSION['msg'] = "Контакт <b>$cont[nick]</b> успешно удален";
} else {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'trash'"), 0) == 0) {
mysql_query("UPDATE `mail_conts` SET `type` = 'trash' WHERE `id` = '$cont[id]'");
} else {
$tcont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'trash'"));
mysql_query("UPDATE `mail` SET `id_cont` = '$tcont[id]' WHERE `id_cont` = '$cont[id]'");
mysql_query("DELETE FROM `mail_conts` WHERE `id` = '$cont[id]'");
$_SESSION['msg'] = "Контакт <b>$cont[nick]</b> успешно перенесен в корзину";
}
}
header("Location:/user/mail/");
exit;
}
if (isset($_GET['out_trash'])) {
if ($cont['type'] == 'trash') {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"), 0) == 0) {
mysql_query("UPDATE `mail_conts` SET `type` = 'all' WHERE `id` = '$cont[id]'");
} else {
$tcont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"));
mysql_query("UPDATE `mail` SET `id_cont` = '$tcont[id]' WHERE `id_cont` = '$cont[id]'");
mysql_query("DELETE FROM `mail_conts` WHERE `id` = '$cont[id]'");
$_SESSION['msg'] = "Контакт <b>$cont[nick]</b> успешно восстановлен";
}
$_SESSION['msg'] = "Контакт <b>$cont[nick]</b> успешно восстановлен";
}
header("Location:/user/mail/");
exit;
}
if (isset($_POST['msg']) && $ank['id'] != 0 && $_POST['mdp'] == md5($user['pass'])) {
$msg = $_POST['msg'];
if (text::utf8_strlen($msg) > 10024) {
$err[] = 'Сообщение превышает 10024 символа';
}
if (text::utf8_strlen($msg) < 2) {
$err[] = 'Слишком короткое сообщение';
}
//$mat=text::antimat($msg);
//if ($mat)$err[]='В тексте сообщения обнаружен мат: '.$mat;
if (!isset($err) && mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id_user` = '$user[id]' AND `id_cont` = '" . (!isset($fl) ? "$cont[id]" : "$cont2[id]") . "' AND `time` > '" . ($time - 360) . "' AND `msg` = '" . mysql_real_escape_string($msg) . "'"), 0) == 0) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$ank[id]' AND `id_ank` = '$user[id]' AND `type` = 'all'"), 0) == 0) {
mysql_query("INSERT INTO `mail_conts` (`id_user`, `id_ank`, `time`, `nick`, `time_last`, `count`) VALUES ('$ank[id]', '$user[id]', '$time', '$user[nick]', '$time', '1')");
mysql_query("INSERT INTO `mail` SET `id_user` = '$ank[id]', `id_cont` = '" . mysql_insert_id() . "', `msg` = '" . mysql_real_escape_string($_POST['msg']) . "', `time` = '$time', `type` = 'to', `read` = '0'");
} else {
$acont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$ank[id]' AND `id_ank` = '$user[id]' AND `type` = 'all'"));
mysql_query("INSERT INTO `mail` SET `id_user` = '$ank[id]', `id_cont` = '$acont[id]', `msg` = '" . mysql_real_escape_string($_POST['msg']) . "', `time` = '$time', `type` = 'to', `read` = '0'");
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id_cont` = '$acont[id]' AND `read` = '0'"), 0);
mysql_query("UPDATE `mail_conts` SET `time_last` = '$time', `count` = '$count' WHERE `id` = '$acont[id]'");
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"), 0) == 0) {
mysql_query("INSERT INTO `mail_conts` (`id_user`, `id_ank`, `time`, `nick`, `time_last`) VALUES ('$user[id]', '$ank[id]', '$time', '$ank[nick]', '$time')");
$hid = mysql_insert_id();
mysql_query("INSERT INTO `mail` SET `id_user` = '$user[id]', `id_cont` = '" . mysql_insert_id() . "', `msg` = '" . mysql_real_escape_string($msg) . "', `time` = '$time', `type` = 'at', `read` = '0'");
} else {
$ucont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"));
mysql_query("UPDATE `mail_conts` SET `time_last` = '$time' WHERE `id` = '$ucont[id]'");
mysql_query("INSERT INTO `mail` SET `id_user` = '$user[id]', `id_cont` = '$ucont[id]', `msg` = '" . mysql_real_escape_string($msg) . "', `time` = '$time', `type` = 'at', `read` = '0'");
$hid = $ucont['id'];
}
header("Location:?cid=$hid");
echo (!isset($fl) ? msg('Сообщение успешно отправлено') : header("Location:?cid=$cont2[id]"));
}
}
if ($cont['type'] == 'arhive') {
unset($fl);
}
aut();
err();
echo "<table>";
if ($ank['id'] != 0) {
echo "<div class = 'adm_menu'>";
echo "<a href = '?new_message=$ank[id]' class = 'adm_menu_link'><img src = '/style/icons/Envelope.png' /><div class = 'adm_menu_title'>Написать</div></a>";
echo "</div>";
}
if ($cont['type'] == 'all') {
echo "<div class = 'adm_menu'>";
echo "<a href='?cid=$cont[id]&in_arhive' class = 'adm_menu_link'><img src = '/style/icons/Box-Incoming.png' /><div class = 'adm_menu_title'>В архив</div></a>";
echo "</div>";
}
if ($cont['type'] == 'arhive') {
echo "<div class = 'adm_menu'>";
echo "<a href='?cid=$cont[id]&in_all' class = 'adm_menu_link'><img src = '/style/icons/Box-Outgoing.png' /><div class = 'adm_menu_title'>Восcтановить</div></a>";
echo "</div>";
}
if ($cont['type'] == 'trash') {
echo "<div class = 'adm_menu'>";
echo "<a href='?cid=$cont[id]&out_trash' class = 'adm_menu_link'><img src = '/style/icons/Box-Outgoing.png' /><div class = 'adm_menu_title'>Восстановить контакт</div></a>";
echo "</div>";
}
if ($cont['type'] != 'favorite') {
echo "<div class = 'adm_menu'>";
echo "<a href='?cid=$cont[id]&in_trash' class = 'adm_menu_link'><img src = '/style/icons/delete.png' /><div class = 'adm_menu_title'>Удалить контакт</div></a>";
echo "</div>";
}
echo "</table>";
if (isset($_GET['sort/list']) && $_GET['sort/list'] == 1) {
$sort = " `type` = 'at' AND ";
} elseif (isset($_GET['sort/list']) && $_GET['sort/list'] == 2) {
$sort = " `type` = 'to' AND ";
} else {
$sort = NULL;
}
echo '<div class="busi_switcher"><table width="33.3%"><tr><td>';
echo (@$_GET['sort/list'] != 1 && (@$_GET['sort/list']) != 2 ? "<span class='active brd'>" : "<a href='?cid=" . intval(@$_GET['cid']) . "&sort/list=0' class='brd'>") . "Все" . (@$_GET['sort/list'] != 1 || $_GET['sort/list'] != 2 ? "</span>" : "</a>");
echo '</td>';
echo '<td style = "width: 33.3%;">';
echo (isset($_GET['sort/list']) && $_GET['sort/list'] == 1 ? "<span class='active brd'>" : "<a href='?cid=" . intval($_GET['cid']) . "&sort/list=1' class='brd'>") . "Исходящие" . (isset($_GET['sort/list']) && $_GET['sort/list'] == 1 ? "</span>" : "</a>");
echo '</td>';
echo '<td style = "width: 33.3%;">';
echo (isset($_GET['sort/list']) && $_GET['sort/list'] == 2 ? "<span class = 'active brd'>" : "<a href='?cid=" . intval($_GET['cid']) . "&sort/list=2' class='brd'>") . "Входящие" . (isset($_GET['sort/list']) && $_GET['sort/list'] == 2 ? "</span>" : "</a>");
echo '</td></tr></table></div>';
if ($cont['type'] != 'trash') {
if ($cont['type'] == 'favorite') {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` INNER JOIN `mail` ON `mail`.`id_cont`=`mail_conts`.`id` WHERE `mail`.`favorite` = '1' AND `mail`.`id_user` = '$user[id]' AND (`mail_conts`.`type` = 'all' OR `mail_conts`.`type` = 'arhive') AND `mail`.`id_cont` = '$cont2[id]'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if ($k_post != 0) {
$last = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` INNER JOIN `mail` ON `mail`.`id_cont`=`mail_conts`.`id` WHERE `mail`.`favorite` = '1' AND `mail`.`id_user` = '$user[id]' AND (`mail_conts`.`type` = 'all' OR `mail_conts`.`type` = 'arhive') AND `mail`.`id_cont` = '$cont2[id]' ORDER BY `mail`.`time` DESC LIMIT $start, 1"));
}
} else {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE $sort `id_cont` = '" . (!isset($fl) ? "$cont[id]" : "$cont2[id]") . "' AND `id_user` = '$user[id]'" . (isset($flf) ? " AND `favorite` = '1'" : null) . ""), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if ($k_post != 0) {
$last = mysql_fetch_array(mysql_query("SELECT * FROM `mail` WHERE $sort `id_cont` = '" . (!isset($fl) ? "$cont[id]" : "$cont2[id]") . "' AND `id_user` = '$user[id]'" . (isset($flf) ? " AND `favorite` = '1'" : null) . " ORDER BY id DESC LIMIT $start, 1"));
}
}
if (isset($last)) {
echo "<div class='" . ($last['type'] == 'to' ? 'comm' : 'comm') . "'>";
echo "<span style='float: right' id = 'hide'>";
if ($last['type'] == 'to') {
if ($cont['type'] == 'all') {
echo "<a href='?cid=$cont[id]&reply=$last[id]' title = 'Ответ'><img src = '/style/icons/pen.png' /></a> ";
}
}
if ($cont['type'] == 'all' || $cont['type'] == 'arhive' || $cont['type'] == 'favorite') {
echo "<a href='?cid=$cont[id]&favorite=$last[id]' title = 'В избранное'><img src = '/style/icons/zak.png' /></a> ";
}
echo "<a href='?cid=$cont[id]&delete=$last[id]' title = 'Удалить'><img src = '/style/icons/dell.png' /></a>";
echo "</span>";
echo ($last['type'] == 'to' ? null : "<span style='font-weight:bold;color:#209143'><small>Я</small></span> > ");
echo "<a href='/info.php?id=$ank[id]' class=''>$ank[nick]</a> ";
echo "<small>" . date::time($last['time']) . "</small>";
if ($last['type'] == 'at') {
$last2 = mysql_fetch_array(mysql_query("SELECT * FROM `mail` WHERE `id_user` = '$ank[id]' AND `id` = '" . ($last['id'] - 1) . "'"));
}
if (isset($last2) && $last2['read'] == 0 && $last['type'] == 'at') {
echo " <small>(не прочитано)</small>";
}
echo "<br/>";
echo text::toOutput($last['msg']) . "<br />n";
echo "</div>";
}
if ($ank['id'] != 0) {
echo "<form method='post' name='message' action='?cid=$cont[id]&$passgen' class = 'comm'>n";
echo "<b>Сообщение</b><br />";
echo "<input type='hidden' name='mdp' value='" . md5($user['pass']) . "'><textarea name='msg'></textarea><br />";
echo "<button class = 'button-green'>Отправить</button><br /><br />";
echo "<a href='?cid=$cont[id]&rfr=1' class = 'add' style = 'color:#88C057;'><img src = '/style/icons/update.png' /> Обновить</a>";
echo "</form>n";
}
}
if ($cont['type'] == 'favorite') {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` INNER JOIN `mail` ON `mail`.`id_cont`=`mail_conts`.`id` WHERE `mail`.`favorite` = '1' AND `mail`.`id_user` = '$user[id]' AND (`mail_conts`.`type` = 'all' OR `mail_conts`.`type` = 'arhive') AND `mail`.`id_cont` = '$cont2[id]'" . (isset($last) ? " AND `mail`.`id` != '$last[id]'" : NULL) . ""), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$q = mysql_query("SELECT * FROM `mail_conts` INNER JOIN `mail` ON `mail`.`id_cont`=`mail_conts`.`id` WHERE `mail`.`favorite` = '1' AND `mail`.`id_user` = '$user[id]' AND (`mail_conts`.`type` = 'all' OR `mail_conts`.`type` = 'arhive') AND `mail`.`id_cont` = '$cont2[id]'" . (isset($last) ? " AND `mail`.`id` != '$last[id]'" : NULL) . " ORDER BY `mail`.`time` DESC LIMIT $start, $set[p_str]");
} else {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE $sort `id_cont` = '" . (!isset($fl) ? "$cont[id]" : "$cont2[id]") . "' AND `id_user` = '$user[id]'" . (isset($last) ? " AND `id` != '$last[id]'" : NULL) . "" . (isset($flf) ? " AND `favorite` = '1'" : null) . ""), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$q = mysql_query("SELECT * FROM `mail` WHERE $sort `id_cont` = '" . (!isset($fl) ? "$cont[id]" : "$cont2[id]") . "' AND `id_user` = '$user[id]'" . (isset($last) ? " AND `id` != '$last[id]'" : NULL) . "" . (isset($flf) ? " AND `favorite` = '1'" : null) . " ORDER BY `time` DESC LIMIT $start, $set[p_str]");
}
while ($post = mysql_fetch_array($q)) {
echo "<div class='" . ($post['type'] == 'to' ? 'comm' : 'comm') . "'>";
echo "<span style='float: right' id = 'hide'>";
if ($cont['type'] == 'trash') {
echo "<a href='?cid=$cont[id]&reset=$post[id]' title = 'Восстановить'><img src = '/style/icons/vs.png' /></a> ";
} elseif ($post['type'] == 'to') {
if ($cont['type'] == 'all') {
echo "<a href='?cid=$cont[id]&reply=$post[id]' title = 'Ответ'><img src = '/style/icons/pen.png' /></a> ";
}
}
if ($cont['type'] == 'all' || $cont['type'] == 'arhive' || $cont['type'] == 'favorite') {
echo "<a href='?cid=$cont[id]&favorite=$post[id]' title = 'В избранное'><img src = '/style/icons/zak.png' /></a> ";
}
echo "<a href='?cid=$cont[id]&delete=$post[id]' title = 'Удалить'><img src = '/style/icons/dell.png' /></a>";
echo "</span>";
echo ($post['type'] == 'to' ? null : "<span style='font-weight:bold;color:#209143'><small>Я</small></span> > ");
echo "<a href='/info.php?id=$ank[id]'>$ank[nick]</a> ";
echo "<small>" . date::time($post['time']) . "</small>";
if ($post['type'] == 'at') {
$post2 = mysql_fetch_array(mysql_query("SELECT * FROM `mail` WHERE `id_user` = '$ank[id]' AND `id` = '" . ($post['id'] - 1) . "'"));
}
if (isset($post2) && $post2['read'] == 0 && $post['type'] == 'at') {
echo " <small>(не прочитано)</small>";
}
echo "<br/>";
echo text::toOutput($post['msg']);
echo "</div>";
}
if ($k_page > 1) {
str("?cid=$cont[id]&sort/list=" . intval($_GET['sort/list']) . "&", $k_page, $page); // Вывод страниц
}
echo "<div class = 'comm'><a href = '/user/mail/' style = 'color:#88C057;'><img src = '/style/icons/left.png' /> Контакты</a></div>";
require_once H . 'sys/inc/tfoot.php';
}
if (isset($_GET['favorite'])) {
$sort = 'favorite';
} elseif (isset($_GET['arhive'])) {
$sort = 'arhive';
} elseif (isset($_GET['trash'])) {
$sort = 'trash';
} else {
$sort = 'all';
}
if ($sort != 'favorite') {
if (isset($_POST['contact_archive']) && $_POST['mdp'] == md5($user['pass'])) {
$count = 0;
foreach ($_POST as $key => $value) {
if (preg_match('#^cd_([0-9]*)$#', $key, $kid) && $value = '1') {
$cont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id` = '$kid[1]' AND `id_user` = '$user[id]' AND `type` = 'all' LIMIT 1"));
$ank = user::get_user($cont['id_ank']);
if ($cont) {
$count++;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'arhive'"), 0) == 0) {
mysql_query("UPDATE `mail_conts` SET `type` = 'arhive' WHERE `id` = '$cont[id]'");
} else {
$tcont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'arhive'"));
mysql_query("UPDATE `mail` SET `id_cont` = '$tcont[id]' WHERE `id_cont` = '$cont[id]'");
mysql_query("DELETE FROM `mail_conts` WHERE `id` = '$cont[id]'");
}
$_SESSION['msg'] = "Контакты успешно перенесены в архив";
}
}
}
} elseif (isset($_POST['contact_delete']) && $_POST['mdp'] == md5($user['pass'])) {
$count = 0;
foreach ($_POST as $key => $value) {
if (preg_match('#^cd_([0-9]*)$#', $key, $kid) && $value = '1') {
$cont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id` = '$kid[1]' AND `id_user` = '$user[id]' LIMIT 1"));
$ank = user::get_user($cont['id_ank']);
if ($cont) {
$count++;
if ($cont['type'] == 'trash') {
mysql_query("DELETE FROM `mail_conts` WHERE `id` = '$cont[id]'");
mysql_query("DELETE FROM `mail` WHERE `id_cont` = '$cont[id]'");
$_SESSION['msg'] = "Контакты успешно удалены";
} else {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'trash'"), 0) == 0) {
mysql_query("UPDATE `mail_conts` SET `type` = 'trash' WHERE `id` = '$cont[id]'");
} else {
$tcont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'trash'"));
mysql_query("UPDATE `mail` SET `id_cont` = '$tcont[id]' WHERE `id_cont` = '$cont[id]'");
mysql_query("DELETE FROM `mail_conts` WHERE `id` = '$cont[id]'");
}
$_SESSION['msg'] = "Контакты успешно перенесены в корзину";
}
}
}
}
} elseif (isset($_POST['contact_reset']) && $_POST['mdp'] == md5($user['pass']) && $sort == 'trash') {
$count = 0;
foreach ($_POST as $key => $value) {
if (preg_match('#^cd_([0-9]*)$#', $key, $kid) && $value = '1') {
$cont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id` = '$kid[1]' AND `id_user` = '$user[id]' LIMIT 1"));
$ank = user::get_user($cont['id_ank']);
if ($cont) {
$count++;
if ($cont['type'] == 'trash') {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"), 0) == 0) {
mysql_query("UPDATE `mail_conts` SET `type` = 'all' WHERE `id` = '$cont[id]'");
} else {
$tcont = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND `type` = 'all'"));
mysql_query("UPDATE `mail` SET `id_cont` = '$tcont[id]' WHERE `id_cont` = '$cont[id]'");
mysql_query("DELETE FROM `mail_conts` WHERE `id` = '$cont[id]'");
}
$_SESSION['msg'] = "Контакты успешно восстановлены";
}
}
}
}
} elseif (isset($_POST['contact_delete_all']) && $_POST['mdp'] == md5($user['pass']) && $sort == 'trash') {
$q = mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `type` = 'trash'");
while ($cont = mysql_fetch_array($q)) {
mysql_query("DELETE FROM `mail_conts` WHERE `id` = '$cont[id]'");
mysql_query("DELETE FROM `mail` WHERE `id_cont` = '$cont[id]'");
$_SESSION['msg'] = "Контакты успешно удалены";
}
}
}
$set['title'] = 'Почта';
require_once H . 'sys/inc/thead.php';
title();
aut();
if (isset($_SESSION['msg'])) {
msg_mail($_SESSION['msg']);
unset($_SESSION['msg']);
}
if ($sort == 'arhive') {
echo '<div class="comm"><b>Архив</b></div>';
} elseif ($sort == 'favorite') {
echo '<div class="comm"><b>Избранное</b></div>';
} elseif ($sort == 'trash') {
echo '<div class="comm"><b>Корзина</b></div>';
} else {
echo "<div class = 'comm'><a href = '/user/mail/?new_message'><img src = '/style/icons/mails.png' /> Новое сообщение</a></div>";
}
$csearch = NULL;
if (isset($_SESSION['csearch'])) {
$csearch = $_SESSION['csearch'];
}
if (isset($_POST['csearch'])) {
$csearch = $_POST['csearch'];
}
if ($csearch == NULL) {
unset($_SESSION['csearch']);
} else {
$_SESSION['csearch'] = $csearch;
}
$csearch = @preg_replace("#( ){1,}#", "", $csearch);
if ($sort != 'all') {
unset($csearch);
}
if ($sort == 'all') {
?>
<style>
.mail_sc{
width: 60%;
transition: width 0.4s cubic-bezier(1, 1, 1, 1) 0.4s;
}
.mail_sc:focus{
transition: width 0.4s cubic-bezier(0, 0, 1, 1) 0s;
width: 80%;
}
</style>
<?php
echo "<form method='post' action='?go' class = 'comm'>";
echo "<b>Поиск контакта:</b><br />";
echo "<input type='text' name='csearch' value='' class='search' placeholder='Введите логин...'/>";
echo " <input type='submit' value='Искать'/>";
echo "</form>";
}
echo "<form method='post'>";
echo "<input type='hidden' name='mdp' value='" . md5($user['pass']) . "'/>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `type` = '$sort'" . (isset($_GET['go']) && $csearch != NULL ? " AND `nick` like '%" . mysql_real_escape_string($csearch) . "%'" : NULL) . ""), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if ($k_post == 0) {
echo "<div class = 'errs'>";
echo "<img src = '/style/icons/error.png' /> Нет результатов";
echo "</div>";
}
$q = mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `type` = '$sort'" . (isset($_GET['go']) && $csearch != NULL ? " AND `nick` like '%" . mysql_real_escape_string($csearch) . "%' ORDER BY `nick` ASC" : " ORDER BY `time_last` DESC, `count` DESC") . " LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_array($q)) {
echo "<div class = 'comm'>";
$post['count_in'] = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id_cont` = '$post[id]' AND `type` = 'to'"), 0);
$post['count_out'] = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id_cont` = '$post[id]' AND `type` = 'at'"), 0);
$ank = user::get_user($post['id_ank']);
if ($sort != 'favorite') {
echo "<input type='checkbox' name='cd_$post[id]' value=''/> n";
}
echo "<a href = '?sid=&list=0&p=1&cid=$post[id]&link_id=$user[id]'" . ($post['count'] != 0 ? '' : null) . ">" . ($post['count'] != 0 ? '' : null) . "";
echo "<img src = '/style/icons/userm.png' />";
echo text::gradient("$ank[nick]", "$ank[ncolor]", "$ank[ncolor2]");
echo "</a> ";
if (@$ank['date_last'] > (TIME - 600)) {
if ($ank['browser'] == 'web') {
echo " <small><font color = 'green'>Веб</font></small>";
} else {
echo " <small><font color = 'green'>Моб</font></small>";
}
} else {
if (@$ank['browser'] == 'web') {
echo " <small><font color = 'grey'>Веб</font></small>";
} else {
echo " <small><font color = 'grey'>Моб</font></small>";
}
}
if ($sort == 'favorite') {
$cont2 = mysql_fetch_array(mysql_query("SELECT * FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `id_ank` = '$post[id_ank]' AND `type` = 'all'"));
echo "<span style='color: green'>(" . mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` INNER JOIN `mail` ON `mail`.`id_cont`=`mail_conts`.`id` WHERE `mail`.`favorite` = '1' AND `mail`.`id_user` = '$user[id]' AND (`mail_conts`.`type` = 'all' OR `mail_conts`.`type` = 'arhive') AND `mail`.`id_cont` = '$cont2[id]'"), 0) . ")</span>";
} else {
echo " <small>" . ($post['count'] != 0 ? "<b>" : null) . "(<a href='?cid=$post[id]&sort/list=2'>$post[count_in]</a>/<a href='?cid=$post[id]&sort/list=1'>$post[count_out]</a>)" . ($post['count'] != 0 ? "</b>" : null) . "</small>";
}
if ($post['count'] != 0) {
echo " <font color = 'red'><small>(+$post[count])</small></font>";
}
echo "</div>";
}
if ($sort != 'favorite') {
echo "<div class='comm'>";
echo "<b>Отмеченные контакты:</b><br />";
if ($sort == 'all') {
echo "<button name = 'contact_archive' class = 'button-green'>в архив</button> ";
}
if ($sort == 'trash') {
echo "<button name = 'contact_reset' class = 'button-green'>восстановить</button> ";
}
echo "<button name = 'contact_delete' class = 'button-green'>удалить</button> ";
if ($sort == 'trash') {
echo "<button class = 'button-green' name = 'contact_delete_all'>очистить корзину</button> ";
}
echo "</div>";
}
echo "</form>";
if ($k_page > 1) {
str("?", $k_page, $page);
}
if ($sort != 'all') {
echo "<div class = 'comm'><a href = '/user/mail/' style = 'color:#88C057;'><img src = '/style/icons/left.png' /> Контакты</a></div>";
}
echo "<table>";
echo "<div class = 'adm_menu'>";
echo "<a href = '?sid=&favorite=1&link_id=$user[id]' class = 'adm_menu_link'><img src = '/style/icons/Star.png' /><div class = 'adm_menu_title'> Избранное (" . mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `type` = 'favorite'"), 0) . ")</div></a>";
echo "</div>";
echo "<div class = 'adm_menu'>";
echo "<a href='?sid=&arhive=2&link_id=$user[id]' class = 'adm_menu_link'><img src = '/style/icons/Box-File.png' /><div class = 'adm_menu_title'> Архив (" . mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `type` = 'arhive'"), 0) . ")</div></a>";
echo "</div>";
echo "<div class = 'adm_menu'>";
echo "<a href='?sid=&trash=3&link_id=$user[id]' class = 'adm_menu_link'><img src = '/style/icons/Delete.png' /><div class = 'adm_menu_title'> Корзина (" . mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_conts` WHERE `id_user` = '$user[id]' AND `type` = 'trash'"), 0) . ")</div></a>";
echo "</div>";
echo "<div class = 'adm_menu'>";
echo "<a href='?sid=&mail_access=" . ($user['set_mail'] == 2 ? "2" : "1") . "&link_id=$user[id]' class = 'adm_menu_link'><img src = '/style/icons/Settings32.png' /><div class = 'adm_menu_title'>Настройки</div></a>";
echo "</div>";
if (isset($user) && $user['group_access'] == 15) {
echo "<div class = 'adm_menu'>";
echo "<a href='?sid=&mail_admin_access=1&link_id=$user[id]' class = 'adm_menu_link'><img src = '/style/icons/Browser-Settings.png' /><div class = 'adm_menu_title'>Админка</div></a>";
echo "</div>";
}
echo "</table>";
require_once H . 'sys/inc/tfoot.php';