From: opensides Date: Sun, 4 Nov 2007 18:01:22 +0000 (+0000) Subject: - Latest cleanup plugin X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e8a189fb5ba7d21de9509ac59395b2cd0eb600a5;hp=7d061eb579c35a2f71d795d1241d13376599bd54;p=gosa.git - Latest cleanup plugin - Added function to check valid hostname git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5-plugins@7728 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/vhost-apache2/src/class_servApacheEditVhost.inc b/vhost-apache2/src/class_servApacheEditVhost.inc index 0f8672c5d..1b0b61725 100644 --- a/vhost-apache2/src/class_servApacheEditVhost.inc +++ b/vhost-apache2/src/class_servApacheEditVhost.inc @@ -364,7 +364,7 @@ class servapacheVhostEdit extends plugin */ } - if(is_domain($this->apacheServerName) || empty($this->apacheServerName)){ + if(!GetVhostsDomain($this->apacheServerName) || empty($this->apacheServerName)){ $message[] =sprintf(_("Please choose a valid Virtual Host Name.")); } diff --git a/vhost-apache2/src/class_servApacheVhost.inc b/vhost-apache2/src/class_servApacheVhost.inc index 495da7485..4b97104b3 100644 --- a/vhost-apache2/src/class_servApacheVhost.inc +++ b/vhost-apache2/src/class_servApacheVhost.inc @@ -130,7 +130,7 @@ class servapache extends plugin /* Initiate deletion */ - $this->RemoveVhost($tmp); + $this->RemoveVhost($tmp); } } @@ -160,7 +160,7 @@ class servapache extends plugin $smarty->assign("servapacheACL",chkacl($this->acl,"servapache")); - /* Display tempalte + /* Display template */ $smarty->assign("VhostList",$VhostList->DrawList()); $display.= $smarty->fetch(get_template_path('servApacheVhost.tpl', TRUE)); @@ -169,51 +169,12 @@ class servapache extends plugin /* Delete specified vhost - */ + */ function RemoveVhost($id) { - $vhosts = $this->getUsedServerNames(); - - $vhostname = ""; - if(isset($this->Vhosts[$id]['InitialApacheServerName'])){ - $vhostname= $this->Vhosts[$id]['InitialApacheServerName']; - } - - $used = array(); - - /* Add Records which use this apacheServerName - */ - if(isset($vhosts[$vhostname])){ - $used = array_merge($used,$vhosts[$vhostname]); - } - - - /* There are still entries using this configuration - * Abort deletion - */ - if(count($used)){ - $i = 2; - $str =""; - foreach($used as $dn){ - if($i > 0 ){ - $i --; - $str.=$dn." "; - } - } - - /* Only show 2 apache in the error message - */ - if(count($used)> 2) { - $str .=" ... "; - } - print_red(sprintf(_("Can't delete the selected vhost, because it is still in use by these entry/entries '%s'"),trim($str))); - - }else{ unset($this->Vhosts[$id]); return(true); - } - return(false); - } + } /* This function returns all used Vhostnames diff --git a/vhost-apache2/src/functions_apache.inc b/vhost-apache2/src/functions_apache.inc index be0b3f026..edaa39d2e 100644 --- a/vhost-apache2/src/functions_apache.inc +++ b/vhost-apache2/src/functions_apache.inc @@ -247,4 +247,11 @@ function getAvailableVhosts($config) return($zones); } +/* Simple is domain check, it checks if the given string looks like "string.string.string" + or string.string */ +function GetVhostsDomain($str) +{ + return(preg_match("/[^\.\/]+\.[^\.\/]+$/",$str)); +} + ?>