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;
