$port=array(22);
$col='0';
$a1=$_POST[rest1];
$a2=$_POST[rest2];
$a3=$_POST[rest3];
$a4=$_POST[rest4];
$a5=$_POST[rest5];
$a6=$_POST[rest6];
exec('/usr/local/bin/mpc --host Pi1MPD-Pass@192.168.0.1 volume',$result1);
$rest1=str_replace("%","",trim(substr(implode($result1),-4,4)));
exec('/usr/local/bin/mpc --host Pi2MPD-Pass@192.168.0.2 volume',$result2);
$rest2=str_replace("%","",trim(substr(implode($result2),-4,4)));
exec('/usr/local/bin/mpc --host Pi3MPD-Pass@192.168.0.3 volume',$result3);
$rest3=str_replace("%","",trim(substr(implode($result3),-4,4)));
exec('/usr/local/bin/mpc --host Pi4MPD-Pass@192.168.0.4 volume',$result4);
$rest4=str_replace("%","",trim(substr(implode($result4),-4,4)));
exec('/usr/local/bin/mpc --host Pi5MPD-Pass@192.168.0.5 volume',$result5);
$rest5=str_replace("%","",trim(substr(implode($result5),-4,4)));
exec('/usr/local/bin/mpc --host Pi6MPD-Pass@192.168.0.6 volume',$result6);
$rest6=str_replace("%","",trim(substr(implode($result6),-4,4)));
echo "<table cellpadding='20' border='1'>";
echo "<tr>";
echo "<td align='right' valign='top' width='400' ROWSPAN='10'>";
echo "<table cellpadding='20' border='1'><tr><th>On\Off</th><th>Off</th><th>On</th><th>Volume</th></tr>";
#if (empty($_POST['$rest1']) && empty($_POST['$rest2']) && empty($_POST['$rest3']) && empty($_POST['$rest4']) && empty($_POST['$rest5']) && empty($_POST['$rest6']) && !isset($_POST[submit])){
if (!isset($_POST['submit'])){
foreach($port as $p){
############## 1 #############################################
if (!$socket = @fsockopen("192.168.0.1", $p, $errno, $errstr, $col))
{
echo "<form action='index.php' method='post'>
<tr><td><font size='3'color='red'>1-Down</font></td>
<td><input type='checkbox' class='checkbox' name='1off' value='0'></td>
<td><input type='checkbox' class='checkbox' name='1on' value='1'></td>
<td><input type='text' name='volume1' value='$rest1'></td></tr>";
}
else
{
echo "<tr><td><font size='3' color='green'>1-Up</font></td>
<td><input type='checkbox' class='checkbox' name='1off' value='0'></td>
<td><input type='checkbox' class='checkbox' name='1on' value='1'></td>
<td><input type='text' name='volume1' value='$rest1'></form></td></tr>";
fclose($socket);
}
############## 2 #############################################
if (!$socket = @fsockopen("192.168.0.2",$p, $errno, $errstr, $col))
{
echo "<tr><td><font size='3' color='red'>2-Down</font></td>
<td><input type='checkbox' class='checkbox' name='2off' value='0'></td>
<td><input type='checkbox' class='checkbox' name='2on' value='1'></td>
<td><input type='text' name='volume2' value='$rest2'></form></td></tr>";
}
else
{
echo "<tr><td><font size='3' color='green'>2 - Up</font></td>
<td><input type='checkbox' class='checkbox' name='2off' value='0'></td>
<td><input type='checkbox' class='checkbox' name='2on' value='1'></td>
<td><input type='text' name='volume2' value='$rest2'></form></td></tr>";
fclose($socket);
}
############## 3 #############################################
if (!$socket = @fsockopen("192.168.0.3", $p, $errno, $errstr, $col))
{
echo "<tr><td><font size='3' color='red'>3-Down</font></td>
<td><input type='checkbox' class='checkbox' name='3off' value='0'></td>
<td><input type='checkbox' class='checkbox' name='3on' value='1'></td>
<td><input type='text' name='volume3' value='$rest3'></form></td></tr>";
}
else
{
echo "<tr><td><font size='3' color='green'>3-Up</font></td>
<td><input type='checkbox' class='checkbox' name='3off' value='0'></td>
<td><input type='checkbox' class='checkbox' name='3on' value='1'></td>
<td><input type='text' name='volume3' value='$rest3'></form></td></tr>";
fclose($socket);
}
############## 4 #############################################
if (!$socket = @fsockopen("192.168.0.4", $p, $errno, $errstr, $col))
{
echo "<tr><td><font size='3' color='red'>4-Down</font></td>
<td><input type='checkbox' class='checkbox' name='4off' value='0'></td>
<td><input type='checkbox' class='checkbox' name='4on' value='1'></td>
<td><input type='text' name='volume4' value='$rest4'></form></td></tr>";
}
else
{
echo "<tr><td><font size='3' color='green'>4-Up</font></td>
<td><input type='checkbox' class='checkbox' name='4off' value='0'></td>
<td><input type='checkbox' class='checkbox' name='4on' value='1'></td>
<td><input type='text' name='volume4' value='$rest4'></form></td></tr>";
fclose($socket);
}
############## 5 #############################################
if (!$socket = @fsockopen("192.168.0.5", $p, $errno, $errstr, $col))
{
echo "<tr><td><font size='3' color='red'>5-Down</font></td>
<td><input type='checkbox' class='checkbox' name='5off' value='0'></td>
<td><input type='checkbox' class='checkbox' name='5on' value='1'></td>
<td><input type='text' name='volume5' value='$rest5'></form></td></tr>";
}
else
{
echo "<tr><td><font size='3' color='green'>5-Up</font></td>
<td><input type='checkbox' class='checkbox' name='5off' value='0'></td>
<td><input type='checkbox' class='checkbox' name='5on' value='1'></td>
<td><input type='text' name='volume' value='$rest5'></form></td></tr>";
fclose($socket);
}
############## 6 #############################################
if (!$socket = @fsockopen("192.168.0.6", $p, $errno, $errstr, $col))
{
echo "<td><font size='3' color='red'>6-Down</font></td>
<td><input type='checkbox' class='checkbox' name='6off' value='0'></td>
<td><input type='checkbox' class='checkbox' name='6on' value='1'></td>
<td><input type='text' name='volume6' value='$rest6'></form></td></tr>";
}
else
{
echo "<td><font size='3' color='green'>6-Up</font></td>
<td><input type='checkbox' class='checkbox' name='6off' value='0'></td>
<td><input type='checkbox' class='checkbox' name='6on' value='1'></td>
<td><input type='text' name='volume6' value='$rest6'></form></td></tr>";
fclose($socket);
}
}
}else{
echo "1212";
exec('/usr/local/bin/mpc --host Pi1MPD-Pass@192.168.0.1 volume $a1');
exec('/usr/local/bin/mpc --host Pi2MPD-Pass@192.168.0.2 volume $a2');
exec('/usr/local/bin/mpc --host Pi3MPD-Pass@192.168.0.3 volume $a3');
exec('/usr/local/bin/mpc --host Pi4MPD-Pass@192.168.0.4 volume $a4');
exec('/usr/local/bin/mpc --host Pi5MPD-Pass@192.168.0.5 volume $a5');
exec('/usr/local/bin/mpc --host Pi6MPD-Pass@192.168.0.6 volume $a6');
}
echo "<tr ><td COLSPAN='4' align='right'><input type='submit' name='submit' value='Change'></form></td></tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "<td ROWSPAN='10' align='center' valign='top' width='400' >";