tazpanel view index.cgi @ rev 60

Tiny edits
author Paul Issott <paul@slitaz.org>
date Mon Apr 11 19:48:06 2011 +0100 (2011-04-11)
parents 92ad1f0612db
children 95dc2475f4ae
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
15 query_string_parser
17 # Include gettext helper script.
18 . /usr/bin/gettext.sh
20 # Export package name for gettext.
21 TEXTDOMAIN='tazpanel'
22 export TEXTDOMAIN
24 #
25 # Things to do before displaying the page
26 #
28 case "$QUERY_STRING" in
29 panel-pass=*)
30 new=${QUERY_STRING#*=}
31 sed -i s@/:root:.*@/:root:$new@ $HTTPD_CONF ;;
32 *) continue ;;
33 esac
35 #
36 # Commands
37 #
39 case "$QUERY_STRING" in
40 file=*)
41 #
42 # Handle files (may have an edit function, we will see)
43 #
44 TITLE="- File"
45 xhtml_header
46 echo "<h2>$WANT</h2>"
47 echo '<pre>'
48 # Handle file type by extension as a Web Server does it.
49 # HTML entities: -e 's|&|\&amp;|g' -e 's|<|\&lt;|g' -e 's|>|\&gt;|g'
50 case "$WANT" in
51 *.conf|*.lst)
52 cat $WANT | sed \
53 -e s"#^\#\([^']*\)#<span style='color: \#555;'>\0</span>#"g \
54 -e s"#^[A-Z]\([^']*\)=#<span style='color: \#000073;'>\0</span>#"g \
55 -e s"#^[a-z]\([^']*\)#<span style='color: \#730c00;'>\0</span>#"g \
56 -e s"#\"\([^']*\)\"#<span style='color: \#730c00;'>\0</span>#"g ;;
57 *)
58 cat $WANT ;;
59 esac
60 echo '</pre>' ;;
61 debug*)
62 TITLE="- Debug"
63 xhtml_header
64 cat << EOT
65 <h2>QUERY_STRING</h2>
66 <pre>
67 QUERY_STRING="$QUERY_STRING"
69 Fuction: query_string_parser (<a href="?debug=test=var1=var2">test</a>)
71 CASE="$CASE"
72 WANT="$WANT"
73 VAR_1="$VAR_1"
74 VAR_2="$VAR_2"
75 </pre>
76 EOT
77 echo '<h2>HTTP Environment</h2>'
78 local var
79 local info
80 echo '<pre>'
81 for var in SERVER_SOFTWARE SERVER_NAME SERVER_PORT GATEWAY_INTERFACE \
82 AUTH_TYPE REMOTE_ADDR REMOTE_PORT HTTP_HOST HTTP_USER_AGENT \
83 HTTP_ACCEPT_LANGUAGE REQUEST_METHOD REQUEST_URI QUERY_STRING \
84 CONTENT_LENGTH CONTENT_TYPE SCRIPT_NAME SCRIPT_FILENAME PWD
85 do
86 eval info=\$$var
87 echo "$var=\"$info\""
88 done
89 echo '</pre>' ;;
90 *)
91 #
92 # Default xHTML content
93 #
94 xhtml_header
95 debug_info
96 case "$QUERY_STRING" in
97 gen-locale=*)
98 new_locale=${QUERY_STRING#gen-locale=} ;;
99 rdate)
100 echo "" ;;
101 esac
102 cat << EOT
103 <div id="wrapper">
104 <h2>`gettext "Host:"` `hostname`</h2>
105 <p>`gettext "SliTaz administration and configuration Panel"`<p>
106 </div>
108 <h3>`gettext "Summary"`</h3>
109 <div id="summary">
110 <p>
111 `gettext "Uptime:"` `uptime`
112 </p>
113 <p>
114 `gettext "Memory in Mb"`
115 `free -m | grep Mem: | awk \
116 '{print "| Total:", $2, "| Used:", $3, "| Free:", $4}'`
117 </p>
118 <!-- Close summary -->
119 </div>
121 <h4>`gettext "Network status"`</h4>
122 `list_network_interfaces`
124 <h4>`gettext "Filesystem usage statistics"`</h4>
125 <pre>
126 `df -h | grep ^/dev`
127 </pre>
129 <h3>`gettext "Panel settings"`</h3>
130 <form method="get" action="$SCRIPT_NAME">
131 <div>
132 `gettext "Panel password:"`
133 <input type="password" name="panel-pass"/>
134 <input type="submit" value="`gettext "Change"`" />
135 </div>
136 </form>
137 <p>
138 $(gettext "TazPanel provides a debuging mode and page:")
139 <a href='$SCRIPT_NAME?debug'>debug</a>
140 </p>
142 EOT
143 ;;
144 esac
146 xhtml_footer
147 exit 0