tazpanel view index.cgi @ rev 56

Add a file view CASE so we can displa any file on the system (ex at boot.cgi with rcS.conf)
author Christophe Lincoln <pankso@slitaz.org>
date Sun Apr 10 20:20:19 2011 +0200 (2011-04-10)
parents eef817291804
children 92ad1f0612db
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, will see)
43 #
44 TITLE="- File"
45 xhtml_header
46 echo "<h2>$WANT</h2>"
47 echo '<pre>'
48 cat $WANT
49 echo '</pre>' ;;
50 debug*)
51 TITLE="- Debug"
52 xhtml_header
53 cat << EOT
54 <h2>QUERY_STRING</h2>
55 <pre>
56 QUERY_STRING="$QUERY_STRING"
58 Fuction: query_string_parser (<a href="?debug=test=var1=var2">test</a>)
60 CASE="$CASE"
61 WANT="$WANT"
62 VAR_1="$VAR_1"
63 VAR_2="$VAR_2"
64 </pre>
65 EOT
66 echo '<h2>HTTP Environment</h2>'
67 local var
68 local info
69 echo '<pre>'
70 for var in SERVER_SOFTWARE SERVER_NAME SERVER_PORT GATEWAY_INTERFACE \
71 AUTH_TYPE REMOTE_ADDR REMOTE_PORT HTTP_HOST HTTP_USER_AGENT \
72 HTTP_ACCEPT_LANGUAGE REQUEST_METHOD REQUEST_URI QUERY_STRING \
73 CONTENT_LENGTH CONTENT_TYPE SCRIPT_NAME SCRIPT_FILENAME PWD
74 do
75 eval info=\$$var
76 echo "$var=\"$info\""
77 done
78 echo '</pre>' ;;
79 *)
80 #
81 # Default xHTML content
82 #
83 xhtml_header
84 debug_info
85 case "$QUERY_STRING" in
86 gen-locale=*)
87 new_locale=${QUERY_STRING#gen-locale=} ;;
88 rdate)
89 echo "" ;;
90 esac
91 cat << EOT
92 <div id="wrapper">
93 <h2>`gettext "Host:"` `hostname`</h2>
94 <p>`gettext "SliTaz administration and configuration Panel"`<p>
95 </div>
97 <h3>`gettext "Summary"`</h3>
98 <div id="summary">
99 <p>
100 `gettext "Uptime:"` `uptime`
101 </p>
102 <p>
103 `gettext "Memory in Mb"`
104 `free -m | grep Mem: | awk \
105 '{print "| Total:", $2, "| Used:", $3, "| Free:", $4}'`
106 </p>
107 <!-- Close summary -->
108 </div>
110 <h4>`gettext "Network status"`</h4>
111 `list_network_interfaces`
113 <h4>`gettext "Filesystem usage statistics"`</h4>
114 <pre>
115 `df -h | grep ^/dev`
116 </pre>
118 <h3>`gettext "Panel settings"`</h3>
119 <form method="get" action="$SCRIPT_NAME">
120 <div>
121 `gettext "Panel password:"`
122 <input type="password" name="panel-pass"/>
123 <input type="submit" value="`gettext "Change"`" />
124 </div>
125 </form>
126 <p>
127 $(gettext "TazPanel provide a debuging mode and page:")
128 <a href='$SCRIPT_NAME?debug'>debug</a>
129 </p>
131 EOT
132 ;;
133 esac
135 xhtml_footer
136 exit 0