X-Git-Url: http://git.pjr.cc/?p=CBFWR.git;a=blobdiff_plain;f=libcbfwr%2Fconfig.php;h=e0b4f37702f782d6fc883cef23ec4420677cfea2;hp=f2aaa521d7f4b6d6c527eaa2fcfea8f8066684f6;hb=b571fcf2648a6d5a4893125cb97db4f3f73ee134;hpb=86842492eae6203c9df0df46363b4e809d577c70 diff --git a/libcbfwr/config.php b/libcbfwr/config.php index f2aaa52..e0b4f37 100644 --- a/libcbfwr/config.php +++ b/libcbfwr/config.php @@ -114,8 +114,15 @@ class Config { function addConfigLine($line, $lineno=0) { + $line_n = trim($line); + $line = $line_n; $expl = preg_split("/ +/", $line); + if(count($expl) < 2) { + $c = count($expl); + error_log("Not a valid config line ($c), $line"); + return 0; + } echo "process command ".$expl[0]."\n"; // find a description @@ -133,7 +140,7 @@ class Config { } } - // now rebuild the array if there was one + // now rebuild the array if there was a description if($hasdescription) { for($i=0; $i<$hasdescription; $i++) { $expl_r[$i] = $expl[$i]; @@ -153,6 +160,19 @@ class Config { unset($expl[count($expl)-1]); } + // now for modify + $modify = false; + // check for delete on the line + if($expl[0] == "modify") { + $modify = true; + + // re-order the array + for($i=0; $i < (count($expl)-1); $i++) { + $expl[$i] = $expl[$i+1]; + } + unset($expl[count($expl)-1]); + } + switch($expl[0]) { case "hostname": // set the hostname to $1