add network settings (beta)

git-svn-id: file:///root/webif/svn/pkg/webif/trunk@2212 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2015-01-19 21:16:52 +00:00
parent 24e1ee5210
commit 2c2c434fec
15 changed files with 817 additions and 365 deletions

View File

@ -1,10 +1,10 @@
Package: webif
Priority: optional
Section: web
Version: 1.2.0-1
Version: 1.2.0-2
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif-channelicons(>=1.1.14),lighttpd(>=1.4.35-2),jim(>=0.75-1),jim-oo,jim-sqlite3(>=0.75),jim-cgi(>=0.7),jim-binary(>=0.75),service-control(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.0),hmt(>=1.2.0),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2-1),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,mongoose
Depends: webif-channelicons(>=1.1.14),lighttpd(>=1.4.35-2),jim(>=0.75-1),jim-oo,jim-sqlite3(>=0.75),jim-cgi(>=0.7),jim-binary(>=0.75),service-control(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.0),hmt(>=1.2.0),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2-1),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools,dbupdate,mongoose
Suggests:
Description: An evolving web interface for the Humax.
Tags: http://hummy.tv/forum/threads/5866/

68
webif/cgi-bin/wifiscan.jim Executable file
View File

@ -0,0 +1,68 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
require system.class
httpheader "application/json"
if {![system has wifi_dongle]} {
puts "\[]"
exit
}
catch {exec ifconfig wlan0 up}
if {[catch {set op [exec /mod/bin/iwlist wlan0 scan]}]} {
puts "\[]"
exit
}
set lines [split $op "\n"]
puts "\["
set cur 0
foreach line [split $op "\n"] {
set extra [lassign [split $line :] key val]
switch -glob [string trim $key] {
*Address {
if {$cur} {
puts ""
puts " \},"
} else {
incr cur
}
puts " \{"
set mac "$val:[join $extra :]"
puts -nonewline " \"address\": \"[string trim $mac]\""
}
ESSID {
puts ","
puts -nonewline " \"ssid\": \"[string trim $val \"]\""
}
Channel {
puts ","
puts -nonewline " \"channel\": \"[string trim $val]\""
}
Quality {
puts ","
#puts "$val $extra"
set q [lindex [split $val /] 0]
set s [lindex [split [lindex $extra 0] " "] 0]
set n [lindex [split [lindex $extra 1] " "] 0]
puts " \"quality\": \"$q\","
puts " \"signal\": \"$s\","
puts -nonewline " \"noise\": \"$n\""
}
Encryption?key {
puts ","
puts -nonewline " \"encryption\": \"[string trim $val]\""
}
}
}
if {$cur} {
puts ""
puts " \}"
}
puts "\]"

View File

@ -235,7 +235,7 @@ pre, .pre
.blood
{
color: #ff4000;
color: #ff4000 !important;
background: transparent;
}
@ -254,7 +254,7 @@ pre, .pre
.footnote
{
color: #ff4000;
color: #ff4000 !important;
}
.blueshade

View File

@ -0,0 +1,24 @@
######################################################################
# Advanced Settings
puts -nonewline "
<h4>Advanced Settings</h4>
<div>
<fieldset style=\"display: inline\">
<legend> Advanced Settings </legend>
<table>
"
setting_toggle "Show development and advanced packages?" "pkgdev" $pkgdev
if {[system modversion 1] >= 214} {
setting_toggle "Expert mode telnet server?" "xtelnet" \
[file exists /mod/boot/xtelnet] 0 1
}
puts "
</table>
</fieldset>
</div>
"

View File

@ -0,0 +1,125 @@
######################################################################
# EPG Settings
puts "
<h4>EPG Settings</h4>
<div><fieldset style=\"display: inline\">
<legend>
EPG Settings
</legend>
<table>
"
puts "
<tr>
<form class=auto id=epg_style method=get action=$env(SCRIPT_NAME)>
<th class=key>Default Now/Next style</th>
<td><select id=epg_style name=epg_style
class=\"text ui-widget-content ui-corner-all\">
"
puts "<option value=standard"
if {$epg_style ne "grid"} { puts " selected" }
puts ">Standard\n"
puts "<option value=grid"
if {$epg_style eq "grid"} { puts " selected" }
puts ">Grid\n"
puts "
</select>
<small>
<input name=epg_style value=\"set\" type=submit>
</small>
<div id=epg_style_output></div>
</td>
</form>
</tr>
"
puts "
<tr>
<form class=auto id=service_style method=get action=$env(SCRIPT_NAME)>
<th class=key>Default Single-channel style</th>
<td><select id=service_style name=service_style
class=\"text ui-widget-content ui-corner-all\">
"
puts "<option value=standard"
if {$service_style eq "standard"} { puts " selected" }
puts ">Standard\n"
puts "<option value=grid"
if {$service_style ne "standard"} { puts " selected" }
puts ">Grid\n"
puts "
</select>
<small>
<input name=service_style value=\"set\" type=submit>
</small>
<div id=service_style_output></div>
</td>
</form>
</tr>
"
puts "
<tr>
<form class=auto id=channel_group method=get action=$env(SCRIPT_NAME)>
<th class=key>Channel Group for EPG</th>
<td><select id=channel_group name=channel_group
class=\"text ui-widget-content ui-corner-all\">
"
set i 0
puts "<option value=0>-- None --"
foreach grp [$settings channel_groups] {
incr i
puts -nonewline "<option value=$i"
if {$channel_group == $i} {
puts -nonewline " selected"
}
puts ">$grp"
}
puts "
</select>
<small>
<input name=channel_group value=\"set\" type=submit>
</small>
<div id=channel_group_output></div>
</td>
</form>
</tr>
"
puts "
<tr>
<form class=auto id=xepghours method=get action=$env(SCRIPT_NAME)>
<th class=key>Grid-style EPG Hours</th>
<td><select id=xepghours name=xepghours
class=\"text ui-widget-content ui-corner-all\">
"
foreach xehopt {2 3 4 5 6} {
puts -nonewline "<option value=$xehopt"
if {$xehopt == $xepghours} {
puts -nonewline " selected"
}
puts ">$xehopt hours"
}
puts "
</select>
<small>
<input name=xepghours value=\"set\" type=submit>
</small>
<div id=xepghours_output></div>
</td>
</form>
</tr>
"
setting_toggle "De-duplicate genre search results?" genrededup $genrededup
puts "
</table>
</fieldset></div>
"

View File

@ -0,0 +1,94 @@
######################################################################
# General Settings
puts "
<h4>General Settings</h4>
<div><fieldset style=\"display: inline\">
<legend>
General Settings
</legend>
<table>
"
puts "
<tr>
<form class=auto id=hostname method=get action=$env(SCRIPT_NAME)>
<th class=key>Hostname</th>
<td><input name=hostname value=\"$hostname\"
class=\"text ui-widget-content ui-corner-all\"
length=20 maxlength=50>
<small>
<input id=hostname_submit value=\"change\" type=submit>
</small>
<div id=hostname_output></div>
</td>
</form>
</tr>
"
setting_toggle "Slide-down toolbar?" "notoolbar" $(!$notoolbar) 1
setting_toggle "Mobile link on main page?" "nomobile" $(!$nomobile) 1
setting_toggle "Help links on main page?" "nohelplinks" $(!$nohelplinks) 1
setting_toggle "Twitter feed ticker on main page?" "notwitfeed" $(!$notwitfeed) 1
setting_toggle "Unwatched count on folders?" "nounwatchedcount" $(!$nounwatchedcount) 1
if {[system pkginst ir]} {
setting_toggle "Disable channel change confirmation?" \
"chanchangenc" $chanchangenc 0
}
puts -nonewline "
<tr>
<form class=auto id=autolog method=get action=$env(SCRIPT_NAME)>
<th class=key>Auto-processing log level</th>
<td><select id=autolog name=autolog
class=\"text ui-widget-content ui-corner-all\">
"
puts "<option value=0"
if {$autolog == 0} { puts " selected" }
puts ">Actions and errors only\n"
puts "<option value=1"
if {$autolog == 1} { puts " selected" }
puts ">Actions, errors and scan information\n"
puts "<option value=2"
if {$autolog == 2} { puts " selected" }
puts ">Debugging information\n"
puts "
</select>
<small>
<input name=autolog value=\"set\" type=submit>
</small>
<div id=autolog_output></div>
</td>
</form>
</tr>
"
puts -nonewline "
<tr>
<form class=auto id=audiomp3 method=get action=$env(SCRIPT_NAME)>
<th class=key>Audio extraction type</th>
<td><select id=audiomp3 name=audiomp3
class=\"text ui-widget-content ui-corner-all\">
"
puts "<option value=0"
if {$audiomp3 == 0} { puts " selected" }
puts ">[$settings audiomp3descr 0] - very fast but less compatible.\n"
puts "<option value=1"
if {$audiomp3 == 1} { puts " selected" }
puts ">[$settings audiomp3descr 1] - around 60 times slower.\n"
puts "
</select>
<small>
<input name=audiomp3 value=\"set\" type=submit>
</small>
<div id=audiomp3_output></div>
</td>
</form>
</tr>
"
puts "
</table></fieldset></div>
"

View File

@ -0,0 +1,125 @@
#!/mod/bin/jimsh
package require cgi
package require sqlite3
source /mod/webif/lib/setup
require system.class hexdump
httpheader
set tag [cgi_get tag -]
set if [cgi_get if -]
if {$tag eq "-" || $if eq "-"} {
puts "Missing tag or interface."
exit
}
proc ip2x {ip {validate 0}} {
set octets [split $ip .]
if {[llength $octets] != 4} {
error "Invalid IP address (octets)"
set octets [lrange [concat $octets 0 0 0] 0 3]
}
if {$validate} {
foreach oct $octets {
if {$oct < 0 || $oct > 255} {
error "Invalid octet, $oct"
}
}
}
binary scan [binary format c4 $octets] H8 x
return $x
}
proc valid_ip {ip} {
if {[catch {ip2x $ip 1} msg]} {
return 0
}
return 1
}
set file "/mod/boot/dbupdate/webif_network_$if"
switch [cgi_get mode -] {
static {
foreach f {ip mask gw dns} {
set errs {}
set $f [cgi_get $f -]
if {[set $f] eq "-"} {
lappend errs "Missing $f"
} elseif {![valid_ip [set $f]]} {
lappend errs "Invalid $f - [set $f]"
}
}
if {[llength $errs]} {
puts [join $errs "<br>"]
exit
}
set fd [open $file w]
puts $fd "setup:MENUCONFIG:ETHERNET_CONF_$tag:Value:1"
puts $fd "setup:MENUCONFIG:ETHERNET_CONF_${tag}_IP:Blob:[ip2x $ip]"
puts $fd "setup:MENUCONFIG:ETHERNET_CONF_${tag}_NETMASK:Blob:[ip2x $mask]"
puts $fd "setup:MENUCONFIG:ETHERNET_CONF_${tag}_GATEWAY:Blob:[ip2x $gw]"
puts $fd "setup:MENUCONFIG:ETHERNET_CONF_${tag}_DNS:Blob:[ip2x $dns]"
puts $fd "setup:MENUCONFIG:ETHERNET_CONF_${tag}_IP:Value:1"
puts $fd "setup:MENUCONFIG:ETHERNET_CONF_${tag}_NETMASK:Value:1"
puts $fd "setup:MENUCONFIG:ETHERNET_CONF_${tag}_GATEWAY:Value:1"
puts $fd "setup:MENUCONFIG:ETHERNET_CONF_${tag}_DNS:Value:1"
}
dhcp {
set fd [open $file w]
puts $fd "setup:MENUCONFIG:ETHERNET_CONF_$tag:Value:0"
}
default {
puts "Unknown mode."
exit
}
}
if {$if eq "wifi"} {
set ssid [cgi_get ssid SSID]
set pass [cgi_get pass PASSPHRASE]
set auth [cgi_get auth 7]
set data [string repeat "\x0" 0xfc]
pack data $ssid -str $([string length $ssid] * 8)
pack data $pass -str $([string length $pass] * 8) $(8 * 0x78)
switch $auth {
8 {
# "WPA2 PSK (AES)"
set bytes {3 4 4}
}
7 {
# "WPA2 PSK (TKIP+AES)"
set bytes {3 4 2}
}
6 {
# "WPA PSK (AES)"
set bytes {2 3 4}
}
5 {
# "WPA PSK (TKIP)"
set bytes {2 3 2}
}
default {
set bytes {0 0 0}
}
}
pack data [lindex $bytes 0] -intle 8 $(8 * 0x68)
pack data [lindex $bytes 1] -intle 8 $(8 * 0x6c)
pack data [lindex $bytes 2] -intle 8 $(8 * 0x70)
#hexdump $data
binary scan $data H* val
puts $fd "setup:MENUCONFIG:WLAN_CONNECTED_AP:Value:0"
puts $fd "setup:MENUCONFIG:WLAN_CONNECTED_AP:Blob:$val"
puts $fd "setup:MENUCONFIG:WLAN_IS_CONNECTED:Value:1"
puts $fd "setup:MENUCONFIG:WLAN_AUTH_TYPE:Value:$auth"
}
$fd close
system restartpending
puts "Settings will take effect on next boot."

View File

@ -0,0 +1,72 @@
$('#network_settings form').resetForm();
$('#network_settings').on('change', 'input[name=mode]', function(el) {
var form = $(this).closest('form');
val = $(form).find('input[name=mode]:checked').val();
if (val == 'dhcp')
$(form).find('input.static').disable();
else
$(form).find('input.static').enable();
});
$('#network_settings input[name=mode]').trigger('change');
$('#ns_pp_toggle').on('click', function(e) {
e.preventDefault();
if ($('#ns_pp').attr('type') == 'password')
{
$('#ns_pp').attr('type', 'input');
$('#ns_pp_toggle').text('Hide');
}
else
{
$('#ns_pp').attr('type', 'password');
$('#ns_pp_toggle').text('Reveal');
}
});
$('#ns_ssid_scan').button({
icons : {
primary : "ui-icon-signal-diag"
}
}).button('enable')
.on('click', function(e) {
e.preventDefault();
$('#ns_ssid_scan').button('disable');
$('#ns_ssid_loading').show();
$('#ns_ssid_list tbody').empty();
$('#ns_ssid_list_row').slideDown();
$.getJSON('/cgi-bin/wifiscan.jim', function(data) {
$.each(data, function(k,v) {
index = Math.round(v.quality / 20);
if (index > 5) index = 5;
str =
'<tr><td><img class=va height=20 src=/images/345_5_08_ST_WiFi_Signal_0' +
index + '.png alt="' + v.quality + '%"></td>';
if (v.encryption == 'on')
str += '<td><img height=20 src=/images/178_1_00_Icon_Lock.png></td>';
else
str += '<td></td>';
str += '<td><a class=ssid href=#>' + v.ssid + '</a></td>';
str += '<td class=footnote>(Channel ' + v.channel + ')</td>';
str += '</tr>';
$('#ns_ssid_list').append(str);
});
$('#ns_ssid_loading').hide();
$('#ns_ssid_scan').button('enable');
});
});
$('#ns_ssid_list').on('click', 'a.ssid', function(el) {
el.preventDefault();
var form = $(this).closest('form');
$(form).find('input[name=ssid]').val($(this).text());
});

View File

@ -0,0 +1,174 @@
######################################################################
# Network Settings
proc _ns_extractip {blob} {
if {[string bytelength $blob] != 4} { return "" }
set r {}
binary scan $blob c4 octets
foreach octet $octets {
lappend r [expr {$octet & 0xff}]
}
return [join $r .]
}
proc _ns_ssid {} {
set val [system param WLAN_CONNECTED_AP Blob]
if {$val ne "0"} {
return [string trim [string range $val 0 20]]
}
return ""
}
proc _ns_pass {} {
set val [system param WLAN_CONNECTED_AP Blob]
if {$val ne "0"} {
return [string trim [string range $val 120 239]]
}
return ""
}
proc _ns_iftable {if tag} {
if {[system param ETHERNET_CONF_${tag}] eq 1} {
set _static checked
set _dhcp ""
} else {
set _static ""
set _dhcp checked
}
set r "
<form id=networksettings_$if class=auto method=post
action=modules/network/save.jim>
<input type=hidden name=if value=$if />
<input type=hidden name=tag value=$tag />
<table>
<tr>
<th class=key>Mode</th>
<td>
<input type=radio name=mode value=static $_static>Static
<br>
<input type=radio name=mode value=dhcp $_dhcp>DHCP
</td>
</tr><tr>
<th class=key>IP Address</th>
<td><input name=ip class=static value=\"[
_ns_extractip [system param ETHERNET_CONF_${tag}_IP Blob]]\"></td>
</tr><tr>
<th class=key>Network Mask</th>
<td><input name=mask class=static value=\"[
_ns_extractip [system param ETHERNET_CONF_${tag}_NETMASK Blob]]\">
</td>
</tr><tr>
<th class=key>Gateway</th>
<td><input name=gw class=static value=\"[
_ns_extractip [system param ETHERNET_CONF_${tag}_GATEWAY Blob]]\">
</td>
</tr><tr>
<th class=key>DNS Server</th>
<td><input name=dns class=static value=\"[
_ns_extractip [system param ETHERNET_CONF_${tag}_DNS Blob]]\"></td>
</tr><tr>
"
if {$if eq "wifi"} {
set authtypes {
0 "None"
1 "WEP 64-bit Hex"
2 "WEP 64-bit ASCII"
3 "WEP 128-bit Hex"
4 "WEP 128-bit ASCII"
5 "WPA PSK (TKIP)"
6 "WPA PSK (AES)"
7 "WPA2 PSK (TKIP+AES)"
8 "WPA2 PSK (AES)"
}
append r "
<tr>
<th class=key>SSID</th>
<td>
<input name=ssid value=\"[_ns_ssid]\">
<small>
<button id=ns_ssid_scan>Scan</button>
</small>
</td>
</tr>
<tr id=ns_ssid_list_row class=hidden>
<th class=key>&nbsp;</th>
<td>
<div id=ns_ssid_loading class=blood>
<img src=/img/loading.gif>
Scanning for wireless networks...
</div>
<table id=ns_ssid_list></table>
</td>
</tr>
"
append r "
<th class=key>Authentication Type</th>
<td><select name=auth>
"
set val [system param WLAN_AUTH_TYPE]
foreach id [array names authtypes] {
append r "<option value=\"$id\""
if {$id eq $val} { append r " selected" }
append r ">$authtypes($id)\n"
}
append r "</select></td></tr><tr>"
append r "
<tr>
<th class=key>
Passphrase/key
<br>
<a href=# class=footnote id=ns_pp_toggle>
Reveal
</a>
</th>
<td><input type=password id=ns_pp name=pass size=40
value=\"[_ns_pass]\"></td>
</tr><tr>
"
}
append r "
<td></td>
<td align=right><small><input type=submit value=\"Save\"></small></td>
</table>
</form>
<div id=networksettings_${if}_output></div>
"
}
puts "
<h4>Network Settings</h4>
<div id=network_settings>
<fieldset style=\"display: inline; float: left\">
<legend>
Ethernet Interface
</legend>
[_ns_iftable eth 1ST]
</fieldset>
<fieldset style=\"display: inline; float: left\">
<legend>
Wireless Interface
</legend>
"
if {[system has wifi_dongle]} {
puts [_ns_iftable wifi 2ND]
} else {
puts "<i>No wireless dongle detected.</i>"
puts "<br>"
puts "<img src=/images/217_1_08_WIZ_WiFi.png>"
}
puts "
</fieldset>
</div>
<script type=text/javascript src=/settings/modules/network/script.js>
</script>
"

View File

@ -0,0 +1,107 @@
######################################################################
# Web Interface Settings
puts "
<h4>Web Interface Settings</h4>
<div>
<fieldset style=\"display: inline\">
<legend> Web Interface Settings </legend>
<table>
"
setting_toggle "HTTPS web server?" "https" \
[file exists /mod/etc/webif.pem] 0 1
puts "
</table>
</legend></fieldset>
<br>
<fieldset style=\"display: inline\">
<legend> User Access Control </legend>
<table>
"
set aclusers [$settings aclusers]
if {[llength $aclusers]} {
puts "<tr><th colspan=5 class=odd>Existing Users</th></tr>"
foreach user [$settings aclusers] {
lassign $user user
puts "<tr><td align=center style=\"font-weight: bold\">
$user</td>"
puts "<th class=key>New password:
<input
class=\"aclpass text ui-widget-content ui-corner-all\"
type=password size=20 maxlength=50><br>"
puts "Again:
<input
class=\"aclpassc text ui-widget-content ui-corner-all\"
type=password size=20 maxlength=50></td>"
puts "<th class=key><button class=pwchange>
Change</button></td>"
puts "<th class=key><button class=userdel>
Delete User</button></td>"
puts "</tr>"
}
puts "<tr><td colspan=5 id=aclusermod_output>&nbsp;</td></tr>"
puts "<tr><td colspan=5>&nbsp;</td></tr>"
} else {
puts "<tr><td colspan=5 class=blood><b>
Add a user to enable authentication.</b></td></tr>"
}
puts "<tr><th colspan=5 class=odd>Add New User</th></tr>"
puts "
<form id=aclnewuser method=get action=$env(SCRIPT_NAME)>
<tr><th class=key>New User:</th><td>
<input
class=\"text ui-widget-content ui-corner-all\"
id=acluser name=acluser size=20 maxlength=50></td></tr>
<tr><th class=key>Password:</th><td>
<input type=password
class=\"text ui-widget-content ui-corner-all\"
id=aclpass name=aclpass size=20 maxlength=50></td></tr>
<tr><th class=key>Password (confirm):</th><td>
<input type=password
class=\"text ui-widget-content ui-corner-all\"
id=aclpassc name=aclpassc size=20 maxlength=50></td></tr>
<tr><td><input id=aclnewuser_submit value=\"Add User\" type=submit>
</td></tr>
</form>
</table>
<div id=aclnewuser_output></div>
</fieldset>
</div>
"
puts {
<script type=text/javascript>
$('#aclnewuser').ajaxForm({
target: '#aclnewuser_output',
success: function(txt) {
if (txt.indexOf('Success') >= 0)
window.location.reload(true);
}
});
$('button.userdel').click(function(el) {
var user = $('td:first', $(this).parents('tr')).text().trim();
$('#aclusermod_output').load(
'/settings/settings.jim?aclact=del&acluser=' +
encodeURIComponent(user), function(txt) {
if (txt.indexOf('Success') >= 0)
window.location.reload(true);
});
});
$('button.pwchange').click(function(el) {
var tr = $(this).parents('tr');
var user = $('td:first', $(tr)).text().trim();
var pass = $(tr).find('input.aclpass').val();
var passc = $(tr).find('input.aclpassc').val();
$('#aclusermod_output').load('/settings/settings.jim?' +
'acluser=' + encodeURIComponent(user) + '&' +
'aclpass=' + encodeURIComponent(pass) + '&' +
'aclpassc=' + encodeURIComponent(passc));
});
</script>
}

View File

@ -156,368 +156,17 @@ proc setting_toggle {name attr checked {invert 0} {val 0}} {
"
}
puts "
<h4>General Settings</h4>
<div><fieldset style=\"display: inline\">
<legend>
General Settings
</legend>
<table>
"
######################################################################
# Settings Modules
puts "
<tr>
<form class=auto id=hostname method=get action=$env(SCRIPT_NAME)>
<th class=key>Hostname</th>
<td><input name=hostname value=\"$hostname\"
class=\"text ui-widget-content ui-corner-all\"
length=20 maxlength=50>
<small>
<input id=hostname_submit value=\"change\" type=submit>
</small>
<div id=hostname_output></div>
</td>
</form>
</tr>
"
setting_toggle "Slide-down toolbar?" "notoolbar" $(!$notoolbar) 1
setting_toggle "Mobile link on main page?" "nomobile" $(!$nomobile) 1
setting_toggle "Help links on main page?" "nohelplinks" $(!$nohelplinks) 1
setting_toggle "Twitter feed ticker on main page?" "notwitfeed" $(!$notwitfeed) 1
setting_toggle "Unwatched count on folders?" "nounwatchedcount" $(!$nounwatchedcount) 1
if {[system pkginst ir]} {
setting_toggle "Disable channel change confirmation?" \
"chanchangenc" $chanchangenc 0
set moddir /mod/webif/html/settings/modules
foreach mod {general web epg network advanced} {
if {[file exists "$moddir/$mod/.disabled"]} continue
catch {source "$moddir/$mod/settings.hook"}
}
puts -nonewline "
<tr>
<form class=auto id=autolog method=get action=$env(SCRIPT_NAME)>
<th class=key>Auto-processing log level</th>
<td><select id=autolog name=autolog
class=\"text ui-widget-content ui-corner-all\">
"
puts "<option value=0"
if {$autolog == 0} { puts " selected" }
puts ">Actions and errors only\n"
puts "<option value=1"
if {$autolog == 1} { puts " selected" }
puts ">Actions, errors and scan information\n"
puts "<option value=2"
if {$autolog == 2} { puts " selected" }
puts ">Debugging information\n"
puts "
</select>
<small>
<input name=autolog value=\"set\" type=submit>
</small>
<div id=autolog_output></div>
</td>
</form>
</tr>
"
puts -nonewline "
<tr>
<form class=auto id=audiomp3 method=get action=$env(SCRIPT_NAME)>
<th class=key>Audio extraction type</th>
<td><select id=audiomp3 name=audiomp3
class=\"text ui-widget-content ui-corner-all\">
"
puts "<option value=0"
if {$audiomp3 == 0} { puts " selected" }
puts ">[$settings audiomp3descr 0] - very fast but less compatible.\n"
puts "<option value=1"
if {$audiomp3 == 1} { puts " selected" }
puts ">[$settings audiomp3descr 1] - around 60 times slower.\n"
puts "
</select>
<small>
<input name=audiomp3 value=\"set\" type=submit>
</small>
<div id=audiomp3_output></div>
</td>
</form>
</tr>
"
puts "
</table></fieldset></div>
"
puts "
<h4>Web Interface Settings</h4>
<div>
<fieldset style=\"display: inline\">
<legend> Web Interface Settings </legend>
<table>
"
setting_toggle "HTTPS web server?" "https" \
[file exists /mod/etc/webif.pem] 0 1
puts "
</table>
</legend></fieldset>
<br>
<fieldset style=\"display: inline\">
<legend> User Access Control </legend>
<table>
"
set aclusers [$settings aclusers]
if {[llength $aclusers]} {
puts "<tr><th colspan=5 class=odd>Existing Users</th></tr>"
foreach user [$settings aclusers] {
lassign $user user
puts "<tr><td align=center style=\"font-weight: bold\">
$user</td>"
puts "<th class=key>New password:
<input
class=\"aclpass text ui-widget-content ui-corner-all\"
type=password size=20 maxlength=50><br>"
puts "Again:
<input
class=\"aclpassc text ui-widget-content ui-corner-all\"
type=password size=20 maxlength=50></td>"
puts "<th class=key><button class=pwchange>
Change</button></td>"
puts "<th class=key><button class=userdel>
Delete User</button></td>"
puts "</tr>"
}
puts "<tr><td colspan=5 id=aclusermod_output>&nbsp;</td></tr>"
puts "<tr><td colspan=5>&nbsp;</td></tr>"
} else {
puts "<tr><td colspan=5 class=blood><b>
Add a user to enable authentication.</b></td></tr>"
}
puts "<tr><th colspan=5 class=odd>Add New User</th></tr>"
puts "
<form id=aclnewuser method=get action=$env(SCRIPT_NAME)>
<tr><th class=key>New User:</th><td>
<input
class=\"text ui-widget-content ui-corner-all\"
id=acluser name=acluser size=20 maxlength=50></td></tr>
<tr><th class=key>Password:</th><td>
<input type=password
class=\"text ui-widget-content ui-corner-all\"
id=aclpass name=aclpass size=20 maxlength=50></td></tr>
<tr><th class=key>Password (confirm):</th><td>
<input type=password
class=\"text ui-widget-content ui-corner-all\"
id=aclpassc name=aclpassc size=20 maxlength=50></td></tr>
<tr><td><input id=aclnewuser_submit value=\"Add User\" type=submit>
</td></tr>
</form>
</table>
<div id=aclnewuser_output></div>
</fieldset>
</div>
"
puts {
<script type=text/javascript>
$('#aclnewuser').ajaxForm({
target: '#aclnewuser_output',
success: function(txt) {
if (txt.indexOf('Success') >= 0)
window.location.reload(true);
}
});
$('button.userdel').click(function(el) {
var user = $('td:first', $(this).parents('tr')).text().trim();
$('#aclusermod_output').load(
'/settings/settings.jim?aclact=del&acluser=' +
encodeURIComponent(user), function(txt) {
if (txt.indexOf('Success') >= 0)
window.location.reload(true);
});
});
$('button.pwchange').click(function(el) {
var tr = $(this).parents('tr');
var user = $('td:first', $(tr)).text().trim();
var pass = $(tr).find('input.aclpass').val();
var passc = $(tr).find('input.aclpassc').val();
$('#aclusermod_output').load('/settings/settings.jim?' +
'acluser=' + encodeURIComponent(user) + '&' +
'aclpass=' + encodeURIComponent(pass) + '&' +
'aclpassc=' + encodeURIComponent(passc));
});
</script>
}
puts "
<h4>EPG Settings</h4>
<div><fieldset style=\"display: inline\">
<legend>
EPG Settings
</legend>
<table>
"
puts "
<tr>
<form class=auto id=epg_style method=get action=$env(SCRIPT_NAME)>
<th class=key>Default Now/Next style</th>
<td><select id=epg_style name=epg_style
class=\"text ui-widget-content ui-corner-all\">
"
puts "<option value=standard"
if {$epg_style ne "grid"} { puts " selected" }
puts ">Standard\n"
puts "<option value=grid"
if {$epg_style eq "grid"} { puts " selected" }
puts ">Grid\n"
puts "
</select>
<small>
<input name=epg_style value=\"set\" type=submit>
</small>
<div id=epg_style_output></div>
</td>
</form>
</tr>
"
puts "
<tr>
<form class=auto id=service_style method=get action=$env(SCRIPT_NAME)>
<th class=key>Default Single-channel style</th>
<td><select id=service_style name=service_style
class=\"text ui-widget-content ui-corner-all\">
"
puts "<option value=standard"
if {$service_style eq "standard"} { puts " selected" }
puts ">Standard\n"
puts "<option value=grid"
if {$service_style ne "standard"} { puts " selected" }
puts ">Grid\n"
puts "
</select>
<small>
<input name=service_style value=\"set\" type=submit>
</small>
<div id=service_style_output></div>
</td>
</form>
</tr>
"
puts "
<tr>
<form class=auto id=channel_group method=get action=$env(SCRIPT_NAME)>
<th class=key>Channel Group for EPG</th>
<td><select id=channel_group name=channel_group
class=\"text ui-widget-content ui-corner-all\">
"
set i 0
puts "<option value=0>-- None --"
foreach grp [$settings channel_groups] {
incr i
puts -nonewline "<option value=$i"
if {$channel_group == $i} {
puts -nonewline " selected"
}
puts ">$grp"
}
puts "
</select>
<small>
<input name=channel_group value=\"set\" type=submit>
</small>
<div id=channel_group_output></div>
</td>
</form>
</tr>
"
puts "
<tr>
<form class=auto id=xepghours method=get action=$env(SCRIPT_NAME)>
<th class=key>Grid-style EPG Hours</th>
<td><select id=xepghours name=xepghours
class=\"text ui-widget-content ui-corner-all\">
"
foreach xehopt {2 3 4 5 6} {
puts -nonewline "<option value=$xehopt"
if {$xehopt == $xepghours} {
puts -nonewline " selected"
}
puts ">$xehopt hours"
}
puts "
</select>
<small>
<input name=xepghours value=\"set\" type=submit>
</small>
<div id=xepghours_output></div>
</td>
</form>
</tr>
"
setting_toggle "De-duplicate genre search results?" genrededup $genrededup
puts "
</table>
</fieldset></div>
"
#puts "
# <fieldset style=\"display: inline\">
# <legend> Email Settings </legend>
# <table>
#"
#
#puts "
# <tr>
# <form class=auto id=smtp_server method=get action=$env(SCRIPT_NAME)>
# <th class=key>SMTP Server for outbound email</th>
# <td><input name=smtp_server value=\"$smtp_server\"
# class=\"text ui-widget-content ui-corner-all\"
# length=20 maxlength=50>
# <small>
# <input id=smtp_server_submit value=\"change\" type=submit>
# </small>
# <div id=smtp_server_output></div>
# </td>
# </form>
# </tr>
#"
#
#puts "
# </table>
# </fieldset>
# <br><br>
#"
puts -nonewline "
<h4>Advanced Settings</h4>
<div>
<fieldset style=\"display: inline\">
<legend> Advanced Settings </legend>
<table>
"
setting_toggle "Show development and advanced packages?" "pkgdev" $pkgdev
if {[system modversion 1] >= 214} {
setting_toggle "Expert mode telnet server?" "xtelnet" \
[file exists /mod/boot/xtelnet] 0 1
}
puts "
</table>
</fieldset>
</div>
"
######################################################################
# Plugins
set hook settings
foreach plugin [lsort [glob -nocomplain /mod/webif/plugin/*]] {

View File

@ -13,7 +13,8 @@ puts {
<div style="width: 100%; height: 0.7em;
background: url(/img/stripes.gif) repeat-x;"></div>
<div style="font-size: 1.2em; width: 60%; text-align: center; padding: 0.5em">
A restart is required in order to complete a scheduling operation.
A restart is required in order to complete a scheduling operation or
system settings change.
<br>
<font class=blood>
}

View File

@ -7,7 +7,8 @@ proc hexdump data {
set bytes [string byterange $data $n $($n+15)]
binary scan $bytes H* hex
set hex [regexp -all -inline .. $hex]
regsub -all -- {[^a-z0-9]} $bytes . ascii
regsub -all -- {[\x01-\x1f\x80-\xff]} [\
string map {\x00 .} $bytes] . ascii
append dump [format "%04X: %-48s %-16s\n" $n $hex $ascii]
incr n 16
}

View File

@ -456,3 +456,15 @@ proc {system usbmounts} {{full 0}} {
return $ret
}
proc {system has} {comp} {
switch $comp {
wifi_dongle {
if {[catch {exec /mod/bin/iwgetid}]} {
return 0
}
return 1
}
}
return 0
}