<?php

if (is_file($dir_loads . '/' . $dirlist[$i] . '.1.GIF')) {
    echo "<img src=\"resize.php?" . url("f=$l/$dirlist[$i].1.GIF") . "&amp;w=48&amp;h=48\" alt=\"—крин...\" /><br />\n";
} elseif (is_file($dir_loads . '/' . $dirlist[$i] . '.1.JPG')) {
    echo "<img src=\"resize.php?" . url("f=$l/$dirlist[$i].1.JPG") . "&amp;w=48&amp;h=48\" alt=\"—крин...\" /><br />\n";
} elseif (is_file($dir_loads . '/' . $dirlist[$i] . '.1.PNG')) {
    echo "<img src=\"resize.php?" . url("f=$l/$dirlist[$i].1.PNG") . "&amp;w=48&amp;h=48\" alt=\"—крин...\" /><br />\n";
}
if (is_file(H . "sys/loads/screens/48/$size.$name.gif")) {
    if (USE_ICONV) {
        echo "<img src='" . iconv('windows-1251', 'utf-8', "/sys/loads/screens/48/$size.$name.gif") . "' alt='scr...' /><br />\n";
    } else {
        echo "<img src='/sys/loads/screens/48/$size.$name.gif' alt='scr...' />\n";
    }
}
elseif (class_exists('ffmpeg_movie')) {
    $media = new ffmpeg_movie(realpath($dir_loads . '/' . $dirlist[$i]));
    $k_frame = intval($media->getFrameCount());

    $w = $media->GetFrameWidth();
    $h = $media->GetFrameHeight();
    $ff_frame = $media->getFrame(intval($k_frame / 2));
    if ($ff_frame) {
        $gd_image = $ff_frame->toGDImage();
        if ($gd_image) {
            $des_img = imagecreatetruecolor(48, 48);
            $s_img = $gd_image;
            imagecopyresampled($des_img, $s_img, 0, 0, 0, 0, 48, 48, $w, $h);
            imagegif($des_img, H . "sys/loads/screens/48/$size.$name.gif");
            chmod(H . "sys/loads/screens/48/$size.$name.gif", 0777);
            imagedestroy($des_img);
            imagedestroy($s_img);

            if (USE_ICONV) {
                echo "<img src='" . iconv('windows-1251', 'utf-8', "/sys/loads/screens/48/$size.$name.gif") . "' alt='scr...' /><br />\n";
            } else {
                echo "<img src='/sys/loads/screens/48/$size.$name.gif' alt='scr...' /><br />\n";
            }
            if (is_file($dir_loads . '/' . $dirlist[$i] . '' . $file . '.1.GIF')) {
                echo "<img src=\"resize.php?" . url("f=$l/$dirlist[$i]$file.1.GIF") . "&amp;w=48&amp;h=48\" alt=\"—крин...\" /><br />\n";
            } elseif (is_file($dir_loads . '/' . $dirlist[$i] . '' . $file . '.1.JPG')) {
                echo "<img src=\"resize.php?" . url("f=$l/$dirlist[$i]$file.1.JPG") . "&amp;w=48&amp;h=48\" alt=\"—крин...\" /><br />\n";
            } elseif (is_file($dir_loads . '/' . $dirlist[$i] . '' . $file . '.1.PNG')) {
                echo "<img src=\"resize.php?" . url("f=$l/$dirlist[$i]$file.1.PNG") . "&amp;w=48&amp;h=48\" alt=\"—крин...\" /><br />\n";
            }
        }
    }
}
?>