summaryrefslogtreecommitdiffstats
path: root/ldap-site-mngmt/webinterface/ip/ip_rechner_change.php
blob: 68023cb0c706a84ea89e28f4d89b39fd67d5b199 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php

include('../standard_header.inc.php');

$auDN = $_POST['audn'];
$hostDN = $_POST['hostdn'];
$oldip = $_POST['oldip'];
$newip = $_POST['newip'];
# print_r($newip);echo "<br>";
# print_r($oldip);echo "<br>";

$syntax = new Syntaxcheck;
$url = "ip_rechner.php";

echo "
<html>
<head>
	<title>IP Address Management</title>
	<link rel='stylesheet' href='../styles.css' type='text/css'>
</head>
<body>
<table border='0' cellpadding='30' cellspacing='0'> 
<tr><td>";


$diff1 = array_keys(array_diff_assoc($oldip,$newip)); 
$diff2 = array_keys(array_diff_assoc($newip,$oldip));
$tochange = array_unique(array_merge($diff1,$diff2));
# print_r($diff1);echo "<br>";
# print_r($diff2);echo "<br>";
# print_r($tochange);echo "<br><br>";

foreach ($tochange as $i){

	if ( $oldip[$i] == "" && $newip[$i] != "" ){
		echo "neue IP";echo "<br>";echo "<br>";
		#print_r($auDN[$i]);echo "<br>";
		#print_r($hostDN[$i]);echo "<br>";
		echo "<br>";
		echo "alte IP: ";print_r($oldip[$i]);echo "<br>";
		echo "neue IP: ";print_r($newip[$i]);echo "<br>";
		
		if ($syntax->check_ip_syntax($newip[$i])){
			echo "korrekte IP Syntax";
			$newip[$i] = htmlentities($newip[$i]);
			$newip_array = array($newip[$i],$newip[$i]);
			#print_r($newip_array);
			$newipp = implode('_',$newip_array);
			#print_r($newipp);
			$oldip[$i] = htmlentities($oldip[$i]);
			if (new_ip_host($newipp,$hostDN[$i],$auDN[$i])){
			 	$mesg = "Neue IP Adresse eingetragen<br>";
			}else{$mesg = "Fehler beim eintragen der neuen IP Adresse<br>";}
		}else{echo "falsche IP Syntax";}
		
		$mesg .= "<br>Sie werden automatisch auf die vorherige Seite zur&uuml;ckgeleitet. <br>
				Falls nicht, klicken Sie hier <a href='ip_rechner.php' style='publink'>back</a>";
		redirect(4, $url, $mesg, $addSessionId = TRUE);
	}
	
	elseif ( $oldip[$i] != "" && $newip[$i] != "" ){
		echo "aendern IP";echo "<br>";echo "<br>";
		#print_r($auDN[$i]);echo "<br>";
		#print_r($hostDN[$i]);echo "<br>";
		echo "<br>";
		echo "alte IP: ";print_r($oldip[$i]);echo "<br>";
		echo "neue IP: ";print_r($newip[$i]);echo "<br>";
		
		if ($syntax->check_ip_syntax($newip[$i])){
			echo "korrekte IP Syntax";
			$newip[$i] = htmlentities($newip[$i]);
			$newip_array = array($newip[$i],$newip[$i]);
			#print_r($newip_array);
			$newipp = implode('_',$newip_array);
			#print_r($newipp);
			$oldip[$i] = htmlentities($oldip[$i]);
			$oldip_array = array($oldip[$i],$oldip[$i]); 
			$oldipp = implode('_',$oldip_array);
			if (modify_ip_host($newipp,$hostDN[$i],$auDN[$i])){
				$mesg = "IP Adresse geaendert<br>";
			}else{
				$mesg = "Fehler beim aendern der IP Adresse<br>";
				# oldip die schon gelöscht wurde wieder einfügen
				new_ip_host($oldipp,$hostDN[$i],$auDN[$i]);}
		}else{echo "falsche IP Syntax";}
		
		$mesg .= "<br>Sie werden automatisch auf die vorherige Seite zur&uuml;ckgeleitet. <br>
				Falls nicht, klicken Sie hier <a href='ip_rechner.php' style='publink'>back</a>";
		redirect(4, $url, $mesg, $addSessionId = TRUE);
	}

	elseif ( $oldip[$i] != "" && $newip[$i] == "" ){
		echo "loeschen IP";echo "<br>";echo "<br>";
		#print_r($auDN[$i]);echo "<br>";
		#print_r($hostDN[$i]);echo "<br>";
		echo "<br>";
		echo "alte IP: ";print_r($oldip[$i]);echo "<br>";
		echo "neue IP: ";print_r($newip[$i]);echo "<br>";
		
		echo "korrekte IP Syntax";
		$newip[$i] = htmlentities($newip[$i]);
		$oldip[$i] = htmlentities($oldip[$i]);
		if (delete_ip_host($hostDN[$i],$auDN[$i])){
			$mesg = "IP Adresse geloescht<br>";
		}else{$mesg = "Fehler beim loeschen der IP Adresse<br>";}
		
		$mesg .= "<br>Sie werden automatisch auf die vorherige Seite zur&uuml;ckgeleitet. <br>
				Falls nicht, klicken Sie hier <a href='ip_rechner.php' style='publink'>back</a>";
		redirect(4, $url, $mesg, $addSessionId = TRUE);
	}
	
	else{
		$mesg = "keine Aenderung<br>";
		$mesg .= "<br>Sie werden automatisch auf die vorherige Seite zur&uuml;ckgeleitet. <br>
				Falls nicht, klicken Sie hier <a href='ip_rechner.php' style='publink'>back</a>";
		redirect(3, $url, $mesg, $addSessionId = TRUE);
	}

}

echo "
</td></tr></table>
</head>
</html>";
?>