All pastes #546217 Raw Edit

Something

public text v1 · immutable
·published 2007-06-07 00:52 UTC
rendered paste body
	<?
	//CIDR functions
		
		// TESTING.
			$num_ips	=	array(
							"/24" => "254",
							"/25" => "126",
							"/26" => "62",
							"/27" => "30",
							"/28" => "14",
							"/29" => "6"
								);
								
			$subnet_mask	=	array(
								"/24" => "255.255.255.0",
								"/25" => "255.255.255.128",
								"/26" => "255.255.255.192",
								"/27" => "255.255.255.224",
								"/28" => "255.255.255.240",
								"/29" => "255.255.255.248"
								);
								
			$cidr_29	=	array(
							"1" => "1-6",
							"2" => "9-15",
							"3" => "17-22",
							"4" => "25-30",
							"5" => "33-38",
							"6" => "41-46",
							"7" => "49-54",
							"8" => "57-62",
							"9" => "65-70",
							"10" => "73-78",
							"11" => "81-86",
							"12" => "89-94",
							"13" => "97-102",
							"14" => "105-110",
							"15" => "113-118",
							"16" => "121-126",
							"17" => "129-134",
							"18" => "137-142",
							"19" => "145-150",
							"20" => "153-158",
							"21" => "161-166",
							"22" => "169-174",
							"23" => "177-182",
							"24" => "185-190",
							"25" => "193-198",
							"26" => "201-206",
							"27" => "209-214",
							"28" => "217-222",
							"29" => "225-230",
							"30" => "233-238",
							"31" => "241-246",
							"32" => "249-254",
							);
							
			$cidr_28	=	array(
							"1" => "1-14",
							"2" => "17-30",
							"3" => "33-46",
							"4" => "49-62",
							"5" => "65-78",
							"6" => "81-94",
							"7" => "97-110",
							"8" => "113-126",
							"9" => "129-142",
							"10" => "145-158",
							"11" => "161-174",
							"12" => "177-190",
							"13" => "193-206",
							"14" => "209-222",
							"15" => "225-238",
							"16" => "241-254",
							);
							
			$cidr_27	=	array(
							"1" => "1-30",
							"2" => "33-62",
							"3" => "65-94",
							"4" => "97-126",
							"5" => "129-158",
							"6" => "161-190",
							"7" => "193-222",
							"8" => "225-254",
							);
							
			$cidr_26	=	array(
							"1" => "1-62",
							"2" => "65-126",
							"3" => "129-190",
							"4" => "193-254",
							);
			
			$cidr_25	=	array(
							"1" => "1-126",
							"2" => "129-254",
							);
							
			$cidr_24	=	array(
							"1" => "1-254"
							);
		
		
		function ip($ip, $allocation)
		{
			function findRange($value, $cidr)
			{
				$v = explode(
				if($v[0] >= $value && <= $v[1])
				{
					$cidr[$x];
				}
			}
			
			for($v = 1; $v <= 32; $v++)
			{
				
			}
		}
		
		function cidr($start, $allocation)
		{
			function gateway($start_ip, $cidr)
			{
				$usable = explode("-", $cidr);
				$gateway = $usable[1] - 1;
				return $gateway;
			}
			
			function usable($start_ip, $cidr)
			{
				$usable = explode("-", $cidr);
				$start = $usable[1];
				$end = $usable[2];
				return "Start: ".$start." End: ".$end;
			}
			
			function broadcast($start_ip, $cidr)
			{
				$usable = explode("-", $cidr);
				$broadcast = $usable[2] + 1;
				return $broadcast;
			}
			
			$ip_network 	=	$start;
			$ip_gateway		=	gateway($start, $cidr);
			$ip_usable		=	usable($start, $cidr);
			$ip_broadcast	=	broadcast($start, $cidr);
		
		}
		
	
		
	?>
	
	<form action='cidr.php' method='get'>
	<select name='block'>
		<option value='205.234.152'>205.234.152
	</select>
	<input type='text' name='start'>
	<select name='cidr'>
		<option value='cidr_29'>/29
		<option value='cidr_28'>/28
		<option value='cidr_27'>/27
		<option value='cidr_26'>/26
		<option value='cidr_25'>/25
		<option value='cidr_24'>/24
	</select>
	<input type='submit' value='submit'>