diff --git a/utils.inc.php b/utils.inc.php index 27051c6..f0d972b 100644 --- a/utils.inc.php +++ b/utils.inc.php @@ -8,8 +8,12 @@ use Amp\Http\Client\Request; function domainIsOnServer($domain) { - $domainWithoutWww = preg_replace('/^www\./m', '', $domain); - return file_exists('/etc/nginx/conf.d/'.$domainWithoutWww.'.conf'); + return file_exists('/etc/nginx/conf.d/'.$domain.'.conf'); +} + +function wikiIsOnServer($path) +{ + return glob('/home/*/'.$path.'/wakka.config.php'); } function checkIP($domain, $withWww = false, $noip6 = false) diff --git a/yeswiki-move.php b/yeswiki-move.php index 30fc108..c0ee600 100755 --- a/yeswiki-move.php +++ b/yeswiki-move.php @@ -54,22 +54,32 @@ if (!filter_var($from, FILTER_VALIDATE_URL)) { exit; } $fromUrl = parse_url($from); -var_dump($fromUrl); -if (!domainIsOnServer($fromUrl['host'])) { +$fromDomainWithoutWww = preg_replace('/^www\./m', '', $fromUrl['host']); + +if (!domainIsOnServer($fromDomainWithoutWww)) { $climate->error('ERROR : Domain '.$fromUrl['host'].' was not found on the server.'."\n"); exit; } +if (!wikiIsOnServer($fromDomainWithoutWww.$fromUrl['path'])) { + $climate->error('ERROR : no Yeswiki found '.$fromDomainWithoutWww.$fromUrl['path'].' on the server.'."\n"); + exit; +} if (!filter_var($to, FILTER_VALIDATE_URL)) { $climate->error('ERROR : the destination url given with --to '.$to.' is not a valid url.'."\n"); exit; } $toUrl = parse_url($to); -var_dump($toUrl); -if (!domainIsOnServer($toUrl['host'])) { +$toDomainWithoutWww = preg_replace('/^www\./m', '', $toUrl['host']); + +if (!domainIsOnServer($toDomainWithoutWww)) { $climate->error('ERROR : Domain '.$toUrl['host'].' was not found on the server.'."\n"); exit; } +if (!wikiIsOnServer($toDomainWithoutWww.$toUrl['path'])) { + $climate->error('ERROR : no Yeswiki found '.$toDomainWithoutWww.$toUrl['path'].' on the server.'."\n"); + exit; +} if ($from === $to) { $climate->error('ERROR : --from and --to parameters must be different.'."\n"); @@ -78,7 +88,7 @@ if ($from === $to) { $climate->bold()->underline()->out('Move a YesWiki'); $climate->out('This will move yeswiki on '.$from.' to '.$to.''); -$climate->red('CAREFUL: the destination yeswiki will be replaced'."\n"); +$climate->red('CAREFUL: the destination yeswiki will be replaced.'."\n"); $input = $climate->confirm('Is it all good ?'); if ($input->confirmed()) { $climate->shout(