tazpanel diff index.cgi @ rev 31

index.cgi: Add support for network connection detection and listing + up po/*
author Christophe Lincoln <pankso@slitaz.org>
date Tue Apr 05 05:10:57 2011 +0200 (2011-04-05)
parents f82057fcce3f
children b4e001e85045
line diff
     1.1 --- a/index.cgi	Tue Apr 05 03:34:47 2011 +0200
     1.2 +++ b/index.cgi	Tue Apr 05 05:10:57 2011 +0200
     1.3 @@ -18,6 +18,47 @@
     1.4  TEXTDOMAIN='tazpanel-cgi'
     1.5  export TEXTDOMAIN
     1.6  
     1.7 +# Network interface status
     1.8 +interface_status() {
     1.9 +	if 	ifconfig | grep -A 1 $i | grep -q inet; then
    1.10 +		ip=`ifconfig | grep -A 1 $i | grep inet | \
    1.11 +			awk '{ print $2 }' | cut -d ":" -f 2`
    1.12 +		echo "<td>connected</td> <td>$ip</td>"
    1.13 +	else
    1.14 +		echo "<td>-</td>"
    1.15 +	fi
    1.16 +}
    1.17 +
    1.18 +# Catch network interface
    1.19 +list_network_interfaces() {
    1.20 +	table_start
    1.21 +	cat << EOT
    1.22 +<tr id="thead">
    1.23 +	<td>`gettext "Interface"`</td>
    1.24 +	<td>`gettext "Name"`</td>
    1.25 +	<td>`gettext "Statut"`</td>
    1.26 +	<td>`gettext "IP Address"`</td>
    1.27 +</tr>
    1.28 +EOT
    1.29 +	for i in `ls /sys/class/net`
    1.30 +	do
    1.31 +		case $i in
    1.32 +			eth*)
    1.33 +				echo "<tr><td><img src='$IMAGES/ethernet.png' />$i</td>
    1.34 +					<td>Ethernet</td> `interface_status`</tr>" ;;
    1.35 +			wlan*|ath*|ra*)
    1.36 +				echo "<tr><td><img src='$IMAGES/wireless.png' />$i</td>
    1.37 +					<td>Wireless</td> `interface_status`</tr>" ;;
    1.38 +			lo)
    1.39 +				echo "<tr><td><img src='$IMAGES/loopback.png' />$i</td>
    1.40 +				<td>Loopback</td> `interface_status`</tr>" ;;
    1.41 +			*)
    1.42 +				continue ;;
    1.43 +		esac
    1.44 +	done
    1.45 +	table_end
    1.46 +}
    1.47 +
    1.48  #
    1.49  # Commands
    1.50  #
    1.51 @@ -144,6 +185,8 @@
    1.52  	<p>`gettext "Manage network connection and services`</p>
    1.53  </div>
    1.54  
    1.55 +`list_network_interfaces`
    1.56 +
    1.57  <h3>Output of: ifconfig -a</h3>
    1.58  <pre>
    1.59  `ifconfig -a`
    1.60 @@ -201,6 +244,8 @@
    1.61  `df -h | grep ^/dev`
    1.62  </pre>
    1.63  
    1.64 +`list_network_interfaces`
    1.65 +
    1.66  <!-- Close summary -->
    1.67  </div>
    1.68  EOT