Providers
Debian Linux
SDF
MinGW-W64
Verizon
Research
Search Engines
Bing
DuckDuckGo
Google
Metacrawler
SearX
Miscellaneous
Faqs and RFCs
Open Directory Project
W3Schools Online Web Tutorials
Wikipedia
Multimedia
CTIS
For the Pigs Among Us
Family Photos
My House
My Photos (1999-2002?)
My Photos (2005)
Retro Computers
Minions of Mirth
Main
Criticals
Criticals (Single Player)
Ghaqua
Maps and Points of Interest
Miscellaneous
Monster Templates
Miscellaneous
Area Codes
Bard’s Tale
Dungeons & Dragons Online
My Blog
Quote of the Day
RogueBasin
Slashdot
The Adventuer’s Guild
Weather
GitHub:eprive/Z80-MBC3
Programming
Main
Across
Biorhythm
BMP Chips
Complex Roots
Magic Square
Magic Square(js)
Matrix(js)
More DOS Programs
Roll
Strip Dups (bash)
Wacky Wood-Worker
How To
Enlightenment 0.16.7.2 Startup Patch
How to Create an OS X Iconset
My RedHat Howto
SSH to VMS (Deathrow OpenVMS Cluster)
Tools
Allowable Mortgage Interest
Dates and Mileage
Day of the Year
Fun With Time
Downloads
Educational
Utilities
across.c
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include "ncsa.h" #include "query.h" #define MAX_ALLOWED 64 void list_words(char *); int okay_word(char *); int main(int argc, char **argv) { int i, j; /* counters */ int n; /* string length */ int nofoul; /* boolean value, 0 indicates foul language */ char nowstring[255]; char query_string[2048]; char query[255]; char lquery[255]; char pQuery[255]; char *pWhere; time_t now; struct tm nowstruct; FILE *fp; now = time(NULL); strcpy(nowstring, asctime(localtime(&now))); setvbuf( stdout, NULL, _IONBF, 0); /* stdout buffering off */ pWhere = getenv("REMOTE_ADDR"); strcpy(query_string, getenv("QUERY_STRING")); get_var(pQuery, "r", query_string); strncpy(query, pQuery, MAX_ALLOWED); /* Limit characters to alphanumeric, space, dash or period. Replace others with period. Keep in mind that spaces were converted to '+'. */ for (i=0;query[i];i++) query[i]= (isalnum(query[i])||(query[i]=='%')|| (query[i]=='+')||(query[i]=='-'))?query[i]:'.'; for (i=0; query[i]; i++) lquery[i] = tolower(query[i]); printf("<p><h3><center>Thank you for visiting my site on %s \n" "<p>from %s.\n" "<p>Please come again!</center></h3>\n", nowstring, pWhere); if (fp = fopen("../data/across.cnt", "r")) { fscanf(fp, "%d", &n); fclose(fp); if (*pQuery) n++; } else { n=1; } fp = fopen("../data/across.cnt", "w"); fprintf(fp, "%06d\n\n", n); fclose(fp); if (*query) { /* check to see if string contains foul language, if so log it seperately. */ nofoul=okay_word(query); if (nofoul) fp=fopen("../data/across.log", "a"); else fp=fopen("../data/bad_across.log", "a"); if (fp) { fprintf(fp, "%06d, %s, %s, %s", n, lquery, pWhere, nowstring); fclose(fp); } else { printf("<strong><center>Log Failed!</center></strong>\n"); } } if (!nofoul) printf("<p><h1><center><b>But please don't use punctuation or foul language here!!" "</b></center></h1>"); else { plustospace(query); unescape_url(query); printf("<p>Original input was: %s<br>\n", query); printf( "<center><h2><strong>\n" "<table border=10>\n" "<th><center>Output is as follows:</center></th>\n" "<th><center>Previous words have been:</center></th><tr>\n" "<td><center><table border=5>\n" ); n = strlen(query); for (j=0; j<n; j++) { for (i=0; i<n; i++) { printf("<td>%c</td>", query[(j+i)%n]); } printf("<tr>\n"); } printf( "</table></center></td>\n" "<td><form action=\"\"><h4><textarea name=hi OnFocus=\"this.blur();\" cols=24 rows=5 >\n" ); list_words("../data/across.log"); printf( "</textarea></h4></form></td>\n" "</table>\n" "</strong></h2></center>\n" "<hr width=\"60%\">\n" "<table class=\"hidden\" width=\"90%\">\n" "<td class=\"hidden\" link=\"#009999\"><a href=\"http://www.google.com\"><h2>google</h2></a></td>\n" "<td class=\"hidden\" ><form action=\"http://www.google.com/search\">\n" "<input type=\"text\" name=\"q\" size=40 >\n" "</form></td>\n" "<td class=\"hidden\" >source:</td>\n" "<td class=\"hidden\" ><a href=\"/cgi-bin/source.pl?s=../sources/across.c\">across.c</a></td><tr>\n" "<td class=\"hidden\" >another word</td>\n" "<td class=\"hidden\" ><form action=\"/cgi-bin/across.pl\">\n" "<input type=\"text\" name=\"r\" size=40 >\n" "</form></td>\n" "<td class=\"hidden\" >visit:</td>\n" "<td class=\"hidden\" ><a href=\"http://mcsuper5.freeshell.org\"><h4>http://mcsuper5.freeshell.org/</h4></a></td><tr>\n" "</table>\n" ); } return 0; } /* main */ void list_words(char *fname) { FILE *fp; char buffer[255]; /* cut using , for delimiter, use field 2 only. Sort ignoring leading blanks -b, ignore case -f, unique lines only -u. */ system("cut -d, -f2 ../data/across.log | sort -bfu >../data/temp"); if (fp=fopen("../data/temp","r")) { while (!feof(fp)) { fgets(buffer, 255, fp); if (feof(fp)) break; plustospace(buffer); unescape_url(buffer); fputs(buffer, stdout); } fclose(fp); unlink("../data/temp"); } else printf ("\n unable to access temp in list words\n"); } /* list_words */ int okay_word(char *check) { FILE *foul; int okay=1; char word[80]; if (strlen(check)==0) return 0; /* don't add empty string */ foul=fopen("../data/foul.language", "r"); if (!foul) return okay; /* couldn't open file, we'll assume it's ok */ while (EOF!=fscanf(foul, "%s ", word)) { if (strstr(check, word)) { okay = 0; break; } } fclose(foul); return okay; } /* okay_word */
This source has been viewed 7 times.
Monday, 23 June 2025
Michael J. Chappell
Contact me at:
mcsuper5@freeshell.org