Jump to content

PHP issue please help..


dc2007

Recommended Posts

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

 

0but errors out on <?xml version="1.0" encoding="iso-8859-1" ?>

 

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

 

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.

Link to comment
https://forums.phpfreaks.com/topic/264810-php-issue-please-help/
Share on other sites

hi i have looked around that site i cant see any example with LIBXML_PARSEHUGE in it but also it states 

 

Only available in Libxml >= 2.7.0 (as of PHP >= 5.3.2 and PHP >= 5.2.12)

 

im running PHP 5.3.13 and 5.4.4 can you please give me an example of how to implement it into the original code.. thanks

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.