// 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
</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" >
###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