# OTT mirror
-# Copyright (C) 2014-2016 Balthasar Szczepański
-# bot2.awk (bothasar_t)
+# Copyright (C) 2014-2016, 2022 Balthasar Szczepański
+# bot2.awk (bothasar_t) automatically generated from bot2.1.awk
# relinking, archiving avatars, attachments, images.
-# 28.03.2016
+# 18.09.2020
# This file is part of OTT mirror.
#
related6=0
np=0
p=0
-###USERAGENT2a
+###AWK_useragent_2: useragent="\"bothasar_t (http://1190.bicyclesonthemoon.info/ott/; Time thread mirror bot)\""
arr[0]=0
arr2[0]=0
-###findpost_path
-###imgformat_path
-###wayback
-###fora
+###AWK_findpost_path: findpost_path="/eizm/pro/ottmirror/findpost"
+###AWK_imgformat_path: imgformat_path="/eizm/pro/ottmirror/image"
+###AWK_wayback: wayback="http://web.archive.org/web/"
+###AWK_fora: fora="http://forums.xkcd.com"
+###AWK_wget: wget=/usr/bin/wget
+###AWK_mv: mv=/usr/bin/mv
if (wait=="")
{
}
# relink OTT links to mirror links
- if($i ~ /###links_regexp;/)
+ if($i ~ ###AWK_links_regexp;)
{
split($i, arr, "#|\?|&|\"|\"")
for(j=1;j in arr;++j)
split(arr[j], arr2, "=")
if(arr2[1]=="t")
{
- if(arr2[2]==###threadID;)
+ if(arr2[2]==###AWK_thread_id;)
related=1
else
{
}
# relink prosilver(default) to mirror
- else if($i ~ /###prosilver_regexp;/)
+ else if($i ~ ###AWK_prosilver_regexp;)
{
- split($i, arr, "###prosilver_regexp2;")
+ split($i, arr, ###AWK_prosilver_regexp2;)
related2=1
}
# relink smileys to mirror
- else if($i ~ /###smiley_regexp;/)
+ else if($i ~ ###AWK_smiley_regexp;)
{
- split($i, arr, "###smiley_regexp2;")
+ split($i, arr, ###AWK_smiley_regexp2;)
related5=1
}
# download and relink avatars
- else if($i ~ /###avatar_regexp;/)
+ else if($i ~ ###AWK_avatar_regexp;)
{
split($i, arr, "\"")
split(arr[2],arr2,"=")
}
else if (tolower(download)=="yes")
{
- if (system("wget -q -t 3 -U " useragent " -O " tempfile " " arr[2])==0)
+ if (system(wget " -q -t 3 -U " useragent " -O " tempfile " " arr[2])==0)
{
- if ((system ("mv " tempfile " " arr2[1]))==0)
+ if ((system (mv " " tempfile " " arr2[1]))==0)
{
printf ("\nsaved avatar %s", arr2[2])
related3==1
}
# download and relink attachments
- else if($i ~ /###attachment_regexp;/)
+ else if($i ~ ###AWK_attachment_regexp;)
{
split($i, arr, "(\")|(%)")
split(arr[2],arr2,"(\?id=)|((\?mode=view)?&(id=)?)");
}
else if (tolower(download2)=="yes")
{
- r=system ("wget -q -t 3 -S -U " useragent " -O " tempfile " \"" arr[2] "\" 2> " tempfile2)
+ r=system (wget " -q -t 3 -S -U " useragent " -O " tempfile " \"" arr[2] "\" 2> " tempfile2)
d=""
h404=""
ext=""
}
if ((h404=="")&&(d!=""))
{
- if ((system ("mv " tempfile " " arr2[1] ext))==0)
+ if ((system (mv " " tempfile " " arr2[1] ext))==0)
{
related4=1
printf ("\nsaved attachment %s%s", arr2[2],ext)
}
# download and relink images
- else if(($i ~ /src=.https?:\/\//)&&($(i-1) ~ /<img/) && ($i !~ /###own_image_regexp;/))
+ else if(($i ~ /src=.https?:\/\//)&&($(i-1) ~ /<img/) && ($i !~ ###AWK_own_image_regexp;))
{
split($i, arr,"\"");
gsub(/&/,"\&",arr[2]);
else if (tolower(download3)=="yes")
{
ext=""
- r=system ("wget -q --no-check-certificate -t 3 -S -U " useragent " -O " tempfile " \"" arr[2] "\" 2> " tempfile2)
+ r=system (wget " -q --no-check-certificate -t 3 -S -U " useragent " -O " tempfile " \"" arr[2] "\" 2> " tempfile2)
if(r)
- r=system ("wget -q --no-check-certificate -t 3 -S -U " useragent " -O " tempfile " \"" wayback arr[2] "\" 2> " tempfile2)
+ r=system (wget " -q --no-check-certificate -t 3 -S -U " useragent " -O " tempfile " \"" wayback arr[2] "\" 2> " tempfile2)
if(r)
printf("\nfailed to download %s",arr[2])
else
{
if ((system ("mkdir -p " imagepath imgdir))==0)
{
- if ((system ("mv " tempfile " " imagepath imgdir imgname ext))==0)
+ if ((system (mv " " tempfile " " imagepath imgdir imgname ext))==0)
{
related6=1
printf ("\nsaved image %s", arr[2])
if($0 ~ /<div class=.postbody/)
{
print "<ul class=\"profile-icons\" >" >> outfile
- print "<li class=\"quote-icon\" ><a title=\"Reply with quote\" href=\"###foraaddr;/posting.php?mode=quote&f=7&p=" id "\" ></a></li>" >> outfile
+ print "<li class=\"quote-icon\" ><a title=\"Reply with quote\" href=\"" fora "/posting.php?mode=quote&f=7&p=" id "\" ></a></li>" >> outfile
print "<li class=\"quote-icon-mustard\" ><a title=\"Reply with quote\" href=\"/ott/post?q=p" id "\" ></a></li>" >> outfile
print "</ul>" >> outfile
}
escaped = escaped "_" ch2hex[ch]
}
return escaped
-};
\ No newline at end of file
+};
-CC=g++
-CF=-g -Wall
-LF1=-lcgi
-AI=mawk -f
+# OTT mirror
+# Copyright (C) 2020 Balthasar Szczepański
+# "makefile" is automatically generated from "makefile.1.mak"
+# find the latest page and number of posts.
+# 18.09.2020
+
+# 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/>.
+
+
+# CC=g++
+# CF=-g -Wall
+# LF1=-lcgi
+# AI=mawk -f
+
+ifndef TARGET
+TARGET = release
+# when want to change target run this first:
+# make -B TARGET=target_name makefile
+endif
+
+CONFIGFILE = settings-$(TARGET).txt settings.txt
+
+PERL = /usr/bin/perl
+RM = /usr/bin/rm
+
+# The configuration tool
+# http://bicyclesonthemoon.info/git/botm-config
+CONFIGURE = /botm/bin/config/configure.pl
+CONFIGURE_CMD = $(PERL) $(CONFIGURE) $(CONFIGFILE)
+
+all:
+
+
+makefile: makefile.1.mak $(CONFIGFILE)
+ $(CONFIGURE_CMD) < makefile.1.mak > makefile
+
+bot2.awk: bot2.1.awk $(CONFIGFILE)
+ $(CONFIGURE_CMD) < bot2.1.awk > bot2.awk
+
+bot2.cpp: bot2.1.cpp $(CONFIGFILE)
+ $(CONFIGURE_CMD) < bot2.1.cpp > bot2.cpp
+clean:
+ $(RM) -f bot2.awk
+PHONY: all clean
-all: bot2 bot3 findpost image view mview mpview index update post posted redirect enable
+# all: bot2 bot3 findpost image view mview mpview index update post posted redirect enable
-bot2: bot2.cpp bot2.awk findlatest.awk list.awk upload.awk index.awk makefile
- $(CC) $(CF) -o bot2 bot2.cpp
+# bot2: bot2.cpp bot2.awk findlatest.awk list.awk upload.awk index.awk makefile
+ # $(CC) $(CF) -o bot2 bot2.cpp
-bot3: bot3.cpp post.awk pm.awk makefile
- $(CC) $(CF) -o bot3 bot3.cpp
+# bot3: bot3.cpp post.awk pm.awk makefile
+ # $(CC) $(CF) -o bot3 bot3.cpp
-findpost: findpost.cpp makefile
- $(CC) $(CF) -o findpost findpost.cpp
+# findpost: findpost.cpp makefile
+ # $(CC) $(CF) -o findpost findpost.cpp
-image: image.cpp makefile
- $(CC) $(CF) -o image image.cpp
+# image: image.cpp makefile
+ # $(CC) $(CF) -o image image.cpp
-view: view.cpp view.awk makefile
- $(CC) $(CF) -o view view.cpp $(LF1)
+# view: view.cpp view.awk makefile
+ # $(CC) $(CF) -o view view.cpp $(LF1)
-mview: mview.cpp view.awk mview.awk makefile
- $(CC) $(CF) -o mview mview.cpp $(LF1)
+# mview: mview.cpp view.awk mview.awk makefile
+ # $(CC) $(CF) -o mview mview.cpp $(LF1)
-mpview: mpview.cpp view.awk mview.awk makefile
- $(CC) $(CF) -o mpview mpview.cpp $(LF1)
+# mpview: mpview.cpp view.awk mview.awk makefile
+ # $(CC) $(CF) -o mpview mpview.cpp $(LF1)
-update: update.cpp bot2 makefile
- $(CC) $(CF) -o update update.cpp $(LF1)
+# update: update.cpp bot2 makefile
+ # $(CC) $(CF) -o update update.cpp $(LF1)
-index: index.cpp makefile
- $(CC) $(CF) -o index index.cpp $(LF1)
+# index: index.cpp makefile
+ # $(CC) $(CF) -o index index.cpp $(LF1)
-post: post.cpp preview.awk view.awk bb2html.awk verify.awk makefile
- $(CC) $(CF) -o post post.cpp $(LF1)
+# post: post.cpp preview.awk view.awk bb2html.awk verify.awk makefile
+ # $(CC) $(CF) -o post post.cpp $(LF1)
-posted: posted.cpp posted.awk makefile
- $(CC) $(CF) -o posted posted.cpp $(LF1)
+# posted: posted.cpp posted.awk makefile
+ # $(CC) $(CF) -o posted posted.cpp $(LF1)
-redirect: redirect.cpp makefile
- $(CC) $(CF) -o redirect redirect.cpp $(LF1)
+# redirect: redirect.cpp makefile
+ # $(CC) $(CF) -o redirect redirect.cpp $(LF1)
-enable: post update view mview posted mpview
- chmod u+s post update view mview posted mpview
+# enable: post update view mview posted mpview
+ # chmod u+s post update view mview posted mpview
-bot2.cpp: bot2.1.cpp re.awk makefile
- $(AI) re.awk bot2.1.cpp > bot2.cpp
+# bot2.cpp: bot2.1.cpp re.awk makefile
+ # $(AI) re.awk bot2.1.cpp > bot2.cpp
-bot3.cpp: bot3.1.cpp re.awk makefile
- $(AI) re.awk bot3.1.cpp > bot3.cpp
+# bot3.cpp: bot3.1.cpp re.awk makefile
+ # $(AI) re.awk bot3.1.cpp > bot3.cpp
-findpost.cpp: findpost.1.cpp re.awk makefile
- $(AI) re.awk findpost.1.cpp > findpost.cpp
+# findpost.cpp: findpost.1.cpp re.awk makefile
+ # $(AI) re.awk findpost.1.cpp > findpost.cpp
-index.cpp: index.1.cpp re.awk makefile
- $(AI) re.awk index.1.cpp > index.cpp
+# index.cpp: index.1.cpp re.awk makefile
+ # $(AI) re.awk index.1.cpp > index.cpp
-mview.cpp: mview.1.cpp re.awk makefile
- $(AI) re.awk mview.1.cpp > mview.cpp
+# mview.cpp: mview.1.cpp re.awk makefile
+ # $(AI) re.awk mview.1.cpp > mview.cpp
-mpview.cpp: mpview.1.cpp re.awk makefile
- $(AI) re.awk mpview.1.cpp > mpview.cpp
+# mpview.cpp: mpview.1.cpp re.awk makefile
+ # $(AI) re.awk mpview.1.cpp > mpview.cpp
-post.cpp: post.1.cpp re.awk makefile
- $(AI) re.awk post.1.cpp > post.cpp
+# post.cpp: post.1.cpp re.awk makefile
+ # $(AI) re.awk post.1.cpp > post.cpp
-posted.cpp: posted.1.cpp re.awk makefile
- $(AI) re.awk posted.1.cpp > posted.cpp
+# posted.cpp: posted.1.cpp re.awk makefile
+ # $(AI) re.awk posted.1.cpp > posted.cpp
-update.cpp: update.1.cpp re.awk makefile
- $(AI) re.awk update.1.cpp > update.cpp
+# update.cpp: update.1.cpp re.awk makefile
+ # $(AI) re.awk update.1.cpp > update.cpp
-view.cpp: view.1.cpp re.awk makefile
- $(AI) re.awk view.1.cpp > view.cpp
+# view.cpp: view.1.cpp re.awk makefile
+ # $(AI) re.awk view.1.cpp > view.cpp
-bot2.awk: bot2.1.awk re.awk makefile
- $(AI) re.awk bot2.1.awk > bot2.awk
+# bot2.awk: bot2.1.awk re.awk makefile
+ # $(AI) re.awk bot2.1.awk > bot2.awk
-index.awk: index.1.awk re.awk makefile
- $(AI) re.awk index.1.awk > index.awk
+# index.awk: index.1.awk re.awk makefile
+ # $(AI) re.awk index.1.awk > index.awk
-pm.awk: pm.1.awk re.awk makefile
- $(AI) re.awk pm.1.awk > pm.awk
+# pm.awk: pm.1.awk re.awk makefile
+ # $(AI) re.awk pm.1.awk > pm.awk
-post.awk: post.1.awk re.awk makefile
- $(AI) re.awk post.1.awk > post.awk
+# post.awk: post.1.awk re.awk makefile
+ # $(AI) re.awk post.1.awk > post.awk
-preview.awk: preview.1.awk re.awk makefile
- $(AI) re.awk preview.1.awk > preview.awk
+# preview.awk: preview.1.awk re.awk makefile
+ # $(AI) re.awk preview.1.awk > preview.awk
--- /dev/null
+# OTT mirror
+# Copyright (C) 2020 Balthasar Szczepański
+# "makefile" is automatically generated from "makefile.1.mak"
+# find the latest page and number of posts.
+# 18.09.2020
+
+# 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/>.
+
+
+# CC=g++
+# CF=-g -Wall
+# LF1=-lcgi
+# AI=mawk -f
+
+ifndef TARGET
+TARGET = debug ###MAKE_TARGET:
+# when want to change target run this first:
+# make -B TARGET=target_name makefile
+endif
+
+CONFIGFILE = settings-$(TARGET).txt settings.txt
+
+###MAKE_PERL: PERL = perl
+###MAKE_RM: RM = rm
+
+# The configuration tool
+# http://bicyclesonthemoon.info/git/botm-config
+CONFIGURE = /botm/bin/config/configure.pl ###MAKE_CONFIGURE:
+CONFIGURE_CMD = $(PERL) $(CONFIGURE) $(CONFIGFILE)
+
+all:
+
+
+makefile: makefile.1.mak $(CONFIGFILE)
+ $(CONFIGURE_CMD) < makefile.1.mak > makefile
+
+bot2.awk: bot2.1.awk $(CONFIGFILE)
+ $(CONFIGURE_CMD) < bot2.1.awk > bot2.awk
+
+bot2.cpp: bot2.1.cpp $(CONFIGFILE)
+ $(CONFIGURE_CMD) < bot2.1.cpp > bot2.cpp
+
+clean:
+ $(RM) -f bot2.awk
+
+PHONY: all clean
+
+# all: bot2 bot3 findpost image view mview mpview index update post posted redirect enable
+
+# bot2: bot2.cpp bot2.awk findlatest.awk list.awk upload.awk index.awk makefile
+ # $(CC) $(CF) -o bot2 bot2.cpp
+
+# bot3: bot3.cpp post.awk pm.awk makefile
+ # $(CC) $(CF) -o bot3 bot3.cpp
+
+# findpost: findpost.cpp makefile
+ # $(CC) $(CF) -o findpost findpost.cpp
+
+# image: image.cpp makefile
+ # $(CC) $(CF) -o image image.cpp
+
+# view: view.cpp view.awk makefile
+ # $(CC) $(CF) -o view view.cpp $(LF1)
+
+# mview: mview.cpp view.awk mview.awk makefile
+ # $(CC) $(CF) -o mview mview.cpp $(LF1)
+
+# mpview: mpview.cpp view.awk mview.awk makefile
+ # $(CC) $(CF) -o mpview mpview.cpp $(LF1)
+
+# update: update.cpp bot2 makefile
+ # $(CC) $(CF) -o update update.cpp $(LF1)
+
+# index: index.cpp makefile
+ # $(CC) $(CF) -o index index.cpp $(LF1)
+
+# post: post.cpp preview.awk view.awk bb2html.awk verify.awk makefile
+ # $(CC) $(CF) -o post post.cpp $(LF1)
+
+# posted: posted.cpp posted.awk makefile
+ # $(CC) $(CF) -o posted posted.cpp $(LF1)
+
+# redirect: redirect.cpp makefile
+ # $(CC) $(CF) -o redirect redirect.cpp $(LF1)
+
+# enable: post update view mview posted mpview
+ # chmod u+s post update view mview posted mpview
+
+
+
+# bot2.cpp: bot2.1.cpp re.awk makefile
+ # $(AI) re.awk bot2.1.cpp > bot2.cpp
+
+# bot3.cpp: bot3.1.cpp re.awk makefile
+ # $(AI) re.awk bot3.1.cpp > bot3.cpp
+
+# findpost.cpp: findpost.1.cpp re.awk makefile
+ # $(AI) re.awk findpost.1.cpp > findpost.cpp
+
+# index.cpp: index.1.cpp re.awk makefile
+ # $(AI) re.awk index.1.cpp > index.cpp
+
+# mview.cpp: mview.1.cpp re.awk makefile
+ # $(AI) re.awk mview.1.cpp > mview.cpp
+
+# mpview.cpp: mpview.1.cpp re.awk makefile
+ # $(AI) re.awk mpview.1.cpp > mpview.cpp
+
+# post.cpp: post.1.cpp re.awk makefile
+ # $(AI) re.awk post.1.cpp > post.cpp
+
+# posted.cpp: posted.1.cpp re.awk makefile
+ # $(AI) re.awk posted.1.cpp > posted.cpp
+
+# update.cpp: update.1.cpp re.awk makefile
+ # $(AI) re.awk update.1.cpp > update.cpp
+
+# view.cpp: view.1.cpp re.awk makefile
+ # $(AI) re.awk view.1.cpp > view.cpp
+
+# bot2.awk: bot2.1.awk re.awk makefile
+ # $(AI) re.awk bot2.1.awk > bot2.awk
+
+# index.awk: index.1.awk re.awk makefile
+ # $(AI) re.awk index.1.awk > index.awk
+
+# pm.awk: pm.1.awk re.awk makefile
+ # $(AI) re.awk pm.1.awk > pm.awk
+
+# post.awk: post.1.awk re.awk makefile
+ # $(AI) re.awk post.1.awk > post.awk
+
+# preview.awk: preview.1.awk re.awk makefile
+ # $(AI) re.awk preview.1.awk > preview.awk
--- /dev/null
+target: release
+configure: /botm/bin/config/configure.pl
+
+useragent2: bothasar_t (http://1190.bicyclesonthemoon.info/ott/; Time thread mirror bot)
+
+bin_path: /botm/bin/ottmirror
+
+#ictaddr= "http://forums.xkcd.com/viewforum.php?f=7"
+#ottaddr= "http://forums.xkcd.com/viewtopic.php?f=7&t=101043&start="
+fora_addr: http://forums.xkcd.com
+wayback_addr: http://web.archive.org/web/
+
+thread_id: 101043
+links_regexp: href=.http:\/\/((for(ums3?|a)\.xkcd\.com)|echochamber\.me)\/viewtopic\.php
+prosilver_regexp: ((url.\.)|(((href)|(src))=.http:\/\/((for(ums3?|a)\.xkcd\.com)|echochamber\.me)))\/styles\/prosilver
+prosilver_regexp2: ((\.)|(http:\/\/((for(ums3?|a)\.xkcd\.com)|echochamber\.me)))\/styles\/prosilver
+smiley_regexp: ((url.\.)|(((href)|(src))=.http:\/\/((for(ums3?|a)\.xkcd\.com)|echochamber\.me)))\/images\/smilies
+smiley_regexp2: ((\.)|(http:\/\/((for(ums3?|a)\.xkcd\.com)|echochamber\.me)))\/images\/smilies
+avatar_regexp: ((src)|(href))=.http:\/\/((for(ums3?|a)\.xkcd\.com)|echochamber\.me)\/download\/file.php\?avatar=
+attachment_regexp: ((src)|(href))=.http:\/\/(www\.)?((for(ums3?|a)\.xkcd\.com)|echochamber\.me)\/download\/file.php\?(mode=view\&)?id=
+own_image_regexp: ((1190.bicyclesonthemoon.(dnsd.)?info)|(1190-botm.dnsdynamic.com))\/ott\/image\/
+
+
+mv: /usr/bin/mv
+perl: /usr/bin/perl
+rm: /usr/bin/rm
+wget: /usr/bin/wget
\ No newline at end of file
--- /dev/null
+_AWK_DEFINE_STR: $0="@_ESCAPE($1)"
+
+_bin_findpost_path = @_PATH($bin_path, findpost)
+_bin_image_path = @_PATH($bin_path, image)
+
+MAKE_CONFIGURE = CONFIGURE = $configure
+MAKE_TARGET = TARGET = $target
+
+MAKE_PERL = PERL = $perl
+MAKE_RM = RM = $rm
+
+AWK_useragent_2 = \t@_AWK_DEFINE_STR(useragent, "$useragent2")
+AWK_findpost_path = \t@_AWK_DEFINE_STR(findpost_path, $_bin_findpost_path)
+AWK_imgformat_path = \t@_AWK_DEFINE_STR(imgformat_path, $_bin_image_path)
+AWK_wayback = \t@_AWK_DEFINE_STR(wayback, $wayback_addr)
+AWK_fora = \t@_AWK_DEFINE_STR(fora, $fora_addr)
+AWK_wget = \t@_AWK_DEFINE_STR(wget, $wget)
+AWK_mv = \t@_AWK_DEFINE_STR(mv, $mv)
+
+AWK_links_regexp = /$links_regexp/
+AWK_prosilver_regexp = /$prosilver_regexp/
+AWK_prosilver_regexp2 = /$prosilver_regexp2/
+AWK_smiley_regexp = /$smiley_regexp/
+AWK_smiley_regexp2 = /$smiley_regexp2/
+AWK_avatar_regexp = /$avatar_regexp/
+AWK_attachment_regexp = /$attachment_regexp/
+AWK_own_image_regexp = /$own_image_regexp/
+AWK_thread_id = $thread_id
\ No newline at end of file