]> bicyclesonthemoon.info Git - ott/mirror/commitdiff
redirect interface now only works with POST requests
authorb <rowerynaksiezycu@gmail.com>
Mon, 8 Jan 2024 21:09:06 +0000 (21:09 +0000)
committerb <rowerynaksiezycu@gmail.com>
Mon, 8 Jan 2024 21:09:06 +0000 (21:09 +0000)
redirect.c
www/ott/end
www/ott/np/end

index dd4180950d48083567cd01fffaa878d8ec6c3cb5..c07f669eac056b85ab1a2016106f251266ca84c9 100644 (file)
@@ -1,5 +1,5 @@
 // OTT mirror\r
-// Copyright (C) 2014 Balthasar Szczepañski\r
+// Copyright (C) 2014 Balthasar Szczepański\r
 // redirect.c\r
 // redirect srevice for the "Jump to:" list.\r
 // 24.08.2014\r
 // along with OTT mirror. If not, see <http://www.gnu.org/licenses/>.\r
 \r
 #include <cgi.h>\r
-int main(int argc, char **argv)\r
+#include <stdio.h>\r
+#include <string.h>\r
+int main(int argc, char **argv, char **env)\r
 {\r
        s_cgi *cgi;\r
-       char *redirect;\r
+       char *f;\r
+       int i;\r
+       int post = 0;\r
        cgi=cgiInit();\r
-       redirect=cgiGetValue(cgi,"f");\r
-       cgiRedirect(redirect?redirect:"/ott");\r
+       f=cgiGetValue(cgi,"f");\r
+       \r
+       for (i=0; env[i]; i++) {\r
+               if (strcmp(env[i], "REQUEST_METHOD=POST") == 0) {\r
+                       post = 1;\r
+                       break;\r
+               }\r
+       }\r
+       \r
+       if (post) {\r
+               cgiRedirect(f?f:"/ott");\r
+       }\r
+       else {\r
+               printf("Status: 405 Method Not Allowed\n");\r
+               printf("Allow: POST\n");\r
+               printf("Content-type: text/plain\n");\r
+               printf("\n");\r
+               printf("Only POST requests allowed.\n");\r
+       }\r
        return 0;\r
-}
\ No newline at end of file
+}\r
index 9ec7c326dea7f0cc40015cd8f8d7c41e44b75c1b..d925ac7788d6888940550a9b5da184660e11d431 100644 (file)
@@ -26,7 +26,7 @@
 
 </div>
 <p></p><!-- <p><a href="http://forums.xkcd.com/index.php" class="left-box left" >Return to Board index</a></p> -->
-<form method="get" id="jumpbox" action="/ott/redirect" onsubmit="if(this.f.value == -1){return false;}" >
+<form method="post" id="jumpbox" action="/ott/redirect" onsubmit="if(this.f.value == -1){return false;}" >
 
 <fieldset class="jumpbox" >
 
index b31f683026088fb20c9e56a8cee2da577efc0d62..57b3c1f2c5cdbb2dc95226848ec5667bd57b16a5 100644 (file)
@@ -22,7 +22,7 @@ go to newpage:
 ###links\r
 </div>\r
 <p></p><!-- <p><a href="http://forums.xkcd.com/viewforum.php?f=7" class="left-box left" >Return to Individual XKCD Comic Threads</a></p> -->\r
-<form method="get" id="jumpbox" action="/ott/redirect" onsubmit="if(this.f.value == -1){return false;}" >\r
+<form method="post" id="jumpbox" action="/ott/redirect" onsubmit="if(this.f.value == -1){return false;}" >\r
 \r
 <fieldset class="jumpbox" >\r
 \r