Witam,
Jestem mega początkujący i mam problem z połączeniem dwóch kodów w jeden duży działający.
Ten kod działa i jest wszystko OK:
<?
if(isset($_GET['on'])){
$message = shell_exec("/var/www/power.sh on ".intval($_GET['on'],10));
header("Location: test.php");
exit;
}
if(isset($_GET['off'])){
$message = shell_exec("/var/www/power.sh off ".intval($_GET['off'],10));
header("Location: test.php");
exit;
}
$lastRelay=10;
?>
<!DOCTYPE html>
body{
min-width:500px;
min-height:500px;
height:100%;
width:100%;
background:#000 url('images/test.jpg') no-repeat left top;
position:relative;
margin:0;
}
a{
position:absolute;
display:block;
}
<?php
$buttonsPosition=array(
array(50,50),
array(100,100),
array(150,150),
array(200,200),
array(250,250),
array(300,300),
);
for($i=1;$i<$lastRelay;$i++){
if(trim(shell_exec("/var/www/power.sh status ".$i))=='on')
echo '<a href="?off='.$i.'" '.(isset($buttonsPosition[$i-1])?'style="left:'.$buttonsPosition[$i-1][0].'px;top:'.$buttonsPosition[$i-1][1].'px;"':'').'><img style="width: 50px; height: 50px;" src="images/on.png"></a>';
else
echo '
<a href="?on='.$i.'" '.(isset($buttonsPosition[$i-1])?'style="left:'.$buttonsPosition[$i-1][0].'px;top:'.$buttonsPosition[$i-1][1].'px;"':'').'><img style="width: 50px; height: 50px;" src="images/off.png"></a>';
usleep(10000);
}
?>
Tamten kod chciałbym połączyć z tym, ale nie bardzo wiem jak to zrobić poprawnie

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">
#exCenter {
background-color : #000000;
width : 970px;
margin : auto;
}
#exHeader, #exContent, #exFooter {
background-color : #000000;
border : #000000 solid 0;
margin-bottom : 0;
}
#exLeftColumn {
float : left;
width : 245px;
height : 440px;
background-color : #000000;
}
#exRightColumn {
float : right;
width : 725px;
height : 440px;
background : url('images/sypialnia_sciany.png') center top no-repeat #000000;
position : relative;
margin : 0;
}
.exClear {
clear : both;
line-height : 0;
}
<a href="index.html"><img style="width: 150px; height: 30px;" alt="" src="images/home.jpg" onmouseover="this.src = 'images/home_ne.jpg'" onmouseout="this.src = 'images/home.jpg'" /></a> <a href="edom.php"><img style="width: 150px; height:30px;" alt="" src="images/edom.jpg" onmouseover="this.src = 'images/edom_ne.jpg'" onmouseout="this.src = 'images/edom.jpg'" /></a> <a href="forums.html"><img style="width: 150px; height:30px;" alt="" src="images/temperatura.jpg" onmouseover="this.src = 'images/temperatura_ne.jpg'" onmouseout="this.src = 'images/temperatura.jpg'" /></a> <a href="energia.php"><img style="width: 150px; height:30px;" alt="" src="images/energia.jpg" onmouseover="this.src = 'images/energia_ne.jpg'" onmouseout="this.src = 'images/energia.jpg'" /></a> <a href="woda.php"><img style="width: 150px; height:30px;" alt="" src="images/woda.jpg" onmouseover="this.src = 'images/woda_ne.jpg'" onmouseout="this.src = 'images/woda.jpg'" /></a> <a href="webcam.php"><img style="width: 150px; height:30px;" alt="" src="images/webcam.jpg" onmouseover="this.src = 'images/webcam_ne.jpg'" onmouseout="this.src = 'images/webcam.jpg'" /></a> <a href="salon.php"><img style="width: 150px; height: 30px;" alt="" src="images/salon.jpg" onmouseover="this.src = 'images/salon_ne.jpg'" onmouseout="this.src = 'images/salon.jpg'" /></a> <a href="sypialnia_media.php"><img style="width:150px; height: 30px;" alt="" src="images/sypialnia.jpg" onmouseover="this.src = 'images/sypialnia_ne.jpg'"onmouseout="this.src = 'images/sypialnia.jpg'" /></a> <a href="boys.php"><img style="width: 150px; height: 30px;" alt="" src="images/boys.jpg" onmouseover="this.src = 'images/boys_ne.jpg'" onmouseout="this.src = 'images/boys.jpg'" /></a> <a href="kuchnia.php"><img style="width: 150px; height: 30px;" alt="" src="images/kuchnia.jpg" onmouseover="this.src = 'images/kuchnia_ne.jpg'" onmouseout="this.src = 'images/kuchnia.jpg'" /></a> <a href="hol.php"><img style="width: 150px; height: 30px;" alt="" src="images/hol.jpg" onmouseover="this.src = 'images/hol_ne.jpg'" onmouseout="this.src = 'images/hol.jpg'" /></a> <a href="lazienka.php"><img style="width: 150px; height: 30px;" alt="" src="images/lazienka.jpg" onmouseover="this.src = 'images/lazienka_ne.jpg'" onmouseout="this.src = 'images/lazienka.jpg'" /></a> <a href="sypialnia_media.php"><img style="width: 150px; height: 30px;" alt="" src="images/media.jpg" onmouseover="this.src= 'images/media_ne.jpg'" onmouseout="this.src = 'images/media.jpg'" /></a> <a href="sypialnia_swiatlo.php"><img style="width: 150px; height: 30px;" alt="" src="images/swiatlo.jpg" onmouseover="this.src= 'images/swiatlo_ne.jpg'" onmouseout="this.src = 'images/swiatlo.jpg'" /></a> <a href="sypialnia_gniazdka.php"><img style="width: 150px; height: 30px;" alt="" src="images/gniazdka.jpg" onmouseover="this.src = 'images/gniazdka_ne.jpg'" onmouseout="this.src = 'images/gniazdka.jpg'" /></a> <a herf="sypialnia_okna.php"><img style="width: 150px; height: 30px;" alt="" src="images/okna.jpg" onmouseover="this.src = 'images/okna_ne.jpg'" onmouseout="this.src = 'images/okna.jpg'" /></a> <div id="exRightColumn"></div>
Z góry dziękuję za pomoc.
Już sobie poradziłem