2006-02-03 17:42:39 +01:00
< ? PHP
2007-04-07 13:54:20 +02:00
/* Copyright ( C ) 2002 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2006-02-03 17:42:39 +01:00
* Copyright ( C ) 2003 Xavier Dutoit < doli @ sydesy . com >
2007-01-31 18:52:54 +01:00
* Copyright ( C ) 2004 - 2007 Laurent Destailleur < eldy @ users . sourceforge . net >
2006-02-03 17:42:39 +01:00
* Copyright ( C ) 2004 Sebastien Di Cintio < sdicintio @ ressource - toi . org >
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
2007-05-24 11:26:28 +02:00
* Copyright ( C ) 2005 - 2007 Regis Houssin < regis . houssin @ cap - networks . com >
2006-02-03 17:42:39 +01:00
* Copyright ( C ) 2005 Simon Tosser < simon @ kornog - computing . com >
2006-02-03 18:48:47 +01:00
* Copyright ( C ) 2006 Andre Cianfarani < andre . cianfarani @ acdeveloppement . net >
2006-02-03 17:42:39 +01:00
*
* 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 ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
* $Id $
* $Source $
*/
/**
2007-04-07 13:54:20 +02:00
\file htdocs / master . inc . php
\brief Fichier de preparation de l ' environnement Dolibarr
\version $Revision $
2006-02-03 17:42:39 +01:00
*/
2007-05-01 22:07:47 +02:00
define ( 'DOL_VERSION' , '2.2-dev' );
2006-11-07 23:56:04 +01:00
define ( 'EURO' , chr ( 128 ));
2006-02-03 17:42:39 +01:00
2007-05-10 20:25:19 +02:00
// La fonction clearstatcache ne doit pas etre appel<65> e de mani<6E> re globale car ralenti.
2006-02-03 19:08:46 +01:00
// Elle doit etre appel<65> e uniquement par les pages qui ont besoin d'un cache fichier vid<69>
2006-02-03 17:42:39 +01:00
// comme par exemple document.php
//clearstatcache();
2007-05-10 20:25:19 +02:00
// Definition des constantes syslog
2006-02-03 17:42:39 +01:00
if ( function_exists ( " define_syslog_variables " ))
{
define_syslog_variables ();
}
2007-05-10 20:25:19 +02:00
else
{
// Pour PHP sans syslog (comme sous Windows)
define ( 'LOG_EMERG' , 0 );
define ( 'LOG_ALERT' , 1 );
define ( 'LOG_CRIT' , 2 );
define ( 'LOG_ERR' , 3 );
define ( 'LOG_WARNING' , 4 );
define ( 'LOG_NOTICE' , 5 );
define ( 'LOG_INFO' , 6 );
define ( 'LOG_DEBUG' , 7 );
}
// Forcage du parametrage PHP error_reporting (Dolibarr non utilisable en mode error E_ALL)
// error_reporting(E_ALL);
2006-02-03 17:42:39 +01:00
error_reporting ( E_ALL ^ E_NOTICE );
// Test si install ok
if ( ! @ include_once ( " conf/conf.php " ))
{
2007-04-07 13:54:20 +02:00
Header ( " Location: install/index.php " );
exit ;
2006-02-03 17:42:39 +01:00
}
else
{
2007-04-07 13:54:20 +02:00
if ( ! isset ( $dolibarr_main_db_host ))
2006-02-03 17:42:39 +01:00
{
2007-04-07 13:54:20 +02:00
Header ( " Location: install/index.php " );
exit ;
2006-02-03 17:42:39 +01:00
}
}
if ( ! isset ( $dolibarr_main_db_type ))
{
$dolibarr_main_db_type = 'mysql' ; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql'
}
if ( ! $dolibarr_main_data_root ) {
2007-04-07 13:54:20 +02:00
// Si repertoire documents non defini, on utilise celui par defaut
$dolibarr_main_data_root = ereg_replace ( " /htdocs " , " " , $dolibarr_main_document_root );
$dolibarr_main_data_root .= " /documents " ;
2006-02-03 17:42:39 +01:00
}
2007-02-10 15:36:01 +01:00
define ( 'DOL_DOCUMENT_ROOT' , $dolibarr_main_document_root ); // Filesystem pages php (htdocs)
define ( 'DOL_DATA_ROOT' , $dolibarr_main_data_root ); // Filesystem donnes (documents)
define ( 'DOL_MAIN_URL_ROOT' , $dolibarr_main_url_root ); // URL racine absolue
2006-02-03 17:42:39 +01:00
$uri = eregi_replace ( '^http(s?)://' , '' , $dolibarr_main_url_root );
$pos = strstr ( $uri , '/' ); // $pos contient alors url sans nom domaine
if ( $pos == '/' ) $pos = '' ; // si $pos vaut /, on le met a ''
2007-02-10 15:36:01 +01:00
define ( 'DOL_URL_ROOT' , $pos ); // URL racine relative
2006-02-03 17:42:39 +01:00
/*
2006-06-03 01:20:36 +02:00
* Creation objet $conf
2006-02-03 17:42:39 +01:00
*/
2007-04-25 13:45:01 +02:00
// on d<> code le mot de passe de la base si besoin
require_once ( DOL_DOCUMENT_ROOT . " /lib/functions.inc.php " );
2007-04-25 16:16:27 +02:00
if ( $dolibarr_main_db_encrypted_pass ) $dolibarr_main_db_pass = dolibarr_decode ( $dolibarr_main_db_encrypted_pass );
2007-04-25 13:45:01 +02:00
2006-02-03 17:42:39 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /conf/conf.class.php " );
2007-04-25 13:45:01 +02:00
2006-02-03 17:42:39 +01:00
$conf = new Conf ();
2007-07-13 14:57:07 +02:00
// Identifiant propres au serveur base de donnee
2006-02-03 17:42:39 +01:00
$conf -> db -> host = $dolibarr_main_db_host ;
$conf -> db -> name = $dolibarr_main_db_name ;
$conf -> db -> user = $dolibarr_main_db_user ;
$conf -> db -> pass = $dolibarr_main_db_pass ;
2007-05-25 22:02:23 +02:00
if ( ! isset ( $dolibarr_main_db_type ) && ! $dolibarr_main_db_type ) $dolibarr_main_db_type = 'mysql' ; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql'
2006-02-03 17:42:39 +01:00
$conf -> db -> type = $dolibarr_main_db_type ;
2007-08-01 12:13:08 +02:00
if ( ! isset ( $dolibarr_main_db_character_set ) && ! $dolibarr_main_db_character_set ) $dolibarr_main_db_character_set = 'latin1' ;
$conf -> db -> character_set = $dolibarr_main_db_character_set ;
2006-02-03 17:42:39 +01:00
if ( ! isset ( $dolibarr_main_db_prefix ) || ! $dolibarr_main_db_prefix ) $dolibarr_main_db_prefix = 'llx_' ;
$conf -> db -> prefix = $dolibarr_main_db_prefix ;
2007-07-13 14:57:07 +02:00
if ( ! isset ( $collation_connection ) || ! $collation_connection ) $collation_connection = 'latin1_swedish_ci' ;
2007-07-14 22:36:31 +02:00
$conf -> db -> collation_connection = $collation_connection ;
2007-07-13 14:57:07 +02:00
// Identifiant autres
2007-06-02 17:12:49 +02:00
$conf -> main_authentication = $dolibarr_main_authentication ;
2007-08-01 12:13:08 +02:00
// Identifiant propre au client
if ( ! isset ( $character_set_client ) || ! $character_set_client ) $character_set_client = 'ISO-8859-1' ;
$conf -> character_set_client = $character_set_client ;
2007-05-25 22:02:23 +02:00
// Defini prefix
if ( isset ( $_SERVER [ " LLX_DBNAME " ])) $dolibarr_main_db_prefix = $_SERVER [ " LLX_DBNAME " ];
2006-02-03 17:42:39 +01:00
define ( 'MAIN_DB_PREFIX' , $dolibarr_main_db_prefix );
2006-09-17 17:51:52 +02:00
// Detection browser
if ( isset ( $_SERVER [ " HTTP_USER_AGENT " ]))
{
2007-04-07 13:54:20 +02:00
if ( eregi ( 'firefox' , $_SERVER [ " HTTP_USER_AGENT " ])) $conf -> browser -> firefox = 1 ;
if ( eregi ( 'iceweasel' , $_SERVER [ " HTTP_USER_AGENT " ])) $conf -> browser -> firefox = 1 ;
2006-09-17 17:51:52 +02:00
}
2006-06-03 01:20:36 +02:00
// Chargement des includes principaux
2006-02-03 17:42:39 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /user.class.php " );
require_once ( DOL_DOCUMENT_ROOT . " /menu.class.php " );
require_once ( DOL_DOCUMENT_ROOT . " /html.form.class.php " );
2006-08-06 01:55:10 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/databases/ " . $conf -> db -> type . " .lib.php " );
2006-02-03 17:42:39 +01:00
2007-05-24 11:26:28 +02:00
/*
* Creation objet $langs
*/
require_once ( DOL_DOCUMENT_ROOT . " /translate.class.php " );
2007-05-25 22:02:23 +02:00
$langs = new Translate ( DOL_DOCUMENT_ROOT . " /langs " , $conf ); // A mettre apres lecture de la conf
2007-05-23 23:10:11 +02:00
2006-06-03 01:20:36 +02:00
/*
* Creation objet $db
*/
2006-02-03 17:42:39 +01:00
$db = new DoliDb ( $conf -> db -> type , $conf -> db -> host , $conf -> db -> user , $conf -> db -> pass , $conf -> db -> name );
if ( ! $db -> connected ) {
2007-04-07 13:54:20 +02:00
dolibarr_print_error ( $db , " host= " . $conf -> db -> host . " , user= " . $conf -> db -> user . " , databasename= " . $conf -> db -> name . " , " . $db -> error );
exit ;
2006-02-03 17:42:39 +01:00
}
/*
2006-06-03 01:20:36 +02:00
* Creation objet $user
2006-02-03 17:42:39 +01:00
*/
2006-06-03 01:20:36 +02:00
$user = new User ( $db );
2006-02-03 17:42:39 +01:00
/*
2006-06-03 01:20:36 +02:00
* Chargement objet $conf
2006-02-03 17:42:39 +01:00
*/
2006-06-03 01:20:36 +02:00
$conf -> setValues ( $db );
2006-02-03 17:42:39 +01:00
/*
2007-05-24 11:26:28 +02:00
* Chargement langage par d<EFBFBD> faut
2006-06-03 01:20:36 +02:00
*/
2006-02-03 17:42:39 +01:00
$langs -> setDefaultLang ( $conf -> global -> MAIN_LANG_DEFAULT );
$langs -> setPhpLang ( $conf -> global -> MAIN_LANG_DEFAULT );
/*
* Pour utiliser d ' autres versions des librairies externes que les
2006-02-03 19:11:35 +01:00
* versions embarqu<EFBFBD> es dans Dolibarr , d<EFBFBD> finir les constantes adequates :
2006-02-03 17:42:39 +01:00
* Pour FPDF : FPDF_PATH
2006-08-13 21:07:43 +02:00
* Pour Pear : PEAR_PATH
2006-02-03 17:42:39 +01:00
* Pour PHP_WriteExcel : PHP_WRITEEXCEL_PATH
* Pour MagpieRss : MAGPIERSS_PATH
2006-08-13 21:07:43 +02:00
* Pour PHPlot : PHPLOT_PATH
2006-07-13 14:58:59 +02:00
* Pour JPGraph : JPGRAPH_PATH
* Pour NuSOAP : NUSOAP_PATH
2006-07-20 10:57:10 +02:00
* Pour TCPDF : TCPDF_PATH
2006-02-03 17:42:39 +01:00
*/
2006-06-18 03:34:15 +02:00
// Les path racines
2006-02-03 17:42:39 +01:00
if ( ! defined ( 'FPDF_PATH' )) { define ( 'FPDF_PATH' , DOL_DOCUMENT_ROOT . '/includes/fpdf/fpdf/' ); }
2007-08-21 11:23:15 +02:00
if ( ! defined ( 'FPDFI_PATH' )) { define ( 'FPDFI_PATH' , DOL_DOCUMENT_ROOT . '/includes/fpdf/fpdfi/' ); }
2006-02-03 17:42:39 +01:00
if ( ! defined ( 'PEAR_PATH' )) { define ( 'PEAR_PATH' , DOL_DOCUMENT_ROOT . '/includes/pear/' ); }
if ( ! defined ( 'PHP_WRITEEXCEL_PATH' )) { define ( 'PHP_WRITEEXCEL_PATH' , DOL_DOCUMENT_ROOT . '/includes/php_writeexcel/' ); }
if ( ! defined ( 'MAGPIERSS_PATH' )) { define ( 'MAGPIERSS_PATH' , DOL_DOCUMENT_ROOT . '/includes/magpierss/' ); }
2006-08-13 21:07:43 +02:00
if ( ! defined ( 'PHPLOT_PATH' ))
{
if ( versioncompare ( versionphp (), array ( 4 , 2 , 0 )) >= 0 )
{
define ( 'PHPLOT_PATH' , DOL_DOCUMENT_ROOT . '/includes/phplot5/' );
}
else
{
define ( 'PHPLOT_PATH' , DOL_DOCUMENT_ROOT . '/includes/phplot/' );
}
}
2006-02-03 17:42:39 +01:00
if ( ! defined ( 'JPGRAPH_PATH' )) { define ( 'JPGRAPH_PATH' , DOL_DOCUMENT_ROOT . '/includes/jpgraph/' ); }
2006-07-13 14:58:59 +02:00
if ( ! defined ( 'NUSOAP_PATH' )) { define ( 'NUSOAP_PATH' , DOL_DOCUMENT_ROOT . '/includes/nusoap/lib/' ); }
2006-06-18 03:34:15 +02:00
// Les autres path
2006-07-21 10:54:24 +02:00
if ( ! defined ( 'FPDF_FONTPATH' )) { define ( 'FPDF_FONTPATH' , FPDF_PATH . 'font/' ); }
2006-06-18 03:34:15 +02:00
if ( ! defined ( 'MAGPIE_DIR' )) { define ( 'MAGPIE_DIR' , MAGPIERSS_PATH ); }
2006-08-20 01:00:53 +02:00
if ( ! defined ( 'MAGPIE_CACHE_DIR' )) { define ( 'MAGPIE_CACHE_DIR' , $conf -> externalrss -> dir_temp ); }
2006-02-03 17:42:39 +01:00
// \todo Ajouter la ligne
// require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php");
2006-06-03 01:20:36 +02:00
// dans le fichier facturation-emission.php du module telephonie afin de pouvoir supprimer la ligne suivante
2006-02-03 17:42:39 +01:00
if ( defined ( " MAIN_MODULE_TELEPHONIE " ) && MAIN_MODULE_TELEPHONIE ) require_once ( DOL_DOCUMENT_ROOT . " /includes/modules/facture/modules_facture.php " );
2006-06-03 01:20:36 +02:00
// require_once(FPDF_PATH . "fpdf.php");
// dans le fichier pdfdetail_standard_modeles du module telephonie afin de pouvoir supprimer la ligne suivante
2007-08-21 11:23:15 +02:00
if ( defined ( " MAIN_MODULE_TELEPHONIE " ) && MAIN_MODULE_TELEPHONIE ) require_once ( FPDFI_PATH . " fpdi_protection.php " );
2006-02-03 17:42:39 +01:00
/*
* Creation objet mysoc
2006-02-03 19:08:46 +01:00
* Objet Societe qui contient carac de l ' institution g<EFBFBD> r<EFBFBD> par Dolibarr .
2006-02-03 17:42:39 +01:00
*/
require_once ( DOL_DOCUMENT_ROOT . " /societe.class.php " );
$mysoc = new Societe ( $db );
$mysoc -> id = 0 ;
$mysoc -> nom = $conf -> global -> MAIN_INFO_SOCIETE_NOM ;
$mysoc -> adresse = $conf -> global -> MAIN_INFO_SOCIETE_ADRESSE ;
$mysoc -> cp = $conf -> global -> MAIN_INFO_SOCIETE_CP ;
$mysoc -> ville = $conf -> global -> MAIN_INFO_SOCIETE_VILLE ;
2006-06-16 02:33:04 +02:00
// Si dans MAIN_INFO_SOCIETE_PAYS on a un id de pays, on recupere code
if ( is_numeric ( $conf -> global -> MAIN_INFO_SOCIETE_PAYS ))
{
$mysoc -> pays_id = $conf -> global -> MAIN_INFO_SOCIETE_PAYS ;
$sql = " SELECT code from " . MAIN_DB_PREFIX . " c_pays " ;
$sql .= " WHERE rowid = " . $conf -> global -> MAIN_INFO_SOCIETE_PAYS ;
$result = $db -> query ( $sql );
if ( $result )
{
$obj = $db -> fetch_object ();
$mysoc -> pays_code = $obj -> code ;
}
else {
dolibarr_print_error ( $db );
}
}
// Si dans MAIN_INFO_SOCIETE_PAYS on a deja un code, tout est fait
else
{
$mysoc -> pays_code = $conf -> global -> MAIN_INFO_SOCIETE_PAYS ;
}
2006-02-03 17:42:39 +01:00
$mysoc -> tel = $conf -> global -> MAIN_INFO_SOCIETE_TEL ;
$mysoc -> fax = $conf -> global -> MAIN_INFO_SOCIETE_FAX ;
$mysoc -> url = $conf -> global -> MAIN_INFO_SOCIETE_WEB ;
2006-07-02 14:35:41 +02:00
// Anciens id prof
2006-02-03 17:42:39 +01:00
$mysoc -> siren = $conf -> global -> MAIN_INFO_SIREN ;
$mysoc -> siret = $conf -> global -> MAIN_INFO_SIRET ;
$mysoc -> ape = $conf -> global -> MAIN_INFO_APE ;
$mysoc -> rcs = $conf -> global -> MAIN_INFO_RCS ;
2006-07-02 14:35:41 +02:00
// Id prof g<> n<EFBFBD> riques
$mysoc -> profid1 = $conf -> global -> MAIN_INFO_SIREN ;
$mysoc -> profid2 = $conf -> global -> MAIN_INFO_SIRET ;
$mysoc -> profid3 = $conf -> global -> MAIN_INFO_APE ;
$mysoc -> profid4 = $conf -> global -> MAIN_INFO_RCS ;
2006-03-16 02:03:55 +01:00
$mysoc -> tva_assuj = $conf -> global -> FACTURE_TVAOPTION ;
$mysoc -> tva_intra = $conf -> global -> MAIN_INFO_TVAINTRA ;
2006-02-03 17:42:39 +01:00
$mysoc -> capital = $conf -> global -> MAIN_INFO_CAPITAL ;
2006-07-02 14:35:41 +02:00
$mysoc -> forme_juridique_code = $conf -> global -> MAIN_INFO_SOCIETE_FORME_JURIDIQUE ;
2006-02-03 17:42:39 +01:00
$mysoc -> email = $conf -> global -> MAIN_INFO_SOCIETE_MAIL ;
2006-05-05 22:01:58 +02:00
$mysoc -> adresse_full = $mysoc -> adresse . " \n " . $mysoc -> cp . " " . $mysoc -> ville ;
2006-05-08 19:22:53 +02:00
$mysoc -> logo = $conf -> global -> MAIN_INFO_SOCIETE_LOGO ;
2007-08-09 20:22:39 +02:00
$mysoc -> logo_small = $conf -> global -> MAIN_INFO_SOCIETE_LOGO_SMALL ;
$mysoc -> logo_mini = $conf -> global -> MAIN_INFO_SOCIETE_LOGO_MINI ;
2006-02-03 17:42:39 +01:00
2006-06-03 01:20:36 +02:00
// Sert uniquement dans module telephonie
2006-02-03 17:42:39 +01:00
$yesno [ 0 ] = " no " ;
$yesno [ 1 ] = " yes " ;
if ( ! defined ( 'MENTION_NPR' ) ) define ( 'MENTION_NPR' , '(npr)' );
2006-05-05 22:01:58 +02:00
?>