* "Finished" the MIME parser.
* Got image uploads working.
* Added "add/edit user photo" screens.
+Thu Dec 31 21:53:20 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+ * Final cvs commit for 1998 (an awful year, I'm glad to see it over).
+ * "Finished" the MIME parser.
+ * Got image uploads working.
+ * Added "add/edit user photo" screens.
+
Wed Dec 30 20:36:13 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Wrote mime_parser.c for handling of image uploads. This will also
be used in future Citadel MIME projects.
webcit: webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \
roomops.o tools.o messages.o userlist.o paging.o sysmsgs.o \
- mime_parser.o
+ mime_parser.o graphics.o
$(CC) webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \
tools.o roomops.o messages.o userlist.o paging.o sysmsgs.o \
- mime_parser.o -o webcit
+ mime_parser.o graphics.o -o webcit
webcit.o: webcit.c webcit.h child.h
$(CC) $(CFLAGS) $(DEFS) -c webcit.c
messages.o: messages.c webcit.h child.h
$(CC) $(CFLAGS) $(DEFS) -c messages.c
+graphics.o: graphics.c webcit.h child.h
+ $(CC) $(CFLAGS) $(DEFS) -c graphics.c
+
paging.o: paging.c webcit.h child.h
$(CC) $(CFLAGS) $(DEFS) -c paging.c
void validate(void);
void mime_parser(char *, int, char *);
void handle_multipart(char *, int, char *);
+void display_graphics_upload(char *description, char *check_cmd, char *uplurl);
+void do_graphics_upload(char *upl_cmd);
+void serv_read(char *buf, int bytes);
+void serv_gets(char *strbuf);
+void serv_write(char *buf, int nbytes);
+void serv_puts(char *string);
+void serv_printf(const char *format, ...);
+
+
+
+
+
--- /dev/null
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+#include "webcit.h"
+#include "child.h"
+
+
+void display_graphics_upload(char *description, char *check_cmd, char *uplurl) {
+ char buf[256];
+
+ serv_puts(check_cmd);
+ serv_gets(buf);
+ if (buf[0] != '2') {
+ display_error(&buf[4]);
+ return;
+ }
+
+ printf("HTTP/1.0 200 OK\n");
+ output_headers(1);
+ wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
+ wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
+ wprintf("<B>Set/change %s</B>\n", description);
+ wprintf("</FONT></TD></TR></TABLE>\n");
+
+ wprintf("<CENTER>\n");
+ wprintf("Please select a file to upload:<BR>\n");
+ wprintf("<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"%s\" METHOD=\"POST\">\n", uplurl);
+ wprintf("<INPUT TYPE=\"FILE\" NAME=\"filename\" SIZE=\"35\">\n");
+ wprintf("<BR>");
+ wprintf("<INPUT TYPE=\"SUBMIT\" VALUE=\"Upload\">\n");
+ wprintf("<INPUT TYPE=\"RESET\" VALUE=\"Reset Form\">\n");
+ wprintf("</FORM>\n");
+ wprintf("<A HREF=\"/display_main_menu\">Cancel</A>\n");
+ wprintf("</CENTER></BODY></HTML>\n");
+ wDumpContent();
+ }
+
+void do_graphics_upload(char *upl_cmd) {
+ char buf[256];
+ int bytes_remaining;
+ int pos = 0;
+ int thisblock;
+
+ if (upload_length == 0) {
+ display_error("You didn't upload a file.\n");
+ return;
+ }
+
+ serv_puts(upl_cmd);
+ serv_gets(buf);
+ if (buf[0] != '2') {
+ display_error(&buf[4]);
+ return;
+ }
+
+ bytes_remaining = upload_length;
+ while (bytes_remaining) {
+ thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
+ serv_printf("WRIT %d", thisblock);
+ serv_gets(buf);
+ if (buf[0] != '7') {
+ display_error(&buf[4]);
+ serv_puts("UCLS 0");
+ serv_gets(buf);
+ return;
+ }
+ thisblock = extract_int(&buf[4], 0);
+ serv_write(&upload[pos], thisblock);
+ pos = pos + thisblock;
+ bytes_remaining = bytes_remaining - thisblock;
+ }
+
+ serv_puts("UCLS 1");
+ serv_gets(buf);
+ /* FIX display something other than an error if it's ok */
+ if (buf[0] != 'x') {
+ display_error(&buf[4]);
+ return;
+ }
+ }
*/
else if (strlen(name)>0) {
-
+ upload = malloc(length);
+ if (upload != NULL) {
+ upload_length = length;
+ memcpy(upload, content, length);
+ }
}
}
<TITLE>MenuBar</TITLE>
</HEAD>
<BODY BACKGROUND="/image&name=background" TEXT="#000000" LINK="#004400">
- <IMG SRC="/static/citadel-logo.jpg" ALT="Citadel/UX"><BR>
<FONT SIZE=-1>
- <A HREF="/knrooms" TARGET="bottom">List known rooms<BR>
- <A HREF="/gotonext" TARGET="top">Goto next room<BR>
- <A HREF="/skip" TARGET="top">Skip this room<BR>
- <A HREF="/ungoto" TARGET="top">Ungoto<BR>
+ <IMG SRC="/image&name=hello"><BR>
+ <A HREF="/knrooms" TARGET="bottom">List known rooms</A><BR>
+ <A HREF="/gotonext" TARGET="top">Goto next room</A><BR>
+ <A HREF="/skip" TARGET="top">Skip this room</A><BR>
+ <A HREF="/ungoto" TARGET="top">Ungoto</A><BR>
<HR>
- <A HREF="/readnew" TARGET="bottom">Read new messages<BR>
- <A HREF="/readfwd" TARGET="bottom">Read all messages<BR>
- <A HREF="/display_enter" TARGET="bottom">Enter a message<BR>
+ <A HREF="/readnew" TARGET="bottom">Read new messages</A><BR>
+ <A HREF="/readfwd" TARGET="bottom">Read all messages</A><BR>
+ <A HREF="/display_enter" TARGET="bottom">Enter a message</A><BR>
<HR>
- <A HREF="/whobbs" TARGET="bottom">Who is online?<BR>
- <A HREF="/userlist" TARGET="bottom">User list<BR>
- <A HREF="/advanced" TARGET="bottom">Advanced options<BR>
+ <A HREF="/whobbs" TARGET="bottom">Who is online?</A><BR>
+ <A HREF="/userlist" TARGET="bottom">User list</A><BR>
+ <A HREF="/advanced" TARGET="bottom">Advanced options</A><BR>
<HR>
- <A HREF="/static/upload.html" TARGET="bottom">upload test<BR>
- <A HREF="/termquit" TARGET="_top">Log off<BR>
+ <A HREF="/termquit" TARGET="_top">Log off</A><BR>
</FONT>
+ <HR>
+ <A HREF="http://uncnsrd.mt-kisco.ny.us/citadel" TARGET="aboutcit">
+ <FONT SIZE=-1>Powered by</FONT><BR>
+ <IMG SRC="/static/citadel-logo.jpg" ALT="Citadel/UX"></A><BR>
</BODY>
</HTML>
static const char *defaulthost = DEFAULT_HOST;
static const char *defaultport = DEFAULT_PORT;
+int upload_length = 0;
+char *upload;
+
void unescape_input(char *buf)
{
strcpy(c_password, "");
strcpy(c_roomname, "");
+ upload_length = 0;
+ upload = NULL;
+
getz(cmd);
extract_action(action, cmd);
validate();
}
+ else if (!strcasecmp(action, "display_editpic")) {
+ display_graphics_upload("your photo",
+ "UIMG 0|_userpic_",
+ "/editpic");
+ }
+
+ else if (!strcasecmp(action, "editpic")) {
+ do_graphics_upload("UIMG 1|_userpic_");
+ }
+
/* When all else fails... */
else {
printf("HTTP/1.0 200 OK\n");
content = NULL;
}
free_urls();
+ if (upload_length > 0) {
+ free(upload);
+ upload_length = 0;
+ }
}
int main(int argc, char *argv[]) {
extern char ugname[128];
extern long uglsn;
extern char *axdefs[];
+extern int upload_length;
+extern char *upload;