Преглед изворни кода

#308 Free IPs: do not show the subnet address (the first one)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@933 a333f486-631f-4898-b8df-5754b55c2be0
romainq пре 14 година
родитељ
комит
87420bb9ff
1 измењених фајлова са 38 додато и 38 уклоњено
  1. 38 38
      modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php

+ 38 - 38
modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php

@@ -458,49 +458,49 @@ class Subnet extends cmdbAbstractObject
 
 		if (!$bEditMode)
 		{
-		$oPage->SetCurrentTab(Dict::S('Class:Subnet/Tab:IPUsage'));
-
-		$bit_ip = ip2long($this->Get('ip'));
-		$bit_mask = ip2long($this->Get('ip_mask'));
-
-		$iIPMin = $bit_ip & $bit_mask;
-		$iIPMax = ($bit_ip | (~$bit_mask)) - 1;
-
-		$sIPMin = long2ip($iIPMin);
-		$sIPMax = long2ip($iIPMax);
-
-		$oPage->p(Dict::Format('Class:Subnet/Tab:IPUsage-explain', $sIPMin, $sIPMax));
-		
-		$oIfSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT NetworkInterface AS if WHERE INET_ATON(if.ip_address) >= INET_ATON('$sIPMin') AND INET_ATON(if.ip_address) <= INET_ATON('$sIPMax')"));
-		self::DisplaySet($oPage, $oIfSet, array('block_id' => 'nwif'));
-
-		$iCountUsed = $oIfSet->Count();
-		$iCountRange = $iIPMax - $iIPMin;
-		$iFreeCount =  $iCountRange - $iCountUsed;
-
-		$oPage->SetCurrentTab(Dict::S('Class:Subnet/Tab:FreeIPs'));
-		$oPage->p(Dict::Format('Class:Subnet/Tab:FreeIPs-count', $iFreeCount));
-		$oPage->p(Dict::S('Class:Subnet/Tab:FreeIPs-explain'));
-
-		$aUsedIPs = $oIfSet->GetColumnAsArray('ip_address', false);
-		$iAnIP = $iIPMin;
-		$iFound = 0;
-		while (($iFound < min($iFreeCount, 10)) && ($iAnIP <= $iIPMax))
-		{
-			$sAnIP = long2ip($iAnIP);
-			if (!in_array($sAnIP, $aUsedIPs))
-			{
-				$iFound++;
-				$oPage->p($sAnIP);
-			}
-			else
+			$oPage->SetCurrentTab(Dict::S('Class:Subnet/Tab:IPUsage'));
+	
+			$bit_ip = ip2long($this->Get('ip'));
+			$bit_mask = ip2long($this->Get('ip_mask'));
+	
+			$iIPMin = ($bit_ip & $bit_mask) + 1; // exclude the first one: identifies the subnet itsel
+			$iIPMax = ($bit_ip | (~$bit_mask)) - 1; // exclude the last one : reserved for DHCP
+	
+			$sIPMin = long2ip($iIPMin);
+			$sIPMax = long2ip($iIPMax);
+	
+			$oPage->p(Dict::Format('Class:Subnet/Tab:IPUsage-explain', $sIPMin, $sIPMax));
+			
+			$oIfSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT NetworkInterface AS if WHERE INET_ATON(if.ip_address) >= INET_ATON('$sIPMin') AND INET_ATON(if.ip_address) <= INET_ATON('$sIPMax')"));
+			self::DisplaySet($oPage, $oIfSet, array('block_id' => 'nwif'));
+	
+			$iCountUsed = $oIfSet->Count();
+			$iCountRange = $iIPMax - $iIPMin;
+			$iFreeCount =  $iCountRange - $iCountUsed;
+	
+			$oPage->SetCurrentTab(Dict::S('Class:Subnet/Tab:FreeIPs'));
+			$oPage->p(Dict::Format('Class:Subnet/Tab:FreeIPs-count', $iFreeCount));
+			$oPage->p(Dict::S('Class:Subnet/Tab:FreeIPs-explain'));
+	
+			$aUsedIPs = $oIfSet->GetColumnAsArray('ip_address', false);
+			$iAnIP = $iIPMin;
+			$iFound = 0;
+			while (($iFound < min($iFreeCount, 10)) && ($iAnIP <= $iIPMax))
 			{
+				$sAnIP = long2ip($iAnIP);
+				if (!in_array($sAnIP, $aUsedIPs))
+				{
+					$iFound++;
+					$oPage->p($sAnIP);
+				}
+				else
+				{
+				}
+				$iAnIP++;
 			}
-			$iAnIP++;
 		}
 	}
 }
-}
 class Patch extends cmdbAbstractObject
 {