diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index edafa985c2001efb28abaf4e655df7017e0d8499..95b5844269cacf364a161d9b775c69cd44095d06 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2006 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2007 Laurent Destailleur  <eldy@users.sourceforge.net>
  *
  * 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
@@ -37,62 +37,70 @@ if (!$user->admin)
 if ( (isset($_POST["action"]) && $_POST["action"] == 'update')
   || (isset($_POST["action"]) && $_POST["action"] == 'updateedit') )
 {
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"]);
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"]);
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_VILLE",$_POST["ville"]);
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_CP",$_POST["cp"]);
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS",$_POST["pays_id"]);
-    dolibarr_set_const($db, "MAIN_MONNAIE",$_POST["currency"]);
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL",$_POST["tel"]);
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX",$_POST["fax"]);
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL",$_POST["mail"]);
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB",$_POST["web"]);
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE",$_POST["note"]);
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD",$_POST["gencod"]);
-    if ($_FILES["logo"]["tmp_name"])
-      {
-        if (eregi('([^\\\/:]+)$',$_FILES["logo"]["name"],$reg))
-	  {
-            $original_file=$reg[1];
-	    
-            dolibarr_syslog("Move file ".$_FILES["logo"]["tmp_name"]." to ".$conf->societe->dir_logos.'/'.$original_file);
-	    if (! is_dir($conf->societe->dir_logos))
-	      {
-		create_exdir($conf->societe->dir_logos);
-	      }        
-            if (doliMoveFileUpload($_FILES["logo"]["tmp_name"],$conf->societe->dir_logos.'/'.$original_file))
-	      {
-                dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO",$original_file);
-	      }
-	    else
-	      {
-                $message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
-	      }	    
-	  }
-      }
-
-    dolibarr_set_const($db, "MAIN_INFO_CAPITAL",$_POST["capital"]);
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE",$_POST["forme_juridique_code"]);
-    dolibarr_set_const($db, "MAIN_INFO_SIREN",$_POST["siren"]);
-    dolibarr_set_const($db, "MAIN_INFO_SIRET",$_POST["siret"]);
-    dolibarr_set_const($db, "MAIN_INFO_APE",$_POST["ape"]);
-    dolibarr_set_const($db, "MAIN_INFO_RCS",$_POST["rcs"]);
-    dolibarr_set_const($db, "MAIN_INFO_TVAINTRA",$_POST["tva"]);
-
-    dolibarr_set_const($db, "FACTURE_TVAOPTION",$_POST["optiontva"]);
-
-    if ($_POST['action'] != 'updateedit')
-    {
-        Header("Location: ".$_SERVER["PHP_SELF"]);
-        exit;
-    }
+	dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"]);
+	dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"]);
+	dolibarr_set_const($db, "MAIN_INFO_SOCIETE_VILLE",$_POST["ville"]);
+	dolibarr_set_const($db, "MAIN_INFO_SOCIETE_CP",$_POST["cp"]);
+	dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS",$_POST["pays_id"]);
+	dolibarr_set_const($db, "MAIN_MONNAIE",$_POST["currency"]);
+	dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL",$_POST["tel"]);
+	dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX",$_POST["fax"]);
+	dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL",$_POST["mail"]);
+	dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB",$_POST["web"]);
+	dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE",$_POST["note"]);
+	dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD",$_POST["gencod"]);
+	if ($_FILES["logo"]["tmp_name"])
+	{
+		if (eregi('([^\\\/:]+)$',$_FILES["logo"]["name"],$reg))
+		{
+			$original_file=$reg[1];
+			
+			if (eregi('(\.png|\.jpg|\.jpeg)$',$original_file))
+			{
+				dolibarr_syslog("Move file ".$_FILES["logo"]["tmp_name"]." to ".$conf->societe->dir_logos.'/'.$original_file);
+				if (! is_dir($conf->societe->dir_logos))
+				{
+					create_exdir($conf->societe->dir_logos);
+				}        
+				if (doliMoveFileUpload($_FILES["logo"]["tmp_name"],$conf->societe->dir_logos.'/'.$original_file))
+				{
+					dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO",$original_file);
+				}
+				else
+				{
+					$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
+				}
+			}
+			else
+			{
+				$message .= '<div class="error">'.$langs->trans("ErrorOnlyPngJpgSupported").'</div>';
+			}	    
+		}
+	}
+
+	dolibarr_set_const($db, "MAIN_INFO_CAPITAL",$_POST["capital"]);
+	dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE",$_POST["forme_juridique_code"]);
+	dolibarr_set_const($db, "MAIN_INFO_SIREN",$_POST["siren"]);
+	dolibarr_set_const($db, "MAIN_INFO_SIRET",$_POST["siret"]);
+	dolibarr_set_const($db, "MAIN_INFO_APE",$_POST["ape"]);
+	dolibarr_set_const($db, "MAIN_INFO_RCS",$_POST["rcs"]);
+	dolibarr_set_const($db, "MAIN_INFO_TVAINTRA",$_POST["tva"]);
+
+	dolibarr_set_const($db, "FACTURE_TVAOPTION",$_POST["optiontva"]);
+
+	if ($_POST['action'] != 'updateedit' && ! $message)
+	{
+		Header("Location: ".$_SERVER["PHP_SELF"]);
+		exit;
+	}
 }
 
 if ($_GET["action"] == 'removelogo')
 {
-  $logofile=$conf->societe->dir_logos.'/'.$mysoc->logo;
-  @unlink($logofile);
-  dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO");
+	$logofile=$conf->societe->dir_logos.'/'.$mysoc->logo;
+	@unlink($logofile);
+	dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO");
+	$mysoc->logo='';
 }
 
 /*
@@ -183,7 +191,7 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit')
     {
       print '<a href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete")).'</a>';
         print ' &nbsp; ';
-        print '<img height="30" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.$mysoc->logo.'">';
+        print '<img height="30" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.urlencode($mysoc->logo).'">';
     }
   else
     {
diff --git a/htdocs/install/default.css b/htdocs/install/default.css
index 8c3dd46cc29675d3f2bf4e2ae78580977250f385..75c91e7d51f74a93f50ab34dcb2449fa2cdd5487 100644
--- a/htdocs/install/default.css
+++ b/htdocs/install/default.css
@@ -55,6 +55,14 @@ border-right: 1px solid #8CACBB;
 text-align: right;
 }
 
+inputdisabled
+{
+    background: #FDFDFD;
+    border: 1px solid #ACBCBB;
+    padding: 0px 0px 0px 0px;
+    margin: 0px 0px 0px 0px;
+}
+
 table.main {
 background: #dcdcd3;
 text-align: left;
@@ -62,8 +70,8 @@ border: 1px solid #8CACBB;
 }
 
 table.main-inside {
-padding-left: 20px;
-padding-right: 20px;
+padding-left: 10px;
+padding-right: 10px;
 margin-bottom: 20px;
 margin-top: 10px;
 }
@@ -150,7 +158,7 @@ background-color: #B5C5C5;
 td.label {
 background: #dcdcd3;
 color: #5945A3;
-padding: 0.5em 0.5em 0.5em;
+padding: 5px 5px 5px 5px;
 margin: 0em 0em 0em 0em;
 border-bottom: 1px solid #8CACBB;
 }
@@ -158,7 +166,7 @@ border-bottom: 1px solid #8CACBB;
 td.comment {
 background: #dcdcd3;
 color: black;
-padding: 0.5em 0.5em 0.5em;
+padding: 5px 5px 5px 5px;
 margin: 0em 0em 0em 0em;
 text-decoration:none;
 font-size: 13px;
@@ -166,11 +174,11 @@ border-bottom: 1px solid #8CACBB;
 }
 
 table {
-font-size: 13px;
+font-size: 12px;
 }
 
 .install
 {
 border: 1px solid #8CACBB;
 padding: 4px 4px 4px 4px;
-}
\ No newline at end of file
+}
diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php
index f042742d0c1ed1ae786ef97bc1d2fb11aa05dcc8..94ed4bb7fc5d6868d83f32d1e30ad38e268339c3 100644
--- a/htdocs/install/fileconf.php
+++ b/htdocs/install/fileconf.php
@@ -271,7 +271,7 @@ while (($file = readdir($handle))!==false)
 <?php echo $langs->trans("CreateDatabase"); ?>
 </td>
 
-<td class="label"><input type="checkbox" name="db_create_database"></td>
+<td class="label" valign="top"><input type="checkbox" name="db_create_database"></td>
 <td class="comment">
 <?php echo $langs->trans("CheckToCreateDatabase"); ?>
 </td>
@@ -302,7 +302,7 @@ while (($file = readdir($handle))!==false)
 <?php echo $langs->trans("CreateUser"); ?>
 </td>
 
-<td class="label"><input type="checkbox" name="db_create_user"></td>
+<td class="label" valign="top"><input type="checkbox" name="db_create_user"></td>
 <td class="comment">
 <?php echo $langs->trans("CheckToCreateUser"); ?>
 </td>
diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php
index 3f183ec82ff79813860f5c3d2a89b4590b6aa48d..be87d37f3f877e15df22b605d1f6bb4233bc5999 100644
--- a/htdocs/install/inc.php
+++ b/htdocs/install/inc.php
@@ -134,26 +134,26 @@ function pHeader($soutitre,$next,$action='set')
 	header("Content-type: text/html; charset=".$conf->character_set_client);
 
     print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
-    print '<html>';
-    print '<head>';
-    print '<meta http-equiv="content-type" content="text/html; charset='.$conf->character_set_client.'">';
-    print '<link rel="stylesheet" type="text/css" href="./default.css">';
-    print '<title>'.$langs->trans("DolibarrSetup").'</title>';
-    print '</head>';
-    print '<body>';
+    print '<html>'."\n";
+    print '<head>'."\n";
+    print '<meta http-equiv="content-type" content="text/html; charset='.$conf->character_set_client.'">'."\n";
+    print '<link rel="stylesheet" type="text/css" href="./default.css">'."\n";
+    print '<title>'.$langs->trans("DolibarrSetup").'</title>'."\n";
+    print '</head>'."\n";
+    print '<body>'."\n";
     print '<span class="titre">'.$langs->trans("DolibarrSetup");
     if ($soutitre) {
         print ' - '.$soutitre;
     }
-	print '</span>';
+	print '</span>'."\n";
 
-    print '<form action="'.$next.'.php" method="POST">';
-    print '<input type="hidden" name="testpost" value="ok">';
-    print '<input type="hidden" name="action" value="'.$action.'">';
+    print '<form action="'.$next.'.php" method="POST">'."\n";
+    print '<input type="hidden" name="testpost" value="ok">'."\n";
+    print '<input type="hidden" name="action" value="'.$action.'">'."\n";
 
-	print '<table class="main" width="100%"><tr><td>';
+	print '<table class="main" width="100%"><tr><td>'."\n";
 
-	print '<table class="main-inside" width="100%"><tr><td>';
+	print '<table class="main-inside" width="100%"><tr><td>'."\n";
 }
 
 function pFooter($nonext=0,$setuplang='')
@@ -162,8 +162,8 @@ function pFooter($nonext=0,$setuplang='')
     $langs->load("main");
     $langs->load("admin");
     
-    print '</td></tr></table>';
-    print '</td></tr></table>';
+    print '</td></tr></table>'."\n";
+    print '</td></tr></table>'."\n";
     
     if (! $nonext)
     {
@@ -174,9 +174,9 @@ function pFooter($nonext=0,$setuplang='')
         print '<input type="hidden" name="selectlang" value="'.$setuplang.'">';
     }
 
-    print '</form>';
-    print '</body>';
-    print '</html>';
+    print '</form>'."\n";
+    print '</body>'."\n";
+    print '</html>'."\n";
 }
 
 
diff --git a/htdocs/install/licence.php b/htdocs/install/licence.php
index 0f4f469a94e978418d890926660c1a51b88981ac..581e21c825473a42d0da18a904c1da357427e49d 100644
--- a/htdocs/install/licence.php
+++ b/htdocs/install/licence.php
@@ -1,6 +1,6 @@
 <?php
-/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 
- * Copyright (C) 2005 Laurent Destailleur  <eldy@users.sourceforge.net> 
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org> 
+ * Copyright (C) 2005-2007 Laurent Destailleur  <eldy@users.sourceforge.net> 
  *
  * 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
@@ -18,7 +18,6 @@
  *
  * $Id$
  * $Source$
- *
  */
 
 /**
@@ -40,9 +39,13 @@ dolibarr_install_syslog("licence: Entering licence.php page");
 
 pHeader($langs->trans("License"),"fileconf");
 
-print '<pre style="align: center; font-size: 12px">';
+print '<center>'."\n";
+//print '<pre style="align: center; font-size: 12px">';
+print '<textarea readonly="1" rows="26" cols="80">';
 $langs->print_file("html/gpl.txt",1);
-print '</pre>';
+//print '</pre>';
+print '</textarea>';
+print '</center>'."\n";
 
 pFooter(0,$setuplang);
 
diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang
index da1702de3194be2a1eb4840e00f7f85cf5d678d7..79b2250777863c4fa352367376322e739fda3641 100644
--- a/htdocs/langs/en_US/install.lang
+++ b/htdocs/langs/en_US/install.lang
@@ -25,7 +25,7 @@ PHPVersion=PHP Version
 YouCanContinue=You can continue...
 License=Using license
 ConfigurationFile=Configuration file
-WebPagesDirectory=Directory to store web pages
+WebPagesDirectory=Directory where web pages are stored
 DocumentsDirectory=Directory to store uploaded and generated documents
 URLRoot=URL Root
 DolibarrDatabase=Dolibarr Database
@@ -44,10 +44,10 @@ AdminPassword=Password for Dolibarr database administrator. Keep empty if you co
 CreateDatabase=Create database
 CreateUser=Create user
 DatabaseSuperUserAccess=Database - Superuser access
-CheckToCreateDatabase=Check box if database does not exist and must be created
-CheckToCreateUser=Check box if login does not exist and must be created
+CheckToCreateDatabase=Check box if database does not exist and must be created.<br>In this case, you must fill the login/password for superuser account at the bottom of this page.
+CheckToCreateUser=Check box if login does not exist and must be created.<br>In this case, you must fill the login/password for superuser account at the bottom of this page.
 Experimental=(experimental, non operationnal)
-DatabaseRootLoginDescription=Login for user user allowed to create new databases, useless if your database is already created (like when you are hosted by an web hosting provider).
+DatabaseRootLoginDescription=Login for the user allowed to create new databases or new users, useless if your database and your database login already exists (like when you're hosted by a web hosting provider).
 KeepEmptyIfNoPassword=Keep empty if user has no password
 SaveConfigurationFile=Save values
 ConfigurationSaving=Configuration file saving
@@ -101,11 +101,11 @@ AlreadyDone=Already migrated
 DatabaseVersion=Database version
 ServerVersion=Database server version
 YouMustCreateItAndAllowServerToWrite=You must create this directory and grant web server to write into.
-CharsetChoice=Ccharacter set choice
-CharacterSetClient=Character set used for generating web pages
+CharsetChoice=Character set choice
+CharacterSetClient=Character set used for generated HTML web pages
 CharacterSetClientComment=Choose character set for web display.<br/> Default proposed character set is the one of your database.
-CollationConnection=Collation used for the database
-CollationConnectionComment=Choose collation wanted for creating database.<br/>This parameter can't be defined if database already exists.
+CollationConnection=Character sorting order
+CollationConnectionComment=Choose page code that defines character's sorting order used by database. This parameter is also called 'collation' by some databases.<br/>This parameter can't be defined if database already exists.
 CharacterSetDatabase=Character set for database
 CharacterSetDatabaseComment=Choose character set wanted for database creation.<br/>This parameter can't be defined if database already exists.
 YouAskDatabaseCreationSoDolibarrNeedToConnect=You ask to create database login <b>%s</b>, but for this, Dolibarr need to connect to server <b>%s</b> with super user <b>%s</b> permissions.
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index a3159c8dd52333425f8e0920fd8d5cde8f889100..492f96219c4da04e4f9f35b96dadad41462abfce 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -33,6 +33,8 @@ ErrorSomeErrorWereFoundRollbackIsDone=Some errors were found. We rollback change
 ErrorConfigParameterNotDefined=Parameter <b>%s</b> is not defined inside Dolibarr config file <b>conf.php</b>.
 ErrorCantLoadUserFromDolibarrDatabase=Failed to find user <b>%s</b> in Dolibarr database.
 ErrorNoVATRateDefinedForSellerCountry=Error, no vat rates defined for country '%s'.
+ErrorFailedToSaveFile=Error, failed to save file.
+ErrorOnlyPngJpgSupported=Error, only .png and .jpg image format file are supported.
 DolibarrInHttpAuthenticationSoPasswordUseless=Dolibarr authentication mode is setup to <b>%s</b> in configuration file <b>conf.php</b>.<br>This means that password database is extern to Dolibarr, so changing this field may have no effects.
 Undefined=Undefined
 PasswordForgotten=Password forgotten ?
diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang
index 9c03ac2594a2c53af596424683544aea67f8ca8b..4dbd35fcd4ebd9fd1f07fb2a42e968693587a9c6 100755
--- a/htdocs/langs/en_US/users.lang
+++ b/htdocs/langs/en_US/users.lang
@@ -74,7 +74,6 @@ LoginAccountDisable=Account disabled, put a new login to activate it.
 LoginAccountDisableInDolibarr=Account disabled in Dolibarr.
 LoginAccountDisableInLdap=Account disabled in the domain.
 UsePersonalValue=Use personal value
-ErrorFailedToSaveFile=Error - Failed to save file
 GuiLanguage=Interface language
 InternalUser=Internal user
 MyInformations=My data
diff --git a/htdocs/langs/fr_FR/install.lang b/htdocs/langs/fr_FR/install.lang
index d30c2ee920f414da5952a7a49fd1fdbf3964a15e..8256318434df855c22cc0348c191be6d5b94b21e 100644
--- a/htdocs/langs/fr_FR/install.lang
+++ b/htdocs/langs/fr_FR/install.lang
@@ -25,8 +25,8 @@ PHPVersion=Version PHP
 YouCanContinue=Vous pouvez continuer...
 License=Licence d'utilisation
 ConfigurationFile=Fichier de configuration
-WebPagesDirectory=R�pertoire d'installation des pages web
-DocumentsDirectory=R�pertoire contenant les documents g�n�r�s (PDF, etc.)
+WebPagesDirectory=R�pertoire contenat les pages web
+DocumentsDirectory=R�pertoire devant contenir les documents g�n�r�s (PDF, etc.)
 URLRoot=URL Racine
 DolibarrDatabase=Base de donn�es Dolibarr
 DatabaseChoice=Choix de la base de donn�es
@@ -44,10 +44,10 @@ AdminPassword=Mot de passe de l'administrateur de la base de donn
 CreateDatabase=Cr�er la base de donn�e
 CreateUser=Cr�er l'utilisateur
 DatabaseSuperUserAccess=Base de donn�es - Acc�s super utilisateur
-CheckToCreateDatabase=Cochez cette option si la base de donn�es n'existe pas et doit �tre cr��e
-CheckToCreateUser=Cochez cette option si le login n'existe pas et doit �tre cr��
+CheckToCreateDatabase=Cochez cette option si la base de donn�es n'existe pas et doit �tre cr��e.<br>Dans ce cas, il faut renseigner le login/mot de passe du superutilisateur au bas de cette page.
+CheckToCreateUser=Cochez cette option si le login n'existe pas et doit �tre cr��.<br>Dans ce cas, il faut renseigner le login/mot de passe du superutilisateur au bas de cette page.
 Experimental=(exp�rimental, non op�rationnel)
-DatabaseRootLoginDescription=Login de l'utilisateur ayant les droits de cr�ation de la base de donn�es, inutile si votre base est d�j� cr��e (comme lorsque vous �tes chez un h�bergeur).
+DatabaseRootLoginDescription=Login de l'utilisateur de la base ayant les droits de cr�ation de base de donn�es ou de compte pour la base, inutile si la base et son compte d'acc�s existe d�j� (comme lorsque vous �tes chez un h�bergeur).
 KeepEmptyIfNoPassword=Laissez vide si l'utilisateur n'a pas de mot de passe
 SaveConfigurationFile=Enregistrement du fichier de configuration
 ConfigurationSaving=Enregistrement du fichier de configuration
@@ -104,8 +104,8 @@ YouMustCreateItAndAllowServerToWrite=Vous devez cr
 CharsetChoice=Choix du codage des caract�res
 CharacterSetClient=Codage utilis� pour l'affichage des pages
 CharacterSetClientComment=Veuillez choisir le codage que vous souhaitez pour l'affichage des pages.<br/> Le codage propos� par d�faut est celui de votres base de donn�e par d�faut.
-CollationConnection=Collation utilis�e pour la base de donn�es
-CollationConnectionComment=Veuillez choisir la collation que vous d�sirez choisir pour la cr�ation de la base de donn�es.<br/> Ce param�tre n'est pas s�lectionnable si votre base est d�j� cr��e.
+CollationConnection=Ordre de tri utilis� pour la base de donn�es
+CollationConnectionComment=Veuillez choisir la page de code d�finissant l'ordre de tri des caract�res utilis� par la base de donn�e. Ce param�tre est aussi appel� 'collation' par certaines bases de donn�es.<br/> Ce param�tre n'est pas s�lectionnable si votre base est d�j� cr��e.
 CharacterSetDatabase=Codage utilis� pour la base de donn�es
 CharacterSetDatabaseComment=Veuillez choisir le codage que vous d�sirez choisir pour la cr�ation de la base de donn�es.<br/> Ce param�tre n'est pas s�lectionnable si votre base est d�j� cr��e.
 YouAskDatabaseCreationSoDolibarrNeedToConnect=Vous avez demand� la cr�ation du login de base de donn�e <b>%s</b>, mais pour cela, Dolibarr doit se connecter sur le serveur <b>%s</b> via le super utilisateur <b>%s</b>.
diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang
index 92314ef498ec1b990e7231484e88f06cad45535a..3b70de67732df99b9caf0eebed8f5bd9f6cea06a 100644
--- a/htdocs/langs/fr_FR/main.lang
+++ b/htdocs/langs/fr_FR/main.lang
@@ -33,6 +33,8 @@ ErrorSomeErrorWereFoundRollbackIsDone=Des erreurs ont 
 ErrorConfigParameterNotDefined=Le parametre <b>%s</b> n'est pas d�fini dans le fichier de configuration Dolibarr <b>conf.php</b>.
 ErrorCantLoadUserFromDolibarrDatabase=Impossible de trouver l'utilisateur <b>%s</b> dans la base Dolibarr.
 ErrorNoVATRateDefinedForSellerCountry=Erreur, aucun taux tva d�fini pour le pays '%s'.
+ErrorFailedToSaveFile=Erreur, l'enregistrement du fichier a �chou�.
+ErrorOnlyPngJpgSupported=Erreur, seuls les formats images .jpg et .png sont support�s.
 DolibarrInHttpAuthenticationSoPasswordUseless=Dolibarr est configur� en mode authentification <b>%s</b> dans son fichier de configuration <b>conf.php</b>.<br>Cela signifie que la base des mots de passe est externe � Dolibarr, aussi toute modification de ce champ peut s'av�rer sans effet.
 Undefined=Non d�fini
 PasswordForgotten=Mot de passe oubli� ?
diff --git a/htdocs/langs/fr_FR/users.lang b/htdocs/langs/fr_FR/users.lang
index 5b568ea0acee273d30b203349e499f03662ff4fb..a6caa5bd4103c40cb511ca2f65b7034a2777ee06 100755
--- a/htdocs/langs/fr_FR/users.lang
+++ b/htdocs/langs/fr_FR/users.lang
@@ -74,7 +74,6 @@ LoginAccountDisable=Le compte est d
 LoginAccountDisableInDolibarr=Le compte est d�sactiv� sur Dolibarr.
 LoginAccountDisableInLdap=Le compte est d�sactiv� sur le domaine.
 UsePersonalValue=Utiliser valeur personalis�e
-ErrorFailedToSaveFile=Erreur - l'enregistrement du fichier a �chou�
 GuiLanguage=Langage de l'interface
 InternalUser=Utilisateur interne
 MyInformations=Mes informations
diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php
index a269e4cb8b5a39e5872fdd2c47492fc7aa6b897d..437b729602218b1fb7e75ada3fc99d01f01e1366 100644
--- a/htdocs/lib/functions.inc.php
+++ b/htdocs/lib/functions.inc.php
@@ -1124,77 +1124,78 @@ function info_admin($texte)
 */
 function dol_loginfunction($notused,$pearstatus)
 {
-    global $langs,$conf;
-    $langs->load("main");
-    $langs->load("other");
+	global $langs,$conf,$mysoc;
+	$langs->load("main");
+	$langs->load("other");
 
-    $conf->css  = "theme/".$conf->theme."/".$conf->theme.".css";
-    // Si feuille de style en php existe
-    if (file_exists(DOL_DOCUMENT_ROOT.'/'.$conf->css.".php")) $conf->css.=".php";
+	$conf->css  = "theme/".$conf->theme."/".$conf->theme.".css";
+	// Si feuille de style en php existe
+	if (file_exists(DOL_DOCUMENT_ROOT.'/'.$conf->css.".php")) $conf->css.=".php";
 
-    // Ce DTD est KO car inhibe document.body.scrollTop
-    //print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
-    // Ce DTD est OK
-    print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
+	// Ce DTD est KO car inhibe document.body.scrollTop
+	//print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
+	// Ce DTD est OK
+	print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
 
 	// En tete html
-    print "<html>\n";
-    print "<head>\n";
-    print '<meta name="robots" content="noindex,nofollow">'."\n";      // Evite indexation par robots
+	print "<html>\n";
+	print "<head>\n";
+	print '<meta name="robots" content="noindex,nofollow">'."\n";      // Evite indexation par robots
 	print "<title>Dolibarr Authentification</title>\n";
 
-    print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/'.$conf->css.'">'."\n";
-
-    print '<style type="text/css">'."\n";
-    print '<!--'."\n";
-    print '#login {';
-    print '  margin-top: 70px;';
-    print '  margin-bottom: 30px;';
-    print '  text-align: center;';
-    print '  font: 12px arial,helvetica;';
-    print '}'."\n";
-    print '#login table {';
-    print '  border: 1px solid #C0C0C0;';
-    if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_background.png'))
-    {
-      print 'background: #F0F0F0 url('.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png) repeat-x;';
-    }
-    else
-    {
-      print 'background: #F0F0F0 url('.DOL_URL_ROOT.'/theme/login_background.png) repeat-x;';
-    }
-    print 'font-size: 12px;';
-    print '}'."\n";
-    print '-->'."\n";
-    print '</style>'."\n";
-    print '<script language="javascript" type="text/javascript">'."\n";
-    print "function donnefocus() {\n";
-    print "document.getElementsByTagName('INPUT')[0].focus();";
-    print "}\n";
-    print '</script>'."\n";
-    print '</head>'."\n";
-
-    // Body
+	print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/'.$conf->css.'">'."\n";
+
+	print '<style type="text/css">'."\n";
+	print '<!--'."\n";
+	print '#login {';
+	print '  margin-top: 70px;';
+	print '  margin-bottom: 30px;';
+	print '  text-align: center;';
+	print '  font: 12px arial,helvetica;';
+	print '}'."\n";
+	print '#login table {';
+	print '  border: 1px solid #C0C0C0;';
+	if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_background.png'))
+	{
+		print 'background: #F0F0F0 url('.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png) repeat-x;';
+	}
+	else
+	{
+		print 'background: #F0F0F0 url('.DOL_URL_ROOT.'/theme/login_background.png) repeat-x;';
+	}
+	print 'font-size: 12px;';
+	print '}'."\n";
+	print '-->'."\n";
+	print '</style>'."\n";
+	print '<script language="javascript" type="text/javascript">'."\n";
+	print "function donnefocus() {\n";
+	print "document.getElementsByTagName('INPUT')[0].focus();";
+	print "}\n";
+	print '</script>'."\n";
+	print '</head>'."\n";
+
+	// Body
 	print '<body class="body" onload="donnefocus();">';
 
 	// Start Form
-    print '<form id="login" name="login" method="post" action="';
-    print $_SERVER['PHP_SELF'];
-    print $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:'';
-    print '">';
+	print '<form id="login" name="login" method="post" action="';
+	print $_SERVER['PHP_SELF'];
+	print $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:'';
+	print '">';
 
 	// Table 1
-    print '<table cellpadding="0" cellspacing="0" border="0" align="center" width="400">';
-    if (file_exists(DOL_DOCUMENT_ROOT.'/logo.png'))
-    {
-      print '<tr><td colspan="3" style="text-align:center;">';
-      print '<img src="/logo.png"></td></tr>';
-    }
-    else
-    {
-      print '<tr class="vmenu"><td align="center">Dolibarr '.DOL_VERSION.'</td></tr>';
-    }
-    print '</table>';
+	print '<table cellpadding="0" cellspacing="0" border="0" align="center" width="400">';
+	if (file_exists(DOL_DOCUMENT_ROOT.'/logo.png'))
+	{
+		// Cas qui ne devrait pas arriver (pour compatibilit�)
+		print '<tr><td colspan="3" style="text-align:center;">';
+		print '<img src="/logo.png"></td></tr>';
+	}
+	else
+	{
+		print '<tr class="vmenu"><td align="center">Dolibarr '.DOL_VERSION.'</td></tr>';
+	}
+	print '</table>';
 	print '<br>';
 
 	// Table 2
@@ -1205,41 +1206,45 @@ function dol_loginfunction($notused,$pearstatus)
 	print '<tr><td align="left"><br> &nbsp; <b>'.$langs->trans("Login").'</b>  &nbsp;</td>';
 	print '<td><input name="username" class="flat" size="15" maxlength="25" value="" tabindex="1" /></td>';
 
-    // Affiche logo du theme si existe, sinon logo commun
-    if ($conf->main_authentication) $title.=$langs->trans("AuthenticationMode").': '.$conf->main_authentication;
-    if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png'))
-    {
-        print '<td rowspan="2"><img title="'.$title.'" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png"></td>';
-    }
-    else
-    {
-        print '<td rowspan="2"><img title="'.$title.'" src="'.DOL_URL_ROOT.'/theme/login_logo.png"></td>';
-    }
+	if ($conf->main_authentication) $title.=$langs->trans("AuthenticationMode").': '.$conf->main_authentication;
+	// Affiche logo du theme si existe, sinon logo commun
+	$urllogo=DOL_URL_ROOT.'/theme/login_logo.png';
+	if (is_readable($conf->societe->dir_logos.'/'.$mysoc->logo))
+	{
+		$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.urlencode($mysoc->logo);
+		$height=100;	// \TODO Forcer la hauteur uniquement si hauteur > 100 ou largeur > 100
+	}
+	elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png'))
+	{
+		$urllogo=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png';
+		$height=80;
+	}
+	print '<td rowspan="2"><img title="'.$title.'" height="'.$height.'" src="'.$urllogo.'"></td>';
 
-    print '</tr>';
+	print '</tr>';
 
-    print '<tr><td align="left" valign="top"> &nbsp; <b>'.$langs->trans("Password").'</b> &nbsp; </td>';
-    print '<td valign="top" nowrap="nowrap"><input name="password" class="flat" type="password" size="15" maxlength="30" tabindex="2">';
+	print '<tr><td align="left" valign="top"> &nbsp; <b>'.$langs->trans("Password").'</b> &nbsp; </td>';
+	print '<td valign="top" nowrap="nowrap"><input name="password" class="flat" type="password" size="15" maxlength="30" tabindex="2">';
 	print '</td></tr>';
 
-    print '<tr><td colspan="3" style="text-align:center;"><br>';
-    print '<input type="submit" class="button" value="&nbsp; '.$langs->trans("Connection").' &nbsp;" tabindex="4" />';
-    print '</td></tr>';
+	print '<tr><td colspan="3" style="text-align:center;"><br>';
+	print '<input type="submit" class="button" value="&nbsp; '.$langs->trans("Connection").' &nbsp;" tabindex="4" />';
+	print '</td></tr>';
 
 	if (! $conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)
 	{
 		print '<tr><td colspan="3" align="center"><a style="color: #888888; font-size: 10px" href="'.DOL_URL_ROOT.'/user/passwordforgotten.php">('.$langs->trans("PasswordForgotten").')</a></td></tr>';
 	}
 
-    print '</table>';
-    print '<input type="hidden" name="loginfunction" value="loginfunction" />';
+	print '</table>';
+	print '<input type="hidden" name="loginfunction" value="loginfunction" />';
 
-    print '</form>';
+	print '</form>';
 
 	// Message
-    if ($_SESSION["loginmesg"] || ! empty($pearstatus))
-    {
-    	print '<center><table width="60%"><tr><td align="center" class="small"><div class="error">';
+	if ($_SESSION["loginmesg"] || ! empty($pearstatus))
+	{
+		print '<center><table width="60%"><tr><td align="center" class="small"><div class="error">';
 		if ($pearstatus == AUTH_EXPIRED) print "<i>Your session expired. Please login again!</i>\n";
 		elseif ($pearstatus == AUTH_IDLED) print "<i>You have been idle for too long. Please login again!</i>\n";
 		elseif ($pearstatus == AUTH_WRONG_LOGIN) print $langs->trans("ErrorBadLoginPassword");
@@ -1252,11 +1257,11 @@ function dol_loginfunction($notused,$pearstatus)
 	}
 	if ($conf->global->MAIN_HOME)
 	{
-	    print '<center><table cellpadding="0" cellspacing="0" border="0" align="center" width="750"><tr><td align="center">';
-	    print nl2br($conf->global->MAIN_HOME);
-	    print '</td></tr></table></center><br>';
+		print '<center><table cellpadding="0" cellspacing="0" border="0" align="center" width="750"><tr><td align="center">';
+		print nl2br($conf->global->MAIN_HOME);
+		print '</td></tr></table></center><br>';
 	}
-    
+	
 	// Fin entete html
 	print "\n</body>\n</html>";
 }
diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php
index 58cd705ef1da3383414bc29ba01092119e39d0b1..38151d25ea2fb294c2104f8dabefed5531f52285 100644
--- a/htdocs/viewimage.php
+++ b/htdocs/viewimage.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2005-2006 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2007 Laurent Destailleur  <eldy@users.sourceforge.net>
  *
  * 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
@@ -28,18 +28,31 @@
 		\version    $Revision$
 */
 
-require_once("main.inc.php");
-
 
 // C'est un wrapper, donc header vierge
 function llxHeader() { }
 
 
-
 $original_file = urldecode($_GET["file"]);
 $modulepart = urldecode($_GET["modulepart"]);
 $type = urldecode($_GET["type"]);
 
+// Protection, on interdit les .. dans les chemins
+$original_file = eregi_replace('\.\.','',$original_file);
+
+
+if ($modulepart == 'companylogo')
+{
+	// Pour companylogo, on charge juste environnement sans logon qui charge le user
+	require_once("master.inc.php");
+}
+else
+{
+	// Pour autre que companylogo, on charge environnement + info issus de logon comme le user
+	require_once("main.inc.php");
+}
+
+
 
 $accessallowed=0;
 if ($modulepart)