Subversion Repositories RepoView

Rev

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

Rev 6 Rev 7
Line 1... Line 1...
1
/* $Id: modern.c 6 2024-08-21 00:44:17Z nishi $ */
1
/* $Id: modern.c 7 2024-08-21 01:12:44Z 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"
7
#include "rv_auth.h"
7
#include "rv_auth.h"
8
#include "rv_db.h"
8
#include "rv_db.h"
9
 
9
 
10
#include "../../config.h"
10
#include "../../config.h"
11
 
11
 
-
 
12
#include <stdio.h>
12
#include <stdlib.h>
13
#include <stdlib.h>
13
#include <string.h>
14
#include <string.h>
14
 
15
 
15
extern char* buffer;
16
extern char* buffer;
16
void add_data(char** data, const char* txt);
17
void add_data(char** data, const char* txt);
Line 73... Line 74...
73
				}
74
				}
74
			} else {
75
			} else {
75
				add_data(&page, "User does not exist.");
76
				add_data(&page, "User does not exist.");
76
			}
77
			}
77
		}
78
		}
-
 
79
	} else if(strcmp(query, "sendlogout") == 0) {
-
 
80
		title = rv_strdup("Logout Result");
-
 
81
		page = rv_strdup("");
-
 
82
		if(user == NULL) {
-
 
83
			add_data(&page, "You were not logged in.\n");
-
 
84
		} else {
-
 
85
			rv_logout();
-
 
86
			add_data(&page, "Goodbye.\n");
-
 
87
			free(user);
-
 
88
			user = NULL;
-
 
89
		}
78
	} else if(strcmp(query, "mypage") == 0) {
90
	} else if(strcmp(query, "mypage") == 0) {
79
		title = rv_strdup("My Page");
91
		title = rv_strdup("My Page");
80
		desc = rv_strdup("You manage your information here.");
92
		desc = rv_strdup("You manage your information here.");
81
		if(user == NULL) {
93
		if(user == NULL) {
82
			page = rv_strdup("It looks like you are not logged in.<br>Want to <a href=\"");
94
			page = rv_strdup("It looks like you are not logged in.<br>Want to <a href=\"");
83
			add_data(&page, INSTANCE_ROOT);
95
			add_data(&page, INSTANCE_ROOT);
84
			add_data(&page, "/?page=login\">log in</a>?\n");
96
			add_data(&page, "/?page=login\">log in</a>?\n");
85
		}
97
		}
-
 
98
	} else if(strcmp(query, "logout") == 0) {
-
 
99
		title = rv_strdup("Logout");
-
 
100
		desc = rv_strdup("You can log out from your account here.");
-
 
101
		if(user == NULL) {
-
 
102
			page = rv_strdup("It looks like you are not logged in.<br>Want to <a href=\"");
-
 
103
			add_data(&page, INSTANCE_ROOT);
-
 
104
			add_data(&page, "/?page=login\">log in</a>?\n");
-
 
105
		} else {
-
 
106
			page = rv_strdup("");
-
 
107
			add_data(&page, "Are you sure you want to log out?\n");
-
 
108
			add_data(&page, "<form method=\"POST\" action=\"");
-
 
109
			add_data(&page, INSTANCE_ROOT);
-
 
110
			add_data(&page, "/?page=sendlogout\">\n");
-
 
111
			add_data(&page, "	<input type=\"submit\" value=\"Yes\">\n");
-
 
112
			add_data(&page, "</form>\n");
-
 
113
		}
86
	}
114
	}
87
 
115
 
88
	if(title == NULL) title = rv_strdup("");
116
	if(title == NULL) title = rv_strdup("");
89
	if(desc == NULL) desc = rv_strdup("");
117
	if(desc == NULL) desc = rv_strdup("");
90
	if(page == NULL) page = rv_strdup("");
118
	if(page == NULL) page = rv_strdup("");
Line 242... Line 270...
242
		add_data(&buffer, "			<div>\n");
270
		add_data(&buffer, "			<div>\n");
243
		add_data(&buffer, "				<a href=\"");
271
		add_data(&buffer, "				<a href=\"");
244
		add_data(&buffer, INSTANCE_ROOT);
272
		add_data(&buffer, INSTANCE_ROOT);
245
		add_data(&buffer, "/?page=login\">Login</a>\n");
273
		add_data(&buffer, "/?page=login\">Login</a>\n");
246
		add_data(&buffer, "			</div>\n");
274
		add_data(&buffer, "			</div>\n");
-
 
275
	} else {
-
 
276
		add_data(&buffer, "			<div>\n");
-
 
277
		add_data(&buffer, "				<a href=\"");
-
 
278
		add_data(&buffer, INSTANCE_ROOT);
-
 
279
		add_data(&buffer, "/?page=logout\">Logout</a>\n");
-
 
280
		add_data(&buffer, "			</div>\n");
247
	}
281
	}
248
	if(user != NULL) {
282
	if(user != NULL) {
249
		add_data(&buffer, "<div style=\"float: right;font-size: 10px;padding-top: 36px;padding-right: 0;font-style: italic;\">You have logged in as <a href=\"");
283
		add_data(&buffer, "<div style=\"float: right;font-size: 10px;padding-top: 36px;padding-right: 0;font-style: italic;\">You have logged in as <a href=\"");
250
		add_data(&buffer, INSTANCE_ROOT);
284
		add_data(&buffer, INSTANCE_ROOT);
251
		add_data(&buffer, "/?page=mypage\">");
285
		add_data(&buffer, "/?page=mypage\">");