Bugzilla – Attachment 1127 Details for
Bug 3144
anti-spam for opac-suggestions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bugfix
0001--3.0.x-bug-3144-Added-antispam-filter-for-anonymo.patch (text/plain), 6.72 KB, created by
Chris Cormack
on 2009-06-22 11:36:00 UTC
(
hide
)
Description:
Bugfix
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2009-06-22 11:36:00 UTC
Size:
6.72 KB
patch
obsolete
>From 24e9618ef156817cbb71dfaf2c359a1c2dc19f52 Mon Sep 17 00:00:00 2001 >From: =?utf-8?q?Jean-Andr=C3=A9=20Santoni?= <jeanandre.santoni@biblibre.com> >Date: Mon, 22 Jun 2009 13:20:44 +0200 >Subject: [PATCH] [3.0.x](bug #3144) Added antispam filter for anonymous suggestions > >This antispam is based on Mollom. You will need to register and get an API key to access it, then set the Mollom* sysprefs. >This patch only use the statistic way to filter spam. A future patch could add a captcha if Mollom can't determinate if content is spam or ham. >--- > installer/data/mysql/en/mandatory/sysprefs.sql | 4 ++ > installer/data/mysql/updatedatabase.pl | 9 +++++ > .../prog/en/modules/opac-suggestions.tmpl | 1 + > opac/opac-suggestions.pl | 33 ++++++++++++++++++-- > 4 files changed, 44 insertions(+), 3 deletions(-) > >diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql >index 7d8016e..2d55548 100644 >--- a/installer/data/mysql/en/mandatory/sysprefs.sql >+++ b/installer/data/mysql/en/mandatory/sysprefs.sql >@@ -215,3 +215,7 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('MergeAuthoritiesOnUpdate', '1', 'if ON, Updating authorities will automatically updates biblios',NULL,'YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowNotForLoanOverride', '0', 'if ON, enables the librarian to choose when they want to check out a notForLoan regular item',NULL,'YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RenewalPeriodBase', 'date_due', 'Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','date_due|now','Choice'); >+ >+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('Mollom',0,'Turn ON Mollom antispam for anonimous suggestions - You MUST set MollomPublicKey and MollomPrivateKey if enabled','','YesNo'); >+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MollomPublicKey','','See: http://mollom.com','','free'); >+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MollomPrivateKey','','See: http://mollom.com','','free'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index aa3e547..02577c5 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -1965,6 +1965,15 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { > $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ILS-DI','0','if ON, ILS-DI server is enabled',NULL,'YesNo');"); > SetVersion ($DBversion); > } >+ >+$DBversion = "3.01.00.039"; >+if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('Mollom',0,'Turn ON Mollom antispam for anonimous suggestions - You MUST set MollomPublicKey and MollomPrivateKey if enabled','','YesNo');"); >+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MollomPublicKey','','See: http://mollom.com','','free');"); >+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MollomPrivateKey','','See: http://mollom.com','','free');"); >+ SetVersion ($DBversion); >+} >+ > if (C4::Context->preference("Version") =~/3\.00/) { > warn "inside 3.00"; > my $perllibdir=C4::Context->config('intranetdir'); >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl >index 56d56fc..0189549 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl >@@ -73,6 +73,7 @@ $.tablesorter.addParser({ > > <!-- TMPL_IF name="op_else" --> > <h1><!-- TMPL_UNLESS NAME="OPACViewOthersSuggestions" --><!-- TMPL_IF NAME="loggedinusername" -->My <!-- /TMPL_IF --><!-- /TMPL_UNLESS -->Purchase Suggestions</h1> >+ <!-- TMPL_IF NAME="spam" -->Sorry, your suggestion has been considered as spam. Please login to your account and try again.<!-- /TMPL_IF --> > <!-- TMPL_IF NAME="suggestions_loop" --> > <!-- TMPL_IF NAME="OPACViewOthersSuggestions" --> > <form action="/cgi-bin/koha/opac-suggestions.pl" method="get"> >diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl >index b739817..218230b 100755 >--- a/opac/opac-suggestions.pl >+++ b/opac/opac-suggestions.pl >@@ -23,6 +23,7 @@ use C4::Auth; # get_template_and_user > use C4::Branch; > use C4::Output; > use C4::Suggestions; >+use Net::Mollom; > > my $input = new CGI; > my $title = $input->param('title'); >@@ -67,13 +68,12 @@ else { > ); > } > >-if ( $op eq "add_confirm" ) { >+sub create_suggestion { > &NewSuggestion( > $borrowernumber, $title, $author, $publishercode, > $note, $copyrightdate, $volumedesc, $publicationyear, > $place, $isbn, '' > ); >- > # empty fields, to avoid filter in "SearchSuggestion" > $title = ''; > $author = ''; >@@ -86,6 +86,33 @@ if ( $op eq "add_confirm" ) { > $op = 'else'; > } > >+if ( $op eq "add_confirm" ) { >+ # If antispam is enabled and user not logged >+ if (C4::Context->preference('Mollom') >+ and $borrowernumber == C4::Context->preference("AnonSuggestions")) { >+ # Instanciates Mollom Antispam >+ my $mollom = Net::Mollom->new( >+ 'public_key' => C4::Context->preference("MollomPublicKey"), >+ 'private_key' => C4::Context->preference("MollomPrivateKey"), >+ ); >+ # Checks the suggestion content >+ my $check = $mollom->check_content( >+ post_title => $title, >+ post_body => $author . ' ' . $publishercode . ' ' . $note >+ ); >+ # You can add a $check->is_unsure case to display a captcha >+ if ($check->is_ham) { >+ create_suggestion; >+ } else { >+ $template->param(spam => 1); >+ $op = 'else'; >+ } >+ # If the user is logged or antispam is turned off, create the suggestion >+ } else { >+ create_suggestion; >+ } >+} >+ > if ( $op eq "delete_confirm" ) { > my @delete_field = $input->param("delete_field"); > foreach my $delete_field (@delete_field) { >@@ -106,7 +133,7 @@ $template->param( > status => $status, > suggestedbyme => $suggestedbyme, > "op_$op" => 1, >- suggestionsview => 1 >+ suggestionsview => 1 > ); > > output_html_with_http_headers $input, $cookie, $template->output; >-- >1.6.0.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 3144
:
1127
|
28504
|
28505
|
28506
|
28507
|
28508
|
28667
|
28701