<?
include_once '../../sys/inc/start.php';
include_once '../../sys/inc/compress.php';
include_once '../../sys/inc/sess.php';
include_once '../../sys/inc/home.php';
include_once '../../sys/inc/settings.php';
include_once '../../sys/inc/db_connect.php';
include_once '../../sys/inc/ipua.php';
include_once '../../sys/inc/fnc.php';
include_once '../../sys/inc/adm_check.php';
include_once '../../sys/inc/user.php';
if (isset($_GET['id_dir']))
{
$id_dir=intval($_GET['id_dir']);
}
else
{
echo "Ошибка";
exit;
}
$set['title']='Новое объявление';
include_once '../../sys/inc/thead.php';
title();
if (!isset($user))header("location: index.php?");
if (isset($_POST['title']) && isset($_POST['msg']))
{
if ($user['level']==0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `users_konts` WHERE `id_kont` = '$user[id]' AND `id_user` = '$ank[id]'"), 0)==0)
{
if (!isset($_SESSION['captcha']))$err[]='Ошибка проверочного числа';
if (!isset($_POST['chislo']))$err[]='Введите проверочное число';
elseif ($_POST['chislo']==null)$err[]='Введите проверочное число';
elseif ($_POST['chislo']!=$_SESSION['captcha'])$err[]='Проверьте правильность ввода проверочного числа';
}
if ($user['balls']<49){
$err = 'У вас не достаточно баллов';
}
if (!isset($err))
{
$title=my_esc($_POST['title'],1);
$msg=my_esc($_POST['msg']);
$id_dir=intval($_POST['id_dir']);
/*
if (isset($_POST['type'])){
$type=intval($_POST['type']);
}else{
$err='Укажите тип объявления';
}
*/
if (strlen2($title)>32){$err='Название не может превышать больше 32 символов';}
if (strlen2($title)<3){$err='Короткое название';}
if (strlen2($msg)>30000){$err='Содержание не может превышать больше 30000 символов';}
if (strlen2($msg)<2){$err='Содержание слишком короткое';}
if (!isset($err)){
mysql_query("INSERT INTO `ads` (`time`, `msg`, `name`, `id_user`, `id_dir`, `type`) values('$time', '$msg', '$title', '$user[id]', '$id_dir', '$type')");
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']-50)."' WHERE `id` = '$user[id]' LIMIT 1",$db);
mysql_query("OPTIMIZE TABLE `ads`");
$pos=mysql_result(mysql_query("SELECT MAX(`id`) FROM `ads`"), 0);
header("Location: list.php?id=$pos");
$_SESSION['captcha']=NULL;
}
}
}
err();
aut();
if ($user['balls']<49){
err('У вас не достаточно баллов для добавления объявления');
}
echo "<div class='main'>\n";
echo "После размещения объявления с вас спишется 50 баллов сайта, сейчас у вас $user[balls] баллов.";
echo "</div>\n";
echo "<form method=\"post\" name=\"message\" action=\"add.php?id_dir=$id_dir\">\n";
echo "Название:<br />\n<input name=\"title\" size=\"16\" maxlength=\"32\" value=\"\" type=\"text\" /><br />\n";
if ($set['web'] && is_file(H.'style/themes/'.$set['set_them'].'/altername_post_form.php'))
include_once H.'style/themes/'.$set['set_them'].'/altername_post_form.php';
elseif ($set['mobile'] && is_file(H.'style/themes/'.$set['set_them'].'/altername_post_form.php'))
include_once H.'style/themes/'.$set['set_them'].'/altername_post_form.php';
elseif ($set['smart'] && is_file(H.'style/themes/'.$set['set_them'].'/altername_post_form.php'))
include_once H.'style/themes/'.$set['set_them'].'/altername_post_form.php';
else
echo "Сообщение:<br />\n<textarea name=\"msg\"></textarea><br />\n";
echo "Категория:<br />\n<select name='id_dir'>\n";
$q=mysql_query("SELECT * FROM `ads_dir` ORDER BY `id` DESC");
while ($post = mysql_fetch_assoc($q))
{
echo "<option value='$post[id]'".($id_dir==$post['id']?" selected='selected'":null).">$post[name]</option>\n";
}
echo "</select><br />\n";
/*
echo "<div class='main'>Тип:<br />";
echo "<input name='type' type='radio' value='0' />Куплю ";
echo "<input name='type' type='radio' value='1' />Продам </div>";
echo "<input name='type' type='radio' value='2' />Другое </div>";
*/
if ($user['level'] < 1)
echo "<img src='/captcha.php?SESS=$sess' width='100' height='30' alt='Проверочное число' /><br />\n<input name='chislo' size='5' maxlength='5' value='' type='text' /><br/>\n";
echo "<input value=\"Создать\" type=\"submit\" />\n";
echo "</form>\n";
echo "<div class='foot'>\n";
echo "«<a href='index.php'>Объявления</a><br />\n";
echo "</div>\n";
include_once '../../sys/inc/tfoot.php';
?>