diff --git a/app/Factories/NginxVhostFactory.php b/app/Factories/NginxVhostFactory.php index c591e10..da38edb 100644 --- a/app/Factories/NginxVhostFactory.php +++ b/app/Factories/NginxVhostFactory.php @@ -136,8 +136,6 @@ class NginxVhostFactory ->addMenuItem($checkbox) ->addLineBreak('-'); - var_dump($vhost); die(); - if ($vhost['ssl'] === true) { if ($vhost['ssl_certificate_exists']) { $builder->addStaticItem('expired_at: '.$vhost['ssl_certificate_expired_at']); diff --git a/app/Helpers/NginxVhostHelper.php b/app/Helpers/NginxVhostHelper.php index be2ab6d..63f0911 100644 --- a/app/Helpers/NginxVhostHelper.php +++ b/app/Helpers/NginxVhostHelper.php @@ -98,6 +98,27 @@ class NginxVhostHelper return $result; } + /** + * + * @return + */ + private function getRedirect($path, $domain) + { + // getting .conf-file + $content = file_get_contents($path); + + // result + $result = false; + + preg_match('/server_name www.'.$domain.'/', $content, $matches); + + if (count($matches) > 0) { + $result = true; + } + + return $result; + } + /** * get vhost * @@ -113,10 +134,14 @@ class NginxVhostHelper // getting certificates from a configuration $certificate = $this->getCertificate($path); + // domain + $domain = str_replace('.conf', '', $filename); + $result = array_merge([ - 'domain' => str_replace('.conf', '', $filename), + 'domain' => $domain, 'path' => $path, 'file' => $filename, + 'redirect_www' => $this->getRedirect($path, $domain) 'enabled' => in_array($filename, $enabled), ], $certificate);