From grdetil@scrc.umanitoba.ca Fri Jan 22 11:01:17 1999 Date: Fri, 22 Jan 1999 10:48:46 -0600 (CST) From: Gilles Detillieux To: ghutchis@wso.williams.edu Cc: DougB@simplenet.com, grdetil@scrc.umanitoba.ca, htdig@sdsu.edu Subject: Re: htdig: htsearch logging problem I've GOT to get in the habit of reading all my mail before responding to it. I was all set to post a patch for this, when I saw you had beat me to it. Your patch is a little cleaner than mine, but I saw a couple problems with it. First of all, if REMOTE_HOST & REMOTE_ADDR are both undefined, host will remain NULL. Secondly, if ref is NULL, you can't assign to *ref. Here's my amended patch, applied to 3.1.0b4: --- htsearch/Display.cc.envbug Tue Dec 22 20:15:39 1998 +++ htsearch/Display.cc Fri Jan 22 10:41:57 1999 @@ -1017,21 +1017,30 @@ void Display::logSearch(int page, List *matches) { - // Currently unused char *env_host; // Currently unused time_t t; int nMatches = 0; int level = LOG_LEVEL; int facility = LOG_FACILITY; + char *host = getenv("REMOTE_HOST"); + char *ref = getenv("HTTP_REFERER"); + + if (host == NULL) + host = getenv("REMOTE_ADDR"); + if (host == NULL) + host = "-"; + + if (ref == NULL) + ref = "-"; if (matches) nMatches = matches->Count(); openlog("htsearch", LOG_PID, facility); syslog(level, "%s [%s] (%s) [%s] [%s] (%d/%s) - %d -- %s\n", - getenv("REMOTE_HOST"), + host, input->exists("config") ? input->get("config") : "default", config["match_method"], input->get("words"), logicalWords.get(), nMatches, config["matches_per_page"], - page, getenv("HTTP_REFERER") + page, ref ); } According to Geoff Hutchison: > > At 7:37 PM -0400 1/21/99, Doug wrote: > >patch I could test it to see if it helps, but I won't be able to work on > >it myself (which isn't saying much given my lack of C++ ability :). > > This is from the latest CVS tree, so it will probably require some fuzz to > apply correctly: > > diff -u -r1.35 -r1.39 > --- htdig3/htsearch/Display.cc 1999/01/20 19:18:54 1.35 > +++ htdig3/htsearch/Display.cc 1999/01/22 04:40:57 1.39 > @@ -1263,21 +1278,28 @@ > void > Display::logSearch(int page, List *matches) > { > - // Currently unused char *env_host; > // Currently unused time_t t; > int nMatches = 0; > int level = LOG_LEVEL; > int facility = LOG_FACILITY; > + char *host = getenv("REMOTE_HOST"); > + char *ref = getenv("HTTP_REFERER"); > + > + if (host == NULL) > + host = getenv("REMOTE_ADDR"); > + > + if (ref == NULL) > + *ref = '-'; > > if (matches) > nMatches = matches->Count(); > > openlog("htsearch", LOG_PID, facility); > syslog(level, "%s [%s] (%s) [%s] [%s] (%d/%s) - %d -- %s\n", > - getenv("REMOTE_HOST"), > + host, > input->exists("config") ? input->get("config") : "default", > config["match_method"], input->get("words"), logicalWords.get(), > nMatches, config["matches_per_page"], > - page, getenv("HTTP_REFERER") > + page, ref > ); > } > > >announce a "Hey, take a look at this!" type post, and if not can someone > >point me to one? :) We'd also like to be included in the list of sites > >that use htdig if that's appropriate.... the boss is *really* happy with > > Sure you can announce that. I don't think anyone will mind. As for the > list, I suggest filling out the handy form on > http://www.htdig.org/uses.html ;-) > > > -Geoff Hutchison > Williams Students Online > http://wso.williams.edu/ -- Gilles R. Detillieux E-mail: Spinal Cord Research Centre WWW: http://www.scrc.umanitoba.ca/~grdetil Dept. Physiology, U. of Manitoba Phone: (204)789-3766 Winnipeg, MB R3E 3J7 (Canada) Fax: (204)789-3930 ---------------------------------------------------------------------- To unsubscribe from the htdig mailing list, send a message to htdig-request@sdsu.edu containing the single word "unsubscribe" in the body of the message.