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
/*
VroumVroumBlog 0.3.0
This blog automatically publishes articles from an external RSS 2.0 or ATOM feed.
VroumVroumBlog 0.3.0
This blog automatically publishes articles from an external RSS 2.0 or ATOM 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 valid UTF-8
- Source feed MUST contain article body
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 valid UTF-8
- 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';
if (!version_compare(phpversion(), '5.3.0', '>='))
@ -226,23 +226,23 @@ class VroumVroum_Blog
if ($create_articles_db)
{
$this->articles->exec('
CREATE TABLE articles (
id INTEGER PRIMARY KEY,
feed_id TEXT,
title TEXT,
uri TEXT,
url TEXT,
date INT,
content TEXT
);
CREATE TABLE update_log (
date INT PRIMARY KEY,
success INT,
log TEXT
);
CREATE UNIQUE INDEX feed_id ON articles (feed_id);
CREATE INDEX date ON articles (date);
');
CREATE TABLE articles (
id INTEGER PRIMARY KEY,
feed_id TEXT,
title TEXT,
uri TEXT,
url TEXT,
date INT,
content TEXT
);
CREATE TABLE update_log (
date INT PRIMARY KEY,
success INT,
log TEXT
);
CREATE UNIQUE INDEX feed_id ON articles (feed_id);
CREATE INDEX date ON articles (date);
');
}
$this->articles->createFunction('countintegers', array($this, 'sql_countintegers'));
@ -256,7 +256,7 @@ class VroumVroum_Blog
protected function log_update($success, $log = '')
{
$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
$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);
$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($uri).'\', \''.$this->articles->escapeString($url).'\',
\''.(int)$date.'\', \''.$this->articles->escapeString($content).'\');');
\''.$this->articles->escapeString($feed_id).'\', \''.$this->articles->escapeString($title).'\',
\''.$this->articles->escapeString($uri).'\', \''.$this->articles->escapeString($url).'\',
\''.(int)$date.'\', \''.$this->articles->escapeString($content).'\');');
$id = $this->articles->lastInsertRowId();
@ -304,8 +304,8 @@ class VroumVroum_Blog
$content = $this->mirrorMediasForArticle($content, $url);
$this->articles->exec('UPDATE articles SET title=\''.$this->articles->escapeString($title).'\',
url=\''.$this->articles->escapeString($url).'\', content=\''.$this->articles->escapeString($content).'\',
date=\''.(int)$date.'\' WHERE id = \''.(int)$id.'\';');
url=\''.$this->articles->escapeString($url).'\', content=\''.$this->articles->escapeString($content).'\',
date=\''.(int)$date.'\' WHERE id = \''.(int)$id.'\';');
$title = self::removeHTML($title);
$content = self::removeHTML($content);
@ -456,9 +456,9 @@ class VroumVroum_Blog
break;
} /* first element empty: import finished */
$time = time();
}
}
unlink('import.lock');
}
}
}
public function listArticlesByPage($page = 1)
@ -500,11 +500,11 @@ class VroumVroum_Blog
public function searchArticles($query)
{
$res = $this->articles->query('SELECT id, uri, title, content
FROM articles
WHERE content LIKE \'%'.$this->articles->escapeString($query).'%\'
OR title LIKE \'%'.$this->articles->escapeString($query).'%\'
ORDER BY id DESC
LIMIT 0,100;');
FROM articles
WHERE content LIKE \'%'.$this->articles->escapeString($query).'%\'
OR title LIKE \'%'.$this->articles->escapeString($query).'%\'
ORDER BY id DESC
LIMIT 0,100;');
$out = array();
@ -525,7 +525,7 @@ class VroumVroum_Blog
}
$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);
$from = parse_url($url);
@ -603,36 +603,36 @@ if (isset($_GET['feed'])) // FEED
{
header('Content-Type: application/atom+xml; charset=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">
<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>';
<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 '
<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>
<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['url']).'">source</a>)<br />'.escape_content($art['content']).']]>
</content>
</entry>';
<content type="html">
<![CDATA[(<a href="'.escape($art['url']).'">source</a>)<br />'.escape_content($art['content']).']]>
</content>
</entry>';
}
echo '
</feed>';
</feed>';
exit;
}
@ -640,7 +640,7 @@ if (isset($_GET['opml'])) // OPML
{
//header('Content-Type: application/octet-stream');
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->addAttribute('version', '1.0');
$opmlhead = $opmlfile->addChild('head');
@ -662,7 +662,7 @@ if (isset($_GET['media'])) // MEDIA
header('Content-Type: application/json');
if(is_dir(MEDIA_DIR))
{
$url = str_replace('?media', 'media/', LOCAL_URL);
$url = str_replace('?media', 'media/', LOCAL_URL);
$files = scandir(MEDIA_DIR);
unset($files[0]); // .
unset($files[1]); // ..
@ -693,125 +693,125 @@ if (!$search && !empty($_SERVER['QUERY_STRING']) && !is_numeric($_SERVER['QUERY_
// common CSS
$css='* { margin: 0; padding: 0; }
body { font-family:sans-serif; background-color: #efefef; padding: 1%; color: #333; }
img { max-width: 100%; height: auto; }
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 > article > header { margin-bottom: 1em; }
body > article > header h2 a:hover { color:#403976; }
body > article h4 { font-weight: normal; font-size: small; color: #666; }
body > article .source a { color: #666; }
body > header > form { float:right; }
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 strong { font-size: 1.2em; color: #333; }
body > nav a { color:#000; margin: 0 0.5em; }
body > nav a:hover { color:#333; }
body > footer a { color:#000; }
body > footer a:hover { color:#333; }
.content ul, .content ol { margin-left: 2em; }
.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 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 h1 { font-size: 1.5em; }
.content h2 { font-size: 1.4em;color:#000; }
.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; }
body { font-family:sans-serif; background-color: #efefef; padding: 1%; color: #333; }
img { max-width: 100%; height: auto; }
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 > article > header { margin-bottom: 1em; }
body > article > header h2 a:hover { color:#403976; }
body > article h4 { font-weight: normal; font-size: small; color: #666; }
body > article .source a { color: #666; }
body > header > form { float:right; }
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 strong { font-size: 1.2em; color: #333; }
body > nav a { color:#000; margin: 0 0.5em; }
body > nav a:hover { color:#333; }
body > footer a { color:#000; }
body > footer a:hover { color:#333; }
.content ul, .content ol { margin-left: 2em; }
.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 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 h1 { font-size: 1.5em; }
.content h2 { font-size: 1.4em;color:#000; }
.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; }
';
switch($site_type) {
case 'microblog':
case 'twitter':
$css .= "\n".' /* twitter/microblog style */
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 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 .source { font-size: 0.8em; color: #666; }
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;}';
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 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 .source { font-size: 0.8em; color: #666; }
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;}';
break;
case 'shaarli':
$css .= "\n".' /* shaarli style */
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 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 footer.source { margin-top:1em;font-size: 0.8em; color: #666; }
body > footer { text-align:center; font-size: small; color:#333; clear: both; }';
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 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 footer.source { margin-top:1em;font-size: 0.8em; color: #666; }
body > footer { text-align:center; font-size: small; color:#333; clear: both; }';
break;
case 'generic':
case 'youtube':
default:
$css .= "\n".' /* youtube style */
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 a { color:#000; text-decoration:none; }
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 > footer { text-align:center; font-size: small; color:#333; clear: both; }';
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 a { color:#000; text-decoration:none; }
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 > footer { text-align:center; font-size: small; color:#333; clear: both; }';
}
// HTML HEADER
echo '<!DOCTYPE html>
<html lang="fr" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="utf-8" />
<title>'.escape($config->site_title).'</title>
<link rel="canonical" href="'.escape($config->site_url).'">
<link rel="alternate" type="application/atom+xml" title="'.__('ATOM Feed').'" href="?feed">
<style type="text/css" media="screen,projection">
'.$css.'
</style>';
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="utf-8" />
<title>'.escape($config->site_title).'</title>
<link rel="canonical" href="'.escape($config->site_url).'">
<link rel="alternate" type="application/atom+xml" title="'.__('ATOM Feed').'" href="?feed">
<style type="text/css" media="screen,projection">
'.$css.'
</style>';
if( $vvb->mustUpdateXsaf()) {
echo ' <meta http-equiv="Refresh" content="1">';
}
echo '
</head>
<body>
<header>
<h1><a href="../../" style="font-size:0.8em;">PROJET AUTOBLOG'. (strlen(HEAD_TITLE) > 0 ? ' ~ '. HEAD_TITLE : '') .'</a></h1>
<hr />
<h1><a href="./">'.escape($config->site_title).'</a></h1>';
</head>
<body>
<header>
<h1><a href="../../" style="font-size:0.8em;">PROJET AUTOBLOG'. (strlen(HEAD_TITLE) > 0 ? ' ~ '. HEAD_TITLE : '') .'</a></h1>
<hr />
<h1><a href="./">'.escape($config->site_title).'</a></h1>';
if (!empty($config->site_description))
echo '
<p>'.$config->site_description.'</p>
<p><a href="../../">&lArr; retour index</a></p>';
<p>'.$config->site_description.'</p>
<p><a href="../../">&lArr; retour index</a></p>';
echo '
<form method="get" action="'.escape(LOCAL_URL).'">
<input type="search" name="q" value="'.escape($search).'" />
<input type="submit" value="'.__('Search').'" />
</form>
</header>
<form method="get" action="'.escape(LOCAL_URL).'">
<input type="search" name="q" value="'.escape($search).'" />
<input type="submit" value="'.__('Search').'" />
</form>
</header>
';
if( $vvb->mustUpdateXsaf()) {
echo '
<article>
<header>
<h2>'.__('Update').'</h2>
</header>
<div class="content" id="update">
'.__('Import running: '). $vvb->getXsafCounter() . __(' files remaining').'<br>
'.__('The page should refresh every second. If not, <a href="javascript:window.location.reload()">refresh manually</a>.').'
</div>
</article>';
<article>
<header>
<h2>'.__('Update').'</h2>
</header>
<div class="content" id="update">
'.__('Import running: '). $vvb->getXsafCounter() . __(' files remaining').'<br>
'.__('The page should refresh every second. If not, <a href="javascript:window.location.reload()">refresh manually</a>.').'
</div>
</article>';
}
elseif ($vvb->mustUpdate())
{
echo '
<article>
<header>
<h2>'.__('Update').'</h2>
</header>
<div class="content" id="update">
'.__('Updating database... Please wait.').'
</div>
</article>';
<article>
<header>
<h2>'.__('Update').'</h2>
</header>
<div class="content" id="update">
'.__('Updating database... Please wait.').'
</div>
</article>';
}
if (!empty($search))
@ -819,22 +819,22 @@ if (!empty($search))
$results = $vvb->searchArticles($search);
$text = sprintf(__('<strong>%d</strong> results for <em>%s</em>'), count($results), escape($search));
echo '
<article id="results">
<header>
<h2>'.__('Search').'</h2>
'.$text.'
</header>
<article>';
<article id="results">
<header>
<h2>'.__('Search').'</h2>
'.$text.'
</header>
<article>';
foreach ($results as $art)
{
echo '
<article class="result">
<header>
<h3><a href="./?'.escape($art['uri']).'">'.escape($art['title']).'</a></h3>
</header>
<p>'.$art['content'].'</p>
</article>';
<article class="result">
<header>
<h3><a href="./?'.escape($art['uri']).'">'.escape($art['title']).'</a></h3>
</header>
<p>'.$art['content'].'</p>
</article>';
}
}
elseif (!is_null($article))
@ -842,13 +842,13 @@ elseif (!is_null($article))
if (!$article)
{
echo '
<article>
<header>
<h2>'.__('Not Found').'</h2>
'.(!empty($uri) ? '<p><tt>'.escape($vvb->getLocalURL($uri)) . '</tt></p>' : '').'
'.__('Article not found.').'
</header>
</article>';
<article>
<header>
<h2>'.__('Not Found').'</h2>
'.(!empty($uri) ? '<p><tt>'.escape($vvb->getLocalURL($uri)) . '</tt></p>' : '').'
'.__('Article not found.').'
</header>
</article>';
}
else
{
@ -888,12 +888,12 @@ else
}
echo '
<footer>
<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>
</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>'.__('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>
</footer>';
if( $vvb->mustUpdateXsaf() ) {
try {
@ -911,9 +911,9 @@ if( $vvb->mustUpdateXsaf() ) {
catch (VroumVroum_Feed_Exception $e)
{
echo '
<div id="error">
'.escape($e->getMessage()).'
</div>';
<div id="error">
'.escape($e->getMessage()).'
</div>';
$updated = 0;
}
}
@ -934,34 +934,34 @@ elseif ($vvb->mustUpdate())
catch (VroumVroum_Feed_Exception $e)
{
echo '
<div id="error">
'.escape($e->getMessage()).'
</div>';
<div id="error">
'.escape($e->getMessage()).'
</div>';
$updated = 0;
}
if ($updated > 0)
{
echo '
<script type="text/javascript">
window.onload = function () {
document.getElementById("update").innerHTML = "'.__('Update complete!').' <a href=\\"#reload\\" onclick=\\"window.location.reload();\\">'.__('Click here to reload this webpage.').'</a>";
};
</script>';
<script type="text/javascript">
window.onload = function () {
document.getElementById("update").innerHTML = "'.__('Update complete!').' <a href=\\"#reload\\" onclick=\\"window.location.reload();\\">'.__('Click here to reload this webpage.').'</a>";
};
</script>';
}
else
{
echo '
<script type="text/javascript">
window.onload = function () {
document.body.removeChild(document.getElementById("update").parentNode);
};
</script>';
<script type="text/javascript">
window.onload = function () {
document.body.removeChild(document.getElementById("update").parentNode);
};
</script>';
}
}
echo '
</body>
</body>
</html>';
@ -977,14 +977,14 @@ function display_article($article)
{
global $vvb, $config;
echo '
<article>
<header>
<h2><a href="'.$vvb->getLocalURL($article).'">'.escape($article['title']).'</a></h2>
'.strftime(__('_date_format'), $article['date']).'
</header>
<div class="content">'.escape_content($article['content']).'</div>
<footer class="source"><p>'.__('Source:').' <a href="'.escape($article['url']).'">'.escape($article['url']).'</a></p></footer>
</article>';
<article>
<header>
<h2><a href="'.$vvb->getLocalURL($article).'">'.escape($article['title']).'</a></h2>
'.strftime(__('_date_format'), $article['date']).'
</header>
<div class="content">'.escape_content($article['content']).'</div>
<footer class="source"><p>'.__('Source:').' <a href="'.escape($article['url']).'">'.escape($article['url']).'</a></p></footer>
</article>';
}
?>

View file

@ -35,9 +35,9 @@
* twitter2feed : https://github.com/mitsukarenai/twitter2feed
* rss-bridge : https://github.com/sebsauvage/rss-bridge
* replace LOCAL with:
- 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 leave LOCAL to use the included twitter2feed.php.
- 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 leave LOCAL to use the included twitter2feed.php.
* set to FALSE if you want to fully disable Twitter support
**/
// define( 'API_TWITTER', 'LOCAL' );
@ -51,4 +51,7 @@ $friends_autoblog_farm = array(
// 'http://autoblog.suumitsu.eu/?export',
// 'http://streisand.hoa.ro/?export',
);
$myOptions['enableThumbShot'] = true;
$myOptions['externalThumbSdhot'] = 'http://soshot.knah-tsaeb.org/?key=apikey&s=m&url=';
?>

View file

@ -96,7 +96,24 @@ function escape($str) {
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 )) {
$var = updateType( $siteurl );
$type = $var['type'];
@ -114,6 +131,7 @@ function createAutoblog($type, $sitename, $siteurl, $rssurl) {
if ( mkdir($foldername, 0755, false) ) {
$fp = fopen($foldername .'/index.php', 'w+');
if( !fwrite($fp, "<?php require_once '../autoblog.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_TITLE="'. $sitename .'"
SITE_DESCRIPTION="Site original : <a href=\''. $siteurl .'\'>'. $sitename .'</a>"
SITE_META_DESCRIPTION="'.$siteDesc.'"
SITE_URL="'. $siteurl .'"
FEED_URL="'. $rssurl .'"
ARTICLES_PER_PAGE="'. getArticlesPerPage( $type ) .'"
@ -194,6 +213,24 @@ function debug($data)
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)
{
switch ($str)

View file

@ -209,8 +209,8 @@ function svg_status($fill, $text, $back)
$oldvalue = null;
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)) /* errorlog existe encore ? se contenter de lire sa taille pour avoir le statut */
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(filesize($errorlog) == "0") {die($svg_ok);}
else if(filesize($errorlog) == "1") {die($svg_mv);}
@ -442,7 +442,7 @@ if( isset($_GET['updateall']) ) {
$antibot = generate_antibot();
$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="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="submit" value="Vérifier">
</form>';
@ -494,6 +494,7 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG
$sitename = get_title_from_datafeed($datafeed);
$sitetype = updateType($siteurl);
$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 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 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>
<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>';
}
else {
@ -577,7 +579,7 @@ if( !empty($_POST['socialinstance']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLO
try {
$headers = get_headers($rssurl, 1);
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);
$success[] = '<iframe width="1" height="1" frameborder="0" src="'. urlToFolder( $siteurl, $rssurl ) .'/index.php"></iframe>
@ -589,7 +591,7 @@ if( !empty($_POST['socialinstance']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLO
}
}
else
$error[] = 'Antibot : chiffres incorrects.';
$error[] = 'Antibot : chiffres incorrects.';
}
/**
@ -599,9 +601,9 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L
if(empty($_POST['rssurl']))
{$error[] = "Veuillez entrer l'adresse du flux.";}
if(empty($_POST['number']) || empty($_POST['antibot']) )
{$error[] = "Vous êtes un bot ?";}
{$error[] = "Vous êtes un bot ?";}
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)) {
try {
@ -629,6 +631,7 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L
$sitetype = 'generic';
$siteurl = get_link_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 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['number']) || empty($_POST['antibot']) )
{$error[] = "Vous êtes un bot ?";}
{$error[] = "Vous êtes un bot ?";}
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 (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['number']) || empty($_POST['antibot']) )
{$error[] = "Vous êtes un bot ?";}
{$error[] = "Vous êtes un bot ?";}
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'] ))
{$error[] = 'Le lien est incorrect.';}
@ -741,10 +744,10 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<h2>Mise à jour</h2>
</header>
<p>Une mise à jour du Projet Autoblog est disponible !</p>
<p>Une mise à jour du Projet Autoblog est disponible !</p>
<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; <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; <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>
</ul>
</section>
<?php } ?>
@ -756,7 +759,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<?php
if( !empty( $error ) || !empty( $success )) {
echo '<p>Message'. (count($error) ? 's' : '') ." :</p>\n";
echo '<p>Message'. (count($error) ? 's' : '') ." :</p>\n";
echo " <ul>\n";
foreach ( $error AS $value ) {
echo ' <li class="error">'. $value ."</li>\n";
@ -769,7 +772,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
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)
$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) {
@ -791,7 +794,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<h3>Ajouter un site web</h3>
</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"; ?>
</section>
@ -815,7 +818,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<input type="radio" name="socialinstance" value="statusnet" />
<input placeholder="statusnet.personnel.com" type="text" name="statusneturl" id="statusneturl" /><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="submit" value="Créer" />
</form>
@ -828,7 +831,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<form method="POST">
<input type="hidden" name="socialinstance" value="shaarli" />
<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="submit" value="Créer" />
</form>
@ -843,7 +846,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 : é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='submit' value='Importer' />
</form>
@ -858,7 +861,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 : é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="submit" value="Envoyer" />
</form>
@ -929,7 +932,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
// et on envoie le fichier statique à la place
} else {
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">
@ -987,8 +990,18 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
<img width="15" height="15" alt="" src="./?check='.$key.'" />
<h3>'.escape($autoblog->site_title).'</h3>
</a>
</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>
</header>';
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>';
}
}