fix & optim

autoblogs: broken RSS feed :-> working ATOM feed
index:  index added to sitemap
This commit is contained in:
Mitsukarenai 2013-04-07 13:04:19 +02:00
parent 84469c668d
commit f9e9d0dbbe
3 changed files with 42 additions and 37 deletions

View file

@ -557,36 +557,38 @@ $site_type = escape($config->site_type);
if (isset($_GET['feed'])) // FEED
{
header('Content-Type: application/xhtml+xml; charset=utf-8');
header('Content-Type: application/atom+xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>'.escape($config->site_title).'</title>
<link>'.escape($config->site_url).'</link>
<description>'.escape(html_entity_decode(strip_tags($config->site_description), ENT_COMPAT, 'UTF-8')).'</description>
<language></language>
<copyright></copyright>';
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xml:lang="fr-FR">
<title type="text">'.escape($config->site_title).'</title>
<subtitle type="text">'.escape(html_entity_decode(strip_tags($config->site_description), ENT_COMPAT, 'UTF-8')).'</subtitle>
<updated>'.date(DATE_ATOM, filemtime(ARTICLES_DB_FILE)).'</updated>
<link rel="alternate" type="text/html" href="'.str_replace('?feed./', '', LOCAL_URL).'" />
<id>'.LOCAL_URL.'</id>
<link rel="self" type="application/atom+xml" href="'.LOCAL_URL.'" />
<generator uri="https://github.com/mitsukarenai/Projet-Autoblog" version="3">Projet Autoblog</generator>';
foreach($vvb->listLastArticles() as $art)
{
echo '
<item>
<title>'.escape($art['title']).'</title>
<guid>'.escape($art['feed_id']).'</guid>
<link>'.$vvb->getLocalURL($art).'</link>
<pubDate>'.date(DATE_RSS, $art['date']).'</pubDate>
<description>
<![CDATA['.escape_content($art['content']).']]>
</description>
<content:encoded>
<![CDATA['.escape_content($art['content']).']]>
</content:encoded>
</item>';
<entry>
<author>
<name>'.escape($config->site_title).'</name>
<uri>'.escape($config->site_url).'</uri>
</author>
<title type="html"><![CDATA['.escape($art['title']).']]></title>
<link rel="alternate" type="text/html" href="'.str_replace('?feed', '?', LOCAL_URL).urlencode(str_replace('./?', '', $vvb->getLocalURL($art))).'" />
<id>'.str_replace('?feed', '?', LOCAL_URL).urlencode(str_replace('./?', '', $vvb->getLocalURL($art))).'</id>
<updated>'.date(DATE_ATOM, $art['date']).'</updated>
<content type="html">
<![CDATA[(<a href="'.escape($art['feed_id']).'">source</a>)<br />'.escape_content($art['content']).']]>
</content>
</entry>';
}
echo '
</channel>
</rss>';
</feed>';
exit;
}
@ -713,7 +715,7 @@ echo '
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>'.escape($config->site_title).'</title>
<link rel="canonical" href="'.escape($config->site_url).'">
<link rel="alternate" type="application/rss+xml" title="'.__('RSS Feed').'" href="?feed">
<link rel="alternate" type="application/atom+xml" title="'.__('ATOM Feed').'" href="?feed">
<style type="text/css" media="screen,projection">
'.$css.'
</style>
@ -826,7 +828,7 @@ else
echo '
<div class="footer">
<p>Propulsé par <a href="https://github.com/mitsukarenai/Projet-Autoblog">Projet Autoblog '.$vvbversion.'</a> - <a href="?feed">'.__('RSS Feed').'</a></p>
<p>Propulsé par <a href="https://github.com/mitsukarenai/Projet-Autoblog">Projet Autoblog '.$vvbversion.'</a> - <a href="?feed">'.__('ATOM Feed').'</a></p>
<p>'.__('Download:').' <a href="./'.basename(CONFIG_FILE).'">'.__('configuration').'</a> (<a href="?opml">OPML</a>)
- <a href="./'.basename(ARTICLES_DB_FILE).'">'.__('articles').'</a><p/>
<p><a href="./?media">'.__('Media export').' <sup> JSON</sup></a></p>

View file

@ -178,8 +178,8 @@ function __($str)
return 'Plus anciens';
case 'Newer':
return 'Plus récents';
case 'RSS Feed':
return 'Flux RSS';
case 'ATOM Feed':
return 'Flux ATOM';
case 'Update complete!':
return 'Mise à jour terminée !';
case 'Click here to reload this webpage.':

View file

@ -255,7 +255,7 @@ if (isset($_GET['export'])) {
$subdirs = glob($directory . "*");
foreach($subdirs as $unit) {
if(is_dir($unit) && strpos($unit.'/', DOC_FOLDER) === FALSE) {
if(is_dir($unit)) {
$unit=substr($unit, 2);
$ini = parse_ini_file($unit.'/vvb.ini');
$config = new stdClass;
@ -289,7 +289,7 @@ if (isset($_GET['export_twitter'])) {
$response = array();
foreach($subdirs as $unit) {
if(is_dir($unit) && strpos($unit.'/', DOC_FOLDER) === FALSE) {
if(is_dir($unit)) {
$unit=substr($unit, 2);
$ini = parse_ini_file($unit.'/vvb.ini');
if( $ini['SITE_TYPE'] == 'twitter' ) {
@ -323,7 +323,7 @@ if (isset($_GET['exportopml'])) // OPML
$subdirs = glob($directory . "*");
foreach($subdirs as $unit) {
if(is_dir($unit) && strpos($unit.'/', DOC_FOLDER) === FALSE) {
if(is_dir($unit)) {
$unit=substr($unit, 2);
$ini = parse_ini_file($unit.'/vvb.ini');
$config = new stdClass;
@ -352,6 +352,9 @@ if (isset($_GET['sitemap']))
{
header('Content-Type: application/xml');
echo '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
echo '<url><loc>'.'http' . (!empty($_SERVER['HTTPS']) ? 's' : '')."://{$_SERVER['HTTP_HOST']}".str_replace('?sitemap', '', $_SERVER['REQUEST_URI'])."</loc>\n";
echo '<lastmod>'.date('c', time())."</lastmod>\n";
echo '<changefreq>daily</changefreq></url>';
$directory = "./";
$subdirs = glob($directory . "*");
foreach($subdirs as $unit) {
@ -392,7 +395,7 @@ if( isset($_GET['updateall']) && ALLOW_FULL_UPDATE) {
$directory = "./";
$subdirs = glob($directory . "*");
foreach($subdirs as $unit) {
if(is_dir($unit) && strpos($unit.'/', DOC_FOLDER) === FALSE) {
if(is_dir($unit)) {
if( !file_exists(ROOT_DIR . '/' . $unit . '/.disabled')) {
file_get_contents(serverUrl() . substr($_SERVER['PHP_SELF'], 0, -9) . $unit . '/index.php');
}
@ -403,7 +406,7 @@ if( isset($_GET['updateall']) && ALLOW_FULL_UPDATE) {
$antibot = generate_antibot();
$form = '<form method="POST"><input type="hidden" name="generic" value="1" />
<input placeholder="Adresse du flux RSS/ATOM" type="text" name="rssurl" id="rssurl"><br>
<input placeholder="Antibot : Ecrivez '. $antibot .' en chiffre" type="text" name="number"><br>
<input placeholder="Antibot : Ecrivez '. $antibot .' en chiffre" type="text" name="number" id="number"><br>
<input type="hidden" name="antibot" value="'. $antibot .'" />
<input type="submit" value="Vérifier">
</form>';
@ -586,7 +589,7 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L
<input placeholder="Adresse du site" type="text" name="siteurl" id="siteurl" value="'.$siteurl.'"><label for="siteurl">&larr; page d\'accueil (auto)</label><br>
<input placeholder="Adresse du flux RSS/ATOM" type="text" name="rssurl" id="rssurl" value="'.$rssurl.'"><label for="rssurl">&larr; adresse du flux</label><br>
<input placeholder=""Type de site" type="text" name="sitetype" id="sitetype" value="'.$sitetype.'" '.( $datafeed === false?'':'disabled').'><label for="sitetype">&larr; type de site</label><br>
<input placeholder="Antibot: '. escape($_POST['antibot']) .' en chiffre" type="text" name="number" value="'. escape($_POST['number']) .'"><label for="number">&larr; antibot</label><br>
<input placeholder="Antibot: '. escape($_POST['antibot']) .' en chiffre" type="text" name="number" id="number" value="'. escape($_POST['number']) .'"><label for="number">&larr; antibot</label><br>
<input type="hidden" name="antibot" value="'. escape($_POST['antibot']) .'" /><input type="submit" value="Créer"></form>';
}
@ -775,7 +778,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<input type="radio" name="socialinstance" value="identica">Identica<br>
<input type="radio" name="socialinstance" value="statusnet">
<input placeholder="statusnet.personnel.com" type="text" name="statusneturl" id="statusneturl"><br>
<input placeholder="Antibot : Ecrivez '<?php echo $antibot; ?>' en chiffres" type="text" name="number" class="smallinput"><br>
<input placeholder="Antibot : Ecrivez '<?php echo $antibot; ?>' en chiffres" type="text" name="number" id="number" class="smallinput"><br>
<input type="hidden" name="antibot" value="<?php echo $antibot; ?>" />
<input type="submit" value="Créer">
</form>
@ -787,7 +790,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<form method="POST">
<input type="hidden" name="socialaccount" value="shaarli">
<input placeholder="shaarli.personnel.com" type="text" name="shaarliurl" id="shaarliurl"><br>
<input placeholder="Antibot : Ecrivez '<?php echo $antibot; ?>' en chiffres" type="text" name="number" class="smallinput"><br>
<input placeholder="Antibot : Ecrivez '<?php echo $antibot; ?>' en chiffres" type="text" name="number" id="number" class="smallinput"><br>
<input type="hidden" name="antibot" value="<?php echo $antibot; ?>" />
<input type="submit" value="Créer">
</form>
@ -801,7 +804,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<form enctype='multipart/form-data' method='POST'>
<input type='hidden' name='opml_file' value='1' />
<input type='file' name='file' /><br>
<input placeholder="Antibot : Ecrivez '<?php echo $antibot; ?>' en chiffres" type="text" name="number" class="smallinput"><br>
<input placeholder="Antibot : Ecrivez '<?php echo $antibot; ?>' en chiffres" type="text" name="number" id="number" class="smallinput"><br>
<input type="hidden" name="antibot" value="<?php echo $antibot; ?>" />
<input type='submit' value='Importer' />
</form>
@ -816,7 +819,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<form method="POST">
<input type="hidden" name="opml_link" value="1">
<input placeholder="Lien vers OPML" type="text" name="opml_url" id="opml_url" class="smallinput"><br>
<input placeholder="Antibot : Ecrivez '<?php echo $antibot; ?>' en chiffres" type="text" name="number" class="smallinput"><br>
<input placeholder="Antibot : Ecrivez '<?php echo $antibot; ?>' en chiffres" type="text" name="number" id="number" class="smallinput"><br>
<input type="hidden" name="antibot" value="<?php echo $antibot; ?>" />
<input type="submit" value="Envoyer">
</form>
@ -872,7 +875,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
$autoblogs = array();
foreach($subdirs as $unit)
{
if(is_dir($unit) && strpos($unit.'/', DOC_FOLDER) === FALSE)
if(is_dir($unit))
{
if( !file_exists(ROOT_DIR . '/' . $unit . '/.disabled')) {
$ini = parse_ini_file(ROOT_DIR . '/' . $unit . '/vvb.ini');