#!/usr/bin/perl ##################################################################### # Building a Web Site Index by Keywords to Search # with JavaScript SiteSearch Engine, see: # http://members.tripod.com/~schick/sitesuche.html # # Version 3.0 16Aug99, Perl Version 5.001 Win32 # written by Arnold Schick (copyright) # # This Perl script is free for domestic use # and is provided "as it is" (at your own risk) # # This Perl script spage.cgi is to copy into # your cgi-bin directory on your local machine # (file: http://members.tripod.com/~schick/spage.txt) # AND the related Perl script: key.cgi # (file: http://members.tripod.com/~schick/key.txt) # # The HTML document with the FORM element for these both # scripts are to copy into your Web subdirectory # (file: http://members.tripod.com/~schick/collect.html) # # Names: Perl script : key.cgi # Perl script : spage.cgi # HTML document : collect.html # call: this script is called by key.cgi if an Index File # should be created. # # note: Don't place this script into a public cgi-bin directory # on a public Web server, it's a maintain tool of # your own Web Site files on a local machine (PC) # # if you use Apace Web server on WIN32, use the directive # #!perl in place of #!/usr/bin/perl at top of this script # # For off-line Command-Line using, see below (nothing for beginners) ##################################################################### $now = time(); $now = localtime($now); @date = split(/ /,$now); $content_length = $ENV{'CONTENT_LENGTH'}; read(STDIN, $posted, $content_length); $posted =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $posted =~ s/\+/ /g; # for offline use: uncomment the following line and try that Perl script on command line, like: c:\perl5\perl.exe spage.cgi #$posted="indexfile=c:\\tmp\\my_index.js&spage=c:\\tmp\\search.html&frame="; # the parameters can be changed for your own conditions: # indexfile=... from the previous cgi script (key.cgi) run # spage=..... the search.html page # frame=..... the frame name of result output page, if empty there is no frame used # present=... number of index to continue at old index file -if used # file=..file=..list of files to index with virtual server path @fields = split (/&/, $posted); $h1 ="HT"; $h2 ="ML"; $h3 ="BO"; $h4 ="DY"; foreach $name (@fields) { ($n, $w) = split(/=/, $name); if ($n eq 'file') { @files = (@files, $w); } else { $tokens{$n} = $w; } } print "Content-type: text/html", "\n\n"; print "<$h1$h2>\n
\n"; print "\n"; print "\n";
goto fin;
}
open(INFILE, "<$tokens{'indexfile'}") || (print "Can't open Index File $tokens{'indexfile'}: $!\n");
chomp;
@allLines =
$h3$h4>
$h1$h2>
PART3
;
$p1 = rindex $tokens{'spage'}, "\\"; #DOS backslash
$p2 = rindex $tokens{'spage'}, "\/"; #UNIX slash
$p = $p1 + $p2 +2;
$fn = substr($tokens{'spage'}, $p); #extract filename
if ($n ==1) { $what = "$n indexed page" } else { $what = "$n indexed pages"; }
if (@remove) {
$r = @remove;
if ($r == 1) { $r = " " . $r . " duplicate page was not taken.";
} else { $r = " " . $r . " duplicate pages were not taken."; }
}
print " Site Search Page with $what created and saved to: $tokens{'spage'}
Search my Web Pages
This SiteSearch JavaScript runs in Netscape (version >=3) and
Microsoft Internet Explorer (version >=4) only, if JavaScript is enabled.
$r
This produced Search Page can be viewed and used offline created with Perl Script written by Arnold Schick
by loading that Web document into your browser.
\n";
print "
If the used local work subdirectory path, the virtual subdirectory path at the server
and the path of the Search Page above points to the same subdirectory
there can be used that link above to view the Site Search Page now.\n";
print "
Note: when you'll change now checked files on previous page,
only unwanted files can be unchecked. To check additional files
create before a new index file by reloading of previous page.\n";
print "
If it's O.K.? Yes, put the Site Search Page into the Web.
@date
\n";
print "