View file forum/m/forum.php

File size: 12.4Kb
<?php
// Системный файл для надстроек
require('../flowap/system.php');
//
switch ($act) {
	default:
		$title->SetTitle('Форум');
		$title->GetHeader();
		?>
		<div class="_34t5rgteg">
			<div id="oshhb" style="display: none;"><?php echo $errs;?></div>
			<div class="_3rt4g5hegrf4"><i class="fas fa-feather"></i> Форум</div>
			<?php if(isset($user['id']) and $user['lvl'] == 100) echo '<a href="/forum/addrazd/" class="_34fgrwed"><i class="fas fa-plus"></i> Создать раздел</a>'; ?>
			<?php $sql = DB::$dbs->query('SELECT `id`,`name`,`url` FROM `forum_razd` ORDER BY `id` ASC LIMIT 15')->fetchAll(PDO::FETCH_BOTH);
				foreach ($sql as $sqlls => $im): ?>
					<a href="/forum/r/<?php echo $im['url'];?>/" class="_34fgrwed"><i class="fas fa-angle-double-right"></i> <?php echo $im['name']; ?></a>
			<?php endforeach?>
		</div>
		<?php
		$title->GetFooter();
	break;
	case 'addrazd':
		if (empty($user['id']) or $user['lvl'] < 100): header('location: /'); exit; endif;
		$title->SetTitle('Создать раздел');
		$title->GetHeader();
		?>в
		<div class="_34t5rgteg">
			<div id="oshhb" style="display: none;"><?php echo $errs;?></div>
			<div class="_3rt4g5hegrf4"><i class="fas fa-plus"></i> Создать раздел</div>
			<div class="_3rfgwvwdd3 _dop345yhte">
				<form id="formj_1" action="" onsubmit="return false;">
					<input type="text" maxlength="30" name="names" value="" class="_dop34t5geefgf" autofocus="true" style="padding-right: 0;" placeholder="Название раздела">
					<input onclick='saveform ("/ajax/forum.php?act=addrazd","1");return false;' type="submit" name="add" class="_dop34tgweef" value="Создать">
				</form>
			</div>
		</div>
		<div class="_34t5rgteg">
			<div class="_3rt4g5hegrf4"><i class="fas fa-biohazard"></i> Созданные разделы</div>
			<?php $sql = DB::$dbs->query('SELECT `id`,`name` FROM `forum_razd` ORDER BY `id` ASC LIMIT 15')->fetchAll(PDO::FETCH_BOTH);
				foreach ($sql as $sqlls => $im): ?>
					<div class="_3rfgwvwdd3"><?php echo $im['name']; ?></div>
			<?php endforeach; ?>
		</div>
		<?php
		$title->GetFooter();
	break;
	case 'razdel':
		$url = functions::htmlred($_GET['url']);
		$sql = DB::$dbs->queryFetch('SELECT `id`,`name` FROM `forum_razd` WHERE `url` = ? LIMIT 1', [$url]);
		if (empty($sql['id'])): $_SESSION['err'] = 'Такого раздела нет.'; header('location: /'); exit; endif;
		$title->SetTitle('Раздел форума :: '.$sql['name']);
		$title->GetHeader();
		?>
		<div class="_34t5rgteg">
			<div id="oshhb" style="display: none;"><?php echo $errs;?></div>
			<div class="_3rt4g5hegrf4"><i class="fas fa-feather"></i> <?php echo $sql['name'];?></div>
			<?php if(isset($user['id']) and $user['lvl'] == 100) echo '<a href="/forum/addpodr/'.$sql['id'].'/" class="_34fgrwed"><i class="fas fa-plus"></i> Создать подраздел</a>';
			$sql = DB::$dbs->query('SELECT `id`,`name`,`url` FROM `forum_podr` WHERE `id_razd` = ? ORDER BY `id` ASC LIMIT 15',[$sql['id']])->fetchAll(PDO::FETCH_BOTH);
				foreach ($sql as $sqlls => $im): ?>
					<a href="/forum/p/<?php echo $im['url'];?>/" class="_34fgrwed"><i class="fas fa-angle-double-right"></i> <?php echo $im['name']; ?></a>
			<?php endforeach?>
		</div>
		<?php
		$title->GetFooter();
	break;
	case 'addpodr':
		if (empty($user['id']) or $user['lvl'] < 100): header('location: /'); exit; endif;
		$sql = DB::$dbs->queryFetch('SELECT `id` FROM `forum_razd` WHERE `id` = ? LIMIT 1', [$id]);
		if (empty($sql['id'])): $_SESSION['err'] = 'Такого раздела нет.'; header('location: /'); exit; endif;
		$title->SetTitle('Создать подраздел');
		$title->GetHeader();
		?>
		<div class="_34t5rgteg">
			<div id="oshhb" style="display: none;"><?php echo $errs;?></div>
			<div class="_3rt4g5hegrf4"><i class="fas fa-feather"></i> Создать подраздел</div>
			<div class="_3rfgwvwdd3 _dop345yhte">
				<form id="formj_1" action="" onsubmit="return false;">
					<input type="text" maxlength="30" name="names" value="" class="_dop34t5geefgf" autofocus="true" style="padding-right: 0;" placeholder="Название раздела">
					<input onclick='saveform ("/ajax/forum.php?act=addpodr&id=<?php echo $sql['id'];?>","1");return false;' type="submit" name="add" class="_dop34tgweef" value="Создать">
				</form>
			</div>
		</div>
		<div class="_34t5rgteg">
			<div class="_3rt4g5hegrf4"><i class="fas fa-biohazard"></i> Созданные подразделы</div>
			<?php $sql = DB::$dbs->query('SELECT `id`,`name` FROM `forum_podr` WHERE `id_razd` = ? ORDER BY `id` ASC LIMIT 15',[$sql['id']])->fetchAll(PDO::FETCH_BOTH);
				foreach ($sql as $sqlls => $im): ?>
					<div class="_3rfgwvwdd3"><?php echo $im['name']; ?></div>
			<?php endforeach?>
		</div>
		<?php
		$title->GetFooter();
	break;
	case 'podr':
		$url = functions::htmlred($_GET['url']);
		$sql = DB::$dbs->queryFetch('SELECT `id`,`name` FROM `forum_podr` WHERE `url` = ? LIMIT 1', [$url]);
		if (empty($sql['id'])): $_SESSION['err'] = 'Такого подраздела нет.'; header('location: /'); exit; endif;
		$title->SetTitle('Подраздел форума :: '.$sql['name']);
		$title->GetHeader();
		?>
		<div class="_34t5rgteg">
			<div id="oshhb" style="display: none;"><?php echo $errs;?></div>
			<div class="_3rt4g5hegrf4"><i class="fas fa-feather"></i> <?php echo $sql['name'];?></div>
			<?php if(isset($user['id'])) echo '<a href="/forum/addthem/'.$sql['id'].'/" class="_34fgrwed"><i class="fas fa-plus"></i> Создать тему</a>';
			if(DB::$dbs->querySingle('SELECT COUNT(`id`) FROM `forum_them` WHERE `id_podr` = ?', [$sql['id']]) > 0):
				$sql = DB::$dbs->query('SELECT `id`,`name`,`status`,`idus`,`time` FROM `forum_them` WHERE `id_podr` = ? ORDER BY `dateupd` DESC LIMIT 15',[$sql['id']])->fetchAll(PDO::FETCH_BOTH);
					foreach ($sql as $sqlls => $im): ?>
						<a href="/forum/t/<?php echo $im['id'];?>/" class="_34fgrwed">
							<div class="_dopwer5ethd"><?php echo $im['name']; ?> <?php echo $im['status'] == 2 ? '<i class="_dop3r4t5grwe fas fa-lock"></i>' : NULL;?> </div>
							<div style="font-size: 15px;color: #b1b1b1;" class="_dopwer5ethd"><?php echo user::logins(['id' => $im['idus']]);?> <span class="_3te4grbfseagw"></span> <?php echo functions::times($im['time']);?></div>
						</a>
				<?php endforeach;
				else: ?>
					<div class="_3rfgwvwdd3 _dop345yhte">Тем нет.</div>
			<?php endif?>
		</div>
		<?php
		$title->GetFooter();
	break;
	case 'addthem':
		if (empty($user['id'])): header('location: /'); exit; endif;
		$sql = DB::$dbs->queryFetch('SELECT `id` FROM `forum_podr` WHERE `id` = ? LIMIT 1', [$id]);
		if (empty($sql['id'])): $_SESSION['err'] = 'Такого подраздела нет.'; header('location: /'); exit; endif;
		$title->SetTitle('Создать тему');
		$title->GetHeader();
		?>
		<div class="_34t5rgteg">
			<div id="oshhb" style="display: none;"><?php echo $errs;?></div>
			<div class="_3rt4g5hegrf4"><i class="fas fa-feather"></i> Создание темы</div>
			<div class="_3rfgwvwdd3 _dop345yhte">
				<form id="formj_1" action="" onsubmit="return false;">
					<input type="text" maxlength="30" name="names" value="" class="_dop34t5geefgf" autofocus="true" placeholder="Название темы">
					<textarea placeholder="Текст темы" name="textt" class="_doprtjyr45g" style="overflow-y: hidden;"></textarea>
					<div style="margin-bottom: 5px;"><img style="cursor: pointer;width: 67px;" onclick="this.setAttribute('src','/css/captcha/kcaptcha.php?'+Math.random());var captcha=document.getElementById('obnc');if(captcha){captcha.focus()}" id="obnc" src="/css/captcha/kcaptcha.php" title="Обновить капчу" /></div>
					<input type="text" maxlength="8" name="captcha" value="" class="_dop34t5geefgf" autocomplete="off" autofocus="true" placeholder="Код с картинки">
					<input onclick="saveform ('/ajax/forum.php?act=addthem&id=<?php echo $sql['id'];?>','1');return false;" type="submit" name="add" class="_dop34tgweef" value="Создать тему">
				</form>
			</div>
		</div>
		<?php
		$title->GetFooter();
	break;
	case 'them':
		$sql = DB::$dbs->queryFetch('SELECT `id`,`name`,`idus`,`text`,`status` FROM `forum_them` WHERE `id` = ? LIMIT 1', [$id]);
		if (empty($sql['id'])): $_SESSION['err'] = 'Такой темы не существует.'; header('location: /'); exit; endif;
		$title->SetTitle('Тема на форуме :: '.$sql['name']);
		$title->GetHeader();
		//
		if(isset($_GET['close']) and $sql['idus'] == $user['id'] and $sql['status'] == 1):
			if($sql['status'] == 1):
				DB::$dbs->query('UPDATE `forum_them` SET `status` = 2 WHERE `id` = ? LIMIT 1', [$id]);
				$_SESSION['good'] = 'Тема закрыта.';
				header('location: /forum/t/'.$id.'/'); exit;
			else:
				DB::$dbs->query('UPDATE `forum_them` SET `status` = 1 WHERE `id` = ? LIMIT 1', [$id]);
				$_SESSION['good'] = 'Тема открыта.';
				header('location: /forum/t/'.$id.'/'); exit;
			endif;
		endif?>
		<div class="_34t5rgteg">
			<div id="oshhb" style="display: none;"><?php echo $errs;?></div>
			<div class="_3rt4g5hegrf4"><?php echo $sql['name'];?></div>
			<table class="_4rgethbrs" style="line-height: 25px;">
				<tbody>
					<tr>
						<td style="width: 60px;text-align: center;">
							<?php echo user::avass(['id' => $sql['idus'],'opts' => ['rad' => NULL,'razm' => '50px','mobe' => 1]]);?>
						</td>
						<td>
							<div style="display: inline-block;"><?php echo user::logins(['id' => $sql['idus'],'url' => 1,'dop' => 1]);?></div>
							<?php if(isset($user['id']) and $sql['idus'] == $user['id'] and $sql['status'] == 1): ?>
							<div onclick="okeaw(2);return;" style="display: inline-block;float: right;opacity: .5;padding: 5px;cursor: pointer;"><i class="fas fa-ellipsis-h"></i></div>
							<div id="menuss_2" class="_3r4gwedwf _dop34t5ge">
								<div onclick="zaiid(<?php echo $sql['id'];?>,1,'/ajax/forum.php?act=redthem');return;">Редактировать</div>
								<a href="?close">Закрыть тему</a>
							</div>
							<?php endif?>
							<div title="когда был онлайн на сайте"><?php echo user::vseet(['id' => $sql['idus']]);?></div>
						</td>
					</tr>
				</tbody>
			</table>
			<div class="_3rfgwvwdd3 _dop345yhte" id="them_<?php echo $sql['id'];?>">
				<div><?php echo bbcode::tags($sql['text']);?></div>
				<?php if(DB::$dbs->querySingle('SELECT COUNT(`id`) FROM `forum_files` WHERE `idthem` = ?', [$id]) > 0): ?>
					<div class="_dop345grwe _dop34t5hter">Прикрепленные файлы:</div>
					<?php $sql2 = DB::$dbs->query('SELECT `file`,`raz` FROM `forum_files` WHERE `idthem` = ? ORDER BY `id` ASC LIMIT 15',[$id])->fetchAll(PDO::FETCH_BOTH);
					foreach ($sql2 as $sqlls2 => $files): ?>
						<div><i class="_dop34t5hter fas fa-file-archive"></i> <a title="скачать файл" class="_dop34t5hter _dop34tg5rtw" href="/files/them/<?php echo $files['file'];?>"><?php echo $files['file'];?></a></div>
					<?php endforeach;
				endif?>
				<?php if(isset($user['id']) and $sql['idus'] == $user['id'] and $sql['status'] == 1): ?>
					<div style="padding: 5px 0 2px 0;">
						<form style="display: inline-block;" action="/upload/them/<?php echo $sql['id'];?>/" class="_dop45yhewfew" method="post" enctype="multipart/form-data">
							<input type="file" name="file" id="file" class="_45y46hew" onchange="this.form.submit ()">
							<label for="file"><i class="fas fa-paperclip"></i></label>
						</form>
					</div>
				<?php endif?>
			</div>
		</div>
		<div class="_34t5rgteg">
			
			<script type="text/javascript">
				function deiil (ids,formass) {
					$.ajax({
						url: formass,
						type: 'post',
						data: {id: ids},
						success: function(data) {
							const obj = jQuery.parseJSON(data);
							if (obj.type == 'success') {
								alert();
							} else if (obj.type == 'error') {
								window.location.href = obj.location; 
							}
						}
					});
				}

			</script>
			<?php
			$komm->vivkomm([
				'sett' => [
					'idchto' => $id,
					'chto' => 1,
					'status' => $sql['status']
				]
			]);

			$komm->addkomm([
				'sett' => [
					'idchto' => $id,
					'chto' => 1,
					'status' => $sql['status']
				],
				'url' => $_SERVER['REQUEST_URI']
			]);
			?>
		</div>
		<?php
		$title->GetFooter();
	break;
}
?>