you were darn close leonard, my man... here is the way i got it to work
i will start from the beginning in case someone else wants to do this (all credit to leonard for the starting point)...
in comments4l.cgi
1) add this subroutine
before sub display
Code:
sub rate_it {
# --------------------------------------------------------
require "$db_lib_path/links.def";
my $id = $in{'LID'};
my $delim = quotemeta($db_delim);
my $time = time();
my $rating = $in{'rate'};# Make sure we have a valid rating.
unless (($rating =~ /^\d\d?/) and ($rating >= 1) and ($rating <= 10)) {
&site_html_rate_failure ("Your rating '$rating' is invalid.");
return;
}
# Let's get the link information.
my %rec = &get_record ($id);
($rec{$db_key} eq $id) or (&site_html_rate_failure ("Unable to find link with ID '$id'.") and return);# Increase the rating.
if (open (HIT, "<$db_rates_path/$id")) {
my $input = <HIT>; chomp $input;
($votes, $old_rating) = split /\s/, $input;
chomp ($old_time = <HIT>);
chomp (@IP = <HIT>);
(($time - $old_time) > 21600) and (@IP = ());
foreach $ip (@IP) {
$ip eq $ENV{'REMOTE_ADDR'} and ($visited++ and last);
}
close HIT; if (!$visited) {
push (@IP, $ENV{'REMOTE_ADDR'});
$votes = $votes + 1;
$rating = $rating + $old_rating;
open (HIT, ">$db_rates_path/$id") or &cgierr ("Can't open for output counter file. Reason: $!");
if ($db_use_flock) { flock (HIT, 2) or &cgierr ("Can't get file lock. Reason: $!"); }
local $" = "\n";
print HIT "$votes $rating\n$time\n@IP";
close HIT;
}
else {
;
}
}
else {
open (HIT, ">$db_rates_path/$id") or &cgierr ("Can't increment counter file '$db_rates_path/$id'. Reason: $!");
print HIT "1 $rating\n$time\n$ENV{'REMOTE_ADDR'}";
close HIT;
}
}
2) add what is in red to
sub display routine:
Code:
require "$db_lib_path/links.def";
if ($in{$db_key} =~ /^\d+$/) {
my (%rek) = &get_record ($in{$db_key});
($rek{$db_key} eq $in{$db_key}) ?
&site_html_rate_form (%rek) :
&site_html_rate_failure ("Unkown Link ID: $in{$db_key}");
} my %rec = &get_record ($in{'LID'});
$pheader= "There are $links comments for <b>$rec{'Title'}</b>
<br><br>(<b>$rate1</b> people liked the site)
(<b>$rate2</b> thought it was okay)
(<b>$rate3</b> didn't like it)
";
[/code]
3) still in sub display, replace
Code:
require "$db_lib_path/links.def";
my %rec = &get_record ($in{'LID'});
$pheader= "There are $links comments for <b>$rec{'Title'}</b>
<br><br>(<b>$rate1</b> people liked the site)
(<b>$rate2</b> thought it was okay)
(<b>$rate3</b> didn't like it)
";
with
Code:
require "$db_lib_path/links.def";
if ($in{$db_key} =~ /^\d+$/) {
my (%rek) = &get_record ($in{$db_key});
($rek{$db_key} eq $in{$db_key}) ?
&site_html_rate_form (%rek) :
&site_html_rate_failure ("Unkown Link ID: $in{$db_key}");
}
my %rec = &get_record ($in{'LID'});
$pheader= "There are $links comments for <b>$rec{'Title'}</b>
<br><br>Overall it is rated $rec{'Rating'} on a scale of 1 to 10 (ten being best)
";
4) yet still in sub display replace
Code:
<INPUT type="radio" name=Rating value = 2><IMG SRC="$db_images/up.jpg" ALT="Great site">
<INPUT type="radio" name=Rating value = 1><IMG SRC="$db_images/okay.jpg" ALT="Okay site">
<INPUT type="radio" name=Rating value = 0><IMG SRC="$db_images/down.jpg" ALT="Terrible site">
with
Code:
<p><select name=rate>
<option>---
<option>1
<option>2
<option>3
<option>4
<option>5
<option>6
<option>7
<option>8
<option>9
<option>10
</select>
5) in sub post_comment add what is in red
Code:
close DB;
&rate_it; my ($key, $status, $line, $output);
$name = $in{'Contact Name'};
6) in site_html_templates.pl replace the entire sub site_html_commenter2 routine with
Code:
sub site_html_commenter2 {
# --------------------------------------------------------
# This routine is used to display what a comment/review should look
# like.
my %rec = @_;
return &load_template ('comment4.html', {
ratepict => $rec{'Rating'},
%rec,
%globals
});
}
I think that is everything... hope it helps :)
Vote Stinky