-2
So I do computer networks and I’m the last semester, we’re doing a TCC where it will work as follows:
A Mesh network for remote areas that do not have internet access, so whoever is connected to this network will be able to watch movies, listen to music, talk via text and voice, etc.
I am tasked with creating a community page where the staff will access the link and will have the button of the applications that will be redirected to the application and the problem is there.
I need to perform the validation to see if the IP/ DNS is in the air or not, but doing this in the front end is not 100% sure because it has several contradictory because an offline web page can be several things that only emits an HTTP, so I’m doing it in PHP, but I’m not able to perform the "merge" of javascript with PHP, see:
Calling on Function Javascript:
document.getElementById('plex').addEventListener('click', () => checagemplex());
Function:
function checagemplex () {
var checar = <?php
if (!fsockopen("192.168.1.145", 80, $errno, $errstr, 10)) {
echo "Offline";
} else {
echo "Online";
}
?>;
$.ajax({
checar;
}).done(function() {
alert('Online');
}).fail(function() {
alert('Offline');
})
}
Has anyone ever been in this situation and knows some way to improve the checking function and make it work?
Thank you!
I believe that the best way would be for you to use a ping: https://answall.com/questions/158466/usando-ping-comphp
– Diego