Файл: moduls/forum/new_theme.php
Строк: 109
<?php
/**
* @package Prime Social
* @link http://primesocial.ru
* @copyright Copyright (C) 2016 Prime Social
* @author BoB | http://primesocial.ru/about
*/
require_once('../../core/start.php');
check_auth();
$forum = DB::$dbs->queryFetch("SELECT * FROM ".FORUMS." WHERE `id` = ? ", array(abs(num($_GET['forum']))));
if (empty($forum)) {
head('Forum topilmadi');
echo DIV_ERROR . 'Xatolik!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <a href="'.HOME.'/forum/">Forum</a> / <b>Forum topilmadi</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
$forumc = DB::$dbs->queryFetch("SELECT * FROM ".FORUMS_CAT." WHERE `id` = ? ", array(abs(num($_GET['forumc']))));
if (empty($forumc)) {
head('Podforum topilmadi');
echo DIV_ERROR . 'Xatolik!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <a href="'.HOME.'/forum/">Forum</a> / <b>Podforum topilmadi</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
head('Yangi mavzu | ' . $forumc['name']);
if ($_POST['add']) {
$name2 = html($_POST['name']);
$msg = html($_POST['msg']);
$uvedom = abs(num($_POST['uvedom']));
$vote = html($_POST['vote']);
$vote_1 = html($_POST['vote_1']);
$vote_2 = html($_POST['vote_2']);
$vote_3 = html($_POST['vote_3']);
$vote_4 = html($_POST['vote_4']);
$vote_5 = html($_POST['vote_5']);
$vote_6 = html($_POST['vote_6']);
$vote_7 = html($_POST['vote_7']);
$vote_8 = html($_POST['vote_8']);
$vote_9 = html($_POST['vote_9']);
$vote_10 = html($_POST['vote_10']);
if (empty($name2)) {
$err = 'Mavzu nomini kiriting.<br />';
}
if (strlen($name2) < 8) {
$err .= 'Mavzu nomi juda qisqa. [min. 8 belgi]<br />';
}
if (empty($msg)) {
$err .= 'Mavzu matnini to`ldiring.<br />';
}
if (strlen($msg) < 20) {
$err .= 'Juda qisqa habar. [min. 20 belgi]<br />';
}
if (!empty($vote) && strlen($vote) < 20) {
$err .= 'So`rovnoma nomi juda qisqa. [min. 10 belgi]<br />';
}
if (!empty($vote) && (empty($vote_1) || empty($vote_2))) {
$err .= 'So`rovnomaning asosiy variantlarini to`ldiring';
}
if (!empty($_FILES['file'])) {
$name = $_FILES['file']['name']; # Название файла
$ext = strtolower(strrchr($name, '.')); # Расширение файла
$size = $_FILES['file']['size']; # Вес файла
$time = time();
$file = $time.$ext;
if ($size > (1048576 * $config['max_upload_forum'])) {
$err .= 'Fayl hajmi belglangan miqdordan ortmoqda. [Max. '.$config['max_upload_forum'].'Mb.]<br />';
}
if (preg_match('/.php/i', $name) || preg_match('/.pl/i', $name) || $name == '.htaccess') {
$err .= 'Fayl formatida xatolik.<br />';
}
}
if (empty($err)) {
if (!empty($ext)) {
copy($_FILES['file']['tmp_name'], '../../files/forum/'.$time.$ext);
}
$file = (empty($ext) ? 0 : $file);
DB::$dbs->query("INSERT INTO ".FORUM_THEME." (`forum_id`, `forumc_id`, `name`, `user_id`, `uvedom`, `time`, `vote`, `vote_1`, `vote_2`, `vote_3`, `vote_4`, `vote_5`, `vote_6`, `vote_7`, `vote_8`, `vote_9`, `vote_10`, `activ`) VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", array($forum['id'], $forumc['id'], $name2, $user['user_id'], $uvedom, time(), $vote, $vote_1, $vote_2, $vote_3, $vote_4, $vote_5, $vote_6, $vote_7, $vote_8, $vote_9, $vote_10, time()));
$lastid = DB::$dbs->lastInsertId();
DB::$dbs->query("INSERT INTO ".FORUM_POST." (`forum_id`, `forumc_id`, `theme_id`, `msg`, `user_id`, `time`, `file`) VALUES
(?,?,?,?,?,?,?)", array($forum['id'], $forumc['id'], $lastid, $msg, $user['user_id'], time(),$file));
balls_operation(10);
header("Location: ".HOME."/forum/".$forum['id']."/".$forumc['id']."/".$lastid."/");
} else {
echo DIV_ERROR . $err . CLOSE_DIV;
}
}
echo '<div class="white">
<span style="color: #70B000;font-size:11px;">Diqqat! Mavzu ochayotganda imlo qoidalariga amal qiling va <a href="/forum/"><u>Izlashdan</u></a> foydalaning agar bo`limda shunday mavzu bo`lsa,
mavzungiz yopiladi va ogohlantirilasiz.
</span>' . CLOSE_DIV;
echo DIV_BLOCK;
echo '<form action="#" enctype="multipart/form-data" method="POST">';
echo '<b>Mavzu nomi:</b> [min. 8]<br /><input type="text" name="name" /><br /><br />';
echo '<b>Mavzu matni:</b> [min. 20]<br /><textarea name="msg"></textarea><br />';
echo '<b>Fayl biriktirish:</b> [max. '.$config['max_upload_forum'].'mb.]<br /><input type="file" name="file"/><br /><br />';
echo 'Qoldirilgan sharhlar haqida habardor qilish: <input type="checkbox" name="uvedom" value="1" /><br /><br />';
echo '<b style="color: #0566A3;">+ So`rovnoma yaratish:</b><br /><br />';
echo '<b>Nomi:</b> [min. 10]<br /><input type="text" name="vote" /><br />';
echo '<b>Variantlar:</b> [min. 2 shart]]<br />';
echo '<b>1.</b><input type="text" name="vote_1" /><br />';
echo '<b>2.</b><input type="text" name="vote_2" /><br />';
echo '<b>3.</b><input type="text" name="vote_3" /><br />';
echo '<b>4.</b><input type="text" name="vote_4" /><br />';
echo '<b>5.</b><input type="text" name="vote_5" /><br />';
echo '<b>6.</b><input type="text" name="vote_6" /><br />';
echo '<b>7.</b><input type="text" name="vote_7" /><br />';
echo '<b>8.</b><input type="text" name="vote_8" /><br />';
echo '<b>9.</b><input type="text" name="vote_9" /><br />';
echo '<b>10.</b><input type="text" name="vote_10" /><br /><br />';
echo '<input type="submit" name="add" value="Mavzu ochish" /><br />';
echo '</form>';
echo CLOSE_DIV;
$array = array('Forum');
nav($array);
require_once('../../core/stop.php');
?>