How to connect to WIFI from a browser with Javascript and PHP?
题意 :
如何通过浏览器使用 JavaScript 和 PHP 连接到 WIFI?
问题背景:
I working on creating a Linux Digital signage Box, which my clients can buy, and choose what to show on it. At the moment, it boot up in Firefox, check if it have internet, query my server and get a unique URL which Firefox change to. If it don't have any internet connection, i show a page "You dont have internet, please connect a ethernet cable or connect to WIFI."
我正在创建一个 Linux 数字标牌盒子,客户可以购买并选择要在上面显示的内容。目前,它启动时会进入 Firefox,检查是否有互联网连接,查询我的服务器并获取一个唯一的 URL,Firefox 会切换到该 URL。如果没有互联网连接,我会显示一个页面:“您没有互联网连接,请连接以太网电缆或连接到 WIFI。”
That my question, what will be the best way to allow my client to connect a Wireless hotspot from Firefox? At the moment my idea is:
这是我的问题,允许客户从 Firefox 连接无线热点的最佳方法是什么?目前我的想法是:
I add a "Connect wireless" button, which with some javascript call a php script, which SSH to the BOX (localhost), and use connmanctl to first, find all WIFI hotspot and if they require password. The Javascript then show this, and SSH again to connect and so on..
我添加了一个“连接无线”按钮,使用一些 JavaScript 调用一个 PHP 脚本,该脚本通过 SSH 连接到盒子(localhost),并使用 connmanctl 首先查找所有的 WIFI 热点,检查是否需要密码。然后,JavaScript 显示这些信息,再次通过 SSH 连接以进行连接,依此类推。
Do you know a opensource system, which do that? or a better way to do it?
你知道一个开源系统可以做到这一点吗?或者有更好的方法吗?
问题解决:
This is what i would do.
这就是我会做的。
You can run system code with the function shell_exec. Use this function in your PHP script to execute the native WiFi connection possibilities of your Linux distribution. How to do this for your distro is most likey answered here.
Good luck!
你可以使用 shell_exec 函数系统代码。在你的 PHP 脚本中使用这个函数来执行你 Linux 发行版的本地 WiFi 连接功能。如何为你的发行版做到这一点,最有可能在这里找到答案。 祝你好运!

