Gossamer Forum
Home : Products : Links 2.0 : Customization :

Review.cgi, problems, lol

Quote Reply
Review.cgi, problems, lol
Ok, i need help

I used to run a site with Links v2 and Widgetz review_it mod, however, ratings were not necessary so I did what widget said in

http://gossamer-threads.com/perl/forum/showthreaded.pl?Cat=&Board=L2Cust&Number=35397&Search=true&Forum=All_Forums&Words=$totalpages = int&Match=Entire Phrase&Searchpage=0&Limit=25&Old=allposts

it worked good and was fine for my old site, however, that was nearly 2 years ago and the site which i backed up to CD had no rating functionality. I would like to add this back to the site i am currently building but dont have the code for the sub get_reviews subroutine, the rest was easy to add back but i cant get review_it to add the graph, highest rated, lowest rated, or average rated. BTW, i do have the get_rating_graph and get_rating_image subroutines, just not the code to link them to templates.

I do believe that i require the origional get_reviews subroutine working again, as all i have is:

sub get_reviews {
my ($id) = @_;
my (@values);
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>< Back</b></font>~ if ($prev_page == 0);
$span = qq~<a href="$build_review_url?$links_key=$id"><b>< Back</b></a>~ if ($prev_page == 1);
$span = qq~<a href="$build_review_url?$links_key=$id&page=$prev_page"><b>< Back</b></a>~ if ($prev_page > 1);
$span .= qq~ <font color="#808080">/</font> ~;
if ($page == $totalpages) { $span .= qq~<font color="#c0c0c0"><b>Forward ></b></font>~; }
else { $span .= qq~<a href="$build_review_url?$links_key=$id&page=$next_page"><b>Forward ></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 "");
$review_results .= &site_html_review (%tmp);
}
}
}

I do realise that widgetz has stopped distributing this mod, but seeing as i did have the mod before this occurred i was wondering if someone who has the source for this subroutine could email it me at icebot134@hotmail.com

Then maybe i could add ratings back :)