2 * Handles HTTP upload of graphics files into the system.
4 * Copyright (c) 1996-2011 by the citadel.org team
6 * This program is open source software. You can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 extern void output_static(const char* What);
25 void display_graphics_upload(char *filename)
29 snprintf(buf, SIZ, "UIMG 0||%s", filename);
31 serv_getln(buf, sizeof buf);
33 strcpy(WC->ImportantMessage, &buf[4]);
37 output_headers(1, 0, 0, 0, 1, 0);
38 do_template("files_graphicsupload");
42 void do_graphics_upload(char *filename)
50 bytes_remaining = WCC->upload_length;
52 if (havebstr("cancel_button")) {
53 strcpy(WC->ImportantMessage,
54 _("Graphics upload has been cancelled."));
59 if (WCC->upload_length == 0) {
60 strcpy(WC->ImportantMessage,
61 _("You didn't upload a file."));
66 MimeType = GuessMimeType(ChrPtr(WCC->upload), bytes_remaining);
67 snprintf(buf, SIZ, "UIMG 1|%s|%s", MimeType, filename);
70 serv_getln(buf, sizeof buf);
72 strcpy(WCC->ImportantMessage, &buf[4]);
76 while (bytes_remaining) {
77 thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
78 serv_printf("WRIT %d", thisblock);
79 serv_getln(buf, sizeof buf);
81 strcpy(WCC->ImportantMessage, &buf[4]);
83 serv_getln(buf, sizeof buf);
87 thisblock = extract_int(&buf[4], 0);
88 serv_write(&ChrPtr(WCC->upload)[pos], thisblock);
89 pos = pos + thisblock;
90 bytes_remaining = bytes_remaining - thisblock;
94 serv_getln(buf, sizeof buf);
96 display_success(&buf[4]);
102 void edithellopic(void) { do_graphics_upload("hello"); }
103 void editpic(void) { do_graphics_upload("_userpic_"); }
104 void editgoodbuyepic(void) { do_graphics_upload("UIMG 1|%s|goodbuye"); }
106 /* The users photo display / upload facility */
107 void display_editpic(void) {
108 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_userpic_")));
109 putbstr("__PICDESC", NewStrBufPlain(_("your photo"), -1));
110 putbstr("__UPLURL", NewStrBufPlain(HKEY("editpic")));
111 display_graphics_upload("editpic");
113 /* room picture dispay / upload facility */
114 void display_editroompic(void) {
115 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_roompic_")));
116 putbstr("__PICDESC", NewStrBufPlain(_("the icon for this room"), -1));
117 putbstr("__UPLURL", NewStrBufPlain(HKEY("editroompic")));
118 display_graphics_upload("editroompic");
121 /* the greetingpage hello pic */
122 void display_edithello(void) {
123 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("hello")));
124 putbstr("__PICDESC", NewStrBufPlain(_("the Greetingpicture for the login prompt"), -1));
125 putbstr("__UPLURL", NewStrBufPlain(HKEY("edithellopic")));
126 display_graphics_upload("edithellopic");
129 /* the logoff banner */
130 void display_editgoodbyepic(void) {
131 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("UIMG 0|%s|goodbuye")));
132 putbstr("__PICDESC", NewStrBufPlain(_("the Logoff banner picture"), -1));
133 putbstr("__UPLURL", NewStrBufPlain(HKEY("editgoodbuyepic")));
134 display_graphics_upload("editgoodbuyepic");
137 void display_editfloorpic(void) {
140 PicAction = NewStrBuf();
141 StrBufPrintf(PicAction, "_floorpic_|%s", bstr("which_floor"));
142 putbstr("__WHICHPIC", PicAction);
143 putbstr("__PICDESC", NewStrBufPlain(_("the icon for this floor"), -1));
144 putbstr("__UPLURL", NewStrBufPlain(HKEY("editfloorpic")));
145 display_graphics_upload("editfloorpic");
148 void editroompic(void) {
150 snprintf(buf, SIZ, "_roompic_|%s",
152 do_graphics_upload(buf);
155 void editfloorpic(void){
157 snprintf(buf, SIZ, "_floorpic_|%s",
158 bstr("which_floor"));
159 do_graphics_upload(buf);
166 WebcitAddUrlHandler(HKEY("display_editpic"), "", 0, display_editpic, 0);
167 WebcitAddUrlHandler(HKEY("editpic"), "", 0, editpic, 0);
168 WebcitAddUrlHandler(HKEY("display_editroompic"), "", 0, display_editroompic, 0);
169 WebcitAddUrlHandler(HKEY("editroompic"), "", 0, editroompic, 0);
170 WebcitAddUrlHandler(HKEY("display_edithello"), "", 0, display_edithello, 0);
171 WebcitAddUrlHandler(HKEY("edithellopic"), "", 0, edithellopic, 0);
172 WebcitAddUrlHandler(HKEY("display_editgoodbuye"), "", 0, display_editgoodbyepic, 0);
173 WebcitAddUrlHandler(HKEY("editgoodbuyepic"), "", 0, editgoodbuyepic, 0);
174 WebcitAddUrlHandler(HKEY("display_editfloorpic"), "", 0, display_editfloorpic, 0);
175 WebcitAddUrlHandler(HKEY("editfloorpic"), "", 0, editfloorpic, 0);