summaryrefslogtreecommitdiff
path: root/libs/services.php
blob: 9b83acb67dac555a13597b7102c6c6ae18b7f1d6 (plain)
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
<?php
require 'Utils/Config.class.php';
$Config = new Config();


$datas = array();

if (count($Config->get('services')) > 0)
{
    foreach ($Config->get('services') as $service)
    {
        $host = $service['host'];
        $sock = @fsockopen($host, $service['port'], $num, $error, 5);
        
        if ($sock)
        {
            $datas[] = array(
                'port'      => $service['port'],
                'name'      => $service['name'],
                'status'    => 1,
            );
            
            fclose($sock);
        }
        else
        {
            $datas[] = array(
                'port'      => $service['port'],
                'name'      => $service['name'],
                'status'    => 0,
            );
        }
    }
}


echo json_encode($datas);