From 6e06f3875a5f97876bc5eefe69501141941a9324 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Thu, 18 Oct 2012 19:37:39 +0000 Subject: [PATCH] fix db.jim git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1170 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 2 +- var/mongoose/cgi-bin/db.jim | 89 +++++++++++++++++++++++++++------ var/mongoose/cgi-bin/epg/db.jim | 23 +++++++++ 3 files changed, 97 insertions(+), 17 deletions(-) create mode 100755 var/mongoose/cgi-bin/epg/db.jim diff --git a/CONTROL/control b/CONTROL/control index 18fb855b..2ea5327a 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: webif Priority: optional Section: web -Version: 0.9.14-1 +Version: 0.9.14-2 Architecture: mipsel Maintainer: af123@hummypkg.org.uk Depends: webif-channelicons(>=1.0.3),mongoose(>=3.0-7),jim(>=0.73-1),jim-oo,jim-sqlite3(>=0.73),jim-cgi(>=0.5),service-control(>=1.2),busybox(>=1.19.3-1),lsof,epg(>=1.0.9),hmt(>=1.1.6),ssmtp,anacron,trm,openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.1.2) diff --git a/var/mongoose/cgi-bin/db.jim b/var/mongoose/cgi-bin/db.jim index 4a112ad6..e64909a1 100755 --- a/var/mongoose/cgi-bin/db.jim +++ b/var/mongoose/cgi-bin/db.jim @@ -1,23 +1,80 @@ -#!/bin/sh +#!/mod/bin/jimsh -PATH=$PATH:/mod/bin export PATH - -echo "Content-Type: text/plain" -echo "" +package require cgi +package require sqlite3 +source /mod/webif/lib/setup +require altrow -[ -n "$QUERY_STRING" ] && data="${QUERY_STRING##*=}" || data=epg +puts "Content-Type: text/html" +puts "" -case $data in - channels) - sqlite3 -header -batch -separator ' ' \ - /var/lib/humaxtv/channel.db ' - select * from TBL_SVC; - ' - ;; +set databases [glob /var/lib/humaxtv/*.db] +lappend databases "/mnt/hd2/dms_cds.db" +header - *) /mod/bin/epg -p dump ;; -esac +cgi_input +#cgi_dump -exit 0 +set ftab [cgi_get tab] +set fdb [cgi_get db] + +if {$fdb != 0} { + puts "

Remove filters

" +} + +proc db_info {db_file} { + global _cgi fdb ftab + + if {$fdb != 0 && [file tail $db_file] ne $fdb} { return } + 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 + }] + + puts "

+ $db_file

" + + foreach table $tables { + set table [lindex $table 1] + if {$ftab != 0 && $ftab ne $table} { continue } + set columns [$db query "pragma table_info($table)"] + set datas [$db query "SELECT * FROM $table order by 1"] + + puts "

$table

" + puts "" + puts " " + foreach column $columns { + puts " " + } + puts " " + foreach data $datas { + altrow + + for {set i 1} {$i < [llength $data]} {incr i 2} { + puts " " + } + puts " " + } + puts "
[lindex $column 3]
[lindex $data $i]
" + } + + $db close +} + +if {$fdb == 0} { + puts "Please choose database to view:" +} else { + foreach db $databases { db_info $db } +} + +footer diff --git a/var/mongoose/cgi-bin/epg/db.jim b/var/mongoose/cgi-bin/epg/db.jim new file mode 100755 index 00000000..4a112ad6 --- /dev/null +++ b/var/mongoose/cgi-bin/epg/db.jim @@ -0,0 +1,23 @@ +#!/bin/sh + +PATH=$PATH:/mod/bin export PATH + +echo "Content-Type: text/plain" +echo "" + +[ -n "$QUERY_STRING" ] && data="${QUERY_STRING##*=}" || data=epg + +case $data in + channels) + sqlite3 -header -batch -separator ' ' \ + /var/lib/humaxtv/channel.db ' + select * from TBL_SVC; + ' + ;; + + + *) /mod/bin/epg -p dump ;; +esac + +exit 0 +