MOD 2
====================
taking out the ratings..
====================
first in review.cgi..
delete:
Code:
foreach (@rating_fields) {
unless (($in{$db_cols[$_]} =~ /^\d\d?/) and ($in{$db_cols[$_]} >= 1) and ($in{$db_cols[$_]} <= 10)) {
&site_html_review_failure ("Your $db_cols[$_] '$in{$db_cols[$_]}' is invalid.") and return;
}
}
if ($in{$db_cols[$db_review]}) {
($in{$db_cols[$db_contact_name]}) or &site_html_review_failure ("$db_cols[$db_contact_name] (Can not be left blank with Review)") and return;
($in{$db_cols[$db_contact_email]}) or &site_html_review_failure ("$db_cols[$db_contact_email] (Can not be left blank with Review)") and return;
}
then in site_html.pl or site_html_templates.pl
delete sub get_rating_graph...
delete sub get_rating_image (unless you want to use it for links.. much shorter than pheonix's)
then change your sub get_reviews to:
Code:
sub get_reviews {
my ($id) = @_;
my (@values, $reviews);
require "$db_lib_path/review.def";
open (DB, "<$db_file_name") or &cgierr ("Can't open review file '$db_file_name'. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
/^#/ and next LINE;
/^\s*$/ and next LINE;
chomp;
@values = &split_decode($_);
if ($values[$db_linkid] eq $id) {
($values[$db_review]) and (push (@reviews, @values)) and ($reviews++);
}
}
close DB;
if ($reviews) {
@reviews = &build_sorthit (@reviews);
$totalpages = int($reviews/$reviews_per_page);
if ($totalpages < $reviews/$reviews_per_page) { $totalpages++; }
if ($page > $totalpages) { $page = 1; }
$displayed1 = ($page-1) * $reviews_per_page + 1;
$displayed2 = $reviews_per_page * $page;
$displayed2 = $displayed2 - ($displayed2 - $reviews) if ($page == $totalpages);
my $prev_page = $page-1;
my $next_page = $page+1;
$span = qq~<font color="#c0c0c0"><b>< Previous</b></font>~ if ($prev_page == 0);
$span = qq~<a href="$build_review_url?$links_key=$id"><b>< Previous</b></a>~ if ($prev_page == 1);
$span = qq~<a href="$build_review_url?$links_key=$id&page=$prev_page"><b>< Previous</b></a>~ if ($prev_page > 1);
$span .= qq~ <font color="#808080">/</font> ~;
if ($page == $totalpages) { $span .= qq~<font color="#c0c0c0"><b>Next ></b></font>~; }
else { $span .= qq~<a href="$build_review_url?$links_key=$id&page=$next_page"><b>Next ></b></a>~; }
@reviews = @reviews[(($#db_cols+1)*($reviews_per_page*($page-1))) .. $#reviews] if ($page > 1);
for ($i = 0; $i < $reviews_per_page; $i++) {
%tmp = &array_to_hash ($i, @reviews);
last if ($tmp{$db_key} eq "");
$results .= &site_html_review (%tmp);
}
}
}
now.... in site_html_review_form.. you are going to get alot of unknown tags.. just delete each one of them from the list.. except for the ones for review.. and take them out of the template..
for people not using templates.. it should just show up blank on the page.. delete them as you find them!
now in nph-build.cgi you are going to have to change your update_ratings to the old one..
here is the code..
Code:
sub build_update_ratings {
# --------------------------------------------------------
# Updates the ratings of each link.
#
# Let's collect the ratings.
my ($id, %rating, %votes, @values, $input);
opendir (HITS, $db_rates_path) or &cgierr ("unable to open ratings directory: $db_rates_path. Reason: $!");
while (defined ($id = readdir HITS)) {
next unless ($id =~ /^\d+$/);
open (HIT, "$db_rates_path/$id") or &cgierr ("unable to open rating counter: $db_rates_path/$id. Reason: $!");
my $input = <HIT>;
chomp $input;
($votes{$id}, $rating{$id}) = split /\s/, $input;
close HIT;
}
closedir HITS;
# Update the links database.
my $output = '';
INLINE: {
local ($^I, @ARGV) = ('.bak', $db_links_name);
LINE: while (<> ) {
/^#/ and print OUT and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = split /\Q$db_delim\E/;
$id = $values[0];
if (exists $votes{$id}) {
$values[$db_rating] = (($values[$db_rating] * $values[$db_votes]) + $rating{$id}) /
($values[$db_votes] + $votes{$id});
$values[$db_rating] = sprintf ("%.2f", $values[$db_rating]);
$values[$db_votes] = $values[$db_votes] + $votes{$id};
$output .= "\tUpdating rating to $values[$db_rating] for link id $id\n";
}
print &join_encode(&array_to_hash(0, @values));
}
}
print $output;
# Delete the ratings.
foreach (keys %votes) {
unlink ("$db_rates_path/$_") or &cgierr ("unable to remove rating: $db_rates_path/$_. Reason: $!");
}
}
then in review.def you need to take out the Rating field...
and also this line:
Code:
# Rating Fields
@rating_fields = (4);
that should be all......
jerry