Файл: modules/obmen/inc/icons/jar.php
Строк: 54
<?php
$zip = new PclZip($file['path']);
$content = $zip->extract(PCLZIP_OPT_BY_NAME, "META-INF/MANIFEST.MF", PCLZIP_OPT_EXTRACT_AS_STRING);
$manifest = @$content[0]['content'];
if (preg_match('#^midlet-icon:s*/?(.*?)s*$#im', $manifest, $icon)) {
    $icon = $icon[1];
} elseif (preg_match('#^midlet-d+:.*?,s*/?(.*?)s*,.*?$#im', $manifest, $icon)) {
    $icon = $icon[1];
} else {
    $icon = false;
}
if ($icon) {
    $content = $zip->extract(PCLZIP_OPT_BY_NAME, $icon, PCLZIP_OPT_EXTRACT_AS_STRING);
    if ($imgc = @imagecreatefromstring($content[0]['content'])) {
        $img_x = imagesx($imgc);
        $img_y = imagesy($imgc);
        $dstW = 14; #ширина
        if ($img_x == $img_y) {
            $dstH = 14; #высота
        } else {
            $dstH = ceil($dstW / $img_x * $img_y); #высота
        }
        $screen = imagecreate($dstW, $dstH);
        imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
        imagedestroy($imgc);
    } else {
        $screen = $imgc;
    }
#наложение иконки файла на уменьшенный скриншот
    if (is_file($file['path'] . '.GIF') && $img_f = @imagecreatefromgif($file['path'] . '.GIF')) {
        
    } elseif (is_file($file['path'] . '.JPG') && $img_f = @imagecreatefromjpeg($file['path'] . '.JPG')) {
        
    } elseif (is_file($file['path'] . '.PNG') && $img_f = @imagecreatefrompng($file['path'] . '.PNG')) {
        
    }
    if (isset($img_f)) {
        $imgf_x = imagesx($img_f);
        $imgf_y = imagesy($img_f);
        $dstW2 = 48; #ширина
        if ($imgf_x == $imgf_y) {
            $dstH2 = 48;  #высота
        } else {
            $dstH2 = ceil($dstW2 / $imgf_x * $imgf_y); #высота
        }
        $screen2 = imagecreatetruecolor($dstW2, $dstH2);
        imagecopyresampled($screen2, $img_f, 0, 0, 0, 0, $dstW2, $dstH2, $imgf_x, $imgf_y);
        imagedestroy($img_f);
        imagecopy($screen2, $screen, $dstW2 - $dstW - 1, $dstH2 - $dstH - 1, 0, 0, $dstW, $dstH);
        imagejpeg($screen2, $file['scr48']['jpg'], 95);
        $file['icon'] = "/sys/obmen/screens/width-48_$file[file_base64]" . THEME_DIR . "$file[size].jpg";
        imagedestroy($screen2);
    } else {
        imagepng($screen, $file['scr14']['png']);
        $file['icon'] = "/sys/obmen/screens/width-14_$file[file_base64]-$file[size].png";
    }
} elseif (is_file(H . ICONS_FILES . $file['ras'] . '.png')) {
    $file['icon'] = ICONS_FILES . $file['ras'] . '.png';
} else {
    $file['icon'] = ICONS_FILES . 'file.png';
}
@chmod($file['scr14']['png'], 0777);