htdocs: Added simple web archive
This commit is contained in:
parent
849292f821
commit
de4fb9bc2d
|
@ -0,0 +1,20 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
char line[4096] = {0};
|
||||
printf("Content-type: text/plain\n\n");
|
||||
|
||||
FILE *f = fopen("data.txt", "rt");
|
||||
if (f) {
|
||||
int c;
|
||||
while (EOF != (c = fgetc(f)))
|
||||
printf("%c", c);
|
||||
fclose(f);
|
||||
} else {
|
||||
printf("failed to open data\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static void unencode(const char *src, char *dest)
|
||||
{
|
||||
for (; *src; src++, dest++) {
|
||||
if (*src == '+')
|
||||
*dest = ' ';
|
||||
else if (*src == '%') {
|
||||
int code;
|
||||
if (sscanf(src+1, "%2x", &code) != 1)
|
||||
code = '?';
|
||||
*dest = code;
|
||||
src += 2;
|
||||
} else
|
||||
*dest = *src;
|
||||
}
|
||||
*dest = '\0';
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char *query_string = getenv("QUERY_STRING");
|
||||
if (query_string == NULL) {
|
||||
printf("Content-type: text/plain\n\n");
|
||||
printf("empty/invalid data\n");
|
||||
} else if (strlen(query_string) > 1024) {
|
||||
printf("Content-type: text/plain\n\n");
|
||||
printf("data size limit exceeded (1024)\n");
|
||||
} else {
|
||||
char data[4096] = {0};
|
||||
unencode(query_string, data);
|
||||
|
||||
FILE *f = fopen("data.txt", "a");
|
||||
fprintf(f,"%s\n",data);
|
||||
fclose(f);
|
||||
|
||||
printf("Content-type: text/plain\n\n");
|
||||
printf("saved\n");
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>Submit file</h1>
|
||||
|
||||
<form action="http://cppcheck.sf.net/cgi-bin/submit.cgi" method="GET">
|
||||
|
||||
Name:<br>
|
||||
<input name="name" size="30">
|
||||
|
||||
<br><br>
|
||||
Copy/paste the file data:<br>
|
||||
<textarea name="data" rows="10" cols="40" maxlength="512"></textarea>
|
||||
|
||||
<br><br>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue