Index: /trunk/admin/admin.php
===================================================================
--- /trunk/admin/admin.php	(revision 20)
+++ /trunk/admin/admin.php	(revision 21)
@@ -26,35 +26,89 @@
 //--------------------------------------- validating page and creation of title
 $page_valide = false;
+$title = '';
 switch ( $_GET['page'] )
 {
  case 'user_add':
-   $titre = $lang['title_add'];           $page_valide = true; break;
+   $title = $lang['title_add'];           $page_valide = true; break;
  case 'user_list':
-   $titre = $lang['title_liste_users'];   $page_valide = true; break;
+   $title = $lang['title_liste_users'];   $page_valide = true; break;
  case 'user_modify':
-   $titre = $lang['title_modify'];        $page_valide = true; break;
+   $title = $lang['title_modify'];        $page_valide = true; break;
+ case 'user_perm':
+   if ( !is_numeric( $_GET['user_id'] ) ) $_GET['user_id'] = -1;
+   $query = 'SELECT status,username';
+   $query.= ' FROM '.PREFIX_TABLE.'users';
+   $query.= ' WHERE id = '.$_GET['user_id'];
+   $query.= ';';
+   $result = mysql_query( $query );
+   if ( mysql_num_rows( $result ) > 0 )
+   {
+     $row = mysql_fetch_array( $result );
+     $page['user_status']   = $row['status'];
+     if ( $row['username'] == 'guest' ) $row['username'] = $lang['guest'];
+     $page['user_username'] = $row['username'];
+     $page_valide = true;
+     $title = $lang['title_user_perm'].' "'.$page['user_username'].'"';
+   }
+   else
+   {
+     $page_valide = false;
+   }
+   break;
+ case 'group_list' :
+   $title = $lang['title_groups'];        $page_valide = true; break;
+ case 'group_perm' :
+   if ( !is_numeric( $_GET['group_id'] ) ) $_GET['group_id'] = -1;
+   $query = 'SELECT name';
+   $query.= ' FROM '.PREFIX_TABLE.'groups';
+   $query.= ' WHERE id = '.$_GET['group_id'];
+   $query.= ';';
+   $result = mysql_query( $query );
+   if ( mysql_num_rows( $result ) > 0 )
+   {
+     $row = mysql_fetch_array( $result );
+     $title = $lang['title_group_perm'].' "'.$row['name'].'"';
+     $page_valide = true;
+   }
+   else
+   {
+     $page_valide = false;
+   }
+   break;
  case 'historique':
-   $titre = $lang['title_history'];       $page_valide = true; break;
+   $title = $lang['title_history'];       $page_valide = true; break;
  case 'update':
-   $titre = $lang['title_update'];        $page_valide = true; break;
+   $title = $lang['title_update'];        $page_valide = true; break;
  case 'configuration':
-   $titre = $lang['title_configuration']; $page_valide = true; break;
+   $title = $lang['title_configuration']; $page_valide = true; break;
  case 'manuel':
-   $titre = $lang['title_instructions'];  $page_valide = true; break;
- case 'perm':
-   $titre = $lang['title_permissions'];   $page_valide = true; break;
- case 'cat':
-   $titre = $lang['title_categories'];    $page_valide = true; break;
- case 'edit_cat':
-   $titre = $lang['title_edit_cat'];      $page_valide = true; break;
+   $title = $lang['title_instructions'];  $page_valide = true; break;
+ case 'cat_perm':
+   $title = $lang['title_cat_perm'];
+   if ( isset( $_GET['cat_id'] ) )
+   {
+     check_cat_id( $_GET['cat_id'] );
+     if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
+     {
+       $result = get_cat_info( $page['cat'] );
+       $name = get_cat_display_name( $result['name'],' &gt; ', '' );
+       $title.= ' "'.$name.'"';
+     }
+   }
+   $page_valide = true;
+   break;
+ case 'cat_list':
+   $title = $lang['title_categories'];    $page_valide = true; break;
+ case 'cat_modify':
+   $title = $lang['title_edit_cat'];      $page_valide = true; break;
  case 'infos_images':
-   $titre = $lang['title_info_images'];   $page_valide = true; break;
+   $title = $lang['title_info_images'];   $page_valide = true; break;
  case 'waiting':
-   $titre = $lang['title_waiting'];       $page_valide = true; break;
+   $title = $lang['title_waiting'];       $page_valide = true; break;
  case 'thumbnail':
-   $titre = $lang['title_thumbnails'];
+   $title = $lang['title_thumbnails'];
    if ( isset( $_GET['dir'] ) )
    {
-     $titre.= ' '.$lang['title_thumbnails_2'].' <span style="color:#006699;">';
+     $title.= ' '.$lang['title_thumbnails_2'].' <span style="color:#006699;">';
      // $_GET['dir'] contient :
      // ../galleries/vieux_lyon ou
@@ -62,17 +116,18 @@
      // ../galleries/vieux_lyon/visite/truc ...
      $dir = explode( "/", $_GET['dir'] );
-     $titre.= $dir[2];
+     $title.= $dir[2];
      for ( $i = 3; $i < sizeof( $dir ) - 1; $i++ )
      {
-       $titre.= ' &gt; '.$dir[$i];
+       $title.= ' &gt; '.$dir[$i];
      }
-     $titre.= "</span>";
+     $title.= "</span>";
    }
    $page_valide = true;
    break;
  default:
-   $titre = $lang['title_default']; break;
-}
-$vtp->setGlobalVar( $handle, 'title', $titre );
+   $title = $lang['title_default']; break;
+}
+if ( $title == '' ) $title = $lang['title_default'];
+$vtp->setGlobalVar( $handle, 'title', $title );
 //--------------------------------------------------------------------- summary
 $link_start = './admin.php?page=';
@@ -88,5 +143,5 @@
 $vtp->setVar( $handle, 'summary.indent', '' );
 $vtp->setVar( $handle, 'summary.link',
-              add_session_id( $link_start.'liste_users' ) );
+              add_session_id( $link_start.'user_list' ) );
 $vtp->setVar( $handle, 'summary.name', $lang['menu_users'] );
 $vtp->closeSession( $handle, 'summary' );
@@ -105,8 +160,15 @@
 $vtp->setVar( $handle, 'summary.name', $lang['menu_add_user'] );
 $vtp->closeSession( $handle, 'summary' );
+// groups
+$vtp->addSession( $handle, 'summary' );
+$vtp->setVar( $handle, 'summary.indent', '' );
+$vtp->setVar( $handle, 'summary.link',
+              add_session_id( $link_start.'group_list' ) );
+$vtp->setVar( $handle, 'summary.name', $lang['menu_groups'] );
+$vtp->closeSession( $handle, 'summary' );
 // categories
 $vtp->addSession( $handle, 'summary' );
 $vtp->setVar( $handle, 'summary.indent', '' );
-$vtp->setVar( $handle, 'summary.link', add_session_id( $link_start.'cat' ) );
+$vtp->setVar( $handle, 'summary.link',add_session_id( $link_start.'cat_list'));
 $vtp->setVar( $handle, 'summary.name', $lang['menu_categories'] );
 $vtp->closeSession( $handle, 'summary' );
Index: unk/admin/cat.php
===================================================================
--- /trunk/admin/cat.php	(revision 20)
+++ 	(revision )
@@ -1,279 +1,0 @@
-<?php
-/***************************************************************************
- *                                  cat.php                                *
- *                            -------------------                          *
- *   application          : PhpWebGallery 1.3                              *
- *   website              : http://www.phpwebgallery.net                   *
- *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
- *                                                                         *
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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;                                         *
- *                                                                         *
- ***************************************************************************/
-include_once( './include/isadmin.inc.php' );
-//----------------------------------------------------- template initialization
-$sub = $vtp->Open( '../template/'.$user['template'].'/admin/cat.vtp' );
-// language
-$vtp->setGlobalVar( $sub, 'cat_edit',        $lang['cat_edit'] );
-$vtp->setGlobalVar( $sub, 'cat_up',          $lang['cat_up'] );
-$vtp->setGlobalVar( $sub, 'cat_down',        $lang['cat_down'] );
-$vtp->setGlobalVar( $sub, 'cat_image_info',  $lang['cat_image_info'] );
-$vtp->setGlobalVar( $sub, 'cat_permission',  $lang['cat_permission'] );
-$vtp->setGlobalVar( $sub, 'cat_update',      $lang['cat_update'] );
-//---------------------------------------------------------------  rank updates
-if ( isset( $_GET['up'] ) && is_numeric( $_GET['up'] ) )
-{
-  // 1. searching level (id_uppercat)
-  //    and rank of the category to move
-  $query = 'select id_uppercat,rank';
-  $query.= ' from '.PREFIX_TABLE.'categories';
-  $query.= ' where id = '.$_GET['up'];
-  $query.= ';';
-  $row = mysql_fetch_array( mysql_query( $query ) );
-  $level = $row['id_uppercat'];
-  $rank  = $row['rank'];
-  // 2. searching the id and the rank of the category
-  //    just above at the same level
-  $query = 'select id,rank';
-  $query.= ' from '.PREFIX_TABLE.'categories';
-  $query.= ' where rank < '.$rank;
-  if ( $level == '' )
-  {
-    $query.= ' and id_uppercat is null';
-  }
-  else
-  {
-    $query.= ' and id_uppercat = '.$level;
-  }
-  $query.= ' order by rank desc';
-  $query.= ' limit 0,1';
-  $query.= ';';
-  $row = mysql_fetch_array( mysql_query( $query ) );
-  $new_rank     = $row['rank'];
-  $replaced_cat = $row['id'];
-  // 3. exchanging ranks between the two categories
-  $query = 'update '.PREFIX_TABLE.'categories';
-  $query.= ' set rank = '.$new_rank;
-  $query.= ' where id = '.$_GET['up'];
-  $query.= ';';
-  mysql_query( $query );
-  $query = 'update '.PREFIX_TABLE.'categories';
-  $query.= ' set rank = '.$rank;
-  $query.= ' where id = '.$replaced_cat;
-  $query.= ';';
-  mysql_query( $query );
-}
-if ( isset( $_GET['down'] ) && is_numeric( $_GET['down'] ) )
-{
-  // 1. searching level (id_uppercat)
-  //    and rank of the category to move
-  $query = 'select id_uppercat,rank';
-  $query.= ' from '.PREFIX_TABLE.'categories';
-  $query.= ' where id = '.$_GET['down'];
-  $query.= ';';
-  $row = mysql_fetch_array( mysql_query( $query ) );
-  $level = $row['id_uppercat'];
-  $rank  = $row['rank'];
-  // 2. searching the id and the rank of the category
-  //    just below at the same level
-  $query = 'select id,rank';
-  $query.= ' from '.PREFIX_TABLE.'categories';
-  $query.= ' where rank > '.$rank;
-  if ( $level == '' )
-  {
-    $query.= ' and id_uppercat is null';
-  }
-  else
-  {
-    $query.= ' and id_uppercat = '.$level;
-  }
-  $query.= ' order by rank asc';
-  $query.= ' limit 0,1';
-  $query.= ';';
-  $row = mysql_fetch_array( mysql_query( $query ) );
-  $new_rank     = $row['rank'];
-  $replaced_cat = $row['id'];
-  // 3. exchanging ranks between the two categories
-  $query = 'update '.PREFIX_TABLE.'categories';
-  $query.= ' set rank = '.$new_rank;
-  $query.= ' where id = '.$_GET['down'];
-  $query.= ';';
-  mysql_query( $query );
-  $query = 'update '.PREFIX_TABLE.'categories';
-  $query.= ' set rank = '.$rank;
-  $query.= ' where id = '.$replaced_cat;
-  $query.= ';';
-  mysql_query( $query );
-}
-//------------------------------------------------------------------ reordering
-function ordering( $id_uppercat )
-{
-  $rank = 1;
-		
-  $query = 'select id';
-  $query.= ' from '.PREFIX_TABLE.'categories';
-  if ( !is_numeric( $id_uppercat ) )
-  {
-    $query.= ' where id_uppercat is NULL';
-  }
-  else
-  {
-    $query.= ' where id_uppercat = '.$id_uppercat;
-  }
-  $query.= ' order by rank asc, dir asc';
-  $query.= ';';
-  $result = mysql_query( $query );
-  while ( $row = mysql_fetch_array( $result ) )
-  {
-    $query = 'update '.PREFIX_TABLE.'categories';
-    $query.= ' set rank = '.$rank;
-    $query.= ' where id = '.$row['id'];
-    $query.= ';';
-    mysql_query( $query );
-    $rank++;
-    ordering( $row['id'] );
-  }
-}
-	
-ordering( 'NULL' );
-//----------------------------------------------------affichage de la page
-function display_cat_manager( $id_uppercat, $indent,
-                              $uppercat_visible, $level )
-{
-  global $lang,$conf,$sub,$vtp;
-		
-  // searching the min_rank and the max_rank of the category
-  $query = 'select min(rank) as min, max(rank) as max';
-  $query.= ' from '.PREFIX_TABLE.'categories';
-  if ( !is_numeric( $id_uppercat ) )
-  {
-    $query.= ' where id_uppercat is NULL';
-  }
-  else
-  {
-    $query.= ' where id_uppercat = '.$id_uppercat;
-  }
-  $query.= ';';
-  $result = mysql_query( $query );
-  $row    = mysql_fetch_array( $result );
-  $min_rank = $row['min'];
-  $max_rank = $row['max'];
-		
-  // will we use <th> or <td> lines ?
-  $td    = 'td';
-  $class = '';
-  if ( $level > 0 )
-  {
-    $class = 'row'.$level;
-  }
-  else
-  {
-    $td = 'th';
-  }
-		
-  $query = 'select id,name,dir,nb_images,status,rank,site_id';
-  $query.= ' from '.PREFIX_TABLE.'categories';
-  if ( !is_numeric( $id_uppercat ) )
-  {
-    $query.= ' where id_uppercat is NULL';
-  }
-  else
-  {
-    $query.= ' where id_uppercat = '.$id_uppercat;
-  }
-  $query.= ' order by rank asc';
-  $query.= ';';
-  $result = mysql_query( $query );
-  while ( $row = mysql_fetch_array( $result ) )
-  {
-    $subcat_visible = true;
-
-    $vtp->addSession( $sub, 'cat' );
-    $vtp->setVar( $sub, 'cat.td', $td );
-    $vtp->setVar( $sub, 'cat.class', $class );
-    $vtp->setVar( $sub, 'cat.indent', $indent );
-    if ( $row['name'] == '' )
-    {
-      $name = str_replace( '_', ' ', $row['dir'] );
-    }
-    else
-    {
-      $name = $row['name'];
-    }
-    $vtp->setVar( $sub, 'cat.name', $name );
-    $vtp->setVar( $sub, 'cat.dir', $row['dir'] );
-    if ( $row['status'] == 'invisible' || !$uppercat_visible )
-    {
-      $subcat_visible = false;
-      $vtp->setVar( $sub, 'cat.invisible', $lang['cat_invisible'] );
-    }
-    $vtp->setVar( $sub, 'cat.nb_picture', $row['nb_images'] );
-    $url = add_session_id( './admin.php?page=edit_cat&amp;cat='.$row['id'] );
-    $vtp->setVar( $sub, 'cat.edit_url', $url );
-    if ( $row['rank'] != $min_rank )
-    {
-      $vtp->addSession( $sub, 'up' );
-      $url = add_session_id( './admin.php?page=cat&amp;up='.$row['id'] );
-      $vtp->setVar( $sub, 'up.up_url', $url );
-      $vtp->closeSession( $sub, 'up' );
-    }
-    else
-    {
-      $vtp->addSession( $sub, 'no_up' );
-      $vtp->closeSession( $sub, 'no_up' );
-    }
-    if ( $row['rank'] != $max_rank )
-    {
-      $vtp->addSession( $sub, 'down' );
-      $url = add_session_id( './admin.php?page=cat&amp;down='.$row['id'] );
-      $vtp->setVar( $sub, 'down.down_url', $url );
-      $vtp->closeSession( $sub, 'down' );
-    }
-    else
-    {
-      $vtp->addSession( $sub, 'no_down' );
-      $vtp->closeSession( $sub, 'no_down' );
-    }
-    if ( $row['nb_images'] > 0 )
-    {
-      $vtp->addSession( $sub, 'image_info' );
-      $url = add_session_id( './admin.php?page=infos_images&amp;cat_id='
-                             .$row['id'] );
-      $vtp->setVar( $sub, 'image_info.image_info_url', $url );
-      $vtp->closeSession( $sub, 'image_info' );
-    }
-    else
-    {
-      $vtp->addSession( $sub, 'no_image_info' );
-      $vtp->closeSession( $sub, 'no_image_info' );
-    }
-    $url = add_session_id( './admin.php?page=perm&amp;cat_id='.$row['id'] );
-    $vtp->setVar( $sub, 'cat.permission_url', $url );
-    if ( $row['site_id'] == 1 )
-    {
-      $vtp->addSession( $sub, 'update' );
-      $url = add_session_id('./admin.php?page=update&amp;update='.$row['id']);
-      $vtp->setVar( $sub, 'update.update_url', $url );
-      $vtp->closeSession( $sub, 'update' );
-    }
-    else
-    {
-      $vtp->addSession( $sub, 'no_update' );
-      $vtp->closeSession( $sub, 'no_update' );
-    }
-
-    $vtp->closeSession( $sub, 'cat' );
-
-    display_cat_manager( $row['id'], $indent.str_repeat( '&nbsp', 4 ),
-                         $subcat_visible, $level + 1 );
-  }
-}
-display_cat_manager( 'NULL', str_repeat( '&nbsp', 4 ), true, 0 );
-//----------------------------------------------------------- sending html code
-$vtp->Parse( $handle , 'sub', $sub );
-?>
Index: /trunk/admin/cat_list.php
===================================================================
--- /trunk/admin/cat_list.php	(revision 21)
+++ /trunk/admin/cat_list.php	(revision 21)
@@ -0,0 +1,293 @@
+<?php
+/***************************************************************************
+ *                                  cat.php                                *
+ *                            -------------------                          *
+ *   application          : PhpWebGallery 1.3                              *
+ *   website              : http://www.phpwebgallery.net                   *
+ *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
+ *                                                                         *
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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;                                         *
+ *                                                                         *
+ ***************************************************************************/
+include_once( './include/isadmin.inc.php' );
+//----------------------------------------------------- template initialization
+$sub = $vtp->Open( '../template/'.$user['template'].'/admin/cat_list.vtp' );
+// language
+$vtp->setGlobalVar( $sub, 'cat_edit',        $lang['cat_edit'] );
+$vtp->setGlobalVar( $sub, 'cat_up',          $lang['cat_up'] );
+$vtp->setGlobalVar( $sub, 'cat_down',        $lang['cat_down'] );
+$vtp->setGlobalVar( $sub, 'cat_image_info',  $lang['cat_image_info'] );
+$vtp->setGlobalVar( $sub, 'cat_permission',  $lang['cat_permission'] );
+$vtp->setGlobalVar( $sub, 'cat_update',      $lang['cat_update'] );
+//---------------------------------------------------------------  rank updates
+if ( isset( $_GET['up'] ) && is_numeric( $_GET['up'] ) )
+{
+  // 1. searching level (id_uppercat)
+  //    and rank of the category to move
+  $query = 'SELECT id_uppercat,rank';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  $query.= ' WHERE id = '.$_GET['up'];
+  $query.= ';';
+  $row = mysql_fetch_array( mysql_query( $query ) );
+  $level = $row['id_uppercat'];
+  $rank  = $row['rank'];
+  // 2. searching the id and the rank of the category
+  //    just above at the same level
+  $query = 'SELECT id,rank';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  $query.= ' WHERE rank < '.$rank;
+  if ( $level == '' )
+  {
+    $query.= ' AND id_uppercat IS NULL';
+  }
+  else
+  {
+    $query.= ' AND id_uppercat = '.$level;
+  }
+  $query.= ' ORDER BY rank DESC';
+  $query.= ' LIMIT 0,1';
+  $query.= ';';
+  $row = mysql_fetch_array( mysql_query( $query ) );
+  $new_rank     = $row['rank'];
+  $replaced_cat = $row['id'];
+  // 3. exchanging ranks between the two categories
+  $query = 'UPDATE '.PREFIX_TABLE.'categories';
+  $query.= ' SET rank = '.$new_rank;
+  $query.= ' WHERE id = '.$_GET['up'];
+  $query.= ';';
+  mysql_query( $query );
+  $query = 'UPDATE '.PREFIX_TABLE.'categories';
+  $query.= ' SET rank = '.$rank;
+  $query.= ' WHERE id = '.$replaced_cat;
+  $query.= ';';
+  mysql_query( $query );
+}
+if ( isset( $_GET['down'] ) && is_numeric( $_GET['down'] ) )
+{
+  // 1. searching level (id_uppercat)
+  //    and rank of the category to move
+  $query = 'SELECT id_uppercat,rank';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  $query.= ' WHERE id = '.$_GET['down'];
+  $query.= ';';
+  $row = mysql_fetch_array( mysql_query( $query ) );
+  $level = $row['id_uppercat'];
+  $rank  = $row['rank'];
+  // 2. searching the id and the rank of the category
+  //    just below at the same level
+  $query = 'SELECT id,rank';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  $query.= ' WHERE rank > '.$rank;
+  if ( $level == '' )
+  {
+    $query.= ' AND id_uppercat is null';
+  }
+  else
+  {
+    $query.= ' AND id_uppercat = '.$level;
+  }
+  $query.= ' ORDER BY rank ASC';
+  $query.= ' LIMIT 0,1';
+  $query.= ';';
+  $row = mysql_fetch_array( mysql_query( $query ) );
+  $new_rank     = $row['rank'];
+  $replaced_cat = $row['id'];
+  // 3. exchanging ranks between the two categories
+  $query = 'UPDATE '.PREFIX_TABLE.'categories';
+  $query.= ' SET rank = '.$new_rank;
+  $query.= ' WHERE id = '.$_GET['down'];
+  $query.= ';';
+  mysql_query( $query );
+  $query = 'UPDATE '.PREFIX_TABLE.'categories';
+  $query.= ' SET rank = '.$rank;
+  $query.= ' WHERE id = '.$replaced_cat;
+  $query.= ';';
+  mysql_query( $query );
+}
+//------------------------------------------------------------------ reordering
+function ordering( $id_uppercat )
+{
+  $rank = 1;
+		
+  $query = 'SELECT id';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  if ( !is_numeric( $id_uppercat ) )
+  {
+    $query.= ' WHERE id_uppercat IS NULL';
+  }
+  else
+  {
+    $query.= ' WHERE id_uppercat = '.$id_uppercat;
+  }
+  $query.= ' ORDER BY rank ASC, dir ASC';
+  $query.= ';';
+  $result = mysql_query( $query );
+  while ( $row = mysql_fetch_array( $result ) )
+  {
+    $query = 'UPDATE '.PREFIX_TABLE.'categories';
+    $query.= ' SET rank = '.$rank;
+    $query.= ' WHERE id = '.$row['id'];
+    $query.= ';';
+    mysql_query( $query );
+    $rank++;
+    ordering( $row['id'] );
+  }
+}
+	
+ordering( 'NULL' );
+//----------------------------------------------------affichage de la page
+function display_cat_manager( $id_uppercat, $indent,
+                              $uppercat_visible, $level )
+{
+  global $lang,$conf,$sub,$vtp;
+		
+  // searching the min_rank and the max_rank of the category
+  $query = 'SELECT MIN(rank) AS min, MAX(rank) AS max';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  if ( !is_numeric( $id_uppercat ) )
+  {
+    $query.= ' WHERE id_uppercat IS NULL';
+  }
+  else
+  {
+    $query.= ' WHERE id_uppercat = '.$id_uppercat;
+  }
+  $query.= ';';
+  $result = mysql_query( $query );
+  $row    = mysql_fetch_array( $result );
+  $min_rank = $row['min'];
+  $max_rank = $row['max'];
+		
+  // will we use <th> or <td> lines ?
+  $td    = 'td';
+  $class = '';
+  if ( $level > 0 )
+  {
+    $class = 'row'.$level;
+  }
+  else
+  {
+    $td = 'th';
+  }
+		
+  $query = 'SELECT id,name,dir,nb_images,status,rank,site_id,visible';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  if ( !is_numeric( $id_uppercat ) )
+  {
+    $query.= ' WHERE id_uppercat IS NULL';
+  }
+  else
+  {
+    $query.= ' WHERE id_uppercat = '.$id_uppercat;
+  }
+  $query.= ' ORDER BY rank ASC';
+  $query.= ';';
+  $result = mysql_query( $query );
+  while ( $row = mysql_fetch_array( $result ) )
+  {
+    $subcat_visible = true;
+
+    $vtp->addSession( $sub, 'cat' );
+    $vtp->setVar( $sub, 'cat.td', $td );
+    $vtp->setVar( $sub, 'cat.class', $class );
+    $vtp->setVar( $sub, 'cat.indent', $indent );
+    if ( $row['name'] == '' )
+    {
+      $name = str_replace( '_', ' ', $row['dir'] );
+    }
+    else
+    {
+      $name = $row['name'];
+    }
+    $vtp->setVar( $sub, 'cat.name', $name );
+    $vtp->setVar( $sub, 'cat.dir', $row['dir'] );
+    if ( $row['visible'] == 'false' or !$uppercat_visible )
+    {
+      $subcat_visible = false;
+      $vtp->setVar( $sub, 'cat.invisible', $lang['cat_invisible'] );
+    }
+    if ( $row['status'] == 'private' )
+    {
+      $vtp->setVar( $sub, 'cat.private', $lang['private'] );
+    }
+    $vtp->setVar( $sub, 'cat.nb_picture', $row['nb_images'] );
+    $url = add_session_id( './admin.php?page=cat_modify&amp;cat='.$row['id'] );
+    $vtp->setVar( $sub, 'cat.edit_url', $url );
+    if ( $row['rank'] != $min_rank )
+    {
+      $vtp->addSession( $sub, 'up' );
+      $url = add_session_id( './admin.php?page=cat&amp;up='.$row['id'] );
+      $vtp->setVar( $sub, 'up.up_url', $url );
+      $vtp->closeSession( $sub, 'up' );
+    }
+    else
+    {
+      $vtp->addSession( $sub, 'no_up' );
+      $vtp->closeSession( $sub, 'no_up' );
+    }
+    if ( $row['rank'] != $max_rank )
+    {
+      $vtp->addSession( $sub, 'down' );
+      $url = add_session_id( './admin.php?page=cat&amp;down='.$row['id'] );
+      $vtp->setVar( $sub, 'down.down_url', $url );
+      $vtp->closeSession( $sub, 'down' );
+    }
+    else
+    {
+      $vtp->addSession( $sub, 'no_down' );
+      $vtp->closeSession( $sub, 'no_down' );
+    }
+    if ( $row['nb_images'] > 0 )
+    {
+      $vtp->addSession( $sub, 'image_info' );
+      $url = add_session_id( './admin.php?page=infos_images&amp;cat_id='
+                             .$row['id'] );
+      $vtp->setVar( $sub, 'image_info.image_info_url', $url );
+      $vtp->closeSession( $sub, 'image_info' );
+    }
+    else
+    {
+      $vtp->addSession( $sub, 'no_image_info' );
+      $vtp->closeSession( $sub, 'no_image_info' );
+    }
+    if ( $row['status'] == 'private' )
+    {
+      $vtp->addSession( $sub, 'permission' );
+      $url=add_session_id('./admin.php?page=cat_perm&amp;cat_id='.$row['id']);
+      $vtp->setVar( $sub, 'permission.url', $url );
+      $vtp->closeSession( $sub, 'permission' );
+    }
+    else
+    {
+      $vtp->addSession( $sub, 'no_permission' );
+      $vtp->closeSession( $sub, 'no_permission' );
+    }
+    if ( $row['site_id'] == 1 )
+    {
+      $vtp->addSession( $sub, 'update' );
+      $url = add_session_id('./admin.php?page=update&amp;update='.$row['id']);
+      $vtp->setVar( $sub, 'update.update_url', $url );
+      $vtp->closeSession( $sub, 'update' );
+    }
+    else
+    {
+      $vtp->addSession( $sub, 'no_update' );
+      $vtp->closeSession( $sub, 'no_update' );
+    }
+
+    $vtp->closeSession( $sub, 'cat' );
+
+    display_cat_manager( $row['id'], $indent.str_repeat( '&nbsp', 4 ),
+                         $subcat_visible, $level + 1 );
+  }
+}
+display_cat_manager( 'NULL', str_repeat( '&nbsp', 4 ), true, 0 );
+//----------------------------------------------------------- sending html code
+$vtp->Parse( $handle , 'sub', $sub );
+?>
Index: /trunk/admin/cat_modify.php
===================================================================
--- /trunk/admin/cat_modify.php	(revision 21)
+++ /trunk/admin/cat_modify.php	(revision 21)
@@ -0,0 +1,153 @@
+<?php
+/***************************************************************************
+ *                               cat_modify.php                            *
+ *                            -------------------                          *
+ *   application          : PhpWebGallery 1.3                              *
+ *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
+ *                                                                         *
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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;                                         *
+ *                                                                         *
+ ***************************************************************************/
+
+include_once( './include/isadmin.inc.php' );
+//----------------------------------------------------- template initialization
+$sub = $vtp->Open( '../template/'.$user['template'].'/admin/cat_modify.vtp' );
+$tpl = array( 'remote_site','editcat_confirm','editcat_back','editcat_title1',
+              'editcat_name','editcat_comment','editcat_status',
+              'editcat_visible','editcat_status_info', 'submit' );
+templatize_array( $tpl, 'lang', $sub );
+//---------------------------------------------------------------- verification
+if ( !is_numeric( $_GET['cat'] ) )
+{
+  $_GET['cat'] = '-1';
+}
+//--------------------------------------------------------- form criteria check
+if ( isset( $_POST['submit'] ) )
+{
+  // if new status is different from previous one, deletion of all related
+  // links for access rights
+  $query = 'SELECT status';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  $query.= ' WHERE id = '.$_GET['cat'];
+  $query.= ';';
+  $row = mysql_fetch_array( mysql_query( $query ) );
+
+  if ( $_POST['status'] != $row['status'] )
+  {
+    // deletion of all access for groups concerning this category
+    $query = 'DELETE';
+    $query.= ' FROM '.PREFIX_TABLE.'group_access';
+    $query.= ' WHERE cat_id = '.$_GET['cat'];
+    mysql_query( $query );
+    // deletion of all access for users concerning this category
+    $query = 'DELETE';
+    $query.= ' FROM '.PREFIX_TABLE.'user_access';
+    $query.= ' WHERE cat_id = '.$_GET['cat'];
+    mysql_query( $query );
+  }
+  
+  $query = 'UPDATE '.PREFIX_TABLE.'categories';
+  if ( $_POST['name'] == '' )
+  {
+    $query.= ' SET name = NULL';
+  }
+  else
+  {
+    $query.= " SET name = '".htmlentities( $_POST['name'], ENT_QUOTES)."'";
+  }
+  if ( $_POST['comment'] == '' )
+  {
+    $query.= ', comment = NULL';
+  }
+  else
+  {
+    $query.= ", comment = '".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
+  }
+  $query.= ", status = '".$_POST['status']."'";
+  $query.= ", visible = '".$_POST['visible']."'";
+  $query.= " WHERE id = '".$_GET['cat']."'";
+  $query.= ';';
+  mysql_query( $query );
+
+  $query = 'SELECT id';
+  $query.= ' FROM '.PREFIX_TABLE.'users';
+  $query.= " WHERE username != '".$conf['webmaster']."'";
+  $query.= ';';
+  $result = mysql_query( $query );
+  while ( $row = mysql_fetch_array ( $result ) )
+  {
+    check_favorites( $row['id'] );
+  }
+  $vtp->addSession( $sub, 'confirmation' );
+  $url = add_session_id( './admin.php?page=cat_list' );
+  $vtp->setVar( $sub, 'confirmation.back_url', $url );
+  $vtp->closeSession( $sub, 'confirmation' );
+}
+//------------------------------------------------------------------------ form
+$form_action = './admin.php?page=cat_modify&amp;cat='.$_GET['cat'];
+$vtp->setVar( $sub, 'form_action', add_session_id( $form_action ) );
+
+$query = 'SELECT a.id,name,dir,status,comment';
+$query.= ',id_uppercat,site_id,galleries_url,visible';
+$query.= ' FROM '.PREFIX_TABLE.'categories as a, '.PREFIX_TABLE.'sites as b';
+$query.= ' WHERE a.id = '.$_GET['cat'];
+$query.= ' AND a.site_id = b.id';
+$query.= ';';
+$row = mysql_fetch_array( mysql_query( $query ) );
+$result = get_cat_info( $row['id'] );
+// cat name
+$cat_name = get_cat_display_name( $result['name'], ' - ', '' );
+$vtp->setVar( $sub, 'cat:name', $cat_name );
+// cat dir
+$vtp->setVar( $sub, 'cat:dir', $row['dir'] );
+// remote site ?
+if ( $row['site_id'] != 1 )
+{
+  $vtp->addSession( $sub, 'server' );
+  $vtp->setVar( $sub, 'server.url', $row['galleries_url'] );
+  $vtp->closeSession( $sub, 'server' );
+}
+$vtp->setVar( $sub, 'name',    $row['name'] );
+$vtp->setVar( $sub, 'comment', $row['comment'] );
+// status : public, private...
+$options = get_enums( PREFIX_TABLE.'categories', 'status' );
+foreach ( $options as $option  ) {
+  $vtp->addSession( $sub, 'status_option' );
+  $vtp->setVar( $sub, 'status_option.option', $lang[$option] );
+  $vtp->setVar( $sub, 'status_option.value', $option );
+  if ( $option == $row['status'] )
+  {
+    $vtp->setVar( $sub, 'status_option.checked', ' checked="checked"' );  
+  }
+  $vtp->closeSession( $sub, 'status_option' );
+}
+// visible : true or false
+$vtp->addSession( $sub, 'visible_option' );
+$vtp->setVar( $sub, 'visible_option.value', 'true' );
+$vtp->setVar( $sub, 'visible_option.option', $lang['yes'] );
+$checked = '';
+if ( $row['visible'] == 'true' )
+{
+  $checked = ' checked="checked"';
+}
+$vtp->setVar( $sub, 'visible_option.checked', $checked );
+$vtp->closeSession( $sub, 'visible_option' );
+$vtp->addSession( $sub, 'visible_option' );
+$vtp->setVar( $sub, 'visible_option.value', 'false' );
+$vtp->setVar( $sub, 'visible_option.option', $lang['no'] );
+$checked = '';
+if ( $row['visible'] == 'false' )
+{
+  $checked = ' checked="checked"';
+}
+$vtp->setVar( $sub, 'visible_option.checked', $checked );
+$vtp->closeSession( $sub, 'visible_option' );
+//----------------------------------------------------------- sending html code
+$vtp->Parse( $handle , 'sub', $sub );
+?>
Index: /trunk/admin/cat_perm.php
===================================================================
--- /trunk/admin/cat_perm.php	(revision 21)
+++ /trunk/admin/cat_perm.php	(revision 21)
@@ -0,0 +1,210 @@
+<?php
+/***************************************************************************
+ *                               cat_perm.php                              *
+ *                            ------------------                           *
+ *   application          : PhpWebGallery 1.3                              *
+ *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
+ *                                                                         *
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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;                                         *
+ *                                                                         *
+ ***************************************************************************/
+include_once( './include/isadmin.inc.php' );
+//----------------------------------------------------- template initialization
+$sub = $vtp->Open( '../template/'.$user['template'].'/admin/cat_perm.vtp' );
+$error = array();
+$tpl = array( 'permuser_authorized','permuser_forbidden','menu_groups',
+              'submit','menu_users','permuser_parent_forbidden' );
+templatize_array( $tpl, 'lang', $sub );
+//-------------------------------------------------------------- category infos
+if ( isset( $_GET['cat_id'] ) )
+{
+  check_cat_id( $_GET['cat_id'] );
+  if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
+  {
+    $result = get_cat_info( $page['cat'] );
+    $page['cat_name']    = $result['name'];
+    $page['id_uppercat'] = $result['id_uppercat'];
+  }
+}
+//---------------------------------------------------------- permission updates
+if ( isset( $_POST['submit'] ) )
+{
+  // groups access update
+  $query = 'DELETE';
+  $query.= ' FROM '.PREFIX_TABLE.'group_access';
+  $query.= ' WHERE cat_id = '.$page['cat'];
+  $query.= ';';
+  mysql_query( $query );
+  $query = 'SELECT id';
+  $query.= ' FROM '.PREFIX_TABLE.'groups';
+  $query.= ';';
+  $result = mysql_query( $query );
+  while ( $row = mysql_fetch_array( $result ) )
+  {
+    $radioname = 'groupaccess-'.$row['id'];
+    if ( $_POST[$radioname] == 0 )
+    {
+      $query = 'INSERT INTO '.PREFIX_TABLE.'group_access';
+      $query.= ' (cat_id,group_id) VALUES';
+      $query.= ' ('.$page['cat'].','.$row['id'].')';
+      $query.= ';';
+      mysql_query( $query );
+    }
+  }
+  // users access update
+  $query = 'DELETE';
+  $query.= ' FROM '.PREFIX_TABLE.'user_access';
+  $query.= ' WHERE cat_id = '.$page['cat'];
+  $query.= ';';
+  mysql_query( $query );
+  $query = 'SELECT id';
+  $query.= ' FROM '.PREFIX_TABLE.'users';
+  $query.= ';';
+  $result = mysql_query( $query );
+  while ( $row = mysql_fetch_array( $result ) )
+  {
+    $radioname = 'useraccess-'.$row['id'];
+    if ( $_POST[$radioname] == 0 )
+    {
+      $query = 'INSERT INTO '.PREFIX_TABLE.'user_access';
+      $query.= ' (cat_id,user_id) VALUES';
+      $query.= ' ('.$page['cat'].','.$row['id'].')';
+      $query.= ';';
+      mysql_query( $query );
+    }
+    check_favorites( $row['id'] );
+  }
+  // echo "<div class=\"info\">".$lang['permuser_info_message']." [ <a href=\"".add_session_id_to_url( "./admin.php?page=cat" )."\">".$lang['editcat_back']."</a> ]</div>";
+}
+//---------------------------------------------------------------------- groups
+$query = 'SELECT id,name';
+$query.= ' FROM '.PREFIX_TABLE.'groups';
+$query. ';';
+$result = mysql_query( $query );
+if ( mysql_num_rows( $result ) > 0 )
+{
+  $vtp->addSession( $sub, 'groups' );
+  // creating an array with all authorized groups for this category
+  $query = 'SELECT group_id';
+  $query.= ' FROM '.PREFIX_TABLE.'group_access';
+  $query.= ' WHERE cat_id = '.$_GET['cat_id'];
+  $query.= ';';
+  $subresult = mysql_query( $query );
+  $authorized_groups = array();
+  while ( $subrow = mysql_fetch_array( $subresult ) )
+  {
+    array_push( $authorized_groups, $subrow['group_id'] );
+  }
+  // displaying each group
+  while( $row = mysql_fetch_array( $result ) )
+  {
+    $vtp->addSession( $sub, 'group' );
+    if ( in_array( $row['id'], $authorized_groups ) )
+    {
+      $vtp->setVar( $sub, 'group.color', 'green' );
+      $vtp->setVar( $sub, 'group.authorized_checked', ' checked="checked"' );
+    }
+    else
+    {
+      $vtp->setVar( $sub, 'group.color', 'red' );
+      $vtp->setVar( $sub, 'group.forbidden_checked', ' checked="checked"' );
+    }
+    $vtp->setVar( $sub, 'group.groupname', $row['name'] );
+    $vtp->setVar( $sub, 'group.id', $row['id'] );
+    $vtp->closeSession( $sub, 'group' );
+  }
+  $vtp->closeSession( $sub, 'groups' );
+}
+//----------------------------------------------------------------------- users
+$query = 'SELECT id,username,status';
+$query.= ' FROM '.PREFIX_TABLE.'users';
+$query.= " WHERE username != '".$conf['webmaster']."'";
+$query.= ';';
+$result = mysql_query( $query );
+while ( $row = mysql_fetch_array( $result ) )
+{
+  $vtp->addSession( $sub, 'user' );
+  $vtp->setVar( $sub, 'user.id', $row['id'] );
+  $url = add_session_id( './admin.php?page=user_perm&amp;user_id='.$row['id']);
+  $vtp->setVar( $sub, 'user.user_perm_link', $url);
+  if ( $row['username'] == 'guest' )
+  {
+    $row['username'] = $lang['guest'];
+  }
+  $vtp->setVar( $sub, 'user.username', $row['username'] );
+
+  // for color of user : (red means access forbidden, green authorized) we
+  // ask all forbidden categories, including the groups rights
+  $restrictions = get_restrictions( $row['id'], $row['status'], false );
+  $is_user_allowed = is_user_allowed( $page['cat'], $restrictions );
+  if ( $is_user_allowed == 0 )
+  {
+    $vtp->setVar( $sub, 'user.color', 'green' );
+  }
+  else
+  {
+    $vtp->setVar( $sub, 'user.color', 'red' );
+  }
+  // for permission update button, we only ask forbidden categories for the
+  // user, not taking into account the groups the user belongs to
+  $restrictions = get_restrictions( $row['id'], $row['status'], false, false );
+  $is_user_allowed = is_user_allowed( $page['cat'], $restrictions );
+  if ( $is_user_allowed == 2 )
+  {
+    $vtp->addSession( $sub, 'parent_forbidden' );
+    $url = './admin.php?page=cat_perm&amp;cat_id='.$page['id_uppercat'];
+    $vtp->setVar( $sub, 'parent_forbidden.url', add_session_id( $url ) );
+    $vtp->closeSession( $sub, 'parent_forbidden' );
+  }
+  if ( $is_user_allowed == 0 )
+  {
+    $vtp->setVar( $sub, 'user.authorized_checked', ' checked="checked"' );
+  }
+  else
+  {
+    $vtp->setVar( $sub, 'user.forbidden_checked', ' checked="checked"' );
+  }
+  // user's group(s)
+  $query = 'SELECT g.name as groupname, g.id as groupid';
+  $query.= ' FROM '.PREFIX_TABLE.'groups as g';
+  $query.= ', '.PREFIX_TABLE.'user_group as ug';
+  $query.= ' WHERE ug.group_id = g.id';
+  $query.= ' AND ug.user_id = '.$row['id'];
+  $query.= ';';
+  $subresult = mysql_query( $query );
+  if ( mysql_num_rows( $subresult ) > 0 )
+  {
+    $vtp->addSession( $sub, 'usergroups' );
+    $i = 0;
+    while( $subrow = mysql_fetch_array( $subresult ) )
+    {
+      $vtp->addSession( $sub, 'usergroup' );
+      if ( in_array( $subrow['groupid'], $authorized_groups ) )
+      {
+        $vtp->setVar( $sub, 'usergroup.color', 'green' );
+      }
+      else
+      {
+        $vtp->setVar( $sub, 'usergroup.color', 'red' );
+      }
+      $vtp->setVar( $sub, 'usergroup.name', $subrow['groupname'] );
+      if ( $i < mysql_num_rows( $subresult ) - 1 )
+      {
+        $vtp->setVar( $sub, 'usergroup.separation', ',' );
+      }
+      $vtp->closeSession( $sub, 'usergroup' );
+      $i++;
+    }
+    $vtp->closeSession( $sub, 'usergroups' );
+  }
+  $vtp->closeSession( $sub, 'user' );
+}
+//----------------------------------------------------------- sending html code
+$vtp->Parse( $handle , 'sub', $sub );
+?>
Index: /trunk/admin/configuration.php
===================================================================
--- /trunk/admin/configuration.php	(revision 20)
+++ /trunk/admin/configuration.php	(revision 21)
@@ -16,5 +16,5 @@
  *                                                                         *
  ***************************************************************************/
- 
+
 include_once( './include/isadmin.inc.php' );
 	
@@ -49,5 +49,6 @@
 if ( isset( $_POST['submit'] ) )
 {
-  //purge de la table des session si demandé
+  $int_pattern = '/^\d+$/';
+  // empty session table if asked
   if ( $_POST['empty_session_table'] == 1 )
   {
@@ -80,6 +81,6 @@
   }
   // periods must be integer values, they represents number of days
-  if ( !is_int( $_POST['short_period'] )
-       or !is_int( $_POST['long_period'] ) )
+  if ( !preg_match( $int_pattern, $_POST['short_period'] )
+       or !preg_match( $int_pattern, $_POST['long_period'] ) )
   {
     array_push( $error, $lang['err_periods'] );
@@ -95,5 +96,5 @@
   }
   // session_id size must be an integer between 4 and 50
-  if ( !is_int( $_POST['session_id_size'] )
+  if ( !preg_match( $int_pattern, $_POST['session_id_size'] )
        or $_POST['session_id_size'] < 4
        or $_POST['session_id_size'] > 50 )
@@ -102,5 +103,5 @@
   }
   // session_time must be an integer between 5 and 60, in minutes
-  if ( !is_int( $_POST['session_time'] )
+  if ( !preg_match( $int_pattern, $_POST['session_time'] )
        or $_POST['session_time'] < 5
        or $_POST['session_time'] > 60 )
@@ -109,5 +110,5 @@
   }
   // max_user_listbox must be an integer between 0 and 255 included
-  if ( !is_int( $_POST['max_user_listbox'] )
+  if ( !preg_match( $int_pattern, $_POST['max_user_listbox'] )
        or $_POST['max_user_listbox'] < 0
        or $_POST['max_user_listbox'] > 255 )
@@ -117,5 +118,5 @@
   // the number of comments per page must be an integer between 5 and 50
   // included
-  if ( !is_int( $_POST['nb_comment_page'] )
+  if ( !preg_match( $int_pattern, $_POST['nb_comment_page'] )
        or $_POST['nb_comment_page'] < 5
        or $_POST['nb_comment_page'] > 50 )
@@ -124,5 +125,5 @@
   }
   // the maximum upload filesize must be an integer between 10 and 1000
-  if ( !is_int( $_POST['upload_maxfilesize'] )
+  if ( !preg_match( $int_pattern, $_POST['upload_maxfilesize'] )
        or $_POST['upload_maxfilesize'] < 10
        or $_POST['upload_maxfilesize'] > 1000 )
@@ -132,5 +133,5 @@
   // the maximum width of uploaded pictures must be an integer superior to
   // 10
-  if ( !is_int( $_POST['upload_maxwidth'] )
+  if ( !preg_match( $int_pattern, $_POST['upload_maxwidth'] )
        or $_POST['upload_maxwidth'] < 10 )
   {
@@ -139,5 +140,5 @@
   // the maximum height  of uploaded pictures must be an integer superior to
   // 10
-  if ( !is_int( $_POST['upload_maxheight'] )
+  if ( !preg_match( $int_pattern, $_POST['upload_maxheight'] )
        or $_POST['upload_maxheight'] < 10 )
   {
@@ -146,5 +147,5 @@
   // the maximum width of uploaded thumbnails must be an integer superior to
   // 10
-  if ( !is_int( $_POST['upload_maxwidth_thumbnail'] )
+  if ( !preg_match( $int_pattern, $_POST['upload_maxwidth_thumbnail'] )
        or $_POST['upload_maxwidth_thumbnail'] < 10 )
   {
@@ -153,33 +154,27 @@
   // the maximum width of uploaded thumbnails must be an integer superior to
   // 10
-  if ( !is_int( $_POST['upload_maxheight_thumbnail'] )
+  if ( !preg_match( $int_pattern, $_POST['upload_maxheight_thumbnail'] )
        or $_POST['upload_maxheight_thumbnail'] < 10 )
   {
     array_push( $error, $lang['conf_err_upload_maxheight_thumbnail'] );
   }
-  $test = '';
-  if ( is_int( $test ) ) echo 'salut'; exit();
-  if ( $_POST['maxwidth'] != '' )
-  {
-    if ( !ereg( "^[0-9]{2,}$", $_POST['maxwidth'] )
-         or $_POST['maxwidth'] < 50 )
-    {
-      $error[$i++] = $lang['err_maxwidth'];
-    }
-  }
-  if ( $_POST['maxheight'] != '' )
-  {
-    if ( !ereg( "^[0-9]{2,}$", $_POST['maxheight'] )
-         or $_POST['maxheight'] < 50 )
-    {
-      $error[$i++] = $lang['err_maxheight'];
-    }
-  }
-  // on met à jour les paramètres de l'application
-  // dans le cas où il n'y aucune erreurs
-  if ( sizeof( $error ) == 0 )
-  {
-    mysql_query( 'delete from '.PREFIX_TABLE.'config;' );
-    $query = 'insert into '.PREFIX_TABLE.'config';
+
+  if ( $_POST['maxwidth'] != ''
+       and ( !preg_match( $int_pattern, $_POST['maxwidth'] )
+             or $_POST['maxwidth'] < 50 ) )
+  {
+    array_push( $error, $lang['err_maxwidth'] );
+  }
+  if ( $_POST['maxheight']
+       and ( !preg_match( $int_pattern, $_POST['maxheight'] )
+             or $_POST['maxheight'] < 50 ) )
+  {
+    array_push( $error, $lang['err_maxheight'] );
+  }
+  // updating configuraiton if no error found
+  if ( count( $error ) == 0 )
+  {
+    mysql_query( 'DELETE FROM '.PREFIX_TABLE.'config;' );
+    $query = 'INSERT INTO '.PREFIX_TABLE.'config';
     $query.= ' (';
     foreach ( $conf_infos as $i => $conf_info ) {
@@ -188,5 +183,5 @@
     }
     $query.= ')';
-    $query.= ' values';
+    $query.= ' VALUES';
     $query.= ' (';
     foreach ( $conf_infos as $i => $conf_info ) {
@@ -261,13 +256,10 @@
 }
 //----------------------------------------------------- template initialization
-$sub = $vtp->Open( '../template/'.$user['template'].
-                   '/admin/configuration.vtp' );
-// language
-$vtp->setGlobalVar( $sub, 'conf_confirmation',  $lang['conf_confirmation'] );
-$vtp->setGlobalVar( $sub, 'remote_site',        $lang['remote_site'] );
-$vtp->setGlobalVar( $sub, 'delete',             $lang['delete'] );
-$vtp->setGlobalVar( $sub, 'conf_remote_site_delete_info',
-                    $lang['conf_remote_site_delete_info'] );
-$vtp->setGlobalVar( $sub, 'submit',             $lang['submit'] );
+$sub = $vtp->Open(
+  '../template/'.$user['template'].'/admin/configuration.vtp' );
+
+$tpl = array( 'conf_confirmation','remote_site','delete',
+              'conf_remote_site_delete_info','submit' );
+templatize_array( $tpl, 'lang', $sub );
 //-------------------------------------------------------------- errors display
 if ( sizeof( $error ) != 0 )
@@ -346,5 +338,4 @@
 $vtp->setVar( $sub, 'radio.option', $lang['conf_general_access_1'] );
 $checked = '';
-echo $access.'<br />';
 if ( $access == 'free' )
 {
Index: unk/admin/edit_cat.php
===================================================================
--- /trunk/admin/edit_cat.php	(revision 20)
+++ 	(revision )
@@ -1,100 +1,0 @@
-<?php
-/***************************************************************************
- *                               edit_cat.php                              *
- *                            -------------------                          *
- *   application          : PhpWebGallery 1.3                              *
- *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
- *                                                                         *
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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;                                         *
- *                                                                         *
- ***************************************************************************/
-
-include_once( './include/isadmin.inc.php' );
-//----------------------------------------------------- template initialization
-$sub = $vtp->Open( '../template/'.$user['template'].'/admin/edit_cat.vtp' );
-$tpl = array( 'remote_site','editcat_confirm','editcat_back','editcat_title1',
-              'editcat_name', 'editcat_comment', 'editcat_status',
-              'editcat_status_info', 'submit' );
-templatize_array( $tpl, 'lang', $sub );
-//--------------------------------------------------------- form criteria check
-if ( isset( $_POST['submit'] ) )
-{
-  $query = 'UPDATE '.PREFIX_TABLE.'categories';
-  if ( $_POST['name'] == '' )
-  {
-    $query.= ' SET name = NULL';
-  }
-  else
-  {
-    $query.= " SET name = '".htmlentities( $_POST['name'], ENT_QUOTES)."'";
-  }
-  if ( $_POST['comment'] == '' )
-  {
-    $query.= ', comment = NULL';
-  }
-  else
-  {
-    $query.= ", comment = '".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
-  }
-  $query.= ", status = '".$_POST['status']."'";
-  $query.= " WHERE id = '".$_GET['cat']."'";
-  $query.= ';';
-  mysql_query( $query );
-
-  $query = 'SELECT id';
-  $query.= ' FROM '.PREFIX_TABLE.'users';
-  $query.= " WHERE username != '".$conf['webmaster']."'";
-  $query.= ';';
-  $result = mysql_query( $query );
-  while ( $row = mysql_fetch_array ( $result ) )
-  {
-    check_favorites( $row['id'] );
-  }
-  $vtp->addSession( $sub, 'confirmation' );
-  $url = add_session_id( './admin.php?page=cat' );
-  $vtp->setVar( $sub, 'confirmation.back_url', $url );
-  $vtp->closeSession( $sub, 'confirmation' );
-}
-//------------------------------------------------------------------------ form
-$form_action = './admin.php?page=edit_cat&amp;cat='.$_GET['cat'];
-$vtp->setVar( $sub, 'form_action', add_session_id( $form_action ) );
-
-$query = 'SELECT a.id,name,dir,status,comment';
-$query.= ',id_uppercat,site_id,galleries_url';
-$query.= ' FROM '.PREFIX_TABLE.'categories as a, '.PREFIX_TABLE.'sites as b';
-$query.= ' WHERE a.id = '.$_GET['cat'];
-$query.= ' AND a.site_id = b.id';
-$query.= ';';
-$row = mysql_fetch_array( mysql_query( $query ) );
-$result = get_cat_info( $row['id'] );
-
-$cat_name = get_cat_display_name( $result['name'], ' - ', '' );
-$vtp->setVar( $sub, 'cat:name', $cat_name );
-$vtp->setVar( $sub, 'cat:dir', $row['dir'] );
-if ( $row['site_id'] != 1 )
-{
-  $vtp->addSession( $sub, 'server' );
-  $vtp->setVar( $sub, 'server.url', $row['galleries_url'] );
-  $vtp->closeSession( $sub, 'server' );
-}
-$vtp->setVar( $sub, 'name',    $row['name'] );
-$vtp->setVar( $sub, 'comment', $row['comment'] );
-$options = get_enums( PREFIX_TABLE.'categories', 'status' );
-foreach ( $options as $option  ) {
-  $vtp->addSession( $sub, 'status_option' );
-  $vtp->setVar( $sub, 'status_option.option', $option );
-  if ( $option == $row['status'] )
-  {
-    $vtp->setVar( $sub, 'status_option.checked', ' checked="checked"' );  
-  }
-  $vtp->closeSession( $sub, 'status_option' );
-}
-//----------------------------------------------------------- sending html code
-$vtp->Parse( $handle , 'sub', $sub );
-?>
Index: /trunk/admin/group_list.php
===================================================================
--- /trunk/admin/group_list.php	(revision 21)
+++ /trunk/admin/group_list.php	(revision 21)
@@ -0,0 +1,135 @@
+<?php
+/***************************************************************************
+ *                                 group.php                               *
+ *                            -------------------                          *
+ *   application          : PhpWebGallery 1.3                              *
+ *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
+ *                                                                         *
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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;                                         *
+ *                                                                         *
+ ***************************************************************************/
+include_once( './include/isadmin.inc.php' );
+//----------------------------------------------------- template initialization
+$sub = $vtp->Open( '../template/'.$user['template'].'/admin/group_list.vtp' );
+$tpl = array( 'group_add','add','listuser_permission','delete',
+              'group_confirm','yes','no','group_list_title' );
+templatize_array( $tpl, 'lang', $sub );
+//-------------------------------------------------------------- delete a group
+$error = array();
+if ( isset ( $_GET['delete'] ) and is_numeric( $_GET['delete'] ) )
+{
+  $query = 'SELECT name';
+  $query.= ' FROM '.PREFIX_TABLE.'groups';
+  $query.= ' WHERE id = '.$_GET['delete'];
+  $query.= ';';
+  $row = mysql_fetch_array( mysql_query( $query ) );
+  // confirm group deletion ?
+  if ( $_GET['confirm'] != 1 )
+  {
+    $vtp->addSession( $sub, 'deletion' );
+    $vtp->setVar( $sub, 'deletion.name', $row['name'] );
+    $yes_url = './admin.php?page=group&amp;delete='.$_GET['delete'];
+    $yes_url.= '&amp;confirm=1';
+    $vtp->setVar( $sub, 'deletion.yes_url', add_session_id( $yes_url ) );
+    $no_url = './admin.php?page=group';
+    $vtp->setVar( $sub, 'deletion.no_url', add_session_id( $no_url ) );
+    $vtp->closeSession( $sub, 'deletion' );
+  }
+  // group deletion confirmed
+  else
+  {
+    $vtp->addSession( $sub, 'confirmation' );
+    $query = 'SELECT COUNT(*) AS nb_result';
+    $query.= ' FROM '.PREFIX_TABLE.'groups';
+    $query.= ' WHERE id = '.$_GET['delete'];
+    $query.= ';';
+    $row2 = mysql_fetch_array( mysql_query( $query ) );
+    if ( $row2['nb_result'] > 0 )
+    {
+      delete_group( $_GET['delete'] );
+      $vtp->setVar( $sub, 'confirmation.class', 'info' );
+      $info = '"'.$row['name'].'" '.$lang['listuser_info_deletion'];
+      $vtp->setVar( $sub, 'confirmation.info', $info );
+    }
+    else
+    {
+      $vtp->setVar( $sub, 'confirmation.class', 'erreur' );
+      $vtp->setVar( $sub, 'confirmation.info', $lang['group_err_unknown'] );
+    }
+    $vtp->closeSession( $sub, 'confirmation' );
+  }
+}
+//----------------------------------------------------------------- add a group
+if ( isset( $_POST['submit'] ) )
+{
+  if ( preg_match( "/'/", $_POST['name'] )
+       or preg_match( '/"/', $_POST['name'] ) )
+  {
+    array_push( $error, $lang['group_add_error1'] );
+  }
+  if ( count( $error ) == 0 )
+  {
+    // is the group not already existing ?
+    $query = 'SELECT id';
+    $query.= ' FROM '.PREFIX_TABLE.'groups';
+    $query.= " WHERE name = '".$_POST['name']."'";
+    $query.= ';';
+    $result = mysql_query( $query );
+    if ( mysql_num_rows( $result ) > 0 )
+    {
+      array_push( $error, $lang['group_add_error2'] );
+    }
+  }
+  if ( count( $error ) == 0 )
+  {
+    // creating the group
+    $query = ' INSERT INTO '.PREFIX_TABLE.'groups';
+    $query.= " (name) VALUES ('".$_POST['name']."')";
+    $query.= ';';
+    mysql_query( $query );
+  }
+}
+//-------------------------------------------------------------- errors display
+if ( sizeof( $error ) != 0 )
+{
+  $vtp->addSession( $sub, 'errors' );
+  for ( $i = 0; $i < sizeof( $error ); $i++ )
+  {
+    $vtp->addSession( $sub, 'li' );
+    $vtp->setVar( $sub, 'li.li', $error[$i] );
+    $vtp->closeSession( $sub, 'li' );
+  }
+  $vtp->closeSession( $sub, 'errors' );
+}
+//----------------------------------------------------------------- groups list
+$vtp->addSession( $sub, 'groups' );
+
+$query = 'SELECT id,name';
+$query.= ' FROM '.PREFIX_TABLE.'groups';
+$query.= ' ORDER BY id ASC';
+$query.= ';';
+$result = mysql_query( $query );
+while ( $row = mysql_fetch_array( $result ) )
+{
+  $vtp->addSession( $sub, 'group' );
+  $vtp->setVar( $sub, 'group.name', $row['name'] );
+  $url = './admin.php?page=group_perm&amp;group_id='.$row['id'];
+  $vtp->setVar( $sub, 'group.permission_url', add_session_id( $url ) );
+  $url = './admin.php?page=group&amp;delete='.$row['id'];
+  $vtp->setVar( $sub, 'group.deletion_url', add_session_id( $url ) );
+  $vtp->closeSession( $sub, 'group' );
+}
+
+$vtp->closeSession( $sub, 'groups' );
+//------------------------------------------------------- create new group form
+$action = './admin.php?'.$_SERVER['QUERY_STRING'];
+$vtp->setVar( $sub, 'form_action', $action );
+//----------------------------------------------------------- sending html code
+$vtp->Parse( $handle , 'sub', $sub );
+?>
Index: /trunk/admin/group_perm.php
===================================================================
--- /trunk/admin/group_perm.php	(revision 21)
+++ /trunk/admin/group_perm.php	(revision 21)
@@ -0,0 +1,104 @@
+<?php
+/***************************************************************************
+ *                               group_perm.php                             *
+ *                            ------------------                           *
+ *   application          : PhpWebGallery 1.3                              *
+ *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
+ *                                                                         *
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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;                                         *
+ *                                                                         *
+ ***************************************************************************/
+include_once( './include/isadmin.inc.php' );
+//----------------------------------------------------- template initialization
+$sub = $vtp->Open( '../template/'.$user['template'].'/admin/group_perm.vtp' );
+$error = array();
+$tpl = array( 'permuser_authorized','permuser_forbidden','submit',
+              'permuser_parent_forbidden','permuser_info_message',
+              'adduser_info_back' );
+templatize_array( $tpl, 'lang', $sub );
+//--------------------------------------------------------------------- updates
+if ( isset( $_POST['submit'] ) )
+{
+  // cleaning the user_access table for this group
+  $query = 'DELETE FROM '.PREFIX_TABLE.'group_access';
+  $query.= ' WHERE group_id = '.$_GET['group_id'];
+  $query.= ';';
+  mysql_query( $query );
+  // selecting all private categories
+  $query = 'SELECT id';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  $query.= " WHERE status = 'private'";
+  $query.= ';';
+  $result = mysql_query( $query );
+  while ( $row = mysql_fetch_array( $result ) )
+  {
+    $radioname = 'access-'.$row['id'];
+    if ( $_POST[$radioname] == 0 )
+    {
+      $query = 'INSERT INTO '.PREFIX_TABLE.'group_access';
+      $query.= ' (group_id,cat_id) VALUES';
+      $query.= ' ('.$_GET['group_id'].','.$row['id'].')';
+      $query.= ';';
+      mysql_query ( $query );
+    }
+  }
+  $vtp->addSession( $sub, 'confirmation' );
+  $url = './admin.php?page=group_list';
+  $vtp->setVar( $sub, 'confirmation.back_url', add_session_id( $url ) );
+  $vtp->closeSession( $sub, 'confirmation' );
+}
+//---------------------------------------------------------------- form display
+$restrictions = get_group_restrictions( $_GET['group_id'] );
+$action = './admin.php?page=group_perm&amp;group_id='.$_GET['group_id'];
+$vtp->setVar( $sub, 'action', add_session_id( $action ) );
+// only private categories are listed
+$query = 'SELECT id';
+$query.= ' FROM '.PREFIX_TABLE.'categories';
+$query.= " WHERE status = 'private'";
+$query.= ';';
+$result = mysql_query( $query );
+while ( $row = mysql_fetch_array( $result ) )
+{
+  $vtp->addSession( $sub, 'category' );
+  $vtp->setVar( $sub, 'category.id', $row['id'] );
+  // Is the group allowed to access this category
+  $is_group_allowed = is_group_allowed( $row['id'], $restrictions );
+  if ( $is_group_allowed == 0 )
+  {
+    $vtp->setVar( $sub, 'category.color', 'green' );
+  }
+  else
+  {
+    $vtp->setVar( $sub, 'category.color', 'red' );
+  }
+  // category name
+  $cat_infos = get_cat_info( $row['id'] );
+  $name = get_cat_display_name( $cat_infos['name'],' &gt; ',
+                                'font-weight:bold;' );
+  $vtp->setVar( $sub, 'category.name', $name );
+  // any subcat forbidden for this group ?
+  if ( $is_group_allowed == 2 )
+  {
+    $vtp->addSession( $sub, 'parent_forbidden' );
+    $vtp->closeSession( $sub, 'parent_forbidden' );
+  }
+  // forbidden or authorized access ?
+  if ( $is_group_allowed == 0 or $is_group_allowed == 2 )
+  {
+    $vtp->setVar( $sub, 'category.authorized_checked', ' checked="checked"' );
+  }
+  else
+  {
+    $vtp->setVar( $sub, 'category.forbidden_checked', ' checked="checked"' );
+  }
+  $vtp->closeSession( $sub, 'category' );
+}
+//----------------------------------------------------------- sending html code
+$vtp->Parse( $handle , 'sub', $sub );
+?>
Index: /trunk/admin/include/functions.php
===================================================================
--- /trunk/admin/include/functions.php	(revision 20)
+++ /trunk/admin/include/functions.php	(revision 21)
@@ -102,11 +102,15 @@
     delete_image( $row['id'] );
   }
-		
-  // destruction of the restrictions linked to the category
-  $query = 'DELETE FROM '.PREFIX_TABLE.'restrictions';
+
+  // destruction of the access linked to the category
+  $query = 'DELETE FROM '.PREFIX_TABLE.'user_access';
   $query.= ' WHERE cat_id = '.$id;
   $query.= ';';
   mysql_query( $query );
-		
+  $query = 'DELETE FROM '.PREFIX_TABLE.'group_access';
+  $query.= ' WHERE cat_id = '.$id;
+  $query.= ';';
+  mysql_query( $query );
+
   // destruction of the sub-categories
   $query = 'SELECT id';
@@ -119,5 +123,5 @@
     delete_category( $row['id'] );
   }
-		
+
   // destruction of the category
   $query = 'DELETE FROM '.PREFIX_TABLE.'categories';
@@ -157,16 +161,30 @@
 // The delete_user function delete a user identified by the $user_id
 // It also deletes :
-//     - all the restrictions linked to this user
+//     - all the access linked to this user
+//     - all the links to any group
 //     - all the favorites linked to this user
+//     - all sessions linked to this user
 function delete_user( $user_id )
 {
-  // destruction of the restrictions linked to the user
-  $query = 'DELETE FROM '.PREFIX_TABLE.'restrictions';
-  $query.= ' WHERE user_id = '.$user_id;
-  $query.= ';';
-  mysql_query( $query );
-		
+  // destruction of the access linked to the user
+  $query = 'DELETE FROM '.PREFIX_TABLE.'user_access';
+  $query.= ' WHERE user_id = '.$user_id;
+  $query.= ';';
+  mysql_query( $query );
+
+  // destruction of the group links for this user
+  $query = 'DELETE FROM '.PREFIX_TABLE.'user_group';
+  $query.= ' WHERE user_id = '.$user_id;
+  $query.= ';';
+  mysql_query( $query );
+
   // destruction of the favorites associated with the user
   $query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
+  $query.= ' WHERE user_id = '.$user_id;
+  $query.= ';';
+  mysql_query( $query );
+
+  // destruction of the sessions linked with the user
+  $query = 'DELETE FROM '.PREFIX_TABLE.'sessions';
   $query.= ' WHERE user_id = '.$user_id;
   $query.= ';';
@@ -179,5 +197,30 @@
   mysql_query( $query );
 }
-	
+
+// delete_group deletes a group identified by its $group_id.
+// It also deletes :
+//     - all the access linked to this group
+//     - all the links between this group and any user
+function delete_group( $group_id )
+{
+  // destruction of the access linked to the group
+  $query = 'DELETE FROM '.PREFIX_TABLE.'group_access';
+  $query.= ' WHERE group_id = '.$group_id;
+  $query.= ';';
+  mysql_query( $query );
+
+  // destruction of the group links for this group
+  $query = 'DELETE FROM '.PREFIX_TABLE.'user_group';
+  $query.= ' WHERE group_id = '.$group_id;
+  $query.= ';';
+  mysql_query( $query );
+
+  // destruction of the group
+  $query = 'DELETE FROM '.PREFIX_TABLE.'groups';
+  $query.= ' WHERE id = '.$group_id;
+  $query.= ';';
+  mysql_query( $query );
+}
+
 // The check_favorites function deletes all the favorites of a user if he is
 // not allowed to see them (the category or an upper category is restricted
Index: /trunk/admin/include/isadmin.inc.php
===================================================================
--- /trunk/admin/include/isadmin.inc.php	(revision 20)
+++ /trunk/admin/include/isadmin.inc.php	(revision 21)
@@ -15,11 +15,9 @@
  *                                                                         *
  ***************************************************************************/
-define( PREFIXE_INCLUDE, '.' );
+define( PREFIX_INCLUDE, '.' );
 
 include_once( '../include/config.inc.php' );
 include_once( '../include/user.inc.php' );
 include( './include/functions.php' );
-
-$conf['lien_puce'] = $conf['repertoire_image'].'puce.gif';
 
 $isadmin = true;
Index: unk/admin/perm.php
===================================================================
--- /trunk/admin/perm.php	(revision 20)
+++ 	(revision )
@@ -1,270 +1,0 @@
-<?php
-/***************************************************************************
- *                     perm.php is a part of PhpWebGallery                 *
- *                            -------------------                          *
- *   last update          : Tuesday, July 16, 2002                         *
- *   email                : pierrick@z0rglub.com                           *
- *                                                                         *
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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;                                         *
- *                                                                         *
- ***************************************************************************/
-	include_once( "./include/isadmin.inc.php" );
-	//---------------------------------------------------données de l'utilisateur
-	if ( isset( $HTTP_GET_VARS['user_id'] ) )
-	{
-		$query = "select id,pseudo,status from PREFIX_TABLE"."users where id = '".$HTTP_GET_VARS['user_id']."';";
-		$result = mysql_query( $query );
-		$row = mysql_fetch_array( $result );
-		$page['pseudo'] = $row['pseudo'];
-		$page['status'] = $row['status'];
-		if ( mysql_num_rows( $result ) == 0 )
-		{
-			echo"<div class=\"erreur\">".$lang['user_err_unknown']."</div>";
-			$erreur = true;
-		}
-		if ( $row['pseudo'] == $conf['webmaster'] )
-		{
-			echo"<div class=\"erreur\">".$lang['user_err_modify']."</div>";
-			$erreur = true;
-		}
-	}
-	//---------------------------------------------------données de la catégorie
-	if ( isset( $HTTP_GET_VARS['cat_id'] ) )
-	{
-		$HTTP_GET_VARS['cat'] = $HTTP_GET_VARS['cat_id'];
-		check_cat_id( $HTTP_GET_VARS['cat_id'] );
-		if ( isset( $page['cat'] ) )
-		{
-			$result = get_cat_info( $page['cat'] );
-			$page['cat_name'] = $result['name'];
-			$page['id_uppercat'] = $result['id_uppercat'];
-		}
-	}
-	//--------------------------------------------------------------- mise à jour
-	if ( isset( $HTTP_POST_VARS['submit'] ) )
-	{
-		if ( isset( $HTTP_GET_VARS['user_id'] ) )
-		{
-			mysql_query ( "delete from PREFIX_TABLE"."restrictions where user_id = ".$HTTP_GET_VARS['user_id'].";" );
-			$result = mysql_query ( "select id from PREFIX_TABLE"."categories;" );
-			while ( $row = mysql_fetch_array ( $result ) )
-			{
-				$nom_select = "acces-".$row['id'];
-				if ( $HTTP_POST_VARS[$nom_select] == 1 )
-				{
-					mysql_query ( "insert into PREFIX_TABLE"."restrictions (user_id,cat_id) values ('".$HTTP_GET_VARS['user_id']."','".$row['id']."');" );
-				}
-			}
-			check_favorites( $HTTP_GET_VARS['user_id'] );
-			echo "<div class=\"info\">".$lang['permuser_info_message']." [ <a href=\"".add_session_id_to_url( "./admin.php?page=liste_users" )."\">".$lang['adduser_info_back']."</a> ]</div>";
-		}
-		else if ( isset( $HTTP_GET_VARS['cat_id'] ) )
-		{
-			mysql_query ( "delete from PREFIX_TABLE"."restrictions where cat_id = '".$page['cat']."';" );
-			$result = mysql_query( "select id from PREFIX_TABLE"."users where pseudo != '".$conf['webmaster']."';" );
-			while ( $row = mysql_fetch_array ( $result ) )
-			{
-				$nom_select = "acces-".$row['id'];
-				if ( $HTTP_POST_VARS[$nom_select] == 1 )
-				{
-					mysql_query ( "insert into PREFIX_TABLE"."restrictions (user_id,cat_id) values ('".$row['id']."','".$page['cat']."');" );
-				}
-				check_favorites( $row['id'] );
-			}
-			echo "<div class=\"info\">".$lang['permuser_info_message']." [ <a href=\"".add_session_id_to_url( "./admin.php?page=cat" )."\">".$lang['editcat_back']."</a> ]</div>";
-		}
-	}
-	//--------------------------------------------------------------- formulaire
-	function display_cat_manager( $id_uppercat, $indent, $uppercat_authorized, $level, $restriction )
-	{
-		global PREFIX_TABLE,$lang,$conf;
-		
-		$output = "";
-		
-		// will we use <th> or <td> lines ?
-		if ( $level == 0 )
-		{
-			$start_line = "<th ";
-			$start_line2 = "<th ";
-			$end_line = "</th>";
-		}
-		else
-		{
-			$start_line = "<td ";
-			$end_line = "</td>";
-			if ( $level == 1 )
-			{
-				$start_line2 = "<td class=\"row1\" ";
-			}
-			else if ( $level == 2 )
-			{
-				$start_line2 = "<td class=\"row2\" ";
-			}
-			else if ( $level == 3 )
-			{
-				$start_line2 = "<td class=\"row3\" ";
-			}
-			else if ( $level == 4 )
-			{
-				$start_line2 = "<td class=\"row4\" ";
-			}
-			else
-			{
-				$start_line2 = "<td ";
-			}
-		}
-		
-		$query = "select id,name,dir,rank";
-		$query.= " from PREFIX_TABLE"."categories";
-		if ( !is_numeric( $id_uppercat ) )
-		{
-			$query.= " where id_uppercat is NULL";
-		}
-		else
-		{
-			$query.= " where id_uppercat = $id_uppercat";
-		}
-		$query.= " order by rank asc;";
-		$result = mysql_query( $query );
-		while ( $row = mysql_fetch_array( $result ) )
-		{
-			$subcat_authorized = true;
-			
-			$output.= "\n<tr>";
-			$output.= "\n\t".$start_line."style=\"width:85%;text-align:left;\">$indent<img src=\"".$conf['lien_puce']."\" alt=\"&gt;\" />&nbsp;";
-			if ( in_array( $row['id'], $restriction ) || !$uppercat_authorized )
-			{
-				$subcat_authorized = false;
-				$color = "red";
-			}
-			else
-			{
-				$color = "green";
-			}
-			$output.= "<span style=\"color:$color;\">";
-			if ( $row['name'] == "" )
-			{
-				$output.= str_replace( "_", " ", $row['dir'] );
-			}
-			else
-			{
-				$output.= $row['name'];
-			}
-			$output.= " [ dir : ".$row['dir']." ]";
-			$output.= "</span>".$end_line;
-			$output.= "\n\t".$start_line2." style=\"width:15%;white-space:nowrap;text-align:right;font-weight:normal;\">";
-			$output.= "\n\t\t<input type=\"radio\" name=\"acces-".$row['id']."\" value=\"0\" checked=\"checked\"/>".$lang['permuser_authorized'];
-			$output.= "\n\t\t<input type=\"radio\" name=\"acces-".$row['id']."\" value=\"1\"";
-			if ( in_array( $row['id'], $restriction ) )
-			{
-				$output.= " checked=\"checked\"";
-			}
-			$output.= "/>".$lang['permuser_forbidden'];
-			$output.= $end_line;
-			$output.= "\n<tr>";
-			$output.= display_cat_manager( $row['id'], $indent."&nbsp;&nbsp;&nbsp;&nbsp;", $subcat_authorized, $level + 1, $restriction );
-		}
-		return $output;
-	}
-	
-	if ( !$erreur )
-	{
-		//----------------------------------------------
-		// cas 1 : permissions pour un utilisateur donné
-		if ( isset( $HTTP_GET_VARS['user_id'] ) )
-		{
-			echo"
-			<table style=\"width:100%;\">
-				<tr>
-					<th>".$lang['permuser_title']." \"".$page['pseudo']."\"</th>
-				</tr>
-			</table>";
-			$restriction = get_restrictions( $HTTP_GET_VARS['user_id'], $page['status'], false );
-			echo"
-			<form action=\"".add_session_id_to_url( "./admin.php?page=perm&amp;user_id=".$HTTP_GET_VARS['user_id'] )."\" method=\"post\">
-				<div style=\"color:darkblue;margin:10px;text-align:center;\">".$lang['permuser_warning']."</div>
-				<table style=\"width:100%;\">";
-
-			echo display_cat_manager( "NULL", "&nbsp;&nbsp;&nbsp;&nbsp;", true, 0, $restriction );
-
-			echo"
-					<tr>
-						<td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"".$lang['submit']."\"/></td>
-					</tr>
-				<table>
-			</form>";
-		}
-		//----------------------------------------------
-		// cas 2 : permissions pour une catégorie donnée
-		else if ( isset( $HTTP_GET_VARS['cat_id'] ) )
-		{
-			echo"
-			<table style=\"width:100%;\">
-				<tr>
-					<th>".$lang['permuser_cat_title']."\"".get_cat_display_name( $page['cat_name'], " - ", "font-style:italic;" )."\"</th>
-				</tr>
-			</table>";
-			echo"
-			<form action=\"".add_session_id_to_url( "./admin.php?page=perm&amp;cat_id=".$page['cat'] )."\" method=\"post\">
-				<table style=\"width:100%;\">";
-			
-			$result = mysql_query( "select id,pseudo,status from PREFIX_TABLE"."users where pseudo != '".$conf['webmaster']."';" );
-			$i = 0;
-			while ( $row = mysql_fetch_array( $result ) )
-			{
-				$restrictions = get_restrictions( $row['id'], $row['status'], false );
-				$is_user_allowed = is_user_allowed( $page['cat'], $restrictions );
-				$class = "";
-				if ( $i%2 == 1 )
-				{
-					$class = "class=\"row2\"";
-				}
-				echo"
-					<tr>
-						<td $class><a href=\"".add_session_id_to_url( "./admin.php?page=perm&amp;user_id=".$row['id'] )."\">";
-				echo "<span style=\"color:";
-				if ( $is_user_allowed > 0 )
-				{
-					echo "red";
-				}
-				else
-				{
-					echo "green";
-				}
-				echo "\">".$row['pseudo']."</span></a></td>
-						<td $class style=\"text-align:right;\">";
-				if ( $is_user_allowed == 2 )
-				{
-					echo "<a href=\"".add_session_id_to_url( "./admin.php?page=perm&amp;cat_id=".$page['id_uppercat'] )."\"><span style=\"color:red;\">".$lang['permuser_parent_forbidden']."</span></a>";
-				}
-				else
-				{
-					echo"
-							<input type=\"radio\" name=\"acces-".$row['id']."\" value=\"0\" checked=\"checked\"/>".$lang['permuser_authorized']."
-							<input type=\"radio\" name=\"acces-".$row['id']."\" value=\"1\"";
-					if ( $is_user_allowed == 1 )
-					{
-						echo" checked=\"checked\"";
-					}
-					echo"/>".$lang['permuser_forbidden'];
-				}
-				echo"
-						</td>
-					</tr>";
-				$i++;
-			}
-			echo"
-					<tr>
-						<td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"".$lang['submit']."\"/></td>
-					</tr>
-				</table>
-			</form>";
-		}
-	}
-?>
Index: /trunk/admin/user_list.php
===================================================================
--- /trunk/admin/user_list.php	(revision 20)
+++ /trunk/admin/user_list.php	(revision 21)
@@ -18,30 +18,16 @@
 //----------------------------------------------------- template initialization
 $sub = $vtp->Open( '../template/'.$user['template'].'/admin/user_list.vtp' );
-// language
-$vtp->setGlobalVar( $sub, 'listuser_confirm',  $lang['listuser_confirm'] );
-$vtp->setGlobalVar( $sub, 'listuser_modify_hint',
-                    $lang['listuser_modify_hint'] );
-$vtp->setGlobalVar( $sub, 'listuser_modify', $lang['listuser_modify'] );
-$vtp->setGlobalVar( $sub, 'listuser_permission',
-                    $lang['listuser_permission'] );
-$vtp->setGlobalVar( $sub, 'listuser_permission_hint',
-                    $lang['listuser_permission_hint'] );
-$vtp->setGlobalVar( $sub, 'listuser_delete_hint',
-                    $lang['listuser_delete_hint'] );
-$vtp->setGlobalVar( $sub, 'listuser_delete',   $lang['listuser_delete'] );
-$vtp->setGlobalVar( $sub, 'yes',               $lang['yes'] );
-$vtp->setGlobalVar( $sub, 'no',                $lang['no'] );
-$vtp->setGlobalVar( $sub, 'listuser_button_all',
-                    $lang['listuser_button_all'] );
-$vtp->setGlobalVar( $sub, 'listuser_button_invert',
-                    $lang['listuser_button_invert'] );
-$vtp->setGlobalVar( $sub, 'listuser_button_create_address',
-                    $lang['listuser_button_create_address'] );
+$tpl = array( 'listuser_confirm','listuser_modify_hint','listuser_modify',
+              'listuser_permission','listuser_permission_hint',
+              'listuser_delete_hint','listuser_delete','yes','no',
+              'listuser_button_all','listuser_button_invert',
+              'listuser_button_create_address' );
+templatize_array( $tpl, 'lang', $sub );
 //--------------------------------------------------------------- delete a user
 if ( isset ( $_GET['delete'] ) and is_numeric( $_GET['delete'] ) )
 {
-  $query = 'select username';
-  $query.= ' from '.PREFIX_TABLE.'users';
-  $query.= ' where id = '.$_GET['delete'];
+  $query = 'SELECT username';
+  $query.= ' FROM '.PREFIX_TABLE.'users';
+  $query.= ' WHERE id = '.$_GET['delete'];
   $query.= ';';
   $row = mysql_fetch_array( mysql_query( $query ) );
@@ -65,7 +51,7 @@
          and $row['username'] != $conf['webmaster'] )
     {
-      $query = 'select count(*) as nb_result';
-      $query.= ' from '.PREFIX_TABLE.'users';
-      $query.= ' where id = '.$_GET['delete'];
+      $query = 'SELECT COUNT(*) AS nb_result';
+      $query.= ' FROM '.PREFIX_TABLE.'users';
+      $query.= ' WHERE id = '.$_GET['delete'];
       $query.= ';';
       $row2 = mysql_fetch_array( mysql_query( $query ) );
@@ -103,7 +89,7 @@
   $vtp->setVar( $sub, 'users.form_action', $action );
 
-  $query = 'select id,username,status,mail_address';
-  $query.= ' from '.PREFIX_TABLE.'users';
-  $query.= ' order by status asc, username asc';
+  $query = 'SELECT id,username,status,mail_address';
+  $query.= ' FROM '.PREFIX_TABLE.'users';
+  $query.= ' ORDER BY status ASC, username ASC';
   $query.= ';';
   $result = mysql_query( $query );
@@ -123,14 +109,6 @@
       switch ( $row['status'] )
       {
-      case 'admin' :
-      {
-        $title.= $lang['adduser_status_admin'];
-        break;
-      }
-      case 'guest' :
-      {
-        $title.= $lang['adduser_status_guest'];
-        break;
-      }
+      case 'admin' : $title.= $lang['adduser_status_admin']; break;
+      case 'guest' : $title.= $lang['adduser_status_guest']; break;
       }
       $vtp->setVar( $sub, 'category.title', $title );
@@ -153,7 +131,4 @@
     {
       $vtp->setVar( $sub, 'user.color', 'green' );
-    }
-    if ( $row['username'] == 'guest' )
-    {
       $vtp->setVar( $sub, 'user.login', $lang['guest'] );
     }
@@ -180,5 +155,6 @@
     }
     // manage permission or not ?
-    if ( $row['username'] == $conf['webmaster'] )
+    if ( $row['username'] == $conf['webmaster']
+         and $user['username'] != $conf['webmaster'] )
     {
       $vtp->addSession( $sub, 'not_permission' );
@@ -188,5 +164,5 @@
     {
       $vtp->addSession( $sub, 'permission' );
-      $url = './admin.php?page=perm&amp;user_id='.$row['id'];
+      $url = './admin.php?page=user_perm&amp;user_id='.$row['id'];
       $vtp->setVar( $sub, 'permission.url', add_session_id( $url ) );
       $vtp->setVar( $sub, 'permission.login', $row['username'] );
@@ -216,7 +192,6 @@
     $mail_address = array();
     $i = 0;
-    $query = 'select';
-    $query.= ' id,mail_address';
-    $query.= ' from '.PREFIX_TABLE.'users';
+    $query = 'SELECT id,mail_address';
+    $query.= ' FROM '.PREFIX_TABLE.'users';
     $query.= ';';
     $result = mysql_query( $query );
Index: /trunk/admin/user_modify.php
===================================================================
--- /trunk/admin/user_modify.php	(revision 20)
+++ /trunk/admin/user_modify.php	(revision 21)
@@ -21,5 +21,6 @@
 $tpl = array( 'adduser_info_message', 'adduser_info_back', 'adduser_fill_form',
               'login', 'new', 'password', 'mail_address', 'adduser_status',
-              'submit', 'adduser_info_password_updated' );
+              'submit', 'adduser_info_password_updated','menu_groups',
+              'dissociate','adduser_associate' );
 templatize_array( $tpl, 'lang', $sub );
 //--------------------------------------------------------- form criteria check
@@ -35,5 +36,7 @@
 $query.= ';';
 $row = mysql_fetch_array( mysql_query( $query ) );
-
+$page['username'] = $row['username'];
+$page['status'] = $row['status'];
+$page['mail_address'] = $row['mail_address'];
 // user is not modifiable if :
 //   1. the selected user is the user "guest"
@@ -67,4 +70,32 @@
                           $_POST['password'] ) );
 }
+// association with groups management
+if ( isset( $_POST['submit'] ) )
+{
+  // deletion of checked groups
+  $query = 'SELECT id,name';
+  $query.= ' FROM '.PREFIX_TABLE.'groups';
+  $query.= ' ORDER BY id ASC';
+  $query.= ';';
+  $result = mysql_query( $query );
+  while ( $row = mysql_fetch_array( $result ) )
+  {
+    $dissociate = 'dissociate-'.$row['id'];
+    if ( $_POST[$dissociate] == 1 )
+    {
+      $query = 'DELETE FROM '.PREFIX_TABLE.'user_group';
+      $query.= ' WHERE user_id = '.$_GET['user_id'];
+      $query.= ' AND group_id ='.$row['id'];
+      $query.= ';';
+      mysql_query( $query );
+    }
+  }
+  // create a new association between the user and a group
+  $query = 'INSERT INTO '.PREFIX_TABLE.'user_group';
+  $query.= ' (user_id,group_id) VALUES';
+  $query.= ' ('.$_GET['user_id'].','.$_POST['associate'].')';
+  $query.= ';';
+  mysql_query( $query );
+}
 //-------------------------------------------------------------- errors display
 if ( sizeof( $error ) != 0 )
@@ -83,5 +114,5 @@
 {
   $vtp->addSession( $sub, 'confirmation' );
-  $vtp->setVar( $sub, 'confirmation.username', $row['username'] );
+  $vtp->setVar( $sub, 'confirmation.username', $page['username'] );
   $url = add_session_id( './admin.php?page=user_list' );
   $vtp->setVar( $sub, 'confirmation.url', $url );
@@ -92,5 +123,4 @@
     $vtp->closeSession( $sub, 'password_updated' );
   }
-  $display_form = false;
 }
 //------------------------------------------------------------------------ form
@@ -100,11 +130,13 @@
   $action = './admin.php?page=user_modify&amp;user_id='.$_GET['user_id'];
   $vtp->setVar( $sub, 'form.form_action', add_session_id( $action ) );
-  $vtp->setVar( $sub, 'form.user:username',     $row['username'] );
-  $vtp->setVar( $sub, 'form.user:password',     $_POST['password'] );
-  $vtp->setVar( $sub, 'form.user:mail_address', $_POST['mail_address'] );
-
-  if ( !isset( $_POST['status'] ) )
-  {
-    $_POST['status'] = 'guest';
+  $vtp->setVar( $sub, 'form.user:username',     $page['username'] );
+  if ( isset( $_POST['mail_address'] ) )
+  {
+    $page['mail_address'] = $_POST['mail_address'];
+  }
+  $vtp->setVar( $sub, 'form.user:mail_address', $page['mail_address'] );
+  if ( isset( $_POST['status'] ) )
+  {
+    $page['status'] = $_POST['status'];
   }
   $option = get_enums( PREFIX_TABLE.'users', 'status' );
@@ -115,5 +147,5 @@
     $vtp->setVar( $sub, 'status_option.option',
                   $lang['adduser_status_'.$option[$i]] );
-    if( $option[$i] == $_POST['status'] )
+    if( $option[$i] == $page['status'] )
     {
       $vtp->setVar( $sub, 'status_option.selected', ' selected="selected"' );
@@ -121,4 +153,47 @@
     $vtp->closeSession( $sub, 'status_option' );
   }
+  // groups linked with this user
+  $query = 'SELECT id,name';
+  $query.= ' FROM '.PREFIX_TABLE.'user_group, '.PREFIX_TABLE.'groups';
+  $query.= ' WHERE group_id = id';
+  $query.= ' AND user_id = '.$_GET['user_id'];
+  $query.= ';';
+  $result = mysql_query( $query );
+  $user_groups = array();
+  if ( mysql_num_rows( $result ) > 0 )
+  {
+    $vtp->addSession( $sub, 'groups' );
+    while ( $row = mysql_fetch_array( $result ) )
+    {
+      $vtp->addSession( $sub, 'group' );
+      $vtp->setVar( $sub, 'group.name', $row['name'] );
+      $vtp->setVar( $sub, 'group.dissociate_id', $row['id'] );
+      $vtp->closeSession( $sub, 'group' );
+      array_push( $user_groups, $row['id'] );
+    }
+    $vtp->closeSession( $sub, 'groups' );
+  }
+  // empty group not to take into account
+  $vtp->addSession( $sub, 'associate_group' );
+  $vtp->setVar( $sub, 'associate_group.value', 'undef' );
+  $vtp->setVar( $sub, 'associate_group.option', '' );
+  $vtp->closeSession( $sub, 'associate_group' );
+  // groups not linked yet to the user
+  $query = 'SELECT id,name';
+  $query.= ' FROM '.PREFIX_TABLE.'groups';
+  $query.= ' ORDER BY id ASC';
+  $query.= ';';
+  $result = mysql_query( $query );
+  while ( $row = mysql_fetch_array( $result ) )
+  {
+    if ( !in_array( $row['id'], $user_groups ) )
+    {
+      $vtp->addSession( $sub, 'associate_group' );
+      $vtp->setVar( $sub, 'associate_group.value', $row['id'] );
+      $vtp->setVar( $sub, 'associate_group.option', $row['name'] );
+      $vtp->closeSession( $sub, 'associate_group' );
+    }
+  }
+
   $url = add_session_id( './admin.php?page=user_list' );
   $vtp->setVar( $sub, 'form.url_back', $url );
Index: /trunk/admin/user_perm.php
===================================================================
--- /trunk/admin/user_perm.php	(revision 21)
+++ /trunk/admin/user_perm.php	(revision 21)
@@ -0,0 +1,174 @@
+<?php
+/***************************************************************************
+ *                               user_perm.php                             *
+ *                            ------------------                           *
+ *   application          : PhpWebGallery 1.3                              *
+ *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
+ *                                                                         *
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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;                                         *
+ *                                                                         *
+ ***************************************************************************/
+include_once( './include/isadmin.inc.php' );
+//----------------------------------------------------- template initialization
+$sub = $vtp->Open( '../template/'.$user['template'].'/admin/user_perm.vtp' );
+$error = array();
+$tpl = array( 'permuser_authorized','permuser_forbidden','submit',
+              'permuser_parent_forbidden','permuser_info_message',
+              'adduser_info_back' );
+templatize_array( $tpl, 'lang', $sub );
+//--------------------------------------------------------------------- updates
+if ( isset( $_POST['submit'] ) )
+{
+  // cleaning the user_access table for this user
+  $query = 'DELETE FROM '.PREFIX_TABLE.'user_access';
+  $query.= ' WHERE user_id = '.$_GET['user_id'];
+  $query.= ';';
+  mysql_query( $query );
+  // selecting all private categories
+  $query = 'SELECT id';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  $query.= " WHERE status = 'private'";
+  $query.= ';';
+  $result = mysql_query( $query );
+  while ( $row = mysql_fetch_array( $result ) )
+  {
+    $radioname = 'access-'.$row['id'];
+    if ( $_POST[$radioname] == 0 )
+    {
+      $query = 'INSERT INTO '.PREFIX_TABLE.'user_access';
+      $query.= ' (user_id,cat_id) VALUES';
+      $query.= ' ('.$_GET['user_id'].','.$row['id'].')';
+      $query.= ';';
+      mysql_query ( $query );
+    }
+  }
+  check_favorites( $_GET['user_id'] );
+  $vtp->addSession( $sub, 'confirmation' );
+  $url = './admin.php?page=user_list';
+  $vtp->setVar( $sub, 'confirmation.back_url', add_session_id( $url ) );
+  $vtp->closeSession( $sub, 'confirmation' );
+}
+//---------------------------------------------------------------- form display
+$restrictions = get_restrictions( $_GET['user_id'], $page['user_status'],
+                                  false, false );
+$action = './admin.php?page=user_perm&amp;user_id='.$_GET['user_id'];
+$vtp->setVar( $sub, 'action', add_session_id( $action ) );
+// Association of group_ids with group_names -> caching informations
+$query = 'SELECT id,name';
+$query.= ' FROM '.PREFIX_TABLE.'groups';
+$query.= ';';
+$result = mysql_query( $query );
+$groups = array();
+while ( $row = mysql_fetch_array( $result ) )
+{
+  $groups[$row['id']] = $row['name'];
+}
+// Listing of groups the user belongs to
+$query = 'SELECT ug.group_id as groupid';
+$query.= ' FROM '.PREFIX_TABLE.'user_group as ug';
+$query.= ' WHERE user_id = '.$_GET['user_id'];
+$query.= ';';
+$result = mysql_query( $query );
+$usergroups = array();
+while ( $row = mysql_fetch_array( $result ) )
+{
+  array_push( $usergroups, $row['groupid'] );
+}
+// only private categories are listed
+$query = 'SELECT id';
+$query.= ' FROM '.PREFIX_TABLE.'categories';
+$query.= " WHERE status = 'private'";
+$query.= ';';
+$result = mysql_query( $query );
+while ( $row = mysql_fetch_array( $result ) )
+{
+  $vtp->addSession( $sub, 'category' );
+  $vtp->setVar( $sub, 'category.id', $row['id'] );
+  // we have to know whether the user is authorized to access this
+  // category. The category can be accessible for this user thanks to his
+  // personnal access rights OR thanks to the access rights of a group he
+  // belongs to.
+  // 1. group access :
+  //    retrieving all authorized groups for this category and for this user
+  $query = 'SELECT ga.group_id as groupid';
+  $query.= ' FROM '.PREFIX_TABLE.'group_access as ga';
+  $query.= ', '.PREFIX_TABLE.'user_group as ug';
+  $query.= ' WHERE ga.group_id = ug.group_id';
+  $query.= ' AND ug.user_id = '.$_GET['user_id'];
+  $query.= ' AND cat_id = '.$row['id'];
+  $query.= ';';
+  $subresult = mysql_query( $query );
+  $authorized_groups = array();
+  while ( $subrow = mysql_fetch_array( $subresult ) )
+  {
+    array_push( $authorized_groups, $subrow['groupid'] );
+  }
+  // 2. personnal access
+  $is_user_allowed = is_user_allowed( $row['id'], $restrictions );
+  // link to the category permission management
+  $url = './admin.php?page=cat_perm&amp;cat_id='.$row['id'];
+  $vtp->setVar( $sub, 'category.cat_perm_link', add_session_id( $url ) );
+  // color of the category : green if the user is allowed by himself or
+  // thanks to a group he belongs to
+  if ( $is_user_allowed == 0 or count( $authorized_groups ) > 0 )
+  {
+    $vtp->setVar( $sub, 'category.color', 'green' );
+  }
+  else
+  {
+    $vtp->setVar( $sub, 'category.color', 'red' );
+  }
+  // category name
+  $cat_infos = get_cat_info( $row['id'] );
+  $name = get_cat_display_name( $cat_infos['name'],' &gt; ',
+                                'font-weight:bold;' );
+  $vtp->setVar( $sub, 'category.name', $name );
+  // usergroups
+  if ( count( $usergroups ) > 0 )
+  {
+    $vtp->addSession( $sub, 'usergroups' );
+    foreach ( $usergroups as $i => $usergroup ) {
+      $vtp->addSession( $sub, 'usergroup' );
+      $vtp->setVar( $sub, 'usergroup.name', $groups[$usergroup] );
+      if ( in_array( $usergroup, $authorized_groups ) )
+      {
+        $vtp->setVar( $sub, 'usergroup.color', 'green' );
+      }
+      else
+      {
+        $vtp->setVar( $sub, 'usergroup.color', 'red' );
+      }
+      if ( $i < count( $usergroups ) - 1 )
+      {
+        $vtp->setVar( $sub, 'usergroup.separation', ',' );
+      }
+      $vtp->closeSession( $sub, 'usergroup' );
+    }
+    $vtp->closeSession( $sub, 'usergroups' );
+  }
+  // any subcat forbidden for this user ?
+  if ( $is_user_allowed == 2 )
+  {
+    $vtp->addSession( $sub, 'parent_forbidden' );
+    $vtp->closeSession( $sub, 'parent_forbidden' );
+  }
+  // personnal forbidden or authorized access ?
+  if ( $is_user_allowed == 0 )
+  {
+    $vtp->setVar( $sub, 'category.authorized_checked', ' checked="checked"' );
+  }
+  else
+  {
+    $vtp->setVar( $sub, 'category.forbidden_checked', ' checked="checked"' );
+  }
+  $vtp->closeSession( $sub, 'category' );
+}
+//----------------------------------------------------------- sending html code
+$vtp->Parse( $handle , 'sub', $sub );
+?>
Index: /trunk/include/config.inc.php
===================================================================
--- /trunk/include/config.inc.php	(revision 20)
+++ /trunk/include/config.inc.php	(revision 21)
@@ -21,6 +21,6 @@
 $lang = array();
 
-include_once( PREFIXE_INCLUDE.'./include/functions.inc.php' );
-include_once( PREFIXE_INCLUDE.'./include/vtemplate.class.php' );
+include_once( PREFIX_INCLUDE.'./include/functions.inc.php' );
+include_once( PREFIX_INCLUDE.'./include/vtemplate.class.php' );
 
 // How to change the order of display for images in a category ?
Index: /trunk/include/functions.inc.php
===================================================================
--- /trunk/include/functions.inc.php	(revision 20)
+++ /trunk/include/functions.inc.php	(revision 21)
@@ -19,4 +19,5 @@
 include( 'functions_category.inc.php' );
 include( 'functions_xml.inc.php' );
+include( 'functions_group.inc.php' );
 
 //----------------------------------------------------------- generic functions
@@ -320,13 +321,15 @@
 function database_connection()
 {
-  // $cfgHote,$cfgUser,$cfgPassword,$cfgBase;
-
-  $xml_content = getXmlCode( PREFIXE_INCLUDE.'./include/database_config.xml' );
-  $mysql_conf = getChild( $xml_content, 'mysql' );
-
-  $cfgHote     = getAttribute( $mysql_conf, 'host' );
-  $cfgUser     = getAttribute( $mysql_conf, 'user' );
-  $cfgPassword = getAttribute( $mysql_conf, 'password' );
-  $cfgBase     = getAttribute( $mysql_conf, 'base' );
+//   $xml_content = getXmlCode( PREFIXE_INCLUDE.'./include/database_config.xml' );
+//   $mysql_conf = getChild( $xml_content, 'mysql' );
+
+//   $cfgHote     = getAttribute( $mysql_conf, 'host' );
+//   $cfgUser     = getAttribute( $mysql_conf, 'user' );
+//   $cfgPassword = getAttribute( $mysql_conf, 'password' );
+//   $cfgBase     = getAttribute( $mysql_conf, 'base' );
+//   define( PREFIX_TABLE, getAttribute( $mysql_conf, 'tablePrefix' ) );
+
+  include( PREFIX_INCLUDE.'./include/mysql.inc.php' );
+  define( PREFIX_TABLE, $prefix_table );
 
   @mysql_connect( $cfgHote, $cfgUser, $cfgPassword )
@@ -334,6 +337,4 @@
   @mysql_select_db( $cfgBase )
     or die ( "Could not connect to database" );
-
-  define( PREFIX_TABLE, getAttribute( $mysql_conf, 'tablePrefix' ) );
 }
 
Index: /trunk/include/functions_category.inc.php
===================================================================
--- /trunk/include/functions_category.inc.php	(revision 20)
+++ /trunk/include/functions_category.inc.php	(revision 21)
@@ -15,25 +15,23 @@
  *                                                                         *
  ***************************************************************************/
+
 function get_subcats_id( $cat_id )
 {
-  $restricted_cat = array();
-  $i = 0;
+  $restricted_cats = array();
                 
-  $query = 'select id';
-  $query.= ' from '.PREFIX_TABLE.'categories';
-  $query.= ' where id_uppercat = '.$cat_id;
+  $query = 'SELECT id';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  $query.= ' WHERE id_uppercat = '.$cat_id;
   $query.= ';';
   $result = mysql_query( $query );
   while ( $row = mysql_fetch_array( $result ) )
   {
-    $restricted_cat[$i++] = $row['id'];
-    $sub_restricted_cat = get_subcats_id( $row['id'] );
-    for ( $j = 0; $j < sizeof( $sub_restricted_cat ); $j++ )
-    {
-      $restricted_cat[$i++] = $sub_restricted_cat[$j];
-    }
-  }
-                
-  return $restricted_cat;
+    array_push( $restricted_cats, $row['id'] );
+    $sub_restricted_cats = get_subcats_id( $row['id'] );
+    foreach ( $sub_restricted_cats as $sub_restricted_cat ) {
+      array_push( $restricted_cats, $sub_restricted_cat );
+    }
+  }
+  return $restricted_cats;
 }
 
Index: /trunk/include/functions_group.inc.php
===================================================================
--- /trunk/include/functions_group.inc.php	(revision 21)
+++ /trunk/include/functions_group.inc.php	(revision 21)
@@ -0,0 +1,104 @@
+<?php
+/***************************************************************************
+ *                           functions_group.inc.php                       *
+ *                            --------------------                         *
+ *   application          : PhpWebGallery 1.3                              *
+ *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
+ *                                                                         *
+ ***************************************************************************
+
+ ***************************************************************************
+ *                                                                         *
+ *   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;                                         *
+ *                                                                         *
+ ***************************************************************************/
+
+// get_group_restrictions returns an array containing all unaccessible
+// category ids.
+function get_group_restrictions( $group_id )
+{
+  // 1. retrieving ids of private categories
+  $query = 'SELECT id';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  $query.= " WHERE status = 'private'";
+  $query.= ';';
+  $result = mysql_query( $query );
+  $privates = array();
+  while ( $row = mysql_fetch_array( $result ) )
+  {
+    array_push( $privates, $row['id'] );
+  }
+  // 2. retrieving all authorized categories for the group
+  $authorized = array();
+  $query = 'SELECT cat_id';
+  $query.= ' FROM '.PREFIX_TABLE.'group_access';
+  $query.= ' WHERE group_id = '.$group_id;
+  $query.= ';';
+  $result = mysql_query( $query );
+  while ( $row = mysql_fetch_array( $result ) )
+  {
+    array_push( $authorized, $row['cat_id'] );
+  }
+
+  $forbidden = array();
+  foreach ( $privates as $private ) {
+    if ( !in_array( $private, $authorized ) )
+    {
+      array_push( $forbidden, $private );
+    }
+  }
+
+  return $forbidden;
+}
+
+// get_all_group_restrictions returns an array with ALL unaccessible
+// category ids, including sub-categories
+function get_all_group_restrictions( $group_id )
+{
+  $restricted_cats = get_group_restrictions( $group_id );
+  foreach ( $restricted_cats as $restricted_cat ) {
+    $sub_restricted_cats = get_subcats_id( $restricted_cat );
+    foreach ( $sub_restricted_cats as $sub_restricted_cat ) {
+      array_push( $restricted_cats, $sub_restricted_cat );
+    }
+  }
+  return $restricted_cats;
+}
+
+// The function is_group_allowed returns :
+//      - 0 : if the category is allowed with this $restrictions array
+//      - 1 : if this category is not allowed
+//      - 2 : if an uppercat category is not allowed
+function is_group_allowed( $category_id, $restrictions )
+{
+  $lowest_category_id = $category_id;
+                
+  $is_root = false;
+  while ( !$is_root and !in_array( $category_id, $restrictions ) )
+  {
+    $query = 'SELECT id_uppercat';
+    $query.= ' FROM '.PREFIX_TABLE.'categories';
+    $query.= ' WHERE id = '.$category_id;
+    $query.= ';';
+    $row = mysql_fetch_array( mysql_query( $query ) );
+    if ( $row['id_uppercat'] == '' )
+    {
+      $is_root = true;
+    }
+    $category_id = $row['id_uppercat'];
+  }
+                
+  if ( in_array( $lowest_category_id, $restrictions ) )
+  {
+    return 1;
+  }
+  if ( in_array( $category_id, $restrictions ) )
+  {
+    return 2;
+  }
+  // this group is allowed to go in this category
+  return 0;
+}
+?>
Index: /trunk/include/functions_user.inc.php
===================================================================
--- /trunk/include/functions_user.inc.php	(revision 20)
+++ /trunk/include/functions_user.inc.php	(revision 21)
@@ -145,20 +145,20 @@
     mysql_query( $query );
     // 3. retrieving the id of the newly created user
-    $query = 'select id';
-    $query.= ' from '.PREFIX_TABLE.'users';
-    $query.= " where username = '".$login."';";
+    $query = 'SELECT id';
+    $query.= ' FROM '.PREFIX_TABLE.'users';
+    $query.= " WHERE username = '".$login."';";
     $row = mysql_fetch_array( mysql_query( $query ) );
     $user_id = $row['id'];
-    // 4. adding restrictions to the new user, the same as the user "guest"
-    $query = 'select cat_id';
-    $query.= ' from '.PREFIX_TABLE.'restrictions as r';
+    // 4. adding access to the new user, the same as the user "guest"
+    $query = 'SELECT cat_id';
+    $query.= ' FROM '.PREFIX_TABLE.'user_access as ua';
     $query.=      ','.PREFIX_TABLE.'users as u ';
-    $query.= ' where u.id = r.user_id';
+    $query.= ' where u.id = ua.user_id';
     $query.= " and u.username = 'guest';";
     $result = mysql_query( $query );
     while( $row = mysql_fetch_array( $result ) )
     {
-      $query = 'insert into '.PREFIX_TABLE.'restrictions';
-      $query.= ' (user_id,cat_id) values';
+      $query = 'INSERT INTO '.PREFIX_TABLE.'user_access';
+      $query.= ' (user_id,cat_id) VALUES';
       $query.= ' ('.$user_id.','.$row['cat_id'].');';
       mysql_query ( $query );
@@ -182,6 +182,6 @@
   if ( sizeof( $error ) == 0 )
   {
-    $query = 'update '.PREFIX_TABLE.'users';
-    $query.= " set status = '".$status."'";
+    $query = 'UPDATE '.PREFIX_TABLE.'users';
+    $query.= " SET status = '".$status."'";
     if ( $use_new_password )
     {
@@ -197,7 +197,6 @@
       $query.= 'NULL';
     }
-    $query.= ' where id = '.$user_id;
+    $query.= ' WHERE id = '.$user_id;
     $query.= ';';
-    echo $query;
     mysql_query( $query );
   }
@@ -210,5 +209,5 @@
 
   if ( $user['is_the_guest']
-       and ( $conf['acces'] == 'restreint' or $page['cat'] == 'fav' ) )
+       and ( $conf['access'] == 'restricted' or $page['cat'] == 'fav' ) )
   {
     echo '<div style="text-align:center;">'.$lang['only_members'].'<br />';
@@ -222,34 +221,73 @@
 // If the $check_invisible parameter is set to true, invisible categories
 // are added to the restricted one in the array.
-function get_restrictions( $user_id, $user_status, $check_invisible )
-{
-  // 1. getting the ids of the restricted categories
+function get_restrictions( $user_id, $user_status,
+                           $check_invisible, $use_groups = true )
+{
+  // 1. retrieving ids of private categories
+  $query = 'SELECT id';
+  $query.= ' FROM '.PREFIX_TABLE.'categories';
+  $query.= " WHERE status = 'private'";
+  $query.= ';';
+  $result = mysql_query( $query );
+  $privates = array();
+  while ( $row = mysql_fetch_array( $result ) )
+  {
+    array_push( $privates, $row['id'] );
+  }
+  // 2. retrieving all authorized categories for the user
+  $authorized = array();
+  // 2.1. retrieving authorized categories thanks to personnal user
+  //      authorization
   $query = 'SELECT cat_id';
-  $query.= ' FROM '.PREFIX_TABLE.'restrictions';
+  $query.= ' FROM '.PREFIX_TABLE.'user_access';
   $query.= ' WHERE user_id = '.$user_id;
   $query.= ';';
   $result = mysql_query( $query );
-
-  $restriction = array();
   while ( $row = mysql_fetch_array( $result ) )
   {
-    array_push( $restriction, $row['cat_id'] );
-  }
+    array_push( $authorized, $row['cat_id'] );
+  }
+  // 2.2. retrieving authorized categories thanks to group authorization to
+  //      which the user is a member
+  if ( $use_groups )
+  {
+    $query = 'SELECT ga.cat_id';
+    $query.= ' FROM '.PREFIX_TABLE.'user_group as ug';
+    $query.= ', '.PREFIX_TABLE.'group_access as ga';
+    $query.= ' WHERE ug.group_id = ga.group_id';
+    $query.= ' AND ug.user_id = '.$user_id;
+    $query.= ';';
+    $result = mysql_query( $query );
+    while ( $row = mysql_fetch_array( $result ) )
+    {
+      array_push( $authorized, $row['cat_id'] );
+    }
+    $authorized = array_unique( $authorized );
+  }
+
+  $forbidden = array();
+  foreach ( $privates as $private ) {
+    if ( !in_array( $private, $authorized ) )
+    {
+      array_push( $forbidden, $private );
+    }
+  }
+
   if ( $check_invisible )
   {
-    // 2. adding to the restricted categories, the invisible ones
+    // 3. adding to the restricted categories, the invisible ones
     if ( $user_status != 'admin' )
     {
       $query = 'SELECT id';
       $query.= ' FROM '.PREFIX_TABLE.'categories';
-      $query.= " WHERE status = 'invisible';";
+      $query.= " WHERE visible = 'false';";
       $result = mysql_query( $query );
       while ( $row = mysql_fetch_array( $result ) )
       {
-        array_push( $restriction, $row['id'] );
-      }
-    }
-  }
-  return $restriction;
+        array_push( $forbidden, $row['id'] );
+      }
+    }
+  }
+  return array_unique( $forbidden );
 }
 
@@ -259,15 +297,12 @@
 function get_all_restrictions( $user_id, $user_status )
 {
-  $restricted_cat = get_restrictions( $user_id, $user_status, true );
-  $i = sizeof( $restricted_cat );
-  for ( $k = 0; $k < sizeof( $restricted_cat ); $k++ )
-  {
-    $sub_restricted_cat = get_subcats_id( $restricted_cat[$k] );
-    for ( $j = 0; $j < sizeof( $sub_restricted_cat ); $j++ )
-    {
-      $restricted_cat[$i++] = $sub_restricted_cat[$j];
-    }
-  }
-  return $restricted_cat;
+  $restricted_cats = get_restrictions( $user_id, $user_status, true );
+  foreach ( $restricted_cats as $restricted_cat ) {
+    $sub_restricted_cats = get_subcats_id( $restricted_cat );
+    foreach ( $sub_restricted_cats as $sub_restricted_cat ) {
+      array_push( $restricted_cats, $sub_restricted_cat );
+    }
+  }
+  return $restricted_cats;
 }
 
@@ -278,6 +313,4 @@
 function is_user_allowed( $category_id, $restrictions )
 {
-  global $user;
-                
   $lowest_category_id = $category_id;
                 
@@ -285,10 +318,10 @@
   while ( !$is_root and !in_array( $category_id, $restrictions ) )
   {
-    $query = 'select id_uppercat';
-    $query.= ' from '.PREFIX_TABLE.'categories';
-    $query.= ' where id = '.$category_id;
+    $query = 'SELECT id_uppercat';
+    $query.= ' FROM '.PREFIX_TABLE.'categories';
+    $query.= ' WHERE id = '.$category_id;
     $query.= ';';
     $row = mysql_fetch_array( mysql_query( $query ) );
-    if ( $row['id_uppercat'] == "" )
+    if ( $row['id_uppercat'] == '' )
     {
       $is_root = true;
Index: /trunk/include/functions_xml.inc.php
===================================================================
--- /trunk/include/functions_xml.inc.php	(revision 20)
+++ /trunk/include/functions_xml.inc.php	(revision 21)
@@ -19,5 +19,4 @@
 define( ATT_REG, '\w+' );
 define( VAL_REG, '[^"]*' );
-
 //------------------------------------------------------------------- functions
 // getContent returns the content of a tag
@@ -33,5 +32,5 @@
   $content = preg_replace( '/^<[^>]+>/', '', $element );
   // deleting end of the tag
-  $content = preg_replace( '/<\/\w+>$/', '', $content );
+  $content = preg_replace( '/<\/[^>]+>$/', '', $content );
   // replacing multiple instance of space character
   $content = preg_replace( '/\s+/', ' ', $content );
@@ -40,6 +39,6 @@
 }
 
-// The function get Attribute returns the value corresponding to the attribute
-// $attribute for the tag $element.
+// The function get Attribute returns the value corresponding to the
+// attribute $attribute for the tag $element.
 function getAttribute( $element, $attribute )
 {
Index: /trunk/include/init.inc.php
===================================================================
--- /trunk/include/init.inc.php	(revision 20)
+++ /trunk/include/init.inc.php	(revision 21)
@@ -15,6 +15,6 @@
  *                                                                         *
  ***************************************************************************/
-define( PREFIXE_INCLUDE, '' );
-        
+define( PREFIX_INCLUDE, '' );
+
 include_once( './include/config.inc.php' );
 include_once( './include/user.inc.php' );
Index: /trunk/include/user.inc.php
===================================================================
--- /trunk/include/user.inc.php	(revision 20)
+++ /trunk/include/user.inc.php	(revision 21)
@@ -25,5 +25,5 @@
                 'long_period', 'template' );
 
-$query_user  = 'select';
+$query_user  = 'SELECT';
 for ( $i = 0; $i < sizeof( $infos ); $i++ )
 {
@@ -38,5 +38,5 @@
   $query_user.= $infos[$i];
 }
-$query_user.= ' from '.PREFIX_TABLE.'users';
+$query_user.= ' FROM '.PREFIX_TABLE.'users';
 $query_done = false;
 $user['is_the_guest'] = false;
@@ -45,7 +45,7 @@
 {
   $page['session_id'] = $_GET['id'];
-  $query = 'select user_id,expiration,ip';
-  $query.= ' from '.PREFIX_TABLE.'sessions';
-  $query.= " where id = '".$_GET['id']."'";
+  $query = 'SELECT user_id,expiration,ip';
+  $query.= ' FROM '.PREFIX_TABLE.'sessions';
+  $query.= " WHERE id = '".$_GET['id']."'";
   $query.= ';';
   $result = mysql_query( $query );
@@ -57,6 +57,6 @@
       // deletion of the session from the database,
       // because it is out-of-date
-      $delete_query = 'delete from '.PREFIX_TABLE.'sessions';
-      $delete_query.= " where id = '".$page['session_id']."'";
+      $delete_query = 'DELETE FROM '.PREFIX_TABLE.'sessions';
+      $delete_query.= " WHERE id = '".$page['session_id']."'";
       $delete_query.= ';';
       mysql_query( $delete_query );
@@ -66,5 +66,5 @@
       if ( $_SERVER['REMOTE_ADDR'] == $row['ip'] )
       {
-        $query_user .= ' where id = '.$row['user_id'];
+        $query_user .= ' WHERE id = '.$row['user_id'];
         $query_done = true;
       }
@@ -74,5 +74,5 @@
 if ( !$query_done )
 {
-  $query_user .= ' where id = 2';
+  $query_user .= ' WHERE id = 2';
   $user['is_the_guest'] = true;
 }
@@ -83,12 +83,11 @@
 // affectation of each value retrieved in the users table into a variable
 // of the array $user.
-for ( $i = 0; $i < sizeof( $infos ); $i++ )
-{
-  $user[$infos[$i]] = $row[$infos[$i]];
+foreach ( $infos as $info ) {
+  $user[$info] = $row[$info];
   // If the field is true or false, the variable is transformed into a
   // boolean value.
-  if ( $row[$infos[$i]] == 'true' || $row[$infos[$i]] == 'false' )
+  if ( $row[$info] == 'true' or $row[$info] == 'false' )
   {
-    $user[$infos[$i]] = get_boolean( $row[$infos[$i]] );
+    $user[$info] = get_boolean( $row[$info] );
   }
 }
Index: /trunk/include/vtemplate.class.php
===================================================================
--- /trunk/include/vtemplate.class.php	(revision 20)
+++ /trunk/include/vtemplate.class.php	(revision 21)
@@ -3,370 +3,367 @@
  *			VIRTUAL-TEMPLATE
  *
- * Version : 1.3.1 Base Edition ( Juillet 2002 ) build 6
+ * Version : 1.3.2 Base Edition ( Decembre 2003 ) build 1
  *
  * Address : http://vtemplate.sourceforge.net
  * 
  * Authors: 
- *   + THIEBAUT Jean-Baptiste(J.Baptiste@leweby.com) - http://www.leweby.com .
+ *   + THIEBAUT Jean-Baptiste(J.Baptiste@leweby.com)  -  http://www.leweby.com .
  *   + CAMPANA François (fc@netouaibe.com).
  * Licence: GPL.
+ * 
+ * 
  *
- *
+ *			  
  *****************************************************************/ 
 
-if ( !isset($DEFINE_VTEMPLATE) )
-{
-  define("ALL",1);
-  define("VARTAG","{#"); // Tag d'ouverture des variables :
-                         //  vous pouvez changer ce paramètre.
-  define("VTEMPLATE_VERSION","1.3.1");
-  define("VTEMPLATE_TYPE","BA");
-  define("VTEMPLATE_BUILD","6");
-  
-  
-  class Err
-    {
-      var $msg;
-      var $titre;
-      
-      function error( $errno, $arg = "", $code = 0, $disp = 0 )
-        {
+if ( !isset($DEFINE_VTEMPLATE) ){
+define("ALL",1);
+define("VARTAG","{#"); // Tag d'ouverture des variables : vous pouvez changer ce paramètre.
+define("VTEMPLATE_VERSION","1.3.1");
+define("VTEMPLATE_TYPE","BA");
+define("VTEMPLATE_BUILD","6");
+
+
+class Err {
+var $msg;
+var $titre;
+
+function error($errno,$arg="",$code=0,$disp=0){
 // Gestion des erreurs
-          switch($errno)
-          {
-          case 1:
-            $this->titre="Erreur de session n° $code";
-            $this->msg = "La zone $arg est déjà ouverte.Avant d'ajouter une session sur cette zone, vous devez la fermer à l'aide de la fonction closeSession().<br>"	;
-            break;
-          case 2:
-            $this->titre="Erreur de session n° $code";
-            $this->msg = "Vous tentez de fermer une session de la zone $arg alors qu'aucune session pour cette zone n'existe.Pour ouvrir une session, utilisez la fonction addSession().<br>";
-            break;
-          case 3:
-            $this->titre="Erreur de session n° $code";
-            $var = $arg[1];
-            $zone = $arg[0];
-            $this->msg = "Vous essayez de valoriser la variable $var sans avoir créer de session de la zone $zone.Utilisez la fonction addSession() pour créer une session, puis setVar pour valoriser une variable.<br>";
-            break;
-          case 4:
-            $this->titre="Erreur de session n° $code";
-            $var = $arg[1];
-            $zone = $arg[0];
-            $this->msg = "La variable $var que vous souhaitez valoriser n'existe pas dans la zone $zone.<br>";
-            break;
-          case 5:
-            $this->titre="Erreur de parsing n° $code";
-            $this->msg = "Vous utilisez des caractère non autorisés pour déclarer vos zones.Vous pouvez utiliser tous les caractères à l'exception de \'{\' , \'#\' \'}\' et \'|\'.<br>";
-          break;
-        case 6:
-          $this->titre="Erreur de parsing n° $code";
-          $this->msg = "Vous ne pouvez pas utiliser le même nom ($arg)de zone plusieurs fois.<br>";
-          break;
-        case 7:
-          $this->titre="Erreur de parsing n° $code";
-          $this->msg = "Vous avez oublié de fermer la zone $arg.<br>";
-          break;
-        case 8:
-          $this->titre="Erreur de traitement n° $code";
-          $this->msg = "Le fichier template $arg est introuvable.<br>";
-          break;
-        case 9:
-          $this->titre="Erreur de traitement n° $code";
-          $this->msg = "Impossible d'ouvrir le fichier $arg.Vérifiez les droits de ce fichier.<br>";
-          break;
-        case 10:
-          $this->titre="Erreur de traitement n° $code";
-          $this->msg = "Impossible de lire le fichier template $arg.<br>";	
-          break;
-        case 11:
-          $this->titre="Erreur de traitement n° $code";
-          $this->msg = "La zone $arg est introuvable.Vérifiez la syntaxe de cette zone.<br>"; 
-          break;
-        case 12:  
-          $this->titre="Erreur de traitement n° $code";
-          $this->msg = "La variable $arg est introuvable .Vérifiez la syntaxe de la variable.<br>";	
-          break;
-        case 13:
-          $this->titre="Erreur de traitement n° $code";
-          $this->msg = "L'identifiant de fichier spécifié n'existe pas.Vérifiez les fonctions Open() de votre script.<br>";
-          break;  
-        case 14:
-          $this->titre="Erreur de traitement n° $code";
-          $var = $arg[1];
-          $file = $arg[0];
-          $this->msg = "La variable $var dans le fichier $file est introuvable.Vérifiez la syntaxe de la variable.<br>";	
-          break;  
-        case 15:
-          $this->titre="Erreur de traitement n° $code";
-          $var = $arg[2];
-          $zone = $arg[1];
-          $fichier = $arg[0];
-          $this->msg = "La variable $var dans la zone $zone du fichier $fichier est introuvable.Vérifiez la syntaxe de la variable et du nom de la zone.<br>";	
-          break; 
-        default:
-          $this->titre = "Erreur inconnue $code";	 
-          $this->msg = "Veuillez le rapporter aux auteurs de la classe.";
-        }
-        $this->titre .= ": <br>";
-        if ($disp){
-          $web = "Pour plus d'informations, consultez la <a href=\"http://www.virtual-solution.net/vtemplate/docs/debug-mod.php?version=".VTEMPLATE_VERSION."&build=".VTEMPLATE_BUILD."&type=".VTEMPLATE_TYPE."&error=$code\" target=\"_blank\">doc en ligne</a>";
-          echo "<font face=verdana size=2 color=red><u>$this->titre</u><i>$this->msg</i>$web<br><br></font>";
-        } 
-        return -1;
-      }
+switch($errno){
+  case 1:
+    $this->titre="Erreur de session n° $code";
+    $this->msg = "La zone $arg est déjà ouverte.Avant d'ajouter une session sur cette zone, vous devez la fermer à l'aide de la fonction closeSession().<br>"	;
+  break;
+  case 2:
+    $this->titre="Erreur de session n° $code";
+    $this->msg = "Vous tentez de fermer une session de la zone $arg alors qu'aucune session pour cette zone n'existe.Pour ouvrir une session, utilisez la fonction addSession().<br>";
+  break;
+  case 3:
+    $this->titre="Erreur de session n° $code";
+	$var = $arg[1];
+	$zone = $arg[0];
+    $this->msg = "Vous essayez de valoriser la variable $var sans avoir créer de session de la zone $zone.Utilisez la fonction addSession() pour créer une session, puis setVar pour valoriser une variable.<br>";
+  break;
+  case 4:
+    $this->titre="Erreur de session n° $code";
+	$var = $arg[1];
+	$zone = $arg[0];
+    $this->msg = "La variable $var que vous souhaitez valoriser n'existe pas dans la zone $zone.<br>";
+  break;
+  case 5:
+    $this->titre="Erreur de parsing n° $code";
+    $this->msg = "Vous utilisez des caractère non autorisés pour déclarer vos zones.Vous pouvez utiliser tous les caractères à l'exception de \'{\' , \'#\' \'}\' et \'|\'.<br>";
+  break;
+  case 6:
+    $this->titre="Erreur de parsing n° $code";
+    $this->msg = "Vous ne pouvez pas utiliser le même nom ($arg)de zone plusieurs fois.<br>";
+  break;
+  case 7:
+    $this->titre="Erreur de parsing n° $code";
+    $this->msg = "Vous avez oublié de fermer la zone $arg.<br>";
+  break;
+  case 8:
+    $this->titre="Erreur de traitement n° $code";
+    $this->msg = "Le fichier template $arg est introuvable.<br>";
+  break;
+  case 9:
+    $this->titre="Erreur de traitement n° $code";
+    $this->msg = "Impossible d'ouvrir le fichier $arg.Vérifiez les droits de ce fichier.<br>";
+  break;
+  case 10:
+    $this->titre="Erreur de traitement n° $code";
+    $this->msg = "Impossible de lire le fichier template $arg.<br>";	
+  break;
+  case 11:
+    $this->titre="Erreur de traitement n° $code";
+    $this->msg = "La zone $arg est introuvable.Vérifiez la syntaxe de cette zone.<br>"; 
+  break;
+  case 12:  
+    $this->titre="Erreur de traitement n° $code";
+    $this->msg = "La variable $arg est introuvable .Vérifiez la syntaxe de la variable.<br>";	
+  break;
+  case 13:
+    $this->titre="Erreur de traitement n° $code";
+    $this->msg = "L'identifiant de fichier spécifié n'existe pas.Vérifiez les fonctions Open() de votre script.<br>";
+  break;  
+  case 14:
+    $this->titre="Erreur de traitement n° $code";
+	$var = $arg[1];
+	$file = $arg[0];
+    $this->msg = "La variable $var dans le fichier $file est introuvable.Vérifiez la syntaxe de la variable.<br>";	
+  break;  
+  case 15:
+    $this->titre="Erreur de traitement n° $code";
+	$var = $arg[2];
+	$zone = $arg[1];
+	$fichier = $arg[0];
+    $this->msg = "La variable $var dans la zone $zone du fichier $fichier est introuvable.Vérifiez la syntaxe de la variable et du nom de la zone.<br>";	
+  break; 
+  default:
+	 $this->titre = "Erreur inconnue $code";	 
+     $this->msg = "Veuillez le rapporter aux auteurs de la classe.";
+}
+$this->titre .= ": <br>";
+if ($disp){
+	$web = "Pour plus d'informations, consultez la <a href=\"http://www.virtual-solution.net/vtemplate/docs/debug-mod.php?version=".VTEMPLATE_VERSION."&build=".VTEMPLATE_BUILD."&type=".VTEMPLATE_TYPE."&error=$code\" target=\"_blank\">doc en ligne</a>";
+	echo "<font face=verdana size=2 color=red><u>$this->titre</u><i>$this->msg</i>$web<br><br></font>";
+} 
+return -1;
+}
 // Fin classe
+}
+
+class Session extends err{
+
+var $name;		// Name of the session
+var $globalvar = array();  // List of global variable of the session
+var $varlist = array();  // List of var in this session
+var $subzone = array(); // list of sub-zone
+var $temp; // Generated code for the current session
+var $generated = NULL; // The final code
+var $source; // Source code
+var $used=0; // Indicates if the session contain used variable
+var $stored; // Give the filename were is stored the session
+
+function Session($name,$source,$stored){
+ $this->name = $name;
+ $this->source = $source;
+ $this->stored = $stored;
+ $this->parseVar();
+}
+
+function parseVar(){
+ // Récupération des noms des variables
+ $regle = "|".VARTAG."(.*)}|sU"; 
+ preg_match_all ($regle,$this->source,$var1);
+ // Création du tableau de variable  à partir de la liste parsée.
+ $this->varlist=@array_merge($var[1],$var1[1]);
+return 1;
+} 
+
+function init(){
+if($this->used) return $this->error(1,array($this->stored,$this->name),"SESSION1",1);
+// Reset generated code
+$this->temp = $this->source;
+$this->used = 1;
+}
+function closeSession(){
+// Check if the zone has been used.    
+if(!$this->used) return $this->error(2,array($this->stored,$this->name),"SESSION2",1);
+// Set Globals vars.
+$this->generateCode();
+$this->used=0;
+return 1;
+}
+
+function reset(){
+$this->used = 0;
+$this->generated = NULL;
+return 1;
+}
+
+function addSubZone(&$subzone){
+$this->subzone[$subzone->name] = &$subzone;
+return 1;
+}
+
+function setVar($varname,$value){
+if (!$this->used) return $this->error(3,array($this->stored,$this->name,$varname),"SESSION3",1);
+if (!in_array($varname,$this->varlist)) return $this->error(4,array($this->name,$varname),"SESSION4",1);
+$regle = "(\\".VARTAG."$varname\})";
+$this->temp = preg_replace($regle,$value,$this->temp);
+return 1;
+}
+
+function dispVar(){
+ echo "Liste variables de $this->name:<br>";
+ foreach ( $this->varlist as $vars )
+    echo "$vars <br>";
+}
+
+function setGlobalVar($varname,$value){
+$set = 0;
+if (in_array($varname,$this->varlist)){
+  // Replace the var into this session 
+  $this->globalvar[$varname]=$value;   
+  $set = 1;
+}
+  // Replace the var into sub zones
+  foreach(array_keys($this->subzone) as $subzone){
+      $set = $this->subzone[$subzone]->setGlobalVar($varname,$value) || $set;
+  }
+  return $set;
+}
+
+function replaceGlobalVar(){
+if ( count($this->globalvar) )
+foreach($this->globalvar as $varname => $value){
+  $regle = "(\\".VARTAG."$varname\})";
+  $this->temp = preg_replace($regle,$value,$this->temp);
+}
+}
+
+
+function generateCode(){
+    if ($this->used == 0) return $this->generated;
+    // Replace global var.
+	if ( count($this->globalvar) ) $this->replaceGlobalVar();
+	// Replace all unused variable by ""
+    $regle = "|\\".VARTAG."([^}]*)\}|";
+	$this->temp = preg_replace($regle,"",$this->temp);
+	// Generate the subzone(s) code
+	if(count($this->subzone)){
+	  foreach(array_keys($this->subzone) as $subzone){
+		$text = ($this->subzone[$subzone]->used) ? $this->subzone[$subzone]->generateCode() : $this->subzone[$subzone]->generated;
+		$this->temp = preg_replace("(\|$subzone\|)",$text,$this->temp); 	
+		$this->subzone[$subzone]->reset();
+	  }
     }
-
-  class Session extends err{
-
-    var $name;		// Name of the session
-    var $globalvar = array();  // List of global variable of the session
-    var $varlist = array();  // List of var in this session
-    var $subzone = array(); // list of sub-zone
-    var $temp; // Generated code for the current session
-    var $generated = NULL; // The final code
-    var $source; // Source code
-    var $used=0; // Indicates if the session contain used variable
-    var $stored; // Give the filename were is stored the session
-
-    function Session($name,$source,$stored){
-      $this->name = $name;
-      $this->source = $source;
-      $this->stored = $stored;
-      $this->parseVar();
-    }
-
-    function parseVar(){
-      // Récupération des noms des variables
-      $regle = "|".VARTAG."(.*)}|sU"; 
-      preg_match_all ($regle,$this->source,$var1);
-      // Création du tableau de variable  à partir de la liste parsée.
-      $this->varlist=@array_merge($var[1],$var1[1]);
-      return 1;
-    } 
-
-    function init(){
-      if($this->used) return $this->error(1,array($this->stored,$this->name),"SESSION1",1);
-// Reset generated code
-      $this->temp = $this->source;
-      $this->used = 1;
-    }
-    function closeSession(){
-// Check if the zone has been used.    
-      if(!$this->used) return $this->error(2,array($this->stored,$this->name),"SESSION2",1);
-// Set Globals vars.
-      $this->generateCode();
-      $this->used=0;
-      return 1;
-    }
-
-    function reset(){
-      $this->used = 0;
-      $this->generated = NULL;
-      return 1;
-    }
-
-    function addSubZone(&$subzone){
-      $this->subzone[$subzone->name] = &$subzone;
-      return 1;
-    }
-
-    function setVar($varname,$value){
-      if (!$this->used) return $this->error(3,array($this->stored,$this->name,$varname),"SESSION3",1);
-      if (!in_array($varname,$this->varlist)) return $this->error(4,array($this->name,$varname),"SESSION4",1);
-      $regle = "(\\".VARTAG."$varname\})";
-      $this->temp = preg_replace($regle,$value,$this->temp);
-      return 1;
-    }
-
-    function dispVar(){
-      echo "Liste variables de $this->name:<br>";
-      foreach ( $this->varlist as $vars )
-        echo "$vars <br>";
-    }
-
-    function setGlobalVar($varname,$value){
-      $set = 0;
-      if (in_array($varname,$this->varlist)){
-        // Replace the var into this session 
-        $this->globalvar[$varname]=$value;   
-        $set = 1;
-      }
-      // Replace the var into sub zones
-      foreach(array_keys($this->subzone) as $subzone){
-        $set = $this->subzone[$subzone]->setGlobalVar($varname,$value) || $set;
-      }
-      return $set;
-    }
-
-    function replaceGlobalVar(){
-      if ( count($this->globalvar) )
-        foreach($this->globalvar as $varname => $value){
-        $regle = "(\\".VARTAG."$varname\})";
-        $this->temp = preg_replace($regle,$value,$this->temp);
-      }
-    }
-
-
-    function generateCode(){
-      if ($this->used == 0) return $this->generated;
-      // Replace global var.
-      if ( count($this->globalvar) ) $this->replaceGlobalVar();
-      // Replace all unused variable by ""
-      $regle = "|\\".VARTAG."(.*)\}|";
-      $this->temp = preg_replace($regle,"",$this->temp);
-      // Generate the subzone(s) code
-      if(count($this->subzone)){
-        foreach(array_keys($this->subzone) as $subzone){
-          $text = ($this->subzone[$subzone]->used) ? $this->subzone[$subzone]->generateCode() : $this->subzone[$subzone]->generated;
-          $this->temp = preg_replace("(\|$subzone\|)",$text,$this->temp); 	
-          $this->subzone[$subzone]->reset();
-        }
-      }
-      $this->generated .= $this->temp;
-      return $this->generated;
-    }
-
-    function inVarList($varname){
-      return in_array($varname,$this->varlist);
-    }
+$this->generated .= $this->temp;
+return $this->generated;
+}
+
+function inVarList($varname){
+return in_array($varname,$this->varlist);
+}
 
 // Fin classe
-  }
-
-  class VTemplate_Private extends Err{
+}
+
+class VTemplate_Private extends Err{
 /****************************************
- *	   Private Class.		*
- * ***************************************/
-
-    var $sources=array(); // Sources des zones issues de la premiere partie du parsing.
-    var $sessions=array(); // Tableau de sessions
-    var $v_global=array(); // Globla var array.
+*	   Private Class.		*
+* ***************************************/
+
+var $sources=array(); // Sources des zones issues de la premiere partie du parsing.
+var $sessions=array(); // Tableau de sessions
+var $v_global=array(); // Globla var array.
 
 /****************************************************************
 	    Parsing Functions for Template files.  ( PF 1.0 )
-****************************************************************/
-
-    function getNom($code){
+ ****************************************************************/
+
+function getNom($code){
 // Retourne le premier nom de zone qu'il trouve dans le code
 
-      preg_match("(<!--VTP_([^()]+)-->)sU",$code,$reg);
+   preg_match("(<!--VTP_([^()]+)-->)sU",$code,$reg);
    
-      // Tester la présence des caratère invalides dans le nom ( | et {});
-      if (@count(explode("|",$reg[1]))>1 || @count(explode("{",$reg[1]))>1 || @count(explode("}",$reg[1]))>1) exit($this->error(5,$reg[1],"PARSE1",1));
+   // Tester la présence des caratère invalides dans le nom ( | et {});
+   if (@count(explode("|",$reg[1]))>1 || @count(explode("{",$reg[1]))>1 || @count(explode("}",$reg[1]))>1) exit($this->error(5,$reg[1],"PARSE1",1));
    
-      return @$reg[1];
-    }
-
-    function endTag($code,$nom){
+   return @$reg[1];
+}
+
+function endTag($code,$nom){
 // Renvoie TRUE(1) si le tag de fermeture est présent.
 
-      preg_match("(<!--/VTP_$nom-->)sU",$code,$reg);
-
-      return ($reg[0]!="<!--/VTP_$nom-->") ? 0 : 1;
-    }
-
-    function getSource($code,$nom,$type=0){
+   preg_match("(<!--/VTP_$nom-->)sU",$code,$reg);
+
+return ($reg[0]!="<!--/VTP_$nom-->") ? 0 : 1;
+}
+
+function getSource($code,$nom,$type=0){
 // Retourne le source de la zone de nom $nom
 
-      preg_match_all ("(<!--VTP_$nom-->(.*)<!--/VTP_$nom-->)sU",$code,$reg);
-
-      return $reg[$type][0];
-    }
-
-    function parseZone($code_source,$nom_zone="|root|"){
+   preg_match_all ("(<!--VTP_$nom-->(.*)<!--/VTP_$nom-->)sU",$code,$reg);
+
+return $reg[$type][0];
+}
+
+function parseZone($code_source,$nom_zone="|root|"){
 // Fonction récursive de parsing du fichier template
-      // Vérification que la zone n'existe pas
-      if (isset($this->sources[$nom_zone])) exit($this->error(6,$nom_zone,"PARSE2",1));
-
-      // Enregistrement du code source
-      $this->sources[$nom_zone]["source"]=$code_source;
-
-      // Rappel de la fonction pour chaque fils.
-      while($nom_fils=$this->getNom($this->sources[$nom_zone]["source"])){
-
-        // Vérification que le tag de fin est présent.
-        if (!$this->endTag($code_source,$nom_fils)) exit($this->error(7,$nom_fils,"PARSE3",1));
-
-        // Parse le fils
-        $this->parseZone($this->getSource($this->sources[$nom_zone]["source"],$nom_fils,1),$nom_fils);
-
-        // Enregistre le nom du fils dans la liste des fils
-        $this->sources[$nom_zone]["fils"][]=$nom_fils;
-
-        // Remplace le code du fils dans le source du père
-        $this->sources[$nom_zone]["source"]=str_replace(
-          $this->getSource($this->sources[$nom_zone]["source"],$nom_fils,0),
-          "|$nom_fils|",
-          $this->sources[$nom_zone]["source"]
-          );
-        // Teste si la zone $nom_fils n'existe pas plusieurs fois dans la zone $nom_zone
-        if (count(explode("|$nom_fils|",$this->sources[$nom_zone]["source"]))>2) exit($this->error(6,$nom_fils,"PARSE4",1));
-      }// fin While
-
-      return 1;
-    }
+   // Vérification que la zone n'existe pas
+   if (isset($this->sources[$nom_zone])) exit($this->error(6,$nom_zone,"PARSE2",1));
+
+   // Enregistrement du code source
+   $this->sources[$nom_zone]["source"]=$code_source;
+
+   // Rappel de la fonction pour chaque fils.
+   while($nom_fils=$this->getNom($this->sources[$nom_zone]["source"])){
+
+     // Vérification que le tag de fin est présent.
+     if (!$this->endTag($code_source,$nom_fils)) exit($this->error(7,$nom_fils,"PARSE3",1));
+
+     // Parse le fils
+     $this->parseZone($this->getSource($this->sources[$nom_zone]["source"],$nom_fils,1),$nom_fils);
+
+     // Enregistre le nom du fils dans la liste des fils
+     $this->sources[$nom_zone]["fils"][]=$nom_fils;
+
+     // Remplace le code du fils dans le source du père
+     $this->sources[$nom_zone]["source"]=str_replace(
+				     $this->getSource($this->sources[$nom_zone]["source"],$nom_fils,0),
+				     "|$nom_fils|",
+				     $this->sources[$nom_zone]["source"]
+				     );
+     // Teste si la zone $nom_fils n'existe pas plusieurs fois dans la zone $nom_zone
+     if (count(explode("|$nom_fils|",$this->sources[$nom_zone]["source"]))>2) exit($this->error(6,$nom_fils,"PARSE4",1));
+   }// fin While
+
+return 1;
+}
 
 /****************************************************************
 	    Session Management functions ( SMF 1.0 )
-****************************************************************/
-
-    function createSession($handle,$zone = "|root|"){
+ ****************************************************************/
+
+function createSession($handle,$zone = "|root|"){
 // Create a new session of the zone
-      $this->sessions[$handle][$zone] = new Session($zone,$this->sources[$zone]["source"],$this->file_name[$handle]);
+$this->sessions[$handle][$zone] = new Session($zone,$this->sources[$zone]["source"],$this->file_name[$handle]);
 
 // Create sub-zone
-      if (@count($this->sources[$zone]["fils"])){
-        foreach($this->sources[$zone]["fils"] as $subzone){	  
-          $this->createSession($handle,$subzone);
-          $this->sessions[$handle][$zone]->addSubZone($this->sessions[$handle][$subzone]);
-        }
-      }
+if (@count($this->sources[$zone]["fils"])){
+   foreach($this->sources[$zone]["fils"] as $subzone){	  
+    $this->createSession($handle,$subzone);
+    $this->sessions[$handle][$zone]->addSubZone($this->sessions[$handle][$subzone]);
+   }
+}
 				  
 //end createSession
-    }
+}
 
 
 /****************************************************************
 	    Global Variable Management Functions ( GVMF 1.0 )
-****************************************************************/
-
-    function setGZone($handle,$zone,$var,$value){
-      // Define Global var for $zone and its sub-zone.
-      // Set global value to $zone vars.
-      return $this->sessions[$handle][$zone]->setGlobalVar($var,$value);
-    }
-
-    function setGFile($handle,$var,$value) {
-      return $this->sessions[$handle]["|root|"]->setGlobalVar($var,$value);
-    }
-
-    function setGAll($var,$value){
-      $declare = 0;
-      $this->v_global[$var]=$value;
-      if (is_array($this->sessions)){
-        foreach($this->sessions as $handle => $v){
-          $declare = $this->setGFile($handle,$var,$value) || $declare;
-        }	
-      } 
-      return $declare;
-    }
-
-    function setGOpened($handle){
+ ****************************************************************/
+
+ function setGZone($handle,$zone,$var,$value){
+ // Define Global var for $zone and its sub-zone.
+   // Set global value to $zone vars.
+  return $this->sessions[$handle][$zone]->setGlobalVar($var,$value);
+}
+
+function setGFile($handle,$var,$value) {
+  return $this->sessions[$handle]["|root|"]->setGlobalVar($var,$value);
+}
+
+function setGAll($var,$value){
+$declare = 0;
+$this->v_global[$var]=$value;
+if (is_array($this->sessions)){
+    foreach($this->sessions as $handle => $v){
+		$declare = $this->setGFile($handle,$var,$value) || $declare;
+		}	
+  } 
+return $declare;
+}
+
+function setGOpened($handle){
 // Set Global var into the opened file
-      foreach($this->v_global as $name => $val){
-        $this->setGFile($handle,$name,$val);
-      }
-      return 1;
-    }
+foreach($this->v_global as $name => $val){
+  $this->setGFile($handle,$name,$val);
+}
+return 1;
+}
  
 // Fin VTemplate_Private
-  }
-
-
-  class VTemplate extends VTemplate_Private{
+}
+
+
+class VTemplate extends VTemplate_Private{
 /****************************************
- *	   Public Class.		*
- * ***************************************/
+*	   Public Class.		*
+* ***************************************/
 
 
@@ -376,144 +373,232 @@
 
 
-    function Open($nomfichier){
+function Open($nomfichier){
 // Ouverture d'un fichier source et retourne le handle de ce fichier
 // Création du handle:
-      $handle =  "{".count($this->sessions)."}" ;
+$handle =  "{".count($this->sessions)."}" ;
 
 
 // Récupération du source à parser
-      if (!@file_exists($nomfichier)) return $this->error(8,$nomfichier,"TTT1",1);
-      if (!$f_id=@fopen($nomfichier,"r")) return $this->error(9,$nomfichier,"TTT2",1);
-      if (!$source=@fread($f_id, filesize($nomfichier))) return $this->error(10,$nomfichier,"TTT3",1);
-      clearstatcache();
-      fclose($f_id);
+if (!@file_exists($nomfichier)) return $this->error(8,$nomfichier,"TTT1",1);
+if (!$f_id=@fopen($nomfichier,"r")) return $this->error(9,$nomfichier,"TTT2",1);
+if (!$source=@fread($f_id, filesize($nomfichier))) return $this->error(10,$nomfichier,"TTT3",1);
+clearstatcache();
+fclose($f_id);
 
 // Store the filename
-      $this->file_name[$handle]=$nomfichier;
+$this->file_name[$handle]=$nomfichier;
 
 // Parse les zones
-      $this->parseZone($source);
+$this->parseZone($source);
 
 // Création du tableau de session
-      $this->createSession($handle);
+$this->createSession($handle);
 
 //Nettoyage des variables temporaires
-      $this->sources=NULL;
+$this->sources=NULL;
 
 // Set global var.
-      $this->setGOpened($handle);
-
-      $this->addSession($handle);
-      return $handle;
-    }
-
-    function newSession($handle="{0}",$nom_zone = "|root|"){
-      if ( $this->sessions[$handle][$nom_zone]->used ) $this->closeSession($handle,$nom_zone);
-      $this->addSession($handle,$nom_zone,$cache,$time,$num_session);
-      return 1;
-    }
-
-    function addSession($handle="{0}",$nom_zone = "|root|"){
-      // Does the zone exist ?
-      if(!isset($this->sessions[$handle][$nom_zone])) return $this->error(11,array($nom_zone,$this->file_name[$handle]),"TTT4",1);   
-      $this->sessions[$handle][$nom_zone]->init();
-      return 1;
-    }
-
-    function closeSession($handle="{0}",$nom_zone = "|root|"){ 
+$this->setGOpened($handle);
+
+$this->addSession($handle);
+return $handle;
+}
+
+function newSession($handle="{0}",$nom_zone = "|root|"){
+if ( $this->sessions[$handle][$nom_zone]->used ) $this->closeSession($handle,$nom_zone);
+$this->addSession($handle,$nom_zone,$cache,$time,$num_session);
+return 1;
+}
+
+function addSession($handle="{0}",$nom_zone = "|root|"){
+	// Does the zone exist ?
+   if(!isset($this->sessions[$handle][$nom_zone])) return $this->error(11,array($nom_zone,$this->file_name[$handle]),"TTT4",1);   
+   $this->sessions[$handle][$nom_zone]->init();
+   return 1;
+}
+
+function closeSession($handle="{0}",$nom_zone = "|root|"){ 
 // Close the current session and all his sub-session
-      // Check if the zone exists.
-      if(!isset($this->sessions[$handle][$nom_zone])) return $this->error(11,array($nom_zone,$this->file_name[$handle]),"TTT5",1);
-      // Closing sub-zone
-      $this->sessions[$handle][$nom_zone]->closeSession();	
-      return 1;
-    }
-
-    function setGlobalVar($arg1,$arg2,$arg3){
-      if ($arg1 == 1){
-        if (!$this->setGAll($arg2,$arg3)) return $this->error(12,$arg2,"TTT6",1);
-        return 1; 
-      }
-      if (!isset($this->sessions[$arg1])) return $this->error(13,$arg1,"TTT7",1);
-      $tab=explode(".",$arg2);
-      if (count($tab)==1){
-        if (!$this->setGFile($arg1,$arg2,$arg3)) return $this->error(14,array($this->file_name[$arg1],$arg2),"TTT8",1);
-      }
-      else if (count($tab==2)){
-        if (!isset($this->sessions[$arg1][$tab[0]])) return $this->error(11,array($tab[0],$this->file_name[$arg1],"TTT9",1));
-        if (!$this->setGZone($arg1,$tab[0],$tab[1],$arg3)) return $this->error(15,array($this->file_name[$arg1],$tab[0],$tab[1]),"TTT10",1);
-      }
-      return 1;
-    }
-
-    function setVar($handle,$zone_var,$val){
-      // Fill the variable
-      $tab=explode(".",$zone_var);
-      if(count($tab)==2){
-        $zone=$tab[0];
-        $var=$tab[1];
-      }
-      else
-      {
-        $zone="|root|";
-        $var=$tab[0];
-      }
-
-      // Teste l'existence de la zone dans la liste
-      if (!isset($this->sessions[$handle][$zone])) return $this->error(11,array($this->file_name[$handle],$zone),"TTT11",1);
-
-      //Enregistre la variable
-      return $this->sessions[$handle][$zone]->setVar($var,$val);
-    }
-
-    function Parse($handle_dest,$zone_var_dest,$handle_source,$zone_source="|root|"){
-      if($this->sessions[$handle_source][$zone_source]->used == 1) $this->closeSession($handle_source,$zone_source);
-      $this->setVar($handle_dest,$zone_var_dest, $this->sessions[$handle_source][$zone_source]->generated);
-    }
-
-    function setVarF($handle,$zone_var,$file){
+	  // Check if the zone exists.
+	if(!isset($this->sessions[$handle][$nom_zone])) return $this->error(11,array($nom_zone,$this->file_name[$handle]),"TTT5",1);
+     // Closing sub-zone
+     $this->sessions[$handle][$nom_zone]->closeSession();	
+   return 1;
+}
+
+function setGlobalVar($arg1,$arg2,$arg3){
+if ($arg1 == 1){
+  if (!$this->setGAll($arg2,$arg3)) return $this->error(12,$arg2,"TTT6",1);
+  return 1; 
+}
+if (!isset($this->sessions[$arg1])) return $this->error(13,$arg1,"TTT7",1);
+ $tab=explode(".",$arg2);
+ if (count($tab)==1){
+    if (!$this->setGFile($arg1,$arg2,$arg3)) return $this->error(14,array($this->file_name[$arg1],$arg2),"TTT8",1);
+ }
+ else if (count($tab==2)){
+    if (!isset($this->sessions[$arg1][$tab[0]])) return $this->error(11,array($tab[0],$this->file_name[$arg1],"TTT9",1));
+    if (!$this->setGZone($arg1,$tab[0],$tab[1],$arg3)) return $this->error(15,array($this->file_name[$arg1],$tab[0],$tab[1]),"TTT10",1);
+ }
+return 1;
+}
+
+function setVar($handle,$zone_var,$val){
+ // Fill the variable
+$tab=explode(".",$zone_var);
+ if(count($tab)==2){
+   $zone=$tab[0];
+   $var=$tab[1];
+ }
+ else
+ {
+  $zone="|root|";
+  $var=$tab[0];
+ }
+
+ // Teste l'existence de la zone dans la liste
+ if (!isset($this->sessions[$handle][$zone])) return $this->error(11,array($this->file_name[$handle],$zone),"TTT11",1);
+
+ //Enregistre la variable
+ return $this->sessions[$handle][$zone]->setVar($var,$val);
+}
+
+function Parse($handle_dest,$zone_var_dest,$handle_source,$zone_source="|root|"){
+	if($this->sessions[$handle_source][$zone_source]->used == 1) $this->closeSession($handle_source,$zone_source);
+	  $this->setVar($handle_dest,$zone_var_dest, $this->sessions[$handle_source][$zone_source]->generated);
+}
+
+function setVarF($handle,$zone_var,$file){
 // Fonction qui ouvre le fichier file et copie ce qu'il y a dedans dans une variable.
-      $tab=explode(".",$zone_var);
+$tab=explode(".",$zone_var);
 
 // Récupération nom de la zone et de la variable.
-      if(count($tab)==2){
-        $zone=$tab[0];
-        $var=$tab[1];
-      }
-      else
-      {
-        $zone="|root|";
-        $var=$tab[0];
-      }
+ if(count($tab)==2){
+   $zone=$tab[0];
+   $var=$tab[1];
+ }
+ else
+ {
+  $zone="|root|";
+  $var=$tab[0];
+ }
 // Teste l'existence de la zone dans la liste
-      if (!is_object($this->sessions[$handle][$zone])) return $this->error(11,array($handle,$zone),"TTT12",1);
-
-      // Récupération du source à lire
-      if (!@file_exists($file)) return $this->error(8,$file,"TTT13",1);
-      if (!$f_id=@fopen($file,"r")) return $this->error(9,$file,"TTT14",1);
-      if (!$val=@fread($f_id, filesize($file))) return $this->error(10,$file,"TTT15",1);
-      clearstatcache();
-      fclose($f_id);
+ if (!is_object($this->sessions[$handle][$zone])) return $this->error(11,array($handle,$zone),"TTT12",1);
+
+ // Récupération du source à lire
+if (!@file_exists($file)) return $this->error(8,$file,"TTT13",1);
+if (!$f_id=@fopen($file,"r")) return $this->error(9,$file,"TTT14",1);
+if (!$val=@fread($f_id, filesize($file))) return $this->error(10,$file,"TTT15",1);
+clearstatcache();
+fclose($f_id);
 
 //Enregistre la variable
-      return $this->sessions[$handle][$zone]->setVar($var,$val);
-    }
-
-    function isZone($handle, $zone="|root|") 
-      { 
-        return isset($this->sessions[$handle][$zone]) ; 
-      } 
-
-    function Display($handle="{0}",$display=1,$zone="|root|"){
-      $this->closeSession($handle,$zone);
-      $c_genere = $this->sessions[$handle][$zone]->generated; 
+return $this->sessions[$handle][$zone]->setVar($var,$val);
+}
+
+
+
+
+
+function isZone($handle, $zone="|root|") 
+{ 
+return isset($this->sessions[$handle][$zone]) ; 
+} 
+
+function Display($handle="{0}",$display=1,$zone="|root|"){
+	$this->closeSession($handle,$zone);
+	$c_genere = $this->sessions[$handle][$zone]->generated; 
 	
-      if ($display) echo $c_genere; else return ($c_genere);
-    }
+	if ($display) echo $c_genere; else return ($c_genere);
+}
+//fonction complementaire version BETA
+
+/*
+* 
+On peut l'utiliser : 
+- SetVarTab($array): tout les couples clef/valeur sont valorisées 
+- SetVarTab($array,$index) seuls les couples clef/valeur dont la clef est dans le tableau index ou dont la valeur == $index (si pas tableau) 
+Si $index contient ou est une clef de type zone.clef, la clef sera extraite du texte est servira d'index pour $array 
+
+Vincent 
+*/
+
+function setVarTab($handle,$zones,$index = array()){ 
+	if (is_array($index)) 
+	{ 
+		if (count($index)>0) 
+		{ 
+			reset($index); 
+			while (list (, $key) = each ($index)) 
+			{ 
+				$tab=explode(".",$key); 
+				if(count($tab)==2){ 
+					$var=$tab[1]; 
+				} 
+				else 
+				{ 
+					$var=$tab[0]; 
+				} 
+				setVar($handle,$key,$zones[$var]); 
+			} 
+		} 
+		else 
+		{ 
+			reset($zones); 
+			while (list ($key, $val) = each ($zones)) 
+			{ 
+				setVar($handle,$key,$val); 
+			} 
+		} 
+	} 
+	else 
+	{ 
+		setVar($handle,$index,$zones[$index]); 
+	} 
+} 
+
+function setGlobalVarTab($handle,$zones,$index = array()){ 
+
+	if (is_array($index)) 
+	{ 
+		if (count($index)>0) 
+		{ 
+			reset($index); 
+			while (list (, $key) = each ($index)) 
+			{ 
+				$tab=explode(".",$key); 
+				if(count($tab)==2){ 
+					$var=$tab[1]; 
+				} 
+				else 
+				{ 
+					$var=$tab[0]; 
+				} 
+				setGlobalVar($handle,$key,$zones[$var]); 
+			} 
+		} 
+		else 
+		{ 
+			reset($zones); 
+			while (list ($key, $val) = each ($zones)) 
+			{
+				GlobalVar($handle,$key,$val); 
+			} 
+		} 
+	} 
+	else 
+	{ 
+		setBlobalVar($handle,$index,$zones[$index]); 
+	} 
+} 
+
+
+
+
 
 
 // End VTemplate
-  }
-  $DEFINE_VTEMPLATE = 1;
+}
+$DEFINE_VTEMPLATE = 1;
 }
 ?>
Index: /trunk/index.php
===================================================================
--- /trunk/index.php	(revision 20)
+++ /trunk/index.php	(revision 21)
@@ -1,15 +1,12 @@
 <?php
-include_once( './include/mysql.inc.php' );
+define( PREFIX_INCLUDE, '' );
 include_once( './include/functions.inc.php' );
 database_connection();
-// récupération des informations de configuration du site
-$query  = 'select acces ';
-$query .= 'from '.PREFIX_TABLE.'config;';
+// retrieving configuration informations
+$query = 'SELECT access';
+$query.= ' FROM '.PREFIX_TABLE.'config;';
 $row = mysql_fetch_array( mysql_query( $query ) );
-$url = 'category';
-if ( $row['acces'] == 'restreint' )
-{
-  $url = 'identification';
-}
+if ( $row['access'] == 'restricted' ) $url = 'identification';
+else                                  $url = 'category';
 // redirection
 $url.= '.php';
Index: /trunk/language/francais.php
===================================================================
--- /trunk/language/francais.php	(revision 20)
+++ /trunk/language/francais.php	(revision 21)
@@ -16,4 +16,8 @@
 $lang['guest'] = 'visiteur';
 $lang['mail_address'] = 'adresse mail';
+$lang['public'] = 'publique';
+$lang['private'] = 'privée';
+$lang['add'] = 'ajouter';
+$lang['dissociate'] = 'dissocier';
 // end version 1.3
 
@@ -219,4 +223,5 @@
   $lang['title_add'] = 'Ajouter un utilisateur';
   $lang['title_modify'] = 'Modifier un utilisateur';
+  $lang['title_groups'] = 'Gestion des groupes';
 // end version 1.3
   $lang['title_liste_users'] = 'Liste des utilisateurs';
@@ -225,5 +230,10 @@
   $lang['title_configuration'] = 'Configuration de PhpWebGallery';
   $lang['title_instructions'] = 'Instructions';
-  $lang['title_permissions'] = 'Modifier les permissions pour un utilisateur';
+// start version 1.3
+// $lang['title_permissions'] = 'Modifier les permissions pour un utilisateur';
+  $lang['title_user_perm'] = 'Modifier les permissions pour l\'utilisateur';
+  $lang['title_cat_perm'] = 'Modifier les permissions pour la catégorie';
+  $lang['title_group_perm'] = 'Modifier les permissions pour le groupe';
+// end version 1.3
   $lang['title_categories'] = 'Gestion des catégories';
   $lang['title_edit_cat'] = 'Editer une catégorie';
@@ -232,5 +242,5 @@
   $lang['title_thumbnails_2'] = 'pour';
   $lang['title_default'] = 'Administration de PhpWebGallery';
-		
+	
   $lang['menu_title'] = 'Administration';
   $lang['menu_config'] = 'Configuration';
@@ -244,5 +254,8 @@
   $lang['menu_instructions'] = 'Instructions';
   $lang['menu_back'] = 'Page diapo';
-
+// start version 1.3
+  $lang['menu_groups'] = 'Groupes';
+// end version 1.3
+  
   $lang['title_waiting'] = 'Images en attente de validation';
   $lang['menu_waiting'] = 'En attente';
@@ -384,7 +397,17 @@
 // start version 1.3
 //  $lang['adduser_status_member'] = 'membre';
+  $lang['adduser_associate'] = 'Associer au groupe';
 // end version 1.3
   $lang['adduser_status_guest'] = 'visiteur';
-		
+
+// start version 1.3
+  $lang['group_add'] = 'Ajouter un groupe';
+  $lang['group_add_error1'] = 'Le nom du groupe ne doit pas comporter de " ou de \'';
+  $lang['group_add_error2'] = 'Ce nom de groupe est déjà utilisé';
+  $lang['group_confirm'] = 'Etes-vous sûr de vouloir supprimer le groupe';
+  $lang['group_list_title'] = 'Liste des groupes existants';
+  $lang['group_err_unknown'] = 'Ce groupe n\'existe pas dans la base de données';
+// end version 1.3
+
   // page permissions
   $lang['permuser_info_message'] = 'Permissions enregistrées';
@@ -394,5 +417,7 @@
   $lang['permuser_forbidden'] = 'interdit';
   $lang['permuser_parent_forbidden'] = 'catégorie parente interdite';
-  $lang['permuser_cat_title'] = 'Modifier les permissions pour ';
+// start version 1.3
+// $lang['permuser_cat_title'] = 'Modifier les permissions pour ';
+// end version 1.3
 		
   // page liste utilisateurs
@@ -434,5 +459,7 @@
   $lang['editcat_status'] = 'Status';
   $lang['editcat_status_info'] = '(invisible sauf pour les administrateurs)';
-		
+// start version 1.3
+  $lang['editcat_visible'] = 'Visible';
+// end version 1.3
   // page info images
   $lang['infoimage_err_date'] = 'date erronée';
Index: /trunk/picture.php
===================================================================
--- /trunk/picture.php	(revision 20)
+++ /trunk/picture.php	(revision 21)
@@ -29,7 +29,7 @@
 }
 //---------------------------------------- incrementation of the number of hits
-$query = 'update '.PREFIX_TABLE.'images';
-$query.= ' set hit=hit+1';
-$query.= ' where id='.$_GET['image_id'];
+$query = 'UPDATE '.PREFIX_TABLE.'images';
+$query.= ' SET hit=hit+1';
+$query.= ' WHERE id='.$_GET['image_id'];
 $query.= ';';
 @mysql_query( $query );
@@ -38,9 +38,9 @@
 $cat_directory = $page['cat_dir']; // by default
 //------------------------------------- main picture information initialization
-$query = 'select id,date_available,comment,hit';
+$query = 'SELECT id,date_available,comment,hit';
 $query.= ',author,name,file,date_creation,filesize,width,height,cat_id';
-$query.= ' from '.PREFIX_TABLE.'images';
+$query.= ' FROM '.PREFIX_TABLE.'images';
 $query.= $page['where'];
-$query.= ' and id = '.$_GET['image_id'];
+$query.= ' AND id = '.$_GET['image_id'];
 $query.= $conf['order_by'];
 $query.= ';';
@@ -60,6 +60,6 @@
 $page['cat_id']         = $row['cat_id'];
 // retrieving the number of the picture in its category (in order)
-$query = 'select id';
-$query.= ' from '.PREFIX_TABLE.'images';
+$query = 'SELECT id';
+$query.= ' FROM '.PREFIX_TABLE.'images';
 $query.= $page['where'];
 $query.= $conf['order_by'];
@@ -79,8 +79,8 @@
   {
     // verify if the picture is already in the favorite of the user
-    $query = 'select count(*) as nb_fav';
-    $query.= ' from '.PREFIX_TABLE.'favorites';
-    $query.= ' where image_id = '.$page['id'];
-    $query.= ' and user_id = '.$user['id'];
+    $query = 'SELECT COUNT(*) AS nb_fav';
+    $query.= ' FROM '.PREFIX_TABLE.'favorites';
+    $query.= ' WHERE image_id = '.$page['id'];
+    $query.= ' AND user_id = '.$user['id'];
     $query.= ';';
     $result = mysql_query( $query );
@@ -88,6 +88,6 @@
     if ( $row['nb_fav'] == 0 )
     {
-      $query = 'insert into '.PREFIX_TABLE.'favorites';
-      $query.= ' (image_id,user_id) values';
+      $query = 'INSERT INTO '.PREFIX_TABLE.'favorites';
+      $query.= ' (image_id,user_id) VALUES';
       $query.= ' ('.$page['id'].','.$user['id'].')';
       $query.= ';';
@@ -97,7 +97,7 @@
   if ( $_GET['add_fav'] == 0 )
   {
-    $query = 'delete from '.PREFIX_TABLE.'favorites';
-    $query.= ' where user_id = '.$user['id'];
-    $query.= ' and image_id = '.$page['id'];
+    $query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
+    $query.= ' WHERE user_id = '.$user['id'];
+    $query.= ' AND image_id = '.$page['id'];
     $query.= ';';
     $result = mysql_query( $query );
@@ -121,9 +121,9 @@
       $page['num'] = 0;
     }
-    $query = 'select id';
-    $query.= ' from '.PREFIX_TABLE.'images';
+    $query = 'SELECT id';
+    $query.= ' FROM '.PREFIX_TABLE.'images';
     $query.= $page['where'];
     $query.= $conf['order_by'];
-    $query.= ' limit '.$page['num'].',1';
+    $query.= ' LIMIT '.$page['num'].',1';
     $query.= ';';
     $result = mysql_query( $query );
@@ -144,22 +144,13 @@
 //----------------------------------------------------- template initialization
 $vtp = new VTemplate;
-$handle = $vtp->Open( './template/default/picture.vtp' );
-// language
-$vtp->setGlobalVar( $handle, 'back',             $lang['back'] );
-$vtp->setGlobalVar( $handle, 'submit',           $lang['submit'] );
-$vtp->setGlobalVar( $handle, 'comments_title',   $lang['comments_title'] );
-$vtp->setGlobalVar( $handle, 'comments_del',     $lang['comments_del'] );
-$vtp->setGlobalVar( $handle, 'delete',           $lang['delete'] );
-$vtp->setGlobalVar( $handle, 'comments_add',     $lang['comments_add'] );
-$vtp->setGlobalVar( $handle, 'author',           $lang['author'] );
-// user
-$vtp->setGlobalVar( $handle, 'page_style',       $user['style'] );
-$vtp->setGlobalVar( $handle, 'text_color',       $user['couleur_text'] );
-// structure
-$vtp->setGlobalVar( $handle, 'frame_start',      get_frame_start() );
-$vtp->setGlobalVar( $handle, 'frame_begin',      get_frame_begin() );
-$vtp->setGlobalVar( $handle, 'frame_end',        get_frame_end() );
+$handle = $vtp->Open( './template/'.$user['template'].'/picture.vtp' );
+initialize_template();
+
+$tpl = array( 'back','submit','comments_title','comments_del','delete',
+              'comments_add','author' );
+templatize_array( $tpl, 'lang', $handle );
+$vtp->setGlobalVar( $handle, 'text_color', $user['couleur_text'] );
 //------------------------------------------------------------------ page title
-if ( $page['name'] != "" )
+if ( $page['name'] != '' )
 {
   $vtp->setGlobalVar( $handle, 'page_title', $page['name'] );
@@ -173,9 +164,9 @@
 {
   $prev = $page['num'] - 1;
-  $query = 'select id,name,file,tn_ext,cat_id';
-  $query.= ' from '.PREFIX_TABLE.'images';
+  $query = 'SELECT id,name,file,tn_ext,cat_id';
+  $query.= ' FROM '.PREFIX_TABLE.'images';
   $query.= $page['where'];
   $query.= $conf['order_by'];
-  $query.= ' limit '.$prev.',1';
+  $query.= ' LIMIT '.$prev.',1';
   $query.= ';';
   $result = mysql_query( $query );
@@ -198,12 +189,6 @@
   $prev_title = $lang['previous_image'].' : ';
   $alt_thumbnaill = '';
-  if ( $row['name'] != "" )
-  {
-    $alt_thumbnail = $row['name'];
-  }
-  else
-  {
-    $alt_thumbnail = $file;
-  }
+  if ( $row['name'] != '' ) $alt_thumbnail = $row['name'];
+  else                      $alt_thumbnail = $file;
   $prev_title.= $alt_thumbnail;
   
@@ -321,7 +306,7 @@
   $vtp->addSession( $handle, 'info_line' );
   $vtp->setVar( $handle, 'info_line.name', $lang['creation_date'].' : ' );
-  $tab_date = explode( '-', $page['date_creation'] );
+  list( $year,$month,$day ) = explode( '-', $page['date_creation'] );
   $vtp->setVar( $handle, 'info_line.content',
-                $tab_date[2].'/'.$tab_date[1].'/'.$tab_date[0] );
+                $day.'/'.$month.'/'.$year );
   $vtp->closeSession( $handle, 'info_line' );
 }
@@ -329,12 +314,12 @@
 $vtp->addSession( $handle, 'info_line' );
 $vtp->setVar( $handle, 'info_line.name', $lang['registration_date'].' : ' );
-$tab_date = explode( '-', $page['date_available'] );
+list( $year,$month,$day ) = explode( '-', $page['date_available'] );
 $vtp->setVar( $handle, 'info_line.content',
-              $tab_date[2].'/'.$tab_date[1].'/'.$tab_date[0] );
+              $day.'/'.$month.'/'.$year );
 $vtp->closeSession( $handle, 'info_line' );
 // size in pixels
 $vtp->addSession( $handle, 'info_line' );
 $vtp->setVar( $handle, 'info_line.name', $lang['size'].' : ' );
-if ( $original_width != $final_width || $original_height != $final_height )
+if ( $original_width != $final_width or $original_height != $final_height )
 {
   $content = '[ <a href="'.$lien_image.'" title="'.$lang['true_size'].'">';
@@ -380,5 +365,5 @@
 $vtp->closeSession( $handle, 'info_line' );
 //------------------------------------------------------- favorite manipulation
-if ( $page['cat'] != 'fav' && !$user['is_the_guest'] )
+if ( $page['cat'] != 'fav' and !$user['is_the_guest'] )
 {
   $url = './picture.php?cat='.$page['cat'].'&amp;image_id='.$page['id'];
@@ -442,5 +427,5 @@
 
   $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") );
-  $lien_thumbnail = $cat_directory."thumbnail/";
+  $lien_thumbnail = $cat_directory.'thumbnail/';
   $lien_thumbnail.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext'];
   
@@ -481,11 +466,11 @@
   if ( isset( $_POST['content'] ) && $_POST['content'] != '' )
   {
-    $author = $user['pseudo'];
-    if ( $_POST['author'] != "" )
+    $author = $user['username'];
+    if ( $_POST['author'] != '' )
     {
       $author = $_POST['author'];
     }
-    $query = 'insert into '.PREFIX_TABLE.'comments';
-    $query.= ' (author,date,image_id,content) values';
+    $query = 'INSERT INTO '.PREFIX_TABLE.'comments';
+    $query.= ' (author,date,image_id,content) VALUES';
     $query.= " ('".$author."',".time().",".$page['id'];
     $query.= ",'".htmlspecialchars( $_POST['content'], ENT_QUOTES)."');";
@@ -497,12 +482,12 @@
        && $user['status'] == 'admin' )
   {
-    $query = 'delete from '.PREFIX_TABLE.'comments';
-    $query.= ' where id = '.$_GET['del'].';';
+    $query = 'DELETE FROM '.PREFIX_TABLE.'comments';
+    $query.= ' WHERE id = '.$_GET['del'].';';
     mysql_query( $query );
   }
   // number of comment for this picture
-  $query = 'select count(*) as nb_comments';
-  $query.= ' from '.PREFIX_TABLE.'comments';
-  $query.= ' where image_id = '.$page['id'].';';
+  $query = 'SELECT COUNT(*) AS nb_comments';
+  $query.= ' FROM '.PREFIX_TABLE.'comments';
+  $query.= ' WHERE image_id = '.$page['id'].';';
   $row = mysql_fetch_array( mysql_query( $query ) );
   $page['nb_comments'] = $row['nb_comments'];
@@ -515,6 +500,6 @@
   }
   if( !isset( $_GET['start'] )
-      || !is_numeric( $_GET['start'] )
-      || ( is_numeric( $_GET['start'] ) && $_GET['start'] < 0 ) )
+      or !is_numeric( $_GET['start'] )
+      or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
   {
     $page['start'] = 0;
@@ -532,9 +517,9 @@
   $vtp->setGlobalVar( $handle, 'nb_comments', $page['nb_comments'] );
 
-  $query = 'select id,author,date,image_id,content';
-  $query.= ' from '.PREFIX_TABLE.'comments';
-  $query.= ' where image_id = '.$page['id'];
-  $query.= ' order by date asc';
-  $query.= ' limit '.$page['start'].', '.$conf['nb_comment_page'].';';
+  $query = 'SELECT id,author,date,image_id,content';
+  $query.= ' FROM '.PREFIX_TABLE.'comments';
+  $query.= ' WHERE image_id = '.$page['id'];
+  $query.= ' ORDER BY date ASC';
+  $query.= ' LIMIT '.$page['start'].', '.$conf['nb_comment_page'].';';
   $result = mysql_query( $query );
                 
@@ -581,9 +566,3 @@
 $code = $vtp->Display( $handle, 0 );
 echo $code;
-//------------------------------------------------------------ log informations
-$query = 'insert into '.PREFIX_TABLE.'history';
-$query.= ' (date,login,IP,page,titre,categorie) values';
-$query.= " (".time().", '".$user['pseudo']."','".$_SERVER['REMOTE_ADDR']."'";
-$query.= ",'picture','".$page['file']."','".$intitule_cat."');";
-@mysql_query( $query );
 ?>
Index: /trunk/register.php
===================================================================
--- /trunk/register.php	(revision 20)
+++ /trunk/register.php	(revision 21)
@@ -17,7 +17,7 @@
 
 //----------------------------------------------------------- personnal include
-include_once( "./include/init.inc.php" );
+include_once( './include/init.inc.php' );
 //-------------------------------------------------- access authorization check
-if ( $conf['acces'] == "restreint" )
+if ( $conf['access'] == "restricted" )
 {
   echo $lang['only_members'];
Index: unk/template/default/admin/cat.vtp
===================================================================
--- /trunk/template/default/admin/cat.vtp	(revision 20)
+++ 	(revision )
@@ -1,58 +1,0 @@
-<table style="width:100%;">
-<!--VTP_cat-->
-<tr>
-  <{#td} style="width:40%;text-align:left;">
-    {#indent}<img src="./images/puce.gif" alt="&gt;" />
-    &nbsp;{#name} [ dir : {#dir} ]
-    <span style="color:red;font-weight:normal;"> {#invisible}</span>
-  </{#td}>
-  <{#td} style="text-align:center;">
-    <div style="margin-left:3px;margin-right:3px;">{#nb_picture}</div>
-  </{#td}>
-  <{#td} class="{#class}"
-         style="width:10%;white-space:nowrap;text-align:center;">
-    <a href="{#edit_url}">{#cat_edit}</a>
-  </{#td}>
-  <{#td} class="{#class}"
-         style="width:10%;white-space:nowrap;text-align:center;">
-    <!--VTP_up-->
-    <a href="{#up_url}">{#cat_up}</a>
-    <!--/VTP_up-->
-    <!--VTP_no_up-->
-    <span style="color:darkgray;">{#cat_up}</span>
-    <!--/VTP_no_up-->
-  </{#td}>
-  <{#td} class="{#class}"
-         style="width:10%;white-space:nowrap;text-align:center;">
-    <!--VTP_down-->
-    <a href="{#down_url}">{#cat_down}</a>
-    <!--/VTP_down-->
-    <!--VTP_no_down-->
-    <span style="color:darkgray;">{#cat_down}</span>
-    <!--/VTP_no_down-->
-  </{#td}>
-  <{#td} class="{#class}"
-         style="width:10%;white-space:nowrap;text-align:center;">
-    <!--VTP_image_info-->
-    <a href="{#image_info_url}">{#cat_image_info}</a>
-    <!--/VTP_image_info-->
-    <!--VTP_no_image_info-->
-    <span style="color:darkgray;">{#cat_image_info}</span>
-    <!--/VTP_no_image_info-->
-  </{#td}>
-  <{#td} class="{#class}"
-         style="width:10%;white-space:nowrap;text-align:center;">
-    <a href="{#permission_url}">{#cat_permission}</a>
-  </{#td}>
-  <{#td} class="{#class}"
-         style="width:10%;white-space:nowrap;text-align:center;">
-    <!--VTP_update-->
-    <a href="{#update_url}">{#cat_update}</a>
-    <!--/VTP_update-->
-    <!--VTP_no_update-->
-    <span style="color:darkgray;">{#cat_update}</span>
-    <!--/VTP_no_update-->
-  </{#td}>
-<tr>
-<!--/VTP_cat-->
-</table>
Index: /trunk/template/default/admin/cat_list.vtp
===================================================================
--- /trunk/template/default/admin/cat_list.vtp	(revision 21)
+++ /trunk/template/default/admin/cat_list.vtp	(revision 21)
@@ -0,0 +1,63 @@
+<table style="width:100%;">
+<!--VTP_cat-->
+<tr>
+  <{#td} style="width:40%;text-align:left;">
+    {#indent}<img src="./images/puce.gif" alt="&gt;" />
+    &nbsp;{#name} [ dir : {#dir} ]
+    <span style="color:red;font-weight:normal;"> {#invisible} <span style="font-weight:bold;">{#private}</span></span>
+  </{#td}>
+  <{#td} style="text-align:center;">
+    <div style="margin-left:3px;margin-right:3px;">{#nb_picture}</div>
+  </{#td}>
+  <{#td} class="{#class}"
+         style="width:10%;white-space:nowrap;text-align:center;">
+    <a href="{#edit_url}">{#cat_edit}</a>
+  </{#td}>
+  <{#td} class="{#class}"
+         style="width:10%;white-space:nowrap;text-align:center;">
+    <!--VTP_up-->
+    <a href="{#up_url}">{#cat_up}</a>
+    <!--/VTP_up-->
+    <!--VTP_no_up-->
+    <span style="color:darkgray;">{#cat_up}</span>
+    <!--/VTP_no_up-->
+  </{#td}>
+  <{#td} class="{#class}"
+         style="width:10%;white-space:nowrap;text-align:center;">
+    <!--VTP_down-->
+    <a href="{#down_url}">{#cat_down}</a>
+    <!--/VTP_down-->
+    <!--VTP_no_down-->
+    <span style="color:darkgray;">{#cat_down}</span>
+    <!--/VTP_no_down-->
+  </{#td}>
+  <{#td} class="{#class}"
+         style="width:10%;white-space:nowrap;text-align:center;">
+    <!--VTP_image_info-->
+    <a href="{#image_info_url}">{#cat_image_info}</a>
+    <!--/VTP_image_info-->
+    <!--VTP_no_image_info-->
+    <span style="color:darkgray;">{#cat_image_info}</span>
+    <!--/VTP_no_image_info-->
+  </{#td}>
+  <{#td} class="{#class}"
+         style="width:10%;white-space:nowrap;text-align:center;">
+    <!--VTP_permission-->
+    <a href="{#url}">{#cat_permission}</a>
+    <!--/VTP_permission-->
+    <!--VTP_no_permission-->
+    <span style="color:darkgray;">{#cat_permission}</span>
+    <!--/VTP_no_permission-->
+  </{#td}>
+  <{#td} class="{#class}"
+         style="width:10%;white-space:nowrap;text-align:center;">
+    <!--VTP_update-->
+    <a href="{#update_url}">{#cat_update}</a>
+    <!--/VTP_update-->
+    <!--VTP_no_update-->
+    <span style="color:darkgray;">{#cat_update}</span>
+    <!--/VTP_no_update-->
+  </{#td}>
+<tr>
+<!--/VTP_cat-->
+</table>
Index: /trunk/template/default/admin/cat_modify.vtp
===================================================================
--- /trunk/template/default/admin/cat_modify.vtp	(revision 21)
+++ /trunk/template/default/admin/cat_modify.vtp	(revision 21)
@@ -0,0 +1,54 @@
+<!--VTP_confirmation-->
+<div style="color:red;text-align:center;">
+  {#editcat_confirm} [ <a href="{#back_url}">{#editcat_back}</a> ]</div>
+<!--/VTP_confirmation-->
+<form action="{#form_action}" method="post">
+  <table style="width:100%;">
+    <tr>
+      <th colspan="2">{#editcat_title1} "{#cat:name}" [ {#cat:dir} ]</th>
+    </tr>
+    <!--VTP_server-->
+    <tr>
+      <td style="width:20%;">{#remote_site}</td>
+      <td class="row2">{#url}</td>
+    </tr>
+    <!--/VTP_server-->
+    <tr>
+      <td style="width:20%;">{#editcat_name}</td>
+      <td class="row2">
+        <input type="text" name="name" value="{#name}" maxlength="255"/>
+      </td>
+    </tr>
+    <tr>
+      <td style="width:20%;">{#editcat_comment}</td>
+      <td class="row2">
+        <textarea name="comment" rows="5" cols="50" style="overflow:auto">{#comment}</textarea>
+      </td>
+    </tr>
+    <tr>
+      <td style="width:20%;">{#editcat_status}</td>
+      <td class="row2">
+        <!--VTP_status_option-->
+        <input type="radio" name="status" value="{#value}"{#checked} />{#option}
+        <!--/VTP_status_option-->
+      </td>
+    </tr>
+    <tr>
+      <td style="width:20%;">{#editcat_visible}</td>
+      <td class="row2">
+        <!--VTP_visible_option-->
+        <input type="radio" name="visible" value="{#value}"{#checked} />{#option}
+        <!--/VTP_visible_option-->
+	{#editcat_status_info}
+      </td>
+    </tr>
+    <tr>
+      <td colspan="2">&nbsp;</td>
+    </tr>
+    <tr>
+      <td colspan="2" align="center">
+        <input type="submit" name="submit" value="{#submit}" />
+      </td>
+    </tr>
+  </table>
+</form>
Index: /trunk/template/default/admin/cat_perm.vtp
===================================================================
--- /trunk/template/default/admin/cat_perm.vtp	(revision 21)
+++ /trunk/template/default/admin/cat_perm.vtp	(revision 21)
@@ -0,0 +1,47 @@
+<form action="{#action}" method="post">
+  <!--VTP_groups-->
+  <table style="width:100%;">
+    <tr>
+      <th colspan="2">{#menu_groups}</th>
+    </tr>
+    <!--VTP_group-->
+    <tr>
+      <td><a href="{#group_perm_link}"><span style="color:{#color}">{#groupname}</span></a></td>
+      <td style="text-align:right;">
+        <input type="radio" name="groupaccess-{#id}" value="0"{#authorized_checked}/>{#permuser_authorized}
+        <input type="radio" name="groupaccess-{#id}" value="1"{#forbidden_checked}/>{#permuser_forbidden}
+      </td>
+    </tr>
+    <!--/VTP_group-->
+  </table>
+  <!--/VTP_groups-->
+  <table style="width:100%;">
+    <tr>
+      <th colspan="2">{#menu_users}</th>
+    </tr>
+    <!--VTP_user-->
+    <tr>
+      <td>
+        <a href="{#user_perm_link}"><span style="color:{#color}">{#username}</span></a>
+        <!--VTP_usergroups-->
+        [
+        <!--VTP_usergroup-->
+        <span style="color:{#color};">{#name}</span>{#separation}
+        <!--/VTP_usergroup-->
+        ]
+        <!--/VTP_usergroups-->
+      </td>
+      <td style="text-align:right;">
+        <!--VTP_parent_forbidden-->
+        <a href="{#url}">{#permuser_parent_forbidden}</a>
+        <!--/VTP_parent_forbidden-->
+        <input type="radio" name="useraccess-{#id}" value="0"{#authorized_checked}/>{#permuser_authorized}
+        <input type="radio" name="useraccess-{#id}" value="1"{#forbidden_checked}/>{#permuser_forbidden}
+      </td>
+    </tr>
+    <!--/VTP_user-->
+    <tr>
+      <td colspan="2" align="center"><input type="submit" name="submit" value="{#submit}"/></td>
+    </tr>
+  </table>
+</form>
Index: unk/template/default/admin/edit_cat.vtp
===================================================================
--- /trunk/template/default/admin/edit_cat.vtp	(revision 20)
+++ 	(revision )
@@ -1,55 +1,0 @@
-<!--VTP_confirmation-->
-<div style="color:red;text-align:center;">
-  {#editcat_confirm} [ <a href="{#back_url}">{#editcat_back}</a> ]</div>
-<!--/VTP_confirmation-->
-<form action="{#form_action}" method="post">
-  <table style="width:100%;">
-    <tr>
-      <th colspan="2">{#editcat_title1} "{#cat:name}" [ {#cat:dir} ]</th>
-    </tr>
-    <!--VTP_server-->
-    <tr>
-      <td style="width:20%;">{#remote_site}</td>
-      <td class="row2">{#url}</td>
-    </tr>
-    <!--/VTP_server-->
-    <tr>
-      <td style="width:20%;">{#editcat_name}</td>
-      <td class="row2">
-        <input type="text" name="name" value="{#name}" maxlength="255"/>
-      </td>
-    </tr>
-    <tr>
-      <td style="width:20%;">{#editcat_comment}</td>
-      <td class="row2">
-        <textarea name="comment" rows="5" cols="50" style="overflow:auto">{#comment}</textarea>
-      </td>
-    </tr>
-    <tr>
-      <td style="width:20%;">{#editcat_status}</td>
-      <td class="row2">
-        <!--VTP_status_option-->
-        <input type="radio" name="status" value="{#option}"{#checked} />{#option}
-        <!--/VTP_status_option-->
-	{#editcat_status_info}
-      </td>
-    </tr>
-    <tr>
-      <td style="width:20%;">{#editcat_visible}</td>
-      <td class="row2">
-        <!--VTP_visible_option-->
-        <input type="radio" name="visible" value="{#option}"{#checked} />{#option}
-        <!--/VTP_visible_option-->
-	{#editcat_status_info}
-      </td>
-    </tr>
-    <tr>
-      <td colspan="2">&nbsp;</td>
-    </tr>
-    <tr>
-      <td colspan="2" align="center">
-        <input type="submit" name="submit" value="{#submit}" />
-      </td>
-    </tr>
-  </table>
-</form>
Index: /trunk/template/default/admin/group_list.vtp
===================================================================
--- /trunk/template/default/admin/group_list.vtp	(revision 21)
+++ /trunk/template/default/admin/group_list.vtp	(revision 21)
@@ -0,0 +1,49 @@
+<!--VTP_errors-->
+<div class="errors">
+  <ul>
+    <!--VTP_li-->
+    <li>{#li}</li>
+    <!--/VTP_li-->
+  </ul>
+</div>
+<!--/VTP_errors-->
+<!--VTP_deletion-->
+<table style="width:100%;">
+  <tr>
+    <th colspan="2">{#group_confirm} "{#name}" ?</th>
+  </tr>
+  <tr>
+    <td align="center"><a href="{#yes_url}">{#yes}</a></td>
+    <td align="center" class="row2"><a href="{#no_url}">{#no}</a></td>
+  </tr>
+</table>
+<!--/VTP_deletion-->
+<!--VTP_confirmation-->
+<div class="{#class}">{#info}</div>
+<!--/VTP_confirmation-->
+<!--VTP_groups-->
+<table width="100%">
+  <tr>
+    <th colspan="3">{#group_list_title}</th>
+  </tr>
+  <!--VTP_group-->
+  <tr>
+    <td style="width:25%;">
+      <div style="margin-left:10px;color:{#color}"><img src="./images/puce.gif" alt="&gt;" /> {#name}</div>
+    </td>
+    <td class="row2" style="text-align:center;width:25%;">
+      <a href="{#permission_url}">{#listuser_permission}</a>
+    </td>
+    <td class="row2" style="text-align:center;width:25%;">
+      <a href="{#deletion_url}">{#delete}</a>
+    </td>
+  </tr>
+  <!--/VTP_group-->
+</table>
+<!--/VTP_groups-->
+<form method="post" action="{#form_action}">
+  <div style="text-align:center;margin:10px;">
+    {#group_add} <input type="text" name="name" />
+    <input type="submit" value="{#add}" name="submit" />
+  </div>
+</form>
Index: /trunk/template/default/admin/group_perm.vtp
===================================================================
--- /trunk/template/default/admin/group_perm.vtp	(revision 21)
+++ /trunk/template/default/admin/group_perm.vtp	(revision 21)
@@ -0,0 +1,24 @@
+<!--VTP_confirmation-->
+<div class="info">{#permuser_info_message} [ <a href="{#back_url}">{#adduser_info_back}</a> ]</div>
+<!--/VTP_confirmation-->
+<form action="{#action}" method="post">
+  <table style="width:100%;">
+    <!--VTP_category-->
+    <tr>
+      <td>
+        <img src="./images/puce.gif" alt="&gt;" /> <a href="{#cat_perm_link}"><span style="color:{#color}">{#name}</span></a>
+      </td>
+      <td style="text-align:right;">
+        <!--VTP_parent_forbidden-->
+        {#permuser_parent_forbidden}
+        <!--/VTP_parent_forbidden-->
+        <input type="radio" name="access-{#id}" value="0"{#authorized_checked}/>{#permuser_authorized}
+        <input type="radio" name="access-{#id}" value="1"{#forbidden_checked}/>{#permuser_forbidden}
+      </td>
+    </tr>
+    <!--/VTP_category-->
+    <tr>
+      <td colspan="2" align="center"><input type="submit" name="submit" value="{#submit}"/></td>
+    </tr>
+  </table>
+</form>
Index: /trunk/template/default/admin/user_modify.vtp
===================================================================
--- /trunk/template/default/admin/user_modify.vtp	(revision 20)
+++ /trunk/template/default/admin/user_modify.vtp	(revision 21)
@@ -35,5 +35,5 @@
           <tr>
             <td>{#new} {#password}<input type="checkbox" name="use_new_pwd" value="1" /></td>
-            <td><input type="text" name="password" value="{#user:password}" /></td>
+            <td><input type="text" name="password" value="" /></td>
           </tr>
           <tr>
@@ -48,4 +48,29 @@
                 <option value="{#value}"{#selected}>{#option}</option>
                 <!--/VTP_status_option-->
+              </select>
+            </td>
+          </tr>
+          <!--VTP_groups-->
+          <tr>
+            <td valign="top">{#menu_groups}</td>
+            <td>
+              <table>
+                <!--VTP_group-->
+                <tr>
+                  <td>{#name}</td>
+                  <td><input type="checkbox" name="dissociate-{#dissociate_id}" value="1" /> {#dissociate}</td>
+                </tr>
+                <!--/VTP_group-->
+              </table>
+            </td>
+          </tr>
+          <!--/VTP_groups-->
+          <tr>
+            <td>{#adduser_associate}</td>
+            <td>
+              <select name="associate">
+                <!--VTP_associate_group-->
+                <option value="{#value}">{#option}</option>
+                <!--/VTP_associate_group-->
               </select>
             </td>
Index: /trunk/template/default/admin/user_perm.vtp
===================================================================
--- /trunk/template/default/admin/user_perm.vtp	(revision 21)
+++ /trunk/template/default/admin/user_perm.vtp	(revision 21)
@@ -0,0 +1,31 @@
+<!--VTP_confirmation-->
+<div class="info">{#permuser_info_message} [ <a href="{#back_url}">{#adduser_info_back}</a> ]</div>
+<!--/VTP_confirmation-->
+<form action="{#action}" method="post">
+  <table style="width:100%;">
+    <!--VTP_category-->
+    <tr>
+      <td>
+        <img src="./images/puce.gif" alt="&gt;" /> <a href="{#cat_perm_link}"><span style="color:{#color}">{#name}</span></a>
+        <!--VTP_usergroups-->
+        [
+        <!--VTP_usergroup-->
+        <span style="color:{#color};">{#name}</span>{#separation}
+        <!--/VTP_usergroup-->
+        ]
+        <!--/VTP_usergroups-->
+      </td>
+      <td style="text-align:right;">
+        <!--VTP_parent_forbidden-->
+        {#permuser_parent_forbidden}
+        <!--/VTP_parent_forbidden-->
+        <input type="radio" name="access-{#id}" value="0"{#authorized_checked}/>{#permuser_authorized}
+        <input type="radio" name="access-{#id}" value="1"{#forbidden_checked}/>{#permuser_forbidden}
+      </td>
+    </tr>
+    <!--/VTP_category-->
+    <tr>
+      <td colspan="2" align="center"><input type="submit" name="submit" value="{#submit}"/></td>
+    </tr>
+  </table>
+</form>
Index: /trunk/template/default/picture.vtp
===================================================================
--- /trunk/template/default/picture.vtp	(revision 20)
+++ /trunk/template/default/picture.vtp	(revision 21)
@@ -1,5 +1,5 @@
 <html>
   <head>
-    {#page_style}
+    {#style}
     <!-- Specific style to picture.php-->
     <style type="text/css">
@@ -45,4 +45,5 @@
   </head>
   <body>
+    {#header}
     <table style="width:100%;height:100%;">
       <tr align="center" valign="middle">
@@ -163,4 +164,5 @@
       <!--/VTP_comments-->
     </table>
+    {#footer}
   </body>
 </html>
