Jump to content
php.lv forumi

Kā izdzēst pirmo rindiņu iekš PHP skripta?


malka1

Recommended Posts

Tātad ir skripts, kas atver .jar failu, sameklē info iekš META-INF/MANIFEST.MF un pēc tam izveido .jad failu (java spēles mobīlajā telefonā), bet .jad fails izvadās ar tukšu pirmo rindiņu un es nesaprotu, kur tā rodas. Kā varētu izdzēst to pirmo rindiņu?

 

<?php
header("Content-type: text/vnd.sun.j2me.app-descriptor;charset=UTF-8");
//error_reporting (0);
if (!is_file("code.php")) exit (":)");
if(!$d) exit;
if(substr($d,0,5)=='http:') exit;
$d = htmlspecialchars(stripslashes($d));
$d = str_replace(array('..','//'),array('','/'),$d);
if(!is_file($d)) exit;
$ex = pathinfo ($d); $ex = $ex['extension'];
if($ex != 'jar') exit;
include 'pclzip.lib.php';
$zip = new PclZip($d);
$cont = $zip->extract(PCLZIP_OPT_BY_NAME,"META-INF/MANIFEST.MF", PCLZIP_OPT_EXTRACT_AS_STRING);
$cont = $cont[0]['content'];
$cont = str_replace("\r","",$cont);
$cont = str_replace("\n\n","\n",$cont);
$cont = str_replace("\r\n","",$cont);
$cont .= "MIDlet-Jar-Size: ".filesize($d)."\r\nMIDlet-Jar-URL: http://mans-saits.com/download2/".$d."";
//header ("Content-type: text/vnd.sun.j2me.app-descriptor");
unset($cont[0]);
exit ($cont);
?>

 

iekš boot foruma man teica, ka jaalieto unset funkcija, bet pasham nekaadiigi nesanaak to veiksmiigi ieintegreet skriptaa. varbuut kaads var pateikt, kur esmu kljuudiijies?

Link to comment
Share on other sites

mans risinaajums:

jadold.php:

<?php
//header("Content-type: text/vnd.sun.j2me.app-descriptor;charset=UTF-8");
//error_reporting (E_ALL);
if (!is_file("code.php")) exit (":)");
if(!$d) exit;
if(substr($d,0,5)=='http:') exit;
$d = htmlspecialchars(stripslashes($d));
$d = str_replace(array('..','//'),array('','/'),$d);
if(!is_file($d)) exit;
$ex = pathinfo ($d); $ex = $ex['extension'];
if($ex != 'jar') exit;
include 'pclzip.lib.php';
$zip = new PclZip($d);
$cont = $zip->extract(PCLZIP_OPT_BY_NAME,"META-INF/MANIFEST.MF", PCLZIP_OPT_EXTRACT_AS_STRING);
$cont = $cont[0]['content'];
$cont = str_replace("\r","",$cont);
$cont = str_replace("\n\n","\n",$cont);
$cont = str_replace("\r\n","",$cont);
$cont .= "MIDlet-Jar-Size: ".filesize($d)."\r\nMIDlet-Jar-URL: http://my-site.org/download2/".$d."";
//header ("Content-type: text/vnd.sun.j2me.app-descriptor");
while ($cont[0]=="\r" || $cont[0]=="\n")
$cont=substr($cont,1,strlen($cont)-1);
exit ($cont);
?>

 

jad.php:

<?php
//error_reporting (E_ALL);
header("Content-type: text/vnd.sun.j2me.app-descriptor;charset=UTF-8");
if (!is_file("code.php")) exit (":)");
if(!$d) exit;
if(substr($d,0,5)=='http:') exit;
$d = htmlspecialchars(stripslashes($d));
$d = str_replace(array('..','//'),array('','/'),$d);
if(!is_file($d)) exit;
$ex = pathinfo ($d); $ex = $ex['extension'];
if($ex != 'jar') exit;
$jad = file("http://my-site.org/download2/jadold.php?d=$d");
print"$jad[1]$jad[2]$jad[3]$jad[4]$jad[5]$jad[6]$jad[7]$jad[8]$jad[9]$jad[10]$jad[11]$jad[12]$jad[13]$jad[14]";
//file_put_contents("file.jad", join('', $jad));
?>

 

tas nekas, ka esmu iespeejams skjiibaakais koderis uz pasaules, bet galvenais ka straadaa ;)

Edited by malka1
Link to comment
Share on other sites

×
×
  • Create New...