- values in config files can be surrounded by apostrophes
[opensuse:smpppd.git] / web / internet.html
1 #!/bin/sh
2 #
3 # Internet Connection Script / HTML Frontend
4 # Authors:  Christian Steinruecken <cstein@suse.de>
5 #           Arvin Schnell <arvin@suse.de>
6 #           Christopher Hofmann <cwh@suse.de>
7 #           Adrian Schroeter <adrian@suse.de>
8 #
9
10 VERSION="0.42"
11
12 url="internet.html"
13 imgdir="/images/smpppd"
14 cint_cmd="/usr/sbin/cinternet-wwwrun --only-local"
15
16
17 wait=60
18 cmd=""
19 lang=""
20
21 conn_status=`${cint_cmd} --status | grep "status = " | cut -b 10-`
22
23 case "$conn_status" in
24     DISCONNECTED)  wait=60 ;;
25     LURKING)       wait=30 ;;
26     CONNECTING)    wait=5 ;;
27     CONNECTED)     wait=30 ;;
28     DISCONNECTING) wait=5 ;;
29     *)             wait=60 ;;
30 esac
31
32 while [ -n "$1" ]; do
33 echo "XXX" >> /tmp/log
34 echo "$1" >> /tmp/log
35     case "$1" in
36     "con") # CONNECT CMD
37            ${cint_cmd} --start
38            wait=1
39            cmd=""
40            ;;
41     "dis") # DISCONNECT CMD
42            ${cint_cmd} --stop
43            wait=1
44            cmd=""
45            ;;
46     "sel") # SELECT: DISPLAY ISP BOX
47            wait=60
48            cmd="sel"
49            ;;
50     "act") # SELECT ISP CMD
51            ${cint_cmd} --provider-number "$2"
52            shift
53            cmd=""
54            ;;
55     "lang")# CHOOSE LANGUAGE
56            lang="$2"
57            shift
58            ;;
59     esac
60     shift
61 done
62
63 # LANGUAGE definitions
64
65 case "$lang" in
66 de*) STR_DIS="Nicht verbunden"
67      STR_LURING="Wartend"
68      STR_CONING="Wird aufgebaut"
69      STR_CON="Verbunden"
70      STR_DISING="Wird getrennt"
71      STR_ERR="Fehler"
72
73      STR_CONNECT="Verbinden"
74      STR_DISCONNECT="Trennen"
75
76      STR_STATUS="Status"
77      STR_RETURN="Zurück"
78
79      STR_CISP="Aktueller Provider:"
80      STR_SEL_ISP="Provider auswählen"
81      STR_ASEL_ISP="Wählen Sie einen Provider:"
82      STR_NO_ISP="Kein Provider gewählt"
83
84      STR_HEADLINE="Internet Einwahl Verbindung"
85      STR_SERVER="Rechner"
86      ;;
87
88 cs*) STR_DIS="NepÅ231ipojeno"
89      STR_LURING="Ä214eká se"
90      STR_CONING="PÅ231ipojuje se"
91      STR_CON="PÅ231ipojeno"
92      STR_DISING="Odpojuje se"
93      STR_ERR="Chyba"
94
95      STR_CONNECT="PÅ231ipojit"
96      STR_DISCONNECT="Odpojit"
97
98      STR_STATUS="Stav"
99      STR_RETURN="Návrat"
100
101      STR_CISP="Aktuální poskytovatel:"
102      STR_SEL_ISP="Vybrat poskytovatele"
103      STR_ASEL_ISP="Vyberte poskytovatele:"
104      STR_NO_ISP="Není vybraný poskytovatel"
105
106      STR_HEADLINE="VytáÄ215ené pÅ231ipojení k Internetu"
107      STR_SERVER="Server"
108      ;;
109
110 *)   STR_DIS="Disconnected"
111      STR_LURING="Lurking"
112      STR_CONING="Connecting"
113      STR_CON="Connected"
114      STR_DISING="Disconnecting"
115      STR_ERR="Error"
116
117      STR_CONNECT="Connect"
118      STR_DISCONNECT="Disconnect"
119
120      STR_STATUS="Status"
121      STR_RETURN="Return"
122
123      STR_CISP="Current provider:"
124      STR_SEL_ISP="Select provider"
125      STR_ASEL_ISP="Select a provider:"
126      STR_NO_ISP="No provider selected"
127
128      STR_HEADLINE="Internet Dialup Connection"
129      STR_SERVER="Server"
130      ;;
131
132 esac
133
134 # END of language definitions
135
136
137 getproviders() {
138     n="0"
139     while read line; do
140         set -- $line
141         num="$1"
142         n=`expr $n + 1`
143         shift
144         prov=$*
145         case "$num" in
146             0) echo "<tr><td bgcolor=\"#ffffde\">[ <a href=\"$url?lang+$lang+act+${n}\">$prov</a> ]</td></tr>" ;;
147             1) echo "<tr><td bgcolor=\"#d0d0d0\">[ <a href=\"$url?lang+$lang+act+${n}\">$prov</a> (*) ]</td></tr>" ;;
148         esac
149     done
150 }
151
152
153 get_current_provider() {
154     found=""
155     while read line; do
156         set -- $line
157         num="$1"
158         shift
159         prov=$*
160         if [ "$num" = "1" ]; then
161             echo "$prov"
162             found=1;
163         fi
164     done
165     if [ -z "$found" ]; then
166         echo "<i>$STR_NO_ISP</i>"
167     fi
168 }
169
170
171 ISP_box() {
172         cat <<-EOF
173                 <table bgcolor="#aFaF8E" border=0 cellpadding=3 cellspacing=0>
174                 <tr>
175                 <td>
176                         <table bgcolor="#FFFFDE" border=0 cellpadding=4 cellspacing=0>
177                         <tr>
178                         <td>
179                                 <b>$STR_ASEL_ISP</b>
180                         </td>
181                         </tr>
182         EOF
183
184         ${cint_cmd} --provider-list | getproviders
185
186         cat <<-EOF
187                         </table>
188                 </td></tr>
189                 </table>
190
191         EOF
192 }
193
194
195 page_start() {
196         cat <<-EOF
197                 Content-type: text/html; charset=UTF-8
198                 Refresh: $wait; URL=$url?lang+$lang
199
200                 <!--------------------------------------------- page start ------------------------------------------>
201                 <html>
202                 <head>
203                 <title>SuSE Linux Connectivity Server - $STR_HEADLINE</title>
204                 <meta http-equiv="expires" content="0">
205                 <meta name="Author" content="Christian Steinrücken <cstein@suse.de>">
206                 <meta name="Author" content="Christopher Hofmann <cwh@suse.de">
207                 <meta name="Version" content="$Version">
208                 <meta name="charset" content="iso-8859-1">
209                 <link rel=stylesheet type="text/css" href="/slcs.css">
210                 <!--<link rel="SHORTCUT ICON" href="/favicon.ico">-->
211                 </head>
212                 <body bgcolor="#FFFFFF" marginwidth="0" marginheight="0">
213                 <table border="0" cellspacing="0" cellpadding="0" width="100%">
214                         <tr>
215                         <td>
216                         <table border="0" cellspacing="0" cellpadding="0" width="100%">
217                                 <tr bgcolor="#FFFFFF">
218                                 <td valign="top" width="1%"><img src="/images/logo-new-l.gif" alt=""></td>
219                                 <td valign="top">
220                                 <table border="0" cellspacing="0" cellpadding="0" width="100%">
221                                         <tr>
222                                         <td valign="top">
223                                                 <img src="/images/logo-new-r.gif" alt=""><nobr><BR><img src="/images/space.gif" alt="" width="1" height="4"><BR>
224                                                 <font size="+3">SuSE Linux Connectivity Server</font><BR>
225                                                 $STR_HEADLINE<br><br></nobr>
226                                         </td>
227                                         </tr>
228                                         <tr>
229                                         <td>
230                                                 <font size="-1">
231                                                 <a href="http://`hostname -f`/">Main Page</a>
232                                                 | <a href="http://internet/">Internet Connection</a>
233                                                 | <a href="http://password/">Change Password</a>
234                                                 | <a href="http://`hostname -f`/susehelp/">Help</a>
235                                                 </font>
236                                         </td>
237                                         </tr>
238                                 </table>
239                                 <hr noshade>
240                                 </td>
241                                 </tr>
242                         </table>
243                         <table width="100%" border="0" cellspacing="0" cellpadding="5">
244                                 <tr>
245                                 <td valign="top" align="left" width="1%" bgcolor="#FFFFFF"><img src="/images/space.gif" alt="" width="2" height="1" border="0"></td>
246                                 <td valign="top" width="1%" bgcolor="#FFFFFF">
247                                 <img src="/images/space.gif" alt="" width="120" height="5" border="0"><br>
248                                 <!--
249                                 <table bgcolor="#adad89" border="0" cellpadding="2" cellspacing="0">
250                                         <tr>
251                                         <td>
252                                         <table bgcolor="#fdfdc8" border="0" cellpadding="3" cellspacing="0">
253                                         <tr>
254                                         <td><font size="-1">
255                                         <img src="/images/space.gif" width="110" height="1"><br>
256                                         [MENU]
257                                         </font>
258                                         </td>
259                                         </tr>
260                                         </table>
261                                         </td>
262                                         </tr>
263                                 </table>
264                                 -->
265                                 </td>
266                                 <td valign="top" align="left">
267                                 <CENTER>
268                                 <font size=\"+2\"><b>$STR_SERVER: `hostname -f`</b></font><br><br>
269
270         EOF
271 }
272
273
274 page_end() {
275         cat <<-EOF
276
277                 <!--------------------------------------------footer -------------------------------------------->
278                                 </CENTER>
279                                 <br>
280                                 <hr noshade>
281
282                                 <table border="0" cellspacing="0" cellpadding="0" width="100%">
283                                 <tr>
284                                 <td align="right">&copy;2001 <a href="http://www.suse.com">SuSE Linux AG</a></td>
285                                 </tr>
286                                 </table>
287
288                                 </td>
289                                 </tr>
290                         </table>
291                         </td>
292                         </tr>
293                 </table>
294                 </body>
295                 </html>
296
297         EOF
298 }
299
300 connection_status() {
301     case "$conn_status" in
302     DISCONNECTED)  echo -n "<font color=\"#1DD624\"><b>$STR_DIS</b></font>" ;;
303     LURKING)       echo -n "<font color=\"#E55C0D\"><b>$STR_LURING</b></font>" ;;
304     CONNECTING)    echo -n "<font color=\"#E55C0D\"><b>$STR_CONING</b></font>" ;;
305     CONNECTED)     echo -n "<font color=\"#F02020\"><b>$STR_CON</b></font>" ;;
306     DISCONNECTING) echo -n "<font color=\"#E55C0D\"><b>$STR_DISING</b></font>" ;;
307     *)             echo -n "<font color=\"#A0A0FF\"><b>$STR_ERR</b></font>" ;;
308     esac
309 }
310
311 dialbox() {
312         cat <<-EOF
313                 <table bgcolor="#aFaF8E" border="0" cellpadding="3" cellspacing="0">
314                 <tr>
315                 <td>
316                 <table bgcolor="#FFFFDE" border="0" cellpadding="3" cellspacing="0">
317                 <tr>
318                 <td colspan="2" align="center">$STR_CISP<b>
319         EOF
320
321         ${cint_cmd} --provider-list | get_current_provider
322
323         echo "<br>$STR_STATUS"
324         connection_status
325
326         cat <<-EOF
327                 </b></td></tr>
328                 <tr>
329                 <td align="center"><a href="$url?con+lang+$lang"><img src="/images/connect_creating.png" border="0"></a><br>
330                 [&nbsp;<a href="$url?con+lang+$lang">$STR_CONNECT</a>&nbsp;]</td>
331                 <td align="center"><a href="$url?dis+lang+$lang"><img src="/images/connect_no.png" border="0"></a><br>
332                 [&nbsp;<a href="$url?dis+lang+$lang">$STR_DISCONNECT</a>&nbsp;]</td>
333                 </tr>
334                 </table>
335                 </td>
336                 </tr>
337                 </table>
338
339         EOF
340 }
341
342 #
343 # here comes the main page
344 #
345
346 page_start
347
348 case "$cmd" in
349     sel) ISP_box
350          echo "<br>[ <a href=\"$url?lang+$lang\">$STR_RETURN</a> ]" ;;
351     *)   dialbox
352          getproviders
353          echo "<br>[ <a href=\"$url?lang+$lang+sel\">$STR_SEL_ISP</a> ]" ;;
354 esac
355
356 page_end
357