Файл: modules/albums/delete_album.php
Строк: 48
<?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';
$alb_id = abs(intval($_GET['id']));
$album = $db->query("SELECT * FROM `albums` WHERE `id` = '". $alb_id ."'")->fetch();
if(!isset($alb_id) && $db->query("SELECT * FROM `albums` WHERE `id` = '$alb_id'")->rowCount() == 0 || $album['user_id'] != User::Id() || User::level() != 2 && User::level() < 6)
{
header('location: /albums/');
exit;
}
if(isset($_GET['act']) && $_GET['act'] == 'delete')
{
if(isset($_POST['yes']))
{
$db->query("DELETE FROM `albums_photo` WHERE `album_id` = '". $alb_id ."'");
$db->query("DELETE FROM `albums` WHERE `id` = '". $alb_id ."'");
rrmdir(ROOT.'/files/albums/'.$alb_id);
rrmdir(ROOT.'/cache/albums/thumbs/'.$alb_id);
// print_r($db->errorInfo());
header('location: /albums/user/'.$album['user_id']);
exit;
}
elseif(isset($_POST['no']))
{
header('location: /albums/user/'.$album['user_id']);
exit;
}
}
$title = _t('delete');
include_header($title);
$tpl->div('title', _t('delete'));
echo '<div class="post">
<form action="/albums/delete_album/'.$alb_id.'?act=delete" method="post">
'._t('del_album').' <b>'.$album['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('nav.png') . ' <a href="/albums/user/'.$album['user_id'].'">'. _t('back') .'</a><br/>'
. img('nav.png') . ' <a href="/albums/">'. _t('photo_albums') .'</a><br/>'
. HICO .' <a href="/">'. _t('home') .'</a>');
include_footer();
?>