[CODE] get ping results asynchronously for faster page loading
This commit is contained in:
parent
8446cfe206
commit
0115ea37d2
2 changed files with 85 additions and 17 deletions
20
ping.php
Normal file
20
ping.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
// -------------------------------------------
|
||||
// Wake On LAN Webclient -- on private LAN
|
||||
|
||||
// copyright: Jannik Beyerstedt | https://jannikbeyerstedt.de
|
||||
// license: http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License
|
||||
// -------------------------------------------
|
||||
|
||||
if (isset($_GET['hostname'])) {
|
||||
$foo = array(); $status;
|
||||
exec("ping -c 1 ".$_GET['hostname'], $foo, $status);
|
||||
if (!$status) {
|
||||
echo "1 online";
|
||||
} else {
|
||||
echo "0 offline";
|
||||
}
|
||||
} else {
|
||||
header("HTTP/1.1 400 Bad Request");
|
||||
echo "ERROR: invalid request";
|
||||
}
|
Reference in a new issue