Index: trunk/admin/history.php
===================================================================
--- trunk/admin/history.php	(revision 1882)
+++ trunk/admin/history.php	(revision 1883)
@@ -228,14 +228,4 @@
   
   $query = '
-SELECT COUNT(*)
-  FROM '.HISTORY_TABLE.'
-  WHERE '.$where_separator.'
-;';
-
-  // echo '<pre>'.$query.'</pre>';
-  
-  list($page['nb_lines']) = mysql_fetch_row(pwg_query($query));
-
-  $query = '
 SELECT
     date,
@@ -250,9 +240,18 @@
   FROM '.HISTORY_TABLE.'
   WHERE '.$where_separator.'
-  LIMIT '.$page['start'].', '.$conf['nb_logs_page'].'
 ;';
 
+  // LIMIT '.$page['start'].', '.$conf['nb_logs_page'].'
+
   $result = pwg_query($query);
-  $history_lines = $user_ids = $category_ids = $image_ids = array();
+
+  $page['nb_lines'] = mysql_num_rows($result);
+  
+  $history_lines = array();
+  $user_ids = array();
+  $category_ids = array();
+  $image_ids = array();
+  $tag_ids = array();
+  
   while ($row = mysql_fetch_assoc($result))
   {
@@ -315,15 +314,69 @@
   {
     $query = '
-SELECT id, IF(name IS NULL, file, name) AS label
+SELECT
+    id,
+    IF(name IS NULL, file, name) AS label,
+    filesize,
+    high_filesize
   FROM '.IMAGES_TABLE.'
   WHERE id IN ('.implode(',', array_keys($image_ids)).')
 ;';
-    $label_of_image = simple_hash_from_query($query, 'id', 'label');
+    // $label_of_image = simple_hash_from_query($query, 'id', 'label');
+    $label_of_image = array();
+    $filesize_of_image = array();
+    $high_filesize_of_image = array();
+    
+    $result = pwg_query($query);
+    while ($row = mysql_fetch_array($result))
+    {
+      $label_of_image[ $row['id'] ] = $row['label'];
+
+      if (isset($row['filesize']))
+      {
+        $filesize_of_image[ $row['id'] ] = $row['filesize'];
+      }
+
+      if (isset($row['high_filesize']))
+      {
+        $high_filesize_of_image[ $row['id'] ] = $row['high_filesize'];
+      }
+    }
+
+    // echo '<pre>'; print_r($high_filesize_of_image); echo '</pre>';
   }
   
   $i = 0;
+  $first_line = $page['start'] + 1;
+  $last_line = $page['start'] + $conf['nb_logs_page'];
+
+  $total_filesize = 0;
 
   foreach ($history_lines as $line)
   {
+    if (isset($line['image_type']))
+    {
+      if ($line['image_type'] == 'high')
+      {
+        if (isset($high_filesize_of_image[$line['image_id']]))
+        {
+          $total_filesize+= $high_filesize_of_image[$line['image_id']];
+        }
+      }
+      else
+      {
+        if (isset($filesize_of_image[$line['image_id']]))
+        {
+          $total_filesize+= $filesize_of_image[$line['image_id']];
+        }
+      }
+    }
+    
+    $i++;
+    
+    if ($i < $first_line or $i > $last_line)
+    {
+      continue;
+    }
+    
     $template->assign_block_vars(
       'detail',
@@ -338,7 +391,15 @@
         'IMAGE'     => isset($line['image_id'])
           ? ( isset($label_of_image[$line['image_id']])
-                ? $label_of_image[$line['image_id']]
-                : 'deleted '.$line['image_id'])
-          : $line['image_id'],
+                ? sprintf(
+                    '(%u) %s',
+                    $line['image_id'],
+                    $label_of_image[$line['image_id']]
+                  )
+                : sprintf(
+                    '(%u) deleted ',
+                    $line['image_id']
+                  )
+            )
+          : '',
         'TYPE'      => $line['image_type'],
         'SECTION'   => $line['section'],
@@ -349,8 +410,15 @@
           : '',
         'TAGS'       => $line['tag_ids'],
-        'T_CLASS'   => ($i++ % 2) ? 'row1' : 'row2',
+        'T_CLASS'   => ($i % 2) ? 'row1' : 'row2',
         )
       );
   }
+
+  $template->assign_block_vars(
+    'summary',
+    array(
+      'FILESIZE' => $total_filesize.' KB',
+      )
+    );
 }
 
Index: trunk/admin/include/functions_metadata.php
===================================================================
--- trunk/admin/include/functions_metadata.php	(revision 1882)
+++ trunk/admin/include/functions_metadata.php	(revision 1883)
@@ -106,4 +106,26 @@
   $datas = array();
   $tags_of = array();
+  $has_high_images = array();
+
+  $image_ids = array();
+  foreach ($files as $id => $file)
+  {
+    array_push($image_ids, $id);
+  }
+  
+  $query = '
+SELECT id
+  FROM '.IMAGES_TABLE.'
+  WHERE has_high = \'true\'
+    AND id IN (
+'.wordwrap(implode(', ', $image_ids), 80, "\n").'
+)
+;';
+
+  $result = pwg_query($query);
+  while ($row = mysql_fetch_array($result))
+  {
+    array_push($has_high_images, $row['id']);
+  }
 
   foreach ($files as $id => $file)
@@ -117,4 +139,11 @@
       $data['width'] = $image_size[0];
       $data['height'] = $image_size[1];
+    }
+
+    if (in_array($id, $has_high_images))
+    {
+      $high_file = dirname($file).'/pwg_high/'.basename($file);
+
+      $data['high_filesize'] = floor(filesize($high_file)/1024);
     }
   
@@ -162,4 +191,5 @@
         'width',
         'height',
+        'high_filesize',
         'date_metadata_update'
         );
Index: trunk/admin/picture_modify.php
===================================================================
--- trunk/admin/picture_modify.php	(revision 1882)
+++ trunk/admin/picture_modify.php	(revision 1883)
@@ -263,4 +263,16 @@
   );
 
+if ($row['has_high'] == 'true')
+{
+  $template->assign_block_vars(
+    'high',
+    array(
+      'FILESIZE' => isset($row['high_filesize'])
+        ? $row['high_filesize'].' KB'
+        : l10n('unknown'),
+      )
+    );
+}
+
 // creation date
 unset($day, $month, $year);
Index: trunk/admin/site_reader_local.php
===================================================================
--- trunk/admin/site_reader_local.php	(revision 1882)
+++ trunk/admin/site_reader_local.php	(revision 1883)
@@ -158,5 +158,5 @@
   global $conf;
 
-  $update_fields = array('filesize', 'width', 'height');
+  $update_fields = array('filesize', 'width', 'height', 'high_filesize');
 
   if ($conf['use_exif'])
@@ -182,5 +182,5 @@
 
 // returns a hash of attributes (metadata+filesize+width,...) for file
-function get_element_metadata($file)
+function get_element_metadata($file, $has_high = false)
 {
   global $conf;
@@ -200,4 +200,11 @@
   }
 
+  if ($has_high)
+  {
+    $high_file = dirname($file).'/pwg_high/'.basename($file);
+    
+    $data['high_filesize'] = floor(filesize($high_file)/1024);
+  }
+  
   if ($conf['use_exif'])
   {
Index: trunk/admin/site_reader_remote.php
===================================================================
--- trunk/admin/site_reader_remote.php	(revision 1882)
+++ trunk/admin/site_reader_remote.php	(revision 1883)
@@ -48,5 +48,5 @@
     );
   $this->metadata_attributes = array(
-    'filesize', 'width', 'height'
+    'filesize', 'width', 'height', 'high_filesize'
     );
 
@@ -89,9 +89,14 @@
     }
 
-    $this->metadata_attributes = array_merge(
-      $this->metadata_attributes,
-      explode(',', getAttribute($info_xml_element, 'metadata'))
-      );
-
+    $additional_metadata = getAttribute($info_xml_element, 'metadata');
+
+    if ($additional_metadata != '')
+    {
+      $this->metadata_attributes = array_merge(
+        $this->metadata_attributes,
+        explode(',', $additional_metadata)
+        );
+    }
+    
     $this->build_structure($xml_content, '', 0);
 
@@ -180,5 +185,5 @@
 
 // returns a hash of attributes (metadata+width,...) for file
-function get_element_metadata($file)
+function get_element_metadata($file, $has_high = false)
 {
   return $this->get_element_attributes(
Index: trunk/admin/site_update.php
===================================================================
--- trunk/admin/site_update.php	(revision 1882)
+++ trunk/admin/site_update.php	(revision 1883)
@@ -776,7 +776,38 @@
   $datas = array();
   $tags_of = array();
+
+  $has_high_images = array();
+
+  $image_ids = array();
+  foreach ($files as $id => $file)
+  {
+    array_push($image_ids, $id);
+  }
+
+  if (count($image_ids) > 0)
+  {
+    $query = '
+SELECT id
+  FROM '.IMAGES_TABLE.'
+  WHERE has_high = \'true\'
+    AND id IN (
+'.wordwrap(implode(', ', $image_ids), 80, "\n").'
+)
+;';
+
+    $result = pwg_query($query);
+    while ($row = mysql_fetch_array($result))
+    {
+      array_push($has_high_images, $row['id']);
+    }
+  }
+  
   foreach ( $files as $id=>$file )
   {
-    $data = $site_reader->get_element_metadata($file);
+    $data = $site_reader->get_element_metadata(
+      $file,
+      in_array($id, $has_high_images)
+      );
+    
     if ( is_array($data) )
     {
@@ -814,4 +845,6 @@
     if (count($datas) > 0)
     {
+      // echo '<pre>', print_r($datas); echo '</pre>';
+      
       mass_updates(
         IMAGES_TABLE,
Index: trunk/include/functions_xml.inc.php
===================================================================
--- trunk/include/functions_xml.inc.php	(revision 1882)
+++ trunk/include/functions_xml.inc.php	(revision 1883)
@@ -53,5 +53,5 @@
 {
 //  echo htmlentities($element).'<br /><br />';
-  $regex = '/^<\w+[^>]*'.$attribute.'\s*=\s*"('.VAL_REG.')"/i';
+  $regex = '/^<\w+[^>]*\b'.$attribute.'\s*=\s*"('.VAL_REG.')"/i';
   if ( preg_match( $regex, $element, $out ) ) 
   {
Index: trunk/install/db/55-database.php
===================================================================
--- trunk/install/db/55-database.php	(revision 1883)
+++ trunk/install/db/55-database.php	(revision 1883)
@@ -0,0 +1,63 @@
+<?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 |
+// +-----------------------------------------------------------------------+
+// | branch        : BSF (Best So Far)
+// | file          : $Id: 45-database.php 1741 2007-01-22 21:47:03Z vdigital $
+// | last update   : $Date: 2007-01-22 22:47:03 +0100 (lun., 22 janv. 2007) $
+// | last modifier : $Author: vdigital $
+// | revision      : $Revision: 1741 $
+// +-----------------------------------------------------------------------+
+// | 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.                                                                  |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+  die('Hacking attempt!');
+}
+
+$upgrade_description =
+  'Update #history.image_type to "picture" by default when image_id is not null';
+
+include_once(PHPWG_ROOT_PATH.'include/constants.php');
+
+// +-----------------------------------------------------------------------+
+// |                            Upgrade content                            |
+// +-----------------------------------------------------------------------+
+
+$query = "
+UPDATE ".HISTORY_TABLE."
+  SET image_type = 'picture'
+  WHERE image_id IS NOT NULL
+    AND image_type IS NULL
+;";
+pwg_query($query);
+
+$query = "
+UPDATE ".HISTORY_TABLE."
+  SET image_type = NULL
+  WHERE image_id IS NULL
+;";
+pwg_query($query);
+
+echo
+"\n"
+.'"'.$upgrade_description.'"'.', ended'
+."\n"
+;
+
+?>
Index: trunk/install/db/56-database.php
===================================================================
--- trunk/install/db/56-database.php	(revision 1883)
+++ trunk/install/db/56-database.php	(revision 1883)
@@ -0,0 +1,53 @@
+<?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 |
+// +-----------------------------------------------------------------------+
+// | branch        : BSF (Best So Far)
+// | file          : $Id: 45-database.php 1741 2007-01-22 21:47:03Z vdigital $
+// | last update   : $Date: 2007-01-22 22:47:03 +0100 (lun., 22 janv. 2007) $
+// | last modifier : $Author: vdigital $
+// | revision      : $Revision: 1741 $
+// +-----------------------------------------------------------------------+
+// | 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.                                                                  |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+  die('Hacking attempt!');
+}
+
+$upgrade_description = 'Add #images.high_filesize';
+
+include_once(PHPWG_ROOT_PATH.'include/constants.php');
+
+// +-----------------------------------------------------------------------+
+// |                            Upgrade content                            |
+// +-----------------------------------------------------------------------+
+
+$query = "
+ALTER TABLE ".IMAGES_TABLE."
+  ADD COLUMN high_filesize mediumint(9) unsigned default NULL
+;";
+pwg_query($query);
+
+echo
+"\n"
+.'"'.$upgrade_description.'"'.', ended'
+."\n"
+;
+
+?>
Index: trunk/install/phpwebgallery_structure.sql
===================================================================
--- trunk/install/phpwebgallery_structure.sql	(revision 1882)
+++ trunk/install/phpwebgallery_structure.sql	(revision 1883)
@@ -39,8 +39,8 @@
   `global_rank` varchar(255) default NULL,
   `image_order` varchar(128) default NULL,
-  `permalink` VARCHAR(64) default NULL,
-  PRIMARY KEY  (`id`),
-  KEY `categories_i2` (`id_uppercat`),
-  UNIQUE KEY `categories_i3` (`permalink`)
+  `permalink` varchar(64) default NULL,
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `categories_i3` (`permalink`),
+  KEY `categories_i2` (`id_uppercat`)
 ) TYPE=MyISAM;
 
@@ -197,4 +197,5 @@
   `path` varchar(255) NOT NULL default '',
   `storage_category_id` smallint(5) unsigned default NULL,
+  `high_filesize` mediumint(9) unsigned default NULL,
   PRIMARY KEY  (`id`),
   KEY `images_i2` (`date_available`),
@@ -211,10 +212,10 @@
 DROP TABLE IF EXISTS `phpwebgallery_old_permalinks`;
 CREATE TABLE `phpwebgallery_old_permalinks` (
-  `cat_id` smallint(5) unsigned NOT NULL,
-  `permalink` VARCHAR(64) NOT NULL,
-  `date_deleted` datetime NOT NULL,
+  `cat_id` smallint(5) unsigned NOT NULL default '0',
+  `permalink` varchar(64) NOT NULL default '',
+  `date_deleted` datetime NOT NULL default '0000-00-00 00:00:00',
   `last_hit` datetime default NULL,
   `hit` int(10) unsigned NOT NULL default '0',
-  PRIMARY KEY (`permalink`)
+  PRIMARY KEY  (`permalink`)
 ) TYPE=MyISAM;
 
Index: trunk/template/yoga/admin/history.tpl
===================================================================
--- trunk/template/yoga/admin/history.tpl	(revision 1882)
+++ trunk/template/yoga/admin/history.tpl	(revision 1883)
@@ -66,5 +66,13 @@
 </form>
 
-<h3>{L_DATE_TITLE}</h3>
+<!-- BEGIN summary -->
+<fieldset>
+  <legend>{lang:Summary}</legend>
+
+  <ul>
+    <li>{summary.FILESIZE}</li>
+  </ul>
+</fieldset>
+<!-- END summary -->
 
 <!-- BEGIN navigation -->
Index: trunk/template/yoga/admin/picture_modify.tpl
===================================================================
--- trunk/template/yoga/admin/picture_modify.tpl	(revision 1882)
+++ trunk/template/yoga/admin/picture_modify.tpl	(revision 1883)
@@ -37,4 +37,11 @@
         <td>{FILESIZE}</td>
       </tr>
+
+<!-- BEGIN high -->
+      <tr>
+        <td><strong>{lang:High filesize}</strong></td>
+        <td>{high.FILESIZE}</td>
+      </tr>
+<!-- END high -->
 
       <tr>
Index: trunk/tools/create_listing_file.php
===================================================================
--- trunk/tools/create_listing_file.php	(revision 1882)
+++ trunk/tools/create_listing_file.php	(revision 1883)
@@ -715,4 +715,7 @@
       {
         $element['has_high'] = 'true';
+        
+        $high_file = $file_dir.'/'.$conf['high'].'/'.$file_base;
+        $element['high_filesize'] = floor(filesize($high_file) / 1024);
       }
       
