Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 578

Přidáno uživatelem Tomáš Dulík před více než 14 roky(ů)

Opraven bug - nebylo mozne pridavat IP adresy >= 128.0.0.0 (PHP nema 32bit unsigned int, takze tyhle IP po ip2long vraci zaporne hodnoty...)

Zobrazit rozdíly:

freenetis/trunk/kohana/application/controllers/ip_addresses.php
$method=$this->form->ip_address->method; // <FORM> method = POST, GET, ...
$ip=ip2long($this->input->$method('ip_address')); // Submitted values;
$subnet_id=$this->input->$method('subnet_id');
if ($ip <= 0)
if ($ip === FALSE || $ip == -1)
{ // invalid IP adress
$input->add_error('required', url_lang::lang('texts.Invalid IP address'));
return false;
}
}
$subnet_id=$this->input->$method('subnet_id');
$subnet_model = new Subnet_Model();
$subnet = $subnet_model->
select("inet_aton(network_address) as net", "32-log2((~inet_aton(netmask) & 0xffffffff) + 1) as mask")->
where('id',$subnet_id)->
find();
$this->check_ip($ip, $subnet->net, $subnet->mask, $input);
$this->check_ip($ip, 0+$subnet->net, $subnet->mask, $input);
// checks if exists this ip
......
function check_ip($ip, $net, $mask, $input)
{
$mask=0xffffffff<<(32-$mask) & 0xffffffff;
//printf(" ip=%lx, net=%lx, mask=%lx, AND=%lx", $ip, $net, $mask, $ip & $mask);
if (($ip & $mask) != $net)
// printf(" ip=%lx, net=%lx, mask=%lx, AND=%lx", $ip, 0+$net, $mask, $ip & $mask);
if (($ip & $mask) != (int)$net )
{
$input->add_error('required', url_lang::lang('texts.IP address does not match the subnet/mask.'));
}

Také k dispozici: Unified diff