--- /dev/null
+confirmd
+cookf
+htmltemp
+htmltmp2
+lastmax
+lasttemp
+nextpost
+postf
+postfile
+tempf
+thispost
--- /dev/null
+SCHEDULE2 = */12 * * * *
+SCHEDULE4 = 11 6 */2 * *
+CRON_USER = b
+ROOT = root
+
+CRON_DIR = /etc/cron.d
+BIN_DIR = /botm/bin/mrobsniped
+
+CP = /usr/bin/cp
+MV = /usr/bin/mov
+RM = /usr/bin/rm
+CHMOD = /usr/bin/chmod
+CHOWN = /usr/bin/chown
+
+all: mrobsniped.cron
+
+install: cronout
+
+mrobsniped.cron:
+ echo "###mrobsniped" > mrobsniped.cron
+ echo "$(SCHEDULE2) $(CRON_USER) $(BIN_DIR)/sniped2.awk" >> mrobsniped.cron
+ echo "$(SCHEDULE4) $(CRON_USER) $(BIN_DIR)/sniped4.awk" >> mrobsniped.cron
+
+cronout: mrobsniped.cron
+ $(CHMOD) o-w,g-w mrobsniped.cron
+ $(CHOWN) $(ROOT) mrobsniped.cron
+ $(MV) mrobsniped.cron $(CRON_DIR)
+
+clean:
+ $(RM) mrobsniped.cron
+
+PHONY: all install cronout clean
--- /dev/null
+BEGIN{\r
+ FS="="\r
+ fora="http://1190.bicyclesonthemoon.info/ott"\r
+ useragent="\"mr*bdexbot (http://1190.bicyclesonthemoon.info/mrobsniped/; mr*bdex bOTTeriada post bot)\""\r
+};\r
+{\r
+ eq=index($0,"=")\r
+ argtab[substr($0,1,eq-1)]=substr($0,eq+1)\r
+};\r
+END{\r
+ printf ("username=%s",argtab["username"])>postfile\r
+ printf ("&password=%s",argtab["password"])>>postfile\r
+ printf ("&subject=%s",argtab["subject"])>>postfile\r
+ if("&addbbcode20" in argtab)\r
+ printf ("&addbbcode20=%s",argtab["addbbcode20"])>>postfile\r
+ printf ("&message=%s",argtab["message"])>>postfile\r
+ printf ("&post=%s","Submit")>>postfile\r
+ if("disable_bbcode" in argtab)\r
+ printf ("&disable_bbcode=%s",argtab["disable_bbcode"])>>postfile\r
+ if("disable_smilies" in argtab)\r
+ printf ("&disable_smilies=%s",argtab["disable_smilies"])>>postfile\r
+ if("disable_magic_url" in argtab)\r
+ printf ("&disable_magic_url=%s",argtab["disable_magic_url"])>>postfile\r
+ if("attach_sig" in argtab)\r
+ printf ("&attach_sig=%s",argtab["attach_sig"])>>postfile\r
+ if("notify" in argtab)\r
+ printf ("¬ify=%s",argtab["notify"])>>postfile\r
+ printf ("&creation_time=%s",argtab["creation_time"])>>postfile\r
+ printf ("&form_token=%s",argtab["form_token"])>>postfile\r
+ close(postfile)\r
+ \r
+ if(system("wget -q -t 3 --connect-timeout=60 --post-file=" postfile " -U " useragent " -O " tempfile " \""fora "/post\""))\r
+ {\r
+ print "Submit fail."\r
+ exit 1\r
+ }\r
+ \r
+ while((getline temp < tempfile)>0)\r
+ {\r
+ if (temp ~ /<p class=.error/)\r
+ {\r
+ print temp\r
+ print "POST IMPOSSIBLE!"\r
+ exit 2\r
+ }\r
+ if (tolower(temp) ~ /<h2>information/)\r
+ {\r
+ success=1\r
+ }\r
+ }\r
+ close(tempfile)\r
+ \r
+ if (success!=1)\r
+ {\r
+ print "Sent back to preview!"\r
+ exit INDELIVERABLE\r
+ }\r
+}\r
--- /dev/null
+###mrobsniped
+*/12 * * * * b /botm/bin/mrobsniped/sniped2.awk
+11 6 */2 * * b /botm/bin/mrobsniped/sniped4.awk
--- /dev/null
+BEGIN{\r
+ FS="="\r
+ fora="http://forums.xkcd.com"\r
+ useragent="\"mr*bdexbot (http://1190.bicyclesonthemoon.info/mrobsniped/; mr*bdex bOTTeriada post bot)\""\r
+ \r
+ for(i=0;i<256;++i)\r
+ {\r
+ ch=sprintf("%c",i)\r
+ hex=sprintf("%02X",i);\r
+ ch2hex[ch]=hex\r
+ }\r
+};\r
+{\r
+ eq=index($0,"=")\r
+ argtab[substr($0,1,eq-1)]=substr($0,eq+1)\r
+};\r
+END{\r
+ if(system("wget -q -t 3 --connect-timeout=60 --save-cookies=" cookiefile " -U " useragent " -O " tempfile " " fora "/ucp.php?mode=login"))\r
+ {\r
+ print "Pre-login fail."\r
+ exit 1\r
+ }\r
+ while((getline cookie < cookiefile)>0)\r
+ {\r
+ if(cookie ~ /_sid/)\r
+ {\r
+ split(cookie,arr,"_sid[ \t]*")\r
+ SID=arr[2]\r
+ }\r
+ }\r
+ close(cookiefile)\r
+ print "username=" argtab["username"] "&password=" argtab["password"] "&sid=" SID "&login=Login" > postfile\r
+ close(postfile)\r
+ if(system("wget -q -t 3 --connect-timeout=60 --save-cookies=" cookiefile " --post-file=" postfile " -U " useragent " -O " tempfile " \"" fora "/ucp.php?mode=login\""))\r
+ {\r
+ print "Login fail."\r
+ exit 1\r
+ }\r
+ \r
+ while((getline temp < tempfile)>0)\r
+ {\r
+ if (temp ~ /<div class=.error/)\r
+ {\r
+ print temp\r
+ print "LOGIN IMPOSSIBLE!"\r
+ exit 2\r
+ }\r
+ }\r
+ close(tempfile)\r
+ \r
+ if(system("wget -q -t 3 --connect-timeout=60 --load-cookies=" cookiefile " --save-cookies=" cookiefile " -U " useragent " -O " tempfile " \"" fora "/posting.php?mode="((edit!="")?"edit&f=7&p="edit:"reply&f=7&t=101043")"\""))\r
+ {\r
+ print "Postreply fail."\r
+ exit 1\r
+ }\r
+ \r
+ while((getline temp < tempfile)>0)\r
+ {\r
+ if(((i=match(temp, /<textarea.*id=\"message\"/))!=0)) #"\r
+ {\r
+ textarea="1"\r
+ temp=substr(temp, i)\r
+ temp=substr(temp, index(temp, ">")+1)\r
+ }\r
+ if(textarea!="")\r
+ {\r
+ if((i=match(temp, /<\/textarea/))!=0)\r
+ {\r
+ temp=substr(temp,1,i-1)\r
+ textarea=""\r
+ }\r
+ argtab["old_message"] = argtab["old_message"] urlencode(entitydecode(temp)"\n")\r
+ \r
+ }\r
+ else if(temp ~ /name=\"form_token/)\r
+ #\"#"\r
+ {\r
+ temp=substr(temp, index(temp, "value=\"")+7)\r
+ temp=substr(temp, 1, index(temp, "\"")-1)\r
+ argtab["form_token"]=urlencode(entitydecode(temp))\r
+ }\r
+ else if(temp ~ /name=\"creation_time/)\r
+ #\"#"\r
+ {\r
+ temp=substr(temp, index(temp, "value=\"")+7)\r
+ temp=substr(temp, 1, index(temp, "\"")-1)\r
+ argtab["creation_time"]=urlencode(entitydecode(temp))\r
+ }\r
+ else if(temp ~ /name=\"subject/)\r
+ #\"#"\r
+ {\r
+ temp=substr(temp, index(temp, "value=\"")+7)\r
+ temp=substr(temp, 1, index(temp, "\"")-1)\r
+ argtab["old_subject"]=urlencode(entitydecode(temp))\r
+ }\r
+ if (tolower(temp) ~ /<h2>information/)\r
+ {\r
+ print "Unexpected h2: information\n"\r
+ getline temp < tempfile\r
+ print temp\r
+ exit 1\r
+ }\r
+ }\r
+ close(tempfile)\r
+ \r
+ printf ("subject=%s",argtab[(edit!="")?"old_subject":"subject"])>postfile\r
+ if("&addbbcode20" in argtab)\r
+ printf ("&addbbcode20=%s",argtab["addbbcode20"])>>postfile\r
+ if(edit!="")\r
+ printf ("&message=%s",argtab["old_message"] "%5Bsize%3D110%5D%5Bb%5D" argtab["subject"] "%5B%2Fb%5D%5B%2Fsize%5D%0A%5Bsize%3D80%5D" argtab["d"] "." argtab["m"] "." argtab["y"] "%20" argtab["h"] "%3A00%20GMT%5B%2Fsize%5D%0A" argtab["message"])>>postfile\r
+ else\r
+ printf ("&message=%s",argtab["message"])>>postfile\r
+ printf ("&post=%s","Submit")>>postfile\r
+ if("disable_bbcode" in argtab)\r
+ printf ("&disable_bbcode=%s",argtab["disable_bbcode"])>>postfile\r
+ if("disable_smilies" in argtab)\r
+ printf ("&disable_smilies=%s",argtab["disable_smilies"])>>postfile\r
+ if("disable_magic_url" in argtab)\r
+ printf ("&disable_magic_url=%s",argtab["disable_magic_url"])>>postfile\r
+ if("attach_sig" in argtab)\r
+ printf ("&attach_sig=%s",argtab["attach_sig"])>>postfile\r
+ if("notify" in argtab)\r
+ printf ("¬ify=%s",argtab["notify"])>>postfile\r
+ printf ("&creation_time=%s",argtab["creation_time"])>>postfile\r
+ printf ("&form_token=%s",argtab["form_token"])>>postfile\r
+ close(postfile)\r
+ \r
+ system("sleep 1")\r
+ 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")"\""))\r
+ {\r
+ print "Submit fail."\r
+ exit 1\r
+ }\r
+ \r
+ while((getline temp < tempfile)>0)\r
+ {\r
+ if (temp ~ /<p class=.error/)\r
+ {\r
+ print temp\r
+ print "POST IMPOSSIBLE!"\r
+ exit 2\r
+ }\r
+ if (tolower(temp) ~ /<h2>information/)\r
+ {\r
+ success=1\r
+ }\r
+ }\r
+ close(tempfile)\r
+ \r
+ if (success!=1)\r
+ {\r
+ print "Sent back to preview!"\r
+ exit INDELIVERABLE\r
+ }\r
+ \r
+ while((getline cookie < cookiefile)>0)\r
+ {\r
+ if(cookie ~ /_sid/)\r
+ {\r
+ split(cookie,arr,"_sid[ \t]*")\r
+ SID=arr[2]\r
+ break\r
+ }\r
+ }\r
+ close(cookiefile)\r
+ if(system("wget -q -t 3 --connect-timeout=60 -U " useragent " -O " tempfile " \"" fora "/ucp.php?mode=logout&sid=" SID"\""))\r
+ {\r
+ print "Logout fail."\r
+ }\r
+ \r
+ \r
+}\r
+function urlencode(name,all, len,iii,escaped,ch)\r
+{\r
+ len=length(name)\r
+ escaped=""\r
+ for(iii=1;iii<=len;++iii)\r
+ {\r
+ ch=substr(name,iii,1);\r
+ if ((ch ~ /[a-zA-Z0-9\.\-_~]/)&&(all==""))\r
+ escaped = escaped ch\r
+ else\r
+ escaped = escaped "%" ch2hex[ch]\r
+ }\r
+ return escaped\r
+}\r
+function entitydecode(ht ,i,j,un,num)\r
+# quot, amp, lt, gt, nbsp, and decimal numbered.\r
+{\r
+ while ((i=match(ht, /&((#[0-9]+)|([a-zA-Z]+));/))!=0)#\r
+ {\r
+ un=un substr(ht, 1, i-1)\r
+ ht=substr(ht, i)\r
+ j=index(ht, ";")\r
+ \r
+ if(ht~/^&#/)\r
+ {\r
+ num=int(substr(ht, 3, j-3))\r
+ un=un sprintf("%c",num)\r
+ }\r
+ else\r
+ {\r
+ num=tolower(substr(ht, 2, j-2))\r
+ if(num == "quot")\r
+ un=un "\""\r
+ else if(num == "amp")\r
+ un=un "&"\r
+ else if(num == "lt")\r
+ un=un "<"\r
+ else if(num == "gt")\r
+ un=un ">"\r
+ else if(num == "nbsp")\r
+ un=un "\xA0"\r
+ else\r
+ un = un ht\r
+ }\r
+ ht=substr(ht, j+1)\r
+ }\r
+ un=un ht\r
+ return un\r
+}\r
--- /dev/null
+BEGIN{\r
+ RS="<"\r
+ FS="#"\r
+ for(i=0;i<255;++i)\r
+ {\r
+ ch=sprintf("%c",i)\r
+ hex=sprintf("%02x",i)\r
+ HEX=sprintf("%02X",i)\r
+ hex2ch[HEX]=ch\r
+ hex2ch[hex]=ch\r
+ }\r
+ #hex2ch["00"]=" "\r
+}\r
+{\r
+ if($0 ~ /id=\"content\"/) #")\r
+ ok=1\r
+ if($0 ~ /href=\"(index.html)?#contents\"/) #")\r
+ ok=""\r
+ if(ok!="")\r
+ {\r
+ if($0 ~ /class=\"bl0nk\"/) #")\r
+ a=a "0"\r
+ if($0 ~ /class=\"bl1nk\"/) #")\r
+ a=a "1"\r
+ }\r
+}\r
+END{\r
+ b=length(a)\r
+ for(i=0;i<b;i+=8)\r
+ {\r
+ d=substr(a,i+1,8)\r
+ e=0\r
+ for(j=1;j<=8;j+=1)\r
+ {\r
+ e=e*2+substr(d,j,1)\r
+ }\r
+ printf("%c",e);\r
+ }\r
+ print ""\r
+}\r
--- /dev/null
+#!/usr/bin/mawk -f
+BEGIN{
+ lasttemp="/eizm/pro/mrobsniped/lasttemp"
+ confirmd="/eizm/pro/mrobsniped/confirmd"
+ htmltemp="/eizm/pro/mrobsniped/htmltemp"
+ htmltmp2="/eizm/pro/mrobsniped/htmltmp2"
+ result0="/eizm/www/time/mrobsniped/mrobdexmessage.txt"
+ result1="/eizm/www/time/mrobsniped/mrobdexmessage-onlytext.txt"
+ snipedawk="/eizm/pro/mrobsniped/sniped.awk"
+ snipedawk3="/eizm/pro/mrobsniped/sniped3.awk"
+ wget="/usr/bin/wget"
+ mawk="/usr/bin/mawk"
+ cat="/bin/cat"
+ sleep="/bin/sleep"
+
+ getline last < lasttemp
+ close(lasttemp)
+
+ getline conf < confirmd
+ close(confirmd)
+
+ for(i=1;i<=34;++i)
+ {
+ if(i==1)
+ system(wget" mrob.com/time -q -U mrobsniped-blinkenstein -O "htmltemp)
+ else
+ {
+ system(wget" mrob.com/time/index-"i".html -q -U mrobsniped-blinkenstein -O "htmltmp2)
+ system (cat" "htmltmp2" >> "htmltemp)
+ system(sleep" 2")
+ }
+ }
+ system(mawk" -f "snipedawk" "htmltemp" > "lasttemp)
+
+ getline this < lasttemp
+ close(lasttemp)
+
+ if(this!=last)
+ exit
+ if(this==conf)
+ exit
+
+ print this > confirmd
+ close(confirmd)
+
+ r13in ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+ r13out="NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"
+ len=length(r13in)
+
+ for(i=1;i<=len;++i)
+ {
+ rot13[substr(r13in,i,1)]=substr(r13out,i,1)
+ }
+
+ len=length(this)
+ for(i=1;i<=len;++i)
+ {
+ ch=substr(this,i,1)
+ if(ch~/[A-Za-z]/)
+ out=out rot13[ch]
+ else
+ out=out ch
+ }
+ print out >> result0
+ close(result)
+
+ system(mawk" -f "snipedawk3" "result0" > "result1)
+}
+{
+
+}
\ No newline at end of file
--- /dev/null
+BEGIN{\r
+ FS=""\r
+ max=0\r
+ lastmax="/eizm/pro/mrobsniped/lastmax"\r
+ nextpost="/eizm/pro/mrobsniped/nextpost"\r
+ getline last < lastmax\r
+ close(lastmax)\r
+ lm=int(last)\r
+}\r
+{\r
+ ii=substr($0, 19, 4)\r
+ tt=substr($0, 1, 8) substr($0, 10, 4)\r
+ i=int(ii)\r
+ t=int(tt)\r
+ \r
+ if(i>max)\r
+ max=i\r
+ \r
+ if( line[i]!="" && time[i]>=t)\r
+ next\r
+ \r
+ line[i]=substr($0, 23)\r
+ sub(/^ /,"\n ",line[i])\r
+ sub(/^ ----/,"\n----",line[i])\r
+ sub(/^ =/,"\n=",line[i])\r
+ time[i]=t\r
+}\r
+END{\r
+ for(i=0;i<=max;++i)\r
+ {\r
+ printf ("%s",line[i])\r
+ if (i>lm)\r
+ printf ("%s",line[i]) >> nextpost\r
+ }\r
+ close(nextpost)\r
+ print max > lastmax\r
+ close(lastmax)\r
+}\r
--- /dev/null
+#!/usr/bin/mawk -f
+BEGIN{
+ nextpost="/eizm/pro/mrobsniped/nextpost"
+ thispost="/eizm/pro/mrobsniped/thispost"
+ postfile="/eizm/pro/mrobsniped/postfile"
+ userpass="/eizm/mem/ottmirror/name"
+ tempf="tempfile=/eizm/pro/mrobsniped/tempf"
+ postf="postfile=/eizm/pro/mrobsniped/postf"
+ cookf="cookiefile=/eizm/pro/mrobsniped/cookf"
+ mv="/bin/mv"
+ mawk="/usr/bin/mawk"
+ postawk="/eizm/pro/mrobsniped/post.awk"
+ mpostawk="/eizm/pro/mrobsniped/mpost.awk"
+ fscmd="ls -l"
+ #rm="/bin/rm"
+
+ for(i=0;i<256;++i)
+ {
+ ch=sprintf("%c",i)
+ hex=sprintf("%02X",i)
+ ch2hex[ch]=hex
+ }
+
+ fscmd = fscmd " " nextpost
+ fscmd | getline lsline
+ close(fscmd)
+ split(lsline,lstab," ")
+ nextpostsize = int(lstab[5])
+
+# if(nextpostsize<729)
+ if(nextpostsize<3300)
+ exit
+
+ if(system(mv" "nextpost" "thispost))
+ exit
+
+ for(i=0;(getline line < thispost) > 0;++i)
+ {
+ if(i!=0)
+ line="\n"line
+ post=post line
+ }
+ close(thispost)
+
+ getline name < userpass
+ getline pass < userpass
+ close(userpass)
+
+ post="the [url=http://1190.bicyclesonthemoon.info/mrobsniped/mrobdexmessage-onlytext.txt]mr*bdex story[/url] cONGtinues.\n[quote]"post"[/quote]\n[right][size=85]-- posted by mr[img]http://1190.bicyclesonthemoon.info/ott/attachment/41728[/img]bdexbot[/size][/right]"
+
+ print "username="name > postfile
+ print "password="pass >>postfile
+ print "subject="urlencode("bOTTeriada goes ONG") >>postfile
+ print "addbbcode20=100" >>postfile
+ print "message="urlencode(post,1) >>postfile
+ print "disable_magic_url=on"
+
+ close(postfile)
+
+ if(system(mawk" -f "postawk" -v "postf" -v "tempf" -v "cookf" "postfile)!=0)
+ system(mawk" -f "mpostawk" -v "postf" -v "tempf" -v "cookf" "postfile)
+
+ #system(rm" "thispost)
+ #system(rm" "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
+}
\ No newline at end of file
--- /dev/null
+{\r
+ print length($0)\r
+}
\ No newline at end of file