diff --git a/autoblogs/autoblog.php b/autoblogs/autoblog.php index 87a8b28..16b8063 100644 --- a/autoblogs/autoblog.php +++ b/autoblogs/autoblog.php @@ -498,11 +498,11 @@ class VroumVroum_Blog $from['path'] = ''; } - preg_match_all('!(src|href)\s*=\s*[\'"]?([^"\'<>\s]+\.(?:'.$extensions.'))[\'"]?!i', $content, $match, PREG_SET_ORDER); + preg_match_all('!(src|href)\s*=\s*[\'"]?([^"\'<>\s]+\.(?:'.$extensions.')[\'"])[\'"]?!i', $content, $match, PREG_SET_ORDER); foreach ($match as $m) { - $url = parse_url($m[2]); + $url = parse_url(substr($m[2], 0, -1)); if (empty($url['scheme'])) $url['scheme'] = $from['scheme']; diff --git a/functions.php b/functions.php index ec49743..d3c601a 100755 --- a/functions.php +++ b/functions.php @@ -35,7 +35,9 @@ if( !defined('LOGO')) define( 'LOGO', 'icon-logo.svg' ); if( !defined('HEAD_TITLE')) define( 'HEAD_TITLE', ''); if( !defined('FOOTER')) define( 'FOOTER', 'D\'après les premières versions de SebSauvage et Bohwaz.'); -// Functions +/** + * Functions + **/ function NoProtocolSiteURL($url) { $protocols = array("http://", "https://"); $siteurlnoproto = str_replace($protocols, "", $url); @@ -58,11 +60,15 @@ function DetectRedirect($url) if(parse_url($url, PHP_URL_HOST)==FALSE) { throw new Exception('Not a URL: '. escape ($url) ); } - $response = get_headers($url, 1); + + try { $response = get_headers($url, 1); } + catch (Exception $e) { throw new Exception('RSS URL unreachable: '. escape($url) ); } if(!empty($response['Location'])) { - $response2 = get_headers($response['Location'], 1); + try { $response2 = get_headers($response['Location'], 1); } + catch (Exception $e) { throw new Exception('RSS URL unreachable: '. escape($url) ); } + if(!empty($response2['Location'])) { - throw new Exception('too much redirection: '. escape ($url) ); + throw new Exception('Too much redirection: '. escape ($url) ); } else { return $response['Location']; } } @@ -107,14 +113,14 @@ function createAutoblog($type, $sitename, $siteurl, $rssurl) { /** * RSS - **/ + */ try { // à déplacer après la tentative de création de l'autoblog crée avec succès ? require_once('class_rssfeed.php'); $rss = new AutoblogRSS(RSS_FILE); $rss->addNewAutoblog($sitename, $foldername, $siteurl, $rssurl); } catch (Exception $e) { - ; + ; // DO NOTHING } $fp = fopen($foldername .'/index.php', 'w+'); @@ -139,7 +145,9 @@ UPDATE_TIMEOUT="'. getTimeout( $type ) .'"') ) throw new Exception('Impossible de créer le répertoire.'); /* @Mitsu: Il faudrait remonter les erreurs d'I/O */ - updateXML('new_autoblog_added', 'new', $foldername, $sitename, $siteurl, $rssurl); + /* Comme ça ? :) */ + if(updateXML('new_autoblog_added', 'new', $foldername, $sitename, $siteurl, $rssurl) === FALSE) + { throw new Exception('Impossible d\'écrire le fichier rss.json'); } } function getArticlesPerPage( $type ) { @@ -248,7 +256,9 @@ $json[] = array( 'status'=>$status, 'response_code'=>$response_code ); -file_put_contents(RESOURCES_FOLDER.'rss.json', json_encode($json), LOCK_EX); +if(file_put_contents(RESOURCES_FOLDER.'rss.json', json_encode($json), LOCK_EX) === FALSE) + { return FALSE; } + else { return TRUE; } } function displayXMLstatus_tmp($status, $response_code, $autoblog_url, $autoblog_title, $autoblog_sourceurl, $autoblog_sourcefeed) { diff --git a/index.php b/index.php index 788fcbb..bfceded 100755 --- a/index.php +++ b/index.php @@ -105,22 +105,31 @@ function check_antibot($number, $text_number) { function create_from_opml($opml) { global $error, $success; - + $cpt = 0; foreach( $opml->body->outline as $outline ) { if ( !empty( $outline['title'] ) && !empty( $outline['text'] ) && !empty( $outline['xmlUrl']) && !empty( $outline['htmlUrl'] )) { try { - $rssurl = DetectRedirect(escape( $outline['xmlUrl'])); - $sitename = escape( $outline['title'] ); $siteurl = escape($outline['htmlUrl']); + + // Lighten process by checking folderExists first + // A CHANGER SELON ISSUE #20 + if(folderExists($siteurl)) + throw new Exception('Erreur : l\'autoblog '. $sitename .' existe déjà.'); + $sitetype = escape($outline['text']); if ( $sitetype != 'microblog' && $sitetype != 'shaarli' && $sitetype != 'twitter' && $sitetype != 'identica' ) $sitetype = 'generic'; + + $rssurl = DetectRedirect(escape($outline['xmlUrl'])); createAutoblog( $sitetype, $sitename, $siteurl, $rssurl ); - - if( empty ( $error )) - $success[] = 'Autoblog "'. $sitename .'" crée avec succès. → afficher l\'autoblog.'; + + $message = 'Autoblog "'. $sitename .'" crée avec succès. → afficher l\'autoblog.'; + // Do not print iframe on big import (=> heavy and useless) + if( ++$cpt < 10 ) + $message .= ''; + $success[] = $message; } catch (Exception $e) { $error[] = $e->getMessage(); @@ -541,11 +550,14 @@ if(!empty($_POST['socialaccount']) && !empty($_POST['socialinstance']) && ALLOW_ if( empty($error) ) { try { - $headers = get_headers($rssurl, 1); - if (strpos($headers[0], '200') === FALSE) { - throw new Exception('Flux inaccessible (compte inexistant ?)'); + // TwitterBridge user will be allowed after Autoblog creation + // TODO: Twitter user does not exist ? + if($sitetype != 'twitter') { + $headers = get_headers($rssurl, 1); + if (strpos($headers[0], '200') === FALSE) + throw new Exception('Flux inaccessible (compte inexistant ?)'); } - + createAutoblog($sitetype, ucfirst($socialinstance) .' - '. $socialaccount, $siteurl, $rssurl); $success[] = ''.ucfirst($socialinstance) .' - '. $socialaccount.' ajouté avec succès.'; } @@ -681,10 +693,10 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
- '; - ?> + '; + ?>

Présentation

@@ -697,6 +709,11 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY Voici une liste d'autoblogs hébergés sur (plus d'infos sur le projet).

+ +

+ Autres fermes + → Rechercher +

@@ -852,11 +869,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY

Autoblogs hébergés rss

-

- Autres fermes - → Rechercher -

- +
sitemap | export JSON | export OPML