diff --git a/config.php.example b/config.php.example index 1493324..d82b527 100644 --- a/config.php.example +++ b/config.php.example @@ -28,10 +28,11 @@ // define( 'ALLOW_NEW_AUTOBLOGS_BY_XSAF', TRUE ); /** - * More about TwitterBridge : https://github.com/mitsukarenai/twitterbridge - * replace FALSE with the twitterbridge request URL (example: 'http://www.suumitsu.eu/twitter/?u=' ) + * More about TwitterBridge : https://github.com/mitsukarenai/twitterbridge and twitter2feed: https://github.com/mitsukarenai/twitter2feed + * replace LOCAL with the twitterbridge request URL (example: 'http://www.suumitsu.eu/twitter/?u=' ) or leave LOCAL to use the included twitter2feed.php. + * set to FALSE if you want to fully disable Twitter support **/ -// define( 'API_TWITTER', FALSE ); +// define( 'API_TWITTER', LOCAL ); /** * Import autoblogs from friend's autoblog farm - Add a link to the JSON export diff --git a/index.php b/index.php index 19eea78..d90e2e6 100755 --- a/index.php +++ b/index.php @@ -232,15 +232,15 @@ if (isset($_GET['check'])) /* SVG minimalistes */ -function svg_status($fill, $stroke, $text) +function svg_status($fill, $text, $back) { - $svg = ''.$text.''; + $svg = ''.$back.''.$text.''; return $svg; } - $svg_vert=svg_status('#00ff00', '#008000', 'OK'); - $svg_jaune=svg_status('#ffff00', '#ffcc00', 'mv'); - $svg_rouge=svg_status('#ff0000', '#800000', 'err'); + $svg_ok=svg_status('#008000', 'ok', ''); + $svg_mv=svg_status('#0000ff', 'mv', ''); + $svg_err=svg_status('#000000', 'err', ''); $errorlog="./".escape( $_GET['check'] ) ."/error.log"; @@ -249,9 +249,9 @@ function svg_status($fill, $stroke, $text) 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);} + if(filesize($errorlog) == "0") {die($svg_ok);} + else if(filesize($errorlog) == "1") {die($svg_mv);} + else {die($svg_err);} } else /* ..sinon, lancer la procédure de contrôle */ { @@ -263,7 +263,7 @@ function svg_status($fill, $stroke, $text) updateXML('unavailable', 'nxdomain', escape($_GET['check']), $ini['SITE_TITLE'], $ini['SITE_URL'], $ini['FEED_URL']); } file_put_contents($errorlog, '..'); - die($svg_rouge); + die($svg_err); } $code=explode(" ", $headers[0]); /* code retour 200: flux disponible */ @@ -272,7 +272,7 @@ function svg_status($fill, $stroke, $text) updateXML('available', '200', escape($_GET['check']), $ini['SITE_TITLE'], $ini['SITE_URL'], $ini['FEED_URL']); } file_put_contents($errorlog, ''); - die($svg_vert); + die($svg_ok); } /* autre code retour: un truc a changé (redirection, changement de CMS, .. bref vvb.ini doit être corrigé) */ else { @@ -280,7 +280,7 @@ function svg_status($fill, $stroke, $text) updateXML('moved', '3xx', escape($_GET['check']), $ini['SITE_TITLE'], $ini['SITE_URL'], $ini['FEED_URL']); } file_put_contents($errorlog, '.'); - die($svg_jaune); + die($svg_mv); } } } @@ -554,10 +554,15 @@ if( !empty($_POST['socialinstance']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLO if( API_TWITTER !== FALSE ) { $sitetype = 'twitter'; $siteurl = 'http://twitter.com/'. $socialaccount; - $rssurl = API_TWITTER.$socialaccount; + if ( API_TWITTER === 'LOCAL' ) { + $rssurl = serverUrl(true).'twitter2feed.php?u='.$socialaccount; + } + else { + $rssurl = API_TWITTER.$socialaccount; // check $twitterbridge = get_headers($rssurl, 1); if ($twitterbridge['0'] == 'HTTP/1.1 403 Forbidden') { $error[] = "La twitterbridge a refusé ce nom d'utilisateur:
\n
".htmlentities($twitterbridge['X-twitterbridge']).'
'; } + } } else $error[] = 'Vous devez définir une API Twitter -> RSS dans votre fichier de configuration (see TwitterBridge).'; @@ -825,7 +830,12 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
Twitter (via twitterbridge)
'; + { + if( API_TWITTER === 'LOCAL' ) + echo 'Twitter (local)
'; + else + echo 'Twitter (via twitterbridge)
'; + } else echo 'Twitter
'; ?> Identica
diff --git a/twitter2feed.php b/twitter2feed.php index 9bcf177..2014182 100755 --- a/twitter2feed.php +++ b/twitter2feed.php @@ -3,13 +3,21 @@ * Récupération du flux RSS d'un compte Twitter * Passez le nom du compte en Paramètre. Exemple: http://monsite.com/twit2rss.php?name=Craftbukkit * 2013 - by Tronics - * -- ajout exclusion de réponses par Mitsu >> suggéré pour Projet Autoblog */ - if (!isset($_GET["name"])) - die (); +// ---------------------------- +// Autoblog Project inclusion +// ---------------------------- +if(file_exists("config.php")) require_once "config.php"; +if( !defined('API_TWITTER')) {header("HTTP/1.1 404 Not Found"); die('API_TWITTER is undefined: make it LOCAL in "config.php" if you want me to work for you.');} +if ('API_TWITTER' === FALSE) {header("HTTP/1.1 404 Not Found"); die('Twitter support disabled in "config.php". Sorry.');} +if ('API_TWITTER' !== 'LOCAL') {header("HTTP/1.1 404 Not Found"); die('Custom twitterbridge defined in "config.php": leave me alone.');} +if(!isset($_GET['u'])) {header("HTTP/1.1 404 Not Found"); die('no username provided');} +$exclude_reply = '@'; // if you want twitter2feed to return replies too: $exclude_reply = ''; +// ---------------------------- +// Let's rock ! - $name = $_GET["name"]; + $name = $_GET["u"]; $str = file_get_contents("https://twitter.com/$name"); $nb = preg_match_all('%
\r\nAfficher la conversation"; $message = "$header$rt$message$footer"; $message = htmlspecialchars($message); - if(substr($title, 0, 1) !== '@') { // exclude response + if(substr($title, 0, 1) !== $exclude_reply) { echo << $title @@ -106,7 +114,7 @@ HTML; - } // end exclude response + } } }