;
close(IDB);
## precomile
my $check = '';
$check = 'while (@database) {';
$check .= ' $_ = shift(@database);';
$check .= ' chomp;';
$check .= ' ($ID,$Category,$ELink,$Position,$Qualifier,$Email,$Title,$URL,$Description,$Keys,$desc_image,$title_tag,$site_icon,$Name,$Address,$City,$State,$Zip,$Country,$Phone,$Fax,$startdate,$enddate,$price,$account,$xfactor,$field1,$field2,$field3,$field4,$field5,$field6,$field7,$field8,$field9,$field10)= split(/\|/);';
$check .= ' if($hyperseek{required}) {';
$check .= ' if($Title =~ m/$hyperseek{required}/i) { $scores{$ID} += 10; }';
$check .= ' if($Description =~ m/$hyperseek{required}/i) { $scores{$ID} += 8; }';
$check .= ' if($Category =~ m/$hyperseek{required}/i) { $scores{$ID} += 7; }';
$check .= ' }';
$check .= ' if($hyperseek{optional}) {';
$check .= ' if($Title =~ m/$hyperseek{required}/i) { $scores{$ID} += 3; }';
$check .= ' if($Description =~ m/$hyperseek{required}/i) { $scores{$ID} += 2; }';
$check .= ' if($Category =~ m/$hyperseek{required}/i) { $scores{$ID} += 1; }';
$check .= ' }';
$check .= ' if($hyperseek{screened}) {';
$check .= ' if($_ =~ m/$hyperseek{screened}/i) { delete $scores{$ID}; }';
$check .= ' }';
$check .= ' if($scores{$ID}) {';
$check .= ' @{$results[$count++]}{qw(ID Cat ELink Cool Qualifier Email Title URL Description Keys desc_image title_tag site_icon Name Address City State Zip Country Phone Fax field1 field2 field3 field4 field5)} = split(/\|/);';
$check .= ' $results[$count]{Score} = $scores{$ID};';
$check .= ' }';
$check .= '}';
eval($check);
@results = sort { $b->{'Score'} <=> $a->{'Score'} } @results;
if(! $input{'start'}) { $input{'start'}=0; }
$start = $input{'start'}+1;
## LISTINGS
for $x (0 .. $#results) {
$found++;
next if ($input{'start'} && $found <= $input{'start'});
next if($shown >= $global{'ilink_hits_per_page'});
$shown++;
if($results[$x]{'URL'}) {
$outlinks .= qq! $results[$x]{'Title'}
$results[$x]{'Description'}\n !;
}
else {
$outlinks .= qq! $results[$x]{'Title'}
$results[$x]{'Description'}
\n ! if($results[$x]{'ID'} > 1);
}
}
$hyperseek{'shown'} = $input{'start'} + $shown;
$hyperseek{'remaining'} = $#results - $hyperseek{'shown'};
$hyperseek{'previous'} = $input{'start'} - $global{'ilink_hits_per_page'};
$hyperseek{'next'} = $input{'start'} + $global{'ilink_hits_per_page'};
$end = $input{'start'} + $global{'ilink_hits_per_page'};
$end = $#results if($hyperseek{'remaining'} < 1);
## FOOTER ##
$footer = "
\n";
if($input{'start'}) {
$footer .= qq!
$language{'previous'}
!;
}
if($hyperseek{'remaining'} >= 1) {
$footer .= qq!
$language{'next'}
!;
}
$footer .= "\n";
## HEADER
if(@results) {
$header = "$#results $language{'found'} ... $language{'showing'} $start - $end
\n";
}
else {
$header = "0 $language{'found'}
\n";
}
return("$header $outlinks $footer");
}
sub CategorySelectList {
my(@categories,$catselect,$x,$tmpc) = undef;
@categories = IWEB::ReadCategories();
$catselect = "$language{'category_prompt'}
\n";
}
sub ReadCategories {
my($sub_count,@tmp_subs,$rec,$tmp_subs,%tmp_subs,@sub_categories);
open (CAT,"$hyperseek{'catdb'}");
while ( ) {
$tmp_subs={};
foreach $rec(split /\n/,join '',){
(undef,
@{$tmp_subs[$sub_count++]}{qw(Category SubCategory Count Teaser_Flag)})=split(/\|/,$rec,5);
}
}
close (CAT);
@sub_categories = sort { $a->{'Category'} cmp $b->{'Category'}
or $a->{'SubCategory'} cmp $b->{'SubCategory'} } @tmp_subs;
return(@sub_categories);
}
sub Add_Form {
my ($catlist) = IWEB::CategorySelectList();
my $f1 = qq! !;
my $f2 = qq! !;
my $spellcheck;
if ( $global{ilink_spellcheck} eq "YES" ) { $spellcheck = qq~ $f1 $language{'spell_prompt'} $f2 |
~; }
my ($addform) = qq~
~;
return($addform);
}
sub Post_New {
my $gt=">";
my $lt="<";
my $newline = undef;
## Check Spelling
if($input{'do_spellcheck'}) {
($bad,$badmsg) = IWEB::Spelling_Errors($input{'a_text'}, "$data_dir/dictionary");
if ( $bad ) {
$err = IWEB::ERROR($bad);
IWEB::iWeb_Header($err);
IWEB::Quit();
}
}
if( ! IWEB::lock("hyperseek")) {
$err = IWEB::ERROR("Server is busy");
IWEB::iWeb_Header($err);
IWEB::Quit();
}
### Make the entry ###
$time = time;
$input{'a_xtra'} =~ s/\r\n/ /g;
### Screw with the Description a bit.
## We need to change "|" into "%%%%"
$input{'a_text'} =~ s/\|/\%\%\%\%/g;
## Respect webmasters HTML wishes
$input{'a_text'} = IWEB::Remove_HTML_Tags($input{'a_text'});
## Change \r\n into
so that we can use the formatting entered.
$input{'a_text'} =~ s/\r\n//g;
### FINALLY ... Save it.
$newline = "$time|";
$newline .= "$input{'category'}|";
$newline .= "|";
$newline .= "$global{'Default_Rank'}|";
$newline .= "$input{'Qualifier'}|";
$newline .= "$input{'a_email'}|";
$newline .= "$input{'a_title'}|";
$newline .= "$input{'a_url'}|";
$newline .= "$input{'a_text'}|";
$newline .= "$input{'a_xtra'}|";
$newline .= "$input{'title_tag'}|";
$newline .= "$input{'desc_icon'}|";
$newline .= "$input{'site_icon'}|";
$newline .= "$input{'a_name'}|";
$newline .= "$input{'a_address'}|";
$newline .= "$input{'a_city'}|";
$newline .= "$input{'a_state'}|";
$newline .= "$input{'a_zip'}|";
$newline .= "$input{'a_country'}|";
$newline .= "$input{'a_phone'}|";
$newline .= "$input{'a_fax'}|";
$newline .= "$input{'startdate'}|";
$newline .= "$input{'enddate'}|";
$newline .= "$input{'price'}|";
$newline .= "$input{'account'}|";
$newline .= "$input{'xfactor'}|";
$newline .= "$input{'field1'}|";
$newline .= "$input{'field2'}|";
$newline .= "$input{'field3'}|";
$newline .= "$input{'field4'}|";
$newline .= "$input{'field5'}|";
$newline .= "$input{'field6'}|";
$newline .= "$input{'field7'}|";
$newline .= "$input{'field8'}|";
$newline .= "$input{'field9'}|";
$newline .= "$input{'field10'}|\n";
open (MSG,">>$data_dir/ilink/hyperseek.temp");
print MSG "$newline";
close(MSG);
IWEB::unlock("hyperseek");
print "Location: $global{'ilink_thanks'}\n\n";
IWEB::Quit();
}
sub ul {
my $string = $_[0];
$string =~ s/ /_/g;
return ($string);
}