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 Array URL du flux RSS incorrect. Erreur : '. $rssurl['error'] .' Autoblog '. $sitename .' ajouté avec succès.
+ 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 '
{
';
- foreach ( $data AS $Key => $Element )
- {
- echo ' ['. $Key .'] =>';
- debug($Element);
- }
- echo '}
';
- 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='';
- $svg_jaune='';
- $svg_rouge='';
- $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='';
+ $svg_jaune='';
+ $svg_rouge='';
+ $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('
Fermer la fenêtre.
';
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 .= '
';
- }
+ }
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.
Erreur : '. $rssurl['error'] .'
Fermer la fenêtre.
URL du flux RSS incorrecte.
Fermer la fenêtre.