Просмотр файла blogs/index.php

Размер файла: 19.49Kb
<?php
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";
include_once"../template/isset.php";
include_once"distribution/db.php";
include_once"distribution/fnc.php";

if (isset($_GET['add_razdel'])){
if ($_SESSION['ners']==1){ $_SESSION['ners']=''; header ("Location: index.php"); die ();}
else if($_SESSION['ners']==''){ $_SESSION['ners']=1; header ("Location: index.php"); die ();}}
$do = isset($_GET['do']) ? $_GET['do'] : '';
$id = (int)$_GET['id_blog_category'];
if (empty($do)){
echo '<img src="../images/img/partners.gif" alt=""> Блоги на '.$config_title.'<br><br>';
$cat_trees = mysql_query("SELECT * FROM `blog_categories` ORDER BY `id` DESC");
if (mysql_num_rows($cat_trees)){
while ($cat_tree = mysql_fetch_array($cat_trees)){
echo '<div class="b"><img src="images/dir.gif" alt="">
<a href="index.php?do=category&amp;id_blog_category='.$cat_tree['id'].'"><b>'.$cat_tree['name_category_blog'].'</b></a> ';
echo '('.mysql_result(mysql_query("SELECT COUNT(*) FROM `directly_blogs` WHERE `id_blog_category` = '".$cat_tree['id']."'"),0).')';
if($provpar==md5($_SESSION['par']) && $provlog==$_SESSION['log']) {
if ($dostup==101 || $dostup==102){
if ($_SESSION['ners']==1){
echo '<small> [<a href="index.php?edit_category&edit_category_id='.$cat_tree['id'].'"><font color="#009900">EDIT</font></a>|';
echo '<a href="index.php?del_category&del_category_id='.$cat_tree['id'].'"><font color="#ff0000">DEL</font></a>]</small>';
}}}
echo '</div><div>'.nl2_br($cat_tree['comm_category_blog']).'</div>';}
}else{ echo '<br><div><b>Категории не созданы!</b></div><br>';}
if($provpar==md5($_SESSION['par']) && $provlog==$_SESSION['log']) {
if ($dostup==101 || $dostup==102){
if ($_SESSION['ners']==1){
if (isset($_GET['add_category'])){
if (isset($_POST['new_cat'])){
if (iconv_strlen($_POST['new_cat_name'],'UTF-8') > 5){
if (iconv_strlen($_POST['new_cat_name'],'UTF-8') < 50){
if (iconv_strlen($_POST['new_cat_text'],'UTF-8') > 5){
if (iconv_strlen($_POST['new_cat_text'],'UTF-8') < 150){
mysql_query("INSERT INTO `blog_categories` SET 
`name_category_blog` = '".check($_POST['new_cat_name'])."',
`comm_category_blog` = '".check($_POST['new_cat_text'])."'");
header ("Location: index.php?add_category"); die();
}else{ echo '<hr><div align="center"><font color="#FF0000"><b>Слишком большое описание!</b></font><br></div>';}
}else{ echo '<hr><div align="center"><font color="#FF0000"><b>Слишком маленькое описание!</b></font><br></div>';}
}else{ echo '<hr><div align="center"><font color="#FF0000"><b>Слишком большое название!</b></font><br></div>';}
}else{ echo '<hr><div align="center"><font color="#FF0000"><b>Слишком маленькое название!</b></font><br></div>';}}
echo '<hr><div><form method="post" action="index.php?add_category">';
echo 'Название раздела:<br><input name="new_cat_name" type="text"><br>';
echo 'Описание:<br><textarea name="new_cat_text" cols="50" rows="3"></textarea>';
echo '<input name="new_cat" type="submit" value=" Создать ">';
echo '</form></div>';
}else{ echo '<div class="b"><a href="index.php?add_category">Создать раздел</a></div>';}
if (isset($_GET['edit_category']) && isset($_GET['edit_category_id'])){
$edit_id = (int)$_GET['edit_category_id'];
if (isset($_POST['edite_cat'])){
if (iconv_strlen($_POST['new_cat_name'],'UTF-8') > 5){
if (iconv_strlen($_POST['new_cat_name'],'UTF-8') < 50){
if (iconv_strlen($_POST['new_cat_text'],'UTF-8') > 5){
if (iconv_strlen($_POST['new_cat_text'],'UTF-8') < 150){
mysql_query("UPDATE `blog_categories` SET `name_category_blog` = '".check($_POST['new_cat_name'])."' WHERE `id` ='".$edit_id."'");
mysql_query("UPDATE `blog_categories` SET `comm_category_blog` = '".check($_POST['new_cat_text'])."' WHERE `id` ='".$edit_id."'");
header ("Location: index.php"); die();
}else{ echo '<hr><div align="center"><font color="#FF0000"><b>Слишком большое описание!</b></font><br></div>';}
}else{ echo '<hr><div align="center"><font color="#FF0000"><b>Слишком маленькое описание!</b></font><br></div>';}
}else{ echo '<hr><div align="center"><font color="#FF0000"><b>Слишком большое название!</b></font><br></div>';}
}else{ echo '<hr><div align="center"><font color="#FF0000"><b>Слишком маленькое название!</b></font><br></div>';}}
$edit_c = mysql_fetch_array(mysql_query("SELECT * FROM `blog_categories` WHERE `id` = '".$edit_id."'"));
echo '<hr><div><form method="post" action="index.php?edit_category&edit_category_id='.$edit_id.'">';
echo 'Название раздела:<br><input name="new_cat_name" value="'.$edit_c['name_category_blog'].'" type="text"><br>';
echo 'Описание:<br><textarea name="new_cat_text" cols="50" rows="3">'.$edit_c['comm_category_blog'].'</textarea>';
echo '<input name="edite_cat" type="submit" value=" Вперед ">';
echo '</form></div>';}
if (isset($_GET['del_category']) && isset($_GET['del_category_id'])){
$del_id = (int)$_GET['del_category_id'];
if (isset($_POST['del_yes'])){
mysql_query("DELETE FROM `blog_categories` WHERE id='".$del_id."'");
header ("Location: index.php"); die();}
else if (isset($_POST['del_no'])){
header ("Location: index.php"); die();}else{
echo '<hr><div><form method="post" action="index.php?del_category&del_category_id='.$del_id.'">';
echo 'Вы уверены что хотите удалить блог?<br><br>';
echo '<input name="del_yes" type="submit" value="Удалить"> ';
echo '<input name="del_no" type="submit" value="Отмена">';
echo '</form></div>';}}}}}
echo '<hr><div>';
if($provpar==md5($_SESSION['par']) && $provlog==$_SESSION['log']) {
if ($dostup==101 || $dostup==102){
echo '<img src="../images/img/panel.gif" alt=""> <a href="index.php?add_razdel'.SID.'">Админка</a><br>';}}
echo '<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a></div>';
}else if($do == 'category'){
$cat_tree = mysql_fetch_array(mysql_query("SELECT * FROM `blog_categories` WHERE `id` = '".$id."'"));
if (trim($cat_tree)){
echo '<img src="../images/img/partners.gif" alt=""> '.$cat_tree['name_category_blog'].'<br><br>';
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `directly_blogs`  WHERE `id_blog_category` = '".$id."'"),0);
$start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0;
if($start > $total) $start = 0;
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");
if (mysql_num_rows($blog_kel)){
while($blog_ges = mysql_fetch_array($blog_kel)){
echo '<div class="b"><img src="images/blg.gif" alt=""> ';
echo '<a href="index.php?do=blog&amp;id_blog_category='.$blog_ges['id'].'&amp;"><b>'.$blog_ges['name_blog_categories'].'</b></a>';
if($provpar==md5($_SESSION['par']) && $provlog==$_SESSION['log']) {
if ($dostup==101 || $dostup==102 || $dostup==103 || $dostup==105){
echo ' <a href="index.php?do=del_blog&amp;id_bloge='.$blog_ges['id'].'"><font color="#FF0000">[Del]</font></a>';}}
echo '</div><div>Просмотров: '.$blog_ges['read_blog_categories'].'<br>';
echo 'Комментариев: '.mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_comments` WHERE `id_bloge_comment` = '".$blog_ges['id']."'"),0).'<br>';
echo 'Добавил: <b>'.nickname($blog_ges['author_blog_categories']).'</b> ('.date_fixed($blog_ges['time_blog_categories']).')<br>';
echo '</div>';}
}else{ echo '<br><div><b>Блогов еще нет!</b></div><br>';}
if ($total > $config_navig_blog){
echo '<div class="b">';
if ($start != 0){
echo '<a href="index.php?do=category&amp;id_blog_category='.$id.'&amp;start='.($start - $config_navig_blog).'">&lt;-Назад</a> ';
}else{ echo '&lt;-Назад';}
echo ' | ';
if ($total > $start + $config_navig_blog){
echo ' <a href="index.php?do=category&amp;id_blog_category='.$id.'&amp;start='.($start + $config_navig_blog).'">Далее-&gt;</a>';
}else{ echo 'Далее-&gt;';}
if($total>0){
$ba = ceil($total/$config_navig_blog);
$ba2 = $ba*$onpage-$config_navig_blog;
echo '<br/>Страницы:';
$asd = $start-($config_navig_blog*3);
$asd2 = $start+($config_navig_blog*4);
if($asd<$total && $asd>0) echo ' <a href="index.php?do=category&amp;id_blog_category='.$id.'&amp;start=0">1</a> ... ';
for($i=$asd; $i<$asd2;){
if($i<$total && $i>=0){
$ii = floor(1+$i/$config_navig_blog);
if ($start==$i) echo ' <b>['.$ii.']</b>';
else echo ' <a href="index.php?do=category&amp;id_blog_category='.$id.'&amp;start='.$i.'">'.$ii.'</a>';}
$i=$i+$config_navig_blog;}
if($asd2<$total) echo ' ... <a href="index.php?do=category&amp;id_blog_category='.$id.'&amp;start='.$ba2.'">'.$ba.'</a>';}
echo '</div>';
}else{echo '<hr>';}
echo '<div><a href="index.php?do=new_blog&amp;id_blog_category='.$id.'">Создать блог</a></div>';
}else{ echo '<br><div><img src="images/err.gif" alt=""> Такой категории не существует!</div><br>';}
echo '<hr><div><img src="../images/img/back.gif" alt=""> <a href="index.php?'.SID.'">В блоги</a><br>';
echo '<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a></div>';
}else if($do == 'new_blog'){
if($provpar==md5($_SESSION['par']) && $provlog==$_SESSION['log']) {
$cat_tree = mysql_fetch_array(mysql_query("SELECT * FROM `blog_categories` WHERE `id` = '".$id."'"));
if (trim($cat_tree)){
echo '<img src="../images/img/partners.gif" alt="">Создание блога<br><br>';
if (isset($_POST['submit'])){
if (iconv_strlen($_POST['new_name_blog'],'UTF-8') > 5){
if (iconv_strlen($_POST['new_name_blog'],'UTF-8') < 100){
if (iconv_strlen($_POST['new_text_blog'],'UTF-8') > 30){
if (iconv_strlen($_POST['new_text_blog'],'UTF-8') < 10000){
mysql_query("INSERT INTO `directly_blogs` SET 
`id_blog_category` = '".$id."',
`name_blog_categories` = '".check($_POST['new_name_blog'])."',
`text_blog_categories` = '".check($_POST['new_text_blog'])."',
`key_blog_categories` = '".check($_POST['key_name_blog'])."',
`time_blog_categories` = '".$sitetime."',
`author_blog_categories` = '".$log."'");
header ("Location: index.php?do=category&id_blog_category=".$id.""); die();
}else{ echo '<div align="center"><font color="#FF0000"><b>Слишком большой текст блога!</b></font><br></div>';}
}else{ echo '<div align="center"><font color="#FF0000"><b>Слишком маленький текст блога!</b></font><br></div>';}
}else{ echo '<div align="center"><font color="#FF0000"><b>Слишком большое название!</b></font><br></div>';}
}else{ echo '<div align="center"><font color="#FF0000"><b>Слишком маленькое название!</b></font><br></div>';}}
echo '<div><form method="post" action="index.php?do=new_blog&amp;id_blog_category='.$id.'" name="new_blog">';
echo 'Название блога:<br><input name="new_name_blog" value="'.$_POST['new_name_blog'].'" type="text"><br>';
echo 'Текст блога:<br>';
if ($os_user_ag == 1){include_once "distribution/js_form.php";
}else{echo '<textarea name="new_text_blog" cols="50" rows="10">'.$_POST['new_text_blog'].'</textarea>';}
echo 'Ключевые слова через запятую:<br><input name="key_name_blog" value="'.$_POST['key_name_blog'].'" type="text"><br>';
echo '<input name="submit" type="submit" value=" Создать блог ">';
echo '</form></div><hr><div>';
echo '<a href="#up">Вверх</a> | ';
echo '<a href="../pages/smiles.php?">Смайлы</a> | ';
echo '<a href="../pages/tegi.php?">Теги</a></div>';
}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 '<hr><div><img src="../images/img/back.gif" alt=""> <a href="index.php?'.SID.'">В блоги</a><br>';
echo '<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a></div>';
}else if($do == 'blog'){
$blog_kel = mysql_fetch_array(mysql_query("SELECT * FROM `directly_blogs` WHERE `id` = '".$id."'"));
if (trim($blog_kel)){
if ($provlog==$_SESSION['log'] && $provpar==md5($_SESSION['par']) && $_SESSION['log']!="" && md5($_SESSION['par'])!="") {
$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($_GET['isset']=='vote'){
echo '<div align="center"><font color="#FF0000"><b>Вы уже голосовали за этот блог!</b></font></div>';}
if($_GET['isset']=='voter'){
echo '<div align="center"><font color="#009900"><b>Голос успешно принят!</b></font></div>';}
echo '<img src="../images/img/partners.gif" alt=""> '.$blog_kel['name_blog_categories'].'<br><br>';
echo '<div>';
echo smiles(bb_code(nl2_br($blog_kel['text_blog_categories']))).'</div>';
if($blog_kel['key_blog_categories'] != NULL){
echo '<div class="b">Ключевые теги:<br>';
$keys_ex = explode(",",$blog_kel['key_blog_categories']);
$count_keys = count($keys_ex);
foreach($keys_ex as $k => $v){ ++$n; 
if ($count_keys != $n){echo '<a href="search_key.php?key_teg='.rawurlencode(base64_encode(base64_encode($v))).'">'.$v.'</a>, ';
}else{echo '<a href="search_key.php?key_teg='.rawurlencode(base64_encode(base64_encode($v))).'">'.$v.'</a>';}}
echo '</div>';
}else{ echo '<hr>';}
$vote_voi = mysql_fetch_array(mysql_query("SELECT * FROM `blog_vote` WHERE `id_blog_vote` = '".$id."' AND `user_vote` = '".$log."'"));
if (!trim($vote_voi)){
if($provpar==md5($_SESSION['par']) && $provlog==$_SESSION['log']) {
echo '<div>Оставить голос: ';
echo '[<a href="index.php?do=vote&id_blog_category='.$id.'&amp;voice_a"><img src="images/j_up.gif" alt=""></a> | ';
echo '<a href="index.php?do=vote&id_blog_category='.$id.'&amp;voice_b"><img src="images/j_down.gif" alt=""></a>]<br>';
}else{ echo '<div>Рейтинг:<br>';}
}else{ echo '<div>Рейтинг:<br>';}
$vot_a = mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_vote` WHERE `id_blog_vote`='".$id."' AND `voice_vote_a`='1'"),0).')';
$vot_b = mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_vote` WHERE `id_blog_vote`='".$id."' AND `voice_vote_b`='1'"),0).')';
echo '<img src="grafic.php?percent='.($vot_a-$vot_b).'" alt=""><br>';
echo 'Всего оценок: <b>'.($vot_a+$vot_b).'</b></div>';
echo '<div class="b">';
echo 'Добавил: <a href="../pages/anketa.php?uz='.$blog_kel['author_blog_categories'].'"><b>'.nickname($blog_kel['author_blog_categories']).'</b></a><br>';
echo 'Добавлено: '.date_fixed($blog_kel['time_blog_categories']).'<br>';
echo 'Просмотров: <b>'.nickname($blog_kel['read_blog_categories']).'</b><br>';
echo '<a href="comments.php?id_blog='.$blog_kel['id'].'">';
echo 'Комментариев</a>: <b>'.mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_comments` WHERE `id_bloge_comment` = '".$id."'"),0).'</b><br>';
echo '</div>';
}else{ echo '<br><div><img src="images/err.gif" alt=""> Такого блога не существует!</div><br>';}
echo '<hr><div><img src="../images/img/reload.gif" alt=""> <a href="index.php?do=category&id_blog_category='.$blog_kel['id_blog_category'].'">Назад</a><br>';
echo '<img src="../images/img/back.gif" alt=""> <a href="index.php?'.SID.'">В блоги</a><br>';
echo '<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a></div>';
}else if($do == 'vote'){
if($provpar==md5($_SESSION['par']) && $provlog==$_SESSION['log']) {
$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_vote` = '".$id."' AND `user_vote` = '".$log."'"));
if (trim($vote_voi)){
header ("Location: index.php?do=blog&id_blog_category=".$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_blog_category=".$id.""); die();}
mysql_query("INSERT INTO `blog_vote` SET 
`id_blog_vote` = '".$id."',
`voice_vote_a` = '".$voice_a."',
`voice_vote_b` = '".$voice_b."',
`user_vote` = '".$log."'");
header ("Location: index.php?do=blog&id_blog_category=".$id."&isset=voter"); die(); }}
header ("Location: index.php?do=blog&id_blog_category=".$id."&isset=voter"); die(); }
}else if($do == 'del_comm'){
if($provpar==md5($_SESSION['par']) && $provlog==$_SESSION['log']) {
if ($dostup==101 || $dostup==102 || $dostup==103 || $dostup==105){
if (isset($_GET['id_comm'])){
if (isset($_POST['yes'])){
$id_comm = (int)$_GET['id_comm'];
$id_bloge = (int)$_GET['id_bloge'];
mysql_query("DELETE FROM `blog_comments` WHERE `id` = '".$id_comm."'");
header ("Location: comments.php?id_blog=".$id_bloge.""); die ();
}elseif (isset($_POST['no'])){
header ("Location: comments.php?id_blog=".$id_bloge.""); die ();}
echo '<div>Вы уверены что хотите удалить комментарий?<br><br>';
echo '<form action="index.php?do=del_comm&amp;id_comm='.$id_comm.'&amp;id_bloge='.$id_bloge.'" method="post">';
echo '<input name="yes" type="submit" value="Удалить"> ';
echo '<input name="no" type="submit" value="Отмена"></form>';
echo '</div><hr><div>';
echo '<img src="../images/img/reload.gif" alt=""> <a href="comments.php?id_blog='.$id_bloge.'">Назад</a><br>';
echo '<img src="../images/img/back.gif" alt=""> <a href="index.php?'.SID.'">В блоги</a><br>';
echo '<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a></div>';}}}
}else if($do == 'del_blog'){
if($provpar==md5($_SESSION['par']) && $provlog==$_SESSION['log']) {
if ($dostup==101 || $dostup==102 || $dostup==103 || $dostup==105){
if (isset($_GET['id_bloge'])){
if (isset($_POST['yes'])){
$id_bloge = (int)$_GET['id_bloge'];
mysql_query("DELETE FROM `directly_blogs` WHERE `id` = '".$id_bloge."'");
mysql_query("DELETE FROM `blog_comments` WHERE `id_bloge_comment` = '".$id_bloge."'");
mysql_query("DELETE FROM `blog_vote` WHERE `id_blog_vote` = '".$id_bloge."'");
header ("Location: index.php"); die ();
}elseif (isset($_POST['no'])){
header ("Location: index.php"); die ();}
echo '<div>Вы уверены что хотите удалить блог?<br><br>';
echo '<form action="index.php?do=del_blog&amp;id_bloge='.$id_bloge.'" method="post">';
echo '<input name="yes" type="submit" value="Удалить"> ';
echo '<input name="no" type="submit" value="Отмена"></form>';
echo '</div><hr><div>';
echo '<img src="../images/img/reload.gif" alt=""> <a href="comments.php?id_blog='.$id_bloge.'">Назад</a><br>';
echo '<img src="../images/img/back.gif" alt=""> <a href="index.php?'.SID.'">В блоги</a><br>';
echo '<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a></div>';}}}}
include_once"../themes/$config_themes/foot.php";
?>