View file includes/inc_make_jad.php

File size: 0.99Kb
<?php

if (!defined('SECURED'))
{
	die("Unknown Error!");
}

require_once('includes/pclzip.lib.php');

function make_jad($jarsource,$jardestination,$jarurl) 
{
global $config;

$zip = new PclZip($jarsource);
$c = $zip->extract(PCLZIP_OPT_BY_NAME,"META-INF/MANIFEST.MF", PCLZIP_OPT_EXTRACT_AS_STRING);
$c = $c[0]['content'];
$filename = basename($jarsource);
if($c)
	{
	$jn=str_replace(".jar", ".jad", $filename);
	$c=trim(str_replace("\r\n","\n",$c));
	$a=explode("\n",$c);
	unset($c);
	foreach($a as $s)
		{
		if(strpos($s,"MIDlet-Jar-Size:")===false && strpos($s,"MIDlet-Jar-URL:")===false && strpos($s,"MIDlet-Vendor:")===false)
			{
			$c.=$s."\n";
			}
		}
	$c.="MIDlet-Jar-Size: ".filesize($jarsource)."\n";
	$c.="MIDlet-Jar-URL: ".$jarurl."\n";
	$c.="MIDlet-Vendor: ".$config['site']."(".str_replace('http://', null, $config['url']).")\n";
	
	$jadsource="$jardestination/$jn";
	$fp=fopen($jadsource,"a+");
	fputs($fp,$c);
	fclose($fp);
	@chmod ($jadsource, 0777);

	return $jadsource;
	}
else return false;
}
?>