sub link_moderate { my $self = shift; my $q = $self->query(); my $output = ""; my $tmpl = $self->load_tmpl('.tmpl'); my $uri = $q->param('uri')||""; my $direction = $q->param('direction')||""; #FIX!! (check for existence of URL) my $statementHandle = $Database->prepare("SELECT COUNT(*) FROM moderation WHERE userkey LIKE '".$q->remote_addr."-$uri';"); my $returnValue = $statementHandle->execute; my @results = $statementHandle->fetchrow_array; if ($results[0] >= 1) { $tmpl->param('message' => "Ahem, you've alredy voted at this. Stop doing it, you won't get any further."); } else { if ($direction eq "up") { my $returnValueStatus = $Database->do("UPDATE saved_search SET moderation=moderation+1 WHERE uri LIKE '$uri';"); $returnValueStatus = $Database->do("INSERT INTO moderation VALUES('".$q->remote_addr."-$uri');"); if ($returnValueStatus == 1) { $tmpl->param('message' => "The moderation value for the url has been updated."); } else { $tmpl->param('message' => "The URL could not be found in the database."); } } elsif ($direction eq "down") { my $returnValueStatus = $Database->do("UPDATE saved_search SET moderation=moderation-1 WHERE uri LIKE '$uri';"); $returnValueStatus = $Database->do("INSERT INTO moderation VALUES('".$q->remote_addr."-$uri');"); if ($returnValueStatus == 1) { $tmpl->param('message' => "The moderation value for the url has been updated."); } else { $tmpl->param('message' => "The URL could not be found in the database."); } $Database->do("DELETE FROM saved_search WHERE moderation <= -15;"); } else { $tmpl->param('message' => "Eh, what direction would '$direction' be?"); } } $tmpl->param('version' => $VERSION); $tmpl->param('number_of_links' => &get_number_of_links); $tmpl->param('list_urls' => &getlast(10)); $output = clean_html($tmpl->output); $self->header_props(-Content_length=>length($output)); return $output; }