-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbnapbnap.inc.php
132 lines (111 loc) · 2.61 KB
/
bnapbnap.inc.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/* Globals */
$devices = Array();
$devices[] = "Unknown";
$devices[] = "USB Dongle";
$devices[] = "PCCard";
$devices[] = "PDACard";
$devices[] = "Phone";
$devices[] = "Smart phone";
$devices[] = "Headset";
$devices[] = "Keyboard";
$devices[] = "Mouse";
$devices[] = "Other Pointing Device";
$devices[] = "Desktop workstation";
$devices[] = "Server";
$devices[] = "Laptop";
$devices[] = "Handheld sized PC";
$devices[] = "Palm sized PC";
$devices[] = "Wearable";
$devices[] = "Cordless";
$devices[] = "LAN access device";
$devices[] = "Microphone";
$devices[] = "Loudspeaker";
$devices[] = "Headphones";
$devices[] = "Portable audio";
$devices[] = "Car audio";
$devices[] = "Set-top box";
$devices[] = "Video Camera";
$devices[] = "Gaming/Toy";
$devices[] = "Other";
$dbfile = "bnapbnap.db";
// Don't like that the oui has to be valid
//$thelistquery = 'select distinct(bdaddr0 || ":" || bdaddr1 || ":" || bdaddr2) bdprefix, partnum, manuf, function, vendor from bnap, oui where bdprefix = oui and oui != "" group by bdprefix having count(submitterhost) > 1';
$thelistquery = 'select distinct(bdaddr0 || ":" || bdaddr1 || ":" || bdaddr2) bdprefix, partnum, manuf, function from bnap group by bdprefix having count(submitterhost) > 1';
function response_error($message)
{
/* XML error response */
print "<?xml version=\"1.0\" standalone=\"yes\"?>
<response>
<returnval>failure</returnval>
<message>$message</message>
</response>
";
return;
}
function response_success($message)
{
/* XML success message */
print "<?xml version=\"1.0\" standalone=\"yes\"?>
<response>
<returnval>success</returnval>
<message>$message</message>
</response>
";
return;
}
function print_header()
{
print "
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\">
<title>BNAP, BNAP; Bluetooth Device Address Collection</title>
</head>
<body>
";
}
function print_trailer()
{
print "</body></html>";
}
function check_addrbyte($input)
{
if ($input == "") {
return -1;
}
if (preg_replace("/[^A-Fa-f0-9]/", "", $input) != $input) {
return -1;
}
return 0;
}
function sanitize_manuf($input)
{
return sanitize_partnum($input);
}
function sanitize_partnum($input)
{
$input = preg_replace("/[^A-Za-z0-9\- ]/", "", $input);
$input = preg_replace("/--/", "-", $input);
return $input;
}
function check_function($input)
{
global $devices;
if ($input == "Unknown") {
return 0;
}
foreach($devices as $key=>$value) {
if ($input == $value) {
return 0;
}
}
return -1;
}
function errorprint($str)
{
print "<span style=\"font-weight: bold;\"><font color=\"#FF0000\">" .
$str . "</font></span><br>";
return;
}
?>