Few fixes and handle DetectRedirect errors
This commit is contained in:
parent
bb3795e9a7
commit
22de0b26e0
|
@ -3,7 +3,7 @@ Projet Autoblog serie 0.3
|
|||
|
||||
- version VroumVroumBlog 0.3.0 BETA
|
||||
|
||||
Auteurs: Mitsu (https://www.suumitsu.eu/) & Oros (https://www.ecirtam.net/)
|
||||
Auteurs: Mitsu (https://www.suumitsu.eu/), Oros (https://www.ecirtam.net/) et Arthur Hoaro (http://hoa.ro)
|
||||
|
||||
Licence: Domaine Public
|
||||
|
||||
|
|
|
@ -20,13 +20,15 @@ function NoProtocolSiteURL($url) {
|
|||
function DetectRedirect($url)
|
||||
{
|
||||
if(parse_url($url, PHP_URL_HOST)==FALSE) {
|
||||
die('Not a URL');
|
||||
//die('Not a URL');
|
||||
return array( 'error' => 'Not a URL: '. escape ($url) );
|
||||
}
|
||||
$response = get_headers($url, 1);
|
||||
if(!empty($response['Location'])) {
|
||||
$response2 = get_headers($response['Location'], 1);
|
||||
if(!empty($response2['Location'])) {
|
||||
die('too much redirection');
|
||||
//die('too much redirection');
|
||||
return array( 'error' => 'too much redirection: '. escape ($url) );
|
||||
}
|
||||
else { return $response['Location']; }
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
Authors:
|
||||
Mitsu https://www.suumitsu.eu/
|
||||
Oros https://www.ecirtam.net/
|
||||
Arthur Hoaro http://aryo.fr
|
||||
Arthur Hoaro http://hoa.ro
|
||||
License: Public Domain
|
||||
|
||||
Instructions:
|
||||
|
@ -104,10 +104,13 @@ function create_from_opml($opml) {
|
|||
|
||||
foreach( $opml->body->outline as $outline ) {
|
||||
if ( !empty( $outline['title'] ) && !empty( $outline['text'] ) && !empty( $outline['xmlUrl']) && !empty( $outline['htmlUrl'] )) {
|
||||
$rssurl = DetectRedirect(escape( $outline['xmlUrl']));
|
||||
if( isset($rssurl['error']) )
|
||||
$error[] = $rssurl['error'];
|
||||
else {
|
||||
$sitename = escape( $outline['title'] );
|
||||
$siteurl = escape($outline['htmlUrl']);
|
||||
$sitetype = escape($outline['text']); if ( $sitetype == 'generic' or $sitetype == 'microblog' or $sitetype == 'shaarli') { } else { $sitetype = 'generic'; }
|
||||
$rssurl = DetectRedirect(escape( $outline['xmlUrl']));
|
||||
$sitename = escape( $outline['title'] );
|
||||
|
||||
$error = array_merge( $error, createAutoblog( $sitetype, $sitename, $siteurl, $rssurl, $error ) );
|
||||
|
||||
|
@ -115,6 +118,7 @@ function create_from_opml($opml) {
|
|||
$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>.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,9 +346,13 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG
|
|||
else {
|
||||
if(isset($_GET['add']) && $_GET['add'] === '1' && !empty($_GET['siteurl']) && !empty($_GET['sitename'])) {
|
||||
$rssurl = DetectRedirect(escape($_GET['rssurl']));
|
||||
if( isset($rssurl['error']) )
|
||||
$form .= '<p>Erreur : '. $rssurl['error'] .'<br>';
|
||||
else {
|
||||
$siteurl = escape($_GET['siteurl']);
|
||||
$sitename = escape($_GET['sitename']);
|
||||
$sitetype = escape($_GET['type']);
|
||||
$sitetype = updateType($siteurl); // Disabled input doesn't send POST data
|
||||
$sitetype = $sitetype['type'];
|
||||
|
||||
$error = array_merge( $error, createAutoblog($sitetype, $sitename, $siteurl, $rssurl, $error));
|
||||
if( empty($error)) {
|
||||
|
@ -357,15 +365,19 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG
|
|||
$form .= '<li>'. $value .'</li>';
|
||||
$form .= '</ul>';
|
||||
}
|
||||
}
|
||||
$form .= '<a href="#" onclick="window.close()">Fermer la fenêtre.</a></p>';
|
||||
}
|
||||
else {
|
||||
$rssurl = DetectRedirect(escape($_GET['rssurl']));
|
||||
if( isset($rssurl['error']) )
|
||||
$form .= '<p>Erreur : '. $rssurl['error'] .'<br><a href="#" onclick="window.close()">Fermer la fenêtre.</a></p>';
|
||||
else {
|
||||
$datafeed = file_get_contents($rssurl);
|
||||
if( $datafeed !== false ) {
|
||||
$siteurl = get_link_from_datafeed($datafeed);
|
||||
$sitename = get_title_from_datafeed($datafeed);
|
||||
$sitetype = updateType($_GET['type']);
|
||||
$sitetype = updateType($siteurl);
|
||||
$sitetype = $sitetype['type'];
|
||||
|
||||
$form .= '<span style="color:blue">Merci de vérifier les informations suivantes, corrigez si nécessaire.</span><br>
|
||||
|
@ -382,6 +394,7 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$form .= '</body></html>';
|
||||
echo $form; die;
|
||||
}
|
||||
|
@ -420,6 +433,7 @@ if(!empty($_POST['socialaccount']) && !empty($_POST['socialinstance']) && ALLOW_
|
|||
$socialaccount = get_title_from_feed($rssurl);
|
||||
}
|
||||
|
||||
if( !isset($rssurl['error']) && !isset($siteurl['error']) ) {
|
||||
$headers = get_headers($rssurl, 1);
|
||||
if (strpos($headers[0], '200') == FALSE) {
|
||||
$error[] = "Flux inaccessible (compte inexistant ?)";
|
||||
|
@ -430,6 +444,8 @@ if(!empty($_POST['socialaccount']) && !empty($_POST['socialinstance']) && ALLOW_
|
|||
$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>';
|
||||
}
|
||||
}
|
||||
else $error[] = (isset($rssurl['error'])) ? $rssurl['error'] : $siteurl['error'];
|
||||
}
|
||||
else
|
||||
$error[] = 'Antibot : Chiffres incorrects.';
|
||||
}
|
||||
|
@ -447,8 +463,9 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L
|
|||
|
||||
if(empty($error)) {
|
||||
$rssurl = DetectRedirect(escape($_POST['rssurl']));
|
||||
|
||||
if( !isset($rssurl['error']) ) {
|
||||
if(!empty($_POST['siteurl'])) {
|
||||
|
||||
$siteurl = escape($_POST['siteurl']);
|
||||
$sitename = get_title_from_feed($rssurl);
|
||||
|
||||
|
@ -459,7 +476,7 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L
|
|||
}
|
||||
else {
|
||||
// checking procedure
|
||||
$rssurl = DetectRedirect($rssurl);
|
||||
|
||||
$datafeed = file_get_contents($rssurl);
|
||||
if( $datafeed === false ) {
|
||||
$error[] = 'URL "'. $rssurl .'" inaccessible.';
|
||||
|
@ -479,6 +496,8 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L
|
|||
|
||||
}
|
||||
}
|
||||
else $error[] = $rssurl['error'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -770,7 +789,7 @@ if( !empty($_POST['opml_file']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY
|
|||
|
||||
<?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)
|
||||
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)
|
||||
<?php if(isset($HTML_footer)){ echo "<br/>".$HTML_footer; } ?>
|
||||
<iframe width="1" height="1" style="display:none" src="xsaf3.php"></iframe>
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ define('AUTOBLOG_FILE_NAME', 'autoblog.php');
|
|||
define('ALLOW_REMOTE_DB_DL', false);
|
||||
define('ALLOW_REMOTE_MEDIA_DL', false);
|
||||
define('EXEC_TIME', 5);
|
||||
define( 'ALLOW_NEW_AUTOBLOGS_BY_XSAF', TRUE );
|
||||
|
||||
header("HTTP/1.0 403 Forbidden"); /* Uncivilized method to prevent bot indexing, huh :) */
|
||||
header('X-Robots-Tag: noindex'); /* more civilized method, but bots may not all take into account */
|
||||
|
|
Loading…
Reference in a new issue