]> Nishi Git Mirror - mandshurica.git/commitdiff
login
authornishi <nishi@f982e544-4a7d-3444-ad1a-fde59a2a69f1>
Sat, 20 Apr 2024 03:25:10 +0000 (03:25 +0000)
committernishi <nishi@f982e544-4a7d-3444-ad1a-fde59a2a69f1>
Sat, 20 Apr 2024 03:25:10 +0000 (03:25 +0000)
git-svn-id: file:///raid/svn-main/nishi-mandshurica/trunk@52 f982e544-4a7d-3444-ad1a-fde59a2a69f1

Module/http.c
Webroot/bar.html [new file with mode: 0644]
Webroot/body-start.html [new file with mode: 0644]
Webroot/end.html [new file with mode: 0644]
Webroot/head-start.html [new file with mode: 0644]
Webroot/login-fail/index.html.tmpl [new file with mode: 0644]

index cef0b0024209692d46aa675cc594b806adec8635..ec404331cac6db616db4e53c751a4fdd118d719e 100644 (file)
@@ -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 (file)
index 0000000..0eb3904
--- /dev/null
@@ -0,0 +1,3 @@
+<hr>
+<a href="/">Home</a> <a href="/login">Login</a>
+<hr>
diff --git a/Webroot/body-start.html b/Webroot/body-start.html
new file mode 100644 (file)
index 0000000..735c654
--- /dev/null
@@ -0,0 +1,3 @@
+</head>
+<body>
+       <a href="/"><img src="/mandshurica.gif"></a>
diff --git a/Webroot/end.html b/Webroot/end.html
new file mode 100644 (file)
index 0000000..7fb2bd6
--- /dev/null
@@ -0,0 +1,2 @@
+       </body>
+</html>
diff --git a/Webroot/head-start.html b/Webroot/head-start.html
new file mode 100644 (file)
index 0000000..bcf3c06
--- /dev/null
@@ -0,0 +1,3 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
+<html>
+       <head>
diff --git a/Webroot/login-fail/index.html.tmpl b/Webroot/login-fail/index.html.tmpl
new file mode 100644 (file)
index 0000000..b998c14
--- /dev/null
@@ -0,0 +1,10 @@
+<!--@chdir_webroot@
+vim: syntax=html
+-->
+@include head-start.html@
+<title>Mandshurica - Failed to login</title>
+@include body-start.html@
+<h1>Mandshurica - Failed to login</h1>
+@include bar.html@
+Failed to login, <a href="/login">retry</a>?
+@include end.html@