Index: trunk/admin/include/functions.php
===================================================================
--- trunk/admin/include/functions.php	(revision 649)
+++ trunk/admin/include/functions.php	(revision 650)
@@ -331,35 +331,40 @@
 //     - all sessions linked to this user
 //     - all categories informations linked to this user
-function delete_user( $user_id )
+function delete_user($user_id)
 {
   // destruction of the access linked to the user
-  $query = 'DELETE FROM '.PREFIX_TABLE.'user_access';
-  $query.= ' WHERE user_id = '.$user_id;
-  $query.= ';';
-  pwg_query( $query );
+  $query = '
+DELETE FROM '.USER_ACCESS_TABLE.'
+  WHERE user_id = '.$user_id.'
+;';
+  pwg_query($query);
 
   // destruction of the group links for this user
-  $query = 'DELETE FROM '.PREFIX_TABLE.'user_group';
-  $query.= ' WHERE user_id = '.$user_id;
-  $query.= ';';
-  pwg_query( $query );
+  $query = '
+DELETE FROM '.USER_GROUP_TABLE.'
+  WHERE user_id = '.$user_id.'
+;';
+  pwg_query($query);
 
   // destruction of the favorites associated with the user
-  $query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
-  $query.= ' WHERE user_id = '.$user_id;
-  $query.= ';';
-  pwg_query( $query );
+  $query = '
+DELETE FROM '.FAVORITES_TABLE.'
+  WHERE user_id = '.$user_id.'
+;';
+  pwg_query($query);
 
   // destruction of the sessions linked with the user
-  $query = 'DELETE FROM '.PREFIX_TABLE.'sessions';
-  $query.= ' WHERE user_id = '.$user_id;
-  $query.= ';';
-  pwg_query( $query );
+  $query = '
+DELETE FROM '.SESSIONS_TABLE.'
+  WHERE user_id = '.$user_id.'
+;';
+  pwg_query($query);
 
   // destruction of the user
-  $query = 'DELETE FROM '.USERS_TABLE;
-  $query.= ' WHERE id = '.$user_id;
-  $query.= ';';
-  pwg_query( $query );
+  $query = '
+DELETE FROM '.USERS_TABLE.'
+  WHERE id = '.$user_id.'
+;';
+  pwg_query($query);
 }
 
Index: trunk/admin/include/isadmin.inc.php
===================================================================
--- trunk/admin/include/isadmin.inc.php	(revision 649)
+++ trunk/admin/include/isadmin.inc.php	(revision 650)
@@ -28,6 +28,5 @@
 include( PHPWG_ROOT_PATH.'admin/include/functions.php' );
 
-$isadmin = true;
-if ( $user['status'] != 'admin' )
+if ($user['status'] != 'admin')
 {
   echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />';
Index: trunk/include/common.inc.php
===================================================================
--- trunk/include/common.inc.php	(revision 649)
+++ trunk/include/common.inc.php	(revision 650)
@@ -26,7 +26,7 @@
 // +-----------------------------------------------------------------------+
 
-if( !defined("PHPWG_ROOT_PATH") )
+if (!defined('PHPWG_ROOT_PATH'))
 {
-	die ("Hacking attempt!");
+  die('Hacking attempt!');
 }
 // determine the initial instant to indicate the generation time of this page
@@ -115,7 +115,7 @@
 
 include(PHPWG_ROOT_PATH .'include/mysql.inc.php');
-if( !defined("PHPWG_INSTALLED") )
+if (!defined('PHPWG_INSTALLED'))
 {
-  header( 'Location: install.php' );
+  header('Location: install.php');
   exit;
 }
@@ -126,8 +126,5 @@
 include(PHPWG_ROOT_PATH . 'include/template.php');
 
-//
 // Database connection
-//
-
 mysql_connect( $dbhost, $dbuser, $dbpasswd )
 or die ( "Could not connect to database server" );
@@ -135,33 +132,4 @@
 or die ( "Could not connect to database" );
 	
-//
-// Obtain and encode users IP
-//
-if ( getenv( 'HTTP_X_FORWARDED_FOR' ) != '' )
-{
-  $client_ip = ( !empty($_SERVER['REMOTE_ADDR']) ) ? 
-    $_SERVER['REMOTE_ADDR'] : ( ( !empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : $REMOTE_ADDR );
-
-  if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/",
-                  getenv('HTTP_X_FORWARDED_FOR'), $ip_list) )
-  {
-    $private_ip = array( '/^0\./'
-                         ,'/^127\.0\.0\.1/'
-                         ,'/^192\.168\..*/'
-                         ,'/^172\.16\..*/'
-                         ,'/^10.\.*/'
-                         ,'/^224.\.*/'
-                         ,'/^240.\.*/'
-      );
-    $client_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);
-  }
-}
-else
-{
-  $client_ip = ( !empty($_SERVER['REMOTE_ADDR']) ) ? 
-    $_SERVER['REMOTE_ADDR'] : ( ( !empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : $REMOTE_ADDR );
-}
-$user_ip = encode_ip($client_ip);
-
 //
 // Setup gallery wide options, if this fails then we output a CRITICAL_ERROR
@@ -172,5 +140,5 @@
  FROM '.CONFIG_TABLE.'
 ;';
-if( !( $result = pwg_query( $query ) ) )
+if (!($result = pwg_query($query)))
 {
   die("Could not query config information");
@@ -195,13 +163,11 @@
 }
 
-//---------------
-// A partir d'ici il faudra dispatcher le code dans d'autres fichiers
-//---------------
-
-include(PHPWG_ROOT_PATH . 'include/user.inc.php');
+include(PHPWG_ROOT_PATH.'include/user.inc.php');
 
 // displaying the username in the language of the connected user, instead of
 // "guest" as you can find in the database
-if ( $user['is_the_guest'] ) $user['username'] = $lang['guest'];
-define('PREFIX_TABLE', $table_prefix);
+if ($user['is_the_guest'])
+{
+  $user['username'] = $lang['guest'];
+}
 ?>
Index: trunk/include/config.inc.php
===================================================================
--- trunk/include/config.inc.php	(revision 649)
+++ trunk/include/config.inc.php	(revision 650)
@@ -159,8 +159,4 @@
 $conf['info_nb_elements_page'] = 5;
 
-// default_language : language used if language set in user database is not
-// available
-$conf['default_language'] = 'en_UK.iso-8859-1';
-
 // show_queries : for debug purpose, show queries and execution times
 $conf['show_queries'] = false;
Index: trunk/include/functions_user.inc.php
===================================================================
--- trunk/include/functions_user.inc.php	(revision 649)
+++ trunk/include/functions_user.inc.php	(revision 650)
@@ -172,42 +172,4 @@
 }
 
-//
-// Initialise user settings on page load
-function init_userprefs($userdata)
-{
-  global $conf, $template, $lang, $lang_info;
-  
-  $language = (!empty($userdata['language']) && !$userdata['is_the_guest'] )?$userdata['language']:$conf['default_language'];
-
-  if (!empty($userdata['template']) and !$userdata['is_the_guest'])
-  {
-    $template = $userdata['template'];
-  }
-  else
-  {
-    $template = $conf['default_template'];
-  }
-
-  if ( !file_exists(@realpath(PHPWG_ROOT_PATH . 'language/' . $language . '/common.lang.php')) )
-  {
-    $language = $conf['default_language'];
-  }
-  include_once(PHPWG_ROOT_PATH . 'language/' . $language . '/common.lang.php');
-  
-  
-  if ($userdata['status'] == 'admin')
-  {
-    if ( !file_exists(@realpath(PHPWG_ROOT_PATH . 'language/' . $language. '/admin.lang.php')) )
-    {
-      $language = $conf['default_language'];
-    }
-  include_once(PHPWG_ROOT_PATH . 'language/' . $language . '/admin.lang.php');
-  include_once(PHPWG_ROOT_PATH . 'language/' . $language . '/faq.lang.php');
-  }
-
-  $template = setup_style($template);
-  return;
-}
-
 function setup_style($style)
 {
@@ -216,16 +178,4 @@
   $template = new Template(PHPWG_ROOT_PATH . $template_path . $template_name);
   return $template;
-}
-
-function encode_ip($dotquad_ip)
-{
-  $ip_sep = explode('.', $dotquad_ip);
-  return sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]);
-}
-
-function decode_ip($int_ip)
-{
-  $hexipbang = explode('.', chunk_split($int_ip, 2, '.'));
-  return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]);
 }
 
Index: trunk/include/user.inc.php
===================================================================
--- trunk/include/user.inc.php	(revision 649)
+++ trunk/include/user.inc.php	(revision 650)
@@ -128,12 +128,31 @@
 }
 
-$isadmin = false;
-if ($user['status'] == 'admin')
-{
-  $isadmin = true;
-}
 // calculation of the number of picture to display per page
 $user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page'];
 
-init_userprefs($user);
+if (empty($user['language'])
+    or !file_exists(PHPWG_ROOT_PATH.'language/'.
+                    $user['language'].'/common.lang.php'))
+{
+  $user['language'] = $conf['default_language'];
+}
+include_once(PHPWG_ROOT_PATH.'language/'.$user['language'].'/common.lang.php');
+
+// only if we are in the administration section
+if (defined('IN_ADMIN') and IN_ADMIN)
+{
+  $langdir = PHPWG_ROOT_PATH.'language/'.$user['language'];
+  if (!file_exists($langdir.'/admin.lang.php'))
+  {
+    $langdir = PHPWG_ROOT_PATH.'language/'.$conf['default_language'];
+  }
+  include_once($langdir.'/admin.lang.php');
+  include_once($langdir.'/faq.lang.php');
+}
+
+if (empty($user['template']))
+{
+  $user['template'] = $conf['default_template'];
+}
+$template = setup_style($user['template']);
 ?>
