Index: /trunk/include/functions.inc.php
===================================================================
--- /trunk/include/functions.inc.php	(revision 1112)
+++ /trunk/include/functions.inc.php	(revision 1113)
@@ -6,5 +6,5 @@
 // +-----------------------------------------------------------------------+
 // | branch        : BSF (Best So Far)
-// | file          : $RCSfile$
+// | file          : $Id$
 // | last update   : $Date$
 // | last modifier : $Author$
@@ -786,194 +786,4 @@
 
 /**
- * Prepends and appends a string at each value of the given array.
- *
- * @param array
- * @param string prefix to each array values
- * @param string suffix to each array values
- */
-function prepend_append_array_items($array, $prepend_str, $append_str)
-{
-  array_walk(
-    $array,
-    create_function('&$s', '$s = "'.$prepend_str.'".$s."'.$append_str.'";')
-    );
-
-  return $array;
-}
-
-/**
- * returns search rules stored into a serialized array in "search"
- * table. Each search rules set is numericaly identified.
- *
- * @param int search_id
- * @return array
- */
-function get_search_array($search_id)
-{
-  if (!is_numeric($search_id))
-  {
-    die('Search id must be an integer');
-  }
-
-  $query = '
-SELECT rules
-  FROM '.SEARCH_TABLE.'
-  WHERE id = '.$search_id.'
-;';
-  list($serialized_rules) = mysql_fetch_row(pwg_query($query));
-
-  return unserialize($serialized_rules);
-}
-
-/**
- * returns the SQL clause from a search identifier
- *
- * Search rules are stored in search table as a serialized array. This array
- * need to be transformed into an SQL clause to be used in queries.
- *
- * @param int search_id
- * @return string
- */
-function get_sql_search_clause($search_id)
-{
-  $search = get_search_array($search_id);
-
-  // SQL where clauses are stored in $clauses array during query
-  // construction
-  $clauses = array();
-
-  foreach (array('file','name','comment','keywords','author') as $textfield)
-  {
-    if (isset($search['fields'][$textfield]))
-    {
-      $local_clauses = array();
-      foreach ($search['fields'][$textfield]['words'] as $word)
-      {
-        array_push($local_clauses, $textfield." LIKE '%".$word."%'");
-      }
-
-      // adds brackets around where clauses
-      $local_clauses = prepend_append_array_items($local_clauses, '(', ')');
-
-      array_push(
-        $clauses,
-        implode(
-          ' '.$search['fields'][$textfield]['mode'].' ',
-          $local_clauses
-          )
-        );
-    }
-  }
-
-  if (isset($search['fields']['allwords']))
-  {
-    $fields = array('file', 'name', 'comment', 'keywords', 'author');
-    // in the OR mode, request bust be :
-    // ((field1 LIKE '%word1%' OR field2 LIKE '%word1%')
-    // OR (field1 LIKE '%word2%' OR field2 LIKE '%word2%'))
-    //
-    // in the AND mode :
-    // ((field1 LIKE '%word1%' OR field2 LIKE '%word1%')
-    // AND (field1 LIKE '%word2%' OR field2 LIKE '%word2%'))
-    $word_clauses = array();
-    foreach ($search['fields']['allwords']['words'] as $word)
-    {
-      $field_clauses = array();
-      foreach ($fields as $field)
-      {
-        array_push($field_clauses, $field." LIKE '%".$word."%'");
-      }
-      // adds brackets around where clauses
-      array_push(
-        $word_clauses,
-        implode(
-          "\n          OR ",
-          $field_clauses
-          )
-        );
-    }
-
-    array_walk(
-      $word_clauses,
-      create_function('&$s','$s="(".$s.")";')
-      );
-
-    array_push(
-      $clauses,
-      "\n         ".
-      implode(
-        "\n         ".
-              $search['fields']['allwords']['mode'].
-        "\n         ",
-        $word_clauses
-        )
-      );
-  }
-
-  foreach (array('date_available', 'date_creation') as $datefield)
-  {
-    if (isset($search['fields'][$datefield]))
-    {
-      array_push(
-        $clauses,
-        $datefield." = '".$search['fields'][$datefield]['date']."'"
-        );
-    }
-
-    foreach (array('after','before') as $suffix)
-    {
-      $key = $datefield.'-'.$suffix;
-
-      if (isset($search['fields'][$key]))
-      {
-        array_push(
-          $clauses,
-
-          $datefield.
-          ($suffix == 'after'             ? ' >' : ' <').
-          ($search['fields'][$key]['inc'] ? '='  : '').
-          " '".$search['fields'][$key]['date']."'"
-
-          );
-      }
-    }
-  }
-
-  if (isset($search['fields']['cat']))
-  {
-    if ($search['fields']['cat']['sub_inc'])
-    {
-      // searching all the categories id of sub-categories
-      $cat_ids = get_subcat_ids($search['fields']['cat']['words']);
-    }
-    else
-    {
-      $cat_ids = $search['fields']['cat']['words'];
-    }
-
-    $local_clause = 'category_id IN ('.implode(',', $cat_ids).')';
-    array_push($clauses, $local_clause);
-  }
-
-  // adds brackets around where clauses
-  $clauses = prepend_append_array_items($clauses, '(', ')');
-
-  $where_separator =
-    implode(
-      "\n    ".$search['mode'].' ',
-      $clauses
-      );
-
-  $search_clause = $where_separator;
-
-  if (isset($forbidden))
-  {
-    $search_clause.= "\n    AND ".$forbidden;
-  }
-
-  return $search_clause;
-}
-
-/**
  * Returns webmaster mail address depending on $conf['webmaster_id']
  *
Index: /trunk/include/functions_category.inc.php
===================================================================
--- /trunk/include/functions_category.inc.php	(revision 1112)
+++ /trunk/include/functions_category.inc.php	(revision 1113)
@@ -6,5 +6,5 @@
 // +-----------------------------------------------------------------------+
 // | branch        : BSF (Best So Far)
-// | file          : $RCSfile$
+// | file          : $Id$
 // | last update   : $Date$
 // | last modifier : $Author$
@@ -43,20 +43,9 @@
 function check_restrictions($category_id)
 {
-  global $user, $lang;
+  global $user;
 
   if (in_array($category_id, explode(',', $user['forbidden_categories'])))
   {
-    $login_url =
-      get_root_url().'identification.php?redirect='
-      .urlencode(urlencode($_SERVER['REQUEST_URI']));
-
-    if (!$user['is_the_guest'])
-    {
-      die('Fatal: you are trying to reach a forbidden category');
-    }
-    else
-    {
-      redirect($login_url);
-    }
+    access_denied();
   }
 }
Index: /trunk/include/functions_html.inc.php
===================================================================
--- /trunk/include/functions_html.inc.php	(revision 1112)
+++ /trunk/include/functions_html.inc.php	(revision 1113)
@@ -6,5 +6,5 @@
 // +-----------------------------------------------------------------------+
 // | branch        : BSF (Best So Far)
-// | file          : $RCSfile$
+// | file          : $Id$
 // | last update   : $Date$
 // | last modifier : $Author$
@@ -494,3 +494,29 @@
   return get_cat_display_name($cat_info['name'], $url, $replace_space);
 }
+
+/**
+ * exits the current script (either exit or redirect)
+ */
+function access_denied()
+{
+  global $user, $lang;
+
+  $login_url =
+      get_root_url().'identification.php?redirect='
+      .urlencode(urlencode($_SERVER['REQUEST_URI']));
+
+  if ( isset($user['is_the_guest']) and !$user['is_the_guest'] )
+  {
+    echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />';
+    echo '<a href="'.get_root_url().'identification.php">'.$lang['identification'].'</a>&nbsp;';
+    echo '<a href="'.make_index_url().'">'.$lang['home'].'</a></div>';
+    exit();
+  }
+  else
+  {
+    header('HTTP/1.1 401 Authorization required');
+    header('Status: 401 Authorization required');
+    redirect($login_url);
+  }
+}
 ?>
Index: /trunk/include/functions_metadata.inc.php
===================================================================
--- /trunk/include/functions_metadata.inc.php	(revision 1112)
+++ /trunk/include/functions_metadata.inc.php	(revision 1113)
@@ -6,5 +6,5 @@
 // +-----------------------------------------------------------------------+
 // | branch        : BSF (Best So Far)
-// | file          : $RCSfile$
+// | file          : $Id$
 // | last update   : $Date$
 // | last modifier : $Author$
@@ -36,11 +36,11 @@
 {
   $result = array();
-  
+
   // Read IPTC data
   $iptc = array();
-  
+
   $imginfo = array();
   getimagesize($filename, $imginfo);
-  
+
   if (isset($imginfo['APP13']))
   {
@@ -83,5 +83,5 @@
 {
   // strip leading zeros (weird Kodak Scanner software)
-  while ($value[0] == chr(0))
+  while ( isset($value[0]) and $value[0] == chr(0))
   {
     $value = substr($value, 1);
@@ -89,5 +89,5 @@
   // remove binary nulls
   $value = str_replace(chr(0x00), ' ', $value);
-  
+
   return $value;
 }
@@ -108,5 +108,5 @@
     die('Exif extension not available, admin should disable exif use');
   }
-  
+
   // Read EXIF data
   if ($exif = @read_exif_data($filename))
Index: /trunk/include/functions_search.inc.php
===================================================================
--- /trunk/include/functions_search.inc.php	(revision 1113)
+++ /trunk/include/functions_search.inc.php	(revision 1113)
@@ -0,0 +1,219 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch        : BSF (Best So Far)
+// | file          : $Id$
+// | last update   : $Date$
+// | last modifier : $Author$
+// | revision      : $Revision$
+// +-----------------------------------------------------------------------+
+// | 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.                                                                  |
+// +-----------------------------------------------------------------------+
+
+
+/**
+ * Prepends and appends a string at each value of the given array.
+ *
+ * @param array
+ * @param string prefix to each array values
+ * @param string suffix to each array values
+ */
+function prepend_append_array_items($array, $prepend_str, $append_str)
+{
+  array_walk(
+    $array,
+    create_function('&$s', '$s = "'.$prepend_str.'".$s."'.$append_str.'";')
+    );
+
+  return $array;
+}
+
+/**
+ * returns search rules stored into a serialized array in "search"
+ * table. Each search rules set is numericaly identified.
+ *
+ * @param int search_id
+ * @return array
+ */
+function get_search_array($search_id)
+{
+  if (!is_numeric($search_id))
+  {
+    die('Search id must be an integer');
+  }
+
+  $query = '
+SELECT rules
+  FROM '.SEARCH_TABLE.'
+  WHERE id = '.$search_id.'
+;';
+  list($serialized_rules) = mysql_fetch_row(pwg_query($query));
+
+  return unserialize($serialized_rules);
+}
+
+/**
+ * returns the SQL clause from a search identifier
+ *
+ * Search rules are stored in search table as a serialized array. This array
+ * need to be transformed into an SQL clause to be used in queries.
+ *
+ * @param int search_id
+ * @return string
+ */
+function get_sql_search_clause($search_id)
+{
+  $search = get_search_array($search_id);
+
+  // SQL where clauses are stored in $clauses array during query
+  // construction
+  $clauses = array();
+
+  foreach (array('file','name','comment','keywords','author') as $textfield)
+  {
+    if (isset($search['fields'][$textfield]))
+    {
+      $local_clauses = array();
+      foreach ($search['fields'][$textfield]['words'] as $word)
+      {
+        array_push($local_clauses, $textfield." LIKE '%".$word."%'");
+      }
+
+      // adds brackets around where clauses
+      $local_clauses = prepend_append_array_items($local_clauses, '(', ')');
+
+      array_push(
+        $clauses,
+        implode(
+          ' '.$search['fields'][$textfield]['mode'].' ',
+          $local_clauses
+          )
+        );
+    }
+  }
+
+  if (isset($search['fields']['allwords']))
+  {
+    $fields = array('file', 'name', 'comment', 'keywords', 'author');
+    // in the OR mode, request bust be :
+    // ((field1 LIKE '%word1%' OR field2 LIKE '%word1%')
+    // OR (field1 LIKE '%word2%' OR field2 LIKE '%word2%'))
+    //
+    // in the AND mode :
+    // ((field1 LIKE '%word1%' OR field2 LIKE '%word1%')
+    // AND (field1 LIKE '%word2%' OR field2 LIKE '%word2%'))
+    $word_clauses = array();
+    foreach ($search['fields']['allwords']['words'] as $word)
+    {
+      $field_clauses = array();
+      foreach ($fields as $field)
+      {
+        array_push($field_clauses, $field." LIKE '%".$word."%'");
+      }
+      // adds brackets around where clauses
+      array_push(
+        $word_clauses,
+        implode(
+          "\n          OR ",
+          $field_clauses
+          )
+        );
+    }
+
+    array_walk(
+      $word_clauses,
+      create_function('&$s','$s="(".$s.")";')
+      );
+
+    array_push(
+      $clauses,
+      "\n         ".
+      implode(
+        "\n         ".
+              $search['fields']['allwords']['mode'].
+        "\n         ",
+        $word_clauses
+        )
+      );
+  }
+
+  foreach (array('date_available', 'date_creation') as $datefield)
+  {
+    if (isset($search['fields'][$datefield]))
+    {
+      array_push(
+        $clauses,
+        $datefield." = '".$search['fields'][$datefield]['date']."'"
+        );
+    }
+
+    foreach (array('after','before') as $suffix)
+    {
+      $key = $datefield.'-'.$suffix;
+
+      if (isset($search['fields'][$key]))
+      {
+        array_push(
+          $clauses,
+
+          $datefield.
+          ($suffix == 'after'             ? ' >' : ' <').
+          ($search['fields'][$key]['inc'] ? '='  : '').
+          " '".$search['fields'][$key]['date']."'"
+
+          );
+      }
+    }
+  }
+
+  if (isset($search['fields']['cat']))
+  {
+    if ($search['fields']['cat']['sub_inc'])
+    {
+      // searching all the categories id of sub-categories
+      $cat_ids = get_subcat_ids($search['fields']['cat']['words']);
+    }
+    else
+    {
+      $cat_ids = $search['fields']['cat']['words'];
+    }
+
+    $local_clause = 'category_id IN ('.implode(',', $cat_ids).')';
+    array_push($clauses, $local_clause);
+  }
+
+  // adds brackets around where clauses
+  $clauses = prepend_append_array_items($clauses, '(', ')');
+
+  $where_separator =
+    implode(
+      "\n    ".$search['mode'].' ',
+      $clauses
+      );
+
+  $search_clause = $where_separator;
+
+  if (isset($forbidden))
+  {
+    $search_clause.= "\n    AND ".$forbidden;
+  }
+
+  return $search_clause;
+}
+
+?>
Index: /trunk/include/functions_user.inc.php
===================================================================
--- /trunk/include/functions_user.inc.php	(revision 1112)
+++ /trunk/include/functions_user.inc.php	(revision 1113)
@@ -6,8 +6,7 @@
 // +-----------------------------------------------------------------------+
 // | branch        : BSF (Best So Far)
-// | file          : $RCSfile$
+// | file          : $Id$
 // | last update   : $Date$
 // | last modifier : $Author$
-// | revision      : $Revision$
 // | revision      : $Revision$
 // +-----------------------------------------------------------------------+
@@ -609,11 +608,7 @@
 function check_status($access_type, $user_status = '')
 {
-  global $lang;
-
   if (!is_autorize_status($access_type, $user_status))
   {
-    echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />';
-    echo '<a href="'.PHPWG_ROOT_PATH.'identification.php">'.$lang['identification'].'</a></div>';
-    exit();
+    access_denied();
   }
 }
Index: /trunk/include/section_init.inc.php
===================================================================
--- /trunk/include/section_init.inc.php	(revision 1112)
+++ /trunk/include/section_init.inc.php	(revision 1113)
@@ -6,5 +6,5 @@
 // +-----------------------------------------------------------------------+
 // | branch        : BSF (Best So Far)
-// | file          : $RCSfile$
+// | file          : $Id$
 // | last update   : $Date$
 // | last modifier : $Author$
@@ -343,4 +343,5 @@
   if ($page['section'] == 'search')
   {
+    include_once( PHPWG_ROOT_PATH .'include/functions_search.inc.php' );
     $query = '
 SELECT DISTINCT(id)
Index: /trunk/index.php
===================================================================
--- /trunk/index.php	(revision 1112)
+++ /trunk/index.php	(revision 1113)
@@ -55,5 +55,5 @@
     'pwg_image_order',
     $_GET['image_order'] > 0 ? $_GET['image_order'] : '',
-    0
+    0, cookie_path()
     );
 
Index: /trunk/language/fr_FR.iso-8859-1/common.lang.php
===================================================================
--- /trunk/language/fr_FR.iso-8859-1/common.lang.php	(revision 1112)
+++ /trunk/language/fr_FR.iso-8859-1/common.lang.php	(revision 1113)
@@ -246,5 +246,5 @@
 $lang['picture'] = 'image';
 $lang['picture_high'] = 'Cliquer sur l\'image pour la visualiser en haute définition';
-$lang['picture_show_metadata'] = 'Monter les méta-données du fichier';
+$lang['picture_show_metadata'] = 'Montrer les méta-données du fichier';
 $lang['powered_by'] = 'Propulsé par';
 $lang['preferences'] = 'Préférences';
Index: /trunk/search_rules.php
===================================================================
--- /trunk/search_rules.php	(revision 1112)
+++ /trunk/search_rules.php	(revision 1113)
@@ -6,8 +6,8 @@
 // +-----------------------------------------------------------------------+
 // | branch        : BSF (Best So Far)
-// | file          : $RCSfile$
-// | last update   : $Date: 2005-09-27 23:57:14 +0200 (mar, 27 sep 2005) $
-// | last modifier : $Author: plg $
-// | revision      : $Revision: 879 $
+// | file          : $Id$
+// | last update   : $Date$
+// | last modifier : $Author$
+// | revision      : $Revision$
 // +-----------------------------------------------------------------------+
 // | This program is free software; you can redistribute it and/or modify  |
@@ -44,4 +44,5 @@
 define('PHPWG_ROOT_PATH','./');
 include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
+include_once( PHPWG_ROOT_PATH.'include/functions_search.inc.php' );
 
 $page['body_id'] = 'thePopuphelpPage';
