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)
160 const char *FileName;
162 FileName = GetIconFilename(bstr("type"), strlen(bstr("type")));
164 if (FileName == NULL)
165 snprintf (FileBuf, SIZ, "%s%s", static_dirs[0], "/diskette_24x.gif");
167 snprintf (FileBuf, SIZ, "%s%s", static_dirs[3], FileName);
168 output_static(FileBuf);
172 void download_file(char *filename)
176 char content_type[256];
177 char *content = NULL;
179 /* Setting to nonzero forces a MIME type of application/octet-stream */
180 int force_download = 1;
182 safestrncpy(buf, filename, sizeof buf);
184 serv_printf("OPEN %s", buf);
185 serv_getln(buf, sizeof buf);
187 bytes = extract_long(&buf[4], 0);
188 content = malloc(bytes + 2);
189 if (force_download) {
190 strcpy(content_type, "application/octet-stream");
193 extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
195 output_headers(0, 0, 0, 0, 0, 0);
196 read_server_binary(content, bytes);
198 serv_getln(buf, sizeof buf);
199 http_transmit_thing(content, bytes, content_type, 0);
202 wprintf("HTTP/1.1 404 %s\n", &buf[4]);
203 output_headers(0, 0, 0, 0, 0, 0);
204 wprintf("Content-Type: text/plain\r\n");
206 wprintf(_("An error occurred while retrieving this file: %s\n"), &buf[4]);
213 void upload_file(void)
215 const char *MimeType;
217 size_t bytes_transmitted = 0;
219 struct wcsession *WCC = WC; /* stack this for faster access (WC is a function) */
221 MimeType = GuessMimeType(WCC->upload, WCC->upload_length);
222 serv_printf("UOPN %s|%s|%s", WCC->upload_filename, MimeType, bstr("description"));
223 serv_getln(buf, sizeof buf);
226 strcpy(WCC->ImportantMessage, &buf[4]);
227 display_room_directory();
231 while (bytes_transmitted < WCC->upload_length)
234 if (blocksize > (WCC->upload_length - bytes_transmitted))
236 blocksize = (WCC->upload_length - bytes_transmitted);
238 serv_printf("WRIT %d", blocksize);
239 serv_getln(buf, sizeof buf);
242 blocksize = atoi(&buf[4]);
243 serv_write(&WCC->upload[bytes_transmitted], blocksize);
244 bytes_transmitted += blocksize;
249 serv_getln(buf, sizeof buf);
250 strcpy(WCC->ImportantMessage, &buf[4]);
251 display_room_directory();