diff --git a/0.3/functions.php b/0.3/functions.php index 0be8f2e..ad2bcb9 100755 --- a/0.3/functions.php +++ b/0.3/functions.php @@ -30,6 +30,10 @@ function urlToFolder($url) { return sha1(NoProtocolSiteURL($url)); } +function urlToFolderWithTrailingSlash($url) { + return sha1(NoProtocolSiteURL($url).'/'); +} + function escape($str) { return htmlspecialchars($str, ENT_COMPAT, 'UTF-8', false); } @@ -47,6 +51,12 @@ function createAutoblog($type, $sitename, $siteurl, $rssurl, $error = array()) { $error[] = 'Erreur: l\'autoblog '. $sitename .' existe déjà.'; return $error; } + + $foldername = urlToFolderWithTrailingSlash($siteurl); + if(file_exists($foldername)) { + $error[] = 'Erreur: l\'autoblog '. $sitename .' existe déjà.'; + return $error; + } if ( mkdir('./'. $foldername, 0755, false) ) { $fp = fopen('./'. $foldername .'/index.php', 'w+'); @@ -97,4 +107,4 @@ function updateType($siteurl) { else return array('type' => 'generic', 'name' => ''); } -?> \ No newline at end of file +?>