[CODE] get ping results asynchronously for faster page loading

This commit is contained in:
Jannik Beyerstedt 2017-10-21 00:16:21 +02:00
parent 8446cfe206
commit 0115ea37d2
2 changed files with 85 additions and 17 deletions

20
ping.php Normal file
View 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";
}