summaryrefslogtreecommitdiffstats
path: root/ldap-site-mngmt/webinterface/dhcp/dhcppool_add.php
diff options
context:
space:
mode:
Diffstat (limited to 'ldap-site-mngmt/webinterface/dhcp/dhcppool_add.php')
-rw-r--r--ldap-site-mngmt/webinterface/dhcp/dhcppool_add.php88
1 files changed, 47 insertions, 41 deletions
diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcppool_add.php b/ldap-site-mngmt/webinterface/dhcp/dhcppool_add.php
index c6cef33a..416654e2 100644
--- a/ldap-site-mngmt/webinterface/dhcp/dhcppool_add.php
+++ b/ldap-site-mngmt/webinterface/dhcp/dhcppool_add.php
@@ -8,7 +8,7 @@ $range2 = $_POST['addrange2'];
$unknownclients = $_POST['unknownclients'];
$mnr = $_POST['mnr'];
-$seconds = 200;
+$seconds = 2;
$url = "dhcppool.php?mnr=".$mnr;
echo "
@@ -28,57 +28,63 @@ if ($syntax->check_ip_syntax($range1) && $syntax->check_ip_syntax($range2)){
$fe = explode('.',$range2);
if ( $fs[0] == $fe[0] && $fs[1] == $fe[1] && $fs[2] == $fe[2] ) {
if ( $fs[3] <= $fe[3] ){
- # Range zusammenstellen
- $range = implode("_", array($range1,$range2));
- # Freie IP Bereiche testen
- $fipb_array = get_freeipblocks_au($auDN);
- for ($i=0; $i < count($fipb_array); $i++){
- if ( split_iprange($range,$fipb_array[$i]) != 0 ){
- $ipranges = split_iprange($range,$fipb_array[$i]);
- array_splice($fipb_array, $i, 1, $ipranges);
- break;
- }
+ # DHCP Subnet DN finden
+ $subnet = implode(".", array($fs[0],$fs[1],$fs[2],"0"));
+ print_r($subnet);echo"<br><br>";
+ if(!($result = uniLdapSearch($ds, "ou=RIPM,".$suffix, "(&(objectclass=dhcpSubnet)(cn=$subnet))", array("dn","dhcphlpcont"), "", "sub", 0, 0))) {
+ # redirect(5, "", $ldapError, FALSE);
+ echo "no search";
+ die;
}
- if ($i < count($fipb_array) ){
- foreach ( $fipb_array as $item ){
- $entry ['FreeIPBlock'][] = $item;
- }
- $results = ldap_mod_replace($ds,$auDN,$entry);
- if ($results){
- echo "<br>Neue FIPBs erfolgreich eingetragen!<br>";
-
- # DHCP Subnet DN finden
- $subnet = implode(".", array($fs[0],$fs[1],$fs[2],"0"));
- print_r($subnet);echo"<br><br>";
- if(!($result = uniLdapSearch($ds, "ou=RIPM,".$suffix, "(&(objectclass=dhcpSubnet)(cn=$subnet))", array("dn","dhcphlpcont"), "", "sub", 0, 0))) {
- # redirect(5, "", $ldapError, FALSE);
- echo "no search";
- die;
- }
- $result = ldapArraySauber($result);
- print_r($result);echo "<br><br>";
- if (count($result[0]) != 0){
- $result = add_dhcppool($result[0]['dn'],$range,$unknownclients,$result[0]['dhcphlpcont']);
+ $result = ldapArraySauber($result);
+ #print_r($result);echo "<br><br>";
+ if (count($result[0]) != 0){
+
+ $subnetdn = $result[0]['dn'];
+ $subnetdnexp = ldap_explode_dn( $subnetdn, 0);
+ $subnetauexp = array_slice($subnetdnexp, 3);
+ $subnetau = implode(',',$subnetauexp);
+
+ # Range zusammenstellen
+ $range = implode("_", array($range1,$range2));
+
+ # Freie IP Bereiche testen
+ $fipb_array = get_freeipblocks_au($auDN);
+ for ($i=0; $i < count($fipb_array); $i++){
+ if ( split_iprange($range,$fipb_array[$i]) != 0 ){
+ $ipranges = split_iprange($range,$fipb_array[$i]);
+ array_splice($fipb_array, $i, 1, $ipranges);
+ break;
+ }
+ }
+ if ($i < count($fipb_array) ){
+ foreach ( $fipb_array as $item ){
+ $entry ['FreeIPBlock'][] = $item;
+ }
+ $results = ldap_mod_replace($ds,$auDN,$entry);
+ if ($results){
+ echo "<br>Neue FIPBs erfolgreich eingetragen!<br>";
+ $result = add_dhcppool($subnetdn,$range,$unknownclients,$result[0]['dhcphlpcont']);
if ($result){
echo "<br>Dynamischer DHCP Pool erfolgreich eingetragen!<br>" ;
- update_dhcpmtime();
+ update_dhcpmtime(array($subnetau));
}else{
echo "<br>Fehler beim eintragen des dynamischen DHCP Pools!<br>";
# Range wieder in FIPBs aufnehmen.
$entry2 ['FreeIPBlock'] = $range;
ldap_mod_add($ds,$auDN,$entry2);
merge_ipranges($auDN);
- }
- }else{
- echo "DHCP Subnet nicht im System vorhanden!<br>";
- }
- }else{
- echo "<br>Fehler beim eintragen der FIPBs!<br>";
- }
+ }
+ }else{
+ echo "<br>Fehler beim eintragen der FIPBs!<br>";
+ }
+ }else{
+ printf("<br>IP Range %s ist nicht im verfuegbaren Bereich!<br>", $range );
+ }
}else{
- printf("<br>IP Range %s ist nicht im verfuegbaren Bereich!<br>", $range );
- }
+ echo "DHCP Subnet nicht im System vorhanden!<br>";
+ }
}else{
echo "erster Range Wert gr&ouml;sser als zweiter Range Wert<br>";
}