2014-06-18 04:11:11 -04:00
|
|
|
<?php
|
2015-07-07 09:57:41 -04:00
|
|
|
require '../autoload.php';
|
2014-06-18 04:11:11 -04:00
|
|
|
$Config = new Config();
|
|
|
|
|
|
|
|
|
|
|
|
$datas = array();
|
|
|
|
|
2015-07-07 09:57:41 -04:00
|
|
|
$available_protocols = array('tcp', 'udp');
|
|
|
|
|
|
|
|
$show_port = $Config->get('services:show_port');
|
|
|
|
|
|
|
|
if (count($Config->get('services:list')) > 0)
|
2014-06-18 04:11:11 -04:00
|
|
|
{
|
2015-07-07 09:57:41 -04:00
|
|
|
foreach ($Config->get('services:list') as $service)
|
2014-06-18 04:11:11 -04:00
|
|
|
{
|
2015-07-07 09:57:41 -04:00
|
|
|
$host = $service['host'];
|
|
|
|
$port = $service['port'];
|
|
|
|
$name = $service['name'];
|
|
|
|
$protocol = isset($service['protocol']) && in_array($service['protocol'], $available_protocols) ? $service['protocol'] : 'tcp';
|
|
|
|
|
|
|
|
if (Misc::scanPort($host, $port, $protocol))
|
|
|
|
$status = 1;
|
2014-06-18 04:11:11 -04:00
|
|
|
else
|
2015-07-07 09:57:41 -04:00
|
|
|
$status = 0;
|
|
|
|
|
|
|
|
$datas[] = array(
|
|
|
|
'port' => $show_port === true ? $port : '',
|
|
|
|
'name' => $name,
|
|
|
|
'status' => $status,
|
|
|
|
);
|
2014-06-18 04:11:11 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
echo json_encode($datas);
|