You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by jf...@apache.org on 2011/10/27 20:56:55 UTC

svn commit: r1189936 - /incubator/vcl/trunk/web/.ht-inc/computers.php

Author: jfthomps
Date: Thu Oct 27 18:56:55 2011
New Revision: 1189936

URL: http://svn.apache.org/viewvc?rev=1189936&view=rev
Log:
VCL-533
error when trying to download dhcp data when private IP address was not entered

modified submitAddBulkComputers - added check that $dopr is also true to print the generate dhcp form
modified processBulkComputerInput - found this in testing the above - no checks were done for duplicate mac addresses - added checks for that

Modified:
    incubator/vcl/trunk/web/.ht-inc/computers.php

Modified: incubator/vcl/trunk/web/.ht-inc/computers.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/computers.php?rev=1189936&r1=1189935&r2=1189936&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/computers.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/computers.php Thu Oct 27 18:56:55 2011
@@ -1622,7 +1622,7 @@ function submitAddBulkComputers() {
 	else
 		print $count - $addedrows . " computers failed to get added<br><br>\n";
 	print "</div>\n";
-	if($domacs)
+	if($domacs && $dopr)
 		generateDhcpForm($dhcpdata);
 	clearPrivCache();
 }
@@ -3328,6 +3328,9 @@ function processBulkComputerInput($check
 			$topplus = implode(':', str_split(dechex($topdec + 1), 2));
 			$start = $botdec;
 			$return['macs'] = array();
+			$eth0macs = array();
+			$eth1macs = array();
+			$toggle = 0;
 			$end = $start + (($endaddrArr[3] - $startaddrArr[3] + 1) * 2);
 			for($i = $start; $i < $end; $i++) {
 				if($i > 16777215) {
@@ -3341,8 +3344,27 @@ function processBulkComputerInput($check
 					$tmp2 = str_split($tmp, 2);
 					$return['macs'][] = $topmac . ':' . implode(':', $tmp2);
 				}
+				if($toggle % 2)
+					$eth1macs[] = $topmac . ':' . implode(':', $tmp2);
+				else
+					$eth0macs[] = $topmac . ':' . implode(':', $tmp2);
+				$toggle++;
+			}
+			$ineth0s = implode("','", $eth0macs);
+			$ineth1s = implode("','", $eth1macs);
+			$query = "SELECT id "
+			       . "FROM computer "
+			       . "WHERE eth0macaddress IN ('$ineth0s') OR "
+			       .       "eth1macaddress IN ('$ineth1s')";
+			$qh = doQuery($query);
+			if(mysql_num_rows($qh)) {
+				$submitErr |= MACADDRERR;
+				$submitErrMsg[MACADDRERR] = "The specified starting MAC address "
+				                          . "combined with the number of computers "
+				                          . "entered will result in a MAC address "
+				                          . "already assigned to another computer.";
 			}
-			if($i > 16777215 && $topdec == 16777215) {
+			elseif($i > 16777215 && $topdec == 16777215) {
 				$submitErr |= MACADDRERR;
 				$submitErrMsg[MACADDRERR] = "Starting MAC address too large for given "
 				                          . "given number of machines";