572714 PHP XML Memory Issue
N/A
Paiement à la livraison
Hi i have a little bit of php code and its uses simple xml to parse file uploads
but it seems to work fine with
<?xml version="1.0" encoding="UTF-8"?> when its parsed tidly
but errors out on <?xml version="1.0" encoding="iso-8859-1" ?>
not just that also fails on large nzb files..
the code is
function pieceslisting($where, $id) {
$filecontent = file_get_contents($where);
$xml = simplexml_load_string($filecontent) or die ("Unable to load XML file!");
$nzbpiece = 0;
foreach($xml->{"file"} as $nfile) {
$nsubject = (string) trim($nfile['subject']);
$ndate = 0 + trim($nfile['date']);
$nposter = (string) trim($nfile['poster']);
$nposter = sqlesc($nposter);
// To find num of segments in subject:
$nsubjsegs = 0 + subj_seg($nsubject);
// To find out if Par or not
$npar = sqlesc(stristr($nsubject, "par2")?0:1);
$nsfv = sqlesc(stristr($nsubject, "sfv")?0:1);
$nnfo = sqlesc(stristr($nsubject, "nfo")?0:1);
$navi= sqlesc(stristr($nsubject, "avi")?0:1);
//$nr = sqlesc(stristr($nsubject, 'r')?0:1000);
$nrar = sqlesc(stristr($nsubject, "rar")?0:1);
$nsubject = sqlesc($nsubject);
$groups = array();
foreach($nfile->groups->group as $group) {
$groups[] = (string) trim($group);
}
$ngroups = sqlesc(serialize($groups));
$nsegcount = 0;
$nsize = 0;
foreach($nfile->segments->segment as $segment) {
$nbytes = 0 + trim($segment['bytes']);
$nsize += $nbytes;
$nsegcount++;
}
$query = mysql_query("UPDATE " . TABLE_PREFIX . "nzbpiecelist SET piece_poster = $nposter, piece_date = $ndate, piece_subject = $nsubject, piece_groups = $ngroups, piece_size = $nsize, piece_segments = $nsegcount, piece_subjseg = $nsubjsegs, piece_par = $npar, piece_sfv = $nsfv, piece_nfo = $nnfo, piece_avi = $navi, piece_rar = $nrar WHERE nzb = $id AND nzb_piece = $nzbpiece");
$nzbpiece++;
}
unset ($filecontent, $nzbpiece, $xml, $nposter, $ndate, $nsubject, $ngroups, $nsize, $nsegcount, $nsubjsegs, $npar, $nsfv, $nnfo, $navi, $nrar);
}
i upload a file and it come up with erros like this
Quote
Warning: simplexml_load_string() [function.simplexml-load-string]: (null)Entity: line 27881: parser error : out of memory
but i have memory_limit = 500M and im running php5.4.4 and also tried on 5.3.13.
can any one help thanks.
Nº du projet : #2318685