Index: /trunk/admin/include/functions_metadata.php
===================================================================
--- /trunk/admin/include/functions_metadata.php	(revision 2520)
+++ /trunk/admin/include/functions_metadata.php	(revision 2521)
@@ -29,7 +29,7 @@
 {
   global $conf, $page;
-  
+
   $map = $conf['use_iptc_mapping'];
-  
+
   $iptc = get_iptc_data($file, $map);
 
@@ -109,5 +109,5 @@
     array_push($image_ids, $id);
   }
-  
+
   $query = '
 SELECT id
@@ -119,9 +119,5 @@
 ;';
 
-  $result = pwg_query($query);
-  while ($row = mysql_fetch_array($result))
-  {
-    array_push($has_high_images, $row['id']);
-  }
+  $has_high_images = array_from_query($query, 'id');
 
   foreach ($files as $id => $file)
@@ -130,5 +126,5 @@
     $data['id'] = $id;
     $data['filesize'] = floor(filesize($file)/1024);
-  
+
     if ($image_size = @getimagesize($file))
     {
@@ -143,5 +139,5 @@
       $data['high_filesize'] = floor(filesize($high_file)/1024);
     }
-  
+
     if ($conf['use_exif'])
     {
@@ -162,5 +158,5 @@
               $tags_of[$id] = array();
             }
-            
+
             foreach (explode(',', $iptc[$key]) as $tag_name)
             {
@@ -179,5 +175,5 @@
     array_push($datas, $data);
   }
-  
+
   if (count($datas) > 0)
   {
@@ -190,5 +186,5 @@
         'date_metadata_update'
         );
-    
+
     if ($conf['use_exif'])
     {
@@ -199,5 +195,5 @@
           );
     }
-    
+
     if ($conf['use_iptc'])
     {
@@ -218,5 +214,6 @@
         'update'  => array_unique($update_fields)
         ),
-      $datas
+      $datas,
+      MASS_UPDATES_SKIP_EMPTY
       );
   }
@@ -235,10 +232,10 @@
  * @return array
  */
-function get_filelist($category_id = '', $site_id=1, $recursive = false, 
+function get_filelist($category_id = '', $site_id=1, $recursive = false,
                       $only_new = false)
 {
   // filling $cat_ids : all categories required
   $cat_ids = array();
-  
+
   $query = '
 SELECT id
@@ -293,5 +290,5 @@
     $files[$row['id']] = $row['path'];
   }
-  
+
   return $files;
 }
Index: /trunk/admin/template/yoga/default-layout.css
===================================================================
--- /trunk/admin/template/yoga/default-layout.css	(revision 2520)
+++ /trunk/admin/template/yoga/default-layout.css	(revision 2521)
@@ -291,5 +291,5 @@
   font-size: 1em;	/* <= some browsers don't set it correctly */
 }
-UL, DL { text-align: left;}
+UL, DL, OL { text-align: left;}
 TABLE {			/* horizontaly centered */
   margin-left: auto;
Index: /trunk/admin/template/yoga/layout.css
===================================================================
--- /trunk/admin/template/yoga/layout.css	(revision 2520)
+++ /trunk/admin/template/yoga/layout.css	(revision 2521)
@@ -1,6 +1,5 @@
-/* $Id$ */
 
 /* template css */
-@import "menubar.css";
+/*@import "menubar.css";*/
 @import "content.css";
 @import "thumbnails.css";
Index: /trunk/admin/template/yoga/theme/admin/theme.css
===================================================================
--- /trunk/admin/template/yoga/theme/admin/theme.css	(revision 2520)
+++ /trunk/admin/template/yoga/theme/admin/theme.css	(revision 2521)
@@ -45,9 +45,7 @@
 .content dl, dd { margin:5px; }
 .content div.titrePage { height:55px; }
-.content ol li { text-align: left; }
 .instructions { text-align: left; padding: 20px 20px 0 20px; }
 .throw, td h3 {
  background-image: url(images/fillet.png); background-repeat: repeat-x; }
-.browsePath a { color: #eee; }
 /* borders */ /* TODO */
 INPUT, SELECT, TEXTAREA { border-left: 2px inset #696969; 
Index: /trunk/include/functions.inc.php
===================================================================
--- /trunk/include/functions.inc.php	(revision 2520)
+++ /trunk/include/functions.inc.php	(revision 2521)
@@ -748,11 +748,6 @@
   if (empty($msg))
   {
-    $redirect_msg = l10n('redirect_msg');
-  }
-  else
-  {
-    $redirect_msg = $msg;
-  }
-  $redirect_msg = nl2br($redirect_msg);
+    $msg = nl2br(l10n('redirect_msg'));
+  }
 
   $refresh = $refresh_time;
@@ -765,4 +760,6 @@
 
   $template->set_filenames( array( 'redirect' => 'redirect.tpl' ) );
+  $template->assign('REDIRECT_MSG', $msg);
+
   $template->parse('redirect');
 
Index: /trunk/include/functions_category.inc.php
===================================================================
--- /trunk/include/functions_category.inc.php	(revision 2520)
+++ /trunk/include/functions_category.inc.php	(revision 2521)
@@ -259,6 +259,7 @@
 {
   global $conf, $page;
-  
-  return array(
+
+  return trigger_event('get_category_preferred_image_orders',
+    array(
     array(l10n('default_sort'), '', true),
     array(l10n('Average rate'), 'average_rate DESC', $conf['rate']),
@@ -270,7 +271,7 @@
       l10n('Rank'),
       'rank ASC',
-      ('categories' == $page['section'] and !isset($page['flat']))
+      ('categories' == @$page['section'] and !isset($page['flat']))
       )
-    );
+    ));
 }
 
Index: /trunk/include/functions_search.inc.php
===================================================================
--- /trunk/include/functions_search.inc.php	(revision 2520)
+++ /trunk/include/functions_search.inc.php	(revision 2521)
@@ -353,4 +353,8 @@
         else
         {
+          if ( strcspn($ch, '%_')==0)
+          {// escape LIKE specials %_
+            $ch = '\\'.$ch;
+          }
           $crt_token .= $ch;
         }
@@ -367,4 +371,8 @@
             break;
           default:
+            if ( strcspn($ch, '%_')==0)
+            {// escape LIKE specials %_
+            	$ch = '\\'.$ch;
+            }
             $crt_token .= $ch;
         }
Index: /trunk/include/functions_session.inc.php
===================================================================
--- /trunk/include/functions_session.inc.php	(revision 2520)
+++ /trunk/include/functions_session.inc.php	(revision 2521)
@@ -91,4 +91,9 @@
 }
 
+function get_remote_addr_session_hash()
+{
+	return vsprintf( "%02X%02X", explode('.',$_SERVER['REMOTE_ADDR']) );
+}
+
 /**
  * this function returns
@@ -103,5 +108,5 @@
 SELECT data
   FROM '.SESSIONS_TABLE.'
-  WHERE id = \''.$session_id.'\'
+  WHERE id = \''.get_remote_addr_session_hash().$session_id.'\'
 ;';
   $result = pwg_query($query);
@@ -129,5 +134,5 @@
   SET expiration = now(),
   data = \''.$data.'\'
-  WHERE id = \''.$session_id.'\'
+  WHERE id = \''.get_remote_addr_session_hash().$session_id.'\'
 ;';
   pwg_query($query);
@@ -139,5 +144,5 @@
 INSERT INTO '.SESSIONS_TABLE.'
   (id,data,expiration)
-  VALUES(\''.$session_id.'\',\''.$data.'\',now())
+  VALUES(\''.get_remote_addr_session_hash().$session_id.'\',\''.$data.'\',now())
 ;';
   mysql_query($query);
@@ -155,5 +160,5 @@
 DELETE
   FROM '.SESSIONS_TABLE.'
-  WHERE id = \''.$session_id.'\'
+  WHERE id = \''.get_remote_addr_session_hash().$session_id.'\'
 ;';
   pwg_query($query);
Index: /trunk/include/page_header.php
===================================================================
--- /trunk/include/page_header.php	(revision 2520)
+++ /trunk/include/page_header.php	(revision 2521)
@@ -70,9 +70,8 @@
 // refresh
 if ( isset( $refresh ) and intval($refresh) >= 0
-    and isset( $url_link ) and isset( $redirect_msg ) )
+    and isset( $url_link ) )
 {
   $template->assign(
     array(
-      'REDIRECT_MSG' => $redirect_msg,
       'page_refresh' => array(
             'TIME' => $refresh,
Index: /trunk/include/template.class.php
===================================================================
--- /trunk/include/template.class.php	(revision 2520)
+++ /trunk/include/template.class.php	(revision 2521)
@@ -63,5 +63,5 @@
     $this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') );
     $this->smarty->register_block('html_head', array(&$this, 'block_html_head') );
-    $this->smarty->register_function('known_script', array(&$this, 'func_known_script'), false );
+    $this->smarty->register_function('known_script', array(&$this, 'func_known_script') );
     $this->smarty->register_prefilter( array('Template', 'prefilter_white_space') );
     if ( $conf['compiled_template_cache_language'] )
Index: /trunk/include/ws_core.inc.php
===================================================================
--- /trunk/include/ws_core.inc.php	(revision 2520)
+++ /trunk/include/ws_core.inc.php	(revision 2521)
@@ -379,10 +379,8 @@
     if ( is_null($this->_responseEncoder) )
     {
-      set_status_header(500);
+      set_status_header(400);
       @header("Content-Type: text/plain");
       echo ("Cannot process your request. Unknown response format.
-Request format: ".@$this->_requestFormat." handler:".$this->_requestHandler."
-Response format: ".@$this->_responseFormat." encoder:".$this->_responseEncoder."
-    ");
+Request format: ".@$this->_requestFormat." Response format: ".@$this->_responseFormat."\n");
       var_export($this);
       die(0);
@@ -392,5 +390,5 @@
     {
       $this->sendResponse(
-        new PwgError(500, 'Unknown request format')
+        new PwgError(400, 'Unknown request format')
         );
       return;
Index: /trunk/include/ws_protocols/rest_handler.php
===================================================================
--- /trunk/include/ws_protocols/rest_handler.php	(revision 2520)
+++ /trunk/include/ws_protocols/rest_handler.php	(revision 2521)
@@ -31,5 +31,5 @@
     foreach ($param_array as $name => $value)
     {
-      if ($name=='format' or $name=='partner')
+      if ($name=='format')
         continue; // ignore - special keys
       if ($name=='method')
@@ -46,5 +46,5 @@
     {
       $service->sendResponse(
-          new PwgError(400, 'Missing "method" name')
+          new PwgError(WS_ERR_INVALID_METHOD, 'Missing "method" name')
         );
       return;
Index: /trunk/install/db/77-database.php
===================================================================
--- /trunk/install/db/77-database.php	(revision 2521)
+++ /trunk/install/db/77-database.php	(revision 2521)
@@ -0,0 +1,54 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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 = 'images.file categories.permalink old_permalinks.permalink - become binary';
+
+// +-----------------------------------------------------------------------+
+// |                            Upgrade content                            |
+// +-----------------------------------------------------------------------+
+
+$query = 'ALTER TABLE '.CATEGORIES_TABLE.'
+  MODIFY COLUMN permalink varchar(64) binary default NULL';
+pwg_query($query);
+
+$query = 'ALTER TABLE '.OLD_PERMALINKS_TABLE.'
+  MODIFY COLUMN permalink varchar(64) binary NOT NULL default ""';
+pwg_query($query);
+
+$query = 'ALTER TABLE '.IMAGES_TABLE.'
+  MODIFY COLUMN file varchar(255) binary NOT NULL default ""';
+pwg_query($query);
+
+
+echo
+"\n"
+.'"'.$upgrade_description.'"'.' ended'
+."\n"
+;
+
+?>
Index: /trunk/install/piwigo_structure.sql
===================================================================
--- /trunk/install/piwigo_structure.sql	(revision 2520)
+++ /trunk/install/piwigo_structure.sql	(revision 2521)
@@ -37,5 +37,5 @@
   `global_rank` varchar(255) default NULL,
   `image_order` varchar(128) default NULL,
-  `permalink` varchar(64) default NULL,
+  `permalink` varchar(64) binary default NULL,
   PRIMARY KEY  (`id`),
   UNIQUE KEY `categories_i3` (`permalink`),
@@ -175,5 +175,5 @@
 CREATE TABLE `piwigo_images` (
   `id` mediumint(8) unsigned NOT NULL auto_increment,
-  `file` varchar(255) NOT NULL default '',
+  `file` varchar(255) binary NOT NULL default '',
   `date_available` datetime NOT NULL default '0000-00-00 00:00:00',
   `date_creation` date default NULL,
@@ -209,5 +209,5 @@
 CREATE TABLE `piwigo_old_permalinks` (
   `cat_id` smallint(5) unsigned NOT NULL default '0',
-  `permalink` varchar(64) NOT NULL default '',
+  `permalink` varchar(64) binary NOT NULL default '',
   `date_deleted` datetime NOT NULL default '0000-00-00 00:00:00',
   `last_hit` datetime default NULL,
Index: /trunk/picture.php
===================================================================
--- /trunk/picture.php	(revision 2520)
+++ /trunk/picture.php	(revision 2521)
@@ -537,5 +537,5 @@
     if (!empty($id_pict_redirect))
     {
-      // $redirect_msg, $refresh, $url_link and $title are required for creating
+      // $refresh, $url_link and $title are required for creating
       // an automated refresh page in header.tpl
       $refresh = $slideshow_params['period'];
@@ -544,5 +544,4 @@
           $slideshow_url_params
         );
-      $redirect_msg = nl2br(l10n('redirect_msg'));
     }
   }
Index: /trunk/template/yoga/menubar_menu.tpl
===================================================================
--- /trunk/template/yoga/menubar_menu.tpl	(revision 2520)
+++ /trunk/template/yoga/menubar_menu.tpl	(revision 2521)
@@ -1,5 +1,5 @@
-<dt>{$block->get_title()|@translate}</dt>
+<dt>{'title_menu'|@translate}</dt>
 <dd>
-	<form action="{$ROOT_URL}qsearch.php" method="get" id="quicksearch">
+	<form action="{$ROOT_URL}qsearch.php" method="get" id="quicksearch" onsubmit="return this.q.value!='' && this.q.value!=qsearch_prompt;">
 		<p style="margin:0;padding:0"{*this <p> is for html validation only - does not affect positioning*}>
 			<input type="text" name="q" id="qsearchInput" onfocus="if (value==qsearch_prompt) value='';" onblur="if (value=='') value=qsearch_prompt;" style="width:90%"/>
Index: /trunk/template/yoga/redirect.tpl
===================================================================
--- /trunk/template/yoga/redirect.tpl	(revision 2520)
+++ /trunk/template/yoga/redirect.tpl	(revision 2521)
@@ -1,5 +1,12 @@
 {* $Id$ *}
-<h2>{$REDIRECT_MSG}</h2>
-<p style="text-align:center; margin: 2em">
+{html_head}
+<style type="text/css">#the_page {ldelim}text-align:center;} </style>
+{/html_head}
+
+<div>
+	{$REDIRECT_MSG}
+</div>
+
+<p style="margin: 2em">
 	<a href="{$page_refresh.U_REFRESH}">
 		{'click_to_redirect'|@translate}
