tazpanel view index.cgi @ rev 53

Add a debug page and a QUERY_STRING parser so we can use names CASE WANT VAR_1 VAR_2
author Christophe Lincoln <pankso@slitaz.org>
date Sun Apr 10 21:28:13 2011 +0200 (2011-04-10)
parents 730f8bcacabc
children 6104795d77ff
line source
1 #!/bin/sh
2 #
3 # Main CGI interface for TazPanel. In on word: KISS. Use the main css form
4 # command so we are faster and do not load unneeded functions. If necessary
5 # you can use the lib/ dir to handle external resources.
6 #
7 # Copyright (C) 2011 SliTaz GNU/Linux - GNU gpl v3
8 #
9 echo "Content-Type: text/html"
10 echo ""
12 # Common functions from libtazpanel
13 . lib/libtazpanel
14 get_config
16 # Include gettext helper script.
17 . /usr/bin/gettext.sh
19 # Export package name for gettext.
20 TEXTDOMAIN='tazpanel'
21 export TEXTDOMAIN
25 #
26 # Things to do before displaying the page
27 #
29 case "$QUERY_STRING" in
30 panel-pass=*)
31 new=${QUERY_STRING#*=}
32 sed -i s@/:root:.*@/:root:$new@ $HTTPD_CONF ;;
33 *) continue ;;
34 esac
36 #
37 # Commands
38 #
40 case "$QUERY_STRING" in
41 debug*)
42 TITLE="- Debug"
43 query_string_parser
44 xhtml_header
45 cat << EOT
46 <pre>
47 QUERY_STRING="$QUERY_STRING"
49 Fuction: query_string_parser (<a href="?debug=test=var1=var2">test</a>)
51 CASE="$CASE"
52 WANT="$WANT"
53 VAR_1="$VAR_1"
54 VAR_2="$VAR_2"
55 </pre>
56 EOT
57 ;;
58 *)
59 #
60 # Default xHTML content
61 #
62 xhtml_header
63 debug_info
64 case "$QUERY_STRING" in
65 gen-locale=*)
66 new_locale=${QUERY_STRING#gen-locale=} ;;
67 rdate)
68 echo "" ;;
69 esac
70 cat << EOT
71 <div id="wrapper">
72 <h2>`gettext "Host:"` `hostname`</h2>
73 <p>`gettext "SliTaz administration and configuration Panel"`<p>
74 </div>
76 <h3>`gettext "Summary"`</h3>
77 <div id="summary">
78 <p>
79 `gettext "Uptime:"` `uptime`
80 </p>
81 <p>
82 `gettext "Memory in Mb"`
83 `free -m | grep Mem: | awk \
84 '{print "| Total:", $2, "| Used:", $3, "| Free:", $4}'`
85 </p>
86 <!-- Close summary -->
87 </div>
89 <h4>`gettext "Network status"`</h4>
90 `list_network_interfaces`
92 <h4>`gettext "Filesystem usage statistics"`</h4>
93 <pre>
94 `df -h | grep ^/dev`
95 </pre>
97 <h3>`gettext "Panel settings"`</h3>
98 <form method="get" action="$SCRIPT_NAME">
99 <div>
100 <input type="submit" value="`gettext "Change Panel password"`" />
101 <input type="password" name="panel-pass"/>
102 </div>
103 </form>
104 <p>
105 $(gettext "TazPanel provide a debuging mode and page:")
106 <a href='$SCRIPT_NAME?debug'>debug</a>
107 </p>
109 EOT
110 ;;
111 esac
113 xhtml_footer
114 exit 0