tazpanel diff network.cgi @ rev 531
index.cgi: add renice support (again)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Aug 28 14:03:48 2015 +0200 (2015-08-28) |
parents | 4f619f973b88 |
children | 7bf0e359133e |
line diff
1.1 --- a/network.cgi Mon Aug 24 01:05:08 2015 +0300 1.2 +++ b/network.cgi Fri Aug 28 14:03:48 2015 +0200 1.3 @@ -617,100 +617,6 @@ 1.4 ;; 1.5 1.6 1.7 - *\ hosts\ *) 1.8 - # Configure to use hosts as Ad blocker 1.9 - xhtml_header "$(_ 'Use hosts file as Ad blocker')" 1.10 - 1.11 - term=$(GET term) 1.12 - found=$(mktemp) 1.13 - 1.14 - # Find the hosts list 1.15 - hosts=$(echo "$QUERY_STRING&" | awk ' 1.16 - BEGIN { RS="&"; FS="=" } 1.17 - $1=="host" { printf "%s ", $2 } 1.18 - ') 1.19 - hosts=$(httpd -d "${hosts% }") 1.20 - # now hosts='host1 host2 ... hostn' 1.21 - 1.22 - if [ -n "$(GET add)" ]; then 1.23 - # Add given host 1.24 - 1.25 - host="$(GET add)" 1.26 - 1.27 - echo "0.0.0.0 $host #U" >> /etc/hosts 1.28 - echo -n '<p><span data-img="info"></span>' 1.29 - _ 'Host "%s" added to /etc/hosts.' "$host" 1.30 - echo '</p>' 1.31 - 1.32 - elif [ -n "$hosts" ]; then 1.33 - # Disable given hosts 1.34 - 1.35 - for host in $hosts; do 1.36 - sed -i "s|^0.0.0.0[ \t][ \t]*$host\$|#\0|" /etc/hosts 1.37 - sed -i "s|^0.0.0.0[ \t][ \t]*$host .*|#\0|" /etc/hosts 1.38 - done 1.39 - r=$(echo "$hosts" | tr ' ' '\n' | wc -l) 1.40 - echo -n '<p><span data-img="info"></span>' 1.41 - _p '%d record disabled' \ 1.42 - '%d records disabled' "$r" "$r" 1.43 - echo '</p>' 1.44 - fi 1.45 - 1.46 - # When search term given 1.47 - if [ -z "$term" ]; then 1.48 - getdb hosts | fgrep 0.0.0.0 > "$found" 1.49 - r=$(wc -l < "$found") 1.50 - echo -n '<p><span data-img="info"></span>' 1.51 - _p '%d record used for Ad blocking' \ 1.52 - '%d records used for Ad blocking' "$r" "$r" 1.53 - else 1.54 - getdb hosts | fgrep 0.0.0.0 | fgrep "$term" > "$found" 1.55 - r=$(wc -l < "$found") 1.56 - echo -n '<p><span data-img="info"></span>' 1.57 - _p '%d record found for "%s"' \ 1.58 - '%d records found for "%s"' "$r" "$r" "$term" 1.59 - fi 1.60 - 1.61 - [ "$r" -gt 100 ] && _ ' (The list is limited to the first 100 entries.)' 1.62 - echo '</p>' 1.63 - 1.64 - cat <<EOT 1.65 - <section> 1.66 - <header> 1.67 - <span data-icon="list">$(_ 'Hosts')</span> 1.68 - <form id="hosts"> 1.69 - <input type="hidden" name="hosts" value=""/> 1.70 - <input type="search" name="term" value="$(GET term)" results="5" autosave="hosts" autocomplete="on"/> 1.71 - </form> 1.72 - </header> 1.73 - <pre class="scroll"> 1.74 -EOT 1.75 - sort "$found" | head -n100 | awk '{ 1.76 - printf "<label><input type=\"checkbox\" name=\"host\" value=\"%s\" form=\"hosts\"/> %s</label>\n", $2, $2; 1.77 - }' 1.78 - rm "$found" 1.79 - cat <<EOT 1.80 -</pre> 1.81 - <footer> 1.82 - <button form="hosts" data-icon="delete" data-root>$(_ 'Disable selected')</button> 1.83 - </footer> 1.84 - </section> 1.85 - 1.86 - <section> 1.87 - <header><span data-icon="add">$(_ 'Add')</span></header> 1.88 - <form class="wide"> 1.89 - <div> 1.90 - <input type="hidden" name="hosts"/> 1.91 - $(_ 'Host:') 1.92 - <input type="text" name="add"/> 1.93 - <button type="submit" data-icon="add" data-root>$(_ 'Add')</button> 1.94 - </div> 1.95 - </form> 1.96 - </section> 1.97 -EOT 1.98 - ;; 1.99 - 1.100 - 1.101 *) 1.102 # Main Network page starting with a summary 1.103 xhtml_header "$(_ 'Manage network connections and services')" 1.104 @@ -763,13 +669,13 @@ 1.105 <section> 1.106 <header id="hosts">$(_ 'Hosts'; edit_button /etc/hosts)</header> 1.107 <span data-icon="info">$(r=$(getdb hosts | wc -l); 1.108 - _p '%s record in the hosts DB' \ 1.109 - '%s records in the hosts DB' "$r" \ 1.110 + _p '%d record in the hosts DB' \ 1.111 + '%d records in the hosts DB' "$r" \ 1.112 "$r")</span> 1.113 <pre class="scroll">$(getdb hosts | fgrep -v 0.0.0.0)</pre> 1.114 <footer> 1.115 - <form> 1.116 - <button name="hosts" data-icon="admin" data-root>$(_ 'Configure')</button> 1.117 + <form action="hosts.cgi"> 1.118 + <button data-icon="admin" data-root>$(_ 'Configure')</button> 1.119 $(_ 'Use hosts file as Ad blocker') 1.120 </form> 1.121 </footer>