upload adapted for comma sep macs, subnet is ip4 addr and post instead of get query

This commit is contained in:
sandb 2009-12-29 16:46:33 +01:00
parent 6899918fce
commit 6366bfdef4

View File

@ -32,8 +32,8 @@ class Upload {
private $macs; private $macs;
function __construct() { function __construct() {
$this->subnet = intvaldef(getQuery("sn"), NULL); $this->subnet = getPost("sn");
$this->macs = getQuery("macs"); $this->macs = getPost("macs");
} }
private function parseAndValidate() { private function parseAndValidate() {
@ -45,11 +45,23 @@ class Upload {
echoln("Missing macs param"); echoln("Missing macs param");
return false; return false;
} }
if (($this->subnet < 0) || ($this->subnet > 4294967295)) {
if (preg_match("/^(\d{1,3}\.){3}\d{1,3}$/", $this->subnet) != 1) {
echoln("subnet ($this->subnet) is not valid"); echoln("subnet ($this->subnet) is not valid");
return false; return false;
} }
$mcs = explode('|', $this->macs);
$snParts = explode('.', $this->subnet);
foreach($snParts as $part) {
$i = intvaldef($part, -1);
if (($i >= 0) && ($i <= 255))
continue;
echoln("subnet ($this->subnet) contains invalid parts ($part)");
return false;
}
$mcs = explode(',', $this->macs);
foreach($mcs as $mac) { foreach($mcs as $mac) {
if (preg_match("/^(([\dABCDEF]){2}:){5}([\dABCDEF]){2}$/i", $mac) == 1) if (preg_match("/^(([\dABCDEF]){2}:){5}([\dABCDEF]){2}$/i", $mac) == 1)
continue; continue;