Файл: mini_chat/index.php
Строк: 63
<?
////////////////////////////////////////
///// Kyber ApiCMS 2013 apicms.ru //////
///// Запрещается продажа данной CMS ///
///// Автор Евгений Медянкин Kyber /////
///// ICQ 626-000-895 или 37-22-47 /////
////////////////////////////////////////
/////////////////////////////////////////
$title = 'Админ чат';
require_once '../api_core/apicms_system.php';
require_once '../api_core/head.php';
/////////////////////////////////////////
if($user['level'] == 0){
echo'<div class="content"><center>Данный чат только для админов.</center></div>';
apicms_foot();
exit();
}
if (isset($_POST['txt'])){
$text = mysql_real_escape_string($_POST['txt']);
if (strlen($text)>1024)$err = '<div class="content"><center>Очень длинное сообщение</center></div>';
if (strlen($text)<10)$err = '<div class="content"><center>Короткое сообщение</center></div>';
if (!isset($err)){
mysql_query("INSERT INTO `mini_chat` (`txt`, `id_user`, `time`) VALUES ('$text', '$user[id]', '$time')");
////////////////////////////////////
$plus_fishka = $user['fishka'] + $api_settings['fishka_chat'];
mysql_query("UPDATE `users` SET `fishka` = '$plus_fishka' WHERE `id` = '$user[id]' LIMIT 1");
echo '<div class="content"><center>Сообщение успешно добавлено</center></div>';
}else{
apicms_error($err);
}
}
/////////////////////////////////////////
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `mini_chat`"),0);
$k_page=k_page($k_post,$api_settings['on_page']);
$page=page($k_page);
$start=$api_settings['on_page']*$page-$api_settings['on_page'];
if ($k_post==0)echo "<div class='content'><center>Сообщений в мини-чате ненайдено</center></div>";
/////////////////////////////////////////
$qii=mysql_query("SELECT * FROM `mini_chat` ORDER BY id DESC LIMIT $start, $api_settings[on_page]");
while ($post_chat = mysql_fetch_assoc($qii)){
$ank2=mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $post_chat[id_user] LIMIT 1"));
echo '<div class="subhead"><table width="100%" ><tr><td width="20%"><center>';
echo apicms_ava32($ank2['id']);
echo "</center></td><td width='80%'><a href='/profile.php?id=$ank2[id]'>".$ank2['login']."</a> ";
echo "<span style='float:right'> ".apicms_data($post_chat['time'])." ";
echo " </span>";
echo "</br> <b>".apicms_bb_code(apicms_smiles(apicms_br(htmlspecialchars($post_chat['txt']))))."</b></td></tr></table></div>";
}
/////////////////////////////////////////
if ($user['id']){
echo "<form name="message" action="?ok" method="post">n";
echo ''.auto_bb("message","txt").'';
echo "<div class='content'><center><textarea name="txt"></textarea><br />n";
echo "<input type='submit' value='Добавить'/></form></center></div>n";
}else{
echo "<div class='content'>Извините вы неможете писать в чате</div>n";
}
/////////////////////////////////////////
if ($k_page > 1){
echo '<div class="subhead"><center>';
str('?',$k_page,$page); // генерируем постраничную навигацию
echo '</center></div>';
}
apicms_foot();
?>