Index: /trunk/include/common.inc.php
===================================================================
--- /trunk/include/common.inc.php	(revision 2769)
+++ /trunk/include/common.inc.php	(revision 2770)
@@ -37,62 +37,19 @@
 if( !get_magic_quotes_gpc() )
 {
+  function sanitize_mysql_kv(&$v, $k)
+  {
+    $v = addslashes($v);
+  }
   if( is_array( $_GET ) )
   {
-    while( list($k, $v) = each($_GET) )
-    {
-      if( is_array($_GET[$k]) )
-      {
-        while( list($k2, $v2) = each($_GET[$k]) )
-        {
-          $_GET[$k][$k2] = addslashes($v2);
-        }
-        @reset($_GET[$k]);
-      }
-      else
-      {
-        $_GET[$k] = addslashes($v);
-      }
-    }
-    @reset($_GET);
-  }
-
-  if( is_array($_POST) )
-  {
-    while( list($k, $v) = each($_POST) )
-    {
-      if( is_array($_POST[$k]) )
-      {
-        while( list($k2, $v2) = each($_POST[$k]) )
-        {
-          $_POST[$k][$k2] = addslashes($v2);
-        }
-        @reset($_POST[$k]);
-      }
-      else
-      {
-        $_POST[$k] = addslashes($v);
-      }
-    }
-    @reset($_POST);
-  }
-
-  if( is_array($_COOKIE) )
-  {
-    while( list($k, $v) = each($_COOKIE) )
-    {
-      if( is_array($_COOKIE[$k]) )
-      {
-        while( list($k2, $v2) = each($_COOKIE[$k]) )
-        {
-          $_COOKIE[$k][$k2] = addslashes($v2);
-        }
-        @reset($_COOKIE[$k]);
-      }
-      else
-      {
-        $_COOKIE[$k] = addslashes($v);
-      }
-    }
-    @reset($_COOKIE);
+    array_walk_recursive( $_GET, 'sanitize_mysql_kv' );
+  }
+  if( is_array( $_POST ) )
+  {
+    array_walk_recursive( $_POST, 'sanitize_mysql_kv' );
+  }
+  if( is_array( $_COOKIE ) )
+  {
+    array_walk_recursive( $_COOKIE, 'sanitize_mysql_kv' );
   }
 }
Index: /trunk/include/functions_category.inc.php
===================================================================
--- /trunk/include/functions_category.inc.php	(revision 2769)
+++ /trunk/include/functions_category.inc.php	(revision 2770)
@@ -274,5 +274,6 @@
       'rank ASC',
       ('categories' == @$page['section'] and !isset($page['flat']) and !isset($page['chronology_field']) )
-      )
+      ),
+    array( l10n('permissions'), 'level DESC', is_admin() )
     ));
 }
Index: /trunk/include/ws_functions.inc.php
===================================================================
--- /trunk/include/ws_functions.inc.php	(revision 2769)
+++ /trunk/include/ws_functions.inc.php	(revision 2770)
@@ -188,4 +188,5 @@
     return new PwgError(401, 'Access denied');
   }
+  $params['image_id'] = array_map( 'intval',$params['image_id'] );
   if ( empty($params['image_id']) )
   {
@@ -292,5 +293,5 @@
 GROUP BY i.id
 '.$order_by.'
-LIMIT '.$params['per_page']*$params['page'].','.$params['per_page'];
+LIMIT '.(int)($params['per_page']*$params['page']).','.(int)$params['per_page'];
 
     $result = pwg_query($query);
@@ -684,6 +685,6 @@
   WHERE '.$where_comments.'
   ORDER BY date
-  LIMIT '.$params['comments_per_page']*(int)$params['comments_page'].
-    ','.$params['comments_per_page'];
+  LIMIT '.(int)($params['comments_per_page']*$params['comments_page']).
+    ','.(int)$params['comments_per_page'];
 
     $result = pwg_query($query);
@@ -858,4 +859,5 @@
     return new PwgError(401, 'Access denied');
   }
+  $params['image_id'] = array_map( 'intval',$params['image_id'] );
   if ( empty($params['image_id']) )
   {
@@ -1343,5 +1345,5 @@
     AND ', $where_clauses).'
 '.$order_by.'
-LIMIT '.$params['per_page']*$params['page'].','.$params['per_page'];
+LIMIT '.(int)($params['per_page']*$params['page']).','.(int)$params['per_page'];
 
     $result = pwg_query($query);
Index: /trunk/index.php
===================================================================
--- /trunk/index.php	(revision 2769)
+++ /trunk/index.php	(revision 2770)
@@ -198,5 +198,5 @@
     foreach ( $cats as $cat )
     {
-      $hints[] = get_cat_display_name( array($cat) );
+      $hints[] = get_cat_display_name( array($cat), '', false );
     }
     $template->assign( 'category_search_results', $hints);
Index: /trunk/template/yoga/index.tpl
===================================================================
--- /trunk/template/yoga/index.tpl	(revision 2769)
+++ /trunk/template/yoga/index.tpl	(revision 2770)
@@ -33,17 +33,17 @@
 
       {if isset($U_MODE_FLAT) }
-      <li><a href="{$U_MODE_FLAT}" title="{'mode_flat_hint'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/flat.png" class="button" alt="{'mode_flat_hint'|@translate}"></a></li>
+      <li><a href="{$U_MODE_FLAT}" title="{'mode_flat_hint'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/flat.png" class="button" alt="{'mode_flat_hint'|@translate}" /></a></li>
       {/if}
 
       {if isset($U_MODE_NORMAL) }
-      <li><a href="{$U_MODE_NORMAL}" title="{'mode_normal_hint'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/normal_mode.png" class="button" alt="{'mode_normal_hint'|@translate}"></a></li>
+      <li><a href="{$U_MODE_NORMAL}" title="{'mode_normal_hint'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/normal_mode.png" class="button" alt="{'mode_normal_hint'|@translate}" /></a></li>
       {/if}
 
       {if isset($U_MODE_POSTED) }
-      <li><a href="{$U_MODE_POSTED}" title="{'mode_posted_hint'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/calendar.png" class="button" alt="{'mode_posted_hint'|@translate}"></a></li>
+      <li><a href="{$U_MODE_POSTED}" title="{'mode_posted_hint'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/calendar.png" class="button" alt="{'mode_posted_hint'|@translate}" /></a></li>
       {/if}
       
       {if isset($U_MODE_CREATED) }
-      <li><a href="{$U_MODE_CREATED}" title="{'mode_created_hint'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/calendar_created.png" class="button" alt="{'mode_created_hint'|@translate}"></a></li>
+      <li><a href="{$U_MODE_CREATED}" title="{'mode_created_hint'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/calendar_created.png" class="button" alt="{'mode_created_hint'|@translate}" /></a></li>
       {/if}
       
@@ -72,5 +72,5 @@
 
 {if !empty($category_search_results) }
-<div style="font-size:16px;text-align:left;margin:10px">{'Category results for'|@translate} <strong>{$QUERY_SEARCH}</strong> :
+<div style="font-size:16px;margin:10px 16px">{'Category results for'|@translate} <strong>{$QUERY_SEARCH}</strong> :
   <em><strong>
   {foreach from=$category_search_results item=res name=res_loop}
@@ -83,5 +83,5 @@
 
 {if !empty($tag_search_results) }
-<div style="font-size:16px;text-align:left;margin:10px">{'Tag results for'|@translate} <strong>{$QUERY_SEARCH}</strong> :
+<div style="font-size:16px;margin:10px 16px">{'Tag results for'|@translate} <strong>{$QUERY_SEARCH}</strong> :
   <em><strong>
   {foreach from=$tag_search_results item=res name=res_loop}
