Файл: modules/downloads/delete_file.php
Строк: 66
<?php
/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) 2013, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
* @link http://perf-engine.net
* @package PerfEngine
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
$locate = 'in_downloads';
$file_id = abs(intval($_GET['id']));
if(!isset($_GET['id']) && $db->query("SELECT * FROM `downloads_files` WHERE `id` = '$file_id'")->rowCount() == 0 || !User::logged())
{
redirect('/downloads/');
}
if($db->query("SELECT user_id FROM `downloads_files` WHERE `id` = '$file_id'")->fetchColumn() != User::Id() && User::level() < 5)
{
redirect('/downloads/');
}
$filei = $db->query("SELECT * FROM `downloads_files` WHERE `id` = '". $file_id ."'")->fetch();
$root_dir = $db->query("SELECT `server_path` FROM `downloads` WHERE `id` = '". abs(intval($filei['ref_id'])) ."'")->fetchColumn();
if(isset($_GET['act']) && $_GET['act'] == 'delete')
{
if(isset($_POST['yes']))
{
rrmdir(ROOT.'/files/downloads/'.$root_dir.'/'.$filei['server_dir']);
$db->query("DELETE FROM `downloads_files` WHERE `id` = '". $file_id ."'");
$db->query("DELETE FROM `downloads_comms` WHERE `downloads_id` = '". $file_id ."'");
$db->query("DELETE FROM `downloads` WHERE `id` = '". $filei['from_id'] ."'");
header('location: /downloads/');
exit;
}
elseif(isset($_POST['no']))
{
header('location: /downloads/file/'.$file_id);
exit;
}
}
$title = _t('dl_edit_file').' | '._t('downloads');
include_header($title);
$tpl->div('title', _t('dl_edit_file'));
echo '<div class="post">
<form action="/downloads/delete_file/'.$file_id.'?act=delete" method="post">
'._t('dl_file_delete_attention').' <b>'.$filei['name'].'</b>?<br/>
<input type="submit" name="yes" value="'. _t('yyes') .'" /> <input type="submit" name="no" value="'. _t('yno') .'" />
</form>
</div>';
$tpl->div('block', img('download.png') . ' <a href="/downloads/">'. _t('downloads') .'</a><br/>'
. HICO .' <a href="/">'. _t('home') .'</a>');
include_footer();
?>