phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ all elements ]

Source for file _antispam_list.view.php

Documentation is available at _antispam_list.view.php

  1. <?php
  2. /**
  3.  * This file implements the UI controller for the antispam management.
  4.  *
  5.  * This file is part of the Quam Plures project - {@link http://quamplures.net/}.
  6.  * See also {@link https://launchpad.net/quam-plures}.
  7.  *
  8.  * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
  9.  * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}.
  10.  *
  11.  * @license http://quamplures.net/license.html GNU General Public License (GPL)
  12.  *
  13.  *  {@internal Open Source relicensing agreement:
  14.  *  }}}
  15.  *
  16.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  17.  *
  18.  * @todo Allow applying / re-checking of the known data, not just after an update!
  19.  *
  20.  * @package pond
  21.  */
  22. if!defined('QP_MAIN_INIT') ) die'Please, do not access this page directly.' );
  23.  
  24.  
  25. echo '<a href="?ctrl=set_antispam" style="float: right;"><strong>'.T_('Antispam settings').' &raquo;</strong></a>';
  26. echo '<h2>'.T_('Antispam blacklist').'</h2>';
  27.  
  28. // ADD KEYWORD FORM:
  29. if$current_User->check_perm'spamblacklist''edit' ) ) // TODO: check for 'add' here once it's mature.
  30. // add keyword or domain
  31.     global $keyword;
  32.  
  33.     // this is when you select "tools->antispam"
  34.     $Form new FormNULL'antispam_add''post''compact' );
  35.     $Form->begin_form'fform'T_('Add a banned keyword') );
  36.         $Form->hidden_ctrl();
  37.         $Form->hidden'action''ban' );
  38.         $Form->text'keyword'$keyword50T_('Keyword/phrase to ban')''80 )// TODO: add note
  39.         /*
  40.          * TODO: explicitly add a domain?
  41.          * $add_Form->text( 'domain', $domain, 30, T_('Add a banned domain'), 'note..', 80 ); // TODO: add note
  42.          */
  43.     $Form->hidden'aspm_source''local' )// local means manually entered
  44.     $Form->end_formarrayarray'submit''submit'T_('Check & ban...')'SaveButton' ) ) );
  45. }
  46.  
  47.  
  48. echo '<p class="center">'.T_('Any URL containing one of the following keywords will be banned from posts, comments and logs.');
  49. if$current_User->check_perm'spamblacklist''edit' ) )
  50. {
  51.     echo '<br />'.T_'If a keyword restricts legitimate domains, click on the green tick to stop banning with this keyword.');
  52. }
  53. echo '</p>';
  54.  
  55.  
  56. /*
  57.  * Query antispam blacklist:
  58.  */
  59. $keywords param'keywords''string'''true );
  60.  
  61. $where_clause '';
  62.  
  63. if!empty$keywords ) )
  64. {
  65.     $kw_array split' '$keywords );
  66.     foreach$kw_array as $kw )
  67.     {
  68.         $where_clause .= 'aspm_string LIKE "%'.$DB->escape($kw).'%" AND ';
  69.     }
  70. }
  71.  
  72. $sql 'SELECT aspm_ID, aspm_string, aspm_source
  73.                     FROM T_antispam
  74.                  WHERE '.$where_clause.' 1';
  75.  
  76. // Create result set:
  77. $Results new Results$sql'antispam_' );
  78.  
  79. $Results->title T_('Banned keywords blacklist');
  80.  
  81.  
  82. /**
  83.  * Callback to add filters on top of the result set
  84.  *
  85.  * @param Form 
  86.  */
  87. function filter_antispam$Form )
  88. {
  89.     $Form->text'keywords'get_param('keywords')20T_('Keywords')T_('Separate with space')50 );
  90. }
  91. $Results->filter_area array(
  92.     'callback' => 'filter_antispam',
  93.     'url_ignore' => 'results_antispam_page,keywords',
  94.     'presets' => array(
  95.         'all' => arrayT_('All keywords')'?ctrl=antispam' ),
  96.         )
  97.     );
  98.  
  99.  
  100.  
  101. /*
  102.  * Column definitions:
  103.  */
  104. $Results->cols[array(
  105.                         'th' => T_('Keyword'),
  106.                         'order' => 'aspm_string',
  107.                         'td' => '%htmlspecialchars(#aspm_string#)%',
  108.                     );
  109.  
  110. // Set columns:
  111. function antispam_source2$row )
  112. {
  113.     static $aspm_sources NULL;
  114.  
  115.     if$aspm_sources === NULL )
  116.     {
  117.         /**
  118. /**
  119.          * the antispam sources
  120.          * @var array 
  121.          * @static
  122.          */
  123.         $aspm_sources array (
  124.             'local' => T_('Entered'),
  125.             'reported' => T_('Banned'),
  126.             'central' => T_('Shortened'),
  127.         );
  128.     }
  129.  
  130.     return $aspm_sources[$row->aspm_source];
  131. }
  132. $Results->cols[array(
  133.                         'th' => T_('Source'),
  134.                         'order' => 'aspm_source',
  135.                         'td' => '%antispam_source2({row})%',
  136.                     );
  137.  
  138. // Check if we need to display more:
  139. if$current_User->check_perm'spamblacklist''edit' ) )
  140. // User can edit, spamlist: add controls to output columns:
  141.     // Add CHECK to 1st column:
  142.     $Results->cols[0]['td'action_iconTS_('Allow keyword back (Remove it from the blacklist)')'allowback',
  143.                                                              '?ctrl=antispam&amp;action=remove&amp;hit_ID=$aspm_ID$' )
  144.                                                              .$Results->cols[0]['td'];
  145.  
  146.     // Add a column for actions:
  147.     function antispam_actions$row )
  148.     {
  149.         $output '';
  150.  
  151.         return $output.'[<a href="'.regenerate_url'action,keyword''action=ban&amp;keyword='
  152.                                     .rawurlencode$row->aspm_string )).'" title="'.
  153.                                     T_('Check hit-logs and comments for this keyword!').'">'.
  154.                                     T_('Re-check').'</a>]';
  155.     }
  156.     $Results->cols[array(
  157.                             'th' => T_('Actions'),
  158.                             'td' => '%antispam_actions({row})%',
  159.                         );
  160. }
  161.  
  162. // Display results:
  163. $Results->display();
  164.  
  165.  
  166. ?>