2013-02-13 11:22:51 +01:00
< ? php
/*
2013-02-18 19:42:10 +01:00
Projet Autoblog 0.3 - beta - fah
2013-02-13 11:22:51 +01:00
Code : https :// github . com / mitsukarenai / Projet - Autoblog
2013-02-18 19:42:10 +01:00
Authors :
Mitsu https :// www . suumitsu . eu /
Oros https :// www . ecirtam . net /
Arthur Hoaro http :// aryo . fr
2013-02-13 11:22:51 +01:00
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 )
- upload all files on your server ( PHP 5.3 + required )
- PROFIT !
*/
2013-02-18 19:42:10 +01:00
define ( 'XSAF_VERSION' , 3 );
2013-02-13 11:22:51 +01:00
define ( 'ROOT_DIR' , __DIR__ );
if ( file_exists ( " config.php " )){
include " config.php " ;
2013-02-19 12:20:13 +01:00
} else {
echo " config.php not found ! " ;
die ;
2013-02-13 11:22:51 +01:00
}
2013-02-18 19:42:10 +01:00
if ( file_exists ( " functions.php " )){
include " functions.php " ;
2013-02-19 12:20:13 +01:00
} else {
echo " functions.php not found ! " ;
die ;
2013-02-18 19:42:10 +01:00
}
$error = array ();
$success = array ();
function get_title_from_feed ( $url ) {
return get_title_from_datafeed ( file_get_contents ( $url ));
}
2013-02-13 11:22:51 +01:00
2013-02-18 19:42:10 +01:00
function get_title_from_datafeed ( $data ) {
2013-02-19 12:20:13 +01:00
if ( $data === false ) { return 'url inaccessible' ; }
2013-02-13 11:22:51 +01:00
$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 ) {
return get_link_from_datafeed ( file_get_contents ( $url ));
}
function get_link_from_datafeed ( $data ) {
2013-02-19 12:20:13 +01:00
if ( $data === false ) { return 'url inaccessible' ; }
2013-02-13 11:22:51 +01:00
$xml = simplexml_load_string ( $data ); // quick feed check
2013-02-18 19:42:10 +01:00
2013-02-16 16:23:21 +01:00
// ATOM feed && RSS 1.0 /RDF && RSS 2.0
if ( ! isset ( $xml -> entry ) && ! isset ( $xml -> item ) && ! isset ( $xml -> channel -> item ))
2013-02-18 19:42:10 +01:00
die ( 'le flux n\'a pas une syntaxe valide' );
$check = substr ( $data , 0 , 5 );
if ( $check !== '<?xml' ) {
die ( 'n\'est pas un flux valide' );
}
2013-02-16 16:23:21 +01:00
2013-02-13 11:22:51 +01:00
$xml = new SimpleXmlElement ( $data );
$channel [ 'link' ] = $xml -> channel -> link ;
2013-02-18 19:42:10 +01:00
if ( $channel [ 'link' ] === NULL ) {
$dom = new DOMDocument ;
$dom -> loadXML ( $data ) or die ( 'xml malformé' );
$link = $dom -> getElementsByTagName ( 'uri' );
return $link -> item ( 0 ) -> nodeValue ;
2013-02-13 11:22:51 +01:00
}
2013-02-18 19:42:10 +01:00
else {
return $channel [ 'link' ];
}
}
2013-02-13 11:22:51 +01:00
function serverUrl ()
{
$https = ( ! empty ( $_SERVER [ 'HTTPS' ]) && ( strtolower ( $_SERVER [ 'HTTPS' ]) == 'on' )) || $_SERVER [ " SERVER_PORT " ] == '443' ; // HTTPS detection.
$serverport = ( $_SERVER [ " SERVER_PORT " ] == '80' || ( $https && $_SERVER [ " SERVER_PORT " ] == '443' ) ? '' : ':' . $_SERVER [ " SERVER_PORT " ]);
return 'http' . ( $https ? 's' : '' ) . '://' . $_SERVER [ " SERVER_NAME " ] . $serverport ;
}
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-18 19:42:10 +01:00
/**
* SVG
**/
2013-02-13 11:22:51 +01:00
if ( isset ( $_GET [ 'check' ]))
{
2013-02-18 19:42:10 +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-02-13 11:22:51 +01:00
2013-02-18 19:42:10 +01:00
$errorlog = " ./ " . escape ( $_GET [ 'check' ] ) . " /error.log " ;
2013-02-13 11:22:51 +01:00
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-02-18 19:42:10 +01:00
{
2013-02-13 11:22:51 +01:00
if ( filesize ( $errorlog ) == " 0 " ) { die ( $svg_vert );}
else if ( filesize ( $errorlog ) == " 1 " ) { die ( $svg_jaune );}
else { die ( $svg_rouge );}
2013-02-18 19:42:10 +01:00
}
2013-02-13 11:22:51 +01:00
else /* ..sinon, lancer la procédure de contrôle */
2013-02-18 19:42:10 +01:00
{
$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' ]);
2013-02-13 11:22:51 +01:00
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é) */
2013-02-18 19:42:10 +01:00
}
2013-02-13 11:22:51 +01:00
}
2013-02-18 19:42:10 +01:00
/**
* Simple and Full Export
**/
if ( isset ( $_GET [ 'export' ]) || isset ( $_GET [ 'feedexport' ])) {
header ( 'Content-Type: application/json' );
$directory = " ./ " ;
$subdirs = glob ( $directory . " * " );
foreach ( $subdirs as $unit ) {
if ( is_dir ( $unit )) {
2013-02-13 11:22:51 +01:00
$unit = substr ( $unit , 2 );
$ini = parse_ini_file ( $unit . '/vvb.ini' );
$config = new stdClass ;
2013-02-18 19:42:10 +01:00
foreach ( $ini as $key => $value ) {
2013-02-13 11:22:51 +01:00
$key = strtolower ( $key );
$config -> $key = $value ;
2013-02-18 19:42:10 +01:00
}
2013-02-13 11:22:51 +01:00
unset ( $ini );
2013-02-18 19:42:10 +01:00
$feed = $config -> feed_url ;
if ( isset ( $_GET [ 'export' ]) ) {
$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 " );
}
// export feed only
else
$reponse = $reponse . " ; $feed " ;
}
}
if ( isset ( $_GET [ 'export' ]) )
echo json_encode ( array ( " meta " => array ( " xsaf-version " => XSAF_VERSION , " xsaf-db_transfer " => " true " , " xsaf-media_transfer " => " true " ),
2013-02-13 11:22:51 +01:00
" autoblogs " => $reponse ));
2013-02-18 19:42:10 +01:00
else
echo json_encode ( explode ( ';' , substr ( $reponse , 1 )));
die ;
2013-02-13 11:22:51 +01:00
}
2013-02-18 19:42:10 +01:00
/**
* Site map
**/
2013-02-13 11:22:51 +01:00
if ( isset ( $_GET [ 'sitemap' ]))
// url-list sitemap
{
2013-02-18 19:42:10 +01:00
header ( 'Content-Type: text/plain' );
$directory = " ./ " ;
$subdirs = glob ( $directory . " * " );
foreach ( $subdirs as $unit ) {
if ( is_dir ( $unit )) {
2013-02-13 11:22:51 +01:00
$unit = substr ( $unit , 2 );
$proto = $_SERVER [ 'HTTPS' ] ? " https:// " : " http:// " ;
echo $proto . $_SERVER [ 'SERVER_NAME' ] . substr ( $_SERVER [ 'PHP_SELF' ], 0 , - 9 ) . " $unit / " . " \n " ;
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
**/
if ( isset ( $_GET [ 'updateAll' ]) && ALLOW_FULL_UPDATE ) {
$expire = time () - 84600 ; // 23h30 en secondes
$lockfile = " .updatealllock " ;
if ( file_exists ( $lockfile ) && filemtime ( $lockfile ) > $expire ) {
echo " too early " ;
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 ;
}
}
$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' );
}
}
}
2013-02-13 11:22:51 +01:00
}
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 >
< input placeholder = " Antibot: \ 'dix-sept \ ' en chiffre " type = " text " name = " number " id = " number " >< br >
< 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-02-18 19:42:10 +01: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>' ;
}
else {
if ( isset ( $_GET [ 'add' ]) && $_GET [ 'add' ] === '1' && ! empty ( $_GET [ 'siteurl' ]) && ! empty ( $_GET [ 'sitename' ])) {
$rssurl = DetectRedirect ( escape ( $_GET [ 'rssurl' ]));
$siteurl = escape ( $_GET [ 'siteurl' ]);
$sitename = escape ( $_GET [ 'sitename' ]);
$sitetype = updateType ()[ 'type' ];
$error = createAutoblog ( $sitetype , $sitename , $siteurl , $rssurl , $error );
if ( empty ( $error )) {
$form .= '<p>' . $sitetype . '</p>' ;
$form .= '<iframe width="1" height="1" frameborder="0" src="' . urlToFolder ( $siteurl ) . '/index.php"></iframe>' ;
$form .= '<p><span style="color:darkgreen">Autoblog <a href="' . urlToFolder ( $siteurl ) . '">' . $sitename . '</a> ajouté avec succès.</span><br>' ;
}
else {
$form .= '<ul>' ;
foreach ( $error AS $value )
$form .= '<li>' . $value . '</li>' ;
$form .= '</ul>' ;
}
$form .= '<a href="#" onclick="window.close()">Fermer la fenêtre.</a></p>' ;
}
else {
$rssurl = DetectRedirect ( escape ( $_GET [ 'rssurl' ]));
$datafeed = file_get_contents ( $rssurl );
if ( $datafeed !== false ) {
$siteurl = get_link_from_datafeed ( $datafeed );
$sitename = get_title_from_datafeed ( $datafeed );
$sitetype = updateType ()[ 'type' ];
$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 " >
< input style = " width:30em; " type = " text " name = " sitename " id = " sitename " value = " '. $sitename .' " >< label for = " sitename " >& larr ; titre du site ( auto ) </ label >< br >
< 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 >
< 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 > ' ;
}
else {
$form .= '<p>URL du flux RSS incorrect.<br><a href="#" onclick="window.close()">Fermer la fenêtre.</a></p>' ;
}
}
}
$form .= '</body></html>' ;
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-02-18 19:42:10 +01:00
$socialaccount = strtolower ( escape ( $_POST [ 'socialaccount' ]));
$socialinstance = strtolower ( escape ( $_POST [ 'socialinstance' ]));
if ( $socialinstance === 'twitter' ) {
$sitetype = 'microblog' ;
$siteurl = " http://twitter.com/ $socialaccount " ;
$rssurl = " http://api.twitter.com/1/statuses/user_timeline.rss?screen_name= $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 );
}
$headers = get_headers ( $rssurl , 1 );
if ( strpos ( $headers [ 0 ], '200' ) == FALSE ) {
$error [] = " Flux inaccessible (compte inexistant ?) " ;
}
if ( empty ( $error ) ) {
$error = createAutoblog ( $sitetype , ucfirst ( $socialinstance ) . ' - ' . $socialaccount , $siteurl , $rssurl , $error );
if ( empty ( $error ))
$success [] = '<iframe width="1" height="1" frameborder="0" src="' . urlToFolder ( $siteurl ) . '/index.php"></iframe><b style="color:darkgreen">AutoMicroblog <a href="' . $foldername . '">ajouté avec succès</a>.</b>' ;
2013-02-13 11:22:51 +01:00
}
}
2013-02-18 19:42:10 +01:00
/**
* ADD BY GENERIC LINK
**/
if ( ! empty ( $_POST [ 'generic' ]) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_LINK ) {
2013-02-13 11:22:51 +01:00
if ( empty ( $_POST [ 'rssurl' ]))
{ $error [] = " Veuillez entrer l'adresse du flux. " ;}
if ( empty ( $_POST [ 'number' ]))
2013-02-18 19:42:10 +01:00
{ $error [] = " Vous êtes un bot ? " ;}
2013-02-13 11:22:51 +01:00
if ( $_POST [ 'number' ] !== '17' )
2013-02-18 19:42:10 +01:00
{ $error [] = " C'est pas le bon nombre. " ;}
2013-02-13 11:22:51 +01:00
2013-02-18 19:42:10 +01:00
if ( empty ( $error )) {
2013-02-13 11:22:51 +01:00
$rssurl = DetectRedirect ( escape ( $_POST [ 'rssurl' ]));
2013-02-18 19:42:10 +01:00
if ( ! empty ( $_POST [ 'siteurl' ])) {
$siteurl = escape ( $_POST [ 'siteurl' ]);
2013-02-13 11:22:51 +01:00
$sitename = get_title_from_feed ( $rssurl );
2013-02-18 19:42:10 +01:00
$error = createAutoblog ( 'generic' , $sitename , $siteurl , $rssurl , $error );
if ( empty ( $error ))
$success [] = '<iframe width="1" height="1" frameborder="0" src="' . urlToFolder ( $siteurl ) . '/index.php"></iframe><b style="color:darkgreen">autoblog crée avec succès.</b> → <a target="_blank" href="' . urlToFolder ( $siteurl ) . '">afficher l\'autoblog</a>' ;
}
else {
// checking procedure
$rssurl = DetectRedirect ( $rssurl );
$datafeed = file_get_contents ( $rssurl );
$sitetype = 'generic' ;
$siteurl = get_link_from_datafeed ( $datafeed );
$foldername = urlToFolder ( $siteurl );
$sitename = get_title_from_datafeed ( $datafeed );
if ( file_exists ( $foldername )) {
$error [] = 'Erreur: l\'autoblog <a href="./' . $foldername . '/">existe déjà</a>.' ;
}
else {
$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 " />
< input style = " color:black " type = " text " id = " sitename " value = " '. $sitename .' " disabled >< label for = " sitename " >& larr ; titre du site ( auto ) </ label >< br >
< input placeholder = " Adresse du site " type = " text " name = " siteurl " id = " siteurl " value = " '. $siteurl .' " >< label for = " siteurl " >& larr ; page d\ ' accueil ( auto ) </ label >< br >
< 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.' " disabled><label for= " sitetype " >← type de site</label><br>
< input placeholder = " Antibot: \ 'dix sept \ ' en chiffre " type = " text " name = " number " id = " number " value = " 17 " >< label for = " number " >& larr ; antibot </ label >< br >< input type = " submit " value = " Créer " ></ form > ' ;
}
}
}
2013-02-13 11:22:51 +01:00
}
2013-02-18 19:42:10 +01:00
/**
* ADD BY OPML
**/
if ( ! empty ( $_POST [ 'opml' ]) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML ) {
if ( is_uploaded_file ( $_FILES [ 'file' ][ 'tmp_name' ])) {
$opml = null ;
if ( ( $opml = simplexml_load_file ( $_FILES [ 'file' ][ 'tmp_name' ])) !== false ) {
foreach ( $opml -> body -> outline as $outline ) {
if ( ! empty ( $outline [ 'title' ] ) && ! empty ( $outline [ 'xmlUrl' ]) && ! empty ( $outline [ 'htmlUrl' ] )) {
$siteurl = escape ( $outline [ 'htmlUrl' ]);
$rssurl = DetectRedirect ( escape ( $outline [ 'xmlUrl' ]));
$sitename = escape ( $outline [ 'title' ] );
$error = createAutoblog ( 'generic' , $sitename , $siteurl , $rssurl , $error );
if ( empty ( $error ))
$success [] = '<iframe width="1" height="1" frameborder="0" src="' . urlToFolder ( $siteurl ) . '/index.php"></iframe>Autoblog "' . $sitename . '" crée avec succès. → <a target="_blank" href="' . urlToFolder ( $siteurl ) . '">afficher l\'autoblog</a>.' ;
}
}
}
else
$error [] = " Impossible de lire le contenu du fichier OPML. " ;
unlink ( $_FILES [ 'file' ][ 'tmp_name' ]);
} else {
$error [] = " Le fichier n'a pas été envoyé. " ;
}
}
2013-02-13 11:22:51 +01:00
?>
<! DOCTYPE html >
< html lang = " en " dir = " ltr " >
< 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-02-13 11:22:51 +01:00
< style type = " text/css " >
body { background - color : #efefef;text-align:center;color:#333;font-family:sans-serif}
a { color : black ; text - decoration : none ; font - weight : bold ;}
a : hover { color : darkred ;}
h1 { text - align : center ; font - size : 40 pt ; text - shadow : #ccc 0px 5px 5px; }
h2 { text - align : center ; font - size : 16 pt ; margin : 0 0 1 em 0 ; font - style : italic ; text - shadow : #ccc 0px 5px 5px; }
. pbloc { background - color : white ; padding : 12 px 10 px 12 px 10 px ; border : 1 px solid #aaa;max-width:70em;margin:1em auto;text-align:justify;box-shadow:0px 5px 7px #aaa;}
input { width : 30 em ;}
input [ type = " radio " ] { width : 1 em ; }
input #socialaccount, input#statusneturl, input#shaarliurl, input#socialsub {width:12em;}
div . form { padding : 0.2 em ; margin : 1 px ;}
div . form : hover { background - color : #FAF4DA;border:1px dotted;margin:0; }
. vignette { width : 20 em ; height : 2 em ; float : left ; margin : 0 ; padding : 20 px ; background - color : #eee;border: 1px solid #888;}
. vignette : hover { background - color : #fff;}
. vignette . title { font - size : 14 pt ; text - shadow : #ccc 0px 5px 5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
. vignette . title a : hover { color : darkred ; text - decoration : none ;}
. vignette . source { font - size : x - small ; white - space : nowrap ; overflow : hidden ; text - overflow : ellipsis ;}
. vignette . source a : hover { color : darkred ; text - decoration : none ;}
. clear { clear : both ; text - align : right ; font - size : small ;}
#logo {float: right;}
. bouton { background : - moz - linear - gradient ( center top , #EDEDED 5%, #DFDFDF 100%) repeat scroll 0 0 #EDEDED;border: 1px none;padding: 10px;border: 1px solid #7777777;border-radius: 8px 8px 8px 8px;box-shadow: 0 1px 0 0 #FFFFFF inset;display: inline-block;}
2013-02-18 19:42:10 +01:00
. success { color : green ;}
. error { color : red ;}
2013-02-13 11:22:51 +01:00
</ style >
2013-02-18 19:42:10 +01:00
</ head >
2013-02-13 11:22:51 +01:00
< body >
2013-02-19 12:20:13 +01:00
< h1 > PROJET AUTOBLOG < ? php if ( ! empty ( $head_title )) { echo " | " . escape ( $head_title ); } ?> </h1>
2013-02-18 19:42:10 +01:00
2013-02-13 11:22:51 +01:00
< div class = " pbloc " >
2013-02-18 19:42:10 +01:00
< img id = " logo " src = " <?php if(isset( $logo )) { echo $logo ; }else { echo './icon-logo.svg'; } ?> " alt = " " >
< h2 > Présentation </ h2 >
< p >
2013-02-19 12:20:13 +01:00
Le Projet Autoblog a pour objectif de répliquer les articles d 'un blog ou d' un site site web .< br />
2013-02-18 22:15:15 +01:00
Si l 'article source est supprimé, et même si le site d' origine disparaît , les articles restent lisibles sur l ' autoblog . < br />
2013-02-18 19:42:10 +01:00
L ' objectif premier de ce projet est de lutter contre la censure et toute sorte de pression ...
</ p >
< p >
Voici une liste d 'autoblogs hébergés sur <i><?php echo $_SERVER[' SERVER_NAME ' ]; ?> </i>
( < a href = " http://sebsauvage.net/streisand.me/fr/ " > plus d ' infos sur le projet </ a > ) .
</ p >
</ div >
< ? php if ( ALLOW_NEW_AUTOBLOGS == TRUE ) { ?>
< div class = " pbloc " >
< h2 > Ajouter un autoblog </ h2 >
< ? 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>' ;
}
echo '</ul>' ;
}
?>
< ? php if ( ALLOW_NEW_AUTOBLOGS_BY_LINKS == TRUE ) { ?>
< div class = " form " >
< h3 > Ajouter un site web </ h3 >
< 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 >
< ? php echo $form ; ?>
</ div >
< ? php }
if ( ALLOW_NEW_AUTOBLOGS_BY_SOCIAL == TRUE ) { ?>
< div class = " form " >
< h3 > Ajouter un compte social </ h3 >
< form method = " POST " >
< input class = " text " placeholder = " Identifiant du compte " type = " text " name = " socialaccount " id = " socialaccount " >< br >
< input type = " radio " name = " socialinstance " value = " twitter " > Twitter < br >
< input type = " radio " name = " socialinstance " value = " identica " > Identica < br >
< input type = " radio " name = " socialinstance " value = " statusnet " >
< input placeholder = " statusnet.personnel.com " type = " text " name = " statusneturl " id = " statusneturl " >< br >
< input id = " socialsub " type = " submit " value = " Créer " >
</ form >
</ div >
< div class = " form " >
< h3 > Ajouter un Shaarli </ h3 >
< form method = " POST " >
< input class = " text " placeholder = " identifiant compte " type = " hidden " name = " socialaccount " id = " socialaccount " value = " shaarli " >
< input type = " hidden " name = " socialinstance " value = " shaarli " >< input placeholder = " shaarli.personnel.com " type = " text " name = " shaarliurl " id = " shaarliurl " >< br >
< input id = " socialsub " type = " submit " value = " Créer " >
</ form >
</ div >
< ? php }
if ( ALLOW_NEW_AUTOBLOGS_BY_OPML == TRUE ) { ?>
< div class = " form " >
< h3 > Ajout par fichier OPML </ h3 >
< form enctype = 'multipart/form-data' method = 'POST' >
< input type = 'hidden' name = 'opml' value = '1' />
< input type = 'file' name = 'file' />< br >
< input type = 'submit' value = 'Importer' />
</ form >
</ div >
< ? php }
if ( ALLOW_NEW_AUTOBLOGS_BY_BUTTON == TRUE ) { ?>
< h3 > Marque page </ h3 >
< 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; "
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 >
< ? php } ?>
</ div >
< ? php } ?>
< div class = " pbloc " >
< h2 > Autoblogs hébergés </ h2 >
< p >
< b > Autres fermes </ b >
& rarr ; < a href = " https://duckduckgo.com/?q=!g%20%22Voici%20une%20liste%20d'autoblogs%20hébergés%22 " > Rechercher </ a >
</ p >
< div class = " clear " >< a href = " ?export " > export < sup > JSON </ sup ></ a ></ div >
< ? php
$directory = " ./ " ;
$subdirs = glob ( $directory . " * " );
$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 );
}
}
}
}
uasort ( $autoblogs , " objectCmp " );
$autoblogs_display = '' ;
if ( ! empty ( $autoblogs )){
foreach ( $autoblogs as $key => $autoblog ) {
$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 " >< a href = " '. $key .'/vvb.ini " > config </ a > | '.escape($autoblog->site_type).' source : < a href = " '.escape( $autoblog->site_url ).' " > '.escape($autoblog->site_url).' </ a ></ div >
</ div > ' ;
}
}
echo $autoblogs_display ;
?>
< div class = " clear " ></ div >
< ? php echo " <p> " . count ( $autoblogs ) . " autoblogs hébergés</p> " ; ?>
</ div >
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://aryo.fr " > Arthur Hoaro </ a > ( Domaine Public )
< ? php if ( isset ( $HTML_footer )){ echo " <br/> " . $HTML_footer ; } ?>
< iframe width = " 1 " height = " 1 " style = " display:none " src = " xsaf3.php " ></ iframe >
</ body >
</ html >