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 void display_graphics_upload(char *filename)
27 snprintf(buf, SIZ, "UIMG 0||%s", filename);
29 serv_getln(buf, sizeof buf);
31 strcpy(WC->ImportantMessage, &buf[4]);
35 output_headers(1, 0, 0, 0, 1, 0);
36 do_template("files_graphicsupload");
40 void do_graphics_upload(char *filename)
48 bytes_remaining = WCC->upload_length;
50 if (havebstr("cancel_button")) {
51 strcpy(WC->ImportantMessage,
52 _("Graphics upload has been cancelled."));
57 if (WCC->upload_length == 0) {
58 strcpy(WC->ImportantMessage,
59 _("You didn't upload a file."));
64 MimeType = GuessMimeType(ChrPtr(WCC->upload), bytes_remaining);
65 snprintf(buf, SIZ, "UIMG 1|%s|%s", MimeType, filename);
68 serv_getln(buf, sizeof buf);
70 strcpy(WCC->ImportantMessage, &buf[4]);
74 while (bytes_remaining) {
75 thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
76 serv_printf("WRIT %d", thisblock);
77 serv_getln(buf, sizeof buf);
79 strcpy(WCC->ImportantMessage, &buf[4]);
81 serv_getln(buf, sizeof buf);
85 thisblock = extract_int(&buf[4], 0);
86 serv_write(&ChrPtr(WCC->upload)[pos], thisblock);
87 pos = pos + thisblock;
88 bytes_remaining = bytes_remaining - thisblock;
92 serv_getln(buf, sizeof buf);
94 display_success(&buf[4]);
100 void edithellopic(void) { do_graphics_upload("hello"); }
101 void editpic(void) { do_graphics_upload("_userpic_"); }
102 void editgoodbuyepic(void) { do_graphics_upload("UIMG 1|%s|goodbuye"); }
104 /* The users photo display / upload facility */
105 void display_editpic(void) {
106 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_userpic_")));
107 putbstr("__PICDESC", NewStrBufPlain(_("your photo"), -1));
108 putbstr("__UPLURL", NewStrBufPlain(HKEY("editpic")));
109 display_graphics_upload("editpic");
111 /* room picture dispay / upload facility */
112 void display_editroompic(void) {
113 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_roompic_")));
114 putbstr("__PICDESC", NewStrBufPlain(_("the icon for this room"), -1));
115 putbstr("__UPLURL", NewStrBufPlain(HKEY("editroompic")));
116 display_graphics_upload("editroompic");
119 /* the greetingpage hello pic */
120 void display_edithello(void) {
121 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("hello")));
122 putbstr("__PICDESC", NewStrBufPlain(_("the Greetingpicture for the login prompt"), -1));
123 putbstr("__UPLURL", NewStrBufPlain(HKEY("edithellopic")));
124 display_graphics_upload("edithellopic");
127 /* the logoff banner */
128 void display_editgoodbyepic(void) {
129 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("UIMG 0|%s|goodbuye")));
130 putbstr("__PICDESC", NewStrBufPlain(_("the Logoff banner picture"), -1));
131 putbstr("__UPLURL", NewStrBufPlain(HKEY("editgoodbuyepic")));
132 display_graphics_upload("editgoodbuyepic");
135 void display_editfloorpic(void) {
138 PicAction = NewStrBuf();
139 StrBufPrintf(PicAction, "_floorpic_|%s", bstr("which_floor"));
140 putbstr("__WHICHPIC", PicAction);
141 putbstr("__PICDESC", NewStrBufPlain(_("the icon for this floor"), -1));
142 putbstr("__UPLURL", NewStrBufPlain(HKEY("editfloorpic")));
143 display_graphics_upload("editfloorpic");
146 void editroompic(void) {
148 snprintf(buf, SIZ, "_roompic_|%s",
150 do_graphics_upload(buf);
153 void editfloorpic(void){
155 snprintf(buf, SIZ, "_floorpic_|%s",
156 bstr("which_floor"));
157 do_graphics_upload(buf);
164 WebcitAddUrlHandler(HKEY("display_editpic"), "", 0, display_editpic, 0);
165 WebcitAddUrlHandler(HKEY("editpic"), "", 0, editpic, 0);
166 WebcitAddUrlHandler(HKEY("display_editroompic"), "", 0, display_editroompic, 0);
167 WebcitAddUrlHandler(HKEY("editroompic"), "", 0, editroompic, 0);
168 WebcitAddUrlHandler(HKEY("display_edithello"), "", 0, display_edithello, 0);
169 WebcitAddUrlHandler(HKEY("edithellopic"), "", 0, edithellopic, 0);
170 WebcitAddUrlHandler(HKEY("display_editgoodbuye"), "", 0, display_editgoodbyepic, 0);
171 WebcitAddUrlHandler(HKEY("editgoodbuyepic"), "", 0, editgoodbuyepic, 0);
172 WebcitAddUrlHandler(HKEY("display_editfloorpic"), "", 0, display_editfloorpic, 0);
173 WebcitAddUrlHandler(HKEY("editfloorpic"), "", 0, editfloorpic, 0);