-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwifi_survey.php
194 lines (170 loc) · 5.37 KB
/
wifi_survey.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
/*
* wifi_survey.php
*
* Copyright (C) 2013-2014 by Erland Hedman <[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
* 2 of the License, or (at your option) any later version.
*/
include 'cgi-bin/common.php';
@system("iwscan ".g_wan()." >/tmp/scanlist");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?php p_title(); ?></title>
<script>
var ckssidnum = 0;
var stoptimer = 0;
function ClickMenu(num)
{
if (!stoptimer)
stoptimer = 1;
ckssidnum = num;
}
function StopTimer(num)
{
if (!stoptimer)
stoptimer = 1;
document.getElementById("sel_item"+num).checked = true;
ckssidnum = num;
}
function valid_pp(pp)
{
if (pp) return 0;
alert("A passphrase is required!");
return 1;
}
function do_connect()
{
var str="";
var pp = document.getElementById("ck_passp"+ckssidnum).value;
var cp = document.getElementById("ck_cipher"+ckssidnum).value;
if (valid_pp(pp)) return;
str+="/wireless.php?connect=1&ckssidnum="+ckssidnum+"&ck_passp="+encodeURIComponent(pp)+"&ck_cipher="+cp;
opener.location.href=str;
window.close();
}
function do_exit()
{
window.close();
}
function initPage()
{
setTimeout("re_scan()",7000);
var targetWidth = 700;
var targetHeight = 400;
window.resizeTo(targetWidth,targetHeight);
var body = document.body,
html = document.documentElement;
var height = Math.max( body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight );
var innerWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var innerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
window.resizeBy(targetWidth-innerWidth, height-innerHeight);
}
function re_scan()
{
var cnt = document.getElementById("cnt").value;
if (++cnt > 9)
window.close();
if (stoptimer > 0) {
initPage();
if (stoptimer++ < 9)
return true;
else window.close();
}
var str="/wifi_survey.php?cnt="+cnt;
self.location.href=str;
}
</script>
<style>
html, body, td, input
{
font-family: Tahoma, Helvetica, Geneva, Arial, sans-serif;
font-size: 0.9em;
empty-cells: show;
}
html>body
{
margin: 0;
padding: 0;
border: 0;
}
table
{
width: 100%;
}
td
{
background: #c0c0c0;
text-align:left;
padding: 4px;
font-weight: bold;
}
</style>
</head>
<body onload="initPage();" style="background-color: #dfdfdf">
<table>
<tr>
<td style="width:20%;">SSID</td>
<td>BSSID</td>
<td>CH</td>
<td>Security</td>
<td>Signal</td>
<td>Type</td>
<td>Passphrase</td>
<td>Select</td>
</tr>
<?php
$fd = fopen("/tmp/scanlist", "r");
$indx=1;
while (!feof($fd)) {
$a=explode("," ,fgets($fd),7);
if (empty($a[1]) || $a[1][0] == '\\') continue; // 00:24:01:6B:54:53, pegasus_media, Master, 36, CCMP, WPA2-PSK, 63%
if (count($a) == 5) {
$a[6] = $a[4];
$a[4] = "";
$a[5] = "WEP";
$cipher="0";
} else {
$cipher="4";
switch (trim($a[4])) {
case 'TKIP': $cipher="2"; break;
default: if (trim($a[5]) == "WPA2-PSK" && trim($a[4]) == "") {$cipher="3";} break;
}
}
echo ' <tr>'."\n";
echo ' <td>'.trim($a[1]).'</td>'."\n";
echo ' <td>'.trim($a[0]).'</td>'."\n";
echo ' <td>'.trim($a[3]).'</td>'."\n";
echo ' <td>'.trim($a[5]).'</td>'."\n";
echo ' <td>'.trim($a[6]).'</td>'."\n";
echo ' <td>'.trim($a[2]).'</td>'."\n";
echo ' <td><input id="ck_passp'.$indx.'" style="width:96%" name="passphrase" onclick="StopTimer('.$indx.')" value=""></td>'."\n";
echo ' <td>'."\n";
echo ' <input type="radio" name="station" id="sel_item'.$indx.'" onclick="ClickMenu('.$indx.')">'."\n";
echo ' <input type="hidden" id="ck_ssid'.$indx.'" name="ssid" value="'.trim($a[1]).'">'."\n";
echo ' <input type="hidden" id="ck_chan'.$indx.'" name="ch" value="'.trim($a[3]).'">'."\n";
echo ' <input type="hidden" id="ck_cipher'.$indx.'" name="cipher" value="'.$cipher.'">'."\n";
echo ' </td>'."\n";
echo ' </tr>'."\n";
$indx++;
}
@fclose($fd);
?>
<tr>
<td colspan="8" style="text-align:right;">Connect with DHCP
<input type="button" value="OK" name="connect" onclick="do_connect()">
<input type="button" value="Cancel" name="exit" onclick="do_exit()">
<input type="hidden" id="cnt" name="cnt" value="0<?php echo isset($_GET['cnt'])? $_GET['cnt']: 1; ?>">
</td>
</tr>
</table>
</body>
</html>