summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cab77df)
raw | patch | inline | side by side (parent: cab77df)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 4 Jun 2008 11:11:31 +0000 (11:11 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 4 Jun 2008 11:11:31 +0000 (11:11 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11206 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/apache2/admin/systems/services/apache2/class_apacheUtils.inc b/gosa-plugins/apache2/admin/systems/services/apache2/class_apacheUtils.inc
index 5439cac35a04a0af1817a52c04fe01849a810029..7271ddc1c23177987fb6f0edf5f6b6476a113041 100644 (file)
}
return($zones);
}
-
- /* Simple is domain check, it checks if the given string looks like "string.string.string"
- or string.string */
- public static function GetVhostsDomain($str)
- {
- return(preg_match("/[^\.\/]+\.[^\.\/]+$/",$str));
- }
}
?>
diff --git a/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheEditVhost.inc b/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheEditVhost.inc
index 60d64b9c58b43bd2a14271ffeccab317000c472e..19fba7af31b6d2fae48eec60684bf7679b4ed42b 100644 (file)
<?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: class_gosaSupportDaemon.inc 10788 2008-05-06 11:15:57Z $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
class servapacheVhostEdit extends plugin
{
var $ignore_account= TRUE;
var $attributes = array("apacheServerName","apacheDocumentRoot","apacheServerAlias",
- "apacheServerAdmin","apacheScriptAlias","apacheSuexecUid","apacheSuexecGid");
+ "apacheServerAdmin","apacheScriptAlias","apacheSuexecUid","apacheSuexecGid");
var $objectclasses = array("whatever");
-
var $apacheServerName = "";
var $apacheDocumentRoot = "";
var $apacheServerAdmin = "";
var $cn;
var $VhostObject = array();
+
function servapacheVhostEdit ($config, $dn= NULL,$attrs = array())
{
plugin::plugin ($config, $dn);
-
if(!count($attrs)){
$this->OldApacheServerName = "";
$this->isNew = true;
-
$this->InitialApacheServerName = "";//$attrs['InitialApacheServerName'];
}else{
$this->VhostObject = $attrs;
-
$this->OldApacheServerName = $attrs['apacheServerName'];
-
$this->InitialApacheServerName = $attrs['InitialApacheServerName'];
-
$this->isNew = false;
-
foreach($this->attributes as $value){
if(isset($attrs[$value])){
$this->$value = $attrs[$value];
if(!isset($attrs['apacheServerAlias'])) $this->apacheServerAlias = array();
if(!isset($attrs['apacheScriptAlias'])) $this->apacheScriptAlias = array();
-
}
}
$smarty= get_smarty();
$display= "";
- /* Open Vhost Entry Edit Dialog
+// Outdated?
+
+# /* Open Vhost Entry Edit Dialog
+# */
+# if(!count($this->VhostObject)){
+# $smarty->assign("AllowVhostEdit" , false);
+# }else{
+# $smarty->assign("AllowVhostEdit" , true);
+# if(isset($_POST['EditVhostEntries'])){
+# $this->dialog= new apacheVhostEditEntries($this->config,$this->dn,$this->VhostObject);
+# }
+# }
+#
+# /* Save Vhost Entry Edit Dialog
+# */
+# if(isset($_POST['SaveVhostEntryChanges'])){
+# $this->dialog->save_object();
+# if(count($this->dialog->check())){
+# msg_dialog::displayChecks($this->dialog->check());
+# }else{
+# $this->dialog->save();
+# $this->dialog = false;
+# }
+# }
+#
+# /* Cancel Vhost Entrie Edit Dialog
+# */
+# if(isset($_POST['CancelVhostEntryChanges'])){
+# $this->dialog = false;
+# }
+#
+# /* Display any type of open dialogs
+# */
+# if($this->dialog){
+# $this->dialog->save_object();
+# return($this->dialog->execute());
+# }
+#
+
+ /* Check posts
*/
- if(!count($this->VhostObject)){
- $smarty->assign("AllowVhostEdit" , false);
- }else{
- $smarty->assign("AllowVhostEdit" , true);
- if(isset($_POST['EditVhostEntries'])){
- $this->dialog= new apacheVhostEditEntries($this->config,$this->dn,$this->VhostObject);
- }
- }
-
- /* Save Vhost Entry Edit Dialog
- */
- if(isset($_POST['SaveVhostEntryChanges'])){
- $this->dialog->save_object();
- if(count($this->dialog->check())){
- msg_dialog::displayChecks($this->dialog->check());
- }else{
- $this->dialog->save();
- $this->dialog = false;
- }
- }
-
- /* Cancel Vhost Entrie Edit Dialog
- */
- if(isset($_POST['CancelVhostEntryChanges'])){
- $this->dialog = false;
- }
-
- /* Display any type of open dialogs
- */
- if($this->dialog){
- $this->dialog->save_object();
- return($this->dialog->execute());
- }
-
$once =true;
foreach($_POST as $name => $value){
+
+ /* Move Server Aliases one position up
+ */
if((preg_match("/^SAup_/",$name)) && ($once)){
$once = false;
-
$id = preg_replace("/^SAup_/","",$name);
$id = preg_replace("/_.*$/","",$id);
$id = base64_decode($id);
-
$this->apacheServerAlias = $this->ArrayUp(($id+1),$this->apacheServerAlias);
}
+
+ /* Move Server Aliases one position down
+ */
if((preg_match("/^SAdown_/",$name)) && ($once)){
$once = false;
$this->apacheServerAlias = $this->ArrayDown(($id+1),$this->apacheServerAlias);
}
+
+ /* Delete a "Server Alias"
+ */
if((preg_match("/^SAdel_/",$name)) && ($once)){
$once = false;
-
$id = preg_replace("/^SAdel_/","",$name);
$id = preg_replace("/_.*$/","",$id);
$id = base64_decode($id);
-
unset($this->apacheServerAlias[$id]);
-
$tmp =array();
foreach($this->apacheServerAlias as $entry){
$tmp[] = $entry;
}
-
$this->apacheServerAlias = $tmp;
}
+ /* Move "Script Alias" one position up
+ */
if((preg_match("/^SCup_/",$name)) && ($once)){
$once = false;
-
$id = preg_replace("/^SCup_/","",$name);
$id = preg_replace("/_.*$/","",$id);
$id = base64_decode($id);
-
$this->apacheScriptAlias = $this->ArrayUp(($id+1),$this->apacheScriptAlias);
}
+
+ /* Move "Script Alias" one position down
+ */
if((preg_match("/^SCdown_/",$name)) && ($once)){
$once = false;
-
$id = preg_replace("/^SCdown_/","",$name);
$id = preg_replace("/_.*$/","",$id);
$id = base64_decode($id);
-
$this->apacheScriptAlias = $this->ArrayDown(($id+1),$this->apacheScriptAlias);
}
+
+ /* Remove "Script Alias"
+ */
if((preg_match("/^SCdel_/",$name)) && ($once)){
$once = false;
-
$id = preg_replace("/^SCdel_/","",$name);
$id = preg_replace("/_.*$/","",$id);
$id = base64_decode($id);
-
unset($this->apacheScriptAlias[$id]);
-
$tmp =array();
foreach($this->apacheScriptAlias as $entry){
$tmp[] = $entry;
}
-
$this->apacheScriptAlias = $tmp;
}
-
}
+ /* Add a new "Server Alias"
+ */
if((isset($_POST['AddSARecord'])) && (!empty($_POST['StrSAAlias'])) && (!empty($_POST['StrSADir']))){
$this->apacheServerAlias[] = trim($_POST['StrSAAlias']." ".$_POST['StrSADir']);
}
+ /* Add a new "Script Alias"
+ */
if((isset($_POST['AddSCRecord'])) && (!empty($_POST['StrSCAlias'])) && (!empty($_POST['StrSCDir']))){
$this->apacheScriptAlias[] = trim($_POST['StrSCAlias']." ".$_POST['StrSCDir']);
}
- /* Handle Post events */
- $once = true;
- foreach($_POST as $name => $value){
-
- /* Delete vhosts if requested */
- if((preg_match("/RemoveRecord_/",$name))&&($once)){
- $once = false;
- $id= preg_replace("/RemoveRecord_/","",$name);
- unset($this->Records[$id]);
- }
- }
-
- /* Add new Vhostrecord */
- /* if(isset($_POST['AddNewRecord'])){
- $this->Records[] = array("type"=>"aRecord","value"=>"");
- }*/
-
/* Fill in values */
foreach($this->attributes as $name){
$smarty->assign($name,$this->$name);
}
/* Set apacheServerNames without server suffix */
- $smarty->assign("apacheServerName",$this->apacheServerName);
+ $smarty->assign("apacheServerName",$this->apacheServerName);
+ $smarty->assign("NotNew", false);
+
+ /* Create Server Aliases divlist
+ */
$div = new divSelectBox("apacheServerAlias");
$div->setHeight(120);
$recs = $this->apacheServerAlias;
- $oneup = "<input name='SAup_%s' type='image' src='images/sort_up.png' title='"._("Up")."' class='center'> ";
- $onedown = "<input name='SAdown_%s' type='image' src='images/sort_down.png' title='"._("Down")."' class='center'> ";
- $onedel = "<img src='images/empty.png' width='20' class='center'>
- <input name='SAdel_%s' type='image' src='images/edittrash.png' title='"._("Delete")."' class='center'>";
+ $oneup = "<input name='SAup_%s' type='image' src='images/lists/sort-up.png' title='"._("Up")."' class='center'> ";
+ $onedown = "<input name='SAdown_%s' type='image' src='images/lists/sort-down.png' title='"._("Down")."' class='center'> ";
+ $onedel = "<input name='SAdel_%s' type='image' src='images/lists/trash.png' title='"._("Delete")."' class='center'>";
foreach($recs as $key => $rec){
$div ->AddEntry(array(
array("string"=>$rec),
-/* array("string"=>$key,
- "attach"=>"style='width:20px;'"),*/
array("string"=>str_replace("%s",base64_encode($key),$oneup.$onedown.$onedel),
"attach"=>"style='width:70px;border-right:0px;'")
));
}
-
- $smarty->assign("NotNew", false);
-
$smarty->assign("apacheServerAlias", $div->DrawList());
+
+ /* Create Server Aliases divlist
+ */
$div = new DivSelectBox("apacheScriptAlias");
$div->setHeight(120);
$recs = $this->apacheScriptAlias;
- $oneup = "<input name='SCup_%s' type='image' src='images/sort_up.png' title='"._("Up")."' class='center'> ";
- $onedown = "<input name='SCdown_%s' type='image' src='images/sort_down.png' title='"._("Down")."' class='center'> ";
- $onedel = "<img src='images/empty.png' width='20' class='center'>
- <input name='SCdel_%s' type='image' src='images/edittrash.png' title='"._("Delete")."' class='center'>";
+ $oneup = "<input name='SCup_%s' type='image' src='images/lists/sort-up.png' title='"._("Up")."' class='center'> ";
+ $onedown = "<input name='SCdown_%s' type='image' src='images/lists/sort-down.png' title='"._("Down")."' class='center'> ";
+ $onedel = "<input name='SCdel_%s' type='image' src='images/lists/trash.png' title='"._("Delete")."' class='center'>";
foreach($recs as $key => $rec){
$div ->AddEntry(array(
array("string"=>$rec),
-/* array("string"=>$key,
- "attach"=>"style='width:20px;'"),*/
array("string"=>str_replace("%s",base64_encode($key),$oneup.$onedown.$onedel),
"attach"=>"style='width:70px;border-right:0px;'")
));
}
-
- $smarty->assign("NotNew", false);
-
$smarty->assign("apacheScriptAlias", $div->DrawList());
/* Display template */
return($display);
}
+
function remove_from_parent()
{
}
+
/* Save data to object */
function save_object()
{
- //plugin::save_object();
- foreach($this->attributes as $attr){
- if(isset($_POST[$attr])){
- $this->$attr = $_POST[$attr];
- }
- }
-
+ plugin::save_object();
}
/* Check if apacheServerName is already in use */
$usedVhosts = $this->getUsedServerNames();
if(($this->isNew == true)||($this->apacheServerName != $this->InitialApacheServerName)){
-/* if((isset($usedVhosts[$this->apacheServerName]))&&($this->apacheServerName != $this->InitialApacheServerName)){
- $message[] =_("This apacheServerName is already in use");
+ if((isset($usedVhosts[$this->apacheServerName]))&&($this->apacheServerName != $this->InitialApacheServerName)){
+ $message[] = msgPool::duplicated(_("Name"));
}
-*/
}
- if(!apacheUtils::GetVhostsDomain($this->apacheServerName) || empty($this->apacheServerName)){
- $message[] =sprintf(_("Please choose a valid Virtual Host Name."));
+ /* Check given virtual server name
+ */
+ if(!tests::is_domain($this->apacheServerName) || empty($this->apacheServerName)){
+ $message[] = msgPool::invalid(_("Virtual host name"),$this->apacheServerName,"",
+ _("Only lowercase strings are allowed as Virtual Host Name.")." "._("e.g. example.com"));
}
+ /* check if there is a valid document root given
+ */
if(!tests::is_path($this->apacheDocumentRoot) || empty($this->apacheDocumentRoot)){
- $message[] = _("Please choose a valid Path as Virtual Host Document Root.");
+ $message[] = msgPool::invalid(_("Document root"),$this->apacheDocumentRoot);
}
-
+
+ /* Check given mail address
+ */
if(!tests::is_email($this->apacheServerAdmin) || empty($this->apacheServerAdmin)){
- $message[] = _("Please choose a valid Email Account as Admin Mail address.");
- }
-
- if($this->apacheServerName != strtolower($this->apacheServerName)){
- $message[] = _("Only lowercase strings are allowed as Virtual Host Name.");
- }
-
- if($this->apacheDocumentRoot != strtolower($this->apacheDocumentRoot)){
- $message[] = _("Only lowercase strings are allowed as Virtual Host Document Root.");
- }
-
- if($this->apacheServerAdmin != strtolower($this->apacheServerAdmin)){
- $message[] = _("Only lowercase strings are allowed as Admin Mail address.");
+ $message[] = msgPool::invalid(_("Admin mail address"),$this->apacheServerAdmin);
}
+ /* Check server aliases
+ */
foreach($this->apacheServerAlias as $key => $line){
- $apacheServerAlias_ar=split(" ",$line);
- $url=$apacheServerAlias_ar[0];
- if(!is_path($url)){
- $message[] = sprintf(_("Please choose a valid Path as URL Alias Path in line: %s"),$line);
- }
+ $apacheServerAlias_ar=split(" ",$line);
+ $url=$apacheServerAlias_ar[1];
+ if(!tests::is_path($url)){
+ $message[] = msgPool::invalid(_("Server alias"));
+ }
}
-
- foreach($this->apacheScriptAlias as $key => $line){
- $apacheScriptAlias_ar=split(" ",$line);
- $url=$apacheScriptAlias_ar[0];
- if(!is_path($url)){
- $message[] = sprintf(_("Please choose a valid Path as URL Alias Path in line: %s"),$line);
- }
+
+ /* Check script aliases
+ */
+ foreach($this->apacheScriptAlias as $key => $line){
+ $apacheScriptAlias_ar=split(" ",$line);
+ $url=$apacheScriptAlias_ar[1];
+ if(!tests::is_path($url)){
+ $message[] = msgPool::invalid(_("Script alias"));
+ }
}
-
+
return ($message);
}
+
/* This funtion returns all used apacheServerNames */
function getUsedServerNames()
{
return($ret);
}
+
/* Save to LDAP */
function save()
{
$rec['value']= $key." ".$rec['value'];
$this->Records [] = $rec;
}
-
- /* Create SC records
+
+ /* Create SC records
*/
foreach($this->apacheScriptAlias as $key => $rec){
$rec['value']= $key." ".$rec['value'];
}
$ret['RECORDS'] = $this->Records;
-
$ret['InitialApacheServerName'] = $this->InitialApacheServerName;
-
return($ret);
}
}
-
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
diff --git a/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheVhost.inc b/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheVhost.inc
index 3cb51cd74385f7f415ff25205296434eaf00e0e2..51c7c4d1677d5a2b9ee7383477c32c8cc2b111f1 100644 (file)
<?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: class_gosaSupportDaemon.inc 10788 2008-05-06 11:15:57Z hickert $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
class servapache extends goService
{
/* attribute list for save action */
*/
$once = false;
foreach( $_POST as $name => $value){
- //user_error(print_r($this->Vhosts,true));
+
/* check all post for edit request
*/
if(preg_match("/^editVhost_/",$name)&& !$once && $this->acl_is_writeable("VirtualHosts")){
*/
$VhostList = new divSelectBox("apacheConfigs");
$VhostList -> SetHeight(254);
-
+
/* Add entries to divlist
*/
- $editImg = "<input type='image' src='images/edit.png' name='editVhost_%s'>
- <input type='image' src='images/edittrash.png' name='delVhost_%s'>";
+ $editImg = "<input type='image' src='images/lists/edit.png' name='editVhost_%s'>
+ <input type='image' src='images/lists/trash.png' name='delVhost_%s'>";
foreach($this->Vhosts as $vhost => $values ){
$VhostList->AddEntry(array(
array("string" => $vhost),
));
}
-
/* Assign ACL to smarty
*/
$info = $this->plInfo();
}
- /* Remove apache service
+ /* Remove apache service
*/
function remove_from_parent()
{
}
$tmp = apacheUtils::getVhostEntriesDiff($this->config,$this->Vhosts,$old_dn);
- print_a($tmp);
/* Updated vhost entries if reverser or forward name has changed
* Must be done before moving entries, else the given dn is invalid
*/
foreach($tmp['add'] as $dn => $attrs){
$ldap->cd($dn);
-// user_error(print_r($dn,true));
$ldap->cat($dn, array('dn'));
if(count($ldap->fetch())){
$ldap->cd($dn);
diff --git a/gosa-plugins/apache2/admin/systems/services/apache2/servApacheVhostEdit.tpl b/gosa-plugins/apache2/admin/systems/services/apache2/servApacheVhostEdit.tpl
index 3044f9d1b577b018d5fc38b05ad227cd99bb488d..9f08e8db1c154c9452af2e3192fa4264a3622337 100644 (file)
<td style="width:50%;vertical-align:top;border-right:1px solid #b0b0b0;">
<table summary="">
<tr>
- <td>{t}Virtual Host Name{/t}{$must}
+ <td>{t}Virtual host name{/t}{$must}
</td>
<td><input type="text" name="apacheServerName" value="{$apacheServerName}" {if $NotNew} disabled {/if}>
</td>
</tr>
<tr>
- <td>{t}Virtual Host Document Root{/t}{$must}
+ <td>{t}Document root{/t}{$must}
</td>
<td><input type="text" name="apacheDocumentRoot" value="{$apacheDocumentRoot}">
</td>
</tr>
<tr>
- <td>{t}Admin Mail address{/t}{$must}
+ <td>{t}Admin mail address{/t}{$must}
</td>
<td><input type="text" name="apacheServerAdmin" value="{$apacheServerAdmin}">
</td>