Index: /extensions/Prune_History/admin/PH_admin.php
===================================================================
--- /extensions/Prune_History/admin/PH_admin.php	(revision 21099)
+++ /extensions/Prune_History/admin/PH_admin.php	(revision 21100)
@@ -35,8 +35,8 @@
 {
 
-  $newconf_PH[0] = $version;
-  $newconf_PH[1] = $_POST['PH_AutoPrune'];
-  $newconf_PH[2] = $_POST['PH_Range_Value'];
-  $newconf_PH[3] = $_POST['PH_Range'];
+  $newconf_PH['PHVersion'] = $version;
+  $newconf_PH['AUTOPRUNE'] = (isset($_POST['PH_AutoPrune']) ? $_POST['PH_AutoPrune'] : 'false');
+  $newconf_PH['RANGEVALUE'] = (isset($_POST['PH_Range_Value']) ? $_POST['PH_Range_Value'] : '0');
+  $newconf_PH['RANGE'] = (isset($_POST['PH_Range']) ? $_POST['PH_Range'] : '0');
 
   $conf['PruneHistory'] = serialize($newconf_PH);
@@ -162,8 +162,8 @@
     'PH_VERSION'                 => $version,
     'PH_DUMP_DOWNLOAD'           => $dump_download,
-		'PH_AUTOPRUNE_TRUE'          => $conf_PH[1]=='true' ? 'checked="checked"' : '' ,
-		'PH_AUTOPRUNE_FALSE'         => $conf_PH[1]=='false' ? 'checked="checked"' : '' ,
-    'PH_RANGE_VALUE'             => $conf_PH[2],
-    'PH_RANGE_SELECTED'          => $conf_PH[3],
+		'PH_AUTOPRUNE_TRUE'          => $conf_PH['AUTOPRUNE']=='true' ? 'checked="checked"' : '' ,
+		'PH_AUTOPRUNE_FALSE'         => $conf_PH['AUTOPRUNE']=='false' ? 'checked="checked"' : '' ,
+    'PH_RANGE_VALUE'             => $conf_PH['RANGEVALUE'],
+    'PH_RANGE_SELECTED'          => $conf_PH['RANGE'],
     'range_list'                 => $range_list,
     'month_list'                 => $month_list,
Index: /extensions/Prune_History/changelog.txt
===================================================================
--- /extensions/Prune_History/changelog.txt	(revision 21099)
+++ /extensions/Prune_History/changelog.txt	(revision 21100)
@@ -28,2 +28,6 @@
 
 2012-10-05 - 1.0.8 - Bug fixed : Possible MySql error when using "0" value in auto-prune function.
+
+2013-02-28 - 1.1.0 - Compliance with Piwigo 2.5
+                   - Code refactory : Change config variables to assoc array and $_POST vars control before writing conf in database - Thx to flop25 for his advices ;-)
+                   - Bug fixed : Unable to restore a backup file
Index: /extensions/Prune_History/include/functions.inc.php
===================================================================
--- /extensions/Prune_History/include/functions.inc.php	(revision 21099)
+++ /extensions/Prune_History/include/functions.inc.php	(revision 21100)
@@ -99,8 +99,8 @@
   $result = pwg_query($query);
   $conf_PH = pwg_db_fetch_assoc($result);
-    
+
   $Newconf_PH = unserialize($conf_PH['value']);
-  
-  $Newconf_PH[0] = $version;
+
+  $Newconf_PH['PHVersion'] = $version;
 
   $update_conf = serialize($Newconf_PH);
@@ -228,19 +228,19 @@
 
   // Definition of the range to keep
-  if (isset($conf_PH[1]) and $conf_PH[1] == 'true' and isset($conf_PH[2]) and $conf_PH[2] <> '0' and isset($conf_PH[3]) and $conf_PH[3] <> '0')
-  {
-    if ($conf_PH[3] == '1') // Ranged for days
-    {
-      $limit = mktime(0, 0, 0, date("m") , date("d")-$conf_PH[2], date("Y"));
+  if (isset($conf_PH['AUTOPRUNE']) and $conf_PH['AUTOPRUNE'] == 'true' and isset($conf_PH['RANGEVALUE']) and $conf_PH['RANGEVALUE'] <> '0' and isset($conf_PH['RANGE']) and $conf_PH['RANGE'] <> '0')
+  {
+    if ($conf_PH['RANGE'] == '1') // Ranged for days
+    {
+      $limit = mktime(0, 0, 0, date("m") , date("d")-$conf_PH['RANGEVALUE'], date("Y"));
       $limit = date('Y-m-d', $limit);
     }
-    else if ($conf_PH[3] == '2') // Ranged for months
-    {
-      $limit = mktime(0, 0, 0, date("m")-$conf_PH[2] , date("d"), date("Y"));
+    else if ($conf_PH['RANGE'] == '2') // Ranged for months
+    {
+      $limit = mktime(0, 0, 0, date("m")-$conf_PH['RANGEVALUE'] , date("d"), date("Y"));
       $limit = date('Y-m-d', $limit);
     }
-    else if  ($conf_PH[3] == '3') // Ranged for years
-    {
-      $limit = mktime(0, 0, 0, date("m") , date("d"), date("Y")-$conf_PH[2]);
+    else if  ($conf_PH['RANGE'] == '3') // Ranged for years
+    {
+      $limit = mktime(0, 0, 0, date("m") , date("d"), date("Y")-$conf_PH['RANGEVALUE']);
       $limit = date('Y-m-d', $limit);
     }
@@ -307,11 +307,13 @@
       $insertions .= "DROP TABLE IF EXISTS ".$ListTables[$j].";\n\n";
 
-      $array = mysql_fetch_array($res);
+      $array = pwg_db_fetch_row($res);
       $array[1] .= ";\n\n";
       $insertions .= $array[1];
 
-      $req_table = pwg_query('SELECT * FROM '.$ListTables[$j]) or die(mysql_error());
-      $nb_fields = mysql_num_fields($req_table);
-      while ($line = mysql_fetch_array($req_table))
+      $req_table = pwg_query('DESCRIBE '.$ListTables[$j].';') or die(my_error());
+      $nb_fields = pwg_db_num_rows($req_table);
+      $req_table2 = pwg_query('SELECT * FROM '.$ListTables[$j]) or die(my_error());
+
+      while ($line = pwg_db_fetch_row($req_table2))
       {
         $insertions .= 'INSERT INTO '.$ListTables[$j].' VALUES (';
@@ -375,5 +377,5 @@
   // Restore sql backup file - DROP TABLE queries are executed
   // ---------------------------------------------------------
-  UAM_execute_sqlfile(
+  PH_execute_sqlfile(
     $Backup_File,
     DEFAULT_PREFIX_TABLE,
Index: /extensions/Prune_History/include/upgradedb.inc.php
===================================================================
--- /extensions/Prune_History/include/upgradedb.inc.php	(revision 21100)
+++ /extensions/Prune_History/include/upgradedb.inc.php	(revision 21100)
@@ -0,0 +1,53 @@
+<?php
+/**
+ * @author Eric@piwigo.org
+ *  
+ * Upgrade processes for old plugin version
+ * Called from maintain.inc.php on plugin activation
+ * 
+ */
+
+if(!defined('PH_PATH'))
+{
+  define('PH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+}
+
+include_once (PH_PATH.'include/functions.inc.php');
+
+// +----------------------------------------------------------+
+// |       Upgrading database from old plugin versions        |
+// +----------------------------------------------------------+
+
+/* upgrade from 1.0 to 1.1 */
+/* *********************** */
+function upgrade_100_110()
+{
+  global $conf;
+  
+  load_language('plugin.lang', PH_PATH);
+
+  // Upgrading options - Changing config variables to assoc array
+  // ------------------------------------------------------------
+  
+  // Upgrade $conf_PH options
+  $conf_PH = unserialize($conf['PruneHistory']);
+
+  $Newconf_PH = array(
+    'PHVersion'   => $conf_PH[0],
+    'AUTOPRUNE'   => $conf_PH[1],
+    'RANGEVALUE'  => $conf_PH[2],
+    'RANGE'       => $conf_PH[3],
+  );
+
+  // unset obsolete conf
+  // -------------------
+  for ($i = 0; $i <= 3; $i++)
+  {
+    unset ($conf_PH[$i]);
+  }
+
+  $update_conf = serialize($Newconf_PH);
+
+  conf_update_param('PruneHistory', pwg_db_real_escape_string($update_conf));
+}
+?>
Index: /extensions/Prune_History/main.inc.php
===================================================================
--- /extensions/Prune_History/main.inc.php	(revision 21099)
+++ /extensions/Prune_History/main.inc.php	(revision 21100)
@@ -31,5 +31,5 @@
 
 /* Prune automation on user login */
-if (isset($conf_PH[1]) and $conf_PH[1] == 'true')
+if (isset($conf_PH['AUTOPRUNE']) and $conf_PH['AUTOPRUNE'] == 'true')
 {
   add_event_handler('login_success', 'history_autoprune' );
Index: /extensions/Prune_History/maintain.inc.php
===================================================================
--- /extensions/Prune_History/maintain.inc.php	(revision 21099)
+++ /extensions/Prune_History/maintain.inc.php	(revision 21100)
@@ -24,9 +24,10 @@
   // Default global parameters for Prune History conf
   // -------------------------------------------------
-  $defaultPH[0] = $version;                                  // Prune History version
-  $defaultPH[1] = 'false';                                   // Enable automated prune
-  $defaultPH[2] = '0';                                       // Range
-  $defaultPH[3] = '0';                                       // Value (Year, month, day)
-
+  $defaultPH = array(
+    'PHVersion'   => $version, // Prune History version
+    'AUTOPRUNE'   => 'false', // Enable automated prune
+    'RANGEVALUE'  => '0', // Range
+    'RANGE'       => '0' // Value (Year, month, day)
+  );
   // Create Prune History conf if not already exists
   // ------------------------------------------------
@@ -57,4 +58,20 @@
   PH_Obsolete_Files();
 
+  include_once (PH_PATH.'include/upgradedb.inc.php');
+
+/* Check database upgrade */
+/* ********************** */
+  $conf_PH = unserialize($conf['PruneHistory']);
+
+  if (isset($conf_PH[0]))
+  {
+    if (version_compare($conf_PH['PHVersion'], '1.1.0') < 0)
+    {
+    /* upgrade from 1.0 to 1.1 */
+    /* *********************** */
+      upgrade_100_110();
+    }
+  }
+
 /* Update plugin version number in #_config table */
 /* and check consistency of #_plugins table       */
