From e25975c0910368dcce87ec4164fa79cc3e96b57e Mon Sep 17 00:00:00 2001 From: b Date: Mon, 8 Jan 2024 21:09:06 +0000 Subject: [PATCH] redirect interface now only works with POST requests --- redirect.c | 33 +++++++++++++++++++++++++++------ www/ott/end | 2 +- www/ott/np/end | 2 +- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/redirect.c b/redirect.c index dd41809..c07f669 100644 --- a/redirect.c +++ b/redirect.c @@ -1,5 +1,5 @@ // OTT mirror -// Copyright (C) 2014 Balthasar Szczepañski +// Copyright (C) 2014 Balthasar Szczepański // redirect.c // redirect srevice for the "Jump to:" list. // 24.08.2014 @@ -20,12 +20,33 @@ // along with OTT mirror. If not, see . #include -int main(int argc, char **argv) +#include +#include +int main(int argc, char **argv, char **env) { s_cgi *cgi; - char *redirect; + char *f; + int i; + int post = 0; cgi=cgiInit(); - redirect=cgiGetValue(cgi,"f"); - cgiRedirect(redirect?redirect:"/ott"); + f=cgiGetValue(cgi,"f"); + + for (i=0; env[i]; i++) { + if (strcmp(env[i], "REQUEST_METHOD=POST") == 0) { + post = 1; + break; + } + } + + if (post) { + cgiRedirect(f?f:"/ott"); + } + else { + printf("Status: 405 Method Not Allowed\n"); + printf("Allow: POST\n"); + printf("Content-type: text/plain\n"); + printf("\n"); + printf("Only POST requests allowed.\n"); + } return 0; -} \ No newline at end of file +} diff --git a/www/ott/end b/www/ott/end index 9ec7c32..d925ac7 100644 --- a/www/ott/end +++ b/www/ott/end @@ -26,7 +26,7 @@

-
+
diff --git a/www/ott/np/end b/www/ott/np/end index b31f683..57b3c1f 100644 --- a/www/ott/np/end +++ b/www/ott/np/end @@ -22,7 +22,7 @@ go to newpage: ###links

- +
-- 2.30.2