tazpanel diff index.cgi @ rev 419
Bunch of changes. Development in progress, please note it have few known bugs.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Tue Mar 24 03:39:08 2015 +0200 (2015-03-24) |
parents | 106b85c1951c |
children | 7488b357abd3 |
line diff
1.1 --- a/index.cgi Sat Jan 03 17:11:14 2015 +0200 1.2 +++ b/index.cgi Tue Mar 24 03:39:08 2015 +0200 1.3 @@ -1,54 +1,56 @@ 1.4 #!/bin/sh 1.5 # 1.6 -# Main CGI interface for TazPanel. In on word: KISS. Use the main css form 1.7 +# Main CGI interface for TazPanel. In on word: KISS. Use the main CSS form 1.8 # command so we are faster and do not load unneeded functions. If necessary 1.9 # you can use the lib/ dir to handle external resources. 1.10 # 1.11 -# Copyright (C) 2011-2014 SliTaz GNU/Linux - BSD License 1.12 +# Copyright (C) 2011-2015 SliTaz GNU/Linux - BSD License 1.13 # 1.14 1.15 + 1.16 # Common functions from libtazpanel 1.17 + 1.18 . lib/libtazpanel 1.19 get_config 1.20 -header 1.21 1.22 TITLE="TazPanel" 1.23 1.24 + 1.25 + 1.26 # Check whether a configuration file has been modified after installation 1.27 + 1.28 file_is_modified() 1.29 { 1.30 grep -l " $1$" $INSTALLED/*/md5sum | while read file; do 1.31 1.32 - # Found, but can we do diff ? 1.33 + # Found, but can we do diff? 1.34 [ "$(grep -h " $1$" $file)" != "$(md5sum $1)" ] || break 1.35 - org=$(dirname $file)/volatile.cpio.gz 1.36 - zcat $org 2>/dev/null | cpio -t 2>/dev/null | \ 1.37 - grep -q "^${1#/}$" || break 1.38 + orig=$(dirname $file)/volatile.cpio.gz 1.39 + zcat $orig 2>/dev/null | cpio -t 2>/dev/null | grep -q "^${1#/}$" || break 1.40 1.41 case "$2" in 1.42 - diff) 1.43 - tmp=/tmp/tazpanel$$ 1.44 - mkdir -p $tmp 1.45 - ( cd $tmp ; zcat $org | cpio -id ${1#/} ) 1.46 - diff -abu $tmp$1 $1 | sed "s|$tmp||" 1.47 - rm -rf $tmp ;; 1.48 - button) 1.49 - cat <<EOT 1.50 - <a class="button" href="?file=$1&action=diff"> 1.51 - <img src="$IMAGES/help.png" />$(gettext 'Differences')</a> 1.52 -EOT 1.53 + diff) 1.54 + tmp=$(mktemp -d) 1.55 + ( cd $tmp; zcat $orig | cpio -id ${1#/} ) 1.56 + diff -abu $tmp$1 $1 | sed "s|$tmp||" 1.57 + rm -rf $tmp;; 1.58 + button) 1.59 + echo -n '<button name="action" value="diff" data-icon="diff">'$(gettext 'Differences')'</button>';; 1.60 esac 1.61 break 1.62 done 1.63 } 1.64 1.65 1.66 + 1.67 # OK status in table 1.68 + 1.69 ok_status_t() { 1.70 - echo " <td>[<span class='diff-add'> OK </span>]</td></tr>" 1.71 + echo '<td><span class="diff-add" data-img="ok"></span></td></tr>' 1.72 } 1.73 1.74 1.75 + 1.76 # 1.77 # Things to do before displaying the page 1.78 # 1.79 @@ -56,66 +58,96 @@ 1.80 [ -n "$(GET panel_pass)" ] && 1.81 sed -i s@/:root:.*@/:root:$(GET panel_pass)@ $HTTPD_CONF 1.82 1.83 + 1.84 + 1.85 + 1.86 + 1.87 # 1.88 # Commands 1.89 # 1.90 1.91 case " $(GET) " in 1.92 + 1.93 + 1.94 *\ exec\ *) 1.95 + # Execute command and display its result in a terminal-like window 1.96 + 1.97 + header; TITLE=$(gettext 'TazPanel - exec'); xhtml_header 1.98 + 1.99 exec="$(GET exec)" 1.100 - TITLE=$(gettext 'TazPanel - exec') 1.101 - xhtml_header 1.102 - cat << EOT 1.103 -<h2>$exec</h2> 1.104 -<pre> 1.105 -$($exec 2>&1 | htmlize) 1.106 -</pre> 1.107 + font="${TERM_FONT:-monospace}" 1.108 + palette=$(echo $TERM_PALETTE | tr A-Z a-z) 1.109 + 1.110 + cat <<EOT 1.111 +<section> 1.112 + <header> 1.113 + $exec 1.114 + $(back_button "$(GET back)" "$(GET back_caption)" "$(GET back_icon)") 1.115 + </header> 1.116 + <div class="term_"> 1.117 + <pre class="term $palette" style="font-family: '$font'">$($exec 2>&1 | htmlize | filter_taztools_msgs)</pre> 1.118 + </div> 1.119 +</section> 1.120 EOT 1.121 ;; 1.122 + 1.123 + 1.124 *\ file\ *) 1.125 # 1.126 # Handle files 1.127 # 1.128 + header 1.129 file="$(GET file)" 1.130 + action="$(POST action)"; [ -z "$action" ] && action="$(GET action)" # receive 'action' both on POST or GET 1.131 + 1.132 case $file in 1.133 *.html) 1.134 - cat $file && exit 0 ;; 1.135 + cat $file; exit 0 ;; 1.136 *) 1.137 - TITLE=$(gettext 'TazPanel - File') 1.138 - xhtml_header 1.139 - echo "<h2>$file</h2>" ;; 1.140 + TITLE=$(gettext 'TazPanel - File'); xhtml_header ;; 1.141 esac 1.142 1.143 - if [ "$(GET action)" == "edit" ]; then 1.144 - cat <<EOT 1.145 -<form method="post" action="?file=$file"> 1.146 - <img src="$IMAGES/edit.png" /> 1.147 - <input type="submit" value="$(gettext 'Save')"> 1.148 - <a class="button" href="?file=$file&action=diff"> 1.149 - <img src="$IMAGES/help.png" />$(gettext 'Differences')</a> 1.150 - <textarea name="content" rows="30" style="width: 100%;"> 1.151 -$(cat $file | htmlize) 1.152 -</textarea> 1.153 -</form> 1.154 + case "$action" in 1.155 + edit) 1.156 + cat <<EOT 1.157 +<section> 1.158 + <header> 1.159 + <span data-icon="edit">$file</span> 1.160 + <form id="editform" method="post" action="?file=$file" class="nogap"> 1.161 + <button data-icon="save">$(gettext 'Save')</button> 1.162 + <button name="action" value="diff" data-icon="diff">$(gettext 'Differences')</button> 1.163 + </form> 1.164 + </header> 1.165 + <textarea form="editform" name="content" class="wide" rows="30" autofocus>$(cat $file | htmlize)</textarea> 1.166 +</section> 1.167 EOT 1.168 #The space before textarea gets muddled when the form is submitted. 1.169 #It prevents anything else from getting messed up 1.170 - elif [ "$(GET action)" == "setvar" ]; then 1.171 + ;; 1.172 + 1.173 + setvar) 1.174 data="$(. $(GET file) ;eval echo \$$(GET var))" 1.175 cat <<EOT 1.176 -<form method="post" action="?file=$file"> 1.177 - <img src="$IMAGES/edit.png" /> 1.178 - <input type="submit" value="$(gettext 'Save')"> 1.179 - $(GET var) : 1.180 - <input type="hidden" name="var" value="$(GET var)"> 1.181 - <input type="text" name="content" value="${data:-$(GET default)}"> 1.182 -</form> 1.183 +<section> 1.184 + <header>$(GET var)</header> 1.185 + <form method="post" action="?file=$file" class="nogap"> 1.186 + <input type="hidden" name="var" value="$(GET var)"> 1.187 + <input type="text" name="content" value="${data:-$(GET default)}"> 1.188 + <button type="submit" data-icon="save">$(gettext 'Save')</button> 1.189 + </form> 1.190 +</section> 1.191 EOT 1.192 - elif [ "$(GET action)" == "diff" ]; then 1.193 - echo '<pre id="diff">' 1.194 - file_is_modified $file diff | syntax_highlighter diff 1.195 - echo '</pre>' 1.196 - else 1.197 + ;; 1.198 + 1.199 + diff) 1.200 + cat <<EOT 1.201 +<section> 1.202 + <pre id="diff">$(file_is_modified $file diff | syntax_highlighter diff)</pre> 1.203 +</section> 1.204 +EOT 1.205 + ;; 1.206 + 1.207 + *) 1.208 R=$(echo -en '\r') 1.209 if [ -n "$(POST content)" ]; then 1.210 if [ -n "$(POST var)" ]; then 1.211 @@ -126,15 +158,19 @@ 1.212 EOT 1.213 fi 1.214 fi 1.215 + 1.216 cat <<EOT 1.217 -<div id="actions"> 1.218 - <a class="button" href="?file=$file&action=edit"> 1.219 - <img src="$IMAGES/edit.png" />$(gettext 'Edit')</a> 1.220 -EOT 1.221 - file_is_modified $file button 1.222 - cat << EOT 1.223 -</div> 1.224 -<pre> 1.225 +<section> 1.226 + <header><span data-icon="text">$file</span> 1.227 + <form class="nogap"> 1.228 + <input type="hidden" name="file" value="$file"/> 1.229 + <button name="action" value="edit" data-icon="edit">$(gettext 'Edit')</button><!-- 1.230 + -->$(file_is_modified $file button) 1.231 + </form> 1.232 + </header> 1.233 + 1.234 + <div> 1.235 + <pre> 1.236 EOT 1.237 # Handle file type by extension as a Web Server does it. 1.238 case "$file" in 1.239 @@ -142,110 +178,305 @@ 1.240 syntax_highlighter conf ;; 1.241 *.sh|*.cgi) 1.242 syntax_highlighter sh ;; 1.243 + *Xorg.0.log) 1.244 + syntax_highlighter xlog ;; 1.245 + *dmesg.log) 1.246 + syntax_highlighter kernel ;; 1.247 *) 1.248 cat | htmlize ;; 1.249 esac < $file 1.250 - echo '</pre>' 1.251 - fi ;; 1.252 + cat <<EOT 1.253 + </pre> 1.254 + </div> 1.255 +</section> 1.256 +EOT 1.257 + esac 1.258 + ;; 1.259 + 1.260 1.261 1.262 *\ terminal\ *|*\ cmd\ *) 1.263 - # Cmdline terminal. 1.264 - commands='cat du help ls ping pwd who wget' 1.265 + # Cmdline terminal 1.266 + 1.267 + TITLE=$(gettext 'TazPanel - Terminal'); header; xhtml_header 1.268 + 1.269 + historyfile=/root/.ash_history 1.270 + #commands='cat cd date du fdisk help ls ping pwd who wget' 1.271 cmd=$(GET cmd) 1.272 - TITLE=$(gettext 'TazPanel - Terminal') 1.273 - xhtml_header 1.274 - cat << EOT 1.275 + 1.276 + path="$(GET path)"; path="${path:-/tmp}"; cd "${path/~//root}" 1.277 + [ "$path" == '/root' ] && path='~' 1.278 + user="$REMOTE_USER" 1.279 + [ -z "$HOME" ] && HOME=/root # for apps that modified user settings 1.280 + 1.281 + font="${TERM_FONT:-monospace}" 1.282 + palette=$(echo $TERM_PALETTE | tr A-Z a-z) 1.283 + 1.284 + [ -n "$cmd" -a "$cmd" != "$(tail -n1 $historyfile)" ] && echo "$cmd" >> $historyfile 1.285 + 1.286 + 1.287 + # Terminal history 1.288 + 1.289 + if [ "$cmd" == 'history' ]; then 1.290 + cat <<EOT 1.291 <section> 1.292 -<form method="get" action=""> 1.293 - <div class="box"> 1.294 - root@$(hostname):~# <input autofocus type="text" name="cmd" style="width: 80%;" /> 1.295 - </div> 1.296 -</form> 1.297 + <header> 1.298 + $(gettext 'History') 1.299 + <form><button name="terminal" data-icon="terminal">$(gettext 'Back')</button></form> 1.300 + </header> 1.301 + <form> 1.302 + <input type="hidden" name="path" value="$path"/> 1.303 + <pre class="term $palette" style="font-family: '$font'"> 1.304 EOT 1.305 - echo '<pre id="terminal">' 1.306 - # Allow only a few commands for the moment. 1.307 - case "$cmd" in 1.308 + htmlize < $historyfile | awk -vrun="$(gettext 'run')" -vpath="$path" ' 1.309 + BEGIN { num=1 } 1.310 + { 1.311 + printf("%3d ", num); 1.312 + cmd = $0 1.313 + gsub("%", "%25", cmd); gsub("+", "%2B", cmd); gsub(" ", "+", cmd); 1.314 + gsub("\"", "%22", cmd); gsub("!", "%21", cmd); gsub("'\''", "%27", cmd); 1.315 + printf("<a data-icon=\"run\" href=\"?cmd=%s&path=%s\">%s</a> ", cmd, path, run); 1.316 + printf("<input type=\"checkbox\" name=\"rm\" value=\"%d\" id=\"hist%d\">", num, num); 1.317 + printf("<label for=\"hist%d\">%s</label>\n", num, $0); 1.318 + num++ 1.319 + }' 1.320 + cat <<EOT 1.321 + </pre> 1.322 + <footer> 1.323 + <button name="rmhistory" data-icon="remove">$(gettext 'Clear')</button> 1.324 + </footer> 1.325 + </form> 1.326 +</section> 1.327 +EOT 1.328 + xhtml_footer 1.329 + exit 0 1.330 + fi 1.331 + 1.332 + 1.333 + # Terminal window 1.334 + 1.335 + cat <<EOT 1.336 +<span id="num_hist"></span> 1.337 +<section> 1.338 + <pre class="term $palette" style="font-family: '$font'" onclick="document.getElementById('typeField').focus()"> 1.339 +EOT 1.340 + if [ -n "$cmd" ]; then 1.341 + echo -n "<span class='color31'>$user@$(hostname)</span>:<span class='color33'>$path</span># " 1.342 + echo "$cmd" | htmlize 1.343 + fi 1.344 + 1.345 + case "$cmd" in 1.346 usage|help) 1.347 - gettext 'Small terminal emulator, commands options are supported.' 1.348 - echo "" 1.349 - eval_gettext 'Commands: $commands' 1.350 - echo ;; 1.351 + gettext 'Small non-interactive terminal emulator.'; echo 1.352 + gettext 'Run any command at your own risk, avoid interactive commands (nano, mc, ...)'; echo 1.353 + ;; 1.354 wget*) 1.355 dl=/var/cache/downloads 1.356 [ ! -d "$dl" ] && mkdir -p $dl 1.357 - eval_gettext 'Downloading to: $dl' && echo 1.358 - cd $dl && $cmd ;; 1.359 - du*|ls*|ping*|pwd|who) 1.360 - $cmd ;; 1.361 - cat*) 1.362 + eval_gettext 'Downloading to: $dl'; echo 1.363 + cd $dl; $cmd 2>&1 ;; 1.364 + cd|cd\ *) 1.365 + path="${cmd#cd}"; path="${path:-/root}"; path="$(realpath $path)" ;; 1.366 + ls|ls\ *) 1.367 + $cmd -w80 --color=always 2>&1 | filter_taztools_msgs ;; 1.368 + cat) 1.369 # Cmd must be used with an arg. 1.370 - arg=$(echo $cmd | awk '{print $2}') 1.371 - [ "$arg" == "" ] && eval_gettext '$cmd needs an argument' && break 1.372 - $cmd ;; 1.373 + eval_gettext '$cmd needs an argument' ;; 1.374 + mc|nano) 1.375 + # List of restricted (interactive) commands 1.376 + eval_gettext "Please, don't run interactive command \"$cmd\""; echo; echo ;; 1.377 *) 1.378 - [ "$cmd" == "" ] || \ 1.379 - eval_gettext 'Unknown command: $cmd' && echo 1.380 - eval_gettext 'Commands: $commands' ;; 1.381 + unset HTTP_REFERER # for fooling /lib/libtaz.sh formatting utils (<hr> in the terminal is so-so) 1.382 + export DISPLAY=:0.0 # for run X applications 1.383 + /bin/sh -c "$cmd" 2>&1 | htmlize | filter_taztools_msgs 1.384 + ;; 1.385 esac 1.386 - echo '</pre></section>' 1.387 + 1.388 + [ "$path" == '/root' ] && path='~' 1.389 + cat <<EOT 1.390 +<form id="term"> 1.391 +<div class="cmdline" id="cmdline"><span id="prompt"><span class="color31">$user@$(hostname)</span>:<span class="color33">$path</span># </span><span id="typeField"> </span></div> 1.392 +<input type="hidden" name="path" value="$path"/> 1.393 +<input type="hidden" name="cmd" id="cmd"/> 1.394 +</form> 1.395 +</pre> 1.396 +</section> 1.397 + 1.398 +<form> 1.399 + <button name="termsettings" data-icon="settings">$(gettext 'Settings')</button> 1.400 + <button name="cmd" value="history" data-icon="history">$(gettext 'History')</button> 1.401 +</form> 1.402 + 1.403 +<script type="text/javascript"> 1.404 +with (document.getElementById('typeField')) { 1.405 + contentEditable=true; 1.406 + focus(); 1.407 +} 1.408 +document.onkeydown=keydownHandler; 1.409 +EOT 1.410 + 1.411 + # Export history as array. 1.412 + # Escape "all \"quotes\" in quotes", and all '\' 1.413 + # (because \u, \x, \c has special meaning and can produce syntax error and stop js) 1.414 + sed 's|\\|\\\\|g; s|"|\\"|g' $historyfile | awk ' 1.415 + BEGIN{ i=1; printf("ash_history=[") } 1.416 + { printf("\"%s\",", $0); i++ } 1.417 + END{ 1.418 + printf("\"\"];") 1.419 + i--; printf("cur_hist=\"%d\";max_hist=\"%d\";", i, i) 1.420 + }' 1.421 + cat <<EOT 1.422 +</script> 1.423 +EOT 1.424 ;; 1.425 1.426 1.427 + *\ rmhistory\ *) 1.428 + # Manage shell commandline history 1.429 + historyfile=/root/.ash_history 1.430 + 1.431 + # Return sed command for removing history lines ('8d12d' to remove 8 and 12 lines) 1.432 + rms=$(echo $QUERY_STRING | awk 'BEGIN{RS="&";FS="="}{if($1=="rm")printf "%dd", $2}') 1.433 + 1.434 + if [ -n "$rms" ]; then 1.435 + # Actually remove lines 1.436 + sed -i $rms $historyfile 1.437 + # Redirects back to the history table 1.438 + header "HTTP/1.1 301 Moved Permanently" "Location: ?terminal&cmd=history&path=$(GET path)" 1.439 + exit 0 1.440 + fi 1.441 + ;; 1.442 + 1.443 + 1.444 + *\ termsettings\ *) 1.445 + # Terminal settings 1.446 + TITLE=$(gettext 'TazPanel - Terminal'); header; xhtml_header; 1.447 + user="$REMOTE_USER" 1.448 + font="$(GET font)"; font="${font:-$TERM_FONT}" 1.449 + palette="$(GET palette)"; palette="${palette:-$TERM_PALETTE}" 1.450 + pal=$(echo $palette | tr A-Z a-z) 1.451 + 1.452 + # Add or change settings in TazPanel config 1.453 + if [ -z "$TERM_FONT" ]; then 1.454 + echo -e "\n# Terminal font family\nTERM_FONT=\"$font\"" >> $CONFIG 1.455 + else 1.456 + sed -i "s|TERM_FONT=.*|TERM_FONT=\"$font\"|" $CONFIG 1.457 + fi 1.458 + if [ -z "$TERM_PALETTE" ]; then 1.459 + echo -e "\n# Terminal color palette\nTERM_PALETTE=\"$palette\"" >> $CONFIG 1.460 + else 1.461 + sed -i "s|TERM_PALETTE=.*|TERM_PALETTE=\"$palette\"|" $CONFIG 1.462 + fi 1.463 + 1.464 + cat <<EOT 1.465 +<section> 1.466 + <header> 1.467 + $(gettext 'Terminal settings') 1.468 + <form> 1.469 + <button name="terminal" data-icon="terminal">$(gettext 'Terminal')</button> 1.470 + </form> 1.471 + </header> 1.472 + <pre class="term $pal" style="height: auto; font-family: '$font'"> 1.473 +<span class='color31'>$user@$(hostname)</span>:<span class='color33'>~</span># palette 1.474 + 1.475 +$( 1.476 + for i in $(seq 30 37); do 1.477 + for b in 0 1; do 1.478 + for j in $(seq 40 47); do 1.479 + echo -n "<span class=\"color$b color$i color$j\">$i:$j</span>" 1.480 + done 1.481 + done 1.482 + echo 1.483 + done 1.484 +) 1.485 + </pre> 1.486 + <footer> 1.487 + <form class="wide"> 1.488 + $(gettext 'Font:') 1.489 + <select name="font"> 1.490 + <option value="">$(gettext 'Default')</option> 1.491 + $(fc-list :spacing=mono:lang=en family | sed '/\.pcf/d;/,/d;s|\\-|-|g' | sort -u | \ 1.492 + awk -vfont="$font" '{ 1.493 + printf("<option value=\"%s\"%s>%s</option>\n", $0, ($0 == font)?" selected":"", $0) 1.494 + }') 1.495 + </select> 1.496 + $(gettext 'Palette:') 1.497 + <select name="palette"> 1.498 + $(echo -e 'Tango\nLinux\nXterm\nRxvt\nEcho' | awk -vpal="$palette" '{ 1.499 + printf("<option value=\"%s\"%s>%s</option>\n", $0, ($0 == pal)?" selected":"", $0) 1.500 + }') 1.501 + </select> 1.502 + <button name="termsettings" data-icon="ok">$(gettext 'Apply')</button> 1.503 + </form> 1.504 + </footer> 1.505 +</section> 1.506 +EOT 1.507 + 1.508 + ;; 1.509 + 1.510 + 1.511 *\ top\ *) 1.512 - TITLE=$(gettext 'TazPanel - Process activity') 1.513 - xhtml_header 1.514 - echo $(gettext 'Refresh:') $(GET refresh) 1.515 - cat << EOT 1.516 -<br/> 1.517 -<form method="get"> 1.518 + TITLE=$(gettext 'TazPanel - Process activity'); header; xhtml_header 1.519 + 1.520 + r=$(GET refresh) 1.521 + cat <<EOT 1.522 +<form> 1.523 + <p>$(gettext 'Refresh:') 1.524 <input type="hidden" name="top"/> 1.525 - <input type="submit" name="refresh" value="$(gettext '1s')"/> 1.526 - <input type="submit" name="refresh" value="$(gettext '5s')"/> 1.527 - <input type="submit" name="refresh" value="$(gettext '10s')"/> 1.528 - <input type="submit" value="$(gettext 'none')"/> 1.529 + <input type="radio" name="refresh" value="1" id="r1" $([ "$r" == 1 ] && echo checked) onchange="this.form.submit()"/> 1.530 + <label for="r1">$(gettext '1s' )</label> 1.531 + <input type="radio" name="refresh" value="5" id="r2" $([ "$r" == 5 ] && echo checked) onchange="this.form.submit()"/> 1.532 + <label for="r2">$(gettext '5s' )</label> 1.533 + <input type="radio" name="refresh" value="10" id="r3" $([ "$r" == 10 ] && echo checked) onchange="this.form.submit()"/> 1.534 + <label for="r3">$(gettext '10s' )</label> 1.535 + <input type="radio" name="refresh" value="" id="r4" $([ -z "$r" ] && echo checked) onchange="this.form.submit()"/> 1.536 + <label for="r4">$(gettext 'none')</label> 1.537 + </p> 1.538 </form> 1.539 EOT 1.540 - if [ -n "$(GET refresh)" ]; then 1.541 - echo -n '<meta http-equiv="refresh" content="' 1.542 - echo -n "$(GET refresh)" | sed 's|\([^0-9]*\)\([0-9]\+\).*|\2|' 1.543 - echo '">' 1.544 - fi 1.545 + [ -n "$r" ] && echo "<meta http-equiv=\"refresh\" content=\"$r\">" 1.546 1.547 - echo '<pre>' 1.548 + echo '<section><div><pre class="term log">' 1.549 top -n1 -b | htmlize | sed \ 1.550 - -e s"#^[A-Z].*:\([^']\)#<span class='sh-comment'>\0</span>#"g \ 1.551 - -e s"#PID.*\([^']\)#<span class='top'>\0</span>#"g 1.552 - echo '</pre>' ;; 1.553 + -e 's|^[A-Z].*:|<span class="color1 color31">\0</span>|g' \ 1.554 + -e 's|^\ *PID|<span class="color1 color32">\0</span>|g' 1.555 + echo '</pre></div></section>' ;; 1.556 1.557 1.558 *\ debug\ *) 1.559 - TITLE=$(gettext 'TazPanel - Debug') 1.560 - xhtml_header 1.561 - cat << EOT 1.562 + TITLE=$(gettext 'TazPanel - Debug'); header; xhtml_header 1.563 + 1.564 + cat <<EOT 1.565 <h2>$(gettext 'HTTP Environment')</h2> 1.566 1.567 -<pre>$(httpinfo)</pre> 1.568 +<section> 1.569 + <div> 1.570 + <pre>$(httpinfo | syntax_highlighter conf)</pre> 1.571 + </div> 1.572 +</section> 1.573 EOT 1.574 ;; 1.575 1.576 1.577 *\ report\ *) 1.578 - TITLE=$(gettext 'TazPanel - System report') 1.579 + TITLE=$(gettext 'TazPanel - System report'); header; xhtml_header 1.580 + 1.581 [ -d /var/cache/slitaz ] || mkdir -p /var/cache/slitaz 1.582 output=/var/cache/slitaz/sys-report.html 1.583 - xhtml_header 1.584 - cat << EOT 1.585 -<h2>$(eval_gettext 'Reporting to: $output')</h2> 1.586 -<table class="zebra outbox"> 1.587 -<tbody> 1.588 - <tr><td>$(gettext 'Creating report header...')</td> 1.589 + 1.590 + cat <<EOT 1.591 + 1.592 +<section> 1.593 + <header>$(eval_gettext 'Reporting to: $output')</header> 1.594 + <table class="wide zebra"> 1.595 + <tbody> 1.596 + <tr><td>$(gettext 'Creating report header...')</td> 1.597 EOT 1.598 - cat > $output << EOT 1.599 + cat > $output <<EOT 1.600 <!DOCTYPE html> 1.601 <html xmlns="http://www.w3.org/1999/xhtml"> 1.602 <head> 1.603 - <meta charset="utf-8" /> 1.604 + <meta charset="utf-8"/> 1.605 <title>$(gettext 'SliTaz system report')</title> 1.606 <style type="text/css"> 1.607 body { padding: 20px 60px; font-size: 13px; } 1.608 @@ -258,11 +489,11 @@ 1.609 </head> 1.610 <body> 1.611 EOT 1.612 - cat << EOT 1.613 + cat <<EOT 1.614 $(ok_status_t) 1.615 <tr><td>$(gettext 'Creating system summary...')</td> 1.616 EOT 1.617 - cat >> $output << EOT 1.618 + cat >> $output <<EOT 1.619 <h1>$(gettext 'SliTaz system report')</h1> 1.620 $(gettext 'Date:') $(date) 1.621 <pre> 1.622 @@ -273,11 +504,11 @@ 1.623 kernel : $(uname -r) 1.624 </pre> 1.625 EOT 1.626 - cat << EOT 1.627 + cat <<EOT 1.628 $(ok_status_t) 1.629 <tr><td>$(gettext 'Getting hardware info...')</td> 1.630 EOT 1.631 - cat >> $output << EOT 1.632 + cat >> $output <<EOT 1.633 <h2>free</h2> 1.634 <pre>$(free)</pre> 1.635 1.636 @@ -291,11 +522,11 @@ 1.637 <pre>$(lsmod)</pre> 1.638 1.639 EOT 1.640 - cat << EOT 1.641 + cat <<EOT 1.642 $(ok_status_t) 1.643 <tr><td>$(gettext 'Getting networking info...')</td> 1.644 EOT 1.645 - cat >> $output << EOT 1.646 + cat >> $output <<EOT 1.647 <h2>ifconfig -a</h2> 1.648 <pre>$(ifconfig -a)</pre> 1.649 1.650 @@ -305,11 +536,11 @@ 1.651 <h2>/etc/resolv.conf</h2> 1.652 <pre>$(cat /etc/resolv.conf)</pre> 1.653 EOT 1.654 - cat << EOT 1.655 + cat <<EOT 1.656 $(ok_status_t) 1.657 <tr><td>$(gettext 'Getting filesystems info...')</td> 1.658 EOT 1.659 - cat >> $output << EOT 1.660 + cat >> $output <<EOT 1.661 <h2>blkid</h2> 1.662 <pre>$(blkid)</pre> 1.663 1.664 @@ -325,34 +556,37 @@ 1.665 <h2>df -i</h2> 1.666 <pre>$(df -i)</pre> 1.667 EOT 1.668 - cat << EOT 1.669 + cat <<EOT 1.670 $(ok_status_t) 1.671 <tr><td>$(gettext 'Getting boot logs...')</td> 1.672 EOT 1.673 - cat >> $output << EOT 1.674 + cat >> $output <<EOT 1.675 <h2>$(gettext 'Kernel messages')</h2> 1.676 <pre>$(cat /var/log/dmesg.log)</pre> 1.677 1.678 <h2>$(gettext 'Boot scripts')</h2> 1.679 <pre>$(cat /var/log/boot.log | filter_taztools_msgs)</pre> 1.680 EOT 1.681 - cat << EOT 1.682 + cat <<EOT 1.683 $(ok_status_t) 1.684 <tr><td>$(gettext 'Creating report footer...')</td> 1.685 EOT 1.686 - cat cat >> $output << EOT 1.687 + cat cat >> $output <<EOT 1.688 </body> 1.689 </html> 1.690 EOT 1.691 - cat << EOT 1.692 + cat <<EOT 1.693 $(ok_status_t) 1.694 -</tbody> 1.695 -</table> 1.696 -<p><a class="button" href="?file=$output"> 1.697 - <img src="/styles/default/images/browser.png" /> 1.698 - $(gettext 'View report')</a> 1.699 + </tbody> 1.700 + </table> 1.701 + <footer> 1.702 + <form><button name="file" value="$output" data-icon="view">$(gettext 'View report')</button></form> 1.703 + </footer> 1.704 +</section> 1.705 + 1.706 + 1.707 $(msg tip "$(gettext 'This report can be attached with a bug report on:') 1.708 - <a href="http://bugs.slitaz.org/">bugs.slitaz.org</a></p>") 1.709 + <a href="http://bugs.slitaz.org/" target="_blank">bugs.slitaz.org</a></p>") 1.710 EOT 1.711 ;; 1.712 1.713 @@ -361,92 +595,96 @@ 1.714 # 1.715 # Default xHTML content 1.716 # 1.717 - xhtml_header 1.718 + header; xhtml_header 1.719 [ -n "$(GET gen_locale)" ] && new_locale=$(GET gen_locale) 1.720 [ -n "$(GET rdate)" ] && echo "" 1.721 hostname=$(hostname) 1.722 - cat << EOT 1.723 -<div id="wrapper"> 1.724 - <h2>$(eval_gettext 'Host: $hostname')</h2> 1.725 - <p>$(gettext 'SliTaz administration and configuration Panel')<p> 1.726 -</div> 1.727 -<div id="actions"> 1.728 - <a class="button" href="?terminal"> 1.729 - <img src="$IMAGES/terminal.png" />$(gettext 'Terminal')</a> 1.730 - <a class="button" href="?top"> 1.731 - <img src="$IMAGES/monitor.png" />$(gettext 'Process activity')</a> 1.732 - <a class="button" href="?report"> 1.733 - <img src="$IMAGES/text.png" />$(gettext 'Create a report')</a> 1.734 -</div> 1.735 + 1.736 + cat <<EOT 1.737 +<h2>$(eval_gettext 'Host: $hostname')</h2> 1.738 +<p>$(gettext 'SliTaz administration and configuration Panel')<p> 1.739 + 1.740 +<form class="nogap"><!-- 1.741 + --><button name="terminal" data-icon="terminal">$(gettext 'Terminal' )</button><!-- 1.742 + --><button name="top" data-icon="proc" >$(gettext 'Process activity')</button><!-- 1.743 + --><button name="report" data-icon="report" >$(gettext 'Create a report' )</button> 1.744 +</form> 1.745 1.746 <section> 1.747 -<h3>$(gettext 'Summary')</h3> 1.748 -<div id="summary"> 1.749 -<table> 1.750 - <tr><td>$(gettext 'Uptime:')</td> 1.751 - <td>$(uptime)</td> 1.752 - </tr> 1.753 - <tr><td>$(gettext 'Memory in Mb:')</td> 1.754 + <header>$(gettext 'Summary')</header> 1.755 + <table> 1.756 + <tr><td>$(gettext 'Uptime:')</td> 1.757 + <td id="uptime">$(uptime | sed 's|\([0-9.:][0-9.:]*\)|<b>\1</b>|g')</td> 1.758 + </tr> 1.759 + <tr><td>$(gettext 'Memory in Mb:')</td> 1.760 + <td>$(free -m | grep Mem: | \ 1.761 + awk -vline="$(gettext 'Total: %d, Used: %d, Free: %d')" \ 1.762 + '{ printf(line, $2, $3, $4) }' | \ 1.763 + sed 's|\([0-9][0-9]*\)|<b>\1</b>|g')</td> 1.764 + </tr> 1.765 + <tr><td>$(gettext 'Linux kernel:')</td> 1.766 + <td>$(uname -r)</td> 1.767 + </tr> 1.768 + </table> 1.769 +</section> 1.770 + 1.771 + 1.772 +<section> 1.773 + <header> 1.774 + $(gettext 'Network status') 1.775 + <form action="network.cgi"> 1.776 + <button data-icon="wifi">$(gettext 'Network')</button> 1.777 + </form> 1.778 + </header> 1.779 + $(list_network_interfaces) 1.780 +</section> 1.781 + 1.782 + 1.783 +<section> 1.784 + <header> 1.785 + $(gettext 'Filesystem usage statistics') 1.786 + <form action="hardware.cgi"> 1.787 + <button data-icon="hdd">$(gettext 'Disks')</button> 1.788 + </form> 1.789 + </header> 1.790 + <table class="wide zebra center"> 1.791 EOT 1.792 - free -m | grep Mem: | awk '{print $2, $3, $4}' | while read memtotal memused memfree 1.793 - do 1.794 - cat << EOT 1.795 - <td>$(eval_gettext 'Total: $memtotal, Used: $memused, Free: $memfree')</td> 1.796 + # Disk stats (management is done as hardware.cgi) 1.797 + df_thead 1.798 + echo '<tbody>' 1.799 + df -h | grep ^/dev | while read fs size used av pct mp; do 1.800 + cat <<EOT 1.801 + <tr> 1.802 + <td><span data-icon="hdd">${fs#/dev/}</span></td> 1.803 + <td>$(blkid $fs | sed '/LABEL=/!d;s/.*LABEL="\([^"]*\).*/\1/')</td> 1.804 + <td>$(blkid $fs | sed '/TYPE=/!d;s/.*TYPE="\([^"]*\).*/\1/')</td> 1.805 + <td>$size</td> 1.806 + <td>$av</td> 1.807 + <td class="meter"><meter min="0" max="100" value="$(echo $pct | cut -d% -f1)" 1.808 + low="$DU_WARN" high="$DU_CRIT" optimum="10"></meter> 1.809 + <span>$used - $pct</span> 1.810 + </td> 1.811 + <td>$mp</td> 1.812 + <td>$(blkid $fs | sed '/UUID=/!d;s/.*UUID="\([^"]*\).*/\1/')</td> 1.813 + </tr> 1.814 EOT 1.815 done 1.816 - cat << EOT 1.817 - </tr> 1.818 - <tr><td>$(gettext 'Linux kernel:')</td> 1.819 - <td>$(uname -r)</td> 1.820 - </tr> 1.821 -</table> 1.822 -<!-- Close summary --> 1.823 -</div> 1.824 + cat <<EOT 1.825 + </tbody> 1.826 + </table> 1.827 </section> 1.828 1.829 <section> 1.830 -<h4>$(gettext 'Network status')</h4> 1.831 -$(list_network_interfaces) 1.832 -</section> 1.833 - 1.834 -<section> 1.835 -<h4>$(gettext 'Filesystem usage statistics')</h4> 1.836 -EOT 1.837 - # Disk stats (management is done as hardware.cgi) 1.838 - cat << EOT 1.839 -<table class="zebra outbox"> 1.840 -EOT 1.841 - df_thead 1.842 - echo '<tbody>' 1.843 - df -h | grep ^/dev | while read fs size used av pct mp 1.844 - do 1.845 - cat << EOT 1.846 -<tr> 1.847 - <td><a href="hardware.cgi"> 1.848 - <img src="$IMAGES/harddisk.png" />${fs#/dev/}</a></td> 1.849 - <td>$(blkid $fs | sed '/LABEL=/!d;s/.*LABEL="\([^"]*\).*/\1/')</td> 1.850 - <td>$(blkid $fs | sed '/TYPE=/!d;s/.*TYPE="\([^"]*\).*/\1/')</td> 1.851 - <td>$size</td> 1.852 - <td>$av</td> 1.853 - <td class="meter"><meter min="0" max="100" value="$(echo $pct | cut -d% -f1)" 1.854 - low="$DU_WARN" high="$DU_CRIT" optimum="10"></meter> 1.855 - <span>$used - $pct</span> 1.856 - </td> 1.857 - <td>$mp</td> 1.858 - <td>$(blkid $fs | sed '/UUID=/!d;s/.*UUID="\([^"]*\).*/\1/')</td> 1.859 -</tr> 1.860 -EOT 1.861 - done 1.862 - cat << EOT 1.863 -</tbody> 1.864 -</table> 1.865 -</section> 1.866 - 1.867 -<section> 1.868 -<h3>$(gettext 'Panel Activity')</h3> 1.869 -<pre id="panel-activity"> 1.870 -$(cat $LOG_FILE | tail -n 8 | sort -r | syntax_highlighter activity) 1.871 -</pre> 1.872 + <header> 1.873 + $(gettext 'Panel Activity') 1.874 + <form> 1.875 + <button name="file" value="$LOG_FILE" data-icon="view">$(gettext 'View')</button> 1.876 + </form> 1.877 + </header> 1.878 + <div> 1.879 + <pre id="panel-activity"> 1.880 +$(cat $LOG_FILE | tail -n 8 | sort -r | syntax_highlighter activity)</pre> 1.881 + </div> 1.882 </section> 1.883 EOT 1.884 ;;