#!/mod/bin/jimsh package require cgi source /mod/webif/lib/setup require settings.class plugin system.class httpheader if {[cgi_get act] eq "https"} { set val [cgi_get val off] if {$val in {0 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 } if {[cgi_get act] eq "xtelnet"} { set val [cgi_get val off] if {$val in {0 off}} { file delete /mod/boot/xtelnet puts "Telnet server expert mode will be disabled after next reboot." } else { exec /mod/bin/busybox/touch /mod/boot/xtelnet puts "Telnet server expert mode will be enabled after next reboot." } exit } set settings [settings new] set hostname [$settings hostname] set smtp_server [$settings smtp_server] set channel_group [$settings channel_group] set epg_style [$settings epg_style] set pkgdev [$settings pkgdev] set notoolbar [$settings notoolbar] set nomobile [$settings nomobile] set nohelplinks [$settings nohelplinks] set xepghours [$settings xepghours] if {$xepghours == 0} { set xepghours 4 } set genrededup [$settings genrededup] set autolog [$settings autolog] # Handle updates if {![dict exists $env REQUEST_URI]} { set env(REQUEST_URI) "" } proc _handle_update {class var old text} { global _cgi global settings if {[dict exists $_cgi $var]} { set new [string trim [dict get $_cgi $var]] if {$new == $old} { puts "$text unchanged." } elseif [string is $class -strict $new] { $settings $var $new puts "$text updated." } else { puts "Invalid value for $var." } exit } } proc handle_int_update {var old {text "Value"}} { _handle_update digit $var $old $text } proc handle_str_update {var old {text "Value"}} { _handle_update alnum $var $old $text } handle_str_update hostname $hostname Hostname _handle_update ascii smtp_server $smtp_server "SMTP Server" handle_int_update channel_group $channel_group "Channel Group" handle_int_update xepghours $xepghours "Grid EPG Hours" handle_str_update epg_style $epg_style "EPG Type" handle_int_update pkgdev $pkgdev "Development Package Display" handle_int_update notoolbar $notoolbar "Disable toolbar" handle_int_update nomobile $nomobile "Disable mobile link" handle_int_update nohelplinks $nohelplinks "Disable help links" handle_int_update genrededup $genrededup "Genre search dedup" handle_int_update autolog $autolog "Auto-processing log level" set acluser [cgi_get acluser "-"] set aclpass [cgi_get aclpass "-"] set aclpassc [cgi_get aclpassc "-"] if {$acluser ne "-" && $aclpass ne "-"} { if {![string length $acluser]} { puts "No username provided." exit } if {$aclpass ne $aclpassc} { puts "Passwords do not match." exit } if {[string length $aclpass] < 4} { puts "Password is too short (< 4 characters)" exit } puts [$settings addacluser $acluser $aclpass] exit } set aclact [cgi_get aclact "-"] if {$aclact ne "-" && $acluser ne "-"} { switch $aclact { "del" { puts [$settings delacluser $acluser] } } exit } header puts {
} proc setting_toggle {name attr checked {invert 0} {val 0}} { puts -nonewline " $name
" } puts "

General Settings

General Settings " puts " " setting_toggle "HTTPS web server?" "https" \ [file exists /mod/etc/mongoose.cert] 0 1 setting_toggle "Slide-down toolbar?" "notoolbar" $(!$notoolbar) 1 setting_toggle "Mobile link on main page?" "nomobile" $(!$nomobile) 1 setting_toggle "Help links on main page?" "nohelplinks" $(!$nohelplinks) 1 puts -nonewline " " puts "
Hostname
Auto-processing log level

EPG Settings

EPG Settings " puts " " puts " " puts " " setting_toggle "De-duplicate genre search results?" genrededup $genrededup puts "
Default Now/Next style
Channel Group for EPG
Grid-style EPG Hours
" #puts " #
# Email Settings # #" # #puts " # # # # # # #" # #puts " #
SMTP Server for outbound email # # # #
#
#
#

#" puts "

Web Interface User Access Control

Web Interface User Access Control " set aclusers [$settings aclusers] if {[llength $aclusers]} { puts "" foreach user [$settings aclusers] { lassign $user user puts "" puts "" } puts "" puts "" } else { puts "" } puts "" puts "
Existing Users
$userNew password:
" puts "Again: " puts "
" puts "" puts "
 
 
Add a user to enable authentication.
Add New User
New User:
Password:
Password (confirm):
" puts { } puts -nonewline "

Advanced Settings

Advanced Settings " setting_toggle "Show development and advanced packages?" "pkgdev" $pkgdev if {[system modversion 1] >= 214} { setting_toggle "Expert mode telnet server?" "xtelnet" \ [file exists /mod/boot/xtelnet] 0 1 } puts "
" set hook settings foreach plugin [glob -nocomplain /mod/webif/plugin/*] { if {[file isfile "$plugin/$hook.hook"]} { puts "

Settings for [file tail $plugin] package

" puts "
" catch {source "$plugin/$hook.hook"} puts "
" } } puts "
" footer