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
|
- 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
|
Licence: Domaine Public
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,15 @@ function NoProtocolSiteURL($url) {
|
||||||
function DetectRedirect($url)
|
function DetectRedirect($url)
|
||||||
{
|
{
|
||||||
if(parse_url($url, PHP_URL_HOST)==FALSE) {
|
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);
|
$response = get_headers($url, 1);
|
||||||
if(!empty($response['Location'])) {
|
if(!empty($response['Location'])) {
|
||||||
$response2 = get_headers($response['Location'], 1);
|
$response2 = get_headers($response['Location'], 1);
|
||||||
if(!empty($response2['Location'])) {
|
if(!empty($response2['Location'])) {
|
||||||
die('too much redirection');
|
//die('too much redirection');
|
||||||
|
return array( 'error' => 'too much redirection: '. escape ($url) );
|
||||||
}
|
}
|
||||||
else { return $response['Location']; }
|
else { return $response['Location']; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
Authors:
|
Authors:
|
||||||
Mitsu https://www.suumitsu.eu/
|
Mitsu https://www.suumitsu.eu/
|
||||||
Oros https://www.ecirtam.net/
|
Oros https://www.ecirtam.net/
|
||||||
Arthur Hoaro http://aryo.fr
|
Arthur Hoaro http://hoa.ro
|
||||||
License: Public Domain
|
License: Public Domain
|
||||||
|
|
||||||
Instructions:
|
Instructions:
|
||||||
|
@ -104,10 +104,13 @@ function create_from_opml($opml) {
|
||||||
|
|
||||||
foreach( $opml->body->outline as $outline ) {
|
foreach( $opml->body->outline as $outline ) {
|
||||||
if ( !empty( $outline['title'] ) && !empty( $outline['text'] ) && !empty( $outline['xmlUrl']) && !empty( $outline['htmlUrl'] )) {
|
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']);
|
$siteurl = escape($outline['htmlUrl']);
|
||||||
$sitetype = escape($outline['text']); if ( $sitetype == 'generic' or $sitetype == 'microblog' or $sitetype == 'shaarli') { } else { $sitetype = 'generic'; }
|
$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 ) );
|
$error = array_merge( $error, createAutoblog( $sitetype, $sitename, $siteurl, $rssurl, $error ) );
|
||||||
|
|
||||||
|
@ -116,6 +119,7 @@ function create_from_opml($opml) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple version check
|
* Simple version check
|
||||||
|
@ -342,9 +346,13 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG
|
||||||
else {
|
else {
|
||||||
if(isset($_GET['add']) && $_GET['add'] === '1' && !empty($_GET['siteurl']) && !empty($_GET['sitename'])) {
|
if(isset($_GET['add']) && $_GET['add'] === '1' && !empty($_GET['siteurl']) && !empty($_GET['sitename'])) {
|
||||||
$rssurl = DetectRedirect(escape($_GET['rssurl']));
|
$rssurl = DetectRedirect(escape($_GET['rssurl']));
|
||||||
|
if( isset($rssurl['error']) )
|
||||||
|
$form .= '<p>Erreur : '. $rssurl['error'] .'<br>';
|
||||||
|
else {
|
||||||
$siteurl = escape($_GET['siteurl']);
|
$siteurl = escape($_GET['siteurl']);
|
||||||
$sitename = escape($_GET['sitename']);
|
$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));
|
$error = array_merge( $error, createAutoblog($sitetype, $sitename, $siteurl, $rssurl, $error));
|
||||||
if( empty($error)) {
|
if( empty($error)) {
|
||||||
|
@ -357,15 +365,19 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG
|
||||||
$form .= '<li>'. $value .'</li>';
|
$form .= '<li>'. $value .'</li>';
|
||||||
$form .= '</ul>';
|
$form .= '</ul>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$form .= '<a href="#" onclick="window.close()">Fermer la fenêtre.</a></p>';
|
$form .= '<a href="#" onclick="window.close()">Fermer la fenêtre.</a></p>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$rssurl = DetectRedirect(escape($_GET['rssurl']));
|
$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);
|
$datafeed = file_get_contents($rssurl);
|
||||||
if( $datafeed !== false ) {
|
if( $datafeed !== false ) {
|
||||||
$siteurl = get_link_from_datafeed($datafeed);
|
$siteurl = get_link_from_datafeed($datafeed);
|
||||||
$sitename = get_title_from_datafeed($datafeed);
|
$sitename = get_title_from_datafeed($datafeed);
|
||||||
$sitetype = updateType($_GET['type']);
|
$sitetype = updateType($siteurl);
|
||||||
$sitetype = $sitetype['type'];
|
$sitetype = $sitetype['type'];
|
||||||
|
|
||||||
$form .= '<span style="color:blue">Merci de vérifier les informations suivantes, corrigez si nécessaire.</span><br>
|
$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>';
|
$form .= '</body></html>';
|
||||||
echo $form; die;
|
echo $form; die;
|
||||||
}
|
}
|
||||||
|
@ -420,6 +433,7 @@ if(!empty($_POST['socialaccount']) && !empty($_POST['socialinstance']) && ALLOW_
|
||||||
$socialaccount = get_title_from_feed($rssurl);
|
$socialaccount = get_title_from_feed($rssurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !isset($rssurl['error']) && !isset($siteurl['error']) ) {
|
||||||
$headers = get_headers($rssurl, 1);
|
$headers = get_headers($rssurl, 1);
|
||||||
if (strpos($headers[0], '200') == FALSE) {
|
if (strpos($headers[0], '200') == FALSE) {
|
||||||
$error[] = "Flux inaccessible (compte inexistant ?)";
|
$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>';
|
$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
|
else
|
||||||
$error[] = 'Antibot : Chiffres incorrects.';
|
$error[] = 'Antibot : Chiffres incorrects.';
|
||||||
}
|
}
|
||||||
|
@ -447,8 +463,9 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L
|
||||||
|
|
||||||
if(empty($error)) {
|
if(empty($error)) {
|
||||||
$rssurl = DetectRedirect(escape($_POST['rssurl']));
|
$rssurl = DetectRedirect(escape($_POST['rssurl']));
|
||||||
|
if( !isset($rssurl['error']) ) {
|
||||||
if(!empty($_POST['siteurl'])) {
|
if(!empty($_POST['siteurl'])) {
|
||||||
|
|
||||||
$siteurl = escape($_POST['siteurl']);
|
$siteurl = escape($_POST['siteurl']);
|
||||||
$sitename = get_title_from_feed($rssurl);
|
$sitename = get_title_from_feed($rssurl);
|
||||||
|
|
||||||
|
@ -459,7 +476,7 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// checking procedure
|
// checking procedure
|
||||||
$rssurl = DetectRedirect($rssurl);
|
|
||||||
$datafeed = file_get_contents($rssurl);
|
$datafeed = file_get_contents($rssurl);
|
||||||
if( $datafeed === false ) {
|
if( $datafeed === false ) {
|
||||||
$error[] = 'URL "'. $rssurl .'" inaccessible.';
|
$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>"; ?>
|
<?php echo "<p>".count($autoblogs)." autoblogs hébergés</p>"; ?>
|
||||||
</div>
|
</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; } ?>
|
<?php if(isset($HTML_footer)){ echo "<br/>".$HTML_footer; } ?>
|
||||||
<iframe width="1" height="1" style="display:none" src="xsaf3.php"></iframe>
|
<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_DB_DL', false);
|
||||||
define('ALLOW_REMOTE_MEDIA_DL', false);
|
define('ALLOW_REMOTE_MEDIA_DL', false);
|
||||||
define('EXEC_TIME', 5);
|
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("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 */
|
header('X-Robots-Tag: noindex'); /* more civilized method, but bots may not all take into account */
|
||||||
|
|
Loading…
Reference in a new issue