{% else-1 %}
(30 июл 2013, 12:12) (0/0) [0]
RD87, ну!
(30 июл 2013, 12:06) (0/0) [0]
lmfao, <?php
include (\'../../system/mysql.php\');
include (\'../../system/sys_func.php\');

if(!isset($user)){
header(\'location: /\');
exit;
}

switch($_GET[\'act\']){
default:
if(isset($_GET[\'name\'])){
if(mysql_result(mysql_query(\"SELECT COUNT(*) FROM `users` WHERE `login` = \'\".html($_GET[\'name\']).\"\'\"*,0)==0){
$title = \'Ошибка\';
echo \'<div class=\"title\">Ошибка</div>\';
include \'../../system/head.php\';
echo \'<div class=\"err\">Нет такого пользователья</div>\';
foot();
exit;
}

$ank = mysql_fetch_assoc(mysql_query(\"SELECT * FROM `users` WHERE `login` = \'\".html($_GET[\'name\']).\"\' LIMIT 1\"*);

mysql_query(\"UPDATE `mail_msg` SET `chit` = \'1\' WHERE `user_1` = \'\".$ank[\'id\'].\"\' AND `user_2` = \'\".$user[\'id\'].\"\'\"*;

$title = \'Переписка с \'.$ank[\'login\'];
$navig = \'<a href=\"/pages/presonal/\">Кабинет</a> / <a href=\"/user/mail/\">Диалоги</a> / \'.$ank[\'login\'];
include \'../../system/head.php\';

if(isset($_POST[\'reload\'])){
header(\'location: ?name=\'.$ank[\'login\']);
}


if(isset($_POST[\'submit\'])){
if(empty($_POST[\'msg\'])){
echo \'<div class=\"err\">Вы не ввели сообщение</div>\';
}elseif($user[\'position\'] != \'admin\' && strlen($_POST[\'msg\']) > 2000){
echo \'<div class=\"err\">Большое сообщение</div>\';
}else{
if(mysql_result(mysql_query(\"SELECT COUNT(*) FROM `mail` WHERE `user_1` = \'\".$user[\'id\'].\"\' AND `user_2` = \'\".$ank[\'id\'].\"\' OR `user_1` = \'\".$ank[\'id\'].\"\' AND `user_2` = \'\".$user[\'id\'].\"\'\"*,0)==0){
mysql_query(\"INSERT INTO `mail` (`user_1`, `user_2`, `time`) VALUES (\'\".$user[\'id\'].\"\', \'\".$ank[\'id\'].\"\', \'\".time().\"\')\"*;
}else{
mysql_query(\"UPDATE `mail` SET `time` = \'\".time().\"\' WHERE `user_1` = \'\".$user[\'id\'].\"\' AND `user_2` = \'\".$ank[\'id\'].\"\' OR `user_1` = \'\".$ank[\'id\'].\"\' AND `user_2` = \'\".$user[\'id\'].\"\' LIMIT 1\"*;
}
mysql_query(\"INSERT INTO `mail_msg` (`user_1`, `user_2`, `msg`, `time`) VALUES (\'\".$user[\'id\'].\"\', \'\".$ank[\'id\'].\"\', \'\".mysql_real_escape_string($_POST[\'msg\']).\"\', \'\".time().\"\')\"*;
}
}

echo \'<form method=\"post\">\';
echo \'<b>Сообщение</b>:<br/><textarea name=\"msg\"></textarea><br/>\';
echo \'<input type=\"submit\" name=\"submit\" value=\"Отправить\"/> <input type=\"submit\" name=\"reload\" value=\"Обновить\"/>\';
echo \'</form>\';

$c_p = mysql_result(mysql_query(\"SELECT COUNT(*) FROM `mail_msg` WHERE `user_1` = \'\".$user[\'id\'].\"\' AND `user_2` = \'\".$ank[\'id\'].\"\' OR `user_1` = \'\".$ank[\'id\'].\"\' AND `user_2` = \'\".$user[\'id\'].\"\'\"*,0);
$k_page = k_page($c_p, 10);
$page = page($k_page);
$start = 10*$page-10;

if($c_p == 0){
echo \'<div class=\"post\">Нет сообщений</div>\';
}

$query = mysql_query(\"SELECT * FROM `mail_msg` WHERE `user_1` = \'\".$user[\'id\'].\"\' AND `user_2` = \'\".$ank[\'id\'].\"\' OR `user_1` = \'\".$ank[\'id\'].\"\' AND `user_2` = \'\".$user[\'id\'].\"\' ORDER BY `id` DESC LIMIT $start, 10\"*;
while($post = mysql_fetch_assoc($query)){
$ot = mysql_fetch_assoc(mysql_query(\"SELECT * FROM `users` WHERE `id` = \'\".$post[\'user_1\'].\"\' LIMIT 1\"*);
echo \'<div class=\"post\">\';
echo online($ot[\'id\']).\'<a href=\"/user/anketa/?name=\'.$ot[\'login\'].\'\">\'.$ot[\'login\'].\'</a>\'.($post[\'chit\'] == 0?\' [<span style=\"color: red\">Не прочитано</span>]\':NULL).\'<span class=\"c_date\">\'.ptime($post[\'time\']).\'</span>\';
echo \'<br/>\';
echo output($post[\'msg\']);
echo \'</div>\';
}

if($k_page > 1)str(\'?name=\'.$ank[\'login\'].\'&\', $page, $k_page);

echo \'<a class=\"link\" href=\"/pages/mail/\">&larr; Назад</a>\';

foot();
exit;
}

$title = \'Кабинет / Диалоги\';
include (\'../../system/head.php\');
echo \'<div class=\"title\"><a href=\"/pages/personal/\">Кабинет</a> / Диалоги</div>\';

$c_p = mysql_result(mysql_query(\"SELECT COUNT(*) FROM `mail` WHERE `user_1` = \'\".$user[\'id\'].\"\' OR `user_2` = \'\".$user[\'id\'].\"\'\"*,0);
$k_page = k_page($c_p, 10);
$page = page($k_page);
$start = 10*$page-10;

if($c_p == 0){
echo \'<div class=\"post\">Нет диалогов</div>\';
}

$query = mysql_query(\"SELECT * FROM mail WHERE user_1 = \'\".$user[\'id\'].\"\' OR user_2 = \'\".$user[\'id\'].\"\' ORDER BY time DESC LIMIT $start, 10\"*;
while($mail = mysql_fetch_assoc($query)){
if($mail[\'user_1\'] == $user[\'id\'])
$ank = mysql_fetch_assoc(mysql_query(\"SELECT * FROM `users` WHERE `id` = \'\".$mail[\'user_2\'].\"\' LIMIT 1\"*);
else
$ank = mysql_fetch_assoc(mysql_query(\"SELECT * FROM `users` WHERE `id` = \'\".$mail[\'user_1\'].\"\' LIMIT 1\"*);

$new = mysql_result(mysql_query(\"SELECT COUNT(*) FROM mail_msg WHERE user_1 = \'\".$ank[\'id\'].\"\' AND user_2 = \'\".$user[\'id\'].\"\' AND chit = \'0\'\"*,0);

echo \'<a class=\"link\" href=\"?name=\'.$ank[\'login\'].\'\">\';
echo online($ank[\'id\']).$ank[\'login\'].\' (\'.mysql_result(mysql_query(\"SELECT COUNT(*) FROM `mail_msg` WHERE `user_1` = \'\".$user[\'id\'].\"\' AND `user_2` = \'\".$ank[\'id\'].\"\'\"*,0).\'/\'.mysql_result(mysql_query(\"SELECT COUNT(*) FROM `mail_msg` WHERE `user_1` = \'\".$ank[\'id\'].\"\' AND `user_2` = \'\".$user[\'id\'].\"\'\"*,0).\')\'.($new > 0 ?\' <span style=\"color: red\">+\'.$new.\'</span>\' : NULL).\'</a>\';
}

if($k_page > 1)str(\'?\', $k_page, $page);

echo \'<a class=\"link\" href=\"/pages/personal/\">&larr; Кабинет</a>\';
break;
}

foot();
?>
(30 июл 2013, 12:00) (0/0) [0]
После отправки сообщения и обновления страницы повторяется отправленное сообщение! как сделать что бы сообщение повторно не отправлялось? двиг peascms!
Добавлено 30.07.13 в 12:04:05:
ну что никто не знает?
  • 1 из 1