Single and full OPML export

This commit is contained in:
ArthurHoaro 2013-02-24 15:44:16 +01:00
parent 2ac5d3e65a
commit 9da3ade305
2 changed files with 58 additions and 16 deletions

View file

@ -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 '<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>'.escape($config->site_title).'.xml</title>
<dateCreated>'.date('r', time()).'</dateCreated>
</head>
<body>
<outline htmlUrl="'.escape($config->site_url).'"/>
<outline xmlUrl="'.escape($config->feed_url).'"/>
<outline title="'.escape($config->site_title).'"/>
</body>
</opml>';
$opmlfile = new SimpleXMLElement('<opml></opml>');
$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
{

View file

@ -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('<opml></opml>');
$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
&rarr; <a href="https://duckduckgo.com/?q=!g%20%22Voici%20une%20liste%20d'autoblogs%20hébergés%22">Rechercher</a>
</p>
<div class="clear"><a href="?sitemap">sitemap</a> | <a href="?export">export<sup> JSON</sup></a></div>
<div class="clear"><a href="?sitemap">sitemap</a> | <a href="?export">export<sup> JSON</sup></a> | <a href="?exportopml">export<sup> OPML</sup></a></div>
<?php
$directory = "./";