/* * WWW-Lame * Version 2.0 */ #include #include #include #include #define MAXLINE 256 #define MAXLAME 1000 #define COUNTER_FILE "/html/user/cgi-bin/lame-count" #define LOG_FILE "/html/user/cgi-bin/lame-log" char buf[MAXLAME]; /***********************************************************/ main() { char *s; printf("Content-type: text/html\n\n"); printf(""); lameo("lame lame lame lame lame lame lame lame lame"); printf("\n"); printf("

"); lameo("Welcome to the ever changing lame page"); printf("

\n"); lameo("That's right, every time you "); printf(""); lameo("reload"); printf(""); lameo(" this lame page with your "); lameo("lame WWW browser its lameness changes. Isn't that lame? "); lameo("Actually, it's not as lame as using some lame computer at "); sprintf(buf, "%s", getenv("REMOTE_HOST") ); lameo(buf); lameo(" running some lame browser like "); sprintf(buf, "%s.", getenv("HTTP_USER_AGENT") ); lameo(buf); s=getenv("HTTP_REFERER"); if ( ( s != NULL ) && ( s[0] != NULL ) ) { lameo(" Your last page at "); printf(" ", getenv("HTTP_REFERER") ); sprintf(buf, "%s", getenv("HTTP_REFERER") ); lameo(buf); printf(""); lameo(" is pretty lame too."); } else lameo(" Lame!!! "); lameo(" And to top it all off, by loading this lame page you've increased"); lameo(" the lame access count to a very lame "); get_access_count(); lameo(" hits since July 1, 1995. How lame!\n"); printf("


"); lameo(" If you want to become even more lame, "); lameo(" then download the "); printf(""); lameo("lame C source code"); printf(""); lameo(" for the lame filter, the lame program that made this page lamely possible"); printf("


"); printf("

"); lameo("Go somewhere less lame"); printf(""); printf("
\n"); log_access(); } /* end of main */ /*********************************************************/ int get_access_count() { int access_count; FILE *cf; /* counter file */ char line[50]; /* line buffer for fgets() */ char access_count_string[MAXLINE]; cf = fopen(COUNTER_FILE, "r"); fgets(line, MAXLINE, cf); access_count = atoi(line); fclose(cf); access_count++; printf("%i", access_count); itoa(access_count, access_count_string); cf = fopen(COUNTER_FILE, "w"); fputs(access_count_string, cf); fclose(cf); } /* end of get_access_count() */ /*******************************************************************/ log_access() { FILE *lf; time_t t; lf = fopen(LOG_FILE, "a"); time(&t); sprintf(buf, ">>>> %s", ctime(&t) ); fputs(buf, lf); sprintf(buf, " REMOTE_HOST = %s\n", getenv("REMOTE_HOST") ); fputs(buf, lf); sprintf(buf, " HTTP_REFERER = %s\n", getenv("HTTP_REFERER") ); fputs(buf, lf); sprintf(buf, " HTTP_USER_AGENT = %s\n", getenv("HTTP_USER_AGENT") ); fputs(buf, lf); fclose(lf); } /* end of log_access */ /********************************************************************/ /********************************************************************/ lameo(buf) char buf[]; { register int j, count=0; char out[MAXLAME]; /* time_t t; */ srand((unsigned) getpid()); for(j=0; j=2)) { out[count++]='1'; } else if( buf[j]=='l' && (rand()%3==1)) { out[count++]='|'; } else if(buf[j]=='s'&&(buf[j+1]=='\0'||ispunct(buf[j+1]))){ out[count++]='z'; out[count++]='z'; } else if( (buf[j]=='e' || buf[j]=='E') &&(rand()%5 >= 3) ){ out[count++]='3'; } else out[count++]=buf[j]; } for(j=0; j 0); if (sign < 0) s[i++] = '-'; s[i] = '\0'; reverse(s); } reverse(s) char s[]; { int c, i, j; for (i=0, j=strlen(s)-1; i