7 void display_room_directory(void)
18 output_headers(1, 1, 2, 0, 0, 0);
19 wprintf("<div id=\"banner\">\n");
21 snprintf(title, sizeof title, _("Files available for download in %s"), WC->wc_roomname);
26 wprintf("<div id=\"content\" class=\"service\">\n");
28 wprintf("<div class=\"fix_scrollbar_bug\">"
29 "<table class=\"downloads_background\"><tr><td>\n");
30 wprintf("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>\n",
38 serv_getln(buf, sizeof buf);
39 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000"))
41 extract_token(filename, buf, 0, '|', sizeof filename);
42 extract_token(filesize, buf, 1, '|', sizeof filesize);
43 extract_token(mimetype, buf, 2, '|', sizeof mimetype);
44 extract_token(comment, buf, 3, '|', sizeof comment);
46 wprintf("<tr bgcolor=\"#%s\">", (bg ? "DDDDDD" : "FFFFFF"));
48 "<a href=\"download_file/");
50 wprintf("\"><img src=\"display_mime_icon?type=%s\" border=0 align=middle>\n", mimetype);
51 escputs(filename); wprintf("</a></td>");
52 wprintf("<td>"); escputs(filesize); wprintf("</td>");
53 wprintf("<td>"); escputs(mimetype); wprintf("</td>");
54 wprintf("<td>"); escputs(comment); wprintf("</td>");
56 if (!havepics && (strstr(mimetype, "image") != NULL))
59 wprintf("</table>\n");
61 /** Now offer the ability to upload files... */
62 if (WC->room_flags & QR_UPLOAD)
66 "enctype=\"multipart/form-data\" "
68 "accept-charset=\"UTF-8\" "
69 "action=\"upload_file\" "
70 "name=\"upload_file_form\""
73 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
75 wprintf(_("Upload a file:"));
76 wprintf(" <input NAME=\"filename\" SIZE=16 TYPE=\"file\"> \n");
77 wprintf(_("Description:"));
78 wprintf(" <input type=\"text\" name=\"description\" maxlength=\"64\" size=\"64\"> ");
79 wprintf("<input type=\"submit\" name=\"attach_button\" value=\"%s\">\n", _("Upload"));
86 wprintf("<div class=\"buttons\"><a href=\"display_pictureview&frame=1\">%s</a></div>", _("Slideshow"));
91 void display_pictureview(void)
102 if (atol(bstr("frame")) == 1) {
104 output_headers(1, 1, 2, 0, 0, 0);
105 wprintf("<div id=\"banner\">\n");
107 snprintf(title, sizeof title, _("Pictures in %s"), WC->wc_roomname);
112 wprintf("<div id=\"content\" class=\"service\">\n");
114 wprintf("<div class=\"fix_scrollbar_bug\">"
115 "<table class=\"downloads_background\"><tr><td>\n");
119 wprintf("<script type=\"text/javascript\" language=\"JavaScript\" > \nvar fadeimages=new Array()\n");
122 serv_getln(buf, sizeof buf);
123 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
124 extract_token(filename, buf, 0, '|', sizeof filename);
125 extract_token(filesize, buf, 1, '|', sizeof filesize);
126 extract_token(mimetype, buf, 2, '|', sizeof mimetype);
127 extract_token(comment, buf, 3, '|', sizeof comment);
128 if (strstr(mimetype, "image") != NULL) {
129 wprintf("fadeimages[%d]=[\"download_file/", n);
131 wprintf("\", \"\", \"\"]\n");
135 escputs(filename); wprintf("</a></td>");
136 wprintf("<td>"); escputs(filesize); wprintf("</td>");
137 wprintf("<td>"); escputs(mimetype); wprintf("</td>");
138 wprintf("<td>"); escputs(comment); wprintf("</td>");
144 wprintf("</script>\n");
145 wprintf("<tr><td><script type=\"text/javascript\" src=\"static/fadeshow.js\">\n</script>\n");
146 wprintf("<script type=\"text/javascript\" >\n");
147 wprintf("new fadeshow(fadeimages, 500, 400, 0, 3000, 1, \"R\");\n");
148 wprintf("</script></td><th>\n");
156 extern char* static_dirs[];
157 void display_mime_icon(void)
161 snprintf (diskette, SIZ, "%s%s", static_dirs[0], "/diskette_24x.gif");
162 output_static(diskette);
166 void download_file(char *filename)
170 char content_type[256];
171 char *content = NULL;
173 /* Setting to nonzero forces a MIME type of application/octet-stream */
174 int force_download = 1;
176 safestrncpy(buf, filename, sizeof buf);
178 serv_printf("OPEN %s", buf);
179 serv_getln(buf, sizeof buf);
181 bytes = extract_long(&buf[4], 0);
182 content = malloc(bytes + 2);
183 if (force_download) {
184 strcpy(content_type, "application/octet-stream");
187 extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
189 output_headers(0, 0, 0, 0, 0, 0);
190 read_server_binary(content, bytes);
192 serv_getln(buf, sizeof buf);
193 http_transmit_thing(content, bytes, content_type, 0);
196 wprintf("HTTP/1.1 404 %s\n", &buf[4]);
197 output_headers(0, 0, 0, 0, 0, 0);
198 wprintf("Content-Type: text/plain\r\n");
200 wprintf(_("An error occurred while retrieving this file: %s\n"), &buf[4]);
207 void upload_file(void)
209 const char *MimeType;
211 size_t bytes_transmitted = 0;
213 struct wcsession *WCC = WC; /* stack this for faster access (WC is a function) */
215 MimeType = GuessMimeType(WCC->upload, WCC->upload_length);
216 serv_printf("UOPN %s|%s|%s", WCC->upload_filename, MimeType, bstr("description"));
217 serv_getln(buf, sizeof buf);
220 strcpy(WCC->ImportantMessage, &buf[4]);
221 display_room_directory();
225 while (bytes_transmitted < WCC->upload_length)
228 if (blocksize > (WCC->upload_length - bytes_transmitted))
230 blocksize = (WCC->upload_length - bytes_transmitted);
232 serv_printf("WRIT %d", blocksize);
233 serv_getln(buf, sizeof buf);
236 blocksize = atoi(&buf[4]);
237 serv_write(&WCC->upload[bytes_transmitted], blocksize);
238 bytes_transmitted += blocksize;
243 serv_getln(buf, sizeof buf);
244 strcpy(WCC->ImportantMessage, &buf[4]);
245 display_room_directory();