Makefile 100644 144 144 610 7150310037 11424 0 ustar maraboli dcsc # For gcc
CC= gcc
# For ANSI compilers
#CC= cc
#For Optimization
CFLAGS= -O2
#For debugging
#CFLAGS= -g
RM= /bin/rm -f
#--- You shouldn't have to edit anything else. ---
.c.o:
$(CC) -c $(CFLAGS) $<
all: query post-query
post-query: post-query.o util.o
$(CC) post-query.o util.o -o ./post-query.cgi
query: query.o util.o
$(CC) query.o util.o -o ./query.cgi
clean:
rm -f *.o *.cgi
form-post.html 100644 144 144 5333 7144110505 12630 0 ustar maraboli dcsc
HTML Form Prototipo
HTML Form Prototipo
Este documento muestra los varios tipos soportados por el HTML.
References
Heres a link to
a handy HTML forms reference
.
Prototypical HTML Form /
maraboli@utfsm.cl
post-query.c 100644 144 144 3167 6703373626 12332 0 ustar maraboli dcsc #include
#ifndef NO_STDLIB_H
#include
#else
char *getenv();
#endif
#include
#define MAX_ENTRIES 10000
typedef struct {
char *name;
char *val;
} entry;
char *makeword(char *line, char stop);
char *fmakeword(FILE *f, char stop, int *len);
char x2c(char *what);
void unescape_url(char *url);
void plustospace(char *str);
main(int argc, char *argv[]) {
entry entries[MAX_ENTRIES];
register int x,m=0;
int cl;
printf("Content-type: text/html%c%c",10,10);
if(strcmp(getenv("REQUEST_METHOD"),"POST")) {
printf("This script should be referenced with a METHOD of POST.\n");
printf("If you don't understand this, see this ");
printf("forms overview.%c",10);
exit(1);
}
if(strcmp(getenv("CONTENT_TYPE"),"application/x-www-form-urlencoded")) {
printf("This script can only be used to decode form results. \n");
exit(1);
}
cl = atoi(getenv("CONTENT_LENGTH"));
for(x=0;cl && (!feof(stdin));x++) {
m=x;
entries[x].val = fmakeword(stdin,'&',&cl);
plustospace(entries[x].val);
unescape_url(entries[x].val);
entries[x].name = makeword(entries[x].val,'=');
}
printf("Query Results
");
printf("You submitted the following name/value pairs:%c",10);
printf("
%c",10);
for(x=0; x <= m; x++)
printf("-
%s = %s
%c",entries[x].name,
entries[x].val,10);
printf("
%c",10);
/* de aqui en adelante colocar el codigo nuevo */
}
post-query.cgi 100755 144 144 24110 7150310061 12641 0 ustar maraboli dcsc ELF 4 $ 4 ( 4 4 v v x x ( t t /usr/lib/ld.so.1 5 C 9 $ 7 3 = 1 ' - 2 <