Compare commits

...

9 commits

Author SHA1 Message Date
af79fc3d18 Fix bad merge 2014-04-11 17:28:35 +02:00
897f3db53c Merge branch 'master' into myAutoBlog
Conflicts:
	autoblogs/autoblog.php
	config.php.example
	functions.php
	index.php
	xsaf3.php
2014-04-11 17:00:48 +02:00
3e3861ee87 Merge branch 'master' into myAutoBlog
Conflicts:
	.gitignore
	docs/docs.txt
	functions.php
	index.php
	xsaf3.php
2013-04-30 12:04:03 +02:00
08f163f609 Merge branch 'master' into myAutoBlog
Conflicts:
	0.3/config.php
	0.3/functions.php
2013-04-12 17:02:04 +02:00
cd936fdf9c [add] Ajout de la description du site (balise meta description) 2013-04-09 15:50:00 +02:00
d9b23add41 Merge branch 'master' into myAutoBlog
Conflicts:
	0.3/index.php
2013-04-08 16:16:16 +02:00
8ac6108585 Merge branch 'master' into myAutoBlog 2013-04-08 15:29:10 +02:00
253a7690ef [add] option for use thumbshot 2013-04-08 15:25:21 +02:00
101922a5c3 [add] user.css 2013-04-08 14:42:37 +02:00
5 changed files with 510 additions and 457 deletions

View file

@ -1,14 +1,14 @@
<?php <?php
/* /*
VroumVroumBlog 0.3.0 VroumVroumBlog 0.3.0
This blog automatically publishes articles from an external RSS 2.0 or ATOM feed. This blog automatically publishes articles from an external RSS 2.0 or ATOM feed.
Requirement for the source RSS feed: Requirement for the source RSS feed:
- Source feed MUST be a valid RSS 2.0, RDF 1.0 or ATOM 1.0 feed. - Source feed MUST be a valid RSS 2.0, RDF 1.0 or ATOM 1.0 feed.
- Source feed MUST be valid UTF-8 - Source feed MUST be valid UTF-8
- Source feed MUST contain article body - Source feed MUST contain article body
This program is public domain. COPY COPY COPY! This program is public domain. COPY COPY COPY!
*/ */
$vvbversion = '0.3.0'; $vvbversion = '0.3.0';
if (!version_compare(phpversion(), '5.3.0', '>=')) if (!version_compare(phpversion(), '5.3.0', '>='))
@ -34,9 +34,9 @@ else die("Functions file not found.");
if (!defined('ROOT_DIR')) if (!defined('ROOT_DIR'))
define('ROOT_DIR', __DIR__); define('ROOT_DIR', __DIR__);
if (!defined('CONFIG_FILE')) define('CONFIG_FILE', ROOT_DIR . '/vvb.ini'); if (!defined('CONFIG_FILE')) define('CONFIG_FILE', ROOT_DIR . '/vvb.ini');
if (!defined('ARTICLES_DB_FILE')) define('ARTICLES_DB_FILE', ROOT_DIR . '/articles.db'); if (!defined('ARTICLES_DB_FILE')) define('ARTICLES_DB_FILE', ROOT_DIR . '/articles.db');
if (!defined('MEDIA_DIR')) define('MEDIA_DIR', ROOT_DIR . '/media'); if (!defined('MEDIA_DIR')) define('MEDIA_DIR', ROOT_DIR . '/media');
if (!defined('LOCAL_URL')) if (!defined('LOCAL_URL'))
{ {
@ -74,7 +74,7 @@ class VroumVroum_Feed_Exception extends Exception
foreach ($errors as $error) foreach ($errors as $error)
{ {
$return = $xml[$error->line - 1] . "\n"; $return = $xml[$error->line - 1] . "\n";
$return .= str_repeat('-', $error->column) . "^\n"; $return .= str_repeat('-', $error->column) . "^\n";
switch ($error->level) { switch ($error->level) {
@ -90,11 +90,11 @@ class VroumVroum_Feed_Exception extends Exception
} }
$return .= trim($error->message) . $return .= trim($error->message) .
"\n Line: ".$error->line . "\n Line: ".$error->line .
"\n Column: ".$error->column; "\n Column: ".$error->column;
if ($error->file) { if ($error->file) {
$return .= "\n File: ".$error->file; $return .= "\n File: ".$error->file;
} }
$out[] = $return; $out[] = $return;
@ -226,23 +226,23 @@ class VroumVroum_Blog
if ($create_articles_db) if ($create_articles_db)
{ {
$this->articles->exec(' $this->articles->exec('
CREATE TABLE articles ( CREATE TABLE articles (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
feed_id TEXT, feed_id TEXT,
title TEXT, title TEXT,
uri TEXT, uri TEXT,
url TEXT, url TEXT,
date INT, date INT,
content TEXT content TEXT
); );
CREATE TABLE update_log ( CREATE TABLE update_log (
date INT PRIMARY KEY, date INT PRIMARY KEY,
success INT, success INT,
log TEXT log TEXT
); );
CREATE UNIQUE INDEX feed_id ON articles (feed_id); CREATE UNIQUE INDEX feed_id ON articles (feed_id);
CREATE INDEX date ON articles (date); CREATE INDEX date ON articles (date);
'); ');
} }
$this->articles->createFunction('countintegers', array($this, 'sql_countintegers')); $this->articles->createFunction('countintegers', array($this, 'sql_countintegers'));
@ -256,7 +256,7 @@ class VroumVroum_Blog
protected function log_update($success, $log = '') protected function log_update($success, $log = '')
{ {
$this->articles->exec('INSERT INTO update_log (date, success, log) VALUES (\''.time().'\', \''.(int)(bool)$success.'\', $this->articles->exec('INSERT INTO update_log (date, success, log) VALUES (\''.time().'\', \''.(int)(bool)$success.'\',
\''.$this->articles->escapeString($log).'\');'); \''.$this->articles->escapeString($log).'\');');
// Delete old log // Delete old log
$this->articles->exec('DELETE FROM update_log WHERE date > (SELECT date FROM update_log ORDER BY date DESC LIMIT 100,1);'); $this->articles->exec('DELETE FROM update_log WHERE date > (SELECT date FROM update_log ORDER BY date DESC LIMIT 100,1);');
@ -280,9 +280,9 @@ class VroumVroum_Blog
$content = $this->mirrorMediasForArticle($content, $url); $content = $this->mirrorMediasForArticle($content, $url);
$this->articles->exec('INSERT INTO articles (id, feed_id, title, uri, url, date, content) VALUES (NULL, $this->articles->exec('INSERT INTO articles (id, feed_id, title, uri, url, date, content) VALUES (NULL,
\''.$this->articles->escapeString($feed_id).'\', \''.$this->articles->escapeString($title).'\', \''.$this->articles->escapeString($feed_id).'\', \''.$this->articles->escapeString($title).'\',
\''.$this->articles->escapeString($uri).'\', \''.$this->articles->escapeString($url).'\', \''.$this->articles->escapeString($uri).'\', \''.$this->articles->escapeString($url).'\',
\''.(int)$date.'\', \''.$this->articles->escapeString($content).'\');'); \''.(int)$date.'\', \''.$this->articles->escapeString($content).'\');');
$id = $this->articles->lastInsertRowId(); $id = $this->articles->lastInsertRowId();
@ -304,8 +304,8 @@ class VroumVroum_Blog
$content = $this->mirrorMediasForArticle($content, $url); $content = $this->mirrorMediasForArticle($content, $url);
$this->articles->exec('UPDATE articles SET title=\''.$this->articles->escapeString($title).'\', $this->articles->exec('UPDATE articles SET title=\''.$this->articles->escapeString($title).'\',
url=\''.$this->articles->escapeString($url).'\', content=\''.$this->articles->escapeString($content).'\', url=\''.$this->articles->escapeString($url).'\', content=\''.$this->articles->escapeString($content).'\',
date=\''.(int)$date.'\' WHERE id = \''.(int)$id.'\';'); date=\''.(int)$date.'\' WHERE id = \''.(int)$id.'\';');
$title = self::removeHTML($title); $title = self::removeHTML($title);
$content = self::removeHTML($content); $content = self::removeHTML($content);
@ -327,9 +327,9 @@ class VroumVroum_Blog
return true; return true;
} }
public function mustUpdateXsaf() public function mustUpdateXsaf()
{ {
return file_exists('import.json'); return file_exists('import.json');
} }
@ -337,10 +337,10 @@ class VroumVroum_Blog
{ {
return stream_context_create( return stream_context_create(
array( array(
'http' => array( 'http' => array(
'method' => 'GET', 'method' => 'GET',
'timeout' => $this->config->update_timeout, 'timeout' => $this->config->update_timeout,
'header' => "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:20.0; Autoblogs; +https://github.com/mitsukarenai/Projet-Autoblog/) Gecko/20100101 Firefox/20.0\r\n", 'header' => "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:20.0; Autoblogs; +https://github.com/mitsukarenai/Projet-Autoblog/) Gecko/20100101 Firefox/20.0\r\n",
) )
) )
); );
@ -379,10 +379,10 @@ class VroumVroum_Blog
{ {
$date = isset($item->published) ? (string) $item->published : (string) $item->updated; $date = isset($item->published) ? (string) $item->published : (string) $item->updated;
$guid = !empty($item->id) ? (string)$item->id : (string)$item->link['href']; $guid = !empty($item->id) ? (string)$item->id : (string)$item->link['href'];
if( count($item->content->children()) > 0 ) $content = (string)$item->content->asXML(); if( count($item->content->children()) > 0 ) $content = (string)$item->content->asXML();
else $content = (string)$item->content; else $content = (string)$item->content;
$id = $this->insertOrUpdateArticle($guid, (string)$item->title, $id = $this->insertOrUpdateArticle($guid, (string)$item->title,
(string)$item->link['href'], strtotime($date), $content ); (string)$item->link['href'], strtotime($date), $content );
@ -432,33 +432,33 @@ class VroumVroum_Blog
return $updated; return $updated;
} }
public function updateXsaf() { public function updateXsaf() {
if($this->mustUpdateXsaf()) { if($this->mustUpdateXsaf()) {
$json = json_decode(file_get_contents('import.json'), true); $json = json_decode(file_get_contents('import.json'), true);
$count = count($json['files']); $count = count($json['files']);
file_put_contents('import.lock', $count); /* one-process locking */ file_put_contents('import.lock', $count); /* one-process locking */
$remoteurl = $json['url']; $remoteurl = $json['url'];
if (!file_exists('media')) { if (!file_exists('media')) {
mkdir('media'); mkdir('media');
} }
$time = time(); $time = time();
$maxtime = $time + 3; /* max exec time: 3 seconds */ $maxtime = $time + 3; /* max exec time: 3 seconds */
while ($time <= $maxtime) { while ($time <= $maxtime) {
$file = array_shift($json['files']); /* get first element while unstacking */ $file = array_shift($json['files']); /* get first element while unstacking */
if(!empty($file)) { if(!empty($file)) {
$this->_copy($remoteurl.$file, "media/$file"); $this->_copy($remoteurl.$file, "media/$file");
file_put_contents('import.json', json_encode($json)); file_put_contents('import.json', json_encode($json));
} }
else { else {
unlink('import.json'); unlink('import.json');
break; break;
} /* first element empty: import finished */ } /* first element empty: import finished */
$time = time(); $time = time();
} }
unlink('import.lock'); unlink('import.lock');
} }
} }
public function listArticlesByPage($page = 1) public function listArticlesByPage($page = 1)
@ -500,11 +500,11 @@ class VroumVroum_Blog
public function searchArticles($query) public function searchArticles($query)
{ {
$res = $this->articles->query('SELECT id, uri, title, content $res = $this->articles->query('SELECT id, uri, title, content
FROM articles FROM articles
WHERE content LIKE \'%'.$this->articles->escapeString($query).'%\' WHERE content LIKE \'%'.$this->articles->escapeString($query).'%\'
OR title LIKE \'%'.$this->articles->escapeString($query).'%\' OR title LIKE \'%'.$this->articles->escapeString($query).'%\'
ORDER BY id DESC ORDER BY id DESC
LIMIT 0,100;'); LIMIT 0,100;');
$out = array(); $out = array();
@ -525,7 +525,7 @@ class VroumVroum_Blog
} }
$schemes = array('http', 'https'); $schemes = array('http', 'https');
$extensions = explode(',', preg_quote('jpg,jpeg,png,apng,gif,svg,pdf,odt,ods,epub,webp,wav,mp3,ogg,aac,wma,flac,opus,mp4,webm', '!')); $extensions = explode(',', preg_quote('jpg,jpeg,png,apng,gif,svg,pdf,odt,ods,epub,webp,wav,mp3,ogg,aac,wma,flac,opus,mp4,webm', '!'));
$extensions = implode('|', $extensions); $extensions = implode('|', $extensions);
$from = parse_url($url); $from = parse_url($url);
@ -573,7 +573,7 @@ class VroumVroum_Blog
} }
return $content; return $content;
} }
public function getXsafCounter() { public function getXsafCounter() {
if($this->mustUpdateXsaf()) { if($this->mustUpdateXsaf()) {
$json = json_decode(file_get_contents('import.json'), true); $json = json_decode(file_get_contents('import.json'), true);
@ -603,36 +603,36 @@ if (isset($_GET['feed'])) // FEED
{ {
header('Content-Type: application/atom+xml; charset=UTF-8'); header('Content-Type: application/atom+xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8"?> echo '<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xml:lang="fr-FR"> <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> <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> <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> <updated>'.date(DATE_ATOM, filemtime(ARTICLES_DB_FILE)).'</updated>
<link rel="alternate" type="text/html" href="'.str_replace('?feed./', '', LOCAL_URL).'" /> <link rel="alternate" type="text/html" href="'.str_replace('?feed./', '', LOCAL_URL).'" />
<id>'.LOCAL_URL.'</id> <id>'.LOCAL_URL.'</id>
<link rel="self" type="application/atom+xml" href="'.LOCAL_URL.'" /> <link rel="self" type="application/atom+xml" href="'.LOCAL_URL.'" />
<generator uri="https://github.com/mitsukarenai/Projet-Autoblog" version="3">Projet Autoblog</generator>'; <generator uri="https://github.com/mitsukarenai/Projet-Autoblog" version="3">Projet Autoblog</generator>';
foreach($vvb->listLastArticles() as $art) foreach($vvb->listLastArticles() as $art)
{ {
echo ' echo '
<entry> <entry>
<author> <author>
<name>'.escape($config->site_title).'</name> <name>'.escape($config->site_title).'</name>
<uri>'.escape($config->site_url).'</uri> <uri>'.escape($config->site_url).'</uri>
</author> </author>
<title type="html"><![CDATA['.escape($art['title']).']]></title> <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))).'" /> <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> <id>'.str_replace('?feed', '?', LOCAL_URL).urlencode(str_replace('./?', '', $vvb->getLocalURL($art))).'</id>
<updated>'.date(DATE_ATOM, $art['date']).'</updated> <updated>'.date(DATE_ATOM, $art['date']).'</updated>
<content type="html"> <content type="html">
<![CDATA[(<a href="'.escape($art['url']).'">source</a>)<br />'.escape_content($art['content']).']]> <![CDATA[(<a href="'.escape($art['url']).'">source</a>)<br />'.escape_content($art['content']).']]>
</content> </content>
</entry>'; </entry>';
} }
echo ' echo '
</feed>'; </feed>';
exit; exit;
} }
@ -640,7 +640,7 @@ if (isset($_GET['opml'])) // OPML
{ {
//header('Content-Type: application/octet-stream'); //header('Content-Type: application/octet-stream');
header('Content-type: text/xml'); header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="'.escape($config->site_title).'.xml"'); header('Content-Disposition: attachment; filename="'.escape($config->site_title).'.xml"');
$opmlfile = new SimpleXMLElement('<opml></opml>'); $opmlfile = new SimpleXMLElement('<opml></opml>');
$opmlfile->addAttribute('version', '1.0'); $opmlfile->addAttribute('version', '1.0');
$opmlhead = $opmlfile->addChild('head'); $opmlhead = $opmlfile->addChild('head');
@ -662,7 +662,7 @@ if (isset($_GET['media'])) // MEDIA
header('Content-Type: application/json'); header('Content-Type: application/json');
if(is_dir(MEDIA_DIR)) if(is_dir(MEDIA_DIR))
{ {
$url = str_replace('?media', 'media/', LOCAL_URL); $url = str_replace('?media', 'media/', LOCAL_URL);
$files = scandir(MEDIA_DIR); $files = scandir(MEDIA_DIR);
unset($files[0]); // . unset($files[0]); // .
unset($files[1]); // .. unset($files[1]); // ..
@ -691,127 +691,127 @@ if (!$search && !empty($_SERVER['QUERY_STRING']) && !is_numeric($_SERVER['QUERY_
} }
} }
// common CSS // common CSS
$css='* { margin: 0; padding: 0; } $css='* { margin: 0; padding: 0; }
body { font-family:sans-serif; background-color: #efefef; padding: 1%; color: #333; } body { font-family:sans-serif; background-color: #efefef; padding: 1%; color: #333; }
img { max-width: 100%; height: auto; } img { max-width: 100%; height: auto; }
a { text-decoration: none; color: #000;font-weight:bold; } a { text-decoration: none; color: #000;font-weight:bold; }
body > header a { text-decoration: none; color: #000;font-weight:bold; } body > header a { text-decoration: none; color: #000;font-weight:bold; }
body > header { text-align:center; padding: 30px 3%; max-width:70em;margin:0 auto; } body > header { text-align:center; padding: 30px 3%; max-width:70em;margin:0 auto; }
body > article > header { margin-bottom: 1em; } body > article > header { margin-bottom: 1em; }
body > article > header h2 a:hover { color:#403976; } body > article > header h2 a:hover { color:#403976; }
body > article h4 { font-weight: normal; font-size: small; color: #666; } body > article h4 { font-weight: normal; font-size: small; color: #666; }
body > article .source a { color: #666; } body > article .source a { color: #666; }
body > header > form { float:right; } body > header > form { float:right; }
body > header > form input { } body > header > form input { }
body > nav { background-color:white;padding: 12px 10px 12px 10px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; } body > nav { background-color:white;padding: 12px 10px 12px 10px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; }
body > nav strong { font-size: 1.2em; color: #333; } body > nav strong { font-size: 1.2em; color: #333; }
body > nav a { color:#000; margin: 0 0.5em; } body > nav a { color:#000; margin: 0 0.5em; }
body > nav a:hover { color:#333; } body > nav a:hover { color:#333; }
body > footer a { color:#000; } body > footer a { color:#000; }
body > footer a:hover { color:#333; } body > footer a:hover { color:#333; }
.content ul, .content ol { margin-left: 2em; } .content ul, .content ol { margin-left: 2em; }
.content h1, .content h2, .content h3, .content h4, .content h5, .content h6, .content h1, .content h2, .content h3, .content h4, .content h5, .content h6,
.content ul, .content ol, .content p, .content object, .content div, .content blockquote, .content ul, .content ol, .content p, .content object, .content div, .content blockquote,
.content dl, .content pre { margin-bottom: 0.8em; } .content dl, .content pre { margin-bottom: 0.8em; }
.content pre, .content blockquote { background: #ddd; border: 1px solid #999; padding: 0.2em; max-width: 100%; overflow: auto; } .content pre, .content blockquote { background: #ddd; border: 1px solid #999; padding: 0.2em; max-width: 100%; overflow: auto; }
.content h1 { font-size: 1.5em; } .content h1 { font-size: 1.5em; }
.content h2 { font-size: 1.4em;color:#000; } .content h2 { font-size: 1.4em;color:#000; }
.result h3 a { color: darkblue; text-decoration: none; text-shadow: 1px 1px 1px #fff; } .result h3 a { color: darkblue; text-decoration: none; text-shadow: 1px 1px 1px #fff; }
#error { position: fixed; top: 0; left: 0; right: 0; padding: 1%; background: #fff; border-bottom: 2px solid red; color: darkred; } #error { position: fixed; top: 0; left: 0; right: 0; padding: 1%; background: #fff; border-bottom: 2px solid red; color: darkred; }
'; ';
switch($site_type) { switch($site_type) {
case 'microblog': case 'microblog':
case 'twitter': case 'twitter':
$css .= "\n".' /* twitter/microblog style */ $css .= "\n".' /* twitter/microblog style */
body > header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px; } body > header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px; }
body > article > header h2 { width: 10em;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;font-size: 0.7em;margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; } body > article > header h2 { width: 10em;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;font-size: 0.7em;margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; }
body > article > header h2 a { color:#333; text-decoration:none; } body > article > header h2 a { color:#333; text-decoration:none; }
body > article { background-color:white;padding: 12px 10px 33px;border:1px solid #aaa;max-width:70em;margin:0 auto;box-shadow:0px 5px 7px #aaa; } body > article { background-color:white;padding: 12px 10px 33px;border:1px solid #aaa;max-width:70em;margin:0 auto;box-shadow:0px 5px 7px #aaa; }
body > article .source { font-size: 0.8em; color: #666; } body > article .source { font-size: 0.8em; color: #666; }
body > footer { margin-top:1em;text-align:center; font-size: small; color:#333; clear: both; } body > footer { margin-top:1em;text-align:center; font-size: small; color:#333; clear: both; }
.content {font-size:0.9em;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}'; .content {font-size:0.9em;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}';
break; break;
case 'shaarli': case 'shaarli':
$css .= "\n".' /* shaarli style */ $css .= "\n".' /* shaarli style */
body > header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px; } body > header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px; }
body > article > header title h2 { margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; } body > article > header title h2 { margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; }
body > article > header h2 a { color:#000; text-decoration:none; } body > article > header h2 a { color:#000; text-decoration:none; }
body > article { background-color:white;padding: 12px 10px 33px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; } body > article { background-color:white;padding: 12px 10px 33px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; }
body > article footer.source { margin-top:1em;font-size: 0.8em; color: #666; } body > article footer.source { margin-top:1em;font-size: 0.8em; color: #666; }
body > footer { text-align:center; font-size: small; color:#333; clear: both; }'; body > footer { text-align:center; font-size: small; color:#333; clear: both; }';
break; break;
case 'generic': case 'generic':
case 'youtube': case 'youtube':
default: default:
$css .= "\n".' /* youtube style */ $css .= "\n".' /* youtube style */
body > header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px;text-transform:uppercase; } body > header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px;text-transform:uppercase; }
body > article > header h2 { margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; } body > article > header h2 { margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; }
body > article > header h2 a { color:#000; text-decoration:none; } body > article > header h2 a { color:#000; text-decoration:none; }
body > article footer.source { font-size: 0.8em; color: #666; } body > article footer.source { font-size: 0.8em; color: #666; }
body > article { background-color:white;padding: 12px 10px 33px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; } body > article { background-color:white;padding: 12px 10px 33px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; }
body > footer { text-align:center; font-size: small; color:#333; clear: both; }'; body > footer { text-align:center; font-size: small; color:#333; clear: both; }';
} }
// HTML HEADER // HTML HEADER
echo '<!DOCTYPE html> echo '<!DOCTYPE html>
<html lang="fr" dir="ltr"> <html lang="fr" dir="ltr">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="utf-8" />
<title>'.escape($config->site_title).'</title> <title>'.escape($config->site_title).'</title>
<link rel="canonical" href="'.escape($config->site_url).'"> <link rel="canonical" href="'.escape($config->site_url).'">
<link rel="alternate" type="application/atom+xml" title="'.__('ATOM Feed').'" href="?feed"> <link rel="alternate" type="application/atom+xml" title="'.__('ATOM Feed').'" href="?feed">
<style type="text/css" media="screen,projection"> <style type="text/css" media="screen,projection">
'.$css.' '.$css.'
</style>'; </style>';
if( $vvb->mustUpdateXsaf()) { if( $vvb->mustUpdateXsaf()) {
echo ' <meta http-equiv="Refresh" content="1">'; echo ' <meta http-equiv="Refresh" content="1">';
} }
echo ' echo '
</head> </head>
<body> <body>
<header> <header>
<h1><a href="../../" style="font-size:0.8em;">PROJET AUTOBLOG'. (strlen(HEAD_TITLE) > 0 ? ' ~ '. HEAD_TITLE : '') .'</a></h1> <h1><a href="../../" style="font-size:0.8em;">PROJET AUTOBLOG'. (strlen(HEAD_TITLE) > 0 ? ' ~ '. HEAD_TITLE : '') .'</a></h1>
<hr /> <hr />
<h1><a href="./">'.escape($config->site_title).'</a></h1>'; <h1><a href="./">'.escape($config->site_title).'</a></h1>';
if (!empty($config->site_description)) if (!empty($config->site_description))
echo ' echo '
<p>'.$config->site_description.'</p> <p>'.$config->site_description.'</p>
<p><a href="../../">&lArr; retour index</a></p>'; <p><a href="../../">&lArr; retour index</a></p>';
echo ' echo '
<form method="get" action="'.escape(LOCAL_URL).'"> <form method="get" action="'.escape(LOCAL_URL).'">
<input type="search" name="q" value="'.escape($search).'" /> <input type="search" name="q" value="'.escape($search).'" />
<input type="submit" value="'.__('Search').'" /> <input type="submit" value="'.__('Search').'" />
</form> </form>
</header> </header>
'; ';
if( $vvb->mustUpdateXsaf()) { if( $vvb->mustUpdateXsaf()) {
echo ' echo '
<article> <article>
<header> <header>
<h2>'.__('Update').'</h2> <h2>'.__('Update').'</h2>
</header> </header>
<div class="content" id="update"> <div class="content" id="update">
'.__('Import running: '). $vvb->getXsafCounter() . __(' files remaining').'<br> '.__('Import running: '). $vvb->getXsafCounter() . __(' files remaining').'<br>
'.__('The page should refresh every second. If not, <a href="javascript:window.location.reload()">refresh manually</a>.').' '.__('The page should refresh every second. If not, <a href="javascript:window.location.reload()">refresh manually</a>.').'
</div> </div>
</article>'; </article>';
} }
elseif ($vvb->mustUpdate()) elseif ($vvb->mustUpdate())
{ {
echo ' echo '
<article> <article>
<header> <header>
<h2>'.__('Update').'</h2> <h2>'.__('Update').'</h2>
</header> </header>
<div class="content" id="update"> <div class="content" id="update">
'.__('Updating database... Please wait.').' '.__('Updating database... Please wait.').'
</div> </div>
</article>'; </article>';
} }
if (!empty($search)) if (!empty($search))
@ -819,22 +819,22 @@ if (!empty($search))
$results = $vvb->searchArticles($search); $results = $vvb->searchArticles($search);
$text = sprintf(__('<strong>%d</strong> results for <em>%s</em>'), count($results), escape($search)); $text = sprintf(__('<strong>%d</strong> results for <em>%s</em>'), count($results), escape($search));
echo ' echo '
<article id="results"> <article id="results">
<header> <header>
<h2>'.__('Search').'</h2> <h2>'.__('Search').'</h2>
'.$text.' '.$text.'
</header> </header>
<article>'; <article>';
foreach ($results as $art) foreach ($results as $art)
{ {
echo ' echo '
<article class="result"> <article class="result">
<header> <header>
<h3><a href="./?'.escape($art['uri']).'">'.escape($art['title']).'</a></h3> <h3><a href="./?'.escape($art['uri']).'">'.escape($art['title']).'</a></h3>
</header> </header>
<p>'.$art['content'].'</p> <p>'.$art['content'].'</p>
</article>'; </article>';
} }
} }
elseif (!is_null($article)) elseif (!is_null($article))
@ -842,13 +842,13 @@ elseif (!is_null($article))
if (!$article) if (!$article)
{ {
echo ' echo '
<article> <article>
<header> <header>
<h2>'.__('Not Found').'</h2> <h2>'.__('Not Found').'</h2>
'.(!empty($uri) ? '<p><tt>'.escape($vvb->getLocalURL($uri)) . '</tt></p>' : '').' '.(!empty($uri) ? '<p><tt>'.escape($vvb->getLocalURL($uri)) . '</tt></p>' : '').'
'.__('Article not found.').' '.__('Article not found.').'
</header> </header>
</article>'; </article>';
} }
else else
{ {
@ -871,29 +871,29 @@ else
$max = $vvb->countArticles(); $max = $vvb->countArticles();
if ($max > $config->articles_per_page) { if ($max > $config->articles_per_page) {
echo "\n".' <nav>'."\n"; echo "\n".' <nav>'."\n";
if ($page > 1) if ($page > 1)
echo ' <a rel="prev" href="'.$vvb->getLocalURL($page - 1).'">&larr; '.__('Newer').'</a>'."\n"; echo ' <a rel="prev" href="'.$vvb->getLocalURL($page - 1).'">&larr; '.__('Newer').'</a>'."\n";
$last = ceil($max / $config->articles_per_page); $last = ceil($max / $config->articles_per_page);
for ($i = 1; $i <= $last; $i++) { for ($i = 1; $i <= $last; $i++) {
echo ' '.($i == $page ? '<strong>'.$i.'</strong>' : '<a href="'.$vvb->getLocalURL($i).'">'.$i.'</a>')."\n"; echo ' '.($i == $page ? '<strong>'.$i.'</strong>' : '<a href="'.$vvb->getLocalURL($i).'">'.$i.'</a>')."\n";
} }
if ($page < $last) if ($page < $last)
echo ' <a rel="next" href="'.$vvb->getLocalURL($page + 1).'">'.__('Older').' &rarr;</a>'."\n"; echo ' <a rel="next" href="'.$vvb->getLocalURL($page + 1).'">'.__('Older').' &rarr;</a>'."\n";
echo ' </nav>'; echo ' </nav>';
} }
} }
echo ' echo '
<footer> <footer>
<p>Propulsé par <a href="https://github.com/mitsukarenai/Projet-Autoblog">Projet Autoblog '.$vvbversion.'</a> - <a href="?feed">'.__('ATOM 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>) <p>'.__('Download:').' <a href="./'.basename(CONFIG_FILE).'">'.__('configuration').'</a> (<a href="?opml">OPML</a>)
<a href="./'.basename(ARTICLES_DB_FILE).'">'.__('articles').'</a></p> <a href="./'.basename(ARTICLES_DB_FILE).'">'.__('articles').'</a></p>
<p><a href="./?media">'.__('Media export').' <sup> JSON</sup></a></p> <p><a href="./?media">'.__('Media export').' <sup> JSON</sup></a></p>
</footer>'; </footer>';
if( $vvb->mustUpdateXsaf() ) { if( $vvb->mustUpdateXsaf() ) {
try { try {
@ -911,9 +911,9 @@ if( $vvb->mustUpdateXsaf() ) {
catch (VroumVroum_Feed_Exception $e) catch (VroumVroum_Feed_Exception $e)
{ {
echo ' echo '
<div id="error"> <div id="error">
'.escape($e->getMessage()).' '.escape($e->getMessage()).'
</div>'; </div>';
$updated = 0; $updated = 0;
} }
} }
@ -934,34 +934,34 @@ elseif ($vvb->mustUpdate())
catch (VroumVroum_Feed_Exception $e) catch (VroumVroum_Feed_Exception $e)
{ {
echo ' echo '
<div id="error"> <div id="error">
'.escape($e->getMessage()).' '.escape($e->getMessage()).'
</div>'; </div>';
$updated = 0; $updated = 0;
} }
if ($updated > 0) if ($updated > 0)
{ {
echo ' echo '
<script type="text/javascript"> <script type="text/javascript">
window.onload = function () { window.onload = function () {
document.getElementById("update").innerHTML = "'.__('Update complete!').' <a href=\\"#reload\\" onclick=\\"window.location.reload();\\">'.__('Click here to reload this webpage.').'</a>"; document.getElementById("update").innerHTML = "'.__('Update complete!').' <a href=\\"#reload\\" onclick=\\"window.location.reload();\\">'.__('Click here to reload this webpage.').'</a>";
}; };
</script>'; </script>';
} }
else else
{ {
echo ' echo '
<script type="text/javascript"> <script type="text/javascript">
window.onload = function () { window.onload = function () {
document.body.removeChild(document.getElementById("update").parentNode); document.body.removeChild(document.getElementById("update").parentNode);
}; };
</script>'; </script>';
} }
} }
echo ' echo '
</body> </body>
</html>'; </html>';
@ -977,14 +977,14 @@ function display_article($article)
{ {
global $vvb, $config; global $vvb, $config;
echo ' echo '
<article> <article>
<header> <header>
<h2><a href="'.$vvb->getLocalURL($article).'">'.escape($article['title']).'</a></h2> <h2><a href="'.$vvb->getLocalURL($article).'">'.escape($article['title']).'</a></h2>
'.strftime(__('_date_format'), $article['date']).' '.strftime(__('_date_format'), $article['date']).'
</header> </header>
<div class="content">'.escape_content($article['content']).'</div> <div class="content">'.escape_content($article['content']).'</div>
<footer class="source"><p>'.__('Source:').' <a href="'.escape($article['url']).'">'.escape($article['url']).'</a></p></footer> <footer class="source"><p>'.__('Source:').' <a href="'.escape($article['url']).'">'.escape($article['url']).'</a></p></footer>
</article>'; </article>';
} }
?> ?>

View file

@ -4,7 +4,7 @@
* --- * ---
* 1. Rename this file to config.php. * 1. Rename this file to config.php.
* 2. Uncomment settings in this file, it will override default option * 2. Uncomment settings in this file, it will override default option
* *
* See how to configure your Autoblog farm at * See how to configure your Autoblog farm at
* https://github.com/mitsukarenai/Projet-Autoblog/wiki/Configuration * https://github.com/mitsukarenai/Projet-Autoblog/wiki/Configuration
**/ **/
@ -33,11 +33,11 @@
/** /**
* TwitterBridge: https://github.com/mitsukarenai/twitterbridge * TwitterBridge: https://github.com/mitsukarenai/twitterbridge
* twitter2feed : https://github.com/mitsukarenai/twitter2feed * twitter2feed : https://github.com/mitsukarenai/twitter2feed
* rss-bridge : https://github.com/sebsauvage/rss-bridge * rss-bridge : https://github.com/sebsauvage/rss-bridge
* replace LOCAL with: * replace LOCAL with:
- the twitterbridge request URL (example: 'http://www.some.website/twitterbridge/?u=' ) - the twitterbridge request URL (example: 'http://www.some.website/twitterbridge/?u=' )
- or the rss-bridge request URL (example: 'http://www.some.website/rss-bridge/?action=display&bridge=TwitterBridge&format=AtomFormat&u=' ) - or the rss-bridge request URL (example: 'http://www.some.website/rss-bridge/?action=display&bridge=TwitterBridge&format=AtomFormat&u=' )
- or leave LOCAL to use the included twitter2feed.php. - or leave LOCAL to use the included twitter2feed.php.
* set to FALSE if you want to fully disable Twitter support * set to FALSE if you want to fully disable Twitter support
**/ **/
// define( 'API_TWITTER', 'LOCAL' ); // define( 'API_TWITTER', 'LOCAL' );
@ -51,4 +51,7 @@ $friends_autoblog_farm = array(
// 'http://autoblog.suumitsu.eu/?export', // 'http://autoblog.suumitsu.eu/?export',
// 'http://streisand.hoa.ro/?export', // 'http://streisand.hoa.ro/?export',
); );
$myOptions['enableThumbShot'] = true;
$myOptions['externalThumbSdhot'] = 'http://soshot.knah-tsaeb.org/?key=apikey&s=m&url=';
?> ?>

View file

@ -17,7 +17,7 @@ date_default_timezone_set('Europe/Paris');
setlocale(LC_TIME, 'fr_FR.UTF-8', 'fr_FR', 'fr'); setlocale(LC_TIME, 'fr_FR.UTF-8', 'fr_FR', 'fr');
if( !defined('DOCS_CACHE_DURATION')) define( 'DOCS_CACHE_DURATION', 1800 ); if( !defined('DOCS_CACHE_DURATION')) define( 'DOCS_CACHE_DURATION', 1800 );
if( !defined('AUTOBLOGS_CACHE_DURATION')) define( 'AUTOBLOGS_CACHE_DURATION', 1800 ); if( !defined('AUTOBLOGS_CACHE_DURATION')) define( 'AUTOBLOGS_CACHE_DURATION', 1800 );
if( !defined('ALLOW_FULL_UPDATE')) define( 'ALLOW_FULL_UPDATE', TRUE ); if( !defined('ALLOW_FULL_UPDATE')) define( 'ALLOW_FULL_UPDATE', TRUE );
if( !defined('ALLOW_CHECK_UPDATE')) define( 'ALLOW_CHECK_UPDATE', TRUE ); if( !defined('ALLOW_CHECK_UPDATE')) define( 'ALLOW_CHECK_UPDATE', TRUE );
@ -63,13 +63,13 @@ function DetectRedirect($url)
if(parse_url($url, PHP_URL_HOST)==FALSE) { if(parse_url($url, PHP_URL_HOST)==FALSE) {
throw new Exception('Not a URL: '. escape ($url) ); throw new Exception('Not a URL: '. escape ($url) );
} }
try { $response = get_headers($url, 1); } try { $response = get_headers($url, 1); }
catch (Exception $e) { throw new Exception('RSS URL unreachable: '. escape($url) ); } catch (Exception $e) { throw new Exception('RSS URL unreachable: '. escape($url) ); }
if(!empty($response['Location'])) { if(!empty($response['Location'])) {
try { $response2 = get_headers($response['Location'], 1); } try { $response2 = get_headers($response['Location'], 1); }
catch (Exception $e) { throw new Exception('RSS URL unreachable: '. escape($url) ); } catch (Exception $e) { throw new Exception('RSS URL unreachable: '. escape($url) ); }
if(!empty($response2['Location'])) { if(!empty($response2['Location'])) {
throw new Exception('Too much redirection: '. escape ($url) ); throw new Exception('Too much redirection: '. escape ($url) );
} }
@ -96,7 +96,24 @@ function escape($str) {
return htmlspecialchars($str, ENT_COMPAT, 'UTF-8', false); return htmlspecialchars($str, ENT_COMPAT, 'UTF-8', false);
} }
function createAutoblog($type, $sitename, $siteurl, $rssurl) { function getSiteDesc($url){
$allMeta = get_meta_tags($url);
if(!empty($allMeta['description'])){
return $allMeta['description'];
} else {
return 'Pas de description trouvé';
}
}
function shortSiteDesc($desc, $length = 145){
$charset = 'UTF-8';
if(mb_strlen($desc, $charset) > $length) {
$desc = mb_substr($desc, 0, $length, $charset) . '...';
}
return $desc;
}
function createAutoblog($type, $sitename, $siteurl, $rssurl, $siteDesc, $error = array()) {
if( $type == 'generic' || empty( $type )) { if( $type == 'generic' || empty( $type )) {
$var = updateType( $siteurl ); $var = updateType( $siteurl );
$type = $var['type']; $type = $var['type'];
@ -105,15 +122,16 @@ function createAutoblog($type, $sitename, $siteurl, $rssurl) {
$sitename = ucfirst($var['name']) . ' - ' . $sitename; $sitename = ucfirst($var['name']) . ' - ' . $sitename;
} }
} }
if(folderExists($siteurl, $rssurl)) { if(folderExists($siteurl, $rssurl)) {
throw new Exception('Erreur : l\'autoblog '. $sitename .' existe déjà.'); throw new Exception('Erreur : l\'autoblog '. $sitename .' existe déjà.');
} }
$foldername = urlToFolder($siteurl, $rssurl); $foldername = urlToFolder($siteurl, $rssurl);
if ( mkdir($foldername, 0755, false) ) { if ( mkdir($foldername, 0755, false) ) {
$fp = fopen($foldername .'/index.php', 'w+'); $fp = fopen($foldername .'/index.php', 'w+');
if( !fwrite($fp, "<?php require_once '../autoblog.php'; ?>") ) if( !fwrite($fp, "<?php require_once '../autoblog.php'; ?>") )
throw new Exception('Impossible d\'écrire le fichier index.php'); throw new Exception('Impossible d\'écrire le fichier index.php');
@ -124,6 +142,7 @@ function createAutoblog($type, $sitename, $siteurl, $rssurl) {
SITE_TYPE="'. $type .'" SITE_TYPE="'. $type .'"
SITE_TITLE="'. $sitename .'" SITE_TITLE="'. $sitename .'"
SITE_DESCRIPTION="Site original : <a href=\''. $siteurl .'\'>'. $sitename .'</a>" SITE_DESCRIPTION="Site original : <a href=\''. $siteurl .'\'>'. $sitename .'</a>"
SITE_META_DESCRIPTION="'.$siteDesc.'"
SITE_URL="'. $siteurl .'" SITE_URL="'. $siteurl .'"
FEED_URL="'. $rssurl .'" FEED_URL="'. $rssurl .'"
ARTICLES_PER_PAGE="'. getArticlesPerPage( $type ) .'" ARTICLES_PER_PAGE="'. getArticlesPerPage( $type ) .'"
@ -177,10 +196,10 @@ function updateType($siteurl) {
if( strpos($siteurl, 'twitter.com') !== FALSE ) { if( strpos($siteurl, 'twitter.com') !== FALSE ) {
return array('type' => 'twitter', 'name' => 'twitter'); return array('type' => 'twitter', 'name' => 'twitter');
} }
elseif( strpos( $siteurl, 'shaarli' ) !== FALSE ) { elseif( strpos( $siteurl, 'shaarli' ) !== FALSE ) {
return array('type' => 'shaarli', 'name' => 'shaarli'); return array('type' => 'shaarli', 'name' => 'shaarli');
} }
elseif( strpos( $siteurl, 'youtube.com' ) !== FALSE ) { elseif( strpos( $siteurl, 'youtube.com' ) !== FALSE ) {
return array('type' => 'youtube', 'name' => ''); return array('type' => 'youtube', 'name' => '');
} }
else else
@ -194,6 +213,24 @@ function debug($data)
echo '</pre>'; echo '</pre>';
} }
/**
* Améliore la sortie print
*
* @author Tatane http://www.tatane.info/index.php/print_rn
* @author http://www.blog.cactuscrew.com/77-print_rn.html
* @param $data (array) tableau à examiner
* @param $name (string) nom a affiché
* @return false affiche les clef valeur du tableau $data
*/
function n_print($data, $name = '') {
$aBackTrace = debug_backtrace();
echo '<h2>', $name, '</h2>';
echo '<fieldset style="border: 1px solid orange; padding: 5px;color: #333; background-color: #fff;">';
echo '<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '</legend>';
echo '<pre>', htmlentities(print_r($data, 1)), '</pre>';
echo '</fieldset><br />';
}
function __($str) function __($str)
{ {
switch ($str) switch ($str)
@ -288,7 +325,7 @@ function displayXML() {
foreach($uitem AS $Key => $Value) { foreach($uitem AS $Key => $Value) {
$item[$Key] = escape($Value); $item[$Key] = escape($Value);
} }
$description = displayXMLstatus($item['status'],$item['response_code'],$item['autoblog_url'],$item['autoblog_title'],$item['autoblog_sourceurl'],$item['autoblog_sourcefeed']); $description = displayXMLstatus($item['status'],$item['response_code'],$item['autoblog_url'],$item['autoblog_title'],$item['autoblog_sourceurl'],$item['autoblog_sourcefeed']);
$link = serverUrl(true).$item['autoblog_url']; $link = serverUrl(true).$item['autoblog_url'];
$date = date(DATE_RSS, $item['timestamp']); $date = date(DATE_RSS, $item['timestamp']);

207
index.php
View file

@ -119,14 +119,14 @@ function create_from_opml($opml) {
$sitename = escape( $outline['title'] ); $sitename = escape( $outline['title'] );
$siteurl = escape($outline['htmlUrl']); $siteurl = escape($outline['htmlUrl']);
$sitetype = escape($outline['text']); $sitetype = escape($outline['text']);
if ( $sitetype != 'microblog' && $sitetype != 'shaarli' && $sitetype != 'twitter' && $sitetype != 'youtube') if ( $sitetype != 'microblog' && $sitetype != 'shaarli' && $sitetype != 'twitter' && $sitetype != 'youtube')
$sitetype = 'generic'; $sitetype = 'generic';
$rssurl = DetectRedirect(escape($outline['xmlUrl'])); $rssurl = DetectRedirect(escape($outline['xmlUrl']));
createAutoblog( $sitetype, $sitename, $siteurl, $rssurl ); createAutoblog( $sitetype, $sitename, $siteurl, $rssurl );
$message = 'Autoblog "'. $sitename .'" crée avec succès. &rarr; <a target="_blank" href="'. urlToFolder( $siteurl, $rssurl ) .'">afficher l\'autoblog</a>.'; $message = 'Autoblog "'. $sitename .'" crée avec succès. &rarr; <a target="_blank" href="'. urlToFolder( $siteurl, $rssurl ) .'">afficher l\'autoblog</a>.';
// Do not print iframe on big import (=> heavy and useless) // Do not print iframe on big import (=> heavy and useless)
if( ++$cpt < 10 ) if( ++$cpt < 10 )
@ -173,10 +173,10 @@ function versionCheck() {
/** /**
* RSS Feed * RSS Feed
* *
**/ **/
if( !file_exists(RESOURCES_FOLDER.'rss.json')) { if( !file_exists(RESOURCES_FOLDER.'rss.json')) {
file_put_contents(RESOURCES_FOLDER.'rss.json', '', LOCK_EX); file_put_contents(RESOURCES_FOLDER.'rss.json', '', LOCK_EX);
} }
if (isset($_GET['rss'])) { if (isset($_GET['rss'])) {
@ -196,21 +196,21 @@ if (isset($_GET['check']))
/* SVG minimalistes */ /* SVG minimalistes */
function svg_status($fill, $text, $back) function svg_status($fill, $text, $back)
{ {
$svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="15" height="15">'.$back.'<text style="font-size:10px;font-weight:bold;text-anchor:middle;font-family:Arial;fill:'.$fill.';"><tspan x="8" y="14">'.$text.'</tspan></text></svg>'; $svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="15" height="15">'.$back.'<text style="font-size:10px;font-weight:bold;text-anchor:middle;font-family:Arial;fill:'.$fill.';"><tspan x="8" y="14">'.$text.'</tspan></text></svg>';
return $svg; return $svg;
} }
$svg_ok=svg_status('#008000', 'ok', '');
$svg_mv=svg_status('#0000ff', 'mv', '<rect width="100%" height="100%" fill="#ffd800"/>');
$svg_err=svg_status('#000000', 'err', '<rect width="100%" height="100%" fill="#ff0000"/>');
$svg_ok=svg_status('#008000', 'ok', '');
$svg_mv=svg_status('#0000ff', 'mv', '<rect width="100%" height="100%" fill="#ffd800"/>');
$svg_err=svg_status('#000000', 'err', '<rect width="100%" height="100%" fill="#ff0000"/>');
$errorlog="./".escape( $_GET['check'] ) ."/error.log"; $errorlog="./".escape( $_GET['check'] ) ."/error.log";
$oldvalue = null; $oldvalue = null;
if(file_exists($errorlog)) { $oldvalue = file_get_contents($errorlog); }; if(file_exists($errorlog)) { $oldvalue = file_get_contents($errorlog); };
if(file_exists($errorlog) && filemtime($errorlog) < $expire) { unlink($errorlog); } /* errorlog périmé ? Suppression. */ if(file_exists($errorlog) && filemtime($errorlog) < $expire) { unlink($errorlog); } /* errorlog périmé ? Suppression. */
if(file_exists($errorlog)) /* errorlog existe encore ? se contenter de lire sa taille pour avoir le statut */ if(file_exists($errorlog)) /* errorlog existe encore ? se contenter de lire sa taille pour avoir le statut */
{ {
if(filesize($errorlog) == "0") {die($svg_ok);} if(filesize($errorlog) == "0") {die($svg_ok);}
else if(filesize($errorlog) == "1") {die($svg_mv);} else if(filesize($errorlog) == "1") {die($svg_mv);}
@ -220,15 +220,15 @@ function svg_status($fill, $text, $back)
{ {
$ini = parse_ini_file("./". escape( $_GET['check'] ) ."/vvb.ini") or die; $ini = parse_ini_file("./". escape( $_GET['check'] ) ."/vvb.ini") or die;
$headers = get_headers($ini['FEED_URL']); $headers = get_headers($ini['FEED_URL']);
if(!empty($headers)) if(!empty($headers))
$code=explode(" ", $headers[0]); $code=explode(" ", $headers[0]);
else $code = array(); else $code = array();
/* le flux est indisponible (typiquement: erreur DNS ou possible censure) - à vérifier */ /* le flux est indisponible (typiquement: erreur DNS ou possible censure) - à vérifier */
if(empty($headers) || $headers === FALSE || (!empty($code) && ($code[1] == '500' || $code[1] == '404'))) { if(empty($headers) || $headers === FALSE || (!empty($code) && ($code[1] == '500' || $code[1] == '404'))) {
if( $oldvalue !== null && $oldvalue != '..' ) { if( $oldvalue !== null && $oldvalue != '..' ) {
updateXML('unavailable', 'nxdomain', escape($_GET['check']), $ini['SITE_TITLE'], $ini['SITE_URL'], $ini['FEED_URL']); updateXML('unavailable', 'nxdomain', escape($_GET['check']), $ini['SITE_TITLE'], $ini['SITE_URL'], $ini['FEED_URL']);
} }
file_put_contents($errorlog, '..'); file_put_contents($errorlog, '..');
die($svg_err); die($svg_err);
@ -236,7 +236,7 @@ function svg_status($fill, $text, $back)
/* code retour 200: flux disponible */ /* code retour 200: flux disponible */
if($code[1] == "200") { if($code[1] == "200") {
if( $oldvalue !== null && $oldvalue != '' ) { if( $oldvalue !== null && $oldvalue != '' ) {
updateXML('available', '200', escape($_GET['check']), $ini['SITE_TITLE'], $ini['SITE_URL'], $ini['FEED_URL']); updateXML('available', '200', escape($_GET['check']), $ini['SITE_TITLE'], $ini['SITE_URL'], $ini['FEED_URL']);
} }
file_put_contents($errorlog, ''); file_put_contents($errorlog, '');
die($svg_ok); die($svg_ok);
@ -244,7 +244,7 @@ function svg_status($fill, $text, $back)
/* autre code retour: un truc a changé (redirection, changement de CMS, .. bref vvb.ini doit être corrigé) */ /* autre code retour: un truc a changé (redirection, changement de CMS, .. bref vvb.ini doit être corrigé) */
else { else {
if( $oldvalue !== null && $oldvalue != '.' ) { if( $oldvalue !== null && $oldvalue != '.' ) {
updateXML('moved', '3xx', escape($_GET['check']), $ini['SITE_TITLE'], $ini['SITE_URL'], $ini['FEED_URL']); updateXML('moved', '3xx', escape($_GET['check']), $ini['SITE_TITLE'], $ini['SITE_URL'], $ini['FEED_URL']);
} }
file_put_contents($errorlog, '.'); file_put_contents($errorlog, '.');
die($svg_mv); die($svg_mv);
@ -327,7 +327,7 @@ if (isset($_GET['exportopml'])) // OPML
foreach($subdirs as $unit) { foreach($subdirs as $unit) {
if(is_dir($unit)) { if(is_dir($unit)) {
$unit=substr($unit, 2); $unit=substr($unit, 2);
$ini = parse_ini_file($unit.'/vvb.ini'); $ini = parse_ini_file($unit.'/vvb.ini');
$config = new stdClass; $config = new stdClass;
@ -354,15 +354,15 @@ if (isset($_GET['exportopml'])) // OPML
if (isset($_GET['sitemap'])) if (isset($_GET['sitemap']))
{ {
header('Content-Type: application/xml'); header('Content-Type: application/xml');
$proto=(!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'])=='on')?"https://":"http://"; $proto=(!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'])=='on')?"https://":"http://";
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n".'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n"; echo '<?xml version="1.0" encoding="UTF-8"?>'."\n".'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n";
echo "<url>\n <loc>".$proto."{$_SERVER['HTTP_HOST']}".str_replace('?sitemap', '', $_SERVER['REQUEST_URI'])."</loc>\n"; echo "<url>\n <loc>".$proto."{$_SERVER['HTTP_HOST']}".str_replace('?sitemap', '', $_SERVER['REQUEST_URI'])."</loc>\n";
echo ' <lastmod>'.date('c', time())."</lastmod>\n"; echo ' <lastmod>'.date('c', time())."</lastmod>\n";
echo " <changefreq>daily</changefreq>\n</url>\n"; echo " <changefreq>daily</changefreq>\n</url>\n";
$subdirs = glob(AUTOBLOGS_FOLDER . "*"); $subdirs = glob(AUTOBLOGS_FOLDER . "*");
foreach($subdirs as $unit) { foreach($subdirs as $unit) {
if(is_dir($unit)) { if(is_dir($unit)) {
$unit=substr($unit, 2); $unit=substr($unit, 2);
echo "<url>\n <loc>".$proto.$_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'], 0, -9)."$unit/"."</loc>\n"; echo "<url>\n <loc>".$proto.$_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'], 0, -9)."$unit/"."</loc>\n";
echo ' <lastmod>'.date('c', filemtime($unit))."</lastmod>\n"; echo ' <lastmod>'.date('c', filemtime($unit))."</lastmod>\n";
echo " <changefreq>hourly</changefreq>\n</url>\n\n"; echo " <changefreq>hourly</changefreq>\n</url>\n\n";
@ -442,7 +442,7 @@ if( isset($_GET['updateall']) ) {
$antibot = generate_antibot(); $antibot = generate_antibot();
$form = '<form method="POST"><input type="hidden" name="generic" value="1" />'."\n".' $form = '<form method="POST"><input type="hidden" name="generic" value="1" />'."\n".'
<input placeholder="Adresse du flux RSS/ATOM" type="text" name="rssurl" id="rssurl"><br> <input placeholder="Adresse du flux RSS/ATOM" type="text" name="rssurl" id="rssurl"><br>
<input placeholder="Antibot : écrivez « '. $antibot .' » en chiffre" type="text" name="number"><br> <input placeholder="Antibot : écrivez « '. $antibot .' » en chiffre" type="text" name="number"><br>
<input type="hidden" name="antibot" value="'. $antibot .'" /> <input type="hidden" name="antibot" value="'. $antibot .'" />
<input type="submit" value="Vérifier"> <input type="submit" value="Vérifier">
</form>'; </form>';
@ -494,6 +494,7 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG
$sitename = get_title_from_datafeed($datafeed); $sitename = get_title_from_datafeed($datafeed);
$sitetype = updateType($siteurl); $sitetype = updateType($siteurl);
$sitetype = $sitetype['type']; $sitetype = $sitetype['type'];
$siteDesc = getSiteDesc(escape($siteurl));
$form .= '<span style="color:blue">Merci de vérifier les informations suivantes, corrigez si nécessaire.</span><br> $form .= '<span style="color:blue">Merci de vérifier les informations suivantes, corrigez si nécessaire.</span><br>
<form method="GET"> <form method="GET">
@ -502,6 +503,7 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG
<input style="width:30em;" placeholder="Adresse du site" type="text" name="siteurl" id="siteurl" value="'.$siteurl.'"><label for="siteurl">&larr; page d\'accueil (auto)</label><br> <input style="width:30em;" placeholder="Adresse du site" type="text" name="siteurl" id="siteurl" value="'.$siteurl.'"><label for="siteurl">&larr; page d\'accueil (auto)</label><br>
<input style="width:30em;" placeholder="Adresse du flux RSS/ATOM" type="text" name="rssurl" id="rssurl" value="'.$rssurl.'"><label for="rssurl">&larr; adresse du flux</label><br> <input style="width:30em;" placeholder="Adresse du flux RSS/ATOM" type="text" name="rssurl" id="rssurl" value="'.$rssurl.'"><label for="rssurl">&larr; adresse du flux</label><br>
<input style="width:30em;" type="text" name="sitetype" id="sitetype" value="'.$sitetype.'" disabled><label for="sitetype">&larr; type de site</label><br> <input style="width:30em;" type="text" name="sitetype" id="sitetype" value="'.$sitetype.'" disabled><label for="sitetype">&larr; type de site</label><br>
<textarea style="width:30em;height:8em;" type="text" name="siteDesc" id="siteDesc">'.escape($siteDesc).'</textarea><label for="siteDesc">&larr; description de site</label><br>
<input type="submit" value="Créer"></form>'; <input type="submit" value="Créer"></form>';
} }
else { else {
@ -529,18 +531,18 @@ if( !empty($_POST['socialinstance']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLO
elseif( !empty($_POST['number']) && !empty($_POST['antibot']) && check_antibot($_POST['number'], $_POST['antibot'])) { elseif( !empty($_POST['number']) && !empty($_POST['antibot']) && check_antibot($_POST['number'], $_POST['antibot'])) {
if($socialinstance === 'twitter') { if($socialinstance === 'twitter') {
if( API_TWITTER !== FALSE ) { if( API_TWITTER !== FALSE ) {
$sitetype = 'twitter'; $sitetype = 'twitter';
$siteurl = 'http://twitter.com/'. $socialaccount; $siteurl = 'http://twitter.com/'. $socialaccount;
if ( API_TWITTER === 'LOCAL' ) { if ( API_TWITTER === 'LOCAL' ) {
$rssurl = serverUrl(true).'twitter2feed.php?u='.$socialaccount; $rssurl = serverUrl(true).'twitter2feed.php?u='.$socialaccount;
} }
else { else {
$rssurl = API_TWITTER.$socialaccount; $rssurl = API_TWITTER.$socialaccount;
// check // check
$twitterbridge = get_headers($rssurl, 1); $twitterbridge = get_headers($rssurl, 1);
if ($twitterbridge['0'] == 'HTTP/1.1 403 Forbidden') { $error[] = "La twitterbridge a refusé ce nom d'utilisateur: <br>\n<pre>".htmlentities($twitterbridge['X-twitterbridge']).'</pre>'; } if ($twitterbridge['0'] == 'HTTP/1.1 403 Forbidden') { $error[] = "La twitterbridge a refusé ce nom d'utilisateur: <br>\n<pre>".htmlentities($twitterbridge['X-twitterbridge']).'</pre>'; }
} }
} }
else else
$error[] = 'Vous devez définir une API Twitter -> RSS dans votre fichier de configuration (see <a href="https://github.com/mitsukarenai/twitterbridge">TwitterBridge</a>).'; $error[] = 'Vous devez définir une API Twitter -> RSS dans votre fichier de configuration (see <a href="https://github.com/mitsukarenai/twitterbridge">TwitterBridge</a>).';
@ -576,9 +578,9 @@ if( !empty($_POST['socialinstance']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLO
if( empty($error) ) { if( empty($error) ) {
try { try {
$headers = get_headers($rssurl, 1); $headers = get_headers($rssurl, 1);
if (strpos($headers[0], '200') === FALSE) if (strpos($headers[0], '200') === FALSE)
throw new Exception('Flux inaccessible (compte inexistant ?)'); throw new Exception('Flux inaccessible (compte inexistant ?)');
createAutoblog($sitetype, ucfirst($socialinstance) .' - '. $socialaccount, $siteurl, $rssurl); createAutoblog($sitetype, ucfirst($socialinstance) .' - '. $socialaccount, $siteurl, $rssurl);
$success[] = '<iframe width="1" height="1" frameborder="0" src="'. urlToFolder( $siteurl, $rssurl ) .'/index.php"></iframe> $success[] = '<iframe width="1" height="1" frameborder="0" src="'. urlToFolder( $siteurl, $rssurl ) .'/index.php"></iframe>
<b style="color:darkgreen">'.ucfirst($socialinstance) .' - '. $socialaccount.' <a href="'. urlToFolder( $siteurl, $rssurl ) .'">ajouté avec succès</a>.</b>'; <b style="color:darkgreen">'.ucfirst($socialinstance) .' - '. $socialaccount.' <a href="'. urlToFolder( $siteurl, $rssurl ) .'">ajouté avec succès</a>.</b>';
@ -589,7 +591,7 @@ if( !empty($_POST['socialinstance']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLO
} }
} }
else else
$error[] = 'Antibot : chiffres incorrects.'; $error[] = 'Antibot : chiffres incorrects.';
} }
/** /**
@ -599,15 +601,15 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L
if(empty($_POST['rssurl'])) if(empty($_POST['rssurl']))
{$error[] = "Veuillez entrer l'adresse du flux.";} {$error[] = "Veuillez entrer l'adresse du flux.";}
if(empty($_POST['number']) || empty($_POST['antibot']) ) if(empty($_POST['number']) || empty($_POST['antibot']) )
{$error[] = "Vous êtes un bot ?";} {$error[] = "Vous êtes un bot ?";}
elseif(! check_antibot($_POST['number'], $_POST['antibot'])) elseif(! check_antibot($_POST['number'], $_POST['antibot']))
{$error[] = "Antibot : ce n'est pas le bon nombre.";} {$error[] = "Antibot : ce n'est pas le bon nombre.";}
if(empty($error)) { if(empty($error)) {
try { try {
$rssurl = parse_url($_POST['rssurl']); $rssurl = parse_url($_POST['rssurl']);
if(!isset($rssurl['query'])) $rssurl['query'] = ''; if(!isset($rssurl['query'])) $rssurl['query'] = '';
$rssurl = $rssurl['scheme'].'://'.$rssurl['host'].$rssurl['path'].'?'.html_entity_decode($rssurl['query']); $rssurl = $rssurl['scheme'].'://'.$rssurl['host'].$rssurl['path'].'?'.html_entity_decode($rssurl['query']);
$rssurl = DetectRedirect($rssurl); $rssurl = DetectRedirect($rssurl);
if(!empty($_POST['siteurl'])) { if(!empty($_POST['siteurl'])) {
@ -629,6 +631,7 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L
$sitetype = 'generic'; $sitetype = 'generic';
$siteurl = get_link_from_datafeed($datafeed); $siteurl = get_link_from_datafeed($datafeed);
$sitename = get_title_from_datafeed($datafeed); $sitename = get_title_from_datafeed($datafeed);
$siteDesc = getSiteDesc(escape($siteurl));
$form = '<span style="color:blue">Merci de vérifier les informations suivantes, corrigez si nécessaire. Tous les champs doivent être renseignés.</span><br> $form = '<span style="color:blue">Merci de vérifier les informations suivantes, corrigez si nécessaire. Tous les champs doivent être renseignés.</span><br>
<form method="POST"><input type="hidden" name="generic" value="1" /> <form method="POST"><input type="hidden" name="generic" value="1" />
@ -652,9 +655,9 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L
**/ **/
if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML_FILE) { if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML_FILE) {
if(empty($_POST['number']) || empty($_POST['antibot']) ) if(empty($_POST['number']) || empty($_POST['antibot']) )
{$error[] = "Vous êtes un bot ?";} {$error[] = "Vous êtes un bot ?";}
elseif(! check_antibot($_POST['number'], $_POST['antibot'])) elseif(! check_antibot($_POST['number'], $_POST['antibot']))
{$error[] = "Antibot : ce n'est pas le bon nombre.";} {$error[] = "Antibot : ce n'est pas le bon nombre.";}
if( empty( $error)) { if( empty( $error)) {
if (is_uploaded_file($_FILES['file']['tmp_name'])) { if (is_uploaded_file($_FILES['file']['tmp_name'])) {
@ -676,9 +679,9 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
**/ **/
if( !empty($_POST['opml_link']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML_LINK) { if( !empty($_POST['opml_link']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML_LINK) {
if(empty($_POST['number']) || empty($_POST['antibot']) ) if(empty($_POST['number']) || empty($_POST['antibot']) )
{$error[] = "Vous êtes un bot ?";} {$error[] = "Vous êtes un bot ?";}
elseif(! check_antibot($_POST['number'], $_POST['antibot'])) elseif(! check_antibot($_POST['number'], $_POST['antibot']))
{$error[] = "Antibot : ce n'est pas le bon nombre.";} {$error[] = "Antibot : ce n'est pas le bon nombre.";}
if( empty( $_POST['opml_url'] )) if( empty( $_POST['opml_url'] ))
{$error[] = 'Le lien est incorrect.';} {$error[] = 'Le lien est incorrect.';}
@ -704,7 +707,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<title>Projet Autoblog<?php if(strlen(HEAD_TITLE)>0) echo " | " . HEAD_TITLE; ?></title> <title>Projet Autoblog<?php if(strlen(HEAD_TITLE)>0) echo " | " . HEAD_TITLE; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" charset="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" charset="utf-8" />
<meta content="initial-scale=1.0, user-scalable=yes" name="viewport" /> <meta content="initial-scale=1.0, user-scalable=yes" name="viewport" />
<meta name="keywords" content="autoblog,effet streisand,censure,replication" /> <meta name="keywords" content="autoblog,effet streisand,censure,replication" />
<meta name="description" content="Le Projet Autoblog a pour objectif de répliquer les articles d'un blog ou d'un site site web." /> <meta name="description" content="Le Projet Autoblog a pour objectif de répliquer les articles d'un blog ou d'un site site web." />
<link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo serverUrl(true) . '?rss';?>" /> <link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo serverUrl(true) . '?rss';?>" />
@ -719,7 +722,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<header> <header>
<h1><a href="<?php echo serverUrl(true); ?>">Projet Autoblog<?php if(strlen(HEAD_TITLE)>0) echo " | " . HEAD_TITLE; ?></a></h1> <h1><a href="<?php echo serverUrl(true); ?>">Projet Autoblog<?php if(strlen(HEAD_TITLE)>0) echo " | " . HEAD_TITLE; ?></a></h1>
</header> </header>
<section id="présentation"> <section id="présentation">
<header> <header>
<?php <?php
@ -728,11 +731,11 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
?> ?>
<h2>Présentation</h2> <h2>Présentation</h2>
</header> </header>
<p>Le Projet Autoblog a pour objectif de répliquer les articles d'un blog ou d'un site site web. Si l'article source est supprimé, et même si le site d'origine disparaît, les articles restent lisibles sur l'autoblog. L'objectif premier de ce projet est de lutter contre la censure et toute sorte de pression…</p> <p>Le Projet Autoblog a pour objectif de répliquer les articles d'un blog ou d'un site site web. Si l'article source est supprimé, et même si le site d'origine disparaît, les articles restent lisibles sur l'autoblog. L'objectif premier de ce projet est de lutter contre la censure et toute sorte de pression…</p>
<p>Voici une liste d'autoblogs hébergés sur <em><?php echo $_SERVER['SERVER_NAME']; ?></em> (<a href="http://sebsauvage.net/streisand.me/fr/">plus d'infos sur le projet</a>).</p> <p>Voici une liste d'autoblogs hébergés sur <em><?php echo $_SERVER['SERVER_NAME']; ?></em> (<a href="http://sebsauvage.net/streisand.me/fr/">plus d'infos sur le projet</a>).</p>
<p><strong>Autres fermes</strong> &rarr; <a href="//startpage.com/do/search?query=%22Voici+une+liste+d%27autoblogs+h%C3%A9berg%C3%A9s%22">Rechercher</a></p> <p><strong>Autres fermes</strong> &rarr; <a href="//startpage.com/do/search?query=%22Voici+une+liste+d%27autoblogs+h%C3%A9berg%C3%A9s%22">Rechercher</a></p>
</section> </section>
<?php if( $update_available ) { ?> <?php if( $update_available ) { ?>
@ -740,11 +743,11 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<header> <header>
<h2>Mise à jour</h2> <h2>Mise à jour</h2>
</header> </header>
<p>Une mise à jour du Projet Autoblog est disponible !</p> <p>Une mise à jour du Projet Autoblog est disponible !</p>
<ul> <ul>
<li>&rarr; <a href="https://github.com/mitsukarenai/Projet-Autoblog/archive/master.zip">télécharger la dernière version</a> ;</li> <li>&rarr; <a href="https://github.com/mitsukarenai/Projet-Autoblog/archive/master.zip">télécharger la dernière version</a> ;</li>
<li>&rarr; <strong>important :</strong> <a href="https://github.com/mitsukarenai/Projet-Autoblog/wiki/Mettre-%C3%A0-jour">consulter la documentation  mise à jour</a>.</li> <li>&rarr; <strong>important :</strong> <a href="https://github.com/mitsukarenai/Projet-Autoblog/wiki/Mettre-%C3%A0-jour">consulter la documentation mise à jour</a>.</li>
</ul> </ul>
</section> </section>
<?php } ?> <?php } ?>
@ -756,7 +759,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<?php <?php
if( !empty( $error ) || !empty( $success )) { if( !empty( $error ) || !empty( $success )) {
echo '<p>Message'. (count($error) ? 's' : '') ." :</p>\n"; echo '<p>Message'. (count($error) ? 's' : '') ." :</p>\n";
echo " <ul>\n"; echo " <ul>\n";
foreach ( $error AS $value ) { foreach ( $error AS $value ) {
echo ' <li class="error">'. $value ."</li>\n"; echo ' <li class="error">'. $value ."</li>\n";
@ -768,8 +771,8 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
echo " \n"; echo " \n";
echo ' '; echo ' ';
} }
$button_list = '<p id="button_list">Ajouter un autoblog via :'."\n"; $button_list = '<p id="button_list">Ajouter un autoblog via :'."\n";
if(ALLOW_NEW_AUTOBLOGS_BY_LINKS) if(ALLOW_NEW_AUTOBLOGS_BY_LINKS)
$button_list .= ' <a href="#add_generic" class="button" id="button_generic" onclick="show_form(\'generic\');return false;">Flux RSS</a>'."\n"; $button_list .= ' <a href="#add_generic" class="button" id="button_generic" onclick="show_form(\'generic\');return false;">Flux RSS</a>'."\n";
if(ALLOW_NEW_AUTOBLOGS_BY_SOCIAL) { if(ALLOW_NEW_AUTOBLOGS_BY_SOCIAL) {
@ -784,15 +787,15 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
$button_list .= ' <a href="#add_bookmark" class="button" id="button_bookmark" onclick="show_form(\'bookmark\');return false;">Marque page</a>'."\n"; $button_list .= ' <a href="#add_bookmark" class="button" id="button_bookmark" onclick="show_form(\'bookmark\');return false;">Marque page</a>'."\n";
$button_list .= " </p>\n"; $button_list .= " </p>\n";
echo $button_list; echo $button_list;
if(ALLOW_NEW_AUTOBLOGS_BY_LINKS == TRUE) { ?> if(ALLOW_NEW_AUTOBLOGS_BY_LINKS == TRUE) { ?>
<section class="form" id="add_generic"> <section class="form" id="add_generic">
<header> <header>
<h3>Ajouter un site web</h3> <h3>Ajouter un site web</h3>
</header> </header>
<p>Si vous souhaitez que <em><?php echo $_SERVER['SERVER_NAME']; ?></em> héberge un autoblog d'un site, remplissez le formulaire suivant :</p> <p>Si vous souhaitez que <em><?php echo $_SERVER['SERVER_NAME']; ?></em> héberge un autoblog d'un site, remplissez le formulaire suivant :</p>
<?php echo $form; echo "\n"; ?> <?php echo $form; echo "\n"; ?>
</section> </section>
<?php } <?php }
@ -801,7 +804,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<header> <header>
<h3>Ajouter un compte social</h3> <h3>Ajouter un compte social</h3>
</header> </header>
<form method="POST"> <form method="POST">
<input placeholder="Identifiant du compte" type="text" name="socialaccount" id="socialaccount" /><br /> <input placeholder="Identifiant du compte" type="text" name="socialaccount" id="socialaccount" /><br />
<?php <?php
@ -815,7 +818,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<input type="radio" name="socialinstance" value="statusnet" /> <input type="radio" name="socialinstance" value="statusnet" />
<input placeholder="statusnet.personnel.com" type="text" name="statusneturl" id="statusneturl" /><br /> <input placeholder="statusnet.personnel.com" type="text" name="statusneturl" id="statusneturl" /><br />
<input type="radio" name="socialinstance" value="youtube" />Youtube<br /> <input type="radio" name="socialinstance" value="youtube" />Youtube<br />
<input placeholder="Antibot : écrivez « <?php echo $antibot; ?> » en chiffres" type="text" name="number" class="smallinput" /><br /> <input placeholder="Antibot : écrivez « <?php echo $antibot; ?> » en chiffres" type="text" name="number" class="smallinput" /><br />
<input type="hidden" name="antibot" value="<?php echo $antibot; ?>" /> <input type="hidden" name="antibot" value="<?php echo $antibot; ?>" />
<input type="submit" value="Créer" /> <input type="submit" value="Créer" />
</form> </form>
@ -824,11 +827,11 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<header> <header>
<h3>Ajouter un Shaarli</h3> <h3>Ajouter un Shaarli</h3>
</header> </header>
<form method="POST"> <form method="POST">
<input type="hidden" name="socialinstance" value="shaarli" /> <input type="hidden" name="socialinstance" value="shaarli" />
<input placeholder="shaarli.personnel.com" type="text" name="shaarliurl" id="shaarliurl" /><br /> <input placeholder="shaarli.personnel.com" type="text" name="shaarliurl" id="shaarliurl" /><br />
<input placeholder="Antibot : écrivez « <?php echo $antibot; ?> » en chiffres" type="text" name="number" class="smallinput" /><br /> <input placeholder="Antibot : écrivez « <?php echo $antibot; ?> » en chiffres" type="text" name="number" class="smallinput" /><br />
<input type="hidden" name="antibot" value="<?php echo $antibot; ?>" /> <input type="hidden" name="antibot" value="<?php echo $antibot; ?>" />
<input type="submit" value="Créer" /> <input type="submit" value="Créer" />
</form> </form>
@ -839,11 +842,11 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<header> <header>
<h3>Ajouter par fichier OPML</h3> <h3>Ajouter par fichier OPML</h3>
</header> </header>
<form enctype='multipart/form-data' method='POST'> <form enctype='multipart/form-data' method='POST'>
<input type='hidden' name='opml_file' value='1' /> <input type='hidden' name='opml_file' value='1' />
<input type='file' name='file' /><br /> <input type='file' name='file' /><br />
<input placeholder="Antibot : écrivez « <?php echo $antibot; ?> » en chiffres" type="text" name="number" class="smallinput" /><br /> <input placeholder="Antibot : écrivez « <?php echo $antibot; ?> » en chiffres" type="text" name="number" class="smallinput" /><br />
<input type="hidden" name="antibot" value="<?php echo $antibot; ?>" /> <input type="hidden" name="antibot" value="<?php echo $antibot; ?>" />
<input type='submit' value='Importer' /> <input type='submit' value='Importer' />
</form> </form>
@ -854,11 +857,11 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<header> <header>
<h3>Ajouter par lien OPML</h3> <h3>Ajouter par lien OPML</h3>
</header> </header>
<form method="POST"> <form method="POST">
<input type="hidden" name="opml_link" value="1" /> <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="Lien vers OPML" type="text" name="opml_url" id="opml_url" class="smallinput" /><br />
<input placeholder="Antibot : écrivez « <?php echo $antibot; ?> » en chiffres" type="text" name="number" class="smallinput" /><br /> <input placeholder="Antibot : écrivez « <?php echo $antibot; ?> » en chiffres" type="text" name="number" class="smallinput" /><br />
<input type="hidden" name="antibot" value="<?php echo $antibot; ?>" /> <input type="hidden" name="antibot" value="<?php echo $antibot; ?>" />
<input type="submit" value="Envoyer" /> <input type="submit" value="Envoyer" />
</form> </form>
@ -869,7 +872,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<header> <header>
<h3>Marque page</h3> <h3>Marque page</h3>
</header> </header>
<p> <p>
Pour ajouter facilement un autoblog d'un site web, glissez ce bouton dans votre barre de marque-pages &rarr; Pour ajouter facilement un autoblog d'un site web, glissez ce bouton dans votre barre de marque-pages &rarr;
<a class="bouton" onclick= <a class="bouton" onclick=
@ -903,7 +906,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<header> <header>
<h2>Autres documents</h2> <h2>Autres documents</h2>
</header> </header>
<ul>'."\n"; <ul>'."\n";
foreach( $docs as $value ) { foreach( $docs as $value ) {
@ -913,36 +916,36 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
} }
echo ' <li>'. $str . "</li>\n"; echo ' <li>'. $str . "</li>\n";
} }
echo ' </ul> echo ' </ul>
</section>'."\n"; </section>'."\n";
} }
} }
// on recuperre le contenu du buffer // on recuperre le contenu du buffer
$contenuCache = ob_get_contents(); $contenuCache = ob_get_contents();
ob_end_clean(); // on termine la bufferisation ob_end_clean(); // on termine la bufferisation
if( !empty($contenuCache) ) { if( !empty($contenuCache) ) {
file_put_contents("$fichierCache",$contenuCache, LOCK_EX); // on écrit le contenu du buffer dans le fichier cache file_put_contents("$fichierCache",$contenuCache, LOCK_EX); // on écrit le contenu du buffer dans le fichier cache
} }
echo $contenuCache; // et on sort echo $contenuCache; // et on sort
// sinon le fichier cache existe déjà, on ne génère pas la page // sinon le fichier cache existe déjà, on ne génère pas la page
// et on envoie le fichier statique à la place // et on envoie le fichier statique à la place
} else { } else {
readfile($fichierCache); // affichage du contenu du fichier readfile($fichierCache); // affichage du contenu du fichier
echo ' <!-- Section « documents » (présente uniquement si non vide) servie par le cache -->'."\n"; // et un petit message echo ' <!-- Section « documents » (présente uniquement si non vide) servie par le cache -->'."\n"; // et un petit message
} }
?> ?>
<section id="autoblogs"> <section id="autoblogs">
<header> <header>
<h2>Autoblogs hébergés <a href="?rss" title="RSS des changements"><img src="<?php echo RESOURCES_FOLDER; ?>rss.png" alt="rss"/></a></h2> <h2>Autoblogs hébergés <a href="?rss" title="RSS des changements"><img src="<?php echo RESOURCES_FOLDER; ?>rss.png" alt="rss"/></a></h2>
</header> </header>
<nav class="clear"> <nav class="clear">
<a href="?sitemap">sitemap</a> | <a href="?sitemap">sitemap</a> |
<a href="?export" >export<sup>JSON</sup></a> | <a href="?export" >export<sup>JSON</sup></a> |
<a href="?exportopml">export<sup>OPML</sup></a> <a href="?exportopml">export<sup>OPML</sup></a>
</nav> </nav>
<?php <?php
$fichierCache = 'cache_autoblogs'; $fichierCache = 'cache_autoblogs';
// si la page n'existe pas dans le cache ou si elle a expiré (durée paramétrable) // si la page n'existe pas dans le cache ou si elle a expiré (durée paramétrable)
@ -950,8 +953,8 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
if (@filemtime($fichierCache)<time()-(AUTOBLOGS_CACHE_DURATION)) { if (@filemtime($fichierCache)<time()-(AUTOBLOGS_CACHE_DURATION)) {
// on démarre la bufferisation : rien n'est envoyé au navigateur // on démarre la bufferisation : rien n'est envoyé au navigateur
ob_start(); ob_start();
echo '<ul> echo '<ul>
'; ';
$subdirs = glob(AUTOBLOGS_FOLDER . "*"); $subdirs = glob(AUTOBLOGS_FOLDER . "*");
$autoblogs = array(); $autoblogs = array();
@ -973,10 +976,10 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
} }
} }
} }
uasort($autoblogs, "objectCmp"); uasort($autoblogs, "objectCmp");
$autoblogs_display = ''; $autoblogs_display = '';
if(!empty($autoblogs)){ if(!empty($autoblogs)){
foreach ($autoblogs as $key => $autoblog) { foreach ($autoblogs as $key => $autoblog) {
$opml_link='<a href="'.$key.'/?opml">opml</a>'; $opml_link='<a href="'.$key.'/?opml">opml</a>';
@ -987,24 +990,34 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<img width="15" height="15" alt="" src="./?check='.$key.'" /> <img width="15" height="15" alt="" src="./?check='.$key.'" />
<h3>'.escape($autoblog->site_title).'</h3> <h3>'.escape($autoblog->site_title).'</h3>
</a> </a>
</header> </header>';
<div class="source">config <sup><a href="'.$key.'/vvb.ini">ini</a> '.$opml_link.'</sup> | '.escape($autoblog->site_type).' source : <a href="'.escape($autoblog->site_url).'">'.escape($autoblog->site_url).'</a></div> if($myOptions['enableThumbShot'] === true){
if(file_exists(ROOT_DIR . '/' . $key . '/thumbshot.png')){
$autoblogs_display .= '<div class="thumbshot"><img src="'.ROOT_DIR . '/' . $key . '/thumbshot.png" title="Thumbshot de '.escape($autoblog->site_title).'"/></div>
<div class="siteDesc">'.shortSiteDesc(escape($autoblog->site_meta_description)).'</div>';
} elseif(!empty($myOptions['externalThumbSdhot'])) {
$autoblogs_display .= '<div class="thumbshot"><img src="'.$myOptions['externalThumbSdhot'].rawurlencode(escape($autoblog->site_url)).'" title="Thumbshot de '.escape($autoblog->site_title).'"/></div>
<div class="siteDesc">'.shortSiteDesc(escape($autoblog->site_meta_description)).'</div>';
}
}
$autoblogs_display .= '
<div class="source">config <sup><a href="'.$key.'/vvb.ini">ini</a> '.$opml_link.'</sup> | '.escape($autoblog->site_type).' source : <a href="'.escape($autoblog->site_url).'">'.escape($autoblog->site_url).'</a></div>
</li>'; </li>';
} }
} }
echo $autoblogs_display; echo $autoblogs_display;
echo ' echo '
</ul> </ul>
<p>'.count($autoblogs).' autoblogs hébergés</p>'; <p>'.count($autoblogs).' autoblogs hébergés</p>';
// on recuperre le contenu du buffer // on recuperre le contenu du buffer
$contenuCache = ob_get_contents(); $contenuCache = ob_get_contents();
ob_end_clean(); // on termine la bufferisation ob_end_clean(); // on termine la bufferisation
if( !empty($contenuCache) ) { if( !empty($contenuCache) ) {
file_put_contents("$fichierCache",$contenuCache, LOCK_EX); // on écrit le contenu du buffer dans le fichier cache file_put_contents("$fichierCache",$contenuCache, LOCK_EX); // on écrit le contenu du buffer dans le fichier cache
} }
echo $contenuCache; // et on sort echo $contenuCache; // et on sort
// sinon le fichier cache existe déjà, on ne génère pas la page // sinon le fichier cache existe déjà, on ne génère pas la page
// et on envoie le fichier statique à la place // et on envoie le fichier statique à la place
} else { } else {
@ -1014,12 +1027,12 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
} }
?> ?>
</section> </section>
<footer> <footer>
<p>Propulsé par <a href="https://github.com/mitsukarenai/Projet-Autoblog">Projet Autoblog 0.3</a> de <a href="https://www.suumitsu.eu/">Mitsu</a>, <a href="https://www.ecirtam.net/">Oros</a> et <a href="http://hoa.ro">Arthur Hoaro</a> (Domaine Public)</p> <p>Propulsé par <a href="https://github.com/mitsukarenai/Projet-Autoblog">Projet Autoblog 0.3</a> de <a href="https://www.suumitsu.eu/">Mitsu</a>, <a href="https://www.ecirtam.net/">Oros</a> et <a href="http://hoa.ro">Arthur Hoaro</a> (Domaine Public)</p>
<p><?php if(defined('FOOTER') && strlen(FOOTER)>0 ){ echo FOOTER; } ?></p> <p><?php if(defined('FOOTER') && strlen(FOOTER)>0 ){ echo FOOTER; } ?></p>
</footer> </footer>
<iframe width="1" height="1" style="display:none" src="xsaf3.php"></iframe> <iframe width="1" height="1" style="display:none" src="xsaf3.php"></iframe>
<script type="text/javascript"> <script type="text/javascript">
<?php if( !empty($_POST['generic']) && !empty($_POST['siteurl']) || empty($_POST['generic']) ) <?php if( !empty($_POST['generic']) && !empty($_POST['siteurl']) || empty($_POST['generic']) )

194
xsaf3.php
View file

@ -17,32 +17,32 @@ $expire = time() -7200 ;
$lockfile = ".xsaflock"; /* defaut delay: 7200 (2 hours) */ $lockfile = ".xsaflock"; /* defaut delay: 7200 (2 hours) */
if (file_exists($lockfile) && filemtime($lockfile) > $expire) { if (file_exists($lockfile) && filemtime($lockfile) > $expire) {
echo "too early"; echo "too early";
die; die;
} }
else { else {
if( file_exists($lockfile) ) if( file_exists($lockfile) )
unlink($lockfile); unlink($lockfile);
if( file_put_contents($lockfile, date(DATE_RFC822)) ===FALSE) { if( file_put_contents($lockfile, date(DATE_RFC822)) ===FALSE) {
echo "Merci d'ajouter des droits d'écriture sur le dossier."; echo "Merci d'ajouter des droits d'écriture sur le dossier.";
die; die;
} }
} }
define('ROOT_DIR', __DIR__); define('ROOT_DIR', __DIR__);
if(file_exists("functions.php")){ if(file_exists("functions.php")){
include "functions.php"; include "functions.php";
}else{ }else{
echo "functions.php not found !"; echo "functions.php not found !";
die; die;
} }
if(file_exists("config.php")){ if(file_exists("config.php")){
include "config.php"; include "config.php";
}else{ }else{
echo "config.php not found !"; echo "config.php not found !";
die; die;
} }
function serverUrl() { function serverUrl() {
@ -55,120 +55,120 @@ libxml_use_internal_errors(true);
// $max_exec_time = temps max d'exécution en seconde // $max_exec_time = temps max d'exécution en seconde
function xsafimport($xsafremote, $max_exec_time) { function xsafimport($xsafremote, $max_exec_time) {
if( DEBUG ) if( DEBUG )
echo "\n*Traitement $xsafremote en maximum $max_exec_time secondes"; echo "\n*Traitement $xsafremote en maximum $max_exec_time secondes";
$max_exec_time+=time()-1; // -1 car l'import prend environ 1 seconde $max_exec_time+=time()-1; // -1 car l'import prend environ 1 seconde
/* détection de ferme autoblog */ /* détection de ferme autoblog */
$json_import = file_get_contents($xsafremote); $json_import = file_get_contents($xsafremote);
if(!empty($json_import)) { if(!empty($json_import)) {
$to_update=array(); $to_update=array();
$json_import = json_decode($json_import, true); $json_import = json_decode($json_import, true);
if(!isset($json_import['meta']) || !isset($json_import['meta']['xsaf-version']) || $json_import['meta']['xsaf-version'] != XSAF_VERSION){ if(!isset($json_import['meta']) || !isset($json_import['meta']['xsaf-version']) || $json_import['meta']['xsaf-version'] != XSAF_VERSION){
if(DEBUG){ if(DEBUG){
echo "\nxsaf-version différentes !"; echo "\nxsaf-version différentes !";
} }
return false; return false;
} }
$get_remote_db = ($json_import['meta']['xsaf-db_transfer'] == "true") ? true : false; $get_remote_db = ($json_import['meta']['xsaf-db_transfer'] == "true") ? true : false;
$get_remote_media = ($json_import['meta']['xsaf-media_transfer'] == "true") ? true : false; $get_remote_media = ($json_import['meta']['xsaf-media_transfer'] == "true") ? true : false;
if(!empty($json_import['autoblogs'])) { if(!empty($json_import['autoblogs'])) {
foreach ($json_import['autoblogs'] as $remote_folder => $value) { foreach ($json_import['autoblogs'] as $remote_folder => $value) {
if(DEBUG) debug('remote = '. $remote_folder); if(DEBUG) debug('remote = '. $remote_folder);
if(count($value)==4 && !empty($value['SITE_TYPE']) && !empty($value['SITE_TITLE']) && !empty($value['SITE_URL']) && !empty($value['FEED_URL'])) { if(count($value)==4 && !empty($value['SITE_TYPE']) && !empty($value['SITE_TITLE']) && !empty($value['SITE_URL']) && !empty($value['FEED_URL'])) {
$sitetype = escape($value['SITE_TYPE']); $sitetype = escape($value['SITE_TYPE']);
$sitename = escape($value['SITE_TITLE']); $sitename = escape($value['SITE_TITLE']);
$siteurl = escape($value['SITE_URL']); $siteurl = escape($value['SITE_URL']);
// Do not use DetectRedirect because it's slow and it has been used when the feed was added // Do not use DetectRedirect because it's slow and it has been used when the feed was added
//$rssurl = DetectRedirect(escape($value['FEED_URL'])); //$rssurl = DetectRedirect(escape($value['FEED_URL']));
$rssurl = escape($value['FEED_URL']); $rssurl = escape($value['FEED_URL']);
} }
/* TOO SLOW /* TOO SLOW
$xml = simplexml_load_file($rssurl); // quick feed check $xml = simplexml_load_file($rssurl); // quick feed check
// ATOM feed && RSS 1.0 /RDF && RSS 2.0 // ATOM feed && RSS 1.0 /RDF && RSS 2.0
$result = (!isset($xml->entry) && !isset($xml->item) && !isset($xml->channel->item)) ? false : true; */ $result = (!isset($xml->entry) && !isset($xml->item) && !isset($xml->channel->item)) ? false : true; */
$result = true; $result = true;
/* autoblog */ /* autoblog */
if( $result === true ) { if( $result === true ) {
$foldername = urlToFolder($siteurl, $rssurl); $foldername = urlToFolder($siteurl, $rssurl);
try { try {
createAutoblog($sitetype, $sitename, $siteurl, $rssurl); createAutoblog($sitetype, $sitename, $siteurl, $rssurl);
if( DEBUG ) { if( DEBUG ) {
echo '<p>autoblog '. $sitename .' crée avec succès (DL DB : '. var_dump($get_remote_db) .' - DL media : '. var_dump($get_remote_media) .') : '. $foldername .'</p>'; echo '<p>autoblog '. $sitename .' crée avec succès (DL DB : '. var_dump($get_remote_db) .' - DL media : '. var_dump($get_remote_media) .') : '. $foldername .'</p>';
if( !ALLOW_REMOTE_DB_DL && !ALLOW_REMOTE_MEDIA_DL ) if( !ALLOW_REMOTE_DB_DL && !ALLOW_REMOTE_MEDIA_DL )
echo '<iframe width="1" height="1" frameborder="0" src="'. urlToFolder( $siteurl, $rssurl ) .'/index.php"></iframe>'; echo '<iframe width="1" height="1" frameborder="0" src="'. urlToFolder( $siteurl, $rssurl ) .'/index.php"></iframe>';
} }
/* ============================================================================================================================================================================== */ /* ============================================================================================================================================================================== */
/* récupération de la DB distante */ /* récupération de la DB distante */
if($get_remote_db == true && ALLOW_REMOTE_DB_DL ) { if($get_remote_db == true && ALLOW_REMOTE_DB_DL ) {
$remote_db = str_replace("?export", $remote_folder."/articles.db", $xsafremote); $remote_db = str_replace("?export", $remote_folder."/articles.db", $xsafremote);
copy($remote_db, './'. $foldername .'/articles.db'); copy($remote_db, './'. $foldername .'/articles.db');
} }
/* préparation à la récupération des médias distants */ /* préparation à la récupération des médias distants */
if($get_remote_media == true && ALLOW_REMOTE_MEDIA_DL ) { if($get_remote_media == true && ALLOW_REMOTE_MEDIA_DL ) {
$remote_media=str_replace("?export", $remote_folder."/?media", $xsafremote); $remote_media=str_replace("?export", $remote_folder."/?media", $xsafremote);
if(DEBUG) if(DEBUG)
debug("Récupération de la liste des médias à $remote_media <br>"); debug("Récupération de la liste des médias à $remote_media <br>");
$json_media_import = file_get_contents($remote_media); $json_media_import = file_get_contents($remote_media);
if(DEBUG) if(DEBUG)
debug($json_media_import); debug($json_media_import);
$media_data = json_decode($json_media_import, true); $media_data = json_decode($json_media_import, true);
if(DEBUG) if(DEBUG)
debug($media_data); debug($media_data);
if(!empty($json_media_import) && $media_data !== null && !empty($media_data['files'])) if(!empty($json_media_import) && $media_data !== null && !empty($media_data['files']))
{ {
file_put_contents('./'. $foldername .'/import.json', $json_media_import); file_put_contents('./'. $foldername .'/import.json', $json_media_import);
} }
} }
/* ============================================================================================================================================================================== */ /* ============================================================================================================================================================================== */
//TODO : tester si articles.db est une DB valide //TODO : tester si articles.db est une DB valide
//$to_update[] = serverUrl().preg_replace("/(.*)\/(.*)$/i","$1/".$foldername , $_SERVER['SCRIPT_NAME']); // url of the new autoblog //$to_update[] = serverUrl().preg_replace("/(.*)\/(.*)$/i","$1/".$foldername , $_SERVER['SCRIPT_NAME']); // url of the new autoblog
} }
catch (Exception $e) { catch (Exception $e) {
if( DEBUG ) if( DEBUG )
echo $e->getMessage(); echo $e->getMessage();
} }
} }
if( DEBUG ) if( DEBUG )
echo '<p>time : '.($max_exec_time - time()) .'</p>'; echo '<p>time : '.($max_exec_time - time()) .'</p>';
if(time() >= $max_exec_time) { if(time() >= $max_exec_time) {
if( DEBUG ) if( DEBUG )
echo "<p>Time out !</p>"; echo "<p>Time out !</p>";
break; break;
} }
} }
} }
else { else {
if( DEBUG ) if( DEBUG )
echo "Format JSON incorrect."; echo "Format JSON incorrect.";
return false; return false;
} }
} }
return; return;
} }
if( DEBUG ) echo '<html><body>'; if( DEBUG ) echo '<html><body>';
if( ALLOW_NEW_AUTOBLOGS and ALLOW_NEW_AUTOBLOGS_BY_XSAF && !empty($friends_autoblog_farm) ) { if( ALLOW_NEW_AUTOBLOGS and ALLOW_NEW_AUTOBLOGS_BY_XSAF && !empty($friends_autoblog_farm) ) {
foreach( $friends_autoblog_farm AS $value ) { foreach( $friends_autoblog_farm AS $value ) {
if( !empty($value) ) if( !empty($value) )
xsafimport($value, EXEC_TIME); xsafimport($value, EXEC_TIME);
} }
if(DEBUG) echo "<p>XSAF import finished</p>"; if(DEBUG) echo "<p>XSAF import finished</p>";
} }
elseif( DEBUG ) elseif( DEBUG )
echo "<p>XSAF désactivé. Positionnez les variables ALLOW_NEW_AUTOBLOGS et ALLOW_NEW_AUTOBLOGS_BY_XSAF à TRUE dans le fichier config.php pour l'activer.</p>"; echo "<p>XSAF désactivé. Positionnez les variables ALLOW_NEW_AUTOBLOGS et ALLOW_NEW_AUTOBLOGS_BY_XSAF à TRUE dans le fichier config.php pour l'activer.</p>";
if( DEBUG ) echo '</body></html>'; if( DEBUG ) echo '</body></html>';
?> ?>