Вход Регистрация
Файл: modules/foto/inc/gallery_show_act.php
Строк: 92
<?php

/* Мод "Фотоальбомы"
 * Версия v0.0.1
 * Дата последнего редактирования 27.11.2014
 * Двиг DCMS Special
 * Модифицировал densnet
 * Файл gallery_show_act.php
 * Описание: выводит информацию
 */

if ((user::access('foto_alb_del') || isset($user) && $user['id'] == $ank['id']) && isset($_GET['act']) && $_GET['act'] == 'edit' && isset($_GET['ok'])) {
    
$name = text::esc(stripcslashes(htmlspecialchars($_POST['name'])), 1);

    if (
text::utf8_strlen($name) < 3) {
        
$err[] = 'Короткое название';
    }
    if (
text::utf8_strlen($name) > 32) {
        
$err[] = 'Название не должно быть длиннее 32-х символов';
    }
    
$name = mysql_real_escape_string($name);
    
$msg = $_POST['opis'];

//if (text::utf8_strlen($msg)<10)$err='Короткое описание';
    
if (text::utf8_strlen($msg) > 256) {
        
$err[] = 'Длина описания превышает предел в 256 символов';
    }
    
$msg = mysql_real_escape_string($msg);

    if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery` WHERE `id_user` = '$ank[id]' AND `name` = '$name' AND `id` != '$gallery[id]'"), 0) != 0) {
        
$err[] = 'Альбом с таким названием уже существует';
    }

    if (
in_array($_POST['access'], array('all', 'only_me', 'friends', 'pass', 'auth'))) {
        
$access = $_POST['access'];
    } else {
        
$access = 'all';
    }

    if (
$access == 'pass') {
        if (
text::utf8_strlen($_POST['passwd']) < 1) {
            
$err[] = 'Введите пароль!';
        }
        if (
text::utf8_strlen($_POST['passwd']) > 16) {
            
$err[] = 'Пароль слишком длинный!';
        }
        
$password = $_POST['passwd'];
    } else {
        
$password = NULL;
    }

    if (!isset(
$err)) {
        if (
$user['id'] != $ank['id']) {
            
admin_log('Фотогалерея', 'Фотоальбомы', "Редактирование фотоальбома пользователя '[url=/info.php?id=$ank[id]]$ank[nick][/url]'");
        }
        
mysql_query("UPDATE `gallery` SET `opis` = '$msg', `name` = '$name', `access` = '$access', `password` = '$password' WHERE `id` = '$gallery[id]'");
        
header("Location: /modules/foto/$ank[id]/$gallery[id]/");
        exit();
    }
}

if ((
user::access('foto_alb_del') || isset($user) && $user['id'] == $ank['id']) && isset($_GET['act']) && $_GET['act'] == 'delete' && isset($_GET['ok'])) {
    
$q = mysql_query("SELECT * FROM `gallery_foto` WHERE `id_gallery` = '$gallery[id]'");
    while (
$post = mysql_fetch_assoc($q)) {
        @
unlink(H . "sys/gallery/48/$post[id].jpg");
        @
unlink(H . "sys/gallery/128/$post[id].jpg");
        @
unlink(H . "sys/gallery/640/$post[id].jpg");
        @
unlink(H . "sys/gallery/foto/$post[id].jpg");

        
mysql_query("DELETE FROM `gallery_foto` WHERE `id` = '$post[id]' LIMIT 1");
    }
    if (
$user['id'] != $ank['id']) {
        
admin_log('Фотогалерея', 'Фотоальбомы', "Удаление альбома $gallery[name] (фотографий: " . mysql_num_rows($q) . ")");
    }
    
mysql_query("DELETE FROM `gallery` WHERE `id` = '$gallery[id]' LIMIT 1");
    
msg('Фотоальбом успешно удален');
    
aut();

    echo 
"<div class = 'razd'>" . img('left.png') . " <a href = '" . DIR_FOTO . "$ank[id]/'>К фотоальбомам</a></div>";

    require_once 
H . 'sys/inc/tfoot.php';
    exit;
}

if (isset(
$user) && $user['id'] == $ank['id'] && isset($_FILES['file'])) {
    if (
$imgc = @imagecreatefromstring(file_get_contents($_FILES['file']['tmp_name']))) {
        
$name = text::esc(stripcslashes(htmlspecialchars($_POST['name'])), 1);

        if (
$name == null) {
            
$name = text::esc(stripcslashes(htmlspecialchars(preg_replace('#.[^.]*$#i', NULL, $_FILES['file']['name']))));
        }

        if (!
preg_match("#^([A-zА-я0-9-_ ])+$#ui", $name)) {
            
$err = 'В названии фото присутствуют запрещенные символы';
        }
        if (
text::utf8_strlen($name) < 3) {
            
$err = 'Короткое название';
        }
        if (
text::utf8_strlen($name) > 32) {
            
$err = 'Название не должно быть длиннее 32-х символов';
        }
        
$name = mysql_real_escape_string($name);
        
$msg = $_POST['opis'];

        
#if (text::utf8_strlen($msg)<10)$err='Короткое описание';
        
if (text::utf8_strlen($msg) > 10024) {
            
$err = 'Длина описания превышает предел в 10024 символов';
        }
        
$msg = mysql_real_escape_string($msg);
        
$img_x = imagesx($imgc);
        
$img_y = imagesy($imgc);

        if (
$img_x > $set['max_upload_foto_x'] || $img_y > $set['max_upload_foto_y']) {
            
$err = 'Размер изображения превышает ограничения в ' . $set['max_upload_foto_x'] . '*' . $set['max_upload_foto_y'];
        }
        if (isset(
$_POST['adult']) && $_POST['adult'] == 1) {
            
$adult = 1;
        } else {
            
$adult = 0;
        }

        if (!isset(
$err)) {
            
mysql_query("INSERT INTO `gallery_foto` (`id_gallery`, `name`, `ras`, `type`, `opis`, `id_user`, `adult`) values ('$gallery[id]', '$name', 'jpg', 'image/jpeg', '$msg', '$user[id]', '$adult')");
            
$id_foto = mysql_insert_id();
            
mysql_query("UPDATE `gallery` SET `time` = '$time' WHERE `id` = '$gallery[id]' LIMIT 1");

            if (
$img_x == $img_y) {
                
$dstW = 48; // ширина
                
$dstH = 48; // высота 
            
} elseif ($img_x > $img_y) {
                
$prop = $img_x / $img_y;
                
$dstW = 48;
                
$dstH = ceil($dstW / $prop);
            } else {
                
$prop = $img_y / $img_x;
                
$dstH = 48;
                
$dstW = ceil($dstH / $prop);
            }

            
$screen = imagecreatetruecolor($dstW, $dstH);
            
imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
            
#imagedestroy($imgc);
            
imagejpeg($screen, H . "sys/gallery/48/$id_foto.jpg", 90);
            @
chmod(H . "sys/gallery/48/$id_foto.jpg", 0777);
            
imagedestroy($screen);

            if (
$img_x == $img_y) {
                
$dstW = 128; // ширина
                
$dstH = 128; // высота 
            
} elseif ($img_x > $img_y) {
                
$prop = $img_x / $img_y;
                
$dstW = 128;
                
$dstH = ceil($dstW / $prop);
            } else {
                
$prop = $img_y / $img_x;
                
$dstH = 128;
                
$dstW = ceil($dstH / $prop);
            }

            
$screen = imagecreatetruecolor($dstW, $dstH);
            
imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
            
#imagedestroy($imgc);
            
$screen = img_copyright($screen); // наложение копирайта
            
imagejpeg($screen, H . "sys/gallery/128/$id_foto.jpg", 90);
            @
chmod(H . "sys/gallery/128/$id_foto.jpg", 0777);
            
imagedestroy($screen);

            if (
$img_x > 640 || $img_y > 640) {
                if (
$img_x == $img_y) {
                    
$dstW = 640; // ширина
                    
$dstH = 640; // высота 
                
} elseif ($img_x > $img_y) {
                    
$prop = $img_x / $img_y;
                    
$dstW = 640;
                    
$dstH = ceil($dstW / $prop);
                } else {
                    
$prop = $img_y / $img_x;
                    
$dstH = 640;
                    
$dstW = ceil($dstH / $prop);
                }

                
$screen = imagecreatetruecolor($dstW, $dstH);
                
imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
                
#imagedestroy($imgc);
                
$screen = img_copyright($screen); // наложение копирайта
                
imagejpeg($screen, H . "sys/gallery/640/$id_foto.jpg", 90);
                
imagedestroy($screen);
                
$imgc = img_copyright($imgc); // наложение копирайта
                
imagejpeg($imgc, H . "sys/gallery/foto/$id_foto.jpg", 90);
                @
chmod(H . "sys/gallery/foto/$id_foto.jpg", 0777);
            } else {
                
$imgc = img_copyright($imgc); // наложение копирайта

                
imagejpeg($imgc, H . "sys/gallery/640/$id_foto.jpg", 90);
                
imagejpeg($imgc, H . "sys/gallery/foto/$id_foto.jpg", 90);
                @
chmod(H . "sys/gallery/foto/$id_foto.jpg", 0777);
            }

            @
chmod(H . "sys/gallery/640/$id_foto.jpg", 0777);

            
imagedestroy($imgc);
            
msg("Фотография успешно добавлена");
        }
    } else {
        
$err = 'Выбранный Вами формат изображения не поддерживается';
    }
}
Онлайн: 3
Реклама