This commit is contained in:
parent
580be0afb8
commit
27830d9a58
3 changed files with 45 additions and 18 deletions
|
@ -1,12 +1,18 @@
|
|||
<?php
|
||||
|
||||
function NoProtocolSiteURL($url) {
|
||||
$siteurlnoprototypes = array("http://", "https://");
|
||||
$siteurlnoproto = str_replace($siteurlnoprototypes, "", $url);
|
||||
|
||||
$protocols = array("http://", "https://");
|
||||
$siteurlnoproto = str_replace($protocols, "", $url);
|
||||
|
||||
// Remove the / at the end of string
|
||||
if ( $siteurlnoproto[strlen($siteurlnoproto) - 1] == '/' )
|
||||
$siteurlnoproto = substr($siteurlnoproto, 0, -1);
|
||||
|
||||
// Remove index.php/html at the end of string
|
||||
if( strpos($url, 'index.php') || strpos($url, 'index.html') ) {
|
||||
$siteurlnoproto = preg_replace('#(.*)/index\.(html|php)$#', '$1', $siteurlnoproto);
|
||||
}
|
||||
|
||||
return $siteurlnoproto;
|
||||
}
|
||||
|
||||
|
@ -30,10 +36,14 @@ function urlToFolder($url) {
|
|||
return sha1(NoProtocolSiteURL($url));
|
||||
}
|
||||
|
||||
function urlToFolderWithTrailingSlash($url) {
|
||||
function urlToFolderSlash($url) {
|
||||
return sha1(NoProtocolSiteURL($url).'/');
|
||||
}
|
||||
|
||||
function folderExists($url) {
|
||||
return file_exists(urlToFolder($url)) || file_exists(urlToFolderSlash($url));
|
||||
}
|
||||
|
||||
function escape($str) {
|
||||
return htmlspecialchars($str, ENT_COMPAT, 'UTF-8', false);
|
||||
}
|
||||
|
@ -46,17 +56,12 @@ function createAutoblog($type, $sitename, $siteurl, $rssurl, $error = array()) {
|
|||
$sitename = ucfirst($var['name']) . ' - ' . $sitename;
|
||||
}
|
||||
|
||||
$foldername = urlToFolder($siteurl);
|
||||
if(file_exists($foldername)) {
|
||||
if(folderExists($siteurl)) {
|
||||
$error[] = 'Erreur: l\'autoblog <a href="./'.$foldername.'/">'. $sitename .'</a> existe déjà.';
|
||||
return $error;
|
||||
}
|
||||
|
||||
$foldername = urlToFolderWithTrailingSlash($siteurl);
|
||||
if(file_exists($foldername)) {
|
||||
$error[] = 'Erreur: l\'autoblog <a href="./'.$foldername.'/">'. $sitename .'</a> existe déjà.';
|
||||
return $error;
|
||||
}
|
||||
$foldername = urlToFolderSlash($siteurl);
|
||||
|
||||
if ( mkdir('./'. $foldername, 0755, false) ) {
|
||||
$fp = fopen('./'. $foldername .'/index.php', 'w+');
|
||||
|
@ -129,4 +134,27 @@ function updateType($siteurl) {
|
|||
else
|
||||
return array('type' => 'generic', 'name' => '');
|
||||
}
|
||||
|
||||
function debug($data)
|
||||
{
|
||||
if(is_array($data))
|
||||
{
|
||||
echo '<p>Array <br/>{<br/>';
|
||||
foreach ( $data AS $Key => $Element )
|
||||
{
|
||||
echo ' ['. $Key .'] =>';
|
||||
debug($Element);
|
||||
}
|
||||
echo '}</p>';
|
||||
}
|
||||
else if(is_bool($data))
|
||||
{
|
||||
if($data === 1)
|
||||
echo 'true<br/>';
|
||||
else
|
||||
echo 'false<br/>';
|
||||
}
|
||||
else
|
||||
echo $data.'<br />';
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -247,8 +247,8 @@ if(!empty($_GET['via_button']) && $_GET['number'] === '17' && ALLOW_NEW_AUTOBLOG
|
|||
$error = createAutoblog($sitetype, $sitename, $siteurl, $rssurl, $error);
|
||||
if( empty($error)) {
|
||||
$form .= '<p>'.$sitetype.'</p>';
|
||||
$form .= '<iframe width="1" height="1" frameborder="0" src="'. urlToFolderWithTrailingSlash($siteurl) .'/index.php"></iframe>';
|
||||
$form .= '<p><span style="color:darkgreen">Autoblog <a href="'. urlToFolderWithTrailingSlash($siteurl) .'">'. $sitename .'</a> ajouté avec succès.</span><br>';
|
||||
$form .= '<iframe width="1" height="1" frameborder="0" src="'. urlToFolderSlash($siteurl) .'/index.php"></iframe>';
|
||||
$form .= '<p><span style="color:darkgreen">Autoblog <a href="'. urlToFolderSlash($siteurl) .'">'. $sitename .'</a> ajouté avec succès.</span><br>';
|
||||
}
|
||||
else {
|
||||
$form .= '<ul>';
|
||||
|
@ -323,7 +323,7 @@ if(!empty($_POST['socialaccount']) && !empty($_POST['socialinstance']) && ALLOW_
|
|||
if( empty($error) ) {
|
||||
$error = createAutoblog($sitetype, ucfirst($socialinstance) .' - '. $socialaccount, $siteurl, $rssurl, $error);
|
||||
if( empty($error))
|
||||
$success[] = '<iframe width="1" height="1" frameborder="0" src="'. urlToFolderWithTrailingSlash( $siteurl ) .'/index.php"></iframe><b style="color:darkgreen">'.ucfirst($socialinstance) .' - '. $socialaccount.' <a href="'.urlToFolderWithTrailingSlash( $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>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -348,7 +348,7 @@ if( !empty($_POST['generic']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_L
|
|||
$error = createAutoblog('generic', $sitename, $siteurl, $rssurl, $error);
|
||||
|
||||
if( empty($error))
|
||||
$success[] = '<iframe width="1" height="1" frameborder="0" src="'. urlToFolderWithTrailingSlash( $siteurl ) .'/index.php"></iframe><b style="color:darkgreen">autoblog crée avec succès.</b> → <a target="_blank" href="'. urlToFolderWithTrailingSlash( $siteurl ) .'">afficher l\'autoblog</a>';
|
||||
$success[] = '<iframe width="1" height="1" frameborder="0" src="'. urlToFolderSlash( $siteurl ) .'/index.php"></iframe><b style="color:darkgreen">autoblog crée avec succès.</b> → <a target="_blank" href="'. urlToFolderSlash( $siteurl ) .'">afficher l\'autoblog</a>';
|
||||
}
|
||||
else {
|
||||
// checking procedure
|
||||
|
@ -385,7 +385,7 @@ if( !empty($_POST['opml']) && ALLOW_NEW_AUTOBLOGS && ALLOW_NEW_AUTOBLOGS_BY_OPML
|
|||
|
||||
$error = createAutoblog( 'generic', $sitename, $siteurl, $rssurl, $error );
|
||||
if( empty ( $error ))
|
||||
$success[] = '<iframe width="1" height="1" frameborder="0" src="'. urlToFolderWithTrailingSlash( $siteurl ) .'/index.php"></iframe>Autoblog "'. $sitename .'" crée avec succès. → <a target="_blank" href="'. urlToFolderWithTrailingSlash( $siteurl ) .'">afficher l\'autoblog</a>.';
|
||||
$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>.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,6 @@ function xsafimport($xsafremote, $max_exec_time) {
|
|||
// Do not use DetectRedirect because it's slow and it has been used when the feed was added
|
||||
//$rssurl = DetectRedirect(escape($value['FEED_URL']));
|
||||
$rssurl = escape($value['FEED_URL']);
|
||||
$foldername = urlToFolder($siteurl);
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,7 +89,7 @@ function xsafimport($xsafremote, $max_exec_time) {
|
|||
|
||||
/* autoblog */
|
||||
if( $result === true ) {
|
||||
$foldername = urlToFolder($siteurl);
|
||||
$foldername = urlToFolderSlash($siteurl);
|
||||
|
||||
$errors = createAutoblog($sitetype, $sitename, $siteurl, $rssurl);
|
||||
foreach( $errors AS $value) {
|
||||
|
|
Loading…
Reference in a new issue