From 02b74c3bf2d5694b8c6e8e9c4e47e4455aba6bc2 Mon Sep 17 00:00:00 2001 From: Mitsukarenai Date: Sun, 14 Apr 2013 20:00:38 +0200 Subject: [PATCH] branched --- 0.1/README.md | 20 -- 0.1/index.php | 403 --------------------- 0.1/vvb.ini | 6 - 0.2/README.md | 24 -- 0.2/autoblog.php | 897 ---------------------------------------------- 0.2/config.php | 54 --- 0.2/icon-logo.svg | 1 - 0.2/index.php | 462 ------------------------ 0.2/xsaf2.php | 179 --------- 9 files changed, 2046 deletions(-) delete mode 100755 0.1/README.md delete mode 100755 0.1/index.php delete mode 100644 0.1/vvb.ini delete mode 100755 0.2/README.md delete mode 100755 0.2/autoblog.php delete mode 100755 0.2/config.php delete mode 100755 0.2/icon-logo.svg delete mode 100755 0.2/index.php delete mode 100755 0.2/xsaf2.php diff --git a/0.1/README.md b/0.1/README.md deleted file mode 100755 index f2b41be..0000000 --- a/0.1/README.md +++ /dev/null @@ -1,20 +0,0 @@ -Projet Autoblog serie 0.1 -============== - -- version VroumVroumBlog 0.1.32 - -Auteur: Sebastien Sauvage - -Licence: Domaine Public - -- À propos du Projet Autoblog - -lire: http://sebsauvage.net/streisand.me/fr/ - -- Contraintes techniques - -voir: http://sebsauvage.net/streisand.me/fr/tech.html - -- Instructions - -Personnalisez vvb.ini. Envoyez index.php et vvb.ini sur votre site web, dans le répertoire de votre choix. Terminé ! diff --git a/0.1/index.php b/0.1/index.php deleted file mode 100755 index 7fe2161..0000000 --- a/0.1/index.php +++ /dev/null @@ -1,403 +0,0 @@ -= 0) { libxml_disable_entity_loader(true); } - -$CONFIG=parse_ini_file('vvb.ini') or die('Missing or bad config file vvb.ini'); // Read config file. -$CONFIG['ARTICLES_PER_PAGE']=10; -$CONFIG['DOWNLOAD_MEDIA_TYPES']=array('jpeg','jpg','gif','png','pdf','txt','odt'); // Media types which will be downloaded. -$CONFIG['MEDIA_TO_DOWNLOAD']=array(); // List of media to download in background. -// ================================================================================================== -/* Callback for the preg_replace_callback() function in remapImageUrls() which remaps URLs to point to local cache. - (src=... and href=...) */ -function remap_callback($matches) -{ - global $CONFIG; - $attr = $matches[1]; $url = $matches[2]; $srchost=parse_url($url,PHP_URL_HOST); - if (!mediaAuthorized($url)) { return $attr.'="'.$url.'"'; } // Not authorized: do not remap URL. - if (!file_exists('media/'.sanitize($url)) ) { $CONFIG['MEDIA_TO_DOWNLOAD'][] = $url; } // If media not present in the cache, add URL to list of media to download in background. - return $attr.'="?m='.$url.'"'; // Return remapped URL. -} - -/* Remaps image URL to point to local cache (src= and href=) -eg. src="http://toto.com/..." --> src="?m=http://toto.com/..." -*/ -function remapImageUrls($html) -{ - return preg_replace_callback("@(src|href)=[\"\'](.+?)[\"\']@i",'remap_callback',$html); -} - -/* updateFeed(): Update articles database from a RSS2.0 feed. - Articles deleted from the feed are not deleted from the database. - You can force the refresh by passing ?force_the_refresh in URL. -*/ -function updateFeed() -{ - global $CONFIG; - // Only update feed if last check was > 60 minutes - // but you can force it with force_the_refresh in GET parameters. - if (@filemtime('store')>time()-(3600) && !isset($_GET['force_the_refresh'])) { return; } - - // Read database from disk - $feed_items=(file_exists('store') ? unserialize(file_get_contents('store')) : array() ); - - // Read the feed and update the database. - $xml = simplexml_load_file($CONFIG['FEED_URL']); - if (isset($xml->entry)) // ATOM feed. - { - foreach ($xml->entry as $item) - { - $pubDate=$item->published; if (!$pubDate) { $pubDate=$item->updated; } - $i=array('title'=>strval($item->title),'link'=>strval($item->link['href']),'guid'=>strval($item->id),'pubDate'=>strval($pubDate), - 'description'=>'','content'=>remapImageUrls(strval($item->content))); - $i['dateiso'] = date('Ymd_His', strtotime($i['pubDate'])); - $feed_items[$i['dateiso']] = $i; - } - } - elseif (isset($xml->item)) // RSS 1.0 /RDF - { - foreach ($xml->item as $item) - { - $guid =$item->attributes('http://www.w3.org/1999/02/22-rdf-syntax-ns#')->about; - $date =$item->children('http://purl.org/dc/elements/1.1/')->date; - $content = $item->children('http://purl.org/rss/1.0/modules/content/'); - $i=array('title'=>strval($item->title),'link'=>strval($item->link),'guid'=>strval($guid),'pubDate'=>strval($date), - 'description'=>strval($item->description),'content'=>remapImageUrls(strval($content))); - $i['dateiso'] = date('Ymd_His', strtotime($i['pubDate'])); - $feed_items[$i['dateiso']] = $i; - } - } - elseif (isset($xml->channel->item)) // RSS 2.0 - { - foreach ($xml->channel->item as $item) - { - $content = strval($item->children('http://purl.org/rss/1.0/modules/content/')); // Get - if (!$content) { $content = strval($item->description); } // Some feeds put content in the description. - $pubDate = $item->pubDate; - if (!$pubDate) { $pubDate=$item->children('http://purl.org/dc/elements/1.1/')->date; } // To read the tag content. - $i=array('title'=>strval($item->title),'link'=>strval($item->link),'guid'=>strval($item->guid),'pubDate'=>strval($pubDate), - 'description'=>strval($item->description),'content'=>remapImageUrls($content)); - $i['dateiso'] = date('Ymd_His', strtotime($i['pubDate'])); - $feed_items[$i['dateiso']] = $i; - } - } - krsort($feed_items); // Sort array, latest articles first. - file_put_contents('store', serialize($feed_items)); // Write database to disk -} - -/* feed(): Returns the feed as an associative array (latest articles first). - Key is timestamp in compact iso format (eg. '20110628_073208') - Value is an associative array (title,link,content,pubDate...) -*/ -function feed() -{ - $data=file_get_contents('store'); - if ($data===FALSE) { $feed_items=array(); } else { $feed_items = unserialize($data); } - return $feed_items; -} - -/* Remove accents (é-->e) */ -function replace_accents($str) { - $str = htmlentities($str, ENT_COMPAT, "UTF-8"); - $str = preg_replace('/&([a-zA-Z])(uml|acute|grave|circ|tilde);/','$1',$str); - return html_entity_decode($str); -} - -// Sanitize strings for use in filename or URLs -function sanitize($name) -{ - $fname=replace_accents($name); - $replace="_"; - $pattern="/([[:alnum:]_\.-]*)/"; // The autorized characters. - $fname=str_replace(str_split(preg_replace($pattern,$replace,$fname)),$replace,$fname); - return $fname; -} - -// Tells if a string start with a substring or not. -function startsWith($haystack,$needle,$case=true) { - if($case){return (strcmp(substr($haystack, 0, strlen($needle)),$needle)===0);} - return (strcasecmp(substr($haystack, 0, strlen($needle)),$needle)===0); -} -// Tells if a string ends with a substring or not. -function endsWith($haystack,$needle,$case=true) { - if($case){return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);} - return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0); -} - -/* Returns the CSS stylesheet to include in HTML document */ -function css() -{ - return << - - -HTML; -} - -/* Render a single article - $article : the article itself (associative array with title,pubDate,content,dateiso keys.) -*/ -function renderArticle($article) -{ - echo '
'; - echo '

'.$article['title'].'

'.$article['pubDate']; - if ($article['link']!='') { echo ' - (source)'; } - echo '
'.$article['content'].'
'; - echo '
'; -} - -function rssHeaderLink() { return ''; } -function searchForm() { return ''; } -function powered() { return '
Powered by VroumVroumBlog 0.1.32 - RSS Feed
Download config articles
'; } -function canonical_metatag($url) { return ''; } - -/* Show a single article - $articleid = article identifier (eg.'20110629_010334') -*/ -function showArticle($articleid) -{ - global $CONFIG; - header('Content-Type: text/html; charset=utf-8'); - $feed=feed();if (!array_key_exists($articleid,$feed)) { die('Article not found.'); } - $a=$feed[$articleid]; - echo ''.$a['title'].' - '.$CONFIG['SITE_TITLE'].''.canonical_metatag($a['link']).css().rssHeaderLink().''; - echo '

'.$CONFIG['SITE_TITLE'].'

'.$CONFIG['SITE_DESCRIPTION'].searchForm().'
'; - renderArticle($a); - echo ''.powered().''; -} - -/* Show a list of articles, starting at a specific page. - $page = start page. First page is page 1. -*/ -function showArticles($page) -{ - global $CONFIG; - header('Content-Type: text/html; charset=utf-8'); - $feed=feed(); - $keys=array_keys($feed); - echo ''.$CONFIG['SITE_TITLE'].''.canonical_metatag($CONFIG['SITE_URL']).css().rssHeaderLink().''; - echo '

'.$CONFIG['SITE_TITLE'].'

'.$CONFIG['SITE_DESCRIPTION'].searchForm().'
'; - $i = ($page-1)*$CONFIG['ARTICLES_PER_PAGE']; // Start index. - $end = $i+$CONFIG['ARTICLES_PER_PAGE']; - while ($i<$end && $i
'; - if ($i!=count($keys)) { echo ''; } - echo ''; - if ($page>1) { echo ''; } - echo '
'.powered().''; -} - -/* Search for text in articles content and title. - $textpage = text to search. -*/ -function search($text) -{ - global $CONFIG; - header('Content-Type: text/html; charset=utf-8'); - $txt = urldecode($text); - echo ''.$CONFIG['SITE_TITLE'].''.css().rssHeaderLink().''; - echo '

'.$CONFIG['SITE_TITLE'].'

'.$CONFIG['SITE_DESCRIPTION'].searchForm().'
'; - echo '
Search for '.htmlspecialchars($txt).' :
'; - $feed=feed(); - foreach($feed as $article) - { - if (stripos($article['content'],$txt) || stripos($article['title'],$txt)) { renderArticle($article); } - } - echo ''.powered().''; -} - -/* Tells if a media URL should be downloaded or not. - Input: $url = absolute URL of a media (jpeg,pdf...) - Output: true= can download. false= should not download (wrong host, wrong file extension) */ -function mediaAuthorized($url) -{ - global $CONFIG; - $goodhost=false; $srchost=parse_url($url,PHP_URL_HOST); - foreach( explode(',',$CONFIG['DOWNLOAD_MEDIA_FROM']) as $host) // Does the URL point to an authorized host ? - { if ($srchost==$host) { $goodhost=true; } } - if (!$goodhost) { return false; } // Wrong host. - $ext = pathinfo($url, PATHINFO_EXTENSION); // Get file extension (eg.'png','gif'...) - if (!in_array(strtolower($ext),$CONFIG['DOWNLOAD_MEDIA_TYPES'])) { return false; } // Not in authorized file extensions. - return true; -} - -// Returns the MIME type corresponding to a file extension. -// (I do not trust mime_content_type() because of some dodgy hosting providers with ill-configured magic.mime file.) -function mime_type($filename) -{ - $MIME_TYPES=array('.jpg'=>'image/jpeg','.jpeg'=>'image/jpeg','.png'=>'image/png','.gif'=>'image/gif', - '.txt'=>'text/plain','.odt'=>'application/vnd.oasis.opendocument.text'); - foreach($MIME_TYPES as $extension=>$mime_type) { if (endswith($filename,$extension,false)) { return $mime_type; } } - return 'application/octet-stream'; // For an unkown extension. -} -// Returns a media from the local cache (and download it if not available). -function showMedia($imgurl) -{ - if (!mediaAuthorized($imgurl)) { header('HTTP/1.1 404 Not Found'); return; } - downloadMedia($imgurl); // Will only download if necessary. - $filename = 'media/'.sanitize($imgurl); - header('Content-Type: '.mime_type($filename)); - readfile($filename); -} - -// Download a media to local cache (if necessary) -function downloadMedia($imgurl) -{ - $filename = 'media/'.sanitize($imgurl); - if (!file_exists($filename) ) // Only download image if not present - { - if (!is_dir('media')) { mkdir('media',0705); file_put_contents('media/index.html',' '); } - file_put_contents($filename, file_get_contents($imgurl,NULL, NULL, 0, 4000000)); // We download at most 4 Mb from source. - } -} - -/* Output the whole feed in RSS 2.0 format with article content (BIG!) */ -function outputFeed() -{ - global $CONFIG; - header('Content-Type: application/xhtml+xml; charset=utf-8'); - echo ''; - echo ''.htmlspecialchars($CONFIG['SITE_TITLE']).''.htmlspecialchars($CONFIG['SITE_URL']).''; - echo ''.htmlspecialchars($CONFIG['SITE_URL']).''."\n\n"; - $feed=feed(); - foreach($feed as $a) - { - echo ''.$a['title'].''.$a['guid'].'http://'.$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"].'?'.$a['dateiso'].'_'.sanitize($a['title']).''.$a['pubDate'].''; - echo ''."\n\n"; - } - echo ''; -} - -// ================================================================================================== -// Update feed if necessary. (you can force refresh with ?force_the_refresh in URL) -updateFeed(); - -// Handle media download requests (eg. http://myserver.com/?m=http___anotherserver.net_images_myimage.jpg) -if (startswith($_SERVER["QUERY_STRING"],'m=')) { showMedia(substr($_SERVER["QUERY_STRING"],2)); } - -// Handle single article URI (eg. http://myserver.com/?20110506_224455-chit-chat) -elseif (preg_match('/^(\d{8}_\d{6})/',$_SERVER["QUERY_STRING"],$matches)) { showArticle($matches[1]); } - -// Handle page URI (eg. http://myserver.com/?page5) -elseif (preg_match('/^page(\d+)/',$_SERVER["QUERY_STRING"],$matches)) { showArticles($matches[1]); } - -// Handle RSS 2.0 feed request (http://myserver.com/?feed) -elseif (startswith($_SERVER["QUERY_STRING"],'feed')) { outputFeed(); } - -// Handle search request (eg. http://myserver.com/?s=tuto4pc) -elseif (startswith($_SERVER["QUERY_STRING"],'s=')) { search(substr($_SERVER["QUERY_STRING"],2)); } - -// Nothing ? Then render page1. -else { showArticles(1); } - -// Force flush, rendered page is fully sent to browser. -ob_end_flush(); -flush(); - -// Now we've finised rendering the page and sending to the user, -// it's time for some background tasks: Are there media to download ? -foreach($CONFIG['MEDIA_TO_DOWNLOAD'] as $url) { downloadMedia($url); } - -exit; -?> \ No newline at end of file diff --git a/0.1/vvb.ini b/0.1/vvb.ini deleted file mode 100644 index 60ebaa3..0000000 --- a/0.1/vvb.ini +++ /dev/null @@ -1,6 +0,0 @@ -[VroumVroumBlogConfig] -SITE_TITLE="Autoblog de Sebsauvage" -SITE_DESCRIPTION="Ce site n'est pas le site officiel de Sebsauvage
C'est un blog automatisé qui réplique les articles de sebsauvage.net" -SITE_URL=http://sebsauvage.net/rhaa/ -FEED_URL=http://sebsauvage.net/rhaa/rss_fulltext.php -DOWNLOAD_MEDIA_FROM=sebsauvage.net diff --git a/0.2/README.md b/0.2/README.md deleted file mode 100755 index a071631..0000000 --- a/0.2/README.md +++ /dev/null @@ -1,24 +0,0 @@ -Projet Autoblog serie 0.2 -============== - -- version VroumVroumBlog 0.2.11 - -Auteurs: BohwaZ (VVB) & Arthur Hoaro, Mitsukarenai, Oros (index ferme d'autoblogs) - -Licence: Domaine Public - -- À propos du Projet Autoblog - -lire: http://sebsauvage.net/streisand.me/fr/ - -- Présentation et Instructions pour VVB 0.2 (par BohwaZ) - -voir: http://blogs.kd2.org/bohwaz/?2011/07/14/369-auto-blog-vroumvroumblog-et-effet-streisand - -- Présentation et Instructions pour la ferme d'autoblogs (par Arthur Hoaro) - -voir: http://wiki.hoa.ro/doku.php?id=web%3Aferme-autoblog - -- Améliorations pour la ferme d'autoblogs et XSAF (par Mitsukarenai et Oros) - -voir: https://www.suumitsu.eu/2012/08/autoblogs-petites-ameliorations/ diff --git a/0.2/autoblog.php b/0.2/autoblog.php deleted file mode 100755 index 647d4d1..0000000 --- a/0.2/autoblog.php +++ /dev/null @@ -1,897 +0,0 @@ -=')) - die("This software requires PHP version 5.3.0 at least, yours is ".phpversion()); - -if (!class_exists('SQLite3')) - die("This software requires the SQLite3 PHP extension, and it can't be found on this system!"); - -libxml_disable_entity_loader(true); - -// Config and data file locations - -if (file_exists(__DIR__ . '/config.php')) -{ - require_once __DIR__ . '/config.php'; -} - -if (!defined('ROOT_DIR')) - define('ROOT_DIR', __DIR__); - -if (!defined('CONFIG_FILE')) define('CONFIG_FILE', ROOT_DIR . '/vvb.ini'); -if (!defined('ARTICLES_DB_FILE')) define('ARTICLES_DB_FILE', ROOT_DIR . '/articles.db'); -if (!defined('LOCAL_DB_FILE')) define('LOCAL_DB_FILE', ROOT_DIR . '/local.db'); -if (!defined('MEDIA_DIR')) define('MEDIA_DIR', ROOT_DIR . '/media'); - -if (!defined('LOCAL_URL')) -{ - // Automagic URL discover - $path = substr(ROOT_DIR, strlen($_SERVER['DOCUMENT_ROOT'])); - $path = (!empty($path[0]) && $path[0] != '/') ? '/' . $path : $path; - $path = (substr($path, -1) != '/') ? $path . '/' : $path; - define('LOCAL_URL', 'http' . (!empty($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $path); -} - -if (!defined('LOCAL_URI')) -{ - // filename - define('LOCAL_URI', (basename($_SERVER['SCRIPT_FILENAME']) == 'index.php' ? '' : basename($_SERVER['SCRIPT_FILENAME'])) . '?'); -} - -if (!function_exists('__')) -{ - // Translation? - function __($str) - { - if ($str == '_date_format') - return '%A %e %B %Y at %H:%M'; - else - return $str; - } -} - -// ERROR MANAGEMENT - -class VroumVroum_User_Exception extends Exception {} - -class VroumVroum_Feed_Exception extends Exception -{ - static public function getXMLErrorsAsString($errors) - { - $out = array(); - - foreach ($errors as $error) - { - $return = $xml[$error->line - 1] . "\n"; - $return .= str_repeat('-', $error->column) . "^\n"; - - switch ($error->level) { - case LIBXML_ERR_WARNING: - $return .= "Warning ".$error->code.": "; - break; - case LIBXML_ERR_ERROR: - $return .= "Error ".$error->code.": "; - break; - case LIBXML_ERR_FATAL: - $return .= "Fatal Error ".$error->code.": "; - break; - } - - $return .= trim($error->message) . - "\n Line: ".$error->line . - "\n Column: ".$error->column; - - if ($error->file) { - $return .= "\n File: ".$error->file; - } - - $out[] = $return; - } - - return $out; - } -} - -error_reporting(E_ALL); - -function exception_error_handler($errno, $errstr, $errfile, $errline ) -{ - // For @ ignored errors - if (error_reporting() === 0) return; - throw new ErrorException($errstr, 0, $errno, $errfile, $errline); -} - -function exception_handler($e) -{ - if ($e instanceOf VroumVroum_User_Exception) - { - echo '

'.$e->getMessage().'

'; - exit; - } - - $error = "Error happened !\n\n". - $e->getCode()." - ".$e->getMessage()."\n\nIn: ". - $e->getFile() . ":" . $e->getLine()."\n\n"; - - if (!empty($_SERVER['HTTP_HOST'])) - $error .= 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."\n\n"; - - $error .= $e->getTraceAsString(); - //$error .= print_r($_SERVER, true); - - echo $error; - exit; -} - -set_error_handler("exception_error_handler"); -set_exception_handler("exception_handler"); - -// CONFIGURATION - -class VroumVroum_Config -{ - public $site_title = ''; - public $site_description = ''; - public $site_url = ''; - public $feed_url = ''; - public $download_media_from = null; - public $download_media_types = 'jpg,jpeg,png,gif,pdf'; - public $articles_per_page = 10; - public $update_interval = 3600; - public $update_timeout = 10; - - public function __construct() - { - if (!file_exists(CONFIG_FILE)) - throw new VroumVroum_User_Exception("Missing configuration file '".basename(CONFIG_FILE)."'."); - - $ini = parse_ini_file(CONFIG_FILE); - - foreach ($ini as $key=>$value) - { - $key = strtolower($key); - - if (!property_exists($this, $key)) - continue; // Unknown config - - if (is_string($this->$key) || is_null($this->$key)) - $this->$key = trim((string) $value); - elseif (is_int($this->$key)) - $this->$key = (int) $value; - elseif (is_bool($this->$key)) - $this->$key = (bool) $value; - } - - // Check that all required values are filled - $check = array('site_title', 'site_url', 'feed_url', 'update_timeout', 'update_interval', 'articles_per_page'); - foreach ($check as $c) - { - if (!trim($this->$c)) - throw new VroumVroum_User_Exception("Missing or empty configuration value '".$c."' which is required!"); - } - - // Default value - if (is_null($this->download_media_from)) - { - $this->download_media_from = preg_replace('!^https?://([^/]+).*$!', '\\1', $this->site_url); - } - } - - public function __set($key, $value) - { - return; - } -} - -// BLOG - -class VroumVroum_Blog -{ - const VERSION = '0.2.11'; - - protected $articles = null; - protected $local = null; - - public $config = null; - - static public function removeHTML($str) - { - $str = strip_tags($str); - $str = html_entity_decode($str, ENT_QUOTES, 'UTF-8'); - return $str; - } - - static public function toURI($str) - { - $uri = self::removeHTML(trim($str)); - $uri = substr($uri, 0, 70); - $uri = preg_replace('/[^\w\d()\p{L}]+/u', '-', $uri); - $uri = preg_replace('/-{2,}/', '-', $uri); - $uri = preg_replace('/^-|-$/', '', $uri); - return $uri; - } - - public function __construct() - { - $this->config = new VroumVroum_Config; - - $create_articles_db = file_exists(ARTICLES_DB_FILE) ? false : true; - $create_local_db = file_exists(LOCAL_DB_FILE) ? false : true; - - $this->articles = new SQLite3(ARTICLES_DB_FILE); - $this->local = new SQLite3(LOCAL_DB_FILE); - - 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 UNIQUE INDEX feed_id ON articles (feed_id); - CREATE INDEX date ON articles (date); - '); - } - - if ($create_local_db) - { - $this->local->exec(' - CREATE VIRTUAL TABLE search USING fts3 ( - id INT PRIMARY KEY, - title TEXT, - content TEXT - ); - - CREATE TABLE update_log ( - date INT PRIMARY KEY, - success INT, - log TEXT - );'); - } - - $this->local->createFunction('countintegers', array($this, 'sql_countintegers')); - } - - public function getLocalURL($in) - { - return LOCAL_URL . LOCAL_URI . (is_array($in) ? $in['uri'] : $in); - } - - protected function log_update($success, $log = '') - { - $this->local->exec('INSERT INTO update_log (date, success, log) VALUES (\''.time().'\', \''.(int)(bool)$success.'\', - \''.$this->articles->escapeString($log).'\');'); - - // Delete old log - $this->local->exec('DELETE FROM update_log WHERE date > (SELECT date FROM update_log ORDER BY date DESC LIMIT 100,1);'); - - return true; - } - - public function insertOrUpdateArticle($feed_id, $title, $url, $date, $content) - { - $exists = $this->articles->querySingle('SELECT date, id, title, content FROM articles WHERE feed_id = \''.$this->articles->escapeString($feed_id).'\';', true); - - if (empty($exists)) - { - $uri = self::toURI($title); - - if ($this->articles->querySingle('SELECT 1 FROM articles WHERE uri = \''.$this->articles->escapeString($uri).'\';')) - { - $uri = date('Y-m-d-') . $uri; - } - - if (!empty($this->config->download_media_from) && !empty($this->config->download_media_types)) - $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).'\');'); - - $id = $this->articles->lastInsertRowId(); - - $title = self::removeHTML($title); - $content = self::removeHTML($content); - - $this->local->exec('INSERT INTO search (id, title, content) VALUES (\''.(int)$id.'\', - \''.$this->local->escapeString($title).'\', \''.$this->local->escapeString($content).'\');'); - } - else - { - // Doesn't need update - if ($date == $exists['date'] && $content == $exists['content'] && $title == $exists['title']) - { - return false; - } - - $id = $exists['id']; - - if ($content != $exists['content'] && !empty($this->config->download_media_from) && !empty($this->config->download_media_types)) - $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.'\';'); - - $title = self::removeHTML($title); - $content = self::removeHTML($content); - - $this->local->exec('UPDATE search SET title=\''.$this->local->escapeString($title).'\', - content=\''.$this->local->escapeString($content).'\' WHERE id = \''.(int)$id.'\';'); - } - - return $id; - } - - public function mustUpdate() - { - if (isset($_GET['update'])) - return true; - - $last_update = $this->local->querySingle('SELECT date FROM update_log ORDER BY date DESC LIMIT 1;'); - - if (!empty($last_update) && (int) $last_update > (time() - $this->config->update_interval)) - return false; - - return true; - } - - protected function _getStreamContext() - { - return stream_context_create( - array( - 'http' => array( - 'method' => 'GET', - 'timeout' => $this->config->update_timeout, - 'header' => "User-Agent: Opera/9.80 (X11; Linux i686; U; fr) Presto/2.2.15 Version/10.10\r\n", - ) - ) - ); - } - - public function update() - { - if (!$this->mustUpdate()) - return false; - - try { - $body = file_get_contents($this->config->feed_url, false, $this->_getStreamContext()); - } - catch (ErrorException $e) - { - $this->log_update(false, $e->getMessage() . "\n\n" . (!empty($http_response_header) ? implode("\n", $http_response_header) : '')); - throw new VroumVroum_Feed_Exception("Can't retrieve feed: ".$e->getMessage()); - } - - libxml_use_internal_errors(true); - $xml = @simplexml_load_string($body); - - if (!$xml) - { - $errors = VroumVroum_Feed_Exception::getXMLErrorsAsString(libxml_get_errors()); - $this->log_update(false, implode("\n", $errors) . "\n\n" . $body); - throw new VroumVroum_Feed_Exception("Feed is invalid - XML error: ".implode(" - ", $errors)); - } - - $updated = 0; - $this->local->exec('BEGIN TRANSACTION;'); - $this->articles->exec('BEGIN TRANSACTION;'); - - if (isset($xml->entry)) // ATOM feed - { - foreach ($xml->entry as $item) - { - $date = isset($item->published) ? (string) $item->published : (string) $item->updated; - $guid = !empty($item->id) ? (string)$item->id : (string)$item->link['href']; - - $id = $this->insertOrUpdateArticle($guid, (string)$item->title, - (string)$item->link['href'], strtotime($date), (string)$item->content); - - if ($id !== false) - $updated++; - } - } - elseif (isset($xml->item)) // RSS 1.0 /RDF - { - foreach ($xml->item as $item) - { - $guid = (string) $item->attributes('http://www.w3.org/1999/02/22-rdf-syntax-ns#')->about ?: (string)$item->link; - $date = (string) $item->children('http://purl.org/dc/elements/1.1/')->date; - - $id = $this->insertOrUpdateArticle($guid, (string)$item->title, (string)$item->link, - strtotime($date), (string) $item->children('http://purl.org/rss/1.0/modules/content/')); - - if ($id !== false) - $updated++; - } - } - elseif (isset($xml->channel->item)) // RSS 2.0 - { - foreach ($xml->channel->item as $item) - { - $content = (string) $item->children('http://purl.org/rss/1.0/modules/content/'); - $guid = !empty($item->guid) ? (string) $item->guid : (string) $item->link; - - if (empty($content) && !empty($item->description)) - $content = (string) $item->description; - - $id = $this->insertOrUpdateArticle($guid, (string)$item->title, (string)$item->link, - strtotime((string) $item->pubDate), $content); - - if ($id !== false) - $updated++; - } - } - else - { - throw new VroumVroum_Feed_Exception("Unknown feed type?!"); - } - - $this->log_update(true, $updated . " elements updated"); - - $this->articles->exec('END TRANSACTION;'); - $this->local->exec('END TRANSACTION;'); - - return $updated; - } - - public function listArticlesByPage($page = 1) - { - $nb = $this->config->articles_per_page; - $begin = ($page - 1) * $nb; - $res = $this->articles->query('SELECT * FROM articles ORDER BY date DESC LIMIT '.(int)$begin.','.(int)$nb.';'); - - $out = array(); - - while ($row = $res->fetchArray(SQLITE3_ASSOC)) - { - $out[] = $row; - } - - return $out; - } - - public function listLastArticles() - { - return array_merge($this->listArticlesByPage(1), $this->listArticlesByPage(2)); - } - - public function countArticles() - { - return $this->articles->querySingle('SELECT COUNT(*) FROM articles;'); - } - - public function getArticleFromURI($uri) - { - return $this->articles->querySingle('SELECT * FROM articles WHERE uri = \''.$this->articles->escapeString($uri).'\';', true); - } - - public function sql_countintegers($in) - { - return substr_count($in, ' '); - } - - public function searchArticles($query) - { - $res = $this->local->query('SELECT id, title, snippet(search, "", "", "...", -1, -40) AS snippet - FROM search - WHERE search MATCH \''.$this->local->escapeString($query).'\' - ORDER BY countintegers(offsets(search)) DESC - LIMIT 0,100;'); - - $out = array(); - - while ($row = $res->fetchArray(SQLITE3_ASSOC)) - { - $row['url'] = $this->getLocalURL($this->articles->querySingle('SELECT uri FROM articles WHERE id = \''.(int)$row['id'].'\';')); - $out[] = $row; - } - - return $out; - } - - public function mirrorMediasForArticle($content, $url) - { - if (!file_exists(MEDIA_DIR)) - { - mkdir(MEDIA_DIR); - } - - $extensions = explode(',', preg_quote($this->config->download_media_types, '!')); - $extensions = implode('|', $extensions); - - $hosts = explode(',', preg_quote($this->config->download_media_from, '!')); - $hosts = implode('|', $hosts); - $hosts = str_replace('\\*', '.*', $hosts); - - $schemes = array('http', 'https'); - - $from = parse_url($url); - $from['path'] = preg_replace('![^/]*$!', '', $from['path']); - - preg_match_all('!(src|href)\s*=\s*[\'"]?([^"\'<>\s]+\.(?:'.$extensions.'))[\'"]?!i', $content, $match, PREG_SET_ORDER); - - foreach ($match as $m) - { - $url = parse_url($m[2]); - - if (empty($url['scheme'])) - $url['scheme'] = $from['scheme']; - - if (empty($url['host'])) - $url['host'] = $from['host']; - - if (!in_array(strtolower($url['scheme']), $schemes)) - continue; - - if (!preg_match('!^(?:'.$hosts.')$!i', $url['host'])) - continue; - - if ($url['path'][0] != '/') - $url['path'] = $from['path'] . $url['path']; - - $filename = basename($url['path']); - $url = $url['scheme'] . '://' . $url['host'] . $url['path']; - - $filename = substr(sha1($url), -8) . '.' . substr(preg_replace('![^\w\d_.-]!', '', $filename), -64); - $copied = false; - - if (!file_exists(MEDIA_DIR . '/' . $filename)) - { - try { - $copied = $this->_copy($url, MEDIA_DIR . '/' . $filename); - } - catch (ErrorException $e) - { - // Ignore copy errors - } - } - - if ($copied) - { - $content = str_replace($m[0], $m[1] . '="media/'.$filename.'" data-original-source="'.$url.'"', $content); - } - else - { - $content = str_replace($m[0], $m[1] . '="'.$url.'"', $content); - } - } - - return $content; - } - - /* copy() is buggy with http streams and safe_mode enabled (which is bad), so here's a workaround */ - protected function _copy($from, $to) - { - $in = fopen($from, 'r', false, $this->_getStreamContext()); - $out = fopen($to, 'w', false); - $size = stream_copy_to_stream($in, $out); - fclose($in); - fclose($out); - return $size; - } -} - -// DISPLAY AND CONTROLLERS - -$vvb = new VroumVroum_Blog; -$config = $vvb->config; - -if (isset($_GET['feed'])) // FEED -{ - header('Content-Type: application/xhtml+xml; charset=utf-8'); - echo ' - - - '.escape($config->site_title).' - '.escape($config->site_url).' - '.escape(html_entity_decode(strip_tags($config->site_description), ENT_COMPAT, 'UTF-8')).' - - '; - - foreach($vvb->listLastArticles() as $art) - { - echo ' - - '.escape($art['title']).' - '.escape($art['feed_id']).' - '.$vvb->getLocalURL($art).' - '.date(DATE_RSS, $art['date']).' - - - - - - - '; - } - - echo ' - - '; - exit; -} - -if (isset($_GET['update'])) -{ - $_SERVER['QUERY_STRING'] = ''; -} - -// CONTROLLERS -$search = !empty($_GET['q']) ? trim($_GET['q']) : ''; -$article = null; - -if (!$search && !empty($_SERVER['QUERY_STRING']) && !is_numeric($_SERVER['QUERY_STRING'])) -{ - $uri = rawurldecode($_SERVER['QUERY_STRING']); - $article = $vvb->getArticleFromURI($uri); - - if (!$article) - { - header('HTTP/1.1 404 Not Found', true, 404); - } -} - -// HTML HEADER -echo ' - - - - - '.escape($config->site_title).' - - - - - -
-

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

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

'.$config->site_description.'

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

'.__('Update').'

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

'.__('Search').'

-

'.$text.'

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

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

-

'.$art['snippet'].'

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

'.__('Not Found').'

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

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

' : '').' -

'.__('Article not found.').'

-
-
'; - } - else - { - display_article($article); - } -} -else -{ - if (!empty($_SERVER['QUERY_STRING']) && is_numeric($_SERVER['QUERY_STRING'])) - $page = (int) $_SERVER['QUERY_STRING']; - else - $page = 1; - - $list = $vvb->listArticlesByPage($page); - - foreach ($list as $article) - { - display_article($article); - } - - $max = $vvb->countArticles(); - if ($max > $config->articles_per_page) - { - echo ''; - } -} - -echo ' -'; - -if ($vvb->mustUpdate()) -{ - try { - ob_end_flush(); - flush(); - } - catch (Exception $e) - { - // Silent, not critical - } - - try { - $updated = $vvb->update(); - } - catch (VroumVroum_Feed_Exception $e) - { - echo ' -
- '.escape($e->getMessage()).' -
'; - $updated = 0; - } - - if ($updated > 0) - { - echo ' - '; - } - else - { - echo ' - '; - } -} - -echo ' - -'; - -// Escaping HTML strings -function escape($str) -{ - return htmlspecialchars($str, ENT_COMPAT, 'UTF-8', false); -} - -function escape_content($str) -{ - $str = preg_replace('!<\s*(style|script|link)!', '<\\1', $str); - $str = str_replace('="media/', '="'.LOCAL_URL.'media/', $str); - return $str; -} - -// ARTICLE HTML CODE -function display_article($article) -{ - global $vvb, $config; - echo ' -
-
-

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

-

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

-
-
'.escape_content($article['content']).'
-

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

-
-
'; -} - -function get_css() -{ - return ' - * { margin: 0; padding: 0; } - body { font-family:"Trebuchet MS",Verdana,Arial,Helvetica,sans-serif; background-color: #3E4B50; padding: 1%; color: #000; } - img { max-width: 100%; height: auto; } - .header h1 { text-shadow: 2px 2px 2px #000; } - .header h1 a { text-decoration: none; color: #eee; } - .header { padding: 1% 3%; color: #eee; margin: 0 10%; border-bottom: 1px solid #aaa; background: #6A6A6A; } - .header p a { color: #bbb; } - .header p a:hover { color:#FFFFC9; text-decoration:none;} - .article .title h2 { margin: 0; color:#666; text-shadow: 1px 1px 1px #fff; } - .article .title h2 a { color:#666; text-decoration:none; } - .article .title h2 a:hover { color:#403976; } - .pagination { margin: 0 10%; padding: 1% 2%; background: #6A6A6A; } - .pagination b { font-size: 1.2em; color: #ffffc9; } - .pagination a { color:#ccc; margin: 0 0.5em; } - .pagination a:hover { color:#FFFFC9; } - .article { margin: 0 10%; padding: 1% 2%; background: #ccc; border-bottom: 1px solid #888; } - .article h4 { font-weight: normal; font-size: small; color: #666; } - .article .title { margin-bottom: 1em; } - .article .source { font-size: 0.8em; color: #666; } - .article .source a { color: #666; } - .searchForm { float:right; background: #6a6a6a; border: 1px solid #aaa; border-top: none; padding: 0 0.3em 0.3em; margin-top: 1.3%; } - .searchForm input { padding: 0.2em; border: 1px solid #999; background: #eee; color: #000; } - .footer { text-align:center; font-size: small; color:#aaa; clear: both; } - .footer a { color:#ccc; } - .footer a:hover { color:#FFFFC9; } - .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; } - .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; }'; -} - -?> diff --git a/0.2/config.php b/0.2/config.php deleted file mode 100755 index 1c3ec6a..0000000 --- a/0.2/config.php +++ /dev/null @@ -1,54 +0,0 @@ -%d results for %s': - return '%d résultats pour la recherche %s'; - case 'Not Found': - return 'Introuvable'; - case 'Article not found.': - return 'Cet article n\'a pas été trouvé.'; - case 'Older': - return 'Plus anciens'; - case 'Newer': - return 'Plus récents'; - case 'RSS Feed': - return 'Flux RSS'; - case 'Update complete!': - return 'Mise à jour terminée !'; - case 'Click here to reload this webpage.': - return 'Cliquez ici pour recharger cette page.'; - case 'Source:': - return 'Source :'; - case '_date_format': - return '%A %e %B %Y à %H:%M'; - case 'configuration': - case 'articles': - return $str; - } -} - -// Logo à utiliser -$logo="./icon-logo.svg"; - -// Marquez ici votre propre message qui apparaîtra en bas de page. -// exemple : -// $HTML_footer="
Love data
Data is essential
Data must flow
Data must be used
Data is neither good nor bad
There is no illegal data
Data is free
Data can not be owned
No man, machine or system shall interrupt the flow of data
Locking data is a crime against datanity"; -$HTML_footer=""; - -?> diff --git a/0.2/icon-logo.svg b/0.2/icon-logo.svg deleted file mode 100755 index 1b73481..0000000 --- a/0.2/icon-logo.svg +++ /dev/null @@ -1 +0,0 @@ -Never surrenderto censorship diff --git a/0.2/index.php b/0.2/index.php deleted file mode 100755 index e57fc2b..0000000 --- a/0.2/index.php +++ /dev/null @@ -1,462 +0,0 @@ -loadXML($data) or die('xml malformé'); - $title = $dom->getElementsByTagName('title'); - return $title->item(0)->nodeValue; - } - -function get_link_from_feed($url) - { - // get site link from feed - $data = file_get_contents("$url"); - $xml = simplexml_load_string($data); // quick feed check - if (isset($xml->entry)) // ATOM feed. - {$result="true";} - elseif (isset($xml->item)) // RSS 1.0 /RDF - {$result="true";} - elseif (isset($xml->channel->item)) // RSS 2.0 - {$result="true";} - else - {$result="false";} - if($result == "false") { die('le flux n\'a pas une syntaxe valide'); } - $check = substr($data, 0, 5); - if($check !== 'channel->link; - if($channel['link'] === NULL) - { - $dom = new DOMDocument; - $dom->loadXML($data) or die('xml malformé'); - $link = $dom->getElementsByTagName('uri'); - return $link->item(0)->nodeValue; - } - else - { - return $channel['link']; - } - } - -function serverUrl() -{ - $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"]); - return 'http'.($https?'s':'').'://'.$_SERVER["SERVER_NAME"].$serverport; -} - -function NoProtocolSiteURL($url) - { - $siteurlnoprototypes = array("http://", "https://"); - $siteurlnoproto = str_replace($siteurlnoprototypes, "", $url); - return $siteurlnoproto; - } - -function DetectRedirect($url) -{ -$response = get_headers($url, 1); -if(!empty($response['Location'])) - { - $response2 = get_headers($response['Location'], 1); - if(!empty($response2['Location'])) - {die('too much redirection');} - else { return $response['Location']; } - } -else - { - return $url; - } -} - -if (isset($_GET['check'])) -{ -$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=''; - - if(strpos($_GET['check'], 'twitter') !== FALSE) { header('Content-type: image/svg+xml');die($svg_twitter); } - if(strpos($_GET['check'], 'identica') !== FALSE) { header('Content-type: image/svg+xml');die($svg_identica); } - if(strpos($_GET['check'], 'statusnet') !== FALSE) { header('Content-type: image/svg+xml');die($svg_statusnet); } - - $errorlog="./".$_GET['check']."/error.log"; - 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 */ - { - header('Content-type: image/svg+xml'); - if(filesize($errorlog) == "0") {die($svg_vert);} - else if(filesize($errorlog) == "1") {die($svg_jaune);} - else {die($svg_rouge);} - } - else /* ..sinon, lancer la procédure de contrôle */ - { - $ini = parse_ini_file("./".$_GET['check']."/vvb.ini") or die; - header('Content-type: image/svg+xml'); - $headers = get_headers("$ini[FEED_URL]"); - if(empty($headers)) { file_put_contents($errorlog, '..'); die($svg_rouge); } /* le flux est indisponible (typiquement: erreur DNS ou possible censure) - à vérifier */ - $code=explode(" ", $headers[0]); - if($code[1] == "200") { file_put_contents($errorlog, ''); die($svg_vert);} /* code retour 200: flux disponible */ - else {file_put_contents($errorlog, '.'); die($svg_jaune);} /* autre code retour: un truc a changé (redirection, changement de CMS, .. bref vvb.ini doit être corrigé) */ - } -} - -if (isset($_GET['export'])) -// autoblog exporting -{ -header('Content-Type: application/json'); -$directory = "./"; -$subdirs = glob($directory . "*"); -foreach($subdirs as $unit) - { - if(is_dir($unit)) - { - $unit=substr($unit, 2); - $ini = parse_ini_file($unit.'/vvb.ini'); - $config = new stdClass; - foreach ($ini as $key=>$value) - { - $key = strtolower($key); - $config->$key = $value; - } - unset($ini); - $title=$config->site_title; - $url=$config->site_url; - $feed=$config->feed_url; - $reponse[$unit] = array("$title", "$url", "$feed"); - } - } -echo json_encode($reponse); -die; -} - -if (isset($_GET['feedexport'])) -// autoblog exporting -feed only -{ -header('Content-Type: application/json'); -$directory = "./"; -$reponse=""; -$subdirs = glob($directory . "*"); -foreach($subdirs as $unit) - { - if(is_dir($unit)) - { - $unit=substr($unit, 2); - $ini = parse_ini_file($unit.'/vvb.ini'); - $config = new stdClass; - foreach ($ini as $key=>$value) - { - $key = strtolower($key); - $config->$key = $value; - } - unset($ini); - $feed=$config->feed_url; - $reponse=$reponse.";$feed"; - } - } -$reponse=substr($reponse, 1); -echo json_encode(explode(';', $reponse)); -die; -} - -if (isset($_GET['sitemap'])) -// url-list sitemap -{ -header('Content-Type: text/plain'); -$directory = "./"; -$subdirs = glob($directory . "*"); -foreach($subdirs as $unit) - { - if(is_dir($unit)) - { - $unit=substr($unit, 2); - $proto=$_SERVER['HTTPS']?"https://":"http://"; - echo $proto.$_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'], 0, -9)."$unit/"."\n"; - } - } -die; -} - -function escape($str) -{ - return htmlspecialchars($str, ENT_COMPAT, 'UTF-8', false); -} - -$form = '

-
'; - -if(!empty($_GET['via_button']) && !empty($_GET['rssurl']) && $_GET['number'] === '17') -{ - if(isset($_GET['add']) && $_GET['add'] === '1' && !empty($_GET['siteurl']) && !empty($_GET['sitename'])) - { - $rssurl = DetectRedirect(escape($_GET['rssurl'])); - $siteurl = escape($_GET['siteurl']); - $foldername = sha1(NoProtocolSiteURL($siteurl)); - if(substr($siteurl, -1) == '/'){ $foldername2 = sha1(NoProtocolSiteURL(substr($siteurl, 0, -1))); }else{ $foldername2 = sha1(NoProtocolSiteURL($siteurl).'/');} - $sitename = escape($_GET['sitename']); - $sitedomain1 = preg_split('/\//', $siteurl, 0); - $sitedomain2=$sitedomain1[2]; - $sitedomain3=explode(".", $sitedomain2); - $sitedomain3=array_reverse($sitedomain3); - $sitedomain = $sitedomain3[1].'.'.$sitedomain3[0]; - if(file_exists($foldername) || file_exists($foldername2)) { die('Erreur: l\'autoblog existe déjà.'); } - if ( mkdir('./'. $foldername, 0755, false) ) { - $fp = fopen('./'. $foldername .'/index.php', 'w+'); - if( !fwrite($fp, "") ) - {die("Impossible d'écrire le fichier index.php");} - fclose($fp); - $fp = fopen('./'. $foldername .'/vvb.ini', 'w+'); - if( !fwrite($fp, '[VroumVroumBlogConfig] -SITE_TITLE="'. $sitename .'" -SITE_DESCRIPTION="Ce site n\'est pas le site officiel de '. $sitename .'
C\'est un blog automatisé qui réplique les articles de '. $sitename .'" -SITE_URL="'. $siteurl .'" -FEED_URL="'. $rssurl .'" -DOWNLOAD_MEDIA_FROM='.$sitedomain) ) - {die("Impossible d'écrire le fichier vvb.ini");} - fclose($fp); - {die('autoblog crée avec succès.afficher l\'autoblog');} - } -else - {die("Impossible de créer le répertoire.");} - - } - else - { - // checking procedure - $rssurl = DetectRedirect($_GET['rssurl']); - $siteurl = get_link_from_feed($rssurl); - $foldername = sha1(NoProtocolSiteURL($siteurl)); - if(substr($siteurl, -1) == '/'){ $foldername2 = sha1(NoProtocolSiteURL(substr($siteurl, 0, -1))); }else{ $foldername2 = sha1(NoProtocolSiteURL($siteurl).'/');} - $sitename = get_title_from_feed($rssurl); - $sitedomain1 = preg_split('/\//', $siteurl, 0);$sitedomain2=$sitedomain1[2];$sitedomain3=explode(".", $sitedomain2);$sitedomain3=array_reverse($sitedomain3);$sitedomain = $sitedomain3[1].'.'.$sitedomain3[0]; - if(file_exists($foldername) || file_exists($foldername2)) { die('Erreur: l\'autoblog existe déjà.'); } - $form = 'Merci de vérifier les informations suivantes, corrigez si nécessaire.
-
- -
-
-
-
'; - echo $form; die; - } -} - -if(!empty($_POST['socialaccount']) && !empty($_POST['socialinstance'])) -{ -$socialaccount = strtolower(escape($_POST['socialaccount'])); - if(escape($_POST['socialinstance']) === 'twitter') { $socialinstance = 'twitter'; } - if(escape($_POST['socialinstance']) === 'identica') { $socialinstance = 'identica'; } - if(escape($_POST['socialinstance']) === 'statusnet') { $socialinstance = 'statusnet'; } - $folder = "$socialinstance-$socialaccount";if(file_exists($folder)) { die('Erreur: l\'autoblog existe déjà.'); } - if($socialinstance === 'twitter') { $siteurl = "http://twitter.com/$socialaccount"; $rssurl = "http://api.twitter.com.nyud.net/1/statuses/user_timeline.rss?screen_name=$socialaccount"; } - if($socialinstance === 'identica') { $siteurl = "http://identi.ca/$socialaccount"; $rssurl = "http://identi.ca.nyud.net/api/statuses/user_timeline/$socialaccount.rss"; } - if($socialinstance === 'statusnet' && !empty($_POST['socialurl'])) { $siteurl = "http://".escape($_POST['socialurl'])."/$socialaccount"; $rssurl = "http://".escape($_POST['socialurl'])."/api/statuses/user_timeline/$socialaccount.rss"; } - $headers = get_headers($rssurl, 1); - if (strpos($headers[0], '200') == FALSE) {$error[] = "Flux inaccessible (compte inexistant ?)";} else { } -if( empty($error) ) { - if( !preg_match('#\.\.|/#', $folder) ) { - if ( mkdir('./'. $folder, 0755, false) ) { - $fp = fopen('./'. $folder .'/index.php', 'w+'); - if( !fwrite($fp, "") ) - $error[] = "Impossible d'écrire le fichier index.php"; - fclose($fp); - $fp = fopen('./'. $folder .'/vvb.ini', 'w+'); - if( !fwrite($fp, '[VroumVroumBlogConfig] -SITE_TITLE="'.$socialinstance.'-'.$socialaccount.'" -SITE_DESCRIPTION="AutoMicroblog automatisé de " -SITE_URL='. $siteurl .' -FEED_URL="'. $rssurl .'"') ) - $error[] = "Impossible d'écrire le fichier vvb.ini"; - fclose($fp); - $error[] = 'AutoMicroblog ajouté avec succès.'; - } - else - $error[] = "Impossible de créer le répertoire."; - } - else - $error[] = "Nom de site invalide."; - } - -} - - -if( !empty($_POST) && empty($_POST['socialinstance']) ) { - $error = array(); - if(empty($_POST['rssurl'])) - {$error[] = "Veuillez entrer l'adresse du flux.";} - if(empty($_POST['number'])) - {$error[] = "Le chiffre. Écrivez le chiffre.";} - if($_POST['number'] !== '17') - {$error[] = "C'est pas le bon chiffre.";} - - if(empty($error)) - { - $rssurl = DetectRedirect(escape($_POST['rssurl'])); - if(!empty($_POST['siteurl'])) - { - // check done, writing out - $siteurl = escape($_POST['siteurl']); - $foldername = sha1(NoProtocolSiteURL($siteurl));$sitename = get_title_from_feed($rssurl); - if(substr($siteurl, -1) == '/'){ $foldername2 = sha1(NoProtocolSiteURL(substr($siteurl, 0, -1))); }else{ $foldername2 = sha1(NoProtocolSiteURL($siteurl).'/');} - $sitedomain1 = preg_split('/\//', $siteurl, 0);$sitedomain2=$sitedomain1[2];$sitedomain3=explode(".", $sitedomain2);$sitedomain3=array_reverse($sitedomain3);$sitedomain = $sitedomain3[1].'.'.$sitedomain3[0]; - if(file_exists($foldername) || file_exists($foldername2)) { die('Erreur: l\'autoblog existe déjà.'); } - if ( mkdir('./'. $foldername, 0755, false) ) { - $fp = fopen('./'. $foldername .'/index.php', 'w+'); - if( !fwrite($fp, "") ) - $error[] = "Impossible d'écrire le fichier index.php"; - fclose($fp); - $fp = fopen('./'. $foldername .'/vvb.ini', 'w+'); - if( !fwrite($fp, '[VroumVroumBlogConfig] -SITE_TITLE="'. $sitename .'" -SITE_DESCRIPTION="Ce site n\'est pas le site officiel de '. $sitename .'
C\'est un blog automatisé qui réplique les articles de '. $sitename .'" -SITE_URL="'. $siteurl .'" -FEED_URL="'. $rssurl .'" -DOWNLOAD_MEDIA_FROM='.$sitedomain) ) - $error[] = "Impossible d'écrire le fichier vvb.ini"; - fclose($fp); - $error[] = 'autoblog crée avec succès.afficher l\'autoblog'; - } - else - $error[] = "Impossible de créer le répertoire."; - - - } - else - { - // checking procedure - $rssurl = DetectRedirect($rssurl); - $siteurl = get_link_from_feed($rssurl); - $foldername = sha1(NoProtocolSiteURL($siteurl)); - $sitename = get_title_from_feed($rssurl); - if(substr($siteurl, -1) == '/'){ $foldername2 = sha1(NoProtocolSiteURL(substr($siteurl, 0, -1))); }else{ $foldername2 = sha1(NoProtocolSiteURL($siteurl).'/');} - $sitedomain1 = preg_split('/\//', $siteurl, 0);$sitedomain2=$sitedomain1[2];$sitedomain3=explode(".", $sitedomain2);$sitedomain3=array_reverse($sitedomain3);$sitedomain = $sitedomain3[1].'.'.$sitedomain3[0]; - if(file_exists($foldername) || file_exists($foldername2)) { die('Erreur: l\'autoblog existe déjà.'); } - $form = 'Merci de vérifier les informations suivantes, corrigez si nécessaire.
-

-
-
-
'; - } - - } -} -?> - - - - - Le Projet Autoblog - - - -

LE PROJET AUTOBLOG

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

- Autres fermes
- → Rechercher

- Ajouter un compte social

-
-
- Twitter
- Identica
-
- -

- Ajouter un site web
-Erreur(s) :

    '; - foreach ( $error AS $value ) { - echo '
  • '. $value .'
  • '; - } - echo '
'; -} -?> -Si vous souhaitez que héberge un autoblog d'un site,
remplissez le formulaire suivant:

- -
Pour ajouter facillement un autoblog, glissez ce bouton dans votre barre de marque-pages => ";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
-
-
-

Autoblogs hébergés

- -$value) - { - $key = strtolower($key); - $config->$key = $value; - } - $autoblogs[$unit] = ' - '; - unset($ini); - } - } -} -if(!empty($autoblogs)){ - sort($autoblogs, SORT_STRING); - foreach ($autoblogs as $autoblog) { - echo $autoblog; - } -} -?> -
-".count($autoblogs)." autoblogs d'hébergés"; ?> -
-Autoblogs propulsés par VroumVroumBlog 0.2.10 [SQLite] (Domaine Public)
index2 inspiré par Arthur et développé par Mitsu et Oros (Domaine Public) -
Code source du projet -".$HTML_footer; } ?> - - - diff --git a/0.2/xsaf2.php b/0.2/xsaf2.php deleted file mode 100755 index ff896fc..0000000 --- a/0.2/xsaf2.php +++ /dev/null @@ -1,179 +0,0 @@ - $expire) { - echo "too early"; - die; - }else{ - unlink($lockfile); - file_put_contents($lockfile, ''); - } -}else{ - file_put_contents($lockfile, ''); -} - -define('ROOT_DIR', __DIR__); -function escape($str) { - return htmlspecialchars($str, ENT_COMPAT, 'UTF-8', false); -} - -function serverUrl() { - $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"]); - return 'http'.($https?'s':'').'://'.$_SERVER["SERVER_NAME"].$serverport; -} - -function NoProtocolSiteURL($url) { - $siteurlnoprototypes = array("http://", "https://"); - $siteurlnoproto = str_replace($siteurlnoprototypes, "", $url); - return $siteurlnoproto; -} - -libxml_use_internal_errors(true); -// $max_exec_time = temps max d'exécution en seconde -function xsafimport($xsafremote, $max_exec_time) { - echo "\n*Traitement $xsafremote en maximum $max_exec_time secondes"; - $max_exec_time+=time()-1; // -1 car l'import prend environ 1 seconde - - $json_import = file_get_contents($xsafremote); - if(!empty($json_import)) { - $to_update=array(); - foreach (json_decode($json_import) as $value) { - $infos=""; - if(count($value)==3 && !empty($value[0]) && !empty($value[1]) && !empty($value[2])) { - $sitename = $value[0]; - $siteurl = escape($value[1]); - $rssurl = escape($value[2]); - if(strpos($siteurl, 'twitter.com') !== FALSE or strpos($siteurl, 'identi.ca') !== FALSE or strpos($sitename, 'statusnet-') !== FALSE) {$social=TRUE;} else {$social=FALSE;} - if($social==FALSE) { - $foldername = sha1(NoProtocolSiteURL($siteurl)); - if(substr($siteurl, -1) == '/'){ $foldername2 = sha1(NoProtocolSiteURL(substr($siteurl, 0, -1))); }else{ $foldername2 = sha1(NoProtocolSiteURL($siteurl).'/');} - } else{ - $foldername = $sitename;$foldername2 = $sitename; - } - - $sitedomain1 = preg_split('/\//', $siteurl, 0); - $sitedomain2=$sitedomain1[2]; - $sitedomain3=explode(".", $sitedomain2); - $sitedomain3=array_reverse($sitedomain3); - $sitedomain = $sitedomain3[1].'.'.$sitedomain3[0]; - if(!file_exists($foldername) && !file_exists($foldername2)) { - if ( mkdir('./'. $foldername, 0755, false) ) { - $fp = fopen('./'. $foldername .'/index.php', 'w+'); - - $response = get_headers($rssurl, 1); // check for redirections - if(!empty($response['Location'])) { - $result="false"; - }else{ - $xml = simplexml_load_file($rssurl); // quick feed check - - if($xml === FALSE){ - $result="false"; - }elseif (isset($xml->entry)) { // ATOM feed. - $result="true"; - }elseif (isset($xml->item)) { // RSS 1.0 /RDF - $result="true"; - }elseif (isset($xml->channel->item)) { // RSS 2.0 - $result="true"; - }else{ - $result="false"; - } - } - - /* autoblog */ - if($social==FALSE and $result!=="false") { - if( !fwrite($fp, "") ) { - $infos = "\nImpossible d'écrire le fichier index.php dans ".$foldername; - fclose($fp); - }else{ - fclose($fp); - $fp = fopen('./'. $foldername .'/vvb.ini', 'w+'); - if( !fwrite($fp, '[VroumVroumBlogConfig] -SITE_TITLE="'. $sitename .'" -SITE_DESCRIPTION="Ce site n\'est pas le site officiel de '. $sitename .'
C\'est un blog automatisé qui réplique les articles de '. $sitename .'" -SITE_URL="'. $siteurl .'" -FEED_URL="'. $rssurl .'" -DOWNLOAD_MEDIA_FROM='.$sitedomain) ){ - fclose($fp); - $infos = "\nImpossible d'écrire le fichier vvb.ini dans ".$foldername; - }else{ - fclose($fp); - $infos = "\nautoblog crée avec succès : $foldername"; - $to_update[]=serverUrl().preg_replace("/(.*)\/(.*)$/i","$1/".$foldername , $_SERVER['SCRIPT_NAME']); // url of the new autoblog - } - } - } - /* automicroblog */ - else if($social!==FALSE and $result!=="false"){ - if( !fwrite($fp, "") ){ - $infos = "\nImpossible d'écrire le fichier index.php dans ".$foldername; - fclose($fp); - }else{ - fclose($fp); - $fp = fopen('./'. $foldername .'/vvb.ini', 'w+'); - if( !fwrite($fp, '[VroumVroumBlogConfig] -SITE_TITLE="'. $sitename .'" -SITE_DESCRIPTION="AutoMicroblog automatisé de " -SITE_URL="'. $siteurl .'" -FEED_URL="'. $rssurl .'"') ){ - fclose($fp); - $infos = "\nImpossible d'écrire le fichier vvb.ini dans ".$foldername; - }else{ - fclose($fp); - $infos = "\nautomicroblog crée avec succès : $foldername"; - $to_update[]=serverUrl().preg_replace("/(.*)\/(.*)$/i","$1/".$foldername , $_SERVER['SCRIPT_NAME']); // url of the new autoblog - } - } - } else { - $infos = "\n$rssurl -> flux invalide"; - } - /* end of file writing */ - }else { - $infos = "\nImpossible de créer le répertoire ".$foldername; - } - } else { - /*$infos = "\nFin d'itération ou Le répertoire ".$foldername." existe déjà ($sitename;$siteurl;$rssurl)";*/ - } - if(DEBUG){ - echo $infos; - } - } - echo "\n time : ".(time() - $max_exec_time); - if(time() >= $max_exec_time){ - break; - } - } - /*if(!empty($to_update)){ - if(DEBUG){ - echo "\nupdate of autoblogs ..."; - } - // because it's could be very long, we finish by updating new autoblogs - foreach ($to_update as $url) { - get_headers($url); - } - if(DEBUG){ - echo "done\n\n"; - } - }*/ - } - return; -} - -/* And now, the XSAF links to be imported, with maximal execusion time for import in second ! */ -xsafimport('https://raw.github.com/mitsukarenai/xsaf-bootstrap/master/2.json', 5); -//xsafimport('https://www.ecirtam.net/autoblogs/?export', 5); -//xsafimport('https://autoblog.suumitsu.eu/?export', 5); - -if(DEBUG) { - echo "\n\nXSAF import finished\n\n"; -} -die; -?>