<?php
#----0000------------------------------------#
#----00--00----------------------------------#
#----00---000----000000-----000000-#
#----00---0000--00----00----00---00--#
#----00---0000--00-----------00---------#
#----00---0000--000000----00000--#
#----00---000---00-----------00---------#
#----00--00-----00---00-----00---------#
#----0000-------000000----00--------#
#-----------------------------------------------------------#
#     Загруз центр вер. 1.00 для Wap Motor       #
#                            Зделано  def                            #
#                            ICQ: 4627473                          #
#        Site of the project: http://wapruk.ru         #
#------------------------------------------------------------#
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
include_once("inc/func.inc");
include('../template/pclzip.php');
$file = ("files$did/$fid");
list($tip,$oform)=file_type("files$did");
$format=format($fid);
$fid1 = str_replace('.'.$format, '', $fid);
$folderscr=rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$site=$_SERVER['SERVER_NAME'];
$jadFileName = $fid1.".jad";
if (((file_exists("$file"))==true) and $format=="jar"){
	$zip = new PclZip($file);
	$ar = $zip->extract(PCLZIP_OPT_BY_NAME,"META-INF/MANIFEST.MF", 
	                    PCLZIP_OPT_EXTRACT_AS_STRING);
	$ars = $ar[0]['content'];
		$ars=trim(str_replace("\r\n","\n",$ars));
		$ars=trim(str_replace("Manifest-Version: 1.0","",$ars));
		$ars=trim(str_replace("Manifest-Version: 2.0","",$ars));
		$ars=trim(str_replace("Manifest-Version: 2.1","",$ars));
		$ars=trim(str_replace("Manifest-Version: 2.2","",$ars));
		$ars=trim(str_replace("Manifest-Version: 2.3","",$ars));
		$ars=trim(str_replace("Manifest-Version: 1.1","",$ars));
		$ars=trim(str_replace("Manifest-Version: 1.2","",$ars));
		$ars=trim(str_replace("Manifest-Version: 1.3","",$ars));
		$ars .= "\nMIDlet-Jar-Size: ".filesize($file)."\nMIDlet-Jar-URL: http://".$site.$folderscr.'/'.$file."\nMIDlet-Info-URL: http://$site\nNokia-MIDlet-Category: Game\nMIDlet-Delete-Confirm: Вы уверены что хотите удалить файл скачаный с сайта http://$site?\nMIDlet-Description: Лучшие игры и приложения на сайте http://$site";
		header("Content-Type: text/vnd.sun.j2me.app-descriptor");
		header("Content-Disposition: attachment; filename=".$_GET["cf"]);
		header("Content-Length: ".strlen($ars));
		
		$fp = fopen("files$did/$jadFileName","w");
		fputs($fp,$ars);
		fclose($fp);

header("Location: files$did/$jadFileName");}else{header("Location: index.php?did=$did&fid=$fid");}
?>