###PERL_LIB: use lib /botm/lib/bsta
use botm_common (
'HTTP_STATUS',
+ 'fail_method', 'fail_content_type',
'http_header_status', 'http_header_allow',
'merge_url',
'read_header_env',
use bsta_lib (
'STATE', 'INTF_STATE',
'get_id',
- 'fail_method', 'fail_content_type',
'print_html_start', 'print_html_end',
'print_html_head_start', 'print_html_head_end',
'print_html_body_start', 'print_html_body_end',
###PERL_LIB: use lib /botm/lib/bsta
use botm_common (
'HTTP_STATUS',
+ 'fail_method', 'fail_content_type', 'fail_attachment', 'fail_500',
+ 'redirect',
'read_header_env',
'url_query_decode',
'join_path',
'STATE',
'merge_settings',
'get_id', 'get_password',
- 'fail_method', 'fail_content_type', 'fail_attachment', 'fail_500',
- 'redirect',
'read_settings', 'read_state', 'read_attachment'
);
###PERL_LIB: use lib /botm/lib/bsta
use botm_common (
'HTTP_STATUS',
+ 'fail_method', 'fail_content_type',
'read_header_env',
'url_query_decode',
'merge_url',
);
use bsta_lib (
'STATE',
- 'fail_method', 'fail_content_type',
'get_frame', 'get_password',
'merge_settings',
'eval_bb', 'bb_to_bbcode',
-Subproject commit f0a6abfdebbbfd1b578d7339df1627f1afacd2be
+Subproject commit 599a7e9a41f68c89f64cd982db730167d2acf28e
our @EXPORT = ();
our @EXPORT_OK = (
'STATE', 'TEXT_MODE', 'INTF_STATE', 'CHAT_STATE', 'CHAT_ACTION',
- 'failpage',
- 'fail_method', 'fail_content_type', 'fail_open_file', 'fail_attachment', 'fail_500',
- 'redirect',
'get_remote_addr', 'get_id', 'get_frame', 'get_password',
'merge_settings',
'print_html_start', 'print_html_end',
};
-# Function to return an error page
-# arguments: 1 - header fields, 2 - page title, 3 - error message, 4 method
-sub failpage {
- (my $header, my $title, my $message, my $method, my $hyperlink) = @_;
-
- if (ref($header)) {
- foreach my $header_name (keys %$header) {
- print http_header_line($header_name, $header->{$header_name});
- }
- }
- elsif($header ne '') {
- print $header;
- }
- if($method eq 'HEAD') {
- print "\n";
- return;
- }
- my $_title = html_entity_encode_dec($title , 1);
- my $_message = html_entity_encode_dec($message , 1);
- my $_hyperlink = html_entity_encode_dec($hyperlink, 1);
-
- print "Content-type: text/html; charset=UTF-8\n\n";
-
- print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">'."\n";
- print ' <html lang="en">'."\n";
- print ' <head>'."\n";
- print ' <meta http-equiv="Content-type" content="text/html; charset=UTF-8">'."\n";
- if ($title ne '') {
- print ' <title>'.$_title.'</title>'."\n";
- }
- print ' </head>'."\n";
- print ' <body>'."\n";
- if ($title ne '') {
- print ' <h1>'.$_title.'</h1>'."\n";
- }
- if (($message ne '') || ($hyperlink ne '')) {
- print " <p>\n";
- if ($message ne '') {
- print ' '.$_message.($hyperlink ne '' ? '<br>' : '')."\n";
- }
- if ($hyperlink ne '') {
- print ' <a href="'.$_hyperlink.'">'.$_hyperlink."</a>\n";
- }
- print " </p>\n";
- }
- print ' </body>'."\n";
- print '</html>'."\n";
-}
-
-sub fail_method {
- (my $method, my $allowed) = @_;
-
- my $status = http_status(HTTP_STATUS->{'method_not_allowed'});
- my $header =
- http_header_line('status', $status) .
- http_header_allow($allowed);
-
- return failpage(
- $header,
- $status,
- "The interface does not support the $method method.",
- $method
- );
-}
-
-sub fail_content_type
-{
- (my $method, my $content_type) = @_;
-
- my $status = http_status(HTTP_STATUS->{'unsupported_media_type'});
- my $header = http_header_line('status', $status);
-
- return failpage(
- $header,
- $status,
- "Unsupported Content-type: $content_type.",
- $method
- );
-}
-
-sub fail_open_file
-{
- (my $method, my $type, my $path) = @_;
-
- my $status = http_status(HTTP_STATUS->{'not_found'});
- my $header = http_header_line('status', $status);
-
- return failpage(
- $header,
- $status,
- "Can't open ".
- ($type ne '' ? $type : 'file').
- ($path ne '' ? ': "'.$path.'"' : '').
- '.',
- $method
- );
-}
-
-sub fail_attachment
-{
- (my $method, my $ID) = @_;
-
- my $status = http_status(HTTP_STATUS->{'not_found'});
- my $header = http_header_line('status', $status);
-
- return failpage(
- $header,
- $status,
- "Attachment $ID not found.",
- $method
- );
-}
-
-sub fail_500
-{
- (my $method, my $text) = @_;
-
- my $status = http_status(HTTP_STATUS->{'internal_server_error'});
- my $header = http_header_line('status', $status);
-
- return failpage(
- $header,
- $status,
- $text,
- $method
- );
-}
-
-sub redirect
-{
- (my $method, my $uri, my $code) = @_;
- my $header;
- my $status;
- if ($code eq '') {
- $code = HTTP_STATUS->{'found'};
- }
- # https://insanecoding.blogspot.com/2014/02/http-308-incompetence-expected.html
- # 301 Moved Permanently
- # 302 Found
- # 303 See Other
- # 307 Temporary Redirect
- # 308 Permanent Redirect
- $status = http_status($code);
- $header = http_header_line('status', $status);
- $header .= http_header_location($uri);
-
- return failpage(
- $header,
- $status,
- '',
- $method,
- $uri
- );
-}
-
# function to obtain address of remote agent
sub get_remote_addr {
###PERL_LIB: use lib /botm/lib/bsta
use botm_common (
'HTTP_STATUS',
+ 'fail_method', 'fail_content_type',
'read_header_env',
'url_query_decode', 'url_query_encode',
'merge_url',
);
use bsta_lib (
'STATE', 'CHAT_STATE', 'CHAT_ACTION',
- 'fail_method', 'fail_content_type',
'get_remote_addr', 'get_id', 'get_password',
'print_html_start', 'print_html_end',
'print_html_head_start', 'print_html_head_end',
-Subproject commit fc9affec336a16cde93b2675a836bdd01d1c2210
+Subproject commit 352e86fd3d4afab9adb6c340d236f501f3d91560
###PERL_LIB: use lib /botm/lib/bsta
use botm_common (
'HTTP_STATUS',
+ 'fail_method', 'fail_content_type', 'fail_open_file', 'fail_500', 'redirect',
'read_header_env',
'url_query_decode',
'join_path',
);
use bsta_lib (
'STATE', 'INTF_STATE',
- 'fail_method', 'fail_content_type', 'fail_open_file', 'fail_500', 'redirect',
'get_frame', 'get_password',
'merge_settings',
'get_frame_file',
###PERL_LIB: use lib /botm/lib/bsta
use botm_common (
+ 'fail_method', 'fail_content_type',
+ 'redirect',
'read_header_env',
'url_query_decode',
'_x_encoded'
);
use bsta_lib (
'STATE',
- 'fail_method', 'fail_content_type',
- 'redirect',
'get_password',
'print_goto',
'merge_settings',
###PERL_LIB: use lib /botm/lib/bsta
use botm_common (
'HTTP_STATUS',
+ 'fail_method', 'fail_content_type',
'http_header_status',
'read_header_env',
'write_data_file',
);
use bsta_lib (
'STATE',
- 'fail_method', 'fail_content_type',
'get_password',
'merge_settings',
'get_page_file', 'get_frame_file',
###PERL_LIB: use lib /botm/lib/bsta
use botm_common (
'HTTP_STATUS',
+ 'fail_method', 'fail_content_type',
+ 'redirect',
'read_header_env', 'url_query_decode',
'write_data_file',
'html_entity_encode_dec',
use bsta_lib (
'TEXT_MODE', 'STATE',
'get_password',
- 'fail_method', 'fail_content_type',
- 'redirect',
'print_html_start', 'print_html_end',
'print_html_head_start', 'print_html_head_end',
'print_html_body_start', 'print_html_body_end',
'read_settings', 'read_state',
'read_words', 'write_words',
'read_words_list', 'write_words_list'
-
);
###PERL_PATH_SEPARATOR: PATH_SEPARATOR = /
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-_version: 1.2.8
+_version: 1.2.9
_SHEBANG: #!$0
###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',
);
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',