Index: /extensions/Back2Front/admin.php
===================================================================
--- /extensions/Back2Front/admin.php	(revision 29252)
+++ /extensions/Back2Front/admin.php	(revision 29253)
@@ -1,4 +1,4 @@
 <?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
 global $conf, $template;
@@ -18,6 +18,6 @@
     );
   
-  conf_update_param('back2front', serialize($conf['back2front']));
-  array_push($page['infos'], l10n('Information data registered in database'));
+  conf_update_param('back2front', $conf['back2front']);
+  $page['infos'][] = l10n('Information data registered in database');
 }
 
@@ -48,4 +48,2 @@
 $template->set_filename('back2front_conf', realpath(B2F_PATH.'template/admin.tpl'));
 $template->assign_var_from_handle('ADMIN_CONTENT', 'back2front_conf');
-
-?>
Index: /extensions/Back2Front/include/Back2Front.php
===================================================================
--- /extensions/Back2Front/include/Back2Front.php	(revision 29252)
+++ /extensions/Back2Front/include/Back2Front.php	(revision 29253)
@@ -1,4 +1,4 @@
 <?php 
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
 include_once(B2F_PATH.'include/functions.inc.php');
@@ -363,4 +363,2 @@
   return $tpl_thumbnails_var;
 }
-
-?>
Index: /extensions/Back2Front/include/functions.inc.php
===================================================================
--- /extensions/Back2Front/include/functions.inc.php	(revision 29252)
+++ /extensions/Back2Front/include/functions.inc.php	(revision 29253)
@@ -1,4 +1,4 @@
 <?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
 /*
@@ -85,5 +85,5 @@
     
   $conf['back2front']['versos_cat'] = $versos_cat['id'];
-  conf_update_param('back2front', serialize($conf['back2front']));
+  conf_update_param('back2front', $conf['back2front']);
 }
 
@@ -106,4 +106,2 @@
   }
 }
-
-?>
Index: tensions/Back2Front/include/install.inc.php
===================================================================
--- /extensions/Back2Front/include/install.inc.php	(revision 29252)
+++ 	(revision )
@@ -1,89 +1,0 @@
-<?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-
-include_once(PHPWG_PLUGINS_PATH . B2F_ID . '/include/functions.inc.php');
-
-function back2front_install() 
-{
-  global $conf, $prefixeTable;
-  
-  // configuration
-  if (empty($conf['back2front']))
-  {
-    // create virtual private cat for storage
-    $versos_cat = create_virtual_category('Back2Front private album');
-    $versos_cat = array(
-      'id' => $versos_cat['id'],
-      'comment' => 'Used by Back2Front to store backsides.',
-      'status'  => 'private',
-      'visible' => 'false',
-      'commentable' => 'false',
-      );
-    
-    mass_updates(
-      CATEGORIES_TABLE,
-      array(
-        'primary' => array('id'),
-        'update' => array_diff(array_keys($versos_cat), array('id'))
-        ),
-      array($versos_cat)
-      );
-    
-    $Back2Front_default_config = array(
-      'versos_cat' => $versos_cat['id'],
-      'switch_mode' => 'click',
-      'transition' => 'none',
-      'position' => 'top',
-      'link_name' => array('default'=>null),
-      'show_thumbnail' => true,
-      );
-      
-    $conf['back2front'] = serialize($Back2Front_default_config);
-    
-    conf_update_param('back2front', $conf['back2front']);
-  }
-  else
-  {
-    if (is_string($conf['back2front']))
-    {
-      if (($old_conf = @unserialize($conf['back2front'])) === false)
-      {
-        $old_conf = explode(',', $conf['back2front']);
-      }
-    }
-    else
-    {
-      $old_conf = $conf['back2front'];
-    }
-    
-    // convert old comma separated conf
-    if (isset($old_conf[0]))
-    {
-      $new_conf = array(
-        'versos_cat' => $old_conf[0],
-        'switch_mode' => $old_conf[1],
-        'transition' => $old_conf[2],
-        'position' => $old_conf[3],
-        'link_name' => unserialize($old_conf[4]),
-        'show_thumbnail' => @$old_conf[5],
-        );
-    
-      $conf['back2front'] = serialize($new_conf);
-      conf_update_param('back2front', $conf['back2front']);
-    }
-  }
-  
-  // create tables
-  $query = '
-CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'image_verso` (
-  `image_id` mediumint(8) unsigned NOT NULL DEFAULT 0,
-  `verso_id` mediumint(8) unsigned NOT NULL DEFAULT 0,
-  `categories` varchar(128) NULL,
-  PRIMARY KEY (`image_id`),
-  UNIQUE KEY (`verso_id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-';
-  pwg_query($query);
-}
-
-?>
Index: /extensions/Back2Front/main.inc.php
===================================================================
--- /extensions/Back2Front/main.inc.php	(revision 29252)
+++ /extensions/Back2Front/main.inc.php	(revision 29253)
@@ -4,55 +4,33 @@
 Version: auto
 Description: Add a link on picture's page to show a alternative version of the pic (for postcards for example)
-Plugin URI: http://piwigo.org/ext/extension_view.php?eid=533
+Plugin URI: auto
 Author: Mistic
 Author URI: http://www.strangeplanet.fr
 */
 
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
+
 global $prefixeTable;
 
-defined('B2F_ID') or define('B2F_ID', basename(dirname(__FILE__)));
-define('B2F_PATH', PHPWG_PLUGINS_PATH . B2F_ID . '/');
+define('B2F_ID',    basename(dirname(__FILE__)));
+define('B2F_PATH',  PHPWG_PLUGINS_PATH . B2F_ID . '/');
 define('B2F_TABLE', $prefixeTable . 'image_verso');
-define('B2F_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . B2F_ID);
-define('B2F_VERSION', 'auto');
+define('B2F_ADMIN', get_root_url() . 'admin.php?page=plugin-' . B2F_ID);
 
 include_once(B2F_PATH . 'include/Back2Front.php');
 
+
 add_event_handler('init', 'back2front_init');
+
 
 function back2front_init()
 {
-  global $conf, $pwg_loaded_plugins;
+  global $conf;
   
-  if (
-    B2F_VERSION == 'auto' or
-    $pwg_loaded_plugins[B2F_ID]['version'] == 'auto' or
-    version_compare($pwg_loaded_plugins[B2F_ID]['version'], B2F_VERSION, '<')
-  )
-  {
-    include_once(B2F_PATH . 'include/install.inc.php');
-    back2front_install();
-    
-    if ( $pwg_loaded_plugins[B2F_ID]['version'] != 'auto' and B2F_VERSION != 'auto' )
-    {
-      $query = '
-UPDATE '. PLUGINS_TABLE .'
-SET version = "'. B2F_VERSION .'"
-WHERE id = "'. B2F_ID .'"';
-      pwg_query($query);
-      
-      $pwg_loaded_plugins[B2F_ID]['version'] = B2F_VERSION;
-      
-      if (defined('IN_ADMIN'))
-      {
-        $_SESSION['page_infos'][] = 'Back2Front updated to version '. B2F_VERSION;
-      }
-    }
-  }
-  
-  $conf['back2front'] = unserialize($conf['back2front']);
+  $conf['back2front'] = safe_unserialize($conf['back2front']);
+
   load_language('plugin.lang', B2F_PATH);
 }
+
 
 if (script_basename() == 'picture')
@@ -80,4 +58,2 @@
   }
 }
-
-?>
Index: /extensions/Back2Front/maintain.class.php
===================================================================
--- /extensions/Back2Front/maintain.class.php	(revision 29253)
+++ /extensions/Back2Front/maintain.class.php	(revision 29253)
@@ -0,0 +1,92 @@
+<?php
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
+
+class Back2Front_maintain extends PluginMaintain
+{
+  private $table;
+  
+  private $default_conf = array(
+    'versos_cat' => 0,
+    'switch_mode' => 'click',
+    'transition' => 'none',
+    'position' => 'top',
+    'link_name' => array('default'=>null),
+    'show_thumbnail' => true,
+    );
+  
+  function __construct($id)
+  {
+    global $prefixeTable;
+    
+    parent::__construct($id);
+    $this->table = $prefixeTable . 'image_verso';
+  }
+
+  function install($plugin_version, &$errors=array())
+  {
+    global $conf;
+
+    if (empty($conf['back2front']))
+    {
+      // create virtual private cat for storage
+      include_once(PHPWG_ROOT_PATH . 'admin/include/functions.inc.php');
+      $cat = create_virtual_category('Back2Front private album');
+      $info = array(
+        'comment' => 'Used by Back2Front to store backsides.',
+        'status'  => 'private',
+        'visible' => 'false',
+        'commentable' => 'false',
+        );
+      
+      single_update(
+        CATEGORIES_TABLE,
+        $info,
+        array('id' => $cat['id'])
+        );
+      
+      $this->default_conf['versos_cat'] = $cat['id'];
+      
+      conf_update_param('back2front', $this->default_conf, true);
+    }
+    
+    // create tables
+    $query = '
+CREATE TABLE IF NOT EXISTS `' . $this->table . '` (
+  `image_id` mediumint(8) unsigned NOT NULL DEFAULT 0,
+  `verso_id` mediumint(8) unsigned NOT NULL DEFAULT 0,
+  `categories` varchar(128) NULL,
+  PRIMARY KEY (`image_id`),
+  UNIQUE KEY (`verso_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+;';
+    pwg_query($query);
+  }
+
+  function update($old_version, $new_version, &$errors=array())
+  {
+    $this->install($new_version, $errors);
+  }
+
+  function uninstall()
+  {
+    global $conf;
+    
+    include_once(PHPWG_PLUGINS_PATH . 'Back2Front/include/functions.inc.php');
+    $conf['back2front'] = safe_unserialize($conf['back2front']);
+    
+    $images_versos = pwg_query("SELECT * FROM `" . $this->table . "`;");
+    while ($item = pwg_db_fetch_assoc($images_versos))
+    {
+      back2front_restaure_categories($item);
+    }
+
+    pwg_query("DROP TABLE `" . $this->table . "`;");
+    pwg_query("DELETE FROM `" . CATEGORIES_TABLE ."`WHERE id = ".$conf['back2front']['versos_cat'].";");
+    
+    // rebuild categories cache
+    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+    invalidate_user_cache(true);
+  
+    conf_delete_param('back2front');
+  }
+}
Index: tensions/Back2Front/maintain.inc.php
===================================================================
--- /extensions/Back2Front/maintain.inc.php	(revision 29252)
+++ 	(revision )
@@ -1,46 +1,0 @@
-<?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-
-defined('B2F_ID') or define('B2F_ID', basename(dirname(__FILE__)));
-include_once(PHPWG_PLUGINS_PATH . B2F_ID . '/include/install.inc.php');
-include_once(PHPWG_PLUGINS_PATH . B2F_ID . '/include/functions.inc.php');
-
-function plugin_install() 
-{
-  back2front_install();
-  
-  define('back2front_installed', true);
-}
-
-function plugin_activate()
-{
-  if (!defined('back2front_installed'))
-  {
-    back2front_install();
-  }
-}
-
-
-function plugin_uninstall()
-{
-  global $conf, $prefixeTable;
-  
-  $conf['back2front'] = unserialize($conf['back2front']);
-  
-  $query = "SELECT * FROM `" . $prefixeTable . "image_verso`;";
-  $images_versos = pwg_query($query);
-  
-  while ($item = pwg_db_fetch_assoc($images_versos))
-  {
-    back2front_restaure_categories($item);
-  }
-
-  pwg_query("DROP TABLE `" . $prefixeTable . "image_verso`;");
-  pwg_query("DELETE FROM `" . CONFIG_TABLE . "` WHERE param = 'back2front';");
-  pwg_query("DELETE FROM `" . CATEGORIES_TABLE ."`WHERE id = ".$conf['back2front']['versos_cat'].";");
-  
-  // rebuild categories cache
-  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
-  invalidate_user_cache(true);
-}
-?>
