Subversion Repositories RepoView

Rev

Rev 3 | Rev 6 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 5
Line 1... Line 1...
1
/* $Id: modern.c 3 2024-08-20 21:05:24Z nishi $ */
1
/* $Id: modern.c 5 2024-08-20 22:43:56Z nishi $ */
2
 
2
 
3
#include "rv_query.h"
3
#include "rv_query.h"
4
 
4
 
5
#include "rv_util.h"
5
#include "rv_util.h"
6
#include "rv_version.h"
6
#include "rv_version.h"
Line 57... Line 57...
57
		title = rv_strdup("Login Result");
57
		title = rv_strdup("Login Result");
58
		page = rv_strdup("");
58
		page = rv_strdup("");
59
 
59
 
60
		rv_load_query('P');
60
		rv_load_query('P');
61
		if(rv_get_query("username") == NULL || rv_get_query("password") == NULL) {
61
		if(rv_get_query("username") == NULL || rv_get_query("password") == NULL) {
62
			add_data(&page, "Invalid form\n");
62
			add_data(&page, "Invalid form.\n");
63
		} else {
63
		} else {
64
			if(rv_has_user(rv_get_query("username"))) {
64
			if(rv_has_user(rv_get_query("username"))) {
-
 
65
				if(rv_check_password(rv_get_query("username"), rv_get_query("password"))) {
-
 
66
					add_data(&page, "Welcome back.\n");
-
 
67
					rv_save_login(rv_get_query("username"));
-
 
68
				} else {
-
 
69
					add_data(&page, "Invalid password.");
-
 
70
				}
65
			} else {
71
			} else {
66
				add_data(&page, "User does not exist");
72
				add_data(&page, "User does not exist.");
67
			}
73
			}
68
		}
74
		}
69
	}
75
	}
70
 
76
 
71
	if(title == NULL) title = rv_strdup("");
77
	if(title == NULL) title = rv_strdup("");
Line 101... Line 107...
101
	}
107
	}
102
	return r;
108
	return r;
103
}
109
}
104
 
110
 
105
void render_stuff(void) {
111
void render_stuff(void) {
-
 
112
	char* user = rv_logged_in();
106
	char* escaped;
113
	char* escaped;
107
	add_data(&buffer, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n");
114
	add_data(&buffer, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n");
108
	add_data(&buffer, "<html>\n");
115
	add_data(&buffer, "<html>\n");
109
	add_data(&buffer, "	<head>\n");
116
	add_data(&buffer, "	<head>\n");
110
	add_data(&buffer, "		<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">\n");
117
	add_data(&buffer, "		<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">\n");
Line 216... Line 223...
216
	add_data(&buffer, "			<div>\n");
223
	add_data(&buffer, "			<div>\n");
217
	add_data(&buffer, "				<a href=\"");
224
	add_data(&buffer, "				<a href=\"");
218
	add_data(&buffer, INSTANCE_ROOT);
225
	add_data(&buffer, INSTANCE_ROOT);
219
	add_data(&buffer, "/\">Home</a>\n");
226
	add_data(&buffer, "/\">Home</a>\n");
220
	add_data(&buffer, "			</div>\n");
227
	add_data(&buffer, "			</div>\n");
-
 
228
	if(user == NULL) {
221
	add_data(&buffer, "			<div>\n");
229
		add_data(&buffer, "			<div>\n");
222
	add_data(&buffer, "				<a href=\"");
230
		add_data(&buffer, "				<a href=\"");
223
	add_data(&buffer, INSTANCE_ROOT);
231
		add_data(&buffer, INSTANCE_ROOT);
224
	add_data(&buffer, "/?page=login\">Login</a>\n");
232
		add_data(&buffer, "/?page=login\">Login</a>\n");
225
	add_data(&buffer, "			</div>\n");
233
		add_data(&buffer, "			</div>\n");
-
 
234
	}
226
	add_data(&buffer, "		</div>\n");
235
	add_data(&buffer, "		</div>\n");
227
	add_data(&buffer, "		<div id=\"desc\">\n");
236
	add_data(&buffer, "		<div id=\"desc\">\n");
228
	add_data(&buffer, "			<div id=\"descinside\">\n");
237
	add_data(&buffer, "			<div id=\"descinside\">\n");
229
	add_data(&buffer, "				<h1>");
238
	add_data(&buffer, "				<h1>");
230
	add_data(&buffer, title);
239
	add_data(&buffer, title);
Line 261... Line 270...
261
	add_data(&buffer, "			</div>\n");
270
	add_data(&buffer, "			</div>\n");
262
	add_data(&buffer, "			<div class=\"fixfloat\"></div>\n");
271
	add_data(&buffer, "			<div class=\"fixfloat\"></div>\n");
263
	add_data(&buffer, "		</div>\n");
272
	add_data(&buffer, "		</div>\n");
264
	add_data(&buffer, "	</body>\n");
273
	add_data(&buffer, "	</body>\n");
265
	add_data(&buffer, "</html>\n");
274
	add_data(&buffer, "</html>\n");
-
 
275
	if(user != NULL) free(user);
266
}
276
}