index c0da9bf10bbcbd0fb1826e45f35e6a62cdf70fc1..b13083fb3f7431eaf0466f2047881c4293ccf9b5 100644 (file)
if (isset($attrs['dhcpOption'])){
foreach ($attrs['dhcpOption'] as $opt){
$idx= preg_replace('/\s.+$/', '', $opt);
- $value= preg_replace('/^[^\s]+\s/', '', $opt);
+ if ($idx == $opt){
+ $value= "";
+ } else {
+ $value= preg_replace('/^[^\s]+\s/', '', $opt);
+ }
$this->options[$idx]= $value;
}
}
if (isset($attrs['dhcpStatements'])){
foreach ($attrs['dhcpStatements'] as $opt){
$idx= preg_replace('/\s.+$/', '', $opt);
- $value= preg_replace('/^[^\s]+\s/', '', $opt);
+ if ($idx == $opt){
+ $value= "";
+ } else {
+ $value= preg_replace('/^[^\s]+\s/', '', $opt);
+ }
$this->statements[$idx]= $value;
}
}
foreach (array("routers", "domain-name", "subnet-mask", "broadcast-address") as $toberemoved){
unset($this->options[$toberemoved]);
}
- foreach (array("filename", "next-server") as $toberemoved){
+ foreach (array("filename", "next-server","get-lease-hostnames","use-host-decl-names") as $toberemoved){
unset($this->statements[$toberemoved]);
}
/* Merge arrays for advanced view */
foreach (array("options", "statements") as $type){
- $tmp= array_merge($this->$type, $this->network->$type);
- $this->advanced->$type= $tmp;
+ $this->advanced->$type= $this->$type + $this->network->$type;;
}
}
function check($cache)
{
$message= array();
-
return $message;
}
{
/* Merge arrays for network and advanced view */
foreach (array("options", "statements") as $type){
- $tmp= array_merge($this->$type, $this->network->$type, $this->advanced->$type);
- $this->$type= $tmp;
+ $this->$type= $this->$type + $this->network->$type + $this->advanced->$type;
}
/* Add cn if we're new */
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]);
+ }
+ }
+
}
?>