]> bicyclesonthemoon.info Git - ott/mirror/commitdiff
now use stable version of post library
authorb <rowerynaksiezycu@gmail.com>
Sun, 3 Sep 2023 21:02:03 +0000 (21:02 +0000)
committerb <rowerynaksiezycu@gmail.com>
Sun, 3 Sep 2023 21:02:03 +0000 (21:02 +0000)
fix.pl [new file with mode: 0644]
settings-release.txt

diff --git a/fix.pl b/fix.pl
new file mode 100644 (file)
index 0000000..5b0912d
--- /dev/null
+++ b/fix.pl
@@ -0,0 +1,217 @@
+# Copyright (C) 2023 Balthasar SzczepaƄski
+# bot2m.pl automatically generated from bot2m.1.pl
+
+# This file is part of OTT mirror.
+#
+# OTT mirror is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affreo General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# OTT mirror is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affreo General Public License for more details.
+# 
+# You should have received a copy of the GNU Affreo General Public License
+# along with OTT mirror. If not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+use utf8;
+use Encode::Locale ('decode_argv');
+use Encode ('encode', 'decode');
+
+use lib '/botm/lib/test-post';
+use botm_common (
+       'read_data_file', 'write_data_file',
+       'join_path', 'dir_path', 'make_temp_path',
+       'html_entity_decode',
+       'url_decode',
+       'merge_url',
+       'system_encoded'
+);
+use post_common (
+       'wget'
+);
+
+use constant MPOST_PATH => '/botm/data/ottmirror/mpost';
+# use constant BKUP_PATH => '!!!!!!!!!!!BKUPPPPP';
+use constant OWN_DOMAIN => '1190.bicyclesonthemoon.info';
+use constant WWW_IMG_PATH => '/botm/www/1190/ott/image';
+use constant IMG_URL => 'http://1190.bicyclesonthemoon.info/ott/image';
+use constant TMP_PATH => '/botm/tmp/ottmirror';
+use constant WAYBACK => 'http://web.archive.org/web/';
+use constant BIN_IMG_PATH => '/botm/bin/ottmirror/image';
+use constant MKDIR => '/usr/bin/mkdir';
+use constant MV => '/usr/bin/mv';
+use constant SENDPOST => '/botm/bin/post/sendpost';
+
+
+binmode STDIN,  ':encoding(console_in)';
+binmode STDOUT, ':encoding(console_out)';
+binmode STDERR, ':encoding(console_out)';
+decode_argv();
+
+my $dh;
+if (opendir $dh, encode('locale_fs', MPOST_PATH)) {
+       my @fl = readdir $dh;  # <-- encoding???
+       closedir $dh;
+       
+       foreach my $fn (@fl) {
+               if ($fn =~ /^[0-9]+$/) {
+                       my %post = read_data_file(join_path('/',MPOST_PATH,$fn), 'utf8');
+                       # my %bkup = read_data_file(join_path('/',BKUP_PATH,$fn), 'utf8');
+                       
+                       my $message = $post{'bb'};
+                       $message =~ s/<br\/>/\n/gs;
+                       $message = html_entity_decode($message);
+                       my $subject = url_decode($post{'subject'});
+                       my $password = url_decode($post{'password'});
+                       if ($subject eq $password) {
+                               $subject = ''
+                       }
+                       
+                       my $tmp_file = make_temp_path(TMP_PATH, 'bot2m.mpost.txt');
+                       
+                       my %new_post = ();
+                       $new_post{'content'} = $message;
+                       $new_post{'username'} = url_decode($post{'username'});
+                       $new_post{'password'}  = $password;
+                       if ($subject ne ''){
+                               $new_post{'subject'}  = $subject;
+                       }
+                       if ($post{'disable_bbcode'}) {
+                               $new_post{'bbcode'} = '0';
+                       }
+                       else {
+                               $new_post{'bbcode'} = '1';
+                       }
+                       if ($post{'disable_smilies'}) {
+                               $new_post{'smilies'} = '0';
+                       }
+                       else {
+                               $new_post{'smilies'} = '1';
+                       }
+                       if ($post{'disable_magic_url'}) {
+                               $new_post{'urls'} = '0';
+                       }
+                       else {
+                               $new_post{'urls'} = '1';
+                       }
+                       if ($post{'attach_sig'}) {
+                               $new_post{'signature'} = '1';
+                       }
+                       else {
+                               $new_post{'signature'} = '0';
+                       }
+                       if ($post{'notify'}) {
+                               $new_post{'notify'} = '1';
+                       }
+                       else {
+                               $new_post{'notify'} = '0';
+                       }
+                       write_data_file($tmp_file, 'utf8', 0, \%new_post);
+                       my $r = system_encoded(SENDPOST, (SENDPOST, '-v', '--mirror', '--edit=m'.$fn, $tmp_file));
+                       unlink $tmp_file;
+               }
+       }
+}
+
+sub save_img {
+       (my $url) = @_;
+       if ($url !~ /^https?:\/\//) {
+               return $url;
+       }
+       if ($url =~ ("^https?://".OWN_DOMAIN)) {
+               return $url;
+       }
+       
+       my $escaped = img_save_url($url);
+       my $path = join_path('/',WWW_IMG_PATH, $escaped);
+       my $new_url = merge_url(IMG_URL, $escaped);
+       
+       my $findpath = encode('locale_fs', $path.'.*');
+       if (my @gfp = glob($findpath)) {
+               print "Already saved $url\n";
+               return $new_url;
+       }
+       else {
+               print "not yet saved $findpath\n";
+               my $tmp_path = make_temp_path(TMP_PATH, 'bot2m.img.tmp');
+               my %wget_options = ('no-check-certificate' => 1);
+               my $r;
+               my $ext = '';
+               print "GET $url\n";
+               $r = wget($url, $tmp_path, \%wget_options);
+               if ($r != 0) {
+                       my $wayback_url =  join_path('/',WAYBACK, $url);
+                       print "GET $wayback_url\n";
+                       $r = wget($wayback_url, $tmp_path, \%wget_options,);
+                       if ($r != 0) {
+                               print "Failed to get $url\n";
+                               unlink $tmp_path;
+                               return $url;
+                       }
+               }
+               $r = system_encoded(BIN_IMG_PATH, (BIN_IMG_PATH, $tmp_path)) >> 8;
+               if ($r == 1) {
+                       $ext = '.gif';
+               }
+               elsif ($r == 2) {
+                       $ext = '.png';
+               }
+               elsif ($r == 3) {
+                       $ext = '.jpg';
+               }
+               elsif ($r == 4) {
+                       $ext = '.bmp';
+               }
+               else {
+                       print "unknown format\n";
+                       unlink $tmp_path;
+                       return $url;
+               }
+               $path .= $ext;
+               (my $dir, my $fn) = dir_path('/',$path);
+               
+               if ($dir ne '') {
+                       system_encoded(MKDIR, (MKDIR, '-p', $dir));
+               }
+               $r = system_encoded(MV, (MV, '-n', $tmp_path, $path));
+               
+               if ($r != 0) {
+                       print "Failed to mv $tmp_path $path\n";
+                       unlink $tmp_path;
+                       return $url;
+               }
+               print "SAVED $path\n";
+               unlink $tmp_path;
+               return $new_url;
+       }
+}
+
+sub img_save_url {
+       (my $url) = @_;
+       
+       my $escaped = '';
+       my $final = '';
+       
+       for my $i (0 .. length($url)-1) {
+               my $ch = substr($url, $i, 1);
+               if ($ch =~ /[A-Za-z0-9]/) {
+                       $escaped .= $ch;
+               }
+               else {
+                       $ch = encode('utf8', $ch);
+                       $ch =~ s/(.)/sprintf('_%02X',ord($1))/egs;
+                       $escaped .= $ch;
+               }
+       }
+       while (length($escaped) > 240) {
+               $final = join_path('/',$final, substr($escaped, 0, 200));
+               $escaped = substr($escaped, 200);
+       }
+       $final = join_path('/',$final, $escaped);
+       
+       return $final;
+}
index fc6a3ae37839d5f5ebe74abfed86ff5694c09264..b35de8bd0698f12b56f20e2eddb6d0142fadb18e 100644 (file)
@@ -10,7 +10,7 @@ target: release
 useragent2: bothasar_t (http://1190.bicyclesonthemoon.info/ott/; Time thread mirror bot)
 useragent3: bothasar_p (http://1190.bicyclesonthemoon.info/ott/; Time thread post bot)
 
-postlib_path: /botm/lib/test-post
+postlib_path: /botm/lib/post
 
 bin_path: /botm/bin/ottmirror
 conf_path: /botm/etc/www/conf/1190
@@ -82,4 +82,4 @@ cron_mustard_post_schedule: #26 23 * * *
 
 cron_mustard_reketchup_schedule: 32 4 * * *
 
-cron_log_relocation_schedule: 0 0 * * 1
\ No newline at end of file
+cron_log_relocation_schedule: 0 0 * * 1