Файл: modules/albums/delete_photo.php
Строк: 54
<?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_photo_albums';
$photo_id = abs(intval($_GET['id']));
if(!isset($_GET['id']) && $db->query("SELECT * FROM `albums_photo` WHERE `id` = '$photo_id'")->rowCount() == 0 || !User::logged())
{
redirect('/albums/');
}
if($db->query("SELECT user_id FROM `albums_photo` WHERE `id` = '$photo_id'")->fetchColumn() != User::Id() && User::level() < 5)
{
redirect('/albums/');
}
$ph = $db->query("SELECT * FROM `albums_photo` WHERE `id` = '". $photo_id ."'")->fetch();
if(isset($_GET['act']) && $_GET['act'] == 'delete')
{
if(isset($_POST['yes']))
{
unlink(ROOT.'/files/albums/'.$ph['server_name'].'.'.$ph['ext']);
unlink(ROOT.'/cache/albums/thumbs/'.$ph['server_name'].'.jpg.');
$db->query("DELETE FROM `albums_photo` WHERE `id` = '". $photo_id ."'");
header('location: /albums/album/'.$ph['album_id']);
exit;
}
elseif(isset($_POST['no']))
{
header('location: /albums/photo/'.$photo_id);
exit;
}
}
$title = _t('delete');
include_header($title);
$tpl->div('title', _t('delete'));
echo '<div class="post">
<form action="/albums/delete_photo/'.$photo_id.'?act=delete" method="post">
'._t('dl_file_delete_attention').'?<br/>
<img src="/cache/albums/thumbs/'.$ph['server_name'].'.jpg" alt="" /><br />
<input type="submit" name="yes" value="'. _t('yyes') .'" /> <input type="submit" name="no" value="'. _t('yno') .'" />
</form>
</div>';
$tpl->div('block', img('nav.png') . ' <a href="/albums/photo/'.$photo_id.'">'. _t('back') .'</a><br/>'
. img('nav.png') . ' <a href="/albums/">'. _t('photo_albums') .'</a><br/>'
. HICO .' <a href="/">'. _t('home') .'</a>');
include_footer();
?>