Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
phpipam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
phpipam
Commits
2bc3317b
Commit
2bc3317b
authored
Dec 22, 2020
by
phpipam
Browse files
Options
Downloads
Patches
Plain Diff
Added selectable popup masks
parent
189f8201
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/tools/subnet-masks/popup.php
+1
-1
1 addition, 1 deletion
app/tools/subnet-masks/popup.php
app/tools/subnet-masks/print-table.php
+50
-2
50 additions, 2 deletions
app/tools/subnet-masks/print-table.php
functions/classes/class.Subnets.php
+33
-0
33 additions, 0 deletions
functions/classes/class.Subnets.php
with
84 additions
and
3 deletions
app/tools/subnet-masks/popup.php
+
1
−
1
View file @
2bc3317b
...
...
@@ -37,6 +37,6 @@ $_POST = $User->strip_input_tags ($_POST);
<!-- footer -->
<div
class=
"pFooter"
>
<div
class=
"btn-group"
>
<button
class=
"btn btn-sm btn-default
<?php
print
@
$_
PO
ST
[
'closeClass'
];
?>
"
>
<?php
print
_
(
'Close'
);
?>
</button>
<button
class=
"btn btn-sm btn-default
<?php
print
@
$_
REQUE
ST
[
'closeClass'
];
?>
"
>
<?php
print
_
(
'Close'
);
?>
</button>
</div>
</div>
This diff is collapsed.
Click to expand it.
app/tools/subnet-masks/print-table.php
+
50
−
2
View file @
2bc3317b
...
...
@@ -4,16 +4,36 @@
* print subnet masks
*/
# default mask
$posted_mask
=
"10"
;
# get masks
if
(
isset
(
$_GET
[
'mask'
]))
{
if
(
$_GET
[
'mask'
]
<
10
||
$_GET
[
'mask'
]
>
32
)
{
$masks
=
$Subnets
->
get_ipv4_masks
();
}
else
{
$masks
=
$Subnets
->
get_ipv4_masks_for_subnet
(
$_GET
[
'mask'
]);
$posted_mask
=
$_GET
[
'mask'
];
}
}
else
{
$masks
=
$Subnets
->
get_ipv4_masks
();
}
?>
<?php
if
(
!
$popup
)
{
print
"<h4>"
.
_
(
'Subnet masks'
)
.
"</h4><hr>"
;
$colspan
=
"8"
;
}
else
{
$colspan
=
"6"
;
}
?>
<div
class=
'subnet_table_overlay'
>
<table
class=
"
<?php
if
(
!
$popup
)
print
"subnet-mask-table sorted"
;
?>
table nosearch nopagination table-noborder1 table-hover table-condensed table-top
<?php
if
(
!
$popup
)
print
'table-auto'
;
?>
"
data-cookie-id-table=
"masks"
>
<!-- headers -->
...
...
@@ -36,6 +56,7 @@ if(!$popup) {
<!-- values -->
<tbody>
<?php
foreach
(
$masks
as
$m
)
{
if
(
$m
->
bitmask
<
31
&&
$m
->
bitmask
>
7
)
{
...
...
@@ -55,5 +76,32 @@ foreach($masks as $m) {
}
}
?>
<tr>
<td
colspan=
"
<?php
print
$colspan
;
?>
"
>
<form>
<div
class=
"input-group pull-right"
>
<input
type=
"text"
class=
"form-control input-sm"
name=
'mask'
placeholder=
"
<?php
print
_
(
"Enter mask"
);
?>
"
value=
'
<?php
print
$posted_mask
;
?>
'
>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-default input-sm"
type=
"submit"
>
<?php
print
_
(
"Update"
);
?>
</button>
</span>
</div>
</form>
</td>
</tr>
</tbody>
</table>
</div>
<?php
if
(
$popup
)
{
?>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
'
form
'
).
submit
(
function
()
{
$
(
'
#popupOverlay2 div.popup_wmasks
'
).
load
(
"
app/tools/subnet-masks/popup.php?mask=
"
+
$
(
'
input[name=mask]
'
).
val
()
+
"
&closeClass=hidePopup2
"
);
return
false
;
})
});
</script>
<?php
}
?>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
functions/classes/class.Subnets.php
+
33
−
0
View file @
2bc3317b
...
...
@@ -940,7 +940,40 @@ class Subnets extends Common_functions {
return
$out
;
}
/**
* Returns all IPv4 subnet masks with different presentations
*
* @access public
* @return array
*/
public
function
get_ipv4_masks_for_subnet
(
$subnet_mask
=
"32"
)
{
$out
=
array
();
# loop masks
for
(
$mask
=
32
;
$mask
>=
$subnet_mask
;
$mask
--
)
{
// initialize
$out
[
$mask
]
=
new
StdClass
();
// fake cidr
$this
->
initialize_pear_net_IPv4
();
$net
=
$this
->
Net_IPv4
->
parseAddress
(
"10.0.0.0/
$mask
"
);
// set
$out
[
$mask
]
->
bitmask
=
$mask
;
// bitmask
$out
[
$mask
]
->
netmask
=
$net
->
netmask
;
// netmask
$out
[
$mask
]
->
host_bits
=
32
-
$mask
;
// host bits
$out
[
$mask
]
->
subnet_bits
=
32
-
$out
[
$mask
]
->
host_bits
;
// network bits
$out
[
$mask
]
->
hosts
=
number_format
(
$this
->
max_hosts
([
'subnet'
=>
'10.0.0.0'
,
'mask'
=>
$mask
])
,
0
,
","
,
"."
);
// max hosts
$out
[
$mask
]
->
subnets
=
number_format
(
pow
(
2
,(
$mask
-
$subnet_mask
)),
0
,
","
,
"."
);
$out
[
$mask
]
->
wildcard
=
long2ip
(
~
ip2long
(
$net
->
netmask
));
//0.0.255.255
// binary
$parts
=
explode
(
"."
,
$net
->
netmask
);
foreach
(
$parts
as
$k
=>
$p
)
{
$parts
[
$k
]
=
str_pad
(
decbin
(
$p
),
8
,
0
);
}
$out
[
$mask
]
->
binary
=
implode
(
"."
,
$parts
);
}
# return result
return
$out
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment