- ncfp = fopen(filename, "r");
- if (ncfp != NULL) {
- while (fgets(buf, sizeof buf, ncfp) != NULL) {
- buf[strlen(buf)-1] = 0;
- extract_token(scancmd, buf, 0, '|', sizeof scancmd);
- extract_token(scanemail, buf, 1, '|', sizeof scanemail);
- if ((!strcasecmp(scancmd, "listrecp"))
- || (!strcasecmp(scancmd, "digestrecp"))) {
- if (!strcasecmp(scanemail, email)) {
- ++found_sub;
- }
- }
- }
- fclose(ncfp);
- }
- end_critical_section(S_NETCONFIGS);
-
- if (found_sub != 0) {
- cprintf("%d '%s' is already subscribed to '%s'.\n",
- ERROR + ALREADY_EXISTS,
- email, qrbuf.QRname);
- return;
- }
-
- /*
- * Now add it to the file
- */
- begin_critical_section(S_NETCONFIGS);
- ncfp = fopen(filename, "a");
- if (ncfp != NULL) {
- fprintf(ncfp, "subpending|%s|%s|%s|%ld|%s\n",
- email,
- subtype,
- token,
- time(NULL),
- webpage
- );
- fclose(ncfp);
- }
- end_critical_section(S_NETCONFIGS);
-
- /* Generate and send the confirmation request */
-
- urlesc(urlroom, ROOMNAMELEN, qrbuf.QRname);
-
- snprintf(confirmation_request, sizeof confirmation_request,
-
- "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 subscribe\n"
- "<%s> to the '%s' mailing list.\n"
- "\n"
- "Please go here to confirm this request:\n"
- " %s?room=%s&token=%s&cmd=confirm \n"
- "\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"
- "\n"
- "--__ctdlmultipart__\n"
- "Content-type: text/html\n"
- "\n"
- "<HTML><BODY>\n"
- "Someone (probably you) has submitted a request to subscribe\n"
- "<%s> to the <B>%s</B> mailing list.<BR><BR>\n"
- "Please click here to confirm this request:<BR>\n"
- "<A HREF=\"%s?room=%s&token=%s&cmd=confirm\">"
- "%s?room=%s&token=%s&cmd=confirm</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"
- "</BODY></HTML>\n"
- "\n"
- "--__ctdlmultipart__--\n",
-
- email, qrbuf.QRname,
- webpage, urlroom, token,
- qrbuf.QRname,
-
- email, qrbuf.QRname,
- webpage, urlroom, token,
- webpage, urlroom, token,
- qrbuf.QRname
- );
-
- quickie_message( /* This delivers the message */
- "Citadel",
- NULL,
- email,
- NULL,
- confirmation_request,
- FMT_RFC822,
- "Please confirm your list subscription"
- );
-
- cprintf("%d Subscription entered; confirmation request sent\n", CIT_OK);
-}
-
-
-/*
- * Enter an unsubscription request
- */
-void do_unsubscribe(char *room, char *email, char *webpage) {
- struct ctdlroom qrbuf;
- FILE *ncfp;
- char filename[256];
- char token[256];
- char buf[512];
- char confirmation_request[2048];
- char urlroom[ROOMNAMELEN];
- char scancmd[256];
- char scanemail[256];
- int found_sub = 0;
-
- if (CtdlGetRoom(&qrbuf, room) != 0) {
- cprintf("%d There is no list called '%s'\n",
- ERROR + ROOM_NOT_FOUND, 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;