#include #include #include #define MAX_ENTRIES 10000 extern char *getenv(char *e); typedef struct { char *name; char *val; } entry; /* Removes trailing white space, etc */ void wsremove(char *s); 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 ok = 0; int cl; FILE* myfile; int nameid = -1; int linkid = -1; char buf[81]; char recipientc[81]; char returnpage[81]; 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"); 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,'='); if ((!strcmp(entries[x].name, "realname")) && (strcmp(entries[x].val, ""))) { nameid = x; } if ((!strcmp(entries[x].name, "address")) && (strcmp(entries[x].val, ""))) { linkid = x; } } if ((nameid == -1) || (linkid == -1)) { printf("

Form Rejected

"); printf("

Please fill out all fields provided.\n"); printf("Back up to the previous page to try again.\n"); return 0; } else { printf("

Your name should now be entered in the list

"); printf("Go to the alt.music.nin home page.\n"); printf("Go to my home page.\n"); } myfile = fopen("/user/s2/pberry/public_html/scripts/facefile.html","a"); if (!myfile) { printf("file failed to open\n"); return(0); } else { fprintf(myfile,"\n
  • %s
  • ", entries[linkid].val, entries[nameid].val); } fclose(myfile); } /* Removes trailing white space, etc */ void wsremove(char *s) { while(1) { int l = strlen(s); if (!l) { break; } if (isspace(s[l-1])) { s[l-1] = '\0'; } else { break; } } }