tazpanel diff network.cgi @ rev 443

Use short gettext commands; use $HTTP_HOST in redirection URL (for localhost 127.0.0.1:82 works too; for local network connection URL like 192.168.1.10:82 works).
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Apr 08 15:32:20 2015 +0300 (2015-04-08)
parents adedebded23a
children 7ca14d55e705
line diff
     1.1 --- a/network.cgi	Wed Apr 08 09:55:46 2015 +0200
     1.2 +++ b/network.cgi	Wed Apr 08 15:32:20 2015 +0300
     1.3 @@ -12,7 +12,7 @@
     1.4  get_config
     1.5  header
     1.6  
     1.7 -TITLE=$(gettext 'TazPanel - Network')
     1.8 +TITLE=$(_ 'TazPanel - Network')
     1.9  
    1.10  
    1.11  # Start a Wi-Fi connection
    1.12 @@ -138,7 +138,7 @@
    1.13  		connect_wifi ;;
    1.14  	*\ host\ *)
    1.15  		get_hostname="$(GET host)"
    1.16 -		echo $(eval_gettext 'Changed hostname: $get_hostname') | log
    1.17 +		echo $(_ 'Changed hostname: %s' $get_hostname) | log
    1.18  		echo "$get_hostname" > /etc/hostname ;;
    1.19  esac
    1.20  
    1.21 @@ -161,13 +161,13 @@
    1.22  		# Scan open ports
    1.23  		scan=$(GET scan); back=$(GET back)
    1.24  		xhtml_header
    1.25 -		LOADING_MSG=$(gettext 'Scanning open ports...'); loading_msg
    1.26 +		LOADING_MSG=$(_ 'Scanning open ports...'); loading_msg
    1.27  
    1.28  		cat <<EOT
    1.29  <section>
    1.30  	<header>
    1.31 -		$(eval_gettext 'Port scanning for $scan')
    1.32 -		$(back_button "$back" "$(gettext 'Network')" "")
    1.33 +		$(_ 'Port scanning for %s' $scan)
    1.34 +		$(back_button "$back" "$(_ 'Network')" "")
    1.35  	</header>
    1.36  	<pre>$(pscan -b $scan)</pre>
    1.37  </section>
    1.38 @@ -194,19 +194,19 @@
    1.39  		fi
    1.40  
    1.41  		cat <<EOT
    1.42 -<h2>$(gettext 'Ethernet connection')</h2>
    1.43 +<h2>$(_ 'Ethernet connection')</h2>
    1.44  EOT
    1.45  		[ -w /etc/network.conf ] && cat <<EOT
    1.46 -<p>$(gettext "Here you can configure a wired connection using DHCP to \
    1.47 +<p>$(_ "Here you can configure a wired connection using DHCP to \
    1.48  automatically get a random IP or configure a static/fixed IP")</p>
    1.49  
    1.50  <section>
    1.51 -	<header>$(gettext 'Configuration')</header>
    1.52 +	<header>$(_ 'Configuration')</header>
    1.53  	<form id="conf">
    1.54  		<input type="hidden" name="eth"/>
    1.55  		<div>
    1.56  			<table>
    1.57 -				<tr><td>$(gettext 'Interface')</td>
    1.58 +				<tr><td>$(_ 'Interface')</td>
    1.59  					<td><select name="iface" value="$INTERFACE" style="width:100%">
    1.60  					$(cd /sys/class/net; ls -1 | awk -viface="$INTERFACE" '{
    1.61  						sel = ($0 == iface) ? " selected":""
    1.62 @@ -214,28 +214,28 @@
    1.63  					}')
    1.64  					</select></td>
    1.65  				</tr>
    1.66 -				<tr><td>$(gettext 'Static IP')</td>
    1.67 +				<tr><td>$(_ 'Static IP')</td>
    1.68  					<td><label><input type="checkbox" name="staticip" id="staticip" $use_static/>
    1.69 -						$(gettext 'Use static IP')</td>
    1.70 +						$(_ 'Use static IP')</td>
    1.71  				</tr>
    1.72 -				<tr id="st1"><td>$(gettext 'IP address')</td>
    1.73 +				<tr id="st1"><td>$(_ 'IP address')</td>
    1.74  					<td><input type="text" name="ip"      value="$IP"         $PAR/></td>
    1.75  				</tr>
    1.76 -				<tr id="st2"><td>$(gettext 'Netmask')</td>
    1.77 +				<tr id="st2"><td>$(_ 'Netmask')</td>
    1.78  					<td><input type="text" name="netmask" value="$NETMASK"    $PAR/></td>
    1.79  				</tr>
    1.80 -				<tr id="st3"><td>$(gettext 'Gateway')</td>
    1.81 +				<tr id="st3"><td>$(_ 'Gateway')</td>
    1.82  					<td><input type="text" name="gateway" value="$GATEWAY"    $PAR/></td>
    1.83  				</tr>
    1.84 -				<tr id="st4"><td>$(gettext 'DNS server')</td>
    1.85 +				<tr id="st4"><td>$(_ 'DNS server')</td>
    1.86  					<td><input type="text" name="dns"     value="$DNS_SERVER" $PAR/></td>
    1.87  				</tr>
    1.88  			</table>
    1.89  		</div>
    1.90  	</form>
    1.91  	<footer><!--
    1.92 -		--><button form="conf" type="submit" name="start_eth" data-icon="start" $start_disabled>$(gettext 'Start'  )</button><!--
    1.93 -		--><button form="conf" type="submit" name="stop"      data-icon="stop"  $stop_disabled >$(gettext 'Stop'   )</button><!--
    1.94 +		--><button form="conf" type="submit" name="start_eth" data-icon="start" $start_disabled>$(_ 'Start'  )</button><!--
    1.95 +		--><button form="conf" type="submit" name="stop"      data-icon="stop"  $stop_disabled >$(_ 'Stop'   )</button><!--
    1.96  	--></footer>
    1.97  </section>
    1.98  
    1.99 @@ -254,17 +254,17 @@
   1.100  		cat <<EOT
   1.101  <section>
   1.102  	<header>
   1.103 -		$(gettext 'Configuration file')
   1.104 +		$(_ 'Configuration file')
   1.105  EOT
   1.106  		[ -w /etc/network.conf ] && cat <<EOT
   1.107  		<form action="index.cgi">
   1.108  			<input type="hidden" name="file" value="/etc/network.conf"/>
   1.109 -			<button name="action" value="edit" data-icon="edit">$(gettext 'Edit')</button>
   1.110 +			<button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button>
   1.111  		</form>
   1.112  EOT
   1.113  		cat <<EOT
   1.114  	</header>
   1.115 -	<div>$(gettext "These values are the ethernet settings in the main /etc/network.conf configuration file")</div>
   1.116 +	<div>$(_ "These values are the ethernet settings in the main /etc/network.conf configuration file")</div>
   1.117  	<pre>$(awk '{if($1 !~ "WIFI" && $1 !~ "#" && $1 != ""){print $0}}' /etc/network.conf | syntax_highlighter conf)</pre>
   1.118  </section>
   1.119  EOT
   1.120 @@ -276,17 +276,17 @@
   1.121  		# Catch ESSIDs and format output.
   1.122  		# We get the list of networks by Cell and without spaces.
   1.123  
   1.124 -		HIDDEN="$(gettext '(hidden)')"
   1.125 +		HIDDEN="$(_ '(hidden)')"
   1.126  
   1.127  		cat <<EOT
   1.128  <table class="wide center zebra">
   1.129  	<thead>
   1.130  		<tr>
   1.131 -			<td>$(gettext 'Name')</td>
   1.132 -			<td>$(gettext 'Signal level')</td>
   1.133 -			<td>$(gettext 'Channel')</td>
   1.134 -			<td>$(gettext 'Encryption')</td>
   1.135 -			<td>$(gettext 'Status')</td>
   1.136 +			<td>$(_ 'Name')</td>
   1.137 +			<td>$(_ 'Signal level')</td>
   1.138 +			<td>$(_ 'Channel')</td>
   1.139 +			<td>$(_ 'Encryption')</td>
   1.140 +			<td>$(_ 'Status')</td>
   1.141  		</tr>
   1.142  	</thead>
   1.143  	<tbody>
   1.144 @@ -337,7 +337,7 @@
   1.145  					fi
   1.146  				else
   1.147  					WIFI_KEY_TYPE='NONE'
   1.148 -					ENC_SIMPLE="$(gettext 'None')"; ENC_ICON='seclo' # low
   1.149 +					ENC_SIMPLE="$(_ 'None')"; ENC_ICON='seclo' # low
   1.150  				fi
   1.151  
   1.152  				# 
   1.153 @@ -350,7 +350,7 @@
   1.154  				# Connected or not connected...
   1.155  				if  ifconfig $WIFI_INTERFACE | fgrep -q inet && \
   1.156  					iwconfig $WIFI_INTERFACE | fgrep -q "ESSID:\"$ESSID\""; then
   1.157 -					status="$(gettext 'Connected')"
   1.158 +					status="$(_ 'Connected')"
   1.159  				else
   1.160  					status='---'
   1.161  				fi
   1.162 @@ -380,7 +380,7 @@
   1.163  
   1.164  		. /etc/network.conf
   1.165  		cat <<EOT
   1.166 -<h2>$(gettext 'Wireless connection')</h2>
   1.167 +<h2>$(_ 'Wireless connection')</h2>
   1.168  EOT
   1.169  
   1.170  		start_disabled=''; stop_disabled=''
   1.171 @@ -393,9 +393,9 @@
   1.172  		[ -w /etc/network.conf ] && cat <<EOT
   1.173  <form>
   1.174  	<input type="hidden" name="wifi"/>
   1.175 -	   <button name="start_wifi" data-icon="start"   $start_disabled>$(gettext 'Start')</button><!--
   1.176 -	--><button name="stop"       data-icon="stop"    $stop_disabled >$(gettext 'Stop' )</button><!--
   1.177 -	--><button type="submit"     data-icon="refresh" $stop_disabled >$(gettext 'Scan' )</button>
   1.178 +	   <button name="start_wifi" data-icon="start"   $start_disabled>$(_ 'Start')</button><!--
   1.179 +	--><button name="stop"       data-icon="stop"    $stop_disabled >$(_ 'Stop' )</button><!--
   1.180 +	--><button type="submit"     data-icon="refresh" $stop_disabled >$(_ 'Scan' )</button>
   1.181  </form>
   1.182  EOT
   1.183  
   1.184 @@ -403,7 +403,7 @@
   1.185  		if [ -n "$start_disabled" ]; then
   1.186  			cat <<EOT
   1.187  <section id="wifiList">
   1.188 -	<div style="text-align: center;"><span id="ajaxStatus"></span>$(gettext 'Scanning wireless interface...')</div>
   1.189 +	<div style="text-align: center;"><span id="ajaxStatus"></span>$(_ 'Scanning wireless interface...')</div>
   1.190  </section>
   1.191  
   1.192  <script type="text/javascript">
   1.193 @@ -421,19 +421,19 @@
   1.194  
   1.195  			cat <<EOT
   1.196  <section>
   1.197 -	<header>$(gettext 'Connection')</header>
   1.198 +	<header>$(_ 'Connection')</header>
   1.199  	<div>
   1.200  		<form id="connection">
   1.201  			<input type="hidden" name="connect_wifi"/>
   1.202  			<input type="hidden" name="bssid" id="bssid"/>
   1.203  			<table>
   1.204 -				<tr><td>$(gettext 'Network SSID')</td>
   1.205 +				<tr><td>$(_ 'Network SSID')</td>
   1.206  					<td><input type="text" name="essid" value="$WIFI_ESSID" id="essid"/></td>
   1.207  				</tr>
   1.208  
   1.209 -				<tr><td>$(gettext 'Security')</td>
   1.210 +				<tr><td>$(_ 'Security')</td>
   1.211  					<td><select name="keyType" id="keyType">
   1.212 -							<option value="NONE">$(gettext 'None')</option>
   1.213 +							<option value="NONE">$(_ 'None')</option>
   1.214  							<option value="WEP" >WEP</option>
   1.215  							<option value="WPA" >WPA/WPA2 PSK</option>
   1.216  							<option value="EAP" >802.1x EAP</option>
   1.217 @@ -442,7 +442,7 @@
   1.218  				</tr>
   1.219  
   1.220  				<tr class="eap">
   1.221 -					<td><div>$(gettext 'EAP method')</div></td>
   1.222 +					<td><div>$(_ 'EAP method')</div></td>
   1.223  					<td><div><select name="eap" id="eap">
   1.224  							<option value="PEAP">PEAP</option>
   1.225  							<option value="TLS" >TLS</option>
   1.226 @@ -453,9 +453,9 @@
   1.227  				</tr>
   1.228  
   1.229  				<tr class="eap1">
   1.230 -					<td><div>$(gettext 'Phase 2 authentication')</div></td>
   1.231 +					<td><div>$(_ 'Phase 2 authentication')</div></td>
   1.232  					<td><div><select name="phase2" id="phase2">
   1.233 -							<option value="none"    >$(gettext 'None')</option>
   1.234 +							<option value="none"    >$(_ 'None')</option>
   1.235  							<option value="pap"     >PAP</option>
   1.236  							<option value="mschap"  >MSCHAP</option>
   1.237  							<option value="mschapv2">MSCHAPV2</option>
   1.238 @@ -465,30 +465,30 @@
   1.239  				</tr>
   1.240  
   1.241  				<tr class="eap1">
   1.242 -					<td><div>$(gettext 'CA certificate')</div></td>
   1.243 +					<td><div>$(_ 'CA certificate')</div></td>
   1.244  					<td><div><input type="text" name="caCert" id="caCert"></div></td>
   1.245  				</tr>
   1.246  
   1.247  				<tr class="eap1">
   1.248 -					<td><div>$(gettext 'User certificate')</div></td>
   1.249 +					<td><div>$(_ 'User certificate')</div></td>
   1.250  					<td><div><input type="text" name="clientCert" id="clientCert"></div></td>
   1.251  				</tr>
   1.252  
   1.253  				<tr class="eap">
   1.254 -					<td><div>$(gettext 'Identity')</div></td>
   1.255 +					<td><div>$(_ 'Identity')</div></td>
   1.256  					<td><div><input type="text" name="identity" id="identity"></div></td>
   1.257  				</tr>
   1.258  
   1.259  				<tr class="eap1">
   1.260 -					<td><div>$(gettext 'Anonymous identity')</div></td>
   1.261 +					<td><div>$(_ 'Anonymous identity')</div></td>
   1.262  					<td><div><input type="text" name="anonymousIdentity" id="anonymousIdentity"></div></td>
   1.263  				</tr>
   1.264  
   1.265  				<tr class="wep wpa eap">
   1.266 -					<td><div>$(gettext 'Password')</div></td>
   1.267 +					<td><div>$(_ 'Password')</div></td>
   1.268  					<td><div>
   1.269  						<input type="password" name="password" value="$WIFI_KEY" id="password"/>
   1.270 -						<span data-img="view" title="$(gettext 'Show password')"
   1.271 +						<span data-img="view" title="$(_ 'Show password')"
   1.272  							onmousedown="document.getElementById('password').type='text'; return false"
   1.273  							  onmouseup="document.getElementById('password').type='password'"
   1.274  							 onmouseout="document.getElementById('password').type='password'"
   1.275 @@ -498,7 +498,7 @@
   1.276  
   1.277  
   1.278  <!--
   1.279 -				<tr><td>$(gettext 'Access point')</td>
   1.280 +				<tr><td>$(_ 'Access point')</td>
   1.281  					<td><input type="text" name="ap" value="$WIFI_AP"/></td>
   1.282  				</tr>
   1.283  -->
   1.284 @@ -536,7 +536,7 @@
   1.285  		</form>
   1.286  	</div>
   1.287  	<footer>
   1.288 -		<button form="connection" type="submit" name="wifi" data-icon="ok">$(gettext 'Configure')</button>
   1.289 +		<button form="connection" type="submit" name="wifi" data-icon="ok">$(_ 'Configure')</button>
   1.290  	</footer>
   1.291  </section>
   1.292  EOT
   1.293 @@ -545,23 +545,23 @@
   1.294  		cat <<EOT
   1.295  <section>
   1.296  	<header>
   1.297 -		$(gettext 'Configuration file')
   1.298 +		$(_ 'Configuration file')
   1.299  EOT
   1.300  		[ -w /etc/network.conf ] && cat <<EOT
   1.301  		<form action="index.cgi">
   1.302  			<input type="hidden" name="file" value="/etc/network.conf"/>
   1.303 -			<button name="action" value="edit" data-icon="edit">$(gettext 'Edit')</button>
   1.304 +			<button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button>
   1.305  		</form>
   1.306  EOT
   1.307  		cat <<EOT
   1.308  	</header>
   1.309 -	<div>$(gettext "These values are the wifi settings in the main /etc/network.conf configuration file")</div>
   1.310 +	<div>$(_ "These values are the wifi settings in the main /etc/network.conf configuration file")</div>
   1.311  	<pre>$(grep ^WIFI /etc/network.conf | sed '/WIFI_KEY=/s|".*"|"********"|' | syntax_highlighter conf)</pre>
   1.312  </section>
   1.313  
   1.314  
   1.315  <section>
   1.316 -	<header>$(gettext 'Output of iwconfig')</header>
   1.317 +	<header>$(_ 'Output of iwconfig')</header>
   1.318  	<pre>$(iwconfig)</pre>
   1.319  </section>
   1.320  EOT
   1.321 @@ -584,20 +584,20 @@
   1.322  		fi
   1.323  
   1.324  		cat <<EOT
   1.325 -<h2>$(gettext 'Networking')</h2>
   1.326 +<h2>$(_ 'Networking')</h2>
   1.327  
   1.328 -<p>$(gettext 'Manage network connections and services')</p>
   1.329 +<p>$(_ 'Manage network connections and services')</p>
   1.330  
   1.331  <form action="index.cgi" id="indexform"></form>
   1.332  
   1.333  <form id="mainform"><!--
   1.334 -	--><button name="start"   data-icon="start"   $start_disabled>$(gettext 'Start'  )</button><!--
   1.335 -	--><button name="stop"    data-icon="stop"    $stop_disabled >$(gettext 'Stop'   )</button><!--
   1.336 -	--><button name="restart" data-icon="restart" $stop_disabled >$(gettext 'Restart')</button>
   1.337 +	--><button name="start"   data-icon="start"   $start_disabled>$(_ 'Start'  )</button><!--
   1.338 +	--><button name="stop"    data-icon="stop"    $stop_disabled >$(_ 'Stop'   )</button><!--
   1.339 +	--><button name="restart" data-icon="restart" $stop_disabled >$(_ 'Restart')</button>
   1.340  </form>
   1.341  
   1.342  <div class="float-right"><!--
   1.343 -	-->$(gettext 'Configuration:')<!--
   1.344 +	-->$(_ 'Configuration:')<!--
   1.345  	--><button form="indexform" name="file" value="/etc/network.conf" data-icon="conf">network.conf</button><!--
   1.346  	--><button form="mainform" name="eth" data-icon="eth">Ethernet</button><!--
   1.347  	--><button form="mainform" name="wifi" data-icon="wifi">Wireless</button>
   1.348 @@ -605,20 +605,20 @@
   1.349  
   1.350  
   1.351  <section>
   1.352 -	<header>$(gettext 'Network interfaces')</header>
   1.353 +	<header>$(_ 'Network interfaces')</header>
   1.354  	$(list_network_interfaces)
   1.355  </section>
   1.356  
   1.357  
   1.358  <section>
   1.359 -	<header id="hosts">$(gettext 'Hosts')</header>
   1.360 +	<header id="hosts">$(_ 'Hosts')</header>
   1.361  	<pre>$(cat /etc/hosts)</pre>
   1.362  EOT
   1.363  		[ -w /etc/hosts ] && cat <<EOT
   1.364  	<footer>
   1.365  		<form action="index.cgi">
   1.366  			<input type="hidden" name="file" value="/etc/hosts"/>
   1.367 -			<button name="action" value="edit" data-icon="edit">$(gettext 'Edit')</button>
   1.368 +			<button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button>
   1.369  		</form>
   1.370  	</footer>
   1.371  EOT
   1.372 @@ -627,7 +627,7 @@
   1.373  
   1.374  
   1.375  <section>
   1.376 -	<header>$(gettext 'Hostname')</header>
   1.377 +	<header>$(_ 'Hostname')</header>
   1.378  	<footer>
   1.379  EOT
   1.380  		if [ -w /etc/hostname ]; then
   1.381 @@ -635,7 +635,7 @@
   1.382  		<form>
   1.383  			<!-- was: name="hostname"; please don't use 'name' in name: unwanted webkit styling -->
   1.384  			<input type="text" name="host" value="$(cat /etc/hostname)"/><!--
   1.385 -			--><button type="submit" data-icon="ok">$(gettext 'Change')</button>
   1.386 +			--><button type="submit" data-icon="ok">$(_ 'Change')</button>
   1.387  		</form>
   1.388  EOT
   1.389  		else
   1.390 @@ -647,31 +647,31 @@
   1.391  
   1.392  
   1.393  <section>
   1.394 -	<header id="ifconfig">$(gettext 'Output of ifconfig')</header>
   1.395 +	<header id="ifconfig">$(_ 'Output of ifconfig')</header>
   1.396  	<pre>$(ifconfig)</pre>
   1.397  </section>
   1.398  
   1.399  
   1.400  <section>
   1.401 -	<header id="routing">$(gettext 'Routing table')</header>
   1.402 +	<header id="routing">$(_ 'Routing table')</header>
   1.403  	<pre>$(route -n)</pre>
   1.404  </section>
   1.405  
   1.406  
   1.407  <section>
   1.408 -	<header id="dns">$(gettext 'Domain name resolution')</header>
   1.409 +	<header id="dns">$(_ 'Domain name resolution')</header>
   1.410  	<pre>$(cat /etc/resolv.conf)</pre>
   1.411  </section>
   1.412  
   1.413  
   1.414  <section>
   1.415 -	<header id="arp">$(gettext 'ARP table')</header>
   1.416 +	<header id="arp">$(_ 'ARP table')</header>
   1.417  	<pre>$(arp)</pre>
   1.418  </section>
   1.419  
   1.420  
   1.421  <section>
   1.422 -	<header id="connections">$(gettext 'IP Connections')</header>
   1.423 +	<header id="connections">$(_ 'IP Connections')</header>
   1.424  	<pre>$(netstat -anp 2>/dev/null | sed -e '/UNIX domain sockets/,$d' \
   1.425  -e 's#\([0-9]*\)/#<a href="boot.cgi?daemons=pid=\1">\1</a>/#')</pre>
   1.426  </section>