Source for file _antispam_list.view.php
Documentation is available at _antispam_list.view.php
* This file implements the UI controller for the antispam management.
* This file is part of the Quam Plures project - {@link http://quamplures.net/}.
* See also {@link https://launchpad.net/quam-plures}.
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
* @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}.
* @license http://quamplures.net/license.html GNU General Public License (GPL)
* {@internal Open Source relicensing agreement:
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @todo Allow applying / re-checking of the known data, not just after an update!
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
echo '<a href="?ctrl=set_antispam" style="float: right;"><strong>'. T_('Antispam settings'). ' »</strong></a>';
echo '<h2>'. T_('Antispam blacklist'). '</h2>';
if( $current_User->check_perm( 'spamblacklist', 'edit' ) ) // TODO: check for 'add' here once it's mature.
{ // add keyword or domain
// this is when you select "tools->antispam"
$Form = new Form( NULL, 'antispam_add', 'post', 'compact' );
$Form->begin_form( 'fform', T_('Add a banned keyword') );
$Form->hidden( 'action', 'ban' );
$Form->text( 'keyword', $keyword, 50, T_('Keyword/phrase to ban'), '', 80 ); // TODO: add note
* TODO: explicitly add a domain?
* $add_Form->text( 'domain', $domain, 30, T_('Add a banned domain'), 'note..', 80 ); // TODO: add note
$Form->hidden( 'aspm_source', 'local' ); // local means manually entered
$Form->end_form( array( array( 'submit', 'submit', T_('Check & ban...'), 'SaveButton' ) ) );
echo '<p class="center">'. T_('Any URL containing one of the following keywords will be banned from posts, comments and logs.');
if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
echo '<br />'. T_( 'If a keyword restricts legitimate domains, click on the green tick to stop banning with this keyword.');
* Query antispam blacklist:
$keywords = param( 'keywords', 'string', '', true );
if( !empty( $keywords ) )
$kw_array = split( ' ', $keywords );
foreach( $kw_array as $kw )
$where_clause .= 'aspm_string LIKE "%'. $DB->escape($kw). '%" AND ';
$sql = 'SELECT aspm_ID, aspm_string, aspm_source
WHERE '. $where_clause. ' 1';
$Results = new Results( $sql, 'antispam_' );
$Results->title = T_('Banned keywords blacklist');
* Callback to add filters on top of the result set
$Form->text( 'keywords', get_param('keywords'), 20, T_('Keywords'), T_('Separate with space'), 50 );
$Results->filter_area = array(
'callback' => 'filter_antispam',
'url_ignore' => 'results_antispam_page,keywords',
'all' => array( T_('All keywords'), '?ctrl=antispam' ),
$Results->cols[] = array(
'order' => 'aspm_string',
'td' => '%htmlspecialchars(#aspm_string#)%',
static $aspm_sources = NULL;
if( $aspm_sources === NULL )
'local' => T_('Entered'),
'reported' => T_('Banned'),
'central' => T_('Shortened'),
return $aspm_sources[$row->aspm_source];
$Results->cols[] = array(
'order' => 'aspm_source',
'td' => '%antispam_source2({row})%',
// Check if we need to display more:
if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
{ // User can edit, spamlist: add controls to output columns:
// Add CHECK to 1st column:
$Results->cols[0]['td'] = action_icon( TS_('Allow keyword back (Remove it from the blacklist)'), 'allowback',
'?ctrl=antispam&action=remove&hit_ID=$aspm_ID$' )
. $Results->cols[0]['td'];
// Add a column for actions:
return $output. '[<a href="'. regenerate_url( 'action,keyword', 'action=ban&keyword='
T_('Check hit-logs and comments for this keyword!'). '">'.
$Results->cols[] = array(
'td' => '%antispam_actions({row})%',
|