Файл: api_forum/theme.php
Строк: 119
<?
////////////////////////////////////////
///// Kyber ApiCMS 2013 apicms.ru //////
///// Запрещается продажа данной CMS ///
///// Автор Евгений Медянкин Kyber /////
///// ICQ 626-000-895 или 37-22-47 /////
////////////////////////////////////////
/////////////////////////////////////////
require_once '../api_core/apicms_system.php';
/////////////////////////////////////////
if (isset($_GET['id']))$theme_id = intval($_GET['id']);
$theme_name = mysql_fetch_assoc(mysql_query("SELECT * FROM `api_forum_theme` WHERE `id` = '$theme_id' LIMIT 1"));
$title = 'APICMS - '.htmlspecialchars($theme_name['name']).'';
require_once '../design/styles/'.htmlspecialchars($api_design).'/head.php';
if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `api_forum_theme` WHERE `id` = '".$theme_name['id']."'"),0)==1){
//////////////////////////////////////////////////////////
if ($theme_name['close']==1) echo '<div class="erors">Тема закрыта для обсуждений</div>';
$reloads = rand(100, 99999);
echo '<div class="apicms_subhead"><table width="100%" ><tr>';
if ($theme_name['close']==0 && ($theme_name['id_user']==$user['id'] || $user['level']==1 || $user['level']==2))echo '<td width="25%"><center><a href="theme_close.php?id='.$theme_name['id'].'"><img src="/design/styles/'.htmlspecialchars($api_design).'/forum/theme_close.png"></a></center></td>';
if ($theme_name['close']==1 && ($theme_name['id_user']==$user['id'] || $user['level']==1 || $user['level']==2))echo '<td width="25%"><center><a href="theme_open.php?id='.$theme_name['id'].'"><img src="/design/styles/'.htmlspecialchars($api_design).'/forum/theme_open.png"></a></center></td>';
echo '<td width="25%"><center><a href="theme.php?id='.$theme_name['id'].'&'.$reloads.'"><img src="/design/styles/'.htmlspecialchars($api_design).'/forum/reload.png"></a></center></td> ';
if ($theme_name['close']==0 && ($theme_name['id_user']==$user['id'] || $user['level']==1 || $user['level']==2))echo '<td width="25%"><center><a href="del_theme.php?id='.$theme_name['id'].'"><img src="/design/styles/'.htmlspecialchars($api_design).'/forum/del_theme.png"></a></center></td>';
if ($theme_name['close']==0 && ($theme_name['id_user']==$user['id'] || $user['level']==1 || $user['level']==2))echo '<td width="25%"><center><a href="edit_theme.php?id='.$theme_name['id'].'"><img src="/design/styles/'.htmlspecialchars($api_design).'/forum/edit_theme.png"></a></center></td>';
echo '</td></tr></table></div>';
/////////////////////////////////////////
$qii22=mysql_query("SELECT * FROM `api_forum_theme` WHERE `id` = '$theme_id' ORDER BY id DESC LIMIT 1");
while ($post_theme = mysql_fetch_assoc($qii22)){
$who_post=mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $post_theme[id_user] LIMIT 1"));
echo '<div class="apicms_subhead"><table width="100%" ><tr><td width="10%"><center>';
echo apicms_ava32($who_post['id']);
echo "</center></td><td width='90%'><a href='/profile.php?id=$who_post[id]'>".$who_post['login']."</a> ";
echo "<span style='float:right'> <small>".apicms_data($post_theme['time'])."</small> </span>";
echo "</br> <b>".apicms_smiles(apicms_br(htmlspecialchars($post_theme['text'])))."</b></td></tr></table></div>";
}
//////////////////////////////////////////////////////////
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `api_forum_post` WHERE `theme` = '$theme_id'"),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='erors'><center>Ответов в данной теме не найдено!</center></div>";
/////////////////////////////////////////
$qii=mysql_query("SELECT * FROM `api_forum_post` WHERE `theme` = '$theme_id' ORDER BY id ASC LIMIT $start, $api_settings[on_page]");
while ($post_post = mysql_fetch_assoc($qii)){
$who_post = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $post_post[id_user] LIMIT 1"));
echo '<div class="apicms_subhead"><table width="100%" ><tr><td width="10%"><center>';
echo apicms_ava32($who_post['id']);
echo "</center></td><td width='85%'><a href='/profile.php?id=$who_post[id]'>".$who_post['login']."</a> ";
echo "<span style='float:right'> <small>".apicms_data($post_post['time'])."</small> </span>";
echo "</br> <b>".apicms_smiles(apicms_br(htmlspecialchars($post_post['text'])))."</b>";
if ($post_post['edit']==1 && $post_post['delete']==0) echo ' </br> <small>Изменено: '.apicms_data($post_post['edit_time']).'</small>';
if ($post_post['delete']==1) echo ' </br> <small>Удалено: '.apicms_data($post_post['delete_time']).'</small>';
echo '</br>';
if ($post_post['delete']==0 && ($post_post['id_user']==$user['id'] || $user['level']==1 || $user['level']==2))echo '<small><a href="edit_post.php?id='.$theme_name['id'].'&post='.$post_post['id'].'">Редактировать</a> / </small>';
if ($user['id'] && $user['id']!=$post_post['id_user'] && ($theme_name['close']==0 && $post_post['delete']==0))echo ' <small> <a href="reply.php?id='.$theme_name['id'].'&user='.$who_post['id'].'">Ответить</a> / </small>';
if ($post_post['delete']==0 && ($post_post['id_user']==$user['id'] || $user['level']==1 || $user['level']==2))echo ' <small> <a href="delete_post.php?id='.$post_post['id'].'&theme='.$theme_name['id'].'">Удалить</a></small>';
echo "</td></tr></table></div>";
}
//////////////////////////////////////////////////////////
if ($k_page > 1){
echo '<div class="apicms_subhead"><center>';
str('theme.php?id='.$theme_id.'&',$k_page,$page); // генерируем постраничную навигацию
echo '</center></div>';
}
//////////////////////////////////////////////////////////
if (isset($user['id']) && $_POST['txt'] != NULL){
$text = apicms_filter($_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 `api_forum_post` (`text`, `id_user`, `theme`, `time`) VALUES ('$text', '$user[id]', '$theme_id', '$time')");
////////////////////////////////////
$plus_fishka = $user['fishka'] + $api_settings['fishka_forum_post'];
mysql_query("UPDATE `users` SET `fishka` = '$plus_fishka' WHERE `id` = '$user[id]' LIMIT 1");
echo '<div class="content"><center>Сообщение успешно добавлено</center></div>';
header("Location: theme.php?id=".$theme_id."&page=end");
}else{
apicms_error($err);
}
}
//////////////////////////////////////////////////////////
if ($user['id'] && $theme_name['close']==0){
echo "<form action='/api_forum/theme.php?id=".$theme_id."&page=end&ok' method='post'>";
echo "<div class='apicms_dialog'><center><textarea name='txt'></textarea><br />";
echo "<input type='submit' value='Добавить'/></form></center></div>";
}else{
echo "<div class='erors'>Извините, вы не можете отправить сообщение</div>";
}
$my_acts = time()-600;
$in_theme = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `my_place` = '$title' AND `activity` > '$my_acts'"),0);
if ($in_theme > 0)echo '<div class="apicms_subhead"><center> <img src="/design/styles/'.htmlspecialchars($api_design).'/forum/in_theme.png"> Сейчас в теме "'.$theme_name['name'].'": '.$in_theme.' чел.</center></div>';
}else{
echo "<div class='erors'><center>Извините, темы не существует</center></div>n";
}
/////////////////////////////////////////
require_once '../design/styles/'.htmlspecialchars($api_design).'/footer.php';
?>