alarma desde php
Publicado por Luis Ramon (2 intervenciones) el 01/06/2018 17:37:01
hola, soy nuevo en estos temas, necesito urgentemente que me ayuden ya que llevo 3 noches sin dormir ya que estan robando los equipos wifi.... tratando de hacer esto:
1-ping a una IP
2-si es falso reproducir alarma
3-si es verdadero ejecutarlo nuevamente cada (x) seg
esto es lo que he logrado hasta ahora......
1-ping a una IP
2-si es falso reproducir alarma
3-si es verdadero ejecutarlo nuevamente cada (x) seg
esto es lo que he logrado hasta ahora......
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
68
69
70
71
<!DOCTYPE html>
<html lang="es">
<head>
<link rel="shortcut icon" href=img/favico.ico>
<title> PING</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
$self = $_SERVER['PHP_SELF']; //Obtenemos la página en la que nos encontramos
header("refresh:3; url=$self"); //Refrescamos cada 3 segundos
?>
<script language="JavaScript1.2">
var inter;
var t;
function interval(){
t=1;
inter=setInterval(function(){
document.getElementById("testdiv").innerHTML=t++;
},1000,"JavaScript");
}
function timeout(){
clear();
setTimeout(function(){
document.getElementById("testdiv").innerHTML="Pasaron 2 segundos antes de que vieras esto.";
},2000,"JavaScript");
}
function clear(){
clearInterval(inter);
}
</script>
<?php
function pingDomain($domain){
$starttime = microtime(true);
$file = @fsockopen ($domain, 80, $errno, $errstr, 10);
$stoptime = microtime(true);
$status = 0;
if (!$file) $status = -1; // Site is down
else {
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);
}
if ($status <> -1) {
return true;
}
return false;
}
if (pingDomain('10.10.10.10')) {
echo 'ON' . time() ;
} else {
echo 'OFF';
}
?>
</head>
<body>
<button onClick="pingDomain($domain)">PING</button>
<button onClick="interval()">INTERVAL</button>
<div id="testdiv"></div>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
Valora esta pregunta
0