From 8ec03f2636c72007f8f6acd747370cbf3708e9b7 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Thu, 19 Jan 2012 21:15:52 +0000 Subject: [PATCH] add SSL server support git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@679 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 6 ++-- var/mongoose/cgi-bin/settings.jim | 43 ++++++++++++----------- var/mongoose/cgi-bin/settings.js | 58 +++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 23 deletions(-) create mode 100644 var/mongoose/cgi-bin/settings.js diff --git a/CONTROL/control b/CONTROL/control index 2427421..6c8ba47 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,9 +1,9 @@ Package: webif Priority: optional Section: web -Version: 0.8.12-3 +Version: 0.8.13 Architecture: mipsel Maintainer: af123@hummypkg.org.uk -Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.5),jim-oo,jim-pack,service-control,busybox(>=1.19.3-1),lsof,epg(>=1.0.8),hmt(>=1.1.4),ssmtp,anacron,trm -Suggests: ffmpeg,webif-iphone,nicesplice,id3v2 +Depends: mongoose(>=3.0-7),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.5),jim-oo,jim-pack,service-control,busybox(>=1.19.3-1),lsof,epg(>=1.0.8),hmt(>=1.1.4),ssmtp,anacron,trm,openssl-command,nicesplice,id3v2 +Suggests: ffmpeg,webif-iphone Description: An evolving web interface for the Humax. diff --git a/var/mongoose/cgi-bin/settings.jim b/var/mongoose/cgi-bin/settings.jim index a5171b7..f500323 100755 --- a/var/mongoose/cgi-bin/settings.jim +++ b/var/mongoose/cgi-bin/settings.jim @@ -11,6 +11,17 @@ puts "" cgi_input #cgi_dump +if {[cgi_get act] eq "https"} { + if {[cgi_get val off] eq "off"} { + file delete /mod/etc/mongoose.cert + puts "HTTPS Server will be disabled after next reboot." + } else { + exec /mod/sbin/mongoose_mkcert + puts "HTTPS Server will be enabled after next reboot." + } + exit +} + set settings [settings new] set hostname [$settings hostname] @@ -89,6 +100,7 @@ if {$aclact ne "-" && $acluser ne "-"} { header puts { + @@ -96,26 +108,6 @@ puts { } -puts { - -} - puts "
@@ -140,6 +132,17 @@ puts " " +puts -nonewline " + + HTTPS web server? + +
+ + +" + puts "
diff --git a/var/mongoose/cgi-bin/settings.js b/var/mongoose/cgi-bin/settings.js new file mode 100644 index 0000000..24e54eb --- /dev/null +++ b/var/mongoose/cgi-bin/settings.js @@ -0,0 +1,58 @@ +(function($) +{ + $.fn.enable = function() + { + return this.each(function() { + $(this) + .removeClass('ui-state-disabled') + .removeProp('disabled'); + }); + }; + + $.fn.disable = function() + { + return this.each(function() { + $(this) + .addClass('ui-state-disabled') + .prop('disabled', true); + }); + }; +})(jQuery); + +$(document).ready(function () { + $(":submit").button(); + $(":checkbox").iphoneStyle(); + $('form.auto').each(function(i, el) { + var id = $(this).attr('id'); + var output = '#' + id + '_output' + $(this).ajaxForm({ + target: output, + success: function() { + $(output).css('font-style', 'italic'); + $(output).show('slow'); + $(output).delay(2000).fadeOut('slow'); + } + }); + }); + + $('#https_toggle').change(function() { + var arg = 'off'; + if ($(this).attr('checked')) + arg = 'on'; + + $(this).disable(); + + $('#https_output') + .empty() + .html('Please Wait...') + .show('slow') + .load('/cgi-bin/settings.jim?act=https&val=' + arg, + function() { + $('#https_toggle').enable(); + $('#https_output') + .css('font-style', 'italic') + .delay(2000).fadeOut('slow'); + }); + }); +}); +