#!/mod/bin/jimsh package require cgi source /mod/var/mongoose/lib/setup require settings.class require plugin puts "Content-Type: text/html" puts "" cgi_input #cgi_dump 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] # 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_str_update epg_style $epg_style "EPG Type" if {[dict exists $_cgi pkgdevoff] && ![dict exists $_cgi pkgdev]} { set _cgi(pkgdev) 0 } handle_int_update pkgdev $pkgdev "Development Package Display" 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 { } puts { } puts "