Ignore:
Timestamp:
Mar 2, 2013, 6:28:58 PM (11 years ago)
Author:
Eric
Message:

Next version will be 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 an history backup file
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Prune_History/include/functions.inc.php

    r20375 r21100  
    9999  $result = pwg_query($query);
    100100  $conf_PH = pwg_db_fetch_assoc($result);
    101    
     101
    102102  $Newconf_PH = unserialize($conf_PH['value']);
    103  
    104   $Newconf_PH[0] = $version;
     103
     104  $Newconf_PH['PHVersion'] = $version;
    105105
    106106  $update_conf = serialize($Newconf_PH);
     
    228228
    229229  // Definition of the range to keep
    230   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')
    231   {
    232     if ($conf_PH[3] == '1') // Ranged for days
    233     {
    234       $limit = mktime(0, 0, 0, date("m") , date("d")-$conf_PH[2], date("Y"));
     230  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')
     231  {
     232    if ($conf_PH['RANGE'] == '1') // Ranged for days
     233    {
     234      $limit = mktime(0, 0, 0, date("m") , date("d")-$conf_PH['RANGEVALUE'], date("Y"));
    235235      $limit = date('Y-m-d', $limit);
    236236    }
    237     else if ($conf_PH[3] == '2') // Ranged for months
    238     {
    239       $limit = mktime(0, 0, 0, date("m")-$conf_PH[2] , date("d"), date("Y"));
     237    else if ($conf_PH['RANGE'] == '2') // Ranged for months
     238    {
     239      $limit = mktime(0, 0, 0, date("m")-$conf_PH['RANGEVALUE'] , date("d"), date("Y"));
    240240      $limit = date('Y-m-d', $limit);
    241241    }
    242     else if  ($conf_PH[3] == '3') // Ranged for years
    243     {
    244       $limit = mktime(0, 0, 0, date("m") , date("d"), date("Y")-$conf_PH[2]);
     242    else if  ($conf_PH['RANGE'] == '3') // Ranged for years
     243    {
     244      $limit = mktime(0, 0, 0, date("m") , date("d"), date("Y")-$conf_PH['RANGEVALUE']);
    245245      $limit = date('Y-m-d', $limit);
    246246    }
     
    307307      $insertions .= "DROP TABLE IF EXISTS ".$ListTables[$j].";\n\n";
    308308
    309       $array = mysql_fetch_array($res);
     309      $array = pwg_db_fetch_row($res);
    310310      $array[1] .= ";\n\n";
    311311      $insertions .= $array[1];
    312312
    313       $req_table = pwg_query('SELECT * FROM '.$ListTables[$j]) or die(mysql_error());
    314       $nb_fields = mysql_num_fields($req_table);
    315       while ($line = mysql_fetch_array($req_table))
     313      $req_table = pwg_query('DESCRIBE '.$ListTables[$j].';') or die(my_error());
     314      $nb_fields = pwg_db_num_rows($req_table);
     315      $req_table2 = pwg_query('SELECT * FROM '.$ListTables[$j]) or die(my_error());
     316
     317      while ($line = pwg_db_fetch_row($req_table2))
    316318      {
    317319        $insertions .= 'INSERT INTO '.$ListTables[$j].' VALUES (';
     
    375377  // Restore sql backup file - DROP TABLE queries are executed
    376378  // ---------------------------------------------------------
    377   UAM_execute_sqlfile(
     379  PH_execute_sqlfile(
    378380    $Backup_File,
    379381    DEFAULT_PREFIX_TABLE,
Note: See TracChangeset for help on using the changeset viewer.