Find fejlen....(Langt ?)
Er der nogen her, der kan finde fejlen i følgende script ?Jeg har downloadet det fra: http://209.204.223.106/web/scripts/search01/index.html
Ved sammenligning af den originale download + "mit" script, er der ikke ret meget jeg har ændret... men det virker stadig ikke :o(
Jeg får bare beskeden nothing found...
Kan det være det lokale dir, der står forkert ??
Her er scriptet >>>>
#!/usr/bin/perl
#============================================================#
# Author: Vladimir Geshanov Email: info@websigh.com #
# Online documentation: http://www.hotarea.com/web/scripts #
#============================================================#
$basedir = "f:/home/rscdcom/faq/";
$baseurl = "http://www.rscd.com/faq/";
@files = (''ABL5-6xx/*.asp'',''abl70/*.asp'',''calibration/*.asp'',''data/*.asp'',''miscellaneous/*.asp'',''oximeter/*.asp'',''parameters/*.asp'',''qc/*.asp'',''radiance/*.asp'',''replacements/*.asp'',''sample_intro/*.asp'',''Samplers/*.asp'',''utilities/*.asp'',''wet_section/*.asp'');
$icon_src = "http://www.rscd.com/faq-search/images/";
$title = "File Search";
$body = "body bgcolor=#FFFFFF text=#000000 link=#000000 vlink=#000000 alink=#000000";
$font = "font size=2 face=Verdana";
$id = "Web Office";
&parse_form;
&get_files;
&search;
&return_html;
sub parse_form {
read(STDIN, $buffer, $ENV{''CONTENT_LENGTH''});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
}
sub get_files {
chdir($basedir);
foreach $file (@files) {
if ($recurs eq "1") {$ls = `ls -R $file`}
else {$ls = `ls $file`}
@ls = split(/\s+/,$ls);
foreach $temp_file (@ls) {
unless ($temp_file) {next}
if ($temp_file =~ /\:/) {
$temp_file =~ s/:/\//;
$pre = $temp_file;
next;
}
$temp_file = "$pre" . "$temp_file";
if (-d $file) {
$filename = "$file$temp_file";
if (-T $filename) {
push(@FILES,$filename);
}
else {push(@BIN,$filename)}
}
elsif (-T $temp_file) {push(@FILES,$temp_file)}
elsif (-B $temp_file) {push(@BIN,$temp_file)}
}
}
}
sub search {
if ($id eq "Web Office") {
$max = $FORM{''max''} - 1;
unless ($FORM{''max''}) {$max=49}
if ($FORM{''boolean''} eq "PHRASE") {
@terms = ("$FORM{''terms''}");
}
else {@terms = split(/\s+/, $FORM{''terms''})}
$numterms = @terms;
foreach $FILE (@BIN) {
if ($FORM{''boolean''} eq ''AND'' |||| $FORM{''boolean''} eq ''PHRASE'') {
foreach $term (@terms) {
if ($FORM{''case''} eq ''Insensitive'') {
if ($FILE =~ /(\W||^)$term\..*/i |||| $FILE =~ /\/$term\..*/i) {$match+=100000}
if ($FILE =~ /$term/i) {$match+=10000}
if ($match) {
$include{$FILE} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $match";
}
if (!($m2)) {$m2 = $match; undef $match}
elsif (!($m3)) {$m3 = $match; undef $match}
elsif (!($m4)) {$m4 = $match; undef $match}
elsif (!($m5)) {$m5 = $match; undef $match}
elsif (!($m6)) {$m6 = $match; undef $match}
else {last}
}
elsif ($FORM{''case''} eq ''Sensitive'') {
if ($FILE =~ /(\W||^)$term\..*/ |||| $FILE =~ /\/$term\..*/) {$match+=100000}
if ($FILE =~ /$term/) {$match+=10000}
if ($match) {
$include{$FILE} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $match";
}
if (!($m2)) {$m2 = $match; undef $match}
elsif (!($m3)) {$m3 = $match; undef $match}
elsif (!($m4)) {$m4 = $match; undef $match}
elsif (!($m5)) {$m5 = $match; undef $match}
elsif (!($m6)) {$m6 = $match; undef $match}
else {last}
}
}
}
elsif ($FORM{''boolean''} eq ''OR'') {
foreach $term (@terms) {
if ($FORM{''case''} eq ''Insensitive'') {
if ($FILE =~ /(\W||^)$term\..*/i |||| $FILE =~ /\/$term\..*/i) {$match+=100000}
if ($FILE =~ /$term/i) {$match+=10000}
if ($match) {
$include{$FILE} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $match";
}
if (!($m2)) {$m2 = $match; undef $match}
elsif (!($m3)) {$m3 = $match; undef $match}
elsif (!($m4)) {$m4 = $match; undef $match}
elsif (!($m5)) {$m5 = $match; undef $match}
elsif (!($m6)) {$m6 = $match; undef $match}
else {last}
}
elsif ($FORM{''case''} eq ''Sensitive'') {
if ($FILE =~ /(\W||^)$term\..*/ |||| $FILE =~ /\/$term\..*/) {$match+=100000}
if ($FILE =~ /$term/) {$match+=10000}
if ($match) {
$include{$FILE} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $match";
}
if (!($m2)) {$m2 = $match; undef $match}
elsif (!($m3)) {$m3 = $match; undef $match}
elsif (!($m4)) {$m4 = $match; undef $match}
elsif (!($m5)) {$m5 = $match; undef $match}
elsif (!($m6)) {$m6 = $match; undef $match}
else {last}
}
}
}
}
foreach $FILE (@FILES) {
undef $match; undef $m2; undef $m3; undef $m4; undef $m5; undef $m6;
open(FILE,"$FILE");
@LINES = <FILE>;
close(FILE);
$string = join('' '',@LINES);
$string =~ s/\n//g;
@LINES = split(/\s+/,$string);
if ($FORM{''boolean''} eq ''AND'' |||| $FORM{''boolean''} eq ''PHRASE'') {
foreach $term (@terms) {
if ($FORM{''case''} eq ''Insensitive'') {
if ($FILE =~ /(\W||^)$term\..*/i |||| $FILE =~ /\/$term\..*/i) {$match+=100000}
if ($FILE =~ /$term/i) {$match+=10000}
if ($string =~ /<title>.* $term .*<\/title>/i) {unless ($match=~/.*9...$/) {$match+=1000}}
if ($string =~ /<title>.*$term.*<\/title>/i) {unless ($match=~/.*9..$/) {$match+=100}}
if ($FORM{''boolean''} eq ''PHRASE'' |||| $FORM{''quicksearch''} eq "YES") {
if ($string =~ /\W$term\W/i) {$match+=10}
if ($string =~ /$term/i) {$match+=1;}
}
else {
foreach $item (@LINES) {
if ($item =~ /(\W||^)$term(\W||$)/i) {unless ($match=~/.*9.$/) {$match+=10}}
if ($item =~ /$term/i) {unless ($match=~/.*9$/) {$match+=1}}
}
}
if ($match) {
$include{$FILE} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $match";
}
if (!($m2)) {$m2 = $match; undef $match}
elsif (!($m3)) {$m3 = $match; undef $match}
elsif (!($m4)) {$m4 = $match; undef $match}
elsif (!($m5)) {$m5 = $match; undef $match}
elsif (!($m6)) {$m6 = $match; undef $match}
else {last}
}
elsif ($FORM{''case''} eq ''Sensitive'') {
if ($FILE =~ /(\W||^)$term\..*/ |||| $FILE =~ /\/$term\..*/) {$match+=100000}
if ($FILE =~ /$term/i) {$match+=10000}
if ($string =~ /<title>.* $term .*<\/title>/) {unless ($match=~/.*9...$/) {$match+=1000}}
if ($string =~ /<title>.*$term.*<\/title>/) {unless ($match=~/.*9..$/) {$match+=100}}
foreach $item (@LINES) {
if ($item =~ /(\W||^)$term(\W||$)/) {unless ($match=~/.*9.$/) {$match+=10}}
if ($item =~ /$term/) {unless ($match=~/.*9$/) {$match+=1}}
}
if ($match) {
$include{$FILE} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $match";
}
if (!($m2)) {$m2 = $match; undef $match}
elsif (!($m3)) {$m3 = $match; undef $match}
elsif (!($m4)) {$m4 = $match; undef $match}
elsif (!($m5)) {$m5 = $match; undef $match}
elsif (!($m6)) {$m6 = $match; undef $match}
else {last}
}
}
}
elsif ($FORM{''boolean''} eq ''OR'') {
foreach $term (@terms) {
if ($FORM{''case''} eq ''Insensitive'') {
if ($FILE =~ /(\W||^)$term\..*/i |||| $FILE =~ /\/$term\..*/i) {$match+=100000}
if ($FILE =~ /$term/i) {$match+=10000}
if ($string =~ /<title>.* $term .*<\/title>/i) {unless ($match=~/.*9...$/) {$match+=1000}}
if ($string =~ /<title>.*$term.*<\/title>/i) {unless ($match=~/.*9..$/) {$match+=100}}
foreach $item (@LINES) {
if ($item =~ /(\W||^)$term(\W||$)/i) {unless ($match=~/.*9.$/) {$match+=10}}
if ($item =~ /$term/i) {unless ($match=~/.*9$/) {$match+=1}}
}
if ($match) {
$include{$FILE} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $match";
$tterms++;
}
if (!($m2)) {$m2 = $match; undef $match}
elsif (!($m3)) {$m3 = $match; undef $match}
elsif (!($m4)) {$m4 = $match; undef $match}
elsif (!($m5)) {$m5 = $match; undef $match}
elsif (!($m6)) {$m6 = $match; undef $match}
else {last}
}
elsif ($FORM{''case''} eq ''Sensitive'') {
if ($FILE =~ /(\W||^)$term\..*/ |||| $FILE =~ /\/$term\..*/) {$match+=100000}
if ($FILE =~ /$term/i) {$match+=10000}
if ($string =~ /<title>.* $term .*<\/title>/) {unless ($match=~/.*9...$/) {$match+=1000}}
if ($string =~ /<title>.*$term.*<\/title>/) {unless ($match=~/.*9..$/) {$match+=100}}
foreach $item (@LINES) {
if ($item =~ /(\W||^)$term(\W||$)/) {unless ($match=~/.*9.$/) {$match+=10}}
if ($item =~ /$term/) {unless ($match=~/.*9$/) {$match+=1}}
}
if ($match) {
$include{$FILE} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $match";
$tterms++;
}
if (!($m2)) {$m2 = $match; undef $match}
elsif (!($m3)) {$m3 = $match; undef $match}
elsif (!($m4)) {$m4 = $match; undef $match}
elsif (!($m5)) {$m5 = $match; undef $match}
elsif (!($m6)) {$m6 = $match; undef $match}
else {last}
}
}
}
}
}
}
sub return_html {
foreach $key (keys %include) {
($m6,$m5,$m4,$m3,$m2,$m1) = split(" _ ",$include{$key});
$score= $m6+$m5+$m4+$m3+$m2+$m1;
if (length($score) ==1) {$score = "00000" . "$score"}
if (length($score) ==2) {$score = "0000" . "$score"}
if (length($score) ==3) {$score = "000" . "$score"}
if (length($score) ==4) {$score = "00" . "$score"}
if (length($score) ==5) {$score = "0" . "$score"}
$score .= "$key";
if ($numterms == 2 && $FORM{''boolean''} eq "AND") {if ($m2) {$order{$score} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $m1 _ $key";}}
elsif ($numterms == 3 && $FORM{''boolean''} eq "AND") {if ($m3) {$order{$score} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $m1 _ $key";}}
elsif ($numterms == 4 && $FORM{''boolean''} eq "AND") {if ($m4) {$order{$score} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $m1 _ $key";}}
elsif ($numterms == 5 && $FORM{''boolean''} eq "AND") {if ($m5) {$order{$score} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $m1 _ $key";}}
elsif ($numterms == 6 && $FORM{''boolean''} eq "AND") {if ($m6) {$order{$score} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $m1 _ $key";}}
else {$order{$score} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $m1 _ $key";}
}
foreach $key (reverse(keys %order)) {
($m6,$m5,$m4,$m3,$m2,$m1,$filename) = split(" _ ",$order{$key});
$order2{$key} = "$m6 _ $m5 _ $m4 _ $m3 _ $m2 _ $m1 _ $filename"; $ctz++;
if ($ctz > $max) {last}
}
print "Content-type: text/html\n\n";
print "<html><title>Results of Search</title>\n";
print "<$body>\n";
print "<p><$font><b>Search Summary:</b> <br>\n";
print "<table border=0 cellspacing=0><tr><td>";
print "<$font>  Keyword(s): </td>\n";
print " <td><$font color=000000><b>";
$i = 0;
foreach $term (@terms) {
print "$term";
$i++;
if (!($i == @terms)) {
print ", ";
}
}
print "</b></font></td></tr>\n";
print "<tr><td><$font>  Matches: </td>\n";
print " <td><$font><b>$ctz</b></td></tr></table>\n";
print "<center><hr></center>\n";
print "<table border=0>\n";
foreach $key (sort(keys %order2)) {
($m6,$m5,$m4,$m3,$m2,$m1,$filename) = split(" _ ",$order2{$key});
if ($filename =~ /\.exe/i) {$type = "EXECUTABLE file"; $icon = "fold.gif"}
elsif ($filename =~ /\.htm/i) {$type = "HTML file"; $icon = "html.gif"}
elsif ($filename =~ /\.html/i) {$type = "HTML file"; $icon = "html.gif"}
elsif ($filename =~ /\.shtml/i) {$type = "HTML file"; $icon = "html.gif"}
elsif ($filename =~ /\.txt/i) {$type = "TEXT file"; $icon = "txt.gif"}
elsif ($filename =~ /\.log/i) {$type = "LOG file"; $icon = "txt.gif"}
elsif ($filename =~ /\.conf/i) {$type = "CONF file"; $icon = "txt.gif"}
elsif ($filename =~ /\.list/i) {$type = "LIST file"; $icon = "txt.gif"}
elsif ($filename =~ /\.doc/i) {$type = "WORD file"; $icon = "word.gif"}
elsif ($filename =~ /\.hlp/i) {$type = "HELP file"; $icon = "help.gif"}
elsif ($filename =~ /\.cgi/i) {$type = "CGI script"; $icon = "cgi.gif"}
elsif ($filename =~ /\.pl/i) {$type = "PERL script"; $icon = "pl.gif"}
elsif ($filename =~ /\.zip/i) {$type = "ZIP file"; $icon = "zip.gif"}
elsif ($filename =~ /\.bmp/i) {$type = "BMP image"; $icon = "bmp.gif"}
elsif ($filename =~ /\.gif/i) {$type = "GIF image"; $icon = "gif.gif"}
elsif ($filename =~ /\.jpg/i) {$type = "JPG image"; $icon = "jpg.gif"}
else {$type = "Unknown"; $icon = "fold.gif"}
$size = (-s "$filename");
$olddata = $data;
$data = "<tr><td align=right><$font>$ctz.</td><td><img src=''$icon_src/$icon''></td><td><$font><a href=''$baseurl$filename''>$filename</a> </td><td><$font>- Size: </td><td align=right><$font>$size bytes </td><td><$font>- Type: </td><td><$font>$type</td></tr>\n";
$ctz--;
$ctt = $numterms;
foreach $term (@terms) {
if ($ctt == 1) {
$a = chop($m1); $b = chop($m1); $c = chop($m1); $d = chop($m1); $e = chop($m1); $f = $m1;
}
if ($ctt == 2) {
$a = chop($m2); $b = chop($m2); $c = chop($m2); $d = chop($m2); $e = chop($m2); $f = $m2
}
if ($ctt == 3) {
$a = chop($m3); $b = chop($m3); $c = chop($m3); $d = chop($m3); $e = chop($m3); $f = $m3
}
if ($ctt == 4) {
$a = chop($m4); $b = chop($m4); $c = chop($m4); $d = chop($m4); $e = chop($m4); $f = $m4
}
if ($ctt == 5) {
$a = chop($m5); $b = chop($m5); $c = chop($m5); $d = chop($m5); $e = chop($m5); $f = $m5
}
if ($ctt == 6) {
$a = chop($m6); $b = chop($m6); $c = chop($m6); $d = chop($m6); $e = chop($m6); $f = $m6
}
unless ($a) {$a="0"}
unless ($b) {$b="0"}
unless ($c) {$c="0"}
unless ($d) {$d="0"}
unless ($e) {$e="0"}
if ($a eq "9") {$a="8+"}
unless ($f) {$f="0"}
if ($b eq "9") {$b="8+"}
if (($FORM{''boolean''} eq ''PHRASE'' |||| $FORM{''quicksearch''} eq "YES") && $a eq "1") {$a = "Yes"}
if (($FORM{''boolean''} eq ''PHRASE'' |||| $FORM{''quicksearch''} eq "YES") && $b eq "1") {$b = "Yes"}
if ($FORM{''boolean''} eq "PHRASE") {$defo = "Phrase:"}
}
undef $ctt;
$data .= $olddata;
}
unless ($data) {
print "<center><h2><font color=\"#000000\">Nothing Found! Try a similar term.</font></h2></center>\n"}
print "$data</table><hr>\n";
print "</body>\n</html>\n";
}
