###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';
binmode STDERR, ':encoding(console_out)';
decode_argv();
-my %options = {};
+my %options = ();
Getopt::Long::Configure('bundling');
GetOptions (
'mirror-url|R=s' => \$options{ 'mirror-url'},
'help|h' => \$options{ 'help'}
+ # TODO: useragent
);
if ($options{'help'} ne '') {
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);
my @arg = (
WGET,
- '-q'
+ '-q',
+ '-t', WGET_RETRIES,
+ '--connect-timeout=', WGET_TIMEOUT,
+ '-U', WGET_USERAGENT
);
if ($options->{'with_header'}) {
push(@arg, '--no-cookies');
}
+ if ($options->{'referer'} ne '') {
+ push(@arg, '--referer=', $options->{'referer'});
+ }
+
if ($options->{'postdata_path'} ne '') {
if (defined $postdata) {
write_postdata_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))