diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php index 098b6c6528aa16380d4b3ec6fb83cd15fdc77576..9cce8dc0625e1c8b0eb9581116f179efec5630da 100644 --- a/htdocs/admin/system/constall.php +++ b/htdocs/admin/system/constall.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr> * * This program is free software; you can redistribute it and/or modify @@ -27,6 +27,8 @@ require("./pre.inc.php"); $langs->load("admin"); +$langs->load("user"); +$langs->load("install"); if (!$user->admin) @@ -41,6 +43,100 @@ llxHeader(); print_fiche_titre($langs->trans("SummaryConst"),'','setup'); + +print_titre($langs->trans("ConfigurationFile")); +// Parameters in conf.php file +$configfileparameters=array( +// 'separator', + 'dolibarr_main_url_root', + 'dolibarr_main_document_root', + 'dolibarr_main_data_root', + 'separator', + 'dolibarr_main_db_host', + 'dolibarr_main_db_port', + 'dolibarr_main_db_name', + 'dolibarr_main_db_type', + 'dolibarr_main_db_user', + 'dolibarr_main_db_pass', + 'dolibarr_main_db_character_set', + 'dolibarr_main_db_collation', + 'separator', + 'dolibarr_main_authentication', + 'separator', + 'dolibarr_main_auth_ldap_login_attribute', + 'dolibarr_main_auth_ldap_host', + 'dolibarr_main_auth_ldap_port', + 'dolibarr_main_auth_ldap_version', + 'dolibarr_main_auth_ldap_dn', + 'dolibarr_main_auth_ldap_admin_login', + 'dolibarr_main_auth_ldap_admin_pass', + 'dolibarr_main_auth_ldap_debug' + ); +$configfilelib=array( +// 'separator', + $langs->trans("URLRoot"), + $langs->trans("DocumentRootServer"), + $langs->trans("DataRootServer"), + 'separator', + $langs->trans("DatabaseServer"), + $langs->trans("DatabasePort"), + $langs->trans("DatabaseName"), + $langs->trans("DriverType"), + $langs->trans("User"), + $langs->trans("Password"), + $langs->trans("DBStoringCharset"), + $langs->trans("DBSortingCharset"), + 'separator', + $langs->trans("AuthenticationMode"), + 'separator', + 'dolibarr_main_auth_ldap_login_attribute', + 'dolibarr_main_auth_ldap_host', + 'dolibarr_main_auth_ldap_port', + 'dolibarr_main_auth_ldap_version', + 'dolibarr_main_auth_ldap_dn', + 'dolibarr_main_auth_ldap_admin_login', + 'dolibarr_main_auth_ldap_admin_pass', + 'dolibarr_main_auth_ldap_debug' + ); +$var=true; +print '<table class="noborder" width="100%">'; +print '<tr class="liste_titre"><td width="280">'.$langs->trans("Label").'</td>'; +print '<td>'.$langs->trans("Parameter").'</td>'; +print '<td>'.$langs->trans("Value").'</td>'; +print '</tr>'."\n"; +$i=0; +foreach($configfileparameters as $key) +{ + $var=!$var; + print "<tr ".$bc[$var].">"; + if ($key == 'separator') + { + print '<td colspan="3"> </td>'; + } + else + { + print "<td>".$configfilelib[$i].'</td><td>'.$key.'</td>'; + print "<td>"; + if ($key == 'dolibarr_main_db_pass') print preg_replace('/./i','*',${$key}); + else print ${$key}; + // TODO Afficher charset effectif de base $db + if ($key == 'dolibarr_main_db_charset') + { + + + } + print "</td>"; + } + print "</tr>\n"; + $i++; +} +print '</table>'; +print '<br>'; + + + +// Parameters in database +print_titre($langs->trans("Database")); print '<table class="noborder">'; print '<tr class="liste_titre">'; print '<td>'.$langs->trans("Parameter").'</td>'; @@ -73,18 +169,18 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; $var=True; - + while ($i < $num) { $obj = $db->fetch_object($resql); $var=!$var; - + print '<tr '.$bc[$var].'>'; print '<td>'.$obj->name.'</td>'."\n"; print '<td>'.$obj->value.'</td>'."\n"; if (empty($conf->multicompany->enabled) || !$user->entity) print '<td>'.$obj->entity.'</td>'."\n"; // If superadmin or multicompany disabled print "</tr>\n"; - + $i++; } } diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 692dec390676e9c856e00a746274e2b963b9ebca..9a0f8ec04584e6de7d1d4e5a6f0b957199385034 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -18,8 +18,8 @@ */ /** - * \file htdocs/lib/memory.lib.php - * \brief Fichier page info systemes Dolibarr + * \file htdocs/admin/system/dolibarr.php + * \brief Page to show Dolibarr informations * \version $Id$ */ @@ -74,7 +74,7 @@ print '<br>'; // Session $var=true; print '<table class="noborder" width="100%">'; -print '<tr class="liste_titre"><td>'.$langs->trans("Version").'</td><td colspan="2">'.$langs->trans("Value").'</td></tr>'."\n"; +print '<tr class="liste_titre"><td>'.$langs->trans("Session").'</td><td colspan="2">'.$langs->trans("Value").'</td></tr>'."\n"; $var=!$var; print "<tr ".$bc[$var]."><td width=\"300\">".$langs->trans("SessionSavePath").'</td><td colspan="2">'.session_save_path()."</td></tr>\n"; $var=!$var; diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index 55b55c9c321fd6270da6b258d1a76c71ebc9208f..6e18a676f42807187fea77c024dfef799a0d241a 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -91,94 +91,5 @@ print "<tr $bc[0]><td width=\"280\">".$langs->trans("Version")."</td><td>" .$dbl print '</table>'; print '<br>'; -// conf.php file -$configfileparameters=array( -// 'separator', - 'dolibarr_main_url_root', - 'dolibarr_main_document_root', - 'dolibarr_main_data_root', - 'separator', - 'dolibarr_main_db_host', - 'dolibarr_main_db_port', - 'dolibarr_main_db_name', - 'dolibarr_main_db_type', - 'dolibarr_main_db_user', - 'dolibarr_main_db_pass', - 'dolibarr_main_db_character_set', - 'dolibarr_main_db_collation', - 'separator', - 'dolibarr_main_authentication', - 'separator', - 'dolibarr_main_auth_ldap_login_attribute', - 'dolibarr_main_auth_ldap_host', - 'dolibarr_main_auth_ldap_port', - 'dolibarr_main_auth_ldap_version', - 'dolibarr_main_auth_ldap_dn', - 'dolibarr_main_auth_ldap_admin_login', - 'dolibarr_main_auth_ldap_admin_pass', - 'dolibarr_main_auth_ldap_debug' - ); -$configfilelib=array( -// 'separator', - $langs->trans("URLRoot"), - $langs->trans("DocumentRootServer"), - $langs->trans("DataRootServer"), - 'separator', - $langs->trans("DatabaseServer"), - $langs->trans("DatabasePort"), - $langs->trans("DatabaseName"), - $langs->trans("DriverType"), - $langs->trans("User"), - $langs->trans("Password"), - $langs->trans("DBStoringCharset"), - $langs->trans("DBSortingCharset"), - 'separator', - $langs->trans("AuthenticationMode"), - 'separator', - 'dolibarr_main_auth_ldap_login_attribute', - 'dolibarr_main_auth_ldap_host', - 'dolibarr_main_auth_ldap_port', - 'dolibarr_main_auth_ldap_version', - 'dolibarr_main_auth_ldap_dn', - 'dolibarr_main_auth_ldap_admin_login', - 'dolibarr_main_auth_ldap_admin_pass', - 'dolibarr_main_auth_ldap_debug' - ); -$var=true; -print '<table class="noborder" width="100%">'; -print '<tr class="liste_titre"><td width="280">'.$langs->trans("ConfigurationFile").'</td>'; -print '<td>'.$langs->trans("Parameter").'</td>'; -print '<td>'.$langs->trans("Value").'</td>'; -print '</tr>'."\n"; -$i=0; -foreach($configfileparameters as $key) -{ - $var=!$var; - print "<tr ".$bc[$var].">"; - if ($key == 'separator') - { - print '<td colspan="3"> </td>'; - } - else - { - print "<td>".$configfilelib[$i].'</td><td>'.$key.'</td>'; - print "<td>"; - if ($key == 'dolibarr_main_db_pass') print preg_replace('/./i','*',${$key}); - else print ${$key}; - // TODO Afficher charset effectif de base $db - if ($key == 'dolibarr_main_db_charset') - { - - - } - print "</td>"; - } - print "</tr>\n"; - $i++; -} -print '</table>'; -print '<br>'; - - llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 3ccc9bbed48fcfab13f2f2b5ae7dbe6b4f3edfcc..c72a5ab216643bdd4a78898cdaf262b5fa57073d 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -137,9 +137,8 @@ $dolibarr_main_authentication="dolibarr"; # dolibarr_main_force_https # This parameter allows to force the HTTPS mode. -# Warning: If you enable this parameter, your dolibarr_main_url_root parameter -# must contains an URL with https and web server must be configured to respond -# to such an URL. +# Warning: If you enable this parameter, your web server must be configured +# to respond URL with https protocol. # Default value: 0 # Possible values: 0 or 1 # Examples: diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ebc897c8c6f5ef1dbe9b9f985817ac7dde43d689..25447dd1546fbc0abfbb3b8bd8ed14cc348c2bc7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -133,36 +133,45 @@ session_start(); // This include will set: config file variable $dolibarr_xxx, $conf, $langs and $mysoc objects require_once("master.inc.php"); -// Check if HTTPS +// Force HTTPS if required ($conf->file->main_force_https is 0/1 or https dolibarr root url) if ($conf->file->main_force_https) { - if (! empty($_SERVER["SCRIPT_URI"])) // If SCRIPT_URI supported by server + $newurl=''; + if ($conf->file->main_force_https == '1') { - if (preg_match('/^http:/i',$_SERVER["SCRIPT_URI"]) && ! preg_match('/^https:/i',$_SERVER["SCRIPT_URI"])) // If link is http + if (! empty($_SERVER["SCRIPT_URI"])) // If SCRIPT_URI supported by server { - $newurl=preg_replace('/^http:/i','https:',$_SERVER["SCRIPT_URI"]); - - dol_syslog("main.inc: dolibarr_main_force_https is on, we make a redirect to ".$newurl); - header("Location: ".$newurl); - exit; + if (preg_match('/^http:/i',$_SERVER["SCRIPT_URI"]) && ! preg_match('/^https:/i',$_SERVER["SCRIPT_URI"])) // If link is http + { + $newurl=preg_replace('/^http:/i','https:',$_SERVER["SCRIPT_URI"]); + } } - } - else // Check on HTTPS environment variable (Apache/mod_ssl only) - { - // $_SERVER["HTTPS"] is 'on' when link is https, otherwise $_SERVER["HTTPS"] is empty or 'off' - if (empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') // If link is http + else // Check HTTPS environment variable (Apache/mod_ssl only) { - $uri=preg_replace('/^http(s?):\/\//i','',$dolibarr_main_url_root); - $val=explode('/',$uri); - $domaineport=$val[0]; // $domaineport contient nom domaine et port - - $newurl='https://'.$domaineport.$_SERVER["REQUEST_URI"]; - //print 'eee'.$newurl; exit; - dol_syslog("main.inc: dolibarr_main_force_https is on, we make a redirect to ".$newurl); - header("Location: ".$newurl); - exit; + // $_SERVER["HTTPS"] is 'on' when link is https, otherwise $_SERVER["HTTPS"] is empty or 'off' + if (empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') // If link is http + { + $uri=preg_replace('/^http(s?):\/\//i','',$dolibarr_main_url_root); + $val=explode('/',$uri); // $val[0] contains domain name and port + $newurl='https://'.$val[0].$_SERVER["REQUEST_URI"]; + } } } + else + { + $newurl=$conf->file->main_force_https.$_SERVER["REQUEST_URI"]; + } + // Start redirect + if ($newurl) + { + dol_syslog("main.inc: dolibarr_main_force_https is on, we make a redirect to ".$newurl); + header("Location: ".$newurl); + exit; + } + else + { + dol_syslog("main.inc: dolibarr_main_force_https is on but we failed to forge new https url so no redirect is done", LOG_WARNING); + } } diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 6eddd0ae2e8c62597ffe5f7d134a0f6c0537043d..2967e94cdca444b25a23e7af2e8a3a2a99d56a55 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -75,6 +75,12 @@ if (empty($dolibarr_main_db_host)) print 'Please, click <a href="install/index.php">here to finish Dolibarr install process</a> ...'."\n"; exit; } +if (empty($dolibarr_main_url_root)) +{ + print 'Value for parameter dolibarr_main_url_root is not defined in your conf.php file'."\n"; + print 'You must add here your Dolibarr full Url (Example: http://mydomain/myurl/)'."\n"; + exit; +} if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql' if (empty($dolibarr_main_data_root)) { @@ -86,6 +92,7 @@ if (empty($dolibarr_main_data_root)) // Define some constants define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); // Filesystem pages php (htdocs) define('DOL_DATA_ROOT', $dolibarr_main_data_root); // Filesystem donnes (documents) +// If dolibarr_main_url_root = auto (Hidden feature for developers only), we try to forge it. if ($dolibarr_main_url_root == 'auto' && ! empty($_SERVER["SCRIPT_URL"]) && ! empty($_SERVER["SCRIPT_URI"])) { $dolibarr_main_url_root=str_replace($_SERVER["SCRIPT_URL"],'',$_SERVER["SCRIPT_URI"]);