Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Fix invalid host for url generation when host does not have tld and subdomain https://github.com/givanz/Vvveb/issues/124

givanz41e99e4e1a21
diff --git a/system/sites.php b/system/sites.php
index 998df5b..39d00f1 100755
--- a/system/sites.php
+++ b/system/sites.php
@@ -128,8 +128,8 @@ class Sites {
return $matches;
}
- //if host is ip number return the ip
- if (is_numeric($host_matches['domain'] ?? null)) {
+ //if host is ip number, localhost or does not have tld remove tld and subdomain
+ if (is_numeric($host_matches['domain'] ?? null) || $host == 'localhost' || (strpos($host, '.') === false)) {
$matches['domain'] = $host;
$matches['subdomain'] = $matches['tld'] = $matches['prefix'] = '';
}
@@ -167,12 +167,8 @@ class Sites {
($matches['path'] ?? '');
}
- //if host is ip number return the ip
- if (is_numeric($host_matches['domain'] ?? null)) {
- return $host;
- }
-
- if ($hostWp == 'localhost') {
+ //if host is ip number, localhost or does not have tld remove tld and subdomain
+ if (is_numeric($host_matches['domain'] ?? null) || $hostWp == 'localhost' || (strpos($hostWp, '.') === false)) {
$matches['domain'] = $host;
$matches['subdomain'] = $matches['tld'] = $matches['prefix'] = '';
}
@@ -219,7 +215,7 @@ class Sites {
}
public static function setSiteDataByKey($site_key, $name, $value) {
- $site = self :: getSiteByKey($site_id);
+ $site = self :: getSiteByKey($site_key);
$site_key = self :: siteKey($site_key);