-
Notifications
You must be signed in to change notification settings - Fork 1
/
dhcp3_add.php
136 lines (123 loc) · 5.6 KB
/
dhcp3_add.php
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
126
127
128
129
130
131
132
133
134
135
136
<?php
// Add DHCP3 subnetwork
// $Id: dhcp3_add.php,v 2.2 2007-09-13 17:47:52 turbo Exp $
// {{{ Setup session etc
require("./include/pql_session.inc");
require($_SESSION["path"]."/include/pql_config.inc");
// }}}
if(isset($_REQUEST['action'])) {
if($_REQUEST['action'] == 'subnet') {
if($_REQUEST["Submit"]) {
// {{{ Add the subnet
$dn = pql_get_define("PQL_ATTR_CN").'='.$_REQUEST["network"].','.$_REQUEST["config"];
$entry = array();
$entry[pql_get_define("PQL_ATTR_CN")] = $_REQUEST["network"];
$entry[pql_get_define("PQL_ATTR_OBJECTCLASS")][] = pql_get_define("PQL_ATTR_DHCP3_SUBNET");
$entry[pql_get_define("PQL_ATTR_OBJECTCLASS")][] = pql_get_define("PQL_ATTR_DHCP3_OPTIONS");
$entry[pql_get_define("PQL_ATTR_DHCP3_NETMASK")] = $_REQUEST["netmask"];
$entry[pql_get_define("PQL_ATTR_DHCP3_RANGE")] = $_REQUEST["range"];
if($_pql->add($dn, $entry, 'dhcp3', 'dhcp3_add.php/subnet'))
$msg = pql_complete_constant($LANG->_("DHCP subhost %subnet% added successfully."),
array('subnet' => $_REQUEST['subnet']));
else
$msg = pql_complete_constant($LANG->_("Failed to add DHCP subhost %subnet%."),
array('subnet' => $_REQUEST['subnet']));
$link = "domain_detail.php?rootdn=".urlencode($_REQUEST["rootdn"])."&domain=".urlencode($_REQUEST["domain"])."&view=".$_REQUEST["view"];
$link .= "&config=".$_REQUEST["config"]."&setup=".urlencode($dn);
$link .= "&msg=".urlencode($msg);
pql_header($link);
// }}}
} else {
// {{{ Output a form to add subnet
require($_SESSION["path"]."/header.html");
?>
<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post">
<table cellspacing="1" cellpadding="3" border="0">
<th colspan="3" align="left"><?php echo $LANG->_("Add New Computer")?>
<tr class="<?php pql_format_table(); ?>">
<td class="title"><?php echo $LANG->_("Network")?></td>
<td>
<input type="text" name="network" size="15" value="<?php echo $_REQUEST['network']?>">
</td>
</tr>
<tr class="<?php pql_format_table(); ?>">
<td class="title"><?php echo $LANG->_("Network mask")?></td>
<td>
<input type="text" name="netmask" size="5" value="<?php echo $_REQUEST['netmask']?>" size="2">
</td>
</tr>
<tr class="<?php pql_format_table(); ?>">
<td class="title"><?php echo $LANG->_('Network range')?></td>
<td><input type="text" name="range" value="<?php echo $_REQUEST["range"]?>" size="31">
</tr>
</th>
</table>
<input type="hidden" name="view" value="dhcp">
<input type="hidden" name="rootdn" value="<?php echo $_REQUEST["rootdn"]?>">
<input type="hidden" name="domain" value="<?php echo $_REQUEST["domain"]?>">
<input type="hidden" name="host" value="<?php echo $_REQUEST["host"]?>">
<input type="hidden" name="config" value="<?php echo $_REQUEST["config"]?>">
<input type="hidden" name="action" value="<?php echo $_REQUEST["action"]?>">
<input type="submit" name="Submit" value="<?php echo $LANG->_('Add New Host')?>">
</form>
</body>
</html>
<?php
// }}}
}
} elseif($_REQUEST['action'] == 'host') {
if($_REQUEST["Submit"]) {
// {{{ Add the host
$dn = pql_get_define("PQL_ATTR_CN").'='.$_REQUEST["hostname"].','.$_REQUEST["config"];
$entry = array();
$entry[pql_get_define("PQL_ATTR_CN")] = $_REQUEST["hostname"];
$entry[pql_get_define("PQL_ATTR_OBJECTCLASS")][] = pql_get_define("PQL_ATTR_DHCP3_HOST");
$entry[pql_get_define("PQL_ATTR_OBJECTCLASS")][] = pql_get_define("PQL_ATTR_DHCP3_OPTIONS");
if($_pql->add($dn, $entry, 'dhcp3', 'dhcp3_add.php/host'))
$msg = pql_complete_constant($LANG->_("DHCP subhost %subnet% added successfully."),
array('subnet' => $_REQUEST['subnet']));
else
$msg = pql_complete_constant($LANG->_("Failed to add DHCP subhost %subnet%."),
array('subnet' => $_REQUEST['subnet']));
$link = "domain_detail.php?rootdn=".urlencode($_REQUEST["rootdn"])."&domain=".urlencode($_REQUEST["domain"])."&view=".$_REQUEST["view"];
$link .= "&config=".$_REQUEST["config"]."&setup=".urlencode($dn);
$link .= "&msg=".urlencode($msg);
pql_header($link);
// }}}
} else {
// {{{ Output a form to add subnet
require($_SESSION["path"]."/header.html");
?>
<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post">
<table cellspacing="1" cellpadding="3" border="0">
<th colspan="3" align="left"><?php echo $LANG->_("Add New DHCP host")?>
<tr class="<?php pql_format_table(); ?>">
<td class="title"><?php echo $LANG->_("Hostname")?></td>
<td>
<input type="text" name="hostname" size="15" value="<?php echo $_REQUEST['hostname']?>">
</td>
</tr>
</th>
</table>
<input type="hidden" name="view" value="dhcp">
<input type="hidden" name="rootdn" value="<?php echo $_REQUEST["rootdn"]?>">
<input type="hidden" name="domain" value="<?php echo $_REQUEST["domain"]?>">
<input type="hidden" name="host" value="<?php echo $_REQUEST["host"]?>">
<input type="hidden" name="config" value="<?php echo $_REQUEST["config"]?>">
<input type="hidden" name="action" value="<?php echo $_REQUEST["action"]?>">
<input type="submit" name="Submit" value="<?php echo $LANG->_('Add New Host')?>">
</form>
</body>
</html>
<?php
// }}}
}
}
}
/* Local variables:
* mode: php
* mode: font-lock
* tab-width: 4
* End:
*/
?>