Revize 1878
Přidáno uživatelem Michal Kliment před více než 11 roky(ů)
freenetis/branches/1.1/application/models/subnet.php | ||
---|---|---|
IFNULL(ROUND((
|
||
SELECT COUNT(*)
|
||
FROM ip_addresses
|
||
WHERE subnet_id = s.id AND member_id IS NULL
|
||
WHERE subnet_id = s.id
|
||
)/((~inet_aton(s.netmask) & 0xffffffff)+1)*100,1),0) AS used,
|
||
m.id AS member_id, m.name AS member_name, dhcp, qos
|
||
FROM subnets s
|
||
... | ... | |
$total_available = (~ip2long($this->netmask) & 0xffffffff)-1;
|
||
|
||
$ip_queries = array();
|
||
for ($i = 1; $i <= $total_available; $i++)
|
||
$ip_queries[] = "SELECT '".long2ip($network+$i)."' AS ip_address";
|
||
|
||
if ($total_available > 1)
|
||
{
|
||
for ($i = 1; $i <= $total_available; $i++)
|
||
$ip_queries[] = "SELECT '".long2ip($network+$i)."' AS ip_address";
|
||
}
|
||
// for special 1-host subnet (mask /32) add only 1 IP address with network address (#507)
|
||
else
|
||
{
|
||
$ip_queries[] = "SELECT '".long2ip($network)."' AS ip_address";
|
||
}
|
||
|
||
if (!count($ip_queries))
|
||
return array();
|
freenetis/branches/1.1/application/controllers/subnets.php | ||
---|---|---|
Filter_form::OPER_NETWORK_IS_IN => 'cidr',
|
||
Filter_form::OPER_NETWORK_IS_NOT_IN => 'cidr',
|
||
));
|
||
|
||
$filter_form->add('netmask')
|
||
->type('network_address');
|
||
|
||
$filter_form->add('member_name')
|
||
->label('Owner')
|
||
... | ... | |
// ip addresses of subnet
|
||
$ips = $subnet->ip_addresses;
|
||
|
||
$total_available = (~ip2long($subnet->netmask) & 0xffffffff)-1;
|
||
$total_available = (~ip2long($subnet->netmask) & 0xffffffff)+1;
|
||
|
||
$used = round(count($ips)/$total_available*100,1);
|
||
|
||
... | ... | |
|
||
$ip_addresses = array();
|
||
|
||
for ($i=1; $i <= $total_available; $i++)
|
||
for ($i=0; $i <= $total_available; $i++)
|
||
{
|
||
// allow add IP address with network address only for 1 host subnet (mask /32) (#507)
|
||
if ($total_available != 1 && $i == 0)
|
||
continue;
|
||
|
||
// not allow add another IP address for 1 host subnet (mask /32) (#507)
|
||
if ($total_available == 1 && $i == 1)
|
||
break;
|
||
|
||
$ip_addresses[$i] = arr::to_object(array
|
||
(
|
||
'ip_address_id' => NULL,
|
freenetis/branches/1.1/application/controllers/ip_addresses.php | ||
---|---|---|
'IP address does not match the subnet/mask.'
|
||
));
|
||
}
|
||
else if ($ip == $net || ($ip == ($net | ~$mask)) && ~$mask != 0)
|
||
else if (($ip == $net || $ip == ($net | ~$mask)) && ~$mask != 0)
|
||
{
|
||
$input->add_error('required', __('Invalid IP address'));
|
||
}
|
Také k dispozici: Unified diff
Upravy:
- fixes #507 - Subnet s maskou 255.255.255.255 - chybne validatory + obsazenost