2004-10-20 23:06:45 +02:00
< ? php
2008-09-30 02:10:49 +02:00
/* Copyright ( C ) 2002 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2004-01-28 01:25:15 +01:00
* Copyright ( C ) 2003 Xavier Dutoit < doli @ sydesy . com >
2009-03-13 14:12:43 +01:00
* Copyright ( C ) 2004 - 2009 Laurent Destailleur < eldy @ users . sourceforge . net >
2004-09-01 23:23:20 +02:00
* Copyright ( C ) 2004 Sebastien Di Cintio < sdicintio @ ressource - toi . org >
2005-10-30 01:42:54 +02:00
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
2009-04-17 09:45:00 +02:00
* Copyright ( C ) 2005 - 2009 Regis Houssin < regis @ dolibarr . fr >
2008-11-28 00:02:49 +01:00
* Copyright ( C ) 2008 Matteli
2002-04-30 12:56:25 +02: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 .
*/
2003-06-18 15:56:26 +02:00
2005-03-21 20:53:50 +01:00
/**
2008-11-28 00:02:49 +01:00
* \file htdocs / main . inc . php
* \ingroup core
2008-11-28 00:24:50 +01:00
* \brief File that defines environment for Dolibarr pages only ( variables not required by scripts )
2008-11-28 00:02:49 +01:00
* \version $Id $
2008-09-30 02:10:49 +02:00
*/
2004-10-29 00:15:31 +02:00
2008-11-28 00:02:49 +01:00
// For optionnal tuning. Enabled if environment variable DOL_TUNING is defined.
2008-03-12 22:26:53 +01:00
// A appeler avant tout. Fait l'equivalent de la fonction dol_microtime_float pas encore chargee.
2008-01-10 18:12:07 +01:00
$micro_start_time = 0 ;
if ( ! empty ( $_SERVER [ 'DOL_TUNING' ]))
{
2008-09-30 02:10:49 +02:00
list ( $usec , $sec ) = explode ( " " , microtime ());
$micro_start_time = (( float ) $usec + ( float ) $sec );
2009-02-21 02:04:35 +01:00
// Add Xdebug coverage of code
//define('XDEBUGCOVERAGE',1);
if ( defined ( 'XDEBUGCOVERAGE' )) { xdebug_start_code_coverage (); }
2008-01-10 18:12:07 +01:00
}
2008-01-20 22:53:43 +01:00
2006-10-02 15:59:05 +02:00
// Forcage du parametrage PHP magic_quotes_gpc et nettoyage des parametres
2006-06-08 21:53:55 +02:00
// (Sinon il faudrait a chaque POST, conditionner
2005-11-22 23:27:20 +01:00
// la lecture de variable par stripslashes selon etat de get_magic_quotes).
2009-05-16 08:31:59 +02:00
// En mode off (recommande, il faut juste faire addslashes au moment d'un insert/update.
2005-11-22 23:27:20 +01:00
function stripslashes_deep ( $value )
{
2008-09-30 02:10:49 +02:00
return ( is_array ( $value ) ? array_map ( 'stripslashes_deep' , $value ) : stripslashes ( $value ));
2005-11-22 23:27:20 +01:00
}
2008-11-28 00:02:49 +01:00
if ( function_exists ( 'get_magic_quotes_gpc' )) // magic_quotes_* removed in PHP6
2005-11-22 23:27:20 +01:00
{
2008-01-06 14:04:06 +01:00
if ( get_magic_quotes_gpc ())
{
2008-09-30 02:10:49 +02:00
$_GET = array_map ( 'stripslashes_deep' , $_GET );
$_POST = array_map ( 'stripslashes_deep' , $_POST );
$_REQUEST = array_map ( 'stripslashes_deep' , $_REQUEST );
2009-05-18 00:40:24 +02:00
$_COOKIE = array_map ( 'stripslashes_deep' , $_COOKIE );
2008-01-06 14:04:06 +01:00
}
@ set_magic_quotes_runtime ( 0 );
2005-11-22 23:27:20 +01:00
}
2009-08-21 22:22:46 +02:00
// Security: SQL and Script Injection protection (Filters on GET, POST)
function test_sql_and_script_inject ( $val )
2007-01-19 19:25:10 +01:00
{
2008-09-30 02:10:49 +02:00
$sql_inj = 0 ;
$sql_inj += eregi ( 'delete[[:space:]]+from' , $val );
$sql_inj += eregi ( 'create[[:space:]]+table' , $val );
$sql_inj += eregi ( 'update.+set.+=' , $val );
$sql_inj += eregi ( 'insert[[:space:]]+into' , $val );
$sql_inj += eregi ( 'select.+from' , $val );
2009-08-21 22:22:46 +02:00
$sql_inj += eregi ( '<script' , $val );
2008-09-30 02:10:49 +02:00
return $sql_inj ;
2007-01-19 19:25:10 +01:00
}
2009-08-21 22:22:46 +02:00
function analyse_sql_and_script ( & $var )
2007-01-19 19:25:10 +01:00
{
2008-09-30 02:10:49 +02:00
if ( is_array ( $var ))
{
$result = array ();
foreach ( $var as $key => $value )
{
2009-08-21 22:22:46 +02:00
if ( test_sql_and_script_inject ( $key ) > 0 )
2009-05-07 01:30:49 +02:00
{
2009-08-21 22:22:46 +02:00
print 'Access refused by SQL/Script injection protection in main.inc.php' ;
exit ;
2009-05-07 01:30:49 +02:00
}
else
{
2009-08-21 22:22:46 +02:00
if ( analyse_sql_and_script ( $value ))
2009-05-07 01:30:49 +02:00
{
$var [ $key ] = $value ;
}
else
{
2009-08-21 22:22:46 +02:00
print 'Access refused by SQL/Script injection protection in main.inc.php' ;
exit ;
2009-05-07 01:30:49 +02:00
}
}
2008-09-30 02:10:49 +02:00
}
return true ;
}
else
{
2009-08-21 22:22:46 +02:00
return ( test_sql_and_script_inject ( $var ) <= 0 );
2008-09-30 02:10:49 +02:00
}
2007-01-19 19:25:10 +01:00
}
2009-08-21 22:22:46 +02:00
analyse_sql_and_script ( $_GET );
analyse_sql_and_script ( $_POST );
2007-01-19 19:25:10 +01:00
2009-05-18 00:40:24 +02:00
// Security: CSRF protection
// The test to do is to check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST']).
if ( ! defined ( 'NOCSRFCHECK' ) && ! empty ( $_SERVER [ 'HTTP_HOST' ]) && ! empty ( $_SERVER [ 'HTTP_REFERER' ]) && ! eregi ( $_SERVER [ 'HTTP_HOST' ], $_SERVER [ 'HTTP_REFERER' ]))
{
2009-05-21 19:45:13 +02:00
//print 'HTTP_POST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER'];
print 'Access refused by CSRF protection in main.inc.php.' ;
exit ;
2009-05-18 00:40:24 +02:00
}
2008-01-20 22:53:43 +01:00
// This is to make Dolibarr working with Plesk
set_include_path ( $_SERVER [ 'DOCUMENT_ROOT' ] . '/htdocs' );
2009-05-22 00:28:05 +02:00
// Init session. Name of session is specific to Dolibarr instance.
$sessionname = 'DOLSESSID_' . md5 ( $_SERVER [ " SERVER_NAME " ] . $_SERVER [ " DOCUMENT_ROOT " ]);
2009-05-22 02:20:45 +02:00
$sessiontimeout = 'DOLSESSTIMEOUT_' . md5 ( $_SERVER [ " SERVER_NAME " ] . $_SERVER [ " DOCUMENT_ROOT " ]);
2009-06-14 18:25:23 +02:00
if ( ! empty ( $_COOKIE [ $sessiontimeout ])) ini_set ( 'session.gc_maxlifetime' , $_COOKIE [ $sessiontimeout ]);
2009-05-20 20:18:25 +02:00
session_name ( $sessionname );
session_start ();
2009-05-22 00:28:05 +02:00
2008-04-09 20:13:45 +02:00
// Set and init common variables
2009-05-21 15:37:18 +02:00
// This include will set: config file variable $dolibarr_xxx, $conf, $langs and $mysoc objects
2005-11-01 00:49:35 +01:00
require_once ( " master.inc.php " );
2008-01-10 18:12:07 +01:00
2008-04-06 22:17:11 +02:00
// Check if HTTPS
2009-05-08 03:23:33 +02:00
if ( $conf -> file -> main_force_https )
2008-04-06 22:17:11 +02:00
{
2008-12-23 21:36:13 +01:00
if ( ! empty ( $_SERVER [ " SCRIPT_URI " ])) // If SCRIPT_URI supported by server
2008-04-06 22:17:11 +02:00
{
2008-12-23 21:36:13 +01:00
if ( eregi ( '^http:' , $_SERVER [ " SCRIPT_URI " ]) && ! eregi ( '^https:' , $_SERVER [ " SCRIPT_URI " ])) // If link is http
2008-04-06 22:17:11 +02:00
{
2008-12-23 21:36:13 +01:00
$newurl = eregi_replace ( '^http:' , 'https:' , $_SERVER [ " SCRIPT_URI " ]);
2009-01-21 14:06:34 +01:00
2009-08-08 18:26:06 +02:00
dol_syslog ( " main.inc: dolibarr_main_force_https is on, we make a redirect to " . $newurl );
2008-12-23 21:36:13 +01:00
header ( " Location: " . $newurl );
exit ;
2008-04-06 22:17:11 +02:00
}
2008-12-23 21:36:13 +01:00
}
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
2008-04-06 22:17:11 +02:00
{
2008-12-23 21:36:13 +01:00
$uri = eregi_replace ( '^http(s?)://' , '' , $dolibarr_main_url_root );
$val = split ( '/' , $uri );
$domaineport = $val [ 0 ]; // $domaineport contient nom domaine et port
$newurl = 'https://' . $domaineport . $_SERVER [ " REQUEST_URI " ];
//print 'eee'.$newurl; exit;
2009-08-08 18:26:06 +02:00
dol_syslog ( " main.inc: dolibarr_main_force_https is on, we make a redirect to " . $newurl );
2008-04-06 22:17:11 +02:00
header ( " Location: " . $newurl );
exit ;
}
}
}
2008-03-12 22:26:53 +01:00
2009-02-02 19:33:44 +01:00
2008-11-28 00:24:50 +01:00
// Chargement des includes complementaires de presentation
2009-08-28 01:31:50 +02:00
if ( ! defined ( 'NOREQUIREMENU' )) require_once ( DOL_DOCUMENT_ROOT . " /menu.class.php " ); // Need 10ko memory (11ko in 2.2)
if ( ! defined ( 'NOREQUIREHTML' )) require_once ( DOL_DOCUMENT_ROOT . " /html.form.class.php " ); // Need 660ko memory (800ko in 2.2)
if ( ! defined ( 'NOREQUIREAJAX' ) && $conf -> use_javascript_ajax ) require_once ( DOL_DOCUMENT_ROOT . '/lib/ajax.lib.php' ); // Need 22ko memory
2008-01-11 11:25:26 +01:00
//stopwithmem();
2006-06-03 01:20:36 +02:00
2009-08-08 18:26:06 +02:00
// If install or upgrade process not done or not completely finished, we call the install page.
if ( ! empty ( $conf -> global -> MAIN_NOT_INSTALLED ) || ! empty ( $conf -> global -> MAIN_NOT_UPGRADED ))
{
dol_syslog ( " main.inc: A previous install or upgrade was not complete. Redirect to install page. " , LOG_WARNING );
Header ( " Location: " . DOL_URL_ROOT . " /install/index.php " );
exit ;
}
// If an upgrade process is required, we call the install page.
if ( ! empty ( $conf -> global -> MAIN_VERSION_LAST_UPGRADE ) && ( $conf -> global -> MAIN_VERSION_LAST_UPGRADE != DOL_VERSION ))
{
require_once ( DOL_DOCUMENT_ROOT . " /lib/admin.lib.php " );
$dolibarrversionlastupgrade = split ( '[\.-]' , $conf -> global -> MAIN_VERSION_LAST_UPGRADE );
$dolibarrversionprogram = split ( '[\.-]' , DOL_VERSION );
if ( versioncompare ( $dolibarrversionprogram , $dolibarrversionlastupgrade ) > 0 ) // Programs have a version higher than database
{
dol_syslog ( " main.inc: database version " . $conf -> global -> MAIN_VERSION_LAST_UPGRADE . " is lower than programs version " . DOL_VERSION . " . Redirect to install page. " , LOG_WARNING );
Header ( " Location: " . DOL_URL_ROOT . " /install/index.php " );
exit ;
}
}
2009-05-15 14:48:13 +02:00
// Creation d'un jeton contre les failles CSRF
2009-05-26 19:01:18 +02:00
if ( ! defined ( 'NOTOKENRENEWAL' ))
{
$token = md5 ( uniqid ( mt_rand (), TRUE )); // Genere un hash d'un nombre aleatoire
// roulement des jetons car cree a chaque appel
2009-07-03 11:04:29 +02:00
if ( isset ( $_SESSION [ 'newtoken' ])) $_SESSION [ 'token' ] = $_SESSION [ 'newtoken' ];
2009-05-26 19:01:18 +02:00
$_SESSION [ 'newtoken' ] = $token ;
}
2009-09-14 03:56:24 +02:00
if ( ! empty ( $conf -> global -> MAIN_SECURITY_CSRF )) // Check validity of token, only if not option enabled (this option breaks some features sometimes)
2009-05-15 14:48:13 +02:00
{
2009-07-03 11:04:29 +02:00
if ( isset ( $_POST [ 'token' ]) && isset ( $_SESSION [ 'token' ]))
2009-05-16 18:12:09 +02:00
{
2009-07-03 11:04:29 +02:00
if (( $_POST [ 'token' ] != $_SESSION [ 'token' ]))
2009-05-24 21:04:25 +02:00
{
2009-09-14 03:56:24 +02:00
dol_syslog ( " Invalid token in " . $_SERVER [ 'HTTP_REFERER' ] . " , action= " . $_POST [ 'action' ] . " , _POST['token']= " . $_POST [ 'token' ] . " , _SESSION['token']= " . $_SESSION [ 'token' ], LOG_WARNING );
2009-06-15 14:15:51 +02:00
//print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers.
2009-05-24 21:04:25 +02:00
unset ( $_POST );
}
2009-05-16 18:12:09 +02:00
}
2009-05-16 17:45:26 +02:00
}
2009-05-22 02:20:45 +02:00
// Disable modules (this must be after session_start and after conf has been loaded)
2008-11-28 00:24:50 +01:00
if ( ! empty ( $_REQUEST [ " disablemodules " ])) $_SESSION [ " disablemodules " ] = $_REQUEST [ " disablemodules " ];
2009-01-21 14:06:34 +01:00
if ( ! empty ( $_SESSION [ " disablemodules " ]))
2008-11-28 00:24:50 +01:00
{
$disabled_modules = split ( ',' , $_SESSION [ " disablemodules " ]);
foreach ( $disabled_modules as $module )
{
$conf -> $module -> enabled = false ;
}
}
2009-05-08 03:23:33 +02:00
2006-07-02 02:43:40 +02:00
/*
2009-05-08 03:23:33 +02:00
* Phase authentication / login
2006-07-02 02:43:40 +02:00
*/
2005-03-26 14:38:30 +01:00
2008-01-04 19:35:17 +01:00
// $authmode contient la liste des differents modes d'identification a tester par ordre de preference.
// Example: 'http'
// Example: 'dolibarr'
// Example: 'ldap'
// Example: 'http,forceuser'
2007-01-04 00:57:14 +01:00
2008-01-04 19:35:17 +01:00
// Authentication mode
if ( empty ( $dolibarr_main_authentication )) $dolibarr_main_authentication = 'http,dolibarr' ;
2007-05-15 01:44:36 +02:00
// Authentication mode: forceuser
2008-01-04 19:35:17 +01:00
if ( $dolibarr_main_authentication == 'forceuser' && empty ( $dolibarr_auto_user )) $dolibarr_auto_user = 'auto' ;
// Set authmode
$authmode = split ( ',' , $dolibarr_main_authentication );
2007-05-15 01:44:36 +02:00
// No authentication mode
2008-09-30 02:10:49 +02:00
if ( ! sizeof ( $authmode ))
2007-05-15 01:44:36 +02:00
{
$langs -> load ( 'main' );
2009-02-20 21:28:16 +01:00
dol_print_error ( '' , $langs -> trans ( " ErrorConfigParameterNotDefined " , 'dolibarr_main_authentication' ));
2007-05-15 01:44:36 +02:00
exit ;
}
2006-12-09 03:23:07 +01:00
2007-12-29 19:42:59 +01:00
// Si la demande du login a deja eu lieu, on le recupere depuis la session
// sinon appel du module qui realise sa demande.
// A l'issu de cette phase, la variable $login sera definie.
2006-07-02 02:43:40 +02:00
$login = '' ;
2008-01-04 10:38:00 +01:00
$resultFetchUser = '' ;
2007-12-31 00:49:16 +01:00
$test = true ;
if ( ! isset ( $_SESSION [ " dol_login " ]))
2005-11-01 18:48:46 +01:00
{
2007-12-29 19:42:59 +01:00
// On est pas deja authentifie, on demande le login/mot de passe
2006-06-25 22:18:56 +02:00
2007-12-31 00:49:16 +01:00
// Verification du code securite graphique
2009-01-21 15:09:42 +01:00
if ( $test && isset ( $_POST [ " username " ]) && ! empty ( $conf -> global -> MAIN_SECURITY_ENABLECAPTCHA ))
2007-12-31 00:49:16 +01:00
{
require_once DOL_DOCUMENT_ROOT . '/../external-libs/Artichow/Artichow.cfg.php' ;
require_once ARTICHOW . " /AntiSpam.class.php " ;
2008-09-30 02:10:49 +02:00
2007-12-31 00:49:16 +01:00
// On cree l'objet anti-spam
$object = new AntiSpam ();
2008-09-30 02:10:49 +02:00
2007-12-31 00:49:16 +01:00
// Verifie code
if ( ! $object -> check ( 'dol_antispam_value' , $_POST [ 'code' ], true ))
{
2009-02-20 21:28:16 +01:00
dol_syslog ( 'Bad value for code, connexion refused' );
2007-12-31 00:49:16 +01:00
$langs -> load ( 'main' );
$langs -> load ( 'other' );
2009-01-21 14:06:34 +01:00
2008-04-09 23:38:39 +02:00
$user -> trigger_mesg = 'ErrorBadValueForCode - login=' . $_POST [ " username " ];
2007-12-31 00:49:16 +01:00
$_SESSION [ " dol_loginmesg " ] = $langs -> trans ( " ErrorBadValueForCode " );
$test = false ;
2009-01-21 14:06:34 +01:00
2008-04-09 23:38:39 +02:00
// Appel des triggers
include_once ( DOL_DOCUMENT_ROOT . " /interfaces.class.php " );
$interface = new Interfaces ( $db );
2009-04-23 15:19:28 +02:00
$result = $interface -> run_triggers ( 'USER_LOGIN_FAILED' , $user , $user , $langs , $conf , $_POST [ " entity " ]);
2008-04-09 23:38:39 +02:00
if ( $result < 0 ) { $error ++ ; }
// Fin appel triggers
2007-12-31 00:49:16 +01:00
}
}
2008-09-30 02:10:49 +02:00
2008-01-04 19:35:17 +01:00
// Tests de validation user/mot de passe
2008-04-10 02:01:50 +02:00
// Si ok, la variable login sera initialisee
// Si erreur, on a placera message erreur dans session sous le nom dol_loginmesg
2008-05-02 03:10:00 +02:00
$goontestloop = false ;
if ( isset ( $_SERVER [ " REMOTE_USER " ]) && in_array ( 'http' , $authmode )) $goontestloop = true ;
if ( isset ( $_POST [ " username " ])) $goontestloop = true ;
2008-09-30 02:10:49 +02:00
2008-05-02 03:10:00 +02:00
if ( $test && $goontestloop )
2006-07-02 02:43:40 +02:00
{
2008-04-09 23:38:39 +02:00
foreach ( $authmode as $mode )
2008-01-02 14:08:27 +01:00
{
2008-04-09 23:38:39 +02:00
if ( $test && $mode && ! $login )
2007-12-31 00:49:16 +01:00
{
2008-04-09 23:38:39 +02:00
$authfile = DOL_DOCUMENT_ROOT . '/includes/login/functions_' . $mode . '.php' ;
$result = include_once ( $authfile );
if ( $result )
{
// Call function to check user/password
2008-09-30 02:10:49 +02:00
$usertotest = $_POST [ " username " ];
$passwordtotest = $_POST [ " password " ];
2008-04-09 23:38:39 +02:00
$function = 'check_user_password_' . $mode ;
$login = $function ( $usertotest , $passwordtotest );
2008-09-30 02:10:49 +02:00
if ( $login )
2008-05-02 03:10:00 +02:00
{
$test = false ;
2009-04-17 20:26:21 +02:00
$conf -> authmode = $mode ; // This properties is defined only when logged
2008-05-02 03:10:00 +02:00
}
2008-04-09 23:38:39 +02:00
}
else
{
2009-02-20 21:28:16 +01:00
dol_syslog ( " Authentification ko - failed to load file ' " . $authfile . " ' " , LOG_ERR );
2008-04-09 23:38:39 +02:00
sleep ( 1 );
$langs -> load ( 'main' );
$langs -> load ( 'other' );
$_SESSION [ " dol_loginmesg " ] = $langs -> trans ( " ErrorFailedToLoadLoginFileForMode " , $mode );
}
2008-01-04 19:35:17 +01:00
}
}
2008-04-09 23:38:39 +02:00
if ( ! $login )
{
2009-02-20 21:28:16 +01:00
dol_syslog ( 'Bad password, connexion refused' , LOG_DEBUG );
2008-04-09 23:38:39 +02:00
$langs -> load ( 'main' );
$langs -> load ( 'other' );
// Bad password. No authmode has found a good password.
$user -> trigger_mesg = $langs -> trans ( " ErrorBadLoginPassword " ) . ' - login=' . $_POST [ " username " ];
$_SESSION [ " dol_loginmesg " ] = $langs -> trans ( " ErrorBadLoginPassword " );
2009-01-21 14:06:34 +01:00
2008-04-09 23:38:39 +02:00
// Appel des triggers
include_once ( DOL_DOCUMENT_ROOT . " /interfaces.class.php " );
$interface = new Interfaces ( $db );
2009-04-23 15:19:28 +02:00
$result = $interface -> run_triggers ( 'USER_LOGIN_FAILED' , $user , $user , $langs , $conf , $_POST [ " entity " ]);
2008-04-09 23:38:39 +02:00
if ( $result < 0 ) { $error ++ ; }
// Fin appel triggers
}
}
2008-09-30 02:10:49 +02:00
2008-01-04 19:35:17 +01:00
// Fin des tests de login/passwords
2008-09-30 02:10:49 +02:00
if ( ! $login )
{
// We show login page
2008-12-15 21:55:44 +01:00
include_once ( DOL_DOCUMENT_ROOT . " /lib/security.lib.php " );
2007-12-31 00:49:16 +01:00
dol_loginfunction ( $langs , $conf , $mysoc );
exit ;
2008-09-30 02:10:49 +02:00
}
2008-01-04 19:35:17 +01:00
2008-01-04 19:46:05 +01:00
$resultFetchUser = $user -> fetch ( $login );
2008-01-04 10:38:00 +01:00
if ( $resultFetchUser <= 0 )
2006-12-09 03:23:07 +01:00
{
2009-02-20 21:28:16 +01:00
dol_syslog ( 'User not found, connexion refused' );
2007-12-31 00:49:16 +01:00
session_destroy ();
2007-05-15 01:44:36 +02:00
session_name ( $sessionname );
session_start ();
2007-12-31 00:49:16 +01:00
2008-09-30 02:10:49 +02:00
if ( $resultFetchUser == 0 )
2008-04-09 23:38:39 +02:00
{
$langs -> load ( 'main' );
$langs -> load ( 'other' );
$user -> trigger_mesg = 'ErrorCantLoadUserFromDolibarrDatabase - login=' . $login ;
$_SESSION [ " dol_loginmesg " ] = $langs -> trans ( " ErrorCantLoadUserFromDolibarrDatabase " , $login );
}
if ( $resultFetchUser < 0 )
{
$user -> trigger_mesg = $user -> error ;
$_SESSION [ " dol_loginmesg " ] = $user -> error ;
}
// Appel des triggers
include_once ( DOL_DOCUMENT_ROOT . " /interfaces.class.php " );
$interface = new Interfaces ( $db );
2009-04-23 15:19:28 +02:00
$result = $interface -> run_triggers ( 'USER_LOGIN_FAILED' , $user , $user , $langs , $conf , $_POST [ " entity " ]);
2008-04-09 23:38:39 +02:00
if ( $result < 0 ) { $error ++ ; }
// Fin appel triggers
2007-05-15 01:44:36 +02:00
header ( 'Location: ' . DOL_URL_ROOT . '/index.php' );
2006-12-09 03:23:07 +01:00
exit ;
}
2003-08-30 11:27:49 +02:00
}
2006-06-25 22:18:56 +02:00
else
{
2007-12-29 19:42:59 +01:00
// On est deja en session qui a sauvegarde login
// Remarks: On ne sauvegarde pas objet user car pose pb dans certains cas mal identifies
2006-12-12 23:44:19 +01:00
$login = $_SESSION [ " dol_login " ];
2008-01-04 10:38:00 +01:00
$resultFetchUser = $user -> fetch ( $login );
2009-02-20 21:28:16 +01:00
dol_syslog ( " This is an already logged session. _SESSION['dol_login']= " . $login );
2009-04-27 21:50:39 +02:00
2008-01-04 10:38:00 +01:00
if ( $resultFetchUser <= 0 )
2007-12-31 00:49:16 +01:00
{
// Account has been removed after login
2009-02-20 21:28:16 +01:00
dol_syslog ( " Can't load user even if session logged. _SESSION['dol_login']= " . $login , LOG_WARNING );
2007-12-31 00:49:16 +01:00
session_destroy ();
session_name ( $sessionname );
session_start ();
2008-09-30 02:10:49 +02:00
if ( $resultFetchUser == 0 )
2008-04-09 23:38:39 +02:00
{
$langs -> load ( 'main' );
$langs -> load ( 'other' );
$user -> trigger_mesg = 'ErrorCantLoadUserFromDolibarrDatabase - login=' . $login ;
$_SESSION [ " dol_loginmesg " ] = $langs -> trans ( " ErrorCantLoadUserFromDolibarrDatabase " , $login );
}
if ( $resultFetchUser < 0 )
{
$user -> trigger_mesg = $user -> error ;
$_SESSION [ " dol_loginmesg " ] = $user -> error ;
}
// Appel des triggers
include_once ( DOL_DOCUMENT_ROOT . " /interfaces.class.php " );
$interface = new Interfaces ( $db );
2009-05-08 03:23:33 +02:00
$result = $interface -> run_triggers ( 'USER_LOGIN_FAILED' , $user , $user , $langs , $conf ,( isset ( $_POST [ " entity " ]) ? $_POST [ " entity " ] : 0 ));
2008-04-09 23:38:39 +02:00
if ( $result < 0 ) { $error ++ ; }
// Fin appel triggers
2007-12-31 00:49:16 +01:00
header ( 'Location: ' . DOL_URL_ROOT . '/index.php' );
exit ;
}
2006-07-02 02:43:40 +02:00
}
2009-04-17 20:26:21 +02:00
// Is it a new session ?
2006-12-12 23:44:19 +01:00
if ( ! isset ( $_SESSION [ " dol_login " ]))
2006-07-02 02:43:40 +02:00
{
2009-01-21 15:09:42 +01:00
$error = 0 ;
2009-04-17 20:26:21 +02:00
// New session for this login
2008-09-30 02:10:49 +02:00
$_SESSION [ " dol_login " ] = $user -> login ;
$_SESSION [ " dol_authmode " ] = $conf -> authmode ;
2009-09-15 18:05:58 +02:00
$_SESSION [ " dol_company " ] = $conf -> global -> MAIN_INFO_SOCIETE_NOM ;
2009-05-08 03:23:33 +02:00
if ( $conf -> multicompany -> enabled ) $_SESSION [ " dol_entity " ] = $conf -> entity ;
2009-02-20 21:28:16 +01:00
dol_syslog ( " This is a new started user session. _SESSION['dol_login']= " . $_SESSION [ " dol_login " ] . ' Session id=' . session_id ());
2008-03-17 15:59:34 +01:00
$db -> begin ();
2008-09-30 02:10:49 +02:00
$user -> update_last_login_date ();
2008-03-17 15:59:34 +01:00
// Appel des triggers
include_once ( DOL_DOCUMENT_ROOT . " /interfaces.class.php " );
$interface = new Interfaces ( $db );
2009-04-23 15:19:28 +02:00
$result = $interface -> run_triggers ( 'USER_LOGIN' , $user , $user , $langs , $conf , $_POST [ " entity " ]);
2008-04-09 23:38:39 +02:00
if ( $result < 0 ) { $error ++ ; }
2008-03-17 15:59:34 +01:00
// Fin appel triggers
2008-09-30 02:10:49 +02:00
2008-03-17 15:59:34 +01:00
if ( $error )
{
$db -> rollback ();
2008-04-09 23:38:39 +02:00
session_destroy ();
2009-02-20 21:28:16 +01:00
dol_print_error ( $db , 'Error in some triggers on action USER_LOGIN' , LOG_ERR );
2008-04-09 23:38:39 +02:00
exit ;
2008-03-17 15:59:34 +01:00
}
else
{
$db -> commit ();
}
2009-04-27 21:50:39 +02:00
2009-05-22 17:24:32 +02:00
// Create entity cookie, just used for login page
if ( ! empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) && ! empty ( $conf -> global -> MAIN_MULTICOMPANY_COOKIE ) && isset ( $_POST [ " entity " ]))
2009-04-23 15:19:28 +02:00
{
2009-05-22 17:24:32 +02:00
include_once ( DOL_DOCUMENT_ROOT . " /core/cookie.class.php " );
2009-05-10 07:44:35 +02:00
2009-05-23 17:35:02 +02:00
$entity = $_SESSION [ " dol_login " ] . '|' . $_POST [ " entity " ];
2009-05-22 17:24:32 +02:00
$entityCookieName = 'DOLENTITYID_' . md5 ( $_SERVER [ " SERVER_NAME " ] . $_SERVER [ " DOCUMENT_ROOT " ]);
// TTL : sera defini dans la page de config multicompany
$ttl = ( ! empty ( $conf -> global -> MAIN_MULTICOMPANY_COOKIE_TTL ) ? $conf -> global -> MAIN_MULTICOMPANY_COOKIE_TTL : time () + 60 * 60 * 8 );
// Cryptkey : sera cree aleatoirement dans la page de config multicompany
2009-05-24 02:19:06 +02:00
$cryptkey = ( ! empty ( $conf -> file -> cookie_cryptkey ) ? $conf -> file -> cookie_cryptkey : '' );
2009-05-22 17:24:32 +02:00
$entityCookie = new DolCookie ( $cryptkey );
2009-05-22 17:38:09 +02:00
$entityCookie -> _setCookie ( $entityCookieName , $entity , $ttl );
2009-04-23 15:19:28 +02:00
}
2008-09-30 02:10:49 +02:00
2007-11-12 23:40:23 +01:00
// Module webcalendar
2009-01-21 15:09:42 +01:00
if ( ! empty ( $conf -> webcal -> enabled ) && $user -> webcal_login != " " )
2007-11-12 23:40:23 +01:00
{
$domain = '' ;
2006-07-02 02:43:40 +02:00
2007-12-16 16:47:45 +01:00
// Creation du cookie permettant de sauver le login
2007-11-12 23:40:23 +01:00
$cookiename = 'webcalendar_login' ;
2009-05-21 15:37:18 +02:00
if ( ! isset ( $_COOKIE [ $cookiename ]))
2007-11-12 23:40:23 +01:00
{
setcookie ( $cookiename , $user -> webcal_login , 0 , " / " , $domain , 0 );
}
2007-12-16 16:47:45 +01:00
// Creation du cookie permettant de sauver la session
2007-11-12 23:40:23 +01:00
$cookiename = 'webcalendar_session' ;
2009-05-21 15:37:18 +02:00
if ( ! isset ( $_COOKIE [ $cookiename ]))
2007-11-12 23:40:23 +01:00
{
setcookie ( $cookiename , 'TODO' , 0 , " / " , $domain , 0 );
}
}
// Module Phenix
2009-01-21 15:09:42 +01:00
if ( ! empty ( $conf -> phenix -> enabled ) && $user -> phenix_login != " " && $conf -> phenix -> cookie )
2007-10-02 15:54:34 +02:00
{
2007-12-29 19:42:59 +01:00
// Creation du cookie permettant la connexion automatique, valide jusqu'a la fermeture du browser
2009-05-21 15:37:18 +02:00
if ( ! isset ( $_COOKIE [ $conf -> phenix -> cookie ]))
2007-11-12 23:40:23 +01:00
{
setcookie ( $conf -> phenix -> cookie , $user -> phenix_login . " : " . $user -> phenix_pass_crypted . " :1 " , 0 , " / " , " " , 0 );
}
2007-10-02 15:54:34 +02:00
}
}
2006-07-02 02:43:40 +02:00
2005-10-22 16:00:01 +02:00
// Si user admin, on force droits sur les modules base
if ( $user -> admin )
{
2008-09-30 02:10:49 +02:00
$user -> rights -> user -> user -> lire = 1 ;
$user -> rights -> user -> user -> creer = 1 ;
$user -> rights -> user -> user -> password = 1 ;
$user -> rights -> user -> user -> supprimer = 1 ;
$user -> rights -> user -> self -> creer = 1 ;
$user -> rights -> user -> self -> password = 1 ;
2005-10-22 16:00:01 +02:00
}
2005-08-11 22:04:33 +02:00
2008-05-23 21:43:28 +02:00
/*
2005-08-11 22:04:33 +02:00
* Overwrite configs global par configs perso
* ------------------------------------------
*/
2008-07-15 20:09:22 +02:00
// Set liste_limit
2008-01-20 19:47:10 +01:00
if ( isset ( $user -> conf -> MAIN_SIZE_LISTE_LIMIT )) // Can be 0
2005-08-11 22:04:33 +02:00
{
2008-09-30 02:10:49 +02:00
$conf -> liste_limit = $user -> conf -> MAIN_SIZE_LISTE_LIMIT ;
2005-08-11 22:04:33 +02:00
}
2008-01-20 19:47:10 +01:00
if ( isset ( $user -> conf -> PRODUIT_LIMIT_SIZE )) // Can be 0
2005-10-13 23:39:38 +02:00
{
2008-09-30 02:10:49 +02:00
$conf -> produit -> limit_size = $user -> conf -> PRODUIT_LIMIT_SIZE ;
2005-10-13 23:39:38 +02:00
}
2008-07-15 20:09:22 +02:00
2009-05-08 17:40:33 +02:00
if ( empty ( $_GET [ " lang " ])) // If language was not forced on URL
2005-08-11 22:04:33 +02:00
{
2009-05-08 17:40:33 +02:00
// If user has choosed its own language
if ( ! empty ( $user -> conf -> MAIN_LANG_DEFAULT ))
2008-09-30 02:10:49 +02:00
{
2009-05-08 17:40:33 +02:00
// If different than current language
//print ">>>".$langs->getDefaultLang()."-".$user->conf->MAIN_LANG_DEFAULT;
if ( $langs -> getDefaultLang () != $user -> conf -> MAIN_LANG_DEFAULT )
{
$langs -> setDefaultLang ( $user -> conf -> MAIN_LANG_DEFAULT );
}
2008-09-30 02:10:49 +02:00
}
2005-08-11 22:04:33 +02:00
}
2009-05-08 17:40:33 +02:00
else // If language was forced on URL
2007-12-16 16:47:45 +01:00
{
2008-09-30 02:10:49 +02:00
$langs -> setDefaultLang ( $_GET [ " lang " ]);
2007-12-16 16:47:45 +01:00
}
2005-10-02 22:38:46 +02:00
2008-12-07 20:19:32 +01:00
// Replace conf->css by personalized value
2006-03-28 14:54:50 +02:00
if ( isset ( $user -> conf -> MAIN_THEME ) && $user -> conf -> MAIN_THEME )
2005-08-13 00:10:34 +02:00
{
2008-09-30 02:10:49 +02:00
$conf -> theme = $user -> conf -> MAIN_THEME ;
$conf -> css = " theme/ " . $conf -> theme . " / " . $conf -> theme . " .css " ;
2005-08-13 00:10:34 +02:00
}
2007-08-02 21:07:50 +02:00
// Cas de forcage du style depuis url
2007-12-16 16:47:45 +01:00
if ( ! empty ( $_GET [ " theme " ]))
2007-08-02 21:07:50 +02:00
{
2008-09-30 02:10:49 +02:00
$conf -> theme = $_GET [ " theme " ];
$conf -> css = " theme/ " . $conf -> theme . " / " . $conf -> theme . " .css " ;
2007-08-02 21:07:50 +02:00
}
2005-10-02 22:38:46 +02:00
// Si feuille de style en php existe
if ( file_exists ( DOL_DOCUMENT_ROOT . '/' . $conf -> css . " .php " )) $conf -> css .= " .php " ;
2008-01-06 22:09:48 +01:00
if ( ! empty ( $user -> conf -> MAIN_DISABLE_JAVASCRIPT ))
2005-09-25 00:11:04 +02:00
{
2008-09-30 02:10:49 +02:00
$conf -> use_javascript_ajax =! $user -> conf -> MAIN_DISABLE_JAVASCRIPT ;
2005-09-25 00:11:04 +02:00
}
2005-08-11 22:04:33 +02:00
2006-03-28 14:54:50 +02:00
// Defini gestionnaire de menu a utiliser
2005-09-26 02:52:33 +02:00
if ( ! $user -> societe_id ) // Si utilisateur interne
{
2008-09-30 02:10:49 +02:00
$conf -> top_menu = $conf -> global -> MAIN_MENU_BARRETOP ;
$conf -> left_menu = $conf -> global -> MAIN_MENU_BARRELEFT ;
// Pour compatibilite
if ( $conf -> left_menu == 'eldy.php' ) $conf -> left_menu = 'eldy_backoffice.php' ;
2005-09-26 02:52:33 +02:00
}
else // Si utilisateur externe
{
2008-09-30 02:10:49 +02:00
$conf -> top_menu = $conf -> global -> MAIN_MENUFRONT_BARRETOP ;
$conf -> left_menu = $conf -> global -> MAIN_MENUFRONT_BARRELEFT ;
2005-09-26 02:52:33 +02:00
}
2005-08-11 22:04:33 +02:00
2008-12-07 23:29:44 +01:00
2009-08-02 19:13:59 +02:00
// If there is at least one module using Smarty
if ( sizeof ( $conf -> need_smarty ) > 0 )
2007-10-07 16:49:36 +02:00
{
2009-08-02 19:13:59 +02:00
// SMARTY (Defined into conf file)
2007-10-07 16:49:36 +02:00
// $dolibarr_smarty_libs_dir="/home/www/dolibarr/external-libs/smarty/libs/";
2008-05-13 23:54:32 +02:00
// $dolibarr_smarty_compile="/home/www/dolibarr/documents/smarty/templates/temp";
// $dolibarr_smarty_cache="/home/www/dolibarr/documents/smarty/cache/temp";
2009-08-02 18:47:06 +02:00
if ( empty ( $dolibarr_smarty_libs_dir )) $dolibarr_smarty_libs_dir = DOL_DOCUMENT_ROOT . '/../external-libs/smarty/libs/' ;
2008-12-07 23:29:44 +01:00
if ( empty ( $dolibarr_smarty_compile )) $dolibarr_smarty_compile = DOL_DATA_ROOT . '/smarty/templates/temp' ;
if ( empty ( $dolibarr_smarty_cache )) $dolibarr_smarty_cache = DOL_DATA_ROOT . '/smarty/cache/temp' ;
2009-01-21 14:06:34 +01:00
2007-10-07 16:49:36 +02:00
$smarty_libs = $dolibarr_smarty_libs_dir . " Smarty.class.php " ;
if ( file_exists ( $smarty_libs ))
{
require_once ( $smarty_libs );
$smarty = new Smarty ();
$smarty -> compile_dir = $dolibarr_smarty_compile ;
$smarty -> cache_dir = $dolibarr_smarty_cache ;
//$smarty->config_dir = '/web/www.domain.com/smarty/configs';
}
else
{
2009-02-20 21:28:16 +01:00
dol_print_error ( '' , " Library Smarty " . $smarty_libs . " not found. Check parameter dolibarr_smarty_libs_dir in conf file. " );
2007-10-07 16:49:36 +02:00
}
}
2006-03-28 14:54:50 +02:00
// Si le login n'a pu etre recupere, on est identifie avec un compte qui n'existe pas.
2005-03-26 14:38:30 +01:00
// Tentative de hacking ?
if ( ! $user -> login ) accessforbidden ();
2009-08-08 18:26:06 +02:00
// Check if user is active
2006-09-02 03:17:50 +02:00
if ( $user -> statut < 1 )
{
2008-09-30 02:10:49 +02:00
// Si non actif, on delogue le user
$langs -> load ( " other " );
2009-08-08 18:26:06 +02:00
dol_syslog ( " Authentification ko as login is disbaled " );
2008-09-30 02:10:49 +02:00
accessforbidden ( $langs -> trans ( " ErrorLoginDisabled " ));
exit ;
2006-09-02 03:17:50 +02:00
}
2009-01-21 14:06:34 +01:00
2006-09-02 03:17:50 +02:00
2009-08-29 00:46:40 +02:00
dol_syslog ( " Access to " . $_SERVER [ " PHP_SELF " ]);
//Another call for easy debugg
//dol_syslog("Access to ".$_SERVER["PHP_SELF"].' GET='.join(',',array_keys($_GET)).'->'.join(',',$_GET).' POST:'.join(',',array_keys($_POST)).'->'.join(',',$_POST));
2005-08-11 22:04:33 +02:00
2008-04-09 20:13:45 +02:00
// For backward compatibility
if ( ! defined ( 'MAIN_INFO_SOCIETE_PAYS' )) define ( 'MAIN_INFO_SOCIETE_PAYS' , '1' );
2004-11-04 21:00:15 +01:00
2007-09-15 16:35:44 +02:00
// On charge les fichiers lang principaux
2004-10-31 16:54:14 +01:00
$langs -> load ( " main " );
2007-09-15 16:35:44 +02:00
$langs -> load ( " dict " );
2003-03-11 17:25:07 +01:00
2008-12-15 21:55:44 +01:00
// Load permissions
2008-01-29 20:03:26 +01:00
$user -> getrights ();
2008-04-09 20:13:45 +02:00
// Define some constants used for style of arrays
$bc [ 0 ] = " class= \" impair \" " ;
$bc [ 1 ] = " class= \" pair \" " ;
2003-09-06 14:41:17 +02:00
2009-05-08 03:23:33 +02:00
// Sert uniquement dans module telephonie
$yesno [ 0 ] = " no " ;
$yesno [ 1 ] = " yes " ;
2009-06-14 14:38:45 +02:00
// Constants used to defined number of lines in textarea
if ( empty ( $conf -> browser -> firefox ))
2005-09-29 21:30:59 +02:00
{
2008-09-30 02:10:49 +02:00
define ( 'ROWS_1' , 1 );
define ( 'ROWS_2' , 2 );
define ( 'ROWS_3' , 3 );
define ( 'ROWS_4' , 4 );
define ( 'ROWS_5' , 5 );
define ( 'ROWS_6' , 6 );
define ( 'ROWS_7' , 7 );
define ( 'ROWS_8' , 8 );
define ( 'ROWS_9' , 9 );
2005-09-29 21:30:59 +02:00
}
else
{
2008-09-30 02:10:49 +02:00
define ( 'ROWS_1' , 0 );
define ( 'ROWS_2' , 1 );
define ( 'ROWS_3' , 2 );
define ( 'ROWS_4' , 3 );
define ( 'ROWS_5' , 4 );
define ( 'ROWS_6' , 5 );
define ( 'ROWS_7' , 6 );
define ( 'ROWS_8' , 7 );
define ( 'ROWS_9' , 8 );
2005-09-29 21:30:59 +02:00
}
2004-02-21 01:15:04 +01:00
2005-01-01 20:48:22 +01:00
/**
2008-02-11 16:51:03 +01:00
* \brief Show HTML header
* \param head Optionnal head lines
* \param title Web page title
2008-09-30 02:10:49 +02:00
* \param disablejs Do not output links to js ( Ex : qd fonction utilisee par sous formulaire Ajax )
2008-02-11 16:51:03 +01:00
* \param disablehead Do not output head section
* \param arrayofjs Array of js files to add in header
* \param arrayofcss Array of css files to add in header
2002-12-31 15:10:59 +01:00
*/
2008-09-30 02:10:49 +02:00
function top_htmlhead ( $head , $title = '' , $disablejs = 0 , $disablehead = 0 , $arrayofjs = '' , $arrayofcss = '' )
2002-12-31 15:10:59 +01:00
{
2008-01-10 18:12:07 +01:00
global $user , $conf , $langs , $db ;
2008-09-30 02:10:49 +02:00
2009-08-19 18:26:12 +02:00
if ( empty ( $conf -> css )) $conf -> css = 'theme/eldy/eldy.css.php' ;
2007-09-15 16:35:44 +02:00
//header("Content-type: text/html; charset=UTF-8");
2009-05-08 03:23:33 +02:00
header ( " Content-type: text/html; charset= " . $conf -> file -> character_set_client );
2006-03-25 17:57:54 +01:00
2007-09-15 16:35:44 +02:00
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' ;
2007-05-26 01:24:21 +02:00
//print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd>';
2007-09-15 16:35:44 +02:00
print " \n " ;
2007-03-16 19:19:33 +01:00
print " <html> \n " ;
2007-05-26 18:52:29 +02:00
if ( $disablehead == 0 )
{
print " <head> \n " ;
2008-09-30 02:10:49 +02:00
2009-05-08 03:23:33 +02:00
print " <meta http-equiv= \" Content-Type \" content= \" text/html; charset= " . $conf -> file -> character_set_client . " \" > \n " ;
2003-06-19 15:12:01 +02:00
2007-09-15 16:35:44 +02:00
// Affiche meta
print '<meta name="robots" content="noindex,nofollow">' . " \n " ; // Evite indexation par robots
print '<meta name="author" content="Dolibarr Development Team">' . " \n " ;
2003-10-21 11:40:34 +02:00
2007-09-15 16:35:44 +02:00
// Affiche title
2008-03-31 07:16:52 +02:00
$appli = 'Dolibarr' ;
2008-11-06 20:55:31 +01:00
if ( ! empty ( $conf -> global -> MAIN_APPLICATION_TITLE )) $appli = $conf -> global -> MAIN_APPLICATION_TITLE ;
2008-09-30 02:10:49 +02:00
2008-03-31 07:16:52 +02:00
if ( $title ) print '<title>' . $appli . ' - ' . $title . '</title>' ;
else print " <title> " . $appli . " </title> " ;
2007-09-15 16:35:44 +02:00
print " \n " ;
2005-04-17 02:23:43 +02:00
2008-02-11 16:51:03 +01:00
// Output style sheets
2009-08-19 18:26:12 +02:00
print '<link rel="stylesheet" type="text/css" title="default" href="' . DOL_URL_ROOT . '/' . $conf -> css . '?lang=' . $langs -> defaultlang . ( ! empty ( $_GET [ " optioncss " ]) ? '&optioncss=' . $_GET [ " optioncss " ] : '' ) . '">' . " \n " ;
2008-03-31 00:25:39 +02:00
// CSS forced by modules
if ( is_array ( $conf -> css_modules ))
{
foreach ( $conf -> css_modules as $cssfile )
{ // cssfile is an absolute path
2009-08-19 18:26:12 +02:00
print '<link rel="stylesheet" type="text/css" title="default" href="' . DOL_URL_ROOT . $cssfile . '?lang=' . $langs -> defaultlang . ( ! empty ( $_GET [ " optioncss " ]) ? '&optioncss=' . $_GET [ " optioncss " ] : '' ) . '">' . " \n " ;
2008-03-31 00:25:39 +02:00
}
}
2009-08-11 14:28:30 +02:00
// CSS forced by page (in top_htmlhead call)
2008-02-11 16:51:03 +01:00
if ( is_array ( $arrayofcss ))
{
foreach ( $arrayofcss as $cssfile )
{
2009-08-19 18:26:12 +02:00
print '<link rel="stylesheet" type="text/css" title="default" href="' . DOL_URL_ROOT . '/' . $cssfile . '?lang=' . $langs -> defaultlang . ( ! empty ( $_GET [ " optioncss " ]) ? '&optioncss=' . $_GET [ " optioncss " ] : '' ) . '">' . " \n " ;
2008-02-11 16:51:03 +01:00
}
}
2008-09-30 02:10:49 +02:00
2009-07-07 17:34:55 +02:00
if ( empty ( $conf -> global -> MAIN_OPTIMIZEFORTEXTBROWSER )) print '<link rel="top" title="' . $langs -> trans ( " Home " ) . '" href="' . ( DOL_URL_ROOT ? DOL_URL_ROOT : '/' ) . '">' . " \n " ;
2009-06-04 01:05:52 +02:00
if ( empty ( $conf -> global -> MAIN_OPTIMIZEFORTEXTBROWSER )) print '<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1">' . " \n " ;
if ( empty ( $conf -> global -> MAIN_OPTIMIZEFORTEXTBROWSER )) print '<link rel="author" title="Dolibarr Development Team" href="http://www.dolibarr.org">' . " \n " ;
2007-09-15 16:35:44 +02:00
2009-08-09 13:37:32 +02:00
// Output standard javascript links
2008-01-06 16:24:23 +01:00
if ( ! $disablejs && $conf -> use_javascript_ajax )
2007-09-15 16:35:44 +02:00
{
2008-10-06 23:31:05 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/lib/lib_head.js"></script>' . " \n " ;
2009-08-09 13:37:32 +02:00
// Other external js
2007-12-29 19:34:24 +01:00
require_once DOL_DOCUMENT_ROOT . '/lib/ajax.lib.php' ;
2009-08-09 13:37:32 +02:00
2009-08-09 21:25:17 +02:00
$mini = '' ; $ext = '.js' ;
if ( ! empty ( $conf -> global -> MAIN_OPTIMIZE_SPEED )) { $mini = '_mini' ; $ext = '.jgz' ; } // mini='_mini', ext='.gz'
2008-01-26 21:22:40 +01:00
// This one is required for all Ajax features
2009-05-08 21:27:39 +02:00
if ( ! defined ( 'DISABLE_PROTOTYPE' ))
{
print '<!-- Includes for Prototype (Used by Scriptaculous and PWC) -->' . " \n " ;
2009-08-09 21:25:17 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/scriptaculous/lib/prototype' . $mini . $ext . '"></script>' . " \n " ;
2009-05-08 21:27:39 +02:00
}
2009-05-19 15:27:44 +02:00
// This one is required for boxes
2009-05-08 21:27:39 +02:00
if ( ! defined ( 'DISABLE_SCRIPTACULOUS' ))
{
print '<!-- Includes for Scriptaculous (Used by Drag and drop and PWC) -->' . " \n " ;
2009-06-15 16:26:34 +02:00
//print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/scriptaculous.js"></script>'."\n";
//print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/scriptaculous.js?load=builder,effects,dragdrop,controls,slider,sound"></script>'."\n";
2009-08-28 00:20:01 +02:00
$listofscripts = 'effects,dragdrop' ;
if ( $conf -> global -> COMPANY_USE_SEARCH_TO_SELECT ) $listofscripts .= ',controls' ; // For Ajax.Autocompleter
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/scriptaculous/src/scriptaculous.js?load=' . $listofscripts . '"></script>' . " \n " ;
2009-05-08 21:27:39 +02:00
}
2008-01-26 14:18:47 +01:00
2008-01-26 21:22:40 +01:00
// Those ones are required only with option "confirm by ajax popup"
2009-05-08 21:27:39 +02:00
if ( ! defined ( 'DISABLE_PWC' ) && $conf -> global -> MAIN_CONFIRM_AJAX )
2008-01-26 21:22:40 +01:00
{
2009-05-08 21:27:39 +02:00
print '<!-- Includes for PWC (Used for confirm popup) -->' . " \n " ;
2008-05-18 21:08:28 +02:00
// PWC js
2009-08-09 21:25:17 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/pwc/window' . $mini . $ext . '"></script>' . " \n " ;
2008-01-26 21:22:40 +01:00
}
2008-09-30 02:10:49 +02:00
}
2009-08-09 13:37:32 +02:00
// Output module javascript
2008-02-11 16:51:03 +01:00
if ( is_array ( $arrayofjs ))
{
foreach ( $arrayofjs as $jsfile )
{
2008-10-06 23:31:05 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/' . $jsfile . '"></script>' . " \n " ;
2008-02-11 16:51:03 +01:00
}
}
2008-09-30 02:10:49 +02:00
2009-08-13 14:32:22 +02:00
// Define tradMonths javascript array (we define this in datapicker AND in parent page to avoid errors with IE8)
$tradTemp = array ( $langs -> trans ( " January " ),
$langs -> trans ( " February " ),
$langs -> trans ( " March " ),
$langs -> trans ( " April " ),
$langs -> trans ( " May " ),
$langs -> trans ( " June " ),
$langs -> trans ( " July " ),
$langs -> trans ( " August " ),
$langs -> trans ( " September " ),
$langs -> trans ( " October " ),
$langs -> trans ( " November " ),
$langs -> trans ( " December " )
);
print '<script type="text/javascript">' ;
print 'var tradMonths = [' ;
foreach ( $tradTemp as $val )
{
print '"' . addslashes ( $val ) . '",' ;
}
print '""];' ;
print '</script>' . " \n " ;
2009-08-22 18:07:46 +02:00
print " </head> \n \n " ;
2007-09-15 16:35:44 +02:00
}
2005-08-20 18:43:30 +02:00
}
2006-09-10 20:07:09 +02:00
2005-08-20 18:43:30 +02:00
/**
2009-05-10 07:44:35 +02:00
* \brief Show an HTML header + a BODY + The top menu bar
2005-08-20 18:43:30 +02:00
* \param head lignes d ' en - tete head
* \param title titre page web
2009-07-06 15:20:52 +02:00
* \param target target to add in menu links
2005-08-20 18:43:30 +02:00
*/
2008-10-18 16:01:55 +02:00
function top_menu ( $head , $title = '' , $target = '' )
2005-08-20 18:43:30 +02:00
{
2008-09-30 02:10:49 +02:00
global $user , $conf , $langs , $db , $dolibarr_main_authentication ;
2005-08-20 18:43:30 +02:00
2008-09-30 02:10:49 +02:00
if ( ! $conf -> top_menu ) $conf -> top_menu = 'eldy_backoffice.php' ;
2006-09-02 03:17:50 +02:00
if ( ! $conf -> left_menu ) $conf -> left_menu = 'eldy_backoffice.php' ;
2009-07-06 15:20:52 +02:00
top_htmlhead ( $head , $title ); // Show html headers
2008-09-30 02:10:49 +02:00
print '<body id="mainbody"><div id="dhtmltooltip"></div>' ;
/*
2009-05-18 13:40:33 +02:00
* Top menu
2008-09-30 02:10:49 +02:00
*/
print " \n " . '<!-- Start top horizontal menu -->' . " \n " ;
print '<div class="tmenu">' . " \n " ;
// Charge le gestionnaire des entrees de menu du haut
2007-03-16 19:19:33 +01:00
if ( ! file_exists ( DOL_DOCUMENT_ROOT . " /includes/menus/barre_top/ " . $conf -> top_menu ))
{
$conf -> top_menu = 'eldy_backoffice.php' ;
}
require_once ( DOL_DOCUMENT_ROOT . " /includes/menus/barre_top/ " . $conf -> top_menu );
2008-09-30 02:10:49 +02:00
$menutop = new MenuTop ( $db );
$menutop -> atarget = $target ;
// Affiche le menu
$menutop -> showmenu ();
2009-08-19 18:51:55 +02:00
// Link to login card
2008-09-30 02:10:49 +02:00
print '<a class="login" href="' . DOL_URL_ROOT . '/user/fiche.php?id=' . $user -> id . '"' ;
print $menutop -> atarget ? ( ' target="' . $menutop -> atarget . '"' ) : '' ;
print '>' . $user -> login . '</a>' ;
2009-08-19 18:51:55 +02:00
// Link info
2008-09-30 02:10:49 +02:00
$htmltext = '' ; $text = '' ;
if ( $_SESSION [ " dol_authmode " ] != 'forceuser'
&& $_SESSION [ " dol_authmode " ] != 'http' )
{
$htmltext = $langs -> trans ( " Logout " ) . '<br>' ;
$htmltext .= " <br> " ;
$text .= '<a href="' . DOL_URL_ROOT . '/user/logout.php"' ;
$text .= $menutop -> atarget ? ( ' target="' . $menutop -> atarget . '"' ) : '' ;
$text .= '>' ;
2009-06-15 16:26:34 +02:00
$text .= '<img class="login" border="0" width="14" height="14" src="' . DOL_URL_ROOT . '/theme/' . $conf -> theme . '/img/logout.png"' ;
2009-08-19 22:57:15 +02:00
$text .= ' alt="' . dol_escape_htmltag ( $langs -> trans ( " Logout " )) . '" title=""' ;
2008-09-30 02:10:49 +02:00
$text .= '>' ;
$text .= '</a>' ;
}
else
{
2009-06-15 16:26:34 +02:00
$text .= '<img class="login" border="0" width="14" height="14" src="' . DOL_URL_ROOT . '/theme/' . $conf -> theme . '/img/logout.png"' ;
2009-08-19 22:57:15 +02:00
$text .= ' alt="' . dol_escape_htmltag ( $langs -> trans ( " Logout " )) . '" title=""' ;
2008-09-30 02:10:49 +02:00
$text .= '>' ;
}
$htmltext .= '<u>' . $langs -> trans ( " User " ) . '</u>' ;
2008-05-02 03:10:00 +02:00
$htmltext .= '<br><b>' . $langs -> trans ( " Name " ) . '</b>: ' . $user -> fullname ;
2008-09-30 02:10:49 +02:00
$htmltext .= '<br><b>' . $langs -> trans ( " Login " ) . '</b>: ' . $user -> login ;
$htmltext .= '<br><b>' . $langs -> trans ( " Administrator " ) . '</b>: ' . yn ( $user -> admin );
$htmltext .= '<br><b>' . $langs -> trans ( " Type " ) . '</b>: ' . ( $user -> societe_id ? $langs -> trans ( " External " ) : $langs -> trans ( " Internal " ));
$htmltext .= '<br>' ;
$htmltext .= '<br><u>' . $langs -> trans ( " Connection " ) . '</u>' ;
2009-05-08 03:23:33 +02:00
if ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) $htmltext .= '<br><b>' . $langs -> trans ( " ConnectedOnMultiCompany " ) . '</b>: ' . $conf -> entity . ' (user entity ' . $user -> entity . ')' ;
2009-02-20 23:53:15 +01:00
$htmltext .= '<br><b>' . $langs -> trans ( " ConnectedSince " ) . '</b>: ' . dol_print_date ( $user -> datelastlogin , " dayhour " );
$htmltext .= '<br><b>' . $langs -> trans ( " PreviousConnexion " ) . '</b>: ' . dol_print_date ( $user -> datepreviouslogin , " dayhour " );
2008-09-30 02:10:49 +02:00
$htmltext .= '<br><b>' . $langs -> trans ( " AuthenticationMode " ) . '</b>: ' . $_SESSION [ " dol_authmode " ];
2008-08-07 08:33:35 +02:00
$htmltext .= '<br><b>' . $langs -> trans ( " CurrentTheme " ) . '</b>: ' . $conf -> theme ;
$htmltext .= '<br><b>' . $langs -> trans ( " CurrentUserLanguage " ) . '</b>: ' . $langs -> getDefaultLang ();
2009-09-15 03:22:19 +02:00
$htmltext .= '<br><b>' . $langs -> trans ( " Browser " ) . '</b>: ' . $conf -> browser -> name . ' (' . $_SERVER [ 'HTTP_USER_AGENT' ] . ')' ;
if ( ! empty ( $conf -> browser -> phone )) $htmltext .= '<br><b>' . $langs -> trans ( " Phone " ) . '</b>: ' . $conf -> browser -> phone ;
2008-12-02 15:22:21 +01:00
if ( ! empty ( $_SESSION [ " disablemodules " ])) $htmltext .= '<br><b>' . $langs -> trans ( " DisabledModules " ) . '</b>: <br>' . join ( '<br>' , split ( ',' , $_SESSION [ " disablemodules " ]));
2009-01-21 14:06:34 +01:00
2008-09-30 02:10:49 +02:00
// print '<img class="login" border="0" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/logout.png"';
// print ' alt="'.$title.'" title="'.$title.'"';
// print '>';
2009-08-19 18:51:55 +02:00
$html = new Form ( $db );
print $html -> textwithtooltip ( '' , $htmltext , 2 , 1 , $text );
2009-08-19 22:57:15 +02:00
// Link to print main content area
if ( empty ( $conf -> global -> MAIN_PRINT_DISABLELINK ))
{
2009-08-23 02:15:30 +02:00
$text = '<a href="' . $_SERVER [ " PHP_SELF " ] . '?' . $_SERVER [ " QUERY_STRING " ] . '&optioncss=print" target="_blank">' ;
2009-08-19 22:57:15 +02:00
$text .= '<img class="printer" border="0" width="14" height="14" src="' . DOL_URL_ROOT . '/theme/' . $conf -> theme . '/img/printer.png"' ;
$text .= ' title="' . dol_escape_htmltag ( $langs -> trans ( " PrintContentArea " )) . '" alt="' . dol_escape_htmltag ( $langs -> trans ( " PrintContentArea " )) . '">' ;
$text .= '</a>' ;
print $text ;
}
2005-08-20 18:43:30 +02:00
2008-09-30 02:10:49 +02:00
print " \n </div> \n <!-- End top horizontal menu --> \n " ;
2003-01-13 22:33:41 +01:00
}
2004-08-21 14:18:03 +02:00
2005-01-01 20:48:22 +01:00
/**
2009-05-10 07:44:35 +02:00
* \brief Show left menu bar
2009-03-09 11:51:42 +01:00
* \param menu_array Tableau des entrees de menu
* \param helppagename Name of wiki page for help ( '' by default ) .
2009-03-09 12:28:12 +01:00
* Syntax is : For a wiki page : EN : EnglishPage | FR : FrenchPage | ES : SpanishPage
* For other external page : http :// server / url
2009-03-09 11:51:42 +01:00
* \param moresearchform Formulaire de recherche permanant supplementaire
2003-01-13 22:33:41 +01:00
*/
2009-02-24 03:41:21 +01:00
function left_menu ( $menu_array , $helppagename = '' , $moresearchform = '' )
2003-01-13 22:33:41 +01:00
{
2008-09-30 02:10:49 +02:00
global $user , $conf , $langs , $db ;
2002-05-09 16:57:48 +02:00
2009-02-24 03:41:21 +01:00
$searchform = '' ;
$bookmarks = '' ;
2008-09-30 02:10:49 +02:00
// print '<div class="vmenuplusfiche">'."\n";
2009-05-27 16:32:19 +02:00
print '<table width="100%" class="notopnoleftnoright" summary="leftmenutable"><tr><td class="vmenu" valign="top">' ;
2004-08-21 16:21:32 +02:00
2008-09-30 02:10:49 +02:00
print " \n " ;
2002-05-09 16:57:48 +02:00
2008-09-30 02:10:49 +02:00
2009-02-24 03:41:21 +01:00
// Define $searchform
2008-12-10 16:17:04 +01:00
if ( $conf -> societe -> enabled && $conf -> global -> MAIN_SEARCHFORM_SOCIETE && $user -> rights -> societe -> lire )
2008-09-30 02:10:49 +02:00
{
2008-12-10 16:17:04 +01:00
$langs -> load ( " companies " );
2009-02-24 03:41:21 +01:00
$searchform .= printSearchForm ( DOL_URL_ROOT . '/societe.php' , DOL_URL_ROOT . '/societe.php' ,
2009-06-04 01:05:52 +02:00
img_object ( '' , 'company' ) . ' ' . $langs -> trans ( " Companies " ), 'soc' , 'socname' );
2008-12-10 16:17:04 +01:00
}
2008-09-30 02:10:49 +02:00
2008-12-10 16:17:04 +01:00
if ( $conf -> societe -> enabled && $conf -> global -> MAIN_SEARCHFORM_CONTACT && $user -> rights -> societe -> lire )
{
$langs -> load ( " companies " );
2009-02-24 03:41:21 +01:00
$searchform .= printSearchForm ( DOL_URL_ROOT . '/contact/index.php' , DOL_URL_ROOT . '/contact/index.php' ,
2009-06-04 01:05:52 +02:00
img_object ( '' , 'contact' ) . ' ' . $langs -> trans ( " Contacts " ), 'contact' , 'contactname' );
2008-12-10 16:17:04 +01:00
}
2008-09-30 02:10:49 +02:00
2009-06-08 20:14:37 +02:00
if ((( $conf -> produit -> enabled && $user -> rights -> produit -> lire ) || ( $conf -> service -> enabled && $user -> rights -> service -> lire ))
2009-08-13 14:32:22 +02:00
&& $conf -> global -> MAIN_SEARCHFORM_PRODUITSERVICE )
2008-12-10 16:17:04 +01:00
{
$langs -> load ( " products " );
2009-02-24 03:41:21 +01:00
$searchform .= printSearchForm ( DOL_URL_ROOT . '/product/liste.php' , DOL_URL_ROOT . '/product/index.php' ,
2009-06-04 01:05:52 +02:00
img_object ( '' , 'product' ) . ' ' . $langs -> trans ( " Products " ) . " / " . $langs -> trans ( " Services " ), 'products' , 'sall' );
2008-12-10 16:17:04 +01:00
}
2008-09-30 02:10:49 +02:00
2008-12-10 16:17:04 +01:00
if ( $conf -> adherent -> enabled && $conf -> global -> MAIN_SEARCHFORM_ADHERENT && $user -> rights -> adherent -> lire )
{
$langs -> load ( " members " );
2009-02-24 03:41:21 +01:00
$searchform .= printSearchForm ( DOL_URL_ROOT . '/adherents/liste.php' , DOL_URL_ROOT . '/adherents/liste.php' ,
2009-06-04 01:05:52 +02:00
img_object ( '' , 'user' ) . ' ' . $langs -> trans ( " Members " ), 'member' , 'sall' );
2008-12-10 16:17:04 +01:00
}
2009-01-21 14:06:34 +01:00
2009-02-24 03:41:21 +01:00
// Define $bookmarks
if ( $conf -> bookmark -> enabled && $user -> rights -> bookmark -> lire )
{
include_once ( DOL_DOCUMENT_ROOT . '/bookmarks/bookmarks.lib.php' );
$langs -> load ( " bookmarks " );
$bookmarks = printBookmarksList ( $db , $langs );
}
// Colonne de gauche
print '<!-- Begin left vertical menu -->' . " \n " ;
print '<div class="vmenu">' . " \n " ;
// Autres entrees du menu par le gestionnaire
if ( ! file_exists ( DOL_DOCUMENT_ROOT . " /includes/menus/barre_left/ " . $conf -> left_menu ))
{
$conf -> left_menu = 'eldy_backoffice.php' ;
}
require_once ( DOL_DOCUMENT_ROOT . " /includes/menus/barre_left/ " . $conf -> left_menu );
$menuleft = new MenuLeft ( $db , $menu_array );
$menuleft -> showmenu ();
if ( $searchform )
2008-12-10 16:17:04 +01:00
{
print " \n " ;
print " <!-- Begin SearchForm --> \n " ;
print '<div class="blockvmenupair">' . " \n " ;
2009-02-24 03:41:21 +01:00
print $searchform ;
2008-12-10 16:17:04 +01:00
print '</div>' . " \n " ;
print " <!-- End SearchForm --> \n " ;
2008-09-30 02:10:49 +02:00
}
2009-01-21 14:06:34 +01:00
2009-02-24 03:41:21 +01:00
if ( $moresearchform )
2008-09-30 02:10:49 +02:00
{
2009-02-24 03:41:21 +01:00
print $moresearchform ;
2008-09-30 02:10:49 +02:00
}
2009-01-30 23:18:07 +01:00
2009-02-24 03:41:21 +01:00
if ( $bookmarks )
2009-01-23 01:47:23 +01:00
{
print " \n " ;
print " <!-- Begin Bookmarks --> \n " ;
print '<div class="blockvmenupair">' . " \n " ;
2009-02-24 03:41:21 +01:00
print $bookmarks ;
2009-01-23 01:47:23 +01:00
print '</div>' . " \n " ;
print " <!-- End Bookmarks --> \n " ;
}
2008-09-30 02:10:49 +02:00
2009-03-09 11:51:42 +01:00
// Link to Dolibarr wiki pages
2009-08-09 21:25:17 +02:00
if ( $helppagename && empty ( $conf -> global -> MAIN_HELP_DISABLELINK ))
2008-09-30 02:10:49 +02:00
{
2007-12-02 21:55:23 +01:00
$langs -> load ( " help " );
2008-09-30 02:10:49 +02:00
$helpbaseurl = '' ;
2009-02-24 22:54:18 +01:00
if ( eregi ( '^http' , $helppagename ))
{
// If complete URL
$helpbaseurl = '%s' ;
$helppage = $helppagename ;
2009-05-18 13:40:33 +02:00
$mode = 'local' ;
2009-02-24 22:54:18 +01:00
}
else
{
2009-05-18 13:40:33 +02:00
// If WIKI URL
2009-03-09 12:28:12 +01:00
$helppage = '' ;
2009-03-09 11:51:42 +01:00
if ( eregi ( '^es' , $langs -> defaultlang ))
{
$helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s' ;
2009-03-09 12:28:12 +01:00
if ( eregi ( 'ES:([^|]+)' , $helppagename , $reg )) $helppage = $reg [ 1 ];
2009-03-09 11:51:42 +01:00
}
2009-03-09 12:28:12 +01:00
if ( eregi ( '^fr' , $langs -> defaultlang ))
2009-03-09 11:51:42 +01:00
{
$helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s' ;
2009-03-09 12:28:12 +01:00
if ( eregi ( 'FR:([^|]+)' , $helppagename , $reg )) $helppage = $reg [ 1 ];
2009-03-09 11:51:42 +01:00
}
2009-03-09 12:28:12 +01:00
if ( empty ( $helppage )) // If help page not already found
2009-02-24 22:54:18 +01:00
{
$helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s' ;
2009-03-09 12:28:12 +01:00
if ( eregi ( 'EN:([^|]+)' , $helppagename , $reg )) $helppage = $reg [ 1 ];
2009-02-24 22:54:18 +01:00
}
2009-05-18 13:40:33 +02:00
$mode = 'wiki' ;
2009-02-24 22:54:18 +01:00
}
2008-09-30 02:10:49 +02:00
2009-05-10 07:44:35 +02:00
// Link to help pages
2009-03-09 11:51:42 +01:00
if ( $helpbaseurl && $helppage )
2007-12-02 21:55:23 +01:00
{
print '<div class="help">' ;
2009-08-09 02:35:17 +02:00
print '<a class="help" target="_blank" title="' . $langs -> trans ( $mode == 'wiki' ? 'GoToWikiHelpPage' : 'GoToHelpPage' );
if ( $mode == 'wiki' ) print ' - ' . $langs -> trans ( " PageWiki " ) . ' "' . strtr ( $helppage , '_' , ' ' ) . '"' ;
2009-05-18 13:40:33 +02:00
print '" href="' ;
2007-12-02 21:55:23 +01:00
print sprintf ( $helpbaseurl , $helppage );
2009-03-09 12:28:12 +01:00
print '">' ;
2009-05-10 07:44:35 +02:00
print img_picto ( '' , DOL_URL_ROOT . '/theme/common/helpdoc.png' , '' , 1 ) . ' ' ;
2009-05-18 13:40:33 +02:00
print $langs -> trans ( $mode == 'wiki' ? 'OnlineHelp' : 'Help' );
2009-08-12 14:59:14 +02:00
//if ($mode == 'wiki') print ' ('.dol_trunc(strtr($helppage,'_',' '),8).')';
2009-05-18 13:40:33 +02:00
print '</a>' ;
2007-12-02 21:55:23 +01:00
print '</div>' ;
}
2008-09-30 02:10:49 +02:00
}
2009-01-21 14:06:34 +01:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_BUGTRACK_LINK ))
2008-09-30 02:10:49 +02:00
{
2009-05-10 07:44:35 +02:00
// Link to bugtrack
2008-09-30 02:10:49 +02:00
$bugbaseurl = 'http://savannah.nongnu.org/bugs/?' ;
$bugbaseurl .= 'func=additem&group=dolibarr&privacy=1&' ;
$bugbaseurl .= " &details= " ;
$bugbaseurl .= urlencode ( " \n \n \n \n \n ------------- \n " );
$bugbaseurl .= urlencode ( $langs -> trans ( " Version " ) . " : " . DOL_VERSION . " \n " );
$bugbaseurl .= urlencode ( $langs -> trans ( " Server " ) . " : " . $_SERVER [ " SERVER_SOFTWARE " ] . " \n " );
$bugbaseurl .= urlencode ( $langs -> trans ( " Url " ) . " : " . $_SERVER [ " REQUEST_URI " ] . " \n " );
print '<div class="help"><a class="help" target="_blank" href="' . $bugbaseurl . '">' . $langs -> trans ( " FindBug " ) . '</a></div>' ;
}
print " \n " ;
print " </div> \n " ;
2008-12-13 13:33:00 +01:00
print " <!-- End left vertical menu --> \n " ;
2008-09-30 02:10:49 +02:00
print " \n " ;
2008-12-13 13:33:00 +01:00
print '<!-- End of left column, begin right area -->' . " \n " ;
2008-09-30 02:10:49 +02:00
// print '</div>'."\n";
// print '<div class="vmenuplusfiche">'."\n";
2008-06-19 01:00:49 +02:00
print '</td><td valign="top">' . " \n " ;
2008-06-19 00:56:02 +02:00
2008-09-30 02:10:49 +02:00
2008-06-19 00:56:02 +02:00
print " \n " ;
2008-12-13 13:33:00 +01:00
print '<div class="fiche"> <!-- begin main area -->' . " \n " ;
2002-05-04 01:01:45 +02:00
2009-08-30 03:39:40 +02:00
if ( ! empty ( $conf -> global -> MAIN_ONLY_LOGIN_ALLOWED )) print info_admin ( $langs -> trans ( " WarningYouAreInMaintenanceMode " , $conf -> global -> MAIN_ONLY_LOGIN_ALLOWED ));
2002-05-04 01:01:45 +02:00
}
2004-08-13 23:45:23 +02:00
2005-01-01 20:48:22 +01:00
/**
2009-08-09 02:35:17 +02:00
* \brief Show a search area
2005-10-31 05:57:20 +01:00
* \param urlaction Url du post
* \param urlobject Url du lien sur titre de la zone de recherche
* \param title Titre de la zone de recherche
* \param htmlmodesearch 'search'
* \param htmlinputname Nom du champ input du formulaire
2004-08-13 23:45:23 +02:00
*/
function printSearchForm ( $urlaction , $urlobject , $title , $htmlmodesearch = 'search' , $htmlinputname )
{
2008-09-30 02:10:49 +02:00
global $langs ;
2009-06-04 01:05:52 +02:00
$ret = '' ;
2008-12-10 16:17:04 +01:00
$ret .= '<div class="menu_titre">' ;
$ret .= '<a class="vsmenu" href="' . $urlobject . '">' ;
$ret .= $title . '</a><br>' ;
$ret .= '</div>' ;
2009-06-04 01:05:52 +02:00
$ret .= '<form action="' . $urlaction . '" method="post">' ;
2009-05-17 10:01:54 +02:00
$ret .= '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2008-12-10 16:17:04 +01:00
$ret .= '<input type="hidden" name="mode" value="search">' ;
$ret .= '<input type="hidden" name="mode-search" value="' . $htmlmodesearch . '">' ;
$ret .= '<input type="text" class="flat" name="' . $htmlinputname . '" size="10"> ' ;
$ret .= '<input type="submit" class="button" value="' . $langs -> trans ( " Go " ) . '">' ;
$ret .= " </form> \n " ;
return $ret ;
2004-08-13 23:45:23 +02:00
}
2005-01-01 20:48:22 +01:00
/**
2009-01-12 20:36:40 +01:00
* \brief Show HTML footer DIV + BODY + HTML
* \remarks Close 2 div
2009-01-12 23:18:09 +01:00
* \param foot A text to add in HTML generated page
2002-12-31 15:10:59 +01:00
*/
2009-03-02 19:25:51 +01:00
function llxFooter ( $foot = '' )
2002-12-12 17:42:08 +01:00
{
2008-09-30 02:10:49 +02:00
global $conf , $dolibarr_auto_user , $micro_start_time ;
2009-01-12 23:18:09 +01:00
print " \n \n " . '</div> <!-- end div class="fiche" -->' . " \n " ;
2008-06-19 00:56:02 +02:00
2008-09-30 02:10:49 +02:00
// print "\n".'</div> <!-- end div class="vmenuplusfiche" -->'."\n";
2008-06-19 00:56:02 +02:00
print " \n " . '</td></tr></table> <!-- end right area -->' . " \n " ;
2008-09-30 02:10:49 +02:00
if ( ! empty ( $_SERVER [ 'DOL_TUNING' ]))
{
2007-05-20 22:07:18 +02:00
$micro_end_time = dol_microtime_float ( true );
2009-01-12 23:18:09 +01:00
print " \n " . '<script type="text/javascript">window.status="Build time: ' . ceil ( 1000 * ( $micro_end_time - $micro_start_time )) . ' ms' ;
2007-09-15 23:04:06 +02:00
if ( function_exists ( " memory_get_usage " ))
{
2009-02-21 02:04:35 +01:00
print ' - Mem: ' . memory_get_usage ();
}
if ( function_exists ( " xdebug_memory_usage " ))
{
print ' - XDebug time: ' . ceil ( 1000 * xdebug_time_index ()) . ' ms' ;
print ' - XDebug mem: ' . xdebug_memory_usage ();
print ' - XDebug mem peak: ' . xdebug_peak_memory_usage ();
2007-09-16 00:42:19 +02:00
}
if ( function_exists ( " zend_loader_file_encoded " ))
{
print ' - Zend encoded file: ' . ( zend_loader_file_encoded () ? 'yes' : 'no' );
}
2009-01-12 20:36:40 +01:00
print '"</script>' . " \n " ;
2009-02-21 02:04:35 +01:00
2009-05-07 01:30:49 +02:00
// Add Xdebug coverage of code
if ( defined ( 'XDEBUGCOVERAGE' )) { var_dump ( xdebug_get_code_coverage ()); }
2008-09-30 02:10:49 +02:00
}
if ( $conf -> use_javascript_ajax )
{
2008-12-15 02:04:32 +01:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/lib/lib_foot.js"></script>' . " \n " ;
2008-09-30 02:10:49 +02:00
}
2009-01-12 20:36:40 +01:00
// If there is some logs in buffer to show
2009-05-07 01:30:49 +02:00
if ( sizeof ( $conf -> logbuffer ))
{
2009-01-12 20:36:40 +01:00
print " \n " ;
2009-01-21 14:06:34 +01:00
print " <!-- Start of log output \n " ;
2009-05-07 01:30:49 +02:00
//print '<div class="hidden">'."\n";
foreach ( $conf -> logbuffer as $logline )
{
print $logline . " <br> \n " ;
}
//print '</div>'."\n";
2009-01-21 14:06:34 +01:00
print " End of log output --> \n " ;
2009-05-07 01:30:49 +02:00
}
2009-01-21 14:06:34 +01:00
2009-01-12 20:36:40 +01:00
print " \n " ;
2009-05-07 01:30:49 +02:00
if ( $foot ) print '<!-- ' . $foot . ' -->' . " \n " ;
2009-02-20 23:53:15 +01:00
2009-01-12 23:18:09 +01:00
print " </body> \n " ;
2008-09-30 02:10:49 +02:00
print " </html> \n " ;
2002-05-09 16:57:48 +02:00
}
2007-01-03 01:07:57 +01:00
2006-04-23 02:01:59 +02:00
?>