View file aiv2 AutoIndex/preview.php

File size: 6.28Kb
<?php
/**
 * @name preview.php
 * @description Generates preview files for most files!
 * @package Punk Autoindex  
 * @author MobiHacK
 * @copyright RockiTech Group
 * @version 2.0
 */
 
include ('config.php');
if (isset($_GET['file']) and !empty($_GET['file']))
$file = $func->file($_GET['file']);
else
$file = null;

if (is_null($file)):
header('Location: ' . $config->installdir . '/customization/file.png');
die();
endif;

$ext = $func->ext($file);
$name = str_replace(array('\\', '/'), 'D', $file);
$name = str_replace('.', 'T', $name);

if (in_array($ext, array(
'png',
'gif',
'jpg',
'jpeg'))) {
$ac=$_GET['loc'];
if (isset($ac) and $ac=='dload') {
$nh = 105;
$nw = 80;
} else {
$nh = $config->nh;
$nw = $config->nw;
}
$name = "./scr/img/" . $name . "($nh-$nw).png";
if (file_exists($name)) {
header('Location: ' . $name, true, 301);
die();
}
list(, , $type, ) = getimagesize($file);

if ($type == 1) {
$funci = 'imagecreatefromgif';
$funco = 'imagegif';
}
if ($type == 2) {
$funci = 'imagecreatefromjpeg';
$funco = 'imagejpeg';
}
if ($type == 3) {
$funci = 'imagecreatefrompng';
$funco = 'imagepng';
}
if (isset($type)) {
$im1 = $funci($file);

$im2 = imagecreatetruecolor($nw, $nh);
imagecopyresized($im2, $im1, 0, 0, 0, 0, $nw, $nh, imagesx($im1), imagesy($im1));

/*$TextColor = imagecolorallocate($im2, 255, 255, 255);
ImageTTFtext($im2, 10, 90, 52, 52, $TextColor, 'arial.ttf', 'WTF');*/

header('Content-type: image/gif');
$funco($im2, $name);
header('Location: ' . $name, true, 301);
die();
}
} elseif (in_array($ext, array('jar'))) {
$name = './scr/jar/' . $name . '.png';
if (is_file($name)) {
header('Location: ' . $name, true, 301);
die();
}
$q = array(
"icon.png",
"ico.png",
"i.png",
"icono.png",
"Icon.png",
"Ico.png",
"I.png",
"Icono.png",
"ICON.png",
"ICO.png",
"I.png",
"ICONO.png",
"ICON.PNG",
"ICO.PNG",
"I.PNG",
"ICONO.PNG",
"icons/icon.png",
"icons/ico.png",
"icons/i.png",
"icons/icono.png",
"i",
"I");
include ($config->pcl);
$zip = new PclZip($file);
$ar = $zip->extract(PCLZIP_OPT_BY_NAME, $q, PCLZIP_OPT_EXTRACT_AS_STRING);
$pre = $ar[0]['content'];
if (!empty($pre)) {
$im = imagecreatefromstring($pre);
$im2 = imagecreatetruecolor($config->nw, $config->nh);
imageCopyResized($im2, $im, 0, 0, 0, 0, $config->nw, $config->nh, imagesx($im),
imagesy($im));
imagepng($im2, $name);
header('Location: ' . $config->installdir . $name, true, 301);
die();
} else {
header('Location: ' . $config->installdir . 'customization/jar.png', true, 301);
die();
}
} elseif (in_array($ext, array(
'3gp',
'avi',
'mp4',
'mpg',
'mpeg'))) {
$name = "./scr/vid/" . $name . ".gif";
if (is_file($name)) {
header('Location: ' . $name, true, 301);
die();
}
if (!class_exists('ffmpeg_movie')) {
header('Location: ' . $config->installdir . '/customization/' . $ext . '.png', true,
301);
die();
}
$mov = new ffmpeg_movie(realpath($file), false); //Never remove the relpath function!(For windows users)
$wn = $mov->GetFrameWidth();
$hn = $mov->GetFrameHeight();

$frame = $mov->getFrame(3);

$gd = $frame->toGDImage();

$new = imageCreateTrueColor($config->nw, $config->nh);
imageCopyResized($new, $gd, 0, 0, 0, 0, $config->nw, $config->nh, $wn, $hn);
imageGif($new, $name, 100);
header('Location: ' . $name, true, 301);
die();
} elseif (in_array($ext, array('nth', 'thm'))) {
$name = './scr/thm/' . $name . '.gif';
if (file_exists($name)) {
header('Location: ' . $name, true, 301);
die();
}
$type = $func->ext($file);
$g_preview_image_w = $neww;
$g_preview_image_h = $neww;
if ($type == 'nth') {
include ($config->pcl);
$nth = @new PclZip($theme);
$content = $nth->extract(PCLZIP_OPT_BY_NAME, 'theme_descriptor.xml',
PCLZIP_OPT_EXTRACT_AS_STRING);
$teg = simplexml_load_string($content[0]['content'])->wallpaper['src'] or $teg =
simplexml_load_string($content[0]['content'])->wallpaper['main_display_graphics'];
if (empty($teg)) {
header('Location: ./customization/file.png', true, 301);
die();
}
$image = $nth->extract(PCLZIP_OPT_BY_NAME, trim($teg),
PCLZIP_OPT_EXTRACT_AS_STRING);
$im = array_reverse(explode('.', $teg));
$im = 'imageCreateFrom' . str_ireplace('jpg', 'jpeg', trim($im[0]));
file_put_contents($name, $image[0]['content']);
$f = $im($name);
$h = imagesy($f);
$w = imagesx($f);
$new = imagecreatetruecolor($config->nw, $config->nh);
imagecopyresampled($new, $f, 0, 0, 0, 0, $config->nw, $config->nh, $w, $h);
imageGif($new, $name, 100);
} elseif ($type == 'thm') {
include ($config->tar);
@$thm = @new Archive_Tar($theme);
$deskside_file = $thm->extractInString('Theme.xml');
$load = simplexml_load_string($deskside_file)->Standby_image['Source'] or $load =
simplexml_load_string($deskside_file)->Desktop_image['Source'] or $load =
simplexml_load_string($deskside_file)->Desktop_image['Source'];
$image = $thm->extractInString(trim($load));
$im = array_reverse(explode('.', $load));
$im = 'imageCreateFrom' . str_ireplace('jpg', 'jpeg', trim($im[0]));
file_put_contents($name, $image);
$f = $im($name);
$h = imagesy($f);
$w = imagesx($f);
$ratio = $w / $h;
if ($g_preview_image_w / $g_preview_image_h > $ratio) {
$g_preview_image_w = $g_preview_image_h * $ratio;
} else {
$g_preview_image_h = $g_preview_image_w / $ratio;
}

$new = imagecreatetruecolor($g_preview_image_w, $g_preview_image_h);
imagecopyresampled($new, $f, 0, 0, 0, 0, $g_preview_image_w, $g_preview_image_h,
$w, $h);
imageGif($new, $name, 100);
}
$ima = getimagesize($name);
if ($ima[0] < 1) {
header('Location: ./customization/file.png', true, 301);
die();
}
header('Location: ' . $name, true, 301);
die();
} elseif ($ext == 'apk') {
include ($config->pcl);
$zip = new PclZip($file);
$ar = $zip->extract(PCLZIP_OPT_BY_PREG, "/png$/", PCLZIP_OPT_EXTRACT_AS_STRING);
$pre = $ar[0]['content'];
if (!empty($pre)) {
$name = './scr/apk/' . $name . '.png';
$im = imagecreatefromstring($pre);
$im2 = imagecreatetruecolor($config->nw, $config->nh);
imageCopyResized($im2, $im, 0, 0, 0, 0, $config->nw, $config->nh, imagesx($im),
imagesy($im));
imagepng($im2, $name);
header('Location: ' . $config->installdir . $name, true, 301);
die();
} else {
header('Location: ' . $config->installdir . 'customization/apk.png', true, 301);
die();
}
} else
header('Location: ' . $config->installdir . 'customization/file.png', true, 301);
?>