#include #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; FILE *temp ; char *name ; static char cmd[256] ; static char submit[256] ; static char last[256] ; static char first[256] ; static char full[256] ; static char work[256] ; static char email[256] ; 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("


\n") ; printf("

PLoP '95 Registration Summary

\n"); printf("You submitted the following information:

%c",10); printf("

%c",10); printf("
\n") ; sprintf(work,"PLOP-%s",full) ; name = tempnam("/tmp",work) ; temp = fopen(name,"w") ; fprintf(temp,"* * * PLoP \'95 Registration For %s * * *\n\n",full) ; strcpy(submit,"tpeckish") ; for (x=0 ; x<=m ; x++) { fprintf(temp,"%s = %s\n",entries[x].name, entries[x].val) ; if (strcmp(entries[x].name,"Submit")==0) { strcpy(submit,entries[x].val) ; } } fclose(temp) ; sprintf(cmd,"mail -s \"Registration: %s\" %s < \"%s\"\n", full,submit,name) ; system(cmd) ; if (strlen(email)) { sprintf(cmd,"mail -s \"PLoP \'95 Receipt: %s\" %s < \"%s\"\n", full,email,name) ; system(cmd) ; } }