-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.php
44 lines (40 loc) · 1.22 KB
/
home.php
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
<?php
function getEurekaInfo( $host ) {
$url = "$host:8008/setup/eureka_info";
$ret = remotePull( $url );
if( $ret === FALSE ) { die( "Failure to retrieve EurekaInfo\n" . curl_error( $curl ) ); }
$res = json_decode( $ret, TRUE );
return( $res );
}
function remotePull( $url ) {
$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $url );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
$ret = curl_exec( $curl );
return( $ret );
}
function getAlarms ( $host ) {
$url = "$host:8008/setup/assistant/alarms";
$ret = remotePull( $url );
if( $ret === FALSE ) { die( "Failure to retrieve Alarms\n" . curl_error( $curl ) ); }
$alarms = json_decode( $ret, TRUE );
if( count( $alarms['alarm'] ) == 0 ) { return( FALSE ); }
$ret = array();
foreach( $alarms['alarm'] as $alarm ) {
array_push( $ret, $alarm );
}
return( $ret );
}
function getTimers ( $host ) {
$url = "$host:8008/setup/assistant/alarms";
$ret = remotePull( $url );
if( $ret === FALSE ) { die( "Failure to retrieve Timers\n" . curl_error( $curl ) ); }
$timers = json_decode( $ret, TRUE );
if( count( $timers['timer'] ) == 0 ) { return( FALSE ); }
$ret = array();
foreach( $timers['timer'] as $timer ) {
array_push( $ret, $timer );
}
return( $ret );
}
?>