<?php
if (!isset ($_GET['jar' ]))exit ;
$zip = new ZipArchive;
if ($zip->open(base64_decode($_GET['jar' ])) === TRUE ) {
if ($manifest = $zip->getFromName('META-INF/MANIFEST.MF' )){
if (strpos($manifest, 'MIDlet-Icon: ' ) !== FALSE ){
$jad = explode('MIDlet-Icon: ' ,$manifest);
$icon = str_replace("\n" ,' ' , $jad[1 ]);
$icon = str_replace("\r" ,' ' , $icon);
$icon = strtok($icon,' ' );
$icon = preg_replace('#^/#' , NULL , $icon);
}
else $icon='icon.png' ;
}else exit ;
if ($image = $zip->getFromName($icon)){
$image = imagecreatefromstring($image);
$width=imagesx($image);
$height=imagesy($image);
$x_ratio=16 /$width;
$y_ratio=16 /$height;
if (($width<=16 )&&($height<=16 )){
$tn_width=$width;
$tn_height=$height;
}elseif (($x_ratio*$height)<16 ){
$tn_height=ceil($x_ratio*$height);
$tn_width=16 ;
}else {
$tn_width=ceil($y_ratio*$width);
$tn_height=16 ;
}
$dst=ImageCreate($tn_width,$tn_height);
imagecopyresampled($dst, $image, 0 , 0 , 0 , 0 , $tn_width,$tn_height,$width,$height);
$image = $dst;
}else {
$image = imagecreatefrompng('my_icon.png' );
}
header('Content-type: image/png' );
ImagePng($image);
ImageDestroy($image);
$zip->close();
}
?>
Описание:
Создаёте файл и туда лепите этот код. Для примера название файла будет icon.php
Тогда пишите такую штуку где вам надо:
echo 'Иконка: <img src="icon.php?jar=' .base64_encode('java_game.jar' ).'"/>' ;