2 * Handles HTTP upload of graphics files into the system.
4 * Copyright (c) 1996-2012 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, version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
17 extern void output_static(const char* What);
19 void display_graphics_upload(char *filename)
24 serv_printf("UIMG 0||%s", filename);
25 StrBuf_ServGetln(Line);
26 if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
32 output_headers(1, 0, 0, 0, 1, 0);
33 do_template("files_graphicsupload");
39 void do_graphics_upload(char *filename)
47 bytes_remaining = WCC->upload_length;
49 if (havebstr("cancel_button")) {
50 AppendImportantMessage(_("Graphics upload has been cancelled."), -1);
55 if (WCC->upload_length == 0) {
56 AppendImportantMessage(_("You didn't upload a file."), -1);
61 MimeType = GuessMimeType(ChrPtr(WCC->upload), bytes_remaining);
62 serv_printf("UIMG 1|%s|%s", MimeType, filename);
65 StrBuf_ServGetln(Line);
66 if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
71 while (bytes_remaining) {
72 thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
73 serv_printf("WRIT %d", thisblock);
74 StrBuf_ServGetln(Line);
75 if (GetServerStatusMsg(Line, NULL, 1, 7) != 7) {
77 StrBuf_ServGetln(Line);
82 thisblock = extract_int(ChrPtr(Line) +4, 0);
83 serv_write(&ChrPtr(WCC->upload)[pos], thisblock);
85 bytes_remaining -= thisblock;
89 StrBuf_ServGetln(Line);
90 if (*ChrPtr(Line) != 'x') {
91 display_success(ChrPtr(Line) + 4);
99 void edithellopic(void) { do_graphics_upload("hello"); }
100 void editpic(void) { do_graphics_upload("_userpic_"); }
101 void editgoodbuyepic(void) { do_graphics_upload("UIMG 1|%s|goodbuye"); }
103 /* The users photo display / upload facility */
104 void display_editpic(void) {
105 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_userpic_")));
106 putbstr("__PICDESC", NewStrBufPlain(_("your photo"), -1));
107 putbstr("__UPLURL", NewStrBufPlain(HKEY("editpic")));
108 display_graphics_upload("editpic");
110 /* room picture dispay / upload facility */
111 void display_editroompic(void) {
112 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_roompic_")));
113 putbstr("__PICDESC", NewStrBufPlain(_("the icon for this room"), -1));
114 putbstr("__UPLURL", NewStrBufPlain(HKEY("editroompic")));
115 display_graphics_upload("editroompic");
118 /* the greetingpage hello pic */
119 void display_edithello(void) {
120 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("hello")));
121 putbstr("__PICDESC", NewStrBufPlain(_("the Greetingpicture for the login prompt"), -1));
122 putbstr("__UPLURL", NewStrBufPlain(HKEY("edithellopic")));
123 display_graphics_upload("edithellopic");
126 /* the logoff banner */
127 void display_editgoodbyepic(void) {
128 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("UIMG 0|%s|goodbuye")));
129 putbstr("__PICDESC", NewStrBufPlain(_("the Logoff banner picture"), -1));
130 putbstr("__UPLURL", NewStrBufPlain(HKEY("editgoodbuyepic")));
131 display_graphics_upload("editgoodbuyepic");
134 void display_editfloorpic(void) {
137 PicAction = NewStrBuf();
138 StrBufPrintf(PicAction, "_floorpic_|%s", bstr("which_floor"));
139 putbstr("__WHICHPIC", PicAction);
140 putbstr("__PICDESC", NewStrBufPlain(_("the icon for this floor"), -1));
141 putbstr("__UPLURL", NewStrBufPlain(HKEY("editfloorpic")));
142 display_graphics_upload("editfloorpic");
145 void editroompic(void) {
147 snprintf(buf, SIZ, "_roompic_|%s",
149 do_graphics_upload(buf);
152 void editfloorpic(void){
154 snprintf(buf, SIZ, "_floorpic_|%s",
155 bstr("which_floor"));
156 do_graphics_upload(buf);
163 WebcitAddUrlHandler(HKEY("display_editpic"), "", 0, display_editpic, 0);
164 WebcitAddUrlHandler(HKEY("editpic"), "", 0, editpic, 0);
165 WebcitAddUrlHandler(HKEY("display_editroompic"), "", 0, display_editroompic, 0);
166 WebcitAddUrlHandler(HKEY("editroompic"), "", 0, editroompic, 0);
167 WebcitAddUrlHandler(HKEY("display_edithello"), "", 0, display_edithello, 0);
168 WebcitAddUrlHandler(HKEY("edithellopic"), "", 0, edithellopic, 0);
169 WebcitAddUrlHandler(HKEY("display_editgoodbuye"), "", 0, display_editgoodbyepic, 0);
170 WebcitAddUrlHandler(HKEY("editgoodbuyepic"), "", 0, editgoodbuyepic, 0);
171 WebcitAddUrlHandler(HKEY("display_editfloorpic"), "", 0, display_editfloorpic, 0);
172 WebcitAddUrlHandler(HKEY("editfloorpic"), "", 0, editfloorpic, 0);