From 6a122c422f45b9e499a387c31f8d93379b3e05fd Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 20 Apr 2024 03:25:10 +0000 Subject: [PATCH] login git-svn-id: file:///raid/svn-main/nishi-mandshurica/trunk@52 f982e544-4a7d-3444-ad1a-fde59a2a69f1 --- Module/http.c | 25 ++++++++++++++++++++++++- Webroot/bar.html | 3 +++ Webroot/body-start.html | 3 +++ Webroot/end.html | 2 ++ Webroot/head-start.html | 3 +++ Webroot/login-fail/index.html.tmpl | 10 ++++++++++ 6 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 Webroot/bar.html create mode 100644 Webroot/body-start.html create mode 100644 Webroot/end.html create mode 100644 Webroot/head-start.html create mode 100644 Webroot/login-fail/index.html.tmpl diff --git a/Module/http.c b/Module/http.c index cef0b00..ec40433 100644 --- a/Module/http.c +++ b/Module/http.c @@ -205,7 +205,30 @@ void http_handler(int sock) { send(sock, "Content-Length: 0\r\n", 19, 0); send(sock, "\r\n", 2, 0); } else if(res == MS_AUTH_FAIL) { - + char* type; + uint64_t len; + char* data = NULL; + char* s; + + struct stat st; + char* lastmod = NULL; + const char* pth = mandshurica_strcat(webroot, "/login-fail/"); + if(stat(pth, &st) == 0) { + if(S_ISDIR(st.st_mode)) { + if(data == NULL) { + s = mandshurica_strcat(pth, "/index.html.tmpl"); + data = config->mandshurica_load(s, &type, &lastmod, &len); + free(s); + } + if(data == NULL) { + s = mandshurica_strcat(pth, "/index.html"); + data = config->mandshurica_load(s, &type, &lastmod, &len); + free(s); + } + } else { + data = config->mandshurica_load(pth, &type, &lastmod, &len); + } + } send(sock, "HTTP/1.1 403 Forbidden\r\n", 15 + 9, 0); send(sock, "Connection: keep-alive\r\n", 24, 0); send(sock, "Content-Length: 0\r\n", 19, 0); diff --git a/Webroot/bar.html b/Webroot/bar.html new file mode 100644 index 0000000..0eb3904 --- /dev/null +++ b/Webroot/bar.html @@ -0,0 +1,3 @@ +
+Home Login +
diff --git a/Webroot/body-start.html b/Webroot/body-start.html new file mode 100644 index 0000000..735c654 --- /dev/null +++ b/Webroot/body-start.html @@ -0,0 +1,3 @@ + + + diff --git a/Webroot/end.html b/Webroot/end.html new file mode 100644 index 0000000..7fb2bd6 --- /dev/null +++ b/Webroot/end.html @@ -0,0 +1,2 @@ + + diff --git a/Webroot/head-start.html b/Webroot/head-start.html new file mode 100644 index 0000000..bcf3c06 --- /dev/null +++ b/Webroot/head-start.html @@ -0,0 +1,3 @@ + + + diff --git a/Webroot/login-fail/index.html.tmpl b/Webroot/login-fail/index.html.tmpl new file mode 100644 index 0000000..b998c14 --- /dev/null +++ b/Webroot/login-fail/index.html.tmpl @@ -0,0 +1,10 @@ + +@include head-start.html@ +Mandshurica - Failed to login +@include body-start.html@ +

Mandshurica - Failed to login

+@include bar.html@ +Failed to login, retry? +@include end.html@ -- 2.43.0