\n\n"); die(); } function _xml_startElement($xp, $element, $attr) { global $blogs,$folder,$inOpmlfolder, $inOpmlItem; if (strcasecmp('outline', $element)) { return; } //$attr['__opml_folder__'] = $folder; if (!array_key_exists('XMLURL',$attr) && (array_key_exists('TEXT',$attr)||array_key_exists('TITLE',$attr)) ) { //some opml use title instead of text to define a folder (ex: newzcrawler) $folder = $attr['TEXT']?$attr['TEXT']:$attr['TITLE']; $inOpmlfolder = true; $inOpmlItem = false; //echo "start of folder $folder\n"; } else { $inOpmlItem = true; //echo "start of item $folder/".$attr['TEXT']."\n"; if ($folder != '') { $blogs[$folder][] = $attr; } else { $blogs[] = $attr; } } } function _xml_endElement($xp, $element) { global $blogs,$folder,$inOpmlfolder, $inOpmlItem; if (strcasecmp( $element, "outline") === 0) { if (!$inOpmlItem && $inOpmlfolder) { //echo "end of folder $folder\n"; // end of folder element! $inOpmlfolder = false; $folder = __('Root'); } else { // end of item element $inOpmlItem = false; //echo "end of item\n"; } } return; } /** OPML Export */ /** OPML2.0 RFC: http://techno-weenie.com/archives/2003/04/01/003067.php */ /** OPML1.0 Specs: http://opml.scripting.com/spec */ // This is a pretty lame opml 1.1 generation routine, in that it is not // recursive, but instead relies on the fact that we only have one level // of folders. // Output should be valid xml. (*fingers crossed*) if (array_key_exists('act',$_REQUEST)) { $rs = rss_query( "select fid,tag from " .getTable('tag') ." t " . "inner join " . getTable('metatag') ." mt on mt.tid=t.id" ." where ttype='channel'"); $cats=array(); while(list($cid,$tag) = rss_fetch_row($rs)) { if (!isset($cats[$cid])) { $cats[$cid]=array(); } $cats[$cid][]=$tag; } $sql = "select c.id, c.title, c.url, c.siteurl, d.name, c.parent, c.descr " ." from ". getTable("channels") . " c " ."inner join " . getTable("folders") ." d on d.id = c.parent"; if (hidePrivate()) { $sql .=" where not(c.mode & " . RSS_MODE_PRIVATE_STATE .") "; } // note: should we export deprecated feeds? if (getConfig('rss.config.absoluteordering')) { $sql .= " order by d.position asc, c.position asc"; } else { $sql .=" order by d.name asc, c.title asc"; } $res = rss_query($sql); $dateRes = rss_query("select max(dateadded) from " . getTable("channels")); list($dateModif) = rss_fetch_row($dateRes); $dateLabel = date("r", strtotime($dateModif)); header("Content-Type: text/xml"); echo "\n" ."\n" ."\n" ."\n"; echo "\t\n" ."\t\t"._TITLE_." OPML Feed\n" ."\t\t$dateLabel\n" ."\t\n" ."\t\n"; $prev_parent=0; while (list($id, $title, $url, $siteurl, $name, $parent, $descr) = rss_fetch_row($res)) { $descr_ = htmlspecialchars ($descr); $descr_ = trim(preg_replace('/(\r\n|\r|\n)/', ' ', $descr_)); $title_ = htmlspecialchars($title); $url_ = preg_replace('|(https?://)([^:]+:[^@]+@)(.+)$|','\1\3',$url); $url_ = htmlspecialchars($url_); $siteurl_ = preg_replace('|(https?://)([^:]+:[^@]+@)(.+)$|','\1\3',$siteurl); $siteurl_ = htmlspecialchars($siteurl_); $name_ = htmlspecialchars($name); if ($parent != $prev_parent) { if ($prev_parent != 0) { echo "\t\t\n"; } $prev_parent = $parent; echo "\t\t\n"; } if ($parent > 0) { echo "\t"; } echo "\t\t\n"; } if ($prev_parent > 0) { echo "\t\n"; } echo "\t\n\n"; } ?>