Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1549

Přidáno uživatelem Michal Kliment před asi 12 roky(ů)

Vylepseni adresni mapy (implementace #235):

- zobrazeni pouze adresnich rozsahu (v Nastaveni - System - Adresni rozsahy) = nyni se vzdy zobrazoval po /16 a napr. verejne rozsahy byly zbytecne prazdne
- zobrazeni pouze vyfiltrovanych podsiti

Zobrazit rozdíly:

freenetis/branches/testing/application/helpers/valid.php
*/
public static function address_ranges ($str)
{
$str = str_replace("\n", ",", $str);
if (!preg_match("/^((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])(\/([0-9]|([1-2][0-9])|(3[0-2])))?(,((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])(\/([0-9]|([1-2][0-9])|(3[0-2])))?)*$/",$str,$matches))
return false;
else
freenetis/branches/testing/application/helpers/arr.php
}
/**
* Returns key with minimal value from array
*
* @author Michal Kliment
* @param type $array
* @return type
*/
public static function min_key ($array)
{
return min(array_keys($array));
}
/**
* Returns key with maximal value from array
*
* @author Michal Kliment
freenetis/branches/testing/application/controllers/subnets.php
if ($this->acl_check_view('Devices_Controller', 'subnet'))
{
$grid->add_new_button('subnets/address_map', __('Address map'),
$grid->add_new_button('subnets/address_map/'.server::query_string(),
__('Address map'),
array
(
'title' => __('Address map'),
......
{
Controller::error(ACCESS);
}
$filter_form = new Filter_form('s');
$filter_form->autoload();
$subnet_model = new Subnet_Model();
$total_subnets = $subnet_model->count_all_subnets();
$subnets = $subnet_model->get_all_subnets(0, $total_subnets, 'cidr');
$subnets = $subnet_model->get_all_subnets(
0, $total_subnets, 'cidr', 'ASC', $filter_form->as_sql()
);
// containts subnets itself
$arr_subnets = array();
// contains lengths of subnets
$arr_subnet_lengths = array();
// contains ranges of subnets (for not print empty lines)
$arr_subnet_ranges = array();
// contains colors for subnets
$background_colors = array();
foreach ($subnets as $subnet)
......
special::RGB(rand(50, 150), $nas[2], $nas[3]);
}
// address ranges from settings is used
if (Settings::get('address_ranges') != '')
{
$ranges = explode(",", Settings::get('address_ranges'));
foreach ($ranges as $range_address)
{
// address contains / => it's in CIDR format
if (strpos($range_address, '/') !== FALSE)
{
// split address and mask
list ($range_address, $range_mask) = explode('/', $range_address);
}
// address is without / => it's single address
else
$range_mask = 32;
$range_start = $range_address;
$range_end = long2ip(ip2long($range_address) + (~ip2long(network::cidr2netmask($range_mask)) & 0xffffffff));
// range start segments
$rss = explode(".", $range_start);
// range end segments
$res = explode(".", $range_end);
$arr_subnet_ranges[$rss[0]][$rss[1]]['start'] = $rss[2];
$arr_subnet_ranges[$res[0]][$res[1]]['end'] = $res[2];
$arr_subnet_ranges[$res[0]][$res[1]]['address'] = $range_address.'/'.$range_mask;
}
}
// view
$view = new View('subnets/address_map');
$view->subnets = $arr_subnets;
$view->lengths = $arr_subnet_lengths;
$view->ranges = $arr_subnet_ranges;
$view->background_colors = $background_colors;
$view->render(TRUE);
}
freenetis/branches/testing/application/controllers/settings.php
$this->form->group('Network settings');
$this->form->input('address_ranges')
$this->form->textarea('address_ranges')
->rules('valid_address_ranges')
->value(Settings::get('address_ranges'));
->value(str_replace(",","\n", Settings::get('address_ranges')));
$this->form->group('Module settings');
......
{
$value = max($value, 1);
}
else if ($name == 'address_ranges')
{
$value = str_replace("\n", ",", $value);
}
$issaved = $issaved && Settings::set($name, $value);
}
freenetis/branches/testing/application/views/subnets/address_map.php
foreach ($arr_a as $b => $arr_b)
{
?>
<h2><?php echo $a ?>.<?php echo $b ?>.0.0/16</h2>
<h2><?php echo isset($ranges[$a][$b]['address']) ? $ranges[$a][$b]['address'] : "$a.$b.0.0/16" ?></h2>
<div id="d-box-all">
<div class="d-box"></div>
......
<?php
endfor;
$i = 0;
$height = 30;
while ($i < 256)
$i = isset($ranges[$a][$b]['start']) ? $ranges[$a][$b]['start'] : 0;
$height = 1;
$end = isset($ranges[$a][$b]['end']) ? $ranges[$a][$b]['end'] : 255;
while ($i <= $end)
{
?>
</div>
......
</div>
<?php
$i += $height;
$height = 1;
}
?>
<br clear="all">

Také k dispozici: Unified diff