-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwifi.php
More file actions
68 lines (57 loc) · 1.35 KB
/
wifi.php
File metadata and controls
68 lines (57 loc) · 1.35 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
60
61
62
63
64
65
66
67
<?php
include __DIR__ . '/vendor/autoload.php';
use Sanchescom\WiFi\WiFi;
class Example
{
public $device;
/**
* @throws Exception
*/
public function getAllNetworks()
{
$networks = WiFi::scan()->getAll();
foreach ($networks as $network) {
echo $network . "\n";
}
}
/**
* @param $ssid
* @param $password
*/
public function connect($ssid, $password)
{
try {
WiFi::scan()->getBySsid($ssid)->connect($password, $this->device);
} catch (Exception $exception) {
echo $exception->getMessage();
}
}
/**
* @throws Exception
*/
public function disconnect()
{
$networks = WiFi::scan()->getConnected();
foreach ($networks as $network) {
$network->disconnect($this->device);
}
}
}
$example = new Example();
try {
//$example->device = 'en1';
//$example->getAllNetworks();
if (isset($_POST["SSID"]) && isset($_POST["password"]))
{
$ssid=$_POST["SSID"];
$password=$_POST["password"];
$example->getAllNetworks();
$example->connect($ssid, $password);
echo "<a href=\\"Wlan.html\\">Click here</a>";
//$example->disconnect();
//$example->list();
}
} catch (Exception $e) {
//
}
?>