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 (lbstr("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)
160 const char *FileName;
164 MimeType = xbstr("type", &tlen);
165 FileName = GetIconFilename(MimeType, tlen);
167 if (FileName == NULL)
168 snprintf (FileBuf, SIZ, "%s%s", static_dirs[0], "/diskette_24x.gif");
170 snprintf (FileBuf, SIZ, "%s%s", static_dirs[3], FileName);
171 output_static(FileBuf);
175 void download_file(char *filename)
179 char content_type[256];
180 char *content = NULL;
182 /* Setting to nonzero forces a MIME type of application/octet-stream */
183 int force_download = 1;
185 safestrncpy(buf, filename, sizeof buf);
187 serv_printf("OPEN %s", buf);
188 serv_getln(buf, sizeof buf);
190 bytes = extract_long(&buf[4], 0);
191 content = malloc(bytes + 2);
192 if (force_download) {
193 strcpy(content_type, "application/octet-stream");
196 extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
198 output_headers(0, 0, 0, 0, 0, 0);
199 read_server_binary(content, bytes);
201 serv_getln(buf, sizeof buf);
202 http_transmit_thing(content, bytes, content_type, 0);
205 wprintf("HTTP/1.1 404 %s\n", &buf[4]);
206 output_headers(0, 0, 0, 0, 0, 0);
207 wprintf("Content-Type: text/plain\r\n");
209 wprintf(_("An error occurred while retrieving this file: %s\n"), &buf[4]);
216 void upload_file(void)
218 const char *MimeType;
220 size_t bytes_transmitted = 0;
222 struct wcsession *WCC = WC; /* stack this for faster access (WC is a function) */
224 MimeType = GuessMimeType(WCC->upload, WCC->upload_length);
225 serv_printf("UOPN %s|%s|%s", WCC->upload_filename, MimeType, bstr("description"));
226 serv_getln(buf, sizeof buf);
229 strcpy(WCC->ImportantMessage, &buf[4]);
230 display_room_directory();
234 while (bytes_transmitted < WCC->upload_length)
237 if (blocksize > (WCC->upload_length - bytes_transmitted))
239 blocksize = (WCC->upload_length - bytes_transmitted);
241 serv_printf("WRIT %d", blocksize);
242 serv_getln(buf, sizeof buf);
245 blocksize = atoi(&buf[4]);
246 serv_write(&WCC->upload[bytes_transmitted], blocksize);
247 bytes_transmitted += blocksize;
252 serv_getln(buf, sizeof buf);
253 strcpy(WCC->ImportantMessage, &buf[4]);
254 display_room_directory();