<?php
define('ROOT','../');
define('GCMS',true);
define('SYS','../../');
require_once (ROOT.'system/power.php');

$row = $db -> query("SELECT  TRIM(`infolder`),`name`,`load` FROM `obmen_files` WHERE `id`='".$id."'") -> fetch_assoc();

if (file_exists($row['infolder'])) {

	if (!isset($_COOKIE['jar_'.$id]) && isset($_GET['load'])) {
$up=$row['load']+1;
$db -> query("UPDATE `obmen_files` SET `load`='$up' WHERE `id`='".$id."'"); 
		setCookie('jar_'.$id, time(), time() + 3600 * 24 * 365, '/');
	}
	
	require_once('power/pclzip.lib.php');
	
	$zip = new PclZip($row['infolder']);
	$content = $zip->extract(PCLZIP_OPT_BY_NAME, 'META-INF/MANIFEST.MF', PCLZIP_OPT_EXTRACT_AS_STRING);

	header('Content-type: text/vnd.sun.j2me.app-descriptor');
	header('Content-Disposition: attachment; filename="'.basename($row['infolder']).'.jad";');

	echo $content[0]['content']."\n".'MIDlet-Jar-Size: '.$row['name']."\n".'MIDlet-Jar-URL: '.$row['infolder'];
	
} else {
header('location: index.php');
}
?>