#include <sys/stat.h>
#include <sys/types.h>
#include <regex.h>
+
+#include "md5.h"
+
#include <libcitadel.h>
#include "citadel.h"
#include "server.h"
"hnod",
"msgn",
"jrnl",
- NULL,
+ "rep2",
"list",
"text",
"node",
int do_proto, /* do Citadel protocol responses? */
int crlf, /* Use CRLF newlines instead of LF? */
char *section, /* NULL or a message/rfc822 section */
- int flags /* various flags; see msgbase.h */
+ int flags, /* various flags; see msgbase.h */
+ char **Author,
+ char **Address
) {
struct CitContext *CCC = CC;
struct CtdlMessage *TheMessage = NULL;
*extract_encapsulated_message,
NULL, NULL, (void *)&encap, 0
);
+
+ if ((Author != NULL) && (*Author == NULL))
+ {
+ *Author = TheMessage->cm_fields['A'];
+ TheMessage->cm_fields['A'] = NULL;
+ }
+ if ((Address != NULL) && (*Address == NULL))
+ {
+ *Address = TheMessage->cm_fields['F'];
+ TheMessage->cm_fields['F'] = NULL;
+ }
CtdlFreeMessage(TheMessage);
TheMessage = NULL;
/* Ok, output the message now */
if (retcode == CIT_OK)
retcode = CtdlOutputPreLoadedMsg(TheMessage, mode, headers_only, do_proto, crlf, flags);
+ if ((Author != NULL) && (*Author == NULL))
+ {
+ *Author = TheMessage->cm_fields['A'];
+ TheMessage->cm_fields['A'] = NULL;
+ }
+ if ((Address != NULL) && (*Address == NULL))
+ {
+ *Address = TheMessage->cm_fields['F'];
+ TheMessage->cm_fields['F'] = NULL;
+ }
+
CtdlFreeMessage(TheMessage);
return(retcode);
if (source == NULL) return source;
if (IsEmptyStr(source)) return source;
- cit_backtrace();
+ if (MessageDebugEnabled != 0) cit_backtrace();
MSG_syslog(LOG_DEBUG, "qp_encode_email_addrs: [%s]\n", source);
AddrPtr = malloc (sizeof (long) * nAddrPtrMax);
msgid = extract_long(cmdbuf, 0);
headers_only = extract_int(cmdbuf, 1);
- CtdlOutputMsg(msgid, MT_CITADEL, headers_only, 1, 0, NULL, 0);
+ CtdlOutputMsg(msgid, MT_CITADEL, headers_only, 1, 0, NULL, 0, NULL, NULL);
return;
}
msgid = extract_long(cmdbuf, 0);
headers_only = extract_int(cmdbuf, 1);
- CtdlOutputMsg(msgid, MT_RFC822, headers_only, 1, 1, NULL, 0);
+ CtdlOutputMsg(msgid, MT_RFC822, headers_only, 1, 1, NULL, 0, NULL, NULL);
}
msgid = extract_long(cmdbuf, 0);
extract_token(section, cmdbuf, 1, '|', sizeof section);
- CtdlOutputMsg(msgid, MT_MIME, 0, 1, 0, (section[0] ? section : NULL) , 0);
+ CtdlOutputMsg(msgid, MT_MIME, 0, 1, 0, (section[0] ? section : NULL) , 0, NULL, NULL);
}
extract_token(desired_section, cmdbuf, 1, '|', sizeof desired_section);
safestrncpy(CC->download_desired_section, desired_section,
sizeof CC->download_desired_section);
- CtdlOutputMsg(msgid, MT_DOWNLOAD, 0, 1, 1, NULL, 0);
+ CtdlOutputMsg(msgid, MT_DOWNLOAD, 0, 1, 1, NULL, 0, NULL, NULL);
}
extract_token(desired_section, cmdbuf, 1, '|', sizeof desired_section);
safestrncpy(CC->download_desired_section, desired_section,
sizeof CC->download_desired_section);
- CtdlOutputMsg(msgid, MT_SPEW_SECTION, 0, 1, 1, NULL, 0);
-}
+ CtdlOutputMsg(msgid, MT_SPEW_SECTION, 0, 1, 1, NULL, 0, NULL, NULL);
+}
/*
msglist = realloc(msglist, (sizeof(long) * (num_msgs + num_msgs_to_be_merged)) );
if (msglist == NULL) {
MSGM_syslog(LOG_ALERT, "ERROR: can't realloc message list!\n");
+ free(msgs_to_be_merged);
return (ERROR + INTERNAL_ERROR);
}
memcpy(&msglist[num_msgs], msgs_to_be_merged, (sizeof(long) * num_msgs_to_be_merged) );
}
-
-void aide_message (char *text, char *subject)
-{
- quickie_message("Citadel",NULL,NULL,AIDEROOM,text,FMT_CITADEL,subject);
-}
-
-
/*
* Convenience function for generating small administrative messages.
*/
-void quickie_message(const char *from, const char *fromaddr, char *to, char *room, const char *text,
- int format_type, const char *subject)
+void quickie_message(const char *from,
+ const char *fromaddr,
+ char *to,
+ char *room,
+ const char *text,
+ int format_type,
+ const char *subject)
{
struct CtdlMessage *msg;
struct recptypes *recp = NULL;
if (recp != NULL) free_recipients(recp);
}
+void flood_protect_quickie_message(const char *from,
+ const char *fromaddr,
+ char *to,
+ char *room,
+ const char *text,
+ int format_type,
+ const char *subject,
+ int nCriterions,
+ const char **CritStr,
+ long *CritStrLen)
+{
+ int i;
+ struct UseTable ut;
+ u_char rawdigest[MD5_DIGEST_LEN];
+ struct MD5Context md5context;
+ StrBuf *guid;
+ struct cdbdata *cdbut;
+ char timestamp[64];
+ long tslen;
+ time_t ts = time(NULL);
+ time_t tsday = ts / (8*60*60); /* just care for a day... */
+
+ tslen = snprintf(timestamp, sizeof(timestamp), "%ld", tsday);
+ MD5Init(&md5context);
+
+ for (i = 0; i < nCriterions; i++)
+ MD5Update(&md5context,
+ (const unsigned char*)CritStr[i], CritStrLen[i]);
+ MD5Update(&md5context,
+ (const unsigned char*)timestamp, tslen);
+ MD5Final(rawdigest, &md5context);
+
+ guid = NewStrBufPlain(NULL,
+ MD5_DIGEST_LEN * 2 + 12);
+ StrBufHexEscAppend(guid, NULL, rawdigest, MD5_DIGEST_LEN);
+ StrBufAppendBufPlain(guid, HKEY("_fldpt"), 0);
+ if (StrLength(guid) > 40)
+ StrBufCutAt(guid, 40, NULL);
+ /* Find out if we've already sent a similar message */
+ memcpy(ut.ut_msgid, SKEY(guid));
+ ut.ut_timestamp = ts;
+
+ cdbut = cdb_fetch(CDB_USETABLE, SKEY(guid));
+
+ if (cdbut != NULL) {
+ /* yes, we did. flood protection kicks in. */
+ syslog(LOG_DEBUG,
+ "not sending message again\n");
+ cdb_free(cdbut);
+ }
+
+ /* rewrite the record anyway, to update the timestamp */
+ cdb_store(CDB_USETABLE,
+ SKEY(guid),
+ &ut, sizeof(struct UseTable) );
+
+ if (cdbut != NULL) return;
+ /* no, this message isn't sent recently; go ahead. */
+ quickie_message(from,
+ fromaddr,
+ to,
+ room,
+ text,
+ format_type,
+ subject);
+}
/*
/* User flagged ok? */
if (who->flags & US_INTERNET) return(2);
- /* Aide level access? */
+ /* Admin level access? */
if (who->axlevel >= AxAideU) return(3);
/* No mail for you! */
*/
permit = 0;
- /* Aides can move/copy */
+ /* Admins can move/copy */
if (CC->user.axlevel >= AxAideU) permit = 1;
/* Room aides can move/copy */