-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgetHiddenNetworks.php
More file actions
59 lines (51 loc) · 1.39 KB
/
getHiddenNetworks.php
File metadata and controls
59 lines (51 loc) · 1.39 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
<?php
require_once 'config.inc.php';
require_once 'class/mysq.class.php';
require_once 'class/ipv6.php';
$_SERVER['REQUEST_URI'];
$lastNetwork_bin = $_GET['lastNetwork_bin'];
$mask = $_GET['mask'];
$root = $_isset($_GET['root']) ? $_GET['root'] : 0;
// start database connection
$sql = new mysql("localhost","user","passwort","datenbank");
// dont allow cache
header("Pragma: no-cache");
$q="SELECT *
FROM `".DB_PREFIX."ipamv6`
WHERE (
`mask` > ".($mask) ."
)
ORDER BY network_bin ASC;";
$res = $sql->query($q);
$show=0;
$i=0;
while ($row = $sql->array_result($res))
{
if($i==0 && $lastNetwork_bin == str_repeat("1", $mask+8) )
{
$show=1;
}
$i++;
if ($show == 1 && $row['mask'] <= $mask + 8 )
{
$show=0;
return;
}
if($show == 1)
{
$ip = new IPv6();
$ip->initBinary($row['network_bin'], $row['mask']);
$n = floor(($row['mask']-1)/8)*8;
?>
<li>
<a href="./?action=sudoku&mask=<?php echo $n; ?>&network=<?php echo substr($row['network_bin'], 0, $n).str_repeat("0", 128 - $n);?>">
<?php echo $ip->getMyCompressedAddress(); ?>/<?php echo $ip->myPrefix; ?> (<?php echo ($row['description']); ?>)
</a>
<a href="./?action=editNetworkForm&id=<?php echo $row['id']?>">(edit)</a>
<a href="./?action=deleteNetwork&id=<?php echo $row['id']; ?>">(delete)</a>
</li>
<?php }
if(substr($row['network_bin'], 0, $mask + 8) == substr($lastNetwork_bin, 0, $mask+8))
$show=1;
}
?>