tazpanel view index.cgi @ rev 55
debug: add HTTP environment
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Apr 10 22:01:15 2011 +0200 (2011-04-10) |
parents | 6104795d77ff |
children | 769f91a0718d |
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
23 #
24 # Things to do before displaying the page
25 #
27 case "$QUERY_STRING" in
28 panel-pass=*)
29 new=${QUERY_STRING#*=}
30 sed -i s@/:root:.*@/:root:$new@ $HTTPD_CONF ;;
31 *) continue ;;
32 esac
34 #
35 # Commands
36 #
38 case "$QUERY_STRING" in
39 debug*)
40 TITLE="- Debug"
41 query_string_parser
42 xhtml_header
43 cat << EOT
44 <h2>QUERY_STRING</h2>
45 <pre>
46 QUERY_STRING="$QUERY_STRING"
48 Fuction: query_string_parser (<a href="?debug=test=var1=var2">test</a>)
50 CASE="$CASE"
51 WANT="$WANT"
52 VAR_1="$VAR_1"
53 VAR_2="$VAR_2"
54 </pre>
55 EOT
56 echo '<h2>HTTP Environment</h2>'
57 local var
58 local info
59 echo '<pre>'
60 for var in SERVER_SOFTWARE SERVER_NAME SERVER_PORT GATEWAY_INTERFACE \
61 AUTH_TYPE REMOTE_ADDR REMOTE_PORT HTTP_HOST HTTP_USER_AGENT \
62 HTTP_ACCEPT_LANGUAGE REQUEST_METHOD REQUEST_URI QUERY_STRING \
63 CONTENT_LENGTH CONTENT_TYPE SCRIPT_NAME SCRIPT_FILENAME PWD
64 do
65 eval info=\$$var
66 echo "$var=\"$info\""
67 done
68 echo '</pre>' ;;
69 *)
70 #
71 # Default xHTML content
72 #
73 xhtml_header
74 debug_info
75 case "$QUERY_STRING" in
76 gen-locale=*)
77 new_locale=${QUERY_STRING#gen-locale=} ;;
78 rdate)
79 echo "" ;;
80 esac
81 cat << EOT
82 <div id="wrapper">
83 <h2>`gettext "Host:"` `hostname`</h2>
84 <p>`gettext "SliTaz administration and configuration Panel"`<p>
85 </div>
87 <h3>`gettext "Summary"`</h3>
88 <div id="summary">
89 <p>
90 `gettext "Uptime:"` `uptime`
91 </p>
92 <p>
93 `gettext "Memory in Mb"`
94 `free -m | grep Mem: | awk \
95 '{print "| Total:", $2, "| Used:", $3, "| Free:", $4}'`
96 </p>
97 <!-- Close summary -->
98 </div>
100 <h4>`gettext "Network status"`</h4>
101 `list_network_interfaces`
103 <h4>`gettext "Filesystem usage statistics"`</h4>
104 <pre>
105 `df -h | grep ^/dev`
106 </pre>
108 <h3>`gettext "Panel settings"`</h3>
109 <form method="get" action="$SCRIPT_NAME">
110 <div>
111 `gettext "Panel password:"`
112 <input type="password" name="panel-pass"/>
113 <input type="submit" value="`gettext "Change"`" />
114 </div>
115 </form>
116 <p>
117 $(gettext "TazPanel provide a debuging mode and page:")
118 <a href='$SCRIPT_NAME?debug'>debug</a>
119 </p>
121 EOT
122 ;;
123 esac
125 xhtml_footer
126 exit 0