-Subproject commit 1c21433837c5bc34100f04bbfeb8ce403844e91d
+Subproject commit cc70d0da5dd780e2b7b97672cc0638fd91196ee3
# OTT mirror
-# Copyright (C) 2022, 2023 Balthasar Szczepański
+# Copyright (C) 2022, 2023, 2024 Balthasar Szczepański
# "makefile" is automatically generated from "makefile.1.mak"
# This file is part of OTT mirror.
# You should have received a copy of the GNU Affreo General Public License
# along with OTT mirror. If not, see <http://www.gnu.org/licenses/>.
-
-
-CC =gcc
-CF =-g -Wall -Wno-format-truncation
-L_CGI=-lcgi
-# AI=mawk -f
-
+# TODO: create a debug target and make it default
+DEFAULT_TARGET = release
ifndef TARGET
TARGET =release
# when want to change target run this first:
endif
PERL = perl
+CC =gcc
+CF =-g -Wall -Wno-format-truncation
+L_CGI=-lcgi
+# AI=mawk -f
+
CONFIGFILE = settings-$(TARGET).txt settings.txt
+DEFAULT_CONFIGFILE = settings-$(DEFAULT_TARGET).txt settings.txt
+
+# The configuration tool
+# http://bicyclesonthemoon.info/git/botm-config
+CONFIGURE_CMD = $(PERL) ./configure.pl $(CONFIGFILE)
+
PERL =/usr/bin/perl
MKDIR=/usr/bin/mkdir
CONF = /botm/etc/www/conf/1190/ottmirror.conf
CRON = /etc/cron.d/ottmirror
-
-# The configuration tool
-# http://bicyclesonthemoon.info/git/botm-config
-CONFIGURE_CMD = $(PERL) ./configure.pl $(CONFIGFILE)
-
# keep these 2 lists in the same order!:
GENERATE_FROM=\
bot2.1.awk\
clean:
$(RM) -f configure.pl $(TO_GENERATE) $(C) $(C_CGI)
+ $(PERL) config/configure.1.pl $(DEFAULT_CONFIGFILE) < makefile.1.mak > makefile
PHONY: all clean setuid mktree cp_bin co_conf cp_cron cp_src cp_www cp_www_desc install
# OTT mirror
-# Copyright (C) 2022, 2023 Balthasar Szczepański
+# Copyright (C) 2022, 2023, 2024 Balthasar Szczepański
# "makefile" is automatically generated from "makefile.1.mak"
# This file is part of OTT mirror.
# You should have received a copy of the GNU Affreo General Public License
# along with OTT mirror. If not, see <http://www.gnu.org/licenses/>.
-
-
-###MAKE_CC: CC=gcc
-###MAKE_CF: CF=-g -Wall
-###MAKE_L_CGI: L_CGI=-lcgi
-# AI=mawk -f
-
+# TODO: create a debug target and make it default
+DEFAULT_TARGET = release
ifndef TARGET
-TARGET = debug ###MAKE_TARGET:
+TARGET = $(DEFAULT_TARGET) ###MAKE_TARGET:
# when want to change target run this first:
# make -B TARGET=target_name makefile
endif
PERL = perl
+###MAKE_CC: CC=gcc
+###MAKE_CF: CF=-g -Wall
+###MAKE_L_CGI: L_CGI=-lcgi
+# AI=mawk -f
+
CONFIGFILE = settings-$(TARGET).txt settings.txt
+DEFAULT_CONFIGFILE = settings-$(DEFAULT_TARGET).txt settings.txt
+
+# The configuration tool
+# http://bicyclesonthemoon.info/git/botm-config
+CONFIGURE_CMD = $(PERL) ./configure.pl $(CONFIGFILE)
+
###MAKE_PERL: PERL = perl
###MAKE_MKDIR: MKDIR = mkdir
###MAKE_CONF: CONF = /botm/etc/www/conf/1190/ottmirror.conf
###MAKE_CRON: CRON = /etc/cron.d/ottmirror
-
-# The configuration tool
-# http://bicyclesonthemoon.info/git/botm-config
-CONFIGURE_CMD = $(PERL) ./configure.pl $(CONFIGFILE)
-
# keep these 2 lists in the same order!:
GENERATE_FROM=\
bot2.1.awk\
clean:
$(RM) -f configure.pl $(TO_GENERATE) $(C) $(C_CGI)
+ $(PERL) config/configure.1.pl $(DEFAULT_CONFIGFILE) < makefile.1.mak > makefile
PHONY: all clean setuid mktree cp_bin co_conf cp_cron cp_src cp_www cp_www_desc install
// OTT mirror
-// Copyright (C) 2014, 2022, 2023 Balthasar Szczepański
+// Copyright (C) 2014, 2022, 2023, 2024 Balthasar Szczepański
// post.c automatically generated from post.1.c
// write posts from the mirror.
//
#define N_STRBUF 256
#define N_STRBUF_SH 32
+#define MIN_EDIT_TIME 5
s_cgi *cgi;
pid_t sub;
char zero='\0';
char *username = &zero;
char *password = &zero;
+char *password2 = &zero;
char *subject = &zero;
char *message = &zero;
char *addbbcode20 = &zero;
char *addquote =&zero;
char *edit =&zero;
char *forceID =&zero;
+char *st =&zero;
char wrong[N_STRBUF];
+unsigned char force_starttime = 0;
+
void submit();
void preview (const char *text);
void writeArgA(FILE *file,const char *name,const char *value, char all);
void submit()
{
+ time_t starttime;
time_t posttime;
char timetext[N_STRBUF_SH];
char timenumber[N_STRBUF_SH];
unsigned short postslast;
char listpath[N_STRBUF];
long long time_n;
+ long long time_s;
posttime=time(NULL);
+ if(st[0]!='\0')
+ {
+ time_s = atoll(st);
+ if (time_s != 0)
+ starttime = (time_t) time_s;
+ else
+ {
+ starttime = posttime;
+ st = &zero;
+ }
+ }
+ else
+ starttime = posttime;
+ if((posttime-starttime)<MIN_EDIT_TIME)
+ {
+ force_starttime = 1;
+ preview("Please don't submit the post immediately after entering the editor. Spend at least some minimal time writing and reviewing the post. (By the time you finished reading this message it should already be OK to submit so just try again!)");
+ }
if(forceID[0]!='\0')
{
snprintf(timenumber,N_STRBUF_SH,"%s",forceID);
else
snprintf(timenumber,N_STRBUF_SH,"%llu",(unsigned long long)posttime);
strftime(timetext,N_STRBUF-1,"%a %b %d, %Y %I:%M %p %Z",gmtime(&posttime));
+
+
if(*disable_bbcode=='\0')
snprintf(botinfo,N_STRBUF,"[Posted from the Mirror at %s%s]\r\n",timetext,(forceID[0]!='\0')?", edited":"");
else
void preview (const char *text)
{
char arg1[N_STRBUF];
+ char new_st[N_STRBUF_SH];
tempfile=fopen(temppath,"wt");
if(tempfile==NULL)
end(1);
tf=1;
+ if(st[0]=='\0')
+ {
+ snprintf(new_st,N_STRBUF_SH,"%llu",(unsigned long long)time(NULL));
+ st = new_st;
+ }
+ if((password2[0]=='\0') && force_starttime)
+ password2 = st;
writeArgHN(tempfile,"HTML", message, 1);
writeArgHN(tempfile,"BB", message, 3);
writeArgHN(tempfile,"wrong", text, 0);
writeArgHN(tempfile,"forceID", forceID, 0);
// writeArgHN(tempfile,"Preview", Preview, 0);
// writeArgHN(tempfile,"post", post, 0);
+ writeArgHN(tempfile,"password2", password2, 0);
+ writeArgHN(tempfile,"st", st, 0);
fclose(tempfile);
tf=0;
arg=cgiGetValue(cgi,"password2");
if(arg!=NULL)
{
+ password2=arg;
missing=1;
strcpy(wrong,"Please don't write in the \"Leave this empty\" field.");
}
+ arg=cgiGetValue(cgi,"st");
+ if(arg!=NULL)
+ st=arg;
+ else
+ {
+ missing=1;
+ force_starttime=1;
+ strcpy(wrong,"Please don't try to send the post without going through the editor first.");
+ }
+
arg=cgiGetValue(cgi,"addbbcode20");
if(arg!=NULL)
addbbcode20=arg;
submit();
}
else
+ {
+ force_starttime = 0;
preview("");
+ }
return 0;
# OTT mirror\r
-# Copyright (C) 2014, 2022 Balthasar Szczepański\r
+# Copyright (C) 2014, 2022, 2024 Balthasar Szczepański\r
# preview.awk automatically generated from preview.1.awk\r
# insert content into the preview page.\r
-# 25.09.2022\r
\r
# This file is part of OTT mirror.\r
#\r
wrong="<p class=\"error\">%s</p>\n"\r
subject="<dd><input type=\"text\" name=\"subject\" id=\"subject\" size=\"45\" maxlength=\"64\" tabindex=\"1\" value=\"%s\" class=\"inputbox autowidth\" /></dd>\n"\r
username="<dd><input tabindex=\"2\" name=\"username\" id=\"username\" size=\"45\" value=\"%s\" class=\"inputbox autowidth\" type=\"text\" /></dd>\n"\r
+ password2="<dd><input tabindex=\"2\" name=\"password2\" id=\"password2\" size=\"45\" value=\"%s\" class=\"inputbox autowidth\" type=\"text\" /></dd>\n"\r
message="<textarea name=\"message\" id=\"message\" rows=\"15\" cols=\"76\" tabindex=\"4\" onselect=\"storeCaret(this);\" onclick=\"storeCaret(this);\" onkeyup=\"storeCaret(this);\" onfocus=\"initInsertions();\" class=\"inputbox\" >%s%s</textarea>\n"\r
disable_bbcode="<div><label for=\"disable_bbcode\"><input type=\"checkbox\" name=\"disable_bbcode\" id=\"disable_bbcode\" %s /> Disable BBCode</label></div>\n"\r
disable_smilies="<div><label for=\"disable_smilies\"><input type=\"checkbox\" name=\"disable_smilies\" id=\"disable_smilies\" %s /> Disable smilies</label></div>\n"\r
attach_sig="<div><label for=\"attach_sig\"><input type=\"checkbox\" name=\"attach_sig\" id=\"attach_sig\" %s /> Attach a signature (signatures can be altered via the UCP)</label></div>\n"\r
notify="<div><label for=\"notify\"><input type=\"checkbox\" name=\"notify\" id=\"notify\" %s /> Notify me when a reply is posted</label></div>\n"\r
forceID="<input type=\"hidden\" name=\"forceID\" value=\"%s\"/>\n"\r
+ st="<input type=\"hidden\" name=\"st\" value=\"%s\"/>\n"\r
title0="<h3>Post a reply</h3>"\r
title1="<h3>Edit post m%s</h3>\n"\r
\r
printf(attach_sig,(argtab["attach_sig"]=="on")?"checked=\"checked\"":"")\r
else if ($0 ~ /^###notify/)\r
printf(notify,(argtab["notify"]=="on")?"checked=\"checked\"":"")\r
+ else if ($0 ~ /^###password2/)\r
+ printf(password2,argtab["password2"])\r
+ else if ($0 ~ /^###st_/)\r
+ printf(st,argtab["st"])\r
else if ($0 ~ /^###debug/)\r
{\r
gsub(/###nl;/,"\n",argtab["debug"])\r
</dl>
<dl>
<dt><label for="password2">Leave this empty:</label></dt>
- <dd><input id="password2" name="password2" size="45" class="inputbox autowidth" type="text" /></dd>
+ <!-- <dd><input id="password2" name="password2" size="45" class="inputbox autowidth" type="text" /></dd> -->
+###password2
<!-- <dd><b>Warning</b>: The mirror can't verify your username or password.</dd>
<dd>Use your xkcd forum username and password.</dd> -->
</dl>
<!-- TOKEN -->
<!-- <input type="hidden" name="form_token" value="0" /> -->
+<!-- <input type="hidden" name="st" value="0" /> -->
+###st_
+
<span class="corners-bottom"><span></span></span></div>
</div>