Code

- Latest cleanup plugin
authoropensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8>
Sun, 4 Nov 2007 18:01:22 +0000 (18:01 +0000)
committeropensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8>
Sun, 4 Nov 2007 18:01:22 +0000 (18:01 +0000)
- 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

vhost-apache2/src/class_servApacheEditVhost.inc
vhost-apache2/src/class_servApacheVhost.inc
vhost-apache2/src/functions_apache.inc

index 0f8672c5db5ec97c78cecbf651eaf5a57c9d0dba..1b0b61725d81536553b024d773ef41923e661077 100644 (file)
@@ -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."));
     }
 
index 495da74853eb498bca6c0e01beccad723f3f4fb5..4b97104b33b865a7c9a64b5571f958fa3630246d 100644 (file)
@@ -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 
index be0b3f026d47f552e3a4e9f63dd130383716ef6f..edaa39d2e346b19e24aa9a099d3bfbd6793f510b 100644 (file)
@@ -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));
+}
+
 ?>