<?php
include_once "pclzip.php";
$jarfile=substr($filename,0,(strlen($filename)-4));$jarfile.=".zip";$jarfile="maker/$jarfile";
if(!is_dir("maker")){mkdir("maker");chmod("maker",0777);}
copy("jar/$filename",$jarfile);
$jar=new PclZip($jarfile);
if($jar->extract(PCLZIP_OPT_BY_NAME,"META-INF/MANIFEST.MF",PCLZIP_OPT_PATH,"maker/",PCLZIP_OPT_REMOVE_ALL_PATH)<>0){
if(file_exists("maker/MANIFEST.MF")){
$jadfile=substr($jarfile,0,(strlen($jarfile-4)));
$jad_url="http://".$_SERVER['SERVER_NAME']."/mobileshare/".$jadfile.".jad";
copy("jar/$filename","maker/$filename");unlink($jarfile);
$fp=fopen("maker/MANIFEST.MF",'a');fwrite($fp,"MIDlet-Jar-Url: /".$filename."\r\n");fclose($fp);
copy("maker/MANIFEST.MF",$jadfile.".jad");/*unlink("maker/MANIFEST.MF");*/ echo "<a href=\"$jad_url\">[+JAD]</a><br/>";}}
if(file_exists($jarfile)){unlink($jarfile);}
?>