From 4f900f47b46e80321bf4df602992f9e4d403bb49 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Sat, 13 Aug 2011 00:18:12 +0000 Subject: [PATCH] download decrypted versions of files git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@284 2a923420-c742-0410-a762-8d5b09965624 --- var/mongoose/cgi-bin/browse/browse.js | 3 +- var/mongoose/cgi-bin/browse/download.jim | 48 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 var/mongoose/cgi-bin/browse/download.jim diff --git a/var/mongoose/cgi-bin/browse/browse.js b/var/mongoose/cgi-bin/browse/browse.js index e0c0461..6ee4995 100755 --- a/var/mongoose/cgi-bin/browse/browse.js +++ b/var/mongoose/cgi-bin/browse/browse.js @@ -203,7 +203,8 @@ var menuclick = function(action, el, pos) break; case 'download': - window.location.href = file; + window.location.href = '/cgi-bin/browse/download.jim?file=' + + encodeURIComponent(file); break; default: diff --git a/var/mongoose/cgi-bin/browse/download.jim b/var/mongoose/cgi-bin/browse/download.jim new file mode 100755 index 0000000..177f004 --- /dev/null +++ b/var/mongoose/cgi-bin/browse/download.jim @@ -0,0 +1,48 @@ +#!/mod/bin/jimsh + +package require cgi +package require sqlite3 +source /mod/var/mongoose/lib/setup +require ts.class + +cgi_input +#cgi_dump + +set file [dict get $_cgi file] +set rfile [file normalize $file] +set ts [ts fetch $file] + +set dmsfile /mnt/hd2/dms_cds.db + +set url $file +set mime "video/ts" +if {[file exists $dmsfile]} { + set db [sqlite3.open /mnt/hd2/dms_cds.db] + set muri [$db query " + select tblresource.mimetype, contenturi + from tblresource join tblmedia using (mediaid) + where localurl = '$rfile' + "] + if {$muri != ""} { + set rec [lindex $muri 0] + set xuri [lindex $rec 3] + set mime [lindex $rec 1] + set url "http://$env(HTTP_HOST):9000/web/$xuri" + } +} + +puts "Content-Type: text/plain" +puts "Refresh: 0; url=$url" +puts "Content-length: 0" +puts "" + +#puts "Pragma: public" +#puts "Expires: 0" +#puts "Cache-Control: must-revalidate, post-check=0, pre-check=0" +#puts "Content-Type: application/force-download" +#puts "Content-Type: application/download" +#puts "Content-Type: $mime" +#puts "Content-Disposition: attachment; filename=\"[file tail $file]\"" +#puts "Content-Transfer-Encoding: binary" +#puts "Content-Length: [file size $rfile]" +