1 |
nishi |
1 |
/* $Id: modern.c 75 2024-08-30 05:19:25Z nishi $ */
|
|
|
2 |
|
|
|
3 |
#include "rv_query.h"
|
|
|
4 |
|
|
|
5 |
#include "rv_util.h"
|
|
|
6 |
#include "rv_version.h"
|
3 |
nishi |
7 |
#include "rv_auth.h"
|
1 |
nishi |
8 |
#include "rv_db.h"
|
11 |
nishi |
9 |
#include "rv_repo.h"
|
42 |
nishi |
10 |
#include "rv_multipart.h"
|
1 |
nishi |
11 |
|
|
|
12 |
#include "../../config.h"
|
|
|
13 |
|
13 |
nishi |
14 |
#ifdef USE_ENSCRIPT
|
|
|
15 |
#include "rv_enscript.h"
|
|
|
16 |
#endif
|
|
|
17 |
|
39 |
nishi |
18 |
#ifdef USE_AVATAR
|
|
|
19 |
#include "rv_avatar.h"
|
|
|
20 |
#endif
|
|
|
21 |
|
42 |
nishi |
22 |
#ifdef USE_GRAPHICSMAGICK
|
|
|
23 |
#include "rv_magick.h"
|
|
|
24 |
#endif
|
|
|
25 |
|
43 |
nishi |
26 |
#include <sys/stat.h>
|
7 |
nishi |
27 |
#include <stdio.h>
|
1 |
nishi |
28 |
#include <stdlib.h>
|
|
|
29 |
#include <string.h>
|
39 |
nishi |
30 |
#include <unistd.h>
|
1 |
nishi |
31 |
|
42 |
nishi |
32 |
extern char* nocache;
|
1 |
nishi |
33 |
extern char* buffer;
|
|
|
34 |
void add_data(char** data, const char* txt);
|
|
|
35 |
void render_stuff();
|
|
|
36 |
|
|
|
37 |
char* title = NULL;
|
|
|
38 |
char* desc = NULL;
|
|
|
39 |
char* page = NULL;
|
10 |
nishi |
40 |
char* nav = NULL;
|
46 |
nishi |
41 |
char* logopath = NULL;
|
11 |
nishi |
42 |
char* grepouser;
|
6 |
nishi |
43 |
extern char* user;
|
1 |
nishi |
44 |
|
43 |
nishi |
45 |
bool invalid_char(char c) {
|
|
|
46 |
if(c >= '0' && c <= '9') return false;
|
|
|
47 |
if(c >= 'a' && c <= 'z') return false;
|
|
|
48 |
if(c >= 'A' && c <= 'Z') return false;
|
65 |
nishi |
49 |
if(c == '_' || c == '-' || c == '.') return false;
|
44 |
nishi |
50 |
return true;
|
43 |
nishi |
51 |
}
|
|
|
52 |
|
11 |
nishi |
53 |
char* url_escape(const char* input) {
|
|
|
54 |
const char hex[] = "0123456789ABCDEF";
|
|
|
55 |
char* r = malloc(1);
|
|
|
56 |
r[0] = 0;
|
|
|
57 |
char cbuf[2];
|
|
|
58 |
cbuf[1] = 0;
|
|
|
59 |
int i;
|
|
|
60 |
for(i = 0; input[i] != 0; i++) {
|
|
|
61 |
if(input[i] == 0x20 || input[i] == 0x22 || input[i] == 0x25 || input[i] == 0x2d || input[i] == 0x2e || input[i] == 0x3c || input[i] == 0x3e || input[i] == 0x5c || input[i] == 0x5e || input[i] == 0x5f || input[i] == 0x60 || input[i] == 0x7b || input[i] == 0x7c || input[i] == 0x7d || input[i] == 0x7e || input[i] == 0x21 || input[i] == 0x23 || input[i] == 0x24 || input[i] == 0x26 || input[i] == 0x27 || input[i] == 0x28 || input[i] == 0x29 || input[i] == 0x2a || input[i] == 0x2b || input[i] == 0x2c || input[i] == 0x2f || input[i] == 0x3a || input[i] == 0x3b || input[i] == 0x3d || input[i] == 0x3f || input[i] == 0x40 || input[i] == 0x5b || input[i] == 0x5d) {
|
|
|
62 |
add_data(&r, "%");
|
|
|
63 |
cbuf[0] = hex[(input[i] >> 4) & 0xf];
|
|
|
64 |
add_data(&r, cbuf);
|
|
|
65 |
cbuf[0] = hex[input[i] & 0xf];
|
|
|
66 |
add_data(&r, cbuf);
|
|
|
67 |
} else {
|
|
|
68 |
cbuf[0] = input[i];
|
|
|
69 |
add_data(&r, cbuf);
|
|
|
70 |
}
|
|
|
71 |
}
|
|
|
72 |
return r;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
char* html_escape(const char* input) {
|
|
|
76 |
char* r = malloc(1);
|
|
|
77 |
r[0] = 0;
|
|
|
78 |
char cbuf[2];
|
|
|
79 |
cbuf[1] = 0;
|
|
|
80 |
int i;
|
|
|
81 |
for(i = 0; input[i] != 0; i++) {
|
|
|
82 |
if(input[i] == '<') {
|
|
|
83 |
add_data(&r, "<");
|
|
|
84 |
} else if(input[i] == '>') {
|
|
|
85 |
add_data(&r, ">");
|
75 |
nishi |
86 |
} else if(input[i] == '&') {
|
|
|
87 |
add_data(&r, "&");
|
11 |
nishi |
88 |
} else {
|
|
|
89 |
cbuf[0] = input[i];
|
|
|
90 |
add_data(&r, cbuf);
|
|
|
91 |
}
|
|
|
92 |
}
|
|
|
93 |
return r;
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
char* html_escape_nl_to_br(const char* input) {
|
|
|
97 |
char* r = malloc(1);
|
|
|
98 |
r[0] = 0;
|
|
|
99 |
char cbuf[2];
|
|
|
100 |
cbuf[1] = 0;
|
|
|
101 |
int i;
|
|
|
102 |
for(i = 0; input[i] != 0; i++) {
|
|
|
103 |
if(input[i] == '<') {
|
|
|
104 |
add_data(&r, "<");
|
|
|
105 |
} else if(input[i] == '>') {
|
|
|
106 |
add_data(&r, ">");
|
|
|
107 |
} else if(input[i] == '\n') {
|
|
|
108 |
add_data(&r, "<br>");
|
|
|
109 |
} else {
|
|
|
110 |
cbuf[0] = input[i];
|
|
|
111 |
add_data(&r, cbuf);
|
|
|
112 |
}
|
|
|
113 |
}
|
|
|
114 |
return r;
|
|
|
115 |
}
|
|
|
116 |
|
54 |
nishi |
117 |
int fcounter = 0;
|
56 |
nishi |
118 |
char* instead_username = NULL;
|
11 |
nishi |
119 |
void list_repo(const char* name, const char* rev) {
|
|
|
120 |
char* showname = html_escape(name);
|
56 |
nishi |
121 |
char* urluser = url_escape(instead_username == NULL ? user : instead_username);
|
11 |
nishi |
122 |
char* urlrepo = url_escape(name);
|
53 |
nishi |
123 |
add_data(&page, "<tr style=\"background-color: #");
|
|
|
124 |
if((fcounter % 2) == 0) {
|
|
|
125 |
add_data(&page, "D2E1C0");
|
|
|
126 |
} else {
|
|
|
127 |
add_data(&page, "FFFFFF");
|
|
|
128 |
}
|
|
|
129 |
fcounter++;
|
|
|
130 |
add_data(&page, "\"><td><a href=\"");
|
11 |
nishi |
131 |
add_data(&page, INSTANCE_ROOT);
|
|
|
132 |
add_data(&page, "/?page=repo&reponame=");
|
|
|
133 |
add_data(&page, urlrepo);
|
|
|
134 |
add_data(&page, "&username=");
|
|
|
135 |
add_data(&page, urluser);
|
|
|
136 |
add_data(&page, "\">");
|
|
|
137 |
add_data(&page, showname);
|
|
|
138 |
add_data(&page, "</a></td>");
|
|
|
139 |
add_data(&page, "<td>");
|
|
|
140 |
add_data(&page, rev);
|
|
|
141 |
add_data(&page, "</td>");
|
|
|
142 |
add_data(&page, "</tr>");
|
|
|
143 |
free(showname);
|
|
|
144 |
free(urluser);
|
|
|
145 |
free(urlrepo);
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
void list_files(const char* pathname) {
|
|
|
149 |
if(fcounter == 0) {
|
|
|
150 |
add_data(&nav, "<li><a href=\"#filelist\">File List</a></li>\n");
|
|
|
151 |
add_data(&page, "<h2 id=\"filelist\">File List</h2>\n");
|
|
|
152 |
add_data(&page, "<tr style=\"background-color: #D2E1F6;\"><th>Name</th><th>Size</th></tr>\n");
|
12 |
nishi |
153 |
char* path = rv_get_query("path");
|
|
|
154 |
if(path == NULL) path = "/";
|
|
|
155 |
if(strcmp(path, "/") != 0) {
|
|
|
156 |
char* query = rv_strdup("?page=repo&reponame=");
|
|
|
157 |
char* esc;
|
|
|
158 |
esc = url_escape(rv_get_query("reponame"));
|
|
|
159 |
add_data(&query, esc);
|
|
|
160 |
free(esc);
|
|
|
161 |
add_data(&query, "&username=");
|
15 |
nishi |
162 |
esc = url_escape(rv_get_query("username"));
|
12 |
nishi |
163 |
add_data(&query, esc);
|
|
|
164 |
free(esc);
|
|
|
165 |
add_data(&query, "&path=");
|
|
|
166 |
|
|
|
167 |
char* urlpath = rv_strdup(path);
|
|
|
168 |
int i;
|
|
|
169 |
int counter = 0;
|
|
|
170 |
int rep = urlpath[strlen(urlpath) - 1] == '/' ? 2 : 1;
|
|
|
171 |
for(i = strlen(urlpath) - 1; i >= 0; i--) {
|
|
|
172 |
char oldc = urlpath[i];
|
|
|
173 |
urlpath[i] = 0;
|
|
|
174 |
if(oldc == '/') {
|
|
|
175 |
counter++;
|
|
|
176 |
if(counter == 2) {
|
|
|
177 |
break;
|
|
|
178 |
}
|
|
|
179 |
}
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
if(strlen(urlpath) == 0) {
|
|
|
183 |
free(urlpath);
|
|
|
184 |
urlpath = rv_strdup("/");
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
esc = url_escape(urlpath);
|
|
|
188 |
add_data(&query, esc);
|
|
|
189 |
free(esc);
|
|
|
190 |
|
|
|
191 |
add_data(&page, "<tr><td><a href=\"");
|
|
|
192 |
add_data(&page, query);
|
|
|
193 |
add_data(&page, "\">../</a></td><td><DIR></td></tr>\n");
|
|
|
194 |
fcounter++;
|
|
|
195 |
free(query);
|
|
|
196 |
}
|
11 |
nishi |
197 |
}
|
|
|
198 |
fcounter++;
|
|
|
199 |
add_data(&page, "<tr style=\"background-color: #");
|
|
|
200 |
if((fcounter % 2) == 0) {
|
|
|
201 |
add_data(&page, "D2E1C0");
|
|
|
202 |
} else {
|
|
|
203 |
add_data(&page, "FFFFFF");
|
|
|
204 |
}
|
|
|
205 |
char* path = rv_get_query("path");
|
|
|
206 |
if(path == NULL) path = "/";
|
|
|
207 |
char* query = rv_strdup("?page=repo&reponame=");
|
|
|
208 |
char* esc;
|
|
|
209 |
esc = url_escape(rv_get_query("reponame"));
|
|
|
210 |
add_data(&query, esc);
|
|
|
211 |
free(esc);
|
|
|
212 |
add_data(&query, "&username=");
|
15 |
nishi |
213 |
esc = url_escape(rv_get_query("username"));
|
11 |
nishi |
214 |
add_data(&query, esc);
|
|
|
215 |
free(esc);
|
|
|
216 |
add_data(&query, "&path=");
|
13 |
nishi |
217 |
char* urlpath = rv_strcat3(path, "/", pathname);
|
11 |
nishi |
218 |
esc = url_escape(urlpath);
|
|
|
219 |
add_data(&query, esc);
|
|
|
220 |
free(esc);
|
|
|
221 |
char* sz = malloc(128);
|
|
|
222 |
sprintf(sz, "%lld", rv_get_filesize(grepouser, urlpath));
|
|
|
223 |
add_data(&page, "\"><td><a href=\"");
|
|
|
224 |
add_data(&page, query);
|
|
|
225 |
add_data(&page, "\">");
|
61 |
nishi |
226 |
esc = html_escape(pathname);
|
|
|
227 |
add_data(&page, esc);
|
|
|
228 |
free(esc);
|
11 |
nishi |
229 |
add_data(&page, "</a></td>\n");
|
|
|
230 |
add_data(&page, "<td>\n");
|
|
|
231 |
if(strcmp(sz, "-1") != 0) {
|
|
|
232 |
add_data(&page, sz);
|
|
|
233 |
} else {
|
|
|
234 |
add_data(&page, "<DIR>");
|
|
|
235 |
}
|
|
|
236 |
add_data(&page, "</td>\n");
|
|
|
237 |
free(sz);
|
|
|
238 |
add_data(&page, "</tr>\n");
|
|
|
239 |
free(query);
|
|
|
240 |
free(urlpath);
|
|
|
241 |
}
|
|
|
242 |
|
39 |
nishi |
243 |
void generate_avatar(void) {
|
|
|
244 |
if(user != NULL) {
|
|
|
245 |
char* tmp = rv_strcat3(AVATAR_ROOT, "/", user);
|
|
|
246 |
char* path = rv_strcat(tmp, ".png");
|
|
|
247 |
free(tmp);
|
|
|
248 |
if(access(path, F_OK) != 0) {
|
|
|
249 |
rv_avatar_generate(path, user);
|
|
|
250 |
}
|
|
|
251 |
free(path);
|
|
|
252 |
}
|
67 |
nishi |
253 |
if(rv_get_query("username") != NULL && rv_has_user(rv_get_query("username"))) {
|
49 |
nishi |
254 |
char* un = rv_get_query("username");
|
|
|
255 |
char* tmp = rv_strcat3(AVATAR_ROOT, "/", un);
|
|
|
256 |
char* path = rv_strcat(tmp, ".png");
|
|
|
257 |
free(tmp);
|
|
|
258 |
if(access(path, F_OK) != 0) {
|
|
|
259 |
rv_avatar_generate(path, un);
|
|
|
260 |
}
|
|
|
261 |
free(path);
|
|
|
262 |
}
|
39 |
nishi |
263 |
}
|
|
|
264 |
|
3 |
nishi |
265 |
void render_page(void) {
|
1 |
nishi |
266 |
rv_load_query('Q');
|
|
|
267 |
char* query = rv_get_query("page");
|
|
|
268 |
if(query == NULL) query = "welcome";
|
|
|
269 |
|
39 |
nishi |
270 |
#ifdef USE_AVATAR
|
|
|
271 |
generate_avatar();
|
|
|
272 |
#endif
|
|
|
273 |
|
3 |
nishi |
274 |
if(strcmp(query, "welcome") == 0) {
|
1 |
nishi |
275 |
title = rv_strdup("Welcome");
|
|
|
276 |
desc = rv_strdup("Welcome to " INSTANCE_NAME ".");
|
|
|
277 |
page = rv_strcat3("Welcome to " INSTANCE_NAME ".<br>This instance is running RepoView version ", rv_get_version(), ".");
|
13 |
nishi |
278 |
#ifdef ALLOW_SIGNUP
|
|
|
279 |
} else if(strcmp(query, "signup") == 0) {
|
|
|
280 |
title = rv_strdup("Signup");
|
|
|
281 |
desc = rv_strdup("You can create your account here.");
|
|
|
282 |
page = rv_strdup("");
|
|
|
283 |
|
|
|
284 |
add_data(&page, "<form action=\"");
|
|
|
285 |
add_data(&page, INSTANCE_ROOT);
|
|
|
286 |
add_data(&page, "/?page=sendsignup\" method=\"POST\">\n");
|
|
|
287 |
add_data(&page, " <table border=\"0\">\n");
|
|
|
288 |
add_data(&page, " <tr>\n");
|
|
|
289 |
add_data(&page, " <th>Username</th>\n");
|
|
|
290 |
add_data(&page, " <td>\n");
|
|
|
291 |
add_data(&page, " <input name=\"username\">\n");
|
|
|
292 |
add_data(&page, " </td>\n");
|
|
|
293 |
add_data(&page, " </tr>\n");
|
|
|
294 |
add_data(&page, " <tr>\n");
|
|
|
295 |
add_data(&page, " <th>Password</th>\n");
|
|
|
296 |
add_data(&page, " <td>\n");
|
|
|
297 |
add_data(&page, " <input name=\"password\" type=\"password\">\n");
|
|
|
298 |
add_data(&page, " </td>\n");
|
|
|
299 |
add_data(&page, " </tr>\n");
|
|
|
300 |
add_data(&page, " </table>\n");
|
|
|
301 |
char cbuf[2];
|
|
|
302 |
cbuf[0] = REPO_USER_DELIM;
|
|
|
303 |
cbuf[1] = 0;
|
|
|
304 |
add_data(&page, "Username cannot contain '<code>");
|
|
|
305 |
add_data(&page, cbuf);
|
43 |
nishi |
306 |
add_data(&page, "</code>'.<br>");
|
13 |
nishi |
307 |
add_data(&page, " <input type=\"submit\" value=\"Signup\">\n");
|
|
|
308 |
add_data(&page, "</form>\n");
|
|
|
309 |
} else if(strcmp(query, "sendsignup") == 0) {
|
|
|
310 |
title = rv_strdup("Signup Result");
|
|
|
311 |
page = rv_strdup("");
|
|
|
312 |
|
|
|
313 |
rv_load_query('P');
|
|
|
314 |
if(user != NULL) {
|
|
|
315 |
page = rv_strdup("It looks like you are already logged in.<br>Want to <a href=\"");
|
|
|
316 |
add_data(&page, INSTANCE_ROOT);
|
|
|
317 |
add_data(&page, "/?page=logout\">log out</a>?\n");
|
|
|
318 |
} else if(rv_get_query("username") == NULL || rv_get_query("password") == NULL) {
|
|
|
319 |
add_data(&page, "Invalid form.\n");
|
|
|
320 |
} else {
|
|
|
321 |
if(rv_has_user(rv_get_query("username"))) {
|
|
|
322 |
add_data(&page, "User already exists.");
|
|
|
323 |
} else {
|
|
|
324 |
if(user != NULL) free(user);
|
|
|
325 |
int i;
|
|
|
326 |
bool reject = false;
|
|
|
327 |
char* name = rv_get_query("username");
|
|
|
328 |
for(i = 0; name[i] != 0; i++) {
|
43 |
nishi |
329 |
if(name[i] == REPO_USER_DELIM || invalid_char(name[i])) {
|
13 |
nishi |
330 |
char cbuf[2];
|
|
|
331 |
cbuf[0] = REPO_USER_DELIM;
|
|
|
332 |
cbuf[1] = 0;
|
|
|
333 |
add_data(&page, "Username cannot contain '<code>");
|
|
|
334 |
add_data(&page, cbuf);
|
|
|
335 |
add_data(&page, "</code>'.");
|
|
|
336 |
reject = true;
|
|
|
337 |
break;
|
|
|
338 |
}
|
|
|
339 |
}
|
|
|
340 |
if(!reject) {
|
|
|
341 |
rv_create_user(rv_get_query("username"), rv_get_query("password"));
|
|
|
342 |
user = rv_strdup(rv_get_query("username"));
|
|
|
343 |
add_data(&page, "Welcome.\n");
|
|
|
344 |
rv_save_login(rv_get_query("username"));
|
|
|
345 |
}
|
|
|
346 |
}
|
|
|
347 |
}
|
|
|
348 |
#endif
|
3 |
nishi |
349 |
} else if(strcmp(query, "login") == 0) {
|
1 |
nishi |
350 |
title = rv_strdup("Login");
|
|
|
351 |
desc = rv_strdup("You can log in to your account here.");
|
|
|
352 |
page = rv_strdup("");
|
|
|
353 |
|
|
|
354 |
add_data(&page, "<form action=\"");
|
|
|
355 |
add_data(&page, INSTANCE_ROOT);
|
|
|
356 |
add_data(&page, "/?page=sendlogin\" method=\"POST\">\n");
|
|
|
357 |
add_data(&page, " <table border=\"0\">\n");
|
|
|
358 |
add_data(&page, " <tr>\n");
|
|
|
359 |
add_data(&page, " <th>Username</th>\n");
|
|
|
360 |
add_data(&page, " <td>\n");
|
|
|
361 |
add_data(&page, " <input name=\"username\">\n");
|
|
|
362 |
add_data(&page, " </td>\n");
|
|
|
363 |
add_data(&page, " </tr>\n");
|
|
|
364 |
add_data(&page, " <tr>\n");
|
|
|
365 |
add_data(&page, " <th>Password</th>\n");
|
|
|
366 |
add_data(&page, " <td>\n");
|
|
|
367 |
add_data(&page, " <input name=\"password\" type=\"password\">\n");
|
|
|
368 |
add_data(&page, " </td>\n");
|
|
|
369 |
add_data(&page, " </tr>\n");
|
|
|
370 |
add_data(&page, " </table>\n");
|
|
|
371 |
add_data(&page, " <input type=\"submit\" value=\"Login\">\n");
|
|
|
372 |
add_data(&page, "</form>\n");
|
3 |
nishi |
373 |
} else if(strcmp(query, "sendlogin") == 0) {
|
1 |
nishi |
374 |
title = rv_strdup("Login Result");
|
|
|
375 |
page = rv_strdup("");
|
|
|
376 |
|
|
|
377 |
rv_load_query('P');
|
11 |
nishi |
378 |
if(user != NULL) {
|
|
|
379 |
page = rv_strdup("It looks like you are already logged in.<br>Want to <a href=\"");
|
|
|
380 |
add_data(&page, INSTANCE_ROOT);
|
13 |
nishi |
381 |
add_data(&page, "/?page=logout\">log out</a>?\n");
|
11 |
nishi |
382 |
} else if(rv_get_query("username") == NULL || rv_get_query("password") == NULL) {
|
5 |
nishi |
383 |
add_data(&page, "Invalid form.\n");
|
3 |
nishi |
384 |
} else {
|
|
|
385 |
if(rv_has_user(rv_get_query("username"))) {
|
5 |
nishi |
386 |
if(rv_check_password(rv_get_query("username"), rv_get_query("password"))) {
|
6 |
nishi |
387 |
if(user != NULL) free(user);
|
|
|
388 |
user = rv_strdup(rv_get_query("username"));
|
5 |
nishi |
389 |
add_data(&page, "Welcome back.\n");
|
|
|
390 |
rv_save_login(rv_get_query("username"));
|
|
|
391 |
} else {
|
|
|
392 |
add_data(&page, "Invalid password.");
|
|
|
393 |
}
|
3 |
nishi |
394 |
} else {
|
5 |
nishi |
395 |
add_data(&page, "User does not exist.");
|
1 |
nishi |
396 |
}
|
|
|
397 |
}
|
7 |
nishi |
398 |
} else if(strcmp(query, "sendlogout") == 0) {
|
|
|
399 |
title = rv_strdup("Logout Result");
|
|
|
400 |
page = rv_strdup("");
|
|
|
401 |
if(user == NULL) {
|
|
|
402 |
add_data(&page, "You were not logged in.\n");
|
|
|
403 |
} else {
|
|
|
404 |
rv_logout();
|
|
|
405 |
add_data(&page, "Goodbye.\n");
|
|
|
406 |
free(user);
|
|
|
407 |
user = NULL;
|
|
|
408 |
}
|
27 |
nishi |
409 |
#ifdef USE_MYPAGE
|
6 |
nishi |
410 |
} else if(strcmp(query, "mypage") == 0) {
|
|
|
411 |
title = rv_strdup("My Page");
|
|
|
412 |
desc = rv_strdup("You manage your information here.");
|
|
|
413 |
if(user == NULL) {
|
|
|
414 |
page = rv_strdup("It looks like you are not logged in.<br>Want to <a href=\"");
|
|
|
415 |
add_data(&page, INSTANCE_ROOT);
|
|
|
416 |
add_data(&page, "/?page=login\">log in</a>?\n");
|
39 |
nishi |
417 |
} else {
|
|
|
418 |
page = rv_strdup("");
|
43 |
nishi |
419 |
nav = rv_strdup("");
|
|
|
420 |
add_data(&nav, "<li><a href=\"#youricon\">Your Icon</a></li>\n");
|
|
|
421 |
add_data(&nav, "<li><a href=\"#bio\">Bio</a></li>\n");
|
|
|
422 |
add_data(&page, "<form action=\"");
|
|
|
423 |
add_data(&page, INSTANCE_ROOT);
|
|
|
424 |
add_data(&page, "/?page=upload\" method=\"POST\" enctype=\"multipart/form-data\">\n");
|
|
|
425 |
add_data(&page, " <h2 id=\"youricon\">Your Icon</h2>\n");
|
|
|
426 |
add_data(&page, " <a href=\"");
|
39 |
nishi |
427 |
add_data(&page, WWW_AVATAR_ROOT);
|
|
|
428 |
add_data(&page, "/");
|
|
|
429 |
add_data(&page, user);
|
|
|
430 |
add_data(&page, ".png\"><img src=\"");
|
|
|
431 |
add_data(&page, WWW_AVATAR_ROOT);
|
|
|
432 |
add_data(&page, "/");
|
|
|
433 |
add_data(&page, user);
|
42 |
nishi |
434 |
add_data(&page, ".png");
|
43 |
nishi |
435 |
add_data(&page, "\" alt=\"Your Icon\" width=\"50%\"></a><br>");
|
39 |
nishi |
436 |
add_data(&page, " <input type=\"file\" name=\"pfp\">\n");
|
43 |
nishi |
437 |
add_data(&page, " <h2 id=\"bio\">Bio</h2>\n");
|
|
|
438 |
add_data(&page, " <textarea name=\"bio\" style=\"width: 100%;resize: none;height: 128px;\">\n");
|
|
|
439 |
char* path = rv_strcat3(BIO_ROOT, "/", user);
|
|
|
440 |
FILE* f = fopen(path, "r");
|
|
|
441 |
if(f != NULL) {
|
|
|
442 |
struct stat s;
|
|
|
443 |
stat(path, &s);
|
|
|
444 |
char* biobuf = malloc(s.st_size + 1);
|
|
|
445 |
fread(biobuf, 1, s.st_size, f);
|
|
|
446 |
biobuf[s.st_size] = 0;
|
|
|
447 |
|
|
|
448 |
char* esc = html_escape(biobuf);
|
|
|
449 |
add_data(&page, esc);
|
|
|
450 |
free(esc);
|
|
|
451 |
|
|
|
452 |
free(biobuf);
|
|
|
453 |
fclose(f);
|
|
|
454 |
}
|
|
|
455 |
free(path);
|
|
|
456 |
add_data(&page, "</textarea>\n");
|
|
|
457 |
add_data(&page, " <input type=\"submit\" value=\"Send\">\n");
|
39 |
nishi |
458 |
add_data(&page, "</form>\n");
|
6 |
nishi |
459 |
}
|
27 |
nishi |
460 |
#endif
|
42 |
nishi |
461 |
#ifdef USE_AVATAR
|
43 |
nishi |
462 |
} else if(strcmp(query, "upload") == 0) {
|
|
|
463 |
title = rv_strdup("Uploading My Page Result");
|
42 |
nishi |
464 |
page = rv_strdup("");
|
|
|
465 |
if(user == NULL) {
|
|
|
466 |
add_data(&page, "It looks like you are not logged in.<br>Want to <a href=\"");
|
|
|
467 |
add_data(&page, INSTANCE_ROOT);
|
|
|
468 |
add_data(&page, "/?page=login\">log in</a>?\n");
|
|
|
469 |
} else {
|
|
|
470 |
struct multipart_entry* entry = rv_get_multipart("pfp");
|
43 |
nishi |
471 |
if(entry != NULL && entry->length > 0) {
|
|
|
472 |
char* tmp = rv_strcat3(AVATAR_ROOT, "/", user);
|
|
|
473 |
char* path = rv_strcat(tmp, ".tmp");
|
|
|
474 |
char* outpath = rv_strcat(tmp, ".png");
|
|
|
475 |
free(tmp);
|
|
|
476 |
FILE* f = fopen(path, "wb");
|
|
|
477 |
fwrite(entry->data, 1, entry->length, f);
|
|
|
478 |
fclose(f);
|
|
|
479 |
char* reason;
|
|
|
480 |
if(rv_resize_picture(path, outpath, &reason)) {
|
50 |
nishi |
481 |
add_data(&page, "Uploaded the profile picture successfully.<br>\n");
|
43 |
nishi |
482 |
} else {
|
|
|
483 |
add_data(&page, "Failed to upload the profile picture.<br><code>\n");
|
|
|
484 |
char* esc = html_escape(reason);
|
|
|
485 |
add_data(&page, esc);
|
|
|
486 |
free(esc);
|
|
|
487 |
add_data(&page, "</code>\n");
|
|
|
488 |
free(reason);
|
|
|
489 |
}
|
|
|
490 |
free(path);
|
|
|
491 |
free(outpath);
|
42 |
nishi |
492 |
}
|
43 |
nishi |
493 |
entry = rv_get_multipart("bio");
|
|
|
494 |
if(entry != NULL) {
|
|
|
495 |
char* path = rv_strcat3(BIO_ROOT, "/", user);
|
|
|
496 |
FILE* f = fopen(path, "w");
|
|
|
497 |
fwrite(entry->data, 1, entry->length, f);
|
|
|
498 |
fclose(f);
|
|
|
499 |
free(path);
|
50 |
nishi |
500 |
add_data(&page, "Uploaded the bio successfully.<br>\n");
|
43 |
nishi |
501 |
}
|
42 |
nishi |
502 |
}
|
|
|
503 |
#endif
|
9 |
nishi |
504 |
} else if(strcmp(query, "myrepo") == 0) {
|
|
|
505 |
title = rv_strdup("My Repositories");
|
|
|
506 |
desc = rv_strdup("You manage your repositories here.");
|
|
|
507 |
if(user == NULL) {
|
|
|
508 |
page = rv_strdup("It looks like you are not logged in.<br>Want to <a href=\"");
|
|
|
509 |
add_data(&page, INSTANCE_ROOT);
|
|
|
510 |
add_data(&page, "/?page=login\">log in</a>?\n");
|
10 |
nishi |
511 |
} else {
|
11 |
nishi |
512 |
char cbuf[2];
|
|
|
513 |
cbuf[0] = REPO_USER_DELIM;
|
|
|
514 |
cbuf[1] = 0;
|
10 |
nishi |
515 |
nav = rv_strdup("");
|
|
|
516 |
add_data(&nav, "<li><a href=\"#createrepo\">Create a repository</a></li>\n");
|
|
|
517 |
add_data(&nav, "<li><a href=\"#repolist\">Repository List</a></li>\n");
|
|
|
518 |
page = rv_strdup("");
|
|
|
519 |
add_data(&page, "<h2 id=\"createrepo\">Create a repository</h2>\n");
|
|
|
520 |
add_data(&page, "<form action=\"");
|
|
|
521 |
add_data(&page, INSTANCE_ROOT);
|
|
|
522 |
add_data(&page, "/?page=createrepo\" method=\"POST\">\n");
|
|
|
523 |
add_data(&page, " <table border=\"0\">\n");
|
|
|
524 |
add_data(&page, " <tr>\n");
|
|
|
525 |
add_data(&page, " <th>Repository name</th>\n");
|
|
|
526 |
add_data(&page, " <td>\n");
|
|
|
527 |
add_data(&page, " <input name=\"name\">\n");
|
|
|
528 |
add_data(&page, " </td>\n");
|
|
|
529 |
add_data(&page, " <td><input type=\"submit\" value=\"Create\"></td>\n");
|
|
|
530 |
add_data(&page, " </tr>\n");
|
|
|
531 |
add_data(&page, " </table>\n");
|
11 |
nishi |
532 |
add_data(&page, "Repository name cannot contain '<code>");
|
|
|
533 |
add_data(&page, cbuf);
|
43 |
nishi |
534 |
add_data(&page, "</code>'.");
|
10 |
nishi |
535 |
add_data(&page, "</form>\n");
|
|
|
536 |
add_data(&page, "<h2 id=\"repolist\">Repository List</h2>\n");
|
57 |
nishi |
537 |
add_data(&page, "<table border=\"0\" style=\"width: 100%;\">\n");
|
53 |
nishi |
538 |
add_data(&page, "<tr style=\"background-color: #D2E1F6;\"><th>Repository name</th><th>Revision</th></tr>\n");
|
|
|
539 |
fcounter = 0;
|
11 |
nishi |
540 |
rv_repo_list(user, list_repo);
|
|
|
541 |
add_data(&page, "</table>\n");
|
9 |
nishi |
542 |
}
|
11 |
nishi |
543 |
} else if(strcmp(query, "createrepo") == 0) {
|
|
|
544 |
title = rv_strdup("Creating Repository Result");
|
|
|
545 |
page = rv_strdup("");
|
|
|
546 |
|
|
|
547 |
rv_load_query('P');
|
|
|
548 |
if(user == NULL) {
|
|
|
549 |
page = rv_strdup("It looks like you are not logged in.<br>Want to <a href=\"");
|
|
|
550 |
add_data(&page, INSTANCE_ROOT);
|
|
|
551 |
add_data(&page, "/?page=login\">log in</a>?\n");
|
|
|
552 |
} else if(rv_get_query("name") == NULL) {
|
|
|
553 |
add_data(&page, "Invalid form.\n");
|
|
|
554 |
} else {
|
|
|
555 |
int i;
|
|
|
556 |
bool reject = false;
|
|
|
557 |
char* name = rv_get_query("name");
|
|
|
558 |
for(i = 0; name[i] != 0; i++) {
|
43 |
nishi |
559 |
if(name[i] == REPO_USER_DELIM || invalid_char(name[i])) {
|
11 |
nishi |
560 |
char cbuf[2];
|
|
|
561 |
cbuf[0] = REPO_USER_DELIM;
|
|
|
562 |
cbuf[1] = 0;
|
|
|
563 |
add_data(&page, "Repository name cannot contain '<code>");
|
|
|
564 |
add_data(&page, cbuf);
|
|
|
565 |
add_data(&page, "</code>'.");
|
|
|
566 |
reject = true;
|
|
|
567 |
break;
|
|
|
568 |
}
|
|
|
569 |
}
|
|
|
570 |
if(!reject) {
|
|
|
571 |
char* ru = rv_construct_repouser(name, user);
|
|
|
572 |
if(rv_repo_exists(ru)) {
|
|
|
573 |
add_data(&page, "Repository already exists.");
|
|
|
574 |
} else {
|
|
|
575 |
char* esc;
|
|
|
576 |
rv_create_repo(ru);
|
|
|
577 |
add_data(&page, "Repository has been created.<br>\n");
|
|
|
578 |
add_data(&page, "<a href=\"");
|
|
|
579 |
add_data(&page, INSTANCE_ROOT);
|
|
|
580 |
esc = url_escape(name);
|
|
|
581 |
add_data(&page, "/?page=repo&reponame=");
|
|
|
582 |
add_data(&page, esc);
|
|
|
583 |
free(esc);
|
|
|
584 |
esc = url_escape(user);
|
|
|
585 |
add_data(&page, "&username=");
|
|
|
586 |
add_data(&page, esc);
|
|
|
587 |
free(esc);
|
|
|
588 |
add_data(&page, "\">Go to the repository</a>.\n");
|
|
|
589 |
}
|
|
|
590 |
free(ru);
|
|
|
591 |
}
|
|
|
592 |
}
|
7 |
nishi |
593 |
} else if(strcmp(query, "logout") == 0) {
|
|
|
594 |
title = rv_strdup("Logout");
|
|
|
595 |
desc = rv_strdup("You can log out from your account here.");
|
|
|
596 |
if(user == NULL) {
|
|
|
597 |
page = rv_strdup("It looks like you are not logged in.<br>Want to <a href=\"");
|
|
|
598 |
add_data(&page, INSTANCE_ROOT);
|
|
|
599 |
add_data(&page, "/?page=login\">log in</a>?\n");
|
|
|
600 |
} else {
|
|
|
601 |
page = rv_strdup("");
|
|
|
602 |
add_data(&page, "Are you sure you want to log out?\n");
|
|
|
603 |
add_data(&page, "<form method=\"POST\" action=\"");
|
|
|
604 |
add_data(&page, INSTANCE_ROOT);
|
|
|
605 |
add_data(&page, "/?page=sendlogout\">\n");
|
|
|
606 |
add_data(&page, " <input type=\"submit\" value=\"Yes\">\n");
|
|
|
607 |
add_data(&page, "</form>\n");
|
|
|
608 |
}
|
11 |
nishi |
609 |
} else if(strcmp(query, "repo") == 0) {
|
|
|
610 |
title = rv_strdup("Repository");
|
|
|
611 |
desc = rv_strdup("");
|
|
|
612 |
page = rv_strdup("");
|
|
|
613 |
nav = rv_strdup("");
|
15 |
nishi |
614 |
rv_load_query('Q');
|
11 |
nishi |
615 |
if(rv_get_query("username") == NULL || rv_get_query("reponame") == NULL) {
|
|
|
616 |
add_data(&page, "Required parameters not set.");
|
|
|
617 |
} else {
|
15 |
nishi |
618 |
char* ruser = rv_get_query("username");
|
11 |
nishi |
619 |
char* repo = rv_get_query("reponame");
|
15 |
nishi |
620 |
char* repouser = rv_construct_repouser(repo, ruser);
|
11 |
nishi |
621 |
grepouser = repouser;
|
|
|
622 |
if(rv_repo_exists(repouser)) {
|
15 |
nishi |
623 |
char* showuser = html_escape(ruser);
|
11 |
nishi |
624 |
char* showrepo = html_escape(repo);
|
|
|
625 |
char* showreadme = rv_get_readme(repouser);
|
|
|
626 |
desc = html_escape_nl_to_br(showreadme);
|
|
|
627 |
add_data(&title, " - ");
|
63 |
nishi |
628 |
#ifdef USE_MYPAGE
|
|
|
629 |
add_data(&title, "<a href=\"");
|
|
|
630 |
add_data(&title, INSTANCE_ROOT);
|
|
|
631 |
add_data(&title, "/?page=person&username=");
|
|
|
632 |
char* esc = url_escape(ruser);
|
|
|
633 |
add_data(&title, esc);
|
|
|
634 |
free(esc);
|
|
|
635 |
add_data(&title, "\">");
|
|
|
636 |
#endif
|
32 |
nishi |
637 |
add_data(&title, showuser);
|
63 |
nishi |
638 |
#ifdef USE_MYPAGE
|
|
|
639 |
add_data(&title, "</a>");
|
|
|
640 |
#endif
|
32 |
nishi |
641 |
add_data(&title, "/");
|
11 |
nishi |
642 |
add_data(&title, showrepo);
|
|
|
643 |
free(showuser);
|
|
|
644 |
free(showrepo);
|
|
|
645 |
free(showreadme);
|
15 |
nishi |
646 |
#ifdef WWW_SVN_ROOT
|
16 |
nishi |
647 |
add_data(&nav, "<li><a href=\"#repoinfo\">Info</a></li>\n");
|
15 |
nishi |
648 |
add_data(&page, "<h2 id=\"repoinfo\">Info</h2>\n");
|
|
|
649 |
add_data(&page, "<a href=\"");
|
|
|
650 |
add_data(&page, WWW_SVN_ROOT);
|
|
|
651 |
add_data(&page, "/");
|
|
|
652 |
char* escru = url_escape(repouser);
|
|
|
653 |
add_data(&page, escru);
|
|
|
654 |
free(escru);
|
|
|
655 |
add_data(&page, "\">Raw repository</a>");
|
|
|
656 |
#endif
|
11 |
nishi |
657 |
|
|
|
658 |
int isdir;
|
|
|
659 |
char* path = rv_get_query("path");
|
|
|
660 |
if(path == NULL) path = "/";
|
|
|
661 |
fcounter = 0;
|
|
|
662 |
add_data(&page, "<table border=\"0\" style=\"width: 100%;\">");
|
15 |
nishi |
663 |
bool rej = false;
|
11 |
nishi |
664 |
if(!rv_get_list(repouser, path, list_files, &isdir)) {
|
|
|
665 |
add_data(&page, "<tr><td>Path not found.</td></tr>\n");
|
15 |
nishi |
666 |
rej = true;
|
11 |
nishi |
667 |
}
|
|
|
668 |
add_data(&page, "</table>");
|
15 |
nishi |
669 |
if(isdir == 0 && !rej) {
|
11 |
nishi |
670 |
add_data(&nav, "<li><a href=\"#filecontent\">Content</a></li>");
|
|
|
671 |
add_data(&page, "<h2 id=\"filecontent\">Content</h2>\n");
|
|
|
672 |
add_data(&page, "<pre class=\"codeblock\"><code>");
|
13 |
nishi |
673 |
#ifdef USE_ENSCRIPT
|
|
|
674 |
int i;
|
|
|
675 |
char* ext = NULL;
|
|
|
676 |
for(i = strlen(path) - 1; i >= 0; i--) {
|
|
|
677 |
if(path[i] == '.') {
|
|
|
678 |
ext = path + i + 1;
|
|
|
679 |
break;
|
|
|
680 |
}
|
|
|
681 |
}
|
|
|
682 |
char* data = rv_enscript(repouser, path, ext);
|
|
|
683 |
if(data != NULL) {
|
|
|
684 |
add_data(&page, data);
|
|
|
685 |
free(data);
|
|
|
686 |
} else {
|
|
|
687 |
data = rv_read_file(repouser, path);
|
|
|
688 |
if(data != NULL) {
|
|
|
689 |
char* esc = html_escape_nl_to_br(data);
|
|
|
690 |
add_data(&page, esc);
|
|
|
691 |
free(esc);
|
|
|
692 |
free(data);
|
|
|
693 |
} else {
|
|
|
694 |
add_data(&page, "Cannot open the file.\n");
|
|
|
695 |
}
|
|
|
696 |
}
|
|
|
697 |
#else
|
11 |
nishi |
698 |
char* data = rv_read_file(repouser, path);
|
12 |
nishi |
699 |
if(data != NULL) {
|
|
|
700 |
char* esc = html_escape_nl_to_br(data);
|
|
|
701 |
add_data(&page, esc);
|
|
|
702 |
free(esc);
|
|
|
703 |
free(data);
|
|
|
704 |
} else {
|
|
|
705 |
add_data(&page, "Cannot open the file.\n");
|
|
|
706 |
}
|
13 |
nishi |
707 |
#endif
|
11 |
nishi |
708 |
add_data(&page, "</code></pre>");
|
|
|
709 |
}
|
15 |
nishi |
710 |
if(user != NULL && strcmp(user, ruser) == 0) {
|
|
|
711 |
char* esc;
|
|
|
712 |
add_data(&nav, "<li><a href=\"#managerepo\">Manage The Repository</a></li>\n");
|
|
|
713 |
add_data(&page, "<h2 id=\"managerepo\">Manage The Repository</h2>\n");
|
|
|
714 |
add_data(&page, "<form action=\"");
|
|
|
715 |
add_data(&page, INSTANCE_ROOT);
|
|
|
716 |
add_data(&page, "/?page=sendmanrepo&username=");
|
|
|
717 |
esc = url_escape(ruser);
|
|
|
718 |
add_data(&page, esc);
|
|
|
719 |
free(esc);
|
|
|
720 |
add_data(&page, "&reponame=");
|
21 |
nishi |
721 |
esc = url_escape(repo);
|
15 |
nishi |
722 |
add_data(&page, esc);
|
|
|
723 |
free(esc);
|
|
|
724 |
add_data(&page, "\" method=\"POST\">\n");
|
|
|
725 |
add_data(&page, "<table border=\"0\" style=\"width: 100%;\">\n");
|
|
|
726 |
add_data(&page, " <tr>\n");
|
|
|
727 |
add_data(&page, " <th>README</th>\n");
|
|
|
728 |
add_data(&page, " <td>\n");
|
|
|
729 |
add_data(&page, " <textarea name=\"readme\" style=\"width: 100%;resize: none;height: 128px;\">\n");
|
|
|
730 |
char* readme = rv_get_readme(repouser);
|
|
|
731 |
esc = html_escape(readme);
|
|
|
732 |
add_data(&page, esc);
|
|
|
733 |
free(esc);
|
|
|
734 |
free(readme);
|
43 |
nishi |
735 |
add_data(&page, "</textarea>\n");
|
15 |
nishi |
736 |
add_data(&page, " </td>\n");
|
|
|
737 |
add_data(&page, " </tr>\n");
|
|
|
738 |
add_data(&page, "</table>\n");
|
|
|
739 |
add_data(&page, "<input type=\"submit\" value=\"Send\">\n");
|
|
|
740 |
add_data(&page, "</form>\n");
|
|
|
741 |
add_data(&page, "<a href=\"");
|
|
|
742 |
add_data(&page, INSTANCE_ROOT);
|
|
|
743 |
add_data(&page, "/?page=deleterepo&username=");
|
|
|
744 |
esc = url_escape(ruser);
|
|
|
745 |
add_data(&page, esc);
|
|
|
746 |
free(esc);
|
|
|
747 |
add_data(&page, "&reponame=");
|
|
|
748 |
esc = url_escape(ruser);
|
|
|
749 |
add_data(&page, esc);
|
|
|
750 |
free(esc);
|
|
|
751 |
add_data(&page, "\">\n");
|
|
|
752 |
add_data(&page, "Delete repository\n");
|
|
|
753 |
add_data(&page, "</a>\n");
|
|
|
754 |
}
|
11 |
nishi |
755 |
} else {
|
|
|
756 |
add_data(&page, "Repository does not exist.\n");
|
|
|
757 |
}
|
|
|
758 |
free(repouser);
|
|
|
759 |
}
|
15 |
nishi |
760 |
} else if(strcmp(query, "deleterepo") == 0) {
|
|
|
761 |
title = rv_strdup("Delete The Repository");
|
|
|
762 |
page = rv_strdup("");
|
|
|
763 |
|
|
|
764 |
rv_load_query('Q');
|
|
|
765 |
if(user == NULL) {
|
|
|
766 |
add_data(&page, "It looks like you are not logged in.<br>Want to <a href=\"");
|
|
|
767 |
add_data(&page, INSTANCE_ROOT);
|
|
|
768 |
add_data(&page, "/?page=login\">log in</a>?\n");
|
|
|
769 |
} else if(rv_get_query("username") == NULL || rv_get_query("reponame") == NULL) {
|
|
|
770 |
add_data(&page, "Invalid Form.\n");
|
|
|
771 |
} else {
|
|
|
772 |
char* esc;
|
|
|
773 |
add_data(&page, "Are you sure you want to delete the repository?\n");
|
|
|
774 |
add_data(&page, "<form method=\"POST\" action=\"");
|
|
|
775 |
add_data(&page, INSTANCE_ROOT);
|
|
|
776 |
add_data(&page, "/?page=senddeleterepo&username=");
|
|
|
777 |
esc = url_escape(rv_get_query("username"));
|
|
|
778 |
add_data(&page, esc);
|
|
|
779 |
free(esc);
|
|
|
780 |
add_data(&page, "&reponame=");
|
|
|
781 |
esc = url_escape(rv_get_query("reponame"));
|
|
|
782 |
add_data(&page, esc);
|
|
|
783 |
free(esc);
|
|
|
784 |
add_data(&page, "\">");
|
|
|
785 |
add_data(&page, " <input type=\"submit\" value=\"Yes\">\n");
|
|
|
786 |
add_data(&page, "</form>\n");
|
|
|
787 |
}
|
|
|
788 |
} else if(strcmp(query, "senddeleterepo") == 0) {
|
|
|
789 |
title = rv_strdup("Deleting Repository Result");
|
|
|
790 |
page = rv_strdup("");
|
|
|
791 |
|
|
|
792 |
rv_load_query('Q');
|
|
|
793 |
if(user == NULL) {
|
|
|
794 |
add_data(&page, "It looks like you are not logged in.<br>Want to <a href=\"");
|
|
|
795 |
add_data(&page, INSTANCE_ROOT);
|
|
|
796 |
add_data(&page, "/?page=login\">log in</a>?\n");
|
|
|
797 |
} else if(rv_get_query("username") == NULL || rv_get_query("reponame") == NULL) {
|
|
|
798 |
add_data(&page, "Invalid Form.\n");
|
|
|
799 |
} else if(strcmp(rv_get_query("username"), user) != 0) {
|
|
|
800 |
add_data(&page, "You are not the owner of the repository.\n");
|
|
|
801 |
} else {
|
|
|
802 |
char* repouser = rv_construct_repouser(rv_get_query("reponame"), rv_get_query("username"));
|
|
|
803 |
if(rv_repo_exists(repouser)) {
|
|
|
804 |
rv_remove_repo(repouser);
|
|
|
805 |
add_data(&page, "Deleted the repository successfully.<br>\n");
|
|
|
806 |
} else {
|
|
|
807 |
add_data(&page, "Repository does not exist.<br>\n");
|
|
|
808 |
}
|
|
|
809 |
}
|
43 |
nishi |
810 |
} else if(strcmp(query, "person") == 0) {
|
|
|
811 |
title = rv_strdup("Person");
|
|
|
812 |
page = rv_strdup("");
|
58 |
nishi |
813 |
nav = rv_strdup("");
|
43 |
nishi |
814 |
|
|
|
815 |
rv_load_query('Q');
|
|
|
816 |
if(rv_get_query("username") == NULL) {
|
|
|
817 |
add_data(&page, "Invalid Form.\n");
|
|
|
818 |
} else {
|
|
|
819 |
if(rv_has_user(rv_get_query("username"))) {
|
59 |
nishi |
820 |
add_data(&nav, "<li><a href=\"#repolist\">Repository List</a></li>");
|
43 |
nishi |
821 |
add_data(&title, " - ");
|
|
|
822 |
add_data(&title, rv_get_query("username"));
|
|
|
823 |
char* path = rv_strcat3(BIO_ROOT, "/", rv_get_query("username"));
|
|
|
824 |
FILE* f = fopen(path, "r");
|
|
|
825 |
if(f != NULL) {
|
|
|
826 |
struct stat s;
|
|
|
827 |
stat(path, &s);
|
|
|
828 |
char* buf = malloc(s.st_size + 1);
|
|
|
829 |
fread(buf, 1, s.st_size, f);
|
|
|
830 |
buf[s.st_size] = 0;
|
|
|
831 |
|
|
|
832 |
desc = html_escape_nl_to_br(buf);
|
|
|
833 |
|
|
|
834 |
fclose(f);
|
|
|
835 |
}
|
48 |
nishi |
836 |
|
|
|
837 |
char* tmp = rv_strcat3(WWW_AVATAR_ROOT, "/", rv_get_query("username"));
|
|
|
838 |
logopath = rv_strcat(tmp, ".png");
|
|
|
839 |
free(tmp);
|
|
|
840 |
|
43 |
nishi |
841 |
free(path);
|
52 |
nishi |
842 |
|
|
|
843 |
add_data(&page, "<h2 id=\"repolist\">Repository List</h2>\n");
|
57 |
nishi |
844 |
add_data(&page, "<table border=\"0\" style=\"width: 100%;\">\n");
|
53 |
nishi |
845 |
add_data(&page, "<tr style=\"background-color: #D2E1F6;\"><th>Repository name</th><th>Revision</th></tr>\n");
|
55 |
nishi |
846 |
fcounter = 0;
|
56 |
nishi |
847 |
instead_username = rv_get_query("username");
|
52 |
nishi |
848 |
rv_repo_list(rv_get_query("username"), list_repo);
|
60 |
nishi |
849 |
instead_username = NULL;
|
52 |
nishi |
850 |
add_data(&page, "</table>\n");
|
43 |
nishi |
851 |
} else {
|
|
|
852 |
add_data(&page, "User does not exist.\n");
|
|
|
853 |
}
|
|
|
854 |
}
|
15 |
nishi |
855 |
} else if(strcmp(query, "sendmanrepo") == 0) {
|
|
|
856 |
title = rv_strdup("Modifying Repository Result");
|
|
|
857 |
page = rv_strdup("");
|
|
|
858 |
|
|
|
859 |
rv_load_query('Q');
|
|
|
860 |
if(user == NULL) {
|
|
|
861 |
add_data(&page, "It looks like you are not logged in.<br>Want to <a href=\"");
|
|
|
862 |
add_data(&page, INSTANCE_ROOT);
|
|
|
863 |
add_data(&page, "/?page=login\">log in</a>?\n");
|
|
|
864 |
} else if(rv_get_query("username") == NULL || rv_get_query("reponame") == NULL) {
|
|
|
865 |
add_data(&page, "Invalid Form.\n");
|
|
|
866 |
} else if(strcmp(rv_get_query("username"), user) != 0) {
|
|
|
867 |
add_data(&page, "You are not the owner of the repository.\n");
|
|
|
868 |
} else {
|
|
|
869 |
char* esc;
|
|
|
870 |
rv_load_query('P');
|
|
|
871 |
char* readme = rv_get_query("readme");
|
|
|
872 |
if(readme != NULL) {
|
|
|
873 |
rv_load_query('Q');
|
|
|
874 |
char* name = rv_construct_repouser(rv_get_query("reponame"), rv_get_query("username"));
|
|
|
875 |
rv_set_readme(name, readme);
|
|
|
876 |
free(name);
|
|
|
877 |
}
|
|
|
878 |
rv_load_query('Q');
|
|
|
879 |
add_data(&page, "Modified the repository successfully.<br>\n");
|
|
|
880 |
add_data(&page, "<a href=\"");
|
|
|
881 |
add_data(&page, INSTANCE_ROOT);
|
|
|
882 |
add_data(&page, "?page=repo&username=");
|
|
|
883 |
esc = url_escape(rv_get_query("username"));
|
|
|
884 |
add_data(&page, esc);
|
|
|
885 |
free(esc);
|
|
|
886 |
add_data(&page, "&reponame=");
|
|
|
887 |
esc = url_escape(rv_get_query("reponame"));
|
|
|
888 |
add_data(&page, esc);
|
|
|
889 |
free(esc);
|
|
|
890 |
add_data(&page, "\">Go back to the repository</a>.\n");
|
|
|
891 |
}
|
1 |
nishi |
892 |
}
|
|
|
893 |
|
|
|
894 |
if(title == NULL) title = rv_strdup("");
|
|
|
895 |
if(desc == NULL) desc = rv_strdup("");
|
|
|
896 |
if(page == NULL) page = rv_strdup("");
|
10 |
nishi |
897 |
if(nav == NULL) nav = rv_strdup("");
|
39 |
nishi |
898 |
|
|
|
899 |
#ifdef USE_AVATAR
|
|
|
900 |
generate_avatar();
|
|
|
901 |
#endif
|
|
|
902 |
|
1 |
nishi |
903 |
render_stuff();
|
15 |
nishi |
904 |
freeall:
|
1 |
nishi |
905 |
free(page);
|
|
|
906 |
free(desc);
|
|
|
907 |
free(title);
|
10 |
nishi |
908 |
free(nav);
|
46 |
nishi |
909 |
if(logopath != NULL) free(logopath);
|
1 |
nishi |
910 |
}
|
|
|
911 |
|
3 |
nishi |
912 |
char* escape(const char* str) {
|
1 |
nishi |
913 |
char* r = malloc(1);
|
|
|
914 |
r[0] = 0;
|
|
|
915 |
char cbuf[2];
|
|
|
916 |
cbuf[1] = 0;
|
|
|
917 |
int i;
|
3 |
nishi |
918 |
for(i = 0; str[i] != 0; i++) {
|
|
|
919 |
if(str[i] == '<') {
|
1 |
nishi |
920 |
char* tmp = r;
|
|
|
921 |
r = rv_strcat(tmp, "<");
|
|
|
922 |
free(tmp);
|
3 |
nishi |
923 |
} else if(str[i] == '>') {
|
1 |
nishi |
924 |
char* tmp = r;
|
|
|
925 |
r = rv_strcat(tmp, ">");
|
|
|
926 |
free(tmp);
|
3 |
nishi |
927 |
} else {
|
1 |
nishi |
928 |
cbuf[0] = str[i];
|
|
|
929 |
char* tmp = r;
|
|
|
930 |
r = rv_strcat(tmp, cbuf);
|
|
|
931 |
free(tmp);
|
|
|
932 |
}
|
|
|
933 |
}
|
|
|
934 |
return r;
|
|
|
935 |
}
|
|
|
936 |
|
3 |
nishi |
937 |
void render_stuff(void) {
|
1 |
nishi |
938 |
char* escaped;
|
70 |
nishi |
939 |
char cbuf[2];
|
|
|
940 |
cbuf[1] = 0;
|
1 |
nishi |
941 |
add_data(&buffer, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n");
|
|
|
942 |
add_data(&buffer, "<html>\n");
|
|
|
943 |
add_data(&buffer, " <head>\n");
|
|
|
944 |
add_data(&buffer, " <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">\n");
|
|
|
945 |
add_data(&buffer, " <title>");
|
|
|
946 |
add_data(&buffer, INSTANCE_NAME);
|
|
|
947 |
add_data(&buffer, " - ");
|
70 |
nishi |
948 |
int i;
|
|
|
949 |
bool br = false;
|
|
|
950 |
for(i = 0; title[i] != 0; i++){
|
|
|
951 |
if(title[i] == '<'){
|
|
|
952 |
br = true;
|
|
|
953 |
}else if(title[i] == '>'){
|
|
|
954 |
br = false;
|
|
|
955 |
}else if(!br){
|
|
|
956 |
cbuf[0] = title[i];
|
|
|
957 |
add_data(&buffer, cbuf);
|
|
|
958 |
}
|
|
|
959 |
}
|
1 |
nishi |
960 |
add_data(&buffer, "</title>\n");
|
|
|
961 |
add_data(&buffer, " <style type=\"text/css\">\n");
|
|
|
962 |
add_data(&buffer, "* {\n");
|
|
|
963 |
add_data(&buffer, " padding: 0;\n");
|
|
|
964 |
add_data(&buffer, " margin: 0;\n");
|
|
|
965 |
add_data(&buffer, "}\n");
|
|
|
966 |
add_data(&buffer, "li {\n");
|
|
|
967 |
add_data(&buffer, " list-style: outside;\n");
|
|
|
968 |
add_data(&buffer, " margin-left: 1.25em;\n");
|
|
|
969 |
add_data(&buffer, "}\n");
|
|
|
970 |
add_data(&buffer, "a {\n");
|
|
|
971 |
add_data(&buffer, " text-decoration: none;\n");
|
|
|
972 |
add_data(&buffer, "}\n");
|
|
|
973 |
add_data(&buffer, "#nav div {\n");
|
|
|
974 |
add_data(&buffer, " float: left;\n");
|
|
|
975 |
add_data(&buffer, " margin: 0 0;\n");
|
|
|
976 |
add_data(&buffer, " padding-left: 0;\n");
|
9 |
nishi |
977 |
add_data(&buffer, " padding-right: 25px;\n");
|
1 |
nishi |
978 |
add_data(&buffer, " padding-top: 7px;\n");
|
|
|
979 |
add_data(&buffer, "}\n");
|
11 |
nishi |
980 |
add_data(&buffer, "th,td {\n");
|
|
|
981 |
add_data(&buffer, " padding: 2px;\n");
|
|
|
982 |
add_data(&buffer, "}\n");
|
1 |
nishi |
983 |
add_data(&buffer, "body {\n");
|
|
|
984 |
add_data(&buffer, " background-color: #1F4677;\n");
|
|
|
985 |
add_data(&buffer, " width: 940px;\n");
|
|
|
986 |
add_data(&buffer, " margin: 5px auto;\n");
|
|
|
987 |
add_data(&buffer, " font-family: sans-serif;\n");
|
|
|
988 |
add_data(&buffer, "}\n");
|
|
|
989 |
add_data(&buffer, "#nav {\n");
|
|
|
990 |
add_data(&buffer, " background-color: white;\n");
|
6 |
nishi |
991 |
add_data(&buffer, " background-image: url('");
|
|
|
992 |
add_data(&buffer, INSTANCE_NAVBAR);
|
|
|
993 |
add_data(&buffer, "');\n");
|
1 |
nishi |
994 |
add_data(&buffer, " height: 44px;\n");
|
|
|
995 |
add_data(&buffer, " padding: 8px;\n");
|
|
|
996 |
add_data(&buffer, " padding-left: 32px;\n");
|
|
|
997 |
add_data(&buffer, " font-size: 22px;\n");
|
|
|
998 |
add_data(&buffer, " font-weight: bold;\n");
|
|
|
999 |
add_data(&buffer, "}\n");
|
11 |
nishi |
1000 |
add_data(&buffer, "pre {\n");
|
|
|
1001 |
add_data(&buffer, " background-color: #dddddd;\n");
|
|
|
1002 |
add_data(&buffer, " border: solid 2px #bbbbbb;\n");
|
12 |
nishi |
1003 |
add_data(&buffer, " padding: 8px;\n");
|
|
|
1004 |
add_data(&buffer, " overflow: scroll;\n");
|
11 |
nishi |
1005 |
add_data(&buffer, "}\n");
|
1 |
nishi |
1006 |
add_data(&buffer, "#index {\n");
|
|
|
1007 |
add_data(&buffer, " list-style: none;\n");
|
|
|
1008 |
add_data(&buffer, " line-height: normal;\n");
|
|
|
1009 |
add_data(&buffer, " margin: auto 0;\n");
|
|
|
1010 |
add_data(&buffer, " padding-left: 0;\n");
|
|
|
1011 |
add_data(&buffer, "}\n");
|
|
|
1012 |
add_data(&buffer, "#desc {\n");
|
|
|
1013 |
add_data(&buffer, " background-color: #D2E1F6;\n");
|
|
|
1014 |
add_data(&buffer, " margin: 9px auto;\n");
|
|
|
1015 |
add_data(&buffer, " height: 128px;\n");
|
|
|
1016 |
add_data(&buffer, " padding: 24px;\n");
|
|
|
1017 |
add_data(&buffer, "}\n");
|
|
|
1018 |
add_data(&buffer, "#descinside {\n");
|
|
|
1019 |
add_data(&buffer, " float: left;\n");
|
11 |
nishi |
1020 |
add_data(&buffer, " width: 700px;\n");
|
|
|
1021 |
add_data(&buffer, " overflow-y: scroll;\n");
|
|
|
1022 |
add_data(&buffer, " max-height: 128px;\n");
|
1 |
nishi |
1023 |
add_data(&buffer, "}\n");
|
|
|
1024 |
add_data(&buffer, "#logo {\n");
|
|
|
1025 |
add_data(&buffer, " float: right;\n");
|
|
|
1026 |
add_data(&buffer, "}\n");
|
|
|
1027 |
add_data(&buffer, "#content {\n");
|
|
|
1028 |
add_data(&buffer, " background-color: #FFFFFF;\n");
|
|
|
1029 |
add_data(&buffer, " margin: -10px auto;\n");
|
|
|
1030 |
add_data(&buffer, " padding: 8px 24px 24px;\n");
|
|
|
1031 |
add_data(&buffer, "}\n");
|
|
|
1032 |
add_data(&buffer, "#pageindex {\n");
|
|
|
1033 |
add_data(&buffer, " background-color: #FFFFFF;\n");
|
|
|
1034 |
add_data(&buffer, " padding-right: 24px;\n");
|
|
|
1035 |
add_data(&buffer, " padding-bottom: 24px;\n");
|
|
|
1036 |
add_data(&buffer, " float: left;\n");
|
|
|
1037 |
add_data(&buffer, " border-right: 4px #1F4677 solid;\n");
|
|
|
1038 |
add_data(&buffer, " width: 150px;\n");
|
|
|
1039 |
add_data(&buffer, "}\n");
|
|
|
1040 |
add_data(&buffer, "#pagecontent {\n");
|
|
|
1041 |
add_data(&buffer, " background-color: #FFFFFF;\n");
|
|
|
1042 |
add_data(&buffer, " width: 670px;\n");
|
|
|
1043 |
add_data(&buffer, " float: right;\n");
|
|
|
1044 |
add_data(&buffer, " padding-left: 24px;\n");
|
|
|
1045 |
add_data(&buffer, "}\n");
|
|
|
1046 |
add_data(&buffer, "#footer {\n");
|
|
|
1047 |
add_data(&buffer, " background-color: #D2E1F6;\n");
|
|
|
1048 |
add_data(&buffer, " padding: 8px 8px 48px;\n");
|
|
|
1049 |
add_data(&buffer, " margin: 8px auto;\n");
|
|
|
1050 |
add_data(&buffer, " font-size: 15px;\n");
|
|
|
1051 |
add_data(&buffer, " height: 32px;\n");
|
|
|
1052 |
add_data(&buffer, "}\n");
|
|
|
1053 |
add_data(&buffer, ".fixfloat {\n");
|
|
|
1054 |
add_data(&buffer, " clear: both;\n");
|
|
|
1055 |
add_data(&buffer, "}\n");
|
|
|
1056 |
add_data(&buffer, "#copyright {\n");
|
|
|
1057 |
add_data(&buffer, " float: right;\n");
|
|
|
1058 |
add_data(&buffer, " font-size: 10px;\n");
|
|
|
1059 |
add_data(&buffer, " margin-top: 16px;\n");
|
|
|
1060 |
add_data(&buffer, "}\n");
|
|
|
1061 |
add_data(&buffer, "#gotop {\n");
|
|
|
1062 |
add_data(&buffer, " position: absolute;\n");
|
|
|
1063 |
add_data(&buffer, "}\n");
|
|
|
1064 |
add_data(&buffer, "h2, h3 {\n");
|
|
|
1065 |
add_data(&buffer, " padding-top: 8px;\n");
|
|
|
1066 |
add_data(&buffer, " padding-bottom: 8px;\n");
|
|
|
1067 |
add_data(&buffer, "}\n");
|
|
|
1068 |
add_data(&buffer, "img {\n");
|
|
|
1069 |
add_data(&buffer, " border: none;\n");
|
|
|
1070 |
add_data(&buffer, "}\n");
|
|
|
1071 |
add_data(&buffer, " </style>\n");
|
|
|
1072 |
add_data(&buffer, " </head>\n");
|
|
|
1073 |
add_data(&buffer, " <body>\n");
|
|
|
1074 |
add_data(&buffer, " <div id=\"nav\">\n");
|
|
|
1075 |
add_data(&buffer, " <div>\n");
|
|
|
1076 |
add_data(&buffer, " <a href=\"");
|
|
|
1077 |
add_data(&buffer, INSTANCE_ROOT);
|
|
|
1078 |
add_data(&buffer, "/\">Home</a>\n");
|
|
|
1079 |
add_data(&buffer, " </div>\n");
|
5 |
nishi |
1080 |
if(user == NULL) {
|
|
|
1081 |
add_data(&buffer, " <div>\n");
|
|
|
1082 |
add_data(&buffer, " <a href=\"");
|
|
|
1083 |
add_data(&buffer, INSTANCE_ROOT);
|
|
|
1084 |
add_data(&buffer, "/?page=login\">Login</a>\n");
|
|
|
1085 |
add_data(&buffer, " </div>\n");
|
13 |
nishi |
1086 |
#ifdef ALLOW_SIGNUP
|
|
|
1087 |
add_data(&buffer, " <div>\n");
|
|
|
1088 |
add_data(&buffer, " <a href=\"");
|
|
|
1089 |
add_data(&buffer, INSTANCE_ROOT);
|
|
|
1090 |
add_data(&buffer, "/?page=signup\">Signup</a>\n");
|
|
|
1091 |
add_data(&buffer, " </div>\n");
|
|
|
1092 |
#endif
|
7 |
nishi |
1093 |
} else {
|
27 |
nishi |
1094 |
#ifdef USE_MYPAGE
|
7 |
nishi |
1095 |
add_data(&buffer, " <div>\n");
|
|
|
1096 |
add_data(&buffer, " <a href=\"");
|
|
|
1097 |
add_data(&buffer, INSTANCE_ROOT);
|
9 |
nishi |
1098 |
add_data(&buffer, "/?page=mypage\">My Page</a>\n");
|
|
|
1099 |
add_data(&buffer, " </div>\n");
|
27 |
nishi |
1100 |
#endif
|
9 |
nishi |
1101 |
|
|
|
1102 |
add_data(&buffer, " <div>\n");
|
|
|
1103 |
add_data(&buffer, " <a href=\"");
|
|
|
1104 |
add_data(&buffer, INSTANCE_ROOT);
|
|
|
1105 |
add_data(&buffer, "/?page=myrepo\">My Repositories</a>\n");
|
|
|
1106 |
add_data(&buffer, " </div>\n");
|
|
|
1107 |
|
|
|
1108 |
add_data(&buffer, " <div>\n");
|
|
|
1109 |
add_data(&buffer, " <a href=\"");
|
|
|
1110 |
add_data(&buffer, INSTANCE_ROOT);
|
7 |
nishi |
1111 |
add_data(&buffer, "/?page=logout\">Logout</a>\n");
|
|
|
1112 |
add_data(&buffer, " </div>\n");
|
5 |
nishi |
1113 |
}
|
6 |
nishi |
1114 |
if(user != NULL) {
|
43 |
nishi |
1115 |
#ifdef USE_AVATAR
|
|
|
1116 |
#ifdef USE_MYPAGE
|
|
|
1117 |
add_data(&buffer, "<a href=\"");
|
6 |
nishi |
1118 |
add_data(&buffer, INSTANCE_ROOT);
|
43 |
nishi |
1119 |
add_data(&buffer, "/?page=person&username=");
|
|
|
1120 |
add_data(&buffer, user);
|
|
|
1121 |
add_data(&buffer, "\">");
|
|
|
1122 |
#endif
|
|
|
1123 |
add_data(&buffer, "<img src=\"");
|
|
|
1124 |
add_data(&buffer, WWW_AVATAR_ROOT);
|
|
|
1125 |
add_data(&buffer, "/");
|
|
|
1126 |
add_data(&buffer, user);
|
|
|
1127 |
add_data(&buffer, ".png\" alt=\"Your Icon\" style=\"float: right;height: 32px;\">");
|
|
|
1128 |
#ifdef USE_MYPAGE
|
|
|
1129 |
add_data(&buffer, "</a>");
|
|
|
1130 |
#endif
|
|
|
1131 |
#endif
|
68 |
nishi |
1132 |
add_data(&buffer, "<div style=\"clear: both;float: right;font-size: 10px;padding-right: 0;font-style: italic;padding-top: 0;\">You have logged in as <a href=\"");
|
43 |
nishi |
1133 |
add_data(&buffer, INSTANCE_ROOT);
|
6 |
nishi |
1134 |
add_data(&buffer, "/?page=mypage\">");
|
|
|
1135 |
add_data(&buffer, user);
|
|
|
1136 |
add_data(&buffer, "</a></div>");
|
|
|
1137 |
}
|
1 |
nishi |
1138 |
add_data(&buffer, " </div>\n");
|
|
|
1139 |
add_data(&buffer, " <div id=\"desc\">\n");
|
|
|
1140 |
add_data(&buffer, " <div id=\"descinside\">\n");
|
|
|
1141 |
add_data(&buffer, " <h1>");
|
|
|
1142 |
add_data(&buffer, title);
|
|
|
1143 |
add_data(&buffer, "</h1>\n");
|
|
|
1144 |
add_data(&buffer, " <p>\n");
|
|
|
1145 |
add_data(&buffer, desc);
|
|
|
1146 |
add_data(&buffer, " </p>\n");
|
|
|
1147 |
add_data(&buffer, " </div>\n");
|
|
|
1148 |
add_data(&buffer, " <img id=\"logo\" src=\"");
|
46 |
nishi |
1149 |
if(logopath != NULL) {
|
|
|
1150 |
add_data(&buffer, logopath);
|
43 |
nishi |
1151 |
} else {
|
|
|
1152 |
add_data(&buffer, INSTANCE_LOGO);
|
|
|
1153 |
}
|
1 |
nishi |
1154 |
add_data(&buffer, "\" height=\"128px\" alt=\"logo\">\n");
|
|
|
1155 |
add_data(&buffer, " </div>\n");
|
|
|
1156 |
add_data(&buffer, " <div id=\"content\">\n");
|
|
|
1157 |
add_data(&buffer, " <div id=\"pageindex\">\n");
|
|
|
1158 |
add_data(&buffer, " <h3>Page Menu</h3>\n");
|
|
|
1159 |
add_data(&buffer, " <ul>\n");
|
10 |
nishi |
1160 |
add_data(&buffer, nav);
|
1 |
nishi |
1161 |
add_data(&buffer, " </ul>\n");
|
|
|
1162 |
add_data(&buffer, " </div>\n");
|
|
|
1163 |
add_data(&buffer, " <div id=\"pagecontent\">\n");
|
|
|
1164 |
add_data(&buffer, page);
|
|
|
1165 |
add_data(&buffer, " </div>\n");
|
11 |
nishi |
1166 |
add_data(&buffer, " <div class=\"fixfloat\"></div>\n");
|
1 |
nishi |
1167 |
add_data(&buffer, " </div>\n");
|
|
|
1168 |
add_data(&buffer, " <div id=\"footer\">\n");
|
|
|
1169 |
add_data(&buffer, " <div id=\"gotop\">\n");
|
|
|
1170 |
add_data(&buffer, " <a href=\"#top\">Top</a>\n");
|
|
|
1171 |
add_data(&buffer, " </div>\n");
|
|
|
1172 |
add_data(&buffer, " <div id=\"copyright\">\n");
|
|
|
1173 |
add_data(&buffer, " ");
|
|
|
1174 |
escaped = escape(INSTANCE_ADMIN);
|
|
|
1175 |
add_data(&buffer, escaped);
|
|
|
1176 |
free(escaped);
|
|
|
1177 |
add_data(&buffer, "\n");
|
|
|
1178 |
add_data(&buffer, " </div>\n");
|
|
|
1179 |
add_data(&buffer, " <div class=\"fixfloat\"></div>\n");
|
15 |
nishi |
1180 |
#ifdef INSTANCE_BANNERS
|
|
|
1181 |
add_data(&buffer, " <div id=\"banners\" style=\"clear: both;\">\n");
|
|
|
1182 |
add_data(&buffer, INSTANCE_BANNERS);
|
|
|
1183 |
add_data(&buffer, " </div>\n");
|
|
|
1184 |
#else
|
|
|
1185 |
add_data(&buffer, " <div class=\"fixfloat\"></div>\n");
|
|
|
1186 |
#endif
|
1 |
nishi |
1187 |
add_data(&buffer, " </div>\n");
|
|
|
1188 |
add_data(&buffer, " </body>\n");
|
|
|
1189 |
add_data(&buffer, "</html>\n");
|
5 |
nishi |
1190 |
if(user != NULL) free(user);
|
1 |
nishi |
1191 |
}
|