From 38711a6fa9eb12937ccec4e565381ccf094421c6 Mon Sep 17 00:00:00 2001 From: b Date: Thu, 20 Oct 2022 21:49:40 +0000 Subject: [PATCH] Just the enhance tools --- bb2html.awk | 689 ------------------------- bot4.awk | 496 ------------------ compare-t-1.awk | 33 -- convert1.awk | 16 - convert2.awk | 47 -- findenht1i.awk | 14 - frame.awk | 184 ------- frame.c | 86 ---- info.awk | 403 --------------- info.c | 113 ---- makefile | 32 +- mpost.awk | 77 --- mpview.c | 109 ---- mview.awk | 38 -- ong-bsta.awk | 938 --------------------------------- ong-mscha-t-1.awk | 207 -------- ong-mscha.awk | 129 ----- ong.awk | 1145 ----------------------------------------- pleaseong.c | 70 --- post.awk | 304 ----------- post.cpp | 767 --------------------------- posted.awk | 65 --- posted.c | 141 ----- preview.awk | 198 ------- remove.c | 112 ---- undertext_bb2html.awk | 657 ----------------------- upload.awk | 732 -------------------------- upload.c | 98 ---- verify.awk | 86 ---- view.awk | 59 --- viewer.awk | 687 ------------------------- viewer.c | 115 ----- www/info.htm | 13 - www/post.htm | 169 ------ 34 files changed, 1 insertion(+), 9028 deletions(-) delete mode 100644 bb2html.awk delete mode 100644 bot4.awk delete mode 100644 compare-t-1.awk delete mode 100644 convert1.awk delete mode 100644 convert2.awk delete mode 100644 findenht1i.awk delete mode 100644 frame.awk delete mode 100644 frame.c delete mode 100644 info.awk delete mode 100644 info.c delete mode 100644 mpost.awk delete mode 100644 mpview.c delete mode 100644 mview.awk delete mode 100644 ong-bsta.awk delete mode 100644 ong-mscha-t-1.awk delete mode 100644 ong-mscha.awk delete mode 100644 ong.awk delete mode 100644 pleaseong.c delete mode 100644 post.awk delete mode 100644 post.cpp delete mode 100644 posted.awk delete mode 100644 posted.c delete mode 100644 preview.awk delete mode 100644 remove.c delete mode 100644 undertext_bb2html.awk delete mode 100644 upload.awk delete mode 100644 upload.c delete mode 100644 verify.awk delete mode 100644 view.awk delete mode 100644 viewer.awk delete mode 100644 viewer.c delete mode 100644 www/info.htm delete mode 100644 www/post.htm diff --git a/bb2html.awk b/bb2html.awk deleted file mode 100644 index 4e488e1..0000000 --- a/bb2html.awk +++ /dev/null @@ -1,689 +0,0 @@ -#// bb2html.awk -#// converts bbcode to html. -#// 30.03.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . -#// - -BEGIN{ - FS="=" - debug="debug=bb2html.awk:" - automome="/eizm/pro/ong1/mome.pl" - memepath="/eizm/mem/ong1/mome.txt" - - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i) - dec=sprintf("%u",i) - ch2hex[ch]=hex - ch2dec[ch]=dec - } -}; -{ - eq=index($0,"=") - argtab[substr($0,1,eq-1)]=substr($0,eq+1) -}; -END{ - if(argtab["disable_bbcode"]!="") - { - debug=debug"###nl;BBcode disabled" - print debug>>outfile - exit 0 - } - text=argtab["BB"] - html=bb2html(text) - print "HTML="html>>outfile - print debug>>outfile - - # if(tempfile!="") - # { - # text=argtab["message"] - # gsub(/%5Bbr%5D/,"\n",text) - # while(sub(/%5Bong%5D/,ong(),text)>0){print text} - # while(sub(/%5Bung%5D/,ung(),text)>0){print text} - # while(sub(/%5Bong%3Ddecree%5D/,ong("decree"),text)>0){print text} - # while(sub(/%5Bung%3Ddecree%5D/,ung("decree"),text)>0){print text} - # if(text!=argtab["message"]) - # print "message="text >> outfile - # } -}; - -function bb2html(text, depth,count,bbtree,html,tag,tagstart,taglength,elm,tagv,tagname,tagvalue,matchname) -{ - depth=0 - count[0]=1 - bbtree["0"]="" - bbtree["0.n"]=0 - bbtree["0.t"]="post" - bbtree["0.v"]=argtab["subject"] - html="" - gsub(/=/,"=",text) - debug = debug "###nl;###nl;Build BBcode tree:" - while(length(text)!=0) - { - tag=match(text, /\[\/?[a-z0-9\*]+(=(([^\[<>\"\]]*)|(\"[^\"<>]*\")))?\]/) - #"#\"" - # debug = debug "###nl;" RSTART " " RLENGTH - if (tag==0) - { - debug = debug "###nl;text: " text - bbtree[ind(count,depth)]=text - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - text="" - break; - } - tagstart=RSTART - taglength=RLENGTH - if(tagstart>1) - { - elm=substr(text,1,tagstart-1) - debug = debug "###nl;text: " elm - bbtree[ind(count,depth)]=elm - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - } - tag=substr(text,tagstart,taglength) - text=substr(text,tagstart+taglength) - debug = debug "###nl;tag: " tag - if(tag!~/^\[\//) - { - tagv=index(tag,"=") - if(tagv<2) - { - tagname=substr(tag,2,length(tag)-2) - tagvalue="" - } - else - { - tagname=substr(tag,2,tagv-2) - tagvalue=substr(tag,tagv+1,length(tag)-tagv-1) - } - if(tagname !~ /^((quote)|b|i|u|(code)|(img)|(url)|(size)|(color)|(center)|(right)|(sub)|(sup)|(s)|(spoiler)|(list)|(\*))$/) - { - debug = debug "###nl;unknown tag" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if((bbtree[indt(count,depth)".t"] == "code" && tagname!="code")||bbtree[indt(count,depth)".t"] == "img"||(bbtree[indt(count,depth)".t"] == "spoiler" && tagname=="spoiler")||(bbtree[indt(count,depth)".t"] == "size" && tagname=="size")) - { - debug = debug "###nl;this tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if(tagname=="*") - { - if(bbtree[indt(count,depth)".t"]==tagname) - { - debug = debug "###nl;implied tag: [/"tagname"]" - debug = debug "###nl;matched" - bbtree[ind(count,depth)]="[/"tagname"]" - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]=tagname - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - else if(bbtree[indt(count,depth)".t"]!="list") - { - debug = debug "###nl;this tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - } - debug = debug "###nl;name: " tagname " value: " tagvalue - bbtree[ind(count,depth)]=tagname" "tagvalue - bbtree[ind(count,depth)".k"]="s" - bbtree[indt(count,depth)".n"]=count[depth] - ++depth - count[depth]=1 - bbtree[indt(count,depth)]=tag - bbtree[indt(count,depth)".n"]=0 - bbtree[indt(count,depth)".t"]=tagname - bbtree[indt(count,depth)".v"]=tagvalue - } - else - { - if(depth<=0) - { - debug = debug "###nl;""unmatched" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - tagname=substr(tag,3,length(tag)-3) - if(tagname=="list"&&bbtree[indt(count,depth)".t"]=="*") - { - debug = debug "###nl;implied tag: [/*]" - debug = debug "###nl;matched" - bbtree[ind(count,depth)]="[/*]" - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]="*" - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - debug = debug "###nl;name: " tagname - matchname=bbtree[indt(count,depth)".t"] - if((bbtree[indt(count,depth)".t"] == "code" && tagname!="code")||(bbtree[indt(count,depth)".t"] == "img" && tagname != "img")) - { - debug = debug "###nl;this tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if(tagname!=matchname) - { - debug = debug "###nl;mismatched: " matchname - # bbtree[ind(count,depth)]=tag - # bbtree[indt(count,depth)".n"]=count[depth] - # ++count[depth] - # continue - bbtree[ind(count,depth)]=tag - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".t"]=bbtree[indt(count,depth)".t"] - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - count[depth]="" - --depth - ++count[depth] - continue - } - debug = debug "###nl;matched" - bbtree[ind(count,depth)]=tag - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]=tagname - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - } - if(depth>0) - debug = debug "###nl;unclosed tags: " depth - - debug = debug "###nl;###nl;""generate HTML:" - depth=0 - count[0]=0 - while(count[0]<=bbtree["0.n"]&&depth>=0) - { - if(count[depth]==0) - { - tag=bbtree[indt(count,depth)] - tagname=bbtree[indt(count,depth)".t"] - tagvalue=bbtree[indt(count,depth)".v"] - debug = debug "###nl;name: "tagname" value: "tagvalue" elements: "bbtree[indt(count,depth)".n"] - if(tagname == "post") - { - } - else if(bbtree[indt(count,depth)".m"]=="") - { - debug = debug "###nl;unmatched" - html = html tag - } - else if(tagname == "quote") - { - if (tagvalue=="") - { - html = html "
" - } - else - { - if(tagvalue !~ /^\".*\"$/) - #"#\"" - tagvalue="You forgot about the quote marks, "tagvalue - else - tagvalue=bb2html(substr(tagvalue,2,length(tagvalue)-2)) - html = html "
"tagvalue" wrote:
" - } - } - else if (tagname == "b") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "i") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "u") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "code") - { - if(bbtree[indtu(count,depth)".t"] == "code") - { - html=html tag - debug = debug "###nl;not a tag, actually" - } - else - { - html=html"
Code: Select all
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - } - else if (tagname == "img") - html=html"" - } - else if (tagname == "size") - { - if (tagvalue==""||(tagvalue !~ /^[0-9]+$/)||(tagvalue+0)>200) - html=html" This tag should have a correct value. " - else - html=html"" - } - else if (tagname == "color") - { - if (tagvalue==""||tagvalue !~ /^#[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]$/) #for some reason /^([0-9A-F]{6})$/ doesn't work. - html=html" This tag should have a correct value. " - else - html=html"" - } - else if (tagname ~ /^((center)|(right))$/) - { - html=html"
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="s") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="sub") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="sup") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname=="spoiler") - { - html=html"
Spoiler:
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname=="list") - { - if(tagvalue=="") - html=html"
    " - else - { - if (tagvalue=="1") - tagvalue="decimal" - else if (tagvalue=="i") - tagvalue="lower-roman" - else if (tagvalue=="I") - tagvalue="upper-roman" - else if (tagvalue=="a") - tagvalue="lower-alpha" - else if (tagvalue=="A") - tagvalue="upper-alpha" - else - { - html=html"This tag should have a correct value. " - tagvalue="decimal" - } - html=html"
      " - } - } - else if (tagname=="*") - { - html=html"
    1. " - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else - { - debug = debug "###nl;unknown tag" - html = html tag - } - ++count[depth] - } - else if(bbtree[ind(count,depth)".k"]=="s") - { - debug = debug "###nl;entering tag:" - ++depth - count[depth]=0 - } - else if(bbtree[ind(count,depth)".k"]=="e") - { - debug = debug "###nl;leaving tag:" - tag=bbtree[ind(count,depth)] - tagname=bbtree[ind(count,depth)".t"] - tagvalue=bbtree[ind(count,depth)".v"] - debug = debug "###nl;name: "tagname" value: "tagvalue - if (tagname == "post") - { - } - else if(bbtree[ind(count,depth)".m"]=="") - { - debug = debug "###nl;unmatched" - html = html tag - } - else if(tagname == "quote") - html = html "
" - else if (tagname ~/^(b|i|u|(size)|(color))$/) - html = html"" - else if (tagname == "code") - { - if(bbtree[indtu(count,depth)".t"] == "code") - { - html=html tag - debug = debug "###nl;not a tag, actually" - } - else - html = html"" - } - else if (tagname == "img") - { - html = html"\" alt=\"Image\" />" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if(tagname=="url") - html=html"" - else if (tagname ~ /^((center)|(right))$/) - html=html"
" - else if (tagname =="s") - html=html"" - else if (tagname =="sub") - html=html"" - else if (tagname =="sup") - html=html"" - else if (tagname=="spoiler") - html=html"" - else if (tagname=="list") - { - if (tagvalue=="") - html=html"" - else - html=html"" - } - else if (tagname=="*") - html=html"" - else - { - debug = debug "###nl;unknown tag" - html = html tag - } - count[depth]="" - --depth - ++count[depth] - } - else if(count[depth]>bbtree[indt(count,depth)".n"]) - { - debug = debug "###nl;run out of elements in this tag; leaving" - count[depth]="" - --depth - ++count[depth] - } - else - { - tag=bbtree[ind(count,depth)] - debug = debug "###nl;text: "tag - if(bbtree[indt(count,depth)".t"] == "code") - { - # gsub(/ ?
?/,"
",tag) - gsub(/ /,"\\ ",tag) - gsub(/\t/,"\\ \\ ",tag) - } - if(argtab["disable_magic_url"]==""&& bbtree[indt(count,depth)".t"] !~ /^((code)|(img)|(url))$/) - gsub(/https?:\/\/[^\n\r\t<> ]+/,"&",tag) - if(argtab["disable_smilies"]=="" && bbtree[indt(count,depth)".t"] !~ /^((code)|(img))$/) - { - gsub(/(^|[\n\r\t ]):D($|[\n\r\t ])/," \":D\" ",tag) - gsub(/(^|[\n\r\t ]):\)($|[\n\r\t ])/," \":)\" ",tag) - gsub(/(^|[\n\r\t ]):\(($|[\n\r\t ])/," \":(\" ",tag) - gsub(/(^|[\n\r\t ]):o($|[\n\r\t ])/," \":o\" ",tag) - gsub(/(^|[\n\r\t ]):shock:($|[\n\r\t ])/," \":shock:\" ",tag) - gsub(/(^|[\n\r\t ]):\?($|[\n\r\t ])/," \":?\" ",tag) - gsub(/(^|[\n\r\t ])8-\)($|[\n\r\t ])/," \"8-)\" ",tag) - gsub(/(^|[\n\r\t ]):lol:($|[\n\r\t ])/," \":lol:\" ",tag) - gsub(/(^|[\n\r\t ]):x($|[\n\r\t ])/," \":x\" ",tag) - gsub(/(^|[\n\r\t ]):P($|[\n\r\t ])/," \":P\" ",tag) - gsub(/(^|[\n\r\t ]):oops:($|[\n\r\t ])/," \":oops:\" ",tag) - gsub(/(^|[\n\r\t ]):cry:($|[\n\r\t ])/," \":cry:\" ",tag) - gsub(/(^|[\n\r\t ]):evil:($|[\n\r\t ])/," \":evil:\" ",tag) - gsub(/(^|[\n\r\t ]):twisted:($|[\n\r\t ])/," \":twisted:\" ",tag) - gsub(/(^|[\n\r\t ]):roll:($|[\n\r\t ])/," \":roll:\" ",tag) - gsub(/(^|[\n\r\t ]):wink:($|[\n\r\t ])/," \":wink:\" ",tag) - gsub(/(^|[\n\r\t ]);\)($|[\n\r\t ])/," \":wink:\" ",tag) - gsub(/(^|[\n\r\t ]):!:($|[\n\r\t ])/," \":!:\" ",tag) - gsub(/(^|[\n\r\t ]):\?:($|[\n\r\t ])/," \":?:\" ",tag) - gsub(/(^|[\n\r\t ]):idea:($|[\n\r\t ])/," \":idea:\" ",tag) - gsub(/(^|[\n\r\t ]):arrow:($|[\n\r\t ])/," \":arrow:\" ",tag) - gsub(/(^|[\n\r\t ]):\|($|[\n\r\t ])/," \":|\" ",tag) - gsub(/(^|[\n\r\t ]):mrgreen:($|[\n\r\t ])/," \":mrgreen:\" ",tag) - } - - html = html tag - ++count[depth] - } - } - debug = debug "###nl;done" - return html -} - -function ind(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii<=depth;++ii) - { - if(ii!=0) - iindex = iindex "." - iindex = iindex count[ii] - } - # debug = debug "###nl;" iindex - return iindex -} -function indt(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii0) - iindex=iindex"." - iindex = iindex "0" - # debug = debug "###nl;" iindex - return iindex -} -function indtu(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii0) - iindex=iindex"." - iindex = iindex "0" - # debug = debug "###nl;" iindex - return iindex -} -function ong(decree, line) -{ - system (automome" -lc 256 -n 67 -d "memepath(decree!=""?" -t \"[decr]\"":"")" > "tempfile) - - while((getline line < tempfile)>0) - { - gsub(/[\r\n]/,"",line) - if(sub(/[AEIOUY]-N-G/,"#O-N-G#",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/O+N+G+/,"#&#",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/DON'T/,"D#ON'G#T",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/[AEIOUY]NG/,"#ONG#",line)>0) - { - if($0!~/TH\[b\]ONG/) - return preparebb(line) - } - if(sub(/ON /,"#ONG# ",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/O\.?$/,"#ONG# ",$0)>0) - { - close(tempfile) - return preparebb(line) - } - } - close(tempfile) - return "Ong" -} - -function ung(decree, line) -{ - system (automome" -lc 256 -n 67 -d "memepath(decree!=""?" -t \"[decr]\"":"")" > "tempfile) - - while((getline line < tempfile)>0) - { - gsub(/[\r\n]/,"",line) - if(sub(/[AEIOUY]-N-G/,"#U-N-G#",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/U+N+G+/,"#&#",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/[AEIOUY]NG/,"#UNG#",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/UN /,"#UNG# ",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/U\.?$/,"#UNG# ",$0)>0) - { - close(tempfile) - return preparebb(line) - } - } - close(tempfile) - return "Ung" -} - -function preparebb(rh) -{ - if(nobb=="") - { - gsub(/\*\*/,"¤",rh) - gsub(/\*[^\*]+\*/,"±&±",rh) - gsub(/±\*/,"[i]",rh) - gsub(/\*±/,"[/i]",rh) - gsub(/¤/,"*",rh) - - gsub(/__/,"¤",rh) - gsub(/_[^_]+_/,"±&±",rh) - gsub(/±_/,"[u]",rh) - gsub(/_±/,"[/u]",rh) - gsub(/¤/,"_",rh) - - gsub(/##/,"¤",rh) - gsub(/#[^#]+#/,"±&±",rh) - gsub(/±#/,"[b]",rh) - gsub(/#±/,"[/b]",rh) - gsub(/¤/,"#",rh) - - gsub(/\$\$/,"¤",rh) - gsub(/\$[^\$]+\$/,"±&±",rh) - gsub(/±\$/,"[size=80]",rh) - gsub(/\$±/,"[/size]",rh) - gsub(/¤/,"$",rh) - } - - return rh (nobb==""?" -- [url=http://mrob.com/time/automome]automome[/url]":" -- automome") -} -function urlencode(name,all, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if ((ch ~ /[a-zA-Z0-9\.\-_~]/)&&(all=="")) - escaped = escaped ch - else - escaped = escaped "%" ch2hex[ch] - } - return escaped -} diff --git a/bot4.awk b/bot4.awk deleted file mode 100644 index 2610000..0000000 --- a/bot4.awk +++ /dev/null @@ -1,496 +0,0 @@ -#// bot4.awk -#// The bot to post frames to the OTT -#// 24.04.2021 -#// -#// Copyright (C) 2015, 2018-2019, 2021 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - FS="" - # noticepath="/eizm/mem/aftertime/mpost/" - # framepath="/eizm/www/time/" - datapath="/eizm/data/aftertime/" - timecmd="date" - timecmd2="date -u +%N%s" - lastpath ="/eizm/mem/aftertime/lastong/" - temppath ="/eizm/tmp/aftertime/" - ott_address="http://forums.xkcd.com/viewtopic.php?f=7&t=101043&start=" - tto_address="http://1190.bicyclesonthemoon.info/ott/view?start=" - mstd_address="http://1190.bicyclesonthemoon.info/ott/mview?start=" - lastpost_address="http://forums.xkcd.com/viewtopic.php?f=7&t=101043&sd=d" - - wget="/usr/bin/wget" - rm="/bin/rm" - perl="/usr/bin/perl" - mawk="/usr/bin/mawk" - automome="/eizm/pro/ong1/mome.pl" - memedef="/eizm/mem/ong1/mome.txt" - - postawk="/eizm/pro/aftertime/post.awk" - mpostawk="/eizm/pro/aftertime/mpost.awk" - - # timecmd2="date +\"%H%M%S\"" - botcastleurl="http://1190.bicyclesonthemoon.info" - - if(enhance!="" && int(enhance)!="0") - { - enh=int(enhance) - ext="-"enh - } - else - { - ext="" - enh=0 - } - - f=int(frame) - timecmd | getline thistime - close(timecmd) - - timecmd2 | getline ID - close(timecmd2) - ID=int(ID/3600) - ID =int(ID%9999) - - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i); - ch2hex[ch]=hex - } - - statefile= datapath story"/ongstate" - getline temp < statefile - close(statefile) - - split(temp, temptab, " ") - state=int(temptab[1]) - last=int(temptab[2]) - - if(frame=="") - f=last - - # srand(ID + f) - # for(i=0;i0) - { - gsub(/[\r\n]/, "", line) - - if (line == "" && !undertext) - { - undertext=1 - argtab["text"]="" - continue - } - - if (undertext) - { - argtab["text"] = argtab["text"] line "\n" - } - else - { - - eq=index(line, "=") - argtab[substr(line, 1, eq-1)]=substr(line, eq+1) - } - } - close (specialfile) - } - - - botfile=datapath argtab["story"]"/"ongbot - getline botname < botfile - getline username < botfile - getline password < botfile - gsub(/[\r\n]/, "", botname) - gsub(/[\r\n]/, "", username) - gsub(/[\r\n]/, "", password) - close(botfile) - - if (botname =="" || username=="" || password=="") - { - print "Can't get login and password." - exit 1 - } - print botname - - useragent = "\""botname" (time after Time post bot; http://1190.bicyclesonthemoon.info/aftertime; story="argtab["story"]"; frame "f")\"" - - temp="" - lasttime = lastpath argtab["story"] ext - getline temp < lasttime - close(lasttime) - - split(temp, temptab, " ") - lastpage=int(temptab[1]) - lastframe=int(temptab[2]) - - print "Start with page "lastpage", last frame was "lastframe", current frame is "f"." - if(f <= lastframe && force=="") - { - print "Already ONGed." - exit 1 - } - - if(force=="") - { - temp=argtab["match"ext] - for(i=0;(j=index(substr(temp,2),"%"))!=0;++i) - { - temp2=substr(temp,1,j) - temp=substr(temp,j+1) - regexp = regexp sprintf(temp2,f) - } - regexp = regexp sprintf(temp,f) - print "match "regexp - - for(page=lastpage;page<=lastpage;++page) - { - url= "\""ott_address (page-1)*40"\"" - url2= "\""tto_address (page-1)*40"\"" - - cmd= wget " -q -O "tempfile" -U "useragent" "url - cmd2= wget " -q -O "tempfile" -U "useragent" "url2 - # print "! "cmd" !" - if(system(cmd)!=0) - { - print "Newpage "page" download fail. Retry from mirror." - if(system(cmd2)!=0) - { - print "Newpage "page" download fail." - system(rm" -f "tempfile) - exit 1 - } - } - while((getline temp < tempfile)>0) - { - if(temp ~ regexp) - { - print "Newpage "page" - already ONGed." - system(rm" -f "tempfile) - print page" "f > lasttime - close(lasttime) - exit 1 - } - gsub(/<[^<>]*>/,"",temp) - gsub(/ +/," ",temp) - temp2=tolower(temp) - if((i=match(temp2,/page [0-9]+ of [0-9]+/))!=0) - { - temp2=substr(temp2,i) - temp2=substr(temp2,index(temp2,"of")+3)" " - temp2=substr(temp2,1,index(temp2," ")-1) - lastpage=int(temp2) - } - temp2=tolower(temp) - if((i=match(temp2,/[0-9]+ posts/))!=0) - { - temp2=substr(temp2,index(temp2,"")-1) - posts=int(temp2) - if(posts%40==0) - pope=1 - else - pope="" - } - } - close(tempfile) - print "Newpage "page" - nothing found." - } - mlastpage=1 - for(mpage=1;mpage<=mlastpage;++mpage) - { - url= "\""mstd_address (mpage-1)*40"\"" - - cmd= wget " -q -O "tempfile" -U "useragent" "url - if(system(cmd)!=0) - { - print "Mustardtime newpage "mpage" not downloaded." - break - } - for(j=0;(getline temp < tempfile)>0;++j) - { - if(temp ~ regexp) - { - print "Newpage "mpage" - already ONGed." - system(rm" -f "tempfile) - print page" "f > lasttime - close(lasttime) - - exit 1 - } - gsub(/<[^<>]*>/,"",temp) - gsub(/ +/," ",temp) - temp2=tolower(temp) - if((i=match(temp2,/page [0-9]+ of [0-9]+/))!=0) - { - temp2=substr(temp2,i) - temp2=substr(temp2,index(temp2,"of")+3) - temp2=substr(temp2,1,index(temp2," ")-1) - mlastpage=int(temp2) - } - temp2=tolower(temp) - if((i=match(temp2,/[0-9]+ posts/))!=0) - { - temp2=substr(temp2,index(temp2,"")-1) - posts=int(temp2) - if(posts%40==0) - pope=1 - else - pope="" - } - } - close(tempfile) - print "Mustradtime newpage "mpage" - nothing found." - } - } - - if(argtab["nomeme"]=="") - { - print "Ok, can ONG. Now generate ONGtext" - cmd = perl" "automome" -lc 150 -n 67 -d "memedef (pope!=""?" -t \"[decrall]\"":"") - while ((cmd | getline temp)>0) - { - if(sub(/[AEIOUY]-N-G/,"[b]O-N-G[/b]",temp)>0) - { - ongtext= prepare(temp) - break - } - if(sub(/O+N+G+/,"[b]&[/b]",temp)>0) - { - ongtext= prepare(temp) - break - } - if(sub(/DON'T/,"D[b]ON'G[/b]T",temp)>0) - { - ongtext= prepare(temp) - break - } - if(sub(/[AEIOUY]NG/,"[b]ONG[/b]",temp)>0) - { - if($0!~/TH\[b\]ONG/) - { - ongtext= prepare(temp) - break - } - } - if(sub(/ON G/,"[b]ON G[/b] ",temp)>0) - { - ongtext= prepare(temp) - break - } - if(sub(/ON /,"[b]ONG[/b] ",temp)>0) - { - ongtext= prepare(temp) - break - } - if(sub(/O\.?$/,"[b]ONG[/b] ",temp)>0) - { - ongtext= prepare(temp) - break - } - } - close(cmd) - - if(ongtext=="") - ongtext="ONG" - print ongtext - } - else - ongtext="ONG" - - cmd= wget " -q -O "tempfile" -U "useragent" \""lastpost_address"\"" - if(system(cmd)!=0) - { - print "Can't check last post" - # system(rm" -f "tempfile) - # exit 1 - } - - else - { - while((getline temp < tempfile)>0) - { - if ((i=match(temp, /id=\"p[0-9]+\"/))!=0) #" - { - temp2=substr(temp, i+5) - lastpostid=substr(temp2, 1, index(temp2,"\"")-1) - } - - if (temp ~ /class=\"postprofile\"/) #" - postprofile = "1" - - else if (postprofile=="") - continue - - if(temp ~ /memberlist\.php.*mode=viewprofile[^<>]*>[^<>]+<\/a/) - { - temp2=substr(temp, index(temp, ">")+1) - lastusername=substr(temp2, 1, index(temp2,"<")-1) - break - } - } - close(tempfile) - if(lastusername=="" || lastpostid=="") - { - print "Can't check last post" - # system(rm" -f "tempfile) - # exit 1 - } - } - - srand(ID+lastpostid+f) - - if(rand()<(argtab["npbprob"]+0)) - { - print "Also, let's do some NewpixbOTTification!" - npbsel="npbframe"ext - } - else - npbsel="frame"ext - - - - framedir= (argtab["framedir"]!="" ? argtab["framedir"] : "/aftertime/"argtab["story"]"/") - - print "username="urlencode(username) > tempfile - print "password="urlencode(password,1) >> tempfile - print "subject="urlencode(sprintf(argtab["subject"ext],f,"")) >> tempfile - print "message="urlencode(ongtext"\n[url="botcastleurl"/aftertime/viewer?story="argtab["story"]"&f="f((enh>0)?"&e="enh:"")"][img]"botcastleurl framedir sprintf(argtab[npbsel],f,"")"[/img][/url]"((argtab["text"]!="")?("\n"argtab["text"]):"")"[spoiler]"alt"[/spoiler]\n[right][size=80] -- posted by "botname"[/size][/right]") >> tempfile - print "Send post" - - cmd= mawk" -f "postawk" -v postfile="tempfile_p" -v cookiefile="tempfile_c" -v tempfile="tempfile_t((lastpostid!="" && lastusername!="")?" -v edit="lastpostid" -v user=\""lastusername"\"":"")" "tempfile - cmd2= mawk" -f "mpostawk" -v postfile="tempfile_p" -v cookiefile="tempfile_c" -v tempfile="tempfile_t" "tempfile - - if(system(cmd)!=0) - { - print "Can't post, try again from mirror" - if(system(cmd2)!=0) - { - print "CAN'T POST EITHER!" - system(rm" -f "tempfile) - system(rm" -f "tempfile_t) - system(rm" -f "tempfile_c) - system(rm" -f "tempfile_p) - exit 1 - } - } - print "ONGed" - system(rm" -f "tempfile) - system(rm" -f "tempfile_t) - system(rm" -f "tempfile_c) - system(rm" -f "tempfile_p) - if(force=="") - { - print lastpage" "f > lasttime - close(lasttime) - } - - -} -function urlencode(name, all, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if (ch ~ /[a-z]|[A-Z]|[0-9]/ && all=="") - escaped = escaped ch - else - escaped = escaped "%" ch2hex[ch] - } - return escaped -}; -function prepare(rh) -{ - gsub(/\*\*/,"¤",rh) - gsub(/\*[^\*]+\*/,"±&±",rh) - gsub(/±\*/,"[i]",rh) - gsub(/\*±/,"[/i]",rh) - gsub(/¤/,"*",rh) - - gsub(/__/,"¤",rh) - gsub(/_[^_]+_/,"±&±",rh) - gsub(/±_/,"[u]",rh) - gsub(/_±/,"[/u]",rh) - gsub(/¤/,"_",rh) - - gsub(/\$\$/,"¤",rh) - gsub(/\$[^\$]+\$/,"±&±",rh) - gsub(/±\$/,"[size=80]",rh) - gsub(/\$±/,"[/size]",rh) - gsub(/¤/,"$",rh) - - return rh " -- [url=http://1190.bicyclesonthemoon.info/ongtext?b=on][b]ong[/b]o[/url][url=http://mrob.com/time/automome/]mome[/url]" -} diff --git a/compare-t-1.awk b/compare-t-1.awk deleted file mode 100644 index 2aab0e9..0000000 --- a/compare-t-1.awk +++ /dev/null @@ -1,33 +0,0 @@ -BEGIN{ - # for(i=1; i<=828; ++i) - # { - # f=sprintf("%04d",i) - # cmpcmd="/eizm/pro/aftertime/compare /eizm/www/time/aftertime/t-1/t-1_"f".png /eizm/data/aftertime/testaftertime/t-1/t-1_"f".png" - - # printf("%s","t-1_"f".png ") - - # # print cmpcmd - # system (cmpcmd) - # } - for(i=1; i<=828; ++i) - { - f=sprintf("%04d",i) - cmpcmd="/eizm/pro/aftertime/compare /eizm/www/time/aftertime/t-1/remapt-1_"f".png /eizm/data/aftertime/testaftertime/t-1/remapt-1_"f".png" - cpcmd="/bin/cp /eizm/data/aftertime/testaftertime/t-1/remapt-1_"f".png /eizm/www/time/aftertime/t-1/mustardremapt-1_"f".png" - - printf("%s","remapt-1_"f".png ") - - # print cmpcmd - # system (cmpcmd) - - cmpcmd | getline line - close(cmpcmd) - print line - if (line!="identical.") - { - system(cpcmd) - print "upload "f"." - } - } - -} diff --git a/convert1.awk b/convert1.awk deleted file mode 100644 index b9b4bf6..0000000 --- a/convert1.awk +++ /dev/null @@ -1,16 +0,0 @@ -BEGIN{ - print "SilentTimer\n5TkxDBIL21OyEGwkdTR2EQYwdYC5F4\n" -} -{ - y=substr($1, 1, 4) - m=substr($1, 5, 2) - d=substr($1, 7, 2) - h=substr($1, 9, 2) - - if($NF !~ /^t1i-[0-9]+$/) - next - - id= $NF "-1" - - print y"-"m"-"d" "h"\nq\n" -} \ No newline at end of file diff --git a/convert2.awk b/convert2.awk deleted file mode 100644 index 2bf3c69..0000000 --- a/convert2.awk +++ /dev/null @@ -1,47 +0,0 @@ -BEGIN{ - FS="" - print "SilentTimer\n5TkxDBIL21OyEGwkdTR2EQYwdYC5F4\n" - i=0 -} -{ - ind=index($0, " ") - id=substr($0, 1, ind-1) - value=substr($0, ind+1) - ind=index(value," ") - name=substr(value, 1, ind-1) - value=substr(value, ind+1) - - if (tab[id]=="") - { - list[i]=id - tab[id]=id - ++i - } - tab[id"-"name]=value -} -END{ - for(j=0;j. - -BEGIN{ - FS="" - framepath="/eizm/www/time/" - datapath="/eizm/data/aftertime/" - - if(frame ~ /[a-zA-Z]$/) - { - f=int(substr(frame,1,length(frame)-1)) - s=substr(frame, length(frame)) - } - else - { - f=int(frame) - s="" - } - e=int(enhance) - - lastalt=0 - - ch2num[0]="" - num2ch[""]=0 - for(i=1;i<=26;++i) - { - ch=sprintf("%c",i+96) - num2ch[i]=ch - ch2num[ch]=i - } -} -{ - file=1 - gsub(/[\r\n]/, "", $0) - eq=index($0, "=") - - if($0 ~ /^sf-[0-9]+=/) - { - sf=1 - i=int(substr($0, 4, eq-4)) - if(i==f) - this_sf= tolower(substr($0, eq+1)) - if(i==f-1) - prev_sf=tolower(substr($0, eq+1)) - - } - argtab[substr($0, 1, eq-1)]=substr($0, eq+1) -} -END{ - - if (file=="") - exit 1 - - if (sf=="") - s="" - else if(this_sf=="") - s="" - else if(s>this_sf && argtab["cfrt"]=="") - s=this_sf - - ongoing=int(argtab["ongoing"]) - if(ongoing>0) - { - statefile= datapath argtab["story"]"/ongstate" - getline temp < statefile - close(statefile) - - split(temp, temptab, " ") - state=int(temptab[1]) - last=int(temptab[2]) - nextong=int(temptab[3]) - ongfailcount=int(temptab[4]) - } - else - { - last=int(argtab["last"]) - state=3 - nextong=0 - ongfailcount=0 - } - first=int(argtab["first"]) - - if(frame=="") - { - if(ongoing>0) - { - f=last - onlyframe=1 - } - else - { - f=first - onlyframe="" - } - } - - if(flast && argtab["cfrt"]=="") - f=last - - if(argtab["special"] != "") - { - specialfile=datapath argtab["story"]"/"sprintf(argtab["special"],f,s) - line="" - undertext="" - - while((getline line < specialfile)>0) - { - gsub(/[\r\n]/, "", line) - - if (line == "" && !undertext) - { - undertext=1 - argtab["text"]="" - continue - } - - if (undertext) - { - argtab["text"] = argtab["text"] line "\n" - } - else - { - - eq=index(line, "=") - argtab[substr(line, 1, eq-1)]=substr(line, eq+1) - } - } - close (specialfile) - } - - framedir= (argtab["framedir"]!="" ? argtab["framedir"] : "/aftertime/"argtab["story"]"/") - # if(sf!="") - # { - frame= framedir sprintf(argtab["frame"(e>0 ? "-"e : "")],f,s) - if (system("[ -f " framepath frame" ]")!=0) - frame= framedir sprintf(argtab["frame"],f,s) - # } - # else - # { - # s="" - # frame= framedir sprintf(argtab["frame"(e>0 ? "-"e : "")],f) - # if (system("[ -f " framepath frame" ]")!=0) - # frame=framedir sprintf(argtab["frame"],f) - # } - - if(f==last && state==1) - { - print "2 "f" "nextong" "ongfailcount > statefile - close (statefile) - } - - if((f>last || fthis_sf)) || state==0 && argtab["cfrt"]!="") - frame= framedir argtab["cfrt"] - - if(state==0 && argtab["cfrt"]=="") - { - print "Status: 404 Not Found" - print "" - } - - print "Status: 302 Temporal Relocation" - print "Location: "frame - print "" - -} diff --git a/frame.c b/frame.c deleted file mode 100644 index 93af30e..0000000 --- a/frame.c +++ /dev/null @@ -1,86 +0,0 @@ -// frame.c (1190.bicyclesonthemoon.info/aftertime/frame) -// Dynamic frame for the viewer -// 21.06.2018 -// -// Copyright (C) 2015, 2018 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#define STORYDEF_PRINTF "/eizm/data/aftertime/%s/settings" -#define MAWK_PATH "/usr/bin/mawk" -#define AWK_FRAME "/eizm/pro/aftertime/frame.awk" - -#include -#include -#include -#include -#include -#include - -s_cgi *cgi; - -int main (int argc, char *argv[]) -{ - s_cgi *cgi; - pid_t sub; - int r; - - char *story; - char *f; - char *enh; - - char arg1[256]; - char arg2[256]; - char arg3[256]; - char storydef[256]; - - cgi=cgiInit(); - - //setvbuf(stdout, NULL, _IONBF, 0); - // dup2(fileno(stdout),fileno(stderr)); - - story=cgiGetValue(cgi,"story"); - f=cgiGetValue(cgi,"f"); - enh=cgiGetValue(cgi,"e"); - - snprintf(arg1,256,"story=%s",story!=NULL ? story : ""); - snprintf(arg2,256,"frame=%s",f!=NULL ? f : ""); - snprintf(arg3,256,"enhance=%s",enh!=NULL ? enh : ""); - - sprintf(storydef,STORYDEF_PRINTF,story!=NULL ? story : "time"); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_FRAME,"-v",arg1,"-v",arg2,"-v",arg3,storydef,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - { - sprintf(storydef,STORYDEF_PRINTF,"default"); - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_FRAME,"-v",arg1,"-v",arg2,"-v",arg3,storydef,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - } - - return 0; -} diff --git a/info.awk b/info.awk deleted file mode 100644 index 949a124..0000000 --- a/info.awk +++ /dev/null @@ -1,403 +0,0 @@ -#// info.awk -#// Info about an aftertime story. -#// 10.03.2019 -#// -#// Copyright (C) 2015-2016, 2018-2019 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - #print"INTERFACE IS BEING DEBUGGED. WAIT FOR IT." - noticepath="/eizm/mem/aftertime/mpost/" - framepath="/eizm/www/time/" - datapath="/eizm/data/aftertime/" - timecmd="date -u +\"%Y%m%d%H\"" - botcastleurl="http://1190.bicyclesonthemoon.info" - - # for(i=0;i<256;++i) - # { - # ch=sprintf("%c",i) - # hex=sprintf("%02X",i) - # dec=sprintf("%u",i) - # ch2hex[ch]=hex - # ch2dec[ch]=dec - # } - - listfile = datapath "stories" - stories=0 - line="" - while((getline line < listfile)>0) - { - gsub(/[\r\n]/,"",line) - eq=index(line,"=") - - storytab[stories]=substr(line, 1, eq-1) - storyname[stories]=substr(line, eq+1) - ++stories - } - close(listfile) - - if(frame !~ /^[0-9]+[a-z]?$/){ - noframe=1 - } - else if(frame ~ /[a-zA-Z]$/) - { - f=int(substr(frame,1,length(frame)-1)) - s=substr(frame, length(frame)) - } - else - { - f=int(frame) - s="" - } - e=int(enhance) - if(notice~/^[0-9]+$/) - n=int(notice) - timecmd | getline thistime - close(timecmd) - - lastalt=0 - - ch2num[0]="" - num2ch[""]=0 - for(i=1;i<=26;++i) - { - ch=sprintf("%c",i+96) - num2ch[i]=ch - ch2num[ch]=i - } - alttabsize=0 - argtabsize=0 -} -{ - file=1 - gsub(/[\r\n]/, "", $0) - eq=index($0, "=") - if($0 ~ /^[0-9]+=/) - { - i=int(substr($0, 1, eq-1)) - alttab[alttabsize]=substr($0, eq+1) - alttabn[alttabsize]=i - ++alttabsize - - # i=int(substr($0, 1, eq-1)) - # if(f>=i && i>=lastalt) - # { - # alt=substr($0, eq+1) - # lastalt=i - # } - } - else if($0 ~ /^sf-[0-9]+=/) - { - sf=1 - i=int(substr($0, 4, eq-4)) - if(i==f) - this_sf= tolower(substr($0, eq+1)) - if(i==f-1) - prev_sf=tolower(substr($0, eq+1)) - - } - if (!(substr($0, 1, eq-1) in argtab)) - { - argtabind[argtabsize]=substr($0, 1, eq-1) - ++argtabsize - } - argtab[substr($0, 1, eq-1)]=substr($0, eq+1) -} -END{ - - if (story=="" && f=="") - { - for (i=0; i0) - { - statefile= datapath argtab["story"]"/ongstate" - getline temp < statefile - close(statefile) - - split(temp, temptab, " ") - state=int(temptab[1]) - last=int(temptab[2]) - nextong=int(temptab[3]) - ongfailcount=int(temptab[4]) - } - else - { - last=int(argtab["last"]) - state=3 - } - first=int(argtab["first"]) - - if(noframe!=""){ - if(ongoing>0) - { - print "state="state - print "last="last - print "nextong="nextong - print "ongfailcount="ongfailcount - } - for (i=0; i< argtabsize; ++i) - { - if((argtabind[i] ~ /^[0-9]+$/)&&(ongoing>0)) - { - j=int(argtabind[i]) - if(j<=last) - print argtabind[i]"="argtab[argtabind[i]] - } - else if((argtabind[i] ~ /^sf-[0-9]+$/)&&(ongoing>0)) - { - j=int(substr(argtabind[i],3)) - if(j<=last) - print argtabind[i]"="argtab[argtabind[i]] - } - else if((argtabind[i] ~ /^(last|finalreplacetime|finalreplaceframe)$/)&&(ongoing>0)) - { - } - else - print argtabind[i]"="argtab[argtabind[i]] - } - } - else{ - if(f>last || fthis_sf)) - exit 0 - - if(this_sf=="") - s="" - - if (s!="") - { - if(argtab[s] != "") - s2=argtab[s] - else - s2=s - n=-1 - } - - if(n>0) - { - noticepost=noticepath argtab["story"]"-"sprintf("%04u",f)"-"sprintf("%02u",n) - noticetabsize=0 - for(j=0;(getline line < noticepost)>0;++j) - { - gsub(/[\r\n]/,"",line) - eq=index(line,"=") - noticeind=substr(line, 1, eq-1) - noticeval=substr(line, eq+1) - - if (!(noticeind in noticetab)) - { - noticetabind[noticetabsize]=noticeind - ++noticetabsize - } - noticetab[noticeind]=noticeval - - } - if(j==0) - exit 0 - nposttime=noticetab["y"]noticetab["m"]noticetab["d"]noticetab["h"] - if (thistime0) - { - gsub(/[\r\n]/, "", line) - - if (line == "" && !undertext) - { - undertext=1 - argtab["text"]="" - continue - } - - if (undertext) - { - argtab["text"] = argtab["text"] line "\n" - } - else - { - eq=index(line, "=") - argtab[substr(line, 1, eq-1)]=substr(line, eq+1) - } - } - close (specialfile) - } - - ongtimefile= datapath argtab["story"]"/ongtime" - - while((getline line < ongtimefile)>0) - { - ongind=index(line," ") - ongft=substr(line,1,ongind-1) - ongt=substr(line,ongind+1,4) substr(line,ongind+6,2) substr(line,ongind+9,2) substr(line,ongind+12,2) substr(line,ongind+15,2) - if(ongft ~ /^[0-9]+[a-z]$/) - ongf=int(substr(ongft,1,ongind-2)) substr(ongft,ongind-1,1) - else - ongf=int(ongft) - - if(ongf==(f s) && ongt ~ /^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/) - ongtime=ongt - } - close(ongtimefile) - - if ("alt" in argtab) - alt=argtab["alt"] - else - { - for(i=0; i=alttabn[i] && alttabn[i]>=lastalt) - { - alt=alttab[i] - lastalt=alttabn[i] - } - } - } - - if(argtab["number"]!="") - numberformat=argtab["number"] - else - { - # if (sf!="") - numberformat="%u%s" - # else - # numberformat="%u" - } - - framedir= "/aftertime/"argtab["story"]"/" - # if(sf!="") - # { - title=sprintf(argtab["title"(e>0 ? "-"e : "")],f,s2) - frame=framedir sprintf(argtab["frame"(e>0 ? "-"e : "")],f,s) - otherviewerurl=sprintf(argtab["otherviewerurl"], f+int(argtab["othervieweroffset"]),s2) - # } - # else - # { - # s="" - # title=sprintf(argtab["title"(e>0 ? "-"e : "")],f) - # frame= framedir sprintf(argtab["frame"(e>0 ? "-"e : "")],f) - # otherviewerurl=sprintf(argtab["otherviewerurl"], f+int(argtab["othervieweroffset"])) - # } - - if (system("[ -f " framepath frame" ]")!=0) - exit 0 - - print "story="argtab["story"] - print "f="f s - print "e="e - print "frame="frame - print "alt="alt - print "title="title - if(ongtime!="") - print "ongtime="ongtime - - max_enhance=int(argtab["enhance"]) - - - if(max_enhance>0) - { - for(i=0;i<=max_enhance;++i) - { - # if(sf!="") - enhancedframe = framedir sprintf(argtab["frame"(i>0?"-"i:"")],f,s) - # else - # enhancedframe = framedir sprintf(argtab["frame"(i>0?"-"i:"")],f) - - if (system("[ -f " framepath enhancedframe" ]")==0) - print "enhance-"i"="argtab["enhance-"i] - } - } - - for(i=1; i<=99; ++i) - { - noticepost=noticepath argtab["story"]"-"sprintf("%04u",f)"-"sprintf("%02u",i) - for(j=0;(getline line < noticepost)>0;++j) - { - gsub(/[\r\n]/,"",line) - eq=index(line,"=") - noticetab[substr(line, 1, eq-1)]=substr(line, eq+1) - } - if(j==0) - break; - nposttime=noticetab["y"]noticetab["m"]noticetab["d"]noticetab["h"] - if (thistime/,"\n",ht) - while ((i=match(ht, /&#[0-9]+;/))!=0)# - { - un=un substr(ht, 1, i-1) - ht=substr(ht, i) - j=index(ht, ";") - num=int(substr(ht, 3, j-3)) - un=un sprintf("%c",num) - ht=substr(ht, j+1) - } - un=un ht - return un -} diff --git a/info.c b/info.c deleted file mode 100644 index c73a5ba..0000000 --- a/info.c +++ /dev/null @@ -1,113 +0,0 @@ -// info.c (1190.bicyclesonthemoon.info/aftertime/info) -// Info about an aftertime story. -// 3.01.2019 -// -// Copyright (C) 2016, 2019 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#define STORYDEF_PRINTF "/eizm/data/aftertime/%s/settings" -#define MAWK_PATH "/usr/bin/mawk" -#define AWK_INFO "/eizm/pro/aftertime/info.awk" - -#include -#include -#include -#include -#include -#include - -s_cgi *cgi; - -void escape(char *text); - -int main (int argc, char *argv[]) -{ - s_cgi *cgi; - pid_t sub; - int r; - - char *story; - char *f; - char *enh; - char *notic; - - char arg1[256]; - char arg2[256]; - char arg3[256]; - char arg4[256]; - char storydef[256]; - - cgi=cgiInit(); - - //setvbuf(stdout, NULL, _IONBF, 0); - //dup2(fileno(stdout),fileno(stderr)); - - story=cgiGetValue(cgi,"story"); - f=cgiGetValue(cgi,"f"); - enh=cgiGetValue(cgi,"e"); - notic=cgiGetValue(cgi,"n"); - - if(story!=NULL) - escape(story); - - snprintf(arg1,256,"story=%s",story!=NULL ? story : ""); - snprintf(arg2,256,"frame=%s",f!=NULL ? f : ""); - snprintf(arg3,256,"enhance=%s",enh!=NULL ? enh : ""); - snprintf(arg4,256,"notice=%s",notic!=NULL ? notic : ""); - - sprintf(storydef,STORYDEF_PRINTF,story!=NULL ? story : "time"); - - printf("Content-type: text/plain; charset=utf-8\n\n"); - - // if((story==NULL)&&(f==NULL)){ - // fputs("time\nprickly\npotm\nlucky\nbeany\nbean2\nt1i\nzodiac\nbftf\nt-1\nphys\n",stdout); - // return 0; - // } - - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_INFO,"-v",arg1,"-v",arg2,"-v",arg3,"-v",arg4,storydef,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - //if(r) - //{ - // sprintf(storydef,STORYDEF_PRINTF,"default"); - // fflush(stdout); - // sub=fork(); - // if(sub==0) - // { - // r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_INFO,"-v",arg1,"-v",arg1,"-v",arg1,storydef,(char *)0); - // exit(r); - // } - // waitpid(sub,&r,0); - //} - - return 0; -} - -void escape(char *text){ - unsigned short i, len; - - len=strlen(text); - for (i=0;i. - - -BEGIN{ - FS="=" - fora="http://1190.bicyclesonthemoon.info/ott" - useragent="\"bothasar_p (http://1190.bicyclesonthemoon.info/aftertime; time after Time post bot)\"" -}; -{ - argtab[$1]=$2 -}; -END{ - printf ("username=%s",argtab["username"])>postfile - printf ("&password=%s",argtab["password"])>>postfile - printf ("&subject=%s",argtab["subject"])>>postfile - if("&addbbcode20" in argtab) - printf ("&addbbcode20=%s",argtab["addbbcode20"])>>postfile - printf ("&message=%s",argtab["message"])>>postfile - printf ("&post=%s","Submit")>>postfile - if("disable_bbcode" in argtab) - printf ("&disable_bbcode=%s",argtab["disable_bbcode"])>>postfile - if("disable_smilies" in argtab) - printf ("&disable_smilies=%s",argtab["disable_smilies"])>>postfile - if("disable_magic_url" in argtab) - printf ("&disable_magic_url=%s",argtab["disable_magic_url"])>>postfile - if("attach_sig" in argtab) - printf ("&attach_sig=%s",argtab["attach_sig"])>>postfile - if("notify" in argtab) - printf ("¬ify=%s",argtab["notify"])>>postfile - printf ("&creation_time=%s",argtab["creation_time"])>>postfile - printf ("&form_token=%s",argtab["form_token"])>>postfile - close(postfile) - - if(system("wget -q -t 3 --connect-timeout=60 --post-file=" postfile " -U " useragent " -O " tempfile " \""fora "/post\"")) - { - print "Submit fail." - exit 1 - } - - while((getline temp < tempfile)>0) - { - if (temp ~ /

information/) - { - success=1 - } - } - close(tempfile) - - if (success!=1) - { - print "Sent back to preview!" - exit INDELIVERABLE - } -} diff --git a/mpview.c b/mpview.c deleted file mode 100644 index 0f3f013..0000000 --- a/mpview.c +++ /dev/null @@ -1,109 +0,0 @@ -// mpview.c (1190.bicyclesonthemoon.info/aftertime/view) -// Display one post -// 28.03.2015 -// -// Copyright (C) 2015 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include -#include -#include -#include -#include - -#define RM_PATH "/bin/rm" -#define CAT_PATH "/bin/cat" -#define MAWK_PATH "/usr/bin/mawk" - -#define POST_PATH "/eizm/mem/aftertime/mpost/" - -#define AWK_MVIEW "/eizm/pro/aftertime/mview.awk" -#define TEMP_PATH "/eizm/tmp/aftertime/mpview." - -int main() -{ - s_cgi *cgi; - pid_t sub; - int r; - - char line[32]; - // char filename[32]; - char postpath[256]; - // char cat[8]; - - char *arg; - char key[64]; - - char path2[256]; - - cgi=cgiInit(); - - printf("Content-type: text/html\n\n"); - - arg=cgiGetValue(cgi,"v"); - sprintf(line,"%s",arg?arg:"???"); - - arg=cgiGetValue(cgi,"key"); - sprintf(key,"key=%s",arg?arg:"???"); - - // sprintf(filename,"%s",line); - sprintf(postpath,"%s%s",POST_PATH,line);//UNSAFE! (2019) - - - sprintf(path2,"%s%lu",TEMP_PATH,(unsigned long)getpid()); - - printf("\n"); - printf("\n"); - printf("time after Time • Bicycles on the Moon\n"); - printf("\n"); - printf("\n"); - printf("\n"); - printf("\n"); - printf("\"1190.bicyclesonthemoon.info\"\n"); - printf("

time after Time

\n"); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_MVIEW,"-v","bg=1","-v","s=1","-v",key,postpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - { - printf("
\n",line); - printf("
\n"); - printf("%s %s POST NOT FOUND.\n",AWK_MVIEW,postpath); - printf("\n
\n"); - printf("
\n"); - } - - printf("back to the list
\n"); - printf("
1190.bicyclesonthemoon.info\n"); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,"-f",path2,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - printf("

Ch*rpin* M*stard! file not deleted!

"); - - return 0; -} diff --git a/mview.awk b/mview.awk deleted file mode 100644 index 062883e..0000000 --- a/mview.awk +++ /dev/null @@ -1,38 +0,0 @@ -#// mview.awk -#// Display one post -#// 31.04.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - FS="=" -}; -{ - eq=index($0,"=") - argtab[substr($0,1,eq-1)]=substr($0,eq+1) -}; -END{ - if(key!=argtab["key"]) - { - print"Invalid key.

" - exit - } - print "
" - print "
"argtab["story"]"-"argtab["frame"]"-"argtab["round"]" • "argtab["subject_h"]"
" - print "
"argtab["username_h"]" • "argtab["y"]"-"argtab["m"]"-"argtab["d"]" "argtab["h"]":00
quote edit remove"(argtab["ID"]!=""?" OTT":"")"
" - print "
"((argtab["HTML"]!="")?argtab["HTML"]:argtab["BBHTML"])"
" - print "
" -} diff --git a/ong-bsta.awk b/ong-bsta.awk deleted file mode 100644 index 487d049..0000000 --- a/ong-bsta.awk +++ /dev/null @@ -1,938 +0,0 @@ -#// ong-bsta.awk -#// The bot to ketchup frames from the bsta viewer -#// 6.09.2019 -#// -#// Copyright (C) 2019 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . -#// - -BEGIN{ - FS="" - framepath="/eizm/www/time/" - datapath="/eizm/data/aftertime/" - temppath="/eizm/tmp/aftertime/" - passpath="/eizm/mem/aftertime/pass/" - - bstapath="/eizm/data/bsta/" - bstaviewpath="/eizm/www/time/bsta/" - - timecmd="date -u +%Y%m%d%H%s" - timecmd2="date -u +\"%Y-%m-%d %H:%M:%S\"" - ongtimecmd1="date -u -d@" - ongtimecmd2=" +\"%Y-%m-%d %H:%M:%S\"" - - botcastleurl="http://1190.bicyclesonthemoon.info" - - cp="/bin/cp" - mawk="/usr/bin/mawk" - chmod="/bin/chmod" - - # wget="/usr/bin/wget" - # remap="/eizm/pro/aftertime/remapt-1" - npb="/eizm/pro/ong1/npb" - # bot4awk="/eizm/pro/aftertime/bot4.awk" - # uploadawk="/eizm/pro/aftertime/upload.awk" - - timecmd2 | getline thistime2 - close(timecmd2) - - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i) - dec=sprintf("%u",i) - ch2hex[ch]=hex - ch2dec[ch]=dec - } -} -{ - file=1 - gsub(/[\r\n]/, "", $0) - eq=index($0, "=") - - argtab[substr($0, 1, eq-1)]=substr($0, eq+1) -} -END{ - print "" - print thistime2" "argtab ["story"] - - if (file=="") - { - print "No data." - exit 1 - } - - if(argtab["ongoing"]!="2") - { - print "Story is not externally onged." - exit 1 - } - - framedir = "aftertime/"argtab["story"]"/" - - temp="" - statefile= datapath argtab["story"]"/ongstate" - getline temp < statefile - getline alt < statefile - close(statefile) - - split(temp, temptab, " ") - state=int(temptab[1]) - last=int(temptab[2]) - nextong=int(temptab[3]) - ongfailcount=int(temptab[4]) - - if(state==4) - { - print "Time to start onging." - f=int(argtab["first"]) - } - else if (state==2 || state==1) - f=last+1 - else - { - print "Onging not avtive." - exit 1 - } - - bstasettingsfile = bstapath "settings" - bstastatefile = bstapath "state" - bstadefaultfile = bstapath "default" - - bstaargtab[0]="" - specialtab[0]="" - attachtab[0]="" - - timefile= datapath argtab["story"]"/ongtime" - - while(1) - { - bstaspecialfile = bstapath f - specialfile = datapath argtab["story"]"/"sprintf(argtab["special"],f) - - for (i in bstaargtab) - delete bstaargtab[i] - - readdatafile(bstasettingsfile,bstaargtab) - readdatafile(bstastatefile,bstaargtab) - readdatafile(bstadefaultfile,bstaargtab) - readdatafile(bstaspecialfile,bstaargtab) - - # for (i in bstaargtab) - # print i": "bstaargtab[i] - - if (f > int(bstaargtab["last"])) { - print "Wait for frame "f"." - exit 0 - } - - print "ONG frame "f"." - - for (i in specialtab) - delete specialtab[i] - - #skip NPB frame - - specialtab["title"]=bstaargtab["title"] - # specialtab["alt"]=bstaargtab["title"] - specialtab["frame"]=sprintf(bstaargtab["frame"],f,bstaargtab["ext"]) - specialtab["text"]=bstaargtab["content"] - - inframe = bstaviewpath specialtab["frame"] - frame= framepath framedir specialtab["frame"] - - - text_HTML="" - text_BB="" - text=specialtab["text"] - - while (text!="") - { - eq=match(text,/(###([^#;]*);)/) - - if(eq) - { - text_HTML=text_HTML substr(text, 1, RSTART - 1) - text_BB = text_BB substr(text, 1, RSTART - 1) - tag = substr(text, RSTART +3, RLENGTH -4) - text= substr(text, RSTART + RLENGTH) - - if (match(tag,/^fr&([0-9]+)$/)) - { - id=int(substr(tag,4)) - - tag="/aftertime/frame?story="arrtab["story"]"&f="id - text_HTML=text_HTML tag - text_BB=text_BB botcastleurl tag - } - else if (match(tag,/^vw&([0-9]+)$/)) - { - id=int(substr(tag,4)) - - tag="/aftertime/viewer?story="arrtab["story"]"&f="id - text_HTML=text_HTML tag - text_BB=text_BB botcastleurl tag - - } - else if (match(tag,/^att&([0-9]+)$/)) - { - id=int(substr(tag,5)) - - print "ONG attachment "id"." - - attachfile=bstapath"a"id - for (i in attachtab) - delete attachtab[i] - readdatafile(attachfile, attachtab) - - outfile=framepath framedir attachtab["filename"] - infile= bstapath attachtab["filename"] - - cpcmd = cp" "infile" "outfile - chmodcmd = chmod" +r "outfile - - if (attachtab["content"]!="") - { - printf("%s",attachtab["content"]) > outfile - close(outfile) - } - else if(system(cpcmd)!=0) - { - print "Attachment upload failed." - exit 1 - } - - if(system(chmodcmd)!=0) - { - print "Attachment chmod failed." - exit 1 - } - - tag="/aftertime/"argtab["story"]"/"attachtab["filename"] - text_HTML=text_HTML tag - text_BB=text_BB botcastleurl tag - } - else - { - - } - - } - - else - { - text_HTML = text_HTML text - text_BB = text_BB text - text = "" - } - - } - - # print text_HTML - # print text_BB - - debug="" - specialtab["HTML"]=bb2html(text_HTML) - specialtab["BBHTML"]=bb2bb(text_BB) - - cpcmd = cp" "inframe" "frame - chmodcmd = chmod" +r "frame - - ongtimecmd= ongtimecmd1 bstaargtab["ongtime"] ongtimecmd2 - ongtimecmd | getline ongtime - close(ongtimecmd) - - print ongtime - - if (state==4) - print sprintf("%04u ",f)ongtime > timefile - else - print sprintf("%04u ",f)ongtime >> timefile - close(timefile) - - if(system(cpcmd)!=0) - { - print "Frame upload failed." - exit 1 - } - - if(system(chmodcmd)!=0) - { - print "Frame chmod failed." - exit 1 - } - - # print debug - - for (i in specialtab) - { - if (i!="text") - print i"="specialtab[i] > specialfile - } - print "" > specialfile - if (specialtab["text"]!="") - printf("%s",specialtab["text"]) > specialfile - close (specialfile) - - - print sprintf("%u %u %u %u",2,f,0,0) > statefile - close (statefile) - - state=2 - ++f - - # exit 0 - } -} - -#limited compatibility with bsta data file format -function readdatafile (datafile, argtab, line,undertext,eq) -{ - line="" - while((getline line < datafile)>0) - { - gsub(/[\r\n]/, "", line) - - if (line == "" && !undertext) - { - undertext=1 - argtab["content"]="" - } - else if (undertext) - { - argtab["content"] = argtab["content"] line "\n" - } - else - { - eq = match(line, /(: |=)/) - - if (eq!=0) { - argtab[substr(line, 1, RSTART - 1)]=substr(line, RSTART + RLENGTH) - } - } - } - close (datafile) - - # return bstaargtab -} - -function bb2bb (text) -{ - gsub(/\[(fq|tq)\]/, "[quote]", text) - gsub(/\[\/(fq|tq)\]/, "[/quote]", text) - gsub(/\[br\]/, "[color=#BB6622]", text) - gsub(/\[ni\]/, "[color=#0057AF]", text) - gsub(/\[po\]/, "[color=#FF8800]", text) - gsub(/\[\/(br|ni|po)\]/, "[/color]", text) - - return htmlescape(text,"","br") -} - -function bb2html(text, depth,count,bbtree,html,tag,tagstart,taglength,elm,tagv,tagname,tagvalue,matchname) -{ - depth=0 - count[0]=1 - bbtree["0"]="" - bbtree["0.n"]=0 - bbtree["0.t"]="post" - bbtree["0.v"]=argtab["subject"] - html="" - # gsub(/=/,"=",text) - debug = debug "\n\nBuild BBcode tree:" - while(length(text)!=0) - { - tag=match(text, /\[\/?[a-z0-9\*]+(=(([^\[<>\"\]]*)|(\"[^\"<>]*\")))?\]/) - #"#\"" - if (tag==0) - { - debug = debug "\ntext: " text - bbtree[ind(count,depth)]=text - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - text="" - break; - } - tagstart=RSTART - taglength=RLENGTH - if(tagstart>1) - { - elm=substr(text,1,tagstart-1) - debug = debug "\ntext: " elm - bbtree[ind(count,depth)]=elm - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - } - tag=substr(text,tagstart,taglength) - text=substr(text,tagstart+taglength) - debug = debug "\ntag: " tag - if(tag!~/^\[\//) - { - tagv=index(tag,"=") - if(tagv<2) - { - tagname=substr(tag,2,length(tag)-2) - tagvalue="" - } - else - { - tagname=substr(tag,2,tagv-2) - tagvalue=substr(tag,tagv+1,length(tag)-tagv-1) - } - if(tagname !~ /^((fq)|(tq)|(ni)|(po)|(quote)|b|i|u|(code)|(img)|(url)|(size)|(color)|(center)|(right)|(sub)|(sup)|(s)|(spoiler)|(list)|(br)|(\*))$/) - { - debug = debug "\nunknown tag" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if((bbtree[indt(count,depth)".t"] == "code" && tagname!="code")||bbtree[indt(count,depth)".t"] == "img"||(bbtree[indt(count,depth)".t"] == "spoiler" && tagname=="spoiler")||(bbtree[indt(count,depth)".t"] == "size" && tagname=="size")) - { - debug = debug "\nthis tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if(tagname=="*") - { - if(bbtree[indt(count,depth)".t"]==tagname) - { - debug = debug "\nimplied tag: [/"tagname"]" - debug = debug "\nmatched" - bbtree[ind(count,depth)]="[/"tagname"]" - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]=tagname - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - else if(bbtree[indt(count,depth)".t"]!="list") - { - debug = debug "\nthis tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - } - debug = debug "\nname: " tagname " value: " tagvalue - bbtree[ind(count,depth)]=tagname" "tagvalue - bbtree[ind(count,depth)".k"]="s" - bbtree[indt(count,depth)".n"]=count[depth] - ++depth - count[depth]=1 - bbtree[indt(count,depth)]=tag - bbtree[indt(count,depth)".n"]=0 - bbtree[indt(count,depth)".t"]=tagname - bbtree[indt(count,depth)".v"]=tagvalue - - # if(tagname=="br") #or other single tags in the future - # { - # debug = debug "\nmatched" - # bbtree[ind(count,depth)]=tag - # bbtree[ind(count,depth)".k"]="e" - # bbtree[ind(count,depth)".m"]=1 - # bbtree[ind(count,depth)".t"]=tagname - # bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - # bbtree[indt(count,depth)".n"]=count[depth] - # bbtree[indt(count,depth)".m"]=1 - # count[depth]="" - # --depth - # ++count[depth] - # } - } - else - { - if(depth<=0) - { - debug = debug "\n""unmatched" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - tagname=substr(tag,3,length(tag)-3) - if(tagname=="list"&&bbtree[indt(count,depth)".t"]=="*") - { - debug = debug "\nimplied tag: [/*]" - debug = debug "\nmatched" - bbtree[ind(count,depth)]="[/*]" - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]="*" - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - debug = debug "\nname: " tagname - matchname=bbtree[indt(count,depth)".t"] - if((bbtree[indt(count,depth)".t"] == "code" && tagname!="code")||(bbtree[indt(count,depth)".t"] == "img" && tagname != "img")) - { - debug = debug "\nthis tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if(tagname!=matchname) - { - debug = debug "\nmismatched: " matchname - # bbtree[ind(count,depth)]=tag - # bbtree[indt(count,depth)".n"]=count[depth] - # ++count[depth] - # continue - bbtree[ind(count,depth)]=tag - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".t"]=bbtree[indt(count,depth)".t"] - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - count[depth]="" - --depth - ++count[depth] - continue - } - debug = debug "\nmatched" - bbtree[ind(count,depth)]=tag - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]=tagname - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - } - if(depth>0) - debug = debug "\nunclosed tags: " depth - - debug = debug "\n\n""generate HTML:" - depth=0 - count[0]=0 - while(count[0]<=bbtree["0.n"]&&depth>=0) - { - if(count[depth]==0) - { - tag=bbtree[indt(count,depth)] - tagname=bbtree[indt(count,depth)".t"] - tagvalue=bbtree[indt(count,depth)".v"] - debug = debug "\nname: "tagname" value: "tagvalue" elements: "bbtree[indt(count,depth)".n"] - if(tagname == "post") - { - } - else if(bbtree[indt(count,depth)".m"]=="") - { - debug = debug "\nunmatched" - html = html htmlescape(tag) - } - else if(tagname == "quote") - { - if (tagvalue=="") - { - html = html "
" - } - else - { - if(tagvalue !~ /^\".*\"$/) - #"#\"" - tagvalue="You forgot about the quote marks, "htmlescape(tagvalue) - else - tagvalue=bb2html(substr(tagvalue,2,length(tagvalue)-2)) - html = html "
"tagvalue" wrote:
" - } - } - else if (tagname == "fq") - { - html = html"
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "tq") - { - html = html"
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "br") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "ni") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "po") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "b") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "i") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "u") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "code") - { - if(bbtree[indtu(count,depth)".t"] == "code") - { - html=html htmlescape(tag) - debug = debug "\nnot a tag, actually" - } - else - { - html=html"
Code: Select all
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - } - else if (tagname == "img") - html=html"" - } - else if (tagname == "size") - { - if (tagvalue==""||(tagvalue !~ /^[0-9]+$/)||(tagvalue+0)>200) - html=html" This tag should have a correct value. " - else - html=html"" - } - else if (tagname == "color") - { - if (tagvalue==""||tagvalue !~ /^#[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]$/) #for some reason /^([0-9A-F]{6})$/ doesn't work. - html=html" This tag should have a correct value. " - else - html=html"" - } - else if (tagname ~ /^((center)|(right))$/) - { - html=html"
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="s") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="sub") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="sup") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname=="spoiler") - { - html=html"
Spoiler:
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname=="list") - { - if(tagvalue=="") - html=html"
    " - else - { - if (tagvalue=="1") - tagvalue="decimal" - else if (tagvalue=="i") - tagvalue="lower-roman" - else if (tagvalue=="I") - tagvalue="upper-roman" - else if (tagvalue=="a") - tagvalue="lower-alpha" - else if (tagvalue=="A") - tagvalue="upper-alpha" - else - { - html=html"This tag should have a correct value. " - tagvalue="decimal" - } - html=html"
      " - } - } - else if (tagname=="*") - { - html=html"
    1. " - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - # else if (tagname == "br") - # { - # html = html"
      " - # if(tagvalue!="") - # html=html"This tag shouldn't have any value. " - # } - else - { - debug = debug "\nunknown tag" - html = html htmlescape(tag) - } - ++count[depth] - } - else if(bbtree[ind(count,depth)".k"]=="s") - { - debug = debug "\nentering tag:" - ++depth - count[depth]=0 - } - else if(bbtree[ind(count,depth)".k"]=="e") - { - debug = debug "\nleaving tag:" - tag=bbtree[ind(count,depth)] - tagname=bbtree[ind(count,depth)".t"] - tagvalue=bbtree[ind(count,depth)".v"] - debug = debug "\nname: "tagname" value: "tagvalue - if (tagname == "post") - { - } - else if(bbtree[ind(count,depth)".m"]=="") - { - debug = debug "\nunmatched" - html = html htmlescape(tag) - } - else if(tagname == "quote") - html = html "
" - else if (tagname ~/^(b|i|u|(size)|(color)|(br)|(ni)|(po))$/) - html = html"" - else if (tagname == "code") - { - if(bbtree[indtu(count,depth)".t"] == "code") - { - html=html htmlescape(tag) - debug = debug "\nnot a tag, actually" - } - else - html = html"" - } - else if (tagname == "img") - { - html = html"\" alt=\"Image\" />" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if(tagname=="url") - html=html"" - else if (tagname ~ /^((center)|(right)|(fq)|(tq))$/) - html=html"
" - else if (tagname =="s") - html=html"" - else if (tagname =="sub") - html=html"" - else if (tagname =="sup") - html=html"" - else if (tagname=="spoiler") - html=html"" - else if (tagname=="list") - { - if (tagvalue=="") - html=html"" - else - html=html"" - } - else if (tagname=="*") - html=html"" - # else if (tagname == "br") # - # { - # # - # } - else - { - debug = debug "\nunknown tag" - html = html htmlescape(tag) - } - count[depth]="" - --depth - ++count[depth] - } - else if(count[depth]>bbtree[indt(count,depth)".n"]) - { - debug = debug "\nrun out of elements in this tag; leaving" - count[depth]="" - --depth - ++count[depth] - } - else - { - tag=bbtree[ind(count,depth)] - debug = debug "\ntext: "tag - - tag=htmlescape(tag,"","br") - - if(bbtree[indt(count,depth)".t"] == "code") - { - gsub(/ /,"\\ ",tag) - gsub(/\t/,"\\ \\ ",tag) - } - else{ - gsub(/ /,"\\  ",tag) - gsub(/ /," \\ ",tag) - # gsub(/
/,"
\\ ",tag) - } - - - if(nourl==""&& bbtree[indt(count,depth)".t"] !~ /^((code)|(img)|(url))$/) - gsub(/https?:\/\/[^\n\r\t<> ]+/,"&",tag) - # if(nosmil=="" && bbtree[indt(count,depth)".t"] !~ /^((code)|(img))$/) - # { - # gsub(/(^|[\n\r\t ]):D($|[\n\r\t ])/," \":D\" ",tag) - # gsub(/(^|[\n\r\t ]):\)($|[\n\r\t ])/," \":)\" ",tag) - # gsub(/(^|[\n\r\t ]):\(($|[\n\r\t ])/," \":(\" ",tag) - # gsub(/(^|[\n\r\t ]):o($|[\n\r\t ])/," \":o\" ",tag) - # gsub(/(^|[\n\r\t ]):shock:($|[\n\r\t ])/," \":shock:\" ",tag) - # gsub(/(^|[\n\r\t ]):\?($|[\n\r\t ])/," \":?\" ",tag) - # gsub(/(^|[\n\r\t ])8-\)($|[\n\r\t ])/," \"8-)\" ",tag) - # gsub(/(^|[\n\r\t ]):lol:($|[\n\r\t ])/," \":lol:\" ",tag) - # gsub(/(^|[\n\r\t ]):x($|[\n\r\t ])/," \":x\" ",tag) - # gsub(/(^|[\n\r\t ]):P($|[\n\r\t ])/," \":P\" ",tag) - # gsub(/(^|[\n\r\t ]):oops:($|[\n\r\t ])/," \":oops:\" ",tag) - # gsub(/(^|[\n\r\t ]):cry:($|[\n\r\t ])/," \":cry:\" ",tag) - # gsub(/(^|[\n\r\t ]):evil:($|[\n\r\t ])/," \":evil:\" ",tag) - # gsub(/(^|[\n\r\t ]):twisted:($|[\n\r\t ])/," \":twisted:\" ",tag) - # gsub(/(^|[\n\r\t ]):roll:($|[\n\r\t ])/," \":roll:\" ",tag) - # gsub(/(^|[\n\r\t ]):wink:($|[\n\r\t ])/," \":wink:\" ",tag) - # gsub(/(^|[\n\r\t ]);\)($|[\n\r\t ])/," \":wink:\" ",tag) - # gsub(/(^|[\n\r\t ]):!:($|[\n\r\t ])/," \":!:\" ",tag) - # gsub(/(^|[\n\r\t ]):\?:($|[\n\r\t ])/," \":?:\" ",tag) - # gsub(/(^|[\n\r\t ]):idea:($|[\n\r\t ])/," \":idea:\" ",tag) - # gsub(/(^|[\n\r\t ]):arrow:($|[\n\r\t ])/," \":arrow:\" ",tag) - # gsub(/(^|[\n\r\t ]):\|($|[\n\r\t ])/," \":|\" ",tag) - # gsub(/(^|[\n\r\t ]):mrgreen:($|[\n\r\t ])/," \":mrgreen:\" ",tag) - # } - - html = html tag - ++count[depth] - } - } - debug = debug "\ndone\n" - return html -} - -function ind(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii<=depth;++ii) - { - if(ii!=0) - iindex = iindex "." - iindex = iindex count[ii] - } - # debug = debug "\n" iindex - return iindex -} -function indt(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii0) - iindex=iindex"." - iindex = iindex "0" - # debug = debug "\n" iindex - return iindex -} -function indtu(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii0) - iindex=iindex"." - iindex = iindex "0" - # debug = debug "\n" iindex - return iindex -} -function htmlescape(name,less,br, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if(ch == "\n") - escaped = escaped ((br!="")?"
":"&#"ch2dec[ch]";") - else if(ch =="\r") - escaped = escaped ((br!="")?"":"&#"ch2dec[ch]";") - else if(ch == "\"" && less=="") - escaped = escaped "&#"ch2dec[ch]";" - else if(ch ~ /[=<>&]/) - escaped = escaped "&#"ch2dec[ch]";" - else - escaped = escaped ch - } - return escaped -} -function hexencode(name, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1) - escaped = escaped ch2hex[ch] - } - return escaped -} - diff --git a/ong-mscha-t-1.awk b/ong-mscha-t-1.awk deleted file mode 100644 index 7f03aa3..0000000 --- a/ong-mscha-t-1.awk +++ /dev/null @@ -1,207 +0,0 @@ -#// ong-mscha-t-1.awk -#// The bot to ketchup frames from the mschaviewer, and enhance by remapping -#// 12.02.2019 -#// -#// Copyright (C) 2015, 2019 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . -#// -BEGIN{ - FS="" - framepath="/eizm/www/time/" - datapath="/eizm/data/aftertime/" - temppath="/eizm/tmp/aftertime/" - passpath="/eizm/mem/aftertime/pass/" - - timecmd="date -u +%Y%m%d%H%s" - - cp="/bin/cp" - mawk="/usr/bin/mawk" - wget="/usr/bin/wget" - remap="/eizm/pro/aftertime/remapt-1" - npb="/eizm/pro/ong1/npb" - bot4awk="/eizm/pro/aftertime/bot4.awk" - uploadawk="/eizm/pro/aftertime/upload.awk" -} -{ - file=1 - gsub(/[\r\n]/, "", $0) - eq=index($0, "=") - - argtab[substr($0, 1, eq-1)]=substr($0, eq+1) -} -END{ - - if (file=="") - { - print "No data." - exit 1 - } - - if(argtab["ongoing"]!="2") - { - print "Story is not externally onged." - exit 1 - } - - # timecmd | getline thistime - # close(timecmd) - - statefile= datapath argtab["story"]"/ongstate" - passfile= passpath argtab["story"] - getline temp < statefile - getline alt < statefile - close(statefile) - - split(temp, temptab, " ") - state=int(temptab[1]) - last=int(temptab[2]) - - f=last+1 - - nextstate="2" - - tempfile = temppath "ongmscha-"argtab["story"]"--1" - tempfile2 = temppath "ongmscha-"argtab["story"]"--2" - optionfile = datapath argtab["story"]"/settings" - framedir = "aftertime/"argtab["story"]"/" - - # system("sleep 15") - while(1) - { - - - timecmd | getline thistime - close(timecmd) - - timetext = substr(thistime,1,10); - timenumber = substr(thistime,11); - - print f" "timetext" "timenumber - - newalt="" - frameurl= sprintf(argtab["otherviewerframe"],f) - viewerurl= sprintf(argtab["otherviewerurl"],f) - - frame= framepath framedir sprintf(argtab["frame"],f) - npbframe= framepath framedir sprintf(argtab["npbframe"],f) - - remapframe= framepath framedir sprintf(argtab["frame-1"],f) - npbremapframe= framepath framedir sprintf(argtab["npbframe-1"],f) - - getfcmd= wget " -q -O " frame " "frameurl - getvcmd= wget " -q -O " tempfile " "viewerurl - npbcmd= sprintf(npb " %s %s q",frame,npbframe) - ongcmd= mawk" -f " bot4awk" -v story="argtab["story"]" -v frame="last" "optionfile - ongremapcmd= mawk" -f " bot4awk" -v story="argtab["story"]" -v frame="last" -v enhance=1 "optionfile - npbremapcmd= sprintf(npb " %s %s q",remapframe,npbremapframe) - addhashcmd= mawk" -f "uploadawk" -v timenumber="timenumber" -v timetext="timetext" -v tempfile="tempfile" "tempfile2 - - if(system(getfcmd)!=0) - { - print "Frame download failed: "getfcmd - break - } - system("sleep 2") - - if(system(getvcmd)!=0) - { - print "Viewer download failed: "getvcmd - break - } - system("sleep 1") - - foundalt="" - foundpal="" - while ((getline temp < tempfile) > 0) - { - if(index(temp,frameurl)!=0 && foundalt=="") - { - newalt=substr(temp,index(temp,"title=\"")+7) - newalt=substr(newalt,1,index(newalt,"\"")-1) - foundalt=1 - print "alt: "newalt - } - if(index(temp,"class=\"hash\"")!=0 && foundpal=="" ) - { - pal=substr(temp,index(temp,">")+1) - pal=substr(pal,1,index(pal,".")-1) - foundpal=1 - print "pal: "pal - } - if(foundalt!="" && foundpal!="") - break; - } - close(tempfile) - # if(newalt=="") - # break - - remapcmd= remap " "frame" "remapframe" "pal - - if(newalt!=alt) - { - print f"="newalt >> optionfile - close(optionfile) - } - - if(system(npbcmd)!=0) - break - - last=f - print "ONG "f" "((alt==newalt)?"":""newalt) - - if(system(remapcmd)==0) - { - if(system(npbremapcmd)!=0) - break - } - - if(foundpal){ - getline namef < passfile - getline passf < passfile - close (passfile) - if(namef!="" &&passf !="") - { - print namef > tempfile2 - print passf > tempfile2 - print "" > tempfile2 - print argtab["story"]"#"f"#1" > tempfile2 - print "su" > tempfile2 - print substr(timetext,1,4)"-"substr(timetext,5,2)"-"substr(timetext,7,2)" "substr(timetext,9,2) > tempfile2 - print "Original filename" > tempfile2 - print "[code]"pal".png[/code]"> tempfile2 - print "" > tempfile2 - close (tempfile2) - - system(addhashcmd) - } - } - - # must be changed! - # if (post!="") - # { - # system(ongcmd) - # system("sleep 5") - # system(ongremapcmd) - # } - - alt=newalt - - print nextstate" "f > statefile - print newalt > statefile - close(statefile) - - ++f - } -} diff --git a/ong-mscha.awk b/ong-mscha.awk deleted file mode 100644 index 7895f64..0000000 --- a/ong-mscha.awk +++ /dev/null @@ -1,129 +0,0 @@ -#// ong-mscha.awk -#// The bot to ketchup frames from the mshcaviewer -#// 14.09.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - FS="" - framepath="/eizm/www/time/" - datapath="/eizm/data/aftertime/" - temppath="/eizm/tmp/aftertime/" - - # timecmd="date +\"%H\"" - - cp="/bin/cp" - mawk="/usr/bin/mawk" - wget="/usr/bin/wget" - bot4awk="/eizm/pro/aftertime/bot4.awk" -} -{ - file=1 - gsub(/[\r\n]/, "", $0) - eq=index($0, "=") - - argtab[substr($0, 1, eq-1)]=substr($0, eq+1) -} -END{ - - if (file=="") - exit 1 - - if(argtab["ongoing"]!="2") - exit 1 - - # timecmd | getline thistime - # close(timecmd) - - statefile= datapath argtab["story"]"/ongstate" - getline temp < statefile - getline alt < statefile - close(statefile) - - split(temp, temptab, " ") - state=int(temptab[1]) - last=int(temptab[2]) - - f=last+1 - - nextstate="2" - - tempfile = temppath "ongmscha-"argtab["story"] - optionfile = datapath argtab["story"]"/settings" - framedir = "aftertime/"argtab["story"]"/" - - while(1) - { - newalt="" - frameurl= sprintf(argtab["otherviewerframe"],f) - viewerurl= sprintf(argtab["otherviewerurl"],f) - - frame= framepath framedir sprintf(argtab["frame"],f) - npbframe= framepath framedir sprintf(argtab["npbframe"],f) - - getfcmd= wget " -q -O " frame " "frameurl - getvcmd= wget " -q -O " tempfile " "viewerurl - npbcmd= sprintf("/eizm/pro/ong1/npb %s %s q",frame,npbframe) - ongcmd = mawk" -f " bot4awk" -v story="argtab["story"]" -v frame="last" "optionfile - - # print getfcmd - if(system(getfcmd)!=0) - break - - - # print getvcmd - if(system(getvcmd)!=0) - break - - while ((getline temp < tempfile) > 0) - { - if(index(temp,frameurl)!=0) - { - newalt=substr(temp,index(temp,"title=\"")+7) - newalt=substr(newalt,1,index(newalt,"\"")-1) - break - } - } - close(tempfile) - # if(newalt=="") - # break - - - if(newalt!=alt) - { - print f"="newalt >> optionfile - close(optionfile) - } - - # print npbcmd - if(system(npbcmd)!=0) - break - - last=f - print "ONG "f" "((alt==newalt)?"":""newalt) - - if (post!="") - system(ongcmd) - - alt=newalt - - print nextstate" "f > statefile - print newalt > statefile - close(statefile) - - ++f - } -} diff --git a/ong.awk b/ong.awk deleted file mode 100644 index f6dc1ab..0000000 --- a/ong.awk +++ /dev/null @@ -1,1145 +0,0 @@ -#// ong.awk -#// The bot to ONG new frames to the viewer. -#// 28.08.2020 -#// -#// Copyright (C) 2015, 2018-2020 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - - -BEGIN{ - FS="" - framepath="/eizm/www/time/" - datapath="/eizm/data/aftertime/" - - # timecmd="date +\"%H\"" - timecmd2="date -u +\"%Y-%m-%d %H:%M:%S\"" - timecmd3="date -u +\"%s\"" - - cp="/bin/cp" - mawk="/usr/bin/mawk" - bot4awk="/eizm/pro/aftertime/bot4.awk" - chmod="/bin/chmod" - npb="/eizm/pro/ong1/npb" - - timecmd2 | getline thistime2 - close(timecmd2) - timecmd3 | getline thistime3 - close(timecmd3) - # timecmd | getline thistime - # close(timecmd) - - thistime3 -= thistime3%3600 - - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i) - dec=sprintf("%u",i) - ch2hex[ch]=hex - ch2dec[ch]=dec - } -} -{ - file=1 - gsub(/[\r\n]/, "", $0) - eq=index($0, "=") - - argtab[substr($0, 1, eq-1)]=substr($0, eq+1) -} -END{ - - print "" - print thistime2" "argtab ["story"] - - if (file=="") - { - print "No data." - exit 1 - } - - if(int(argtab["ongoing"])!=1) - { - print "story is not onged from here." - exit 1 - } - - # # replace with actual better conditions - # if(int(thistime) % int(argtab["ongtime"]) != 0) - # { - # print "Not ongtime yet." - # exit 1 - # } - - framedir = "aftertime/"argtab["story"]"/" - - temp="" - statefile= datapath argtab["story"]"/ongstate" - getline temp < statefile - close(statefile) - - split(temp, temptab, " ") - state=int(temptab[1]) - last=int(temptab[2]) - nextong=int(temptab[3]) - ongfailcount=int(temptab[4]) - enhance=int(argtab["enhance"]) - - specialtab[0]="" - effectivetab[0]="" - - # temp="" - # updatefile= datapath argtab["story"]"/update" - # getline temp < updatefile - # close(updatefile) - - timefile= datapath argtab["story"]"/ongtime" - - if (state == 1 || state ==2) - { - updatefail="" - temp="" - updatefile= datapath argtab["story"]"/update" - # timefile= datapath argtab["story"]"/ongtime" - - updated="" - - while((getline temp < updatefile)>0) - { - if (temp !~ /^([0-9]+[a-z]?)|(c)$/) - continue - - if(timeread=="") - { - while((getline line < timefile)>0) - { - ongind=index(line," ") - ongft=substr(line,1,ongind-1) - ongt=substr(line,ongind+1) - - if(ongft ~ /^[0-9]+[a-z]$/) - ongf=int(substr(ongft,1,ongind-2)) substr(ongft,ongind-1,1) - else - ongf=int(ongft) - - timetab[ongft]=ongt - } - close(timefile) - timeread=1 - } - - if(temp=="c") - { - print "Update CFRT." - if (argtab["cfrt"]=="") - { - print "There is no cfrt frame." - continue - } - inframe[0]= datapath argtab["story"]"/"argtab["cfrt"] - - frame[0]= framepath framedir argtab["cfrt"] - - cpcmd[0] = cp" "inframe[0]" "frame[0] - chmodcmd[0] = chmod" +r "frame[0] - } - else - { - if (temp ~ /[a-z]$/) - { - i=int(substr(temp,1,length(temp)-1)) - j=substr(temp, length(temp)) - } - else - { - i = int(temp) - j = "" - } - - print "Update frame "i j"." - - if(argtab["special"] != "") - { - specialfile=datapath argtab["story"]"/"sprintf(argtab["special"],i,j) - readspecialfile(specialfile,argtab,specialtab,effectivetab) - } - else - { - readspecialfile("",argtab,specialtab,effectivetab) - } - if ((i < int(argtab["first"]))||(i > last)) - { - print (i j" not onged yet.") - continue - } - - if(j!="") - { - if(argtab["sf-"i]=="") - { - print (i" doesn't have meteor frames.") - continue - } - else if(j > argtab["sf-"i]) - { - print (j" is not a meteor frame of "i".") - continue - } - - } - for (k=0; k<=enhance; ++k) - { - k2=(k>0)?("-"k):"" - inframe[k]= datapath argtab["story"]"/"sprintf(effectivetab["inframe"k2],i,j) - - frame[k]= framepath framedir sprintf(effectivetab["frame"k2],i,j) - npbframe[k]= framepath framedir sprintf(effectivetab["npbframe"k2],i,j) - - npbcmd[k]= npb" "inframe[k]" "npbframe[k]" q" - cpcmd[k] = cp" "inframe[k]" "frame[k] - chmodcmd[k] = chmod" +r "frame[k] - } - if (specialtab["text"]!="") - { - specialtab["HTML"]=bb2html(specialtab["text"]) - writespecialfile(specialfile,specialtab) - # print debug - } - } - - if(temp!="c" && timetab[sprintf("%04u%s",i,j)]=="") - { - print sprintf("%04u%s",i,j)" "thistime2 >> timefile - close(timefile) - timetab[sprintf("%04u%s",i,j)]=thistime2 - } - - for(k=0; k<=enhance; ++k) - { - k2=(k>0)?("-"k):"" - - if ((system("[ -f " inframe[k]" ]")!=0)&&(k>0)) - continue - - if((argtab["npbframe"]!="") && (temp!="c")) - { - if(system(npbcmd[k])!=0) - { - print i j k2" NewpixbOTTification failed." - updatefail=1 - break - } - } - if(system(cpcmd[k])!=0) - { - print i j k2" Upload failed." - updatefail=1 - break - } - if(system(chmodcmd[k])!=0) - { - print "Chmod failed." - updatefail=1 - break - } - if(temp=="c") - { - break - } - } - if (updatefail) - { - break #come up with other aproach - } - updated=1 - print "Updated." - } - close(updatefile) - if (!updatefail && updated) - { - print "" > updatefile - close(updatefile) - } - } - - firstong="" - if (state==4) { - print "Time to start onging." - firstong=1 - nextong=0 - } - else if(state<1 || state>2) - { - print "Onging not active." - exit 1 - } - else if(thistime3 statefile - close(statefile) - print "Nobody saw frame "last" yet. Wait until "nextong"." - exit 1 - } - - if(thistime30)?("-"k):"" - - inframe[k]= datapath argtab["story"]"/"sprintf(effectivetab["inframe"k2],f,"") - - if (system("[ -f " inframe[k] " ]")!=0) - { - if(k>0) #we only care about missing original frame - { - continue - } - ++ongfailcount - print "Frame "f" doesnt't exist. (#"ongfailcount")" - - print sprintf("%u %u %u %u",state,last,nextong,ongfailcount) > statefile - close(statefile) - - if((argtab["finalreplaceframe"]!="") && (argtab["finalreplacetime"]!="")) - { - if(((thistime3 - nextong) >= int(argtab["finalreplacetime"])*3600) && (ongfailcount>=int(argtab["finalreplacetime"]))) - { - print "Time to stop trying." - print "ONG final replacement frame." - inframe[0]= datapath argtab["story"]"/"argtab["finalreplaceframe"] - nextstate=3 - } - else - exit 1 - } - else - exit 1 - } - - frame[k]= framepath framedir sprintf(effectivetab["frame"k2],f,"") - npbframe[k]= framepath framedir sprintf(effectivetab["npbframe"k2],f,"") - - - npbcmd[k]= npb" "inframe[k]" "npbframe[k]" q" - cpcmd[k] = cp" "inframe[k]" "frame[k] - chmodcmd[k] = chmod" +r "frame[k] - } - ongcmd = mawk" -f " bot4awk" -v story="argtab["story"]" -v frame="last" "datapath argtab["story"]"/settings" -# nextong = thistime3 + int(argtab["ongtime"])*3600 - nextong = getnextongtime() - ### replace this with actual onging!!! - # system("/eizm/pro/ong1/bot4") - - if (specialtab["text"]!="") - { - specialtab["HTML"]=bb2html(specialtab["text"]) - writespecialfile(specialfile,specialtab) - } - - # timefile= datapath argtab["story"]"/ongtime" - print sprintf("%04u ",f)thistime2 >> timefile - close(timefile) - - for(k=0; k<=enhance; ++k) - { - k2=(k>0)?("-"k):"" - - if ((system("[ -f " inframe[k]" ]")!=0)&&(k>0)) - continue - - if(argtab["npbframe"]!="") - { - if(system(npbcmd[k])!=0) - { - print "NewpixbOTTification"k2" failed." - exit 1 - } - } - - if(system(cpcmd[k])!=0) - { - print "Frame"k2" upload failed." - exit 1 - } - - if(system(chmodcmd[k])!=0) - { - print "Frame"k2" chmod failed." - exit 1 - } - } - print sprintf("%u %u %u 0",nextstate,f,nextong) > statefile - close(statefile) - - print sprintf("ONGed. Next ong %u.",nextong) - - # add condition here. - # Ok, done. - - if (!firstong) - { - ongbotfile= datapath argtab["story"] "/" ((argtab["ongbot"]!="")?argtab["ongbot"]:"ongbot") - if (system("[ -f " ongbotfile " ]")==0) - system(ongcmd) - } -} - -function getnextongtime( schedulefile,temp,i) -{ - schedulefile= datapath argtab["story"]"/schedule" - - while((getline temp < schedulefile)>0) - { - if (temp !~ /^[0-9]+$/) - continue - - i = int(temp) - # print i - - if(i>thistime3) - { - close(schedulefile) - print "ok" - return i - } - } - close(schedulefile) - return thistime3 + int(argtab["ongtime"])*3600 -} - -function readspecialfile (datafile, argtab, specialtab, effectivetab, line,undertext,eq,i) -{ - for (i in specialtab) - delete specialtab[i] - - for (i in effectivetab) - delete effectivetab[i] - - if (datafile=="") - return - - line="" - while((getline line < datafile)>0) - { - gsub(/[\r\n]/, "", line) - - if (line == "" && !undertext) - { - undertext=1 - specialtab["text"]="" - } - else if (undertext) - { - specialtab["text"] = specialtab["text"] line "\n" - } - else - { - eq=index(line, "=") - specialtab[substr(line, 1, eq-1)]=substr(line, eq+1) - } - } - - for (i in argtab) - effectivetab[i]=argtab[i] - - for (i in specialtab) - effectivetab[i]=specialtab[i] - - - close (datafile) - -} - -function writespecialfile (datafile, specialtab, i) -{ - for (i in specialtab) - { - if (i!="text") - print i"="specialtab[i] > specialfile - } - - print "" > specialfile - if (specialtab["text"]!="") - printf("%s",specialtab["text"]) > specialfile - close (specialfile) -} - -#HTML STUFF FROM HERE -function bb2html(text, depth,count,bbtree,html,tag,tagstart,taglength,elm,tagv,tagname,tagvalue,matchname) -{ - depth=0 - count[0]=1 - bbtree["0"]="" - bbtree["0.n"]=0 - bbtree["0.t"]="post" - bbtree["0.v"]=argtab["subject"] - html="" - # gsub(/=/,"=",text) - debug = debug "\n\nBuild BBcode tree:" - while(length(text)!=0) - { - tag=match(text, /\[\/?[a-z0-9\*]+(=(([^\[<>\"\]]*)|(\"[^\"<>]*\")))?\]/) - #"#\"" - if (tag==0) - { - debug = debug "\ntext: " text - bbtree[ind(count,depth)]=text - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - text="" - break; - } - tagstart=RSTART - taglength=RLENGTH - if(tagstart>1) - { - elm=substr(text,1,tagstart-1) - debug = debug "\ntext: " elm - bbtree[ind(count,depth)]=elm - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - } - tag=substr(text,tagstart,taglength) - text=substr(text,tagstart+taglength) - debug = debug "\ntag: " tag - if(tag!~/^\[\//) - { - tagv=index(tag,"=") - if(tagv<2) - { - tagname=substr(tag,2,length(tag)-2) - tagvalue="" - } - else - { - tagname=substr(tag,2,tagv-2) - tagvalue=substr(tag,tagv+1,length(tag)-tagv-1) - } - if(tagname !~ /^((fq)|(tq)|(ni)|(po)|(quote)|b|i|u|(code)|(img)|(url)|(size)|(color)|(center)|(right)|(sub)|(sup)|(s)|(spoiler)|(list)|(br)|(\*))$/) - { - debug = debug "\nunknown tag" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if((bbtree[indt(count,depth)".t"] == "code" && tagname!="code")||bbtree[indt(count,depth)".t"] == "img"||(bbtree[indt(count,depth)".t"] == "spoiler" && tagname=="spoiler")||(bbtree[indt(count,depth)".t"] == "size" && tagname=="size")) - { - debug = debug "\nthis tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if(tagname=="*") - { - if(bbtree[indt(count,depth)".t"]==tagname) - { - debug = debug "\nimplied tag: [/"tagname"]" - debug = debug "\nmatched" - bbtree[ind(count,depth)]="[/"tagname"]" - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]=tagname - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - else if(bbtree[indt(count,depth)".t"]!="list") - { - debug = debug "\nthis tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - } - debug = debug "\nname: " tagname " value: " tagvalue - bbtree[ind(count,depth)]=tagname" "tagvalue - bbtree[ind(count,depth)".k"]="s" - bbtree[indt(count,depth)".n"]=count[depth] - ++depth - count[depth]=1 - bbtree[indt(count,depth)]=tag - bbtree[indt(count,depth)".n"]=0 - bbtree[indt(count,depth)".t"]=tagname - bbtree[indt(count,depth)".v"]=tagvalue - - # if(tagname=="br") #or other single tags in the future - # { - # debug = debug "\nmatched" - # bbtree[ind(count,depth)]=tag - # bbtree[ind(count,depth)".k"]="e" - # bbtree[ind(count,depth)".m"]=1 - # bbtree[ind(count,depth)".t"]=tagname - # bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - # bbtree[indt(count,depth)".n"]=count[depth] - # bbtree[indt(count,depth)".m"]=1 - # count[depth]="" - # --depth - # ++count[depth] - # } - } - else - { - if(depth<=0) - { - debug = debug "\n""unmatched" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - tagname=substr(tag,3,length(tag)-3) - if(tagname=="list"&&bbtree[indt(count,depth)".t"]=="*") - { - debug = debug "\nimplied tag: [/*]" - debug = debug "\nmatched" - bbtree[ind(count,depth)]="[/*]" - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]="*" - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - debug = debug "\nname: " tagname - matchname=bbtree[indt(count,depth)".t"] - if((bbtree[indt(count,depth)".t"] == "code" && tagname!="code")||(bbtree[indt(count,depth)".t"] == "img" && tagname != "img")) - { - debug = debug "\nthis tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if(tagname!=matchname) - { - debug = debug "\nmismatched: " matchname - # bbtree[ind(count,depth)]=tag - # bbtree[indt(count,depth)".n"]=count[depth] - # ++count[depth] - # continue - bbtree[ind(count,depth)]=tag - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".t"]=bbtree[indt(count,depth)".t"] - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - count[depth]="" - --depth - ++count[depth] - continue - } - debug = debug "\nmatched" - bbtree[ind(count,depth)]=tag - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]=tagname - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - } - if(depth>0) - debug = debug "\nunclosed tags: " depth - - debug = debug "\n\n""generate HTML:" - depth=0 - count[0]=0 - while(count[0]<=bbtree["0.n"]&&depth>=0) - { - if(count[depth]==0) - { - tag=bbtree[indt(count,depth)] - tagname=bbtree[indt(count,depth)".t"] - tagvalue=bbtree[indt(count,depth)".v"] - debug = debug "\nname: "tagname" value: "tagvalue" elements: "bbtree[indt(count,depth)".n"] - if(tagname == "post") - { - } - else if(bbtree[indt(count,depth)".m"]=="") - { - debug = debug "\nunmatched" - html = html htmlescape(tag) - } - else if(tagname == "quote") - { - if (tagvalue=="") - { - html = html "
" - } - else - { - if(tagvalue !~ /^\".*\"$/) - #"#\"" - tagvalue="You forgot about the quote marks, "htmlescape(tagvalue) - else - tagvalue=bb2html(substr(tagvalue,2,length(tagvalue)-2)) - html = html "
"tagvalue" wrote:
" - } - } - else if (tagname == "fq") - { - html = html"
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "tq") - { - html = html"
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "br") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "ni") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "po") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "b") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "i") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "u") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "code") - { - if(bbtree[indtu(count,depth)".t"] == "code") - { - html=html htmlescape(tag) - debug = debug "\nnot a tag, actually" - } - else - { - html=html"
Code: Select all
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - } - else if (tagname == "img") - html=html"" - } - else if (tagname == "size") - { - if (tagvalue==""||(tagvalue !~ /^[0-9]+$/)||(tagvalue+0)>200) - html=html" This tag should have a correct value. " - else - html=html"" - } - else if (tagname == "color") - { - if (tagvalue==""||tagvalue !~ /^#[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]$/) #for some reason /^([0-9A-F]{6})$/ doesn't work. - html=html" This tag should have a correct value. " - else - html=html"" - } - else if (tagname ~ /^((center)|(right))$/) - { - html=html"
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="s") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="sub") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="sup") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname=="spoiler") - { - html=html"
Spoiler:
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname=="list") - { - if(tagvalue=="") - html=html"
    " - else - { - if (tagvalue=="1") - tagvalue="decimal" - else if (tagvalue=="i") - tagvalue="lower-roman" - else if (tagvalue=="I") - tagvalue="upper-roman" - else if (tagvalue=="a") - tagvalue="lower-alpha" - else if (tagvalue=="A") - tagvalue="upper-alpha" - else - { - html=html"This tag should have a correct value. " - tagvalue="decimal" - } - html=html"
      " - } - } - else if (tagname=="*") - { - html=html"
    1. " - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - # else if (tagname == "br") - # { - # html = html"
      " - # if(tagvalue!="") - # html=html"This tag shouldn't have any value. " - # } - else - { - debug = debug "\nunknown tag" - html = html htmlescape(tag) - } - ++count[depth] - } - else if(bbtree[ind(count,depth)".k"]=="s") - { - debug = debug "\nentering tag:" - ++depth - count[depth]=0 - } - else if(bbtree[ind(count,depth)".k"]=="e") - { - debug = debug "\nleaving tag:" - tag=bbtree[ind(count,depth)] - tagname=bbtree[ind(count,depth)".t"] - tagvalue=bbtree[ind(count,depth)".v"] - debug = debug "\nname: "tagname" value: "tagvalue - if (tagname == "post") - { - } - else if(bbtree[ind(count,depth)".m"]=="") - { - debug = debug "\nunmatched" - html = html htmlescape(tag) - } - else if(tagname == "quote") - html = html "
" - else if (tagname ~/^(b|i|u|(size)|(color)|(br)|(ni)|(po))$/) - html = html"" - else if (tagname == "code") - { - if(bbtree[indtu(count,depth)".t"] == "code") - { - html=html htmlescape(tag) - debug = debug "\nnot a tag, actually" - } - else - html = html"" - } - else if (tagname == "img") - { - html = html"\" alt=\"Image\" />" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if(tagname=="url") - html=html"" - else if (tagname ~ /^((center)|(right)|(fq)|(tq))$/) - html=html"
" - else if (tagname =="s") - html=html"" - else if (tagname =="sub") - html=html"" - else if (tagname =="sup") - html=html"" - else if (tagname=="spoiler") - html=html"" - else if (tagname=="list") - { - if (tagvalue=="") - html=html"" - else - html=html"" - } - else if (tagname=="*") - html=html"" - # else if (tagname == "br") # - # { - # # - # } - else - { - debug = debug "\nunknown tag" - html = html htmlescape(tag) - } - count[depth]="" - --depth - ++count[depth] - } - else if(count[depth]>bbtree[indt(count,depth)".n"]) - { - debug = debug "\nrun out of elements in this tag; leaving" - count[depth]="" - --depth - ++count[depth] - } - else - { - tag=bbtree[ind(count,depth)] - debug = debug "\ntext: "tag - - tag=htmlescape(tag,"","br") - - if(bbtree[indt(count,depth)".t"] == "code") - { - gsub(/ /,"\\ ",tag) - gsub(/\t/,"\\ \\ ",tag) - } - else{ - gsub(/ /,"\\  ",tag) - gsub(/ /," \\ ",tag) - # gsub(/
/,"
\\ ",tag) - } - - - if(nourl==""&& bbtree[indt(count,depth)".t"] !~ /^((code)|(img)|(url))$/) - gsub(/https?:\/\/[^\n\r\t<> ]+/,"&",tag) - # if(nosmil=="" && bbtree[indt(count,depth)".t"] !~ /^((code)|(img))$/) - # { - # gsub(/(^|[\n\r\t ]):D($|[\n\r\t ])/," \":D\" ",tag) - # gsub(/(^|[\n\r\t ]):\)($|[\n\r\t ])/," \":)\" ",tag) - # gsub(/(^|[\n\r\t ]):\(($|[\n\r\t ])/," \":(\" ",tag) - # gsub(/(^|[\n\r\t ]):o($|[\n\r\t ])/," \":o\" ",tag) - # gsub(/(^|[\n\r\t ]):shock:($|[\n\r\t ])/," \":shock:\" ",tag) - # gsub(/(^|[\n\r\t ]):\?($|[\n\r\t ])/," \":?\" ",tag) - # gsub(/(^|[\n\r\t ])8-\)($|[\n\r\t ])/," \"8-)\" ",tag) - # gsub(/(^|[\n\r\t ]):lol:($|[\n\r\t ])/," \":lol:\" ",tag) - # gsub(/(^|[\n\r\t ]):x($|[\n\r\t ])/," \":x\" ",tag) - # gsub(/(^|[\n\r\t ]):P($|[\n\r\t ])/," \":P\" ",tag) - # gsub(/(^|[\n\r\t ]):oops:($|[\n\r\t ])/," \":oops:\" ",tag) - # gsub(/(^|[\n\r\t ]):cry:($|[\n\r\t ])/," \":cry:\" ",tag) - # gsub(/(^|[\n\r\t ]):evil:($|[\n\r\t ])/," \":evil:\" ",tag) - # gsub(/(^|[\n\r\t ]):twisted:($|[\n\r\t ])/," \":twisted:\" ",tag) - # gsub(/(^|[\n\r\t ]):roll:($|[\n\r\t ])/," \":roll:\" ",tag) - # gsub(/(^|[\n\r\t ]):wink:($|[\n\r\t ])/," \":wink:\" ",tag) - # gsub(/(^|[\n\r\t ]);\)($|[\n\r\t ])/," \":wink:\" ",tag) - # gsub(/(^|[\n\r\t ]):!:($|[\n\r\t ])/," \":!:\" ",tag) - # gsub(/(^|[\n\r\t ]):\?:($|[\n\r\t ])/," \":?:\" ",tag) - # gsub(/(^|[\n\r\t ]):idea:($|[\n\r\t ])/," \":idea:\" ",tag) - # gsub(/(^|[\n\r\t ]):arrow:($|[\n\r\t ])/," \":arrow:\" ",tag) - # gsub(/(^|[\n\r\t ]):\|($|[\n\r\t ])/," \":|\" ",tag) - # gsub(/(^|[\n\r\t ]):mrgreen:($|[\n\r\t ])/," \":mrgreen:\" ",tag) - # } - - html = html tag - ++count[depth] - } - } - debug = debug "\ndone\n" - return html -} - -function ind(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii<=depth;++ii) - { - if(ii!=0) - iindex = iindex "." - iindex = iindex count[ii] - } - # debug = debug "\n" iindex - return iindex -} -function indt(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii0) - iindex=iindex"." - iindex = iindex "0" - # debug = debug "\n" iindex - return iindex -} -function indtu(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii0) - iindex=iindex"." - iindex = iindex "0" - # debug = debug "\n" iindex - return iindex -} -function htmlescape(name,less,br, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if(ch == "\n") - escaped = escaped ((br!="")?"
":"&#"ch2dec[ch]";") - else if(ch =="\r") - escaped = escaped ((br!="")?"":"&#"ch2dec[ch]";") - else if(ch == "\"" && less=="") - escaped = escaped "&#"ch2dec[ch]";" - else if(ch ~ /[=<>&]/) - escaped = escaped "&#"ch2dec[ch]";" - else - escaped = escaped ch - } - return escaped -} -function hexencode(name, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1) - escaped = escaped ch2hex[ch] - } - return escaped -} - - - - - - - - - - - diff --git a/pleaseong.c b/pleaseong.c deleted file mode 100644 index eb81ac0..0000000 --- a/pleaseong.c +++ /dev/null @@ -1,70 +0,0 @@ -// pleaseong.c (1190.bicyclesonthemoon.info/aftertime/pleaseongthis) -// Ask the bot to post the frame -// 16.09.2015 -// -// Copyright (C) 2015 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#define STORYDEF_PRINTF "/eizm/data/aftertime/%s/settings" -#define MAWK_PATH "/usr/bin/mawk" -#define AWK_BOT4 "/eizm/pro/aftertime/bot4.awk" - -#include -#include -#include -#include -#include -#include - -s_cgi *cgi; - -int main (int argc, char *argv[]) -{ - s_cgi *cgi; - pid_t sub; - int r; - - char *story; - char *e; - char arg1[256]; - char arg2[256]; - char storydef[256]; - - cgi=cgiInit(); - - setvbuf(stdout, NULL, _IONBF, 0); - dup2(fileno(stdout),fileno(stderr)); - - story=cgiGetValue(cgi,"story"); - e=cgiGetValue(cgi,"e"); - - snprintf(arg1,256,"story=%s",story!=NULL ? story : ""); - snprintf(arg2,256,"enhance=%s",e!=NULL ? e : ""); - - - sprintf(storydef,STORYDEF_PRINTF,story!=NULL ? story : ""); - - printf("Content-type: text\n\n"); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_BOT4,"-v",arg1,"-v",arg2,"-v","please=1",storydef,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - return 0; -} diff --git a/post.awk b/post.awk deleted file mode 100644 index 6a99b04..0000000 --- a/post.awk +++ /dev/null @@ -1,304 +0,0 @@ -#// post.awk -#// The tool to post to the OTT -#// 08.04.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - FS="=" - fora="http://forums.xkcd.com" - useragent="\"bothasar_p (http://1190.bicyclesonthemoon.info/aftertime; time after Time post bot)\"" - timecmd="date -u +\"%d %b %Y, %k:%M UTC\"" - - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i); - ch2hex[ch]=hex - hex2ch[hex]=ch - } -}; -{ - eq=index($0,"=") - argtab[substr($0,1,eq-1)]=substr($0,eq+1) -}; -END{ - if(entitydecode(user)!=urldecode(argtab["username"])) - edit="" - - if(system("wget -q -t 3 --connect-timeout=60 --save-cookies=" cookiefile " -U " useragent " -O " tempfile " " fora "/ucp.php?mode=login")) - { - print "Pre-login fail." - exit 1 - } - while((getline cookie < cookiefile)>0) - { - if(cookie ~ /_sid/) - { - split(cookie,arr,"_sid[ \t]*") - SID=arr[2] - } - } - close(cookiefile) - print "username=" argtab["username"] "&password=" argtab["password"] "&sid=" SID "&login=Login" > postfile - close(postfile) - if(system("wget -q -t 3 --connect-timeout=60 --save-cookies=" cookiefile " --post-file=" postfile " -U " useragent " -O " tempfile " \"" fora "/ucp.php?mode=login\"")) - { - print "Login fail." - exit 1 - } - - while((getline temp < tempfile)>0) - { - if (temp ~ /
0) - { - if (tolower(line) ~ /

information/) - { - print "Unexpected h2: information\n" - getline line < tempfile - print line - exit 1 - } - - while (line!="") - { - i=match(line, //) - if(i!=0) - { - tag=substr(line,1,i) - line=substr(line,i+1) - } - else #oh no tag doesn't end on this line - whatever, I don't care. - { - tag=line - line="" - } - - - if(tag ~ /^postfile - if("&addbbcode20" in argtab) - printf ("&addbbcode20=%s",argtab["addbbcode20"])>>postfile - if(edit!="") - printf ("&message=%s",argtab["old_message"] "%0A%5Bsize%3D110%5D%5Bb%5D" argtab["subject"] "%5B%2Fb%5D%5B%2Fsize%5D%0A%5Bsize%3D80%5D" urlencode(posttime) "%5B%2Fsize%5D%0A" argtab["message"])>>postfile - else - printf ("&message=%s",argtab["message"])>>postfile - printf ("&post=%s","Submit")>>postfile - if("disable_bbcode" in argtab) - printf ("&disable_bbcode=%s",argtab["disable_bbcode"])>>postfile - if("disable_smilies" in argtab) - printf ("&disable_smilies=%s",argtab["disable_smilies"])>>postfile - if("disable_magic_url" in argtab) - printf ("&disable_magic_url=%s",argtab["disable_magic_url"])>>postfile - if("attach_sig" in argtab) - printf ("&attach_sig=%s",argtab["attach_sig"])>>postfile - if("notify" in argtab) - printf ("¬ify=%s",argtab["notify"])>>postfile - printf ("&creation_time=%s",argtab["creation_time"])>>postfile - printf ("&form_token=%s",argtab["form_token"])>>postfile - for(i=0; i>postfile - - close(postfile) - - system("sleep 1") - if(system("wget -q -t 3 --connect-timeout=60 --load-cookies=" cookiefile " --save-cookies=" cookiefile " --post-file=" postfile " -U " useragent " -O " tempfile " \"" fora "/posting.php?mode="((edit!="")?"edit&f=7&p="edit:"reply&f=7&t=101043")"\"")) - { - print "Submit fail." - exit 1 - } - - while((getline temp < tempfile)>0) - { - if (temp ~ /

information/) - { - success=1 - } - } - close(tempfile) - - if (success!=1) - { - print "Sent back to preview!" - exit INDELIVERABLE - } - - while((getline cookie < cookiefile)>0) - { - if(cookie ~ /_sid/) - { - split(cookie,arr,"_sid[ \t]*") - SID=arr[2] - break - } - } - close(cookiefile) - if(system("wget -q -t 3 --connect-timeout=60 -U " useragent " -O " tempfile " \"" fora "/ucp.php?mode=logout&sid=" SID"\"")) - { - print "Logout fail." - } - - -} -function urlencode(name,all, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if ((ch ~ /[a-zA-Z0-9\.\-_~]/)&&(all=="")) - escaped = escaped ch - else - escaped = escaped "%" ch2hex[ch] - } - return escaped -} -function entitydecode(ht ,i,j,un,num) -# quot, amp, lt, gt, nbsp, and decimal numbered. -{ - while ((i=match(ht, /&((#[0-9]+)|([a-zA-Z]+));/))!=0)# - { - un=un substr(ht, 1, i-1) - ht=substr(ht, i) - j=index(ht, ";") - - if(ht~/^&#/) - { - num=int(substr(ht, 3, j-3)) - un=un sprintf("%c",num) - } - else - { - num=tolower(substr(ht, 2, j-2)) - if(num == "quot") - un=un "\"" - else if(num == "amp") - un=un "&" - else if(num == "lt") - un=un "<" - else if(num == "gt") - un=un ">" - else if(num == "nbsp") - un=un "\xA0" - else - un = un ht - } - ht=substr(ht, j+1) - } - un=un ht - return un -} -function urldecode(ht ,i,j,un,num) -# quot, amp, lt, gt, nbsp, and decimal numbered. -{ - while ((i=match(ht, /%[0-9a-fA-F][0-9a-fA-F]/))!=0)# - { - un=un substr(ht, 1, i-1) - ht=substr(ht, i) - num=toupper(substr(ht, 2, 2)) - un=un hex2ch[num] - ht=substr(ht, 4) - } - un=un ht - return un -} diff --git a/post.cpp b/post.cpp deleted file mode 100644 index 4ccac67..0000000 --- a/post.cpp +++ /dev/null @@ -1,767 +0,0 @@ -// post.cpp (1190.bicyclesonthemoon.info/aftertime/post) -// The post edit interface -// 15.04.2019 -// -// Copyright (C) 2015, 2019 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include -#include -#include -#include -#include -#include -#include - -#define RM_PATH "/bin/rm" -#define MV_PATH "/bin/mv" -#define CAT_PATH "/bin/cat" -#define MAWK_PATH "/usr/bin/mawk" - -#define POST_PATH "/eizm/www/time/aftertime/post.htm" -#define INFO_PATH "/eizm/www/time/aftertime/info.htm" -#define MPOST_PATH "/eizm/mem/aftertime/mpost/" - -#define AWK_PREVIEW "/eizm/pro/aftertime/preview.awk" -#define AWK_VIEW "/eizm/pro/aftertime/view.awk" -#define TEMP_PATH "/eizm/tmp/aftertime/preview." -#define AWK_B2H "/eizm/pro/aftertime/bb2html.awk" -#define AWK_VERIFY "/eizm/pro/aftertime/verify.awk" - -s_cgi *cgi; -pid_t sub; -int r; -FILE *tempfile; -FILE *postfile; -bool tf=false; -bool pf=false; -char temppath[256]=""; -char temppath2[256]=""; -char postpath[512]=""; - -char zero='\0'; -char *username = &zero; -char *password = &zero; -char *message = &zero; -char *y = &zero; -char *m = &zero; -char *d = &zero; -char *h = &zero; -char *disable_bbcode = &zero; -char *disable_smilies = &zero; -char *disable_magic_url = &zero; -char *Preview = &zero; -char *post =&zero; -char *addquote =&zero; -char *edit =&zero; -char *forceID =&zero; -char *silent =&zero; -char *story =&zero; -char *frame =&zero; -char *round =&zero; -char *subject =&zero; -char *key =&zero; -char *forcekey =&zero; -char *ID =&zero; -bool special=false; - -char wrong[256]; - -void submit(); -void preview (const char *text); -void writeArg(FILE *file,const char *name,const char *value, bool all); -void writeArg(FILE *file,const char *name,const char *value, const char *insert); -void writeArgH(FILE *file,const char *name,const char *value, unsigned char br); -void writeArgH(FILE *file,const char *value); -// void writeArgBR(FILE *file,const char *name, const char *value); -void end(int m); -void id(char *timenumber, char *story, unsigned short frame, char *subframe, unsigned char round); -void specialid(char *timenumber, char *story, char frame); - -void end(int m) -{ - if(tf) - fclose(tempfile); - if(pf) - fclose(postfile); - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,"-f",temppath2,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(pf) - { - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,"-f",postpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - } - exit(m); -} - -void writeArg(FILE *file,const char *name,const char *value, bool all=false) -{ - unsigned short length, i, v; - fprintf(file,"%s=",name); - for(i=0, length=strlen(value);i='0'&&value[i]<='9')||(value[i]>='A'&&value[i]<='Z')||(value[i]>='a'&&value[i]<='z') - ||value[i]=='.'||value[i]=='~'||value[i]=='-'||value[i]=='_')&&(!all)) - fputc(v,file); - else - fprintf(file,"%%%02X",v); - } - fputc('\n',file); -} - -void writeArg(FILE *file,const char *name,const char *value, const char *insert) -{ - unsigned short length, i, v; - fprintf(file,"%s=",name); - for(i=0, length=strlen(value);i='0'&&value[i]<='9')||(value[i]>='A'&&value[i]<='Z')||(value[i]>='a'&&value[i]<='z') - ||value[i]=='.'||value[i]=='~'||value[i]=='-'||value[i]=='_') - fputc(v,file); - else - fprintf(file,"%%%02X",v); - } - for(i=0, length=strlen(insert);i='0'&&insert[i]<='9')||(insert[i]>='A'&&insert[i]<='Z')||(insert[i]>='a'&&insert[i]<='z') - ||insert[i]=='.'||insert[i]=='~'||insert[i]=='-'||insert[i]=='_') - fputc(v,file); - else - fprintf(file,"%%%02X",v); - } - fputc('\n',file); -} - -void writeArgH(FILE *file,const char *name,const char *value, unsigned char br=0) -{ - unsigned short length, i, v; - fprintf(file,"%s=",name); - for(i=0, length=strlen(value);i"); - case '\r': - if(br&0x01) - break; - case '=': - case '<': - case '>': - case '&': - fprintf(file,"&#%hu;",v); - break; - default: - fputc(v,file); - } - } - fputc('\n',file); -} - -void writeArgH(FILE *file,const char *value) -{ - unsigned short length, i, v; - for(i=0, length=strlen(value);i': - case ' ': - case '\r': - case '\n': - case '=': - fprintf(file,"&#%hu;",v); - break; - default: - fputc(v,file); - } - } -} - -// void writeArgBR(FILE *file,const char *name, const char *value) -// { - // unsigned short length, i, v; - // fprintf(file,"%s=",name); - // for(i=0, length=strlen(value);i0x0fff)||(tm>0x0f)||(td>0x1f)||(th>0x1f)) - preview("Time too long"); - // I accept invalid time as long as it's not too long - - if (special) - specialid(timenumber,story,frame[0]); - else - id(timenumber,story,tf,sf,tr); - snprintf(postpath,512,"%s%s",MPOST_PATH,timenumber); - if(forceID[0]!='\0') - snprintf(forcepath,512,"%s%s",MPOST_PATH,forceID); - - tempfile=fopen(temppath,"wt"); - if(tempfile==NULL) - preview("Couldn't create file."); - tf=true; - writeArgH(tempfile,"timenumber",timenumber); - writeArgH(tempfile,"key",newkey); - writeArgH(tempfile,"username_h",username); - writeArgH(tempfile,"subject_h",subject); - writeArgH(tempfile,"story",story); - if(frame[0]!='\0')writeArgH(tempfile,"frame",ff); - if(round[0]!='\0')writeArgH(tempfile,"round",rr); - writeArgH(tempfile,"BBHTML",message,1); - writeArgH(tempfile,"BB",message,3); - if(h[0]!='\0')writeArgH(tempfile,"h",hh); - if(d[0]!='\0')writeArgH(tempfile,"d",dd); - if(m[0]!='\0')writeArgH(tempfile,"m",mm); - if(y[0]!='\0')writeArgH(tempfile,"y",yy); - if(disable_bbcode[0]!='\0') - writeArg(tempfile,"disable_bbcode",disable_bbcode); - if(disable_smilies[0]!='\0') - writeArg(tempfile,"disable_smilies",disable_smilies); - if(disable_magic_url[0]!='\0') - writeArg(tempfile,"disable_magic_url",disable_magic_url); - if(ID[0]!='\0') - writeArgH(tempfile,"ID",ID); - fclose(tempfile); - tf=false; - - snprintf(arg1,256,"outfile=%s",temppath); - snprintf(arg2,256,"tempfile=%s",temppath2); - fflush(stdout); - sub=fork(); - if(sub==0) - { - setvbuf(stdout, NULL, _IONBF, 0); - dup2(fileno(stdout),fileno(stderr)); - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_B2H,"-v",arg1,"-v",arg2,temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - - snprintf(arg1,256,"name=%s",username); - snprintf(arg2,256,"pass=%s",password); - snprintf(arg3,256,"story=%s",story); - snprintf(arg4,256,"file=%s",(forceID[0]!='\0')?forcepath:postpath); - - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_VERIFY,"-v",arg1,"-v",arg2,"-v",arg3,"-v",arg4,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - - // printf("r=%d\n",r); - - if(r) - preview("Can't submit this post. Not yours or wrong password?"); - - if(forceID[0]!='\0') - { - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,forcepath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - } - - sub=fork(); - if(sub==0) - { - r=execl(MV_PATH,MV_PATH,temppath,postpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - // preview("Couldn't add post to queue."); - preview(postpath); - - printf("Content-type: text/html\n\n"); - snprintf(arg1,256,"info=

This message has been sent successfully.

View your submitted message

Return to the list

",timenumber,newkey); - // printf("Content-type: text/html\n\n"); - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_VIEW,"-v",arg1,INFO_PATH,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - printf("%s",arg1); - end(0); -} -void preview (const char *text) -{ - char arg1[256]; - char arg2[256]; - char yy[8]; - char ff[8]; - char rr[4]; - char mm[4]; - char dd[4]; - char hh[4]; - char sf[2]={0,0}; - unsigned short ty, tf; - unsigned char tm,td,th, tr; - if(y[0]!='\0') - { - sscanf(y,"%hu",&ty); - ty&=0x0fff; - snprintf(yy,8,"%04hu",ty); - } - if(m[0]!='\0') - { - sscanf(m,"%hhu",&tm); - tm&= 0x0f; - snprintf(mm,4,"%02hhu",tm); - } - if(d[0]!='\0') - { - sscanf(d,"%hhu",&td); - td&= 0x1f; - snprintf(dd,4,"%02hhu",td); - } - if(h[0]!='\0') - { - sscanf(h,"%hhu",&th); - th&= 0x1f;snprintf(hh,4,"%02hhu",th); - } - if(frame[0]!='\0') - { - if(special) - { - snprintf(ff,8,"%c",frame[0]); - } - else - { - sscanf(frame,"%hu%c",&tf,sf); - snprintf(ff,8,"%04hu%s",tf,sf); - } - } - if(round[0]!='\0') - { - if(special) - snprintf(rr,4,""); - else - { - sscanf(round,"%hhu",&tr); - snprintf(rr,4,"%02hhu",tr); - } - } - - tempfile=fopen(temppath,"wt"); - if(tempfile==NULL) - end(1); - tf=true; - - writeArgH(tempfile,"message",message); - writeArgH(tempfile,"subject",(subject[0]!='\0')?subject:"Did you notice …"); - writeArgH(tempfile,"wrong",text); - writeArgH(tempfile,"username",username); - writeArgH(tempfile,"message",message); - writeArgH(tempfile,"BB",message,3); - if(h[0]!='\0')writeArgH(tempfile,"h",hh); - if(d[0]!='\0')writeArgH(tempfile,"d",dd); - if(m[0]!='\0')writeArgH(tempfile,"m",mm); - if(y[0]!='\0')writeArgH(tempfile,"y",yy); - writeArgH(tempfile,"story",story); - if(frame[0]!='\0')writeArgH(tempfile,"frame",ff); - writeArgH(tempfile,"round",(round[0]!='\0')?rr:"1"); - writeArgH(tempfile,"disable_bbcode",disable_bbcode); - writeArgH(tempfile,"disable_smilies",disable_smilies); - writeArgH(tempfile,"disable_magic_url",disable_magic_url); - writeArgH(tempfile,"addquote",addquote); - writeArgH(tempfile,"edit",edit); - writeArgH(tempfile,"forceID",forceID); - writeArgH(tempfile,"key",forcekey); - writeArgH(tempfile,"ID",ID); - fclose(tempfile); - tf=false; - - printf("Content-type: text/html\n\n"); - - snprintf(arg1,256,"outfile=%s",temppath); - snprintf(arg2,256,"tempfile=%s",temppath2); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - setvbuf(stdout, NULL, _IONBF, 0); - dup2(fileno(stdout),fileno(stderr)); - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_B2H,"-v",arg1,"-v",arg2,temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - - // printf("Content-type: text/html\n\n"); - snprintf(arg1,256,"argfile=%s",temppath); - snprintf(arg2,256,"key=%s",key[0]?key:"???"); - fflush(stdout); - sub=fork(); - if(sub==0) - { - // setvbuf(stdout, NULL, _IONBF, 0); - // dup2(fileno(stdout),fileno(stderr)); - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_PREVIEW,"-v",arg1,"-v",arg2,POST_PATH,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - printf("

Ch*rpin* M*stard

"); - end(0); -} - -int main() -{ - bool missing=false; - - char *arg; - - // printf("Content-type: text/plain\n\n"); - - cgi=cgiInit(); - srand (time (NULL) + getpid()); - - - snprintf(temppath,256,"%s%lu",TEMP_PATH,(unsigned long)getpid()); - snprintf(temppath2,256,"%s_%lu",TEMP_PATH,(unsigned long)getpid()); - - arg=cgiGetValue(cgi,"password"); - if(arg!=NULL) - password=arg; - else - { - missing=true; - strcpy(wrong,"Password is missing."); - } - - arg=cgiGetValue(cgi,"username"); - if(arg!=NULL) - username=arg; - else - { - missing=true; - strcpy(wrong,"Name is missing."); - } - - arg=cgiGetValue(cgi,"story"); - if(arg!=NULL) - { - story=arg; - if(!strcmp(story,"time")); //really shouldn't be hardcoded! - else if(!strcmp(story,"prickly")); - else if(!strcmp(story,"potm")); - else if(!strcmp(story,"lucky")); - else if(!strcmp(story,"beany")); - else if(!strcmp(story,"bean2")); - else if(!strcmp(story,"t1i")); - else if(!strcmp(story,"zodiac")); - else if(!strcmp(story,"bftf")); - else if(!strcmp(story,"t-1")); - else if(!strcmp(story,"bsta")); - else if(!strcmp(story,"advent")); - else if(!strcmp(story,"phys")); - else - { - missing=true; - strcpy(wrong,"Wrong story name."); - } - } - else - { - missing=true; - strcpy(wrong,"Story name is missing."); - } - - arg=cgiGetValue(cgi,"frame"); - if(arg!=NULL) - { - frame=arg; - if((frame[0]>='a')&&(frame[0]<='z')) - special=true; - } - else - { - missing=true; - strcpy(wrong,"Frame number is missing."); - } - - arg=cgiGetValue(cgi,"round"); - if(arg!=NULL) - round=arg; - else - { - if(!special) - { - missing=true; - strcpy(wrong,"Round number was missing. Replaced with default value."); - } - } - arg=cgiGetValue(cgi,"subject"); - if(arg!=NULL) - subject=arg; - else - { - missing=true; - strcpy(wrong,"Subject was missing. Replaced with default value."); - } - - arg=cgiGetValue(cgi,"message"); - if(arg!=NULL) - message=arg; - else - { - missing=true; - strcpy(wrong,"Post is empty."); - } - - - arg=cgiGetValue(cgi,"y"); - if(arg!=NULL) - y=arg; - else - { - missing=true; - strcpy(wrong,"Time not specified."); - } - - arg=cgiGetValue(cgi,"m"); - if(arg!=NULL) - m=arg; - else - { - missing=true; - strcpy(wrong,"Time not specified."); - } - - arg=cgiGetValue(cgi,"d"); - if(arg!=NULL) - d=arg; - else - { - missing=true; - strcpy(wrong,"Time not specified."); - } - - arg=cgiGetValue(cgi,"h"); - if(arg!=NULL) - h=arg; - else - { - missing=true; - strcpy(wrong,"Time not specified."); - } - - arg=cgiGetValue(cgi,"disable_bbcode"); - if(arg!=NULL) - disable_bbcode=arg; - - arg=cgiGetValue(cgi,"disable_smilies"); - if(arg!=NULL) - disable_smilies=arg; - - arg=cgiGetValue(cgi,"disable_magic_url"); - if(arg!=NULL) - disable_magic_url=arg; - - arg=cgiGetValue(cgi,"Preview"); - if(arg!=NULL) - Preview=arg; - - arg=cgiGetValue(cgi,"post"); - if(arg!=NULL) - post=arg; - - arg=cgiGetValue(cgi,"q"); - if(arg!=NULL) - addquote=arg; - - arg=cgiGetValue(cgi,"e"); - if(arg!=NULL) - edit=arg; - - arg=cgiGetValue(cgi,"forceID"); - if(arg!=NULL) - forceID=arg; - - arg=cgiGetValue(cgi,"key"); - if(arg!=NULL) - key=arg; - - arg=cgiGetValue(cgi,"forcekey"); - if(arg!=NULL) - forcekey=arg; - - arg=cgiGetValue(cgi,"ID"); - if(arg!=NULL) - ID=arg; - - if(strcmp(post,"Submit")==0) - { - if(missing) - preview(wrong); - else - submit(); - } - else - preview(""); - - return 0; - -} - -void id(char *timenumber, char *story, unsigned short frame, char *subframe, unsigned char round) -{ - snprintf(timenumber,256,"%s-%04hu%s-%02hhu",story,frame,subframe,round); -} -void specialid(char *timenumber, char *story, char frame) -{ - snprintf(timenumber,256,"%s-%c",story,frame); -} diff --git a/posted.awk b/posted.awk deleted file mode 100644 index fb6d6f3..0000000 --- a/posted.awk +++ /dev/null @@ -1,65 +0,0 @@ -#// posted.awk -#// Display one entry in the post list -#// 31.03.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - - -BEGIN{ - FS="=" - passpath="/eizm/mem/aftertime/pass/" - # for(i=0;i<256;++i) - # { - # ch=sprintf("%c",i) - # hex=sprintf("%02X",i); - # ch2hex[ch]=hex - # } -}; -{ - gsub(/[\r\n]/,"",$0) - eq=index($0,"=") - argtab[substr($0,1,eq-1)]=substr($0,eq+1) -}; -END{ - passfile = passpath argtab["story"] - getline namef < passfile - getline passf < passfile - close (passfile) - gsub(/[\r\n]/,"",namef) - gsub(/[\r\n]/,"",passf) - - if(namef!=name||passf!=pass) - exit 1; - if (r2==0) - class="plw" - else - class="plv" - print ""argtab["timenumber"]""argtab["y"]"-"argtab["m"]"-"argtab["d"]" "argtab["h"]":00"argtab["subject_h"]"view quote edit remove"(argtab["ID"]!=""?" OTT":"")"" -} -# function urlencode(name,all, len,iii,escaped,ch) -# { - # len=length(name) - # escaped="" - # for(iii=1;iii<=len;++iii) - # { - # ch=substr(name,iii,1); - # if ((ch ~ /[a-zA-Z0-9\.\-_~]/)&&(all=="")) - # escaped = escaped ch - # else - # escaped = escaped "%" ch2hex[ch] - # } - # return escaped -# } \ No newline at end of file diff --git a/posted.c b/posted.c deleted file mode 100644 index c7218bf..0000000 --- a/posted.c +++ /dev/null @@ -1,141 +0,0 @@ -// posted.c (1190.bicyclesonthemoon.info/aftertime/list) -// Display the post list -// 29.03.2015 -// -// Copyright (C) 2015 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include -#include -#include -#include -#include - -#define TEMP_PATH "/eizm/tmp/aftertime/posted." -#define POST_PATH "/eizm/mem/aftertime/mpost/" -#define LS_PATH "/bin/ls" -#define RM_PATH "/bin/rm" -#define MAWK_PATH "/usr/bin/mawk" -#define AWK_POSTED "/eizm/pro/aftertime/posted.awk" - -s_cgi *cgi; -pid_t sub; -int r; - -int main(int argc, char **argv) -{ - char temppath[256]=""; - char line[512]; - char filename[512]; - char postpath[512]; - char argp1[256]; - char argp2[256]; - FILE *tempfile; - // FILE *postfile; - unsigned char i; - // unsigned char sent; - char zero='\0'; - char *value; - char *username; - char *password; - // dup2(fileno(stdout),fileno(stderr)); - cgi=cgiInit(); - - username=((value=cgiGetValue(cgi,"username"))?value:&zero); - password=((value=cgiGetValue(cgi,"password"))?value:&zero); - // sent=cgiGetValue(cgi,"sent"); - sprintf(argp1,"name=%s",username); - sprintf(argp2,"pass=%s",password); - - - sprintf(temppath,"%s%lu",TEMP_PATH,(unsigned long)getpid()); - - printf("Content-type: text/html\n\n"); - printf("\n"); - printf("\n"); - printf("time after Time • Bicycles on the Moon\n"); - printf("\n"); - printf("\n"); - printf("\n"); - printf("\"1190.bicyclesonthemoon.info\"\n"); - printf("

time after Time

\n"); - // printf("(some explanation)
\n"); - printf("
\n"); - printf("\n",username); - printf("\n"); - printf("
Username:
Password:
\n"); - printf("Write a post

\n"); - printf("
\n"); - printf("


\n"); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - if(freopen(temppath,"wt",stdout)==NULL) - exit(255); - r=execl(LS_PATH,LS_PATH,"-1","--color=never",POST_PATH,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - printf("No messages.
\n"); - else - { - printf("\n"); - printf("\n"); - - if(password!=NULL) - { - tempfile=fopen(temppath,"rt"); - if(tempfile!=NULL) - { - for(i=0; fgets(line,511,tempfile)!=NULL; ++i) - { - sscanf(line,"%s",filename); - sprintf(postpath,"%s%s",POST_PATH,filename); - - fflush(stdout); - sub=fork(); - if(!sub) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_POSTED,"-v",i&0x1?"r2=1":"r2=0","-v",argp1,"-v",argp2,postpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - --i; - - } - fclose(tempfile); - } - } - printf("
Waiting
IDpost timesubjectaction

\n"); - - } - - printf("
1190.bicyclesonthemoon.info\n"); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - - return 0; -} diff --git a/preview.awk b/preview.awk deleted file mode 100644 index 01d7db5..0000000 --- a/preview.awk +++ /dev/null @@ -1,198 +0,0 @@ -#// preview.awk -#// Preview a post in the post edit interface -#// 25.05.2021 -#// -#// Copyright (C) 2015, 2021 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - postpath="/eizm/mem/aftertime/mpost/" - - HTML="
Preview: %s
%s

" - wrong="
%s
\n" - postid=" frame: round: \n" - subject="\n" - username="\n" - time="Y: M: D: H: \n" - - ottid="\n" - message="\n" - back="back to the list\n" - - disable_bbcode=" Disable BBcode
\n" - disable_smilies=" Disable smilies
\n" - disable_magic_url=" Do not automatically parse URLs
\n" - - - forceID="\n" - forcekey="\n" - - addquote="" - - # print "" - close(argfile) - if(argtab["edit"] ~ /^[a-zA-Z0-9]+\-(([0-9]+[a-z]?\-[0-9]+)|([a-z]))$/) - { - argtab["forceID"]=argtab["edit"] ### reused from where it made more sense - argfile= postpath argtab["forceID"] - - while((getline argline < argfile)>0) - { - gsub(/[\r\n]/,"",argline) - eq=index(argline,"=") - if(argline ~ /^key=/) - { - if(substr(argline,eq+1)!=key) - { - argtab["wrong"]="Invalid key." - break; - } - argtab["key"]=substr(argline,eq+1) - } - else if(argline ~ /^((username)|(subject))_h=/) - argtab[substr(argline,1,eq-3)]=substr(argline,eq+1) - else if(argline ~ /^BBHTML=/) - { - argtab["message"]=substr(argline,eq+1) - gsub(/
/,"\n",argtab["message"]) - } - else if(argline ~ /^((BB)|(username)|(subject)|(message)|(HTML)|(debug))=/) - {} - else - argtab[substr(argline,1,eq-1)]=substr(argline,eq+1) - } - close(argfile) - } - else if(argtab["addquote"] ~ /^[a-zA-Z0-9]+\-(([0-9]+[a-z]?\-[0-9]+)|([a-z]))$/) - { - argfile= postpath argtab["addquote"] - while((getline argline < argfile)>0) - { - gsub(/[\r\n]/,"",argline) - eq=index(argline,"=") - if(argline ~ /^key=/) - { - if(substr(argline,eq+1)!=key) - { - argtab["wrong"]="Invalid key." - break; - } - } - else if(argline ~ /^BBHTML=/) - { - addquotehtml=substr(argline,eq+1) - gsub(/
/,"\n",addquotehtml) - } - if(argline ~ /^username_h=/) - addquotename=substr(argline,eq+1) - if(argline ~ /^subject_h/) - { - addquotesub=substr(argline,eq+1) - if(addquotesub ~ /^Re:/) - argtab["subject"]=addquotesub - else - argtab["subject"]="Re: "addquotesub - } - if(argline ~ /^y=/) - { - argtab["y"]=substr(argline,eq+1) - } - if(argline ~ /^d=/) - { - argtab["d"]=substr(argline,eq+1) - } - if(argline ~ /^m=/) - { - argtab["m"]=substr(argline,eq+1) - } - if(argline ~ /^h=/) - { - argtab["h"]=substr(argline,eq+1) - } - } - close(argfile) - if(addquotehtml!="") - addquote="[quote=""addquotename""]"addquotehtml"[/quote]" - } -}; -{ - if ($0 ~ /^###HTML/) - { - if((argtab["HTML"]!="")&&(argtab["wrong"]=="")) - printf(HTML,(argtab["story"]!=""?argtab["story"]:"???")"-"(argtab["frame"]!=""?argtab["frame"]:"???")"-"(argtab["round"]!=""?argtab["round"]:"???")" • "argtab["subject"],argtab["HTML"]) - } - else if ($0 ~ /^###wrong/) - { - if(argtab["wrong"]!="") - printf(wrong,argtab["wrong"]) - } - else if ($0 ~ /^###subject/) - printf(subject,argtab["subject"]) - else if ($0 ~ /^###username/) - printf(username,argtab["username"]) - else if ($0 ~ /^###message/) - printf(message,argtab["message"],addquote) - else if ($0 ~ /^###time/) - printf(time,argtab["y"],argtab["m"],argtab["d"],argtab["h"]) - else if ($0 ~ /^###postid/) - printf(postid,argtab["story"],argtab["frame"],argtab["round"]) - else if ($0 ~ /^###future/) - { - # - } - else if ($0 ~ /^###forceID/) - { - if(argtab["forceID"]!="") - printf(forceID,argtab["forceID"]) - } - else if ($0 ~ /^###ottid/) - printf(ottid,argtab["ID"]) - else if ($0 ~ /^###forcekey/) - { - if(argtab["key"]!="") - printf(forcekey,argtab["key"]) - } - else if ($0 ~ /^###img/) - { - print img - } - else if ($0 ~ /^###back/) - { - printf(back,"") - } - else if ($0 ~ /^###debug/) - { - gsub(/###nl;/,"\n",argtab["debug"]) - gsub(/-/," - ",argtab["debug"]) - print "" - } - else if ($0 ~ /^###disable_bbcode/) - printf(disable_bbcode,(argtab["disable_bbcode"]=="on")?"checked=\"checked\"":"") - else if ($0 ~ /^###disable_smilies/) - printf(disable_smilies,(argtab["disable_smilies"]=="on")?"checked=\"checked\"":"") - else if ($0 ~ /^###disable_magic_url/) - printf(disable_magic_url,(argtab["disable_magic_url"]=="on")?"checked=\"checked\"":"") - - else - print $0 -}; diff --git a/remove.c b/remove.c deleted file mode 100644 index 670c4ff..0000000 --- a/remove.c +++ /dev/null @@ -1,112 +0,0 @@ -// remove.c (1190.bicyclesonthemoon.info/aftertime/remove) -// remove a post -// 15.04.2019 -// -// Copyright (C) 2015, 2019 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include -#include -#include -#include -#include - -#define POST_PATH "/eizm/mem/aftertime/mpost/" -#define RMOV_PATH "/eizm/mem/aftertime/mpost/rm/" -#define MV_PATH "/bin/mv" -#define MAWK_PATH "/usr/bin/mawk" -#define AWK_VERIFY "/eizm/pro/aftertime/verify.awk" - -int main(int argc, char **argv) -{ - s_cgi *cgi; - pid_t sub; - int r; - - char zero='\0'; - char *rmov = &zero; - char *arg; - char *username; - char *password; - char inpath[256]; - char outpath[256]; - char argp1[256]; - char argp2[256]; - char argp3[256]; - - cgi=cgiInit(); - - // dup2(fileno(stdout),fileno(stderr)); - // printf("Content-type: text/plain\n\n"); - - rmov=((arg=cgiGetValue(cgi,"r"))?arg:&zero); - - username=((arg=cgiGetValue(cgi,"username"))?arg:&zero); - password=((arg=cgiGetValue(cgi,"password"))?arg:&zero); - if(username[0]=='\0'||password[0]=='\0') - { - arg=cgiGetValue(cgi,"r"); - if(arg!=NULL) - rmov=arg; - printf("Content-type: text/html\n\n"); - printf("\n"); - printf("\n"); - printf("time after Time • Bicycles on the Moon\n"); - printf("\n"); - printf("\n"); - printf("\n"); - printf("\n"); - printf("\"1190.bicyclesonthemoon.info\"\n"); - printf("

time after Time

\n"); - printf("
\n"); - printf("Remove post %s?\n",rmov); - printf("\n",username); - printf("\n"); - printf("
Username:
Password:
\n",rmov); - printf("
1190.bicyclesonthemoon.info\n"); - return 0; - } - - snprintf(inpath,256,"%s%s",POST_PATH,rmov); - - snprintf(argp1,256,"name=%s",username); - snprintf(argp2,256,"pass=%s",password); - snprintf(argp3,256,"file=%s",inpath); - - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_VERIFY,"-v",argp1,"-v",argp2,"-v",argp3,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - { - cgiRedirect("/aftertime/list"); - return(0); - } - snprintf(outpath,256,"%s%s",RMOV_PATH,rmov); - - sub=fork(); - if(sub==0) - { - r=execl(MV_PATH,MV_PATH,inpath,outpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - cgiRedirect("/aftertime/list"); - return 0; -} \ No newline at end of file diff --git a/undertext_bb2html.awk b/undertext_bb2html.awk deleted file mode 100644 index 2dddb69..0000000 --- a/undertext_bb2html.awk +++ /dev/null @@ -1,657 +0,0 @@ -# // undertext_bb2html.awk -# // convert undertext bbcode to html -# // 5.06.2019 -# // -# // Copyright (C) 2015, 2019 Balthasar Szczepański -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU Affero General Public License as -# // published by the Free Software Foundation, either version 3 of the -# // License, or (at your option) any later version. -# // -# // This program 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 Affero General Public License for more details. -# // -# // You should have received a copy of the GNU Affero General Public License -# // along with this program. If not, see . - -BEGIN{ - FS="" - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i) - hexl=sprintf("%02x",i) - dec=sprintf("%u",i) - ch2hex[ch]=hex - ch2hexl[ch]=hexl - ch2dec[ch]=dec - } - argtabsize=0 - undertext="" -} -{ - file=1 - gsub(/[\r\n]/, "", $0) - - if ($0 == "" && !undertext) - { - undertext=1 - if (!("text" in argtab)) - { - argtabind[argtabsize]="text" - ++argtabsize - } - argtab["text"]="" - } - else if (undertext) - { - argtab["text"] = argtab["text"] $0 "\n" - } - else - { - eq=index($0, "=") - - if (!(substr($0, 1, eq-1) in argtab)) - { - argtabind[argtabsize]=substr($0, 1, eq-1) - ++argtabsize - } - argtab[substr($0, 1, eq-1)]=substr($0, eq+1) - } -} -END{ - if (file=="") - exit 1 - - if (argtab["text"]!="") - { - if (!("HTML" in argtab)) - { - argtabind[argtabsize]="HTML" - ++argtabsize - } - argtab["HTML"]=bb2html(argtab["text"]) - - } - - for (i=0; i\"\]]*)|(\"[^\"<>]*\")))?\]/) - #"#\"" - if (tag==0) - { - debug = debug "\ntext: " text - bbtree[ind(count,depth)]=text - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - text="" - break; - } - tagstart=RSTART - taglength=RLENGTH - if(tagstart>1) - { - elm=substr(text,1,tagstart-1) - debug = debug "\ntext: " elm - bbtree[ind(count,depth)]=elm - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - } - tag=substr(text,tagstart,taglength) - text=substr(text,tagstart+taglength) - debug = debug "\ntag: " tag - if(tag!~/^\[\//) - { - tagv=index(tag,"=") - if(tagv<2) - { - tagname=substr(tag,2,length(tag)-2) - tagvalue="" - } - else - { - tagname=substr(tag,2,tagv-2) - tagvalue=substr(tag,tagv+1,length(tag)-tagv-1) - } - if(tagname !~ /^((quote)|b|i|u|(code)|(img)|(url)|(size)|(color)|(center)|(right)|(sub)|(sup)|(s)|(spoiler)|(list)|(br)|(\*))$/) - { - debug = debug "\nunknown tag" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if((bbtree[indt(count,depth)".t"] == "code" && tagname!="code")||bbtree[indt(count,depth)".t"] == "img"||(bbtree[indt(count,depth)".t"] == "spoiler" && tagname=="spoiler")||(bbtree[indt(count,depth)".t"] == "size" && tagname=="size")) - { - debug = debug "\nthis tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if(tagname=="*") - { - if(bbtree[indt(count,depth)".t"]==tagname) - { - debug = debug "\nimplied tag: [/"tagname"]" - debug = debug "\nmatched" - bbtree[ind(count,depth)]="[/"tagname"]" - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]=tagname - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - else if(bbtree[indt(count,depth)".t"]!="list") - { - debug = debug "\nthis tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - } - debug = debug "\nname: " tagname " value: " tagvalue - bbtree[ind(count,depth)]=tagname" "tagvalue - bbtree[ind(count,depth)".k"]="s" - bbtree[indt(count,depth)".n"]=count[depth] - ++depth - count[depth]=1 - bbtree[indt(count,depth)]=tag - bbtree[indt(count,depth)".n"]=0 - bbtree[indt(count,depth)".t"]=tagname - bbtree[indt(count,depth)".v"]=tagvalue - - if(tagname=="br") #or other single tags in the future - { - debug = debug "\nmatched" - bbtree[ind(count,depth)]=tag - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]=tagname - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - } - else - { - if(depth<=0) - { - debug = debug "\n""unmatched" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - tagname=substr(tag,3,length(tag)-3) - if(tagname=="list"&&bbtree[indt(count,depth)".t"]=="*") - { - debug = debug "\nimplied tag: [/*]" - debug = debug "\nmatched" - bbtree[ind(count,depth)]="[/*]" - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]="*" - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - debug = debug "\nname: " tagname - matchname=bbtree[indt(count,depth)".t"] - if((bbtree[indt(count,depth)".t"] == "code" && tagname!="code")||(bbtree[indt(count,depth)".t"] == "img" && tagname != "img")) - { - debug = debug "\nthis tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if(tagname!=matchname) - { - debug = debug "\nmismatched: " matchname - # bbtree[ind(count,depth)]=tag - # bbtree[indt(count,depth)".n"]=count[depth] - # ++count[depth] - # continue - bbtree[ind(count,depth)]=tag - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".t"]=bbtree[indt(count,depth)".t"] - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - count[depth]="" - --depth - ++count[depth] - continue - } - debug = debug "\nmatched" - bbtree[ind(count,depth)]=tag - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]=tagname - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - } - if(depth>0) - debug = debug "\nunclosed tags: " depth - - debug = debug "\n\n""generate HTML:" - depth=0 - count[0]=0 - while(count[0]<=bbtree["0.n"]&&depth>=0) - { - if(count[depth]==0) - { - tag=bbtree[indt(count,depth)] - tagname=bbtree[indt(count,depth)".t"] - tagvalue=bbtree[indt(count,depth)".v"] - debug = debug "\nname: "tagname" value: "tagvalue" elements: "bbtree[indt(count,depth)".n"] - if(tagname == "post") - { - } - else if(bbtree[indt(count,depth)".m"]=="") - { - debug = debug "\nunmatched" - html = html htmlescape(tag) - } - else if(tagname == "quote") - { - if (tagvalue=="") - { - html = html "
" - } - else - { - if(tagvalue !~ /^\".*\"$/) - #"#\"" - tagvalue="You forgot about the quote marks, "htmlescape(tagvalue) - else - tagvalue=bb2html(substr(tagvalue,2,length(tagvalue)-2)) - html = html "
"tagvalue" wrote:
" - } - } - else if (tagname == "b") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "i") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "u") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "code") - { - if(bbtree[indtu(count,depth)".t"] == "code") - { - html=html htmlescape(tag) - debug = debug "\nnot a tag, actually" - } - else - { - html=html"
Code: Select all
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - } - else if (tagname == "img") - html=html"" - } - else if (tagname == "size") - { - if (tagvalue==""||(tagvalue !~ /^[0-9]+$/)||(tagvalue+0)>200) - html=html" This tag should have a correct value. " - else - html=html"" - } - else if (tagname == "color") - { - if (tagvalue==""||tagvalue !~ /^#[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]$/) #for some reason /^([0-9A-F]{6})$/ doesn't work. - html=html" This tag should have a correct value. " - else - html=html"" - } - else if (tagname ~ /^((center)|(right))$/) - { - html=html"
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="s") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="sub") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="sup") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname=="spoiler") - { - html=html"
Spoiler:
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname=="list") - { - if(tagvalue=="") - html=html"
    " - else - { - if (tagvalue=="1") - tagvalue="decimal" - else if (tagvalue=="i") - tagvalue="lower-roman" - else if (tagvalue=="I") - tagvalue="upper-roman" - else if (tagvalue=="a") - tagvalue="lower-alpha" - else if (tagvalue=="A") - tagvalue="upper-alpha" - else - { - html=html"This tag should have a correct value. " - tagvalue="decimal" - } - html=html"
      " - } - } - else if (tagname=="*") - { - html=html"
    1. " - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "br") - { - html = html"
      " - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else - { - debug = debug "\nunknown tag" - html = html htmlescape(tag) - } - ++count[depth] - } - else if(bbtree[ind(count,depth)".k"]=="s") - { - debug = debug "\nentering tag:" - ++depth - count[depth]=0 - } - else if(bbtree[ind(count,depth)".k"]=="e") - { - debug = debug "\nleaving tag:" - tag=bbtree[ind(count,depth)] - tagname=bbtree[ind(count,depth)".t"] - tagvalue=bbtree[ind(count,depth)".v"] - debug = debug "\nname: "tagname" value: "tagvalue - if (tagname == "post") - { - } - else if(bbtree[ind(count,depth)".m"]=="") - { - debug = debug "\nunmatched" - html = html htmlescape(tag) - } - else if(tagname == "quote") - html = html "
" - else if (tagname ~/^(b|i|u|(size)|(color))$/) - html = html"" - else if (tagname == "code") - { - if(bbtree[indtu(count,depth)".t"] == "code") - { - html=html htmlescape(tag) - debug = debug "\nnot a tag, actually" - } - else - html = html"" - } - else if (tagname == "img") - { - html = html"\" alt=\"Image\" />" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if(tagname=="url") - html=html"" - else if (tagname ~ /^((center)|(right))$/) - html=html"
" - else if (tagname =="s") - html=html"" - else if (tagname =="sub") - html=html"" - else if (tagname =="sup") - html=html"" - else if (tagname=="spoiler") - html=html"

" - else if (tagname=="list") - { - if (tagvalue=="") - html=html"" - else - html=html"" - } - else if (tagname=="*") - html=html"" - else if (tagname == "br") # - { - # - } - else - { - debug = debug "\nunknown tag" - html = html htmlescape(tag) - } - count[depth]="" - --depth - ++count[depth] - } - else if(count[depth]>bbtree[indt(count,depth)".n"]) - { - debug = debug "\nrun out of elements in this tag; leaving" - count[depth]="" - --depth - ++count[depth] - } - else - { - tag=bbtree[ind(count,depth)] - debug = debug "\ntext: "tag - - tag=htmlescape(tag,"","br") - - if(bbtree[indt(count,depth)".t"] == "code") - { - gsub(/ /,"\\ ",tag) - gsub(/\t/,"\\ \\ ",tag) - } - else{ - gsub(/ /,"\\  ",tag) - gsub(/ /," \\ ",tag) - # gsub(/
/,"
\\ ",tag) - } - - - if(nourl==""&& bbtree[indt(count,depth)".t"] !~ /^((code)|(img)|(url))$/) - gsub(/https?:\/\/[^\n\r\t<> ]+/,"&",tag) - # if(nosmil=="" && bbtree[indt(count,depth)".t"] !~ /^((code)|(img))$/) - # { - # gsub(/(^|[\n\r\t ]):D($|[\n\r\t ])/," \":D\" ",tag) - # gsub(/(^|[\n\r\t ]):\)($|[\n\r\t ])/," \":)\" ",tag) - # gsub(/(^|[\n\r\t ]):\(($|[\n\r\t ])/," \":(\" ",tag) - # gsub(/(^|[\n\r\t ]):o($|[\n\r\t ])/," \":o\" ",tag) - # gsub(/(^|[\n\r\t ]):shock:($|[\n\r\t ])/," \":shock:\" ",tag) - # gsub(/(^|[\n\r\t ]):\?($|[\n\r\t ])/," \":?\" ",tag) - # gsub(/(^|[\n\r\t ])8-\)($|[\n\r\t ])/," \"8-)\" ",tag) - # gsub(/(^|[\n\r\t ]):lol:($|[\n\r\t ])/," \":lol:\" ",tag) - # gsub(/(^|[\n\r\t ]):x($|[\n\r\t ])/," \":x\" ",tag) - # gsub(/(^|[\n\r\t ]):P($|[\n\r\t ])/," \":P\" ",tag) - # gsub(/(^|[\n\r\t ]):oops:($|[\n\r\t ])/," \":oops:\" ",tag) - # gsub(/(^|[\n\r\t ]):cry:($|[\n\r\t ])/," \":cry:\" ",tag) - # gsub(/(^|[\n\r\t ]):evil:($|[\n\r\t ])/," \":evil:\" ",tag) - # gsub(/(^|[\n\r\t ]):twisted:($|[\n\r\t ])/," \":twisted:\" ",tag) - # gsub(/(^|[\n\r\t ]):roll:($|[\n\r\t ])/," \":roll:\" ",tag) - # gsub(/(^|[\n\r\t ]):wink:($|[\n\r\t ])/," \":wink:\" ",tag) - # gsub(/(^|[\n\r\t ]);\)($|[\n\r\t ])/," \":wink:\" ",tag) - # gsub(/(^|[\n\r\t ]):!:($|[\n\r\t ])/," \":!:\" ",tag) - # gsub(/(^|[\n\r\t ]):\?:($|[\n\r\t ])/," \":?:\" ",tag) - # gsub(/(^|[\n\r\t ]):idea:($|[\n\r\t ])/," \":idea:\" ",tag) - # gsub(/(^|[\n\r\t ]):arrow:($|[\n\r\t ])/," \":arrow:\" ",tag) - # gsub(/(^|[\n\r\t ]):\|($|[\n\r\t ])/," \":|\" ",tag) - # gsub(/(^|[\n\r\t ]):mrgreen:($|[\n\r\t ])/," \":mrgreen:\" ",tag) - # } - - html = html tag - ++count[depth] - } - } - debug = debug "\ndone\n" - return html -} - -function ind(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii<=depth;++ii) - { - if(ii!=0) - iindex = iindex "." - iindex = iindex count[ii] - } - # debug = debug "\n" iindex - return iindex -} -function indt(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii0) - iindex=iindex"." - iindex = iindex "0" - # debug = debug "\n" iindex - return iindex -} -function indtu(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii0) - iindex=iindex"." - iindex = iindex "0" - # debug = debug "\n" iindex - return iindex -} -function htmlescape(name,less,br, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if(ch == "\n") - escaped = escaped ((br!="")?"
":"&#"ch2dec[ch]";") - else if(ch =="\r") - escaped = escaped ((br!="")?"":"&#"ch2dec[ch]";") - else if(ch == "\"" && less=="") - escaped = escaped "&#"ch2dec[ch]";" - else if(ch ~ /[=<>&]/) - escaped = escaped "&#"ch2dec[ch]";" - else - escaped = escaped ch - } - return escaped -} -function hexencode(name, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1) - escaped = escaped ch2hex[ch] - } - return escaped -} - diff --git a/upload.awk b/upload.awk deleted file mode 100644 index 728701d..0000000 --- a/upload.awk +++ /dev/null @@ -1,732 +0,0 @@ -#// upload.awk -#// The post upload interface -#// 25.05.2021 -#// -#// Copyright (C) 2015, 2019, 2021 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - postpath="/eizm/mem/aftertime/mpost/" - passpath="/eizm/mem/aftertime/pass/" - rmpath="/eizm/mem/aftertime/mpost/rm/" - bb2html="/eizm/pro/aftertime/bb2html.awk" - automome="/eizm/pro/ong1/mome.pl" - memepath="/eizm/mem/ong1/mome.txt" - timecmd="date -u +\"%s\"" - - timecmd | getline thistime - close(timecmd) - - srand(int(thistime) + int( PROCINFO["pid"])) - - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i) - hexl=sprintf("%02x",i) - dec=sprintf("%u",i) - ch2hex[ch]=hex - hex2ch[hex]=ch - ch2hexl[ch]=hexl - ch2dec[ch]=dec - } - - # year=substr(timetext,1,4) - # month=substr(timetext,5,2) - # day=substr(timetext,7,2) - # hour=substr(timetext,9,2) - - # yyy=year+0 - # mmm=month+0 - # ddd=day+0 - # hhh=hour+0 - - ln=0 -} -{ - gsub(/[\r\n]/,"",$0) - if (FNR==1) - { - name=$0 - # print "username: "name - next - } - if (FNR==2) - { - pass=$0 - gsub(/./,"*", $0) - # print "password: "$0 - next - } - - if($0=="") - { - if(ln!=0) - { - post() - ln=0 - nobb="" - nosmil="" - nourl="" - quot="" - rmov="" - lst="" - h="" - d="" - m="" - y="" - subject="" - content="" - options="" - story="" - frame="" - round="" - idtab[1]="" - idtab[2]="" - idtab[3]="" - } - next - } - - ++ln - if(ln==1) - { - if($0 ~ /#/) - split($0, idtab, "#") - else - split($0, idtab, "-") - story=idtab[1] - if (idtab[2]~/^[a-z]/) - { - frame=substr(idtab[2],1,1) - subframe="" - } - else if(idtab[2]~/^[0-9]+[a-z]$/) - { - frame=int(substr (idtab[2], 1, length(idtab[2])-1)) - subframe=substr (idtab[2], length(idtab[2]), 1) - } - else - { - frame=int(idtab[2]) - subframe="" - } - round=int(idtab[3]) - } - else if(ln==2) - { - options=tolower($0) - if(options ~ /b/) - nobb=1 - if(options ~ /s/) - nosmil=1 - if(options ~ /u/) - nourl=1 - if(options ~ /r/) - rmov=1 - if(options ~ /q/) - quot=1 - if(options ~ /l/) - lst=1 - } - else if(ln==3) - { - y=substr($0,1,4) - m=substr($0,6,2) - d=substr($0,9,2) - h=substr($0,12,2) - } - - else if(ln==4) - { - subject=$0 - } - else - { - if(ln!=5) - content=content "\n" $0 - else - content=$0 - } - -} -END{ - if(ln!=0) - post() -} - - -function makeid(story,frame,subframe,round) -{ - if(frame ~ /^[a-z]/) - { - return sprintf("%s-%s",story,frame) - } - else - { - return sprintf("%s-%04u%s-%02u",story,frame,subframe,round) - } -} - -function remove( postid,postfile,rmfile,passfile,temp,f,tn,eq,tv,namef,passf) -{ - postid=makeid(story,frame,subframe,round) - postfile=postpath postid - rmfile=rmpath postid - passfile=passpath story - printf("%s",postid" ") - - getline namef < passfile - getline passf < passfile - close (passfile) - gsub(/[\r\n]/,"",namef) - gsub(/[\r\n]/,"",passf) - - if(name!=namef) - { - print "Can't remove. Wrong username." - return - } - if(pass!=passf) - { - print "Can't remove. Wrong password." - return - } - - if(system("mv -f "postfile" "rmfile)==0) - { - print "removed." - return - } - print "not removed." -} - -function quote( postid,postfile,passfile,temp,f,opt,cont,ongt,subj,eq,tn,tv,id,namef,passf,yy,mm,dd,hh) -{ - postid=makeid(story,frame,subframe,round) - postfile=postpath postid - passfile=passpath story - - getline namef < passfile - getline passf < passfile - close (passfile) - gsub(/[\r\n]/,"",namef) - gsub(/[\r\n]/,"",passf) - - if((name!=namef)||(pass!=passf)) - { - print "Can't quote." - return - } - - while((getline temp < postfile)>0) - { - f=1 - gsub(/[\r\n]/,"",temp) - eq=index(temp,"=") - tn=substr(temp,1,eq-1) - tv=substr(temp,eq+1) - - if(tn=="BB") - cont=unhtml(tv) - else if(tn=="brtext") - ongt=tv - else if(tn=="y") - yy=tv - else if(tn=="m") - mm=tv - else if(tn=="d") - dd=tv - else if(tn=="h") - hh=tv - else if(tn=="subject_h") - subj=unhtml(tv) - else if(tn=="ID") - id=tv - else if(tn=="disable_bbcode") - { - if(tv=="on") - opt=opt"B" - } - else if(tn=="disable_smilies") - { - if(tv=="on") - opt=opt"S" - } - else if(tn=="disable_magic_url") - { - if(tv=="on") - opt=opt"U" - } - } - if(f!="") - { - close(postfile) - if (opt=="") - opt="_" - print postid" subject "subj - print postid" options "opt - print postid" time "sprintf("%04u-%02u-%02u %02u:00",yy,mm,dd,hh) - print postid" content "((ongt!="")?ongt:cont) - if(id!="") - print postid" ID "id - return - } - - else - print postid " can't quote." #I shouldn't tell why -} - -function list( cmd,id,postfile,passfile,temp,mt,f,eq,tn,tv,namef,passf,yy,mm,dd,hh) -{ - - passfile = passpath story - - getline namef < passfile - getline passf < passfile - close (passfile) - gsub(/[\r\n]/,"",namef) - gsub(/[\r\n]/,"",passf) - - if((name!=namef)||(pass!=passf)) - return - - cmd="/bin/ls -1 --color=never "postpath - while ((cmd | getline id)>0) - { - f="" - mt="^"story"-" - if(id !~ mt) - continue - postfile = postpath id - - while((getline temp < postfile)>0) - { - f=1 - gsub(/[\r\n]/,"",temp) - eq=index(temp,"=") - tn=substr(temp,1,eq-1) - tv=substr(temp,eq+1) - if(tn=="y") - yy=tv - else if(tn=="m") - mm=tv - else if(tn=="d") - dd=tv - else if(tn=="h") - hh=tv - - } - if(f!="") - { - close(postfile) - print id" time "sprintf("%04u-%02u-%02u %02u:00",yy,mm,dd,hh) - } - } - close (cmd) -} - -function post( postid,replaceid,postfile,passfile,replacefile,temp,i,eq,tn,tv,namef,passf,key,id) -{ - if(lst!="") - return list() - if(quot!="") - return quote() - if(rmov!="") - return remove() - postid=makeid(story,frame,subframe,round) - printf("%s",postid" ") - - postfile=postpath postid - passfile = passpath story - - - if(options=="") - { - print "No options defined." - return - } - - if (name=="") - { - print "Username missing." - return - } - if (pass=="") - { - print "Password missing." - return - } - if (story=="") - { - print "Story name missing." - return - } - if(story !~ /^(time|prickly|potm|lucky|beany|bean2|t1i|zodiac|bftf|t-1|bsta|advent|phys)$/) #this really shouldn't be hardcoded! - { - print "Unknown story." - return - } - if (frame=="") - { - print "Frame number missing." - return - } - if (round=="") - { - print "Round number missing." - return - } - if (subject=="") - { - print "Subject missing." - return - } - if (content=="") - { - print "Post is empty." - return - } - - yy=y+0 - mm=m+0 - dd=d+0 - hh=h+0 - - getline namef < passfile - getline passf < passfile - close (passfile) - gsub(/[\r\n]/,"",namef) - gsub(/[\r\n]/,"",passf) - - if(name!=namef) - { - print "Wrong username." - return - } - if(pass!=passf) - { - print "Wrong password." - return - } - - split("", ongtable, ":") - while((getline temp < postfile)>0) - { - gsub(/[\r\n]/,"",temp) - eq=index(temp,"=") - tn=substr(temp,1,eq-1) - tv=substr(temp,eq+1) - - if(tn ~ /^[ou]ngd?-[0-9]+$/) - { - ongtable[tn]=brunescape(tv) - } - else if(tn == "key") - key=tv - else if(tn == "ID") - id=tv - - } - close(postfile) - - printf("")>postfile - - print "timenumber="htmlescape(postid) >> postfile - print "key="(key==""?newkey():key) >> postfile - print "username_h="htmlescape(name) >> postfile - print "subject_h="htmlescape(subject) >> postfile - print "story="story >> postfile - if (frame ~ /^[a-z]/) - print "frame="frame >> postfile - else - { - print "frame="sprintf("%04u",frame) >> postfile - print "round="sprintf("%02u",round) >> postfile - } - - print "h="htmlescape(h) >> postfile - print "d="htmlescape(d) >> postfile - print "m="htmlescape(m) >> postfile - print "y="htmlescape(y) >> postfile - - if(nobb!="") - print "disable_bbcode=on" >> postfile - if(nosmil!="") - print "disable_smilies=on" >> postfile - if(nourl!="") - print "disable_magic_url=on" >> postfile - - - - print "brtext="brescape(content) >> postfile - - gsub(/\[br\]/,"\n",content) - - for(i=0; content~/\[ong\]/; ++i) - { - tn=sprintf("ong-%u",i) - ongtext = ongtable[tn] - if (ongtext == "") - ongtext=ong() - print(tn"="brescape(ongtext)) >> postfile - sub(/\[ong\]/,subescape(ongtext),content) - } - for(i=0; content~/\[ung\]/; ++i) - { - tn=sprintf("ung-%u",i) - ongtext = ongtable[tn] - if (ongtext == "") - ongtext=ung() - print(tn"="brescape(ongtext)) >> postfile - sub(/\[ung\]/,subescape(ongtext),content) - } - for(i=0; content~/\[ong=decree\]/; ++i) - { - tn=sprintf("ongd-%u",i) - ongtext = ongtable[tn] - if (ongtext == "") - ongtext=ong("decree") - print(tn"="brescape(ongtext)) >> postfile - sub(/\[ong=decree\]/,subescape(ongtext),content) - } - for(i=0; content~/\[ung=decree\]/; ++i) - { - tn=sprintf("ungd-%u",i) - ongtext = ongtable[tn] - if (ongtext == "") - ongtext=ung("decree") - print(tn"="brescape(ongtext)) >> postfile - sub(/\[ung=decree\]/,subescape(ongtext),content) - } - - # print "content:\n"content - print "BBHTML="htmlescape(content,"","br") >> postfile - print "BB="htmlescape(content,"less","br") >> postfile - print "message="urlencode(content ((silent=="")?(nobb==""?"[right][size=80]-- posted by SilentBot [img]http://forums.xkcd.com/download/file.php?id=47884[/img][/size][/right]":"\n\n-- posted by SilentBot"):"")) >> postfile - if(id!="") - print"ID="id >> postfile - - print "posted." - system ("mawk -f "bb2html" -v outfile=\""postfile"\" \""postfile"\"") - system ("wait 1") - close (postfile) -} - -function urlencode(name,all, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if ((ch ~ /[a-zA-Z0-9\.\-_~]/)&&(all=="")) - escaped = escaped ch - else - escaped = escaped "%" ch2hex[ch] - } - return escaped -} -function hexencode(name, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1) - escaped = escaped ch2hex[ch] - } - return escaped -} -function subescape(subtext) -{ - gsub(/&/,"\\\\\\&",subtext) - return subtext -} - -function htmlescape(name,less,br, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if(ch == "\n") - escaped = escaped ((br!="")?"
":"&#"ch2dec[ch]";") - else if(ch =="\r") - escaped = escaped ((br!="")?"":"&#"ch2dec[ch]";") - else if(ch ~ /[\" ]/ && less=="")#"#"\"" - escaped = escaped "&#"ch2dec[ch]";" - else if(ch ~ /[=<>&]/) - escaped = escaped "&#"ch2dec[ch]";" - else - escaped = escaped ch - } - return escaped -} - -function getmeme(decree ,meme,i) -{ - if(decree!="" && lastdecr=="") - { - close(tempfile) - system (automome" -lc 256 -n "memenumber" -d "memepath" -t \"[decr]\" > "tempfile) - } - else if(decree=="" && lastdecr!="") - { - close(tempfile) - system (automome" -lc 256 -n "memenumber" -d "memepath" > "tempfile) - } - for(i=0; ((getline meme < tempfile)<=0) && (i<3); ++i) - { - memenumber=memenumber*2 - close(tempfile) - if(decree!="") - system (automome" -lc 256 -n "memenumber" -d "memepath" -t \"[decr]\" > "tempfile) - else - system (automome" -lc 256 -n "memenumber" -d "memepath" > "tempfile) - } - lastdecr=decree - return meme -} - -function ong(decree, line) -{ - while((line=getmeme(decree))!="") - { - gsub(/[\r\n]/,"",line) - if(sub(/[AEIOUY]-N-G/,"#O-N-G#",line)>0) - return preparebb(line) - if(sub(/O+N+G+/,"#&#",line)>0) - return preparebb(line) - if(sub(/DON'T/,"D#ON'G#T",line)>0) - return preparebb(line) - if(sub(/[AEIOUY]NG/,"#ONG#",line)>0) - { - if($0!~/TH\[b\]ONG/) - return preparebb(line) - } - if(sub(/ON /,"#ONG# ",line)>0) - return preparebb(line) - if(sub(/O\.?$/,"#ONG# ",$0)>0) - return preparebb(line) - } - return "Ong" -} - -function ung(decree, line) -{ - while((line=getmeme(decree))!="") - { - gsub(/[\r\n]/,"",line) - if(sub(/[AEIOUY]-N-G/,"#U-N-G#",line)>0) - return preparebb(line) - if(sub(/U+N+G+/,"#&#",line)>0) - return preparebb(line) - if(sub(/[AEIOUY]NG/,"#UNG#",line)>0) - return preparebb(line) - if(sub(/UN /,"#UNG# ",line)>0) - return preparebb(line) - if(sub(/U\.?$/,"#UNG# ",$0)>0) - return preparebb(line) - } - return "Ung" -} -function preparebb(rh) -{ - if(nobb=="") - { - gsub(/\*\*/,"¤",rh) - gsub(/\*[^\*]+\*/,"±&±",rh) - gsub(/±\*/,"[i]",rh) - gsub(/\*±/,"[/i]",rh) - gsub(/¤/,"*",rh) - - gsub(/&&/,"¤",rh) - gsub(/&[^&]+&/,"±&±",rh) - gsub(/±&/,"[center][b]",rh) - gsub(/&±/,"[/b][/center]",rh) - gsub(/¤/,"\\&",rh) - - gsub(/__/,"¤",rh) - gsub(/_[^_]+_/,"±&±",rh) - gsub(/±_/,"[u]",rh) - gsub(/_±/,"[/u]",rh) - gsub(/¤/,"_",rh) - - gsub(/##/,"¤",rh) - gsub(/#[^#]+#/,"±&±",rh) - gsub(/±#/,"[b]",rh) - gsub(/#±/,"[/b]",rh) - gsub(/¤/,"#",rh) - - gsub(/\$\$/,"¤",rh) - gsub(/\$[^\$]+\$/,"±&±",rh) - gsub(/±\$/,"[size=80]",rh) - gsub(/\$±/,"[/size]",rh) - gsub(/¤/,"$",rh) - } - - return rh (nobb==""?" -- [url=http://1190.bicyclesonthemoon.info/ongtext?b=on][b]ong[/b]o[/url][url=http://mrob.com/time/automome/]mome[/url]":" -- ongomome") -} -function unhtml(ht ,i,j,un,num) -{ - gsub(//,"[br]",ht) - while ((i=match(ht, /&#[0-9]+;/))!=0)# - { - un=un substr(ht, 1, i-1) - ht=substr(ht, i) - j=index(ht, ";") - num=int(substr(ht, 3, j-3)) - un=un sprintf("%c",num) - ht=substr(ht, j+1) - } - un=un ht - return un -} -function brescape(text) #there will be more -{ - gsub(/\r/,"",text) - gsub(/\n/,"[br]",text) - return text -} -function brunescape(text) #there will be more -{ - gsub(/\[br\]/,"\n",text) - return text -} -function urldecode(ht ,i,j,un,num) -# quot, amp, lt, gt, nbsp, and decimal numbered. -{ - while ((i=match(ht, /%[0-9a-fA-F][0-9a-fA-F]/))!=0)# - { - un=un substr(ht, 1, i-1) - ht=substr(ht, i) - num=toupper(substr(ht, 2, 2)) - un=un hex2ch[num] - ht=substr(ht, 4) - } - un=un ht - return un -} -function newkey( key,i,rn) -{ - for(i=0; i<8; ++i) - { - rn=int(rand()*65536) - key = key sprintf("%04X",rn) - } - return key -} diff --git a/upload.c b/upload.c deleted file mode 100644 index e4286a1..0000000 --- a/upload.c +++ /dev/null @@ -1,98 +0,0 @@ -// upload.c (1190.bicyclesonthemoon.info/aftertime/upload) -// The post upload interface -// 28.03.2015 -// -// Copyright (C) 2015 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include -#include -#include -#include -#include -#include - -#define RM_PATH "/bin/rm" -#define MAWK_PATH "/usr/bin/mawk" -#define AWK_UPLOAD "/eizm/pro/aftertime/upload.awk" -#define TEMP_PATH "/eizm/tmp/aftertime/upload." -#define RM_PATH "/bin/rm" - -s_cgi *cgi; -pid_t sub; -int r; - -int main(int argc, char **argv) -{ - char *temppath; - char **up; - time_t posttime; - struct tm *nowS; - char timetext[64]; - char timenumber[64]; - char temppath2[247]; - char temppath3[256]; - - setvbuf(stdout, NULL, _IONBF, 0); - dup2(fileno(stdout),fileno(stderr)); - - cgi=cgiInit(); - - sprintf(temppath2,"%s%lu",TEMP_PATH,(unsigned long)getpid()); - sprintf(temppath3,"tempfile=%s",temppath2); - - printf("Content-type: text\n\n"); - up=cgiGetFiles(cgi); - if (up) - { - temppath=cgiGetFile(cgi,up[0])->tmpfile; - - posttime=time(NULL); - nowS=gmtime(&posttime); - - sprintf(timenumber,"timenumber=%lu",(unsigned long)posttime); - sprintf(timetext,"timetext=%04d%02d%02d%02d",nowS->tm_year+1900,nowS->tm_mon+1,nowS->tm_mday,nowS->tm_hour); - - // printf("%s\n%s\n%s\n",timenumber,timetext,temppath); - - sub=fork(); - if(!sub) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_UPLOAD,"-v",timetext,"-v",timenumber,"-v",temppath3,temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - - sub=fork(); - if(!sub) - { - r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - sub=fork(); - if(!sub) - { - r=execl(RM_PATH,RM_PATH,"-f",temppath2,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - - return 0; - } - printf("File missing\n"); - return 0; -} diff --git a/verify.awk b/verify.awk deleted file mode 100644 index b94bfff..0000000 --- a/verify.awk +++ /dev/null @@ -1,86 +0,0 @@ -#// verify.awk -#// Check if post belongs to user -#// 15.04.2019 -#// -#// Copyright (C) 2015, 2019 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - passpath="/eizm/mem/aftertime/pass/" - FS="=" - # for(i=0;i<256;++i) - # { - # ch=sprintf("%c",i) - # hex=sprintf("%02X",i); - # ch2hex[ch]=hex - # hex2ch[hex]=ch - # } - if(reversed!="") - { - ok=1 - fail=0 - } - else - { - ok=0 - fail=1 - } -} -# { - # gsub(/[\r\n]/,"",$0) - # eq=index($0,"=") - # argtab[substr($0,1,eq-1)]=substr($0,eq+1) -# } -END{ - while((getline line < file)>0) - { - gsub(/[\r\n]/,"",line) - eq=index(line,"=") - argtab[substr(line,1,eq-1)]=substr(line,eq+1) - } - close (file) - - if(story=="") - story=argtab["story"] - - else if(story!=argtab["story"] && argtab["story"]!="") - exit fail - - passfile = passpath story - getline namef < passfile - getline passf < passfile - close (passfile) - gsub(/[\r\n]/,"",namef) - gsub(/[\r\n]/,"",passf) - - if(namef==name&&passf==pass) - exit ok - else - exit fail -} -# function urlencode(name,all, len,iii,escaped,ch) -# { - # len=length(name) - # escaped="" - # for(iii=1;iii<=len;++iii) - # { - # ch=substr(name,iii,1); - # if ((ch ~ /[a-zA-Z0-9\.\-_~]/)&&(all=="")) - # escaped = escaped ch - # else - # escaped = escaped "%" ch2hex[ch] - # } - # return escaped -# } diff --git a/view.awk b/view.awk deleted file mode 100644 index 55d186d..0000000 --- a/view.awk +++ /dev/null @@ -1,59 +0,0 @@ -#// view.awk -#// insert text -#// 27.03.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - - -###reusedfrommirror; - -{ - # if ($0 ~ /^###sig&/) - # { - # split ($0 ,arr,"&") - # system("cat " sig arr[2]) - # } - # else if ($0 ~ /^###inf&/) - # { - # split ($0 ,arr,"&") - # system("cat " otterinf arr[2]) - # } - # else if ($0 ~ /^###prev/) - # { - # print left - # } - # else if ($0 ~ /^###next/) - # { - # print right - # } - # else if ($0 ~ /^###links/) - # { - # system ("cat " links); - # } - # else - if ($0 ~ /^###info/) - { - print info; - } - else if ($0 ~ /^###title/) - { - print title; - } - else - { - print $0 - } -}; diff --git a/viewer.awk b/viewer.awk deleted file mode 100644 index 50e2713..0000000 --- a/viewer.awk +++ /dev/null @@ -1,687 +0,0 @@ -#// viewer.awk -#// The viewer -#// 25.05.2021 -#// -#// Copyright (C) 2015-2021 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero General Public License as -#// published by the Free Software Foundation, either version 3 of the -#// License, or (at your option) any later version. -#// -#// This program 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - - -BEGIN{ - FS="" - noticepath="/eizm/mem/aftertime/mpost/" - framepath="/eizm/www/time/" - datapath="/eizm/data/aftertime/" - timecmd="date -u +\"%Y%m%d%H\"" - timecmd2="date +\"%H%M%S\"" - timecmd3="date -u +\"%m%d%H%M\"" - timecmd4="date -u +\"%s\"" - botcastleurl="http://1190.bicyclesonthemoon.info" - postlink="http://forums.xkcd.com/viewtopic.php?f=7" - - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i) - dec=sprintf("%u",i) - ch2hex[ch]=hex - ch2dec[ch]=dec - } - - listfile = datapath "stories" - stories=0 - line="" - while((getline line < listfile)>0) - { - gsub(/[\r\n]/,"",line) - eq=index(line,"=") - - storytab[stories]=htmlescape(substr(line, 1, eq-1),"","") - storyname[stories]=htmlescape(substr(line, eq+1),"","") - ++stories - } - close(listfile) - - if(frame ~ /[a-zA-Z]$/) - { - f=int(substr(frame,1,length(frame)-1)) - s=substr(frame, length(frame)) - } - else - { - f=int(frame) - s="" - } - e=int(enhance) - n=int(notice) - b=int(bbcode) - - timecmd | getline thistime - close(timecmd) - - timecmd2 | getline thistime2 - close(timecmd2) - - timecmd3 | getline thistime3 - close(timecmd3) - - timecmd4 | getline thistime4 - close(timecmd4) - - thistime3=int(thistime3) - thistime4=int(thistime4) - - lastalt=0 - - ch2num[0]="" - num2ch[""]=0 - for(i=1;i<=26;++i) - { - ch=sprintf("%c",i+96) - num2ch[i]=ch - ch2num[ch]=i - } - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - dec=sprintf("%u",i) - ch2dec[ch]=dec - } - alttabsize=0 -} -{ - file=1 - gsub(/[\r\n]/, "", $0) - eq=index($0, "=") - if($0 ~ /^[0-9]+=/) - { - i=int(substr($0, 1, eq-1)) - alttab[alttabsize]=substr($0, eq+1) - alttabn[alttabsize]=i - ++alttabsize - - # i=int(substr($0, 1, eq-1)) - # if(f>=i && i>=lastalt) - # { - # alt=substr($0, eq+1) - # lastalt=i - # } - } - else if($0 ~ /^sf-[0-9]+=/) - { - sf=1 - i=int(substr($0, 4, eq-4)) - if(i==f) - this_sf= tolower(substr($0, eq+1)) - if(i==f-1) - prev_sf=tolower(substr($0, eq+1)) - - } - argtab[substr($0, 1, eq-1)]=substr($0, eq+1) -} -END{ - - if (file=="") - exit 1 - - if(sf=="") - s="" - else if(this_sf=="") - s="" - else if(s>this_sf && argtab["cfrt"]=="") - s=this_sf - - ongoing=int(argtab["ongoing"]) - if(ongoing>0) - { - statefile= datapath argtab["story"]"/ongstate" - getline temp < statefile - close(statefile) - - split(temp, temptab, " ") - state=int(temptab[1]) - last=int(temptab[2]) - nextong=int(temptab[3]) - } - else - { - last=int(argtab["last"]) - state=3 - } - first=int(argtab["first"]) - - ongtimefile= datapath argtab["story"]"/ongtime" - - if(frame=="") - { - if(ongoing>0) - { - if (int(argtab["onlyframe"])>0) - { - f=last - onlyframe=1 - } - else - { - onlyframe="" - if (int(argtab["showlatest"])>0) - f=last - else - f=first - } - } - else - { - f=first - onlyframe="" - if (replay != "") - { - # print "DEBUG:
" - ongyr=0 - ongsy=0 - line="" - while((getline line < ongtimefile)>0) - { - ongind=index(line," ") - ongft=substr(line,1,ongind-1) - ongt=int((ongsy?(substr(line,ongind+1,4)-ongyr):0) substr(line,ongind+6,2) substr(line,ongind+9,2) substr(line,ongind+12,2) substr(line,ongind+15,2)) - - # printf("o.%d
",ongt) - - if(!ongsy) - { - ongsy=1 - ongyr=substr(line,ongind+1,4) - # printf("3.%d
",thistime3) - if(thistime3",thistime3) - } - } - - if(ongt>thistime3) - { - # if(ongsm) - # print"BREAK!
" - break; - } - # else - # ongsm=1; - if(ongft ~ /^[0-9]+[a-z]$/) - { - f=int(substr(ongft,1,ongind-2)) - s=substr(ongft,ongind-1,1) - } - else - { - f=int(ongft) - s="" - } - # print"f."f"."s"
" - } - close(ongtimefile) - } - } - } - - if (s!="") - { - if(argtab[s] != "") - s2=argtab[s] - else - s2=s - # n=-1 - } - - if(flast && argtab["cfrt"]=="") - f=last - - if(argtab["special"] != "") - { - specialfile=datapath argtab["story"]"/"sprintf(argtab["special"],f,s) - line="" - undertext="" - - while((getline line < specialfile)>0) - { - gsub(/[\r\n]/, "", line) - - if (line == "" && !undertext) - { - undertext=1 - argtab["text"]="" - continue - } - - if (undertext) - { - argtab["text"] = argtab["text"] line "\n" - } - else - { - - eq=index(line, "=") - argtab[substr(line, 1, eq-1)]=substr(line, eq+1) - } - } - close (specialfile) - } - - line="" - while((getline line < ongtimefile)>0) - { - ongind=index(line," ") - ongft=substr(line,1,ongind-1) - ongt=substr(line,ongind+9,2)"."substr(line,ongind+6,2)"."substr(line,ongind+1,4)", "substr(line,ongind+12,2)":"substr(line,ongind+15,2)" UTC" - if(ongft ~ /^[0-9]+[a-z]$/) - ongf=int(substr(ongft,1,ongind-2)) substr(ongft,ongind-1,1) - else - ongf=int(ongft) - - if(ongf==(f s) && ongt ~ /^[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9][0-9][0-9], [0-9][0-9]:[0-9][0-9] UTC$/) - ongtimetext=ongt - } - close(ongtimefile) - - if ("alt" in argtab) - alt=htmlescape(argtab["alt"],"less","bb") - else - { - for(i=0; i=alttabn[i] && alttabn[i]>=lastalt) - { - alt=htmlescape(alttab[i],"less","bb") - lastalt=alttabn[i] - } - } - } - - if(argtab["number"]!="") - numberformat=argtab["number"] - else - { - # if (sf!="") - numberformat="%u%s" - # else - # numberformat="%u" - } - - framedir= (argtab["framedir"]!="" ? argtab["framedir"] : "/aftertime/"argtab["story"]"/") - # if(sf!="") - # { - title=htmlescape(sprintf(argtab["title"(e>0 ? "-"e : "")],f,s2),"less","bb") - frame=framedir sprintf(argtab["frame"(e>0 ? "-"e : "")],f,s) - if (system("[ -f " framepath frame" ]")!=0) - { - frame= framedir sprintf(argtab["frame"],f,s) - title=htmlescape(sprintf(argtab["title"],f,s2),"less","bb") - noenh=1 - } - otherviewerurl=sprintf(argtab["otherviewerurl"], f+int(argtab["othervieweroffset"]),s2) - # } - # else - # { - # s="" - # title=htmlescape(sprintf(argtab["title"(e>0 ? "-"e : "")],f),"less","bb") - # frame= framedir sprintf(argtab["frame"(e>0 ? "-"e : "")],f) - # if (system("[ -f " framepath frame" ]")!=0) - # { - # frame= framedir sprintf(argtab["frame"],f) - # title=htmlescape(sprintf(argtab["title"],f,s),"less","bb") - # noenh=1 - # } - # otherviewerurl=sprintf(argtab["otherviewerurl"], f+int(argtab["othervieweroffset"])) - # } - - dynamicframe="/aftertime/frame?story="argtab["story"](max_enhance>0?"&e="e:"")"&f="f s - - if((f>last || fthis_sf)) && argtab["cfrt"]!="") - frame= framedir argtab["cfrt"] - - border= int(argtab["border"]) - if(argtab["width"]!="") - width= int(argtab["width"]) + 2*border - else - width="100%" - max_enhance=int(argtab["enhance"]) - - if (this_sf=="") - { - next_f= f+1 - next_s= "" - } - else if(s=="") - { - next_f=f - next_s="a" - } - else if(s>=this_sf) - { - next_f= f+1 - next_s= "" - } - else - { - next_f = f - next_s = num2ch[ch2num[s]+1] - } - - if(this_sf!="" && s!="") - { - prev_f = f - prev_s = num2ch[ch2num[s]-1] - } - else if(prev_sf!="") - { - prev_f = f-1 - prev_s = prev_sf - } - else - { - prev_f = f-1 - prev_s = "" - } - - if(prev_s!=""){ - if(argtab[prev_s]!=""){ - prev_s2=argtab[prev_s] - } - else - { - prev_s2=prev_s - } - } - else - prev_s2 = "" - if (next_s!="") - { - if(argtab[next_s]!=""){ - next_s2=argtab[next_s] - } - else - { - next_s2=next_s - } - } - else - next_s2 = "" - - print "" - print "" - print ""title" • time after Time viewer • Bicycles on the Moon" - print "" - print "" - print "" - print "" - print "0?"&e="e:"")"&f="first"\">" - if(f>first) - { - print "0?"&e="e:"")"&f="prev_f prev_s"\">" - } - if(f0?"&e="e:"")"&f="next_f next_s"\">" - print "0?"&e="e:"")"&f="next_f next_s"\">" - } - print "
" - print "\"1190.bicyclesonthemoon.info\"
" - print "

"title"

" - print "" - print "" - - if(ongoing==1) - { - # print "" - } - - if(onlyframe=="") - { - if(max_enhance>0) - { - print "" - } - - print "" - print "" - print "" - print "" - print "" - print "" - - if(ongtimetext!="") - { - if(argtab["ID"]!="") - { - print "" - } - # else if (argtab["otherviewerurl"]!="") - # { - # print "" - # } - else - print "" - } - - if(argtab["HTML"]!="" && b==0) - { - print "" - } - - for(i=-1; i<=n; ++i) - { - if(i<0) - noticepost=noticepath argtab["story"]"-i" - else - noticepost=noticepath argtab["story"]"-"sprintf("%04u%s",f,s)"-"sprintf("%02u",i+1) - # print "" - split("", noticetab, ":") - for(j=0;(getline line < noticepost)>0;++j) - { - gsub(/[\r\n]/,"",line) - eq=index(line,"=") - noticetab[substr(line, 1, eq-1)]=substr(line, eq+1) - } - close(noticepost) - if(j==0) - { - if(i<0) - continue; - else - break; - } - if(i>=0) - { - nposttime=noticetab["y"]noticetab["m"]noticetab["d"]noticetab["h"] - if (thistime=0) - print "" - print"" - } - else - { - print "" - } - } - - if(b>0) - { - if (argtab["BBHTML"]!="") - { - bbtext=argtab["BBHTML"] - } - else if (argtab["text"]!="") - { - bbtext=htmlescape(argtab["text"],"less","bb") - gsub(/ /,"\\  ",bbtext) - gsub(/ /," \\ ",bbtext) - } - - print "" - - ongbotdefined="" - ongbotfile= datapath argtab["story"] "/" ((argtab["pleaseongbot"]!="")?argtab["pleaseongbot"]:"pleaseongbot") - if (system("[ -f " ongbotfile " ]")==0) - ongbotdefined=1 - - if(ongbotdefined && ongoing>0 && state>0 && state<4 && f==last && b==(alt!=""?2:1)) - { - print "" - } - if(b==1 && alt!="") - print "" - } - else - print "" - - if(argtab["otherviewerurl"]!="") - print "" - - print "" - - print "" - - print "" - } - print "
" - if(onlyframe!="") - print "0?"&e="e:"")"&f="f s"\">" - print "0 && state <2 && f==last)?dynamicframe:frame)"\" alt=\""title"\" title=\""alt"\" border=\""border"\">" - if(onlyframe!="") - print "" - print "
" - if(state<3) - { - # ongtime=int(argtab["ongtime"]) - # dt = (3600*ongtime - ( int(substr(thistime2,5,2)) + 60*int(substr(thistime2,3,2)) + 3600*( int(substr(thistime2,1,2))%int(argtab["ongtime"]) ) ))%(ongtime*3600) - # ss=(dt>0 ? sprintf("%02u",dt%60) : "NG") - # mm=sprintf("%02u",int(dt/60)%60) - # hh=sprintf("%02u",int(dt/3600)) - dt=nextong-thistime4 - if (dt<-5) - { - ss="EE" - mm="EE" - hh="EE" - } - else if (dt>0) - { - ss=sprintf("%02u",dt%60) - mm=sprintf("%02u",int(dt/60)%60) - if ((dt/3600)>99) - hh="EE" - else - hh=sprintf("%02u",int(dt/3600)) - } - else { - ss="NG" - mm="00" - hh="00" - } - } - else - { - ss="EE" - mm="EE" - hh="EE" - } - # hh=nextong" "thistime4 - timecolor=(state>1?"br":"ni") - - print "
"hh":"mm":"ss"
[" - for(i=0;i<=max_enhance;++i) - { - if(i!=0) - print "|" - # if(sf!="") - enhancedframe = framedir sprintf(argtab["frame"(i>0?"-"i:"")],f,s) - # else - # enhancedframe = framedir sprintf(argtab["frame"(i>0?"-"i:"")],f) - - - if (system("[ -f " framepath enhancedframe" ]")==0) - { - if(i==e) - print""argtab["enhance-"i]"" - else - print"0)?("&b="b):"")"\">"argtab["enhance-"i]"" - } - else - print argtab["enhance-"i] - } - print "]
0?"&e="e:"")"&f="first"\">|< "sprintf(numberformat,first,"")""(f>first?"0?"&e="e:"")"&f="prev_f prev_s"\">< "sprintf(numberformat,prev_f,prev_s2)"":"")""(f0?"&e="e:"")"&f="next_f next_s"\">"sprintf(numberformat,next_f,next_s2)" >":"")"0?"&e="e:"")"&f="last"\">"sprintf(numberformat,last,"")" >|
"ongtimetext"
"ongtimetext"
"ongtimetext"
"argtab["HTML"]"
"noticetab["subject_h"]" "(noticetab["ID"]!=""?"        (OTT time travel)":"")"
"((noticetab["HTML"]!="")?noticetab["HTML"]:noticetab["BBHTML"])"
0?"&e="e:"")"&f="f s"&n="i+1"\">"noticetab["subject_h"]"
" - print"[url="botcastleurl"/aftertime/viewer?story="argtab["story"](max_enhance>0?"&e="e:"")"&f="f s"][img]"botcastleurl frame"[/img][/url]"(bbtext!=""?"
"bbtext:"")(b>1 && alt!=""?"[spoiler]"alt"[/spoiler]":"") - print"
" - print "
" - print "[]" - print "" - if(e>0 && noenh=="") - print "" - print "
[0?"&e="e:"")"&f="f s"&b=2\">spoiler]
[0?"&e="e:"")"&f="f s"&b=1\">bbcode]
["argtab["otherviewertext"]"]
Go to frame:" - print "" - if(max_enhance>0) - print "" - print "" - print "" - if(ongtimetext!="" && ongoing==0) - { - # print ongoing - # print"" - # print "" - # if(max_enhance>0) - # print "" - # print "" - print "" - # print "
" - } - - print"
Go to story:
Aftertime ONGsystem
" - - print "
1190.bicyclesonthemoon.info" - print "
" - - -} - -function htmlescape(name,less,br, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if(ch == "\n") - escaped = escaped ((br!="")?"
":"&#"ch2dec[ch]";") - else if(ch =="\r") - escaped = escaped ((br!="")?"":"&#"ch2dec[ch]";") - else if(ch ~ /[\" ]/ && less=="")#"#"\"" - escaped = escaped "&#"ch2dec[ch]";" - else if(ch ~ /[=<>&]/) - escaped = escaped "&#"ch2dec[ch]";" - else - escaped = escaped ch - } - return escaped -} diff --git a/viewer.c b/viewer.c deleted file mode 100644 index 5309b5b..0000000 --- a/viewer.c +++ /dev/null @@ -1,115 +0,0 @@ -// viewer.c (1190.bicyclesonthemoon.info/aftertime/viewer) -// The viewer -// 21.06.2018 -// -// Copyright (C) 2015-2016, 2018 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#define STORYDEF_PRINTF "/eizm/data/aftertime/%s/settings" -#define MAWK_PATH "/usr/bin/mawk" -#define AWK_VIEWER "/eizm/pro/aftertime/viewer.awk" - -#include -#include -#include -#include -#include -#include - -s_cgi *cgi; - -void escape(char *text); - -int main (int argc, char *argv[]) -{ - s_cgi *cgi; - pid_t sub; - int r; - - char *story; - char *f; - char *bb; - char *enh; - char *notic; - char *replay; - - char arg1[256]; - char arg2[256]; - char arg3[256]; - char arg4[256]; - char arg5[256]; - char arg6[256]; - char storydef[256]; - - cgi=cgiInit(); - - //setvbuf(stdout, NULL, _IONBF, 0); - dup2(fileno(stdout),fileno(stderr)); - - story=cgiGetValue(cgi,"story"); - if(story!=NULL) - escape(story); - f=cgiGetValue(cgi,"f"); - bb=cgiGetValue(cgi,"b"); - enh=cgiGetValue(cgi,"e"); - notic=cgiGetValue(cgi,"n"); - replay=cgiGetValue(cgi,"r"); - - snprintf(arg1,256,"story=%s",story!=NULL ? story : ""); - snprintf(arg2,256,"frame=%s",f!=NULL ? f : ""); - snprintf(arg3,256,"bbcode=%s",bb!=NULL ? bb : ""); - snprintf(arg4,256,"enhance=%s",enh!=NULL ? enh : ""); - snprintf(arg5,256,"notice=%s",notic!=NULL ? notic : ""); - snprintf(arg6,256,"replay=%s",replay!=NULL ? replay : ""); - - sprintf(storydef,STORYDEF_PRINTF,story!=NULL ? story : "time"); - - printf("Content-type: text/html\n\n"); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_VIEWER,"-v",arg1,"-v",arg2,"-v",arg3,"-v",arg4,"-v",arg5,"-v",arg6,storydef,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - { - sprintf(storydef,STORYDEF_PRINTF,"default"); - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_VIEWER,"-v",arg1,"-v",arg2,"-v",arg3,"-v",arg4,"-v",arg5,"-v",arg5,storydef,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - } - - return 0; -} - -void escape(char *text){ - unsigned short i, len; - - len=strlen(text); - for (i=0;i - -time after Time • Bicycles on the Moon - - - - - - -1190.bicyclesonthemoon.info -

time after Time

-###info -1190.bicyclesonthemoon.info diff --git a/www/post.htm b/www/post.htm deleted file mode 100644 index 87c86af..0000000 --- a/www/post.htm +++ /dev/null @@ -1,169 +0,0 @@ - - -time after Time • Bicycles on the Moon - - - - - - - -1190.bicyclesonthemoon.info -

time after Time

-
-###debug -###future - - - -###HTML -
-
Send a message
-###wrong -
-
- -
Story: -###postid -
Subject: -###subject -
Username: -###username -
Password: - -
Time (gmt): -###time -
Action: - - -
-
-
- - - - - - - - - - - - - - - - - - - - Font size:  - -
-###ottid - (optional post ID) -
- -
-
Write here:
-###message -
Options:
-
-###disable_bbcode -###disable_smilies -###disable_magic_url -###forceID -###forcekey -
-
-###back -

1190.bicyclesonthemoon.info -- 2.30.2