File size: 3.83Kb
<?
///////////////////////////
///by Kyber 2011
///Поддержка klybok.net
///ICQ 626-000-895
///Не для продажы!!!
///Потрачено 23 часа
///Реквизиты для помощи:
///R 191559143752
///Z 109983295073
///U 211922671748
///////////////////////////
include_once 'inc/fnc.php';
include_once 'inc/sys.php';
head('Мини-чат');
echo R(3).'<div class="head">Мини - чат</div>'.P();
switch ($_GET['act']) {
default:
if (isset($_GET['ok'])) echo '<span class="err">Сообщение добавлено успешно</span>';
elseif (isset($_GET['err'])) echo '<span class="err">Ошибка</span>';
elseif (isset($_GET['okd'])) echo '<span class="err">Удалено</span>';
elseif (isset($_GET['okr'])) echo '<span class="err">Изменено</span>';
$k = mysql_result(mysql_query("SELECT COUNT(*) FROM `chat`"),0);
if ($k == 0 ) echo 'Пока ничего нет<br />';
$k_page = ceil($k / $SET['k_p_s']);
$page = page();
$s = $page * $SET['k_p_s'] - $SET['k_p_s'];
$q = mysql_query("SELECT * FROM `chat` ORDER BY `time` DESC LIMIT $s, $SET[k_p_s]");
while ($p = mysql_fetch_assoc($q)) {
$u = mysql_fetch_assoc(mysql_query("SELECT nick, pol, time, sess FROM `users` WHERE `id` = '$p[autor]'"));
echo '<div class="cont">';
if ($U['adm'] == 1) echo '<a href="?act=set&p='.$p['id'].'">';
if ($u['pol'] == 1) echo '<img src="/inc/img/man.gif" alt="" />';
elseif ($u['pol'] == 2) echo '<img src="/inc/img/woman.gif" alt="" />';
else echo '<img src="/inc/img/g.gif" alt="" />';
if ($U['adm'] == 1) echo '</a>';
echo ' <a href="anketa.php?id='.$p['autor'].'">'.$u['nick'].'</a> ';
if ($u['time'] > $time-600 AND $u['sess'] != '' ) echo '<span class="on">В сети</span>';
else echo '<span class="off">Отключен</span>';
if (isset($U) AND $U['id'] != $p['autor']) echo ' <a href="?uid='.$p['autor'].'">Ответить</a><br />';
echo ' ('.data($p['time']).')<br />'.out($p['msg'], true, true);
echo'</div>';
}
if ($k_page > 1) str('?', $k_page, $page);
if (isset($U)) {
if (is_numeric($_GET['uid'])) {
$otv1 = mysql_fetch_assoc(mysql_query("SELECT nick FROM `users` WHERE `id` = '".intval($_GET['uid'])."'"));
$otv = $otv1['nick'].', ';
}
else
$otv = '';
echo '<form action="?act=add" method="post">
Сообщение (3-1000):<br /><textarea name="msg" cols="20" rows="3">'.$otv.'</textarea><br />
[<a href="info.php?act=smiles">Смайлы</a> / <a href="info.php?act=bbcode">BBcode</a>]<br />
<input type="submit" value="Сказать" /></form>';}
echo '<img src="inc/img/home.png" alt="" /> <a href="/">На главную</a>';
break;
case 'add':
$msg = trim($_POST['msg']);
if (isset($U) AND isset($_POST['msg']) AND mb_strlen($msg) >= 3 AND mb_strlen($msg) <=1000) {
mysql_query("INSERT INTO `chat` (autor, time, msg) VALUES ('$U[id]', '$time', '".in($msg)."')");
header('Location: ?ok');
}
else header('Location: ?err');
break;
case 'set':
$pid = intval($_GET['p']);
$q = mysql_query("SELECT msg FROM `chat` WHERE `id` = '$pid' ");
if (mysql_num_rows($q) == 0) header('Location: ?');
$p = mysql_fetch_assoc($q);
if (isset($_GET['go']) AND mysql_query("UPDATE `chat` SET `msg` = '".in($_POST['msg'])."' WHERE `id` = '$pid'")) header('location: ?okr');
echo '<form action="?act=set&p='.$pid.'&go" method="post">
<textarea name="msg" rows="5" cols="20">'.out($p['msg']).'</textarea><br />
[<a href="?act=del&p='.$pid.'">Удалить</a>]<br />
<input type="submit" value="Изменить" /></form>
<a href="mini-chat.php">Назад</a><br />
<img src="inc/img/home.png" alt="" /> <a href="/">На главную</a>';
break;
case 'del':
if (mysql_query("DELETE FROM `chat` WHERE `id` = '".intval($_GET['p'])."' ")) header('Location: ?okd');
else echo'Ошибка<br />';
break;
}
foot();
?>