* Completed self-service list subscription via web.
authorArt Cancro <ajc@citadel.org>
Wed, 21 Aug 2002 21:58:37 +0000 (21:58 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 21 Aug 2002 21:58:37 +0000 (21:58 +0000)
  (Still need to implement unsubscribe.)

citadel/ChangeLog
citadel/file_ops.c
citadel/msgbase.c
citadel/msgbase.h
citadel/serv_listsub.c
citadel/tools.c
citadel/tools.h
webcit/ChangeLog
webcit/listsub.c
webcit/roomops.c

index 33ee1adaa811b0877879dcfd8f276896e75c6a2d..716b0569edd1d8548818598aba9fa3089b1a1fdf 100644 (file)
@@ -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 <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 664a62ff33868a847c0c4cfb14ed738daae02aca..911138168b57dff34c5fcbcbf634c9adfb6b11f3 100644 (file)
@@ -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);
index 997cdd0177809d3037a371a34c8439b6e1c8b430..0123fd39cae032aa2f94e4aea69e15ae4a53c91f 100644 (file)
@@ -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);
index aa1e0f87dcfbb982601512a7e7e3ac9be50a86f5..27860c322fb34ab96a4941760580f814b054c305 100644 (file)
@@ -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);
index a18d8cbbb29f4ba6ffcf6e07fc427b3ab7c0d4d4..53bf0c76e97e1a73af34939ddeee956e7da7b568 100644 (file)
@@ -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"
+               "<HTML><BODY>"
                "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"
+               "&lt;%s&gt; to the <B>%s</B> mailing list.<BR><BR>\n"
+               "<A HREF=\"http://%s?room=%s&token=%s&cmd=confirm\">"
+               "Please click here to confirm this request.</A><BR><BR>\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"
+               "</BODY></HTML>\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);
-
 }
 
 
index e73a9b122d0738c9b189eac89503cb3df1322a3e..3a457ae6efc072a71c87bfa325699e6049df0bd0 100644 (file)
@@ -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]);
+       }
+}
+
+
index d93e93d3773d623b975c7382425931894b4ef5de..cbc4f81f793ffa8841fe929d4265deedc29a9dc6 100644 (file)
@@ -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);
index 66c2dfa0dcf0eca26767a9182b91d0a1d25b30c2..de7e7cea0b87d91fe1d7ae2a2430aa1064377fb6 100644 (file)
@@ -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 <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index 78eb3eab4fe2d21dd17416079910aeef1af63b6c..8d7fd116b50aec5ea554e3c851e4f9d517b508fc 100644 (file)
@@ -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("<CENTER><H1>Confirmation successful!</H1>");
+               }
+               else {
+                       wprintf("<CENTER><H1>Confirmation failed.</H1>");
+               }
+               wprintf("%s</CENTER><BR>\n", &buf[4]);
+       }
+
        /*
         * Any other (invalid) command causes the form to be displayed
         */
@@ -109,7 +127,7 @@ FORM:               wprintf("<FORM METHOD=\"POST\" ACTION=\"/listsub\">\n"
                                self = extract_int(buf, 4) & QR2_SELFLIST ;
                                if (self) {
                                        wprintf("<OPTION VALUE=\"");
-                                       urlescputs(sroom);
+                                       escputs(sroom);
                                        wprintf("\">");
                                        escputs(sroom);
                                        wprintf("</OPTION>\n");
index ba36d87aaf14da1f0061536770b541548fc153ff..c943f7104a2085cc014d23a6da3a17a6d9bb4de6 100644 (file)
@@ -1098,6 +1098,9 @@ void display_editroom(void)
                                " <A HREF=\"/toggle_self_service?newval=0&"
                                "tab=listserv\">"
                                "Click to disable.</A><BR>\n"
+                               "The URL for subscribe/unsubscribe is: "
+                               "<TT>http://%s/listsub</TT><BR>\n",
+                               WC->http_host
                        );
                }
                else {