version 1.0.11

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1848 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2014-04-22 00:03:29 +00:00
parent 52d05a7f48
commit 62a13e18cc
10 changed files with 232 additions and 128 deletions

View File

@ -1,10 +1,11 @@
Package: webif
Priority: optional
Section: web
Version: 1.0.10-6
Version: 1.0.11
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif-channelicons(>=1.1.10),mongoose(>=3.0.11),jim(>=0.75-1),jim-oo,jim-sqlite3(>=0.75),jim-cgi(>=0.7),jim-binary(>=0.75),service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.13),hmt(>=1.1.14),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.05),ffmpeg,id3v2,multienv(>=1.6)
Conflicts: tvdiary(<0.0.2-6)
Suggests:
Description: An evolving web interface for the Humax.
Tags: http://hummy.tv/forum/threads/4723/

View File

@ -0,0 +1 @@
index.html

View File

@ -9,10 +9,10 @@ httpheader
if {[cgi_get act] eq "https"} {
set val [cgi_get val off]
if {$val in {0 off}} {
file delete /mod/etc/mongoose.cert
exec /mod/webif/lib/bin/mkcert -delete
puts "HTTPS Server will be disabled after next reboot."
} else {
exec /mod/sbin/mongoose_mkcert
exec /mod/webif/lib/bin/mkcert
puts "HTTPS Server will be enabled after next reboot."
}
exit
@ -127,10 +127,10 @@ if {$aclact ne "-" && $acluser ne "-"} {
}
jqplugin form iphone-style-checkboxes
jscss settings.js
header
puts {
<script type="text/javascript" src="settings.js"></script>
<div id=accordion>
}
@ -175,8 +175,6 @@ puts "
</tr>
"
setting_toggle "HTTPS web server?" "https" \
[file exists /mod/etc/mongoose.cert] 0 1
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
@ -240,7 +238,113 @@ puts "
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/mongoose.cert] 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>
@ -389,99 +493,6 @@ puts "
# <br><br>
#"
puts "
<h4>Web Interface User Access Control</h4>
<div>
<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>&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(
'/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>
}
puts -nonewline "
<h4>Advanced Settings</h4>
<div>

View File

@ -64,7 +64,8 @@ $(document).ready(function () {
$(output)
.empty()
.show('slow')
.load('/cgi-bin/settings.jim?' + urlargs,
.html('<img src=/img/loading.gif> Please wait...')
.load('/settings/settings.jim?' + urlargs,
function() {
$(el).enable();
$(output)

View File

@ -64,7 +64,7 @@ menuitem "Service Management" "/img/spanner.png" \
menuitem "Package Management" "/img/packages.png" \
/pkg/index.jim 217 228
menuitem "Settings" "/images/326_1_00_Menu_Settings.png" \
/cgi-bin/settings.jim 217 228
/settings/settings.jim 217 228
menuitem "Diagnostics" "/img/diagnostics.png" \
/diag/diag.jim 217 228

View File

@ -16,5 +16,8 @@ puts "<font class=blood style=\"font-size: 0.9em; float: right; clear: right\">
if {![catch {set fhtcpversion [system fhtcpversion]}]} {
puts "<br>Humax Version: $fhtcpversion"
}
if {![catch {set kernelver [system kernelver]}]} {
puts "<br>Kernel Version: $kernelver"
}
puts "</font>"

View File

@ -43,7 +43,7 @@ tb "/images/321_1_00_Menu_CHList.png" "Schedule" "/sched/sched.jim"
tb "/images/328_1_26_Menu_TV_Guide.png" "EPG" $epglink
tb "/img/spanner.png" "Services" "/services/index.jim"
tb "/img/packages.png" "Packages" "/pkg/index.jim"
tb "/images/326_1_00_Menu_Settings.png" "Settings" "/cgi-bin/settings.jim"
tb "/images/326_1_00_Menu_Settings.png" "Settings" "/settings/settings.jim"
tb "/img/diagnostics.png" "Diag" "/diag/diag.jim"
eval_plugins toolbar

41
var/mongoose/lib/bin/mkcert Executable file
View File

@ -0,0 +1,41 @@
#!/bin/sh
config=/tmp/openssl.cnf.$$
if [ "$1" = "-delete" ]; then
cd /mod/etc
[ -f webif.pem ] && rm -f webif.pem
[ -f mongoose.cert ] && rm -f mongoose.cert
exit 0
fi
cat << EOM > $config
[req]
distinguished_name = req_dn
[req_dn]
EOM
/mod/bin/openssl req \
-x509 -nodes -days 365 \
-newkey rsa:2048 \
-subj "/C=GB/ST=Humax/CN=`hostname`" \
-sha1 \
-nodes \
-batch \
-keyout /mod/etc/webif.pem -out /mod/etc/webif.pem \
-config $config
rm -f $config
# Support legacy mongoose server...
(
cd /mod/etc
[ -f mongoose.cert ] && rm -f mongoose.cert
ln -sf webif.pem mongoose.cert
)
exit 0

View File

@ -241,7 +241,10 @@ settings method aclusers {} {
return $users
}
# Legacy function for Mongoose.
settings method mongooseauth {{mode 1}} {
if {![file exists /mod/etc/mongoose.conf]} return
set fd [open "/mod/etc/mongoose.conf" r]
set fdnew [open "/mod/etc/mongoose.conf.new" w]
foreach line [string trim [split [read $fd] "\n"]] {
@ -263,44 +266,56 @@ settings method mongooseauth {{mode 1}} {
file rename "/mod/etc/mongoose.conf.new" "/mod/etc/mongoose.conf"
}
settings method addacluser {user pass} {
set msg ""
if {![llength [$self aclusers]]} {
$self mongooseauth 1
append msg "Enabled web server authentication<br>"
}
set cmd "/mod/sbin/mongoose -A /mod/etc/htpasswd webif $user $pass"
exec {*}$cmd
append msg "Successfully updated user $user"
return $msg
settings method htdigest {user pass} {
set str "$user:webif:$pass"
set hash [string range [exec echo -n $str | md5sum] 0 32]
return "$user:webif:$hash"
}
settings method delacluser {user} {
if {![file exists "/mod/etc/htpasswd"]} { return }
set fd [open "/mod/etc/htpasswd" r]
settings method modacluser {user {pass 0}} {
set fdnew [open "/mod/etc/htpasswd.new" w]
set num 0
foreach line [string trim [split [read $fd] "\n"]] {
lassign [split $line ":"] xuser
if {$xuser eq $user} { continue }
if {$line ne ""} {
puts $fdnew $line
incr num
# Remove existing user, if present.
if {[file exists "/mod/etc/htpasswd"]} {
set fd [open "/mod/etc/htpasswd" r]
set num 0
foreach line [string trim [split [read $fd] "\n"]] {
lassign [split $line ":"] xuser
if {$xuser eq $user} { continue }
if {$line ne ""} {
puts $fdnew $line
incr num
}
}
$fd close
}
$fd close
# Add user, if required.
if {$pass ne "0"} {
puts $fdnew [$self htdigest $user $pass]
incr num
set msg "Added/updated user $user"
} else {
set msg "Removed user $user"
}
$fdnew close
file delete "/mod/etc/htpasswd"
file rename "/mod/etc/htpasswd.new" "/mod/etc/htpasswd"
set msg "Successfully removed user $user"
if {$num == 0} {
$self mongooseauth 0
append msg "<br>Disabled web server authentication<br>"
}
$self mongooseauth $num
return $msg
}
settings method addacluser {user pass} {
return [$self modacluser $user $pass]
}
settings method delacluser {user} {
return [$self modacluser $user]
}
settings method smartdata {} {
global settingsdb

View File

@ -66,6 +66,37 @@ proc {system fhtcpversion} {} {
return $ver
}
proc {system kernelver} {} {
#1 SMP Sun Mar 25 18:30:38 KST 2012
set ver [string range [exec uname -v] 11 end]
return [switch $ver {
# HDR
"Sep 16 20:17:56 KST 2010" { format "HDR_1.01.05" }
"Oct 11 21:11:05 KST 2010" { format "HDR_1.01.09" }
"Jan 21 15:44:39 KST 2011" { format "HDR_1.02.07" }
"Jun 11 00:54:19 KST 2011" { format "HDR_1.02.20" }
"Mar 25 18:30:38 KST 2012" { format "HDR_1.02.27" }
"May 27 00:19:34 KST 2012" { format "HDR_1.02.28" }
"Jul 5 11:11:28 KST 2012" { format "HDR_1.02.29" }
"Jan 12 16:49:05 KST 2013" { format "HDR_1.02.32" }
"Mar 6 07:27:02 KST 2013" { format "HDR_1.03.06(a)" }
"May 8 14:32:30 KST 2013" { format "HDR_1.03.06(b)" }
"Dec 10 14:36:54 KST 2013" { format "HDR_1.03.11" }
"Fri Feb 7 14:15:02 KST 2014 " { format "HDR_1.03.12" }
# HD
"Oct 11 21:14:31 KST 2010" { format "HD_1.01.12" }
"May 17 14:16:20 KST 2011" { format "HD_1.02.18" }
"Jun 11 00:54:19 KST 2011" { format "HD_1.02.20" }
"Mar 25 07:09:19 KST 2012" { format "HD_1.02.27" }
"May 27 00:19:40 KST 2012" { format "HD_1.02.28" }
"Jul 5 19:41:17 KST 2012 " { format "HD_1.02.29" }
"Oct 13 12:48:09 KST 2012" { format "HD_1.02.31" }
- { format "Unknown - $ver" }
}]
}
proc {system pkgver} {{pkg webif}} {
return [lrange [split [exec opkg list-installed $pkg] " "] 2 end]
}