-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpush.php
More file actions
47 lines (37 loc) · 1.34 KB
/
push.php
File metadata and controls
47 lines (37 loc) · 1.34 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
<?php
include 'config.php';
$args = ['hostname','interface','vlan_tag','mac_address','ip_address'];
foreach($args as $arg) {
if(!isset($_GET[$arg])) {
$_GET[$arg]='';
}
}
if(empty($_GET['mac_address'])) {
exit;
}
if(in_array($_GET['mac_address'], $CFG['mac_ignore'])) {
exit;
}
// skip if ipv6 address is link local
if(preg_match("/^fe80:/", $_GET['mac_address'])) {
echo "skipping link-local ipv6 address\n";
exit;
}
// check if this mac is exists and this is last
$sth = $sql->prepare("SELECT * FROM addrwatch WHERE ip_address=:ip_address order by tstamp desc limit 1");
$sth->bindvalue(':ip_address', $_GET['ip_address'], PDO::PARAM_STR);
$sth->execute();
/* bind result variables */
$result = $sth->fetchObject();
if($result->mac_address == $_GET['mac_address']) {
echo "skipping insert\n";
exit;
}
$sth = $sql->prepare("INSERT INTO addrwatch (hostname,interface,vlan_tag,mac_address,ip_address) VALUES (:hostname, :interface, :vlan_tag, :mac_address, :ip_address)");
$sth->bindvalue(':hostname', $_GET['hostname'], PDO::PARAM_STR);
$sth->bindvalue(':interface', $_GET['interface'], PDO::PARAM_STR);
$sth->bindvalue(':vlan_tag', $_GET['vlan_tag'], PDO::PARAM_STR);
$sth->bindvalue(':mac_address', $_GET['mac_address'], PDO::PARAM_STR);
$sth->bindvalue(':ip_address', $_GET['ip_address'], PDO::PARAM_STR);
$sth->execute();
?>