View file modules/downloads/delete_dir.php

File size: 1.78Kb
<?php
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.org.ua  *
**********************************/
$locate	= 'in_downloads';
$dir_id = abs(intval($_GET['id']));
if(!isset($dir_id) && $db->query("SELECT * FROM `downloads` WHERE `id` = '$dir_id'")->rowCount() == 0 || $user['level'] < 4)
	{
		header('location: /downloads/');
		exit;
	}
$diri = $db->query("SELECT * FROM `downloads` WHERE `id` = '". $dir_id ."'")->fetch();
if(isset($_GET['act']) && $_GET['act'] == 'delete')
	{
		if(isset($_POST['yes']))
			{
				rrmdir(ROOT.'/files/downloads/'.$diri['server_path']);
				$db->query("DELETE FROM `downloads_files` WHERE `ref_id` = '". $dir_id ."'");
				$db->query("DELETE FROM `downloads` WHERE `id` = '". $dir_id ."'");
				$db->query("DELETE FROM `downloads` WHERE `dir_id` = '". $dir_id ."'");
				// print_r($db->errorInfo());
				header('location: /downloads/');
				exit;
			}
		elseif(isset($_POST['no']))
			{
				header('location: /downloads/file/'.$dir_id);
				exit;
			}
	}
				
$title = $lang->word('dl_edit_file').' | '.$lang->word('downloads');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('dl_edit_file'));
echo '<div class="post">
		<form action="/downloads/delete_dir/'.$dir_id.'?act=delete" method="post">
		'.$lang->word('dl_dir_delete_attention').' <b>'.$diri['name'].'</>?<br/>
		<input type="submit" name="yes" value="'. $lang->word('yyes') .'" /> <input type="submit" name="no" value="'. $lang->word('yno') .'" />
		</form>
	</div>';
$tpl->div('block', img('download.png') . ' <a href="/downloads/">'. $lang->word('downloads') .'</a><br/>'
				. HICO .' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
?>