#include <stdio.h> #include <string.h> #include <time.h> #define LF 10 #define CR 13 void getword(char *word, char *line, char stop) { int x=0, y; for(x=0;((line[x]) && (line[x] != stop)); x++) word[x] = line[x]; word[x] = '\0'; if(line[x]) ++x; y=0; while(line[y++] = line[x++]); } char *makeword(char *line, char stop) { int x=0, y; char *word = (char *) malloc(sizeof(char) * (strlen(line) +1)); for(x=0; ((line[x]) && (line[x] != stop)); x++) word[x] = line[x]; word[x] = '\0'; if(line[x]) ++x; y=0; while(line[y++] = line[x++]); return word; } char *fmakeword(FILE *f, char stop, int *cl) { int wsize; char *word; int ll; wsize = 102400; ll = 0; word = (char *) malloc(sizeof(char) * (wsize + 1)); while(1) { word[ll] = (char)fgetc(f); if(ll == wsize) { word[ll+1] = '\0'; wsize += 102400; word = (char *) realloc(word,sizeof(char) * (wsize + 1)); } --(*cl); if((word[ll] == stop) || (feof(f)) || (!(*cl))) { if(word[ll] != stop) ll++; word[ll] = '\0'; return word; } ++ll; } } char x2c(char *what) { register char digit; digit = (what[0] >= 'A' ? ((what[0] &0xdf) - 'A')+10 : (what[0] - '0')); digit *= 16; digit += (what[1] >='A' ? ((what[1] & 0xdf) -'A') +10 : (what[1] - '0')); return(digit); } void unescape_url(char *url) { register int x,y; for(x=0,y=0;url[y];++x,++y) { if((url[x] =url[y]) =='%') { url[x] = x2c(&url[y+1]); y += 2; } } url[x] = '\0'; } void plustospace(char *str) { register int x; for(x=0; str[x]; x++) if (str[x] == '+') str[x] = ' '; } int rind(char *s, char c) { register int x; for(x=strlen(s) - 1; x != -1; x--) if(s[x] ==c) return x; return -1; } int getline(char *s, int n, FILE *f) { register int i=0; while(1) { s[i] = (char)fgetc(f); if(s[i] ==CR) s[i] = fgetc(f); if((s[i] ==0x4) || (s[i] ==LF) || (i ==(n-1))) { s[i] = '\0'; return (feof(f) ? 1:0); } ++i; } } void send_fd(FILE *f, FILE *fd) { int num_chars=0; char c; while (1) { c = fgetc(f); if(feof(f)) return; fputc(c,fd); } } int ind(char *s, char c) { register int x; for(x=0; s[x]; x++) if(s[x] == c) return x; return -1; } void escape_shell_cmd(char *cmd) { register int x,y,l; l = strlen(cmd); for(x=0; cmd[x]; x++) { if(ind("&;\"|*?~<>^()[]{}$\\",cmd[x]) != -1) { for(y=l+1; y>x; y--) cmd[y] = cmd[y-1]; l++; cmd[x] = '\\'; x++; } } } void paste() { int x, y, z; char Word[400], index[5][80], Char[80]; char Date[20], c_year[3], c_mon[3], c_day[3]; int i_year, i_mon, i_day; time_t ltime; struct tm *t; FILE *fr1, *fw1, *test; time(<ime); t = localtime(<ime); if((test=fopen("/www/cgi-bin/text/post.txt","a")) == NULL) { exit(0); } fputs("this is test",test); if((fr1=fopen("/www/cgi-bin/text/post.tmp","r")) == NULL) { exit(0); } if((fw1=fopen("/www/cgi-bin/text/post.ind","a")) == NULL) { exit(0); } while(fgets(Word,400,fr1) != NULL) { fputs("This is test",test); y=0; for(x=0; x<5; x++) { for(z=0; Word[y] != ':'; y++) { Char[z] = Word[y]; z++; } Char[z] = '\0'; strcpy(index[x],Char); y++; } strcpy(Date,index[2]); y = 0; for(x=0; Date[x] != '/'; x++) { c_year[y] = Date[x]; y++; } c_year[y] = '\0'; y = 0; x++; for(; Date[x] != '/'; x++) { c_mon[y] = Date[x]; y++; } c_mon[y] = '\0'; y = 0; x++; for(; Date[x] != '\0'; x++) { c_day[y] = Date[x]; y++; } c_day[y] = '\0'; sscanf(c_year,"%d",i_year); sscanf(c_mon,"%d",i_mon); sscanf(c_day,"%d",i_day); if(i_year >= t->tm_year) { if(i_mon >= t->tm_mon+1) { if(i_day >= t->tm_mday) { for(x=0; x<5; x++) { fputs(index[x],fw1); fputc(':',fw1); } } } } fputc('\n',fw1); /* else { strcpy(Char,"rm /www/www_home"); strcat(Char,index[4]); for(x=0; Char[x] != ':'; x++) { Word[x] = Char[x]; } strcat(Word,'\0'); if(system(Word)) { exit(0); } } */ } fclose(fr1); fclose(fw1); fclose(test); }