summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3f880a7)
raw | patch | inline | side by side (parent: 3f880a7)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 17 Jan 2008 16:42:44 +0000 (16:42 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 17 Jan 2008 16:42:44 +0000 (16:42 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8478 594d385d-05f5-0310-b6e9-bd551577e9d8
44 files changed:
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpAdvanced.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpAdvanced.inc
+++ /dev/null
@@ -1,146 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003 Cajus Pollmeier
-
- 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 dhcpAdvanced extends plugin
-{
- /* Used attributes */
- var $options= array();
- var $statements= array();
- var $show_advanced= FALSE;
- var $autoStatements= array();
- var $autoOptions= array();
-
- /* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
-
- function dhcpAdvanced()
- {
- /* This is always an account */
- $this->is_account= TRUE;
- $this->setAutoStatements();
- $this->setAutoOptions();
- }
-
- function execute()
- {
- /* Check for interaction */
- if (isset($_POST['add_statement']) && $_POST['addstatement'] != ""){
- $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addstatement'));
- $val= preg_replace("/^$key\s*/", '', get_post('addstatement'));
- $this->statements[$key]= $val;
- }
- if (isset($_POST['delete_statement']) && isset($_POST['dhcpstatements'])){
- $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpstatements'));
- if (in_array($key, $this->autoStatements)){
- print_red(_("Can't delete automatic statements. Please use the fields above."));
- } else {
- unset($this->statements[$key]);
- }
- }
- if (isset($_POST['add_option']) && $_POST['addoption'] != ""){
- $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addoption'));
- $val= preg_replace("/^$key\s*/", '', get_post('addoption'));
- $this->options[$key]= $val;
- }
- if (isset($_POST['delete_option']) && isset($_POST['dhcpoptions'])){
- $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpoptions'));
- if (in_array($key, $this->autoOptions)){
- print_red(_("Can't delete automatic options. Please use the fields above."));
- } else {
- unset($this->options[$key]);
- }
- }
-
- $smarty= get_smarty();
-
- /* Assign arrays */
- $statements= array();
- foreach ($this->statements as $key => $val){
- if (in_array($key, $this->autoStatements)){
- $statements[$key]= "$key $val ["._("automatic")."]";
- } else {
- $statements[$key]= "$key $val";
- }
- }
- $smarty->assign("dhcpstatements", $statements);
- $options= array();
- foreach ($this->options as $key => $val){
- if (in_array($key, $this->autoOptions)){
- $options[$key]= "$key $val ["._("automatic")."]";
- } else {
- $options[$key]= "$key $val";
- }
- }
- $smarty->assign("dhcpoptions", $options);
-
- /* Show main page */
- $smarty->assign("show_advanced", $this->show_advanced);
- return ($smarty->fetch (get_template_path('dhcp_advanced.tpl', TRUE,dirname(__FILE__))));
- }
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if (isset($_POST['show_advanced'])){
- $this->show_advanced= TRUE;
- }
- if (isset($_POST['hide_advanced'])){
- $this->show_advanced= FALSE;
- }
- }
-
-
- /* Check values */
- function check()
- {
- /* Nothing to check here */
- $message= array();
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- }
-
-
- function setAutoOptions($addopt= array())
- {
- $options= array("routers", "domain-name", "domain-name-servers", "subnet-mask", "broadcast-address");
- $this->autoOptions= array_merge($options, $addopt);
- }
-
-
- function setAutoStatements($addstat= array())
- {
- $statements= array("filename", "next-server", "get-lease-hostnames", "use-host-decl-names");
- $this->autoStatements= array_merge($statements, $addstat);
- }
-
-}
-
-?>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpGroup.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpGroup.inc
+++ /dev/null
@@ -1,126 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003 Cajus Pollmeier
-
- 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 dhcpGroup extends dhcpPlugin
-{
- /* attribute list for save action */
- var $objectclasses= array('top', 'dhcpGroup', 'dhcpOptions');
-
- function dhcpGroup(&$attrs)
- {
- /* Load statements / options */
- dhcpPlugin::dhcpPlugin($attrs);
- }
-
- function execute()
- {
- $smarty= get_smarty();
- $smarty->assign("cn", $this->cn);
-
- /* Show main page */
- $display= $smarty->fetch (get_template_path('dhcp_group.tpl', TRUE)).$this->network->execute();
-
- /* Merge arrays for advanced view */
- $this->fix_options();
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;
- }
-
- $display.= $this->advanced->execute();
-
- /* Merge back for removals */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->advanced->$type;
- $this->network->$type= $this->advanced->$type;
- }
-
- /* Add footer */
- $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
- " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
-
-
- return ($display);
- }
-
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- /* Save cn */
- if (isset($_POST['cn'])){
- $this->cn= validate(get_post('cn'));
- }
-
- /* Handle global saving */
- dhcpPlugin::save_object();
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- $cache = $this->parent->dhcpObjectCache;
-
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= _("Required field 'Name' is not filled.");
- }
- if (!preg_match('/^[a-z0-9_-]*$/i', $this->cn)){
- $message[]= _("Field 'Name' contains illegal characters.");
- }
-
- /* cn already used? */
- if ($this->orig_cn != $this->cn || $this->new){
-
- foreach($cache as $dn => $dummy){
- if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
- $message[]= _("The name for this host section is already used!");
- break;
- }
- }
- }
-
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
-
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- dhcpPlugin::save();
- return ($this->attrs);
- }
-
-
-}
-
-?>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpHost.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpHost.inc
+++ /dev/null
@@ -1,181 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003-2007 Cajus Pollmeier
-
- 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 dhcpHost extends dhcpPlugin
-{
- /* Used attributes */
- var $dhcpHWAddress= "";
- var $realGosaHost = FALSE;
-
- /* attribute list for save action */
- var $objectclasses= array("top", "dhcpHost");
-
- function dhcpHost($attrs,$host_exists_in_gosa = FALSE)
- {
- dhcpPlugin::dhcpPlugin($attrs);
-
- /* Load attributes */
- if (!$this->new){
- $this->dhcpHWAddress= $attrs['dhcpHWAddress'][0];
- }
-
- $this->advanced->setAutoOptions(array("host-name"));
- $this->advanced->setAutoStatements(array("fixed-address"));
-
- $this->realGosaHost = $host_exists_in_gosa;
- }
-
- function execute()
- {
- $smarty= get_smarty();
- $smarty->assign("cn", $this->cn);
- $smarty->assign("dhcpHWAddress", preg_replace('/^[^ ]+ /', '', $this->dhcpHWAddress));
- $smarty->assign("realGosaHost",$this->realGosaHost);
-
- /* Create fixed address */
- if (isset($this->statements['fixed-address'])){
- $smarty->assign("fixedaddr", $this->statements['fixed-address']);
- } else {
- $smarty->assign("fixedaddr", "");
- }
-
- /* Prepare hw type selector */
- $hwtype= preg_replace('/\s.*$/', '', $this->dhcpHWAddress);
- $smarty->assign("hwtype", $hwtype);
- $smarty->assign("hwtypes", array("ethernet" => _("Ethernet"),
- "fddi" => _("FDDI"),
- "token-ring" => _("Token Ring")));
- /* Show main page */
- $display= $smarty->fetch(get_template_path('dhcp_host.tpl', TRUE,dirname(__FILE__))).$this->network->execute();
-
- /* Merge arrays for advanced view */
- $this->fix_options();
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;
- }
- $display.= $this->advanced->execute();
-
- /* Merge back for removals */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->advanced->$type;
- $this->network->$type= $this->advanced->$type;
- }
-
- /* Add footer */
- $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
- " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
-
-
- return ($display);
- }
-
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- /* Save remaining attributes */
- if (isset($_POST['dhcp_host_posted'])){
-
- /* Assemble hwAddress */
- if (isset($_POST['dhcpHWAddress'])){
- $this->dhcpHWAddress= get_post('hwtype')." ".get_post('dhcpHWAddress');
- }
-
- if(!$this->realGosaHost){
- $this->cn= validate(get_post('cn'));
- }
-
- /* Save fixed address */
- if(!$this->realGosaHost){
- if ($_POST['fixedaddr'] != ""){
- $this->statements['fixed-address']= get_post('fixedaddr');
- } else {
- unset ($this->statements['fixed-address']);
- }
- }
- $this->options['host-name']= $this->cn;
- }
-
- dhcpPlugin::save_object();
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- $cache = array();
- if(isset($this->parent)){
- $cache = $this->parent->dhcpObjectCache;
- }
-
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= _("Required field 'Name' is not filled.");
- }
-
- /* cn already used? */
- if ($this->orig_cn != $this->cn || $this->new){
-
- foreach($cache as $dn => $dummy){
- if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
- $message[]= _("The name for this host section is already used!");
- break;
- }
- }
- }
-
- /* Check syntax of MAC address */
- $check= preg_replace('/^[^\s]*\s/', '', $this->dhcpHWAddress);
- if (!preg_match('/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/', $check)){
- $message[]= _("The hardware address specified by you is not valid!");
- }
-
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
-
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- dhcpPlugin::save();
- if ($this->dhcpHWAddress != ""){
- $this->attrs['dhcpHWAddress']= array($this->dhcpHWAddress);
- } else {
- $this->attrs['dhcpHWAddress']= array();
- }
-
- return ($this->attrs);
- }
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc
+++ /dev/null
@@ -1,226 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2004-2007 Cajus Pollmeier
-
- 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 dhcpNetwork extends plugin
-{
- /* Used attributes */
- var $options= array();
- var $statements= array();
-
- /* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
-
- function dhcpNetwork()
- {
- /* This is always an account */
- $this->is_account= TRUE;
- }
-
- function execute()
- {
- /* Check for iteraction */
- if (isset($_POST['add_dns']) && $_POST['addserver'] != ""){
- if (!preg_match('/^[0-9a-z.-]+$/', get_post('addserver'))){
- print_red(_("The name of the DNS server your're going to add is not valid!"));
- } else {
- $servers= array();
- if (isset($this->options['domain-name-servers'])){
- foreach(split(",", $this->options['domain-name-servers']) as $val){
- $servers[$val]= $val;
- }
- }
- $servers[get_post('addserver')]= get_post('addserver');
-
- $tmp= "";
- foreach($servers as $val){
- $tmp.= $val.",";
- }
- $this->options['domain-name-servers']= preg_replace('/,$/', '', $tmp);
- }
- }
- if (isset($_POST['delete_dns']) && isset($_POST['dnsserver'])){
- $tmp= preg_replace("/(\s*,\s*)?".get_post('dnsserver')."/i", '',
- $this->options['domain-name-servers']);
- $tmp= preg_replace("/(\s*)?,(\s*)?$/", '', $tmp);
- if ($tmp != ""){
- $this->options['domain-name-servers']= $tmp;
- } else {
- unset($this->options['domain-name-servers']);
- }
- }
-
- /* Show main page */
- $smarty= get_smarty();
-
- /*
- * Assemble options
- */
-
- /* Router */
- if (isset($this->options['routers'])){
- $smarty->assign("routers", $this->options['routers']);
- } else {
- $smarty->assign("routers", "");
- }
-
- /* DNS */
- if (isset($this->options['domain-name'])){
- $smarty->assign("domain", trim($this->options['domain-name'], '"'));
- } else {
- $smarty->assign("domain", "");
- }
- if (isset($this->options['domain-name-servers'])){
- $servers= array();
- foreach(split(",", $this->options['domain-name-servers']) as $val){
- $servers[$val]= $val;
- }
- $smarty->assign("dnsservers", $servers);
- } else {
- $smarty->assign("dnsservers", "");
- }
-
- /* Netmask / Broadcast */
- if (isset($this->options['subnet-mask'])){
- $this->options['subnet-mask']= normalize_netmask($this->options['subnet-mask']);
- $smarty->assign("subnet_mask", $this->options['subnet-mask']);
- } else {
- $smarty->assign("subnet_mask", "");
- }
- if (isset($this->options['broadcast-address'])){
- $smarty->assign("broadcast_address", $this->options['broadcast-address']);
- } else {
- $smarty->assign("broadcast_address", "");
- }
-
- /* Boot stuff */
- if (isset($this->statements['filename'])){
- $smarty->assign("filename", trim($this->statements['filename'], '"'));
- } else {
- $smarty->assign("filename", "");
- }
- if (isset($this->statements['next-server'])){
- $smarty->assign("nextserver", $this->statements['next-server']);
- } else {
- $smarty->assign("nextserver", "");
- }
-
- /* Set flags */
- $smarty->assign("autohost", "");
- if (isset($this->statements['get-lease-hostnames'])){
- if (preg_match('/^(true|on|yes)$/', $this->statements['get-lease-hostnames'])){
- $smarty->assign("autohost", "checked");
- }
- }
- $smarty->assign("autohostdecl", "");
- if (isset($this->statements['use-host-decl-names'])){
- if (preg_match('/^(true|on|yes)$/', $this->statements['use-host-decl-names'])){
- $smarty->assign("autohostdecl", "checked");
- }
- }
-
- return $smarty->fetch(get_template_path('dhcp_network.tpl', TRUE,dirname(__FILE__)));
- }
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- /* Only save, if we are "active" */
- if (isset($_POST['routers'])){
-
- /*
- * Assemble options
- */
-
- /* Options */
- foreach (array("routers" => "routers", "domain-name" => "domain", "subnet-mask" => "subnet_mask",
- "broadcast-address" => "broadcast_address") as $key => $val){
-
- if ($_POST["$val"] == ''){
- unset($this->options["$key"]);
- } else {
- $this->options["$key"]= get_post("$val");
- }
- }
-
- /* Statements */
- foreach (array("filename" => "filename", "next-server" => "nextserver") as $key => $val){
- if ($_POST["$val"] == ''){
- unset($this->statements["$key"]);
- } else {
-
- /* Only quote filename values */
- if(in_array($key,array("filename"))){
- $this->statements["$key"]= '"'.get_post("$val").'"';
- }else{
- $this->statements["$key"]= get_post("$val");
- }
- }
- }
-
- /* Flags */
- if (isset ($_POST['autohost'])){
- $this->statements['get-lease-hostnames']= "true";
- } else {
- unset($this->statements['get-lease-hostnames']);
- }
- if (isset ($_POST['autohostdecl'])){
- $this->statements['use-host-decl-names']= "on";
- } else {
- unset($this->statements['use-host-decl-names']);
- }
- }
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- /* Check netmask and broadcast */
- foreach(array("subnet-mask" => _("Netmask"), "broadcast-address" => _("Broadcast")) as $key => $typ){
- if (!isset($this->options["$key"])){
- continue;
- }
- $tmp= preg_replace('/^[^\s]+\s/', '', $this->options["$key"]);
-
- if (!tests::is_ip($tmp)){
- $message[]= sprintf(_("Error in definition of '%s'!"), $typ);
- }
- }
-
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- }
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-
-class dhcpNewSectionDialog extends plugin
-{
- /* attribute list for save action */
- var $ignore_account = TRUE;
- var $attributes = array();
- var $objectclasses = array("whatever");
-
- /* Mapping array */
- var $types= array();
- var $classtype= "";
- var $sectionMap= array( "dhcpService" => array("dhcpSharedNetwork", "dhcpSubnet", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/),
- #"dhcpClass" => array("dhcpSubClass"),
- "dhcpSubClass" => array(),
- "dhcpHost" => array(),
- "dhcpGroup" => array("dhcpHost"),
- "dhcpPool" => array(),
- "dhcpSubnet" => array("dhcpPool", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/),
- "dhcpSharedNetwork" => array("dhcpSubnet", "dhcpPool"));
-
-
-
- function dhcpNewSectionDialog($type)
- {
- $this->types= array( "dhcpService" => _("Global options"),
- /*"dhcpClass" => _("Class"),*/
- "dhcpSubClass" => _("Subclass"),
- "dhcpHost" => _("Host"),
- "dhcpGroup" => _("Group"),
- "dhcpPool" => _("Pool"),
- "dhcpSubnet" => _("Subnet"),
- "dhcpSharedNetwork" => _("Shared network"));
-
- $this->classtype= $type;
- }
-
- function execute()
- {
- /* Fill templating stuff */
- $smarty = get_smarty();
- $display= "";
-
- $sections= $this->sectionMap[$this->classtype];
- $t_sections= array();
- foreach ($sections as $section){
- $t_sections[$section]= $this->types[$section];
- }
- asort($t_sections);
- $ui = get_userinfo();
- $smarty->assign("sections", $t_sections);
- $display.= $smarty->fetch(get_template_path('dhcpNewSection.tpl', TRUE));
- return($display);
- }
-
- /* Get posts and set class name
- */
- function save_object()
- {
- }
-
- /* Check given class name */
- function check()
- {
- /* Call common method to give check the hook */
- $message= "";
-
- return ($message);
- }
-
-
- /* Return the class name */
- function save()
- {
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpPlugin.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpPlugin.inc
+++ /dev/null
@@ -1,208 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003-2007 Cajus Pollmeier
-
- 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 dhcpPlugin extends plugin
-{
- /* Used attributes */
- var $cn= "";
- var $orig_cn= "";
- var $options= array();
- var $statements= array();
-
- /* Subobjects */
- var $network;
- var $advanced;
-
- /* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
-
- function dhcpPlugin($attrs)
- {
- /* Load statements / options */
- if (is_array($attrs)){
- $this->dn= $attrs['dn'];
- $this->cn= $attrs['cn'][0];
- $this->new= FALSE;
-
- /* Load options */
- if (isset($attrs['dhcpOption'])){
- foreach ($attrs['dhcpOption'] as $opt){
- $idx= preg_replace('/\s.+$/', '', $opt);
- if ($idx == $opt){
- $value= "";
- } else {
- $value= preg_replace('/^[^\s]+\s/', '', $opt);
- }
- $this->options[$idx]= $value;
- }
- }
-
- /* Load statements */
- if (isset($attrs['dhcpStatements'])){
- foreach ($attrs['dhcpStatements'] as $opt){
- $idx= preg_replace('/\s.+$/', '', $opt);
- if ($idx == $opt){
- $value= "";
- } else {
- $value= preg_replace('/^[^\s]+\s/', '', $opt);
- }
- $this->statements[$idx]= $value;
- }
- }
-
- } else {
- /* We keep the parent dn here if it's new */
- $this->dn= $attrs;
- $this->new= TRUE;
- }
-
- /* Load network module */
- $this->network= new dhcpNetwork();
- $this->network->options= $this->options;
- $this->network->statements= $this->statements;
- $this->advanced= new dhcpAdvanced();
- $this->advanced->options= $this->options;
- $this->advanced->statements= $this->statements;
-
- /* Save CN for later reference */
- $this->orig_cn= $this->cn;
- }
-
- function execute()
- {
- return ("");
- }
-
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- /* Strip network objects */
- foreach (array("routers", "domain-name", "subnet-mask", "broadcast-address") as $toberemoved){
- unset($this->options[$toberemoved]);
- }
- foreach (array("filename", "next-server") as $toberemoved){
- unset($this->statements[$toberemoved]);
- }
-
- /* Save sub-objects */
- $this->network->save_object();
- $this->advanced->save_object();
-
- /* Merge arrays for advanced view */
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;;
- }
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- /* Merge arrays for network and advanced view */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->$type + $this->network->$type + $this->advanced->$type;
- }
-
- /* Add cn if we're new */
- if ($this->new){
- $this->dn= "cn=".$this->cn.",".$this->dn;
- } else {
- $this->dn= "cn=".$this->cn.preg_replace('/^cn=[^,]+/', '', $this->dn);
- }
-
- /* Assemble new entry - options */
- $this->attrs['dhcpOption']= array();
- if (isset ($this->options) && count ($this->options)){
- foreach ($this->options as $key => $val){
- $this->attrs['dhcpOption'][]= "$key $val";
- }
- }
-
- /* Assemble new entry - statements */
- $this->attrs['dhcpStatements']= array();
- if (isset ($this->statements) && count ($this->statements)){
- foreach ($this->statements as $key => $val){
- if ($val != ""){
- $this->attrs['dhcpStatements'][]= "$key $val";
- } else {
- $this->attrs['dhcpStatements'][]= "$key";
- }
- }
- }
-
- /* Move dn to the result */
- $this->attrs['dn']= $this->dn;
- $this->attrs['cn']= array($this->cn);
- $this->attrs['objectClass']= $this->objectclasses;
- $this->attrs['MODIFIED']= TRUE;
-
- return ($this->attrs);
- }
-
-
- function removeAttrs($name, $type)
- {
- $new= array();
- foreach ($this->attrs[$type] as $value){
- if (!preg_match("/^$name /", $value)){
- $new[]= $value;
- }
- }
- $this->attrs[$type]= $new;
- }
-
-
- function removeOption($name)
- {
- $this->removeAttrs($name, 'dhcpOption');
- }
-
-
- function removeStatement($name)
- {
- $this->removeAttrs($name, 'dhcpStatement');
- }
-
-
- function fix_options()
- {
- foreach (array('domain-name-servers') as $key){
- unset ($this->options[$key]);
- }
- }
-
-}
-
-?>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpPool.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpPool.inc
+++ /dev/null
@@ -1,191 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003 Cajus Pollmeier
-
- 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 dhcpPool extends dhcpPlugin
-{
- /* Used attributes */
- var $dhcpRange= "";
- var $range_start= "";
- var $range_stop= "";
-
- /* attribute list for save action */
- var $objectclasses= array('top', 'dhcpPool');
-
- function dhcpPool($attrs)
- {
- dhcpPlugin::dhcpPlugin($attrs);
-
- /* Load attributes */
- if (!$this->new){
- $this->dhcpRange= $attrs['dhcpRange'][0];
- list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange);
- }
-
- $this->advanced->setAutoOptions(array("host-name"));
- $this->advanced->setAutoStatements(array("fixed-address"));
- }
-
- function execute()
- {
- $smarty= get_smarty();
- $smarty->assign("cn", $this->cn);
- $smarty->assign("range_start", $this->range_start);
- $smarty->assign("range_stop", $this->range_stop);
-
- /* Show main page */
- $display= $smarty->fetch(get_template_path('dhcp_pool.tpl', TRUE)).$this->network->execute();
-
- /* Merge arrays for advanced view */
- $this->fix_options();
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;;
- }
-
- $display.= $this->advanced->execute();
-
- /* Merge back for removals */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->advanced->$type;
- $this->network->$type= $this->advanced->$type;
- }
-
- /* Add footer */
- $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
- " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
-
- return ($display);
- }
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if (isset($_POST['cn'])){
- $this->cn= validate(get_post('cn'));
- $this->range_start= validate(get_post('range_start'));
- $this->range_stop= validate(get_post('range_stop'));
- }
-
- dhcpPlugin::save_object();
-
- /* Move range to internal variable */
- $this->dhcpRange= $this->range_start." ".$this->range_stop;
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- $cache = $this->parent->dhcpObjectCache;
-
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= _("Required field 'Name' is not filled.");
- }
-
- /* cn already used? */
- if ($this->orig_cn != $this->cn || $this->new){
-
- foreach($cache as $dn => $dummy){
- if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
- $message[]= _("The name for this section is already used!");
- break;
- }
- }
- }
-
- if ($this->dhcpRange == ""){
- $message[]= _("Required field 'Range' is not filled.");
- }
-
- if (!tests::is_ip($this->range_start) || !tests::is_ip($this->range_stop)){
- $message[]= _("Field 'Range' contains invalid IP addresses.");
- }
-
- if(!tests::is_ip_range($this->range_start,$this->range_stop)){
- $message[] = _("Field 'Range' contains invalid IP range.");
- }
-
- /* Check if range is in the network */
- $dn= $this->dn;
- while (preg_match('/,/', $dn)){
- $type= $this->objectType($cache, $dn);
-
- /* Check for subnet */
- if ($type == 'dhcpSubnet'){
- $network= $cache[$dn]['cn'][0];
- $netmask= normalize_netmask($cache[$dn]['dhcpNetMask'][0]);
- if (!tests::is_in_network($network, $netmask, $this->range_start) ||
- !tests::is_in_network($network, $netmask, $this->range_stop)){
- $message[] = _("'Range' is not inside the configured network.");
- }
- }
-
- /* Stop if we've examined the service base object */
- if ($type == 'dhcpService'){
- break;
- }
- $dn= preg_replace('/^[^,]+,/', '', $dn);
- }
-
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
-
- return $message;
- }
-
- /* Save to LDAP */
- function save()
- {
- dhcpPlugin::save();
- $this->attrs['dhcpRange']= array($this->dhcpRange);
-
- return ($this->attrs);
- }
-
-
- function objectType($cache, $dn)
- {
- $type= "";
- $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost",
- "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork");
-
- foreach ($cache[$dn]['objectClass'] as $oc){
- if (in_array($oc, $types)){
- $type= $oc;
- break;
- }
- }
-
- return ($type);
- }
-
-
-}
-
-?>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpService.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpService.inc
+++ /dev/null
@@ -1,181 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003-2007 Cajus Pollmeier
-
- 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 dhcpService extends dhcpPlugin
-{
- /* Used attributes */
- var $dhcpPrimaryDN= "";
- var $orig_dhcpPrimaryDN= "";
- var $ddns_styles= array('none', 'interim', 'ad-hoc');
-
- /* attribute list for save action */
- var $objectclasses= array('top', 'dhcpService');
-
-
- function dhcpService($attrs)
- {
- dhcpPlugin::dhcpPlugin($attrs);
-
- /* Load statements / options */
- if (!$this->new){
- /* Load attributes */
- $this->dhcpPrimaryDN= $attrs['dhcpPrimaryDN'][0];
- } else {
- /* We keep the parent dn here if it's new */
- $this->statements['default-lease-time']= 600;
- $this->statements['max-lease-time']= 1700;
- $this->statements['authoritative']= TRUE;
- $this->statements['ddns-update-style']= 'none';
- }
-
- $this->advanced->setAutoStatements(array("default-lease-time", "max-lease-time", "authoritative", "server-identifier", "ddns-update-style"));
- $this->advanced->setAutoOptions(array("server-name"));
-
- /* Save for later action */
- $this->orig_dhcpPrimaryDN= $this->dhcpPrimaryDN;
- }
-
-
- function execute()
- {
- /* Show main page */
- $smarty= get_smarty();
-
- $smarty->assign('ddns_styles', $this->ddns_styles);
- foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $value){
- if (isset($this->statements[preg_replace('/_/', '-', $value)])){
- $smarty->assign("$value", $this->statements[preg_replace('/_/', '-', $value)]);
- } else {
- $smarty->assign("$value", "");
- }
- }
-
- if (isset($this->statements['authoritative'])){
- $smarty->assign("authoritative", "checked");
- } else {
- $smarty->assign("authoritative", "");
- }
-
- /* Show main page */
- $display= $smarty->fetch(get_template_path('dhcp_service.tpl', TRUE)).$this->network->execute();
-
- /* Merge arrays for advanced view */
- $this->fix_options();
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;;
- }
-
- $display.= $this->advanced->execute();
-
- /* Merge back for removals */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->advanced->$type;
- $this->network->$type= $this->advanced->$type;
- }
-
- /* Add footer */
- $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
- " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
-
-
- return ($display);
-
- }
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- /* No need to save in the first time */
- if (!isset($_POST['ddns_update_style'])){
- return;
- }
-
- /* Save remaining attributes */
- foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $val){
- $tval= preg_replace('/_/', '-', $val);
- if ($_POST[$val] != ""){
- $this->statements[$tval]= validate(get_post($val));
- } else {
- unset ($this->statements[$tval]);
- }
- }
- if (isset($_POST['authoritative'])){
- $this->statements['authoritative']= "";
- } else {
- unset($this->statements['authoritative']);
- }
-
- dhcpPlugin::save_object();
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- if (!tests::is_id($this->statements['default-lease-time'])){
- $message[]= _('Default lease time needs to be numeric.');
- }
- if (!tests::is_id($this->statements['max-lease-time'])){
- $message[]= _('Maximum lease time needs to be numeric.');
- }
- if ($this->statements['default-lease-time'] > $this->statements['max-lease-time']){
- $message[]= _('Default lease time needs to smaller than the maximum lease time.');
- }
-
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
-
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- global $config;
- $this->attrs= array();
-
- /* Get and set server name */
- $ldap= $config->get_ldap_link();
- $ldap->cat($this->dhcpPrimaryDN, array('cn'));
- $res= $ldap->fetch();
- $server_name= $res['cn'][0];
-
- dhcpPlugin::save();
-
- $this->attrs['dhcpPrimaryDN']= array($this->dhcpPrimaryDN);
- $this->removeOption('server-name');
-# $this->attrs['dhcpOption'][]= "server-name $server_name";
-
- return ($this->attrs);
- }
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc
+++ /dev/null
@@ -1,188 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003-2007 Cajus Pollmeier
-
- 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 dhcpSharedNetwork extends dhcpPlugin
-{
- /* attribute list for save action */
- var $objectclasses= array('top', 'dhcpSharedNetwork');
-
- function dhcpSharedNetwork($attrs)
- {
- dhcpPlugin::dhcpPlugin($attrs);
-
- $this->advanced->setAutoStatements(array("server-identifier", "default-lease-time",
- "max-lease-time", "min-lease-time", "authoritative", "deny-unknown-clients",
- "deny-bootp", "deny-booting"));
- }
-
-
- function execute()
- {
- $smarty= get_smarty();
-
- /* Fill template */
- $smarty->assign ("cn", $this->cn);
- foreach (array("server-identifier", "default-lease-time", "max-lease-time", "min-lease-time") as $attr){
- if (isset($this->statements[$attr])){
- $smarty->assign(preg_replace('/-/', '_', $attr), $this->statements[$attr]);
- } else {
- $smarty->assign(preg_replace('/-/', '_', $attr), "");
- }
- }
- if (isset($this->statements["authoritative"])){
- $smarty->assign("authoritative", "checked");
- } else {
- $smarty->assign("authoritative", "");
- }
- if (!isset($this->statements["deny unknown-clients"])){
- $smarty->assign("allow_unknown_state", "checked");
- } else {
- $smarty->assign("allow_unknown_state", "");
- }
- if (!isset($this->statements["deny bootp"])){
- $smarty->assign("allow_bootp_state", "checked");
- } else {
- $smarty->assign("allow_bootp_state", "");
- }
- if (!isset($this->statements["deny booting"])){
- $smarty->assign("allow_booting_state", "checked");
- } else {
- $smarty->assign("allow_booting_state", "");
- }
-
- /* Show main page */
- $display= $smarty->fetch(get_template_path('dhcp_sharedNetwork.tpl', TRUE)).$this->network->execute();
-
- /* Merge arrays for advanced view */
- $this->fix_options();
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;
- }
-
- $display.= $this->advanced->execute();
-
- /* Merge back for removals */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->advanced->$type;
- $this->network->$type= $this->advanced->$type;
- }
-
- /* Add footer */
- $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
- " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
-
-
- return ($display);
- }
-
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if (isset($_POST['cn'])){
- $this->cn= validate(get_post('cn'));
- dhcpPlugin::save_object();
-
- foreach (array("server-identifier", "default-lease-time",
- "max-lease-time", "min-lease-time") as $attr){
- if (isset($_POST[$attr]) && $_POST[$attr] != ""){
- $this->statements[$attr]= get_post($attr);
- } else {
- unset($this->statements[$attr]);
- }
- }
-
- if (isset($_POST["authoritative"])){
- $this->statements["authoritative"]= "";
- } else {
- unset ($this->statements["authoritative"]);
- }
-
- foreach(array("unknown-clients", "bootp", "booting") as $name){
- if (isset($_POST[$name])){
- $this->statements["allow $name"]= "";
- unset($this->statements["deny $name"]);
- } else {
- $this->statements["deny $name"]= "";
- unset($this->statements["allow $name"]);
- }
- }
- }
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- $cache = $this->parent->dhcpObjectCache;
-
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= _("Required field 'Name' is not filled.");
- }
-
- /* Check lease times */
- foreach (array("default-lease-time" => _("Default lease time"),
- "max-lease-time" => _("Max. lease time"),
- "min-lease-time" => _("Min. lease time")) as $key => $val){
- if (isset($this->statements[$key]) && $this->statements[$key] != "" &&
- !tests::is_id($this->statements[$key])){
- $message[]= sprintf(_("The value specified as '%s' is not numeric!"), $val);
- }
- }
-
- /* cn already used? */
- if ($this->orig_cn != $this->cn || $this->new){
-
- foreach($cache as $dn => $dummy){
- if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
- $message[]= _("The name for this host section is already used!");
- break;
- }
- }
- }
-
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
-
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- dhcpPlugin::save();
-
- return ($this->attrs);
- }
-
-}
-
-?>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc
+++ /dev/null
@@ -1,200 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003-2007 Cajus Pollmeier
-
- 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 dhcpSubnet extends dhcpPlugin
-{
- /* Used attributes */
- var $dhcpNetMask= 24;
- var $dhcpRange= "";
- var $range_start= "";
- var $range_stop= "";
- var $use_range= FALSE;
-
- /* attribute list for save action */
- var $objectclasses= array('top', 'dhcpSubnet', 'dhcpOptions');
-
- function dhcpSubnet($attrs)
- {
- dhcpPlugin::dhcpPlugin($attrs);
-
- if (!$this->new){
- /* Load attributes */
- foreach (array("dhcpNetMask", "dhcpRange") as $attr){
- if (isset($attrs[$attr][0])){
- $this->$attr= $attrs[$attr][0];
- }
- }
- if (isset($attrs['dhcpRange']) && count($attrs['dhcpRange'])){
- $this->use_range= TRUE;
- list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange);
- }
- }
-
- $this->dhcpNetMask= normalize_netmask($this->dhcpNetMask);
- }
-
-
- function execute()
- {
- $smarty= get_smarty();
- $smarty->assign("cn", $this->cn);
- $smarty->assign("dhcp_netmask", $this->dhcpNetMask);
-
- /* Prepare range */
- if ($this->use_range){
- $smarty->assign("use_range", "checked");
- $smarty->assign("range_disabled", "");
- } else {
- $smarty->assign("use_range", "");
- $smarty->assign("range_disabled", "disabled");
- }
- $smarty->assign("range_start", $this->range_start);
- $smarty->assign("range_stop", $this->range_stop);
-
- /* Show main page */
- $display= $smarty->fetch(get_template_path('dhcp_subnet.tpl', TRUE)).$this->network->execute();
-
- /* Merge arrays for advanced view */
- $this->fix_options();
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;
- }
-
- $display.= $this->advanced->execute();
-
- /* Merge back for removals */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->advanced->$type;
- $this->network->$type= $this->advanced->$type;
- }
-
- /* Add footer */
- $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
- " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
-
- /* Show main page */
- return $display;
- }
-
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if(isset($_POST['dhcp_subnet_posted'])){
- if (isset($_POST['cn'])){
- $this->cn= validate(get_post('cn'));
- }
- if (isset($_POST['dhcp_netmask'])){
- $this->dhcpNetMask= validate(get_post('dhcp_netmask'));
- }
- if (isset($_POST['use_range'])){
- $this->use_range= TRUE;
- $this->range_start= validate(get_post('range_start'));
- $this->range_stop= validate(get_post('range_stop'));
- } else {
- $this->use_range= FALSE;
- }
-
- /* Move range to internal variable */
- $this->dhcpRange= $this->range_start." ".$this->range_stop;
- dhcpPlugin::save_object();
- }
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- $cache = $this->parent->dhcpObjectCache;
-
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= _("Required field 'Network address' is not filled.");
- }
- if ($this->dhcpNetMask == ""){
- $message[]= _("Required field 'Netmask' is not filled.");
- }
-
- /* cn already used? */
- if ($this->orig_cn != $this->cn || $this->new){
-
- foreach($cache as $dn => $dummy){
- if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
- $message[]= _("The name for this section is already used!");
- break;
- }
- }
- }
-
- /* IP's? */
- foreach(array('dhcpNetMask' => _("Netmask"), 'cn' => _("Network address"), 'range_start' => _("Range"), 'range_stop' => _("Range")) as $attr => $str){
- if ($this->$attr != "" && !tests::is_ip($this->$attr)){
- $message[]= sprintf(_("The field '%s' contains an invalid IP address"), $str);
- }
- }
-
- /* Check ip range */
- if ($this->use_range){
- if(!tests::is_ip_range($this->range_start,$this->range_stop)){
- $message[] = _("Field 'Range' contains invalid IP range.");
- }
-
- /* Check if range is in the network */
- if (!tests::is_in_network($this->cn, $this->dhcpNetMask, $this->range_start) ||
- !tests::is_in_network($this->cn, $this->dhcpNetMask, $this->range_stop)){
- $message[] = _("'Range' is not inside the configured network.");
- }
- }
-
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
-
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- dhcpPlugin::save();
-
- /* Move dn to the result */
- $this->attrs['dhcpNetMask']= array(netmask_to_bits($this->dhcpNetMask));
- if ($this->use_range && !empty($this->dhcpRange)){
- $this->attrs['dhcpRange']= array($this->range_start." ".$this->range_stop);
- } else {
- $this->attrs['dhcpRange']= array();
- }
-
- return ($this->attrs);
- }
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_servDHCP.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_servDHCP.inc
+++ /dev/null
@@ -1,739 +0,0 @@
-<?php
-
-class servdhcp extends goService
-{
- /* attribute list for save action */
- var $attributes= array("dhcpServiceDN");
- var $objectclasses= array("dhcpServer");
- var $conflicts = array("servdhcp");
- var $dhcpServiceDN= "";
-
- /* Section storage */
- var $dhcpSections= array();
- var $dhcpObjectCache= array();
- var $current_object= "";
- var $types= array();
- var $serviceDN= "";
-
- var $quote_option = array("domain-name");
-
- var $orig_dn = "";
-
- var $dhcp_server_list = array("ENTRIES"=> array(),"FOR_LIST"=> array());
- var $take_over_id = -1;
- var $display_warning = TRUE;
-
- function servdhcp (&$config, $dn= NULL, $parent= NULL)
- {
- plugin::plugin ($config, $dn, $parent);
-
- $this->serviceDN = "cn=dhcp,".$dn;
- $this->orig_dn = $dn;
-
- $this->DisplayName = _("DHCP service");
-
- $this->types= array( "dhcpLog" => _("Logging"),
- "dhcpService" => _("Global options"),
- "dhcpClass" => _("Class"),
- "dhcpSubClass" => _("Subclass"),
- "dhcpHost" => _("Host"),
- "dhcpGroup" => _("Group"),
- "dhcpPool" => _("Pool"),
- "dhcpSubnet" => _("Subnet"),
- "dhcpFailOverPeer" => _("Failover peer"),
- "dhcpSharedNetwork" => _("Shared network"));
-
-
- /* Backport: PHP4 compatibility */
- foreach($this->types as $type => $translation){
- $this->types[strtolower($type)] = $translation;
- }
-
- /* Load information about available services */
- $this->reload();
- if (!count($this->dhcpSections)){
- $this->is_account= FALSE;
- $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
- }
- }
-
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $smarty->assign("dns_take_over",FALSE);
- $display= "";
-
-
- /*****************/
- /* Handle Take Over Actions
- /*****************/
-
- /* Give smarty the required informations */
- $smarty->assign("dhcp_server_list", $this->dhcp_server_list['FOR_LIST']);
- $smarty->assign("dhcp_server_list_cnt", count($this->dhcp_server_list['FOR_LIST']));
-
- /* Take over requested, save id */
- if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){
- $id = $_POST['take_over_src'];
- if(isset($this->dhcp_server_list['ENTRIES'][$id])){
- $this->take_over_id = $id;
- }
- }
-
- /* Abort take over action */
- if(isset($_POST['cancel_take_over'])){
- $this->dialog =false;
- $this->take_over_id = -1;
- $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
- }
-
- /* Display informartion about take over that will be started when saving this server
- * and hide default dhcp output
- */
- if($this->take_over_id != -1){
-
- $this->dialog = FALSE;
- $id = $this->take_over_id;
- $smarty->assign("dns_take_over",TRUE);
- $warning = sprintf(_("You are going to migrate the DHCP setup from server '%s'."),
- $this->dhcp_server_list['ENTRIES'][$id]['cn'][0]);
- $warning.= " "._("The migration will be started when you save this system. To cancel this action, use the cancel button below.");
-
- if($this->display_warning){
- print_red($warning);
- $this->display_warning = FALSE;
- }
- return($smarty->fetch(get_template_path('servdhcp.tpl', TRUE)));
- }
-
-
- /*****************/
- /* List handling
- /*****************/
-
- /* Section Creation? */
- if (isset($_POST['create_section']) && isset($_POST['section'])){
- $section= $_POST['section'];
- $tmp = new dhcpNewSectionDialog(NULL);
- if (isset($tmp->sectionMap[$section])){
- $this->dialog= new $section($this->current_object);
- $this->current_object= "";
- } else {
- $this->dialog= FALSE;
- }
- }
-
- /* Cancel section creation? */
- if (isset($_POST['cancel_section']) || isset($_POST['cancel_dhcp'])){
- $this->dialog= FALSE;
- }
-
- /* Save changes */
- if (isset($_POST['save_dhcp'])){
- $this->dialog->save_object();
- $messages= $this->dialog->check();
- if (count($messages)){
- show_errors($messages);
- } else {
- $dn= $this->dialog->dn;
- $class= get_class($this->dialog);
- $type= $this->types[$class];
- if(empty($this->serviceDN)){
- $indent= substr_count(preg_replace("/".$this->dn."/", '', $dn), ",") -1;
- }else{
- $indent= substr_count(preg_replace("/".$this->serviceDN."/", '', $dn), ",");
- }
- $spaces= "";
- for ($i= 0; $i<$indent; $i++){
- $spaces.= " ";
- }
- $data= $this->dialog->save();
- if ($this->current_object == ""){
- /* New object */
- $newsects= array();
- foreach ($this->dhcpSections as $key => $dsc){
- $newsects[$key]= $dsc;
- if ($key == $dn){
- $spaces.= " ";
- $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'";
- }
- }
- $this->dhcpObjectCache[$data['dn']]= $data;
- $this->dhcpSections= $newsects;
- } else {
- if ($dn != $data['dn']){
- /* Old object, new name */
- $this->dhcpObjectCache[$dn]= array();
- $this->dhcpObjectCache[$data['dn']]= $data;
-
- /* If we renamed a section, we've to rename a couple of objects, too */
- foreach ($this->dhcpObjectCache as $key => $dsc){
- if (preg_match("/,$dn$/", $key)){
- $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key);
- $dsc['MODIFIED']= TRUE;
- $this->dhcpObjectCache[$new_dn]= $dsc;
- unset($this->dhcpObjectCache[$key]);
- }
- }
- $newsects= array();
- foreach ($this->dhcpSections as $key => $dsc){
- if ($key == $dn){
- $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'";
- continue;
- }
- if (preg_match("/,$dn$/", $key)){
- $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key);
- $newsects[$new_dn]= $dsc;
- } else {
- $newsects[$key]= $dsc;
- }
- }
- $this->dhcpSections= $newsects;
-
- } else {
- /* Old object, old name */
- $this->dhcpObjectCache[$data['dn']]= $data;
- }
- }
- $this->dialog= FALSE;
- }
- }
-
- /* Remove section? */
- if (isset($_POST['delete_dhcp_confirm'])){
- if ($this->acl_is_removeable()){
- unset($this->dhcpSections[$this->current_object]);
- unset($this->dhcpObjectCache[$this->current_object]);
- $this->dhcpObjectCache[$this->current_object]= array();
- foreach ($this->dhcpSections as $key => $value){
- if (preg_match("/".$this->current_object."$/", $key)){
- unset($this->dhcpSections[$key]);
- unset($this->dhcpObjectCache[$key]);
- $this->dhcpObjectCache[$key]= array();
- }
- }
- } else {
- print_red(_("You're not allowed to remove DHCP sections!"));
- }
- $this->dialog= FALSE;
- }
-
- /* Look for post entries */
- foreach($_POST as $name => $value){
-
- /* Insert new section? */
- if (preg_match('/^insertDhcp_.*_x$/', $name)){
- $dn= base64_decode(preg_replace('/^insertDhcp_([^_]+)_x$/', '\1', $name));
- if (isset($this->dhcpObjectCache[$dn])){
- $this->dialog= new dhcpNewSectionDialog($this->objectType($dn));
- $this->current_object= $dn;
- $this->dialog->acl= $this->acl;
- }
- }
-
- /* Edit section? */
- if (preg_match('/^editDhcp_.*_x$/', $name)){
- $dn= base64_decode(preg_replace('/^editDhcp_([^_]+)_x$/', '\1', $name));
- if (isset($this->dhcpObjectCache[$dn])){
- $section= $this->objectType($dn);
- $this->current_object= $dn;
- $this->dialog= new $section($this->dhcpObjectCache[$dn]);
- }
- }
-
- /* Remove section? */
- if (preg_match('/^delDhcp_.*_x$/', $name)){
- $dn= base64_decode(preg_replace('/^delDhcp_([^_]+)_x$/', '\1', $name));
- if (isset($this->dhcpObjectCache[$dn])){
- $this->current_object= $dn;
- $this->dialog= 1;
- $smarty->assign("warning", sprintf(_("You're about to delete the DHCP section '%s'."), $dn));
- return($smarty->fetch(get_template_path('remove_dhcp.tpl', TRUE)));
- }
- }
-
- }
-
- if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
- $dn = base64_decode($_GET['id']);
- if (isset($this->dhcpObjectCache[$dn])){
- $section= $this->objectType($dn);
- $this->current_object= $dn;
- $this->dialog= new $section($this->dhcpObjectCache[$dn]);
- }
- }
-
-
- if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
- $dn = base64_decode($_GET['id']);
- if (isset($this->dhcpObjectCache[$dn])){
- $section= $this->objectType($dn);
- $this->current_object= $dn;
- $this->dialog= new $section($this->dhcpObjectCache[$dn]);
- }
- }
-
-
- /* Do we need to flip is_account state? */
- if (isset($_POST['modify_state'])){
- $this->is_account= !$this->is_account;
- }
-
- /* Show tab dialog headers */
- if ($this->is_account){
-# $display= $this->show_header(_("Remove DHCP service"),
-# _("This server has DHCP features enabled. You can disable them by clicking below."));
-
- if (!count($this->dhcpObjectCache)){
- $attrs= array();
- $attrs['dn']= 'cn=dhcp,'.$this->dn;
- $attrs['cn']= array('dhcp');
- $attrs['objectClass']= array('top', 'dhcpService');
- $attrs['dhcpPrimaryDN']= array($this->dn);
- $attrs['dhcpStatements']= array("default-lease-time 600",
- "max-lease-time 1200",
- "authoritative",
- "ddns-update-style none");
- $attrs['MODIFIED']= TRUE;
- $this->dhcpSections['cn=dhcp,'.$this->dn]= _("Global options");
- $this->dhcpObjectCache['cn=dhcp,'.$this->dn]= $attrs;
- }
-
- } else {
-# $display= $this->show_header(_("Add DHCP service"),
-
-# _("This server has DHCP features disabled. You can enable them by clicking below."));
- return ($display);
- }
-
-
- /* Show dialog
- */
- if(isset($this->dialog) && is_object($this->dialog)){
- $this->dialog->save_object();
- $this->dialog->parent = $this;
- return($this->dialog->execute());
- }
-
- /* Create Listbox with existing Zones
- */
- $DhcpList = new divSelectBox("dhcpSections");
- $DhcpList->SetHeight(400);
-
- /* Add entries to divlist
- */
- $editImgIns = "<input type='image' src='images/list_new.png' name='insertDhcp_%s' title='"._("Insert new DHCP section")."'>".
- "<input type='image' src='images/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>".
- "<input type='image' src='images/edittrash.png' name='delDhcp_%s' title='"._("Remove DHCP section")."'>";
- $editImgInsNoDel = "<input type='image' src='images/list_new.png' name='insertDhcp_%s' title='"._("Insert new DHCP section")."'>".
- "<input type='image' src='images/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>";
- $editImg = "<input type='image' src='images/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>".
- "<input type='image' src='images/edittrash.png' name='delDhcp_%s' title='"._("Remove DHCP section")."'>";
-
- $tmp = new dhcpNewSectionDialog(NULL);
- foreach($this->dhcpSections as $section => $values ){
-
- $values = "<a href='?plug=".$_GET['plug']."&act=edit&id=".base64_encode($section)."'>".$values."</a>";
-
- if (count($tmp->sectionMap[$this->objectType($section)])){
- if ($this->objectType($section) == "dhcpService"){
- $DhcpList->AddEntry(array(
- array("string" => $values),
- array("string" => str_replace("%s",base64_encode($section),$editImgInsNoDel), "attach" => "style='text-align:right;'")
- ));
- } else {
- $DhcpList->AddEntry(array(
- array("string" => $values),
- array("string" => str_replace("%s",base64_encode($section),$editImgIns), "attach" => "style='text-align:right;'")
- ));
- }
- } else {
- $DhcpList->AddEntry(array(
- array("string" => $values),
- array("string" => str_replace("%s",base64_encode($section),$editImg), "attach" => "style='text-align:right;'")
- ));
- }
- }
-
- /* Display tempalte */
- $smarty->assign("DhcpList",$DhcpList->DrawList());
- $display.= $smarty->fetch(get_template_path('servdhcp.tpl', TRUE));
- return($display);
- }
-
-
- function remove_from_parent()
- {
- /* Cancel if there's nothing to do here */
- if (!$this->initially_was_account){
- return;
- }
-
- /* Remove subtrees */
- $ldap= $this->config->get_ldap_link();
- foreach ($this->dhcpObjectCache as $dn => $content){
- if ($this->objectType($dn) == 'dhcpService'){
- $ldap->rmdir_recursive($dn);
- show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed"));
- }
- }
-
- /* Remove from self */
- $ldap= $this->config->get_ldap_link();
-
- /* Remove and write to LDAP */
- plugin::remove_from_parent();
-
- @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save");
- $ldap->cd($this->dn);
- $this->cleanup();
- $ldap->modify ($this->attrs);
-
- show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed"));
-
- /* Optionally execute a command after we're done */
- $this->handle_post_events("remove");
- }
-
-
- /* Save data to object */
- function save_object()
- {
- plugin::save_object();
- }
-
-
- /* Check supplied data */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- return ($message);
- }
-
-
- /* Save to LDAP */
- function save()
- {
- /* Take over handling
- * - Load servdhcp class and dhcpObjectCache for the source dhcp setup.
- * - Assign dhcpObjectCache to this configuration.
- * - Save this setup and remove source setup from ldap.
- */
- if($this->take_over_id != -1){
- $id = $this->take_over_id;
- $src = preg_replace("/cn=dhcp,/","",$this->dhcp_server_list['ENTRIES'][$id]['dn']);
- $tmp = new servdhcp ($this->config, $src);
- $this->orig_dn = $src;
- $this->dhcpObjectCache = $tmp->dhcpObjectCache;
- }
-
- /* Save dhcp setttings */
- $ldap= $this->config->get_ldap_link();
- foreach ($this->dhcpObjectCache as $dn => $data){
-
- if($this->dn != $this->orig_dn){
- $dn = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$dn);
- }
-
- /* Remove entry? */
- if (count($data) == 0){
- /* Check if exists, then remove... */
- if($ldap->cat($dn)){
- $ldap->rmdir_recursive($dn);
- show_ldap_error($ldap->get_error(), _("Can't remove DHCP object!"));
- }
- continue;
- }
-
- /* Opdate dhcp option 'server-name' to actual server name */
- if($this->dn != $this->orig_dn){
- $fixed = FALSE;
- foreach(array("dhcpHost","dhcpSubnet","dhcpGroup","dhcpSharedNetwork") as $object){
- if(in_array($object,$data['objectClass']) && isset($data['dhcpOption'])){
- foreach($data['dhcpOption'] as $key => $option){
- if(preg_match("/^server-name /",$option)){
- $data['dhcpOption'][$key] = "server-name ".$this->cn;
- $data['MODIFIED'] = TRUE;
- break;
- }
- }
- }
-
- /* Skip next loops if entry is updated */
- if($fixed){
- break;
- }
- }
- }
-
- /* Modify existing entry? */
- if (isset($data['MODIFIED']) || $this->orig_dn != $this->dn){
-
- if($ldap->cat($dn)){
- $modify= TRUE;
- } else {
- $modify= FALSE;
- }
-
- /* Build new entry */
- $attrs= array();
- foreach ($data as $attribute => $values){
- if ($attribute == "MODIFIED" || $attribute == "dn"){
- continue;
- }
-
- if(in_array($attribute,array("dhcpPrimaryDN","dhcpSecondaryDN","dhcpServerDN","dhcpFailOverPeerDN"))){
- foreach($values as $v_key => $value){
- $values[$v_key] = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$value);
- }
- }
-
- if (count($values)){
-
- if($attribute == "dhcpOption"){
- foreach($values as $key => $value){
- $option_name = trim(preg_replace("/[^ ]*$/","",$value));
- $option_value= trim(preg_replace("/^[^ ]*/","",$value));
- if(in_array($option_name,$this->quote_option)){
- $values[$key] = $option_name." \"".$option_value."\"";
- }
- }
- }
- if (count($values) == 1){
- $attrs[$attribute]= $values[0];
- } else {
- $attrs[$attribute]= $values;
- }
- } else {
- if ($modify){
- $attrs[$attribute]= array();
- }
- }
- }
-
- $ldap->cd($dn);
- if ($modify){
- $ldap->modify($attrs);
- show_ldap_error($ldap->get_error(), _("Can't save DHCP object!"));
-
- /* Optionally execute a command after we're done */
- $this->handle_post_events("modify");
- } else {
- $ldap->add($attrs);
- show_ldap_error($ldap->get_error(), _("Can't save DHCP object!"));
-
- /* Optionally execute a command after we're done */
- $this->handle_post_events("create");
- }
- }
- }
-
- $this->dhcpServiceDN= $this->serviceDN;
- if($this->dn != $this->orig_dn){
- $this->dhcpServiceDN= preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$this->dhcpServiceDN);
- }
-
- /* Replace 'new' dn */
- if(preg_match("/new$/",$this->dhcpServiceDN)){
- $this->dhcpServiceDN = preg_replace("/new$/",$this->dn,$this->dhcpServiceDN);
- }
-
- plugin::save();
-
- /* Save data to LDAP */
- $ldap->cd($this->dn);
- $this->cleanup();
- $ldap->modify ($this->attrs);
-
- show_ldap_error($ldap->get_error(), _("Saving DHCP service failed"));
-
- /* Optionally execute a command after we're done */
- if ($this->initially_was_account == $this->is_account){
- if ($this->is_modified){
- $this->handle_post_events("modify");
- }
- } else {
- $this->handle_post_events("add");
- }
-
- /* Take over handling
- * - Remove old dhcp config from source server
- */
- if($this->take_over_id != -1){
- $id = $this->take_over_id;
- $src = $this->dhcp_server_list['ENTRIES'][$id]['dn'];
- $tmp = new servdhcp ($this->config, $src);
- $tmp->remove_from_parent();
- }
- }
-
-
- function reload()
- {
- /* Init LDAP and load list */
- $ldap= $this->config->get_ldap_link();
- $ui= get_userinfo();
- $me= $this->dn;
-
- $filter = "(&(objectClass=dhcpService)(|(dhcpPrimaryDN=$me)(dhcpSecondaryDN=$me)(dhcpServerDN=$me)(dhcpFailOverPeerDN=$me)))";
-
- $list= get_list($filter, array("server"), $this->config->current['BASE'], array("cn"),GL_SIZELIMIT | GL_SUBSEARCH);
- $final= array();
-
- foreach ($list as $value){
-
- /* Set header */
- $sortpart= split(",", $value['dn']);
- $sortpart= array_reverse($sortpart);
- $tmp= implode(",", $sortpart);
-
- $final[$value['dn']]= $tmp."!"._("Global options");
-
- /* Read all sub entries to place here */
- $ldap->cd($value['dn']);
- $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpLog)(objectClass=dhcpClass)(objectClass=dhcpSubClass)(objectClass=dhcpHost)(objectClass=dhcpGroup)(objectClass=dhcpPool)(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork)(objectClass=dhcpOptions)(objectClass=dhcpTSigKey)(objectClass=dhcpDnsZone)(objectClass=dhcpFailOverPeer))", array());
- $this->serviceDN= $value['dn'];
-
- while ($attrs= $ldap->fetch()){
- $sattrs= array();
- for ($i= 0; $i<$attrs['count']; $i++){
- $sattrs[$attrs[$i]]= $attrs[$attrs[$i]];
- unset($sattrs[$attrs[$i]]['count']);
- }
- $sattrs['dn']= $ldap->getDN();
-
- foreach($sattrs as $name => $values){
- if($name == "dhcpOption"){
- foreach($values as $key => $value){
- $value_name = trim(preg_replace("/[^ ]*$/","",$value));
- $value_value= trim(preg_replace("/^[^ ]*/","",$value));
- if(in_array($value_name,$this->quote_option)){
- $value_value = preg_replace("/^\"/","",$value_value);
- $value_value = preg_replace("/\"$/","",$value_value);
- $sattrs[$name][$key] = $value_name." ".$value_value;
- }
- }
- }
- }
-
- $this->dhcpObjectCache[$ldap->getDN()]= $sattrs;
- $tmp= preg_replace("/".$this->serviceDN."/", "", $ldap->getDN());
- $indent= substr_count($tmp, ",");
- $spaces= "";
- for ($i= 0; $i<$indent; $i++){
- $spaces.= " ";
- }
-
- foreach ($this->types as $key => $val){
- if (in_array("$key", $attrs['objectClass'])){
- $type= $val;
- break;
- }
- }
-
- /* Prepare for sorting... */
- $sortpart= split(",", $ldap->getDN());
- $sortpart= array_reverse($sortpart);
- $tmp= implode(",", $sortpart);
- $final[$ldap->getDN()]= $tmp."!".$spaces.$type." '".$attrs['cn'][0]."'";
- }
- }
-
- /* Sort it... */
- natsort($final);
- $this->dhcpSections= array();
- foreach ($final as $key => $val){
- $this->dhcpSections[$key]= preg_replace('/^[^!]+!(.*)$/', '\\1', $val);
- }
-
- }
-
-
- function objectType($dn)
- {
- $type= "";
- $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost",
- "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork");
-
- foreach ($this->dhcpObjectCache[$dn]['objectClass'] as $oc){
- if (in_array($oc, $types)){
- $type= $oc;
- break;
- }
- }
-
- /* That should not happen... */
- if ($type == ""){
- print_red(_("DHCP configuration set is unknown. Please contact your system administrator."));
- }
-
- return ($type);
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("DHCP service"),
- "plDescription" => _("DHCP service")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 84,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
-
- )
- ));
- }
-
-
- function take_over_service()
- {
-
- }
-
-
- function get_list_of_dhcp_servers()
- {
- $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array());
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(&(objectClass=goServer)(dhcpServiceDN=*))",array("dn","cn","dhcpServiceDN"));
- while($attrs = $ldap->fetch()){
-
- /* Skip own config */
- if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){
- continue;
- }
-
- $ret['ENTRIES'][] = $attrs;
- }
- foreach($ret['ENTRIES'] as $key => $data){
- $ret['FOR_LIST'][$key] = $data['cn'][0];
- }
- return($ret);
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("DHCP service");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcpNewSection.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcpNewSection.tpl
+++ /dev/null
@@ -1,25 +0,0 @@
-<div style="font-size: 18px;">
- {t}Create new DHCP section{/t}
-</div>
-<br>
-<p class="seperator">
-<b>{t}Please choose one of the following DHCP section types.{/t}</b>
-</p>
-<br>
-{t}Section{/t}
-<select size="1" id="section" name="section" title="{t}Choose section type to create{/t}">
- {html_options options=$sections}
-</select>
-
-<p class="plugbottom">
- <input type=submit name="create_section" value="{t}Create{/t}">
-
- <input type=submit name="cancel_section" value="{t}Cancel{/t}">
-</p>
-
-<!-- Place cursor -->
-<script language="JavaScript" type="text/javascript">
- <!--
- focus_field('section');
- -->
-</script>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_advanced.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_advanced.tpl
+++ /dev/null
@@ -1,46 +0,0 @@
-{* GOsa dhcp sharedNetwork - smarty template *}
-
-<p class='seperator'></p>
-<br>
-
-{if $show_advanced}
-
-<input type='submit' name='hide_advanced' value='{t}Hide advanced settings{/t}'>
-
-<table width="100%">
- <tr>
-
- <td width="50%">
- <br>
- <b>{t}DHCP statements{/t}</b>
- <br>
- <select name='dhcpstatements' style="width:100%;" size="14">
- {html_options values=$dhcpstatements output=$dhcpstatements}
- </select>
- <br>
- <input type='text' name='addstatement' size='25' maxlength='80'>
- <input type='submit' name='add_statement' value='{t}Add{/t}'>
- <input type='submit' name='delete_statement' value='{t}Delete{/t}'>
- </td>
-
- <td>
- <br>
- <b>{t}DHCP options{/t}</b>
- <br>
- <select name='dhcpoptions' style="width:100%;" size="14">
- {html_options values=$dhcpoptions output=$dhcpoptions}
- </select>
- <br>
- <input type='text' name='addoption' size='25' maxlength='80'>
- <input type='submit' name='add_option' value='{t}Add{/t}'>
- <input type='submit' name='delete_option' value='{t}Delete{/t}'>
- </td>
- </tr>
-</table>
-
-{else}
-
-<input type='submit' name='show_advanced' value='{t}Show advanced settings{/t}'>
-
-{/if}
-<p class='seperator'> </p>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_group.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_group.tpl
+++ /dev/null
@@ -1,22 +0,0 @@
-{* GOsa dhcp sharedNetwork - smarty template *}
-<p><b>{t}Generic{/t}</b></p>
-<table>
- <tr>
- <td>
- {t}Name{/t}{$must}
- </td>
- <td>
- <input id='cn' type='text' name='cn' size='25' maxlength='80' value='{$cn}'
- title='{t}Name of group{/t}'>
- </td>
- </tr>
-</table>
-
-<p class="seperator"> </p>
-
-<!-- Place cursor in correct field -->
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('cn');
- -->
-</script>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_host.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_host.tpl
+++ /dev/null
@@ -1,52 +0,0 @@
-{* GOsa dhcp host - smarty template *}
-<p><b>{t}Generic{/t}</b></p>
-<table width="100%">
- <tr>
- <td width="50%" style="vertical-align:top">
- <table>
- <tr>
- <td>{t}Name{/t}{$must}</td>
- <td>
- <input {if $realGosaHost} disabled {/if} id='cn' type='text' name='cn' size='25' maxlength='80' value='{$cn}'
- title='{t}Name of host{/t}'>
- </td>
- </tr>
- <tr>
- <td>{t}Fixed address{/t}</td>
- <td>
- <input {if $realGosaHost} disabled {/if}
- type='text' name='fixedaddr' size='25' maxlength='80' value='{$fixedaddr}'
- title='{t}Use hostname or IP-address to assign fixed address{/t}'>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table>
- <tr>
- <td>{t}Hardware type{/t}</td>
- <td>
- <select name='hwtype' {if $realGosaHost} disabled {/if} >
- {html_options options=$hwtypes selected=$hwtype}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Hardware address{/t}{$must}</td>
- <td>
- <input {if $realGosaHost} disabled {/if} type='text' name='dhcpHWAddress' size='20' maxlength='18' value='{$dhcpHWAddress}'>
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-<input type='hidden' name='dhcp_host_posted' value='1'>
-<p class="seperator"></p>
-
-<!-- Place cursor in correct field -->
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('cn');
- -->
-</script>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_network.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_network.tpl
+++ /dev/null
@@ -1,90 +0,0 @@
-{* GOsa dhcp sharedNetwork - smarty template *}
-<table width="100%">
- <tr>
- <td width="50%" style="vertical-align:top">
- <p><b>{t}Network configuration{/t}</b></p>
- <table>
- <tr>
- <td>{t}Router{/t}</td>
- <td>
- <input id='routers' type='text' name='routers' size='25' maxlength='80' value='{$routers}'
- title='{t}Enter name or IP address of router to be used in this section{/t}'>
- </td>
- </tr>
- <tr>
- <td>{t}Netmask{/t}</td>
- <td>
- <input type='text' name='subnet_mask' size='18' maxlength='15' value='{$subnet_mask}'>
- </td>
- </tr>
- <tr>
- <td>{t}Broadcast{/t}</td>
- <td>
- <input type='text' name='broadcast_address' size='18' maxlength='15' value='{$broadcast_address}'>
- </td>
- </tr>
- </table>
- <br>
- <br>
- <p><b>{t}Bootup{/t}</b></p>
- <table>
- <tr>
- <td>{t}Filename{/t}</td>
- <td>
- <input type='text' name='filename' size='25' maxlength='80' value='{$filename}'
- title='{t}Enter name of file that will be loaded via tftp after client has started{/t}'>
- </td>
- </tr>
- <tr>
- <td>{t}Next server{/t}</td>
- <td>
- <input type='text' name='nextserver' size='25' maxlength='80' value='{$nextserver}'
- title='{t}Enter name of server to retrieve bootimages from{/t}'>
- </td>
- </tr>
- </table>
-
- </td>
- <td style="vertical-align:top">
- <p><b>{t}Domain Name Service{/t}</b></p>
- <table>
- <tr>
- <td>{t}Domain{/t}</td>
- <td>
- <input type='text' name='domain' size='25' maxlength='80' value='{$domain}'
- title='{t}Name of domain{/t}'>
- </td>
- </tr>
- <tr>
- <td colspan=2>
- <br>
- {t}DNS server{/t}<br>
- <select name='dnsserver' title='{t}List of DNS servers to be propagated{/t}' style="width:350px;" size="4">
- {html_options options=$dnsservers}
- </select>
- <br>
- <input type='text' name='addserver' size='25' maxlength='80' title='{t}DNS server do be added{/t}'>
- <input type='submit' name='add_dns' value='{t}Add{/t}' title='{t}Click here add the selected server to the list{/t}'>
- <input type='submit' name='delete_dns' value='{t}Delete{/t}' title='{t}Click here remove the selected servers from the list{/t}'>
- </td>
- </tr>
- <tr>
- <td colspan=2>
- <p><b>{t}Domain Name Service options{/t}</b></p>
- <input type=checkbox name="autohost" value="1" {$autohost}>{t}Assign hostnames found via reverse mapping{/t}
- <br>
- <input type=checkbox name="autohostdecl" value="1" {$autohostdecl}>{t}Assign hostnames from host declarations{/t}
- </td>
- </tr>
- </table>
-
- </td>
- </tr>
-</table>
-<!-- Place cursor in correct field -->
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('cn','routers');
- -->
-</script>
-
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_pool.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_pool.tpl
+++ /dev/null
@@ -1,26 +0,0 @@
-{* GOsa dhcp sharedNetwork - smarty template *}
-<p><b>{t}Generic{/t}</b></p>
-<table width="100%">
- <tr>
- <td width="50%">
- {t}Name{/t}{$must}
- <input id='cn' type='text' name='cn' size='25' maxlength='80' value='{$cn}'
- title='{t}Name of pool{/t}'>
- </td>
- <td>
- {t}Range{/t}{$must}
- <input type='text' name='range_start' size='25' maxlength='30' value='{$range_start}'>
- -
- <input type='text' name='range_stop' size='25' maxlength='30' value='{$range_stop}'>
- </td>
- </tr>
-</table>
-
-<p class="seperator"> </p>
-
-<!-- Place cursor in correct field -->
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- document.mainform.cn.focus();
- -->
-</script>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_service.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_service.tpl
+++ /dev/null
@@ -1,43 +0,0 @@
-<p><b>{t}Generic{/t}</b></p>
-
-<table width="100%">
- <tr>
- <td width="50%">
- <input id='authoritative' type=checkbox name="authoritative" value="1" {$authoritative}> {t}Authoritative service{/t}<br>
- <br>
- {t}Dynamic DNS update{/t}
- <select name='ddns_update_style' title='{t}Dynamic DNS update style{/t}' size="1">
- {html_options values=$ddns_styles output=$ddns_styles selected=$ddns_update_style}
- </select>
- </td>
-
- <td style='vertical-align:top'>
-
- <table>
- <tr>
- <td>{t}Default lease time (s){/t}</td>
- <td>
- <input type='text' name='default_lease_time' size='25' maxlength='80' value='{$default_lease_time}' title='{t}Enter default lease time in seconds.{/t}'>
- </td>
- </tr>
- <tr>
- <td>{t}Maximum lease time (s){/t}</td>
- <td>
- <input type='text' name='max_lease_time' size='25' maxlength='80' value='{$max_lease_time}' title='{t}Enter maximum lease time in seconds.{/t}'>
- </td>
- </tr>
- </table>
-
- </td>
-
- </tr>
-</table>
-
-<p class="seperator"></p>
-
-<!-- Place cursor in correct field -->
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('authoritative');
- -->
-</script>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl
+++ /dev/null
@@ -1,107 +0,0 @@
-{* GOsa dhcp sharedNetwork - smarty template *}
-<p><b>{t}Generic{/t}</b></p>
-<table width="100%" border="0">
- <tr>
-
- <td width="50%">
-
- <table>
- <tr>
- <td>{t}Name{/t}{$must}</td>
- <td>
- <input id='cn' type='text' name='cn' size='25' maxlength='80' value='{$cn}' title='{t}Name for shared network{/t}'>
- </td>
- </tr>
- <tr>
- <td>{t}Server identifier{/t}</td>
- <td>
- <input type='text' name='server-identifier' size='25' maxlength='80' value='{$server_identifier}'
- title='{t}Propagated server identifier for this shared network{/t}'>
- </td>
- </tr>
- </table>
-
- </td>
-
- <td style="vertical-align:top;">
- <table>
- <tr>
- <td>
- <input type=checkbox name="authoritative" value="1" {$authoritative}
- title="{t}Select if this server is authoritative for this shared network{/t}">{t}Authoritative server{/t}
- </td>
- </tr>
- </table>
- </td>
-
- </tr>
-</table>
-
-<p class="seperator"> </p>
-
-<table width="100%">
- <tr>
- <td width="50%">
-
- <p><b>{t}Leases{/t}</b></p>
- <table>
- <tr>
- <td>{t}Default lease time{/t}</td>
- <td>
- <input type='text' name='default-lease-time' size='10' maxlength='25' value='{$default_lease_time}'
- title='{t}Default lease time{/t}'> {t}seconds{/t}
- </td>
- </tr>
- <tr>
- <td>{t}Max. lease time{/t}</td>
- <td>
- <input type='text' name='max-lease-time' size='10' maxlength='25' value='{$max_lease_time}'
- title='{t}Maximum lease time{/t}'> {t}seconds{/t}
- </td>
- </tr>
- <tr>
- <td>{t}Min. lease time{/t}</td>
- <td>
- <input type='text' name='min-lease-time' size='10' maxlength='25' value='{$min_lease_time}'
- title='{t}Minimum lease time{/t}'> {t}seconds{/t}
- </td>
- </tr>
- </table>
-
- </td>
-
- <td style="vertical-align:top">
- <p><b>{t}Access control{/t}</b></p>
- <table>
- <tr>
- <td>
- <input type=checkbox name="unknown-clients" value="1" {$allow_unknown_state}
- title="{t}Select if unknown clients should get dynamic IP addresses{/t}">{t}Allow unknown clients{/t}
- </td>
- </tr>
- <tr>
- <td>
- <input type=checkbox name="bootp" value="1" {$allow_bootp_state}
- title="{t}Select if bootp clients should get dynamic IP addresses{/t}">{t}Allow bootp clients{/t}
- </td>
- </tr>
- <tr>
- <td>
- <input type=checkbox name="booting" value="1" {$allow_booting_state}
- title="{t}Select if clients are allowed to boot using this DHCP server{/t}">{t}Allow booting{/t}
- </td>
- </tr>
- </table>
- </td>
-
- </tr>
-</table>
-
-<p class="seperator"> </p>
-
-<!-- Place cursor in correct field -->
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- document.mainform.cn.focus();
- -->
-</script>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_subnet.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_subnet.tpl
+++ /dev/null
@@ -1,41 +0,0 @@
-{* GOsa dhcp subnet - smarty template *}
-<p><b>{t}Generic{/t}</b></p>
-<table width="100%">
- <tr>
- <td width="50%">
- <table>
- <tr>
- <td>{t}Network address{/t}{$must}</td>
- <td><input id='cn' type='text' name='cn' size='25' maxlength='80' value='{$cn}'></td>
- </tr>
- <tr>
- <td>{t}Netmask{/t}{$must}</td>
- <td><input type='text' name='dhcp_netmask' size='25' maxlength='80' value='{$dhcp_netmask}'></tr>
- </table>
- </td>
- <td style='vertical-align:top'>
- <table>
- <tr>
- <td><input type="checkbox" name="use_range" value="1" onChange="changeState('range_start');changeState('range_stop');" {$use_range}></td>
- <td>{t}Range for dynamic address assignment{/t}</td>
- </tr>
- <tr>
- <td> </td>
- <td><input type='text' id='range_start' name='range_start' size='25' maxlength='80' value='{$range_start}' {$range_disabled}>
- <b>-</b>
- <input type='text' id='range_stop' name='range_stop' size='25' maxlength='80' value='{$range_stop}' {$range_disabled}>
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-<input type='hidden' name='dhcp_subnet_posted' value='1'>
-<p class="seperator"></p>
-
-<!-- Place cursor in correct field -->
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('cn');
- -->
-</script>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/remove_dhcp.tpl b/gosa-core/plugins/admin/systems/services/dhcp/remove_dhcp.tpl
+++ /dev/null
@@ -1,17 +0,0 @@
-<div style="font-size:18px;">
-<img alt="" src="images/button_cancel.png" align=top> {t}Warning{/t}
-</div>
-<p>
- {$warning}
- {t}This includes 'all' DHCP subsections that are located within this section. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
-</p>
-
-<p>
- {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t}
-</p>
-
-<p class="plugbottom">
- <input type=submit name="delete_dhcp_confirm" value="{t}Delete{/t}">
-
- <input type=submit name="cancel_section" value="{t}Cancel{/t}">
-</p>
diff --git a/gosa-core/plugins/admin/systems/services/dhcp/servdhcp.tpl b/gosa-core/plugins/admin/systems/services/dhcp/servdhcp.tpl
+++ /dev/null
@@ -1,35 +0,0 @@
-{if $dns_take_over}
-<table summary="" width="100%">
- <tr>
- <td style="width:100%;vertical-align:top;">
- <h2>{t}DHCP take over will take place when saving this entry. Choose 'Cancel' to abort.{/t}</h2>
- </td>
- </tr>
-</table>
-{else}
-<table summary="" width="100%">
-{if $dhcp_server_list_cnt}
-<tr>
- <td style="width:100%;vertical-align:top;">
- <b>{t}Take over dhcp configuration from following server{/t}</b>
- <select name='take_over_src'>
- {html_options options=$dhcp_server_list}
- </select>
- <input type="submit" name="take_over" value="{t}Apply{/t}">
- </td>
-</tr>
-{/if}
-<tr>
- <td style="width:100%;vertical-align:top;">
- <h2>{t}DHCP sections{/t}</h2>
- {$DhcpList}
- </td>
-</tr>
-</table>
-{/if}
-<p class='seperator'> </p>
-<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
- <input type='submit' name='SaveService' value='{t}Save{/t}'>
-
- <input type='submit' name='CancelService' value='{t}Cancel{/t}'>
-</div
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpAdvanced.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpAdvanced.inc
--- /dev/null
@@ -0,0 +1,146 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003 Cajus Pollmeier
+
+ 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 dhcpAdvanced extends plugin
+{
+ /* Used attributes */
+ var $options= array();
+ var $statements= array();
+ var $show_advanced= FALSE;
+ var $autoStatements= array();
+ var $autoOptions= array();
+
+ /* attribute list for save action */
+ var $attributes= array();
+ var $objectclasses= array();
+
+ function dhcpAdvanced()
+ {
+ /* This is always an account */
+ $this->is_account= TRUE;
+ $this->setAutoStatements();
+ $this->setAutoOptions();
+ }
+
+ function execute()
+ {
+ /* Check for interaction */
+ if (isset($_POST['add_statement']) && $_POST['addstatement'] != ""){
+ $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addstatement'));
+ $val= preg_replace("/^$key\s*/", '', get_post('addstatement'));
+ $this->statements[$key]= $val;
+ }
+ if (isset($_POST['delete_statement']) && isset($_POST['dhcpstatements'])){
+ $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpstatements'));
+ if (in_array($key, $this->autoStatements)){
+ print_red(_("Can't delete automatic statements. Please use the fields above."));
+ } else {
+ unset($this->statements[$key]);
+ }
+ }
+ if (isset($_POST['add_option']) && $_POST['addoption'] != ""){
+ $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addoption'));
+ $val= preg_replace("/^$key\s*/", '', get_post('addoption'));
+ $this->options[$key]= $val;
+ }
+ if (isset($_POST['delete_option']) && isset($_POST['dhcpoptions'])){
+ $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpoptions'));
+ if (in_array($key, $this->autoOptions)){
+ print_red(_("Can't delete automatic options. Please use the fields above."));
+ } else {
+ unset($this->options[$key]);
+ }
+ }
+
+ $smarty= get_smarty();
+
+ /* Assign arrays */
+ $statements= array();
+ foreach ($this->statements as $key => $val){
+ if (in_array($key, $this->autoStatements)){
+ $statements[$key]= "$key $val ["._("automatic")."]";
+ } else {
+ $statements[$key]= "$key $val";
+ }
+ }
+ $smarty->assign("dhcpstatements", $statements);
+ $options= array();
+ foreach ($this->options as $key => $val){
+ if (in_array($key, $this->autoOptions)){
+ $options[$key]= "$key $val ["._("automatic")."]";
+ } else {
+ $options[$key]= "$key $val";
+ }
+ }
+ $smarty->assign("dhcpoptions", $options);
+
+ /* Show main page */
+ $smarty->assign("show_advanced", $this->show_advanced);
+ return ($smarty->fetch (get_template_path('dhcp_advanced.tpl', TRUE,dirname(__FILE__))));
+ }
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if (isset($_POST['show_advanced'])){
+ $this->show_advanced= TRUE;
+ }
+ if (isset($_POST['hide_advanced'])){
+ $this->show_advanced= FALSE;
+ }
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ /* Nothing to check here */
+ $message= array();
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ }
+
+
+ function setAutoOptions($addopt= array())
+ {
+ $options= array("routers", "domain-name", "domain-name-servers", "subnet-mask", "broadcast-address");
+ $this->autoOptions= array_merge($options, $addopt);
+ }
+
+
+ function setAutoStatements($addstat= array())
+ {
+ $statements= array("filename", "next-server", "get-lease-hostnames", "use-host-decl-names");
+ $this->autoStatements= array_merge($statements, $addstat);
+ }
+
+}
+
+?>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpGroup.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpGroup.inc
--- /dev/null
@@ -0,0 +1,126 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003 Cajus Pollmeier
+
+ 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 dhcpGroup extends dhcpPlugin
+{
+ /* attribute list for save action */
+ var $objectclasses= array('top', 'dhcpGroup', 'dhcpOptions');
+
+ function dhcpGroup(&$attrs)
+ {
+ /* Load statements / options */
+ dhcpPlugin::dhcpPlugin($attrs);
+ }
+
+ function execute()
+ {
+ $smarty= get_smarty();
+ $smarty->assign("cn", $this->cn);
+
+ /* Show main page */
+ $display= $smarty->fetch (get_template_path('dhcp_group.tpl', TRUE)).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ $this->fix_options();
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;
+ }
+
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
+ " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
+
+
+ return ($display);
+ }
+
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ /* Save cn */
+ if (isset($_POST['cn'])){
+ $this->cn= validate(get_post('cn'));
+ }
+
+ /* Handle global saving */
+ dhcpPlugin::save_object();
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ $cache = $this->parent->dhcpObjectCache;
+
+ /* All required fields are set? */
+ if ($this->cn == ""){
+ $message[]= _("Required field 'Name' is not filled.");
+ }
+ if (!preg_match('/^[a-z0-9_-]*$/i', $this->cn)){
+ $message[]= _("Field 'Name' contains illegal characters.");
+ }
+
+ /* cn already used? */
+ if ($this->orig_cn != $this->cn || $this->new){
+
+ foreach($cache as $dn => $dummy){
+ if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
+ $message[]= _("The name for this host section is already used!");
+ break;
+ }
+ }
+ }
+
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ dhcpPlugin::save();
+ return ($this->attrs);
+ }
+
+
+}
+
+?>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpHost.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpHost.inc
--- /dev/null
@@ -0,0 +1,181 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003-2007 Cajus Pollmeier
+
+ 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 dhcpHost extends dhcpPlugin
+{
+ /* Used attributes */
+ var $dhcpHWAddress= "";
+ var $realGosaHost = FALSE;
+
+ /* attribute list for save action */
+ var $objectclasses= array("top", "dhcpHost");
+
+ function dhcpHost($attrs,$host_exists_in_gosa = FALSE)
+ {
+ dhcpPlugin::dhcpPlugin($attrs);
+
+ /* Load attributes */
+ if (!$this->new){
+ $this->dhcpHWAddress= $attrs['dhcpHWAddress'][0];
+ }
+
+ $this->advanced->setAutoOptions(array("host-name"));
+ $this->advanced->setAutoStatements(array("fixed-address"));
+
+ $this->realGosaHost = $host_exists_in_gosa;
+ }
+
+ function execute()
+ {
+ $smarty= get_smarty();
+ $smarty->assign("cn", $this->cn);
+ $smarty->assign("dhcpHWAddress", preg_replace('/^[^ ]+ /', '', $this->dhcpHWAddress));
+ $smarty->assign("realGosaHost",$this->realGosaHost);
+
+ /* Create fixed address */
+ if (isset($this->statements['fixed-address'])){
+ $smarty->assign("fixedaddr", $this->statements['fixed-address']);
+ } else {
+ $smarty->assign("fixedaddr", "");
+ }
+
+ /* Prepare hw type selector */
+ $hwtype= preg_replace('/\s.*$/', '', $this->dhcpHWAddress);
+ $smarty->assign("hwtype", $hwtype);
+ $smarty->assign("hwtypes", array("ethernet" => _("Ethernet"),
+ "fddi" => _("FDDI"),
+ "token-ring" => _("Token Ring")));
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_host.tpl', TRUE,dirname(__FILE__))).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ $this->fix_options();
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;
+ }
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
+ " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
+
+
+ return ($display);
+ }
+
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ /* Save remaining attributes */
+ if (isset($_POST['dhcp_host_posted'])){
+
+ /* Assemble hwAddress */
+ if (isset($_POST['dhcpHWAddress'])){
+ $this->dhcpHWAddress= get_post('hwtype')." ".get_post('dhcpHWAddress');
+ }
+
+ if(!$this->realGosaHost){
+ $this->cn= validate(get_post('cn'));
+ }
+
+ /* Save fixed address */
+ if(!$this->realGosaHost){
+ if ($_POST['fixedaddr'] != ""){
+ $this->statements['fixed-address']= get_post('fixedaddr');
+ } else {
+ unset ($this->statements['fixed-address']);
+ }
+ }
+ $this->options['host-name']= $this->cn;
+ }
+
+ dhcpPlugin::save_object();
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ $cache = array();
+ if(isset($this->parent)){
+ $cache = $this->parent->dhcpObjectCache;
+ }
+
+ /* All required fields are set? */
+ if ($this->cn == ""){
+ $message[]= _("Required field 'Name' is not filled.");
+ }
+
+ /* cn already used? */
+ if ($this->orig_cn != $this->cn || $this->new){
+
+ foreach($cache as $dn => $dummy){
+ if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
+ $message[]= _("The name for this host section is already used!");
+ break;
+ }
+ }
+ }
+
+ /* Check syntax of MAC address */
+ $check= preg_replace('/^[^\s]*\s/', '', $this->dhcpHWAddress);
+ if (!preg_match('/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/', $check)){
+ $message[]= _("The hardware address specified by you is not valid!");
+ }
+
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ dhcpPlugin::save();
+ if ($this->dhcpHWAddress != ""){
+ $this->attrs['dhcpHWAddress']= array($this->dhcpHWAddress);
+ } else {
+ $this->attrs['dhcpHWAddress']= array();
+ }
+
+ return ($this->attrs);
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNetwork.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNetwork.inc
--- /dev/null
@@ -0,0 +1,226 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2004-2007 Cajus Pollmeier
+
+ 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 dhcpNetwork extends plugin
+{
+ /* Used attributes */
+ var $options= array();
+ var $statements= array();
+
+ /* attribute list for save action */
+ var $attributes= array();
+ var $objectclasses= array();
+
+ function dhcpNetwork()
+ {
+ /* This is always an account */
+ $this->is_account= TRUE;
+ }
+
+ function execute()
+ {
+ /* Check for iteraction */
+ if (isset($_POST['add_dns']) && $_POST['addserver'] != ""){
+ if (!preg_match('/^[0-9a-z.-]+$/', get_post('addserver'))){
+ print_red(_("The name of the DNS server your're going to add is not valid!"));
+ } else {
+ $servers= array();
+ if (isset($this->options['domain-name-servers'])){
+ foreach(split(",", $this->options['domain-name-servers']) as $val){
+ $servers[$val]= $val;
+ }
+ }
+ $servers[get_post('addserver')]= get_post('addserver');
+
+ $tmp= "";
+ foreach($servers as $val){
+ $tmp.= $val.",";
+ }
+ $this->options['domain-name-servers']= preg_replace('/,$/', '', $tmp);
+ }
+ }
+ if (isset($_POST['delete_dns']) && isset($_POST['dnsserver'])){
+ $tmp= preg_replace("/(\s*,\s*)?".get_post('dnsserver')."/i", '',
+ $this->options['domain-name-servers']);
+ $tmp= preg_replace("/(\s*)?,(\s*)?$/", '', $tmp);
+ if ($tmp != ""){
+ $this->options['domain-name-servers']= $tmp;
+ } else {
+ unset($this->options['domain-name-servers']);
+ }
+ }
+
+ /* Show main page */
+ $smarty= get_smarty();
+
+ /*
+ * Assemble options
+ */
+
+ /* Router */
+ if (isset($this->options['routers'])){
+ $smarty->assign("routers", $this->options['routers']);
+ } else {
+ $smarty->assign("routers", "");
+ }
+
+ /* DNS */
+ if (isset($this->options['domain-name'])){
+ $smarty->assign("domain", trim($this->options['domain-name'], '"'));
+ } else {
+ $smarty->assign("domain", "");
+ }
+ if (isset($this->options['domain-name-servers'])){
+ $servers= array();
+ foreach(split(",", $this->options['domain-name-servers']) as $val){
+ $servers[$val]= $val;
+ }
+ $smarty->assign("dnsservers", $servers);
+ } else {
+ $smarty->assign("dnsservers", "");
+ }
+
+ /* Netmask / Broadcast */
+ if (isset($this->options['subnet-mask'])){
+ $this->options['subnet-mask']= normalize_netmask($this->options['subnet-mask']);
+ $smarty->assign("subnet_mask", $this->options['subnet-mask']);
+ } else {
+ $smarty->assign("subnet_mask", "");
+ }
+ if (isset($this->options['broadcast-address'])){
+ $smarty->assign("broadcast_address", $this->options['broadcast-address']);
+ } else {
+ $smarty->assign("broadcast_address", "");
+ }
+
+ /* Boot stuff */
+ if (isset($this->statements['filename'])){
+ $smarty->assign("filename", trim($this->statements['filename'], '"'));
+ } else {
+ $smarty->assign("filename", "");
+ }
+ if (isset($this->statements['next-server'])){
+ $smarty->assign("nextserver", $this->statements['next-server']);
+ } else {
+ $smarty->assign("nextserver", "");
+ }
+
+ /* Set flags */
+ $smarty->assign("autohost", "");
+ if (isset($this->statements['get-lease-hostnames'])){
+ if (preg_match('/^(true|on|yes)$/', $this->statements['get-lease-hostnames'])){
+ $smarty->assign("autohost", "checked");
+ }
+ }
+ $smarty->assign("autohostdecl", "");
+ if (isset($this->statements['use-host-decl-names'])){
+ if (preg_match('/^(true|on|yes)$/', $this->statements['use-host-decl-names'])){
+ $smarty->assign("autohostdecl", "checked");
+ }
+ }
+
+ return $smarty->fetch(get_template_path('dhcp_network.tpl', TRUE,dirname(__FILE__)));
+ }
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ /* Only save, if we are "active" */
+ if (isset($_POST['routers'])){
+
+ /*
+ * Assemble options
+ */
+
+ /* Options */
+ foreach (array("routers" => "routers", "domain-name" => "domain", "subnet-mask" => "subnet_mask",
+ "broadcast-address" => "broadcast_address") as $key => $val){
+
+ if ($_POST["$val"] == ''){
+ unset($this->options["$key"]);
+ } else {
+ $this->options["$key"]= get_post("$val");
+ }
+ }
+
+ /* Statements */
+ foreach (array("filename" => "filename", "next-server" => "nextserver") as $key => $val){
+ if ($_POST["$val"] == ''){
+ unset($this->statements["$key"]);
+ } else {
+
+ /* Only quote filename values */
+ if(in_array($key,array("filename"))){
+ $this->statements["$key"]= '"'.get_post("$val").'"';
+ }else{
+ $this->statements["$key"]= get_post("$val");
+ }
+ }
+ }
+
+ /* Flags */
+ if (isset ($_POST['autohost'])){
+ $this->statements['get-lease-hostnames']= "true";
+ } else {
+ unset($this->statements['get-lease-hostnames']);
+ }
+ if (isset ($_POST['autohostdecl'])){
+ $this->statements['use-host-decl-names']= "on";
+ } else {
+ unset($this->statements['use-host-decl-names']);
+ }
+ }
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ /* Check netmask and broadcast */
+ foreach(array("subnet-mask" => _("Netmask"), "broadcast-address" => _("Broadcast")) as $key => $typ){
+ if (!isset($this->options["$key"])){
+ continue;
+ }
+ $tmp= preg_replace('/^[^\s]+\s/', '', $this->options["$key"]);
+
+ if (!tests::is_ip($tmp)){
+ $message[]= sprintf(_("Error in definition of '%s'!"), $typ);
+ }
+ }
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+
+class dhcpNewSectionDialog extends plugin
+{
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array();
+ var $objectclasses = array("whatever");
+
+ /* Mapping array */
+ var $types= array();
+ var $classtype= "";
+ var $sectionMap= array( "dhcpService" => array("dhcpSharedNetwork", "dhcpSubnet", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/),
+ #"dhcpClass" => array("dhcpSubClass"),
+ "dhcpSubClass" => array(),
+ "dhcpHost" => array(),
+ "dhcpGroup" => array("dhcpHost"),
+ "dhcpPool" => array(),
+ "dhcpSubnet" => array("dhcpPool", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/),
+ "dhcpSharedNetwork" => array("dhcpSubnet", "dhcpPool"));
+
+
+
+ function dhcpNewSectionDialog($type)
+ {
+ $this->types= array( "dhcpService" => _("Global options"),
+ /*"dhcpClass" => _("Class"),*/
+ "dhcpSubClass" => _("Subclass"),
+ "dhcpHost" => _("Host"),
+ "dhcpGroup" => _("Group"),
+ "dhcpPool" => _("Pool"),
+ "dhcpSubnet" => _("Subnet"),
+ "dhcpSharedNetwork" => _("Shared network"));
+
+ $this->classtype= $type;
+ }
+
+ function execute()
+ {
+ /* Fill templating stuff */
+ $smarty = get_smarty();
+ $display= "";
+
+ $sections= $this->sectionMap[$this->classtype];
+ $t_sections= array();
+ foreach ($sections as $section){
+ $t_sections[$section]= $this->types[$section];
+ }
+ asort($t_sections);
+ $ui = get_userinfo();
+ $smarty->assign("sections", $t_sections);
+ $display.= $smarty->fetch(get_template_path('dhcpNewSection.tpl', TRUE));
+ return($display);
+ }
+
+ /* Get posts and set class name
+ */
+ function save_object()
+ {
+ }
+
+ /* Check given class name */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= "";
+
+ return ($message);
+ }
+
+
+ /* Return the class name */
+ function save()
+ {
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpPlugin.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpPlugin.inc
--- /dev/null
@@ -0,0 +1,208 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003-2007 Cajus Pollmeier
+
+ 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 dhcpPlugin extends plugin
+{
+ /* Used attributes */
+ var $cn= "";
+ var $orig_cn= "";
+ var $options= array();
+ var $statements= array();
+
+ /* Subobjects */
+ var $network;
+ var $advanced;
+
+ /* attribute list for save action */
+ var $attributes= array();
+ var $objectclasses= array();
+
+ function dhcpPlugin($attrs)
+ {
+ /* Load statements / options */
+ if (is_array($attrs)){
+ $this->dn= $attrs['dn'];
+ $this->cn= $attrs['cn'][0];
+ $this->new= FALSE;
+
+ /* Load options */
+ if (isset($attrs['dhcpOption'])){
+ foreach ($attrs['dhcpOption'] as $opt){
+ $idx= preg_replace('/\s.+$/', '', $opt);
+ if ($idx == $opt){
+ $value= "";
+ } else {
+ $value= preg_replace('/^[^\s]+\s/', '', $opt);
+ }
+ $this->options[$idx]= $value;
+ }
+ }
+
+ /* Load statements */
+ if (isset($attrs['dhcpStatements'])){
+ foreach ($attrs['dhcpStatements'] as $opt){
+ $idx= preg_replace('/\s.+$/', '', $opt);
+ if ($idx == $opt){
+ $value= "";
+ } else {
+ $value= preg_replace('/^[^\s]+\s/', '', $opt);
+ }
+ $this->statements[$idx]= $value;
+ }
+ }
+
+ } else {
+ /* We keep the parent dn here if it's new */
+ $this->dn= $attrs;
+ $this->new= TRUE;
+ }
+
+ /* Load network module */
+ $this->network= new dhcpNetwork();
+ $this->network->options= $this->options;
+ $this->network->statements= $this->statements;
+ $this->advanced= new dhcpAdvanced();
+ $this->advanced->options= $this->options;
+ $this->advanced->statements= $this->statements;
+
+ /* Save CN for later reference */
+ $this->orig_cn= $this->cn;
+ }
+
+ function execute()
+ {
+ return ("");
+ }
+
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ /* Strip network objects */
+ foreach (array("routers", "domain-name", "subnet-mask", "broadcast-address") as $toberemoved){
+ unset($this->options[$toberemoved]);
+ }
+ foreach (array("filename", "next-server") as $toberemoved){
+ unset($this->statements[$toberemoved]);
+ }
+
+ /* Save sub-objects */
+ $this->network->save_object();
+ $this->advanced->save_object();
+
+ /* Merge arrays for advanced view */
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;;
+ }
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ /* Merge arrays for network and advanced view */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->$type + $this->network->$type + $this->advanced->$type;
+ }
+
+ /* Add cn if we're new */
+ if ($this->new){
+ $this->dn= "cn=".$this->cn.",".$this->dn;
+ } else {
+ $this->dn= "cn=".$this->cn.preg_replace('/^cn=[^,]+/', '', $this->dn);
+ }
+
+ /* Assemble new entry - options */
+ $this->attrs['dhcpOption']= array();
+ if (isset ($this->options) && count ($this->options)){
+ foreach ($this->options as $key => $val){
+ $this->attrs['dhcpOption'][]= "$key $val";
+ }
+ }
+
+ /* Assemble new entry - statements */
+ $this->attrs['dhcpStatements']= array();
+ if (isset ($this->statements) && count ($this->statements)){
+ foreach ($this->statements as $key => $val){
+ if ($val != ""){
+ $this->attrs['dhcpStatements'][]= "$key $val";
+ } else {
+ $this->attrs['dhcpStatements'][]= "$key";
+ }
+ }
+ }
+
+ /* Move dn to the result */
+ $this->attrs['dn']= $this->dn;
+ $this->attrs['cn']= array($this->cn);
+ $this->attrs['objectClass']= $this->objectclasses;
+ $this->attrs['MODIFIED']= TRUE;
+
+ return ($this->attrs);
+ }
+
+
+ function removeAttrs($name, $type)
+ {
+ $new= array();
+ foreach ($this->attrs[$type] as $value){
+ if (!preg_match("/^$name /", $value)){
+ $new[]= $value;
+ }
+ }
+ $this->attrs[$type]= $new;
+ }
+
+
+ function removeOption($name)
+ {
+ $this->removeAttrs($name, 'dhcpOption');
+ }
+
+
+ function removeStatement($name)
+ {
+ $this->removeAttrs($name, 'dhcpStatement');
+ }
+
+
+ function fix_options()
+ {
+ foreach (array('domain-name-servers') as $key){
+ unset ($this->options[$key]);
+ }
+ }
+
+}
+
+?>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpPool.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpPool.inc
--- /dev/null
@@ -0,0 +1,191 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003 Cajus Pollmeier
+
+ 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 dhcpPool extends dhcpPlugin
+{
+ /* Used attributes */
+ var $dhcpRange= "";
+ var $range_start= "";
+ var $range_stop= "";
+
+ /* attribute list for save action */
+ var $objectclasses= array('top', 'dhcpPool');
+
+ function dhcpPool($attrs)
+ {
+ dhcpPlugin::dhcpPlugin($attrs);
+
+ /* Load attributes */
+ if (!$this->new){
+ $this->dhcpRange= $attrs['dhcpRange'][0];
+ list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange);
+ }
+
+ $this->advanced->setAutoOptions(array("host-name"));
+ $this->advanced->setAutoStatements(array("fixed-address"));
+ }
+
+ function execute()
+ {
+ $smarty= get_smarty();
+ $smarty->assign("cn", $this->cn);
+ $smarty->assign("range_start", $this->range_start);
+ $smarty->assign("range_stop", $this->range_stop);
+
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_pool.tpl', TRUE)).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ $this->fix_options();
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;;
+ }
+
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
+ " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
+
+ return ($display);
+ }
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if (isset($_POST['cn'])){
+ $this->cn= validate(get_post('cn'));
+ $this->range_start= validate(get_post('range_start'));
+ $this->range_stop= validate(get_post('range_stop'));
+ }
+
+ dhcpPlugin::save_object();
+
+ /* Move range to internal variable */
+ $this->dhcpRange= $this->range_start." ".$this->range_stop;
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ $cache = $this->parent->dhcpObjectCache;
+
+ /* All required fields are set? */
+ if ($this->cn == ""){
+ $message[]= _("Required field 'Name' is not filled.");
+ }
+
+ /* cn already used? */
+ if ($this->orig_cn != $this->cn || $this->new){
+
+ foreach($cache as $dn => $dummy){
+ if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
+ $message[]= _("The name for this section is already used!");
+ break;
+ }
+ }
+ }
+
+ if ($this->dhcpRange == ""){
+ $message[]= _("Required field 'Range' is not filled.");
+ }
+
+ if (!tests::is_ip($this->range_start) || !tests::is_ip($this->range_stop)){
+ $message[]= _("Field 'Range' contains invalid IP addresses.");
+ }
+
+ if(!tests::is_ip_range($this->range_start,$this->range_stop)){
+ $message[] = _("Field 'Range' contains invalid IP range.");
+ }
+
+ /* Check if range is in the network */
+ $dn= $this->dn;
+ while (preg_match('/,/', $dn)){
+ $type= $this->objectType($cache, $dn);
+
+ /* Check for subnet */
+ if ($type == 'dhcpSubnet'){
+ $network= $cache[$dn]['cn'][0];
+ $netmask= normalize_netmask($cache[$dn]['dhcpNetMask'][0]);
+ if (!tests::is_in_network($network, $netmask, $this->range_start) ||
+ !tests::is_in_network($network, $netmask, $this->range_stop)){
+ $message[] = _("'Range' is not inside the configured network.");
+ }
+ }
+
+ /* Stop if we've examined the service base object */
+ if ($type == 'dhcpService'){
+ break;
+ }
+ $dn= preg_replace('/^[^,]+,/', '', $dn);
+ }
+
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
+
+ return $message;
+ }
+
+ /* Save to LDAP */
+ function save()
+ {
+ dhcpPlugin::save();
+ $this->attrs['dhcpRange']= array($this->dhcpRange);
+
+ return ($this->attrs);
+ }
+
+
+ function objectType($cache, $dn)
+ {
+ $type= "";
+ $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost",
+ "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork");
+
+ foreach ($cache[$dn]['objectClass'] as $oc){
+ if (in_array($oc, $types)){
+ $type= $oc;
+ break;
+ }
+ }
+
+ return ($type);
+ }
+
+
+}
+
+?>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpService.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpService.inc
--- /dev/null
@@ -0,0 +1,181 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003-2007 Cajus Pollmeier
+
+ 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 dhcpService extends dhcpPlugin
+{
+ /* Used attributes */
+ var $dhcpPrimaryDN= "";
+ var $orig_dhcpPrimaryDN= "";
+ var $ddns_styles= array('none', 'interim', 'ad-hoc');
+
+ /* attribute list for save action */
+ var $objectclasses= array('top', 'dhcpService');
+
+
+ function dhcpService($attrs)
+ {
+ dhcpPlugin::dhcpPlugin($attrs);
+
+ /* Load statements / options */
+ if (!$this->new){
+ /* Load attributes */
+ $this->dhcpPrimaryDN= $attrs['dhcpPrimaryDN'][0];
+ } else {
+ /* We keep the parent dn here if it's new */
+ $this->statements['default-lease-time']= 600;
+ $this->statements['max-lease-time']= 1700;
+ $this->statements['authoritative']= TRUE;
+ $this->statements['ddns-update-style']= 'none';
+ }
+
+ $this->advanced->setAutoStatements(array("default-lease-time", "max-lease-time", "authoritative", "server-identifier", "ddns-update-style"));
+ $this->advanced->setAutoOptions(array("server-name"));
+
+ /* Save for later action */
+ $this->orig_dhcpPrimaryDN= $this->dhcpPrimaryDN;
+ }
+
+
+ function execute()
+ {
+ /* Show main page */
+ $smarty= get_smarty();
+
+ $smarty->assign('ddns_styles', $this->ddns_styles);
+ foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $value){
+ if (isset($this->statements[preg_replace('/_/', '-', $value)])){
+ $smarty->assign("$value", $this->statements[preg_replace('/_/', '-', $value)]);
+ } else {
+ $smarty->assign("$value", "");
+ }
+ }
+
+ if (isset($this->statements['authoritative'])){
+ $smarty->assign("authoritative", "checked");
+ } else {
+ $smarty->assign("authoritative", "");
+ }
+
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_service.tpl', TRUE)).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ $this->fix_options();
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;;
+ }
+
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
+ " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
+
+
+ return ($display);
+
+ }
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ /* No need to save in the first time */
+ if (!isset($_POST['ddns_update_style'])){
+ return;
+ }
+
+ /* Save remaining attributes */
+ foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $val){
+ $tval= preg_replace('/_/', '-', $val);
+ if ($_POST[$val] != ""){
+ $this->statements[$tval]= validate(get_post($val));
+ } else {
+ unset ($this->statements[$tval]);
+ }
+ }
+ if (isset($_POST['authoritative'])){
+ $this->statements['authoritative']= "";
+ } else {
+ unset($this->statements['authoritative']);
+ }
+
+ dhcpPlugin::save_object();
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ if (!tests::is_id($this->statements['default-lease-time'])){
+ $message[]= _('Default lease time needs to be numeric.');
+ }
+ if (!tests::is_id($this->statements['max-lease-time'])){
+ $message[]= _('Maximum lease time needs to be numeric.');
+ }
+ if ($this->statements['default-lease-time'] > $this->statements['max-lease-time']){
+ $message[]= _('Default lease time needs to smaller than the maximum lease time.');
+ }
+
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ global $config;
+ $this->attrs= array();
+
+ /* Get and set server name */
+ $ldap= $config->get_ldap_link();
+ $ldap->cat($this->dhcpPrimaryDN, array('cn'));
+ $res= $ldap->fetch();
+ $server_name= $res['cn'][0];
+
+ dhcpPlugin::save();
+
+ $this->attrs['dhcpPrimaryDN']= array($this->dhcpPrimaryDN);
+ $this->removeOption('server-name');
+# $this->attrs['dhcpOption'][]= "server-name $server_name";
+
+ return ($this->attrs);
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc
--- /dev/null
@@ -0,0 +1,188 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003-2007 Cajus Pollmeier
+
+ 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 dhcpSharedNetwork extends dhcpPlugin
+{
+ /* attribute list for save action */
+ var $objectclasses= array('top', 'dhcpSharedNetwork');
+
+ function dhcpSharedNetwork($attrs)
+ {
+ dhcpPlugin::dhcpPlugin($attrs);
+
+ $this->advanced->setAutoStatements(array("server-identifier", "default-lease-time",
+ "max-lease-time", "min-lease-time", "authoritative", "deny-unknown-clients",
+ "deny-bootp", "deny-booting"));
+ }
+
+
+ function execute()
+ {
+ $smarty= get_smarty();
+
+ /* Fill template */
+ $smarty->assign ("cn", $this->cn);
+ foreach (array("server-identifier", "default-lease-time", "max-lease-time", "min-lease-time") as $attr){
+ if (isset($this->statements[$attr])){
+ $smarty->assign(preg_replace('/-/', '_', $attr), $this->statements[$attr]);
+ } else {
+ $smarty->assign(preg_replace('/-/', '_', $attr), "");
+ }
+ }
+ if (isset($this->statements["authoritative"])){
+ $smarty->assign("authoritative", "checked");
+ } else {
+ $smarty->assign("authoritative", "");
+ }
+ if (!isset($this->statements["deny unknown-clients"])){
+ $smarty->assign("allow_unknown_state", "checked");
+ } else {
+ $smarty->assign("allow_unknown_state", "");
+ }
+ if (!isset($this->statements["deny bootp"])){
+ $smarty->assign("allow_bootp_state", "checked");
+ } else {
+ $smarty->assign("allow_bootp_state", "");
+ }
+ if (!isset($this->statements["deny booting"])){
+ $smarty->assign("allow_booting_state", "checked");
+ } else {
+ $smarty->assign("allow_booting_state", "");
+ }
+
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_sharedNetwork.tpl', TRUE)).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ $this->fix_options();
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;
+ }
+
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
+ " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
+
+
+ return ($display);
+ }
+
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if (isset($_POST['cn'])){
+ $this->cn= validate(get_post('cn'));
+ dhcpPlugin::save_object();
+
+ foreach (array("server-identifier", "default-lease-time",
+ "max-lease-time", "min-lease-time") as $attr){
+ if (isset($_POST[$attr]) && $_POST[$attr] != ""){
+ $this->statements[$attr]= get_post($attr);
+ } else {
+ unset($this->statements[$attr]);
+ }
+ }
+
+ if (isset($_POST["authoritative"])){
+ $this->statements["authoritative"]= "";
+ } else {
+ unset ($this->statements["authoritative"]);
+ }
+
+ foreach(array("unknown-clients", "bootp", "booting") as $name){
+ if (isset($_POST[$name])){
+ $this->statements["allow $name"]= "";
+ unset($this->statements["deny $name"]);
+ } else {
+ $this->statements["deny $name"]= "";
+ unset($this->statements["allow $name"]);
+ }
+ }
+ }
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ $cache = $this->parent->dhcpObjectCache;
+
+ /* All required fields are set? */
+ if ($this->cn == ""){
+ $message[]= _("Required field 'Name' is not filled.");
+ }
+
+ /* Check lease times */
+ foreach (array("default-lease-time" => _("Default lease time"),
+ "max-lease-time" => _("Max. lease time"),
+ "min-lease-time" => _("Min. lease time")) as $key => $val){
+ if (isset($this->statements[$key]) && $this->statements[$key] != "" &&
+ !tests::is_id($this->statements[$key])){
+ $message[]= sprintf(_("The value specified as '%s' is not numeric!"), $val);
+ }
+ }
+
+ /* cn already used? */
+ if ($this->orig_cn != $this->cn || $this->new){
+
+ foreach($cache as $dn => $dummy){
+ if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
+ $message[]= _("The name for this host section is already used!");
+ break;
+ }
+ }
+ }
+
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ dhcpPlugin::save();
+
+ return ($this->attrs);
+ }
+
+}
+
+?>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubnet.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubnet.inc
--- /dev/null
@@ -0,0 +1,200 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003-2007 Cajus Pollmeier
+
+ 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 dhcpSubnet extends dhcpPlugin
+{
+ /* Used attributes */
+ var $dhcpNetMask= 24;
+ var $dhcpRange= "";
+ var $range_start= "";
+ var $range_stop= "";
+ var $use_range= FALSE;
+
+ /* attribute list for save action */
+ var $objectclasses= array('top', 'dhcpSubnet', 'dhcpOptions');
+
+ function dhcpSubnet($attrs)
+ {
+ dhcpPlugin::dhcpPlugin($attrs);
+
+ if (!$this->new){
+ /* Load attributes */
+ foreach (array("dhcpNetMask", "dhcpRange") as $attr){
+ if (isset($attrs[$attr][0])){
+ $this->$attr= $attrs[$attr][0];
+ }
+ }
+ if (isset($attrs['dhcpRange']) && count($attrs['dhcpRange'])){
+ $this->use_range= TRUE;
+ list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange);
+ }
+ }
+
+ $this->dhcpNetMask= normalize_netmask($this->dhcpNetMask);
+ }
+
+
+ function execute()
+ {
+ $smarty= get_smarty();
+ $smarty->assign("cn", $this->cn);
+ $smarty->assign("dhcp_netmask", $this->dhcpNetMask);
+
+ /* Prepare range */
+ if ($this->use_range){
+ $smarty->assign("use_range", "checked");
+ $smarty->assign("range_disabled", "");
+ } else {
+ $smarty->assign("use_range", "");
+ $smarty->assign("range_disabled", "disabled");
+ }
+ $smarty->assign("range_start", $this->range_start);
+ $smarty->assign("range_stop", $this->range_stop);
+
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_subnet.tpl', TRUE)).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ $this->fix_options();
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;
+ }
+
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
+ " <input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
+
+ /* Show main page */
+ return $display;
+ }
+
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if(isset($_POST['dhcp_subnet_posted'])){
+ if (isset($_POST['cn'])){
+ $this->cn= validate(get_post('cn'));
+ }
+ if (isset($_POST['dhcp_netmask'])){
+ $this->dhcpNetMask= validate(get_post('dhcp_netmask'));
+ }
+ if (isset($_POST['use_range'])){
+ $this->use_range= TRUE;
+ $this->range_start= validate(get_post('range_start'));
+ $this->range_stop= validate(get_post('range_stop'));
+ } else {
+ $this->use_range= FALSE;
+ }
+
+ /* Move range to internal variable */
+ $this->dhcpRange= $this->range_start." ".$this->range_stop;
+ dhcpPlugin::save_object();
+ }
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ $cache = $this->parent->dhcpObjectCache;
+
+ /* All required fields are set? */
+ if ($this->cn == ""){
+ $message[]= _("Required field 'Network address' is not filled.");
+ }
+ if ($this->dhcpNetMask == ""){
+ $message[]= _("Required field 'Netmask' is not filled.");
+ }
+
+ /* cn already used? */
+ if ($this->orig_cn != $this->cn || $this->new){
+
+ foreach($cache as $dn => $dummy){
+ if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
+ $message[]= _("The name for this section is already used!");
+ break;
+ }
+ }
+ }
+
+ /* IP's? */
+ foreach(array('dhcpNetMask' => _("Netmask"), 'cn' => _("Network address"), 'range_start' => _("Range"), 'range_stop' => _("Range")) as $attr => $str){
+ if ($this->$attr != "" && !tests::is_ip($this->$attr)){
+ $message[]= sprintf(_("The field '%s' contains an invalid IP address"), $str);
+ }
+ }
+
+ /* Check ip range */
+ if ($this->use_range){
+ if(!tests::is_ip_range($this->range_start,$this->range_stop)){
+ $message[] = _("Field 'Range' contains invalid IP range.");
+ }
+
+ /* Check if range is in the network */
+ if (!tests::is_in_network($this->cn, $this->dhcpNetMask, $this->range_start) ||
+ !tests::is_in_network($this->cn, $this->dhcpNetMask, $this->range_stop)){
+ $message[] = _("'Range' is not inside the configured network.");
+ }
+ }
+
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ dhcpPlugin::save();
+
+ /* Move dn to the result */
+ $this->attrs['dhcpNetMask']= array(netmask_to_bits($this->dhcpNetMask));
+ if ($this->use_range && !empty($this->dhcpRange)){
+ $this->attrs['dhcpRange']= array($this->range_start." ".$this->range_stop);
+ } else {
+ $this->attrs['dhcpRange']= array();
+ }
+
+ return ($this->attrs);
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_servDHCP.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_servDHCP.inc
--- /dev/null
@@ -0,0 +1,739 @@
+<?php
+
+class servdhcp extends goService
+{
+ /* attribute list for save action */
+ var $attributes= array("dhcpServiceDN");
+ var $objectclasses= array("dhcpServer");
+ var $conflicts = array("servdhcp");
+ var $dhcpServiceDN= "";
+
+ /* Section storage */
+ var $dhcpSections= array();
+ var $dhcpObjectCache= array();
+ var $current_object= "";
+ var $types= array();
+ var $serviceDN= "";
+
+ var $quote_option = array("domain-name");
+
+ var $orig_dn = "";
+
+ var $dhcp_server_list = array("ENTRIES"=> array(),"FOR_LIST"=> array());
+ var $take_over_id = -1;
+ var $display_warning = TRUE;
+
+ function servdhcp (&$config, $dn= NULL, $parent= NULL)
+ {
+ plugin::plugin ($config, $dn, $parent);
+
+ $this->serviceDN = "cn=dhcp,".$dn;
+ $this->orig_dn = $dn;
+
+ $this->DisplayName = _("DHCP service");
+
+ $this->types= array( "dhcpLog" => _("Logging"),
+ "dhcpService" => _("Global options"),
+ "dhcpClass" => _("Class"),
+ "dhcpSubClass" => _("Subclass"),
+ "dhcpHost" => _("Host"),
+ "dhcpGroup" => _("Group"),
+ "dhcpPool" => _("Pool"),
+ "dhcpSubnet" => _("Subnet"),
+ "dhcpFailOverPeer" => _("Failover peer"),
+ "dhcpSharedNetwork" => _("Shared network"));
+
+
+ /* Backport: PHP4 compatibility */
+ foreach($this->types as $type => $translation){
+ $this->types[strtolower($type)] = $translation;
+ }
+
+ /* Load information about available services */
+ $this->reload();
+ if (!count($this->dhcpSections)){
+ $this->is_account= FALSE;
+ $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
+ }
+ }
+
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $smarty->assign("dns_take_over",FALSE);
+ $display= "";
+
+
+ /*****************/
+ /* Handle Take Over Actions
+ /*****************/
+
+ /* Give smarty the required informations */
+ $smarty->assign("dhcp_server_list", $this->dhcp_server_list['FOR_LIST']);
+ $smarty->assign("dhcp_server_list_cnt", count($this->dhcp_server_list['FOR_LIST']));
+
+ /* Take over requested, save id */
+ if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){
+ $id = $_POST['take_over_src'];
+ if(isset($this->dhcp_server_list['ENTRIES'][$id])){
+ $this->take_over_id = $id;
+ }
+ }
+
+ /* Abort take over action */
+ if(isset($_POST['cancel_take_over'])){
+ $this->dialog =false;
+ $this->take_over_id = -1;
+ $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
+ }
+
+ /* Display informartion about take over that will be started when saving this server
+ * and hide default dhcp output
+ */
+ if($this->take_over_id != -1){
+
+ $this->dialog = FALSE;
+ $id = $this->take_over_id;
+ $smarty->assign("dns_take_over",TRUE);
+ $warning = sprintf(_("You are going to migrate the DHCP setup from server '%s'."),
+ $this->dhcp_server_list['ENTRIES'][$id]['cn'][0]);
+ $warning.= " "._("The migration will be started when you save this system. To cancel this action, use the cancel button below.");
+
+ if($this->display_warning){
+ print_red($warning);
+ $this->display_warning = FALSE;
+ }
+ return($smarty->fetch(get_template_path('servdhcp.tpl', TRUE)));
+ }
+
+
+ /*****************/
+ /* List handling
+ /*****************/
+
+ /* Section Creation? */
+ if (isset($_POST['create_section']) && isset($_POST['section'])){
+ $section= $_POST['section'];
+ $tmp = new dhcpNewSectionDialog(NULL);
+ if (isset($tmp->sectionMap[$section])){
+ $this->dialog= new $section($this->current_object);
+ $this->current_object= "";
+ } else {
+ $this->dialog= FALSE;
+ }
+ }
+
+ /* Cancel section creation? */
+ if (isset($_POST['cancel_section']) || isset($_POST['cancel_dhcp'])){
+ $this->dialog= FALSE;
+ }
+
+ /* Save changes */
+ if (isset($_POST['save_dhcp'])){
+ $this->dialog->save_object();
+ $messages= $this->dialog->check();
+ if (count($messages)){
+ show_errors($messages);
+ } else {
+ $dn= $this->dialog->dn;
+ $class= get_class($this->dialog);
+ $type= $this->types[$class];
+ if(empty($this->serviceDN)){
+ $indent= substr_count(preg_replace("/".$this->dn."/", '', $dn), ",") -1;
+ }else{
+ $indent= substr_count(preg_replace("/".$this->serviceDN."/", '', $dn), ",");
+ }
+ $spaces= "";
+ for ($i= 0; $i<$indent; $i++){
+ $spaces.= " ";
+ }
+ $data= $this->dialog->save();
+ if ($this->current_object == ""){
+ /* New object */
+ $newsects= array();
+ foreach ($this->dhcpSections as $key => $dsc){
+ $newsects[$key]= $dsc;
+ if ($key == $dn){
+ $spaces.= " ";
+ $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'";
+ }
+ }
+ $this->dhcpObjectCache[$data['dn']]= $data;
+ $this->dhcpSections= $newsects;
+ } else {
+ if ($dn != $data['dn']){
+ /* Old object, new name */
+ $this->dhcpObjectCache[$dn]= array();
+ $this->dhcpObjectCache[$data['dn']]= $data;
+
+ /* If we renamed a section, we've to rename a couple of objects, too */
+ foreach ($this->dhcpObjectCache as $key => $dsc){
+ if (preg_match("/,$dn$/", $key)){
+ $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key);
+ $dsc['MODIFIED']= TRUE;
+ $this->dhcpObjectCache[$new_dn]= $dsc;
+ unset($this->dhcpObjectCache[$key]);
+ }
+ }
+ $newsects= array();
+ foreach ($this->dhcpSections as $key => $dsc){
+ if ($key == $dn){
+ $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'";
+ continue;
+ }
+ if (preg_match("/,$dn$/", $key)){
+ $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key);
+ $newsects[$new_dn]= $dsc;
+ } else {
+ $newsects[$key]= $dsc;
+ }
+ }
+ $this->dhcpSections= $newsects;
+
+ } else {
+ /* Old object, old name */
+ $this->dhcpObjectCache[$data['dn']]= $data;
+ }
+ }
+ $this->dialog= FALSE;
+ }
+ }
+
+ /* Remove section? */
+ if (isset($_POST['delete_dhcp_confirm'])){
+ if ($this->acl_is_removeable()){
+ unset($this->dhcpSections[$this->current_object]);
+ unset($this->dhcpObjectCache[$this->current_object]);
+ $this->dhcpObjectCache[$this->current_object]= array();
+ foreach ($this->dhcpSections as $key => $value){
+ if (preg_match("/".$this->current_object."$/", $key)){
+ unset($this->dhcpSections[$key]);
+ unset($this->dhcpObjectCache[$key]);
+ $this->dhcpObjectCache[$key]= array();
+ }
+ }
+ } else {
+ print_red(_("You're not allowed to remove DHCP sections!"));
+ }
+ $this->dialog= FALSE;
+ }
+
+ /* Look for post entries */
+ foreach($_POST as $name => $value){
+
+ /* Insert new section? */
+ if (preg_match('/^insertDhcp_.*_x$/', $name)){
+ $dn= base64_decode(preg_replace('/^insertDhcp_([^_]+)_x$/', '\1', $name));
+ if (isset($this->dhcpObjectCache[$dn])){
+ $this->dialog= new dhcpNewSectionDialog($this->objectType($dn));
+ $this->current_object= $dn;
+ $this->dialog->acl= $this->acl;
+ }
+ }
+
+ /* Edit section? */
+ if (preg_match('/^editDhcp_.*_x$/', $name)){
+ $dn= base64_decode(preg_replace('/^editDhcp_([^_]+)_x$/', '\1', $name));
+ if (isset($this->dhcpObjectCache[$dn])){
+ $section= $this->objectType($dn);
+ $this->current_object= $dn;
+ $this->dialog= new $section($this->dhcpObjectCache[$dn]);
+ }
+ }
+
+ /* Remove section? */
+ if (preg_match('/^delDhcp_.*_x$/', $name)){
+ $dn= base64_decode(preg_replace('/^delDhcp_([^_]+)_x$/', '\1', $name));
+ if (isset($this->dhcpObjectCache[$dn])){
+ $this->current_object= $dn;
+ $this->dialog= 1;
+ $smarty->assign("warning", sprintf(_("You're about to delete the DHCP section '%s'."), $dn));
+ return($smarty->fetch(get_template_path('remove_dhcp.tpl', TRUE)));
+ }
+ }
+
+ }
+
+ if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
+ $dn = base64_decode($_GET['id']);
+ if (isset($this->dhcpObjectCache[$dn])){
+ $section= $this->objectType($dn);
+ $this->current_object= $dn;
+ $this->dialog= new $section($this->dhcpObjectCache[$dn]);
+ }
+ }
+
+
+ if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
+ $dn = base64_decode($_GET['id']);
+ if (isset($this->dhcpObjectCache[$dn])){
+ $section= $this->objectType($dn);
+ $this->current_object= $dn;
+ $this->dialog= new $section($this->dhcpObjectCache[$dn]);
+ }
+ }
+
+
+ /* Do we need to flip is_account state? */
+ if (isset($_POST['modify_state'])){
+ $this->is_account= !$this->is_account;
+ }
+
+ /* Show tab dialog headers */
+ if ($this->is_account){
+# $display= $this->show_header(_("Remove DHCP service"),
+# _("This server has DHCP features enabled. You can disable them by clicking below."));
+
+ if (!count($this->dhcpObjectCache)){
+ $attrs= array();
+ $attrs['dn']= 'cn=dhcp,'.$this->dn;
+ $attrs['cn']= array('dhcp');
+ $attrs['objectClass']= array('top', 'dhcpService');
+ $attrs['dhcpPrimaryDN']= array($this->dn);
+ $attrs['dhcpStatements']= array("default-lease-time 600",
+ "max-lease-time 1200",
+ "authoritative",
+ "ddns-update-style none");
+ $attrs['MODIFIED']= TRUE;
+ $this->dhcpSections['cn=dhcp,'.$this->dn]= _("Global options");
+ $this->dhcpObjectCache['cn=dhcp,'.$this->dn]= $attrs;
+ }
+
+ } else {
+# $display= $this->show_header(_("Add DHCP service"),
+
+# _("This server has DHCP features disabled. You can enable them by clicking below."));
+ return ($display);
+ }
+
+
+ /* Show dialog
+ */
+ if(isset($this->dialog) && is_object($this->dialog)){
+ $this->dialog->save_object();
+ $this->dialog->parent = $this;
+ return($this->dialog->execute());
+ }
+
+ /* Create Listbox with existing Zones
+ */
+ $DhcpList = new divSelectBox("dhcpSections");
+ $DhcpList->SetHeight(400);
+
+ /* Add entries to divlist
+ */
+ $editImgIns = "<input type='image' src='images/list_new.png' name='insertDhcp_%s' title='"._("Insert new DHCP section")."'>".
+ "<input type='image' src='images/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>".
+ "<input type='image' src='images/edittrash.png' name='delDhcp_%s' title='"._("Remove DHCP section")."'>";
+ $editImgInsNoDel = "<input type='image' src='images/list_new.png' name='insertDhcp_%s' title='"._("Insert new DHCP section")."'>".
+ "<input type='image' src='images/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>";
+ $editImg = "<input type='image' src='images/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>".
+ "<input type='image' src='images/edittrash.png' name='delDhcp_%s' title='"._("Remove DHCP section")."'>";
+
+ $tmp = new dhcpNewSectionDialog(NULL);
+ foreach($this->dhcpSections as $section => $values ){
+
+ $values = "<a href='?plug=".$_GET['plug']."&act=edit&id=".base64_encode($section)."'>".$values."</a>";
+
+ if (count($tmp->sectionMap[$this->objectType($section)])){
+ if ($this->objectType($section) == "dhcpService"){
+ $DhcpList->AddEntry(array(
+ array("string" => $values),
+ array("string" => str_replace("%s",base64_encode($section),$editImgInsNoDel), "attach" => "style='text-align:right;'")
+ ));
+ } else {
+ $DhcpList->AddEntry(array(
+ array("string" => $values),
+ array("string" => str_replace("%s",base64_encode($section),$editImgIns), "attach" => "style='text-align:right;'")
+ ));
+ }
+ } else {
+ $DhcpList->AddEntry(array(
+ array("string" => $values),
+ array("string" => str_replace("%s",base64_encode($section),$editImg), "attach" => "style='text-align:right;'")
+ ));
+ }
+ }
+
+ /* Display tempalte */
+ $smarty->assign("DhcpList",$DhcpList->DrawList());
+ $display.= $smarty->fetch(get_template_path('servdhcp.tpl', TRUE));
+ return($display);
+ }
+
+
+ function remove_from_parent()
+ {
+ /* Cancel if there's nothing to do here */
+ if (!$this->initially_was_account){
+ return;
+ }
+
+ /* Remove subtrees */
+ $ldap= $this->config->get_ldap_link();
+ foreach ($this->dhcpObjectCache as $dn => $content){
+ if ($this->objectType($dn) == 'dhcpService'){
+ $ldap->rmdir_recursive($dn);
+ show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed"));
+ }
+ }
+
+ /* Remove from self */
+ $ldap= $this->config->get_ldap_link();
+
+ /* Remove and write to LDAP */
+ plugin::remove_from_parent();
+
+ @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save");
+ $ldap->cd($this->dn);
+ $this->cleanup();
+ $ldap->modify ($this->attrs);
+
+ show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed"));
+
+ /* Optionally execute a command after we're done */
+ $this->handle_post_events("remove");
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ plugin::save_object();
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ return ($message);
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ /* Take over handling
+ * - Load servdhcp class and dhcpObjectCache for the source dhcp setup.
+ * - Assign dhcpObjectCache to this configuration.
+ * - Save this setup and remove source setup from ldap.
+ */
+ if($this->take_over_id != -1){
+ $id = $this->take_over_id;
+ $src = preg_replace("/cn=dhcp,/","",$this->dhcp_server_list['ENTRIES'][$id]['dn']);
+ $tmp = new servdhcp ($this->config, $src);
+ $this->orig_dn = $src;
+ $this->dhcpObjectCache = $tmp->dhcpObjectCache;
+ }
+
+ /* Save dhcp setttings */
+ $ldap= $this->config->get_ldap_link();
+ foreach ($this->dhcpObjectCache as $dn => $data){
+
+ if($this->dn != $this->orig_dn){
+ $dn = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$dn);
+ }
+
+ /* Remove entry? */
+ if (count($data) == 0){
+ /* Check if exists, then remove... */
+ if($ldap->cat($dn)){
+ $ldap->rmdir_recursive($dn);
+ show_ldap_error($ldap->get_error(), _("Can't remove DHCP object!"));
+ }
+ continue;
+ }
+
+ /* Opdate dhcp option 'server-name' to actual server name */
+ if($this->dn != $this->orig_dn){
+ $fixed = FALSE;
+ foreach(array("dhcpHost","dhcpSubnet","dhcpGroup","dhcpSharedNetwork") as $object){
+ if(in_array($object,$data['objectClass']) && isset($data['dhcpOption'])){
+ foreach($data['dhcpOption'] as $key => $option){
+ if(preg_match("/^server-name /",$option)){
+ $data['dhcpOption'][$key] = "server-name ".$this->cn;
+ $data['MODIFIED'] = TRUE;
+ break;
+ }
+ }
+ }
+
+ /* Skip next loops if entry is updated */
+ if($fixed){
+ break;
+ }
+ }
+ }
+
+ /* Modify existing entry? */
+ if (isset($data['MODIFIED']) || $this->orig_dn != $this->dn){
+
+ if($ldap->cat($dn)){
+ $modify= TRUE;
+ } else {
+ $modify= FALSE;
+ }
+
+ /* Build new entry */
+ $attrs= array();
+ foreach ($data as $attribute => $values){
+ if ($attribute == "MODIFIED" || $attribute == "dn"){
+ continue;
+ }
+
+ if(in_array($attribute,array("dhcpPrimaryDN","dhcpSecondaryDN","dhcpServerDN","dhcpFailOverPeerDN"))){
+ foreach($values as $v_key => $value){
+ $values[$v_key] = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$value);
+ }
+ }
+
+ if (count($values)){
+
+ if($attribute == "dhcpOption"){
+ foreach($values as $key => $value){
+ $option_name = trim(preg_replace("/[^ ]*$/","",$value));
+ $option_value= trim(preg_replace("/^[^ ]*/","",$value));
+ if(in_array($option_name,$this->quote_option)){
+ $values[$key] = $option_name." \"".$option_value."\"";
+ }
+ }
+ }
+ if (count($values) == 1){
+ $attrs[$attribute]= $values[0];
+ } else {
+ $attrs[$attribute]= $values;
+ }
+ } else {
+ if ($modify){
+ $attrs[$attribute]= array();
+ }
+ }
+ }
+
+ $ldap->cd($dn);
+ if ($modify){
+ $ldap->modify($attrs);
+ show_ldap_error($ldap->get_error(), _("Can't save DHCP object!"));
+
+ /* Optionally execute a command after we're done */
+ $this->handle_post_events("modify");
+ } else {
+ $ldap->add($attrs);
+ show_ldap_error($ldap->get_error(), _("Can't save DHCP object!"));
+
+ /* Optionally execute a command after we're done */
+ $this->handle_post_events("create");
+ }
+ }
+ }
+
+ $this->dhcpServiceDN= $this->serviceDN;
+ if($this->dn != $this->orig_dn){
+ $this->dhcpServiceDN= preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$this->dhcpServiceDN);
+ }
+
+ /* Replace 'new' dn */
+ if(preg_match("/new$/",$this->dhcpServiceDN)){
+ $this->dhcpServiceDN = preg_replace("/new$/",$this->dn,$this->dhcpServiceDN);
+ }
+
+ plugin::save();
+
+ /* Save data to LDAP */
+ $ldap->cd($this->dn);
+ $this->cleanup();
+ $ldap->modify ($this->attrs);
+
+ show_ldap_error($ldap->get_error(), _("Saving DHCP service failed"));
+
+ /* Optionally execute a command after we're done */
+ if ($this->initially_was_account == $this->is_account){
+ if ($this->is_modified){
+ $this->handle_post_events("modify");
+ }
+ } else {
+ $this->handle_post_events("add");
+ }
+
+ /* Take over handling
+ * - Remove old dhcp config from source server
+ */
+ if($this->take_over_id != -1){
+ $id = $this->take_over_id;
+ $src = $this->dhcp_server_list['ENTRIES'][$id]['dn'];
+ $tmp = new servdhcp ($this->config, $src);
+ $tmp->remove_from_parent();
+ }
+ }
+
+
+ function reload()
+ {
+ /* Init LDAP and load list */
+ $ldap= $this->config->get_ldap_link();
+ $ui= get_userinfo();
+ $me= $this->dn;
+
+ $filter = "(&(objectClass=dhcpService)(|(dhcpPrimaryDN=$me)(dhcpSecondaryDN=$me)(dhcpServerDN=$me)(dhcpFailOverPeerDN=$me)))";
+
+ $list= get_list($filter, array("server"), $this->config->current['BASE'], array("cn"),GL_SIZELIMIT | GL_SUBSEARCH);
+ $final= array();
+
+ foreach ($list as $value){
+
+ /* Set header */
+ $sortpart= split(",", $value['dn']);
+ $sortpart= array_reverse($sortpart);
+ $tmp= implode(",", $sortpart);
+
+ $final[$value['dn']]= $tmp."!"._("Global options");
+
+ /* Read all sub entries to place here */
+ $ldap->cd($value['dn']);
+ $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpLog)(objectClass=dhcpClass)(objectClass=dhcpSubClass)(objectClass=dhcpHost)(objectClass=dhcpGroup)(objectClass=dhcpPool)(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork)(objectClass=dhcpOptions)(objectClass=dhcpTSigKey)(objectClass=dhcpDnsZone)(objectClass=dhcpFailOverPeer))", array());
+ $this->serviceDN= $value['dn'];
+
+ while ($attrs= $ldap->fetch()){
+ $sattrs= array();
+ for ($i= 0; $i<$attrs['count']; $i++){
+ $sattrs[$attrs[$i]]= $attrs[$attrs[$i]];
+ unset($sattrs[$attrs[$i]]['count']);
+ }
+ $sattrs['dn']= $ldap->getDN();
+
+ foreach($sattrs as $name => $values){
+ if($name == "dhcpOption"){
+ foreach($values as $key => $value){
+ $value_name = trim(preg_replace("/[^ ]*$/","",$value));
+ $value_value= trim(preg_replace("/^[^ ]*/","",$value));
+ if(in_array($value_name,$this->quote_option)){
+ $value_value = preg_replace("/^\"/","",$value_value);
+ $value_value = preg_replace("/\"$/","",$value_value);
+ $sattrs[$name][$key] = $value_name." ".$value_value;
+ }
+ }
+ }
+ }
+
+ $this->dhcpObjectCache[$ldap->getDN()]= $sattrs;
+ $tmp= preg_replace("/".$this->serviceDN."/", "", $ldap->getDN());
+ $indent= substr_count($tmp, ",");
+ $spaces= "";
+ for ($i= 0; $i<$indent; $i++){
+ $spaces.= " ";
+ }
+
+ foreach ($this->types as $key => $val){
+ if (in_array("$key", $attrs['objectClass'])){
+ $type= $val;
+ break;
+ }
+ }
+
+ /* Prepare for sorting... */
+ $sortpart= split(",", $ldap->getDN());
+ $sortpart= array_reverse($sortpart);
+ $tmp= implode(",", $sortpart);
+ $final[$ldap->getDN()]= $tmp."!".$spaces.$type." '".$attrs['cn'][0]."'";
+ }
+ }
+
+ /* Sort it... */
+ natsort($final);
+ $this->dhcpSections= array();
+ foreach ($final as $key => $val){
+ $this->dhcpSections[$key]= preg_replace('/^[^!]+!(.*)$/', '\\1', $val);
+ }
+
+ }
+
+
+ function objectType($dn)
+ {
+ $type= "";
+ $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost",
+ "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork");
+
+ foreach ($this->dhcpObjectCache[$dn]['objectClass'] as $oc){
+ if (in_array($oc, $types)){
+ $type= $oc;
+ break;
+ }
+ }
+
+ /* That should not happen... */
+ if ($type == ""){
+ print_red(_("DHCP configuration set is unknown. Please contact your system administrator."));
+ }
+
+ return ($type);
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("DHCP service"),
+ "plDescription" => _("DHCP service")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 84,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+
+ )
+ ));
+ }
+
+
+ function take_over_service()
+ {
+
+ }
+
+
+ function get_list_of_dhcp_servers()
+ {
+ $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array());
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=goServer)(dhcpServiceDN=*))",array("dn","cn","dhcpServiceDN"));
+ while($attrs = $ldap->fetch()){
+
+ /* Skip own config */
+ if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){
+ continue;
+ }
+
+ $ret['ENTRIES'][] = $attrs;
+ }
+ foreach($ret['ENTRIES'] as $key => $data){
+ $ret['FOR_LIST'][$key] = $data['cn'][0];
+ }
+ return($ret);
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("DHCP service");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcpNewSection.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcpNewSection.tpl
--- /dev/null
@@ -0,0 +1,25 @@
+<div style="font-size: 18px;">
+ {t}Create new DHCP section{/t}
+</div>
+<br>
+<p class="seperator">
+<b>{t}Please choose one of the following DHCP section types.{/t}</b>
+</p>
+<br>
+{t}Section{/t}
+<select size="1" id="section" name="section" title="{t}Choose section type to create{/t}">
+ {html_options options=$sections}
+</select>
+
+<p class="plugbottom">
+ <input type=submit name="create_section" value="{t}Create{/t}">
+
+ <input type=submit name="cancel_section" value="{t}Cancel{/t}">
+</p>
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+ <!--
+ focus_field('section');
+ -->
+</script>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_advanced.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_advanced.tpl
--- /dev/null
@@ -0,0 +1,46 @@
+{* GOsa dhcp sharedNetwork - smarty template *}
+
+<p class='seperator'></p>
+<br>
+
+{if $show_advanced}
+
+<input type='submit' name='hide_advanced' value='{t}Hide advanced settings{/t}'>
+
+<table width="100%">
+ <tr>
+
+ <td width="50%">
+ <br>
+ <b>{t}DHCP statements{/t}</b>
+ <br>
+ <select name='dhcpstatements' style="width:100%;" size="14">
+ {html_options values=$dhcpstatements output=$dhcpstatements}
+ </select>
+ <br>
+ <input type='text' name='addstatement' size='25' maxlength='80'>
+ <input type='submit' name='add_statement' value='{t}Add{/t}'>
+ <input type='submit' name='delete_statement' value='{t}Delete{/t}'>
+ </td>
+
+ <td>
+ <br>
+ <b>{t}DHCP options{/t}</b>
+ <br>
+ <select name='dhcpoptions' style="width:100%;" size="14">
+ {html_options values=$dhcpoptions output=$dhcpoptions}
+ </select>
+ <br>
+ <input type='text' name='addoption' size='25' maxlength='80'>
+ <input type='submit' name='add_option' value='{t}Add{/t}'>
+ <input type='submit' name='delete_option' value='{t}Delete{/t}'>
+ </td>
+ </tr>
+</table>
+
+{else}
+
+<input type='submit' name='show_advanced' value='{t}Show advanced settings{/t}'>
+
+{/if}
+<p class='seperator'> </p>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_group.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_group.tpl
--- /dev/null
@@ -0,0 +1,22 @@
+{* GOsa dhcp sharedNetwork - smarty template *}
+<p><b>{t}Generic{/t}</b></p>
+<table>
+ <tr>
+ <td>
+ {t}Name{/t}{$must}
+ </td>
+ <td>
+ <input id='cn' type='text' name='cn' size='25' maxlength='80' value='{$cn}'
+ title='{t}Name of group{/t}'>
+ </td>
+ </tr>
+</table>
+
+<p class="seperator"> </p>
+
+<!-- Place cursor in correct field -->
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('cn');
+ -->
+</script>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_host.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_host.tpl
--- /dev/null
@@ -0,0 +1,52 @@
+{* GOsa dhcp host - smarty template *}
+<p><b>{t}Generic{/t}</b></p>
+<table width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top">
+ <table>
+ <tr>
+ <td>{t}Name{/t}{$must}</td>
+ <td>
+ <input {if $realGosaHost} disabled {/if} id='cn' type='text' name='cn' size='25' maxlength='80' value='{$cn}'
+ title='{t}Name of host{/t}'>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Fixed address{/t}</td>
+ <td>
+ <input {if $realGosaHost} disabled {/if}
+ type='text' name='fixedaddr' size='25' maxlength='80' value='{$fixedaddr}'
+ title='{t}Use hostname or IP-address to assign fixed address{/t}'>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table>
+ <tr>
+ <td>{t}Hardware type{/t}</td>
+ <td>
+ <select name='hwtype' {if $realGosaHost} disabled {/if} >
+ {html_options options=$hwtypes selected=$hwtype}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Hardware address{/t}{$must}</td>
+ <td>
+ <input {if $realGosaHost} disabled {/if} type='text' name='dhcpHWAddress' size='20' maxlength='18' value='{$dhcpHWAddress}'>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+<input type='hidden' name='dhcp_host_posted' value='1'>
+<p class="seperator"></p>
+
+<!-- Place cursor in correct field -->
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('cn');
+ -->
+</script>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_network.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_network.tpl
--- /dev/null
@@ -0,0 +1,90 @@
+{* GOsa dhcp sharedNetwork - smarty template *}
+<table width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top">
+ <p><b>{t}Network configuration{/t}</b></p>
+ <table>
+ <tr>
+ <td>{t}Router{/t}</td>
+ <td>
+ <input id='routers' type='text' name='routers' size='25' maxlength='80' value='{$routers}'
+ title='{t}Enter name or IP address of router to be used in this section{/t}'>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Netmask{/t}</td>
+ <td>
+ <input type='text' name='subnet_mask' size='18' maxlength='15' value='{$subnet_mask}'>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Broadcast{/t}</td>
+ <td>
+ <input type='text' name='broadcast_address' size='18' maxlength='15' value='{$broadcast_address}'>
+ </td>
+ </tr>
+ </table>
+ <br>
+ <br>
+ <p><b>{t}Bootup{/t}</b></p>
+ <table>
+ <tr>
+ <td>{t}Filename{/t}</td>
+ <td>
+ <input type='text' name='filename' size='25' maxlength='80' value='{$filename}'
+ title='{t}Enter name of file that will be loaded via tftp after client has started{/t}'>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Next server{/t}</td>
+ <td>
+ <input type='text' name='nextserver' size='25' maxlength='80' value='{$nextserver}'
+ title='{t}Enter name of server to retrieve bootimages from{/t}'>
+ </td>
+ </tr>
+ </table>
+
+ </td>
+ <td style="vertical-align:top">
+ <p><b>{t}Domain Name Service{/t}</b></p>
+ <table>
+ <tr>
+ <td>{t}Domain{/t}</td>
+ <td>
+ <input type='text' name='domain' size='25' maxlength='80' value='{$domain}'
+ title='{t}Name of domain{/t}'>
+ </td>
+ </tr>
+ <tr>
+ <td colspan=2>
+ <br>
+ {t}DNS server{/t}<br>
+ <select name='dnsserver' title='{t}List of DNS servers to be propagated{/t}' style="width:350px;" size="4">
+ {html_options options=$dnsservers}
+ </select>
+ <br>
+ <input type='text' name='addserver' size='25' maxlength='80' title='{t}DNS server do be added{/t}'>
+ <input type='submit' name='add_dns' value='{t}Add{/t}' title='{t}Click here add the selected server to the list{/t}'>
+ <input type='submit' name='delete_dns' value='{t}Delete{/t}' title='{t}Click here remove the selected servers from the list{/t}'>
+ </td>
+ </tr>
+ <tr>
+ <td colspan=2>
+ <p><b>{t}Domain Name Service options{/t}</b></p>
+ <input type=checkbox name="autohost" value="1" {$autohost}>{t}Assign hostnames found via reverse mapping{/t}
+ <br>
+ <input type=checkbox name="autohostdecl" value="1" {$autohostdecl}>{t}Assign hostnames from host declarations{/t}
+ </td>
+ </tr>
+ </table>
+
+ </td>
+ </tr>
+</table>
+<!-- Place cursor in correct field -->
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('cn','routers');
+ -->
+</script>
+
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_pool.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_pool.tpl
--- /dev/null
@@ -0,0 +1,26 @@
+{* GOsa dhcp sharedNetwork - smarty template *}
+<p><b>{t}Generic{/t}</b></p>
+<table width="100%">
+ <tr>
+ <td width="50%">
+ {t}Name{/t}{$must}
+ <input id='cn' type='text' name='cn' size='25' maxlength='80' value='{$cn}'
+ title='{t}Name of pool{/t}'>
+ </td>
+ <td>
+ {t}Range{/t}{$must}
+ <input type='text' name='range_start' size='25' maxlength='30' value='{$range_start}'>
+ -
+ <input type='text' name='range_stop' size='25' maxlength='30' value='{$range_stop}'>
+ </td>
+ </tr>
+</table>
+
+<p class="seperator"> </p>
+
+<!-- Place cursor in correct field -->
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ document.mainform.cn.focus();
+ -->
+</script>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_service.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_service.tpl
--- /dev/null
@@ -0,0 +1,43 @@
+<p><b>{t}Generic{/t}</b></p>
+
+<table width="100%">
+ <tr>
+ <td width="50%">
+ <input id='authoritative' type=checkbox name="authoritative" value="1" {$authoritative}> {t}Authoritative service{/t}<br>
+ <br>
+ {t}Dynamic DNS update{/t}
+ <select name='ddns_update_style' title='{t}Dynamic DNS update style{/t}' size="1">
+ {html_options values=$ddns_styles output=$ddns_styles selected=$ddns_update_style}
+ </select>
+ </td>
+
+ <td style='vertical-align:top'>
+
+ <table>
+ <tr>
+ <td>{t}Default lease time (s){/t}</td>
+ <td>
+ <input type='text' name='default_lease_time' size='25' maxlength='80' value='{$default_lease_time}' title='{t}Enter default lease time in seconds.{/t}'>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Maximum lease time (s){/t}</td>
+ <td>
+ <input type='text' name='max_lease_time' size='25' maxlength='80' value='{$max_lease_time}' title='{t}Enter maximum lease time in seconds.{/t}'>
+ </td>
+ </tr>
+ </table>
+
+ </td>
+
+ </tr>
+</table>
+
+<p class="seperator"></p>
+
+<!-- Place cursor in correct field -->
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('authoritative');
+ -->
+</script>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl
--- /dev/null
@@ -0,0 +1,107 @@
+{* GOsa dhcp sharedNetwork - smarty template *}
+<p><b>{t}Generic{/t}</b></p>
+<table width="100%" border="0">
+ <tr>
+
+ <td width="50%">
+
+ <table>
+ <tr>
+ <td>{t}Name{/t}{$must}</td>
+ <td>
+ <input id='cn' type='text' name='cn' size='25' maxlength='80' value='{$cn}' title='{t}Name for shared network{/t}'>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Server identifier{/t}</td>
+ <td>
+ <input type='text' name='server-identifier' size='25' maxlength='80' value='{$server_identifier}'
+ title='{t}Propagated server identifier for this shared network{/t}'>
+ </td>
+ </tr>
+ </table>
+
+ </td>
+
+ <td style="vertical-align:top;">
+ <table>
+ <tr>
+ <td>
+ <input type=checkbox name="authoritative" value="1" {$authoritative}
+ title="{t}Select if this server is authoritative for this shared network{/t}">{t}Authoritative server{/t}
+ </td>
+ </tr>
+ </table>
+ </td>
+
+ </tr>
+</table>
+
+<p class="seperator"> </p>
+
+<table width="100%">
+ <tr>
+ <td width="50%">
+
+ <p><b>{t}Leases{/t}</b></p>
+ <table>
+ <tr>
+ <td>{t}Default lease time{/t}</td>
+ <td>
+ <input type='text' name='default-lease-time' size='10' maxlength='25' value='{$default_lease_time}'
+ title='{t}Default lease time{/t}'> {t}seconds{/t}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Max. lease time{/t}</td>
+ <td>
+ <input type='text' name='max-lease-time' size='10' maxlength='25' value='{$max_lease_time}'
+ title='{t}Maximum lease time{/t}'> {t}seconds{/t}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Min. lease time{/t}</td>
+ <td>
+ <input type='text' name='min-lease-time' size='10' maxlength='25' value='{$min_lease_time}'
+ title='{t}Minimum lease time{/t}'> {t}seconds{/t}
+ </td>
+ </tr>
+ </table>
+
+ </td>
+
+ <td style="vertical-align:top">
+ <p><b>{t}Access control{/t}</b></p>
+ <table>
+ <tr>
+ <td>
+ <input type=checkbox name="unknown-clients" value="1" {$allow_unknown_state}
+ title="{t}Select if unknown clients should get dynamic IP addresses{/t}">{t}Allow unknown clients{/t}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input type=checkbox name="bootp" value="1" {$allow_bootp_state}
+ title="{t}Select if bootp clients should get dynamic IP addresses{/t}">{t}Allow bootp clients{/t}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input type=checkbox name="booting" value="1" {$allow_booting_state}
+ title="{t}Select if clients are allowed to boot using this DHCP server{/t}">{t}Allow booting{/t}
+ </td>
+ </tr>
+ </table>
+ </td>
+
+ </tr>
+</table>
+
+<p class="seperator"> </p>
+
+<!-- Place cursor in correct field -->
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ document.mainform.cn.focus();
+ -->
+</script>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_subnet.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/dhcp_subnet.tpl
--- /dev/null
@@ -0,0 +1,41 @@
+{* GOsa dhcp subnet - smarty template *}
+<p><b>{t}Generic{/t}</b></p>
+<table width="100%">
+ <tr>
+ <td width="50%">
+ <table>
+ <tr>
+ <td>{t}Network address{/t}{$must}</td>
+ <td><input id='cn' type='text' name='cn' size='25' maxlength='80' value='{$cn}'></td>
+ </tr>
+ <tr>
+ <td>{t}Netmask{/t}{$must}</td>
+ <td><input type='text' name='dhcp_netmask' size='25' maxlength='80' value='{$dhcp_netmask}'></tr>
+ </table>
+ </td>
+ <td style='vertical-align:top'>
+ <table>
+ <tr>
+ <td><input type="checkbox" name="use_range" value="1" onChange="changeState('range_start');changeState('range_stop');" {$use_range}></td>
+ <td>{t}Range for dynamic address assignment{/t}</td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td><input type='text' id='range_start' name='range_start' size='25' maxlength='80' value='{$range_start}' {$range_disabled}>
+ <b>-</b>
+ <input type='text' id='range_stop' name='range_stop' size='25' maxlength='80' value='{$range_stop}' {$range_disabled}>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+<input type='hidden' name='dhcp_subnet_posted' value='1'>
+<p class="seperator"></p>
+
+<!-- Place cursor in correct field -->
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('cn');
+ -->
+</script>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/remove_dhcp.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/remove_dhcp.tpl
--- /dev/null
@@ -0,0 +1,17 @@
+<div style="font-size:18px;">
+<img alt="" src="images/button_cancel.png" align=top> {t}Warning{/t}
+</div>
+<p>
+ {$warning}
+ {t}This includes 'all' DHCP subsections that are located within this section. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
+</p>
+
+<p>
+ {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t}
+</p>
+
+<p class="plugbottom">
+ <input type=submit name="delete_dhcp_confirm" value="{t}Delete{/t}">
+
+ <input type=submit name="cancel_section" value="{t}Cancel{/t}">
+</p>
diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/servdhcp.tpl b/gosa-plugins/dhcp/admin/systems/services/dhcp/servdhcp.tpl
--- /dev/null
@@ -0,0 +1,35 @@
+{if $dns_take_over}
+<table summary="" width="100%">
+ <tr>
+ <td style="width:100%;vertical-align:top;">
+ <h2>{t}DHCP take over will take place when saving this entry. Choose 'Cancel' to abort.{/t}</h2>
+ </td>
+ </tr>
+</table>
+{else}
+<table summary="" width="100%">
+{if $dhcp_server_list_cnt}
+<tr>
+ <td style="width:100%;vertical-align:top;">
+ <b>{t}Take over dhcp configuration from following server{/t}</b>
+ <select name='take_over_src'>
+ {html_options options=$dhcp_server_list}
+ </select>
+ <input type="submit" name="take_over" value="{t}Apply{/t}">
+ </td>
+</tr>
+{/if}
+<tr>
+ <td style="width:100%;vertical-align:top;">
+ <h2>{t}DHCP sections{/t}</h2>
+ {$DhcpList}
+ </td>
+</tr>
+</table>
+{/if}
+<p class='seperator'> </p>
+<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
+ <input type='submit' name='SaveService' value='{t}Save{/t}'>
+
+ <input type='submit' name='CancelService' value='{t}Cancel{/t}'>
+</div