<?
#-----------------------------------------------#
# Аuthor: Nu3oN #
# ICQ : 100-50-97 #
#-----------------------------------------------#
require_once ('../includes/start.php');
require_once ('../includes/functions.php');
require_once ('../includes/header.php');
require_once ('distribution/db.php');
require_once ('distribution/fnc.php');
if (empty($do))
{
include_once ('../themes/'.$config['themes'].'/index.php');
show_title('partners.gif', 'Блоги от Nu3oN');
include_once ('distribution/management.php');
$cat_trees = mysql_query("SELECT * FROM `blog_categories` ORDER BY `id` DESC");
if (mysql_num_rows($cat_trees))
{
while ($_outCat = mysql_fetch_array($cat_trees)):
echo '<div class="b"><img src="images/dir.gif" alt="Image" />
<a href="index.php?do=category&id='.$_outCat['id'].'&'.SID.'"><b>'.$_outCat['name_category_blog'].'</b></a>
('.mysql_result(mysql_query("SELECT COUNT(*) FROM `directly_blogs` WHERE `id_blog_category` = '".$_outCat['id']."'"),0).')';
if (is_user() and is_admin(array(101,102)) and $_SESSION['ners'] == true){
echo '<span style="font-size: xx-small;">
[<a href="index.php?editeCat='.$_outCat['id'].'&'.SID.'"><span style="color:#009900;">EDIT</span></a> |
<a href="index.php?deleteCat='.$_outCat['id'].'&'.SID.'"><span style="color:#ff0000">DEL</span></a>]
</span>';
}
if (isset($_GET['deleteCat']) and $_outCat['id'] == $_delCat)
{
echo '</div>'; include_once ('distribution/formsActions.php');
}
else
{
echo '</div><div>'.$_outCat['comm_category_blog'].'</div>';
}
endwhile;
}
else
{
echo '<div class="b"><b> Категории не созданы! </b><br /> Создайте категории =) </div>';
include_once ('distribution/formsActions.php');
}
if (is_user() and is_admin(array(101,102)))
{
echo '<div class="b"><span style="font-size: xx-small;">Админка: </span>';
if ($_SESSION['ners'] == false)
{
echo '<span style="font-size: xx-small;"><a href="index.php?add_razdel&'.SID.'">On</a>/Off </span>';
}
else
{
echo '<span style="font-size: xx-small;">On/<a href="index.php?add_razdel&'.SID.'">Off</a> </span>';
include_once ('distribution/formsActions.php');
}
echo '</span></div>';}
echo '<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a>';
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}else if($do == 'category'){
if ($cat_tree = mysql_fetch_array(mysql_query("SELECT * FROM `blog_categories` WHERE `id` = '".$id."'"))){
include_once ('../themes/'.$config['themes'].'/index.php');
show_title('partners.gif', 'Блоги / '.$cat_tree['name_category_blog']);
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `directly_blogs` WHERE `id_blog_category` = '".$id."'"), 0);
if ($start > $total) $start = false;
if ($total < $start + $config['navig_blog']) $end = $total;
else $end = $start + $config['navig_blog'];
$blog_kel = mysql_query("SELECT * FROM `directly_blogs` WHERE `id_blog_category` = '".$id."' ORDER BY `id` DESC LIMIT ".$start.",".$config['navig_blog']."");
echo '<a href="#down"><img src="../images/img/downs.gif" alt="image" /></a>
<a href="index.php?do=new_blog&id='.$id.'"> Создать блог </a><br />';
if (mysql_num_rows($blog_kel))
{
while($blog_ges = mysql_fetch_array($blog_kel)):
$_totalComm = mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_comments` WHERE `id_blog` = '".$blog_ges['id']."'"),0);
$_authorNic = nickname($blog_ges['author_blog_categories']);
$_authorLog = $blog_ges['author_blog_categories'];
echo '<div class="b"> <img src="images/blg.gif" alt="Image" />
<a href="index.php?do=blog&id='.$blog_ges['id'].'&'.SID.'"><b>'.$blog_ges['name_blog_categories'].'</b></a>';
if (is_user() and is_admin(array(101,102,103,104,105)) and $_SESSION['ners'] == true){
echo ' <a href="index.php?do=del_blog&id='.$blog_ges['id'].'"><span style="color:#FF0000">[Del]</span></a>';}
echo '</div><div>
Просмотров: '.$blog_ges['read_blog_categories'].'<br>
Комментариев: '.$_totalComm.' <br />
Добавил: <a href="'.$config['home'].'/pages/anketa.php?'.$_authorLog.'"><b>'.$_authorNic.'</b></a>
('.date_fixed($blog_ges['time_blog_categories']).') </div>';
endwhile;
}
else
{
echo '<div class="b"><b> Блогов еще нет! </b><br /> Будь первым =) </div>';
}
if ($total > $config['navig_blog'])
{
page_jumpnavigation('index.php?do=category&id='.$id.'&', $config['navig_blog'], $start, $total);
page_strnavigation('index.php?do=category&id='.$id.'&', $config['navig_blog'], $start, $total);
}
}
else
{
include_once ('../themes/'.$config['themes'].'/index.php');
show_title('partners.gif', 'Блоги / No category');
echo '<div class="b"><b> Такого раздела не существует! </b><br /> Возможно неверный ID раздела =) </div>';
}
echo '<br /><img src="../images/img/back.gif" alt="Image" /> <a href="index.php?'.SID.'">В блоги</a><br />
<img src="../images/img/homepage.gif" alt="Image" /> <a href="../index.php?'.SID.'">На главную</a>';
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}else if($do == 'new_blog'){
include_once ('../themes/'.$config['themes'].'/index.php');
show_title('partners.gif', 'Блоги / Новый блог');
if (is_user())
{
if ($cat_tree = mysql_fetch_array(mysql_query("SELECT * FROM `blog_categories` WHERE `id` = '".$id."'")))
{
$_newNameB = isset($_POST['new_name_blog']) ? check($_POST['new_name_blog']) : null;
$_newTextB = isset($_POST['new_text_blog']) ? check($_POST['new_text_blog']) : null;
$_newKeysB = isset($_POST['key_name_blog']) ? check($_POST['key_name_blog']) : null;
echo '<a href="#down"><img src="../images/img/downs.gif" alt="image" /></a>
<a href="'.$config['home'].'/pages/smiles.php?'.SID.'">Смайлы</a> /
<a href="'.$config['home'].'/pages/tegi.php?'.SID.'">Теги</a>';
if (isset($_POST['submit']) and $_POST['submit']):
if ((iconv_strlen($_POST['new_name_blog'], 'UTF-8') > 5) and (iconv_strlen($_POST['new_name_blog'], 'UTF-8') < 100)):
if ((iconv_strlen($_POST['new_text_blog'], 'UTF-8') > 100) and (iconv_strlen($_POST['new_text_blog'], 'UTF-8') < 10000)):
$_checkAdd = mysql_query("INSERT INTO `directly_blogs` SET
`id_blog_category` = '".$id."',
`name_blog_categories` = '".$_newNameB."',
`text_blog_categories` = '".no_br($_newTextB, '<br />')."',
`key_blog_categories` = '".no_br($_newKeysB, '<br />')."',
`time_blog_categories` = '".SITETIME."',
`author_blog_categories` = '".$log."'
");
if (trim($_checkAdd))
{
header('Refresh: 1; url='.$config['home'].'/blog/index.php?do=category&id='.$id.'&'.SID);
outputMessage(' Блог успешно создан ');
echo '<div> В <a href="index.php?'.SID.'"> блоги</a> <br /> На <a href="../index.php?'.SID.'"> главную</a> </div> ';
include_once ('../themes/'.$config['themes'].'/foot.php'); die;
}
else
{
outputMessage(' Error writing to database ', 'err');
}
else: outputMessage(' Недопустимое количество символов в блоге ', 'err'); endif;
else: outputMessage(' Недопустимое количество символов в названии ', 'err'); endif;
endif;
echo '<form method="post" action="index.php?do=new_blog&id='.$id.'&'.SID.'" name="new_blog">
<div class="form">
Название блога: <br /> <input name="new_name_blog" value="'.$_newNameB.'" type="text"><br />
Текст блога: <br />';
if ($os_user_ag == 1)
{
include_once ('distribution/js_form.php');
}
else
{
echo '<textarea name="new_text_blog" cols="50" rows="10">'.$_newTextB.'</textarea>';
}
echo 'Ключевые слова через запятую:<br /> <input name="key_name_blog" value="'.$_newKeysB.'" type="text"><br />
<input name="submit" type="submit" value=" Создать блог ">
</div></form>';
}else{ echo '<br><div><img src="images/err.gif" alt=""> Такой категории не существует!</div><br>';}
}else{ echo '<br><div><img src="images/err.gif" alt=""> Посетители, находящиеся в группе Гости, не могут создавать блоги.</div><br>';}
echo '<br /><img src="../images/img/back.gif" alt="Image" /> <a href="index.php?do=category&id='.$id.'&'.SID.'">Назад</a><br />
<img src="../images/img/back.gif" alt="Image" /> <a href="index.php?'.SID.'">В блоги</a><br />
<img src="../images/img/homepage.gif" alt="Image" /> <a href="../index.php?'.SID.'">На главную</a>';
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}else if($do == 'blog'){
if ($blog_kel = mysql_fetch_array(mysql_query("SELECT * FROM `directly_blogs` WHERE `id` = '".$id."'")))
{
include_once ('../themes/'.$config['themes'].'/index.php');
show_title('partners.gif', 'Блоги / '.$blog_kel['name_blog_categories']);
if (is_user())
{
$resr = 'res_com_'.$id;
if (empty($_SESSION[$resr]))
{
mysql_query("UPDATE `directly_blogs` SET `read_blog_categories` = `read_blog_categories`+1 WHERE `id` = '".$id."'");
$_SESSION[$resr]=1;
}
}
if (isset($_GET['isset']) and $_GET['isset']=='vote') outputMessage(' Вы уже голосовали за этот блог! ', 'err');
if (isset($_GET['isset']) and $_GET['isset']=='voter') outputMessage('Голос успешно принят! ');
echo '<div>'.smiles(bb_code($blog_kel['text_blog_categories'])).'</div>';
if ($blog_kel['key_blog_categories'] != null)
{
$n=null; echo '<div class="b"> Ключевые теги: <br />';
$keys_ex = explode(',',$blog_kel['key_blog_categories']); $_totalK = count($keys_ex);
foreach($keys_ex as $k => $v): ++$n;
$_keyTeg = str_replace('%', '&?&',rawurlencode(base64_encode(trim($v))));
echo '<a href="search_key.php?key_teg='.$_keyTeg.'">'.$v.'</a>'.($_totalK == $n ? false : ', ');
endforeach;
echo '</div>';
}
echo '<div><b>Рейтинг блога:</b><br />';
if (is_user())
{
echo 'Оставить голос: ';
echo '[<a href="index.php?do=vote&id='.$id.'&voice_a"><img src="images/j_up.gif" alt=""></a> | ';
echo '<a href="index.php?do=vote&id='.$id.'&voice_b"><img src="images/j_down.gif" alt=""></a>]<br />';
}
$vot_a = mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_vote` WHERE `id_blog`='".$id."' AND `voice_vote_a`='1'"),0).')';
$vot_b = mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_vote` WHERE `id_blog`='".$id."' AND `voice_vote_b`='1'"),0).')';
echo '<img src="grafic.php?percent='.($vot_a-$vot_b).'" alt=""><br />
Всего оценок: <b>'.($vot_a+$vot_b).'</b></div>
<div class="b">Добавил:
<a href="../pages/anketa.php?uz='.$blog_kel['author_blog_categories'].'">
<b>'.nickname($blog_kel['author_blog_categories']).'</b></a><br />
Добавлено: '.date_fixed($blog_kel['time_blog_categories']).'<br />
Просмотров: <b>'.nickname($blog_kel['read_blog_categories']).'</b><br />
<a href="comments.php?id='.$blog_kel['id'].'">Комментариев</a>:
<b>'.mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_comments` WHERE `id_blog` = '".$id."'"),0).'</b></div>';
echo '<img src="../images/img/back.gif" alt="Image" />
<a href="index.php?do=category&id='.$blog_kel['id_blog_category'].'&'.SID.'">Назад</a><br />';
}
else
{
include_once ('../themes/'.$config['themes'].'/index.php');
show_title('partners.gif', 'Блоги / No Blog');
echo '<div class="b"><b> Такого блога не существует! </b><br /> Возможно неверный ID блога =) </div>';
}
echo '<img src="../images/img/back.gif" alt="Image" /> <a href="index.php?'.SID.'">В блоги</a><br />
<img src="../images/img/homepage.gif" alt="Image" /> <a href="../index.php?'.SID.'">На главную</a>';
}else if($do == 'vote'){
if (is_user())
{
include_once ('../themes/'.$config['themes'].'/index.php');
show_title('partners.gif', 'Блоги / Голосование');
$blog_kel = mysql_fetch_array(mysql_query("SELECT * FROM `directly_blogs` WHERE `id` = '".$id."'"));
if (trim($blog_kel))
{
$vote_voi = mysql_fetch_array(mysql_query("SELECT * FROM `blog_vote` WHERE `id_blog` = '".$id."' AND `user_vote` = '".$log."'"));
if (trim($vote_voi))
{
header ("Location: index.php?do=blog&id=".$id."&isset=vote"); die;
}else{ if (isset($_GET['voice_a'])){$voice_a = 1;
}else if (isset($_GET['voice_b'])){$voice_b = 1;
}else{ header ("Location: index.php?do=blog&id=".$id.""); die;
}
mysql_query("INSERT INTO `blog_vote` SET
`id_category` = '".$blog_kel['id_blog_category']."',
`id_blog` = '".$id."',
`voice_vote_a` = '".$voice_a."',
`voice_vote_b` = '".$voice_b."',
`user_vote` = '".$log."'");
header ("Location: index.php?do=blog&id=".$id."&isset=voter"); die;
}
}
header ("Location: index.php?do=blog&id=".$id."&isset=voter"); die;
}
}else if($do == 'del_comm'){
if (is_user() and is_admin(array(101,102,103,104,105))){
mysql_query("DELETE FROM `blog_comments` WHERE `id` = '".$id."'");
header ("Location: comments.php?id=".$start."&".SID); die;}
}else if($do == 'del_blog'){
if (is_user() and is_admin(array(101,102,103,104,105))){
mysql_query("DELETE FROM `directly_blogs` WHERE `id` = '".$id."'");
mysql_query("DELETE FROM `blog_comments` WHERE `id_blog` = '".$id."'");
mysql_query("DELETE FROM `blog_vote` WHERE `id_blog` = '".$id."'");
header ("Location: index.php"); die;
}
}
include_once ('../themes/'.$config['themes'].'/foot.php');
?>