#!/usr/bin/haserl
<?
# This program is copyright © 2013 Cezary Jackiewicz and is distributed under the terms of the GNU GPL
# version 2.0 with a special clarification/exception that permits adapting the program to
# configure proprietary "back end" software provided that all modifications to the web interface
# itself remain covered by the GPL.
# See http://gargoyle-router.com/faq.html#qfoss for more information
eval $( gargoyle_session_validator -c "$COOKIE_hash" -e "$COOKIE_exp" -a "$HTTP_USER_AGENT" -i "$REMOTE_ADDR" -r "login.sh" -t $(uci get gargoyle.global.session_timeout) -b "$COOKIE_browser_time" )
gargoyle_header_footer -h -s "system" -p "powerswitch" -c "internal.css" -j "table.js" powerswitch
status=$( cgi-bin/powersw/urzadzenie.sh )
echo "Content-type: text/html"
echo "$status"
?>
<!-- <script><?
eval $( gargoyle_session_validator -c "$COOKIE_hash" -e "$COOKIE_exp" -a "$HTTP_USER_AGENT" -i "$REMOTE_ADDR" -r "login.sh" -t $(uci get gargoyle.global.session_timeout) -b "$COOKIE_browser_time" )
status=$( cgi-bin/powersw/urzadzenie.sh )
echo "Content-type: text/html"
echo "$status"
?></script>//-->
<fieldset id="powerswitch">
<legend class="sectionheader">Power Switch</legend>
<div align="center" align="justify" style="width: 968px; height: 16px" ><font size="6" color="black" title >Power switch
przekaznikowy -
<span class="auto-style6">Atiny 2313</span>, sterowanie przez:
<? if [ -e /tmp/sysinfo/model ]; then
echo "$(cat /tmp/sysinfo/model)"
else
#echo "var model=\"brak danych\";"
echo "var model=\""$(awk -F: '/machine/ {print $2}' /proc/cpuinfo)"\";"
fi ?> </font> </div>
<div align="center" style="height: 25px; width: 968px;"><br><font size="4" color="red"> <? status=$(cgi-bin/powersw/urzadzenie.sh 2>/dev/null) echo "$status" ?></font></div>
<table class="auto-style1" style="height: 797px" >
<colgroup span="1"></colgroup>
<colgroup span="7"></colgroup>
<tr align="center" class="auto-style2">
<td style="border-bottom-color: #000000; border-color: #000000; height: 48px; border-bottom-style: double; border-bottom-width: inherit;" class="auto-style4" colspan="8">
<strong>Przekazniki (kliknij na ikone aby przelaczyc) <br> info: <a href="http://eko.one.pl/forum/viewtopic.php?id=3894"><br/>http://eko.one.pl/forum/viewtopic.php?id=3894</strong></td>
</tr>
<tr align="center">
<td style="width: 103px; height: 94px;" class="auto-style1">
<font size="4" color="blue">SW-1<br><font size="2" color="black"/font>tu opis przeznaczenia<br>
<br>
<img id="buttona" src="<?
stan=`/dodatki/powersw/power status 2>/dev/null | wc -l`
if [ "$stan" -gt "0" ] ; then
status1=$(/dodatki/powersw/power status | grep 0 | sed 's/port.0..//')
echo -n "iconsw/$status1.png"
else
echo -n "iconsw/NA.png"
fi
?>" power="<?
if [ "$stan" -gt "0" ] ; then
echo -n "$status1"
else
echo -n "NA"
fi
?>" width="50" height="50" >
<br>
<td style="width: 110px; height: 94px;" class="auto-style1">
<font size="4" color="blue">SW-2<br><font size="2" color="black"/font>tu opis przeznaczenia<br>
<br>
<img id="buttonb" src="<?
stan=`/dodatki/powersw/power status 2>/dev/null | wc -l`
if [ "$stan" -gt "0" ] ; then
status1=$(/dodatki/powersw/power status | grep 1 | sed 's/port.1..//')
echo -n "iconsw/$status1.png"
else
echo -n "iconsw/NA.png"
fi
?>" power="<?
if [ "$stan" -gt "0" ] ; then
echo -n "$status1"
else
echo -n "NA"
fi
?>" width="50" height="50" >
<br>
<td style="width: 113; height: 94px;" class="auto-style1">
<font size="4" color="blue">SW-3<font size="2" color="black"/font><br>tu opis
<br>przeznaczenia<br>
<br>
<img id="buttonc" src="<?
stan=`/dodatki/powersw/power status 2>/dev/null | wc -l`
if [ "$stan" -gt "0" ] ; then
status1=$(/dodatki/powersw/power status | grep 2 | sed 's/port.2..//')
echo -n "iconsw/$status1.png"
else
echo -n "iconsw/NA.png"
fi
?>" power="<?
if [ "$stan" -gt "0" ] ; then
echo -n "$status1"
else
echo -n "NA"
fi
?>" width="48" height="47" >
<br>
<td style="width: 107px; height: 94px;" class="auto-style1">
<font size="4" color="blue">SW-4<br><font size="2" color="black"/font>tu opis przeznaczenia<br>
<br>
<img id="buttond" src="<?
stan=`/dodatki/powersw/power status 2>/dev/null | wc -l`
if [ "$stan" -gt "0" ] ; then
status1=$(/dodatki/powersw/power status | grep 3 | sed 's/port.3..//')
echo -n "iconsw/$status1.png"
else
echo -n "iconsw/NA.png"
fi
?>" power="<?
if [ "$stan" -gt "0" ] ; then
echo -n "$status1"
else
echo -n "NA"
fi
?>" width="50" height="50" >
<br>
<td style="width: 108px; height: 94px;" class="auto-style1">
<font size="4" color="blue">SW-5<br><font size="2" color="black"/font>tu opis
<br>przeznaczenia<br>
<br>
<img id="buttone" src="<?
stan=`/dodatki/powersw/power status 2>/dev/null | wc -l`
if [ "$stan" -gt "0" ] ; then
status1=$(/dodatki/powersw/power status | grep 4 | sed 's/port.4..//')
echo -n "iconsw/$status1.png"
else
echo -n "iconsw/NA.png"
fi
?>" power="<?
if [ "$stan" -gt "0" ] ; then
echo -n "$status1"
else
echo -n "NA"
fi
?>" width="50" height="50" >
<br>
<td style="height: 94px;" class="auto-style1">
<font size="4" color="blue">SW-6<br><font size="2" color="black"/font>tu opis
<br>przeznaczenia<br>
<br>
<img id="buttonf" src="<?
stan=`/dodatki/powersw/power status 2>/dev/null | wc -l`
if [ "$stan" -gt "0" ] ; then
status1=$(/dodatki/powersw/power status | grep 5 | sed 's/port.5..//')
echo -n "iconsw/$status1.png"
else
echo -n "iconsw/NA.png"
fi
?>" power="<?
if [ "$stan" -gt "0" ] ; then
echo -n "$status1"
else
echo -n "NA"
fi
?>" width="50" height="50" >
<br>
<td style="width: 101px; height: 94px;" class="auto-style1">
<font size="4" color="blue">SW-7<br><font size="2" color="black"/font>tu opis
<br>przeznaczenia<br>
<br>
<img id="buttong" src="<?
stan=`/dodatki/powersw/power status 2>/dev/null | wc -l`
if [ "$stan" -gt "0" ] ; then
status1=$(/dodatki/powersw/power status | grep 6 | sed 's/port.6..//')
echo -n "iconsw/$status1.png"
else
echo -n "iconsw/NA.png"
fi
?>" power="<?
if [ "$stan" -gt "0" ] ; then
echo -n "$status1"
else
echo -n "NA"
fi
?>" width="47" height="50" class="auto-style12" >
<br>
<td style="height: 94px;" class="auto-style1">
<font size="4" color="blue">SW-8<br><font size="2" color="black"/font>tu opis
<br>przeznaczenia<br>
<br>
<img id="buttonh" src="<?
stan=`/dodatki/powersw/power status 2>/dev/null | wc -l`
if [ "$stan" -gt "0" ] ; then
status1=$(/dodatki/powersw/power status | grep 7 | sed 's/port.7..//')
echo -n "iconsw/$status1.png"
else
echo -n "iconsw/NA.png"
fi
?>" power="<?
if [ "$stan" -gt "0" ] ; then
echo -n "$status1"
else
echo -n "NA"
fi
?>" width="50" height="50" >
<br>
<tr align="center">
<td class="auto-style1" colspan="8" style="height: 28">
<strong>Wlaczenie chwilowe</strong></td>
</tr>
<tr align="center">
<td style="width: 103px; height: 38;" class="auto-style1">
<button style="width: 105px" id="buttona1s" >SW-1 (2s)</button></td>
<td style="width: 110px; height: 38;" class="auto-style1">
<button style="width: 105px" id="buttonb1s" >SW-2 (2s)</button></td>
<td style="width: 103px; height: 38;" class="auto-style1">
<button style="width: 105px" id="buttonc1s" >SW-3 (2s)</button></td>
<td style="width: 103px; height: 38;" class="auto-style1">
<button style="width: 105px" id="buttond1s" >SW-4 (2s)</button></td>
<td style="width: 108px; height: 38;" class="auto-style1">
<button style="width: 105px" id="buttone1s" >SW-5 (2s)</button></td>
<td style="width: 103px; height: 38;" class="auto-style1">
<button style="width: 105px" id="buttonf1s" >SW-6 (2s)</button></td>
<td style="width: 101px; height: 38;" class="auto-style1">
<button style="width: 105px" id="buttong1s" >SW-7 (2s)</button></td>
<td sstyle="width: 103px; height: 38;"class="auto-style1">
<button style="width: 105px" id="buttonh1s" >SW-8 (2s)</button></td>
</tr>
<tr align="center"><td class="auto-style1" colspan="2" style="height: 28px">
<strong>Ustaw czas zalaczenia - crona</strong></td>
<td class="auto-style1" colspan="2" style="height: 28px">
<strong>Wybierz stan przekaznika</strong></td>
<td class="auto-style1" colspan="4" style="height: 28px">
<strong>Usuwanie ustawien crona</strong></td>
<tr align="center">
<td colspan="2" class="auto-style1" rowspan="2">
<form name="listswitchharm" action="/cgi-bin/switchharm/setswitchharm.sh" method="get" enctype="text/plain" >
<table cellpadding="4" style="height: 117px; width: 210px;">
<tr><td style="width: 105px; height: 90px;"> Godzina <br> <br>
<select name="hours" title="Wybierz godzine" style="width: 44px; height: 19px;">
<option value="*"></option>
<option value="0">0</option><option value="1">1</option>
<option value="2">2</option><option value="3">3</option>
<option value="4">4</option><option value="5">5</option>
<option value="6">6</option><option value="7">7</option>
<option value="8">8</option><option value="9">9</option>
<option value="10">10</option><option value="11">11</option>
<option value="12">12</option><option value="13">13</option>
<option value="14">14</option><option value="15">15</option>
<option value="16">16</option><option value="17">17</option>
<option value="18">18</option><option value="19">19</option>
<option value="20">20</option><option value="21">21</option>
<option value="22">22</option><option value="23">23</option>
</select><input type="checkbox" title="Co wybrany zakres godzin" name="everyhour" value="on" class="auto-style10" style="width: 22px"></td>
<td style="height: 90px"> Minuty<br><br>
<select name="minutes" title="Wybierz minuty" style="height: 19px; width: 62px;">
<option value="*"></option>
<option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option>
<option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option>
<option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option>
<option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option>
<option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option>
<option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option>
<option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option>
<option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option>
<option value="32">32</option><option value="33">33</option><option value="34">34</option><option value="35">35</option>
<option value="36">36</option><option value="37">37</option><option value="38">38</option><option value="39">39</option>
<option value="40">40</option><option value="41">41</option><option value="42">42</option><option value="43">43</option>
<option value="44">44</option><option value="45">45</option><option value="46">46</option><option value="47">47</option>
<option value="48">48</option><option value="49">49</option><option value="50">50</option><option value="51">51</option>
<option value="52">52</option><option value="53">53</option><option value="54">54</option><option value="55">55</option>
<option value="56">56</option><option value="57">57</option><option value="58">58</option><option value="59">59</option>
</select><input type="checkbox" title="Co wybrany zakres minut" name="everymin" value="on" class="auto-style7"></td></tr>
<tr><td style="height: 57px; width: 105px;"> Dzien<br> <br>
<select name="day" title="Wybierz dzien" style="width: 40px; height: 19px;" >
<option value="*"></option>
<option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option>
<option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option>
<option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option>
<option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option>
<option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option>
<option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option>
<option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option>
<option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option>
</select><input type="checkbox" title="Co podany dzien" name="everyday" value="on" class="auto-style8" style="width: 20px"></td>
<td style="height: 57" class="auto-style1"> Dzien tygodnia<br><br>
<select name="dayofweek" title="Wybierz dzien tygodnia" style="height: 19px" >
<option value="*"></option>
<option value="1">Poniedzialek</option>
<option value="2">Wtorek</option>
<option value="3">Sroda</option>
<option value="4">Czwartek</option>
<option value="5">Piatek</option>
<option value="6">Sobota</option>
<option value="0">Niedziela</option>
</select></td></tr>
</table>
<td colspan="2" class="auto-style1" rowspan="2">
<table cellpadding="4" style="height: 175px; width: 210px"><tr>
<td align="center" style="height: 11px">
<input type="radio" name="activ1" value="V1" checked="true"/>Wlaczenie</td>
<td style="height: 11px"><input type="radio" name="activ" value="V1" checked="true"/>Wylaczenie</td></tr>
<tr><td align="center" colspan="2" style="height: 114px">Numer przekaznika<br><br>
<select name="nrswitch" title="Wybierz nr portu" class="auto-style6" style="width: 118px; height: 19px;">
<option value="1">1</option>
<option value="2">2</option><option value="3">3</option>
<option value="4">4</option><option value="5">5</option>
<option value="6">6</option><option value="7">7</option>
<option value="8">8</option>
</select></td></tr>
<tr><td align="center" colspan="2" style="height: 36px">
<input type="submit" title="dodaj do harmonogramu" value="Dodaj" id="wpisz" style="width: 133px; height: 28px;"/></td></tr>
</table>
</form>
</td>
<td style="height: 13px;" colspan="4" class="auto-style1">
<iframe src="/cgi-bin/switchharm/readharm.sh" frameborder="1" style="width: 455px; height: 58px;" class="auto-style6" id="I1" name="I1"></iframe></td>
</tr>
<tr align="center">
<td colspan="4" class="auto-style1" style="height: 13px">
<form name="delswitchharm" action="/cgi-bin/switchharm/delswitchharm.sh" method="get" enctype="text/plain" style="height: 50px" class="auto-style11" >
<br>
<input type="submit" name="usuwanie" value="Usun" onclick="return confirm('Na pewno chcesz usunac ?');" style="height: 26px; width: 161px"/>
<select name="lstswitchharm" class="auto-style9" style="height: 34px; width: 172px" >
<?
/www/cgi-bin/switchharm/lstswitchharm.sh
?>
</select></form>
</td>
</tr>
</table>
</div>
<head>
<title>Power Switch w garazu</title>
<script src="file:///H:/GitHub/Gargoyle/62b7660_gargoyle/package/plugin-gargoyle-minidlna/files/www/js/jquery.min.js"></script> <!-- Trzeba pobrać: http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js -->
<script>
$(document).ready(function(){
setInterval(function (){
$.get('cgi-bin/powersw/stan1.sh',function(data) {
$('#buttona').attr('src',"iconsw/"+data+".png");
$('#buttona').attr('power',data);
});
},4000);
$('#buttona').click(function(){
var power=$(this).attr('power');
if(power=='on'){
power='off'
}else{
power='on';
}
if(power=='NA'){
power='NA';
}
$.get('cgi-bin/powersw/power1.sh',{action:power},function(data) {
$('#buttona').attr('src',"iconsw/"+data+".png");
$('#buttona').attr('power',data);
});
});
});
</script>
<script>
$(document).ready(function(){
setInterval(function (){
$.get('cgi-bin/powersw/stan2.sh',function(data) {
$('#buttonb').attr('src',"iconsw/"+data+".png");
$('#buttonb').attr('power',data);
});
},4000);
$('#buttonb').click(function(){
var power=$(this).attr('power');
if(power=='on'){
power='off'
}else{
power='on';
}
if(power=='NA'){
power='NA';
}
$.get('cgi-bin/powersw/power2.sh',{action:power},function(data) {
$('#buttonb').attr('src',"iconsw/"+data+".png");
$('#buttonb').attr('power',data);
});
});
});
</script>
<script>
$(document).ready(function(){
setInterval(function (){
$.get('cgi-bin/powersw/stan3.sh',function(data) {
$('#buttonc').attr('src',"iconsw/"+data+".png");
$('#buttonc').attr('power',data);
});
},4000);
$('#buttonc').click(function(){
var power=$(this).attr('power');
if(power=='on'){
power='off'
}else{
power='on';
}
if(power=='NA'){
power='NA';
}
$.get('cgi-bin/powersw/power3.sh',{action:power},function(data) {
$('#buttonc').attr('src',"iconsw/"+data+".png");
$('#buttonc').attr('power',data);
});
});
});
</script>
<script>
$(document).ready(function(){
setInterval(function (){
$.get('cgi-bin/powersw/stan4.sh',function(data) {
$('#buttond').attr('src',"iconsw/"+data+".png");
$('#buttond').attr('power',data);
});
},4000);
$('#buttond').click(function(){
var power=$(this).attr('power');
if(power=='on'){
power='off'
}else{
power='on';
}
if(power=='NA'){
power='NA';
}
$.get('cgi-bin/powersw/power4.sh',{action:power},function(data) {
$('#buttond').attr('src',"iconsw/"+data+".png");
$('#buttond').attr('power',data);
});
});
});
</script>
<script>
$(document).ready(function(){
setInterval(function (){
$.get('cgi-bin/powersw/stan5.sh',function(data) {
$('#buttone').attr('src',"iconsw/"+data+".png");
$('#buttone').attr('power',data);
});
},4000);
$('#buttone').click(function(){
var power=$(this).attr('power');
if(power=='on'){
power='off'
}else{
power='on';
}
if(power=='NA'){
power='NA';
}
$.get('cgi-bin/powersw/power5.sh',{action:power},function(data) {
$('#buttone').attr('src',"iconsw/"+data+".png");
$('#buttone').attr('power',data);
});
});
});
</script>
<script>
$(document).ready(function(){
setInterval(function (){
$.get('cgi-bin/powersw/stan6.sh',function(data) {
$('#buttonf').attr('src',"iconsw/"+data+".png");
$('#buttonf').attr('power',data);
});
},4000);
$('#buttonf').click(function(){
var power=$(this).attr('power');
if(power=='on'){
power='off'
}else{
power='on';
}
if(power=='NA'){
power='NA';
}
$.get('cgi-bin/powersw/power6.sh',{action:power},function(data) {
$('#buttonf').attr('src',"iconsw/"+data+".png");
$('#buttonf').attr('power',data);
});
});
});
</script>
<script>
$(document).ready(function(){
setInterval(function (){
$.get('cgi-bin/powersw/stan7.sh',function(data) {
$('#buttong').attr('src',"iconsw/"+data+".png");
$('#buttong').attr('power',data);
});
},4000);
$('#buttong').click(function(){
var power=$(this).attr('power');
if(power=='on'){
power='off'
}else{
power='on';
}
if(power=='NA'){
power='NA';
}
$.get('cgi-bin/powersw/power7.sh',{action:power},function(data) {
$('#buttong').attr('src',"iconsw/"+data+".png");
$('#buttong').attr('power',data);
});
});
});
</script>
<script>
$(document).ready(function(){
setInterval(function (){
$.get('cgi-bin/powersw/stan8.sh',function(data) {
$('#buttonh').attr('src',"iconsw/"+data+".png");
$('#buttonh').attr('power',data);
});
},4000);
$('#buttonh').click(function(){
var power=$(this).attr('power');
if(power=='on'){
power='off'
}else{
power='on';
}
if(power=='NA'){
power='NA';
}
$.get('cgi-bin/powersw/power8.sh',{action:power},function(data) {
$('#buttonh').attr('src',"iconsw/"+data+".png");
$('#buttonh').attr('power',data);
});
});
});
</script>
<!-- chwilowe przyciski -->
<script>
$(document).ready(function(){
$('#buttona1s').click(function(){
$.get('cgi-bin/powersw/power11s.sh')
});
});
</script>
<script>
$(document).ready(function(){
$('#buttonb1s').click(function(){
$.get('cgi-bin/powersw/power21s.sh')
});
});
</script>
<script>
$(document).ready(function(){
$('#buttonc1s').click(function(){
$.get('cgi-bin/powersw/power31s.sh')
});
});
</script>
<script>
$(document).ready(function(){
$('#buttond1s').click(function(){
$.get('cgi-bin/powersw/power41s.sh')
});
});
</script>
<script>
$(document).ready(function(){
$('#buttone1s').click(function(){
$.get('cgi-bin/powersw/power51s.sh')
});
});
</script>
<script>
$(document).ready(function(){
$('#buttonf1s').click(function(){
$.get('cgi-bin/powersw/power61s.sh')
});
});
</script>
<script>
$(document).ready(function(){
$('#buttong1s').click(function(){
$.get('cgi-bin/powersw/power71s.sh')
});
});
</script>
<script>
$(document).ready(function(){
$('#buttonh1s').click(function(){
$.get('cgi-bin/powersw/power81s.sh')
});
});
</script>
<style type="text/css">
.auto-style1 {
border: 2px solid #000000;
}
.auto-style2 {
border-width: 2px;
}
.auto-style4 {
border-left-style: solid;
border-left-width: 2px;
border-right-style: solid;
border-right-width: 2px;
border-top-style: solid;
border-top-width: 2px;
border-bottom-width: 2px;
}
.auto-style6 {
margin-left: 0px;
}
.auto-style7 {
margin-left: 11px;
}
.auto-style8 {
margin-left: 6px;
}
.auto-style9 {
margin-left: 40px;
}
.auto-style10 {
margin-left: 2px;
}
.auto-style11 {
margin-left: 1px;
}
.auto-style12 {
margin-left: 13px;
}
</style>
</fieldset>
<?
gargoyle_header_footer -f -s "system" -p "powerswitch"
?>