Index: /extensions/ContactForm/admin/config.php
===================================================================
--- /extensions/ContactForm/admin/config.php	(revision 28838)
+++ /extensions/ContactForm/admin/config.php	(revision 28839)
@@ -33,10 +33,8 @@
     'cf_redirect_url' =>      $_POST['cf_redirect_url'],
     );
-  $conf['ContactForm_before'] = $_POST['cf_before'];
-  $conf['ContactForm_after'] = $_POST['cf_after'];
 
-  conf_update_param('ContactForm', pwg_db_real_escape_string(serialize($conf['ContactForm'])));
-  conf_update_param('ContactForm_before', $conf['ContactForm_before']);
-  conf_update_param('ContactForm_after', $conf['ContactForm_after']);
+  conf_update_param('ContactForm', $conf['ContactForm']);
+  conf_update_param('ContactForm_before', trim($_POST['cf_before']), true);
+  conf_update_param('ContactForm_after', trim($_POST['cf_after']), true);
 
   $page['infos'][] = l10n('Information data registered in database');
Index: /extensions/ContactForm/include/functions.inc.php
===================================================================
--- /extensions/ContactForm/include/functions.inc.php	(revision 28838)
+++ /extensions/ContactForm/include/functions.inc.php	(revision 28839)
@@ -141,5 +141,5 @@
 
   $conf['ContactForm']['cf_must_initialize'] = false;
-  conf_update_param('ContactForm', serialize($conf['ContactForm']));
+  conf_update_param('ContactForm', $conf['ContactForm']);
 }
 
Index: /extensions/ContactForm/main.inc.php
===================================================================
--- /extensions/ContactForm/main.inc.php	(revision 28838)
+++ /extensions/ContactForm/main.inc.php	(revision 28839)
@@ -13,14 +13,15 @@
  */
 
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
 global $prefixeTable;
 
-defined('CONTACT_FORM_ID') or define('CONTACT_FORM_ID', basename(dirname(__FILE__)));
-define('CONTACT_FORM_PATH',    PHPWG_PLUGINS_PATH . CONTACT_FORM_ID . '/');
-define('CONTACT_FORM_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . CONTACT_FORM_ID);
-define('CONTACT_FORM_PUBLIC',  get_absolute_root_url() . make_index_url(array('section' => 'contact')) . '/');
-define('CONTACT_FORM_TABLE',   $prefixeTable .'contact_form');
-define('CONTACT_FORM_VERSION', 'auto');
+define('CONTACT_FORM_ID',     basename(dirname(__FILE__)));
+define('CONTACT_FORM_PATH',   PHPWG_PLUGINS_PATH . CONTACT_FORM_ID . '/');
+define('CONTACT_FORM_ADMIN',  get_root_url() . 'admin.php?page=plugin-' . CONTACT_FORM_ID);
+define('CONTACT_FORM_PUBLIC', get_absolute_root_url() . make_index_url(array('section' => 'contact')) . '/');
+define('CONTACT_FORM_TABLE',  $prefixeTable .'contact_form');
+
+include(CONTACT_FORM_PATH . 'include/functions.inc.php');
 
 
@@ -40,6 +41,4 @@
 add_event_handler('before_parse_mail_template', 'contact_form_mail_template', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
 
-include(CONTACT_FORM_PATH . 'include/functions.inc.php');
-
 
 /**
@@ -48,11 +47,8 @@
 function contact_form_init()
 {
-  global $conf, $template, $pwg_loaded_plugins;
+  global $conf, $template;
 
-  include_once(CONTACT_FORM_PATH . 'maintain.inc.php');
-  $maintain = new ContactForm_maintain(CONTACT_FORM_ID);
-  $maintain->autoUpdate(CONTACT_FORM_VERSION, 'install');
-
-  $conf['ContactForm'] = unserialize($conf['ContactForm']);
+  $conf['ContactForm'] = safe_unserialize($conf['ContactForm']);
+  
   load_language('plugin.lang', CONTACT_FORM_PATH);
   load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true));
Index: /extensions/ContactForm/maintain.class.php
===================================================================
--- /extensions/ContactForm/maintain.class.php	(revision 28839)
+++ /extensions/ContactForm/maintain.class.php	(revision 28839)
@@ -0,0 +1,121 @@
+<?php
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+class ContactForm_maintain extends PluginMaintain
+{
+  private $table;
+  
+  private $default_conf = array(
+    'cf_must_initialize' => true,
+    'cf_menu_link' => true,
+    'cf_subject_prefix' => '%gallery_title%',
+    'cf_default_subject' => 'A comment on your site',
+    'cf_allow_guest' => true,
+    'cf_mandatory_mail' => true,
+    'cf_mandatory_name' => true,
+    'cf_mail_type' => 'text/html',
+    'cf_redirect_url' => null,
+    );
+  
+  function __construct($id)
+  {
+    global $prefixeTable;
+    
+    parent::__construct($id);
+    $this->table = $prefixeTable.'contact_form';
+  }
+
+  function install($plugin_version, &$errors=array())
+  {
+    global $conf;
+
+    // email table
+  $query = '
+CREATE TABLE IF NOT EXISTS `'. $this->table .'` (
+  `id` smallint(5) NOT NULL AUTO_INCREMENT,
+  `name` varchar(128) NOT NULL,
+  `email` varchar(128) NOT NULL,
+  `active` enum("true","false") NOT NULL DEFAULT "true",
+  `group_name` varchar(128) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `UNIQUE` (`email`,`group_name`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;';
+    pwg_query($query);
+
+    // configuration
+    if (empty($conf['ContactForm']))
+    {
+      conf_update_param('ContactForm', $this->default_conf, true);
+      conf_update_param('ContactForm_before', '', true);
+      conf_update_param('ContactForm_after', '', true);
+    }
+    else
+    {
+      $new_conf = safe_unserialize($conf['ContactForm']);
+
+      // migration 2.4 -> 2.5
+      if (!isset($new_conf['cf_must_initialize']))
+      {
+        // new params
+        $new_conf['cf_default_subject'] = 'A comment on your site';
+        $new_conf['cf_mail_type'] = 'text/html';
+        $new_conf['cf_redirect_url'] = null;
+
+        // move emails to database
+        $emails = array();
+        foreach ($new_conf['cf_admin_mails'] as $email => $data)
+        {
+          $emails[] = array(
+            'email' => $email,
+            'name' => $data['NAME'],
+            'active' => boolean_to_string($data['ACTIVE']),
+            );
+        }
+
+        $new_conf['cf_must_initialize'] = empty($emails);
+
+        mass_inserts(
+          $this->table,
+          array('name','email','active'),
+          $emails
+          );
+
+        // old params
+        unset(
+          $new_conf['comment'], $new_conf['cf_redirect_delay'],
+          $new_conf['cf_separator'], $new_conf['cf_separator_length'],
+          $new_conf['cf_admin_mails']
+          );
+
+        // save config
+        conf_update_param('ContactForm', $new_conf, true);
+        conf_update_param('ContactForm_before', stripslashes(@$conf['persoformtop']), true);
+        conf_update_param('ContactForm_after', stripslashes(@$conf['persoformbottom']), true);
+        conf_delete_param(array('persoformtop','persoformbottom'));
+      }
+    }
+
+    // just in case something went wrong in a previous version
+    if (empty($conf['ContactForm_before']))
+    {
+      conf_update_param('ContactForm_before', '', true);
+    }
+
+    if (empty($conf['ContactForm_after']))
+    {
+      conf_update_param('ContactForm_after', '', true);
+    }
+  }
+
+  function update($old_version, $new_version, &$errors=array())
+  {
+    $this->install($new_version, $errors);
+  }
+
+  function uninstall()
+  {
+    pwg_query('DROP TABLE IF EXISTS `'. $this->table .'`;');
+
+    conf_delete_param(array('ContactForm','ContactForm_before','ContactForm_after'));
+  }
+}
Index: tensions/ContactForm/maintain.inc.php
===================================================================
--- /extensions/ContactForm/maintain.inc.php	(revision 28838)
+++ 	(revision )
@@ -1,137 +1,0 @@
-<?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-
-class ContactForm_maintain extends PluginMaintain
-{
-  private $installed = false;
-
-  function install($plugin_version, &$errors=array())
-  {
-    global $conf, $prefixeTable;
-
-    // email table
-  $query = '
-CREATE TABLE IF NOT EXISTS `'. $prefixeTable .'contact_form` (
-  `id` smallint(5) NOT NULL AUTO_INCREMENT,
-  `name` varchar(128) NOT NULL,
-  `email` varchar(128) NOT NULL,
-  `active` enum("true","false") NOT NULL DEFAULT "true",
-  `group_name` varchar(128) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  UNIQUE KEY `UNIQUE` (`email`,`group_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;';
-    pwg_query($query);
-
-    // configuration
-    if (empty($conf['ContactForm']))
-    {
-      $conf['ContactForm'] = serialize(array(
-        'cf_must_initialize' => true,
-        'cf_menu_link' => true,
-        'cf_subject_prefix' => '%gallery_title%',
-        'cf_default_subject' => 'A comment on your site',
-        'cf_allow_guest' => true,
-        'cf_mandatory_mail' => true,
-        'cf_mandatory_name' => true,
-        'cf_mail_type' => 'text/html',
-        'cf_redirect_url' => null,
-        ));
-
-      $conf['ContactForm_before'] = null;
-      $conf['ContactForm_after'] = null;
-
-      conf_update_param('ContactForm', $conf['ContactForm']);
-      conf_update_param('ContactForm_before', $conf['ContactForm_before']);
-      conf_update_param('ContactForm_after', $conf['ContactForm_after']);
-    }
-    else
-    {
-      $new_conf = is_string($conf['ContactForm']) ? unserialize($conf['ContactForm']) : $conf['ContactForm'];
-
-      // migration 2.4 -> 2.5
-      if (!isset($new_conf['cf_must_initialize']))
-      {
-        // new params
-        $new_conf['cf_default_subject'] = 'A comment on your site';
-        $new_conf['cf_mail_type'] = 'text/html';
-        $new_conf['cf_redirect_url'] = null;
-
-        // move emails to database
-        $emails = array();
-        foreach ($new_conf['cf_admin_mails'] as $email => $data)
-        {
-          $emails[] = array(
-            'email' => $email,
-            'name' => $data['NAME'],
-            'active' => boolean_to_string($data['ACTIVE']),
-            );
-        }
-
-        $new_conf['cf_must_initialize'] = empty($emails);
-
-        mass_inserts(
-          $prefixeTable .'contact_form',
-          array('name','email','active'),
-          $emails
-          );
-
-        // old params
-        unset(
-          $new_conf['comment'], $new_conf['cf_redirect_delay'],
-          $new_conf['cf_separator'], $new_conf['cf_separator_length'],
-          $new_conf['cf_admin_mails']
-          );
-
-        // save config
-        $conf['ContactForm_before'] = stripslashes(@$conf['persoformtop']);
-        $conf['ContactForm_after'] = stripslashes(@$conf['persoformbottom']);
-
-        conf_update_param('ContactForm_before', $conf['ContactForm_before']);
-        conf_update_param('ContactForm_after', $conf['ContactForm_after']);
-
-        conf_delete_param(array('persoformtop','persoformbottom'));
-      }
-
-      // save config
-      $conf['ContactForm'] = serialize($new_conf);
-      conf_update_param('ContactForm', pwg_db_real_escape_string($conf['ContactForm']));
-    }
-
-    // just in case something went wrong in a previous version
-    if (empty($conf['ContactForm_before']))
-    {
-      $conf['ContactForm_before'] = null;
-      conf_update_param('ContactForm_before', $conf['ContactForm_before']);
-    }
-
-    if (empty($conf['ContactForm_after']))
-    {
-      $conf['ContactForm_after'] = null;
-      conf_update_param('ContactForm_after', $conf['ContactForm_after']);
-    }
-    
-    $this->installed = false;
-  }
-
-  function activate($plugin_version, &$errors=array())
-  {
-    if (!$this->installed)
-    {
-      $this->install($plugin_version, $errors);
-    }
-  }
-
-  function deactivate()
-  {
-  }
-
-
-  function uninstall()
-  {
-    global $prefixeTable;
-
-    pwg_query('DROP TABLE IF EXISTS `'. $prefixeTable .'contact_form`;');
-
-    conf_delete_param(array('ContactForm','ContactForm_before','ContactForm_after'));
-  }
-}
