/* * identify.c * jskim@www.best5.net */ #include "version3/web.h" #include #include #include #include #include #define DATA_DIR "IDENTIFY" int GetCommentFileName(imgFile, FileName) char *imgFile; char *FileName; { int i; sprintf(FileName, "%s/%s.dsc", DATA_DIR, imgFile); return (int) 1; } int main() { FILE *fp; FILE *fdsc; char *ptr; char comFile[256], email[256]; /* file to identify */ char tmpFile[256]; char myDate[256]; char *comment; postentry entries[10]; char buf[256]; int i, x; int fd; int sendNow = NO; printf("content-type: text/html\n\n"); /* HTML Header */ printf("\n"); i = ProcessPostMethod( entries ); email[0] = '\0'; for (x = 0; x <= i; x++) { if (!strcasecmp(entries[x].name, "comFile")) { strcpy(comFile, entries[x].val); continue; } if (!strcasecmp(entries[x].name, "email")) { strcpy(email, entries[x].val); continue; } if (!strcasecmp(entries[x].name, "comment")) { comment = (char *) malloc(strlen(entries[x].val)+1); strcpy(comment, entries[x].val); continue; } if (!strcasecmp(entries[x].name, "submit") && \ (!strcasecmp(entries[x].val, "send") || !strcasecmp(entries[x].val, "Identify This")) ) { sendNow = YES; continue; } } strcpy(buf, comFile); ptr = (char *)strchr(buf, '/'); strcpy(buf, ptr+1); GetCommentFileName(buf, tmpFile); if (email[0] == '\0') sendNow = NO; if (sendNow) { if ( (fp=fopen(tmpFile, "a")) == NULL ) { printf("File Open Error
\n"); exit(1); } else { getdate(myDate); fd = fileno(fp); flock(fd, LOCK_EX); fprintf(fp, "Comments\n========\n"); fprintf(fp, "From: %s\n", email); fprintf(fp, "Date: %s\n", myDate); fprintf(fp, "File To Comment: %s\n\n", comFile); fprintf(fp, "%s\n", comment); flock(fd, LOCK_UN); fclose(fp); } printf("", '%', '%'); printf("
\n"); printf("\n"); printf("
\n"); printf("
Your comments were successfuly added.\n"); printf("

Thanks.

\n"); printf("
\n"); printf("\n", comFile); printf("\n"); printf("
\n"); printf("
\n"); exit(0); } else { strcpy(buf, comFile); ptr = (char *)strchr(buf, '/'); strcpy(buf, ptr+1); for (i=strlen(buf); i > 0; i--) { if (buf[i] == '.') { if (!strcasecmp(buf+i, ".jpg")) strcpy(buf+i, "-s160.jpg"); else if (!strcasecmp(buf+i, ".gif")) strcpy(buf+i, "-s160.gif"); break; } } printf("

A. P. A. Home\n"); printf("\n"); printf("\n"); printf("\n"); } fdsc = fopen(tmpFile, "r"); if (fdsc != NULL) { printf("\n"); } printf("\n", comFile); printf("
\n", comFile); printf("\n", buf); printf("Identify This Animal

\n"); printf("%s

\n", comFile); printf("Click the left thumbnail to view full image.
\n", comFile); strcpy(buf, comFile); for (i=strlen(buf); i > 0; i--) { if (buf[i] == '.') { strcpy(buf+i, ".txt"); break; } } fdsc = fopen(buf, "r"); if (fdsc != NULL) { printf("

\n"); while(fgets(buf, 256, fdsc)) { printf("%s
", buf); } fclose(fdsc); printf("
\n"); while(fgets(buf, 256, fdsc)) { if (!strcmp(buf, "Comments\n")) { printf("
\n"); continue; } else if (!strcmp(buf, "========\n")) continue; else if (!strncmp(buf, "File To Comment", 15)) continue; else if (!strncmp(buf, "From: ", 6)) { printf("%s
\n", buf); continue; } else if (!strncmp(buf, "Date: ", 6)) { printf("%s
\n", buf); continue; } else printf("%s
\n", buf); } fclose(fdsc); printf("
\n"); printf("
Your Email Address: \n", email); printf("
\n"); printf("
Comments:
"); printf("
\n"); printf(" \n"); printf(" \n"); printf("
\n\n"); } free(comment); exit(0); }