tazpanel view index.cgi @ rev 74

move syntax_highlighter to libtazpanel to be used in other case than file and put colors in CSS so it themeable
author Christophe Lincoln <pankso@slitaz.org>
date Tue Apr 12 03:36:52 2011 +0200 (2011-04-12)
parents 1938c9c0603b
children 1780ef64bcd5
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 | syntax_highlighter conf ;;
53 *)
54 cat $WANT ;;
55 esac
56 echo '</pre>' ;;
57 debug*)
58 TITLE="- Debug"
59 xhtml_header
60 cat << EOT
61 <h2>QUERY_STRING</h2>
62 <pre>
63 QUERY_STRING="$QUERY_STRING"
65 Fuction: query_string_parser (<a href="?debug=test=var1=var2">test</a>)
67 CASE="$CASE"
68 WANT="$WANT"
69 VAR_1="$VAR_1"
70 VAR_2="$VAR_2"
71 </pre>
72 EOT
73 echo '<h2>HTTP Environment</h2>'
74 local var
75 local info
76 echo '<pre>'
77 for var in SERVER_SOFTWARE SERVER_NAME SERVER_PORT GATEWAY_INTERFACE \
78 AUTH_TYPE REMOTE_ADDR REMOTE_PORT HTTP_HOST HTTP_USER_AGENT \
79 HTTP_ACCEPT_LANGUAGE REQUEST_METHOD REQUEST_URI QUERY_STRING \
80 CONTENT_LENGTH CONTENT_TYPE SCRIPT_NAME SCRIPT_FILENAME PWD
81 do
82 eval info=\$$var
83 echo "$var=\"$info\""
84 done
85 echo '</pre>' ;;
86 *)
87 #
88 # Default xHTML content
89 #
90 xhtml_header
91 case "$QUERY_STRING" in
92 gen-locale=*)
93 new_locale=${QUERY_STRING#gen-locale=} ;;
94 rdate)
95 echo "" ;;
96 esac
97 cat << EOT
98 <div id="wrapper">
99 <h2>`gettext "Host:"` `hostname`</h2>
100 <p>`gettext "SliTaz administration and configuration Panel"`<p>
101 </div>
103 <h3>`gettext "Summary"`</h3>
104 <div id="summary">
105 <p>
106 `gettext "Uptime:"` `uptime`
107 </p>
108 <p>
109 `gettext "Memory in Mb"`
110 `free -m | grep Mem: | awk \
111 '{print "| Total:", $2, "| Used:", $3, "| Free:", $4}'`
112 </p>
113 <!-- Close summary -->
114 </div>
116 <h4>`gettext "Network status"`</h4>
117 `list_network_interfaces`
119 <h4>`gettext "Filesystem usage statistics"`</h4>
120 <pre>
121 `df -h | grep ^/dev`
122 </pre>
124 <h3>`gettext "Panel settings"`</h3>
125 <form method="get" action="$SCRIPT_NAME">
126 <div>
127 `gettext "Panel password:"`
128 <input type="password" name="panel-pass"/>
129 <input type="submit" value="`gettext "Change"`" />
130 </div>
131 </form>
132 <p>
133 $(gettext "TazPanel provides a debuging mode and page:")
134 <a href='$SCRIPT_NAME?debug'>debug</a>
135 </p>
137 EOT
138 ;;
139 esac
141 xhtml_footer
142 exit 0