From: paulr Date: Fri, 10 Sep 2010 08:21:14 +0000 (+1000) Subject: working a bit X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=2569c990f8e6d6cd66bf85e0db5da9dcd671825a;p=PHPIPManager.git working a bit --- diff --git a/lib/ip.php b/lib/ip.php index e07eb30..95d71b0 100644 --- a/lib/ip.php +++ b/lib/ip.php @@ -1,6 +1,103 @@ header(); + $this->printError(); $this->mainPage(); $this->footer(); } @@ -51,7 +52,6 @@ class www { { global $db; - echo "

Welcome to PHPIPManager

"; ?>
Create Supernet: name @@ -60,16 +60,42 @@ Mask Description
- dbobject->query("select * from supernet"); + foreach($res as $row) { + //echo "
";
+		//	print_r($row);
+		//	echo "

"; + echo ""; + echo ""; + echo ""; + // now we search for sub's + echo "
".$row["sn_name"]."".$row["sn_ip"]."/".$row["sn_mask"]."".$row["sn_desc"]."Allocate SubnetDelete Supernet

"; + } + } + + function printError() + { + if(isset($_REQUEST["error"])) + { + echo "".$_REQUEST["error"].""; + } + if(isset($_REQUEST["notice"])) + { + echo "".$_REQUEST["notice"].""; + } + } - function header() + function header($title = "Welcome to PHP IP Manager") { ?> - +<?php echo $title ?> - +

dbobject->query($sql); + if(ip::isValid($sn, $mask)) { + $sn = ip::truncateNetwork($sn, $mask); + $sql = "insert into supernet values (NULL, '$name', '$sn', '$mask', '$desc')"; + $db->dbobject->query($sql); + header("Location: index.php?notice=range added"); + } else { + header("Location: index.php?error=invalid ipaddress"); + } - header("Location: index.php"); } ?> \ No newline at end of file diff --git a/unittest/ip_regex.php b/unittest/ip_regex.php new file mode 100644 index 0000000..724a19a --- /dev/null +++ b/unittest/ip_regex.php @@ -0,0 +1,9 @@ + \ No newline at end of file