#!/usr/local/bin/perl # # search_log.cgi - print search_log # # Copyright (C) 1998 KUROKI Gen . # # Author: KUROKI Gen # Version: 1.1.0 (Aug 30 19:45 JST 1998) # # History: # # 1998/8/30 Version 1.1.0 # 1998/8/21 Version 1.0.0 # # How to install: # # 1. Change the first "#!" line. # 2. Change the "chdir ...;" line. # 3. Copy this script to "$top_dir/$spool/search_log.cgi". # 4. Set its execute permissions by chmod +x search_log.cgi. # #--------------------------------------------------------------------------- require "jcode.pl"; chdir "/net/zakuro/mnt/local/etc/httpd/logs"; print "Content-type: text/html\n\n"; print "Search Log\n"; print "

Search Log

\n\n"; @filelist = ("access_log"); while () { @filelist = (@filelist, $_); } foreach $file (@filelist) { open(IN, "$file"); while () { if ($_ =~ /^[^ ]+ [^ ]+ [^ ]+ \[[^\]]*\] "GET ([^ ]*kuroki\/[^ ]*\/spool\/search.cgi\?key=[^\&][^ "]*scope=[^ "]*).*" [^ ]+ [^ ]+/) { $url = $1; if ($url ne '') { $num{$url} += 1; } } } close(IN); } print "
    \n"; foreach $url (sort {$num{$b} <=> $num{$a}} (keys(%num))) { $raw = $url; $raw =~ s/%(..)/pack("c",hex($1))/ge; &jcode'convert(*raw, 'euc'); $raw =~ s//>/g; &jcode'convert(*raw, 'jis'); $url =~ s//>/g; $url =~ s/"/"/g; printf "
  1. [%d] %s<\/a>
    \n", $num{$url}, $url, $raw; } print "
\n\n"; print "\n";