Source for file _antispam_ban.form.php
Documentation is available at _antispam_ban.form.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.' );
global $row_stats; // for hit functions
$Form = new Form( NULL, 'antispam_ban', 'post', 'compact' );
$Form->begin_form( 'fform', T_('Confirm ban & delete') );
$Form->hidden( 'confirm', 'confirm' );
$Form->hidden( 'aspm_source', $aspm_source );
// Check for potentially affected logged hits:
$sql = 'SELECT hit_ID, UNIX_TIMESTAMP(hit_datetime) as hit_datetime, hit_uri, hit_referer, dom_name,
hit_blog_ID, hit_remote_addr, blog_shortname
FROM T_hitlog INNER JOIN T_basedomains ON hit_referer_dom_ID = dom_ID
LEFT JOIN T_blogs ON hit_blog_ID = blog_ID
WHERE hit_referer LIKE '. $DB->quote('%'. $keyword. '%'). '
$res_affected_hits = $DB->get_results( $sql, ARRAY_A );
<input type="checkbox" name="delhits" id="delhits_cb" value="1" checked="checked" />
<strong> <?php printf ( T_('Delete the following %s referer hits:'), $DB->num_rows == 500 ? '500+' : $DB->num_rows ) ?></strong>
<table class="grouped" cellspacing="0">
<th class="firstcol"> <?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 class=" <?php echo ($count% 2 == 1) ? 'odd' : 'even' ?>">
<td> <?php echo format_to_output( $row_stats['blog_shortname'], 'htmlbody' ); ?></td>
<td> <?php disp_url( $row_stats['hit_uri'], 50 ); ?></td>
// 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_email LIKE '. $DB->quote('%'. $keyword. '%'). '
OR comment_author_url LIKE '. $DB->quote('%'. $keyword. '%'). '
OR comment_content LIKE '. $DB->quote('%'. $keyword. '%'). '
ORDER BY comment_date ASC
$res_affected_comments = $DB->get_results( $sql, ARRAY_A, 'Find matching comments' );
<input type="checkbox" name="delcomments" id="delcomments_cb" value="1" checked="checked" />
<label for="delcomments_cb">
<strong> <?php printf ( T_('Delete the following %s comments:'), $DB->num_rows == 500 ? '500+' : $DB->num_rows ) ?></strong>
<table class="grouped" cellspacing="0">
<th class="firstcol"> <?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>
<th> <?php echo T_('Action') ?></th>
foreach( $res_affected_comments as $row_stats )
{ // TODO: new Comment( $row_stats )
<tr class=" <?php echo ($count% 2 == 1) ? 'odd' : 'even' ?>">
<td> <?php echo $row_stats['comment_author'] ?></td>
<td> <?php disp_url( $row_stats['comment_author_url'], 50 ); ?></td>
<td> <?php echo $row_stats['comment_author_IP'] ?></td>
$comment_content = strip_tags( $row_stats['comment_content'] );
// Trail off (truncate and add '...') after 70 chars
<td> <?php echo action_icon( T_('Edit...'), 'edit', '?ctrl=comments&action=edit&comment_ID='. $row_stats['comment_ID'] ) ?></td>
// 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) );
<input type="checkbox" name="blacklist_locally" id="blacklist_locally_cb" value="1" checked="checked" />
<label for="blacklist_locally_cb">
array( '', 'actionArray[ban]', T_('Perform selected operations'), 'DeleteButton' ),
// this is when you click a "ban" symbol next to a comment domain
// figure out what might be shorter and offer it as a "wider net"
$start_char = $string = $new_keyword = '';
if( substr( $keyword, 0, 2 ) == '//' )
{ // remove and remember leading // characters
$string = substr( $keyword, 2 );
elseif( substr( $keyword, 0, 1 ) == '.' )
{ // or remove and remember leading . character
$string = substr( $keyword, 1 );
{ // or we're done (this is not from clicking the "ban" symbol)
if( $aspm_source == 'local' )
{ // no shortening if the keyword was manually entered
{ // count /s and .s and split into elements
$string_slash_array = explode( '/', $string );
$slash_elements = count( $string_slash_array );
$string_dot_array = explode( '.', $string_slash_array[0] );
$dot_elements = count( $string_dot_array );
if( $slash_elements > 1 )
{ // we have at least one / so let's shrink from the right...
while( $ii < $slash_elements- 2 )
{ // rebuild the keyword from the left to the right
$new_keyword .= $string_slash_array[$ii];
if( $slash_elements > 3 )
{ // add a trailing / unless we are down to domain.com
elseif( $dot_elements > 2 )
{ // no /s to work on and we have at least one . so let's shrink from the left...
{ // rebuild the keyword from the right to the left
$new_keyword = $string_dot_array[$ii]. $new_keyword;
$new_keyword = '.'. $new_keyword;
// whatever $start_char was, it got removed with the first subdo
{ // no /s or .s so the form is not displayed
$new_keyword = $start_char. $new_keyword;
{ // offer to check and ban a shortened version of the original keyword
$Form = new Form( NULL, 'antispam_add', 'post', 'compact' );
$Form->begin_form( 'fform', T_('Cast a wider net?') );
$Form->hidden( 'action', 'ban' );
$Form->hidden( 'aspm_source', 'central' ); // central means modified
$Form->hidden( 'keyword', $new_keyword );
$Form->info( T_('Check this instead'), $new_keyword, '<br />'. T_('Check this shorter version of the URL you clicked to ban') );
$Form->end_form( array( array( 'submit', 'submit', T_('Check & ban...'), 'SaveButton' ) ) );
|