File size: 1.34Kb
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/system/function.php';
header('Content-type:image/png');
$name = isset($_GET['file']) ? guard($_GET['file']) : null;
$url = H.'/files/'.$name;
if (empty($name)) {
header('HTTP/2.0 404 Not found');
exit;
} elseif (!file_exists($url)) {
header('HTTP/2.0 404 Not found');
exit;
}
$zip = new ZipArchive;
if ($zip->open($url) === true) {
for ($i = 0; $i < $zip->numFiles; $i++) {
$t = $zip->statIndex($i);
if (preg_match('/res\/mipmap(|-ldpi(|-v4|-v17)|-mdpi(|-v4|-v17)|-hdpi(|-v4|-v17)|-xhdpi(|-v4|-v17)|-xxhdpi(|-v4|-v17)|-xxxhdpi(|-v4|-v17))\/(ic_launcher|launcher_icon|icon|logo|ic).(png|jpg|jpeg|gif)/is', $t['name'])) {
$icon = $t['name'];
} elseif (preg_match('/res\/drawable(|-ldpi(|-v4|-v17)|-mdpi(|-v4|-v17)|-hdpi(|-v4|-v17)|-xhdpi(|-v4|-v17)|-xxhdpi(|-v4|-v17)|-xxxhdpi(|-v4|-v17))\/(ic_launcher|launcher_icon).(png|jpg|jpeg)/is', $t['name'])) {
$icon = $t['name'];
}
}
}
if (isset($icon)) {
$img_str = $zip->getFromName($icon);
$img = imagecreatefromstring($img_str);
imagealphablending($img, false);
imagesavealpha($img, true);
imagepng($img);
imagedestroy($img);
} else {
$img = imagecreatefrompng(H.'/assets/img/ic_launcher.png');
imagealphablending($img, false);
imagesavealpha($img, true);
imagepng($img);
imagedestroy($img);
}
$zip->close();
?>