Файл: public_html/modules/alliance/forum/theme.php
Строк: 93
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
$allianceId = fl($_GET['alliance']);
if(empty($allianceId)) redirect('/alliance/');
$section = fl($_GET['section']);
$sectionInfo = $db->query("SELECT * FROM `alliance_forum_sections` WHERE `id` = '".$section."'");
if($sectionInfo->num_rows == 0) redirect('/alliance/forum/'.$allianceId);
if(allianceInfo($allianceId, 'id') == 'error') redirect('/alliance');
$sectionInfo = $sectionInfo->fetch_object();
if($sectionInfo->access != 'all' && $u['alliance_id'] != $allianceId) redirect('/alliance/forum/'.$allianceId);
$theme_id = fl($_GET['theme']);
$theme = $db->query("SELECT * FROM `alliance_forum_themes` WHERE `id` = '".$theme_id."'")->fetch_object();
$header = $theme->name;
include_once ($root.'/core/head.php');
if(isset($_GET['addcomment']))
{
$text = fl($_POST['text']);
if($ban->num_rows > 0) redirect('/', 'Вы заткнуты!');
if($u['save'] == 1) $db->query("INSERT INTO `alliance_forum_posts` (`text`,`author`,`time`,`theme_id`) VALUES ('".$text."', '".$u['id']."', '".time()."', '".$theme_id."')");
header("Location: /alliance/forum/".$allianceId."/".$section."/theme".$theme_id);
exit;
}
if(isset($_GET['close']))
{
if($u['id'] != $theme->author) redirect('/alliance/forum/'.$allianceId.'/'.$section.'/theme'.$theme_id);
if($theme->opened == 0) redirect('/alliance/forum/'.$allianceId.'/'.$section.'/theme'.$theme_id);
$db->query("UPDATE `alliance_forum_themes` SET `opened` = '0' WHERE `id` = '".$theme_id."'");
redirect('/alliance/forum/'.$allianceId.'/'.$section.'/theme'.$theme_id);
}
echo '<div class = "b">'.who($theme->author).' | '.gmdate('d.m.y в H:i:s', $theme->time).'<br>'.smiles($theme->text).'</a></div>';
$count = $db -> query("SELECT * FROM `alliance_forum_posts` WHERE `theme_id` = '".$theme_id."' ORDER BY `time` DESC") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10*$page-10;
$sql = $db -> query("SELECT * FROM `alliance_forum_posts` WHERE `theme_id` = '".$theme_id."' ORDER BY `time` DESC LIMIT $start, 10");
echo '<div class = "b"><center>Комментариев: '.$count.'</center></div>';
while($q = $sql->fetch_object())
{
echo '<div class = "b">'.who($q->author).' | '.gmdate('d.m.y в H:i:s', $q->time).'<br>'.smiles($q->text).'</div>';
}
if($count >= 10) echo str('/alliance/forum/'.$allianceId.'/'.$section.'/theme'.$theme_id.'?',$k_page,$page);
if($theme->opened == 1 && $u['save'] == 1)
{
echo '<div class = "b"><center><form action="/alliance/forum/'.$allianceId.'/'.$section.'/theme'.$theme_id.'/addComment"
method="post">
Текст комментария:<br>
<textarea name="text" required></textarea></a><br>
<center><input type="submit" name="addcomment" value="Отправить">
</form> </center></div>';
}
elseif($theme->opened == 0)
{
echo '<div class="b"><center><font color="red">Тема закрыта!</font></center></div>';
}
else
{
echo '<div class="b"><center>Вы не сохранены!</center></div>';
}
if(($u['id'] == $theme->author) && $theme->opened == 1) echo '<a class="link" href="?close">Закрыть тему</a>';
include_once ($root.'/core/foot.php');