View file modules/smiles/delete.php

File size: 3.64Kb
<?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_smiles = load_lng('smiles');
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_smile':
if (isset($_GET['id_smile']) && is_numeric($_GET['id_smile']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `smiles_list` WHERE `id` = '".intval($_GET['id_smile'])."' LIMIT 1",$dblink), 0)==1)
{
$id_smile=intval(abs($_GET['id_smile']));
$smile = mysql_fetch_assoc(mysql_query("SELECT * FROM `smiles_list` WHERE `id` = '".$id_smile."' LIMIT 1"));
}else{
header("Location: index.php?".SID);
}
if (isset($user) && $user['level']>=6)
{
mysql_query("DELETE FROM `smiles_list` WHERE `id` = '$smile[id]'");
unlink ($root_path.'/files/smiles/'.$smile['name'].'.gif'); // სმაილის წაშლა
header("Location: index.php?act=view_dir&id_dir=$smile[id_dir]&".SID);
}
break;
/**განყოფილების წაშლა სმაილებიანად**/
case 'delete_dir':
if (isset($_GET['id_dir']) && is_numeric($_GET['id_dir']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `smiles_dir` WHERE `id` = '".intval($_GET['id_dir'])."' LIMIT 1",$dblink), 0)==1)
{
$id_dir=intval(abs($_GET['id_dir']));
$dir = mysql_fetch_assoc(mysql_query("SELECT * FROM `smiles_dir` WHERE `id` = '".$id_dir."' LIMIT 1"));
}else{
header("Location: index.php?".SID);
}
if(isset($_POST['delete_dir_no']))
{
header("Location: index.php?".SID);
}
if(isset($_POST['delete_dir_yes']))
{
if (isset($user) && $user['level']>=8)
{
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `smiles_list` WHERE `id_dir` = '$dir[id]'"),0);
$q=mysql_query("SELECT * FROM `smiles_list` WHERE `id_dir` = '$dir[id]' LIMIT $k_post");
$n=0;
while($post = mysql_fetch_array($q))
{
unlink ($root_path.'/files/smiles/'.$post['name'].'.gif'); // სმაილების წაშლა
//echo $n++.''.$lng_smiles['1_21'].' '.$post['name'].'<br/>';
}
mysql_query("DELETE FROM `smiles_list` WHERE `id_dir` = '$dir[id]'");
mysql_query("DELETE FROM `smiles_dir` WHERE `id` = '$dir[id]'");
header("Location: index.php?".SID);
}
}
head(''.$lng['1_48'].' | '.$lng_smiles['1_22'].' | '.$dir['name']);
echo'<div class="hdr"><b>'.$lng_smiles['1_22'].'</b></div>';
echo'<div class="errmenu">'.$lng_smiles['1_23'].' "'.$dir['name'].'"?';
echo'<form method="POST" action="delete.php?act=delete_dir&amp;id_dir='.$dir['id'].'">';
echo'<input type="submit" name="delete_dir_yes" value="'.$lng['1_62'].'" />';
echo'<input type="submit" name="delete_dir_no" value="'.$lng['1_63'].'" />';
echo'</form></div>';
if (isset($_SERVER['HTTP_REFERER']))
echo'<a href="'.htmlspecialchars($_SERVER['HTTP_REFERER']).'">'.$lng['1_50'].'</a>';
require $root_path.'includes/end.php'; // დასასრული
break;
}
?>