View file Dasty_Social/modules/blogs/add.php

File size: 6.09Kb
<?

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 (mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `razdel` = 'notes' AND `id_user` = '$user[id]' AND (`time` > '$time' OR `view` = '0' OR `navsegda` = '1')"), 0)!=0)
{
header('Location: /ban.php?'.SID);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['rating'] < 2 || $user['group_access'] < 6 ))
{
if (!isset($_SESSION['captcha']))$err[]='Ошибка проверочного числа';
if (!isset($_POST['chislo']))$err[]='Введите проверочное число';
elseif ($_POST['chislo']==null)$err[]='Введите проверочное число';
elseif ($_POST['chislo']!=$_SESSION['captcha'])$err[]='Проверьте правильность ввода проверочного числа';
}

if (!isset($err))
{
if(empty($_POST['title'])){
$title=esc(stripslashes(htmlspecialchars(substr($_POST['msg'],0,24)))).' ...';
$title=my_esc($title);
}else{
$title=my_esc($_POST['title']); }
$msg = my_esc($_POST['msg']);
$id_dir = intval($_POST['id_dir']);

if (isset($_POST['private'])){
$privat=intval($_POST['private']);
}else{
$privat=0;
}
if (isset($_POST['private_komm'])){
$privat_komm=intval($_POST['private_komm']);
}else{
$privat_komm=0;
}

$type=0;

if (strlen2($title)>32){$err='Название не может превышать больше 32 символов';}
if (strlen2($msg)>30000){$err='Содержание не может превышать больше 30000 символов';}
if (strlen2($msg)<2 && $type == 0){$err='Содержание слишком короткое';}

if (!isset($err)){
mysql_query("INSERT INTO `notes` (`time`, `msg`, `name`, `id_user`, `private`, `private_komm`, `id_dir`, `type`) values('$time', '$msg', '$title', '$user[id]', '$privat', '$privat_komm', '$id_dir', '$type')");
$st = mysql_insert_id();
if($privat!=2){
mysql_query("insert into `stena`(`id_stena`,`id_user`,`time`,`info`,`info_1`,`type`) values('".$user['id']."','".$user['id']."','".$time."','новый дневник','".$st."','note')");
}
/*
===================================
Лента
===================================
*/

$q = mysql_query("SELECT * FROM `frends` WHERE `user` = '".$user['id']."' AND `i` = '1'");
while ($f = mysql_fetch_array($q))
{
$a=get_user($f['frend']);
$lentaSet = mysql_fetch_array(mysql_query("SELECT * FROM `tape_set` WHERE `id_user` = '".$a['id']."' LIMIT 1")); // Общая настройка ленты
 
if ($f['lenta_notes'] == 1 && $lentaSet['lenta_notes'] == 1 ) // фильтр рассылки
mysql_query("INSERT INTO `tape` (`id_user`,`avtor`, `type`, `time`, `id_file`) values('$a[id]', '$user[id]', 'notes', '$time', '$st')"); }
		   
mysql_query("OPTIMIZE TABLE `notes`");

//Начисление рейтинга и монет за активность
mysql_query("UPDATE `user` SET `money` = '" . ($user['money'] + 1) . "', `rating_tmp` = '" . ($user['rating_tmp'] + 0) . "' WHERE `id` = '$user[id]' LIMIT 1");

$_SESSION['message'] = 'Блог успешно создан';

//Активность
if($user['pol']==1){
$pol = 'Создал';
}else{
$pol='Создала';
}
mysql_query("INSERT INTO `activnost` SET `msg` = '$pol новый [url=/modules/blogs/]блог[/url]', `time`='$time' ,`id_user` = '$user[id]'");

header("Location: list.php?id=$st");
$_SESSION['captcha']=NULL;
exit;
}
}
}
if (isset($_GET['id_dir']))
$id_dir=intval($_GET['id_dir']);
else
$id_dir=0;
err();
aut();
if (isset($_POST["msg"])) $msg = output_text($_POST["msg"]);
echo '<div class="mess">';
echo "<form method=\"post\" name=\"message\" action=\"add.php\">\n";
echo "<input placeholder='Название' 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';
else
echo "<textarea style='height: 100px;' placeholder='Сообщение' name=\"msg\"></textarea><br />\n";

echo "<select name='id_dir'>\n";
$q=mysql_query("SELECT * FROM `notes_dir` ORDER BY `id` DESC");
echo "<option value='0'".($id_dir==0?" selected='selected'":null).">Выберите категорию</option>\n";

while ($post = mysql_fetch_assoc($q))
{
echo "<option value='$post[id]'".($id_dir == $post['id']?" selected='selected'" : null).">" . text($post['name']) . "</option>\n";
}

echo "</select>";

echo '</div>';

echo '<div class="radio">';
echo '<div class="mess">';
echo "Могут смотреть:</br>
<input id='0' name='private' type='radio' value='0'  selected='selected'/><label for='0'>Все</label></br>";
echo "<input id='1' name='private' type='radio'  value='1' /><label for='1'>Друзья</label></br>";
echo "<input id='2' name='private' type='radio'  value='2' /><label for='2'>Только я</label></br>";

echo "Могут комментировать:</br>
<input id='3' name='private_komm' type='radio' value='0'  selected='selected'/><label for='3'>Все</label></br>";
echo "<input id='4' name='private_komm' type='radio' value='1' /><label for='4'>Друзья</label></br>";
echo "<input id='5' name='private_komm' type='radio' value='2' /><label for='5'>Только я</label></div>";
echo '</div>';

echo '<div class="mess">';
if ($user['rating'] < 6 || $user['group_access'] < 6)
echo "<img src='/sys/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\" />";
echo "</form>\n";
echo '</div>';

include_once '../../sys/inc/tfoot.php';
?>