malka1 Posted March 15, 2008 Report Share Posted March 15, 2008 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 More sharing options...
Zandis Murāns Posted March 15, 2008 Report Share Posted March 15, 2008 Tā unset($cont[0]); vietā ieliec šito: while ($cont[0]=="\r" || $cont[0]=="\n") $cont=substr($cont,1,strlen($cont)-1); Link to comment Share on other sites More sharing options...
Zandis Murāns Posted March 15, 2008 Report Share Posted March 15, 2008 Un vispār, kā tu zini, ka tieši tajā mainīgajā cont ir tukša pirmā rindiņa? Varbūt citur skriptā ir kļūda. Pārliecinies vai tavs skripts nesākas ar: [tukša rinda] <? ... Ieglabā mainīgā saturu failā un paskaties. Vai arī izvadi uz ekrāna: echo '|'.$cont.'|'; Link to comment Share on other sites More sharing options...
malka1 Posted March 15, 2008 Author Report Share Posted March 15, 2008 izskataas, ka $cont nav pie tā vainīgs- skatīshos dziljaak skriptaa... Link to comment Share on other sites More sharing options...
bubu Posted March 15, 2008 Report Share Posted March 15, 2008 Tas while cikls nav labs. Daudz izdevīgāk (efektīvāk) ir rakstīt kautko šādu: $con = ltrim($con, "\r\n"); Link to comment Share on other sites More sharing options...
malka1 Posted March 15, 2008 Author Report Share Posted March 15, 2008 (edited) 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 March 15, 2008 by malka1 Link to comment Share on other sites More sharing options...
Zandis Murāns Posted March 15, 2008 Report Share Posted March 15, 2008 Tavs risinājums vienkārši sūkā, lai neteiktu vairāk. :) Link to comment Share on other sites More sharing options...
malka1 Posted March 15, 2008 Author Report Share Posted March 15, 2008 bet toties straadaa xD Link to comment Share on other sites More sharing options...
Recommended Posts