<?php
include 'functions.php';
$service=getService($_GET['service']);
$proto=$service['protocol'];
$host=$service['machine']['host'];
$port=$service['port'];
$sleep=$service['interval'];
$count=$service['count'];
$extra=isset($_GET['manuall']);
if($extra){
sleep(30);
}
$chk_return=false;
if($proto=="html") {
$cmd = "cat html.txt | nc $host $port 2>/dev/null";
$chk_return=true;
}
else {
if ($proto=="sip") {
$cmd = "cat opt.txt | nc -u $host $port -w2 2>/dev/null";
}
else {
die("unknown protocol $proto<br/>");
}
}
for($i=0; $i<$count; $i++){
exec ($cmd,$out,$return);
if(count($out)>0 || ($return==0 && $chk_return)){
echo "started ".$_GET['service'];
die();
}
sleep($sleep);
if($extra){
sleep(5);
}
}
echo "failed ".$_GET['service'];
die();
?>