feat wikiIsOnServer
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
Florian Schmitt 2024-12-05 23:31:49 +03:00
parent 9091895058
commit 86e9625246
2 changed files with 21 additions and 7 deletions

View file

@ -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)

View file

@ -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 <bold>'.$from.'</bold> to <bold>'.$to.'</bold>');
$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(