From: b Date: Fri, 7 Jul 2023 23:53:31 +0000 (+0000) Subject: wget-related extended not tested X-Git-Tag: v1.0.0~1 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=1f775a11cead854feac3705377bbd0b977154faa;p=ott%2Fpost wget-related extended not tested --- diff --git a/sendpost.1.pl b/sendpost.1.pl index c2a6451..4ae5fd9 100644 --- a/sendpost.1.pl +++ b/sendpost.1.pl @@ -36,6 +36,8 @@ use botm_common ( ###PERL_DEFAULT_SUBJECT: use constant DEFAULT_SUBJECT => 'Re: 1190: "Time"'; ###PERL_DEFAULT_USERNAME: use constant DEFAULT_USERNAME => 'username'; +###PERL_WGET_USERAGENT: use constant WGET_USERAGENT => "post tool (http://bicyclesonthemoon.info/git-projects/?p=ott/post)"; + ###PERL_WGET: use constant WGET => '/usr/bin/wget'; ###PERL_TMP_PATH: use constant TMP_PATH => '/botm/tmp/post'; @@ -74,7 +76,7 @@ binmode STDOUT, ':encoding(console_out)'; binmode STDERR, ':encoding(console_out)'; decode_argv(); -my %options = {}; +my %options = (); Getopt::Long::Configure('bundling'); GetOptions ( @@ -102,6 +104,7 @@ GetOptions ( 'mirror-url|R=s' => \$options{ 'mirror-url'}, 'help|h' => \$options{ 'help'} + # TODO: useragent ); if ($options{'help'} ne '') { @@ -276,12 +279,45 @@ sub post_to_mirror { my %wget_options = ( 'with_header', 1, 'cookie_path', $cookie_path, - 'postdata_path', $postdata_path - ); - my %post_data = ( - 'uvwxyz', 'eół', - 'lel', 'lol' ); + my %post_data = (); + my %query_data = (); + + if ($cmd_options{'edit'} ne '') { + $query_data{'e'} = $cmd_options{'edit'}; + } + if (keys %query_data) { + my $query = join_url(\%query_data); + my %query_url = ('query' => $query); + $post_url = merge_url($post_url, \%query_url); + } + + wget($post_url, $tmp_path, \%wget_options,); + + $wget_options{'referer'} = $post_url; + $wget_options{'postdata_path'} = postdata_path; + + $post_data{'subject'} = $post->{'subject'}; + $post_data{'username'} = $post->{'username'}; + $post_data{'password'} = $post->{'password'}; + $post_data{'password2'} = ''; + $post_data{'message'} = $post->{'content'}; + unless ($post->{'bbcode'}) { + $post_data{'disable_bbcode'} = 'on'; + } + unless ($post->{'smilies'}) { + $post_data{'disable_smilies'} = 'on'; + } + unless ($post->{'urls'}) { + $post_data{'disable_magic_url'} = 'on'; + } + if ($post->{'signature'}) { + $post_data{'attach_sig'} = 'on'; + } + if ($post->{'notify'}) { + $post_data{'notify'} = 'on'; + } + $post_data{'post'} = 'Submit'; wget($post_url, $tmp_path, \%wget_options, \%post_data); @@ -294,7 +330,10 @@ sub wget { my @arg = ( WGET, - '-q' + '-q', + '-t', WGET_RETRIES, + '--connect-timeout=', WGET_TIMEOUT, + '-U', WGET_USERAGENT ); if ($options->{'with_header'}) { @@ -311,6 +350,10 @@ sub wget { push(@arg, '--no-cookies'); } + if ($options->{'referer'} ne '') { + push(@arg, '--referer=', $options->{'referer'}); + } + if ($options->{'postdata_path'} ne '') { if (defined $postdata) { write_postdata_file( diff --git a/settings-debug.txt b/settings-debug.txt index ce4b63a..c10ec4c 100644 --- a/settings-debug.txt +++ b/settings-debug.txt @@ -19,6 +19,9 @@ default_subject: Re: 1190: "Time" default_username: _ default_password: _ +wget_useragent: post tool (http://bicyclesonthemoon.info/git-projects/?p=ott/post) +wget_retries: 3 +wget_timeout: 60 cp: /usr/bin/cp chmod: /usr/bin/chmod diff --git a/settings-release.txt b/settings-release.txt index 3289226..97a6a39 100644 --- a/settings-release.txt +++ b/settings-release.txt @@ -19,6 +19,10 @@ default_subject: Re: 1190: "Time" default_username: _ default_password: _ +wget_useragent: post tool (http://bicyclesonthemoon.info/git-projects/?p=ott/post) +wget_retries: 3 +wget_timeout: 60 + cp: /usr/bin/cp chmod: /usr/bin/chmod diff --git a/settings.txt b/settings.txt index ebb76d2..a82e4cd 100644 --- a/settings.txt +++ b/settings.txt @@ -46,6 +46,10 @@ PERL_ENCODING_FILE = @_PERL_CONSTANT_STR( ENCODING_FILE , $encoding_file) PERL_MIRROR_URL = @_PERL_CONSTANT_STR( MIRROR_URL , $mirror_url) PERL_TMP_PATH = @_PERL_CONSTANT_STR( TMP_PATH , $tmp_path) +PERL_WGET_RETRIES = @_PERL_CONSTANT_STR( WGET_RETRIES , $wget_retries) +PERL_WGET_TIMEOUT = @_PERL_CONSTANT_STR( WGET_TIMEOUT , $wget_timeout) +PERL_WGET_USERAGENT = @_PERL_CONSTANT_STR( WGET_USERAGENT , $wget_useragent) + PERL_WGET = @_PERL_CONSTANT_STR( WGET , $wget) PERL_LIB = @_PERL_USE_2(lib, @_PERL_STR($lib_path))