Source for file b2antispam.php
Documentation is available at b2antispam.php
* Antispam blacklist handling
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
require_once (dirname(__FILE__
).
'/_header.php');
require_once (dirname(__FILE__
).
'/'.
$admin_dirout.
'/'.
$core_subdir.
'/_functions_antispam.php');
$admin_pagetitle =
T_('Antispam');
param( 'action', 'string' );
param( 'confirm', 'string' );
param( 'keyword', 'string' );
param( 'disp_blacklist', 'integer', 0 );
require
(dirname(__FILE__
).
'/_menutop.php');
require
(dirname(__FILE__
).
'/_menutop_end.php');
$current_User->check_perm( 'spamblacklist', 'view', true );
$current_User->check_perm( 'spamblacklist', 'edit', true );
$keyword =
substr( $keyword, 0, 80 );
param( 'delhits', 'integer', 0 );
param( 'delcomments', 'integer', 0 );
param( 'blacklist', 'integer', 0 );
param( 'report', 'integer', 0 );
// Check if the string is too short,
// it has to be a minimum of 5 characters to avoid being too generic
echo
'<div class="panelinfo">';
printf( '<p>'.
T_('The keyword [%s] is too short, it has to be a minimum of 5 characters!').
'</p>', htmlspecialchars($keyword) );
if( $delhits &&
$deluxe_ban )
{ // Delete all banned hit-log entries
echo
'<div class="panelinfo">';
$sql =
'DELETE FROM T_hitlog
WHERE referingURL LIKE '.
$DB->quote('%'.
$keyword.
'%');
if( $delcomments &&
$deluxe_ban )
{ // Then all banned comments
echo
'<div class="panelinfo">';
$sql =
'DELETE FROM T_comments
WHERE comment_author LIKE '.
$DB->quote('%'.
$keyword.
'%').
'
OR comment_author_url LIKE '.
$DB->quote('%'.
$keyword.
'%').
'
OR comment_content LIKE '.
$DB->quote('%'.
$keyword.
'%');
echo
'<div class="panelinfo">';
if( $report &&
$report_abuse )
{ // Report this keyword as abuse:
if( !( $delhits ||
$delcomments ||
$blacklist ||
$report ) )
{ // Nothing to do, ask user:
<form action="b2antispam.php" method="post">
<input type="hidden" name="confirm" value="confirm" />
<input type="hidden" name="keyword" value="
<?php echo
format_to_output( $keyword, 'formvalue' ) ?>" />
<input type="hidden" name="action" value="ban" />
<h2>
<?php echo
T_('Confirm ban & delete') ?></h2>
{ // We can we autodelete junk, check for junk:
// Check for potentially affected log hits:
$sql =
'SELECT visitID, UNIX_TIMESTAMP(visitTime) AS visitTime, referingURL,
baseDomain, hit_blog_ID, visitURL, hit_remote_addr
WHERE referingURL LIKE '.
$DB->quote('%'.
$keyword.
'%').
'
ORDER BY hit_remote_addr ASC, baseDomain ASC, visitTime DESC';
$res_affected_hits =
$DB->get_results( $sql, ARRAY_A );
<p><strong><input type="checkbox" name="delhits" value="1" checked="checked" />
<?php printf ( T_('Delete the following %d referer hits:'), $DB->num_rows ) ?>
<table class="grouped" cellspacing="0">
<th>
<?php echo
T_('Date') ?></th>
<th>
<?php echo
T_('Referer') ?></th>
<th>
<?php echo
T_('Ref. IP') ?></th>
<th>
<?php echo
T_('Target Blog') ?></th>
<th>
<?php echo
T_('Target URL') ?></th>
foreach( $res_affected_hits as $row_stats )
<tr
<?php if($count%
2 ==
1) echo
'class="odd"' ?>>
// Check for potentially affected comments:
$sql =
'SELECT comment_ID, comment_date, comment_author, comment_author_url,
comment_author_IP, comment_content
WHERE comment_author LIKE '.
$DB->quote('%'.
$keyword.
'%').
'
OR comment_author_url LIKE '.
$DB->quote('%'.
$keyword.
'%').
'
OR comment_content LIKE '.
$DB->quote('%'.
$keyword.
'%').
'
ORDER BY comment_author_IP ASC, comment_author_url ASC, comment_date DESC';
$res_affected_comments =
$DB->get_results( $sql, ARRAY_A );
<p><strong><input type="checkbox" name="delcomments" value="1" checked="checked" />
<?php printf ( T_('Delete the following %d comments:'), count($res_affected_comments) ) ?>
<table class="grouped" cellspacing="0">
<th>
<?php echo
T_('Date') ?></th>
<th>
<?php echo
T_('Author') ?></th>
<th>
<?php echo
T_('Auth. URL') ?></th>
<th>
<?php echo
T_('Auth. IP') ?></th>
<th>
<?php echo
T_('Content starts with...') ?></th>
foreach( $res_affected_comments as $row_stats )
{ // TODO: new Comment( $row_stats ) ?>
<tr
<?php if($count%
2 ==
1) echo
'class="odd"' ?>>
<td>
<?php echo
$row_stats['comment_author'] ?></a></td>
<td>
<?php echo
$row_stats['comment_author_url'] ?></td>
<td>
<?php echo
$row_stats['comment_author_IP'] ?></td>
$comment_content =
strip_tags( $row_stats['comment_content'] );
if ( strlen($comment_content) >
70 )
// Trail off (truncate and add '...') after 70 chars
echo
substr($comment_content, 0, 70) .
"...";
// Check if the string is already in the blacklist:
printf( '<p><strong>'.
T_('The keyword [%s] is already handled by the blacklist.').
'</strong></p>', htmlspecialchars($keyword) );
<p><strong><input type="checkbox" name="blacklist" value="1" checked="checked" />
<?php if( $report_abuse )
<strong><input type="checkbox" name="report" value="1" checked="checked" />
[<a href="http://b2evolution.net/about/terms.html">
<?php echo
T_('Terms of service') ?></a>]
<input type="submit" value="
<?php echo
T_('Perform selected operations') ?>" class="search" />
// Remove a domain from ban list:
$current_User->check_perm( 'spamblacklist', 'edit', true );
param( 'hit_ID', 'integer', true ); // Required!
<p>
<?php printf( T_('Removing entry #%d from the ban list...'), $hit_ID) ?></p>
// Report an entry as abuse to centralized blacklist:
$current_User->check_perm( 'spamblacklist', 'edit', true );
// Report this keyword as abuse:
// request abuse list from central blacklist:
$current_User->check_perm( 'spamblacklist', 'edit', true );
if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
<form action="b2antispam.php" method="get" class="fform">
<input type="hidden" name="action" value="ban" />
<input type="hidden" name="type" value="keyword" />
<label for="keyword"><strong>
<?php echo
T_('Add a banned keyword') ?>:</strong></label>
<input type="text" name="keyword" id="keyword" size="30" maxlength="80" value="
<?php echo
format_to_output( $keyword, 'formvalue')?>" />
<input type="submit" value="
<?php echo
T_('Check & ban...') ?>" class="search" />
<h2>
<?php echo
T_('Banned domains blacklist') ?></h2>
<p class="center">
<?php echo
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.');
<?php if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
[<a href="b2antispam.php?action=poll">
<?php echo
T_('Request abuse update from centralized blacklist!') ?></a>]
[<a href="http://b2evolution.net/about/terms.html">
<?php echo
T_('Terms of service') ?></a>]
if( ! $disp_blacklist &&
(count($res_stats) >
100) )
{ // We haven't requested the list
echo
'<p class="center"><strong>'.
sprintf( T_('The blacklist contains more than 100 items. [<a %s>Click here to display</a>].'),
'href="b2antispam.php?disp_blacklist=1"' ).
'</strong></p>';
{ // The list is short enough to be displayed without being annoying
{ // Blacklist display is requested:
<table class="grouped" cellspacing="0">
if( count($res_stats) ) foreach( $res_stats as $row_stats )
<tr
<?php if($count%
2 ==
1) echo
'class="odd"' ?>>
<?php if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
<a href="b2antispam.php?action=remove&hit_ID=
<?php antiSpam_ID() ?>" title="
<?php echo
T_('Allow keyword back (Remove it from the blacklist)') ?>"><img src="img/tick.gif" width="13" height="13" class="middle" alt="
<?php echo
T_('Allow Back') ?>" /></a>
&&
$current_User->check_perm( 'spamblacklist', 'edit' ) )
[<a href="b2antispam.php?action=report&keyword=
<?php echo
urlencode( antiSpam_domain(false) ) ?>" title="
<?php echo
T_('Report abuse to centralized ban blacklist!') ?>">
<?php echo
T_('Report') ?></a>]
[<a href="b2antispam.php?action=ban&keyword=
<?php echo
urlencode( antiSpam_domain(false) ) ?>" title="
<?php echo
T_('Check hit-logs and comments for this keyword!') ?>">
<?php echo
T_('Re-check') ?></a>]
require
( dirname(__FILE__
).
'/_footer.php' );