]> bicyclesonthemoon.info Git - ott/bsta/blobdiff - viewer.1.pl
move error pages out to common library
[ott/bsta] / viewer.1.pl
index c7d74d9d4edb1401940671026c30cab5fe9a085f..69c0abaad567a6489ed6216ec405787783e3967c 100644 (file)
@@ -28,6 +28,7 @@ use Encode ('encode', 'decode');
 ###PERL_LIB: use lib /botm/lib/bsta
 use botm_common (
        'HTTP_STATUS',
+       'fail_method', 'fail_content_type', 'redirect',
        'read_header_env',
        'url_query_decode',
        'join_path',
@@ -37,7 +38,6 @@ use botm_common (
 );
 use bsta_lib (
        'STATE', 'TEXT_MODE', 'INTF_STATE',
-       'fail_method', 'fail_content_type', 'redirect',
        'get_remote_addr', 'get_frame', 'get_password',
        'merge_settings',
        'print_viewer_page',
@@ -52,6 +52,7 @@ use bsta_lib (
 ###PERL_PATH_SEPARATOR:     PATH_SEPARATOR     = /
 
 ###PERL_CGI_PATH:           CGI_PATH           = /bsta/
+###PERL_CGI_GOTO_PATH:      CGI_GOTO_PATH      = /bsta/g
 ###PERL_CGI_VIEWER_PATH:    CGI_VIEWER_PATH    = /bsta/v
 
 ###PERL_DATA_STATE_PATH:    DATA_STATE_PATH    = /botm/data/bsta/state
@@ -121,6 +122,7 @@ if ($method eq 'POST') {
                exit fail_content_type($method, $http{'content-type'});
        }
 }
+
 $no_cgi = (scalar (keys %cgi) == 0);
 
 $IP = get_remote_addr();
@@ -136,6 +138,22 @@ if ($frame >= 0) {
 
 $password_ok = ($password eq $settings{'password'});
 
+if (
+       (defined $cgi{'f'}) &&
+       ($cgi{'f'} eq '') &&
+       ($cgi{'g'} ne '')
+) { # GOTO with no value
+       my $goto_url = CGI_GOTO_PATH();
+       if ($password_ok) {
+               $goto_url = merge_url(
+                       {'path' => $goto_url},
+                       {'query' => {'p' => $password}}
+               );
+       }
+       exit redirect($method, $goto_url, HTTP_STATUS->{'see_other'});
+}
+
+
 # state & activation logic
 if (open_encoded($fh, "+<:encoding(UTF-8)", DATA_STATE_PATH())) {
        if (flock($fh, 2)) {