-
Notifications
You must be signed in to change notification settings - Fork 1
/
search.php
76 lines (65 loc) · 3.12 KB
/
search.php
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
65
66
67
68
69
70
71
72
73
74
75
76
<?php
// +---------------------------------------------------------------------------+
// index.php
// Netmon, Freifunk Netzverwaltung und Monitoring Software
//
// Copyright (c) 2009 Clemens John <[email protected]>
// +---------------------------------------------------------------------------+
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or any later version.
// +---------------------------------------------------------------------------+
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// +---------------------------------------------------------------------------+/
require_once('runtime.php');
require_once(ROOT_DIR.'/lib/core/Ip.class.php');
require_once(ROOT_DIR.'/lib/core/Networkinterface.class.php');
require_once(ROOT_DIR.'/lib/core/Router.class.php');
require_once(ROOT_DIR.'/lib/core/subnetcalculator.class.php');
$smarty->assign('message', Message::getMessage());
if(isset($_POST['what']) AND $_POST['what'] == 'ip' AND $_POST['ipv']==6) {
$ip = Ip::ipv6Expand($_POST['ip']);
//first try to determine network of given address
$network = Ip::ipv6NetworkFromAddr($ip, (int)$_POST['netmask']);
$network = new Network(false, false, $network, (int)$_POST['netmask'], 6);
if($network->fetch()) {
//if network found, then try to add ip address
$ip = new Ip(false, false, $network->getNetworkId(), $ip);
if($ip->fetch()) {
$networkinterface = new Networkinterface($ip->getInterfaceId());
$networkinterface->fetch();
$router = new Router($networkinterface->getRouterId());
$router->fetch();
$smarty->assign('object', "router");
$smarty->assign('object_data', $router);
}
}
} elseif(isset($_POST['what']) AND $_POST['what'] == 'ip' AND $_POST['ipv']==4) {
//first try to determine network of given address
$network = SubnetCalculator::getDqNet($_POST['ip'], (int)$_POST['netmask']);
$network = new Network(false, false, $network, (int)$_POST['netmask'], 4);
if($network->fetch()) {
//if network found, then try to add ip address
$ip = new Ip(false, false, $network->getNetworkId(), $_POST['ip']);
if($ip->fetch()) {
$networkinterface = new Networkinterface($ip->getInterfaceId());
$networkinterface->fetch();
$router = new Router($networkinterface->getRouterId());
$router->fetch();
$smarty->assign('object', "router");
$smarty->assign('object_data', $router);
}
}
} elseif(isset($_POST['what']) AND $_POST['what'] == 'mac_add') {
}
$smarty->display("header.tpl.html");
$smarty->display("search.tpl.html");
$smarty->display("footer.tpl.html");
?>