2011-06-09 21:16:30 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
|
|
|
package require cgi
|
2011-07-01 22:56:53 +00:00
|
|
|
source /mod/var/mongoose/lib/setup
|
|
|
|
require settings.class
|
|
|
|
require plugin
|
2011-06-09 21:16:30 +00:00
|
|
|
|
|
|
|
puts "Content-Type: text/html"
|
|
|
|
puts ""
|
|
|
|
|
|
|
|
cgi_input
|
|
|
|
#cgi_dump
|
|
|
|
|
2012-01-19 21:15:52 +00:00
|
|
|
if {[cgi_get act] eq "https"} {
|
|
|
|
if {[cgi_get val off] eq "off"} {
|
|
|
|
file delete /mod/etc/mongoose.cert
|
|
|
|
puts "HTTPS Server will be disabled after next reboot."
|
|
|
|
} else {
|
|
|
|
exec /mod/sbin/mongoose_mkcert
|
|
|
|
puts "HTTPS Server will be enabled after next reboot."
|
|
|
|
}
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
set settings [settings new]
|
2011-06-09 21:16:30 +00:00
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
set hostname [$settings hostname]
|
2011-06-16 23:49:48 +00:00
|
|
|
set smtp_server [$settings smtp_server]
|
2011-06-14 11:48:55 +00:00
|
|
|
set channel_group [$settings channel_group]
|
2011-10-03 09:37:24 +00:00
|
|
|
set epg_style [$settings epg_style]
|
2011-07-11 23:29:21 +00:00
|
|
|
set pkgdev [$settings pkgdev]
|
2011-06-09 21:16:30 +00:00
|
|
|
|
|
|
|
# Handle updates
|
|
|
|
|
2011-07-01 22:56:53 +00:00
|
|
|
if {![dict exists $env REQUEST_URI]} { set env(REQUEST_URI) "" }
|
2011-06-16 23:49:48 +00:00
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
proc _handle_update {class var old text} {
|
|
|
|
global _cgi
|
|
|
|
global settings
|
|
|
|
|
|
|
|
if {[dict exists $_cgi $var]} {
|
|
|
|
set new [string trim [dict get $_cgi $var]]
|
|
|
|
if {$new == $old} {
|
|
|
|
puts "$text unchanged."
|
|
|
|
} elseif [string is $class -strict $new] {
|
|
|
|
$settings $var $new
|
|
|
|
puts "$text updated."
|
|
|
|
} else {
|
|
|
|
puts "Invalid value for $var."
|
|
|
|
}
|
|
|
|
exit
|
2011-06-09 21:16:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
proc handle_int_update {var old {text "Value"}} {
|
|
|
|
_handle_update digit $var $old $text
|
|
|
|
}
|
|
|
|
|
|
|
|
proc handle_str_update {var old {text "Value"}} {
|
|
|
|
_handle_update alnum $var $old $text
|
|
|
|
}
|
|
|
|
|
|
|
|
handle_str_update hostname $hostname Hostname
|
2011-06-16 23:49:48 +00:00
|
|
|
_handle_update ascii smtp_server $smtp_server "SMTP Server"
|
2011-06-14 11:48:55 +00:00
|
|
|
handle_int_update channel_group $channel_group "Channel Group"
|
2011-10-03 09:37:24 +00:00
|
|
|
handle_str_update epg_style $epg_style "EPG Type"
|
2011-07-11 23:29:21 +00:00
|
|
|
handle_int_update pkgdev $pkgdev "Development Package Display"
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-11-12 23:57:19 +00:00
|
|
|
set acluser [cgi_get acluser "-"]
|
|
|
|
set aclpass [cgi_get aclpass "-"]
|
|
|
|
set aclpassc [cgi_get aclpassc "-"]
|
|
|
|
if {$acluser ne "-" && $aclpass ne "-"} {
|
|
|
|
if {![string length $acluser]} {
|
|
|
|
puts "No username provided."
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
if {$aclpass ne $aclpassc} {
|
|
|
|
puts "Passwords do not match."
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
if {[string length $aclpass] < 4} {
|
|
|
|
puts "Password is too short (< 4 characters)"
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
puts [$settings addacluser $acluser $aclpass]
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
set aclact [cgi_get aclact "-"]
|
|
|
|
if {$aclact ne "-" && $acluser ne "-"} {
|
|
|
|
switch $aclact {
|
|
|
|
"del" { puts [$settings delacluser $acluser] }
|
|
|
|
}
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
2011-07-01 22:56:53 +00:00
|
|
|
header
|
|
|
|
|
2011-10-05 22:07:22 +00:00
|
|
|
puts {
|
2012-01-19 21:15:52 +00:00
|
|
|
<script type="text/javascript" src="/cgi-bin/settings.js"></script>
|
2011-10-05 22:07:22 +00:00
|
|
|
<script type="text/javascript" src="/js/jquery.form.js"></script>
|
|
|
|
<script type="text/javascript" src="/js/jconfirmaction.jquery.js"></script>
|
|
|
|
<link href=/css/jconfirmaction.jquery.css rel=stylesheet type=text/css />
|
|
|
|
<script type="text/javascript" src="/js/iphone-style-checkboxes.js"></script>
|
|
|
|
<link href=/css/iphone-style-checkboxes.css rel=stylesheet type=text/css />
|
|
|
|
}
|
2011-06-09 21:16:30 +00:00
|
|
|
|
|
|
|
puts "
|
2011-06-25 20:59:50 +00:00
|
|
|
<fieldset style=\"display: inline\">
|
|
|
|
<legend>
|
|
|
|
General Settings
|
|
|
|
</legend>
|
|
|
|
<table>
|
|
|
|
"
|
|
|
|
|
|
|
|
puts "
|
2011-06-09 21:16:30 +00:00
|
|
|
<tr>
|
2011-07-01 22:56:53 +00:00
|
|
|
<form class=auto id=hostname method=get action=$env(REQUEST_URI)>
|
2011-06-25 20:59:50 +00:00
|
|
|
<th class=key>Hostname</th>
|
2011-06-09 21:16:30 +00:00
|
|
|
<td><input name=hostname value=\"$hostname\"
|
2011-06-25 20:59:50 +00:00
|
|
|
class=\"text ui-widget-content ui-corner-all\"
|
2011-06-09 21:16:30 +00:00
|
|
|
length=20 maxlength=50>
|
2011-07-08 20:39:57 +00:00
|
|
|
<small>
|
2011-06-09 21:16:30 +00:00
|
|
|
<input id=hostname_submit value=\"change\" type=submit>
|
2011-07-08 20:39:57 +00:00
|
|
|
</small>
|
2011-06-09 21:16:30 +00:00
|
|
|
<div id=hostname_output></div>
|
|
|
|
</td>
|
2011-06-14 11:48:55 +00:00
|
|
|
</form>
|
|
|
|
</tr>
|
|
|
|
"
|
|
|
|
|
2012-01-19 21:15:52 +00:00
|
|
|
puts -nonewline "
|
|
|
|
<tr>
|
|
|
|
<th class=key>HTTPS web server?</th>
|
|
|
|
<td><input id=https_toggle name=https type=checkbox value=yes"
|
|
|
|
if {[file exists /mod/etc/mongoose.cert]} { puts -nonewline " checked" }
|
|
|
|
puts ">
|
|
|
|
<div id=https_output></div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
"
|
|
|
|
|
2011-10-03 09:37:24 +00:00
|
|
|
puts "
|
|
|
|
<tr>
|
|
|
|
<form class=auto id=epg_style method=get action=$env(REQUEST_URI)>
|
|
|
|
<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>
|
|
|
|
"
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
puts "
|
|
|
|
<tr>
|
2011-07-01 22:56:53 +00:00
|
|
|
<form class=auto id=channel_group method=get action=$env(REQUEST_URI)>
|
2011-06-25 20:59:50 +00:00
|
|
|
<th class=key>Channel Group for EPG</th>
|
2011-06-14 11:48:55 +00:00
|
|
|
<td><select id=channel_group name=channel_group
|
2011-10-03 09:37:24 +00:00
|
|
|
class=\"text ui-widget-content ui-corner-all\">
|
2011-06-14 11:48:55 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
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>
|
2011-07-08 20:39:57 +00:00
|
|
|
<small>
|
2011-06-25 20:59:50 +00:00
|
|
|
<input name=channel_group value=\"set\" type=submit>
|
2011-07-08 20:39:57 +00:00
|
|
|
</small>
|
2011-06-14 11:48:55 +00:00
|
|
|
<div id=channel_group_output></div>
|
|
|
|
</td>
|
|
|
|
</form>
|
2011-06-09 21:16:30 +00:00
|
|
|
</tr>
|
2011-06-14 11:48:55 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
puts "
|
2011-06-09 21:16:30 +00:00
|
|
|
</table>
|
2011-06-25 20:59:50 +00:00
|
|
|
</fieldset>
|
|
|
|
<br><br>
|
|
|
|
<fieldset style=\"display: inline\">
|
|
|
|
<legend> Email Settings </legend>
|
|
|
|
<table>
|
|
|
|
"
|
|
|
|
|
|
|
|
puts "
|
|
|
|
<tr>
|
2011-07-01 22:56:53 +00:00
|
|
|
<form class=auto id=smtp_server method=get action=$env(REQUEST_URI)>
|
2011-06-25 20:59:50 +00:00
|
|
|
<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>
|
2011-07-08 20:39:57 +00:00
|
|
|
<small>
|
2011-06-25 20:59:50 +00:00
|
|
|
<input id=smtp_server_submit value=\"change\" type=submit>
|
2011-07-08 20:39:57 +00:00
|
|
|
</small>
|
2011-06-25 20:59:50 +00:00
|
|
|
<div id=smtp_server_output></div>
|
|
|
|
</td>
|
2011-06-09 21:16:30 +00:00
|
|
|
</form>
|
2011-06-25 20:59:50 +00:00
|
|
|
</tr>
|
2011-06-09 21:16:30 +00:00
|
|
|
"
|
2011-06-25 20:59:50 +00:00
|
|
|
|
2011-07-11 23:29:21 +00:00
|
|
|
puts "
|
|
|
|
</table>
|
|
|
|
</fieldset>
|
2011-11-12 23:57:19 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
puts "
|
|
|
|
<br><br>
|
|
|
|
<fieldset style=\"display: inline\">
|
|
|
|
<legend> Web Interface 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> </td></tr>"
|
|
|
|
puts "<tr><td colspan=5> </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(REQUEST_URI)>
|
|
|
|
<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>
|
|
|
|
"
|
|
|
|
|
|
|
|
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(
|
|
|
|
'/cgi-bin/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('/cgi-bin/settings.jim?' +
|
|
|
|
'acluser=' + encodeURIComponent(user) + '&' +
|
|
|
|
'aclpass=' + encodeURIComponent(pass) + '&' +
|
|
|
|
'aclpassc=' + encodeURIComponent(passc));
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
}
|
|
|
|
|
2012-01-21 01:27:06 +00:00
|
|
|
puts -nonewline "
|
2011-07-11 23:29:21 +00:00
|
|
|
<br><br>
|
|
|
|
<fieldset style=\"display: inline\">
|
|
|
|
<legend> Advanced Settings </legend>
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th class=key>Show development and advanced packages?</th>
|
2012-01-21 01:27:06 +00:00
|
|
|
<td><input name=pkgdev id=pkgdev value=1 type=checkbox
|
2011-07-11 23:29:21 +00:00
|
|
|
"
|
2012-01-21 01:27:06 +00:00
|
|
|
if {$pkgdev} { puts -nonewline " checked" }
|
|
|
|
puts ">
|
2011-07-11 23:29:21 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
2011-06-25 20:59:50 +00:00
|
|
|
</table>
|
2012-01-21 01:27:06 +00:00
|
|
|
<div id=pkgdev_output></div>
|
2011-06-25 20:59:50 +00:00
|
|
|
</fieldset>
|
|
|
|
"
|
|
|
|
|
2011-07-01 22:56:53 +00:00
|
|
|
eval_plugins settings
|
|
|
|
|
2011-10-05 22:07:22 +00:00
|
|
|
puts {
|
|
|
|
<br><br>
|
|
|
|
<fieldset style="display: inline">
|
|
|
|
<legend> Reset Custom Firmware </legend>
|
|
|
|
<button id=cfwreset>
|
|
|
|
Click to remove all packages and settings installed by the custom firmware.
|
|
|
|
</button>
|
|
|
|
</fieldset>
|
|
|
|
<script type=text/javascript>
|
|
|
|
$('#cfwreset').jConfirmAction({
|
|
|
|
yesAnswer: "Delete"
|
|
|
|
}, function(el) {
|
|
|
|
$('html').html('Restart the Humax using the remote control.');
|
|
|
|
$.get('/cgi-bin/cfwreset');
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-07-01 22:56:53 +00:00
|
|
|
footer
|
2011-06-09 21:16:30 +00:00
|
|
|
|