uses the vCard editing screen.
* Administratively editing users' address book entries now works again,
mainly due to a fix in the Citadel server. Now requiring Citadel 6.06
in order to enforce this.
$Log$
+Revision 410.1 2003/03/01 22:07:19 ajc
+* New user registration, as well as existing user re-registration, now
+ uses the vCard editing screen.
+* Administratively editing users' address book entries now works again,
+ mainly due to a fix in the Citadel server. Now requiring Citadel 6.06
+ in order to enforce this.
+
Revision 410.0 2003/02/19 03:49:33 ajc
* THIS IS 4.10
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
+
-
-
-
/*
* Display form for registration.
* (Set during_login to 1 if this registration is being performed during
*/
void display_reg(int during_login)
{
- char buf[SIZ];
- int a;
+ long vcard_msgnum;
- output_headers(3);
-
- wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>");
- wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
- wprintf("<B>Enter registration info</B>\n");
- wprintf("</FONT></TD></TR></TABLE>\n");
-
- wprintf("<CENTER>");
- serv_puts("MESG register");
- serv_gets(buf);
- if (buf[0] == '1')
- fmout(NULL);
-
- wprintf("<FORM ACTION=\"/register\" METHOD=\"POST\">\n");
- wprintf("<INPUT TYPE=\"hidden\" NAME=\"during_login\" VALUE=\"%d\">\n", during_login);
-
- serv_puts("GREG _SELF_");
- serv_gets(buf);
- if (buf[0] != '1') {
- wprintf("<EM>%s</EM><BR>\n", &buf[4]);
- } else {
-
- wprintf("<H1>%s</H1><TABLE border>\n", &buf[4]);
- a = 0;
- while (serv_gets(buf), strcmp(buf, "000")) {
- ++a;
- wprintf("<TR><TD>");
- switch (a) {
- case 3:
- wprintf("Real Name:</TD><TD><INPUT TYPE=\"text\" NAME=\"realname\" VALUE=\"%s\" MAXLENGTH=\"29\"><BR>\n", buf);
- break;
- case 4:
- wprintf("Street Address:</TD><TD><INPUT TYPE=\"text\" NAME=\"address\" VALUE=\"%s\" MAXLENGTH=\"24\"><BR>\n", buf);
- break;
- case 5:
- wprintf("City/town:</TD><TD><INPUT TYPE=\"text\" NAME=\"city\" VALUE=\"%s\" MAXLENGTH=\"14\"><BR>\n", buf);
- break;
- case 6:
- wprintf("State/province:</TD><TD><INPUT TYPE=\"text\" NAME=\"state\" VALUE=\"%s\" MAXLENGTH=\"2\"><BR>\n", buf);
- break;
- case 7:
- wprintf("ZIP/postal code:</TD><TD><INPUT TYPE=\"text\" NAME=\"zip\" VALUE=\"%s\" MAXLENGTH=\"10\"><BR>\n", buf);
- break;
- case 8:
- wprintf("Telephone:</TD><TD><INPUT TYPE=\"text\" NAME=\"phone\" VALUE=\"%s\" MAXLENGTH=\"14\"><BR>\n", buf);
- break;
- case 10:
- wprintf("E-Mail:</TD><TD><INPUT TYPE=\"text\" NAME=\"email\" VALUE=\"%s\" MAXLENGTH=\"31\"><BR>\n", buf);
- break;
- case 11:
- wprintf("Country:</TD><TD><INPUT TYPE=\"text\" NAME=\"country\" VALUE=\"%s\" MAXLENGTH=\"31\"><BR>\n", buf);
- break;
- }
- wprintf("</TD></TR>\n");
- }
- wprintf("</TABLE><P>");
+ if (goto_config_room() != 0) {
+ if (during_login) do_welcome();
+ else display_main_menu();
+ return;
}
- wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Register\">\n");
- wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Cancel\">\n");
- wprintf("</CENTER>\n");
- wDumpContent(1);
-}
-
-/*
- * register
- */
-void register_user(void)
-{
- char buf[SIZ];
- if (strcmp(bstr("action"), "Register")) {
- display_error("Cancelled. Registration was not saved.");
+ vcard_msgnum = locate_user_vcard(WC->wc_username, -1);
+ if (vcard_msgnum < 0L) {
+ if (during_login) do_welcome();
+ else display_main_menu();
return;
}
- serv_puts("REGI");
- serv_gets(buf);
- if (buf[0] != '4') {
- display_error(&buf[4]);
+
+ if (during_login) {
+ do_edit_vcard(vcard_msgnum, "1", "/do_welcome");
}
- serv_puts(bstr("realname"));
- serv_puts(bstr("address"));
- serv_puts(bstr("city"));
- serv_puts(bstr("state"));
- serv_puts(bstr("zip"));
- serv_puts(bstr("phone"));
- serv_puts(bstr("email"));
- serv_puts(bstr("country"));
- serv_puts("000");
-
- if (atoi(bstr("during_login"))) {
- do_welcome();
- } else {
- display_success("Registration information has been saved.");
+ else {
+ do_edit_vcard(vcard_msgnum, "1", "/display_main_menu");
}
-}
+}
char buf[SIZ];
long msgnum = 0L;
- lprintf(9, "entering load_preferences()\n");
-
serv_printf("GOTO %s", USERCONFIGROOM);
serv_gets(buf);
if (buf[0] != '2') return;
/* Go back to the room we're supposed to be in */
serv_printf("GOTO %s", WC->wc_roomname);
serv_gets(buf);
- lprintf(9, "exiting load_preferences()\n");
}
-void save_preferences(void) {
+/*
+ * Goto the user's configuration room, creating it if necessary.
+ * Returns 0 on success or nonzero upon failure.
+ */
+int goto_config_room(void) {
char buf[SIZ];
- long msgnum = 0L;
- lprintf(9, "entering save_preferences()\n");
serv_printf("GOTO %s", USERCONFIGROOM);
serv_gets(buf);
if (buf[0] != '2') { /* try to create the config room if not there */
serv_gets(buf);
serv_printf("GOTO %s", USERCONFIGROOM);
serv_gets(buf);
- if (buf[0] != '2') return; /* oh well. */
+ if (buf[0] != '2') return(1);
}
+ return(0);
+}
+
+
+void save_preferences(void) {
+ char buf[SIZ];
+ long msgnum = 0L;
+ if (goto_config_room() != 0) return; /* oh well. */
serv_puts("MSGS ALL|0|1");
serv_gets(buf);
if (buf[0] == '8') {
/* Go back to the room we're supposed to be in */
serv_printf("GOTO %s", WC->wc_roomname);
serv_gets(buf);
- lprintf(9, "exiting save_preferences()\n");
}
void get_preference(char *key, char *value) {
char buf[SIZ];
char thiskey[SIZ];
- lprintf(9, "entering get_preference(%s)\n", key);
strcpy(value, "");
num_prefs = num_tokens(WC->preferences, '\n');
extract_token(value, buf, 1, '|');
}
}
- lprintf(9, "exiting get_preference() = %s\n", value);
}
void set_preference(char *key, char *value) {
char thiskey[SIZ];
char *newprefs = NULL;
- lprintf(9, "entering set_preference(%s, %s)\n", key, value);
num_prefs = num_tokens(WC->preferences, '\n');
for (i=0; i<num_prefs; ++i) {
extract_token(buf, WC->preferences, i, '\n');
WC->preferences = newprefs;
save_preferences();
- lprintf(9, "exiting set_preference()\n");
}
/*
- * Display the form for editing a user's address book entry
+ * Locate the message number of a user's vCard in the current room
*/
-void display_edit_address_book_entry(char *username, long usernum) {
- char roomname[SIZ];
+long locate_user_vcard(char *username, long usernum) {
char buf[SIZ];
- char error_message[SIZ];
long vcard_msgnum = (-1L);
char content_type[SIZ];
char partnum[SIZ];
struct stuff_t *stuff = NULL;
struct stuff_t *ptr;
-
- /* Locate the user's config room, creating it if necessary */
- sprintf(roomname, "%010ld.%s", usernum, USERCONFIGROOM);
- serv_printf("GOTO %s||1", roomname);
- serv_gets(buf);
- if (buf[0] != '2') {
- serv_printf("CRE8 1|%s|5|||1|", roomname);
- serv_gets(buf);
- serv_printf("GOTO %s||1", roomname);
- serv_gets(buf);
- if (buf[0] != '2') {
- sprintf(error_message,
- "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
- "%s<BR><BR>\n", &buf[4]);
- select_user_to_edit(error_message, username);
- return;
- }
- }
-
TRYAGAIN:
/* Search for the user's vCard */
serv_puts("MSGS ALL");
stuff = ptr;
}
- /* Iterate throught the message list looking for vCards */
+ /* Iterate through the message list looking for vCards */
while (stuff != NULL) {
serv_printf("MSG0 %ld|2", stuff->msgnum);
serv_gets(buf);
stuff = ptr;
}
- lprintf(9, "vcard_msgnum == %ld\n", vcard_msgnum);
-
/* If there's no vcard, create one */
if (vcard_msgnum < 0) if (already_tried_creating_one == 0) {
already_tried_creating_one = 1;
goto TRYAGAIN;
}
+ return(vcard_msgnum);
+}
+
+
+/*
+ * Display the form for editing a user's address book entry
+ */
+void display_edit_address_book_entry(char *username, long usernum) {
+ char roomname[SIZ];
+ char buf[SIZ];
+ char error_message[SIZ];
+ long vcard_msgnum = (-1L);
+
+ /* Locate the user's config room, creating it if necessary */
+ sprintf(roomname, "%010ld.%s", usernum, USERCONFIGROOM);
+ serv_printf("GOTO %s||1", roomname);
+ serv_gets(buf);
+ if (buf[0] != '2') {
+ serv_printf("CRE8 1|%s|5|||1|", roomname);
+ serv_gets(buf);
+ serv_printf("GOTO %s||1", roomname);
+ serv_gets(buf);
+ if (buf[0] != '2') {
+ sprintf(error_message,
+ "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
+ "%s<BR><BR>\n", &buf[4]);
+ select_user_to_edit(error_message, username);
+ return;
+ }
+ }
+
+ vcard_msgnum = locate_user_vcard(username, usernum);
+
if (vcard_msgnum < 0) {
sprintf(error_message,
"<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
- "Could not create/edit vCard<BR><BR>\n");
+ "Could not create/edit vCard"
+ "<BR><BR>\n"
+ );
select_user_to_edit(error_message, username);
return;
}
wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
wprintf("</CENTER></FORM>\n");
-
wDumpContent(1);
}
if (!strcmp(bstr("return_to"), "/select_user_to_edit")) {
select_user_to_edit(NULL, NULL);
}
+ else if (!strcmp(bstr("return_to"), "/do_welcome")) {
+ do_welcome();
+ }
else {
readloop("readnew");
}
do_graphics_upload(buf);
} else if (!strcasecmp(action, "display_reg")) {
display_reg(0);
- } else if (!strcasecmp(action, "register")) {
- register_user();
} else if (!strcasecmp(action, "display_changepw")) {
display_changepw();
} else if (!strcasecmp(action, "changepw")) {
#define DEVELOPER_ID 0
#define CLIENT_ID 4
#define CLIENT_VERSION 410 /* This version of WebCit */
-#define MINIMUM_CIT_VERSION 605 /* min required Citadel vers */
+#define MINIMUM_CIT_VERSION 606 /* min required Citadel vers */
#define DEFAULT_HOST "localhost" /* Default Citadel server */
#define DEFAULT_PORT "504"
#define LB (1) /* Internal escape chars */
void serv_printf(const char *format,...);
void load_floorlist(void);
void display_reg(int);
-void register_user(void);
void display_changepw(void);
void changepw(void);
void display_edit_node(void);
extern char *months[];
extern char *days[];
void read_server_binary(char *buffer, size_t total_len);
+int goto_config_room(void);
+long locate_user_vcard(char *username, long usernum);
void sleeeeeeeeeep(int);