', $v); $v = str_replace('\\', '\\\\', $v); $v = str_replace('"', '[s1;]', $v); $v = str_replace("'", '[s2;]', $v); $v = str_replace('<', '[s3;]', $v); $v = str_replace('>', '[s4;]', $v); $v = str_replace(' ', ' ', $v); $v = htmlspecialchars($v, null); return $v; } if (!isset($u->info['id']) || $u->info['banned'] > 0) { die('-1'); } $r = round((int)$_POST['r']); if ($r != 1 && $r != 2 && $r != 3) { $r = 1; } $html = ''; $js = ''; if (isset($_POST['see_msg'])) { $msg = mysql_fetch_array( mysql_query( 'SELECT * FROM `telegram` WHERE `id` = "' . mysql_real_escape_string( $_POST['see_msg'] ) . '" AND (`uid` = "' . $u->info['id'] . '" OR `from` = "' . $u->info['id'] . '") LIMIT 1' ) ); if (!isset($msg['id'])) { $html = '







Сообщение не найдено.
'; } elseif ($msg['uid'] == $u->info['id'] && ($msg['delete'] == 2 || $msg['delete'] == 3)) { $html = '







Сообщение было удалено.
'; } else { $to = mysql_fetch_array( mysql_query('SELECT `id`,`login`,`banned` FROM `users` WHERE `id` = "' . $msg['uid'] . '" LIMIT 1') ); $from = mysql_fetch_array( mysql_query('SELECT `id`,`login`,`banned` FROM `users` WHERE `id` = "' . $msg['from'] . '" LIMIT 1') ); if (($msg['read'] == 0 || $msg['read'] == 1) && $to['id'] == $u->info['id']) { mysql_query('UPDATE `telegram` SET `read` = `read` + 2 WHERE `id` = "' . $msg['id'] . '" LIMIT 1'); } $html = '
'; $html .= '
От:    ' . $from['login'] . 'Закрыть
'; $html .= '
Кому: ' . $to['login'] . '' . date( 'd.m.Y H:i', $msg['time'] ) . '
'; $html .= '
Тема: ' . $msg['tema'] . '
'; $html .= '
Сообщение:
' . $msg['text'] . '
'; $html .= ''; $html .= '
'; $html .= '
'; } } elseif ($r == 3) { if ($u->info['noreal'] == 1) { $html = '







Отправлять сообщения по телеграфу возможно только с основного персонажа
'; } elseif ($u->info['level'] < 4) { $html = '







Отправлять сообщения по телеграфу возможно с 4-го уровня.
'; } elseif ($u->info['molch1'] > time()) { $html = '







Персонажи с молчанкой не могут пользоваться телеграфом.
'; } else { if (isset($_POST['to'])) { if (test_line($_POST['to']) == false) { $error = 'Пустое поле "Кому".'; } elseif (test_line($_POST['text']) == false) { $error = 'Пустое поле "Сообщение".'; } elseif (test_line($_POST['tema']) == false) { $error = 'Пустое поле "Тема".'; } else { $to = mysql_fetch_array( mysql_query( 'SELECT `id`,`login`,`banned` FROM `users` WHERE `login` = "' . mysql_real_escape_string( $_POST['to'] ) . '" LIMIT 1' ) ); if (!isset($to['id'])) { $error = 'Получатель не найден в базе.'; } elseif ($to['banned'] > 0) { $error = 'Получатель был заблокирован.'; } elseif ($to['id'] == $u->info['id']) { $error = 'Нельзя отправлять самому себе.'; } else { $_POST['text'] = str_replace("\n", '
', $_POST['text']); $_POST['text'] = str_replace("\r", '
', $_POST['text']); mysql_query( 'INSERT INTO `telegram` (`uid`,`from`,`tema`,`text`,`time`,`ip`) VALUES ("' . $to['id'] . '","' . $u->info['id'] . '","' . mysql_real_escape_string( $_POST['tema'] ) . '","' . mysql_real_escape_string($_POST['text']) . '","' . time( ) . '","' . mysql_real_escape_string($u->info['ip']) . '")' ); unset($_POST['to'], $_POST['text'], $_POST['tema']); $error = 'Сообщение доставлено "' . $to['login'] . '".'; } } } if (isset($_POST['re']) && $_POST['re'] > 0 && !isset($_POST['to'])) { $msg = mysql_fetch_array( mysql_query( 'SELECT * FROM `telegram` WHERE `id` = "' . mysql_real_escape_string( $_POST['re'] ) . '" AND (`uid` = "' . $u->info['id'] . '" OR `from` = "' . $u->info['id'] . '") LIMIT 1' ) ); if (isset($msg['id'])) { $to = mysql_fetch_array( mysql_query('SELECT `id`,`login`,`banned` FROM `users` WHERE `id` = "' . $msg['uid'] . '" LIMIT 1') ); $from = mysql_fetch_array( mysql_query('SELECT `id`,`login`,`banned` FROM `users` WHERE `id` = "' . $msg['from'] . '" LIMIT 1') ); if ($msg['from'] == $u->info['id']) { $_POST['to'] = $to['login']; } elseif ($msg['uid'] == $u->info['id']) { $_POST['to'] = $from['login']; } else { unset($msg); } $_POST['tema'] = 'Re:' . str_replace('Re:', '', $msg['tema']); } } $html = '
'; $html .= '
От:    ' . $u->info['login'] . '
'; $html .= '
Кому:
'; $html .= '
Тема:
'; $html .= '
Сообщение:
'; $html .= '
' . $error . '
'; $html .= '
'; } } elseif ($r == 1 || $r == 2) { if ($r == 1) { mysql_query( 'UPDATE `telegram` SET `open` = "1" WHERE `uid` = "' . $u->info['id'] . '" AND `open` = "0" LIMIT 100' ); } $pg = round((int)$_POST['p']); if ($pg < 1) { $pg = 1; } $pgssee = ceil(($pg - 1) * 9); if ($r == 1) { if (isset($_POST['del_msg'])) { mysql_query( 'UPDATE `telegram` SET `delete` = `delete` + 2 WHERE `uid` = "' . $u->info['id'] . '" AND (`delete` = 0 OR `delete` = 1) AND `id` = "' . mysql_real_escape_string( $_POST['del_msg'] ) . '" LIMIT 1' ); } $sp = mysql_query( 'SELECT * FROM `telegram` WHERE `uid` = "' . $u->info['id'] . '" AND (`delete` = 0 OR `delete` = 1) ORDER BY `id` DESC LIMIT ' . mysql_real_escape_string( $pgssee ) . ',10' ); } elseif ($r == 2) { if (isset($_POST['del_msg'])) { mysql_query( 'UPDATE `telegram` SET `delete` = `delete` + 1 WHERE `from` = "' . $u->info['id'] . '" AND (`delete` = 0 OR `delete` = 2) AND `id` = "' . mysql_real_escape_string( $_POST['del_msg'] ) . '" LIMIT 1' ); } $sp = mysql_query( 'SELECT * FROM `telegram` WHERE `from` = "' . $u->info['id'] . '" AND (`delete` = 0 OR `delete` = 2) ORDER BY `id` DESC LIMIT ' . mysql_real_escape_string( $pgssee ) . ',10' ); } $msgs = 0; while ($pl = mysql_fetch_array($sp)) { if ($msgs < 9) { if ($r == 1) { $from = mysql_fetch_array( mysql_query('SELECT `id`,`login` FROM `users` WHERE `id` = "' . $pl['from'] . '" LIMIT 1') ); } if ($r == 2) { $from = mysql_fetch_array( mysql_query('SELECT `id`,`login` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1') ); } if (!isset($from['id'])) { $from = '' . $pl['from'] . ''; } else { $from = '' . $from['login'] . ''; } //if($r == 1) { if ($pl['read'] == 0 || $pl['read'] == 1) { $pl['read'] = 0; } else { $pl['read'] = 1; } if ($r == 1) { $html .= '
' . date('d.m.y', $pl['time']) . ' От: ' . $from . ' Тема: ' . $pl['tema'] . '
'; } if ($r == 2) { $html .= '
' . date('d.m.y', $pl['time']) . ' Кому: ' . $from . ' Тема: ' . $pl['tema'] . '
'; } } $msgs++; } if ($msgs > 9 || $pg > 1) { if ($html != '') { $html .= '
'; if ($r == 1) { $pgs = mysql_fetch_array( mysql_query( 'SELECT COUNT(`id`) FROM `telegram` WHERE `uid` = "' . $u->info['id'] . '" AND (`delete` = 0 OR `delete` = 1)' ) ); } else { if ($r == 2) { $pgs = mysql_fetch_array( mysql_query( 'SELECT COUNT(`id`) FROM `telegram` WHERE `from` = "' . $u->info['id'] . '" AND (`delete` = 0 OR `delete` = 2)' ) ); } } $pgs = $pgs[0]; $pga = ceil($pgs / 9); $i = 1; while ($i <= $pga) { if ($i == $pg) { $html .= ' ' . $i . ''; } else { $html .= ' ' . $i . ''; } $i++; } $html .= '
'; } else { $js .= 'top.tgf_rz(' . $r . ',' . ($pg - 1) . ');'; } } } $js .= 'top.tgf_loading(2)'; if ($js != '') { $js = ''; } if ($html == '') { if ($r == 1) { $html = '







У Вас нет сообщений от других пользователей
'; } elseif ($r == 2) { $html = '







У Вас нет сообщений отправленных другим пользователям
'; } } echo $html . $js;