From a7075c82f3e018e5f65320db38c84527dc2b064e Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 12 Mar 2013 18:17:16 +0100 Subject: [PATCH] Status changes by RSS --- 0.3/class_rssfeed.php | 258 ++++++++++++++++ 0.3/functions.php | 22 +- 0.3/index.php | 689 +++++++++++++++++++++++------------------- 0.3/rss.png | Bin 0 -> 691 bytes 4 files changed, 631 insertions(+), 338 deletions(-) create mode 100644 0.3/class_rssfeed.php create mode 100644 0.3/rss.png diff --git a/0.3/class_rssfeed.php b/0.3/class_rssfeed.php new file mode 100644 index 0000000..a6a804d --- /dev/null +++ b/0.3/class_rssfeed.php @@ -0,0 +1,258 @@ + + * + * + 03/2013 + * Few changes, AutoblogRSS and FileRSSFeed + * @author Arthur Hoaro + */ +class RSSFeed { + protected $xml; + + /** + * Construct a RSS feed + */ + public function __construct() { + $template = << + + + + +END; + + $this->xml = new SimpleXMLElement($template); + } + + /** + * Set RSS Feed headers + * @param $title the title of the feed + * @param $link link to the website where you can find the RSS feed + * @param $description a description of the RSS feed + * @param $rsslink the link to this RSS feed + */ + public function setHeaders($title, $link, $description, $rsslink) { + $atomlink = $this->xml->channel->addChild("atom:link","","http://www.w3.org/2005/Atom"); + $atomlink->addAttribute("href",$rsslink); + $atomlink->addAttribute("rel","self"); + $atomlink->addAttribute("type","application/rss+xml"); + + $this->xml->channel->addChild("title",$title); + $this->xml->channel->addChild("link",$link); + $this->xml->channel->addChild("description",$description); + } + + /** + * Set the language of the RSS feed + * @param $lang the language of the RSS feed + */ + public function setLanguage($lang) { + $this->xml->channel->addChild("language",$lang); + } + /** + * Adds a picture to the RSS feed + * @param $url URL to the image + * @param $title The image title. Usually same as the RSS feed's title + * @param $link Where the image should link to. Usually same as the RSS feed's link + */ + public function setImage($url, $title, $link) { + $image = $this->xml->channel->addChild("image"); + $image->addChild("url",$url); + $image->addChild("title",$title); + $image->addChild("link",$link); + } + /** + * Add a item to the RSS feed + * @param $title The title of the RSS feed + * @param $link Link to the item's url + * @param $description The description of the item + * @param $author The author who wrote this item + * @param $guid Unique ID for this post + * @param $timestamp Unix timestamp for making a date + */ + public function addItem($title, $link, $description, $author, $guid, $timestamp) { + $item = $this->xml->channel->addChild("item"); + $item->addChild("title",$title); + $item->addChild("description",$description); + $item->addChild("link",$link); + $item->addChild("guid",$guid); + $item->addChild("author",$author); + $item->addChild("pubDate",date(DATE_RSS,intval($timestamp))); + } + /** + * Displays the RSS feed + */ + public function displayXML() { + header('Content-type: application/rss+xml; charset=utf-8'); + echo $this->xml->asXML(); + exit; + } + + public function getXML() { + return $this->xml; + } +} + +class RSSMerger { + private $feeds = array(); + + /** + * Constructs a RSSmerger object + */ + function __construct() { + + } + + /** + * Populates the feeds array from the given url which is a rss feed + * @param $url + */ + function add($xml) { + + foreach($xml->channel->item as $item) { + $item->sitetitle = $xml->channel->title; + $item->sitelink = $xml->channel->link; + + preg_match("/^[A-Za-z]{3}, ([0-9]{2}) ([A-Za-z]{3}) ([0-9]{4}) ([0-9]{2}):([0-9]{2}):([0-9]{2}) ([\+|\-]?[0-9]{4})$/", $item->pubDate, $match); + $item->time = time($match[4]+($match[6]/100),$match[5],$match[6],date("m",strtotime($match[2])),$match[1],$match[3]); + + $this->feeds[] = $item; + } + } + /** + * Comparing function for sorting the feeds + * @param $value1 + * @param $value2 + */ + function feeds_cmp($value1,$value2) { + if(intval($value1->time) == intval($value2->time)) + return 0; + + return (intval($value1->time) < intval($value2->time)) ? +1 : -1; + } + + /** + * Sorts the feeds array using the Compare function feeds_cmp + */ + function sort() { + usort($this->feeds,Array("RssMerger","feeds_cmp")); + } + + /** + * This function return the feed items. + * @param $limit how many feed items that should be returned + * @return the feeds array + */ + function getFeeds($limit) { + return array_slice($this->feeds,0,$limit); + } +} + +class FileRSSFeed extends RSSFeed { + protected $filename; + + public function __construct($filename) { + parent::__construct(); + $this->filename = $filename; + + $this->load(); + } + + public function load() { + if ( file_exists( $this->filename )) { + $this->xml = simplexml_load_file($this->filename); + } + } + + public function create($title, $link, $description, $rsslink) { + parent::setHeaders($title, $link, $description, $rsslink); + $this->write(); + } + + public function addItem($title, $link, $description, $author, $guid, $timestamp) { + parent::addItem($title, $link, $description, $author, $guid, $timestamp); + $this->write(); + } + + private function write() { + if ( file_exists( $this->filename )) { + unlink($this->filename); + } + + $outputXML = new RSSFeed(); + foreach($this->xml->channel->item as $f) { + $item = $outputXML->addItem($f->title,$f->link,$f->description,$f->author,$f->guid, strtotime($f->pubDate)); + } + + $merger = new RssMerger(); + $merger->add($outputXML->getXML()); + $merger->sort(); + + unset($this->xml->channel->item); + foreach($merger->getFeeds(20) as $f) { + parent::addItem($f->title,$f->link,$f->description,$f->author,$f->guid,$f->time); + } + + file_put_contents( $this->filename, $this->xml->asXML() ); + } +} + +class AutoblogRSS extends FileRSSFeed { + public function __construct($filename) { + parent::__construct($filename); + } + + public function addUnavailable($title, $folder, $siteurl, $rssurl) { + $path = pathinfo( $_SERVER['PHP_SELF'] ); + $autobHref = 'http'.(!empty($_SERVER['HTTPS'])?'s':'').'://'. + $_SERVER["SERVER_NAME"].$_SERVER["SERVER_PORT"]. $path['dirname'].'/'.$folder; + + parent::addItem( 'L\'autoblog "'. $title.'" est indisponible', $autobHref, + 'Autoblog: '.$title.'
+ Site: '. $siteurl .'
+ RSS: '.$rssurl.'
+ Folder: '. $folder , + 'admin', + $autobHref, + time() + ); + } + + public function addAvailable($title, $folder, $siteurl, $rssurl) { + $path = pathinfo( $_SERVER['PHP_SELF'] ); + $autobHref = 'http'.(!empty($_SERVER['HTTPS'])?'s':'').'://'. + $_SERVER["SERVER_NAME"].$_SERVER["SERVER_PORT"]. $path['dirname'].'/'.$folder; + + parent::addItem( 'L\'autoblog "'. $title.' est de nouveau disponible', $autobHref, + 'Autoblog : '.$title.'
+ Site: '. $siteurl .'
+ RSS: '.$rssurl.'
+ Folder: '. $folder , + 'admin', + $autobHref, + time() + ); + } + + public function addCodeChanged($title, $folder, $siteurl, $rssurl, $code) { + $path = pathinfo( $_SERVER['PHP_SELF'] ); + $autobHref = 'http'.(!empty($_SERVER['HTTPS'])?'s':'').'://'. + $_SERVER["SERVER_NAME"].$_SERVER["SERVER_PORT"]. $path['dirname'].'/'.$folder; + + parent::addItem( 'L\'autoblog "'. $title.' a renvoyé un code imprévu', $autobHref, + 'Code: '. $code .'
+ Autoblog : '.$title.'
+ Site: '. $siteurl .'
+ RSS: '.$rssurl.'
+ Folder: '. $folder , + 'admin', + $autobHref, + time() + ); + } +} + +?> \ No newline at end of file diff --git a/0.3/functions.php b/0.3/functions.php index 6166b92..10bf442 100755 --- a/0.3/functions.php +++ b/0.3/functions.php @@ -144,24 +144,8 @@ function updateType($siteurl) { function debug($data) { - if(is_array($data)) - { - echo '

Array
{
'; - foreach ( $data AS $Key => $Element ) - { - echo '      ['. $Key .'] =>'; - debug($Element); - } - echo '}

'; - } - else if(is_bool($data)) - { - if($data === 1) - echo 'true
'; - else - echo 'false
'; - } - else - echo $data.'
'; + echo '
';
+	var_dump($data);
+	echo '
'; } ?> diff --git a/0.3/index.php b/0.3/index.php index adf80c5..842db4b 100755 --- a/0.3/index.php +++ b/0.3/index.php @@ -6,83 +6,89 @@ Mitsu https://www.suumitsu.eu/ Oros https://www.ecirtam.net/ Arthur Hoaro http://hoa.ro - License: Public Domain + License: Public Domain - Instructions: - (by default, autoblog creation is allowed: you can set this to "FALSE" in config.php) - (by default, Cross-Site Autoblog Farming [XSAF] imports a few autoblogs from https://github.com/mitsukarenai/xsaf-bootstrap/blob/master/3.json you can uncomment and add xsafimports in xsaf3.php (jump at end of file) ) - (by default, database and media transfer via XSAF is allowed) + Instructions: + (by default, autoblog creation is allowed: you can set this to "FALSE" in config.php) + (by default, Cross-Site Autoblog Farming [XSAF] imports a few autoblogs from https://github.com/mitsukarenai/xsaf-bootstrap/blob/master/3.json you can uncomment and add xsafimports in xsaf3.php (jump at end of file) ) + (by default, database and media transfer via XSAF is allowed) - - upload all files on your server (PHP 5.3+ required) - - PROFIT ! + - upload all files on your server (PHP 5.3+ required) + - PROFIT ! */ define('XSAF_VERSION', 3); define('ROOT_DIR', __DIR__); +define('RSS_FILE', 'rss.xml'); + if(file_exists("config.php")){ - include "config.php"; + include "config.php"; }else{ echo "config.php not found !"; - die; + die; } if(file_exists("functions.php")){ - include "functions.php"; + include "functions.php"; }else{ echo "functions.php not found !"; - die; + die; } $error = array(); $success = array(); function get_title_from_feed($url) { - return get_title_from_datafeed(file_get_contents($url)); + return get_title_from_datafeed(file_get_contents($url)); } function get_title_from_datafeed($data) { - if($data === false) { return 'url inaccessible'; } - $dom = new DOMDocument; - $dom->loadXML($data) or die('xml malformé'); - $title = $dom->getElementsByTagName('title'); - return $title->item(0)->nodeValue; + if($data === false) { return 'url inaccessible'; } + $dom = new DOMDocument; + $dom->loadXML($data) or die('xml malformé'); + $title = $dom->getElementsByTagName('title'); + return $title->item(0)->nodeValue; } function get_link_from_feed($url) { - return get_link_from_datafeed(file_get_contents($url)); + return get_link_from_datafeed(file_get_contents($url)); } function get_link_from_datafeed($data) { if($data === false) { return 'url inaccessible'; } - $xml = simplexml_load_string($data); // quick feed check + $xml = simplexml_load_string($data); // quick feed check // 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'); + if (!isset($xml->entry) && !isset($xml->item) && !isset($xml->channel->item)) + 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']; - } + $xml = new SimpleXmlElement($data); + $channel['link'] = $xml->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() +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"]); - return 'http'.($https?'s':'').'://'.$_SERVER["SERVER_NAME"].$serverport; + if($return_subfolder === true) { + $path = pathinfo( $_SERVER['PHP_SELF'] ); + $subfolder = $path['dirname'] .'/'; + } else $subfolder = ''; + return 'http'.($https?'s':'').'://'.$_SERVER["SERVER_NAME"].$serverport.$subfolder; } function objectCmp($a, $b) { @@ -151,48 +157,92 @@ function versionCheck() { return false; } $update_available = (ALLOW_CHECK_UPDATE) ? versionCheck() : false; - + +/** +* RSS Feed +**/ +if (isset($_GET['rss'])) { + require_once('class_rssfeed.php'); + $rss = new AutoblogRSS(RSS_FILE); + $rss->displayXML(); + die; +} +if( !file_exists(RSS_FILE)) { + require_once('class_rssfeed.php'); + $rss = new AutoblogRSS(RSS_FILE); + $rss->create('Projet Autoblog'. ((!empty($head_title)) ? ' | '. $head_title : ''), serverUrl(true),"Projet Autoblog, flux RSS des changements de disponibilité.", serverUrl(true) . '/' . RSS_FILE); +} /** * SVG **/ 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 ; + //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=''; - - $errorlog="./".escape( $_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 */ - { - 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("./". escape( $_GET['check'] ) ."/vvb.ini") or die; + /* SVG minimalistes */ + $svg_vert='OK'; + $svg_jaune='mv'; + $svg_rouge='err'; + $svg_twitter=''; + $svg_identica=''; + $svg_statusnet=''; + + $errorlog="./".escape( $_GET['check'] ) ."/error.log"; - 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 */ + $oldvalue = null; + if(file_exists($errorlog)) { $oldvalue = file_get_contents($errorlog); }; + if(file_exists($errorlog) && filemtime($errorlog) < $expire) { unlink($errorlog); } /* errorlog périmé ? Suppression. */ + if(file_exists($errorlog)) /* errorlog existe encore ? se contenter de lire sa taille pour avoir le statut */ + { + if(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("./". escape( $_GET['check'] ) ."/vvb.ini") or die; - $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(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']); + /* le flux est indisponible (typiquement: erreur DNS ou possible censure) - à vérifier */ + if(empty($headers) || $headers === FALSE ) { + if( $oldvalue !== null && $oldvalue != '..' ) { + require_once('class_rssfeed.php'); + $rss = new AutoblogRSS(RSS_FILE); + $rss->addUnavailable($ini['SITE_TITLE'], escape($_GET['check']), $ini['SITE_URL'], $ini['FEED_URL']); + } + file_put_contents($errorlog, '..'); + die($svg_rouge); + } + $code=explode(" ", $headers[0]); + /* code retour 200: flux disponible */ + if($code[1] == "200") { + if( $oldvalue !== null && $oldvalue != '' ) { + require_once('class_rssfeed.php'); + $rss = new AutoblogRSS(RSS_FILE); + $rss->addAvailable($ini['SITE_TITLE'], escape($_GET['check']), $ini['SITE_URL'], $ini['FEED_URL']); + } + file_put_contents($errorlog, ''); + die($svg_vert); + } + /* autre code retour: un truc a changé (redirection, changement de CMS, .. bref vvb.ini doit être corrigé) */ + else { + if( $oldvalue !== null && $oldvalue != '.' ) { + require_once('class_rssfeed.php'); + $rss = new AutoblogRSS(RSS_FILE); + $rss->addCodeChanged($ini['SITE_TITLE'], escape($_GET['check']), $ini['SITE_URL'], $ini['FEED_URL'], $code[1]); + } + file_put_contents($errorlog, '.'); + die($svg_jaune); + } + } } /** @@ -204,40 +254,40 @@ if (isset($_GET['export'])) { $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; + 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); + foreach ($ini as $key=>$value) { + $key = strtolower($key); + $config->$key = $value; + } + unset($ini); $feed=$config->feed_url; $type=$config->site_type; - $title=$config->site_title; - $url=$config->site_url; - $reponse[$unit] = array("SITE_TYPE"=>"$type", "SITE_TITLE"=>"$title", "SITE_URL"=>"$url", "FEED_URL"=>"$feed"); + $title=$config->site_title; + $url=$config->site_url; + $reponse[$unit] = array("SITE_TYPE"=>"$type", "SITE_TITLE"=>"$title", "SITE_URL"=>"$url", "FEED_URL"=>"$feed"); - } - } + } + } echo json_encode( array( "meta"=> array("xsaf-version"=>XSAF_VERSION,"xsaf-db_transfer"=>"true","xsaf-media_transfer"=>"true"), - "autoblogs"=>$reponse)); + "autoblogs"=>$reponse)); die; } /** - * OPML Full Export + * OPML Full Export **/ if (isset($_GET['exportopml'])) // OPML { //header('Content-Type: application/octet-stream'); header('Content-type: text/xml'); - header('Content-Disposition: attachment; filename="autoblogs-'. $_SERVER['SERVER_NAME'] .'.xml"'); + header('Content-Disposition: attachment; filename="autoblogs-'. $_SERVER['SERVER_NAME'] .'.xml"'); - $opmlfile = new SimpleXMLElement(''); + $opmlfile = new SimpleXMLElement(''); $opmlfile->addAttribute('version', '1.0'); $opmlhead = $opmlfile->addChild('head'); $opmlhead->addChild('title', 'Autoblog OPML export from '. $_SERVER['SERVER_NAME'] ); @@ -248,23 +298,23 @@ if (isset($_GET['exportopml'])) // OPML $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; + 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); + foreach ($ini as $key=>$value) { + $key = strtolower($key); + $config->$key = $value; + } + unset($ini); - $outline = $opmlbody->addChild('outline'); - $outline->addAttribute('title', escape($config->site_title)); - $outline->addAttribute('text', escape($config->site_type)); - $outline->addAttribute('htmlUrl', escape($config->site_url)); - $outline->addAttribute('xmlUrl', escape($config->feed_url)); - } + $outline = $opmlbody->addChild('outline'); + $outline->addAttribute('title', escape($config->site_title)); + $outline->addAttribute('text', escape($config->site_type)); + $outline->addAttribute('htmlUrl', escape($config->site_url)); + $outline->addAttribute('xmlUrl', escape($config->feed_url)); + } } echo $opmlfile->asXML(); exit; @@ -275,20 +325,20 @@ if (isset($_GET['exportopml'])) // OPML **/ if (isset($_GET['sitemap'])) { - header('Content-Type: application/xml'); - echo ''; + header('Content-Type: application/xml'); + echo ''; $directory = "./"; $subdirs = glob($directory . "*"); foreach($subdirs as $unit) { - if(is_dir($unit)) { - $unit=substr($unit, 2); - $proto=(!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'])=='on')?"https://":"http://"; - echo ''.$proto.$_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'], 0, -9)."$unit/"."\n"; - echo ''.date('c', filemtime($unit))."\n"; - echo 'hourly'; - } - } - echo ''; + if(is_dir($unit)) { + $unit=substr($unit, 2); + $proto=(!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'])=='on')?"https://":"http://"; + echo ''.$proto.$_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'], 0, -9)."$unit/"."\n"; + echo ''.date('c', filemtime($unit))."\n"; + echo 'hourly'; + } + } + echo ''; die; } @@ -302,26 +352,26 @@ if( isset($_GET['updateall']) && ALLOW_FULL_UPDATE) { $lockfile = ".updatealllock"; if (file_exists($lockfile) && filemtime($lockfile) > $expire) { echo "too early"; - die; + die; } else { if( file_exists($lockfile) ) unlink($lockfile); if( file_put_contents($lockfile, date(DATE_RFC822)) ===FALSE) { - echo "Merci d'ajouter des droits d'écriture sur le fichier."; - die; - } + echo "Merci d'ajouter des droits d'écriture sur le fichier."; + die; + } } $directory = "./"; $subdirs = glob($directory . "*"); foreach($subdirs as $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'); - } - } + if( !file_exists(ROOT_DIR . '/' . $unit . '/.disabled')) { + file_get_contents(serverUrl() . substr($_SERVER['PHP_SELF'], 0, -9) . $unit . '/index.php'); + } + } } } @@ -344,21 +394,21 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG $form .= '

URL du flux RSS incorrect.
Fermer la fenêtre.

'; } else { - if(isset($_GET['add']) && $_GET['add'] === '1' && !empty($_GET['siteurl']) && !empty($_GET['sitename'])) { - $rssurl = DetectRedirect(escape($_GET['rssurl'])); + if(isset($_GET['add']) && $_GET['add'] === '1' && !empty($_GET['siteurl']) && !empty($_GET['sitename'])) { + $rssurl = DetectRedirect(escape($_GET['rssurl'])); if( isset($rssurl['error']) ) $form .= '

Erreur : '. $rssurl['error'] .'
'; else { - $siteurl = escape($_GET['siteurl']); + $siteurl = escape($_GET['siteurl']); $sitename = escape($_GET['sitename']); $sitetype = updateType($siteurl); // Disabled input doesn't send POST data $sitetype = $sitetype['type']; - $error = array_merge( $error, createAutoblog($sitetype, $sitename, $siteurl, $rssurl, $error)); - if( empty($error)) { - $form .= ''; + $error = array_merge( $error, createAutoblog($sitetype, $sitename, $siteurl, $rssurl, $error)); + if( empty($error)) { + $form .= ''; $form .= '

Autoblog '. $sitename .' ajouté avec succès.
'; - } + } else { $form .= '

    '; foreach ( $error AS $value ) @@ -367,24 +417,24 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG } } $form .= 'Fermer la fenêtre.

    '; - } - else { - $rssurl = DetectRedirect(escape($_GET['rssurl'])); + } + else { + $rssurl = DetectRedirect(escape($_GET['rssurl'])); if( isset($rssurl['error']) ) $form .= '

    Erreur : '. $rssurl['error'] .'
    Fermer la fenêtre.

    '; else { $datafeed = file_get_contents($rssurl); if( $datafeed !== false ) { - $siteurl = get_link_from_datafeed($datafeed); + $siteurl = get_link_from_datafeed($datafeed); $sitename = get_title_from_datafeed($datafeed); - $sitetype = updateType($siteurl); + $sitetype = updateType($siteurl); $sitetype = $sitetype['type']; - $form .= 'Merci de vérifier les informations suivantes, corrigez si nécessaire.
    -
    - -
    -
    + $form .= 'Merci de vérifier les informations suivantes, corrigez si nécessaire.
    + + +
    +


    '; @@ -393,7 +443,7 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG $form .= '

    URL du flux RSS incorrecte.
    Fermer la fenêtre.

    '; } } - } + } } $form .= ''; echo $form; die; @@ -406,42 +456,42 @@ if(!empty($_POST['socialaccount']) && !empty($_POST['socialinstance']) && ALLOW_ { if( !empty($_POST['number']) && !empty($_POST['antibot']) && check_antibot($_POST['number'], $_POST['antibot']) ) { - $socialaccount = strtolower(escape($_POST['socialaccount'])); - $socialinstance = strtolower(escape($_POST['socialinstance'])); + $socialaccount = strtolower(escape($_POST['socialaccount'])); + $socialinstance = strtolower(escape($_POST['socialinstance'])); - if($socialinstance === 'twitter') { - $sitetype = 'microblog'; - $siteurl = "http://twitter.com/$socialaccount"; - $rssurl = $apitwitter.$socialaccount; - } - elseif($socialinstance === 'identica') { - $sitetype = 'microblog'; - $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'])); - $rssurl = DetectRedirect("http://".$siteurl."/api/statuses/user_timeline/$socialaccount.rss"); - $siteurl = DetectRedirect("http://".$siteurl."/$socialaccount"); - } - elseif($socialinstance === 'shaarli' && !empty($_POST['shaarliurl'])) { - $sitetype = 'shaarli'; - $siteurl = NoProtocolSiteURL(escape($_POST['shaarliurl'])); - $siteurl = DetectRedirect("http://".$siteurl."/"); - $rssurl = $siteurl."?do=rss"; - $socialaccount = get_title_from_feed($rssurl); - } - + if($socialinstance === 'twitter') { + $sitetype = 'microblog'; + $siteurl = "http://twitter.com/$socialaccount"; + $rssurl = $apitwitter.$socialaccount; + } + elseif($socialinstance === 'identica') { + $sitetype = 'microblog'; + $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'])); + $rssurl = DetectRedirect("http://".$siteurl."/api/statuses/user_timeline/$socialaccount.rss"); + $siteurl = DetectRedirect("http://".$siteurl."/$socialaccount"); + } + elseif($socialinstance === 'shaarli' && !empty($_POST['shaarliurl'])) { + $sitetype = 'shaarli'; + $siteurl = NoProtocolSiteURL(escape($_POST['shaarliurl'])); + $siteurl = DetectRedirect("http://".$siteurl."/"); + $rssurl = $siteurl."?do=rss"; + $socialaccount = get_title_from_feed($rssurl); + } + if( !isset($rssurl['error']) && !isset($siteurl['error']) ) { - $headers = get_headers($rssurl, 1); - if (strpos($headers[0], '200') == FALSE) { - $error[] = "Flux inaccessible (compte inexistant ?)"; - } - if( empty($error) ) { - $error = array_merge( $error, createAutoblog($sitetype, ucfirst($socialinstance) .' - '. $socialaccount, $siteurl, $rssurl, $error)); - if( empty($error)) - $success[] = ''.ucfirst($socialinstance) .' - '. $socialaccount.' ajouté avec succès.'; + $headers = get_headers($rssurl, 1); + if (strpos($headers[0], '200') == FALSE) { + $error[] = "Flux inaccessible (compte inexistant ?)"; + } + if( empty($error) ) { + $error = array_merge( $error, createAutoblog($sitetype, ucfirst($socialinstance) .' - '. $socialaccount, $siteurl, $rssurl, $error)); + if( empty($error)) + $success[] = ''.ucfirst($socialinstance) .' - '. $socialaccount.' ajouté avec succès.'; } } else $error[] = (isset($rssurl['error'])) ? $rssurl['error'] : $siteurl['error']; @@ -454,50 +504,50 @@ if(!empty($_POST['socialaccount']) && !empty($_POST['socialinstance']) && ALLOW_ * ADD BY GENERIC LINK **/ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_LINKS) { - if(empty($_POST['rssurl'])) - {$error[] = "Veuillez entrer l'adresse du flux.";} - if(empty($_POST['number']) || empty($_POST['antibot']) ) - {$error[] = "Vous êtes un bot ?";} + if(empty($_POST['rssurl'])) + {$error[] = "Veuillez entrer l'adresse du flux.";} + 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)) { - $rssurl = DetectRedirect(escape($_POST['rssurl'])); + if(empty($error)) { + $rssurl = DetectRedirect(escape($_POST['rssurl'])); if( !isset($rssurl['error']) ) { - if(!empty($_POST['siteurl'])) { + if(!empty($_POST['siteurl'])) { - $siteurl = escape($_POST['siteurl']); - $sitename = get_title_from_feed($rssurl); + $siteurl = escape($_POST['siteurl']); + $sitename = get_title_from_feed($rssurl); - $error = array_merge( $error, createAutoblog('generic', $sitename, $siteurl, $rssurl, $error)); + $error = array_merge( $error, createAutoblog('generic', $sitename, $siteurl, $rssurl, $error)); - if( empty($error)) - $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.'; - } - $sitetype = 'generic'; - $siteurl = get_link_from_datafeed($datafeed); - $sitename = get_title_from_datafeed($datafeed); + if( empty($error)) + $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.'; + } + $sitetype = 'generic'; + $siteurl = get_link_from_datafeed($datafeed); + $sitename = get_title_from_datafeed($datafeed); - $form = 'Merci de vérifier les informations suivantes, corrigez si nécessaire.
    -
    -
    -
    + $form = 'Merci de vérifier les informations suivantes, corrigez si nécessaire.
    + +
    +



    '; - } + } } else $error[] = $rssurl['error']; - } + } } /** @@ -505,9 +555,9 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L **/ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML_FILE) { if(empty($_POST['number']) || empty($_POST['antibot']) ) - {$error[] = "Vous êtes un bot ?";} + {$error[] = "Vous êtes un bot ?";} elseif(! check_antibot($_POST['number'], $_POST['antibot'])) - {$error[] = "Antibot : Ce n'est pas le bon nombre.";} + {$error[] = "Antibot : Ce n'est pas le bon nombre.";} if( empty( $error)) { if (is_uploaded_file($_FILES['file']['tmp_name'])) { @@ -531,7 +581,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.';} @@ -553,31 +603,32 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY ?> - - + + Projet Autoblog<?php if(!empty($head_title)) { echo " | " . escape($head_title); } ?> - - - -

    PROJET AUTOBLOG

    + .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;} + + + +

    PROJET AUTOBLOG

    -
    +
    -

    Présentation

    +

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

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

    -
    +

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

    +

    Mise à jour

    Une mise à jour du Projet Autoblog est disponible ! → Télécharger -

    +

    - -
    + +

    Ajouter un autoblog

    @@ -651,44 +702,44 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY 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 site web

    +

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

    + + +
    -
    -

    Ajouter un compte social

    +
    +

    Ajouter un compte social

    -
    -
    - Twitter
    - Identica
    - -
    -
    + +
    + Twitter
    + Identica
    + +
    +
    - -
    -
    + + +
    -

    Ajouter un Shaarli

    - -
    - +

    Ajouter un Shaarli

    + + +

    - -
    -
    + + +
    @@ -703,7 +754,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
    - + @@ -712,33 +763,33 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
    -
    +

    - +
    - +
    -

    Autoblogs hébergés

    +

    Autoblogs hébergés rss

    - Autres fermes - → Rechercher + Autres fermes + → Rechercher

    @@ -749,37 +800,37 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY $autoblogs = array(); foreach($subdirs as $unit) { - if(is_dir($unit)) - { - if( !file_exists(ROOT_DIR . '/' . $unit . '/.disabled')) { - $ini = parse_ini_file(ROOT_DIR . '/' . $unit . '/vvb.ini'); - if($ini) - { - $config = new stdClass; - $unit=substr($unit, 2); - foreach ($ini as $key=>$value) - { - $key = strtolower($key); - $config->$key = $value; - } - $autoblogs[$unit] = $config; - unset($ini); - } - } - } + if(is_dir($unit)) + { + if( !file_exists(ROOT_DIR . '/' . $unit . '/.disabled')) { + $ini = parse_ini_file(ROOT_DIR . '/' . $unit . '/vvb.ini'); + if($ini) + { + $config = new stdClass; + $unit=substr($unit, 2); + 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) { + foreach ($autoblogs as $key => $autoblog) { $opml_link='opml'; - $autoblogs_display .= '
    - -
    config ini '.$opml_link.' | '.escape($autoblog->site_type).' source: '.escape($autoblog->site_url).'
    -
    '; - } + $autoblogs_display .= '
    + +
    config ini '.$opml_link.' | '.escape($autoblog->site_type).' source: '.escape($autoblog->site_url).'
    +
    '; + } } echo $autoblogs_display; @@ -791,7 +842,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
    Propulsé par Projet Autoblog 0.3 de Mitsu, Oros et Arthur Hoaro (Domaine Public) ".$HTML_footer; } ?> - + - + diff --git a/0.3/rss.png b/0.3/rss.png new file mode 100644 index 0000000000000000000000000000000000000000..315c4f4fa62cb720326ba3f54259666ba3999e42 GIT binary patch literal 691 zcmV;k0!;mhP)bpQb1=l6TxbDZwj&S={?7%qx-u`rsG(Zp`-rh=e^=%((1yvsuf5d=&62Zj)Y zH&JviNS_F4_Hj|T(1j4$p-!}kixP9&dB4uv^MveG?dGf%sUCoc2!IFxD6wHRA2^dX zXRVk!-qSfk(jcaUKn#RP48(whfPlJUpApdrA!TQi_4D+fVoM;3I0gZ8{=Xv~Po;geVA+Em9@0Wq2 zr>OTZEGR05L=gf1T;ucCxq6Q6EgJiH@@-lVaAlQyw`jIF^c=&IVnj|95hHbE_cnt| zTzZQ?F4Ne@(bH(~&3nM%m)I@ID{@jJ2qZPjr)jhpe9hViOwH5k&|T#EmmL3(vHeUQ zq^!t^Al6JD;=mHq^Bg?J-8-zG2Od7gZbknG;K9czYjPqG*xjPo0k(c4%lPXTpw(qq z@aGMnxtFS(np+2kC} z7P02O874ZkJH$v#nCUVx$({yDN`IX@o2wyvTD#e`qN`_w5<}$3F+_