- pcf_req = SmashStrBuf(&cf_req);
- quickie_message( /* This delivers the message */
- "Citadel",
- EmailSender,
- ChrPtr(*email),
- NULL,
- pcf_req,
- FMT_RFC822,
- "Please confirm your list subscription"
- );
- free(pcf_req);
- cprintf("%d Subscription entered; confirmation request sent\n", CIT_OK);
-
- FreeStrBuf(&UrlRoom);
-}
-
-
-/*
- * Enter an unsubscription request
- */
-void do_unsubscribe(StrBuf **room, StrBuf **email, StrBuf **webpage) {
- struct ctdlroom qrbuf;
- const char *EmailSender = NULL;
- char token[256];
- char *pcf_req;
- StrBuf *cf_req;
- StrBuf *UrlRoom;
- int found_sub = 0;
- const char *RoomMailAddress;
- OneRoomNetCfg *OneRNCfg;
- RoomNetCfgLine *Line;
- long RoomMailAddressLen;
-
- if (CtdlGetRoom(&qrbuf, ChrPtr(*room)) != 0) {
- cprintf("%d There is no list called '%s'\n",
- ERROR + ROOM_NOT_FOUND, ChrPtr(*room));
- return;
- }
-
- if ((qrbuf.QRflags2 & QR2_SELFLIST) == 0) {
- cprintf("%d '%s' "
- "does not accept subscribe/unsubscribe requests.\n",
- ERROR + HIGHER_ACCESS_REQUIRED, qrbuf.QRname);
- return;
- }
-
- listsub_generate_token(token);
-
- /*
- * Make sure there's actually a subscription there to remove
- */
- begin_critical_section(S_NETCONFIGS);
- RoomMailAddress = qrbuf.QRname;
- OneRNCfg = CtdlGetNetCfgForRoom(qrbuf.QRnumber);
- if (OneRNCfg!=NULL) {
- found_sub = CountThisSubscriber(OneRNCfg, *email);
- if (StrLength(OneRNCfg->Sender) > 0)
- EmailSender = RoomMailAddress = ChrPtr(OneRNCfg->Sender);
- }
-
- if (found_sub == 0) {
- cprintf("%d '%s' is not subscribed to '%s'.\n",
- ERROR + NO_SUCH_USER,
- ChrPtr(*email),
- qrbuf.QRname);
-
- end_critical_section(S_NETCONFIGS);
- return;
- }
-
- /*
- * Ok, now enter the unsubscribe-pending entry.
- */
- RoomMailAddressLen = strlen(RoomMailAddress);
- listsub_generate_token(token);
- Line = (RoomNetCfgLine*)malloc(sizeof(RoomNetCfgLine));
- memset(Line, 0, sizeof(RoomNetCfgLine));
-
- Line->Value = (StrBuf**) malloc(sizeof(StrBuf*) * 4);
-
- Line->Value[0] = NewStrBufDup(*email);
- Line->Value[1] = NewStrBufPlain(token, -1);
- Line->Value[2] = NewStrBufPlain(NULL, 10);
- StrBufPrintf(Line->Value[2], "%ld", time(NULL));
- Line->Value[3] = *webpage; *webpage = NULL;
- Line->nValues = 4;
-
- AddRoomCfgLine(OneRNCfg, &qrbuf, unsubpending, Line);
-
- /* Generate and send the confirmation request */
- UrlRoom = NewStrBuf();
- StrBufUrlescAppend(UrlRoom, NULL, qrbuf.QRname);
-
- cf_req = NewStrBufPlain(NULL, 2048);
-
- StrBufAppendBufPlain(
- cf_req,
- HKEY("MIME-Version: 1.0\n"
- "Content-Type: multipart/alternative; boundary=\"__ctdlmultipart__\"\n"
- "\n"
- "This is a multipart message in MIME format.\n"
- "\n"
- "--__ctdlmultipart__\n"
- "Content-type: text/plain\n"
- "\n"
- "Someone (probably you) has submitted a request to unsubscribe\n"
- "<"), 0);
- StrBufAppendBuf(cf_req, Line->Value[0], 0);
-
-
- StrBufAppendBufPlain(
- cf_req,
- HKEY("> from the '"), 0);
- StrBufAppendBufPlain(cf_req, RoomMailAddress, RoomMailAddressLen, 0);
-
- StrBufAppendBufPlain(
- cf_req,
- HKEY("' mailing list.\n"
- "\n"
- "Please go here to confirm this request:\n "), 0);
- StrBufAppendBuf(cf_req, Line->Value[3], 0);
- StrBufAppendBufPlain(cf_req, HKEY("?room="), 0);
- StrBufAppendBuf(cf_req, UrlRoom, 0);
- StrBufAppendBufPlain(cf_req, HKEY("&token="), 0);
- StrBufAppendBuf(cf_req, Line->Value[1], 0);
-
- StrBufAppendBufPlain(
- cf_req,
- HKEY("&cmd=confirm \n"
- "\n"
- "If this request has been submitted in error and you do not\n"
- "wish to unsubscribe from the '"), 0);
-
- StrBufAppendBufPlain(cf_req, RoomMailAddress, RoomMailAddressLen, 0);
-
- StrBufAppendBufPlain(
- cf_req,
- HKEY("' mailing list, simply do nothing,\n"
- "and the request will not be processed.\n"
- "\n"
- "--__ctdlmultipart__\n"
- "Content-type: text/html\n"
- "\n"
- "<HTML><BODY>\n"
- "Someone (probably you) has submitted a request to unsubscribe\n"
- "<"), 0);
- StrBufAppendBuf(cf_req, Line->Value[0], 0);
-
- StrBufAppendBufPlain(cf_req, HKEY("> from the <B>"), 0);
- StrBufAppendBufPlain(cf_req, RoomMailAddress, RoomMailAddressLen, 0);
-
- StrBufAppendBufPlain(
- cf_req,
- HKEY("</B> mailing list.<BR><BR>\n"
- "Please click here to confirm this request:<BR>\n"
- "<A HREF=\""), 0);
- StrBufAppendBuf(cf_req, Line->Value[3], 0);
-
- StrBufAppendBufPlain(cf_req, HKEY("?room="), 0);
- StrBufAppendBuf(cf_req, UrlRoom, 0);
-
- StrBufAppendBufPlain(cf_req, HKEY("&token="), 0);
- StrBufAppendBuf(cf_req, Line->Value[1], 0);
-
- StrBufAppendBufPlain(cf_req, HKEY("&cmd=confirm\">"), 0);
- StrBufAppendBuf(cf_req, Line->Value[3], 0);
-
- StrBufAppendBufPlain(cf_req, HKEY("?room="), 0);
- StrBufAppendBuf(cf_req, UrlRoom, 0);
-
- StrBufAppendBufPlain(cf_req, HKEY("&token="), 0);
- StrBufAppendBuf(cf_req, Line->Value[1], 0);
-
-
- StrBufAppendBufPlain(
- cf_req,
- HKEY("&cmd=confirm</A><BR><BR>\n"
- "If this request has been submitted in error and you do not\n"
- "wish to unsubscribe from the '"), 0);
- StrBufAppendBufPlain(cf_req, RoomMailAddress, RoomMailAddressLen, 0);
-
- StrBufAppendBufPlain(
- cf_req,
- HKEY("' mailing list, simply do nothing,\n"
- "and the request will not be processed.\n"
- "</BODY></HTML>\n"
- "\n"
- "--__ctdlmultipart__--\n"), 0);
-
- end_critical_section(S_NETCONFIGS);