From 9da3ade3054129ad6709de47663b5f360cd6840f Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 24 Feb 2013 15:44:16 +0100 Subject: [PATCH] Single and full OPML export --- 0.3/autoblog.php | 31 ++++++++++++++++--------------- 0.3/index.php | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 16 deletions(-) diff --git a/0.3/autoblog.php b/0.3/autoblog.php index 58ea9e1..49a5f86 100755 --- a/0.3/autoblog.php +++ b/0.3/autoblog.php @@ -589,24 +589,25 @@ if (isset($_GET['feed'])) // FEED exit; } -/*if (isset($_GET['opml'])) // OPML +if (isset($_GET['opml'])) // OPML { - header('Content-Type: application/octet-stream'); + //header('Content-Type: application/octet-stream'); + header('Content-type: text/xml'); header('Content-Disposition: attachment; filename="'.escape($config->site_title).'.xml"'); -echo ' - - - '.escape($config->site_title).'.xml - '.date('r', time()).' - - - - - - -'; + $opmlfile = new SimpleXMLElement(''); + $opmlfile->addAttribute('version', '1.0'); + $opmlhead = $opmlfile->addChild('head'); + $opmlhead->addChild('title', escape($config->site_title)); + $opmlhead->addChild('dateCreated', date('r', time())); + $opmlbody = $opmlfile->addChild('body'); + $outline = $opmlbody->addChild('outline'); + $outline->addAttribute('title', escape($config->site_title)); + $outline->addAttribute('htmlUrl', escape($config->site_url)); + $outline->addAttribute('xmlUrl', escape($config->feed_url)); + + echo $opmlfile->asXML(); exit; -}*/ +} if (isset($_GET['media'])) // MEDIA { diff --git a/0.3/index.php b/0.3/index.php index be68090..ff6dbeb 100755 --- a/0.3/index.php +++ b/0.3/index.php @@ -164,6 +164,47 @@ if (isset($_GET['export'])) { die; } +/** + * OPML Full Export + **/ +if (isset($_GET['exportopml'])) // OPML +{ + //header('Content-Type: application/octet-stream'); + header('Content-type: text/xml'); + header('Content-Disposition: attachment; filename="autoblogs-'. $_SERVER['SERVER_NAME'] .'.xml"'); + + $opmlfile = new SimpleXMLElement(''); + $opmlfile->addAttribute('version', '1.0'); + $opmlhead = $opmlfile->addChild('head'); + $opmlhead->addChild('title', 'Autoblog OPML export from '. $_SERVER['SERVER_NAME'] ); + $opmlhead->addChild('dateCreated', date('r', time())); + $opmlbody = $opmlfile->addChild('body'); + + $directory = "./"; + $subdirs = glob($directory . "*"); + + foreach($subdirs as $unit) { + if(is_dir($unit)) { + $unit=substr($unit, 2); + $ini = parse_ini_file($unit.'/vvb.ini'); + $config = new stdClass; + + foreach ($ini as $key=>$value) { + $key = strtolower($key); + $config->$key = $value; + } + unset($ini); + + $outline = $opmlbody->addChild('outline'); + $outline->addAttribute('title', escape($config->site_title)); + $outline->addAttribute('htmlUrl', escape($config->site_url)); + $outline->addAttribute('xmlUrl', escape($config->feed_url)); + } + } + echo $opmlfile->asXML(); + exit; +} + /** * Site map **/ @@ -537,7 +578,7 @@ if( !empty($_POST['opml']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML → Rechercher

-
sitemap | export JSON
+
sitemap | export JSON | export OPML