[snip]
I tried some reconfiguring of this line under Print the matched record, with out success.
print "<LI><A HREF=". $linkurl . ">" . $linktitle . "</A> : $linkdescrip</B><BR>\n";
Thank you in advance for any help
This is the Script Below.
#!/usr/local/bin/perl
####################################################################
# URL Search Engine
# Copyright 1996 [snip]
# Written By : [snip]
# Date Last Modified : Jan 14, 1997
####################################################################
#
# This script is free of charge.
# Please link back to [snip], thank you :-)
#######
#
# Jan 14, stops people from entering html tags, converts < to <
#
####################################################################
# $linktitle, $linkdescrip, $linkwords, $linkemail, $linkurl
# define some global variables
$fields = 5; # Number of fields in each record
$filename = "urls.txt"; # The database text file
$results = 1000; # maximum number of results to display
&parse_form;
$searchstring = $FORM{'searchstring'};
&addrecord if ($searchstring eq "**ADD RECORD**");
&open_file("FILE1","",$filename);
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF VLINK=#800040 ALINK=#800040>\n";
print "<TITLE>Search Results</TITLE>\n";
print "<CENTER><BR>\n";
print "<FONT SIZE=5 COLOR=000000 FACE=\"ARIAL,TIMES NEW ROMAN\">Search Results</FONT></CENTER>\n";
print "<HR width=80% noshade><BR><UL>\n";
$counter = 0;
while (($line = &read_file("FILE1")) && ($counter < $results)) {
# split the fields at the ¦ character
@tabledata = split(/\s*\¦\s*/,$line ,$fields);
&check_record;
if ($found == 1) {
$counter++;
&print_record;
}
}
close(FILE1);
print "</UL>\n";
if ($counter == 0) {
print "<BR><B> Sorry, No Matches were found.</B>\n";
}
print "<CENTER>\n";
print "<HR width=80% noshade>\n";
print "<FONT SIZE=3 COLOR=000000 FACE=\"ARIAL,TIMES NEW ROMAN\">URL Search Brought to you by : <A HREF=\"http://www.example.com\">Anytown Bunk and Trash Your OEM Parts Source</A></FONT></CENTER>\n";
print "</CENTER>\n";
print "</A></BODY></HTML>\n";
#########################################
#
# Print the matched record
#
#########################################
sub print_record {
print "<BR>\n";
print "<LI><A HREF=". $linkurl . ">" . $linktitle . "</A> : $linkdescrip</B><BR>\n";
}
##########################################
#
# Check to see if record matches search criteria
#
##########################################
sub check_record {
# get the data from the record read from the file. $tabledata
$linktitle = $tabledata[0]; #build the search line with all fields we want to search in #search by keywords $stlen = length($searchstring); # if search string is too small .. set found to 1 ############################################ sub addrecord { $linktitle = $FORM{'linktitle'}; # Convert < tags to < &write_file("FILE1",$linktitle . "¦". $linkdescrip. "¦" .$linkwords ."¦" .$linkemail ."¦" .$linkurl ."\n"); sub parse_form { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); $value =~ tr/+/ /; $FORM{$name} = $value; sub open_file { local ($filevar, $filemode, $filename) = @_; sub read_file { local ($filevar) = @_; <$filevar>; sub write_file { local ($filevar, $line) = @_; print $filevar ($line); [1][edited by: phranque at 8:29 am (utc) on Feb. 8, 2008]
$linkdescrip = $tabledata;
$linkwords = $tabledata[2];
$linemail = $tabledata[3];
$linkurl = $tabledata[4];
chop($linkurl);
$searchline = $linktitle . " " . $linkdescrip . " " . $linkwords;
# only perform the keyword search if the length of the search string is greater than 2
# don't think we want people to search for and or or etc.
$sfound = 0;
$found = 0;
$notfound = 1;
if ($stlen > 1) {
@words = split(/ +/,$searchstring);
foreach $aword (@words) {
if ($searchline =~ /\b$aword/i) {
$sfound = 1;
}
else {
$notfound = 0;
}
}
}
if ($sfound == 1 && $notfound == 1) {
$found = 1;
}
if ($stlen <= 1) {
$found = 1;
}
#if page doesn't have a title then return not found
$tlen = length($linktitle);
if ($tlen < 1) {
$found = 0;
}
}
#
# Add Record
#
############################################
$linkdescrip = $FORM{'linkdescrip'};
$linkwords = $FORM{'linkwords'};
$linkemail = $FORM{'linkemail'};
$linkurl = $FORM{'linkurl'};
$linktitle =~ s/</\</g;
$linkdescrip =~ s/</\</g;
$linkwords =~ s/</\</g;
$linkemail =~ s/</\</g;
$linkurl =~ s/</\</g;
&open_file("FILE1",">>",$filename);
close(FILE1);
print "Content-type: text/html\n\n";
print "<html><head><title>Thank You</title></head>\n";
print "<body><BR><h3><CENTER>Thank You For Adding to this database</CENTER></h3>\n";
print "</body></html>\n";
exit;
}
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
}
}
open ($filevar,$filemode . $filename) ¦¦
die ("Can't open $filename");
}
}
}
[edit reason] removed specifics [/edit]
Thank you for your reply, it really helped. Your information did stop it from reloading into the same window. That was a big help. (I now understand I should have been looking in a different area for the solution.)
But it didn't do completely what I was looking for.
It now opens up in a different window. I thought, I called out for it to load into the main.html frame, but it now opens a new IE window and shows up there.
I would appreciate any additional help, from anyone!
Thanks,
doharr
It now opens up in a different window. I thought, I called out for it to load into the main.html frame, but it now opens a new IE window and shows up there.
Look at my original example again. When you target a link or a form, there has to be a named frame to target it to. If there isn't, it will do as you said - open a new window (and the "name" of that window will be whatever your target is.)
In my example I named the frame containing main.html "frameName". So you don't want
target="main.html"
because "main.html" is the content of the frame named "frameName." You want
target="frameName"
Also the originating form has to be part of the frameset. So your search form has to be one of the files in the current frameset. If you're hoping to target a frameset from a different page, that's a different story. What you need to do then is build the frameset on the fly.