2013-02-13 11:22:51 +01:00
< ? php
/*
2013-02-27 12:04:05 +01:00
Projet Autoblog 0.3 - beta
Code : https :// github . com / mitsukarenai / Projet - Autoblog
2013-04-08 11:45:16 +02:00
Authors :
2013-02-18 19:42:10 +01:00
Mitsu https :// www . suumitsu . eu /
Oros https :// www . ecirtam . net /
2013-03-10 14:48:29 +01:00
Arthur Hoaro http :// hoa . ro
2013-03-12 18:17:16 +01:00
License : Public Domain
2013-02-13 11:22:51 +01:00
2013-03-12 18:17:16 +01:00
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 )
2013-02-13 11:22:51 +01:00
2013-03-12 18:17:16 +01:00
- upload all files on your server ( PHP 5.3 + required )
- PROFIT !
2013-02-13 11:22:51 +01:00
*/
2013-02-18 19:42:10 +01:00
define ( 'XSAF_VERSION' , 3 );
2013-02-13 11:22:51 +01:00
define ( 'ROOT_DIR' , __DIR__ );
2013-03-12 18:17:16 +01:00
2013-02-13 11:22:51 +01:00
if ( file_exists ( " config.php " )){
2013-03-12 18:17:16 +01:00
include " config.php " ;
2013-02-19 12:20:13 +01:00
} else {
echo " config.php not found ! " ;
2013-03-12 18:17:16 +01:00
die ;
2013-02-13 11:22:51 +01:00
}
2013-02-18 19:42:10 +01:00
if ( file_exists ( " functions.php " )){
2013-03-12 18:17:16 +01:00
include " functions.php " ;
2013-02-19 12:20:13 +01:00
} else {
echo " functions.php not found ! " ;
2013-03-12 18:17:16 +01:00
die ;
2013-02-18 19:42:10 +01:00
}
$error = array ();
$success = array ();
function get_title_from_feed ( $url ) {
2013-03-12 18:17:16 +01:00
return get_title_from_datafeed ( file_get_contents ( $url ));
2013-02-18 19:42:10 +01:00
}
2013-02-13 11:22:51 +01:00
2013-02-18 19:42:10 +01:00
function get_title_from_datafeed ( $data ) {
2013-03-12 18:17:16 +01:00
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 ;
2013-02-18 19:42:10 +01:00
}
2013-02-13 11:22:51 +01:00
2013-02-18 19:42:10 +01:00
function get_link_from_feed ( $url ) {
2013-03-12 18:17:16 +01:00
return get_link_from_datafeed ( file_get_contents ( $url ));
2013-02-18 19:42:10 +01:00
}
function get_link_from_datafeed ( $data ) {
2013-02-19 12:20:13 +01:00
if ( $data === false ) { return 'url inaccessible' ; }
2013-03-12 18:17:16 +01:00
$xml = simplexml_load_string ( $data ); // quick feed check
2013-04-08 11:45:16 +02:00
2013-02-16 16:23:21 +01:00
// ATOM feed && RSS 1.0 /RDF && RSS 2.0
2013-04-08 11:45:16 +02:00
if ( ! isset ( $xml -> entry ) && ! isset ( $xml -> item ) && ! isset ( $xml -> channel -> item ))
die ( 'le flux n\'a pas une syntaxe valide' );
2013-03-12 18:17:16 +01:00
$check = substr ( $data , 0 , 5 );
2013-04-08 11:45:16 +02:00
if ( $check !== '<?xml' ) {
die ( 'n\'est pas un flux valide' );
2013-03-12 18:17:16 +01:00
}
$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' ];
}
2013-02-18 19:42:10 +01:00
}
2013-02-13 11:22:51 +01:00
2013-03-12 18:17:16 +01:00
function serverUrl ( $return_subfolder = false )
2013-02-13 11:22:51 +01:00
{
$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 " ]);
2013-03-12 18:17:16 +01:00
if ( $return_subfolder === true ) {
$path = pathinfo ( $_SERVER [ 'PHP_SELF' ] );
$subfolder = $path [ 'dirname' ] . '/' ;
} else $subfolder = '' ;
return 'http' . ( $https ? 's' : '' ) . '://' . $_SERVER [ " SERVER_NAME " ] . $serverport . $subfolder ;
2013-02-13 11:22:51 +01:00
}
2013-02-18 19:42:10 +01:00
function objectCmp ( $a , $b ) {
return strcasecmp ( $a -> site_title , $b -> site_title );
2013-02-13 11:22:51 +01:00
}
2013-02-27 12:04:05 +01:00
function generate_antibot () {
$letters = array ( 'zéro' , 'un' , 'deux' , 'trois' , 'quatre' , 'cinq' , 'six' , 'sept' , 'huit' , 'neuf' , 'dix' , 'onze' , 'douze' , 'treize' , 'quatorze' , 'quinze' , 'seize' , 'dix-sept' , 'dix-huit' , 'dix-neuf' , 'vingt' );
2013-03-01 12:12:54 +01:00
return $letters [ mt_rand ( 1 , 20 )];
2013-02-27 12:04:05 +01:00
}
function check_antibot ( $number , $text_number ) {
$letters = array ( 'zéro' , 'un' , 'deux' , 'trois' , 'quatre' , 'cinq' , 'six' , 'sept' , 'huit' , 'neuf' , 'dix' , 'onze' , 'douze' , 'treize' , 'quatorze' , 'quinze' , 'seize' , 'dix-sept' , 'dix-huit' , 'dix-neuf' , 'vingt' );
2013-04-08 11:45:16 +02:00
return ( array_search ( $text_number , $letters ) === intval ( $number ) ) ? true : false ;
2013-02-27 12:04:05 +01:00
}
2013-03-01 12:14:46 +01:00
function create_from_opml ( $opml ) {
global $error , $success ;
2013-04-08 11:45:16 +02:00
2013-03-01 12:14:46 +01:00
foreach ( $opml -> body -> outline as $outline ) {
2013-03-02 12:33:27 +01:00
if ( ! empty ( $outline [ 'title' ] ) && ! empty ( $outline [ 'text' ] ) && ! empty ( $outline [ 'xmlUrl' ]) && ! empty ( $outline [ 'htmlUrl' ] )) {
2013-04-04 18:58:28 +02:00
try {
$rssurl = DetectRedirect ( escape ( $outline [ 'xmlUrl' ]));
2013-04-08 11:45:16 +02:00
$sitename = escape ( $outline [ 'title' ] );
2013-03-10 14:48:29 +01:00
$siteurl = escape ( $outline [ 'htmlUrl' ]);
2013-04-08 11:45:16 +02:00
$sitetype = escape ( $outline [ 'text' ]); if ( $sitetype == 'generic' or $sitetype == 'microblog' or $sitetype == 'shaarli' ) { } else { $sitetype = 'generic' ; }
2013-03-10 14:48:29 +01:00
$error = array_merge ( $error , createAutoblog ( $sitetype , $sitename , $siteurl , $rssurl , $error ) );
2013-04-08 11:45:16 +02:00
2013-03-10 14:48:29 +01:00
if ( empty ( $error ))
$success [] = '<iframe width="1" height="1" frameborder="0" src="' . urlToFolderSlash ( $siteurl ) . '/index.php"></iframe>Autoblog "' . $sitename . '" crée avec succès. → <a target="_blank" href="' . urlToFolderSlash ( $siteurl ) . '">afficher l\'autoblog</a>.' ;
}
2013-04-04 18:58:28 +02:00
catch ( Exception $e ) {
$error [] = $e -> getMessage ();
}
2013-03-01 12:14:46 +01:00
}
}
}
2013-03-01 13:13:30 +01:00
/**
* Simple version check
**/
function versionCheck () {
$versionfile = 'version' ;
2013-04-08 11:45:16 +02:00
$lastestUrl = 'https://raw.github.com/mitsukarenai/Projet-Autoblog/master/0.3/version' ;
2013-03-01 13:39:33 +01:00
$expire = time () - 84600 ; // 23h30 en secondes
$lockfile = '.versionlock' ;
2013-04-08 11:45:16 +02:00
2013-03-01 13:39:33 +01:00
if ( file_exists ( $lockfile ) && filemtime ( $lockfile ) > $expire ) {
if ( file_get_contents ( $lockfile ) == 'NEW' ) {
// No new version installed
if ( filemtime ( $lockfile ) > filemtime ( $versionfile ) )
return true ;
else unlink ( $lockfile );
2013-04-08 11:45:16 +02:00
}
2013-03-01 13:39:33 +01:00
else return false ;
2013-04-08 11:45:16 +02:00
}
2013-03-01 13:39:33 +01:00
if ( file_exists ( $lockfile ) && filemtime ( $lockfile ) < $expire ) { unlink ( $lockfile ); }
2013-04-08 11:45:16 +02:00
2013-03-01 13:13:30 +01:00
if ( file_get_contents ( $versionfile ) != file_get_contents ( $lastestUrl ) ) {
2013-03-01 13:39:33 +01:00
file_put_contents ( $lockfile , 'NEW' );
2013-03-01 13:13:30 +01:00
return true ;
}
2013-03-01 13:39:33 +01:00
file_put_contents ( $lockfile , '.' );
2013-03-01 13:13:30 +01:00
return false ;
}
2013-03-04 16:20:14 +01:00
$update_available = ( ALLOW_CHECK_UPDATE ) ? versionCheck () : false ;
2013-03-12 18:17:16 +01:00
/**
* 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 );
2013-03-18 10:32:37 +01:00
$rss -> create ( 'Projet Autoblog' . (( ! empty ( $head_title )) ? ' | ' . $head_title : '' ), serverUrl ( true ), " Projet Autoblog - RSS : Ajouts et changements de disponibilité. " , serverUrl ( true ) . '/' . RSS_FILE );
2013-03-12 18:17:16 +01:00
}
2013-03-01 13:13:30 +01:00
2013-02-18 19:42:10 +01:00
/**
* SVG
**/
2013-02-13 11:22:51 +01:00
if ( isset ( $_GET [ 'check' ]))
{
2013-03-12 18:17:16 +01:00
//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 = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="15" height="15"><g><rect width="15" height="15" x="0" y="0" style="fill:#00ff00;stroke:#008000"/></g><text style="font-size:10px;font-weight:bold;text-anchor:middle;font-family:Arial"><tspan x="7" y="11">OK</tspan></text></svg>' ;
$svg_jaune = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="15" height="15"><g><rect width="15" height="15" x="0" y="0" style="fill:#ffff00;stroke:#ffcc00"/></g><text style="font-size:10px;font-weight:bold;text-anchor:middle;font-family:Arial"><tspan x="7" y="11">mv</tspan></text></svg>' ;
$svg_rouge = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="15" height="15"><g><rect width="15" height="15" x="0" y="0" style="fill:#ff0000;stroke:#800000"/></g><text style="font-size:10px;font-weight:bold;text-anchor:middle;font-family:Arial"><tspan x="7" y="11">err</tspan></text></svg>' ;
$svg_twitter = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="15" height="15"><path d="m 11.679889,7.6290431 a 4.1668792,3.7091539 0 1 1 -8.3337586,0 4.1668792,3.7091539 0 1 1 8.3337586,0 z" style="fill:none;stroke:#3aaae1;stroke-width:4;stroke-miterlimit:4" /></svg>' ;
$svg_identica = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="15" height="15"><path d="m 11.679889,7.6290431 a 4.1668792,3.7091539 0 1 1 -8.3337586,0 4.1668792,3.7091539 0 1 1 8.3337586,0 z" style="fill:none;stroke:#a00000;stroke-width:4;stroke-miterlimit:4" /></svg>' ;
$svg_statusnet = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="15" height="15"><path d="m 11.679889,7.6290431 a 4.1668792,3.7091539 0 1 1 -8.3337586,0 4.1668792,3.7091539 0 1 1 8.3337586,0 z" style="fill:none;stroke:#ff6a00;stroke-width:4;stroke-miterlimit:4" /></svg>' ;
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
$errorlog = " ./ " . escape ( $_GET [ 'check' ] ) . " /error.log " ;
$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 */
2013-04-08 11:45:16 +02:00
{
2013-03-12 18:17:16 +01:00
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 ;
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' ]);
}
2013-04-08 11:45:16 +02:00
file_put_contents ( $errorlog , '..' );
die ( $svg_rouge );
}
2013-03-12 18:17:16 +01:00
$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' ]);
}
2013-04-08 11:45:16 +02:00
file_put_contents ( $errorlog , '' );
2013-03-12 18:17:16 +01:00
die ( $svg_vert );
2013-04-08 11:45:16 +02:00
}
2013-03-12 18:17:16 +01:00
/* 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 ]);
}
2013-04-08 11:45:16 +02:00
file_put_contents ( $errorlog , '.' );
2013-03-12 18:17:16 +01:00
die ( $svg_jaune );
2013-04-08 11:45:16 +02:00
}
2013-03-12 18:17:16 +01:00
}
2013-02-13 11:22:51 +01:00
}
2013-02-18 19:42:10 +01:00
/**
2013-03-01 12:12:54 +01:00
* JSON Export
2013-02-18 19:42:10 +01:00
**/
2013-02-23 16:02:14 +01:00
if ( isset ( $_GET [ 'export' ])) {
2013-02-18 19:42:10 +01:00
header ( 'Content-Type: application/json' );
$directory = " ./ " ;
$subdirs = glob ( $directory . " * " );
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
foreach ( $subdirs as $unit ) {
2013-04-07 13:10:07 +02:00
if ( is_dir ( $unit ) && strpos ( $unit . '/' , DOC_FOLDER ) === FALSE ) {
2013-03-12 18:17:16 +01:00
$unit = substr ( $unit , 2 );
$ini = parse_ini_file ( $unit . '/vvb.ini' );
$config = new stdClass ;
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
foreach ( $ini as $key => $value ) {
$key = strtolower ( $key );
$config -> $key = $value ;
}
unset ( $ini );
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
$feed = $config -> feed_url ;
2013-02-23 16:02:14 +01:00
$type = $config -> site_type ;
2013-03-12 18:17:16 +01:00
$title = $config -> site_title ;
2013-04-08 11:45:16 +02:00
$url = $config -> site_url ;
2013-03-12 18:17:16 +01:00
$reponse [ $unit ] = array ( " SITE_TYPE " => " $type " , " SITE_TITLE " => " $title " , " SITE_URL " => " $url " , " FEED_URL " => " $feed " );
2013-02-23 16:02:14 +01:00
2013-03-12 18:17:16 +01:00
}
}
2013-02-23 16:02:14 +01:00
echo json_encode ( array ( " meta " => array ( " xsaf-version " => XSAF_VERSION , " xsaf-db_transfer " => " true " , " xsaf-media_transfer " => " true " ),
2013-03-12 18:17:16 +01:00
" autoblogs " => $reponse ));
2013-02-18 19:42:10 +01:00
die ;
2013-02-13 11:22:51 +01:00
}
2013-03-14 18:25:10 +01:00
/**
* JSON Allowed Twitter accounts export
**/
if ( isset ( $_GET [ 'export_twitter' ])) {
header ( 'Content-Type: application/json' );
$directory = " ./ " ;
$subdirs = glob ( $directory . " * " );
$response = array ();
foreach ( $subdirs as $unit ) {
2013-04-07 13:10:07 +02:00
if ( is_dir ( $unit ) && strpos ( $unit . '/' , DOC_FOLDER ) === FALSE ) {
2013-03-14 18:25:10 +01:00
$unit = substr ( $unit , 2 );
$ini = parse_ini_file ( $unit . '/vvb.ini' );
if ( $ini [ 'SITE_TYPE' ] == 'twitter' ) {
preg_match ( '#twitter\.com/(.+)#' , $ini [ 'SITE_URL' ], $username );
$response [] = $username [ 1 ];
}
unset ( $ini );
}
}
echo json_encode ( $response );
die ;
}
2013-02-24 15:44:16 +01:00
/**
2013-03-12 18:17:16 +01:00
* OPML Full Export
2013-02-24 15:44:16 +01:00
**/
if ( isset ( $_GET [ 'exportopml' ])) // OPML
{
//header('Content-Type: application/octet-stream');
header ( 'Content-type: text/xml' );
2013-03-12 18:17:16 +01:00
header ( 'Content-Disposition: attachment; filename="autoblogs-' . $_SERVER [ 'SERVER_NAME' ] . '.xml"' );
2013-02-24 15:44:16 +01:00
2013-03-12 18:17:16 +01:00
$opmlfile = new SimpleXMLElement ( '<opml></opml>' );
2013-02-24 15:44:16 +01:00
$opmlfile -> addAttribute ( 'version' , '1.0' );
$opmlhead = $opmlfile -> addChild ( 'head' );
$opmlhead -> addChild ( 'title' , 'Autoblog OPML export from ' . $_SERVER [ 'SERVER_NAME' ] );
$opmlhead -> addChild ( 'dateCreated' , date ( 'r' , time ()));
$opmlbody = $opmlfile -> addChild ( 'body' );
$directory = " ./ " ;
$subdirs = glob ( $directory . " * " );
2013-04-08 11:45:16 +02:00
2013-02-24 15:44:16 +01:00
foreach ( $subdirs as $unit ) {
2013-04-08 11:45:16 +02:00
if ( is_dir ( $unit ) && strpos ( $unit . '/' , DOC_FOLDER ) === FALSE ) {
2013-03-12 18:17:16 +01:00
$unit = substr ( $unit , 2 );
$ini = parse_ini_file ( $unit . '/vvb.ini' );
$config = new stdClass ;
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
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 ));
}
2013-02-24 15:44:16 +01:00
}
echo $opmlfile -> asXML ();
exit ;
}
2013-02-18 19:42:10 +01:00
/**
* Site map
**/
2013-02-13 11:22:51 +01:00
if ( isset ( $_GET [ 'sitemap' ]))
{
2013-03-12 18:17:16 +01:00
header ( 'Content-Type: application/xml' );
echo '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' ;
2013-04-07 13:04:19 +02:00
echo '<url><loc>' . 'http' . ( ! empty ( $_SERVER [ 'HTTPS' ]) ? 's' : '' ) . " :// { $_SERVER [ 'HTTP_HOST' ] } " . str_replace ( '?sitemap' , '' , $_SERVER [ 'REQUEST_URI' ]) . " </loc> \n " ;
echo '<lastmod>' . date ( 'c' , time ()) . " </lastmod> \n " ;
echo '<changefreq>daily</changefreq></url>' ;
2013-02-18 19:42:10 +01:00
$directory = " ./ " ;
$subdirs = glob ( $directory . " * " );
foreach ( $subdirs as $unit ) {
2013-04-08 12:09:43 +02:00
if ( is_dir ( $unit ) && strpos ( $unit . '/' , DOC_FOLDER ) === FALSE ) {
2013-03-12 18:17:16 +01:00
$unit = substr ( $unit , 2 );
$proto = ( ! empty ( $_SERVER [ 'HTTPS' ]) && strtolower ( $_SERVER [ 'HTTPS' ]) == 'on' ) ? " https:// " : " http:// " ;
echo '<url><loc>' . $proto . $_SERVER [ 'SERVER_NAME' ] . substr ( $_SERVER [ 'PHP_SELF' ], 0 , - 9 ) . " $unit / " . " </loc> \n " ;
echo '<lastmod>' . date ( 'c' , filemtime ( $unit )) . " </lastmod> \n " ;
echo '<changefreq>hourly</changefreq></url>' ;
}
}
echo '</urlset>' ;
2013-02-18 19:42:10 +01:00
die ;
2013-02-13 11:22:51 +01:00
}
2013-02-18 19:42:10 +01:00
/**
* Update ALL autblogs ( except . disabled )
* This action can be very slow and consume CPU if you have a lot of autoblogs
**/
2013-03-10 13:28:54 +01:00
if ( isset ( $_GET [ 'updateall' ]) && ALLOW_FULL_UPDATE ) {
2013-02-18 19:42:10 +01:00
$expire = time () - 84600 ; // 23h30 en secondes
2013-04-08 11:45:16 +02:00
$lockfile = " .updatealllock " ;
2013-02-18 19:42:10 +01:00
if ( file_exists ( $lockfile ) && filemtime ( $lockfile ) > $expire ) {
echo " too early " ;
2013-03-12 18:17:16 +01:00
die ;
2013-04-08 11:45:16 +02:00
}
2013-02-18 19:42:10 +01:00
else {
if ( file_exists ( $lockfile ) )
unlink ( $lockfile );
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
if ( file_put_contents ( $lockfile , date ( DATE_RFC822 )) === FALSE ) {
2013-03-12 18:17:16 +01:00
echo " Merci d'ajouter des droits d'écriture sur le fichier. " ;
die ;
2013-04-08 11:45:16 +02:00
}
2013-02-18 19:42:10 +01:00
}
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
$directory = " ./ " ;
$subdirs = glob ( $directory . " * " );
foreach ( $subdirs as $unit ) {
2013-04-07 13:10:07 +02:00
if ( is_dir ( $unit ) && strpos ( $unit . '/' , DOC_FOLDER ) === FALSE ) {
2013-03-12 18:17:16 +01:00
if ( ! file_exists ( ROOT_DIR . '/' . $unit . '/.disabled' )) {
2013-04-08 11:45:16 +02:00
file_get_contents ( serverUrl () . substr ( $_SERVER [ 'PHP_SELF' ], 0 , - 9 ) . $unit . '/index.php' );
2013-03-12 18:17:16 +01:00
}
}
2013-04-08 11:45:16 +02:00
}
2013-02-13 11:22:51 +01:00
}
2013-02-27 12:04:05 +01:00
$antibot = generate_antibot ();
2013-02-18 19:42:10 +01:00
$form = ' < form method = " POST " >< input type = " hidden " name = " generic " value = " 1 " />
< input placeholder = " Adresse du flux RSS/ATOM " type = " text " name = " rssurl " id = " rssurl " >< br >
2013-04-07 13:10:07 +02:00
< input placeholder = " Antibot : Ecrivez '. $antibot .' en chiffre " type = " text " name = " number " >< br >
2013-02-27 12:04:05 +01:00
< input type = " hidden " name = " antibot " value = " '. $antibot .' " />
2013-02-18 19:42:10 +01:00
< input type = " submit " value = " Vérifier " >
</ form > ' ;
2013-02-13 11:22:51 +01:00
2013-02-18 19:42:10 +01:00
/**
* ADD BY BOOKMARK BUTTON
**/
2013-02-19 12:20:13 +01:00
if ( ! empty ( $_GET [ 'via_button' ]) && $_GET [ 'number' ] === '17' && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_BUTTON )
2013-02-13 11:22:51 +01:00
{
2013-02-19 12:20:13 +01:00
$form = '<html><head></head><body>' ;
2013-04-08 11:45:16 +02:00
2013-02-19 12:20:13 +01:00
if ( empty ( $_GET [ 'rssurl' ]) ) {
$form .= '<p>URL du flux RSS incorrect.<br><a href="#" onclick="window.close()">Fermer la fenêtre.</a></p>' ;
}
2013-04-08 11:45:16 +02:00
else {
2013-03-12 18:17:16 +01:00
if ( isset ( $_GET [ 'add' ]) && $_GET [ 'add' ] === '1' && ! empty ( $_GET [ 'siteurl' ]) && ! empty ( $_GET [ 'sitename' ])) {
2013-04-04 18:58:28 +02:00
try {
$rssurl = DetectRedirect ( escape ( $_GET [ 'rssurl' ]));
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
$siteurl = escape ( $_GET [ 'siteurl' ]);
2013-03-10 14:48:29 +01:00
$sitename = escape ( $_GET [ 'sitename' ]);
$sitetype = updateType ( $siteurl ); // Disabled input doesn't send POST data
$sitetype = $sitetype [ 'type' ];
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
$error = array_merge ( $error , createAutoblog ( $sitetype , $sitename , $siteurl , $rssurl , $error ));
if ( empty ( $error )) {
$form .= '<iframe width="1" height="1" frameborder="0" src="' . urlToFolderSlash ( $siteurl ) . '/index.php"></iframe>' ;
2013-03-10 14:48:29 +01:00
$form .= '<p><span style="color:darkgreen">Autoblog <a href="' . urlToFolderSlash ( $siteurl ) . '">' . $sitename . '</a> ajouté avec succès.</span><br>' ;
2013-03-12 18:17:16 +01:00
}
2013-03-10 14:48:29 +01:00
else {
$form .= '<ul>' ;
foreach ( $error AS $value )
$form .= '<li>' . $value . '</li>' ;
$form .= '</ul>' ;
}
2013-02-19 12:20:13 +01:00
}
2013-04-04 18:58:28 +02:00
catch ( Exception $e ) {
$form .= $e -> getMessage ();
}
$form .= '<a href="#" onclick="window.close()">Fermer la fenêtre.</a></p>' ;
2013-03-12 18:17:16 +01:00
}
else {
2013-04-04 18:58:28 +02:00
try {
2013-04-08 11:45:16 +02:00
$rssurl = DetectRedirect ( escape ( $_GET [ 'rssurl' ]));
2013-03-10 14:48:29 +01:00
$datafeed = file_get_contents ( $rssurl );
if ( $datafeed !== false ) {
2013-03-12 18:17:16 +01:00
$siteurl = get_link_from_datafeed ( $datafeed );
2013-04-08 11:45:16 +02:00
$sitename = get_title_from_datafeed ( $datafeed );
2013-03-12 18:17:16 +01:00
$sitetype = updateType ( $siteurl );
2013-03-10 14:48:29 +01:00
$sitetype = $sitetype [ 'type' ];
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
$form .= ' < span style = " color:blue " > Merci de vérifier les informations suivantes , corrigez si nécessaire .</ span >< br >
< form method = " GET " >
< input type = " hidden " name = " via_button " value = " 1 " >< input type = " hidden " name = " add " value = " 1 " >< input type = " hidden " name = " number " value = " 17 " >
2013-04-08 11:45:16 +02:00
< input style = " width:30em; " type = " text " name = " sitename " id = " sitename " value = " '. $sitename .' " >< label for = " sitename " >& larr ; titre du site ( auto ) </ label >< br >
2013-03-12 18:17:16 +01:00
< input style = " width:30em; " placeholder = " Adresse du site " type = " text " name = " siteurl " id = " siteurl " value = " '. $siteurl .' " >< label for = " siteurl " >& larr ; page d\ ' accueil ( auto ) </ label >< br >
2013-03-10 14:48:29 +01:00
< input style = " width:30em; " placeholder = " Adresse du flux RSS/ATOM " type = " text " name = " rssurl " id = " rssurl " value = " '. $rssurl .' " >< label for = " rssurl " >& larr ; adresse du flux </ label >< br >
< input style = " width:30em; " type = " text " name = " sitetype " id = " sitetype " value = " '. $sitetype .' " disabled >< label for = " sitetype " >& larr ; type de site </ label >< br >
< input type = " submit " value = " Créer " ></ form > ' ;
2013-04-08 11:45:16 +02:00
}
2013-03-10 14:48:29 +01:00
else {
$form .= '<p>URL du flux RSS incorrecte.<br><a href="#" onclick="window.close()">Fermer la fenêtre.</a></p>' ;
}
2013-02-19 12:20:13 +01:00
}
2013-04-04 18:58:28 +02:00
catch ( Exception $e ) {
$form .= $e -> getMessage () . '<br><a href="#" onclick="window.close()">Fermer la fenêtre.</a></p>' ;
}
2013-03-12 18:17:16 +01:00
}
2013-02-19 12:20:13 +01:00
}
$form .= '</body></html>' ;
2013-04-08 11:45:16 +02:00
echo $form ; die ;
2013-02-13 11:22:51 +01:00
}
2013-02-18 19:42:10 +01:00
/**
* ADD BY SOCIAL / SHAARLI
**/
if ( ! empty ( $_POST [ 'socialaccount' ]) && ! empty ( $_POST [ 'socialinstance' ]) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_SOCIAL )
2013-02-13 11:22:51 +01:00
{
2013-03-01 12:12:54 +01:00
if ( ! empty ( $_POST [ 'number' ]) && ! empty ( $_POST [ 'antibot' ]) && check_antibot ( $_POST [ 'number' ], $_POST [ 'antibot' ]) ) {
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
$socialaccount = strtolower ( escape ( $_POST [ 'socialaccount' ]));
$socialinstance = strtolower ( escape ( $_POST [ 'socialinstance' ]));
2013-04-08 11:45:16 +02:00
if ( $socialinstance === 'twitter' ) {
2013-03-20 15:53:16 +01:00
if ( $apitwitter !== FALSE ) {
2013-04-08 11:45:16 +02:00
$sitetype = 'twitter' ;
$siteurl = " http://twitter.com/ $socialaccount " ;
2013-03-20 15:53:16 +01:00
$rssurl = $apitwitter . $socialaccount ;
}
else
$error [] = " Twitter veut mettre à mort son API ouverte. Du coup on peut plus faire ça comme ça. " ;
2013-04-08 11:45:16 +02:00
}
elseif ( $socialinstance === 'identica' ) {
$sitetype = 'identica' ;
$siteurl = " http://identi.ca/ $socialaccount " ;
$rssurl = " http://identi.ca/api/statuses/user_timeline/ $socialaccount .rss " ;
}
elseif ( $socialinstance === 'statusnet' && ! empty ( $_POST [ 'statusneturl' ])) {
$sitetype = 'microblog' ;
$siteurl = NoProtocolSiteURL ( escape ( $_POST [ 'statusneturl' ]));
2013-04-04 18:58:28 +02:00
try {
2013-04-08 11:45:16 +02:00
$rssurl = DetectRedirect ( " http:// " . $siteurl . " /api/statuses/user_timeline/ $socialaccount .rss " );
$siteurl = DetectRedirect ( " http:// " . $siteurl . " / $socialaccount " );
2013-04-04 18:58:28 +02:00
}
catch ( Exception $e ) {
echo $error [] = $e -> getMessage ();
2013-04-08 11:45:16 +02:00
}
}
elseif ( $socialinstance === 'shaarli' && ! empty ( $_POST [ 'shaarliurl' ])) {
$sitetype = 'shaarli' ;
$siteurl = NoProtocolSiteURL ( escape ( $_POST [ 'shaarliurl' ]));
2013-04-04 18:58:28 +02:00
try {
2013-04-08 11:45:16 +02:00
$siteurl = DetectRedirect ( " http:// " . $siteurl . " / " );
2013-04-04 18:58:28 +02:00
}
catch ( Exception $e ) {
echo $error [] = $e -> getMessage ();
}
2013-03-12 18:17:16 +01:00
$rssurl = $siteurl . " ?do=rss " ;
2013-04-08 11:45:16 +02:00
$socialaccount = get_title_from_feed ( $rssurl );
}
2013-04-04 18:58:28 +02:00
if ( empty ( $error ) ) {
2013-03-20 15:53:16 +01:00
// Twitterbridge do NOT allow this user yet => No check
if ( $sitetype != 'twitter' ) {
$headers = get_headers ( $rssurl , 1 );
if ( strpos ( $headers [ 0 ], '200' ) == FALSE ) {
$error [] = " Flux inaccessible (compte inexistant ?) " ;
}
2013-03-12 18:17:16 +01:00
}
if ( empty ( $error ) ) {
$error = array_merge ( $error , createAutoblog ( $sitetype , ucfirst ( $socialinstance ) . ' - ' . $socialaccount , $siteurl , $rssurl , $error ));
if ( empty ( $error ))
$success [] = '<iframe width="1" height="1" frameborder="0" src="' . urlToFolderSlash ( $siteurl ) . '/index.php"></iframe><b style="color:darkgreen">' . ucfirst ( $socialinstance ) . ' - ' . $socialaccount . ' <a href="' . urlToFolderSlash ( $siteurl ) . '">ajouté avec succès</a>.</b>' ;
2013-03-10 14:48:29 +01:00
}
2013-03-01 12:12:54 +01:00
}
2013-02-13 11:22:51 +01:00
}
2013-04-08 11:45:16 +02:00
else
2013-03-01 12:12:54 +01:00
$error [] = 'Antibot : Chiffres incorrects.' ;
2013-02-13 11:22:51 +01:00
}
2013-02-18 19:42:10 +01:00
/**
* ADD BY GENERIC LINK
**/
2013-02-23 20:31:13 +01:00
if ( ! empty ( $_POST [ 'generic' ]) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_LINKS ) {
2013-03-12 18:17:16 +01:00
if ( empty ( $_POST [ 'rssurl' ]))
{ $error [] = " Veuillez entrer l'adresse du flux. " ;}
if ( empty ( $_POST [ 'number' ]) || empty ( $_POST [ 'antibot' ]) )
{ $error [] = " Vous êtes un bot ? " ;}
2013-02-27 12:04:05 +01:00
elseif ( ! check_antibot ( $_POST [ 'number' ], $_POST [ 'antibot' ]))
2013-04-08 11:45:16 +02:00
{ $error [] = " Antibot : Ce n'est pas le bon nombre. " ;}
2013-02-13 11:22:51 +01:00
2013-03-12 18:17:16 +01:00
if ( empty ( $error )) {
2013-04-04 18:58:28 +02:00
try {
$rssurl = DetectRedirect ( escape ( $_POST [ 'rssurl' ]));
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
if ( ! empty ( $_POST [ 'siteurl' ])) {
2013-04-08 11:45:16 +02:00
$siteurl = escape ( $_POST [ 'siteurl' ]);
2013-03-12 18:17:16 +01:00
$sitename = get_title_from_feed ( $rssurl );
$error = array_merge ( $error , createAutoblog ( 'generic' , $sitename , $siteurl , $rssurl , $error ));
if ( empty ( $error ))
$success [] = '<iframe width="1" height="1" frameborder="0" src="' . urlToFolderSlash ( $siteurl ) . '/index.php"></iframe><b style="color:darkgreen">Autoblog ' . $sitename . ' crée avec succès.</b> → <a target="_blank" href="' . urlToFolderSlash ( $siteurl ) . '">afficher l\'autoblog</a>' ;
2013-04-08 11:45:16 +02:00
}
2013-03-12 18:17:16 +01:00
else {
// checking procedure
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
$datafeed = file_get_contents ( $rssurl );
if ( $datafeed === false ) {
$error [] = 'URL "' . $rssurl . '" inaccessible.' ;
}
$sitetype = 'generic' ;
$siteurl = get_link_from_datafeed ( $datafeed );
2013-04-08 11:45:16 +02:00
$sitename = get_title_from_datafeed ( $datafeed );
2013-03-12 18:17:16 +01:00
$form = ' < span style = " color:blue " > Merci de vérifier les informations suivantes , corrigez si nécessaire .</ span >< br >
< form method = " POST " >< input type = " hidden " name = " generic " value = " 1 " />
2013-04-08 11:45:16 +02:00
< input style = " color:black " type = " text " id = " sitename " value = " '. $sitename .' " '.( $datafeed === false?' ':' disabled ').' >< label for = " sitename " >& larr ; titre du site ( auto ) </ label >< br >
2013-03-12 18:17:16 +01:00
< input placeholder = " Adresse du site " type = " text " name = " siteurl " id = " siteurl " value = " '. $siteurl .' " >< label for = " siteurl " >& larr ; page d\ ' accueil ( auto ) </ label >< br >
2013-03-10 14:48:29 +01:00
< input placeholder = " Adresse du flux RSS/ATOM " type = " text " name = " rssurl " id = " rssurl " value = " '. $rssurl .' " >< label for = " rssurl " >& larr ; adresse du flux </ label >< br >
< input placeholder = " " Type de site " type= " text " name= " sitetype " id= " sitetype " value= " '.$sitetype.' " '.( $datafeed === false?'':'disabled').'><label for= " sitetype " >← type de site</label><br>
2013-04-07 13:10:07 +02:00
< input placeholder = " Antibot: '. escape( $_POST['antibot'] ) .' en chiffre " type = " text " name = " number " value = " '. escape( $_POST['number'] ) .' " >< label for = " number " >& larr ; antibot </ label >< br >
2013-03-10 14:48:29 +01:00
< input type = " hidden " name = " antibot " value = " '. escape( $_POST['antibot'] ) .' " />< input type = " submit " value = " Créer " ></ form > ' ;
2013-04-08 11:45:16 +02:00
}
2013-04-04 18:58:28 +02:00
}
catch ( Exception $e ) {
echo $error [] = $e -> getMessage ();
}
2013-03-12 18:17:16 +01:00
}
2013-02-13 11:22:51 +01:00
}
2013-02-18 19:42:10 +01:00
/**
2013-03-01 12:14:46 +01:00
* ADD BY OPML File
2013-02-18 19:42:10 +01:00
**/
2013-04-08 11:45:16 +02:00
if ( ! empty ( $_POST [ 'opml_file' ]) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML_FILE ) {
2013-03-01 12:12:54 +01:00
if ( empty ( $_POST [ 'number' ]) || empty ( $_POST [ 'antibot' ]) )
2013-03-12 18:17:16 +01:00
{ $error [] = " Vous êtes un bot ? " ;}
2013-03-01 12:12:54 +01:00
elseif ( ! check_antibot ( $_POST [ 'number' ], $_POST [ 'antibot' ]))
2013-04-08 11:45:16 +02:00
{ $error [] = " Antibot : Ce n'est pas le bon nombre. " ;}
2013-03-01 12:12:54 +01:00
if ( empty ( $error )) {
if ( is_uploaded_file ( $_FILES [ 'file' ][ 'tmp_name' ])) {
$opml = null ;
if ( ( $opml = simplexml_load_file ( $_FILES [ 'file' ][ 'tmp_name' ])) !== false ) {
2013-03-01 12:14:46 +01:00
create_from_opml ( $opml );
2013-02-18 19:42:10 +01:00
}
2013-04-08 11:45:16 +02:00
else
2013-03-01 12:12:54 +01:00
$error [] = " Impossible de lire le contenu du fichier OPML. " ;
unlink ( $_FILES [ 'file' ][ 'tmp_name' ]);
} else {
$error [] = " Le fichier n'a pas été envoyé. " ;
2013-04-08 11:45:16 +02:00
}
}
2013-02-18 19:42:10 +01:00
}
2013-03-01 12:14:46 +01:00
/**
* ADD BY OPML Link
**/
2013-04-08 11:45:16 +02:00
if ( ! empty ( $_POST [ 'opml_link' ]) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML_LINK ) {
2013-03-01 12:14:46 +01:00
if ( empty ( $_POST [ 'number' ]) || empty ( $_POST [ 'antibot' ]) )
{ $error [] = " Vous êtes un bot ? " ;}
elseif ( ! check_antibot ( $_POST [ 'number' ], $_POST [ 'antibot' ]))
2013-04-08 11:45:16 +02:00
{ $error [] = " Antibot : Ce n'est pas le bon nombre. " ;}
2013-03-01 12:14:46 +01:00
if ( empty ( $_POST [ 'opml_url' ] ))
{ $error [] = 'Le lien est incorrect.' ;}
2013-04-08 11:45:16 +02:00
2013-03-01 12:14:46 +01:00
if ( empty ( $error )) {
2013-03-04 21:40:43 +01:00
$opml_url = escape ( $_POST [ 'opml_url' ]);
if ( parse_url ( $opml_url , PHP_URL_HOST ) == FALSE ) {
$error [] = " URL du fichier OPML non valide. " ;
} else {
if ( ( $opml = simplexml_load_file ( $opml_url )) !== false ) {
create_from_opml ( $opml );
} else {
$error [] = " Impossible de lire le contenu du fichier OPML ou d'accéder à l'URL donnée. " ;
2013-04-08 11:45:16 +02:00
}
2013-03-01 12:14:46 +01:00
}
2013-03-04 21:40:43 +01:00
2013-04-08 11:45:16 +02:00
}
2013-03-01 12:14:46 +01:00
}
2013-02-13 11:22:51 +01:00
?>
<! DOCTYPE html >
< html lang = " en " dir = " ltr " >
2013-03-12 18:17:16 +01:00
< head >
< meta charset = " utf-8 " >
2013-02-19 12:20:13 +01:00
< title > Projet Autoblog < ? php if ( ! empty ( $head_title )) { echo " | " . escape ( $head_title ); } ?> </title>
2013-03-12 18:17:16 +01:00
< link rel = " alternate " type = " application/rss+xml " title = " RSS " href = " <?php echo serverUrl(true) . RSS_FILE;?> " />
2013-04-08 13:13:25 +02:00
< link href = " <?php echo RESOURCES_FOLDER; ?>autoblog.css " rel = " stylesheet " type = " text/css " >
2013-04-08 12:08:16 +02:00
< ? php
2013-04-08 13:13:25 +02:00
if ( file_exists ( RESOURCES_FOLDER . 'user.css' )){
echo '<link href="' . RESOURCES_FOLDER . 'user.css" rel="stylesheet" type="text/css">' ;
2013-04-08 12:08:16 +02:00
}
?>
2013-03-12 18:17:16 +01:00
</ head >
< body >
2013-03-30 21:19:59 +01:00
< h1 >< a href = " <?php echo serverUrl(true); ?> " > PROJET AUTOBLOG < ? php if ( ! empty ( $head_title )) { echo " | " . escape ( $head_title ); } ?> </a></h1>
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
< div class = " pbloc " >
2013-04-08 13:13:25 +02:00
< img id = " logo " src = " <?php if(isset( $logo )) { echo $logo ; }else { echo RESOURCES_FOLDER.'icon-logo.svg'; } ?> " alt = " " >
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
< h2 > Présentation </ h2 >
2013-02-18 19:42:10 +01:00
< p >
2013-03-12 18:17:16 +01:00
Le Projet Autoblog a pour objectif de répliquer les articles d 'un blog ou d' un site site web .< br />
Si l 'article source est supprimé, et même si le site d' origine disparaît , les articles restent lisibles sur l ' autoblog . < br />
L ' objectif premier de ce projet est de lutter contre la censure et toute sorte de pression ...
</ p >
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
< p >
2013-04-08 11:45:16 +02:00
Voici une liste d 'autoblogs hébergés sur <i><?php echo $_SERVER[' SERVER_NAME ' ]; ?> </i>
2013-03-12 18:17:16 +01:00
( < a href = " http://sebsauvage.net/streisand.me/fr/ " > plus d ' infos sur le projet </ a > ) .
2013-04-08 11:45:16 +02:00
</ p >
2013-03-12 18:17:16 +01:00
</ div >
2013-04-08 11:45:16 +02:00
2013-03-01 13:13:30 +01:00
< ? php if ( $update_available ) { ?>
< div class = " pbloc " >
2013-03-01 13:39:33 +01:00
< h2 > Mise à jour </ h2 >
2013-03-01 13:13:30 +01:00
< p >
2013-03-20 15:10:34 +01:00
Une mise à jour du Projet Autoblog est disponible !< br >
& rarr ; < a href = " https://github.com/mitsukarenai/Projet-Autoblog/archive/master.zip " > Télécharger la dernière version </ a >< br >
& rarr ; < strong > Important : </ strong >< a href = " https://github.com/mitsukarenai/Projet-Autoblog/wiki/Mettre-%C3%A0-jour " > Consulter la documentation - mise à jour </ a >
2013-03-12 18:17:16 +01:00
</ p >
2013-03-01 13:13:30 +01:00
</ div >
< ? php } ?>
2013-02-18 19:42:10 +01:00
2013-03-12 18:17:16 +01:00
< ? php if ( ALLOW_NEW_AUTOBLOGS == TRUE ) { ?>
< div class = " pbloc " >
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
< h2 > Ajouter un autoblog </ h2 >
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
< ? php
if ( ! empty ( $error ) || ! empty ( $success )) {
echo '<p>Message' . ( count ( $error ) ? 's' : '' ) . ' :</p><ul>' ;
foreach ( $error AS $value ) {
echo '<li class="error">' . $value . '</li>' ;
}
foreach ( $success AS $value ) {
echo '<li class="success">' . $value . '</li>' ;
2013-04-08 11:45:16 +02:00
}
2013-02-18 19:42:10 +01:00
echo '</ul>' ;
}
2013-04-08 11:45:16 +02:00
2013-02-27 10:28:49 +01:00
$button_list = '<p id="button_list">Ajouter un autoblog via : ' ;
if ( ALLOW_NEW_AUTOBLOGS_BY_LINKS )
2013-03-01 12:31:11 +01:00
$button_list .= '<a href="#add_generic" class="button" id="button_generic" onclick="show_form(\'generic\');return false;">Flux RSS</a> ' ;
if ( ALLOW_NEW_AUTOBLOGS_BY_SOCIAL ) {
$button_list .= '<a href="#add_social" class="button" id="button_social" onclick="show_form(\'social\');return false;">Compte réseau social</a> ' ;
$button_list .= '<a href="#add_shaarli" class="button" id="button_shaarli" onclick="show_form(\'shaarli\');return false;">Shaarli</a> ' ;
}
2013-03-01 12:14:46 +01:00
if ( ALLOW_NEW_AUTOBLOGS_BY_OPML_FILE )
2013-03-01 12:31:11 +01:00
$button_list .= '<a href="#add_opmlfile" class="button" id="button_opmlfile" onclick="show_form(\'opmlfile\');return false;">Fichier OPML</a> ' ;
2013-03-01 12:14:46 +01:00
if ( ALLOW_NEW_AUTOBLOGS_BY_OPML_LINK )
2013-03-01 12:31:11 +01:00
$button_list .= '<a href="#add_opmllink" class="button" id="button_opmllink" onclick="show_form(\'opmllink\');return false;">Lien vers OPML</a> ' ;
2013-02-27 10:28:49 +01:00
if ( ALLOW_NEW_AUTOBLOGS_BY_BUTTON )
2013-03-01 12:31:11 +01:00
$button_list .= '<a href="#add_bookmark" class="button" id="button_bookmark" onclick="show_form(\'bookmark\');return false;">Marque page</a> ' ;
2013-02-27 10:28:49 +01:00
$button_list .= '</p>' ;
echo $button_list ;
2013-04-08 11:45:16 +02:00
2013-02-27 10:28:49 +01:00
if ( ALLOW_NEW_AUTOBLOGS_BY_LINKS == TRUE ) { ?>
2013-04-08 11:45:16 +02:00
< div class = " form " id = " add_generic " >
< h3 > Ajouter un site web </ h3 >
2013-03-12 18:17:16 +01:00
< p >
Si vous souhaitez que < i >< ? php echo $_SERVER [ 'SERVER_NAME' ]; ?> </i> héberge un autoblog d'un site,<br>
remplissez le formulaire suivant :
</ p >
2013-04-08 11:45:16 +02:00
< ? php echo $form ; ?>
2013-03-12 18:17:16 +01:00
</ div >
2013-04-08 11:45:16 +02:00
< ? php }
2013-02-18 19:42:10 +01:00
if ( ALLOW_NEW_AUTOBLOGS_BY_SOCIAL == TRUE ) { ?>
2013-04-08 11:45:16 +02:00
< div class = " form " id = " add_social " >
2013-03-12 18:17:16 +01:00
< h3 > Ajouter un compte social </ h3 >
< form method = " POST " >
< input placeholder = " Identifiant du compte " type = " text " name = " socialaccount " id = " socialaccount " >< br >
2013-04-08 11:45:16 +02:00
< ? php
if ( $apitwitter !== FALSE )
2013-03-20 15:53:16 +01:00
echo '<input type="radio" name="socialinstance" value="twitter">Twitter<br>' ;
2013-04-08 11:45:16 +02:00
else echo '<s>Twitter</s><br>' ; ?>
2013-03-12 18:17:16 +01:00
< input type = " radio " name = " socialinstance " value = " identica " > Identica < br >
2013-04-08 11:45:16 +02:00
< input type = " radio " name = " socialinstance " value = " statusnet " >
2013-03-12 18:17:16 +01:00
< input placeholder = " statusnet.personnel.com " type = " text " name = " statusneturl " id = " statusneturl " >< br >
2013-04-07 13:10:07 +02:00
< input placeholder = " Antibot : Ecrivez '<?php echo $antibot ; ?>' en chiffres " type = " text " name = " number " class = " smallinput " >< br >
2013-03-01 12:12:54 +01:00
< input type = " hidden " name = " antibot " value = " <?php echo $antibot ; ?> " />
2013-03-12 18:17:16 +01:00
< input type = " submit " value = " Créer " >
</ form >
</ div >
2013-02-18 19:42:10 +01:00
2013-02-27 10:28:49 +01:00
< div class = " form " id = " add_shaarli " >
2013-03-12 18:17:16 +01:00
< h3 > Ajouter un Shaarli </ h3 >
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
< form method = " POST " >
< input type = " hidden " name = " socialaccount " value = " shaarli " >
2013-03-01 12:14:46 +01:00
< input placeholder = " shaarli.personnel.com " type = " text " name = " shaarliurl " id = " shaarliurl " >< br >
2013-04-07 13:10:07 +02:00
< input placeholder = " Antibot : Ecrivez '<?php echo $antibot ; ?>' en chiffres " type = " text " name = " number " class = " smallinput " >< br >
2013-03-01 12:12:54 +01:00
< input type = " hidden " name = " antibot " value = " <?php echo $antibot ; ?> " />
2013-03-12 18:17:16 +01:00
< input type = " submit " value = " Créer " >
</ form >
</ div >
2013-04-08 11:45:16 +02:00
< ? php }
if ( ALLOW_NEW_AUTOBLOGS_BY_OPML_FILE == TRUE ) { ?>
2013-02-27 10:28:49 +01:00
< div class = " form " id = " add_opmlfile " >
2013-02-23 15:27:29 +01:00
< h3 > Ajouter par fichier OPML </ h3 >
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
< form enctype = 'multipart/form-data' method = 'POST' >
2013-03-01 12:14:46 +01:00
< input type = 'hidden' name = 'opml_file' value = '1' />
2013-02-18 19:42:10 +01:00
< input type = 'file' name = 'file' />< br >
2013-04-07 13:10:07 +02:00
< input placeholder = " Antibot : Ecrivez '<?php echo $antibot ; ?>' en chiffres " type = " text " name = " number " class = " smallinput " >< br >
2013-03-01 12:12:54 +01:00
< input type = " hidden " name = " antibot " value = " <?php echo $antibot ; ?> " />
2013-02-18 19:42:10 +01:00
< input type = 'submit' value = 'Importer' />
</ form >
</ div >
2013-04-08 11:45:16 +02:00
< ? php }
if ( ALLOW_NEW_AUTOBLOGS_BY_OPML_LINK == TRUE ) { ?>
2013-03-01 12:14:46 +01:00
< div class = " form " id = " add_opmllink " >
< h3 > Ajouter par lien OPML </ h3 >
2013-04-08 11:45:16 +02:00
2013-03-01 12:14:46 +01:00
< form method = " POST " >
< input type = " hidden " name = " opml_link " value = " 1 " >
2013-03-12 18:17:16 +01:00
< input placeholder = " Lien vers OPML " type = " text " name = " opml_url " id = " opml_url " class = " smallinput " >< br >
2013-04-07 13:10:07 +02:00
< input placeholder = " Antibot : Ecrivez '<?php echo $antibot ; ?>' en chiffres " type = " text " name = " number " class = " smallinput " >< br >
2013-03-01 12:14:46 +01:00
< input type = " hidden " name = " antibot " value = " <?php echo $antibot ; ?> " />
2013-03-12 18:17:16 +01:00
< input type = " submit " value = " Envoyer " >
2013-03-01 12:14:46 +01:00
</ form >
</ div >
2013-04-08 11:45:16 +02:00
< ? php }
if ( ALLOW_NEW_AUTOBLOGS_BY_BUTTON == TRUE ) { ?>
2013-02-27 10:28:49 +01:00
< div class = " form " id = " add_bookmark " >
2013-03-12 18:17:16 +01:00
< h3 > Marque page </ h3 >
2013-04-08 11:45:16 +02:00
< p > Pour ajouter facilement un autoblog d ' un site web , glissez ce bouton dans votre barre de marque - pages & rarr ;
< a class = " bouton " onclick = " alert('Glissez ce bouton dans votre barre de marque-pages (ou clic-droit > marque-page sur ce lien)');return false; "
2013-03-12 18:17:16 +01:00
href = " javascript:(function() { var%20autoblog_url="<?php echo serverUrl(). $_SERVER["REQUEST_URI"] ; ?>";var%20popup=window.open("","Add%20autoblog",'height=180,width=670');popup.document.writeln('<html><head></head><body><form%20action="'+autoblog_url+'"%20method="GET">');popup.document.write('Url%20feed%20%20:%20<br/>');var%20feed_links=new%20Array();var%20links=document.getElementsByTagName('link');if(links.length>0) { for(var%20i=0;i<links.length;i++) { if(links[i].rel=="alternate") { popup.document.writeln('<label%20for="feed_'+i+'"><input%20id="feed_'+i+'"%20type="radio"%20name="rssurl"%20value="'+links[i].href+'"/>'+links[i].title+"%20(%20"+links[i].href+"%20)</label><br/>");}}}popup.document.writeln("<input%20id='number'%20type='hidden'%20name='number'%20value='17'>");popup.document.writeln("<input%20type='hidden'%20name='via_button'%20value='1'>");popup.document.writeln("<br/><input%20type='submit'%20value='Vérifier'%20name='Ajouter'%20>");popup.document.writeln("</form></body></html>");})(); " >
Projet Autoblog
</ a >
2013-02-27 10:28:49 +01:00
</ div >
2013-02-18 19:42:10 +01:00
< ? php } ?>
</ div >
< ? php } ?>
2013-04-05 13:06:10 +02:00
< ? php
$directory = " ./ " . DOC_FOLDER ;
$docs = array ();
if ( is_dir ( $directory ) && ! file_exists ( $directory . '.disabled' ) ) {
2013-04-08 11:45:16 +02:00
$subdirs = glob ( $directory . " * " );
2013-04-05 13:06:10 +02:00
foreach ( $subdirs as $unit )
{
if ( ! is_dir ( $unit ) || file_exists ( $unit . '/index.html' ) || file_exists ( $unit . '/index.htm' ) || file_exists ( $unit . '/index.php' ) ) {
$docs [] = '<a href="' . $unit . '">' . substr ( $unit , ( strrpos ( $unit , '/' )) + 1 ) . '</a>' ;
2013-04-08 11:45:16 +02:00
}
2013-04-05 13:06:10 +02:00
}
}
if ( ! empty ( $docs )) {
echo '<div class="pbloc"><h2>Autres documents</h2><ul>' ;
2013-04-08 11:45:16 +02:00
foreach ( $docs as $value )
2013-04-05 13:06:10 +02:00
echo '<li>' . $value . '</li>' ;
echo '</ul></div>' ;
}
?>
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
< div class = " pbloc " >
2013-04-08 13:13:25 +02:00
< h2 > Autoblogs hébergés < a href = " ?rss " title = " RSS des changements " >< img src = " <?php echo RESOURCES_FOLDER; ?>rss.png " alt = " rss " /></ a ></ h2 >
2013-02-18 19:42:10 +01:00
< p >
2013-03-12 18:17:16 +01:00
< b > Autres fermes </ b >
& rarr ; < a href = " https://duckduckgo.com/?q=!g%20%22Voici%20une%20liste%20d'autoblogs%20hébergés%22 " > Rechercher </ a >
2013-02-18 19:42:10 +01:00
</ p >
2013-02-24 15:44:16 +01:00
< div class = " clear " >< a href = " ?sitemap " > sitemap </ a > | < a href = " ?export " > export < sup > JSON </ sup ></ a > | < a href = " ?exportopml " > export < sup > OPML </ sup ></ a ></ div >
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
< ? php
$directory = " ./ " ;
$subdirs = glob ( $directory . " * " );
$autoblogs = array ();
foreach ( $subdirs as $unit )
{
2013-04-07 13:10:07 +02:00
if ( is_dir ( $unit ) && strpos ( $unit . '/' , DOC_FOLDER ) === FALSE )
2013-03-12 18:17:16 +01:00
{
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 );
}
}
}
2013-02-18 19:42:10 +01:00
}
uasort ( $autoblogs , " objectCmp " );
$autoblogs_display = '' ;
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
if ( ! empty ( $autoblogs )){
2013-03-12 18:17:16 +01:00
foreach ( $autoblogs as $key => $autoblog ) {
2013-03-02 12:33:27 +01:00
$opml_link = '<a href="' . $key . '/?opml">opml</a>' ;
2013-03-12 18:17:16 +01:00
$autoblogs_display .= ' < div class = " vignette " >
< div class = " title " >< a title = " '.escape( $autoblog->site_title ).' " href = " '. $key .'/ " >< img width = " 15 " height = " 15 " alt = " " src = " ./?check='. $key .' " > '.escape($autoblog->site_title).' </ a ></ div >
< div class = " source " > config < sup >< a href = " '. $key .'/vvb.ini " > ini </ a > '.$opml_link.' </ sup > | '.escape($autoblog->site_type).' source : < a href = " '.escape( $autoblog->site_url ).' " > '.escape($autoblog->site_url).' </ a ></ div >
</ div > ' ;
}
2013-02-18 19:42:10 +01:00
}
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
echo $autoblogs_display ;
?>
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
< div class = " clear " ></ div >
2013-04-08 11:45:16 +02:00
2013-02-18 19:42:10 +01:00
< ? php echo " <p> " . count ( $autoblogs ) . " autoblogs hébergés</p> " ; ?>
</ div >
2013-03-10 14:48:29 +01:00
Propulsé par < a href = " https://github.com/mitsukarenai/Projet-Autoblog " > Projet Autoblog 0.3 </ a > de < a href = " https://www.suumitsu.eu/ " > Mitsu </ a > , < a href = " https://www.ecirtam.net/ " > Oros </ a > et < a href = " http://hoa.ro " > Arthur Hoaro </ a > ( Domaine Public )
2013-02-18 19:42:10 +01:00
< ? php if ( isset ( $HTML_footer )){ echo " <br/> " . $HTML_footer ; } ?>
2013-03-12 18:17:16 +01:00
< iframe width = " 1 " height = " 1 " style = " display:none " src = " xsaf3.php " ></ iframe >
2013-04-08 11:45:16 +02:00
2013-02-27 10:28:49 +01:00
< script type = " text/javascript " >
2013-04-08 11:45:16 +02:00
< ? php if ( ! empty ( $_POST [ 'generic' ]) && ! empty ( $_POST [ 'siteurl' ]) || empty ( $_POST [ 'generic' ]) )
2013-02-27 12:04:05 +01:00
echo " document.getElementById('add_generic').style.display = 'none'; " ; ?>
2013-02-27 10:28:49 +01:00
document . getElementById ( 'add_social' ) . style . display = 'none' ;
document . getElementById ( 'add_shaarli' ) . style . display = 'none' ;
document . getElementById ( 'add_opmlfile' ) . style . display = 'none' ;
document . getElementById ( 'add_bookmark' ) . style . display = 'none' ;
2013-03-01 12:14:46 +01:00
document . getElementById ( 'add_opmllink' ) . style . display = 'none' ;
2013-02-27 10:28:49 +01:00
document . getElementById ( 'button_list' ) . style . display = 'block' ;
function show_form ( str ){
2013-04-08 11:45:16 +02:00
document . getElementById ( 'add_' + str ) . style . display = ( document . getElementById ( 'add_' + str ) . style . display != 'block' ? 'block' : 'none' );
document . getElementById ( 'button_' + str ) . className = ( document . getElementById ( 'button_' + str ) . className != 'buttonactive' ? 'buttonactive' : 'button' );
2013-02-27 10:28:49 +01:00
}
</ script >
2013-04-08 11:45:16 +02:00
2013-03-12 18:17:16 +01:00
</ body >
2013-02-23 15:07:29 +01:00
</ html >
2013-04-07 13:10:07 +02:00