merge
This commit is contained in:
commit
b4e64678c9
3 changed files with 52 additions and 29 deletions
|
@ -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'];
|
||||
|
|
|
@ -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 <a href="http://sebsauvage.net">SebSauvage</a> et <a href="http://bohwaz.net/">Bohwaz</a>.');
|
||||
|
||||
// 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) {
|
||||
|
|
51
index.php
51
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[] = '<iframe width="1" height="1" frameborder="0" src="'. AUTOBLOGS_FOLDER . urlToFolderSlash( $siteurl ) .'/index.php"></iframe>Autoblog "'. $sitename .'" crée avec succès. → <a target="_blank" href="'. AUTOBLOGS_FOLDER . urlToFolderSlash( $siteurl ) .'">afficher l\'autoblog</a>.';
|
||||
|
||||
$message = 'Autoblog "'. $sitename .'" crée avec succès. → <a target="_blank" href="'. AUTOBLOGS_FOLDER . urlToFolderSlash( $siteurl ) .'">afficher l\'autoblog</a>.';
|
||||
// Do not print iframe on big import (=> heavy and useless)
|
||||
if( ++$cpt < 10 )
|
||||
$message .= '<iframe width="1" height="1" frameborder="0" src="'. AUTOBLOGS_FOLDER . urlToFolderSlash( $siteurl ) .'/index.php"></iframe>';
|
||||
$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[] = '<iframe width="1" height="1" frameborder="0" src="'. AUTOBLOGS_FOLDER . urlToFolderSlash( $siteurl ) .'/index.php"></iframe><b style="color:darkgreen">'.ucfirst($socialinstance) .' - '. $socialaccount.' <a href="'. AUTOBLOGS_FOLDER .urlToFolderSlash( $siteurl ).'">ajouté avec succès</a>.</b>';
|
||||
}
|
||||
|
@ -681,10 +693,10 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
|
|||
</a></h1>
|
||||
|
||||
<div class="pbloc">
|
||||
<?php
|
||||
if (defined('LOGO'))
|
||||
echo '<img id="logo" src="'. RESOURCES_FOLDER . LOGO .'" alt="">';
|
||||
?>
|
||||
<?php
|
||||
if (defined('LOGO'))
|
||||
echo '<img id="logo" src="'. RESOURCES_FOLDER . LOGO .'" alt="">';
|
||||
?>
|
||||
<h2>Présentation</h2>
|
||||
|
||||
<p>
|
||||
|
@ -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 <i><?php echo $_SERVER['SERVER_NAME']; ?></i>
|
||||
(<a href="http://sebsauvage.net/streisand.me/fr/">plus d'infos sur le projet</a>).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Autres fermes</b>
|
||||
→ <a href="https://duckduckgo.com/?q=!g%20%22Voici%20une%20liste%20d'autoblogs%20hébergés%22">Rechercher</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php if( $update_available ) { ?>
|
||||
|
@ -852,11 +869,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
|
|||
|
||||
<div class="pbloc">
|
||||
<h2>Autoblogs hébergés <a href="?rss" title="RSS des changements"><img src="<?php echo RESOURCES_FOLDER; ?>rss.png" alt="rss"/></a></h2>
|
||||
<p>
|
||||
<b>Autres fermes</b>
|
||||
→ <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="?sitemap">sitemap</a> | <a href="?export">export<sup> JSON</sup></a> | <a href="?exportopml">export<sup> OPML</sup></a></div>
|
||||
<div id="contentVignette">
|
||||
<?php
|
||||
|
|
Loading…
Reference in a new issue