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)
30 serv_printf("UIMG 0||%s", filename);
31 StrBuf_ServGetln(Line);
32 if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
38 output_headers(1, 0, 0, 0, 1, 0);
39 do_template("files_graphicsupload");
45 void do_graphics_upload(char *filename)
54 bytes_remaining = WCC->upload_length;
56 if (havebstr("cancel_button")) {
57 AppendImportantMessage(_("Graphics upload has been cancelled."), -1);
62 if (WCC->upload_length == 0) {
63 AppendImportantMessage(_("You didn't upload a file."), -1);
68 MimeType = GuessMimeType(ChrPtr(WCC->upload), bytes_remaining);
69 serv_printf("UIMG 1|%s|%s", MimeType, filename);
72 StrBuf_ServGetln(Line);
73 if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
78 while (bytes_remaining) {
79 thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
80 serv_printf("WRIT %d", thisblock);
81 StrBuf_ServGetln(Line);
82 if (GetServerStatusMsg(Line, NULL, 1, 7) != 7) {
84 StrBuf_ServGetln(Line);
89 thisblock = extract_int(&buf[4], 0);
90 serv_write(&ChrPtr(WCC->upload)[pos], thisblock);
91 pos = pos + thisblock;
92 bytes_remaining = bytes_remaining - thisblock;
96 StrBuf_ServGetln(Line);
97 if (*ChrPtr(Line) != 'x') {
98 display_success(ChrPtr(Line) + 4);
106 void edithellopic(void) { do_graphics_upload("hello"); }
107 void editpic(void) { do_graphics_upload("_userpic_"); }
108 void editgoodbuyepic(void) { do_graphics_upload("UIMG 1|%s|goodbuye"); }
110 /* The users photo display / upload facility */
111 void display_editpic(void) {
112 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_userpic_")));
113 putbstr("__PICDESC", NewStrBufPlain(_("your photo"), -1));
114 putbstr("__UPLURL", NewStrBufPlain(HKEY("editpic")));
115 display_graphics_upload("editpic");
117 /* room picture dispay / upload facility */
118 void display_editroompic(void) {
119 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_roompic_")));
120 putbstr("__PICDESC", NewStrBufPlain(_("the icon for this room"), -1));
121 putbstr("__UPLURL", NewStrBufPlain(HKEY("editroompic")));
122 display_graphics_upload("editroompic");
125 /* the greetingpage hello pic */
126 void display_edithello(void) {
127 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("hello")));
128 putbstr("__PICDESC", NewStrBufPlain(_("the Greetingpicture for the login prompt"), -1));
129 putbstr("__UPLURL", NewStrBufPlain(HKEY("edithellopic")));
130 display_graphics_upload("edithellopic");
133 /* the logoff banner */
134 void display_editgoodbyepic(void) {
135 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("UIMG 0|%s|goodbuye")));
136 putbstr("__PICDESC", NewStrBufPlain(_("the Logoff banner picture"), -1));
137 putbstr("__UPLURL", NewStrBufPlain(HKEY("editgoodbuyepic")));
138 display_graphics_upload("editgoodbuyepic");
141 void display_editfloorpic(void) {
144 PicAction = NewStrBuf();
145 StrBufPrintf(PicAction, "_floorpic_|%s", bstr("which_floor"));
146 putbstr("__WHICHPIC", PicAction);
147 putbstr("__PICDESC", NewStrBufPlain(_("the icon for this floor"), -1));
148 putbstr("__UPLURL", NewStrBufPlain(HKEY("editfloorpic")));
149 display_graphics_upload("editfloorpic");
152 void editroompic(void) {
154 snprintf(buf, SIZ, "_roompic_|%s",
156 do_graphics_upload(buf);
159 void editfloorpic(void){
161 snprintf(buf, SIZ, "_floorpic_|%s",
162 bstr("which_floor"));
163 do_graphics_upload(buf);
170 WebcitAddUrlHandler(HKEY("display_editpic"), "", 0, display_editpic, 0);
171 WebcitAddUrlHandler(HKEY("editpic"), "", 0, editpic, 0);
172 WebcitAddUrlHandler(HKEY("display_editroompic"), "", 0, display_editroompic, 0);
173 WebcitAddUrlHandler(HKEY("editroompic"), "", 0, editroompic, 0);
174 WebcitAddUrlHandler(HKEY("display_edithello"), "", 0, display_edithello, 0);
175 WebcitAddUrlHandler(HKEY("edithellopic"), "", 0, edithellopic, 0);
176 WebcitAddUrlHandler(HKEY("display_editgoodbuye"), "", 0, display_editgoodbyepic, 0);
177 WebcitAddUrlHandler(HKEY("editgoodbuyepic"), "", 0, editgoodbuyepic, 0);
178 WebcitAddUrlHandler(HKEY("display_editfloorpic"), "", 0, display_editfloorpic, 0);
179 WebcitAddUrlHandler(HKEY("editfloorpic"), "", 0, editfloorpic, 0);