Index: /extensions/comments_blacklist/admin.php
===================================================================
--- /extensions/comments_blacklist/admin.php	(revision 26112)
+++ /extensions/comments_blacklist/admin.php	(revision 26113)
@@ -3,4 +3,6 @@
  
 global $template, $page;
+
+load_language('plugin.lang', COMM_BLACKLIST_PATH);
 
 // save config
@@ -13,5 +15,5 @@
   file_put_contents(COMM_BLACKLIST_FILE, $_POST['content']);
   conf_update_param('comments_blacklist', serialize($conf['comments_blacklist']));
-  array_push($page['infos'], l10n('Information data registered in database'));
+  $page['infos'][] = l10n('Information data registered in database');
 }
   
@@ -27,4 +29,2 @@
 $template->set_filename('comm_blacklist_content', realpath(COMM_BLACKLIST_PATH . 'admin.tpl'));
 $template->assign_var_from_handle('ADMIN_CONTENT', 'comm_blacklist_content');
-
-?>
Index: /extensions/comments_blacklist/main.inc.php
===================================================================
--- /extensions/comments_blacklist/main.inc.php	(revision 26112)
+++ /extensions/comments_blacklist/main.inc.php	(revision 26113)
@@ -4,5 +4,5 @@
 Version: auto
 Description: Define a list of words which are not authorized in a comment.
-Plugin URI: http://piwigo.org/ext/extension_view.php?eid=637
+Plugin URI: auto
 Author: Mistic
 Author URI: http://www.strangeplanet.fr
@@ -11,5 +11,5 @@
 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
-defined('COMM_BLACKLIST_ID') or define('COMM_BLACKLIST_ID', basename(dirname(__FILE__)));
+define('COMM_BLACKLIST_ID',      basename(dirname(__FILE__)));
 define('COMM_BLACKLIST_PATH' ,   PHPWG_PLUGINS_PATH . COMM_BLACKLIST_ID . '/');
 define('COMM_BLACKLIST_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . COMM_BLACKLIST_ID);
@@ -23,20 +23,8 @@
 {
   add_event_handler('get_admin_plugin_menu_links', 'comm_blacklist_admin_plugin_menu_links');
-  
-  function comm_blacklist_admin_plugin_menu_links($menu) 
-  {
-    array_push($menu, array(
-      'NAME' => 'Comments Blacklist',
-      'URL' => COMM_BLACKLIST_ADMIN,
-    ));
-    return $menu;
-  }
 }
 else
 {
   add_event_handler('user_comment_check', 'comm_blacklist_user_comment_check', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
-  add_event_handler('user_comment_check_albums', 'comm_blacklist_user_comment_check', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
-  add_event_handler('user_comment_check_guestbook', 'comm_blacklist_user_comment_check', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
-  include_once(COMM_BLACKLIST_PATH . 'include/functions.inc.php');
 }
 
@@ -47,40 +35,56 @@
 function comm_blacklist_init()
 {
-  global $conf, $pwg_loaded_plugins;
+  global $conf;
   
-  // apply upgrade if needed
-  if (
-    COMM_BLACKLIST_VERSION == 'auto' or 
-    $pwg_loaded_plugins[COMM_BLACKLIST_ID]['version'] == 'auto' or
-    version_compare($pwg_loaded_plugins[COMM_BLACKLIST_ID]['version'], COMM_BLACKLIST_VERSION, '<')
-  )
-  {
-    include_once(COMM_BLACKLIST_PATH . 'include/install.inc.php');
-    comm_blacklist_install();
-    
-    if ( $pwg_loaded_plugins[COMM_BLACKLIST_ID]['version'] != 'auto' and COMM_BLACKLIST_VERSION != 'auto' )
-    {
-      $query = '
-UPDATE '. PLUGINS_TABLE .'
-SET version = "'. COMM_BLACKLIST_VERSION .'"
-WHERE id = "'. COMM_BLACKLIST_ID .'"';
-      pwg_query($query);
-      
-      $pwg_loaded_plugins[COMM_BLACKLIST_ID]['version'] = COMM_BLACKLIST_VERSION;
-      
-      if (defined('IN_ADMIN'))
-      {
-        $_SESSION['page_infos'][] = 'Comments Blacklist updated to version '. COMM_BLACKLIST_VERSION;
-      }
-    }
-  }
+  include_once(COMM_BLACKLIST_PATH . 'maintain.inc.php');
+  $maintain = new comments_blacklist_maintain(COMM_BLACKLIST_ID);
+  $maintain->autoUpdate(COMM_BLACKLIST_VERSION, 'install');
   
-  // load plugin language file
-  load_language('plugin.lang', COMM_BLACKLIST_PATH);
-  
-  // prepare plugin configuration
   $conf['comments_blacklist'] = unserialize($conf['comments_blacklist']);
 }
 
+/**
+ * admin link
+ */
+function comm_blacklist_admin_plugin_menu_links($menu) 
+{
+  $menu[] = array(
+    'NAME' => 'Comments Blacklist',
+    'URL' => COMM_BLACKLIST_ADMIN,
+    );
+  return $menu;
+}
 
-?>
+/**
+ * comment check
+ */
+function comm_blacklist_user_comment_check($comment_action, $comm)
+{
+  global $conf;
+  
+  if ($comment_action==$conf['comments_blacklist']['action']
+      or $comment_action=='reject' or !isset($comm['content'])
+    )
+  {
+    return $comment_action;
+  }
+  
+  $blacklist = @file(COMM_BLACKLIST_FILE, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
+  
+  if (empty($blacklist))
+  {
+    return $comment_action;
+  }
+  
+  $blacklist = array_map(create_function('$w', 'return preg_quote($w);'), $blacklist);
+  $blacklist = implode('|', $blacklist);
+  
+  if (preg_match('#\b('.$blacklist.')\b#i', $comm['content']) or
+      (isset($comm['author']) and preg_match('#\b('.$blacklist.')\b#i', $comm['author']))
+    )
+  {
+    return $conf['comments_blacklist']['action'];
+  }
+  
+  return $comment_action;
+}
Index: /extensions/comments_blacklist/maintain.inc.php
===================================================================
--- /extensions/comments_blacklist/maintain.inc.php	(revision 26112)
+++ /extensions/comments_blacklist/maintain.inc.php	(revision 26113)
@@ -2,26 +2,55 @@
 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
-defined('COMM_BLACKLIST_ID') or define('COMM_BLACKLIST_ID', basename(dirname(__FILE__)));
-include_once(PHPWG_PLUGINS_PATH . COMM_BLACKLIST_ID . '/include/install.inc.php');
+class comments_blacklist_maintain extends PluginMaintain
+{
+  private $installed = false;
+  
+  private $default_conf = array(
+    'action' => 'reject',
+    );
+    
+  private $file;
+  
+  function __contruct($plugin_id)
+  {
+    parent::_construct($plugin_id);
+    $this->file = PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'comments_blacklist.txt';
+  }
 
+  function install($plugin_version, &$errors=array())
+  {
+    global $conf, $prefixeTable;
 
-function plugin_install() 
-{
-  comm_blacklist_install();
-  define('comm_blacklist_installed', true);
-}
+    if (empty($conf['comments_blacklist']))
+    {
+      $conf['comments_blacklist'] = serialize($this->default_conf);
+      conf_update_param('comments_blacklist', $conf['comments_blacklist']);
+    }
+    
+    if (!file_exists($this->file)) 
+    {
+      touch($this->file);
+    }
 
-function plugin_activate()
-{
-  if (!defined('comm_blacklist_installed'))
+    $this->installed = true;
+  }
+
+  function activate($plugin_version, &$errors=array())
   {
-    comm_blacklist_install();
+    if (!$this->installed)
+    {
+      $this->install($plugin_version, $errors);
+    }
+  }
+
+  function deactivate()
+  {
+  }
+
+  function uninstall()
+  {
+    conf_delete_param('comments_blacklist');
+
+    @unlink($this->file);
   }
 }
-
-function plugin_uninstall() 
-{
-  @unlink(PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'comments_blacklist.txt');
-}
-
-?>
