59 lines
2.6 KiB
PHP
59 lines
2.6 KiB
PHP
|
<?php
|
||
|
//Проверяем доступ
|
||
|
if ( $db -> check_access ( 'foto_albums', $_SESSION['album_id'] ) ==0 ) die( 'Нельзя!' );
|
||
|
|
||
|
switch( @$_POST['act'] ) {
|
||
|
/* 06.05.2021 Обновление альбома */
|
||
|
case 'update':
|
||
|
$db -> free_sql2( 'ALTER TABLE `foto_albums` ADD `' . $_POST['t'] . '` varchar(250) NULL' );
|
||
|
$db -> free_sql( "UPDATE `foto_albums` SET `" . $_POST['t'] . "` = '" . $_POST['txt'] . "' WHERE `id` = " . $_SESSION['album_id'] . ";" );
|
||
|
break;
|
||
|
case 'ava':
|
||
|
if ( $_FILES['file']['tmp_name'] ){
|
||
|
if ( preg_match( '/[.](jpg)|(jpeg)|(JPG)|(JPEG)$/', $_FILES['file']['name'] ) ){
|
||
|
require_once MYDIR . '/api/php/genpass.php';
|
||
|
$img_name = generate_password( 15 );
|
||
|
$source = $_FILES['file']['tmp_name'];
|
||
|
$target = MYDIR . '/img/albums/' . $img_name . '.jpg';
|
||
|
copy( $source, $target );
|
||
|
}
|
||
|
require_once MYDIR . '/api/php/img2.php';
|
||
|
rimg ( $target, 740, 556, $target, $zip=80, $c=0 );
|
||
|
echo $img_name;
|
||
|
//узнаем старую фотку и удаляем
|
||
|
unset( $a );
|
||
|
$a['id'] = $_SESSION['album_id'];
|
||
|
$ava = $db -> get_val( 'foto_albums', $a, 'img' );
|
||
|
unlink( MYDIR . '/img/albums/' . $ava . '.jpg' );
|
||
|
unset( $a );
|
||
|
$a['img'] = $img_name;
|
||
|
$db -> update( 'foto_albums', $_SESSION['album_id'], $a );
|
||
|
}
|
||
|
break;
|
||
|
/* 06.05.2021 удаление альбома */
|
||
|
case 'del_album':
|
||
|
//Получаем список фотографий
|
||
|
unset( $a );
|
||
|
$a['album_id'] = $_SESSION['album_id'];
|
||
|
$foto = $db -> get_massiv( 'foto_img', $a );
|
||
|
print_r( $foto );
|
||
|
$num = $db -> num;
|
||
|
for( $i = 0; $i < $num; $i++ ){
|
||
|
echo $foto[$i]['img'];
|
||
|
unlink( MYDIR . '/img/albums/' . $_SESSION['user_id'] . '/' . $_SESSION['album_id'] . '/' . $foto[$i]['img'] . '.jpg' );
|
||
|
unlink( MYDIR . '/img/albums/' . $_SESSION['user_id'] . '/' . $_SESSION['album_id'] . '/250/' . $foto[$i]['img'] . '.jpg' );
|
||
|
unlink( MYDIR . '/img/albums/' . $_SESSION['user_id'] . '/' . $_SESSION['album_id'] . '/big/' . $foto[$i]['img'] . '.jpg' );
|
||
|
unlink( MYDIR . '/img/albums/' . $_SESSION['user_id'] . '/' . $_SESSION['album_id'] . '/original/' . $foto[$i]['img'] . '.jpg' );
|
||
|
}
|
||
|
//Удаляем из таблицы фотографий записи
|
||
|
$db -> free_sql2( 'DELETE FROM `foto_img` WHERE `album_id` = "' . $_SESSION['album_id'] . '"' );
|
||
|
//Узнаем обложку альбома
|
||
|
unset( $a );
|
||
|
$a['id'] = $_SESSION['album_id'];
|
||
|
$img = $db -> get_val( 'foto_albums', $a, 'img' );
|
||
|
unlink ( MYDIR . '/img/albums/' . $img . '.jpg' );
|
||
|
$db -> del_id( 'foto_albums', $_SESSION['album_id'] );
|
||
|
break;
|
||
|
default:
|
||
|
}
|