Index: /extensions/Prune_History/admin.php
===================================================================
--- /extensions/Prune_History/admin.php	(revision 14838)
+++ /extensions/Prune_History/admin.php	(revision 14838)
@@ -0,0 +1,3 @@
+<?php
+  include(PH_PATH.'admin/PH_admin.php');
+?>
Index: /extensions/Prune_History/admin/PH_admin.php
===================================================================
--- /extensions/Prune_History/admin/PH_admin.php	(revision 14838)
+++ /extensions/Prune_History/admin/PH_admin.php	(revision 14838)
@@ -0,0 +1,126 @@
+<?php
+
+global $lang, $conf, $errors;
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+// +-----------------------------------------------------------------------+
+// | Check Access and exit when user status is not ok                      |
+// +-----------------------------------------------------------------------+
+check_status(ACCESS_ADMINISTRATOR);
+
+if(!defined('PH_PATH'))
+{
+  define('PH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+}
+
+load_language('plugin.lang', PH_PATH);
+
+$page['global'] = array();
+$range = array();
+
+// +-----------------------------------------------------------------------+
+// |                      Getting plugin version                           |
+// +-----------------------------------------------------------------------+
+$plugin =  PHInfos(PH_PATH);
+$version = $plugin['version'];
+$name = $plugin['name'];
+
+
+// +-----------------------------------------------------------------------+
+// |                      Saving new configuration                         |
+// +-----------------------------------------------------------------------+
+if (isset($_POST['submit']) and isset($_POST['PH_AutoPrune']) and isset($_POST['PH_Range_Value']) and isset($_POST['PH_Range']))
+{
+
+  $newconf_PH[0] = $version;
+  $newconf_PH[1] = $_POST['PH_AutoPrune'];
+  $newconf_PH[2] = $_POST['PH_Range_Value'];
+  $newconf_PH[3] = $_POST['PH_Range'];
+
+  $conf['PruneHistory'] = serialize($newconf_PH);
+
+  conf_update_param('PruneHistory', pwg_db_real_escape_string($conf['PruneHistory']));
+
+  array_push($page['infos'], l10n('PH_save_config'));
+}
+
+$conf_PH = unserialize($conf['PruneHistory']);
+
+// Manual prune
+if (isset($_POST['prune']))
+{
+  // Starting range date
+  if (!empty($_POST['start_year']))
+  {
+    $range['date-after'] = sprintf(
+      '%d-%02d-%02d',
+      $_POST['start_year'],
+      $_POST['start_month'],
+      $_POST['start_day']
+      );
+  }
+
+  // Ending range date
+  if (!empty($_POST['end_year']))
+  {
+    $range['date-before'] = sprintf(
+      '%d-%02d-%02d',
+      $_POST['end_year'],
+      $_POST['end_month'],
+      $_POST['end_day']
+      );
+  }
+
+  // Prune action on ranged dates
+  if (history_prune($range['date-after'],$range['date-before']))
+  {
+    array_push($page['infos'], l10n('PH_Prune_Done')); 
+  }
+  else array_push($page['errors'], l10n('PH_Prune_Error'));
+}
+else
+{
+  // by default, the selected date have to be the current date
+  $_POST['start_year']  = $_POST['end_year']  = date('Y');
+  $_POST['start_month'] = $_POST['end_month'] = date('n');
+  $_POST['start_day']   = $_POST['end_day']   = date('j');
+}
+
+// +-----------------------------------------------------------------------+
+// |                           templates init                              |
+// +-----------------------------------------------------------------------+
+$month_list = $lang['month'];
+$month_list[0]='------------';
+ksort($month_list);
+
+$range_list = $lang['range'];
+$range_list[0]='------------';
+ksort($range_list);
+
+$template->assign(
+  array(
+    'PH_PATH'                    => PH_PATH,
+    'PWG_ROOT_PATH'              => PHPWG_ROOT_PATH,
+    'PH_NAME'                    => $name,
+    'PH_VERSION'                 => $version,
+		'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],
+    'range_list'                 => $range_list,
+    'month_list'                 => $month_list,
+    'START_DAY_SELECTED'         => @$_POST['start_day'],
+    'START_MONTH_SELECTED'       => @$_POST['start_month'],
+    'START_YEAR'                 => @$_POST['start_year'],
+    'END_DAY_SELECTED'           => @$_POST['end_day'],
+    'END_MONTH_SELECTED'         => @$_POST['end_month'],
+    'END_YEAR'                   => @$_POST['end_year'],
+  )
+);
+
+// +-----------------------------------------------------------------------+
+// |                           templates display                           |
+// +-----------------------------------------------------------------------+
+$template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/PH_admin.tpl');
+$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+?>
Index: /extensions/Prune_History/admin/index.php
===================================================================
--- /extensions/Prune_History/admin/index.php	(revision 14838)
+++ /extensions/Prune_History/admin/index.php	(revision 14838)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/Prune_History/admin/template/PH_admin.tpl
===================================================================
--- /extensions/Prune_History/admin/template/PH_admin.tpl	(revision 14838)
+++ /extensions/Prune_History/admin/template/PH_admin.tpl	(revision 14838)
@@ -0,0 +1,137 @@
+{combine_script id='jquery' path='themes/default/js/jquery.min.js'}
+{combine_script id='jquery.cluetip' require='jquery' path='themes/default/js/plugins/jquery.cluetip.js'}
+
+{combine_css path= $PH_PATH|@cat:'admin/template/ph.css'}
+
+{include file='include/datepicker.inc.tpl'}
+
+{footer_script}{literal}
+  pwg_initialization_datepicker("#start_day", "#start_month", "#start_year", "#start_linked_date", null, null, "#end_linked_date");
+  pwg_initialization_datepicker("#end_day", "#end_month", "#end_year", "#end_linked_date", null, "#start_linked_date", null);
+{/literal}{/footer_script}
+
+<script type="text/javascript">
+jQuery().ready(function()
+{ldelim}
+  jQuery('.cluetip').cluetip(
+  {ldelim}
+    width: 500,
+    splitTitle: '|'
+  {rdelim});
+{rdelim});
+</script>
+
+<div class="titrePage">
+  <h2>{$PH_NAME} {$PH_VERSION}</h2>
+</div>
+
+<fieldset>
+  <ul>
+    <li>
+      <label class="cluetip" title="{'PH_ManualPrune_title'|translate}|{'PH_ManualPrune_title_d'|translate}">
+        {'PH_ManualPrune_title'|@translate}
+      </label>
+      <br><br>
+      <form method="post" name="prune" action="" class="general">
+        <ul class="date">
+          <li class="date">
+            <label class="date">{'Start_Date'|@translate}</label>
+          </li>
+          <li class="date">
+            <select id="start_day" name="start_day">
+              <option value="0">--</option>
+              {section name=day start=1 loop=32}
+                <option value="{$smarty.section.day.index}" {if $smarty.section.day.index==$START_DAY_SELECTED}selected="selected"{/if}>{$smarty.section.day.index}</option>
+              {/section}
+            </select>
+            <select id="start_month" name="start_month">
+              {html_options options=$month_list selected=$START_MONTH_SELECTED}
+            </select>
+            <input id="start_year" name="start_year" value="{$START_YEAR}" type="text" size="4" maxlength="4" >
+            <input id="start_linked_date" name="start_linked_date" type="hidden" size="10" disabled="disabled">
+          </li>
+          <li class="date">
+            <a class="date_today" href="#" onClick="document.prune.start_day.value={$smarty.now|date_format:"%d"};document.prune.start_month.value={$smarty.now|date_format:"%m"};document.prune.start_year.value={$smarty.now|date_format:"%Y"};return false;">{'today'|@translate}</a>
+          </li>
+        </ul>
+
+        <ul class="date">
+          <li class="date">
+            <label class="date">{'End-Date'|@translate}</label>
+          </li>
+          <li class="date">
+            <select id="end_day" name="end_day">
+              <option value="0">--</option>
+              {section name=day start=1 loop=32}
+                <option value="{$smarty.section.day.index}" {if $smarty.section.day.index==$END_DAY_SELECTED}selected="selected"{/if}>{$smarty.section.day.index}</option>
+              {/section}
+            </select>
+            <select id="end_month" name="end_month">
+              {html_options options=$month_list selected=$END_MONTH_SELECTED}
+            </select>
+            <input id="end_year" name="end_year" value="{$END_YEAR}" type="text" size="4" maxlength="4" >
+            <input id="end_linked_date" name="end_linked_date" type="hidden" size="10" disabled="disabled">
+          </li>
+          <li class="date">
+      <a class="date_today" href="#" onClick="document.prune.end_day.value={$smarty.now|date_format:"%d"};document.prune.end_month.value={$smarty.now|date_format:"%m"};document.prune.end_year.value={$smarty.now|date_format:"%Y"};return false;">{'today'|@translate}</a>
+          </li>
+        </ul>
+        <p>
+          <input class="submit" type="submit" value="{'PH_Prune'|@translate}" name="prune" {$TAG_INPUT_ENABLED}>
+        </p>
+      </li>
+    </ul>
+  </form>
+</fieldset>
+
+<fieldset>
+<form method="post" name="autoprune" action="" class="general">
+  <ul>
+    <li>
+      <label class="cluetip" title="{'PH_AutoPrune_title'|translate}|{'PH_AutoPrune_title_d'|translate}">
+        {'PH_AutoPrune_title'|@translate}
+      </label>
+    <br><br>
+      <input type="radio" value="false" {$PH_AUTOPRUNE_FALSE} name="PH_AutoPrune">
+        {'PH_AutoPrune_false'|@translate}<br>
+      <input type="radio" value="true" {$PH_AUTOPRUNE_TRUE} name="PH_AutoPrune">
+        {'PH_AutoPrune_true'|@translate}
+    <fieldset>
+      <ul>
+        <li>
+          <label class="cluetip" title="{'PH_AutoRange_title'|translate}|{'PH_AutoRange_title_d'|translate}">
+            {'PH_AutoRange_title'|@translate}
+          </label>
+        </li>
+        <br>
+        <ul class="date">
+          <li class="date">
+            <input type="text" name="PH_Range_Value" value="{$PH_RANGE_VALUE}" size="10" style="text-align: center;">
+            <select id="PH_Range" name="PH_Range">
+              {html_options options=$range_list selected=$PH_RANGE_SELECTED}
+            </select>
+          </li>
+        </ul>
+      </ul>
+    </fieldset>
+    <p>
+      <input class="submit" type="submit" value="{'PH_submit'|@translate}" name="submit" {$TAG_INPUT_ENABLED}>
+    </p>
+    </li>
+  </ul>
+</form>
+</fieldset>
+
+<fieldset>
+  <label>{'PH_Support'|@translate}</label><br><br>
+</fieldset>
+
+{html_head}
+<script type="text/javascript">
+jQuery(document).ready(function() {ldelim}
+  jQuery('#theAdminPage #the_page').addClass('{$themeconf.name}');
+	jQuery(".infos").fadeOut(800).fadeIn(1200).fadeOut(400).fadeIn(800).fadeOut(400);
+	jQuery(".errors").fadeOut(200).fadeIn(200).fadeOut(300).fadeIn(300).fadeOut(400).fadeIn(400); 
+});
+</script>
+{/html_head}
Index: /extensions/Prune_History/admin/template/index.php
===================================================================
--- /extensions/Prune_History/admin/template/index.php	(revision 14838)
+++ /extensions/Prune_History/admin/template/index.php	(revision 14838)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/Prune_History/admin/template/ph.css
===================================================================
--- /extensions/Prune_History/admin/template/ph.css	(revision 14838)
+++ /extensions/Prune_History/admin/template/ph.css	(revision 14838)
@@ -0,0 +1,16 @@
+.date UL, .date LABEL {
+    display: block;
+    float: left;
+    margin-right: 1em;
+    padding-bottom: 0;
+    padding-left: 0;
+    padding-right: 0;
+    padding-top: 0;
+}
+
+.date LI {
+    list-style-image: none;
+    list-style-position: outside;
+    list-style-type: none;
+    margin-bottom: 0.5em;
+}
Index: /extensions/Prune_History/changelog.txt
===================================================================
--- /extensions/Prune_History/changelog.txt	(revision 14838)
+++ /extensions/Prune_History/changelog.txt	(revision 14838)
@@ -0,0 +1,4 @@
+Plugin Name: Prune History
+** Change log **
+
+1.0.0 - Initial release
Index: /extensions/Prune_History/include/functions.inc.php
===================================================================
--- /extensions/Prune_History/include/functions.inc.php	(revision 14838)
+++ /extensions/Prune_History/include/functions.inc.php	(revision 14838)
@@ -0,0 +1,256 @@
+<?php
+/* Function called from main.inc.php to get the plugin version and name */
+function PHInfos($dir)
+{
+  $path = $dir;
+
+  $plg_data = implode( '', file($path.'main.inc.php') );
+  if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) )
+  {
+    $plugin['name'] = trim( $val[1] );
+  }
+  if (preg_match("|Version: (.*)|", $plg_data, $val))
+  {
+    $plugin['version'] = trim($val[1]);
+  }
+  if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) )
+  {
+    $plugin['uri'] = trim($val[1]);
+  }
+  if ($desc = load_language('description.txt', $path.'/', array('return' => true)))
+  {
+    $plugin['description'] = trim($desc);
+  }
+  elseif ( preg_match("|Description: (.*)|", $plg_data, $val) )
+  {
+    $plugin['description'] = trim($val[1]);
+  }
+  if ( preg_match("|Author: (.*)|", $plg_data, $val) )
+  {
+    $plugin['author'] = trim($val[1]);
+  }
+  if ( preg_match("|Author URI: (.*)|", $plg_data, $val) )
+  {
+    $plugin['author uri'] = trim($val[1]);
+  }
+  if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid='))
+  {
+    list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']);
+    if (is_numeric($extension)) $plugin['extension'] = $extension;
+  }
+// IMPORTANT SECURITY !
+  $plugin = array_map('htmlspecialchars', $plugin);
+
+  return $plugin ;
+}
+
+
+/* *************************************** */
+/* Update plugin version in conf table     */
+/* Used everytime a new version is updated */
+/* even if no database upgrade is needed   */
+/* *************************************** */
+function PH_version_update()
+{
+  global $conf;
+  
+  load_language('plugin.lang', PH_PATH);
+  
+  // Get current plugin version
+  // --------------------------
+  $plugin =  PHInfos(PH_PATH);
+  $version = $plugin['version'];
+
+  // Upgrading options
+  // -----------------
+  $query = '
+SELECT value
+FROM '.CONFIG_TABLE.'
+WHERE param = "PruneHistory"
+;';
+
+  $result = pwg_query($query);
+  $conf_PH = pwg_db_fetch_assoc($result);
+    
+  $Newconf_PH = unserialize($conf_PH['value']);
+  
+  $Newconf_PH[0] = $version;
+
+  $update_conf = serialize($Newconf_PH);
+
+  conf_update_param('PruneHistory', pwg_db_real_escape_string($update_conf));
+
+
+// Check #_plugin table consistency
+// Only useful if a previous version upgrade has not worked correctly (rare case)
+// ------------------------------------------------------------------------------
+  $query = '
+SELECT version
+  FROM '.PLUGINS_TABLE.'
+WHERE id = "PruneHistory"
+;';
+  
+  $data = pwg_db_fetch_assoc(pwg_query($query));
+  
+  if (empty($data['version']) or $data['version'] <> $version)
+  {
+    $query = '
+UPDATE '.PLUGINS_TABLE.'
+SET version="'.$version.'"
+WHERE id = "PruneHistory"
+LIMIT 1
+;';
+
+    pwg_query($query);
+  }
+}
+
+
+/**
+ * Delete obsolete files on plugin upgrade
+ * Obsolete files are listed in file obsolete.list
+ *
+ */
+function PH_Obsolete_Files()
+{
+  if (file_exists(PH_PATH.'obsolete.list')
+    and $old_files = file(PH_PATH.'obsolete.list', FILE_IGNORE_NEW_LINES)
+    and !empty($old_files))
+  {
+    array_push($old_files, 'obsolete.list');
+    foreach($old_files as $old_file)
+    {
+      $path = PH_PATH.$old_file;
+      if (is_file($path))
+      {
+        @unlink($path);
+      }
+      elseif (is_dir($path))
+      {
+        @rmdir($path);
+      }
+    }
+  }
+}
+
+
+/**
+ * Manual prune function
+ * 
+ * @param : Start and stop range to prune
+ * 
+ * @return : boolean
+ */
+function history_prune($startdate,$stopdate)
+{
+  list($year, $month, $day) = explode('-', $startdate); // explode date of $startdate						 
+ 	$starttimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp
+
+  list($year, $month, $day) = explode('-', $stopdate); // explode date of $stopdate						 
+ 	$stoptimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp
+
+  if ($starttimestamp < $stoptimestamp)
+  {
+    $query = '
+DELETE
+FROM '.HISTORY_TABLE.' 
+WHERE date < "'.$stopdate.'" 
+AND date > "'.$startdate.'"
+AND summarized = "true";';
+
+    $r = pwg_query($query);
+
+    if ($r)
+    {
+      $query = 'OPTIMIZE TABLE '.HISTORY_TABLE.';';
+      pwg_query($query);
+    }
+    return true;
+  }
+  else if ($starttimestamp == $stoptimestamp)
+  {
+    $query = '
+DELETE FROM '.HISTORY_TABLE.' 
+WHERE date = "'.$stopdate.'" 
+AND summarized = "true";';
+
+    $r = pwg_query($query);
+
+    if ($r)
+    {
+      $query = 'OPTIMIZE TABLE '.HISTORY_TABLE.';';
+      pwg_query($query);
+    }
+    return true;
+  }
+
+  return false;
+}
+
+
+/**
+ * Automatic prune function
+ * 
+ * @param : Start and stop range to prune
+ * 
+ * @return : boolean
+ */
+function history_autoprune()
+{
+  global $conf;
+  
+  $conf_PH = unserialize($conf['PruneHistory']);
+
+  // 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"));
+      $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"));
+      $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]);
+      $limit = date('Y-m-d', $limit);
+    }
+  }
+
+  $query = '
+DELETE FROM '.HISTORY_TABLE.' 
+WHERE date < "'.$limit.'"
+AND summarized = "true";';
+
+  $r = pwg_query($query);
+
+  if($r)
+	{
+    $query = 'OPTIMIZE TABLE '.HISTORY_TABLE.';';
+    pwg_query($query);
+  }
+}
+
+
+
+/**
+ * Useful for debugging - 4 vars can be set
+ * Output result to log.txt file
+ *
+ */
+function PHLog($var1, $var2, $var3, $var4)
+{
+   $fo=fopen (PH_PATH.'log.txt','a') ;
+   fwrite($fo,"======================\n") ;
+   fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n");
+   fwrite($fo,$var1 ."\r\n") ;
+   fwrite($fo,$var2 ."\r\n") ;
+   fwrite($fo,$var3 ."\r\n") ;
+   fwrite($fo,$var4 ."\r\n") ;
+   fclose($fo) ;
+}
+?>
Index: /extensions/Prune_History/include/index.php
===================================================================
--- /extensions/Prune_History/include/index.php	(revision 14838)
+++ /extensions/Prune_History/include/index.php	(revision 14838)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/Prune_History/index.php
===================================================================
--- /extensions/Prune_History/index.php	(revision 14838)
+++ /extensions/Prune_History/index.php	(revision 14838)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/Prune_History/language/en_UK/description.txt
===================================================================
--- /extensions/Prune_History/language/en_UK/description.txt	(revision 14838)
+++ /extensions/Prune_History/language/en_UK/description.txt	(revision 14838)
@@ -0,0 +1,1 @@
+Manual prune and background process which cleans your history table on regular basis.
Index: /extensions/Prune_History/language/en_UK/index.php
===================================================================
--- /extensions/Prune_History/language/en_UK/index.php	(revision 14838)
+++ /extensions/Prune_History/language/en_UK/index.php	(revision 14838)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/Prune_History/language/fr_FR/description.txt
===================================================================
--- /extensions/Prune_History/language/fr_FR/description.txt	(revision 14838)
+++ /extensions/Prune_History/language/fr_FR/description.txt	(revision 14838)
@@ -0,0 +1,1 @@
+Elaguage manuel et tâche de fond pour nettoyer la table historique.
Index: /extensions/Prune_History/language/fr_FR/index.php
===================================================================
--- /extensions/Prune_History/language/fr_FR/index.php	(revision 14838)
+++ /extensions/Prune_History/language/fr_FR/index.php	(revision 14838)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/Prune_History/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/Prune_History/language/fr_FR/plugin.lang.php	(revision 14838)
+++ /extensions/Prune_History/language/fr_FR/plugin.lang.php	(revision 14838)
@@ -0,0 +1,18 @@
+<?php
+$lang['PH_ManualPrune_title'] = 'Elagage manuel';
+$lang['PH_AutoPrune_title'] = 'Elagage automatique';
+$lang['PH_AutoPrune_false'] = 'Désactiver';
+$lang['PH_AutoPrune_true'] = 'Activer';
+$lang['Start_Date'] = 'Date de début';
+$lang['PH_AutoRange_title'] = 'Ne conserver un historique que sur :';
+$lang['PH_save_config'] = 'Configuration enregistrée !';
+$lang['PH_Prune'] = 'Exécuter l\'élagage manuel';
+$lang['PH_submit'] = 'Enregistrer la configuration';
+
+$lang['PH_Prune_Done'] = 'Elagage manuel effectué !';
+$lang['PH_Prune_Error'] = 'Erreur lors de l\'élagage manuel ! Vérifiez votre plage de dates.';
+
+$lang['range'][1] = 'Jour(s)';
+$lang['range'][2] = 'Mois';
+$lang['range'][3] = 'Année(s)';
+?>
Index: /extensions/Prune_History/main.inc.php
===================================================================
--- /extensions/Prune_History/main.inc.php	(revision 14838)
+++ /extensions/Prune_History/main.inc.php	(revision 14838)
@@ -0,0 +1,51 @@
+<?php
+/*
+Plugin Name: Prune History
+Version: 1.0.0-beta1
+Description: Based on original History_cleanup plugin from VDigital, this plugin allows to manually or automatically prune history table according to configurable criteria
+Plugin URI: http://piwigo.org/ext/extension_view.php?eid=
+Author: Eric
+Author URI: http://www.infernoweb.net
+*/
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+if(!defined('PH_PATH'))
+{
+  define('PH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+}
+
+global $conf;
+
+include_once (PH_PATH.'include/functions.inc.php');
+
+load_language('plugin.lang', PH_PATH);
+$conf_PH = unserialize($conf['PruneHistory']);
+
+/* Plugin admin */
+add_event_handler('get_admin_plugin_menu_links', 'PH_admin_menu');
+
+function PH_admin_menu($menu)
+{
+// +-----------------------------------------------------------------------+
+// |                      Getting plugin name                              |
+// +-----------------------------------------------------------------------+
+  $plugin =  PHInfos(PH_PATH);
+  $name = $plugin['name'];
+  
+  array_push($menu,
+    array(
+      'NAME' => $name,
+      'URL' => get_root_url().'admin.php?page=plugin-'.basename(PH_PATH)
+    )
+  );
+
+  return $menu;
+}
+
+// Prune automation on user login
+if (isset($conf_PH[1]) and $conf_PH[1] == 'true')
+{
+  add_event_handler('login_success', 'history_autoprune' );
+}
+?>
Index: /extensions/Prune_History/maintain.inc.php
===================================================================
--- /extensions/Prune_History/maintain.inc.php	(revision 14838)
+++ /extensions/Prune_History/maintain.inc.php	(revision 14838)
@@ -0,0 +1,82 @@
+<?php
+
+if(!defined('PH_PATH'))
+{
+  define('PH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+}
+
+include_once (PH_PATH.'include/functions.inc.php');
+
+function plugin_install()
+{
+	global $conf;
+
+/* ****************************************************************** */
+/* **************** BEGIN - Data preparation in vars **************** */
+/* ****************************************************************** */
+
+  $defaultPH = array();
+
+  // Set current plugin version in config table
+  $plugin =  PHInfos(PH_PATH);
+  $version = $plugin['version'];
+
+  // Default global parameters for Prune History conf
+  // -------------------------------------------------
+  $defaultPH[0] = $version;                                  // Prune History version
+  $defaultPH[1] = 'false';                                   // Enable automated prune
+
+  // Create Prune History conf if not already exists
+  // ------------------------------------------------
+	$query = '
+SELECT param
+  FROM '.CONFIG_TABLE.'
+WHERE param = "PruneHistory"
+;';
+  $count = pwg_db_num_rows(pwg_query($query));
+  
+  if ($count == 0)
+  {
+    $q = '
+INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
+VALUES ("PruneHistory","'.pwg_db_real_escape_string(serialize($defaultPH)).'","Prune History parameters")
+  ;';
+    pwg_query($q);
+  }
+}
+
+
+function plugin_activate()
+{
+  global $conf;
+
+/* Cleaning obsolete files */
+/* *********************** */
+  PH_Obsolete_Files();
+
+/* Update plugin version number in #_config table */
+/* and check consistency of #_plugins table       */
+/* ********************************************** */
+  PH_version_update();
+
+/* Reload plugin parameters */
+/* ************************ */
+  load_conf_from_db('param like \'PruneHistory\'');
+}
+
+
+function plugin_uninstall()
+{
+  global $conf;
+
+  if (isset($conf['PruneHistory']))
+  {
+    $q = '
+DELETE FROM '.CONFIG_TABLE.'
+WHERE param="PruneHistory"
+;';
+
+    pwg_query($q);
+  }
+}
+?>
