2008-11-12 01:26:54 +01:00
< ? php
2009-02-09 01:50:38 +01:00
/* Copyright ( C ) 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2008-11-12 01:26:54 +01:00
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
* Copyright ( C ) 2004 Sebastien DiCintio < sdicintio @ ressource - toi . org >
2012-04-28 16:37:58 +02:00
* Copyright ( C ) 2007 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
2008-11-12 01:26:54 +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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2008-11-12 01:26:54 +01:00
* ( 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2008-11-12 01:26:54 +01:00
*/
2009-05-09 00:08:41 +02:00
/**
2012-01-29 20:57:40 +01:00
* \file htdocs / support / inc . php
* \ingroup core
* \brief File that define environment for support pages
2009-05-09 00:08:41 +02:00
*/
2008-11-12 01:26:54 +01:00
2013-05-30 19:29:08 +02:00
// Define DOL_DOCUMENT_ROOT
2021-02-26 21:17:52 +01:00
if ( ! defined ( 'DOL_DOCUMENT_ROOT' )) {
define ( 'DOL_DOCUMENT_ROOT' , '..' );
}
2008-11-12 01:26:54 +01:00
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/translate.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2008-11-12 01:26:54 +01:00
2012-04-28 16:37:58 +02:00
// Avoid warnings with strict mode E_STRICT
$conf = new stdClass (); // instantiate $conf explicitely
2013-01-19 14:32:37 +01:00
$conf -> global = new stdClass ();
2020-04-10 10:59:32 +02:00
$conf -> file = new stdClass ();
$conf -> db = new stdClass ();
2013-01-19 14:32:37 +01:00
$conf -> syslog = new stdClass ();
2012-04-28 16:37:58 +02:00
// Force $_REQUEST["logtohtml"]
2020-04-10 10:59:32 +02:00
$_REQUEST [ " logtohtml " ] = 1 ;
2008-11-12 01:26:54 +01:00
// Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative
// et non path absolu.
2021-02-26 21:17:52 +01:00
if ( isset ( $_SERVER [ " DOCUMENT_URI " ]) && $_SERVER [ " DOCUMENT_URI " ]) {
2020-04-10 10:59:32 +02:00
$_SERVER [ " PHP_SELF " ] = $_SERVER [ " DOCUMENT_URI " ];
2008-11-12 01:26:54 +01:00
}
2020-04-10 10:59:32 +02:00
$includeconferror = '' ;
2011-08-07 15:10:26 +02:00
2011-09-20 12:30:56 +02:00
// Define vars
2011-08-07 15:10:26 +02:00
$conffiletoshowshort = " conf.php " ;
2011-09-20 12:30:56 +02:00
// Define localization of conf file
2008-11-12 01:26:54 +01:00
$conffile = " ../conf/conf.php " ;
2011-08-07 15:10:26 +02:00
$conffiletoshow = " htdocs/conf/conf.php " ;
2011-09-20 12:30:56 +02:00
// For debian/redhat like systems
2021-02-26 21:17:52 +01:00
if ( ! file_exists ( $conffile )) {
2018-02-16 18:21:18 +01:00
$conffile = " /etc/dolibarr/conf.php " ;
$conffiletoshow = " /etc/dolibarr/conf.php " ;
}
2011-08-07 15:10:26 +02:00
2012-10-07 20:04:07 +02:00
2016-02-06 17:19:57 +01:00
// Load conf file if it is already defined
2021-02-26 21:17:52 +01:00
if ( ! defined ( 'DONOTLOADCONF' ) && file_exists ( $conffile ) && filesize ( $conffile ) > 8 ) { // Test on filesize is to ensure that conf file is more that an empty template with just <?php in first line
2020-04-25 13:52:07 +02:00
$result = include_once $conffile ; // Load conf file
2021-02-26 21:17:52 +01:00
if ( $result ) {
if ( empty ( $dolibarr_main_db_type )) {
$dolibarr_main_db_type = 'mysql' ; // For backward compatibility
}
2012-05-06 15:36:53 +02:00
2016-04-17 15:39:46 +02:00
//Mysql driver support has been removed in favor of mysqli
if ( $dolibarr_main_db_type == 'mysql' ) {
$dolibarr_main_db_type = 'mysqli' ;
}
2021-02-26 21:17:52 +01:00
if ( empty ( $dolibarr_main_db_port ) && ( $dolibarr_main_db_type == 'mysqli' )) {
$dolibarr_main_db_port = '3306' ; // For backward compatibility
}
2016-04-17 15:39:46 +02:00
2012-04-28 16:37:58 +02:00
// Clean parameters
2020-04-25 13:52:07 +02:00
$dolibarr_main_data_root = isset ( $dolibarr_main_data_root ) ? trim ( $dolibarr_main_data_root ) : '' ;
$dolibarr_main_url_root = isset ( $dolibarr_main_url_root ) ? trim ( $dolibarr_main_url_root ) : '' ;
$dolibarr_main_url_root_alt = isset ( $dolibarr_main_url_root_alt ) ? trim ( $dolibarr_main_url_root_alt ) : '' ;
$dolibarr_main_document_root = isset ( $dolibarr_main_document_root ) ? trim ( $dolibarr_main_document_root ) : '' ;
$dolibarr_main_document_root_alt = isset ( $dolibarr_main_document_root_alt ) ? trim ( $dolibarr_main_document_root_alt ) : '' ;
2009-02-09 01:50:38 +01:00
2008-11-12 01:26:54 +01:00
// Remove last / or \ on directories or url value
2021-02-26 21:17:52 +01:00
if ( ! empty ( $dolibarr_main_document_root ) && ! preg_match ( '/^[\\/]+$/' , $dolibarr_main_document_root )) {
$dolibarr_main_document_root = preg_replace ( '/[\\/]+$/' , '' , $dolibarr_main_document_root );
}
if ( ! empty ( $dolibarr_main_url_root ) && ! preg_match ( '/^[\\/]+$/' , $dolibarr_main_url_root )) {
$dolibarr_main_url_root = preg_replace ( '/[\\/]+$/' , '' , $dolibarr_main_url_root );
}
if ( ! empty ( $dolibarr_main_data_root ) && ! preg_match ( '/^[\\/]+$/' , $dolibarr_main_data_root )) {
$dolibarr_main_data_root = preg_replace ( '/[\\/]+$/' , '' , $dolibarr_main_data_root );
}
if ( ! empty ( $dolibarr_main_document_root_alt ) && ! preg_match ( '/^[\\/]+$/' , $dolibarr_main_document_root_alt )) {
$dolibarr_main_document_root_alt = preg_replace ( '/[\\/]+$/' , '' , $dolibarr_main_document_root_alt );
}
if ( ! empty ( $dolibarr_main_url_root_alt ) && ! preg_match ( '/^[\\/]+$/' , $dolibarr_main_url_root_alt )) {
$dolibarr_main_url_root_alt = preg_replace ( '/[\\/]+$/' , '' , $dolibarr_main_url_root_alt );
}
2012-05-06 15:36:53 +02:00
2008-11-12 01:26:54 +01:00
// Create conf object
2021-02-26 21:17:52 +01:00
if ( ! empty ( $dolibarr_main_document_root )) {
2020-04-25 13:52:07 +02:00
$result = conf ( $dolibarr_main_document_root );
2008-11-12 01:26:54 +01:00
}
// Load database driver
2021-02-26 21:17:52 +01:00
if ( $result ) {
if ( ! empty ( $dolibarr_main_document_root ) && ! empty ( $dolibarr_main_db_type )) {
2020-04-25 13:52:07 +02:00
$result = include_once $dolibarr_main_document_root . " /core/db/ " . $dolibarr_main_db_type . '.class.php' ;
2021-02-26 21:17:52 +01:00
if ( ! $result ) {
2020-04-25 13:52:07 +02:00
$includeconferror = 'ErrorBadValueForDolibarrMainDBType' ;
2008-11-12 01:26:54 +01:00
}
}
2020-05-21 15:05:19 +02:00
} else {
2020-04-25 13:52:07 +02:00
$includeconferror = 'ErrorBadValueForDolibarrMainDocumentRoot' ;
2008-11-12 01:26:54 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2020-04-25 13:52:07 +02:00
$includeconferror = 'ErrorBadFormatForConfFile' ;
2008-11-12 01:26:54 +01:00
}
}
2012-04-28 16:37:58 +02:00
$conf -> global -> MAIN_LOGTOHTML = 1 ;
2008-11-12 01:26:54 +01:00
2009-06-29 16:29:14 +02:00
// Define prefix
2021-02-26 21:17:52 +01:00
if ( ! isset ( $dolibarr_main_db_prefix ) || ! $dolibarr_main_db_prefix ) {
$dolibarr_main_db_prefix = 'llx_' ;
}
2020-04-25 13:52:07 +02:00
define ( 'MAIN_DB_PREFIX' , ( isset ( $dolibarr_main_db_prefix ) ? $dolibarr_main_db_prefix : '' ));
define ( 'DOL_CLASS_PATH' , 'class/' ); // Filsystem path to class dir
define ( 'DOL_DATA_ROOT' , ( isset ( $dolibarr_main_data_root ) ? $dolibarr_main_data_root : '' ));
define ( 'DOL_MAIN_URL_ROOT' , ( isset ( $dolibarr_main_url_root ) ? $dolibarr_main_url_root : '' )); // URL relative root
$uri = preg_replace ( '/^http(s?):\/\//i' , '' , constant ( 'DOL_MAIN_URL_ROOT' )); // $uri contains url without http*
$suburi = strstr ( $uri , '/' ); // $suburi contains url without domain
2021-02-26 21:17:52 +01:00
if ( $suburi == '/' ) {
$suburi = '' ; // If $suburi is /, it is now ''
}
2020-04-25 13:52:07 +02:00
define ( 'DOL_URL_ROOT' , $suburi ); // URL relative root ('', '/dolibarr', ...)
2021-02-26 21:17:52 +01:00
if ( empty ( $character_set_client )) {
$character_set_client = " UTF-8 " ;
}
2020-04-25 13:52:07 +02:00
$conf -> file -> character_set_client = strtoupper ( $character_set_client );
2021-02-26 21:17:52 +01:00
if ( empty ( $dolibarr_main_db_character_set )) {
$dolibarr_main_db_character_set = ( $conf -> db -> type == 'mysqli' ? 'utf8' : '' ); // Old installation
}
2020-04-25 13:52:07 +02:00
$conf -> db -> character_set = $dolibarr_main_db_character_set ;
2021-02-26 21:17:52 +01:00
if ( empty ( $dolibarr_main_db_collation )) {
$dolibarr_main_db_collation = ( $conf -> db -> type == 'mysqli' ? 'utf8_unicode_ci' : '' ); // Old installation
}
2020-04-25 13:52:07 +02:00
$conf -> db -> dolibarr_main_db_collation = $dolibarr_main_db_collation ;
2021-02-26 21:17:52 +01:00
if ( empty ( $dolibarr_main_db_encryption )) {
$dolibarr_main_db_encryption = 0 ;
}
2012-05-06 15:36:53 +02:00
$conf -> db -> dolibarr_main_db_encryption = $dolibarr_main_db_encryption ;
2021-02-26 21:17:52 +01:00
if ( empty ( $dolibarr_main_db_cryptkey )) {
$dolibarr_main_db_cryptkey = '' ;
}
2012-05-06 15:36:53 +02:00
$conf -> db -> dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey ;
2012-04-28 16:37:58 +02:00
2021-02-26 21:17:52 +01:00
if ( empty ( $conf -> db -> user )) {
$conf -> db -> user = '' ;
}
2008-11-12 01:26:54 +01:00
// Defini objet langs
2019-01-27 11:55:16 +01:00
$langs = new Translate ( '..' , $conf );
2021-02-26 21:17:52 +01:00
if ( GETPOST ( 'lang' , 'aZ09' )) {
$langs -> setDefaultLang ( GETPOST ( 'lang' , 'aZ09' ));
} else {
$langs -> setDefaultLang ( 'auto' );
}
2008-11-12 01:26:54 +01:00
2020-04-10 10:59:32 +02:00
$bc [ false ] = ' class="bg1"' ;
$bc [ true ] = ' class="bg2"' ;
2008-11-12 01:26:54 +01:00
2009-05-09 20:00:14 +02:00
/**
2012-01-04 21:47:40 +01:00
* Load conf file ( file must exists )
*
* @ param string $dolibarr_main_document_root Root directory of Dolibarr bin files
* @ return int < 0 if KO , > 0 if OK
2009-05-09 20:00:14 +02:00
*/
2008-11-12 01:26:54 +01:00
function conf ( $dolibarr_main_document_root )
{
global $conf ;
global $dolibarr_main_db_type ;
global $dolibarr_main_db_host ;
global $dolibarr_main_db_port ;
global $dolibarr_main_db_name ;
global $dolibarr_main_db_user ;
global $dolibarr_main_db_pass ;
global $character_set_client ;
2020-04-10 10:59:32 +02:00
$return = include_once $dolibarr_main_document_root . '/core/class/conf.class.php' ;
2021-02-26 21:17:52 +01:00
if ( ! $return ) {
return - 1 ;
}
2008-11-12 01:26:54 +01:00
2020-04-10 10:59:32 +02:00
$conf = new Conf ();
2008-11-12 01:26:54 +01:00
$conf -> db -> type = trim ( $dolibarr_main_db_type );
$conf -> db -> host = trim ( $dolibarr_main_db_host );
$conf -> db -> port = trim ( $dolibarr_main_db_port );
$conf -> db -> name = trim ( $dolibarr_main_db_name );
$conf -> db -> user = trim ( $dolibarr_main_db_user );
$conf -> db -> pass = trim ( $dolibarr_main_db_pass );
2021-02-26 21:17:52 +01:00
if ( empty ( $conf -> db -> dolibarr_main_db_collation )) {
$conf -> db -> dolibarr_main_db_collation = 'utf8_unicode_ci' ;
}
2008-11-12 01:26:54 +01:00
return 1 ;
}
2009-05-09 20:00:14 +02:00
/**
2012-04-28 16:37:58 +02:00
* Show HTML header
2011-12-04 22:25:49 +01:00
*
2012-04-28 16:37:58 +02:00
* @ param string $soutitre Title
* @ param string $next Next
* @ param string $action Action code
* @ return void
2009-05-09 20:00:14 +02:00
*/
2019-01-27 15:20:16 +01:00
function pHeader ( $soutitre , $next , $action = 'none' )
2008-11-12 01:26:54 +01:00
{
global $conf ;
2009-05-09 20:00:14 +02:00
global $langs ;
$langs -> load ( " main " );
$langs -> load ( " admin " );
2008-11-12 01:26:54 +01:00
// On force contenu dans format sortie
2009-05-08 03:11:04 +02:00
header ( " Content-type: text/html; charset= " . $conf -> file -> character_set_client );
2017-05-09 21:01:37 +02:00
header ( " X-Content-Type-Options: nosniff " );
2018-02-16 18:21:18 +01:00
2009-05-09 20:00:14 +02:00
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' . " \n " ;
2013-05-21 14:41:11 +02:00
print '<html manifest="' . DOL_URL_ROOT . '/cache.manifest">' . " \n " ;
2009-05-09 20:00:14 +02:00
print '<head>' . " \n " ;
print '<meta http-equiv="content-type" content="text/html; charset=' . $conf -> file -> character_set_client . '">' . " \n " ;
2009-06-15 22:49:51 +02:00
print '<meta name="robots" content="index,follow">' . " \n " ;
2019-05-13 09:47:58 +02:00
print '<meta name="viewport" content="width=device-width, initial-scale=1.0">' . " \n " ;
2009-06-15 22:49:51 +02:00
print '<meta name="keywords" content="help, center, dolibarr, doliwamp">' . " \n " ;
print '<meta name="description" content="Dolibarr help center">' . " \n " ;
2009-05-09 20:00:14 +02:00
print '<link rel="stylesheet" type="text/css" href="default.css">' . " \n " ;
2009-06-15 22:49:51 +02:00
print '<title>' . $langs -> trans ( " DolibarrHelpCenter " ) . '</title>' . " \n " ;
2009-05-09 20:00:14 +02:00
print '</head>' . " \n " ;
2009-06-03 21:55:39 +02:00
2020-02-01 10:09:31 +01:00
print '<body class="center">' . " \n " ;
print '<div class="noborder centpercent center valignmiddle inline-block">' ;
print '<img src="helpcenter.png" alt="logohelpcenter" class="inline-block"><br><br>' ;
print '<span class="titre inline-block">' . $soutitre . '</span>' . " \n " ;
print '</div><br>' ;
2008-11-12 01:26:54 +01:00
}
2009-05-09 20:00:14 +02:00
/**
2012-04-28 16:37:58 +02:00
* Print HTML footer
2009-05-09 20:00:14 +02:00
*
2015-03-17 00:21:17 +01:00
* @ param integer $nonext No button " Next step "
2012-01-04 21:47:40 +01:00
* @ param string $setuplang Language code
* @ return void
2009-05-09 20:00:14 +02:00
*/
2019-01-27 15:20:16 +01:00
function pFooter ( $nonext = 0 , $setuplang = '' )
2008-11-12 01:26:54 +01:00
{
2009-05-09 20:00:14 +02:00
global $langs ;
$langs -> load ( " main " );
$langs -> load ( " admin " );
2009-02-09 01:50:38 +01:00
2009-05-09 20:00:14 +02:00
print '</body>' . " \n " ;
print '</html>' . " \n " ;
2008-11-12 01:26:54 +01:00
}