git-svn-id: file:///root/webif/svn/pkg/webif/trunk@2451 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2015-08-14 19:33:25 +00:00
parent 427aa42ace
commit a9f7ba3ff2
16 changed files with 206 additions and 39 deletions

View File

@ -1,10 +1,10 @@
Package: webif
Priority: optional
Section: web
Version: 1.2.3-5
Version: 1.2.4
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif-channelicons(>=1.1.18),lighttpd(>=1.4.35-2),jim(>=0.76),jim-oo,jim-sqlite3(>=0.76),jim-cgi(>=0.7),jim-binary(>=0.76),service-control(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.0),hmt(>=2.0.3),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(>=29-1),dbupdate,recmon(>2.0.3-3),auto-unprotect(>=2.0.0-1)
Depends: webif-channelicons(>=1.1.18),lighttpd(>=1.4.35-2),jim(>=0.76),jim-oo,jim-sqlite3(>=0.76),jim-cgi(>=0.7),jim-binary(>=0.76),service-control(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.0),hmt(>=2.0.5),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(>=29-1),dbupdate,recmon(>=2.0.7)
Suggests:
Description: An evolving web interface for the Humax.
Tags: http://hummy.tv/forum/threads/5866/
Tags: http://hummy.tv/forum/threads/6484/

28
webif/cgi-bin/idle.jim Executable file
View File

@ -0,0 +1,28 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
require system.class
httpheader
set idle [system idletime]
if {$idle > 0} {
lassign [clock format $idle -format {%H %M}] h m
set s "Idle: "
# switch $h {
# 1 { append s "1 hour, " }
# 0 {}
# default { append s "$($h + 0) hours, " }
# }
# switch $m {
# 1 { append s "1 min" }
# default { append s "$($m + 0) mins" }
# }
if {$h > 0} { append s "$($h + 0)h, " }
append s "$($m + 0)m"
puts $s
} else {
puts ""
}

View File

@ -75,7 +75,7 @@ proc get_data {} {
}
}
}
if {$opfile ne "" && $opfile ni $ret} {
if {$opfile ne "" && $opfile ni $ret && [file exists $opfile]} {
set ret($opfile) [file size $opfile]
}
}
@ -241,15 +241,17 @@ if {![system instandby] && $play < 1} {
}
if {$runmode eq "cgi"} {
lappend output [concat \
"<span class=\"va stitem\">\n" \
" [epg channelicon $name 30 \
{vertical-align: middle; padding: 0 4px 0 2px}]\n" \
" <span>Watching <i>$lcn: $name $prog</i></span>\n" \
"</span>\n" \
]
set s "
<span class=\"va stitem\">
[epg channelicon $name 30 \
{vertical-align: middle; padding: 0 4px 0 2px}]
<span>Watching <i>$lcn: $name $prog</i></span>
"
append s "</span>"
lappend output $s
} else {
lappend output "Watching $lcn: $name $prog"
set s "Watching $lcn: $name $prog"
lappend output $s
}
}
}
@ -298,6 +300,13 @@ foreach event $events {
}
}
######################################################################
# Idle Time
if {$runmode ne "cgi"} {
lappend output "Idle: [clock format [system idletime] -format %T]"
}
######################################################################
# Output

View File

@ -40,6 +40,8 @@ set nofcount [$config nounwatchedcount]
set model [system model]
set dustbin [system dustbin 1]
set dlnaok [system dlnastatus]
proc icon {img {hover ""} {extra ""} {class "va"}} {
puts -nonewline "<img src=\"$img\" class=\"$class\" height=21 $extra"
if {$hover ne ""} {
@ -233,12 +235,6 @@ proc entry {file} {{i 0}} {
icon "/img/Guidance_blue.png"
}
# Indexed
if {$::model eq "HDR" && [llength [$ts dlnaloc]]} {
icon "/img/dlna.png" "Indexed by DLNA Server"
set dlna 1
}
# Shrunk
if {[$ts flag Shrunk]} {
icon "/img/compress.png" "Shrunk"
@ -248,6 +244,13 @@ proc entry {file} {{i 0}} {
set bx [$ts get bookmarks]
}
# Indexed
if {$::dlnaok && $::model eq "HDR" && [llength [
system dlnaurl [file normalize $file]]]} {
icon "/img/dlna.png" "Indexed by DLNA Server"
set dlna 1
}
# Opt+ button
puts "
@ -271,6 +274,14 @@ set dir [cgi_get dir $mroot]
source assets.jim
if {!$dlnaok} {
puts {
<span class="blood dlnawarning cleft">
Note: Content Sharing is disabled on this system.
</span>
}
}
puts "
<span style=\"display:none\" id=dir>$dir</span>
<span style=\"display:none\" id=mediaroot>$mroot</span>

View File

@ -75,6 +75,15 @@ div.container .usb
top: 8px;
}
#idletime
{
position: absolute;
left: 50px;
top: 45px;
font-style: italic;
font-size: 12px;
}
div.footer
{
clear: both;
@ -239,6 +248,12 @@ pre, .pre
background: transparent;
}
.idletime
{
font-size: 70%;
font-style: italic;
}
.filesize
{
color: #6a6aff;

View File

@ -51,6 +51,8 @@ puts {
</td>
</tr>
<tr><td colspan=2 id=results class=hidden></td></tr>
<tr><td colspan=2 style="height: 10px"></td></tr>
<tr>
@ -181,10 +183,6 @@ foreach file [lsort -command logsort $loglist] {
puts {
</fieldset>
<div style="margin-top: 2em; display: none; float: left; clear: left"
id=results></div>
}
footer

View File

@ -3,14 +3,26 @@ $(function() {
$('button').button();
$('#rundiag').button({icons: {primary: "ui-icon-play"}});
$('#runfopkg').button({icons: {primary: "ui-icon-play"}});
$('#runedit').button({icons: {primary: "ui-icon-folder-open"}});
$('#dbinfo').button({icons: {primary: "ui-icon-wrench"}});
$('#channelinfo').button({icons: {primary: "ui-icon-script"}});
$('#diskdiag').button({icons: {primary: "ui-icon-disk"}});
$('#dlna').button({icons: {primary: "ui-icon-video"}});
$('#dspace').button({icons: {primary: "ui-icon-search"}});
$('#reboot').button({icons: {primary: "ui-icon-power"}});
//$('#runreset').button({icons: {primary: "ui-icon-radio-on"}});
//$('#runrma').button({icons: {primary: "ui-icon-radio-on"}});
$('#rundiag').click(function() {
var val = $('#diagsel').val();
if (val == '0')
val = $('#seq').val();
$('#results')
.slideDown()
.html('<br><br><img src=/img/loading.gif> ' +
'Running diagnostic, please wait...')
.html('<span class=blood><img src=/img/loading.gif> ' +
'Running diagnostic, please wait...</span>')
.load('rundiag.jim?diag=' + encodeURIComponent(val), function() {
$('#results').wrapInner('<pre>');
});
@ -57,7 +69,7 @@ $('#dspace').click(function(e) {
window.location = 'dspace/index.jim';
});
$('#reboot').button({icons:{primary:"ui-icon-power"}}).click(function(e) {
$('#reboot').click(function(e) {
e.preventDefault();
window.location = '/restart/index.jim';
});

View File

@ -32,6 +32,7 @@ class="ui-widget ui-corner-all"></textarea>
<button class=editactive id=save>Save</button>
<button class=editactive id=revert>Revert</button>
<button class=xeditactive id=create>Create File</button>
<button class=editactive id=executable>Make Executable</button>
<div id=result class="blood hidden" />

25
webif/html/edit/perms.jim Executable file
View File

@ -0,0 +1,25 @@
#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
require pretty_size
cgi_input
#cgi_dump
set file [cgi_get file "/tmp/hosts"]
if {$file eq "-"} { exit }
httpheader "text/plain" 0
if {[cgi_get op "-"] eq "x"} {
exec chmod +x $file
}
if {![file exists $file]} {
puts 0
} else {
set stat [file stat $file]
puts $($stat(mode) & 0x1ff)
}

View File

@ -4,12 +4,19 @@ var forcefile = false;
$(function() {
var file = null;
var perms = 0;
var changed = false;
$('button').button();
$('button.editactive').disable();
$('#editor').tabsupport().disable();
$('#open').button({icons: {primary: "ui-icon-folder-open"}});
$('#revert').button({icons: {primary: "ui-icon-refresh"}});
$('#save').button({icons: {primary: "ui-icon-disk"}});
$('#create').button({icons: {primary: "ui-icon-plus"}});
$('#executable').button({icons: {primary: "ui-icon-gear"}});
function loadfile(f)
{
if (!f)
@ -18,7 +25,7 @@ function loadfile(f)
$('button.editactive').disable();
$('#editor').disable().val('');
$('#msg').text('Loading ' + f);
$.get('get.jim?file=' + encodeURIComponent(f), function(data) {
$.get('get.jim', { file: f }, function(data) {
if (data.match('>>>.*does not exist'))
{
$('#msg').text(data);
@ -40,6 +47,15 @@ function loadfile(f)
$('#msg').html('Editing <i>' + f + '</i>');
file = f;
changed = false;
$.get('perms.jim', { file: f }, function(data) {
perms = data;
if (data & 0x49)
{
$('#msg').append(' - Executable');
$('#executable').disable();
}
});
}
});
}
@ -119,7 +135,7 @@ function createf_submit()
console.log('Creating: ' + f);
$('#createf').dialog('close');
$.get('create.jim?file=' + encodeURIComponent(f), function(data) {
$.get('create.jim', { file: f }, function(data) {
if (data.match('^>>>'))
{
$('#msg').text(data);
@ -158,6 +174,19 @@ $('a.qfile').on('click', function() {
loadfile($(this).text());
});
$('#executable').on('click', function() {
if (!confirm('Make ' + file + ' executable?'))
return;
$.get('perms.jim', { file: file, op: 'x' }, function(data) {
perms = data;
if (data & 0x49)
{
$('#executable').disable();
$('#msg').append(' - Executable');
}
});
});
if (forcefile)
{
loadfile(forcefile);

View File

@ -8,3 +8,17 @@ $('#topbar a').on('click', function(e) {
e.stopPropagation();
});
$(function() {
function updateidle()
{
$.get('/cgi-bin/idle.jim', function(idle) {
$('#idletime').html(idle);
});
}
updateidle();
setInterval(updateidle, 60000);
});

View File

@ -28,6 +28,7 @@ if {[system model] eq "HDR" && [system usbdisks] > 0} {
source /mod/webif/include/usbeject.jim
}
puts {
<div id=idletime></div>
</div>
}
source /mod/webif/include/toolbar.jim

View File

@ -13,11 +13,11 @@ if {[catch {$ts get file}]} {
exit
}
if {![$ts flag "ODEncrypted"]} {
set url $rfile
} else {
lassign [$ts dlnaloc] url
if {$url eq ""} {
lassign [$ts dlnaloc] url
if {$url eq ""} {
if {![$ts flag "ODEncrypted"]} {
set url $rfile
} else {
puts "Media is encrypted and not indexed by the DLNA Server."
exit
}

View File

@ -135,13 +135,13 @@ eval_plugins auto 1
set scanstart [clock milliseconds]
log "-------------------------------------------------------"
# is_listening is relatively expensive so it is checked once globally at
# dlnastatus is relatively expensive so it is checked once globally at
# the start and then if the server is not listening then no decrypt
# operations will be attempted for this run, even if the server starts
# up halfway through. Otherwise the server is checked for every decryption
# and if it goes away then decryption will not be attempted for the rest
# of the run.
if {[system is_listening 9000]} {
if {[system dlnastatus]} {
set dlnaok 1
log "DLNA Server is running." 2
} else {
@ -333,7 +333,7 @@ proc do_decrypt {ts} {
return
}
if {![system is_listening 9000]} {
if {![system dlnastatus]} {
log " $file - DLNA Server not running." 2
set ::dlnaok 0
return
@ -445,6 +445,7 @@ proc do_decrypt {ts} {
}
log "Done... [endclock $size]" 0
lappend processed_files [$ts get file]
$ts unflag "ODEncrypted"
runplugin postdecrypt $ts
endop
}

View File

@ -74,6 +74,13 @@ proc {system lastbootreason} {{descr 1}} {{lbr -1}} {
return "Unknown ($lbr)"
}
proc {system idletime} {} {
if {[file exists "/tmp/.lastir"]} {
return $([clock seconds] - [file mtime "/tmp/.lastir"])
}
return 0
}
proc {system fhtcpversion} {} {{ver ""}} {
if {$ver ne ""} { return $ver }
set file "/etc/fhtcpversion"
@ -153,6 +160,10 @@ proc {system mediaroot} {} {
return ""
}
proc {system dlnastatus} {} {
return [system is_listening 9000]
}
proc {system dlnadb} {} {
switch [system model] {
HDR { return "/mnt/hd2/dms_cds.db" }
@ -163,7 +174,9 @@ proc {system dlnadb} {} {
proc {system _dlnaurl} {file urlbase} {
set mime "video/ts"
set db [sqlite3.open [system dlnadb]]
if {[catch {set db [sqlite3.open [system dlnadb]]}]} {
return {}
}
set muri [$db query {
select tblresource.mimetype, contenturi
from tblresource join tblmedia using (mediaid)
@ -300,11 +313,17 @@ proc {system diskspace} {{raw 0}} {
set fperc $(100 - $perc)
switch [system model] {
HDR { set tsrdir "/mnt/hd2/Tsr" }
HD { set tsrdir "/media/drive1/.tsr" }
HDR {
set tsrdir "/mnt/hd2/Tsr"
set tsrok [file isdirectory $tsrdir]
}
HD {
set tsrdir "/media/drive1/.tsr"
set tsrok [file exists "$tsrdir/0.ts"]
}
}
if {[file exists "$tsrdir/0.ts"]} {
if {$tsrok} {
set tsrbuf 21474836480
lassign [exec du -ks $tsrdir] tsrused
set tsrused $($tsrused * 1024)

View File

@ -87,6 +87,10 @@ ts method flag {f} {
if {$f in $flags} {return 1} else {return 0}
}
ts method unflag {f} {
lremove flags $f
}
ts method unlock {} {
set cmd [list /mod/bin/hmt -lock $file]
exec {*}$cmd