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

Source for file antispam_list.ctrl.php

Documentation is available at antispam_list.ctrl.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.  *  Parts of this file are copyright (c)2004 by Vegar BERG GULDAL - {@link http://funky-m.com/}.
  11.  *
  12.  * @license http://quamplures.net/license.html GNU General Public License (GPL)
  13.  *
  14.  *  {@internal Open Source relicensing agreement:
  15.  *  Daniel HAHLER grants Francois PLANQUE the right to license
  16.  *  Daniel HAHLER's contributions to this file and the b2evolution project
  17.  *  under any OSI approved OSS license (http://www.opensource.org/licenses/).
  18.  *  Vegar BERG GULDAL grants Francois PLANQUE the right to license
  19.  *  Vegar BERG GULDAL's contributions to this file and the b2evolution project
  20.  *  under any OSI approved OSS license (http://www.opensource.org/licenses/).
  21.  *  Halton STEWART grants Francois PLANQUE the right to license
  22.  *  Halton STEWART's contributions to this file and the b2evolution project
  23.  *  under any OSI approved OSS license (http://www.opensource.org/licenses/).
  24.  *  }}}
  25.  *
  26.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  27.  * @author blueyed: Daniel HAHLER.
  28.  * @author fplanque: Francois PLANQUE.
  29.  * @author vegarg: Vegar BERG GULDAL.
  30.  * @author halton: Halton STEWART.
  31.  *
  32.  * @todo Allow applying / re-checking of the known data, not just after an update!
  33.  *
  34.  * @package pond
  35.  */
  36. if!defined('QP_MAIN_INIT') ) die'Please, do not access this page directly.' );
  37.  
  38. $AdminUI->set_path'tools''antispam' );
  39.  
  40. param_action'' );
  41. param'confirm''string' );
  42. param'keyword''string'''true );
  43. param'domain''string' );
  44. param'filteron''string'''true );
  45. param'filter''array'array() );
  46.  
  47. ifisset($filter['off']) )
  48. {
  49.     unset$filteron );
  50.     forget_param'filteron' );
  51. }
  52.  
  53. // Check permission:
  54. $current_User->check_perm'spamblacklist''view'true );
  55.  
  56. switch$action )
  57. {
  58.     case 'ban'// only an action if further "actions" given
  59.         // Check permission:
  60.         $current_User->check_perm'spamblacklist''edit'true )// TODO: This should become different for 'edit'/'add' perm level - check for 'add' here.
  61.  
  62.         $keyword evo_substr$keyword080 );
  63.         param'delhits''integer');
  64.         param'delcomments''integer');
  65.         param'blacklist_locally''integer');
  66.         param'aspm_source''string''local' );
  67.  
  68.         // Check if the string is too short,
  69.         // it has to be a minimum of 5 characters to avoid being too generic
  70.         ifevo_strlen($keyword)
  71.         {
  72.             $Messages->addsprintfT_('The keyword &laquo;%s&raquo; is too short, it has to be a minimum of 5 characters!')htmlspecialchars($keyword) )'error' );
  73.             break;
  74.         }
  75.  
  76.         if$delhits )
  77.         // Delete all banned hit-log entries
  78.             $r $DB->query('DELETE FROM T_hitlog
  79.                                                 WHERE hit_referer LIKE '.$DB->quote('%'.$keyword.'%'),
  80.                                                 'Delete all banned hit-log entries' );
  81.  
  82.             $Messages->addsprintfT_('Deleted %d logged hits matching &laquo;%s&raquo;.')$rhtmlspecialchars($keyword) )'success' );
  83.         }
  84.  
  85.         if$delcomments )
  86.         // Then all banned comments
  87.             $r $DB->query('DELETE FROM T_comments
  88.                               WHERE comment_author LIKE '.$DB->quote('%'.$keyword.'%').'
  89.                                  OR comment_author_email LIKE '.$DB->quote('%'.$keyword.'%').'
  90.                                  OR comment_author_url LIKE '.$DB->quote('%'.$keyword.'%').'
  91.                                  OR comment_content LIKE '.$DB->quote('%'.$keyword.'%') );
  92.             $Messages->addsprintfT_('Deleted %d comments matching &laquo;%s&raquo;.')$rhtmlspecialchars($keyword) )'success' );
  93.         }
  94.  
  95.         if$blacklist_locally )
  96.         // Local blacklist:
  97.             ifantispam_create$keyword$aspm_source ) )
  98.             {
  99.                 $Messages->addsprintfT_('The keyword &laquo;%s&raquo; has been blacklisted locally.')htmlspecialchars($keyword) )'success' );
  100.             }
  101.             else
  102.             // TODO: message?
  103.             }
  104.         }
  105.  
  106.         // We'll ask the user later what to do, if no "sub-action" given.
  107.         break;
  108.  
  109.  
  110.     case 'remove':
  111.         // Remove a domain from ban list:
  112.  
  113.         // Check permission:
  114.         $current_User->check_perm'spamblacklist''edit'true );
  115.  
  116.         param'hit_ID''integer'true );    // Required!
  117.         $Messages->addsprintfT_('Removing entry #%d from the ban list...')$hit_ID)'note' );
  118.         antispam_delete$hit_ID );
  119.         break;
  120. }
  121.  
  122.  
  123. // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
  124. $AdminUI->disp_html_head();
  125.  
  126. // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
  127. $AdminUI->disp_body_top();
  128.  
  129. // Begin payload block:
  130. $AdminUI->disp_payload_begin();
  131.  
  132.  
  133. if$action == 'ban' && !$Messages->count('error'&& !$delhits || $delcomments || $blacklist_locally ) )
  134. // Nothing to do, ask user:
  135.     $AdminUI->disp_view'antispam/views/_antispam_ban.form.php' );
  136. }
  137. else
  138. {    // Display blacklist:
  139.     $AdminUI->disp_view'antispam/views/_antispam_list.view.php' );
  140. }
  141.  
  142. // End payload block:
  143. $AdminUI->disp_payload_end();
  144.  
  145. // Display body bottom, debug info and close </html>:
  146. $AdminUI->disp_global_footer();
  147.  
  148.  
  149. ?>