View file modules/forum/delete.php

File size: 6.26Kb
<?php
/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//
// Sitchi CMS - Mobile Content Management System //
// The author:  Nikoloz Sitchinava [sitchi]      //
// Link:        http://sitchicms.num.ge          //
// Skype:       SitchiCMS                        //
// License:     LICENSE.txt (see attached file)  //
// Version:     VERSION.txt (see attached file)  //
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
define('_SITCHICMS', 1);
$root_path='../../';
require $root_path.'includes/db_connect.php'; 
require $root_path.'includes/start.php';
require $root_path.'includes/header.php';
require $root_path.'includes/functions.php';
require $root_path.'includes/head.php'; // თავი
$lng_forum = load_lng('forum');
if (!isset($_GET['act']))
{
if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']!=NULL)
header("Location: ".$_SERVER['HTTP_REFERER']);
else
header("Location: index.php?".SID);
}else{
$act=htmlspecialchars(trim($_GET['act']));
}
switch ($act) 
{
/**პოსტის წაშლა თემაში**/
case 'delete_topic_post':
if (isset($_GET['id_post']) && is_numeric($_GET['id_post']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic2_view` WHERE `id` = '".intval($_GET['id_post'])."' LIMIT 1",$dblink), 0)==1)
{
$id_post=intval(abs($_GET['id_post']));
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_topic2_view` WHERE `id` = '".$id_post."' LIMIT 1"));
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$post['id_user']."' LIMIT 1"));
}else{
header("Location: index.php?".SID);
} 
if (isset($user) && $user['level']>=2 && $user['level']>$ank['level'] || isset($user) && $user['id']==$ank['id'] && $post['time']>$time-$set['forum_edit_time'] || isset($user) && $user['id']==$ank['id'] && $user['level']>=2)
{
mysql_query("DELETE FROM `forum_topic2_view` WHERE `id` = '$post[id]'");
header("Location: index.php?act=view_topic&id_them=$post[id_them]&".SID);
}
break;
/**თემის წაშლა**/
case 'delete_topic':
if (isset($_GET['id_them']) && is_numeric($_GET['id_them']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic1_view` WHERE `id` = '".intval($_GET['id_them'])."' LIMIT 1",$dblink), 0)==1)
{
$id_them=intval(abs($_GET['id_them']));
$them = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_topic1_view` WHERE `id` = '".$id_them."' LIMIT 1"));
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$them['id_user']."' LIMIT 1"));
}else{
header("Location: index.php?".SID);
} 
if (isset($user) && $user['level']>=2 && $user['level']>$ank['level'] || isset($user) && $user['id']==$ank['id'] && $user['level']>=2)
{
mysql_query("DELETE FROM `forum_topic1_view` WHERE `id` = '$them[id]'");
mysql_query("DELETE FROM `forum_topic2_view` WHERE `id_them` = '$them[id]'"); 
header("Location: index.php?act=view_under_section&id_section=$them[id_section]&".SID);
}
break; 
/**განყოფილების წაშლა**/
case 'delete_section':
if (isset($_GET['id_section']) && is_numeric($_GET['id_section']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_section_view` WHERE `id` = '".intval($_GET['id_section'])."' LIMIT 1",$dblink), 0)==1)
{
$id_section=intval(abs($_GET['id_section']));
$section = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_section_view` WHERE `id` = '".$id_section."' LIMIT 1"));
$forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_section` WHERE `id` = '".$section['id_forum']."' LIMIT 1"));
}else{
header("Location: index.php?".SID);
}
if(isset($_POST['delete_section']))
{
if (isset($user) && $user['level']>=6)
{
mysql_query("DELETE FROM `forum_section_view` WHERE `id` = '$section[id]'");
mysql_query("DELETE FROM `forum_topic1_view` WHERE `id_section` = '$section[id]'");
mysql_query("DELETE FROM `forum_topic2_view` WHERE `id_section`='$section[id]'");
header("Location: index.php?act=view_section&id_forum=$section[id_forum]&".SID);
}
}
head(''.$lng_forum['1_1'].' | '.$lng_forum['1_13'].''); 
echo'<div class="hdr"><b>'.$lng_forum['1_1'].' | '.$lng_forum['1_13'].'</b></div>';
echo'<div class="errmenu">'.$lng_forum['1_69'].' "'.$section['name'].'"?';
echo'<form method="POST" action="delete.php?act=delete_section&amp;id_section='.$section['id'].'">';
echo'<input type="submit" name="delete_section" value="'.$lng['1_62'].'" />';
echo'</form></div>';
echo'<a href="/modules/forum/index.php?act=view_under_section&amp;id_section='.$section['id'].'">'.$section['name'].'</a><br/>
<a href="/modules/forum/index.php?act=view_section&amp;id_forum='.$forum['id'].'">'.$forum['name'].'</a><br/>
<a href="/modules/forum/">'.$lng_forum['1_1'].'</a>';
require $root_path.'includes/end.php'; // დასასრული
break;
/**ფორუმის წაშლა**/
case 'delete_forum':
if (isset($_GET['id_forum']) && is_numeric($_GET['id_forum']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_section` WHERE `id` = '".intval($_GET['id_forum'])."' LIMIT 1",$dblink), 0)==1)
{
$id_forum=intval(abs($_GET['id_forum']));
$forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_section` WHERE `id` = '".$id_forum."' LIMIT 1"));
}else{
header("Location: index.php?".SID);
}
if(isset($_POST['delete_forum']))
{
if (isset($user) && $user['level']>=8)
{
mysql_query("DELETE FROM `forum_section` WHERE `id` = '$forum[id]'");
mysql_query("DELETE FROM `forum_section_view` WHERE `id_forum` = '$forum[id]'");
mysql_query("DELETE FROM `forum_topic1_view` WHERE `id_forum` = '$forum[id]'");
mysql_query("DELETE FROM `forum_topic2_view` WHERE `id_forum`='$forum[id]'");
header("Location: index.php?".SID);
}
}
head(''.$lng_forum['1_1'].' | '.$lng_forum['1_10'].''); 
echo'<div class="hdr"><b>'.$lng_forum['1_1'].' | '.$lng_forum['1_10'].'</b></div>';
echo'<div class="errmenu">'.$lng_forum['1_70'].' "'.$forum['name'].'"?';
echo'<form method="POST" action="delete.php?act=delete_forum&amp;id_forum='.$forum['id'].'">';
echo'<input type="submit" name="delete_forum" value="'.$lng['1_62'].'" />';
echo'</form></div>';
echo'<a href="/modules/forum/index.php?act=view_section&amp;id_forum='.$forum['id'].'">'.$forum['name'].'</a><br/>
<a href="/modules/forum/">'.$lng_forum['1_1'].'</a>';
require $root_path.'includes/end.php'; // დასასრული
break;
}
?>