-
Notifications
You must be signed in to change notification settings - Fork 787
Expand file tree
/
Copy pathsubnet-visual.php
More file actions
executable file
·64 lines (51 loc) · 2.31 KB
/
subnet-visual.php
File metadata and controls
executable file
·64 lines (51 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
# show squares to display free/used subnet
print "<br><h4>"._('Visual subnet display')." <i class='icon-gray icon-info-sign' rel='tooltip' data-html='true' title='"._('Click on IP address box<br>to manage IP address')."!'></i></h4><hr>";
print "<div class='ip_vis'>";
# we need to reindex addresses to have ip address in decimal as key!
$visual_addresses = array();
if($addresses_visual) {
foreach($addresses_visual as $a) {
$visual_addresses[$a->ip_addr] = (array) $a;
}
}
$alpha = ($User->user->theme == "dark") ? "cc" : "";
# print
foreach ($Subnets->get_all_possible_subnet_addresses($subnet) as $m) {
$ip_addr = $Subnets->transform_to_dotted($m);
$title = $ip_addr;
# already exists
if (array_key_exists($m, $visual_addresses)) {
# fix for empty states - if state is disabled, set to active
if(is_blank($visual_addresses[$m]['state'])) { $visual_addresses[$m]['state'] = 1; }
# to edit
$class = $visual_addresses[$m]['state'];
$action = 'all-edit';
$id = (int) $visual_addresses[$m]['id'];
# tooltip
if(!is_blank($visual_addresses[$m]['hostname'])) { $title .= "<br>".$visual_addresses[$m]['hostname']; }
if(!is_blank($visual_addresses[$m]['description'])) { $title .= "<br>".$visual_addresses[$m]['description']; }
# set colors
$background = $Subnets->address_types[$visual_addresses[$m]['state']]['bgcolor'].$alpha." !important";
$foreground = $Subnets->address_types[$visual_addresses[$m]['state']]['fgcolor'];
}
else {
# print add new
$class = "unused";
$id = $m;
$action = 'all-add';
# set colors
$background = "#ffffff";
$foreground = "#333333";
}
# print box
$shortname = ($Subnets->identify_address($m) == "IPv6") ? substr(strrchr($ip_addr,':'), 1) : '.'.substr(strrchr($ip_addr,'.'), 1);
if($subnet_permission > 1) {
print "<span class='ip-$class modIPaddr' style='background:$background;color:$foreground' data-action='$action' rel='tooltip' title='$title' data-position='top' data-html='true' data-subnetId='".$subnet['id']."' data-id='$id'>".$shortname."</span>";
} else {
print "<span class='ip-$class ' style='background:$background;color:$foreground' data-action='$action' data-subnetId='".$subnet['id']."' data-id='$id'>".$shortname."</span>";
}
print "\n";
}
print "</div>";
print "<div class='clearfix' style='padding-bottom:20px;'></div>"; # clear float