diff --git a/.gitignore b/.gitignore index 79c93a2..2ac4f7c 100755 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,15 @@ config.php .versionlock .xsaflock +.updatealllock resources/rss.xml resources/rss.json .project resources/user.css autoblogs/* !autoblogs/autoblog.php +docs/* +!docs/docs.txt +robots.txt +.idea +cache_* diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..a91b07e --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,34 @@ +LICENCE +=============== + +- domaine public + +LICENSE +=============== + +- public domain + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/README.md b/README.md index 02d5b2e..66f8f11 100755 --- a/README.md +++ b/README.md @@ -1,23 +1,42 @@ + Projet Autoblog =============== -Création, gestion et échange de blogs automatiques contre la censure (à propos: http://sebsauvage.net/streisand.me/fr/ ). +> This project is historically in French. See [our english README](https://github.com/mitsukarenai/Projet-Autoblog/wiki/Autoblog-Project). + +Réplication automatique de contenu à partir de flux RSS/Atom, avec partage des ajouts entre les fermes d'Autoblog. + +L'objectif premier du projet Autoblog est de lutter contre la censure et toute autre forme de pression allant à l'encontre de la liberté d'expression en favorisant l'[effet Streisand](http://fr.wikipedia.org/wiki/Effet_Streisand). + +Le projet a été initialement lancé par Sébastien Sauvage : [plus d'info par ici](http://sebsauvage.net/streisand.me/fr/). + +Exemples d'instances : +- [autoblog.suumitsu.eu](http://autoblog.suumitsu.eu/) +- [streisand.hoa.ro](http://streisand.hoa.ro/) +- [ecirtam.net](https://ecirtam.net/autoblogs/) +- [autoblog.ohax.fr](http://autoblog.ohax.fr/) +- [flamby.aldarone.fr](http://flamby.aldarone.fr/) +- [tcit.fr](http://www.tcit.fr/streisand/) +- [kaelsitoo.fr](http://kaelsitoo.fr/autoblog/) +- [autoblog.postblue.info](http://autoblog.postblue.info/) + Serie 0.3 par [Mitsu](https://github.com/mitsukarenai/), [Oros](https://github.com/Oros42), [Arthur Hoaro](https://github.com/ArthurHoaro). -Nouveautés majeures +![logo](https://raw.github.com/mitsukarenai/Projet-Autoblog/master/resources/icon-logo.png) +Fonctionnalités majeures =================== -- "ferme" d'autoblogs avec ajout facile par différents formulaires (générique, microblogging, OPML, marque-pages) -- échange de références entre fermes avec XSAF (Cross-Site Autoblog Farming) -- vérification du statut des sites distants, et flux de suivi des changements -- export facile des références, articles et médias -- contrôle de version et alerte de mise à jour -- apparence de l'autoblog selon son type -- CSS utilisateur personnalisable -- hébergement de documents spécifiques +- Ferme d'autoblogs avec ajout facile par différents formulaires (générique, microblogging, OPML, marque-pages). +- Échange de références entre fermes avec XSAF ([Cross-Site Autoblog Farming](https://github.com/mitsukarenai/Projet-Autoblog/wiki/XSAF---Cross-Site-Autoblog-Farming)). +- Vérification du statut des sites distants, et flux de suivi des changements. +- Export des références, articles et médias. +- Contrôle de version de la ferme et alerte de mise à jour. +- Identification du type d'autoblog. +- CSS utilisateur personnalisable. +- Hébergement de documents divers (PDF, images, réplique de site web, etc.). -Branches : +Branches =================== - [master](https://github.com/mitsukarenai/Projet-Autoblog/tree/master/) _(développement)_ : Autoblog Project serie 0.3 par Mitsu, Oros, Arthur Hoaro @@ -28,4 +47,36 @@ Branches : Pré-requis techniques ===================== -- serveur web avec PHP 5.3 et son support SQLite +- Serveur web (Apache, nginx, etc.) +- PHP 5.3 ou supérieur +- Support SQLite 3 pour PHP + +Documentation +===================== + +La documentation du projet est sur le [Wiki du repo](https://github.com/mitsukarenai/Projet-Autoblog/wiki). + +Accès hors ligne : `git clone https://github.com/mitsukarenai/Projet-Autoblog.wiki.git` + +Licence +===================== + +Domaine public. + +Changelog +===================== +- 2014-02-12 MILESTONE 0.3.2 + - separate type icons + - cache added + - pagination fixes + - SVG fixes + - fix date() warnings + - bugfixes +- 2013-10-14 MILESTONE 0.3.1 + - code semantics + - "docs" filesize + - robots.txt + - bugfixes +- 2013-07-30 + - twitter2feed.php fixed (regex on class "avatar"; ``````) +- 2013-07-22 MILESTONE 0.3 diff --git a/autoblogs/autoblog.php b/autoblogs/autoblog.php index 3421829..9b9031d 100644 --- a/autoblogs/autoblog.php +++ b/autoblogs/autoblog.php @@ -8,7 +8,7 @@ - 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', '>=')) @@ -41,7 +41,7 @@ if (!defined('MEDIA_DIR')) define('MEDIA_DIR', ROOT_DIR . '/media'); if (!defined('LOCAL_URL')) { // Automagic URL discover - define('LOCAL_URL', 'http' . (!empty($_SERVER['HTTPS']) ? 's' : '')."://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"); + define('LOCAL_URL', 'http' . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '')."://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"); } if (!defined('LOCAL_URI')) @@ -121,7 +121,7 @@ function exception_handler($e) exit; } - $error = "Error happened !\n\n". + $error = "Error happened!\n\n". $e->getCode()." - ".$e->getMessage()."\n\nIn: ". $e->getFile() . ":" . $e->getLine()."\n\n"; @@ -328,6 +328,11 @@ class VroumVroum_Blog return true; } + + public function mustUpdateXsaf() + { + return file_exists('import.json'); + } protected function _getStreamContext() { @@ -375,9 +380,12 @@ class VroumVroum_Blog { $date = isset($item->published) ? (string) $item->published : (string) $item->updated; $guid = !empty($item->id) ? (string)$item->id : (string)$item->link['href']; - + + if( count($item->content->children()) > 0 ) $content = (string)$item->content->asXML(); + else $content = (string)$item->content; + $id = $this->insertOrUpdateArticle($guid, (string)$item->title, - (string)$item->link['href'], strtotime($date), (string)$item->content); + (string)$item->link['href'], strtotime($date), $content ); if ($id !== false) $updated++; @@ -425,6 +433,34 @@ class VroumVroum_Blog return $updated; } + + public function updateXsaf() { + if($this->mustUpdateXsaf()) { + $json = json_decode(file_get_contents('import.json'), true); + $count = count($json['files']); + file_put_contents('import.lock', $count); /* one-process locking */ + $remoteurl = $json['url']; + if (!file_exists('media')) { + mkdir('media'); + } + $time = time(); + $maxtime = $time + 3; /* max exec time: 3 seconds */ + + while ($time <= $maxtime) { + $file = array_shift($json['files']); /* get first element while unstacking */ + if(!empty($file)) { + $this->_copy($remoteurl.$file, "media/$file"); + file_put_contents('import.json', json_encode($json)); + } + else { + unlink('import.json'); + break; + } /* first element empty: import finished */ + $time = time(); + } + unlink('import.lock'); + } + } public function listArticlesByPage($page = 1) { @@ -467,6 +503,7 @@ class VroumVroum_Blog $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;'); @@ -537,6 +574,13 @@ class VroumVroum_Blog } return $content; } + + public function getXsafCounter() { + if($this->mustUpdateXsaf()) { + $json = json_decode(file_get_contents('import.json'), true); + return count($json['files']); + } + } /* copy() is buggy with http streams and safe_mode enabled (which is bad), so here's a workaround */ protected function _copy($from, $to) @@ -583,7 +627,7 @@ if (isset($_GET['feed'])) // FEED '.date(DATE_ATOM, $art['date']).' - source)
'.escape_content($art['content']).']]> + source)
'.escape_content($art['content']).']]>
'; } @@ -649,6 +693,7 @@ if (!$search && !empty($_SERVER['QUERY_STRING']) && !is_numeric($_SERVER['QUERY_ } // common CSS +<<<<<<< HEAD $css=' * { margin: 0; padding: 0; } body { font-family:sans-serif; background-color: #efefef; padding: 1%; color: #333; } img { max-width: 100%; height: auto; } @@ -676,48 +721,108 @@ $css=' * { margin: 0; padding: 0; } .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; } +||||||| merged common ancestors +$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; } + .header a { text-decoration: none; color: #000;font-weight:bold; } + .header { text-align:center; padding: 30px 3%; max-width:70em;margin:0 auto; } + .article .title { margin-bottom: 1em; } + .article .title h2 a:hover { color:#403976; } + .article h4 { font-weight: normal; font-size: small; color: #666; } + .article .source a { color: #666; } + .searchForm { float:right; } + .searchForm input { } + .pagination { background-color:white;padding: 12px 10px 12px 10px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; } + .pagination b { font-size: 1.2em; color: #333; } + .pagination a { color:#000; margin: 0 0.5em; } + .pagination a:hover { color:#333; } + .footer a { color:#000; } + .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; } +======= +$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; } +>>>>>>> master '; -if($site_type == 'generic') // custom CSS for generic - { - $css = $css.'.header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px;text-transform:uppercase; } - .article .title h2 { margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; } - .article .title h2 a { color:#000; text-decoration:none; } - .article .source { font-size: 0.8em; color: #666; } - .article { background-color:white;padding: 12px 10px 12px 10px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; } - .footer { text-align:center; font-size: small; color:#333; clear: both; }'; - } - else if($site_type == 'microblog' || $site_type == 'twitter' || $site_type == 'identica') // custom CSS for microblog - { - $css = $css.'.header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px; } - .article .title 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; } - .article .title h2 a { color:#333; text-decoration:none; } - .article { background-color:white;padding: 12px 10px 12px 10px;border:1px solid #aaa;max-width:70em;margin:0 auto;box-shadow:0px 5px 7px #aaa; } - .article .source { font-size: 0.8em; color: #666; } - .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;}'; - } - else if($site_type == 'shaarli') // custom CSS for shaarli - { - $css = $css.'.header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px; } - .article .title h2 { margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; } - .article .title h2 a { color:#000; text-decoration:none; } - .article { background-color:white;padding: 12px 10px 12px 10px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; } - .article .source { margin-top:1em;font-size: 0.8em; color: #666; } - .footer { text-align:center; font-size: small; color:#333; clear: both; }'; - } - +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;}'; + 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; }'; + 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; }'; +} // HTML HEADER -echo ' - - - - +echo ' + + + '.escape($config->site_title).' @@ -731,66 +836,111 @@ if (!empty($config->site_description)){ echo '

'.$config->site_description.'
⇐ retour index

'; } echo '

'.$config->site_meta_description.'

'; +||||||| merged common ancestors + '.$css.' + + + +
+

PROJET AUTOBLOG'. (strlen(HEAD_TITLE) > 0 ? ' ~ '. HEAD_TITLE : '') .'

+
+

'.escape($config->site_title).'

'; + +if (!empty($config->site_description)) + echo '

'.$config->site_description.'
⇐ retour index

'; + +======= + '.$css.' + '; + if( $vvb->mustUpdateXsaf()) { + echo ' '; + } echo ' -
-
- - -
-
-
+ + +
+

PROJET AUTOBLOG'. (strlen(HEAD_TITLE) > 0 ? ' ~ '. HEAD_TITLE : '') .'

+
+

'.escape($config->site_title).'

'; + + if (!empty($config->site_description)) + echo ' +

'.$config->site_description.'

+

⇐ retour index

'; + +>>>>>>> master +echo ' +
+ + +
+
'; -if ($vvb->mustUpdate()) +if( $vvb->mustUpdateXsaf()) { + echo ' +
+
+

'.__('Update').'

+
+
+ '.__('Import running: '). $vvb->getXsafCounter() . __(' files remaining').'
+ '.__('The page should refresh every second. If not, refresh manually.').' +
+
'; +} +elseif ($vvb->mustUpdate()) { echo ' -
-
-

'.__('Update').'

-
-
- '.__('Updating database... Please wait.').' -
-
'; +
+
+

'.__('Update').'

+
+
+ '.__('Updating database... Please wait.').' +
+
'; } if (!empty($search)) { $results = $vvb->searchArticles($search); - $text = sprintf(__('%d results for %s'), count($results), escape($search)); + $text = sprintf(__('%d results for %s'), count($results), escape($search)); echo ' -
-
-

'.__('Search').'

- '.$text.' -
-
'; +
+
+

'.__('Search').'

+ '.$text.' +
+
'; foreach ($results as $art) { echo ' -
-

'.escape($art['title']).'

-

'.$art['content'].'

-
'; + '; } } elseif (!is_null($article)) { if (!$article) { - echo ' -
-
-

'.__('Not Found').'

- '.(!empty($uri) ? '

'.escape($vvb->getLocalURL($uri)) . '

' : '').' - '.__('Article not found.').' -
-
'; + echo ' +
+
+

'.__('Not Found').'

+ '.(!empty($uri) ? '

'.escape($vvb->getLocalURL($uri)) . '

' : '').' + '.__('Article not found.').' +
+
'; } else { - display_article($article); + display_article($article); } } else @@ -808,35 +958,54 @@ else } $max = $vvb->countArticles(); - if ($max > $config->articles_per_page) - { - echo ''; + echo ' '; } } echo ' -'; + '; -if ($vvb->mustUpdate()) +if( $vvb->mustUpdateXsaf() ) { + try { + ob_end_flush(); + flush(); + } + catch (Exception $e) + { + // Silent, not critical + } + + try { + $updated = $vvb->updateXsaf(); + } + catch (VroumVroum_Feed_Exception $e) + { + echo ' +
+ '.escape($e->getMessage()).' +
'; + $updated = 0; + } +} +elseif ($vvb->mustUpdate()) { try { ob_end_flush(); @@ -853,34 +1022,34 @@ if ($vvb->mustUpdate()) catch (VroumVroum_Feed_Exception $e) { echo ' -
+
'.escape($e->getMessage()).' -
'; +
'; $updated = 0; } if ($updated > 0) { echo ' - '; + '; } else { echo ' - '; + '; } } echo ' - + '; @@ -896,15 +1065,14 @@ function display_article($article) { global $vvb, $config; echo ' -
-
-

'.escape($article['title']).'

- '.strftime(__('_date_format'), $article['date']).' -
-
'.escape_content($article['content']).'
-

'.__('Source:').' '.escape($article['url']).'

-
-
'; + '; } ?> diff --git a/config.php b/config.php deleted file mode 100755 index 8d9be9c..0000000 --- a/config.php +++ /dev/null @@ -1,46 +0,0 @@ -SebSauvage et Bohwaz.'); - -define( 'ALLOW_FULL_UPDATE', TRUE ); -define( 'ALLOW_CHECK_UPDATE', TRUE ); - -/** - * If you set ALLOW_NEW_AUTOBLOGS to FALSE, the following options do not matter. - **/ -define( 'ALLOW_NEW_AUTOBLOGS', false ); -// define( 'ALLOW_NEW_AUTOBLOGS_BY_LINKS', TRUE ); -// define( 'ALLOW_NEW_AUTOBLOGS_BY_SOCIAL', TRUE ); -// define( 'ALLOW_NEW_AUTOBLOGS_BY_BUTTON', TRUE ); -// define( 'ALLOW_NEW_AUTOBLOGS_BY_OPML_FILE', TRUE ); -// define( 'ALLOW_NEW_AUTOBLOGS_BY_OPML_LINK', TRUE ); -// define( 'ALLOW_NEW_AUTOBLOGS_BY_XSAF', TRUE ); - -/** - * More about TwitterBridge : https://github.com/mitsukarenai/twitterbridge - **/ -// define( 'API_TWITTER', FALSE ); - -/** - * Import autoblogs from friend's autoblog farm - Add a link to the JSON export - **/ -$friends_autoblog_farm = array( - 'https://raw.github.com/mitsukarenai/xsaf-bootstrap/master/3.json', - 'https://www.ecirtam.net/autoblogs/?export', - 'https://autoblog.suumitsu.eu/?export', - 'http://streisand.hoa.ro/?export' -); - -$myOptions['enableThumbShot'] = true; -$myOptions['externalThumbSdhot'] = 'http://soshot.knah-tsaeb.org/?key=3400affe9919&s=m&url='; -?> \ No newline at end of file diff --git a/config.php.example b/config.php.example new file mode 100644 index 0000000..4c8a652 --- /dev/null +++ b/config.php.example @@ -0,0 +1,57 @@ +SebSauvage et Bohwaz.'); + +// define( 'DOCS_CACHE_DURATION', 1800); +// define( 'AUTOBLOGS_CACHE_DURATION', 1800); + +// define( 'ALLOW_FULL_UPDATE', TRUE ); +// define( 'ALLOW_CHECK_UPDATE', TRUE ); + +/** + * If you set ALLOW_NEW_AUTOBLOGS to FALSE, the following options do not matter. + **/ +// define( 'ALLOW_NEW_AUTOBLOGS', TRUE ); +// define( 'ALLOW_NEW_AUTOBLOGS_BY_LINKS', TRUE ); +// define( 'ALLOW_NEW_AUTOBLOGS_BY_SOCIAL', TRUE ); +// define( 'ALLOW_NEW_AUTOBLOGS_BY_BUTTON', TRUE ); +// define( 'ALLOW_NEW_AUTOBLOGS_BY_OPML_FILE', TRUE ); +// define( 'ALLOW_NEW_AUTOBLOGS_BY_OPML_LINK', TRUE ); +// define( 'ALLOW_NEW_AUTOBLOGS_BY_XSAF', TRUE ); + +/** + * TwitterBridge: https://github.com/mitsukarenai/twitterbridge + * 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. + * set to FALSE if you want to fully disable Twitter support + **/ +// define( 'API_TWITTER', 'LOCAL' ); + +/** + * Import autoblogs from friend's autoblog farm - Add a link to the JSON export + **/ +$friends_autoblog_farm = array( + 'https://raw.github.com/mitsukarenai/xsaf-bootstrap/master/3.json', + // 'https://www.ecirtam.net/autoblogs/?export', + // '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='; +?> diff --git a/functions.php b/functions.php index 328c97e..16b89e5 100755 --- a/functions.php +++ b/functions.php @@ -16,6 +16,9 @@ if (!defined('FOLDER_MAX_LENGTH')) define('FOLDER_MAX_LENGTH', 80); date_default_timezone_set('Europe/Paris'); setlocale(LC_TIME, 'fr_FR.UTF-8', 'fr_FR', 'fr'); +if( !defined('DOCS_CACHE_DURATION')) define( 'DOCS_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_CHECK_UPDATE')) define( 'ALLOW_CHECK_UPDATE', TRUE ); @@ -29,7 +32,7 @@ if( !defined('ALLOW_NEW_AUTOBLOGS_BY_OPML_LINK')) define( 'ALLOW_NEW_AUTOBLOGS_B if( !defined('ALLOW_NEW_AUTOBLOGS_BY_XSAF')) define( 'ALLOW_NEW_AUTOBLOGS_BY_XSAF', TRUE ); // More about TwitterBridge : https://github.com/mitsukarenai/twitterbridge -if( !defined('API_TWITTER')) define( 'API_TWITTER', FALSE ); +if( !defined('API_TWITTER')) define( 'API_TWITTER', 'LOCAL' ); if( !defined('LOGO')) define( 'LOGO', 'icon-logo.svg' ); if( !defined('HEAD_TITLE')) define( 'HEAD_TITLE', ''); @@ -39,7 +42,7 @@ if( !defined('FOOTER')) define( 'FOOTER', 'D\'après les premières versions de * Functions **/ function NoProtocolSiteURL($url) { - $protocols = array("http://", "https://"); + $protocols = array("http://", "https://"); $siteurlnoproto = str_replace($protocols, "", $url); // Remove the / at the end of string @@ -158,8 +161,12 @@ function getArticlesPerPage( $type ) { switch( $type ) { case 'microblog': return 20; + case 'twitter': + return 20; case 'shaarli': return 20; + case 'youtube': + return 10; default: return 5; } @@ -169,6 +176,8 @@ function getInterval( $type ) { switch( $type ) { case 'microblog': return 300; + case 'twitter': + return 300; case 'shaarli': return 1800; default: @@ -178,10 +187,6 @@ function getInterval( $type ) { function getTimeout( $type ) { switch( $type ) { - case 'microblog': - return 30; - case 'shaarli': - return 30; default: return 30; } @@ -191,12 +196,12 @@ function updateType($siteurl) { if( strpos($siteurl, 'twitter.com') !== FALSE ) { return array('type' => 'twitter', 'name' => 'twitter'); } - elseif ( strpos( $siteurl, 'identi.ca') !== FALSE ) { - return array('type' => 'identica', 'name' => 'identica'); - } elseif( strpos( $siteurl, 'shaarli' ) !== FALSE ) { return array('type' => 'shaarli', 'name' => 'shaarli'); } + elseif( strpos( $siteurl, 'youtube.com' ) !== FALSE ) { + return array('type' => 'youtube', 'name' => ''); + } else return array('type' => 'generic', 'name' => ''); } @@ -256,11 +261,14 @@ function __($str) return 'Source :'; case '_date_format': return '%A %e %B %Y à %H:%M'; - case 'configuration': - case 'articles': - return $str; case 'Media export': return 'Export fichiers media'; + case 'Import running: ': + return 'Import en cours : '; + case ' files remaining': + return ' fichiers restants'; + case 'The page should refresh every second. If not, refresh manually.': + return 'La page devrait se rafraîchir toutes les secondes. Si non, rafraîchissez là manuellement..'; default: return $str; } @@ -278,6 +286,7 @@ $json[] = array( 'status'=>$status, 'response_code'=>$response_code ); +$json = array_slice($json, -50, 50); if(file_put_contents(RESOURCES_FOLDER.'rss.json', json_encode($json), LOCK_EX) === FALSE) { return FALSE; } else { return TRUE; } @@ -287,47 +296,52 @@ function displayXMLstatus($status, $response_code, $autoblog_url, $autoblog_titl switch ($status) { case 'unavailable': - return 'Autoblog "'.$autoblog_title.'": site distant inaccessible (code '.$response_code.')
Autoblog: '.$autoblog_title.'
Site: '. $autoblog_sourceurl .'
RSS: '.$autoblog_sourcefeed.''; + return 'Autoblog "'.$autoblog_title.'" : site distant inaccessible (code '.$response_code.')
Autoblog : '.$autoblog_title.'
Site : '. $autoblog_sourceurl .'
RSS : '.$autoblog_sourcefeed.''; case 'moved': - return 'Autoblog "'.$autoblog_title.'": site distant redirigé (code '.$response_code.')
Autoblog: '.$autoblog_title.'
Site: '. $autoblog_sourceurl .'
RSS: '.$autoblog_sourcefeed.''; + return 'Autoblog "'.$autoblog_title.'" : site distant redirigé (code '.$response_code.')
Autoblog : '.$autoblog_title.'
Site : '. $autoblog_sourceurl .'
RSS : '.$autoblog_sourcefeed.''; case 'not_found': - return 'Autoblog "'.$autoblog_title.'": site distant introuvable (code '.$response_code.')
Autoblog: '.$autoblog_title.'
Site: '. $autoblog_sourceurl .'
RSS: '.$autoblog_sourcefeed.''; + return 'Autoblog "'.$autoblog_title.'" : site distant introuvable (code '.$response_code.')
Autoblog : '.$autoblog_title.'
Site : '. $autoblog_sourceurl .'
RSS : '.$autoblog_sourcefeed.''; case 'remote_error': - return 'Autoblog "'.$autoblog_title.'": site distant a problème serveur (code '.$response_code.')
Autoblog: '.$autoblog_title.'
Site: '. $autoblog_sourceurl .'
RSS: '.$autoblog_sourcefeed.''; + return 'Autoblog "'.$autoblog_title.'" : site distant a problème serveur (code '.$response_code.')
Autoblog : '.$autoblog_title.'
Site : '. $autoblog_sourceurl .'
RSS : '.$autoblog_sourcefeed.''; case 'available': - return 'Autoblog "'.$autoblog_title.'": site distant à nouveau opérationnel (code '.$response_code.')
Autoblog: '.$autoblog_title.'
Site: '. $autoblog_sourceurl .'
RSS: '.$autoblog_sourcefeed.''; + return 'Autoblog "'.$autoblog_title.'" : site distant à nouveau accessible (code '.$response_code.')
Autoblog : '.$autoblog_title.'
Site : '. $autoblog_sourceurl .'
RSS : '.$autoblog_sourcefeed.''; case 'new_autoblog_added': - return 'Autoblog "'.$autoblog_title.'" ajouté (code '.$response_code.')
Autoblog: '.$autoblog_title.'
Site: '. $autoblog_sourceurl .'
RSS: '.$autoblog_sourcefeed.''; + return 'Autoblog "'.$autoblog_title.'" ajouté.
Autoblog : '.$autoblog_title.'
Site : '. $autoblog_sourceurl .'
RSS : '.$autoblog_sourcefeed.''; } } function displayXML() { -header('Content-type: application/rss+xml; charset=utf-8'); -echo ' -'.serverUrl(true).''; -echo 'Projet Autoblog'. ((strlen(HEAD_TITLE)>0) ? ' | '. HEAD_TITLE : '').''.serverUrl(true),"Projet Autoblog - RSS : Ajouts et changements de disponibilité.".''; -if(file_exists(RESOURCES_FOLDER.'rss.json')) -{ - $json = json_decode(file_get_contents(RESOURCES_FOLDER.'rss.json'), true); - rsort($json); - foreach ($json as $item) + header('Content-type: application/rss+xml; charset=utf-8'); + echo ' + '.serverUrl(true).''; + echo 'Projet Autoblog'. ((strlen(HEAD_TITLE)>0) ? ' | '. HEAD_TITLE : '').'Projet Autoblog - RSS : Ajouts et changements de disponibilité.'; + if(file_exists(RESOURCES_FOLDER.'rss.json')) { - $description = displayXMLstatus($item['status'],$item['response_code'],$item['autoblog_url'],$item['autoblog_title'],$item['autoblog_sourceurl'],$item['autoblog_sourcefeed']); - $link = serverUrl(true).AUTOBLOGS_FOLDER.$item['autoblog_url']; - $date = date("r", $item['timestamp']); - print << $Value) { + $item[$Key] = escape($Value); + } + + $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']; + $date = date(DATE_RSS, $item['timestamp']); + print << {$item['autoblog_title']} {$link} {$item['timestamp']} - admin@{$_SERVER['SERVER_NAME']} + Autoblog {$date} EOT; + } } -} -echo ''; + echo ''; } ?> diff --git a/index.php b/index.php old mode 100755 new mode 100644 index 1c1f372..43f3b76 --- a/index.php +++ b/index.php @@ -14,7 +14,7 @@ (by default, database and media transfer via XSAF is allowed) - upload all files on your server (PHP 5.3+ required) - - PROFIT ! + - PROFIT! */ @@ -26,13 +26,11 @@ $success = array(); if(file_exists("config.php")){ require_once "config.php"; -}else{ - $error[] = "config.php not found !"; } if(file_exists("functions.php")){ require_once "functions.php"; }else{ - echo "functions.php not found !"; + echo "functions.php not found!"; die; } @@ -58,7 +56,7 @@ function get_link_from_datafeed($data) { // ATOM feed && RSS 1.0 /RDF && RSS 2.0 if (!isset($xml->entry) && !isset($xml->item) && !isset($xml->channel->item)) - die('le flux n\'a pas une syntaxe valide'); + { die('le flux n\'a pas une syntaxe valide');} $check = substr($data, 0, 5); if($check !== 'item(0)->nodeValue; } else { - return $channel['link']; + return escape($channel['link']); } } +function get_size($doc) { + $symbol = array('o', 'Kio', 'Mio', 'Gio', 'Tio'); + $size = filesize($doc); + $exp = floor(log($size) / log(1024)); + $nicesize = $size / pow(1024, floor($exp)); + return sprintf('%d %s', $nicesize, $symbol[$exp]); +} + function serverUrl($return_subfolder = false) { $https = (!empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS'])=='on')) || $_SERVER["SERVER_PORT"]=='443'; // HTTPS detection. $serverport = ($_SERVER["SERVER_PORT"]=='80' || ($https && $_SERVER["SERVER_PORT"]=='443') ? '' : ':'.$_SERVER["SERVER_PORT"]); if($return_subfolder === true) { $path = pathinfo( $_SERVER['PHP_SELF'] ); - $subfolder = $path['dirname'] .'/'; + $finalslash = ( $path['dirname'] != '/' ) ? '/' : ''; + $subfolder = $path['dirname'] . $finalslash; } else $subfolder = ''; return 'http'.($https?'s':'').'://'.$_SERVER["SERVER_NAME"].$serverport.$subfolder; } @@ -112,18 +119,13 @@ function create_from_opml($opml) { $sitename = escape( $outline['title'] ); $siteurl = escape($outline['htmlUrl']); - // Lighten process by checking folderExists first - // A CHANGER SELON ISSUE #20 - if(folderExists($siteurl)) - throw new Exception('Erreur : l\'autoblog '. $sitename .' existe déjà.'); - $sitetype = escape($outline['text']); - if ( $sitetype != 'microblog' && $sitetype != 'shaarli' && $sitetype != 'twitter' && $sitetype != 'identica' ) + if ( $sitetype != 'microblog' && $sitetype != 'shaarli' && $sitetype != 'twitter' && $sitetype != 'youtube') $sitetype = 'generic'; - $siteDesc = getSiteDesc(escape($siteurl)); + $rssurl = DetectRedirect(escape($outline['xmlUrl'])); - createAutoblog( $sitetype, $sitename, $siteurl, $rssurl, $siteDesc, $error ); + createAutoblog( $sitetype, $sitename, $siteurl, $rssurl ); $message = 'Autoblog "'. $sitename .'" crée avec succès. → afficher l\'autoblog.'; // Do not print iframe on big import (=> heavy and useless) @@ -174,7 +176,7 @@ function versionCheck() { * **/ 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'])) { @@ -187,18 +189,21 @@ if (isset($_GET['rss'])) { **/ if (isset($_GET['check'])) { - //echo "1"; header('Content-type: image/svg+xml'); $randomtime=rand(86400, 259200); /* intervalle de mise à jour: de 1 à 3 jours (pour éviter que le statut de tous les autoblogs soit rafraichi en bloc et bouffe le CPU) */ $expire=time() -$randomtime ; /* SVG minimalistes */ - $svg_vert='OK'; - $svg_jaune='mv'; - $svg_rouge='err'; - $svg_twitter=''; - $svg_identica=''; - $svg_statusnet=''; + +function svg_status($fill, $text, $back) + { + $svg = ''.$back.''.$text.''; + return $svg; + } + + $svg_ok=svg_status('#008000', 'ok', ''); + $svg_mv=svg_status('#0000ff', 'mv', ''); + $svg_err=svg_status('#000000', 'err', ''); $errorlog="./".escape( $_GET['check'] ) ."/error.log"; @@ -207,43 +212,42 @@ if (isset($_GET['check'])) 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_vert);} - else if(filesize($errorlog) == "1") {die($svg_jaune);} - else {die($svg_rouge);} + if(filesize($errorlog) == "0") {die($svg_ok);} + else if(filesize($errorlog) == "1") {die($svg_mv);} + else {die($svg_err);} } else /* ..sinon, lancer la procédure de contrôle */ { $ini = parse_ini_file("./". escape( $_GET['check'] ) ."/vvb.ini") or die; - - if(strpos(strtolower($ini['SITE_TITLE']), 'twitter') !== FALSE) { die($svg_twitter); } /* Twitter */ - if(strpos(strtolower($ini['SITE_TITLE']), 'identica') !== FALSE) { die($svg_identica); } /* Identica */ - if(strpos(strtolower($ini['SITE_TYPE']), 'microblog') !== FALSE) { die($svg_statusnet); } /* Statusnet */ - $headers = get_headers($ini['FEED_URL']); + + if(!empty($headers)) + $code=explode(" ", $headers[0]); + else $code = array(); + /* le flux est indisponible (typiquement: erreur DNS ou possible censure) - à vérifier */ - if(empty($headers) || $headers === FALSE ) { + if(empty($headers) || $headers === FALSE || (!empty($code) && ($code[1] == '500' || $code[1] == '404'))) { 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, '..'); - die($svg_rouge); + die($svg_err); } - $code=explode(" ", $headers[0]); /* code retour 200: flux disponible */ if($code[1] == "200") { 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, ''); - die($svg_vert); + die($svg_ok); } /* autre code retour: un truc a changé (redirection, changement de CMS, .. bref vvb.ini doit être corrigé) */ else { 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, '.'); - die($svg_jaune); + die($svg_mv); } } } @@ -257,8 +261,8 @@ if (isset($_GET['export'])) { foreach($subdirs as $unit) { if(is_dir($unit)) { - $unit=substr($unit, 2); $ini = parse_ini_file($unit.'/vvb.ini'); + $unit=substr($unit, 2); $config = new stdClass; foreach ($ini as $key=>$value) { @@ -350,18 +354,18 @@ if (isset($_GET['exportopml'])) // OPML if (isset($_GET['sitemap'])) { header('Content-Type: application/xml'); - $proto=(!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'])=='on')?"https://":"http://"; - echo ''; - echo ''.$proto."{$_SERVER['HTTP_HOST']}".str_replace('?sitemap', '', $_SERVER['REQUEST_URI'])."\n"; - echo ''.date('c', time())."\n"; - echo 'daily'; + $proto=(!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'])=='on')?"https://":"http://"; + echo ''."\n".''."\n"; + echo "\n ".$proto."{$_SERVER['HTTP_HOST']}".str_replace('?sitemap', '', $_SERVER['REQUEST_URI'])."\n"; + echo ' '.date('c', time())."\n"; + echo " daily\n\n"; $subdirs = glob(AUTOBLOGS_FOLDER . "*"); foreach($subdirs as $unit) { if(is_dir($unit)) { $unit=substr($unit, 2); - echo ''.$proto.$_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'], 0, -9)."$unit/"."\n"; - echo ''.date('c', filemtime($unit))."\n"; - echo 'hourly'; + echo "\n ".$proto.$_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'], 0, -9)."$unit/"."\n"; + echo ' '.date('c', filemtime($unit))."\n"; + echo " hourly\n\n\n"; } } echo ''; @@ -372,40 +376,75 @@ if (isset($_GET['sitemap'])) * Update ALL autblogs (except .disabled) * This action can be very slow and consume CPU if you have a lot of autoblogs **/ -if( isset($_GET['updateall']) && ALLOW_FULL_UPDATE) { - - $expire = time() - 84600 ; // 23h30 en secondes +if( isset($_GET['updateall']) ) { $lockfile = ".updatealllock"; - if (file_exists($lockfile) && filemtime($lockfile) > $expire) { - echo "too early"; - die; - } - else { - if( file_exists($lockfile) ) - unlink($lockfile); - + if( !isset( $_GET['force']) ) { + $max_exec_time=time()+4; // scipt have 4 seconds to update autoblogs + $expire = time() - 5 ; // 5 seconds + $lockfile_contents = array(); + if (file_exists($lockfile)){ + $lockfile_contents = file_get_contents($lockfile); + if( !isset($lockfile_contents[0]) || $lockfile_contents[0] != "a") { // détection d'une serialisation + if( filemtime($lockfile) > $expire){ + echo "too early"; + die; + }else{ + // need update of all autoblogs + unlink($lockfile); + } + } + // else we need to update some autoblogs + } if( file_put_contents($lockfile, date(DATE_RFC822)) ===FALSE) { echo "Merci d'ajouter des droits d'écriture sur le fichier."; die; } - } - $subdirs = glob(AUTOBLOGS_FOLDER . "*"); - foreach($subdirs as $unit) { + if(!empty($lockfile_contents)) { + $subdirs = unserialize($lockfile_contents); + unset($lockfile_contents); + }else{ + $subdirs = glob(AUTOBLOGS_FOLDER . "*"); + } + } + elseif (ALLOW_FULL_UPDATE) { + $subdirs = glob(AUTOBLOGS_FOLDER . "*"); + $max_exec_time=time() * 2; // workaround to disable max exec time + } + else { + echo "You're not allowed to force full update."; + die; + } + $todo_subdirs = $subdirs; + + foreach($subdirs as $key => $unit) { if(is_dir($unit)) { if( !file_exists(ROOT_DIR . '/' . $unit . '/.disabled')) { file_get_contents(serverUrl() . substr($_SERVER['PHP_SELF'], 0, -9) . $unit . '/index.php'); + unset($todo_subdirs[$key]); } } + if(time() >= $max_exec_time){ + break; + } } + if(!empty($todo_subdirs)){ + // if update is not finish + // save list of autoblogs who need update + file_put_contents($lockfile, serialize($todo_subdirs), LOCK_EX); + echo "Not finish"; + }else{ + echo "Done"; + } + exit; } $antibot = generate_antibot(); -$form = '
-
-
- - +$form = ''."\n".' +
+
+ +
'; /** @@ -427,9 +466,9 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG $sitename = escape($_GET['sitename']); $sitetype = updateType($siteurl); // Disabled input doesn't send POST data $sitetype = $sitetype['type']; - $siteDesc = getSiteDesc(escape($_GET['siteDesc'])); - createAutoblog( $sitetype, $sitename, $siteurl, $rssurl, $siteDesc, $error); + createAutoblog( $sitetype, $sitename, $siteurl, $rssurl ); + if( empty($error)) { $form .= ''; $form .= '

Autoblog '. $sitename .' ajouté avec succès.
'; @@ -460,11 +499,11 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG $form .= 'Merci de vérifier les informations suivantes, corrigez si nécessaire.

-
-
-
-
-
+
+
+
+
+
'; } else { @@ -484,28 +523,30 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG * ADD BY SOCIAL / SHAARLI **/ if( !empty($_POST['socialinstance']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_SOCIAL) -{; +{ $socialinstance = strtolower(escape($_POST['socialinstance'])); $socialaccount = (!empty($_POST['socialaccount'])) ? strtolower(escape($_POST['socialaccount'])) : false; if( $socialaccount === false && $socialinstance !== 'shaarli') $error[] = 'Le compte social doit être renseigné.'; - - if( !empty($_POST['number']) && !empty($_POST['antibot']) && check_antibot($_POST['number'], $_POST['antibot']) && empty($error)) { + elseif( !empty($_POST['number']) && !empty($_POST['antibot']) && check_antibot($_POST['number'], $_POST['antibot'])) { if($socialinstance === 'twitter') { if( API_TWITTER !== FALSE ) { $sitetype = 'twitter'; $siteurl = 'http://twitter.com/'. $socialaccount; - $rssurl = API_TWITTER.$socialaccount; + if ( API_TWITTER === 'LOCAL' ) { + $rssurl = serverUrl(true).'twitter2feed.php?u='.$socialaccount; + } + else { + $rssurl = API_TWITTER.$socialaccount; + // check + $twitterbridge = get_headers($rssurl, 1); + if ($twitterbridge['0'] == 'HTTP/1.1 403 Forbidden') { $error[] = "La twitterbridge a refusé ce nom d'utilisateur:
\n
".htmlentities($twitterbridge['X-twitterbridge']).'
'; } + } } else $error[] = 'Vous devez définir une API Twitter -> RSS dans votre fichier de configuration (see TwitterBridge).'; } - elseif($socialinstance === 'identica') { - $sitetype = 'identica'; - $siteurl = 'http://identi.ca/'.$socialaccount; - $rssurl = 'http://identi.ca/api/statuses/user_timeline/'.$socialaccount.'.rss'; - } elseif($socialinstance === 'statusnet' && !empty($_POST['statusneturl'])) { $sitetype = 'microblog'; $siteurl= NoProtocolSiteURL(escape($_POST['statusneturl'])); @@ -529,31 +570,28 @@ if( !empty($_POST['socialinstance']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLO $rssurl = $siteurl."?do=rss"; $socialaccount = get_title_from_feed($rssurl); } - - + elseif($socialinstance === 'youtube') { + $sitetype = 'youtube'; + $siteurl = 'https://www.youtube.com/user/'.$socialaccount; + $rssurl = 'https://gdata.youtube.com/feeds/base/users/'.$socialaccount.'/uploads?alt=atom&orderby=published'; + } if( empty($error) ) { try { - // TwitterBridge user will be allowed after Autoblog creation - // TODO: Twitter user does not exist ? - // TODO: get remote like http://wwz.suumitsu.eu/twitter/whitelist.json, decode, check if is in array, return error or continue - if($sitetype != 'twitter') { $headers = get_headers($rssurl, 1); if (strpos($headers[0], '200') === FALSE) throw new Exception('Flux inaccessible (compte inexistant ?)'); - } createAutoblog($sitetype, ucfirst($socialinstance) .' - '. $socialaccount, $siteurl, $rssurl); $success[] = ' '.ucfirst($socialinstance) .' - '. $socialaccount.' ajouté avec succès.'; } - catch (Exception $e) { echo $error[] = $e->getMessage(); } } } else - $error[] = 'Antibot : Chiffres incorrects.'; + $error[] = 'Antibot : chiffres incorrects.'; } /** @@ -565,26 +603,27 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L if(empty($_POST['number']) || empty($_POST['antibot']) ) {$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 { - $rssurl = DetectRedirect(escape($_POST['rssurl'])); + $rssurl = parse_url($_POST['rssurl']); + if(!isset($rssurl['query'])) $rssurl['query'] = ''; + $rssurl = $rssurl['scheme'].'://'.$rssurl['host'].$rssurl['path'].'?'.html_entity_decode($rssurl['query']); + $rssurl = DetectRedirect($rssurl); if(!empty($_POST['siteurl'])) { $siteurl = escape($_POST['siteurl']); $sitename = get_title_from_feed($rssurl); - $siteDesc = escape($_POST['siteDesc']); - createAutoblog('generic', $sitename, $siteurl, $rssurl, $siteDesc, $error); + createAutoblog('generic', $sitename, $siteurl, $rssurl); $success[] = ' Autoblog '. $sitename .' crée avec succès.afficher l\'autoblog'; } else { // checking procedure - $datafeed = file_get_contents($rssurl); if( $datafeed === false ) { $error[] = 'URL "'. $rssurl .'" inaccessible.'; @@ -599,7 +638,6 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L


-


'; @@ -619,7 +657,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY if(empty($_POST['number']) || empty($_POST['antibot']) ) {$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'])) { @@ -643,7 +681,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY if(empty($_POST['number']) || empty($_POST['antibot']) ) {$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.';} @@ -664,239 +702,296 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY ?> - - - + + Projet Autoblog<?php if(strlen(HEAD_TITLE)>0) echo " | " . HEAD_TITLE; ?> - + + + + + + '; } ?> - - -

- PROJET AUTOBLOG - 0) echo " | " . HEAD_TITLE; ?> -

- -
- '; - ?> -

Présentation

- -

- 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... -

- -

- Voici une liste d'autoblogs hébergés sur - (plus d'infos sur le projet). -

- -

- Autres fermes - → Rechercher -

-
- - -
-

Mise à jour

-

- Une mise à jour du Projet Autoblog est disponible !
- → Télécharger la dernière version
- → Important : Consulter la documentation - mise à jour -

-
- - - -
- -

Ajouter un autoblog

- - Message'. (count($error) ? 's' : '') .' :

    '; - foreach ( $error AS $value ) { - echo '
  • '. $value .'
  • '; - } - foreach ( $success AS $value ) { - echo '
  • '. $value .'
  • '; - } - echo '
'; - } - - $button_list = '

Ajouter un autoblog via : '; - if(ALLOW_NEW_AUTOBLOGS_BY_LINKS) - $button_list .= 'Flux RSS '; - if(ALLOW_NEW_AUTOBLOGS_BY_SOCIAL) { - $button_list .= 'Compte réseau social '; - $button_list .= 'Shaarli '; - } - if(ALLOW_NEW_AUTOBLOGS_BY_OPML_FILE) - $button_list .= 'Fichier OPML '; - if(ALLOW_NEW_AUTOBLOGS_BY_OPML_LINK) - $button_list .= 'Lien vers OPML '; - if(ALLOW_NEW_AUTOBLOGS_BY_BUTTON) - $button_list .= 'Marque page '; - $button_list .= '

'; - echo $button_list; - - if(ALLOW_NEW_AUTOBLOGS_BY_LINKS == TRUE) { ?> -
-

Ajouter un site web

-

- Si vous souhaitez que héberge un autoblog d'un site,
- remplissez le formulaire suivant: -

- - -
- -
-

Ajouter un compte social

- -
-
- Twitter
'; - else echo 'Twitter
'; ?> - Identica
- -
-
- - -
-
- -
-

Ajouter un Shaarli

- -
- -
-
- - -
-
- -
-

Ajouter par fichier OPML

- -
- -
-
- - -
-
- - - - - - - -
- + + +
+

Projet Autoblog0) echo " | " . HEAD_TITLE; ?>

+
+
+
'."\n"; + ?> +

Présentation

+
+ +

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…

+ +

Voici une liste d'autoblogs hébergés sur (plus d'infos sur le projet).

+ +

Autres fermesRechercher

+
+ +
+
+

Mise à jour

+
+ +

Une mise à jour du Projet Autoblog est disponible !

+ +
+ + +
+
+

Ajouter un autoblog

+
+ + Message'. (count($error) ? 's' : '') ." :

\n"; + echo "
    \n"; + foreach ( $error AS $value ) { + echo '
  • '. $value ."
  • \n"; + } + foreach ( $success AS $value ) { + echo '
  • '. $value ."
  • \n"; + } + echo "
\n"; + echo " \n"; + echo ' '; + } + + $button_list = '

Ajouter un autoblog via :'."\n"; + if(ALLOW_NEW_AUTOBLOGS_BY_LINKS) + $button_list .= ' Flux RSS'."\n"; + if(ALLOW_NEW_AUTOBLOGS_BY_SOCIAL) { + $button_list .= ' Compte réseau social'."\n"; + $button_list .= ' Shaarli'."\n"; + } + if(ALLOW_NEW_AUTOBLOGS_BY_OPML_FILE) + $button_list .= ' Fichier OPML'."\n"; + if(ALLOW_NEW_AUTOBLOGS_BY_OPML_LINK) + $button_list .= ' Lien vers OPML'."\n"; + if(ALLOW_NEW_AUTOBLOGS_BY_BUTTON) + $button_list .= ' Marque page'."\n"; + $button_list .= "

\n"; + echo $button_list; + + if(ALLOW_NEW_AUTOBLOGS_BY_LINKS == TRUE) { ?> +
+
+

Ajouter un site web

+
+ +

Si vous souhaitez que héberge un autoblog d'un site, remplissez le formulaire suivant :

+ + +
+ +
+
+

Ajouter un compte social

+
+ +
+
+ Twitter (local)
'; + else + echo 'Twitter (via bridge)
'; + } + else echo 'Twitter
'; ?> + +
+ Youtube
+
+ + +
+
+
+
+

Ajouter un Shaarli

+
+ +
+ +
+
+ + +
+
+ +
+
+

Ajouter par fichier OPML

+
+ +
+ +
+
+ + +
+
+ + + +
+
+

Marque page

+
+ +

+ Pour ajouter facilement un autoblog d'un site web, glissez ce bouton dans votre barre de marque-pages → + marque-page sur ce lien)'); + return false;" + href="javascript:(function(){var%20autoblog_url="";var%20popup=window.open("","Add%20autoblog",'height=180,width=670');popup.document.writeln('');popup.document.write('Url%20feed%20%20:%20
');var%20feed_links=new%20Array();var%20links=document.getElementsByTagName('link');if(links.length>0){for(var%20i=0;i'+links[i].title+"%20(%20"+links[i].href+"%20)
");}}}popup.document.writeln("");popup.document.writeln("");popup.document.writeln("
");popup.document.writeln("");})();">Projet Autoblog
+

+ +
+'. substr($unit, (strrpos($unit, '/')) + 1 ) .''; - } + $subdirs = glob($directory . "*"); + foreach($subdirs as $unit) { + if(!is_dir($unit) || file_exists( $unit . '/index.html' ) || file_exists( $unit . '/index.htm' ) || file_exists( $unit . '/index.php' ) ) { + $size = ''; + if ( is_file($unit) ) { $size = get_size($unit); } + $docs[] = array(''. substr($unit, (strrpos($unit, '/')) + 1 ) .'', $size); } - } - if(!empty( $docs )) { - echo '

Autres documents

    '; - foreach( $docs as $value ) - echo '
  • '. $value .'
  • '; - echo '
'; - } - ?> + } + if(!empty( $docs )) { + echo '
+
+

Autres documents

+
-
-

Autoblogs hébergés rss

+
    '."\n"; - -
    - $value) - { - $key = strtolower($key); - $config->$key = $value; - } - $autoblogs[$unit] = $config; - unset($ini); - } - } - } + foreach( $docs as $value ) { + $str = $value[0]; + if ( !empty($value[1]) ) { + $str = sprintf('%s (%s)', $value[0], $value[1]); + } + echo '
  • '. $str . "
  • \n"; + } + + echo '
+
'."\n"; + } + } + // on recuperre le contenu du buffer + $contenuCache = ob_get_contents(); + ob_end_clean(); // on termine la bufferisation + if( !empty($contenuCache) ) { + file_put_contents("$fichierCache",$contenuCache, LOCK_EX); // on écrit le contenu du buffer dans le fichier cache + } + echo $contenuCache; // et on sort + // sinon le fichier cache existe déjà, on ne génère pas la page + // et on envoie le fichier statique à la place + } else { + readfile($fichierCache); // affichage du contenu du fichier + echo ' '."\n"; // et un petit message + } + ?> +
+
+

Autoblogs hébergés rss

+
+ + + + + '; + $subdirs = glob(AUTOBLOGS_FOLDER . "*"); + $autoblogs = array(); + foreach($subdirs as $unit) { + if(is_dir($unit)) { + if( !file_exists(ROOT_DIR . '/' . $unit . '/.disabled')) { + if( file_exists(ROOT_DIR . '/' . $unit . '/vvb.ini')) { + $ini = parse_ini_file(ROOT_DIR . '/' . $unit . '/vvb.ini'); + if($ini) { + $config = new stdClass; + foreach ($ini as $key=>$value) { + $key = strtolower($key); + $config->$key = $value; } + $autoblogs[$unit] = $config; + unset($ini); + } } + } + } + } - uasort($autoblogs, "objectCmp"); - $autoblogs_display = ''; - if(!empty($autoblogs)){ - foreach ($autoblogs as $key => $autoblog) { - $opml_link='opml'; - $autoblogs_display .= '
- '; - if($myOptions['enableThumbShot'] === true){ + uasort($autoblogs, "objectCmp"); + $autoblogs_display = ''; + + if(!empty($autoblogs)){ + foreach ($autoblogs as $key => $autoblog) { + $opml_link='opml'; + $autoblogs_display .= '
  • +
    + + + +

    '.escape($autoblog->site_title).'

    +
    +
    '; + if($myOptions['enableThumbShot'] === true){ if(file_exists(ROOT_DIR . '/' . $key . '/thumbshot.png')){ $autoblogs_display .= '
    '.shortSiteDesc(escape($autoblog->site_meta_description)).'
    '; @@ -905,36 +1000,54 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
    '.shortSiteDesc(escape($autoblog->site_meta_description)).'
    '; } } - $autoblogs_display .= '
    config ini '.$opml_link.' | '.escape($autoblog->site_type).' source: '.escape($autoblog->site_url).'
    -
  • '; - } - } - echo $autoblogs_display; - ?> - -
    - - ".count($autoblogs)." autoblogs hébergés

    "; ?> - - Propulsé par Projet Autoblog 0.3 de Mitsu, Oros et Arthur Hoaro (Domaine Public) - 0 ){ echo "
    ".FOOTER; } ?> - - - + } + echo $autoblogs_display; - + echo ' + +

    '.count($autoblogs).' autoblogs hébergés

    '; + + // on recuperre le contenu du buffer + $contenuCache = ob_get_contents(); + ob_end_clean(); // on termine la bufferisation + if( !empty($contenuCache) ) { + file_put_contents("$fichierCache",$contenuCache, LOCK_EX); // on écrit le contenu du buffer dans le fichier cache + } + echo $contenuCache; // et on sort + // sinon le fichier cache existe déjà, on ne génère pas la page + // et on envoie le fichier statique à la place + } else { + echo ''."\n".' '; // un message de début + readfile($fichierCache); // affichage du contenu du fichier + echo "\n".' '."\n"; // et un petit message + } + ?> +
    + + + + + + diff --git a/resources/autoblog.css b/resources/autoblog.css index 259e2e8..5c736db 100644 --- a/resources/autoblog.css +++ b/resources/autoblog.css @@ -9,40 +9,42 @@ body {background-color:#efefef;text-align:center;color:#333;font-family:sans-serif;} a {color:black;text-decoration:none;font-weight:bold;} a:hover {color:darkred;} -h1 {text-align:center;font-size:40pt;text-shadow: #ccc 0px 5px 5px;} +h1 {text-transform:uppercase;text-align:center;font-size:40pt;text-shadow: #ccc 0px 5px 5px;} h2 {text-align:center;font-size: 16pt;margin:0 0 1em 0;font-style:italic;text-shadow: #ccc 0px 5px 5px; } -.pbloc {background-color:white;padding: 12px 10px 12px 10px;border:1px solid #aaa;max-width:70em;margin:1em auto;text-align:justify;box-shadow:0px 5px 7px #aaa;} +body > section {background-color:white;padding: 12px 10px 12px 10px;border:1px solid #aaa;max-width:70em;margin:1em auto;text-align:justify;box-shadow:0px 5px 7px #aaa;} +li {list-style-type:none;} input[type="text"]{width:20em;} input[type="radio"] {width:1em;} input[type="submit"] {width:8em;} -div.form {padding:0.2em;border:1px solid #fff;} -div.form:hover {background-color:#FAF4DA;border:1px dotted;} -#contentVignette {text-align: center;} -.vignette {width:27%;height:2em;display: inline-block;text-align:justify;margin:0; padding:20px;background-color:#eee;border: 1px solid #888;} -.vignette:hover {background-color:#fff;} -.vignette .title {font-size: 14pt;text-shadow: #ccc 0px 5px 5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;} -.vignette .title a:hover {color:darkred; text-decoration:none;} -.vignette .source {font-size:x-small;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;} -.vignette .source a:hover {color:darkred; text-decoration:none;} +section.form {padding:0.2em;border:1px solid #fff;} +section.form:hover {background-color:#FAF4DA;border:1px dotted;} +section#autoblogs > ul {text-align: center;padding:0;} +section#autoblogs > ul > li {width:27%;height:2em;display: inline-block;text-align:justify;margin:0; padding:20px;background-color:#eee;border: 1px solid #888;} +section#autoblogs > ul > li:hover {background-color:#fff;} +section#autoblogs > ul > li header, section#autoblogs > ul > li h3 {font-size: large;text-shadow: #ccc 0px 5px 5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;} +section#autoblogs > ul > li h3 {display:inline;font-size:large;text-overflow:ellipsis;width:100%;} +section#autoblogs > ul > li header a:hover {color:darkred; text-decoration:none;} +section#autoblogs > ul > li .source {font-size:x-small;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;} +section#autoblogs > ul > li .source a:hover {color:darkred; text-decoration:none;} .clear {clear:both;text-align:right;font-size:small;} #logo {float: right;} -.bouton{background: -moz-linear-gradient(center top , #EDEDED 5%, #DFDFDF 100%) repeat scroll 0 0 #EDEDED;border: 1px none;padding: 10px;border: 1px solid #7777777;border-radius: 8px 8px 8px 8px;box-shadow: 0 1px 0 0 #FFFFFF inset;display: inline-block;} +.bouton{border: 1px none;padding: 10px;border: 1px solid #777777;border-radius: 8px 8px 8px 8px;box-shadow: 0 1px 0 0 #FFFFFF inset;display: inline-block;} .success {color: green;} .error {color: red;} .button_list{display:none;} -.button{-moz-box-shadow:inset 0 1px 0 0 #d9fbbe;-webkit-box-shadow:inset 0 1px 0 0 #d9fbbe;box-shadow:inset 0 1px 0 0 #d9fbbe;background:0;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#b8e356',endColorstr='#a5cc52');background-color:#b8e356;-moz-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;border:1px solid #83c41a;display:inline-block;color:#fff;font-family:arial;font-size:14px;font-weight:700;text-decoration:none;text-shadow:1px 1px 0 #86ae47;padding:6px 24px;} -.button:hover{background:0;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#a5cc52',endColorstr='#b8e356');background-color:#a5cc52;} +.button{box-shadow:inset 0 1px 0 0 #d9fbbe;background:0;background-color:#b8e356;border-radius:6px;border:1px solid #83c41a;display:inline-block;color:#fff;font-family:arial;font-size:14px;font-weight:700;text-decoration:none;text-shadow:1px 1px 0 #86ae47;padding:6px 24px;} +.button:hover{background:0;background-color:#a5cc52;} .button:active{position:relative;top:1px;} -.buttonactive{background-color:#aaa;-moz-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;border:1px solid #83c41a;display:inline-block;color:#fff;font-family:arial;font-size:14px;font-weight:700;text-decoration:none;text-shadow:1px 1px 0 #86ae47;padding:6px 24px;} +.buttonactive{background-color:#aaa;border-radius:6px;border:1px solid #83c41a;display:inline-block;color:#fff;font-family:arial;font-size:14px;font-weight:700;text-decoration:none;text-shadow:1px 1px 0 #86ae47;padding:6px 24px;} @media screen and (max-width:1024px) { - .vignette { width: 40%; } + section#autoblogs > ul > li { width: 40%; } } @media screen and (max-width:640px) { h1 { font-size:20pt; } .button, .button:hover, .button:active, .buttonactive { display: block; margin: auto; text-align:center; } - .vignette { width: 80%; } + section#autoblogs > ul > li { width: 80%; } } @media screen and (max-width:480px) { #logo { max-width: 250px; } input[type="text"]{width:15em;} -} \ No newline at end of file +} diff --git a/resources/icon-generic.svg b/resources/icon-generic.svg new file mode 100644 index 0000000..6e8e68b --- /dev/null +++ b/resources/icon-generic.svg @@ -0,0 +1 @@ + diff --git a/resources/icon-logo.png b/resources/icon-logo.png new file mode 100644 index 0000000..62c6320 Binary files /dev/null and b/resources/icon-logo.png differ diff --git a/resources/icon-logo.svg b/resources/icon-logo.svg index e3045dd..f4692f5 100644 --- a/resources/icon-logo.svg +++ b/resources/icon-logo.svg @@ -1,218 +1,64 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/icon-microblog.svg b/resources/icon-microblog.svg new file mode 100644 index 0000000..6c93dc1 --- /dev/null +++ b/resources/icon-microblog.svg @@ -0,0 +1 @@ + diff --git a/resources/icon-shaarli.svg b/resources/icon-shaarli.svg new file mode 100644 index 0000000..e90e3e8 --- /dev/null +++ b/resources/icon-shaarli.svg @@ -0,0 +1 @@ + diff --git a/resources/icon-twitter.svg b/resources/icon-twitter.svg new file mode 100644 index 0000000..fb032ef --- /dev/null +++ b/resources/icon-twitter.svg @@ -0,0 +1 @@ + diff --git a/resources/icon-youtube.svg b/resources/icon-youtube.svg new file mode 100644 index 0000000..5799688 --- /dev/null +++ b/resources/icon-youtube.svg @@ -0,0 +1 @@ + diff --git a/twitter2feed.php b/twitter2feed.php new file mode 100755 index 0000000..d6ffd6f --- /dev/null +++ b/twitter2feed.php @@ -0,0 +1,125 @@ +\d+)"(.*)'. + '(data-retweet-id="(?P\d+)"(.*))?'. + 'data-screen-name="(?P[^"]+)"(.*)'. + '(?P<fullname>[^(.*)'. + 'data-time="(?P\d+)"(.*)'. + '

    (?P.*)

    '. + '%sU', $str, $arr); + + function parsemessage($message) + { + $message = preg_replace('%]+)>%', ']+)>https?://([^/]+)/[^<]*%', '[$2]', $message); + $message = strip_tags($message); + return $message; + } + + $fullname = "?"; + $updated = ""; + if ($nb !== false) + { + for ($i = 0; $i < $nb; $i++) + { + $mname = $arr["name"][$i]; + $mfullname = $arr["fullname"][$i]; + if ($updated == "") + $updated = date(DATE_ATOM, $arr["created"][$i]); + + if ($mname == $name) + { + $fullname = $mfullname; + break; + } + } + } + + header('Content-type: application/xml; charset=UTF-8', true); + echo '' . PHP_EOL; +?> + + Twitter / <?php echo $name ?> + tag:twitter.com,2013:Status: + + "> + + Twitter de . +@$mname : "; + + $title = htmlspecialchars(parsetitle($rt . $message)); + + $header = "\"$mname\"/ $mfullname (@$mname)
    \r\n"; + $footer = "
    \r\nAfficher la conversation"; + $message = "$header$rt$message$footer"; + $message = htmlspecialchars($message); + if(substr($title, 0, 1) !== $exclude_reply) { + echo << + $title + $message + tag:twitter.com,2013:https://twitter.com/$name/status/$id + $created + $created + + + + $name + https://twitter.com/$name + + +HTML; + } + } + } + +?> +
    + diff --git a/version b/version index 4cb2afc..d15723f 100755 --- a/version +++ b/version @@ -1 +1 @@ -0.3.0-DEV Build 1 \ No newline at end of file +0.3.2 diff --git a/xsaf3.php b/xsaf3.php index 08b3f10..fb1a9c1 100755 --- a/xsaf3.php +++ b/xsaf3.php @@ -2,10 +2,12 @@ define('DEBUG', false); define('XSAF_VERSION', 3); -define('AUTOBLOG_FILE_NAME', 'autoblog.php'); -define('ALLOW_REMOTE_DB_DL', false); -define('ALLOW_REMOTE_MEDIA_DL', false); -define('EXEC_TIME', 20); +define('AUTOBLOG_FILE_NAME', 'autoblog.php'); // useless ? +define('ALLOW_REMOTE_DB_DL', true); +define('ALLOW_REMOTE_MEDIA_DL', true); +define('EXEC_TIME', 10); + +date_default_timezone_set('UTC'); header("HTTP/1.0 403 Forbidden"); /* Uncivilized method to prevent bot indexing, huh :) */ header('X-Robots-Tag: noindex'); /* more civilized method, but bots may not all take into account */ @@ -75,17 +77,12 @@ function xsafimport($xsafremote, $max_exec_time) { $get_remote_media = ($json_import['meta']['xsaf-media_transfer'] == "true") ? true : false; if(!empty($json_import['autoblogs'])) { - foreach ($json_import['autoblogs'] as $value) { - + foreach ($json_import['autoblogs'] as $remote_folder => $value) { + 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'])) { $sitetype = escape($value['SITE_TYPE']); $sitename = escape($value['SITE_TITLE']); $siteurl = escape($value['SITE_URL']); - if(empty($value['SITE_META_DESCRIPTION'])){ - $siteDesc = getSiteDesc(escape($value['SITE_URL'])); - } else { - $siteDesc = escape($value['SITE_META_DESCRIPTION']); - } // 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 = escape($value['FEED_URL']); @@ -100,10 +97,10 @@ function xsafimport($xsafremote, $max_exec_time) { /* autoblog */ if( $result === true ) { - $foldername = urlToFolder($sitename, $rssurl); + $foldername = urlToFolder($siteurl, $rssurl); try { - createAutoblog($sitetype, $sitename, $siteurl, $rssurl,$siteDesc); + createAutoblog($sitetype, $sitename, $siteurl, $rssurl); if( DEBUG ) { echo '

    autoblog '. $sitename .' crée avec succès (DL DB : '. var_dump($get_remote_db) .' - DL media : '. var_dump($get_remote_media) .') : '. $foldername .'

    '; @@ -114,23 +111,23 @@ function xsafimport($xsafremote, $max_exec_time) { /* ============================================================================================================================================================================== */ /* récupération de la DB distante */ if($get_remote_db == true && ALLOW_REMOTE_DB_DL ) { - $remote_db = str_replace("?export", $foldername."/articles.db", $xsafremote); + $remote_db = str_replace("?export", $remote_folder."/articles.db", $xsafremote); copy($remote_db, './'. $foldername .'/articles.db'); } - + /* préparation à la récupération des médias distants */ if($get_remote_media == true && ALLOW_REMOTE_MEDIA_DL ) { - $remote_media=str_replace("?export", $foldername."/?media", $xsafremote); + $remote_media=str_replace("?export", $remote_folder."/?media", $xsafremote); + if(DEBUG) + debug("Récupération de la liste des médias à $remote_media
    "); $json_media_import = file_get_contents($remote_media); - if(!empty($json_media_import)) - { - mkdir('./'.$foldername.'/media/'); - $json_media_import = json_decode($json_media_import, true); - $media_path=$json_media_import['url']; - if(!empty($json_media_import['files'])) { - foreach ($json_media_import['files'] as $value) { - copy($media_path.$value, './'.$foldername.'/media/'.$value); - } - } + if(DEBUG) + debug($json_media_import); + $media_data = json_decode($json_media_import, true); + if(DEBUG) + debug($media_data); + if(!empty($json_media_import) && $media_data !== null && !empty($media_data['files'])) + { + file_put_contents('./'. $foldername .'/import.json', $json_media_import); } }