Compare commits

..

8 Commits

Author SHA1 Message Date
hummypkg
ca6129abef update version
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@258 2a923420-c742-0410-a762-8d5b09965624
2011-07-08 20:53:46 +00:00
hummypkg
42b5805c45 finish restart
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@253 2a923420-c742-0410-a762-8d5b09965624
2011-07-08 20:39:57 +00:00
hummypkg
88ada938d1 commit initial backup/restore framework and restart
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@252 2a923420-c742-0410-a762-8d5b09965624
2011-07-07 22:33:19 +00:00
hummypkg
15040206ab work on restore
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@245 2a923420-c742-0410-a762-8d5b09965624
2011-07-06 23:16:20 +00:00
hummypkg
4861459aec checkpoint backup/restore
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@236 2a923420-c742-0410-a762-8d5b09965624
2011-07-05 22:59:34 +00:00
hummypkg
5523ec6a43 initial backup function
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@235 2a923420-c742-0410-a762-8d5b09965624
2011-07-05 18:38:42 +00:00
hummypkg
5f6c7a843c new reservations screen
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@234 2a923420-c742-0410-a762-8d5b09965624
2011-07-05 00:19:02 +00:00
hummypkg
e712f38bb1 fix plugin error
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@233 2a923420-c742-0410-a762-8d5b09965624
2011-07-04 22:41:24 +00:00
42 changed files with 1061 additions and 219 deletions

View File

@@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
Version: 0.5.9
Version: 0.6.0
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: mongoose(>=2.11-6),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.3),jim-oo,jim-pack,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.2),hmt(>=1.0.6),ssmtp

View File

@@ -0,0 +1,75 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require rsv.class
set dir /mod/var/backup
puts "Content-Type: text/html"
puts ""
cgi_input
#cgi_dump
if {![dict exists $_cgi file]} {
puts "No filename supplied."
exit
}
set file [file tail [dict get $_cgi file]]
set ffile "/$dir/$file.rbk"
if {[file exists $ffile]} {
puts "Backup file <i>$file</i> already exists."
exit
}
if {[catch { set fd [open $ffile w] } msg]} {
puts "Error creating backup file. - $msg"
exit
}
puts "Backing up scheduled recordings and events..."
set events [rsv list]
set fields [lsort [[rsv] vars]]
#puts $fd "# [join $fields "\t"]"
foreach event $events {
puts " Backing up scheduled event '[$event name]'"
puts -nonewline $fd "event\t"
foreach f $fields {
if {$f eq "aulEventToRecordInfo"} { continue }
puts -nonewline $fd "[$event get $f]\t"
}
puts $fd ""
}
puts "Done."
puts "Backing up channel favourites..."
set grp 0
foreach res [$rsvdb query {
select eFavGroup,
TBL_FAV.eSvcType,
substr(szSvcName, 2) as szSvcName
from TBL_FAV join TBL_SVC using (hSvc)
order by eFavGroup
}] {
if {$res(eFavGroup) != $grp} {
set grp $res(eFavGroup)
puts " Group $grp"
}
puts " $res(szSvcName)"
puts $fd "fav\t$res(eFavGroup)\t$res(eSvcType)\t$res(szSvcName)"
}
puts "Done."
close $fd
rsv cleanup

View File

@@ -0,0 +1,59 @@
function refresh_files()
{
$('#backup_files').load('/cgi-bin/backup/files.jim', function() {
$('input.restore').change(function() {
$('#restore_button').removeAttr('disabled')
.button('option', 'disabled', false);
$('#delete_button').removeAttr('disabled')
.button('option', 'disabled', false);
});
});
}
$(document).ready(function() {
$('button').button();
refresh_files();
$('#backup_button').click(function() {
$('#backup_working').slideDown();
$('#results').load('/cgi-bin/backup/backup.jim?' +
$('#backup_name').serialize(), function() {
$('#results').slideDown(function() {
$('#backup_working').slideUp();
refresh_files();
});
});
});
$('#delete_button').click(function() {
var backup = $('input.restore').val();
if (confirm('Confirm deletion of ' + backup))
{
$('#results').load('/cgi-bin/backup/delete.jim?' +
$('input.restore').serialize(), function() {
$('#results').slideDown(function() {
refresh_files();
});
});
}
});
$('#restore_button').click(function() {
var backup = $('input.restore').val();
if (confirm('!!!!!!!!!!!!!!!!!!!!!!!!! PLEASE CONFIRM !!!!!!!!!!!!!!!!!!!!!!!!!\n\nAre you sure you wish to erase all scheduled recordings and favourite channels and then restore them from\n' + backup + '?'))
{
$('#restore_working').slideDown();
$('#results').load('/cgi-bin/backup/restore.jim?' +
$('input.restore').serialize(), function() {
$('#results').slideDown(function() {
$('#restore_working').slideUp();
refresh_files();
$('#restore_warning').slideDown();
$('#restart_block').load(
'/cgi-bin/restartblock.jim');
});
});
}
});
});

View File

@@ -0,0 +1,31 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
set dir /mod/var/backup
puts "Content-Type: text/html"
puts "Pragma: nocache"
puts "Expires: Thu, 01 Jan 1970 00:00:00 GMT"
puts ""
cgi_input
#cgi_dump
if {![dict exists $_cgi restore_file]} {
puts "No filename supplied."
exit
}
set file [file tail [dict get $_cgi restore_file]]
set ffile "/$dir/$file.rbk"
if {![file exists $ffile]} {
puts "Backup file <i>$file</i> does not exist."
} elseif {[catch { file delete $ffile } msg]} {
puts "Deletion failed: $msg"
} else {
puts "Successfully deleted <i>$file</i>"
}

View File

@@ -0,0 +1,39 @@
#!/mod/bin/jimsh
package require cgi
puts "Content-Type: text/html"
puts "Pragma: nocache"
puts "Expires: Thu, 01 Jan 1970 00:00:00 GMT"
puts ""
set dir "/mod/var/backup"
proc empty {} {
puts "<font style=\"color: grey\">
<i>No current backup files.</i>
</font>"
}
if {![file isdirectory $dir]} {
empty
exit
}
set backups [glob -nocomplain "$dir/*.rbk"]
if {![llength $backups]} {
empty
exit
}
foreach backup $backups {
set b [file rootname [file tail $backup]]
puts "<input name=restore_file class=restore
type=radio value=\"$b\">$b <font class=footnote>(
[clock format [file mtime $backup] -format {%c %Z}]
)</font></input>
<br>
"
}

View File

@@ -0,0 +1,136 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require rsv.class
set dir /mod/var/backup
puts "Content-Type: text/html"
puts ""
cgi_input
#cgi_dump
#set _cgi(restore_file) "backup-2011-Jul-05-19:22"
if {![dict exists $_cgi restore_file]} {
puts "No filename supplied."
exit
}
set file [file tail [dict get $_cgi restore_file]]
set ffile "/$dir/$file.rbk"
if {![file exists $ffile]} {
puts "Backup file <i>$file</i> does not exist."
exit
}
if {[catch { set fd [open $ffile r] } msg]} {
puts "Error opening backup file. - $msg"
exit
}
proc findhsvc {channel} {
global rsvdb
set hsvc [$rsvdb query "
select hSvc
from channel.TBL_SVC
where szSvcName = '$channel'
or szSvcname = '\025$channel'
limit 1
"]
if {[llength $hsvc] == 1} {
return [lindex [lindex $hsvc 0] 1]
} else {
return 0
}
}
puts "Restoring scheduled events..."
$rsvdb query {delete from TBL_RESERVATION}
set fields [lsort [[rsv] vars]]
set data [split [read $fd] "\n"]
foreach line $data {
set vals [split $line "\t"]
if {[lindex $vals 0] ne "event"} { continue }
set vars {}
set i 0
foreach f $fields {
if {$f eq "aulEventToRecordInfo"} { continue }
incr i
lappend vars $f [lindex $vals $i]
}
set rsv [rsv new $vars]
# Need to fix up channel and CRID mappings in case something has
# changed during a channel scan.
puts " Restoring [$rsv name]"
set bad 0
# First, the service number
set ohsvc [$rsv get hsvc]
if {$ohsvc > 0} {
set hsvc [$rsv fix_hsvc]
if {$hsvc == 0} {
puts " Cannot find channel, restore failed."
set bad 1
} elseif {$hsvc != $ohsvc} {
puts -nonewline " Service number has "
puts "changed $ohsvc -> $hsvc, fixing."
} else {
puts " No change in channel service."
}
}
if {!$bad} { $rsv insert }
}
puts "Restoring favourite channels..."
$rsvdb query {delete from channel.TBL_FAV}
set grp 0
foreach line $data {
set vals [split $line "\t"]
if {[lindex $vals 0] ne "fav"} { continue }
set group [lindex $vals 1]
set type [lindex $vals 2]
set chan [lindex $vals 3]
set hsvc [findhsvc $chan]
if {$grp != $group} {
set grp $group
puts " Group $grp"
}
puts " $chan"
if {!$hsvc} {
puts " Cannot map channel name to service."
continue
}
set query "
insert into channel.TBL_FAV(hSvc, eFavGroup, eSvcType)
values($hsvc, $group, $type);
"
$rsvdb query $query
}
close [open /tmp/.restartpending w]
close $fd
rsv cleanup

View File

@@ -8,7 +8,7 @@ puts "Content-Type: text/html"
puts ""
set ignore {.nts .thm .hmt .hmi}
set include {.ts .avi .mpg .wmv .mkv}
set include {.ts .avi .mpg .mpeg .wmv .mkv .mp3 .mp4 .mov}
cgi_input
#cgi_dump
@@ -46,15 +46,11 @@ proc entry {file} {{i 0}} {
if {$ext eq ".ts" && [file exists "${base}.nts"]} {
set type ts
set ts [ts fetch $file 1]
set img 741_1_10_Video_Title.png
set pad 0
set newpad "top: -6; left: 4;"
set img Video_TS
} else {
set type gen
set ts 0
set img 743_4_10_Video_Xvid_File.png
set pad "2"
set newpad "top: -2; left: 2;"
set img Video_Other
}
puts "
@@ -69,26 +65,9 @@ proc entry {file} {{i 0}} {
if {![file exists "[file rootname $file].hmi"]} { set new 1 }
}
if {$new} {
# Overlay the new image over the media one.
puts "
<span style=\"position: relative; left: 0; top 0;
padding: $pad\">
<img class=va border=0 width=45 src=/images/$img
style=\"padding: $pad;
position: relative; top: 0; left: 0\">
<img class=va border=0
src=/images/743_1_10_Video_New.png
style=\"position: absolute; $newpad
width: 18\">
</span>
"
} else {
puts "
<img class=va border=0 width=45 src=/images/$img
style=\"padding:$pad\">
"
}
if {$new} { append img _New }
puts "<img class=va border=0 src=/img/$img.png>"
puts "
$bfile
@@ -101,11 +80,15 @@ proc entry {file} {{i 0}} {
# Icons
set locked 0
set encd 0
set def unknown
if {$type eq "ts"} {
# HD / SD
if {[$ts get definition] eq "HD"} {
set def HD
set img "172_1_00_HD"
} else {
set def SD
set img "172_1_26_SD"
}
puts "<img class=va src=/images/$img.png height=21>"
@@ -119,6 +102,7 @@ proc entry {file} {{i 0}} {
# Encrypted
if {[$ts flag "Encrypted"] > 0} {
set encd 1
puts "<img class=va
src=/images/749_1_26_Video_Encryption.png
height=21>"
@@ -137,7 +121,7 @@ proc entry {file} {{i 0}} {
puts "
<a href=#>
<img class=\"opt va\" border=0 width=45 type=$type did=$i
locked=$locked
locked=$locked encd=$encd def=$def new=$new
src=/images/181_1_00_Help5_OPT_Plus.png>
</a>
<div class=\"results blood\" style=\"margin: 0 0 0 5em\"></div>
@@ -163,6 +147,8 @@ puts {
<ul id=optmenu class=contextMenu>
<li><a href=#delete>Delete</a></li>
<li><a href=#lock>Toggle Lock</a></li>
<li><a href=#enc>Toggle Enc</a></li>
<li><a href=#new>Toggle New</a></li>
<li><a href=#rename>Rename</a></li>
<li><a href=#download>Download</a></li>
</ul>
@@ -231,7 +217,7 @@ if {$parent ne ""} {
puts "
<div class=va>
<a href=$env(REQUEST_URI)?dir=[cgi_quote_url $parent]>
<img src=/images/711_3_09_Media_Folder_UP.png class=va>
<img border=0 src=/images/711_3_09_Media_Folder_UP.png class=va>
\[parent directory\]</a>
</div>
"

View File

@@ -69,6 +69,18 @@ function lock_callback(file, type, id)
$.get(url, function() { window.location.reload(true); });
}
function enc_callback(file, type, id)
{
var url = '/cgi-bin/browse/enc.jim?file=' + encodeURIComponent(file);
$.get(url, function() { window.location.reload(true); });
}
function new_callback(file, type, id)
{
var url = '/cgi-bin/browse/new.jim?file=' + encodeURIComponent(file);
$.get(url, function() { window.location.reload(true); });
}
function rename_submit()
{
var s = $('#renameform_form').serialize();
@@ -98,6 +110,26 @@ function preparemenu(el, menu)
{
if (el.attr('type') == 'ts')
{
if (el.attr('def') == 'HD')
{
$('#optmenu').enableContextMenuItems('#enc');
if (el.attr('encd') == 1)
$(menu).changeContextMenuItem('#enc',
'Remove ENC');
else
$(menu).changeContextMenuItem('#enc',
'Set ENC');
}
else
$('#optmenu').disableContextMenuItems('#enc');
$('#optmenu').enableContextMenuItems('#new');
if (el.attr('new') == 1)
$(menu).changeContextMenuItem('#new', 'Mark watched');
else
$(menu).changeContextMenuItem('#new', 'Mark new');
$('#optmenu').enableContextMenuItems('#lock');
if (el.attr('locked') == 1)
{
@@ -114,7 +146,10 @@ function preparemenu(el, menu)
{
$('#optmenu').enableContextMenuItems('#delete');
$('#optmenu').disableContextMenuItems('#lock');
$('#optmenu').disableContextMenuItems('#enc');
$('#optmenu').disableContextMenuItems('#new');
}
}
@@ -139,6 +174,16 @@ var menuclick = function(action, el, pos)
file, type, id);
break;
case 'enc':
confirm_action('change the ENC flag on', enc_callback,
file, type, id);
break;
case 'new':
confirm_action('change the New flag on', new_callback,
file, type, id);
break;
case 'rename':
$('#rename').val(bfile);
$('#renameorig').val(file);

View File

@@ -0,0 +1,27 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/ts.class
puts "Content-Type: text/html"
puts ""
cgi_input
#cgi_dump
#set _cgi(file) "/media/My Video/The Walking Dead/The Walking Dead S01E06.ts"
set file [dict get $_cgi file]
set ts [ts fetch $file]
if {[set ts [ts fetch $file]] != 0} {
set action enc
if {[$ts flag "Encrypted"]} { set action unenc }
if {[$ts $action]} {
puts "Successfully [set action]ed $file."
} else {
puts "Problem [set action]ing $file,
[$ts get error]"
}
}

View File

@@ -0,0 +1,27 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/ts.class
puts "Content-Type: text/html"
puts ""
cgi_input
#cgi_dump
#set _cgi(file) "/media/My Video/The Walking Dead/The Walking Dead S01E06.ts"
set file [dict get $_cgi file]
set ts [ts fetch $file]
if {[set ts [ts fetch $file]] != 0} {
set action new
if {[$ts flag "New"]} { set action watched }
if {[$ts set_$action]} {
puts "Successfully marked $file as $action."
} else {
puts "Problem marking $file as $action,
[$ts get error]"
}
}

View File

@@ -9,7 +9,7 @@ puts ""
header
puts "<script type=text/javascript src=/js/highlight.js></script>"
puts "<script type=text/javascript src=/js/jquery.highlight.js></script>"
cgi_input
#cgi_dump
@@ -113,8 +113,7 @@ puts "</table>"
if {$searchterm != ""} {
puts "
<script type=text/javascript>
highlight(document.getElementById(\"results\"),
\"$searchterm\");
\$('#results').highlight('$searchterm');
</script>
"
}

View File

@@ -0,0 +1,8 @@
#!/mod/bin/jimsh
puts "Content-Type: text/html"
puts ""
puts [exec /etc/init.d/S90settop restart]
file delete /tmp/.restartpending

View File

@@ -0,0 +1,7 @@
#!/mod/bin/jimsh
puts "Content-Type: text/html"
puts ""
source /mod/var/mongoose/include/restart.jim

View File

@@ -56,9 +56,6 @@ header
puts {<script type="text/javascript" src="/js/jquery.form.js"></script>}
puts {
<style type=text/css>
.ui-button, .ui-button-text { padding: 0; font-size: 10px; }
</style>
<script type=text/javascript>
$(document).ready(function () {
$(":submit").button();
@@ -93,7 +90,9 @@ puts "
<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>
@@ -122,7 +121,9 @@ foreach grp [$settings channel_groups] {
puts "
</select>
<small>
<input name=channel_group value=\"set\" type=submit>
</small>
<div id=channel_group_output></div>
</td>
</form>
@@ -145,7 +146,9 @@ puts "
<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>

View File

@@ -0,0 +1,4 @@
<!--#include virtual="/lib/header.shtml" -->
<!--#exec cmd="/mod/var/mongoose/include/backup.jim" -->
<!--#include virtual="/lib/footer.shtml" -->

View File

@@ -1,62 +1,62 @@
/* Generic context menu styles */
.contextMenu {
position: absolute;
width: 120px;
z-index: 99999;
border: solid 1px #CCC;
background: #EEE;
padding: 0px;
margin: 0px;
display: none;
}
.contextMenu LI {
list-style: none;
padding: 0px;
margin: 0px;
}
.contextMenu A {
color: #333;
text-decoration: none;
display: block;
line-height: 20px;
height: 20px;
background-position: 6px center;
background-repeat: no-repeat;
outline: none;
padding: 1px 5px;
padding-left: 28px;
}
.contextMenu LI.hover A {
color: #FFF;
background-color: #3399FF;
}
.contextMenu LI.disabled A {
color: #AAA;
cursor: default;
}
.contextMenu LI.hover.disabled A {
background-color: transparent;
}
.contextMenu LI.separator {
border-top: solid 1px #CCC;
}
/*
Adding Icons
You can add icons to the context menu by adding
classes to the respective LI element(s)
*/
.contextMenu LI.edit A { background-image: url(images/page_white_edit.png); }
.contextMenu LI.cut A { background-image: url(images/cut.png); }
.contextMenu LI.copy A { background-image: url(images/page_white_copy.png); }
.contextMenu LI.paste A { background-image: url(images/page_white_paste.png); }
.contextMenu LI.delete A { background-image: url(images/page_white_delete.png); }
.contextMenu LI.quit A { background-image: url(images/door.png); }
/* Generic context menu styles */
.contextMenu {
position: absolute;
width: 140px;
z-index: 99999;
border: solid 1px #CCC;
background: #EEE;
padding: 0px;
margin: 0px;
display: none;
}
.contextMenu LI {
list-style: none;
padding: 0px;
margin: 0px;
}
.contextMenu A {
color: #333;
text-decoration: none;
display: block;
line-height: 20px;
height: 20px;
background-position: 6px center;
background-repeat: no-repeat;
outline: none;
padding: 1px 5px;
padding-left: 28px;
}
.contextMenu LI.hover A {
color: #FFF;
background-color: #3399FF;
}
.contextMenu LI.disabled A {
color: #AAA;
cursor: default;
}
.contextMenu LI.hover.disabled A {
background-color: transparent;
}
.contextMenu LI.separator {
border-top: solid 1px #CCC;
}
/*
Adding Icons
You can add icons to the context menu by adding
classes to the respective LI element(s)
*/
.contextMenu LI.edit A { background-image: url(images/page_white_edit.png); }
.contextMenu LI.cut A { background-image: url(images/cut.png); }
.contextMenu LI.copy A { background-image: url(images/page_white_copy.png); }
.contextMenu LI.paste A { background-image: url(images/page_white_paste.png); }
.contextMenu LI.delete A { background-image: url(images/page_white_delete.png); }
.contextMenu LI.quit A { background-image: url(images/door.png); }

View File

@@ -52,6 +52,13 @@ div.footer
padding-top: 2em;
}
div.warningbox
{
background: url('/img/redshade.png') repeat-x;
padding: 0.5em;
margin: 1em;
}
table
{
empty-cells: show;
@@ -236,8 +243,18 @@ img.progress
display: block;
}
.hidden
{
display: none;
}
input.text
{
padding: .4em;
}
.highlight
{
background-color: yellow;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 936 B

View File

@@ -19,6 +19,8 @@ $(document).ready(function() {
});
</script>
<div style="clear: both">
<div style="float: left">
<center>
<a href=/cgi-bin/browse.jim>
@@ -56,8 +58,11 @@ $(document).ready(function() {
<br>
</center>
</div>
</div>
<div style="float: left; clear: left">
<div style="clear: both">
<div style="float: left">
<center>
<a href=/services.shtml>
<img src=/img/spanner.jpg border=0 width=217 height=228>
@@ -97,12 +102,14 @@ $(document).ready(function() {
</center>
</div>
</div>
<div style="clear: both">
<!--#exec cmd="/mod/var/mongoose/include/mediatomb.jim" -->
</div>
<div class=footer>
<ul>
<li>
<!--#exec cmd="/mod/var/mongoose/include/mediatomb.jim" -->
MediaTomb Web Interface</a>
</li><li>
<a href=/db.shtml target=_blank>SQLite3 Database Dump</a>
</li><li>
<a href=/jim/ref.html target=_blank>Jim Reference Manual</a> |

View File

@@ -0,0 +1,53 @@
/*
highlight v3
Highlights arbitrary terms.
<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
MIT license.
Johann Burkard
<http://johannburkard.de>
<mailto:jb@eaio.com>
*/
jQuery.fn.highlight = function(pat) {
function innerHighlight(node, pat) {
var skip = 0;
if (node.nodeType == 3) {
var pos = node.data.toUpperCase().indexOf(pat);
if (pos >= 0) {
var spannode = document.createElement('span');
spannode.className = 'highlight';
var middlebit = node.splitText(pos);
var endbit = middlebit.splitText(pat.length);
var middleclone = middlebit.cloneNode(true);
spannode.appendChild(middleclone);
middlebit.parentNode.replaceChild(spannode, middlebit);
skip = 1;
}
}
else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
for (var i = 0; i < node.childNodes.length; ++i) {
i += innerHighlight(node.childNodes[i], pat);
}
}
return skip;
}
return this.each(function() {
innerHighlight(this, pat.toUpperCase());
});
};
jQuery.fn.removeHighlight = function() {
return this.find("span.highlight").each(function() {
this.parentNode.firstChild.nodeName;
with (this.parentNode) {
replaceChild(this.firstChild, this);
normalize();
}
}).end();
};

View File

@@ -18,6 +18,7 @@ puts {
}
source /mod/var/mongoose/html/lib/topbar.jim
source /mod/var/mongoose/include/restart.jim
puts {
<div style="clear: both">

View File

@@ -12,6 +12,7 @@
<body>
<!--#include virtual="/lib/topbar.shtml" -->
<!--#exec cmd="/mod/var/mongoose/include/restart.jim" -->
<div style="clear: both">

View File

@@ -4,17 +4,18 @@ puts {
<div class=container onclick="location.href='/'; return false;">
<div class=left><img src=/images/154_1_00_WIN_MD116_1L.png></div>
<div class=middle>
<img border=0 src=/images/516_1_26_Freeview_Logo.png>
<span style="font-size: 150%; padding: 0 0 0 2em;">
}
source /mod/var/mongoose/include/model.jim
puts {
</span>
<!-- Start include diskspace -->
<!-- Start include diskspace - above other items to work around IE feature.. -->
}
source /mod/var/mongoose/include/diskspace.jim
puts {
<!-- End include diskspace -->
<img border=0 src=/images/516_1_26_Freeview_Logo.png>
<span style="display: inline; font-size: 150%;
padding: 0 0 0 2em;">
}
source /mod/var/mongoose/include/model.jim
puts {
</span>
</div>
<div class=right><img src=/images/154_1_00_WIN_MD116_3R.png></div>
</div>

View File

@@ -3,13 +3,13 @@
<div class=container onclick="location.href='/'; return false;">
<div class=left><img src=/images/154_1_00_WIN_MD116_1L.png></div>
<div class=middle>
<img border=0 src=/images/516_1_26_Freeview_Logo.png>
<span style="font-size: 150%; padding: 0 0 0 2em;">
<!--#exec cmd="/mod/var/mongoose/include/model.jim" -->
</span>
<!-- Start include diskspace -->
<!-- Start include diskspace - above other items to work around IE feature.. -->
<!--#exec cmd="/mod/var/mongoose/include/diskspace.jim" -->
<!-- End include diskspace -->
<img border=0 src=/images/516_1_26_Freeview_Logo.png>
<span style="font-size: 1.5em; padding: 0 0 0 2em;">
<!--#exec cmd="/mod/var/mongoose/include/model.jim" -->
</span>
</div>
<div class=right><img src=/images/154_1_00_WIN_MD116_3R.png></div>
</div>

67
var/mongoose/include/backup.jim Executable file
View File

@@ -0,0 +1,67 @@
#!/mod/bin/jimsh
source /mod/var/mongoose/lib/setup
require altrow rsv.class
puts {
<script type=text/javascript src=/cgi-bin/backup/backup.js></script>
<h2>Backup/Restore</h2>
<div id=restart_block></div>
<div id=restore_warning class="hidden warningbox">
<center>
<b>!!!!!!!!!!!!!! PLEASE NOTE !!!!!!!!!!!!!!
<br><br>
After restoring the scheduled recordings you <b>MUST</b> restart the box using
the link at the top of the screen or via the remote control and then add
at least one scheduled entry using the remote control
(which you can then delete).
</div>
<div style="clear: both; float: left; width: 40%; border: 1px solid grey;
padding: 1em">
To create a backup of your current favourite channel configuration and
scheduled recordings, enter a name in the box below and click the button.
A suggested name has been entered for you.
<p>
}
puts "<input type=text size=30 maxlength=50 id=backup_name name=file
class=\"text ui-widget-content ui-corner-all\"
value=\"[clock format [clock seconds] -format "backup-%Y-%b-%d-%H:%M"]\">"
puts "<button id=backup_button>Create Backup</button>"
puts {
<br>
<div id=backup_working class=va style="display: none;">
<img class=va src=/img/loading.gif>&nbsp;
<font class=footnote>Backing up...</font>
</div>
</div>
<div id=backup_files_outer
style="float: left; width: 40%; border: 1px solid grey; margin-left: 1em;
padding: 0 1em 1em 1em">
<h3>Available Backups</h3>
<div id=backup_files style="padding: 0 0 0 2em">
<img src=/img/loading.gif>Retrieving list of backups...
</div>
<br>
<button id=restore_button disabled>Restore Backup</button>
<button id=delete_button disabled>Delete Backup</button>
<br>
<div id=restore_working class=va style="display: none;">
<img class=va src=/img/loading.gif>&nbsp;
<font class=footnote>Restoring...</font>
</div>
</div>
<div id=results class=pre
style="display: none; clear: both; float: left; padding: 1em;
margin-top: 1em; border: 1px solid grey; width: 70%">
</div>
}

View File

@@ -5,6 +5,7 @@ source /mod/var/mongoose/lib/setup
require altrow
proc db_info {db_file} {
if {![file exists $db_file]} { return }
set db [sqlite3.open $db_file]
set tables [$db query {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}]
@@ -40,4 +41,5 @@ puts {<style type="text/css">table, td, th {border-collapse:collapse; border:1px
db_info /var/lib/humaxtv/rsv.db
db_info /var/lib/humaxtv/setup.db
db_info /var/lib/humaxtv/channel.db
#db_info /mnt/hd2/dms_cds.db

View File

@@ -18,13 +18,26 @@ if {[os.gethostname] eq "hosting"} {
set file [format "%02d" [expr {$perc * 25 / 100 + 1}]]
puts "<div style=\"float: right; background:url('/images/345_1_27_ST_USB_BG.png')\">"
puts "<img src=/images/345_2_14_ST_HDD_$file.png>"
puts "</div>"
puts "<span style=\"float: right\">"
puts "<br>"
puts "Total space: $size<br>"
puts "Used: $used ($perc%)"
puts "</span>"
# The HD model only has the USB images which are blue. I prefer the green
# one so use those if available.
if {[file exists /opt/share/images/blue/345_2_14_ST_HDD_01.png]} {
set prefix 345_2_14_ST_HDD
} else {
set prefix 345_1_27_ST_USB
}
puts "
<span style=\"float: right;
background:url('/images/345_1_27_ST_USB_BG.png')
no-repeat\">
<img src=/images/${prefix}_$file.png>
</span>
<span style=\"float: right\">
<br>
Total space: $size<br>
Used: $used ($perc%)
</span>
"

View File

@@ -8,5 +8,18 @@ close $fd
regexp {URL=([^"]*)} $data match
set url [string range $match 4 [string length $match]]
puts "<a href=$url>";
puts "
<div style=\"float: left; padding-top: 5em\">
<center>
<a href=$url>
<img src=/img/mediatomb.png width=180>
</a>
<br>
<a href=$url>
<b>MediaTomb</b>
</a>
<br>
</center>
</div>
"

View File

@@ -0,0 +1,52 @@
#!/mod/bin/jimsh
if {[file exists /tmp/.restartpending]} {
puts {
<center>
<div style="width: 60%; 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 warm restart is required in order to complete a scheduling operation.
<br>
<font class=blood>
}
# Is humaxtv doing anything?
set pid [exec pgrep humaxtv]
set c 0
catch { set c [exec /mod/bin/lsof -p $pid | grep Video | fgrep .ts | wc -l] }
if {$c > 0} {
puts "Cannot restart whilst box is busy."
} else {
puts {
Restart via the remote control or
<small><button id=restart_humaxtv>Restart now</button></small>
}
}
puts {
</font>
</div>
<div style="width: 60%; height: 0.7em; margin-bottom: 2em;
background: url(/img/stripes.gif) repeat-x;"></div>
</center>
<script type=text/javascript>
$('#restart_humaxtv').button();
$('#restart_humaxtv').click(function() {
if (confirm('Are you sure you wish to perform a warm restart now?'))
{
$.ajax({
url: '/cgi-bin/restart.jim',
success: function() {
window.location.reload(true);
}
});
}
});
</script>
}
}

View File

@@ -1,63 +1,45 @@
#!/mod/bin/jimsh
package require sqlite3
source /mod/var/mongoose/lib/setup
require altrow
require altrow rsv.class progressbar
set db [sqlite3.open /var/lib/humaxtv/rsv.db]
$db query {attach database '/var/lib/humaxtv/channel.db' as channel}
set events [rsv list]
set res [$db query {
select *, channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn,
case when ersvtype > 3 then 1 else 0 end as sort
from tbl_reservation
left join channel.TBL_SVC
on main.TBL_RESERVATION.hSvc = channel.TBL_SVC.hSvc
order by sort, nsttime
}]
puts {
<table class=borders>
<tr>
<th></th>
<th colspan=2>Channel</th>
<th>Programme</th>
<th>Start Time</th>
<th>Duration</th>
<th>Mode</th>
<th>Event/Series ID</th>
<th>Events</th>
</tr>
}
puts "<table class=borders>"
puts "<tr>"
#puts "<th>Slot</th>"
puts "<th colspan=2>Programme</th>"
puts "<th>Duration</th>"
puts "<th colspan=2>Channel</th>"
puts "<th>Date/Time</th>"
puts "<th>Mode</th>"
puts "<th>Event/Series ID</th>"
puts "</tr>"
foreach r $res {
set name [string range $r(szevtname) 1 end]
if {[string first "i7" $name] == 0} {
set name [string range $name 2 end]
set b "*"
} else {
set b ""
}
foreach event $events {
set name [$event name]
altrow
set rsvicon ""
set alta ""
switch $r(ersvtype) {
switch [$event get ersvtype] {
1 { set rsvicon "175_1_00_Reservation_Watch.png" }
2 { set rsvicon "175_1_00_Reservation_Watch.png" }
3 { set rsvicon "175_1_11_Reservation_Record.png" }
5 { set rsvicon "745_1_10_Video_2Live.png"; set alta "Wake-up" }
6 { set rsvicon "745_1_11_Video_1REC.png"; set alta "Sleep" }
7 { set rsvicon "345_6_08_ST_Ad_Hoc.png"
set alta "Auto Update" }
default { set alta "Unknown type $r(ersvtype)" }
5 { set rsvicon "745_1_10_Video_2Live.png" }
6 { set rsvicon "745_1_11_Video_1REC.png" }
7 { set rsvicon "345_6_08_ST_Ad_Hoc.png" }
}
if {$name == ""} { set name "-- $alta --" }
set series 0
if {$r(ucRecKind) == 4} {
if {[$event get ucRecKind] == 4} {
set RKIcon "175_1_11_Series_Record.png"
set series 1
} else {
switch $r(erepeat) {
switch [$event get erepeat] {
1 {set RKIcon "521_1_00_RP_Daily_C.png"}
2 {set RKIcon "521_1_00_RP_Weekly_C.png"}
3 {set RKIcon "521_1_00_RP_Weekdays_C.png"}
@@ -67,38 +49,90 @@ foreach r $res {
}
if {$rsvicon ne ""} {
set rsvicon "<img src='images/$rsvicon' height=15>
set rsvicon "<img src='images/$rsvicon' height=20>
}
if {$RKIcon ne ""} {
set RKIcon "<img src='images/$RKIcon' height=15>
set RKIcon "<img src='images/$RKIcon' height=20>
}
# puts "<td>{$r(ulslot)}</td>"
puts "<td>$b</td><td>$name</td>"
puts "<td>[clock format $r(nduration) -format %T]</td>"
puts "<td>$r(usLcn)</td>"
puts "<td>[string range $r(szSvcName) 1 end]</td>"
if { $r(nsttime) < [clock seconds] } {
puts "<td class=blood>"
puts "<td>[$event get ulslot]</td>"
if {[$event get usLcn] ne ""} {
puts "
<td>
<img src=\"/img/channels/[$event channel_name].png\"
width=50>
</td>
<td nowrap>[$event get usLcn]<br>
[$event channel_name]</td>
"
} else {
puts "<td>"
puts "<td colspan=2>&nbsp;<br><br></td>"
}
puts "[clock format $r(nsttime) -format {%c %Z}]</td>"
puts "<td>$rsvicon $RKIcon</td>"
puts "<td>"
set crid [join [lrange [split $r(szCRID) "/"] 1 end]]
puts "<td nowrap>$name</td>"
set s [$event get nsttime]
set d [$event get nduration]
set e $($s + $d)
set n [clock seconds]
if { $n > $e } {
puts "<td class=blood nowrap class=va>"
} else {
puts "<td nowrap class=va>"
}
puts "[clock format $s -format "%a %d %b %Y"]<br>
[clock format $s -format "%H:%M %Z"]"
if {$d > 0 && $n > $s && $n < $e} {
puts "<br>"
set perc [expr [expr $n - $s] * 100 / $d]
puts "<img class=va src=/images/745_1_11_Video_1REC.png>"
puts [progressbar $perc]
}
puts "</td>"
puts "<td>[clock format [$event get nduration] -format %T]</td>"
puts "<td nowrap>$rsvicon $RKIcon</td>"
puts "<td nowrap>"
set crid [join [lrange [split [$event get szCRID] /] 1 end]]
if {$crid != ""} {
puts -nonewline "<a href=/cgi-bin/epg_search.jim?"
if $series { puts -nonewline "s" }
puts "crid=/$crid>
<img border=0 src=/images/421_1_00_CH_Title_2R_Arrow.png
height=14>
$r(szCRID)"
[$event get szCRID]"
puts "</a>"
}
puts "</td>"
puts "<td nowrap>"
set flag 0
foreach ev [split [$event get szEventToRecord] "|"] {
if {$ev eq ""} { continue }
set ev [string range $ev 1 end]
if {$flag} { puts "<br>" }
incr flag
set crid [join [lrange [split $ev /] 1 end]]
puts -nonewline "<a href=/cgi-bin/epg_search.jim?"
puts "crid=/$crid>
<img border=0 src=/images/421_1_00_CH_Title_2R_Arrow.png
height=14>
$ev"
puts "</a>"
}
puts "</td>"
puts "</tr>"
}
puts "</table>"
puts "<font class=footnote>Click on the CRID to view episodes.</font>"
$db close
puts {
<button onclick="window.location='/backup.shtml';">
Backup/Restore Scheduled Recordings/Events.
</button>
}

View File

@@ -1,35 +0,0 @@
#!/mod/bin/jimsh
set ::env(PATH) "/mod/bin/busybox:/mod/bin:/bin"
set pid [exec pgrep humaxtv]
if {[catch {set line [exec lsof -p $pid | grep Video | fgrep .ts]} ]} {
exit
}
regsub -all -- {[[:space:]]+} $line " " line
set fields [split $line " "]
set size [lindex $fields 6]
sleep 2
set line [exec lsof -p $pid | grep Video | fgrep .ts]
regsub -all -- {[[:space:]]+} $line " " line
set fields [split $line " "]
set size2 [lindex $fields 6]
if { $size2 > $size } {
set mode "Recording"
set icon "745_1_11_Video_1REC.png"
} else {
set mode "Watching"
set icon "745_1_10_Video_2Live.png"
}
set name [lindex [split $line "/"] end]
puts "<div class=shadowbox><div>"
puts "<img src=/images/$icon>$mode $name"
puts "</div></div>"

9
var/mongoose/lib/plugin Normal file
View File

@@ -0,0 +1,9 @@
proc eval_plugins {hook} {
foreach plugin [glob /mod/var/mongoose/plugin/*] {
if {[file isfile "$plugin/$hook.hook"]} {
uplevel source "$plugin/$hook.hook"
}
}
}

136
var/mongoose/lib/rsv.class Executable file
View File

@@ -0,0 +1,136 @@
source /mod/var/mongoose/lib/setup
if {![exists -proc class ]} { package require oo }
if {![exists -proc sqlite3.open ]} { package require sqlite3 }
if {![exists -proc settings ]} { require settings.class }
set rsvdb [sqlite3.open /var/lib/humaxtv/rsv.db]
$rsvdb query {attach database '/var/lib/humaxtv/channel.db' as channel}
class rsv {
ulslot 0
ersvtype 0
hsvc 0
nsttime 0
szsttime 0
nduration 0
erepeat 0
usevtid 0
szevtname {}
ulPreOffset 0
ulPostOffset 0
ulProgramId 0
ulSeriesId 0
ucVolume 0
ucInputMode 0
usChNum 0
ucRecKind 0
ucCRIDType 0
szCRID {}
szFPBRecPath {}
szRecordedProgCrid {}
szEventToRecord {}
aulEventToRecordInfo {}
bRecomRsv 0
usLastRecordedEvtId 0
eReady 0
szSvcName {}
usLcn 0
sort 0
}
rsv method name {} {
set name [string range $szevtname 1 end]
if {[string first "i7" $name] == 0} {
set name [string range $name 2 end]
}
if {$name == ""} {
switch $ersvtype {
5 { set name "--- Wake-up ---" }
6 { set name "--- Sleep ---" }
7 { set name "--- Auto Update ---" }
default { set name "--- Unknown event type $ersvtype ---" }
}
}
return $name
}
rsv method channel_name {} {
return [string range $szSvcName 1 end]
}
rsv method fix_hsvc {} {
global rsvdb
set _hsvc [$rsvdb query "
select hSvc
from channel.TBL_SVC
where szSvcName = '$szSvcName'
or szSvcname = '\025$szSvcName'
limit 1
"]
if {[llength $_hsvc] == 1} {
set hsvc [lindex [lindex $_hsvc 0] 1]
} else {
set hsvc 0
}
return $hsvc
}
rsv method insert {} {
global rsvdb
if {!$ulslot} {
set slot [
$rsvdb query {select max(ulslot) FROM TBL_RESERVATION}]
set slot [expr 1 + [lindex [lindex $slot 0] 1]]
set ulslot $slot
}
set fields [lsort [$self vars]]
foreach field {aulEventToRecordInfo szSvcName usLcn sort} {
set df [lsearch $fields $field]
set fields [lreplace $fields $df $df]
}
set vals {}
foreach field $fields {
lappend vals "'[$self get $field]'"
}
set query "insert into TBL_RESERVATION("
append query [join $fields ","]
append query ") values("
append query [join $vals ","]
append query ");"
$rsvdb query $query
}
proc {rsv list} {} {
catch { $::rsvdb query {.mode tcl} }
set res [$::rsvdb query {
select tbl_reservation.*,
channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn,
case when ersvtype > 3 then 1 else 0 end as sort
from tbl_reservation
left join channel.TBL_SVC
on main.TBL_RESERVATION.hSvc = channel.TBL_SVC.hSvc
order by sort, nsttime
}]
set records {}
foreach rec $res {
lappend records [rsv new $rec]
}
return $records
}
proc {rsv cleanup} {} {
catch {$::rsvdb close}
}

View File

@@ -1,8 +1,11 @@
if {![exists -proc require]} {
proc require {args} {
proc require {args} {{done {}}} {
foreach file $args {
uplevel source "/mod/var/mongoose/lib/$file"
if {$file ni $done} {
uplevel source "/mod/var/mongoose/lib/$file"
lappend $done $file
}
}
}

View File

@@ -45,14 +45,36 @@ ts method flag {f} {
ts method unlock {} {
set cmd [list /mod/bin/hmt -lock $file]
#puts "CMD: $cmd"
exec {*}$cmd
return 1
}
ts method lock {} {
set cmd [list /mod/bin/hmt +lock $file]
#puts "CMD: $cmd"
exec {*}$cmd
return 1
}
ts method unenc {} {
set cmd [list /mod/bin/hmt -protect $file]
exec {*}$cmd
return 1
}
ts method enc {} {
set cmd [list /mod/bin/hmt +protect $file]
exec {*}$cmd
return 1
}
ts method set_new {} {
set cmd [list /mod/bin/hmt +new $file]
exec {*}$cmd
return 1
}
ts method set_watched {} {
set cmd [list /mod/bin/hmt -new $file]
exec {*}$cmd
return 1
}