From d65dd711bf8271c815441f826fc0b24e3d6b49ae Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 21 Aug 2002 21:58:37 +0000 Subject: [PATCH] * Completed self-service list subscription via web. (Still need to implement unsubscribe.) --- citadel/ChangeLog | 5 +++++ citadel/file_ops.c | 2 +- citadel/msgbase.c | 5 +++-- citadel/msgbase.h | 4 ++-- citadel/serv_listsub.c | 31 +++++++++++++++++-------------- citadel/tools.c | 27 +++++++++++++++++++++++++++ citadel/tools.h | 1 + webcit/ChangeLog | 5 ++++- webcit/listsub.c | 22 ++++++++++++++++++++-- webcit/roomops.c | 3 +++ 10 files changed, 83 insertions(+), 22 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 33ee1adaa..716b0569e 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 591.95 2002/08/21 21:58:00 ajc + * Completed self-service list subscription via web. + (Still need to implement unsubscribe.) + Revision 591.94 2002/08/16 21:04:56 ajc * Add LPRM command @@ -3912,3 +3916,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/file_ops.c b/citadel/file_ops.c index 664a62ff3..911138168 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -665,7 +665,7 @@ void cmd_ucls(char *cmd) "NEW UPLOAD: '%s'\n %s\n", CC->upl_file, CC->upl_comment); quickie_message(CC->curr_user, NULL, CC->quickroom.QRname, - upload_notice); + upload_notice, 0); } else { abort_upl(CC); cprintf("%d File '%s' aborted.\n", CIT_OK, CC->upl_path); diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 997cdd017..0123fd39c 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -2141,7 +2141,8 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ /* * Convenience function for generating small administrative messages. */ -void quickie_message(char *from, char *to, char *room, char *text) +void quickie_message(char *from, char *to, char *room, char *text, + int format_type) { struct CtdlMessage *msg; struct recptypes *recp = NULL; @@ -2150,7 +2151,7 @@ void quickie_message(char *from, char *to, char *room, char *text) memset(msg, 0, sizeof(struct CtdlMessage)); msg->cm_magic = CTDLMESSAGE_MAGIC; msg->cm_anon_type = MES_NORMAL; - msg->cm_format_type = 0; + msg->cm_format_type = format_type; msg->cm_fields['A'] = strdoop(from); if (room != NULL) msg->cm_fields['O'] = strdoop(room); msg->cm_fields['N'] = strdoop(NODENAME); diff --git a/citadel/msgbase.h b/citadel/msgbase.h index aa1e0f87d..27860c322 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -1,6 +1,6 @@ /* $Id$ */ -#define aide_message(text) quickie_message("Citadel",NULL,AIDEROOM,text) +#define aide_message(text) quickie_message("Citadel",NULL,AIDEROOM,text,0); #define MSGS_ALL 0 #define MSGS_OLD 1 @@ -83,7 +83,7 @@ void cmd_opna (char *cmdbuf); long send_message (struct CtdlMessage *, FILE *); void loadtroom (void); long CtdlSubmitMsg(struct CtdlMessage *, struct recptypes *, char *); -void quickie_message (char *, char *, char *, char *); +void quickie_message (char *, char *, char *, char *, int); void cmd_ent0 (char *entargs); void cmd_dele (char *delstr); void cmd_move (char *args); diff --git a/citadel/serv_listsub.c b/citadel/serv_listsub.c index a18d8cbbb..53bf0c76e 100644 --- a/citadel/serv_listsub.c +++ b/citadel/serv_listsub.c @@ -68,10 +68,8 @@ void listsub_generate_token(char *buf) { * tinfoil-hat secure, it just needs to be reasonably unguessable * and unique. */ - sprintf(sourcebuf, "%d%d%ld", - ++seq, - getpid(), - time(NULL) + sprintf(sourcebuf, "%lx", + (long) (++seq + getpid() + time(NULL)) ); /* Convert it to base64 so it looks cool */ @@ -88,6 +86,7 @@ void do_subscribe(char *room, char *email, char *subtype, char *webpage) { char filename[SIZ]; char token[SIZ]; char confirmation_request[SIZ]; + char urlroom[SIZ]; if (getroom(&qrbuf, room) != 0) { cprintf("%d There is no list called '%s'\n", ERROR, room); @@ -120,28 +119,32 @@ void do_subscribe(char *room, char *email, char *subtype, char *webpage) { /* Generate and send the confirmation request */ + urlesc(urlroom, qrbuf.QRname); + snprintf(confirmation_request, sizeof confirmation_request, + "Content-type: text/html\n\n" + "" "Someone (probably you) has submitted a request to subscribe\n" - "<%s> to the '%s' mailing list.\n\n" - "In order to confirm this subscription request, please\n" - "point your web browser at the following location:\n\n" - "http://%s?room=%s&token=%s\n\n" + "<%s> to the %s mailing list.

\n" + "" + "Please click here to confirm this request.

\n" "If this request has been submitted in error and you do not\n" "wish to receive the '%s' mailing list, simply do nothing,\n" - "and you will not receive any further mailings.\n", + "and you will not receive any further mailings.\n" + "\n", - email, qrbuf.QRname, webpage, qrbuf.QRname, token, qrbuf.QRname + email, qrbuf.QRname, webpage, urlroom, token, qrbuf.QRname ); - quickie_message( + quickie_message( /* This delivers the message */ "Citadel", email, - qrbuf.QRname, - confirmation_request + NULL, + confirmation_request, + FMT_RFC822 ); cprintf("%d Subscription entered; confirmation request sent\n", CIT_OK); - } diff --git a/citadel/tools.c b/citadel/tools.c index e73a9b122..3a457ae6e 100644 --- a/citadel/tools.c +++ b/citadel/tools.c @@ -607,3 +607,30 @@ char *myfgets(char *s, int size, FILE *stream) { return ret; } + +/* + * Escape a string for feeding out as a URL. + * Output buffer must be big enough to handle escape expansion! + */ +void urlesc(char *outbuf, char *strbuf) +{ + int a, b, c; + char *ec = " #&;`'|*?-~<>^()[]{}$\\"; + + strcpy(outbuf, ""); + + for (a = 0; a < strlen(strbuf); ++a) { + c = 0; + for (b = 0; b < strlen(ec); ++b) { + if (strbuf[a] == ec[b]) + c = 1; + } + b = strlen(outbuf); + if (c == 1) + sprintf(&outbuf[b], "%%%02x", strbuf[a]); + else + sprintf(&outbuf[b], "%c", strbuf[a]); + } +} + + diff --git a/citadel/tools.h b/citadel/tools.h index d93e93d37..cbc4f81f7 100644 --- a/citadel/tools.h +++ b/citadel/tools.h @@ -27,3 +27,4 @@ void stripout(char *str, char leftboundary, char rightboundary); void stripallbut(char *str, char leftboundary, char rightboundary); char *myfgets(char *s, int size, FILE *stream); +void urlesc(char *outbuf, char *strbuf); diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 66c2dfa0d..de7e7cea0 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 323.60 2002/08/21 21:58:37 ajc +* Completed self-service list subscription via web. + (Still need to implement unsubscribe.) + Revision 323.59 2002/08/16 22:06:51 ajc * self-service @@ -903,4 +907,3 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix - diff --git a/webcit/listsub.c b/webcit/listsub.c index 78eb3eab4..8d7fd116b 100644 --- a/webcit/listsub.c +++ b/webcit/listsub.c @@ -89,7 +89,25 @@ void do_listsub(void) goto FORM; } } - + + /* + * Confirm command + */ + else if (!strcasecmp(cmd, "confirm")) { + serv_printf("SUBS confirm|%s|%s", + room, + token + ); + serv_gets(buf); + if (buf[0] == '2') { + wprintf("

Confirmation successful!

"); + } + else { + wprintf("

Confirmation failed.

"); + } + wprintf("%s

\n", &buf[4]); + } + /* * Any other (invalid) command causes the form to be displayed */ @@ -109,7 +127,7 @@ FORM: wprintf("
\n" self = extract_int(buf, 4) & QR2_SELFLIST ; if (self) { wprintf("\n"); diff --git a/webcit/roomops.c b/webcit/roomops.c index ba36d87aa..c943f7104 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -1098,6 +1098,9 @@ void display_editroom(void) " " "Click to disable.
\n" + "The URL for subscribe/unsubscribe is: " + "http://%s/listsub
\n", + WC->http_host ); } else { -- 2.30.2