summaryrefslogtreecommitdiff
path: root/cgi
diff options
context:
space:
mode:
Diffstat (limited to 'cgi')
-rwxr-xr-xcgi/.htaccess2
-rw-r--r--cgi/4or6.c14
-rwxr-xr-xcgi/4or6.cgibin0 -> 16712 bytes
-rw-r--r--cgi/hello.c19
-rwxr-xr-xcgi/hello.cgibin0 -> 8712 bytes
5 files changed, 35 insertions, 0 deletions
diff --git a/cgi/.htaccess b/cgi/.htaccess
new file mode 100755
index 0000000..527ad9b
--- /dev/null
+++ b/cgi/.htaccess
@@ -0,0 +1,2 @@
+Options +ExecCGI
+AddHandler cgi-script cgi pl
diff --git a/cgi/4or6.c b/cgi/4or6.c
new file mode 100644
index 0000000..1cf6780
--- /dev/null
+++ b/cgi/4or6.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+int main()
+{
+ printf("Content-type: text/plain\n\n");
+ if(!getenv("REMOTE_ADDR"))return 0;
+ char* s=getenv("REMOTE_ADDR");
+ if(getenv("HTTP_X_FORWARDED_FOR"))
+ s=getenv("HTTP_X_FORWARDED_FOR");
+ if(strchr(s,':')!=NULL)puts("6");
+ else puts("4");
+ return 0;
+}
diff --git a/cgi/4or6.cgi b/cgi/4or6.cgi
new file mode 100755
index 0000000..80d1ea6
--- /dev/null
+++ b/cgi/4or6.cgi
Binary files differ
diff --git a/cgi/hello.c b/cgi/hello.c
new file mode 100644
index 0000000..440cf11
--- /dev/null
+++ b/cgi/hello.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdlib.h>
+int main(int argc,char **argv,char** envp)
+{
+ puts("Content-type: text/html\r\n\r\n");
+ puts("<code>hello cgi...<br>\nEnvironment variables:<br>\n");
+ for(char** env=envp;*env;++env){printf("%s<br>\n",*env);}
+ if(getenv("CONTENT_LENGTH"))
+ {
+ int len=atoi(getenv("CONTENT_LENGTH"));
+ char* buf=malloc(len+1);
+ fread(buf,1,len,stdin);
+ buf[len]=0;
+ printf("stdin:<br>\n");
+ puts(buf);
+ }
+ puts("</code>");
+ return 0;
+}
diff --git a/cgi/hello.cgi b/cgi/hello.cgi
new file mode 100755
index 0000000..7bbd85d
--- /dev/null
+++ b/cgi/hello.cgi
Binary files differ