additional dart sound files
[svn42.git] / powersensordaemon / switch.cgi
1 #!/bin/sh
2
3 for QUERY in `echo $QUERY_STRING | tr '&' ' '`; do
4   for VALUE in `echo $QUERY | tr '=' ' '`; do
5     if [ "$VALUE" == "id" ]; then
6       ID='?'
7     elif [ "$ID" == "?" ]; then
8       ID=$VALUE
9     elif [ "$VALUE" == "power" ]; then
10       POWER='?'
11     elif [ "$POWER" == "?" ]; then
12       POWER=$VALUE
13     elif [ "$VALUE" == "ajax" ]; then
14       AJAX='?'
15     elif [ "$AJAX" == "?" ]; then
16       AJAX=$VALUE
17     fi
18     i=$i+1
19   done
20 done
21
22 UNIXSOCK=/var/run/powersensordaemon/cmd.sock
23 VALID_ONOFF_IDS="decke ambientlights lichter all werkzeug labor dart logo spots1 deckehinten deckevorne boiler"
24 VALID_SEND_IDS="ymhpoweron ymhpoweroff ymhpower ymhvolup ymhvoldown ymhcd ymhwdtv ymhtuner ymhaux ymhsattv ymhvolmute ymhmenu ymhplus ymhminus ymhtest ymhtimelevel ymheffect ymhprgup ymhprgdown ymhtunplus ymhtunminus ymhtunabcde ymhtape ymhvcr ymhextdec ymhsleep ymhp5 panicled blueled moviemode"
25 VALID_BANSHEE_IDS="playPause next prev"
26
27 [ "$POWER" == "send" ] && POWER=on
28 if [ "$POWER" == "on" -o "$POWER" == "off" ]; then
29   for CHECKID in $VALID_ONOFF_IDS $VALID_SEND_IDS; do 
30     if [ "$CHECKID" == "$ID" ]; then
31       echo "power $POWER $ID" | usocket $UNIXSOCK
32       echo "Content-type: text/html"
33       echo ""
34       echo "<html>"
35       echo "<head>"
36       echo "<title>Realraum rf433ctl</title>"
37       echo '<script type="text/javascript">window.location="http://slug.realraum.at/cgi-bin/switch.cgi";</script>'
38       echo "</head></html>"
39       exit 0
40     fi
41   done
42
43   for CHECKID in $VALID_BANSHEE_IDS; do 
44     if [ "$CHECKID" == "$ID" ]; then
45       echo "$ID/" | nc wuerfel.realraum.at 8484
46       echo "Content-type: text/html"
47       echo ""
48       echo "<html>"
49       echo "<head>"
50       echo "<title>Realraum rf433ctl</title>"
51       echo '<script type="text/javascript">window.location="http://slug.realraum.at/cgi-bin/switch.cgi";</script>'
52       echo "</head></html>"
53       exit 0
54     fi
55   done
56 fi
57
58 DESC_werkzeug="Werkzeug LEDs"
59 DESC_stereo="Receiver On/Off"
60 DESC_ambientlights="Ambient Lichter"
61 DESC_labor="Labor Licht"
62 DESC_boiler="Warmwasser WC"
63 DESC_dart="Dart Scheibe"
64 DESC_logo="Logo"
65 DESC_spots1="Spots"
66 DESC_deckehinten="Decke Hinten"
67 DESC_deckevorne="Decke Vorne"
68 DESC_decke="Deckenlichter"
69 DESC_lichter="Alle Lichter"
70 DESC_all="Alles"
71 DESC_ymhpoweron="Receiver On"
72 DESC_ymhpoweroff="Receiver Off"
73 DESC_ymhpower="Receiver On/Off"
74 DESC_ymhvolup="VolumeUp"
75 DESC_ymhvoldown="VolumeDown"
76 DESC_ymhcd="Input CD"
77 DESC_ymhwdtv="Input WDlxTV"
78 DESC_ymhtuner="Input Tuner"
79 DESC_ymhvolmute="Mute"
80 DESC_ymhmenu="Menu"
81 DESC_ymhplus="+"
82 DESC_ymhminus="-"
83 DESC_ymhtest="Test"
84 DESC_ymhtimelevel="Time/Levels"
85 DESC_ymheffect="DSP Effect Toggle"
86 DESC_ymhprgup="DSP Up"
87 DESC_ymhprgdown="DSP Down"
88 DESC_ymhtunplus="Tuner +"
89 DESC_ymhtunminus="Tuner -"
90 DESC_ymhtunabcde="Tuner ABCDE"
91 DESC_ymhtape="Tape"
92 DESC_ymhvcr="VCR"
93 DESC_ymhextdec="ExtDec Toggle"
94 DESC_seep="Sleep Modus"
95 DESC_panicled="HAL9000 says hi"
96 DESC_blueled="Blue Led"
97 DESC_moviemode="Movie Mode"
98 echo "Content-type: text/html"
99 echo ""
100 echo "<html>"
101 echo "<head>"
102 echo "<title>Realraum rf433ctl</title>"
103 echo '<script type="text/javascript">'
104 echo 'function sendButton( onoff, btn )'
105 echo '{'
106 echo ' var req = new XMLHttpRequest();'
107 echo ' url = "http://slug.realraum.at/cgi-bin/switch.cgi?power="+onoff+"&id="+btn;'
108 echo ' req.open("GET", url ,false);'
109 echo ' //google chrome workaround'
110 echo ' req.setRequestHeader("googlechromefix","");'
111 echo ' req.send(null);'
112 echo '}'
113 echo '</script>'
114 echo "</head>"
115 echo "<body>"
116 #echo "<h1>Realraum rf433ctl</h1>"
117 echo "<div style=\"float:left; border:1px solid black;\">"
118 for DISPID in $VALID_ONOFF_IDS; do
119   NAME="$(eval echo \$DESC_$DISPID)"
120   [ -z "$NAME" ] && NAME=$DISPID
121   if [ -z "$AJAX" ]; then
122
123   echo "<form action=\"/cgi-bin/switch.cgi\">"
124   echo "<input type=\"hidden\" name=\"id\" value=\"$DISPID\" />"
125   echo "<div style=\"float:left; margin:2px; padding:1px; max-width:236px; font-size:10pt; border:1px solid black;\"><div style='width:10em; display:inline-block; vertical-align:middle;'>$NAME</div><span style='float:right; text-align:right;'>"
126   echo " <input type='submit' name='power' value='on' />"
127   echo " <input type='submit' name='power' value='off' />"
128   echo "</span></div>"
129   echo "</form>"
130   
131   else
132   
133   echo "<div style=\"float:left; margin:2px; padding:1px; max-width:236px; font-size:10pt; border:1px solid black;\"><div style='width:10em; display:inline-block; vertical-align:middle;'>$NAME</div><span style='float:right; text-align:right;'>"
134   echo " <button onClick='sendButton(\"on\",\"$DISPID\");'>On</button>"
135   echo " <button onClick='sendButton(\"off\",\"$DISPID\");'>Off</button>"
136   echo "</span></div>"
137   
138   fi
139 done
140 echo "</div>"
141 echo "<div style=\"float:left; border:1px solid black;\">"
142 for DISPID in $VALID_SEND_IDS; do
143   NAME="$(eval echo \$DESC_$DISPID)"
144   [ -z "$NAME" ] && NAME=$DISPID
145   if [ -z "$AJAX" ]; then
146
147   echo "<form action=\"/cgi-bin/switch.cgi\">"
148   echo "<input type=\"hidden\" name=\"id\" value=\"$DISPID\" />"
149   echo "<div style=\"float:left; margin:2px; padding:1px; max-width:236px; font-size:10pt; border:1px solid black;\"><div style='width:10em; display:inline-block; vertical-align:middle;'>$NAME</div><span style='float:right; text-align:right;'>"
150   echo " <input type='submit' name='power' value='send' />"
151   echo "</span></div>"
152   echo "</form>"
153
154   else
155   
156   echo "<div style=\"float:left; margin:2px; padding:1px; max-width:236px; font-size:10pt; border:1px solid black;\"><div style='width:10em; display:inline-block; vertical-align:middle;'>$NAME</div><span style='float:right; text-align:right;'>"
157   echo " <button onClick='sendButton(\"on\",\"$DISPID\");'>Send</button>"
158   echo "</span></div>"
159   
160   fi
161 done
162 echo "</div>"
163 echo "<div style=\"float:left; border:1px solid black;\">"
164 for DISPID in $VALID_BANSHEE_IDS; do
165   NAME="$(eval echo \$DESC_$DISPID)"
166   [ -z "$NAME" ] && NAME=$DISPID
167   if [ -z "$AJAX" ]; then
168
169   echo "<form action=\"/cgi-bin/switch.cgi\">"
170   echo "<input type=\"hidden\" name=\"id\" value=\"$DISPID\" />"
171   echo "<div style=\"float:left; margin:2px; padding:1px; max-width:236px; font-size:10pt; border:1px solid black;\"><div style='width:10em; display:inline-block; vertical-align:middle;'>$NAME</div><span style='float:right; text-align:right;'>"
172   echo " <input type='submit' name='power' value='on' />"
173   echo " <input type='submit' name='power' value='off' />"
174   echo "</span></div>"
175   echo "</form>"
176   
177   else
178   
179   echo "<div style=\"float:left; margin:2px; padding:1px; max-width:236px; font-size:10pt; border:1px solid black;\"><div style='width:10em; display:inline-block; vertical-align:middle;'>$NAME</div><span style='float:right; text-align:right;'>"
180   echo " <button onClick='sendButton(\"on\",\"$DISPID\");'>Send</button>"
181   echo "</span></div>"
182   
183   fi
184 done
185 echo "</div>"
186 echo "</body>"
187 echo "</html>"